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 *) {
#define L_DECLARE_PUBLIC(CLASS) \
inline CLASS *getPublic () { \
L_ASSERT(mPublic); \
return getPublicHelper<CLASS>(mPublic, this); \
} \
inline const CLASS *getPublic () const { \
L_ASSERT(mPublic); \
return getPublicHelper<const CLASS>(mPublic, this); \
} \
friend class CLASS;
......
......@@ -72,9 +72,11 @@ Content &Content::operator= (Content &&src) {
return *this;
}
bool Content::operator==(const Content& content) const {
bool Content::operator== (const Content &content) const {
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 {
......
......@@ -39,7 +39,7 @@ public:
Content &operator= (const Content &src);
Content &operator= (Content &&src);
bool operator==(const Content& content) const;
bool operator== (const Content &content) const;
const ContentType &getContentType () const;
void setContentType (const ContentType &contentType);
......
......@@ -17,6 +17,10 @@
* 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 "db/provider/db-session-provider.h"
#include "logger/logger.h"
......@@ -86,17 +90,27 @@ string AbstractDb::primaryKeyAutoIncrementStr (const string &type) const {
return "";
}
string AbstractDb::insertOrIgnoreStr () const {
long AbstractDb::getLastInsertId () const {
L_D();
switch (d->backend) {
case Mysql:
return "INSERT IGNORE INTO ";
string sql;
switch(d->backend) {
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
......@@ -52,7 +52,8 @@ protected:
virtual void init ();
std::string primaryKeyAutoIncrementStr (const std::string &type = "INT") const;
std::string insertOrIgnoreStr () const;
long getLastInsertId () const;
private:
L_DECLARE_PRIVATE(AbstractDb);
......
This diff is collapsed.
......@@ -36,7 +36,7 @@ public:
virtual ~ObjectPrivate () = default;
protected:
Object *mPublic;
Object *mPublic = nullptr;
private:
std::unordered_map<std::string, Variant> properties;
......
......@@ -30,12 +30,14 @@ using namespace std;
LINPHONE_BEGIN_NAMESPACE
Object::Object (ObjectPrivate &p) : mPrivate(&p) {
mPrivate->mPublic = this;
}
Object::~Object () {
delete mPrivate;
}
Object::Object (ObjectPrivate &p) : mPrivate(&p) {}
shared_ptr<Object> Object::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