summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften')
-rw-r--r--Swiften/History/HistoryMessage.h11
-rw-r--r--Swiften/History/SQLiteHistoryManager.cpp7
2 files changed, 13 insertions, 5 deletions
diff --git a/Swiften/History/HistoryMessage.h b/Swiften/History/HistoryMessage.h
index d35474f..574cad4 100644
--- a/Swiften/History/HistoryMessage.h
+++ b/Swiften/History/HistoryMessage.h
@@ -23,12 +23,14 @@ namespace Swift {
const JID& fromJID,
const JID& toJID,
Type type,
- const boost::posix_time::ptime& time) :
+ const boost::posix_time::ptime& time,
+ int utcOffset = 0) :
message_(message),
fromJID_(fromJID),
toJID_(toJID),
type_(type),
- time_(time) {
+ time_(time),
+ utcOffset_(utcOffset) {
}
const std::string& getMessage() const {
@@ -51,6 +53,10 @@ namespace Swift {
return time_;
}
+ int getOffset() const {
+ return utcOffset_;
+ }
+
bool operator==(const HistoryMessage& o) const {
return message_ == o.message_ && fromJID_ == o.fromJID_ && toJID_ == o.toJID_ && type_ == o.type_ && time_ == o.time_;
}
@@ -61,5 +67,6 @@ namespace Swift {
JID toJID_;
Type type_;
boost::posix_time::ptime time_;
+ int utcOffset_;
};
}
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) {