#BR127: user can now set the style of the application in the config menu (behaviour...
[quassel.git] / src / core / sqlitestorage.cpp
index 3176ec4..2121f79 100644 (file)
@@ -24,6 +24,8 @@
 
 #include "network.h"
 
+#include "util.h"
+
 SqliteStorage::SqliteStorage(QObject *parent)
   : AbstractSqlStorage(parent)
 {
@@ -619,13 +621,17 @@ QList<Message> SqliteStorage::requestMsgs(UserId user, BufferId bufferId, int la
   if(!bufferInfo.isValid())
     return messagelist;
 
-  // we have to determine the real offset first
-  QSqlQuery *offsetQuery = cachedQuery("select_messagesOffset");
-  offsetQuery->bindValue(":bufferid", bufferId.toInt());
-  offsetQuery->bindValue(":messageid", offset);
-  offsetQuery->exec();
-  offsetQuery->first();
-  offset = offsetQuery->value(0).toInt();
+  if(offset == -1) {
+    offset = 0;
+  } else {
+    // we have to determine the real offset first
+    QSqlQuery *offsetQuery = cachedQuery("select_messagesOffset");
+    offsetQuery->bindValue(":bufferid", bufferId.toInt());
+    offsetQuery->bindValue(":messageid", offset);
+    offsetQuery->exec();
+    offsetQuery->first();
+    offset = offsetQuery->value(0).toInt();
+  }
 
   // now let's select the messages
   QSqlQuery *msgQuery = cachedQuery("select_messages");
@@ -719,18 +725,7 @@ QList<Message> SqliteStorage::requestMsgRange(UserId user, BufferId bufferId, in
 }
 
 QString SqliteStorage::backlogFile() {
-  // kinda ugly, but I currently see no other way to do that
-#ifdef Q_OS_WIN32
-  QString quasselDir = QDir::homePath() + qgetenv("APPDATA") + "\\quassel\\";
-#else
-  QString quasselDir = QDir::homePath() + "/.quassel/";
-#endif
-
-  QDir qDir(quasselDir);
-  if(!qDir.exists(quasselDir))
-    qDir.mkpath(quasselDir);
-  
-  return quasselDir + "quassel-storage.sqlite";  
+  return quasselDir().absolutePath() + "/quassel-storage.sqlite";  
 }