Commit d60b5fab authored by Ronan's avatar Ronan

feat(EventsDb): import correctly legacy messages

parent 32e22abe
...@@ -117,9 +117,11 @@ constexpr T *getPublicHelper (Object *object, const ObjectPrivate *) { ...@@ -117,9 +117,11 @@ constexpr T *getPublicHelper (Object *object, const ObjectPrivate *) {
#define L_DECLARE_PUBLIC(CLASS) \ #define L_DECLARE_PUBLIC(CLASS) \
inline CLASS *getPublic () { \ inline CLASS *getPublic () { \
L_ASSERT(mPublic); \
return getPublicHelper<CLASS>(mPublic, this); \ return getPublicHelper<CLASS>(mPublic, this); \
} \ } \
inline const CLASS *getPublic () const { \ inline const CLASS *getPublic () const { \
L_ASSERT(mPublic); \
return getPublicHelper<const CLASS>(mPublic, this); \ return getPublicHelper<const CLASS>(mPublic, this); \
} \ } \
friend class CLASS; friend class CLASS;
......
...@@ -72,9 +72,11 @@ Content &Content::operator= (Content &&src) { ...@@ -72,9 +72,11 @@ Content &Content::operator= (Content &&src) {
return *this; return *this;
} }
bool Content::operator==(const Content& content) const { bool Content::operator== (const Content &content) const {
L_D(); L_D();
return d->contentType == content.getContentType() && d->body == content.getBody() && d->contentDisposition == content.getContentDisposition(); return d->contentType == content.getContentType() &&
d->body == content.getBody() &&
d->contentDisposition == content.getContentDisposition();
} }
const ContentType &Content::getContentType () const { const ContentType &Content::getContentType () const {
......
...@@ -39,7 +39,7 @@ public: ...@@ -39,7 +39,7 @@ public:
Content &operator= (const Content &src); Content &operator= (const Content &src);
Content &operator= (Content &&src); Content &operator= (Content &&src);
bool operator==(const Content& content) const; bool operator== (const Content &content) const;
const ContentType &getContentType () const; const ContentType &getContentType () const;
void setContentType (const ContentType &contentType); void setContentType (const ContentType &contentType);
......
...@@ -17,6 +17,10 @@ ...@@ -17,6 +17,10 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/ */
#ifdef SOCI_ENABLED
#include <soci/soci.h>
#endif // ifdef SOCI_ENABLED
#include "abstract-db-p.h" #include "abstract-db-p.h"
#include "db/provider/db-session-provider.h" #include "db/provider/db-session-provider.h"
#include "logger/logger.h" #include "logger/logger.h"
...@@ -86,17 +90,27 @@ string AbstractDb::primaryKeyAutoIncrementStr (const string &type) const { ...@@ -86,17 +90,27 @@ string AbstractDb::primaryKeyAutoIncrementStr (const string &type) const {
return ""; return "";
} }
string AbstractDb::insertOrIgnoreStr () const { long AbstractDb::getLastInsertId () const {
L_D(); L_D();
switch (d->backend) { string sql;
case Mysql: switch(d->backend) {
return "INSERT IGNORE INTO ";
case Sqlite3: case Sqlite3:
return "INSERT OR IGNORE INTO "; sql = "SELECT last_insert_rowid()";
break;
default:
lWarning() << "Unsupported backend.";
return -1;
} }
return ""; long result = 0;
#ifdef SOCI_ENABLED
soci::session *session = d->dbSession.getBackendSession<soci::session>();
*session << sql, soci::into(result);
#endif // ifdef SOCI_ENABLED
return result;
} }
LINPHONE_END_NAMESPACE LINPHONE_END_NAMESPACE
...@@ -52,7 +52,8 @@ protected: ...@@ -52,7 +52,8 @@ protected:
virtual void init (); virtual void init ();
std::string primaryKeyAutoIncrementStr (const std::string &type = "INT") const; std::string primaryKeyAutoIncrementStr (const std::string &type = "INT") const;
std::string insertOrIgnoreStr () const;
long getLastInsertId () const;
private: private:
L_DECLARE_PRIVATE(AbstractDb); L_DECLARE_PRIVATE(AbstractDb);
......
This diff is collapsed.
...@@ -36,7 +36,7 @@ public: ...@@ -36,7 +36,7 @@ public:
virtual ~ObjectPrivate () = default; virtual ~ObjectPrivate () = default;
protected: protected:
Object *mPublic; Object *mPublic = nullptr;
private: private:
std::unordered_map<std::string, Variant> properties; std::unordered_map<std::string, Variant> properties;
......
...@@ -30,12 +30,14 @@ using namespace std; ...@@ -30,12 +30,14 @@ using namespace std;
LINPHONE_BEGIN_NAMESPACE LINPHONE_BEGIN_NAMESPACE
Object::Object (ObjectPrivate &p) : mPrivate(&p) {
mPrivate->mPublic = this;
}
Object::~Object () { Object::~Object () {
delete mPrivate; delete mPrivate;
} }
Object::Object (ObjectPrivate &p) : mPrivate(&p) {}
shared_ptr<Object> Object::getSharedFromThis () { shared_ptr<Object> Object::getSharedFromThis () {
return const_pointer_cast<Object>(static_cast<const Object *>(this)->getSharedFromThis()); return const_pointer_cast<Object>(static_cast<const Object *>(this)->getSharedFromThis());
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment