Commit eab04534 authored by Ronan's avatar Ronan

feat(EventsDb): import messages from old db

parent cc739ef5
......@@ -19,6 +19,7 @@
#ifndef _UTILS_H_
#define _UTILS_H_
#include <ctime>
#include <memory>
#include <string>
#include <vector>
......@@ -92,6 +93,8 @@ namespace Utils {
static const T object;
return object;
}
LINPHONE_PUBLIC std::tm getLongAsTm (long time);
}
LINPHONE_END_NAMESPACE
......
......@@ -60,6 +60,10 @@ AbstractDb::Backend AbstractDb::getBackend () const {
return d->backend;
}
bool AbstractDb::import (Backend, const string &) {
return false;
}
// -----------------------------------------------------------------------------
void AbstractDb::init () {
......@@ -81,4 +85,17 @@ string AbstractDb::primaryKeyAutoIncrementStr (const string &type) const {
return "";
}
string AbstractDb::insertOrIgnoreStr () const {
L_D();
switch (d->backend) {
case Mysql:
return "INSERT IGNORE INTO ";
case Sqlite3:
return "INSERT OR IGNORE INTO ";
}
return "";
}
LINPHONE_END_NAMESPACE
......@@ -43,12 +43,15 @@ public:
Backend getBackend () const;
virtual bool import (Backend backend, const std::string &parameters);
protected:
explicit AbstractDb (AbstractDbPrivate &p);
virtual void init ();
std::string primaryKeyAutoIncrementStr (const std::string &type = "INT") const;
std::string insertOrIgnoreStr () const;
private:
L_DECLARE_PRIVATE(AbstractDb);
......
This diff is collapsed.
......@@ -65,6 +65,8 @@ public:
) const;
void cleanHistory (const std::string &remoteAddress = "");
bool import (Backend backend, const std::string &parameters) override;
protected:
void init () override;
......
......@@ -170,4 +170,11 @@ char *Utils::utf8ToChar (uint32_t ic) {
return result;
}
// -----------------------------------------------------------------------------
tm Utils::getLongAsTm (long time) {
tm result;
return *gmtime_r(&static_cast<time_t &>(time), &result);
}
LINPHONE_END_NAMESPACE
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