diff options
author | Catalin Badea <catalin.badea392@gmail.com> | 2012-08-01 14:04:11 (GMT) |
---|---|---|
committer | Cătălin Badea <catalin.badea392@gmail.com> | 2012-08-11 15:59:13 (GMT) |
commit | f3401e17bf241734414a3ff84e94ee64b882bcbc (patch) | |
tree | 1a90eaefb34dabdbaaff79f017e7084293502950 /Swiften/History/SQLiteHistoryManager.cpp | |
parent | f4a053500a27468c67c17531cb9f3b8d35880678 (diff) | |
download | swift-contrib-f3401e17bf241734414a3ff84e94ee64b882bcbc.zip swift-contrib-f3401e17bf241734414a3ff84e94ee64b882bcbc.tar.bz2 |
log utc offset.
Diffstat (limited to 'Swiften/History/SQLiteHistoryManager.cpp')
-rw-r--r-- | Swiften/History/SQLiteHistoryManager.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/Swiften/History/SQLiteHistoryManager.cpp b/Swiften/History/SQLiteHistoryManager.cpp index 57fce2f..3b90219 100644 --- a/Swiften/History/SQLiteHistoryManager.cpp +++ b/Swiften/History/SQLiteHistoryManager.cpp @@ -31,7 +31,7 @@ SQLiteHistoryManager::SQLiteHistoryManager(const std::string& file) : db_(0) { } char* errorMessage; - int result = sqlite3_exec(db_, "CREATE TABLE IF NOT EXISTS messages('message' STRING, 'fromBare' INTEGER, 'fromResource' STRING, 'toBare' INTEGER, 'toResource' STRING, 'type' INTEGER, 'time' INTEGER)", 0, 0, &errorMessage); + int result = sqlite3_exec(db_, "CREATE TABLE IF NOT EXISTS messages('message' STRING, 'fromBare' INTEGER, 'fromResource' STRING, 'toBare' INTEGER, 'toResource' STRING, 'type' INTEGER, 'time' INTEGER, 'offset' INTEGER)", 0, 0, &errorMessage); if (result != SQLITE_OK) { std::cerr << "SQL Error: " << errorMessage << std::endl; sqlite3_free(errorMessage); @@ -51,14 +51,15 @@ SQLiteHistoryManager::~SQLiteHistoryManager() { void SQLiteHistoryManager::addMessage(const HistoryMessage& message) { int secondsSinceEpoch = (message.getTime() - boost::posix_time::ptime(boost::gregorian::date(1970, 1, 1))).total_seconds(); - std::string statement = std::string("INSERT INTO messages('message', 'fromBare', 'fromResource', 'toBare', 'toResource', 'type', 'time') VALUES(") + + std::string statement = std::string("INSERT INTO messages('message', 'fromBare', 'fromResource', 'toBare', 'toResource', 'type', 'time', 'offset') VALUES(") + "'" + getEscapedString(message.getMessage()) + "', " + boost::lexical_cast<std::string>(getIDForJID(message.getFromJID().toBare())) + ", '" + getEscapedString(message.getFromJID().getResource()) + "', " + boost::lexical_cast<std::string>(getIDForJID(message.getToJID().toBare())) + ", '" + getEscapedString(message.getToJID().getResource()) + "', " + boost::lexical_cast<std::string>(message.getType()) + ", " + - boost::lexical_cast<std::string>(secondsSinceEpoch) + ")"; + boost::lexical_cast<std::string>(secondsSinceEpoch) + ", " + + boost::lexical_cast<std::string>(message.getOffset()) + ")"; char* errorMessage; int result = sqlite3_exec(db_, statement.c_str(), 0, 0, &errorMessage); if (result != SQLITE_OK) { |