OK, another update. This is just prior to redoing the MainWin completely.
authorManuel Nickschas <sputnick@quassel-irc.org>
Sun, 29 Oct 2006 21:17:38 +0000 (21:17 +0000)
committerManuel Nickschas <sputnick@quassel-irc.org>
Sun, 29 Oct 2006 21:17:38 +0000 (21:17 +0000)
I have already switched to a designer-generated .ui rather and thrown out the
hand-written stuff. Next couple of days will hopefully show the first few of Haui's
ideas functional.

In other news: backlog generation is implemented now. The GUI does not sync the backlog
yet, but coreside files are being generated and saved in $HOME/.quassel/backlog. I expect
the format not to change in the foreseeable future, so that at some point in the future,
you'll be able to scroll up your buffers and find everything you did starting from now ;-)

NOTE: Core/GUI mode has not been tested in a while. Though I don't think I have broken
      stuff already, I might be wrong there. Run cmake with -DBUILD="mono" to build
      the monolithic version, which should work quite fine.

18 files changed:
CMakeLists.txt
core/core.cpp
core/core.h
gui/CMakeLists.txt
gui/channelwidget.cpp
gui/mainwin.cpp
gui/mainwin.h
gui/mainwin.ui [new file with mode: 0644]
gui/networkwidget.ui [new file with mode: 0644]
gui/serverlist.cpp
gui/settingsdlg.ui [new file with mode: 0644]
main/global.cpp
main/global.h
main/main_core.cpp
main/main_gui.cpp
main/main_mono.cpp
main/message.cpp
network/server.cpp

index 49bea2d..589e657 100644 (file)
@@ -37,6 +37,7 @@ FOREACH(dir ${quassel_DIRS})
   SET(SDIRS ${SDIRS} "${CMAKE_CURRENT_SOURCE_DIR}/${dir}")
 ENDFOREACH(dir)
 INCLUDE_DIRECTORIES(${SDIRS})
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
 
 # We need Qt4 support.
 SET(QT_MIN_VERSION "4.2.0")
index 9ccbd21..f9f4f23 100644 (file)
@@ -40,6 +40,7 @@ Core::Core() {
   foreach(key, s.childKeys()) {
     global->updateData(key, s.value(key));
   }
+  initBackLog();
   global->updateData("CoreReady", true);
   // Now that we are in sync, we can connect signals to automatically store further updates.
   // I don't think we care if global data changed locally or if it was updated by a client. 
@@ -85,16 +86,89 @@ void Core::connectToIrc(QStringList networks) {
 // ALL messages coming pass through these functions before going to the GUI.
 // So this is the perfect place for storing the backlog and log stuff.
 void Core::recvMessageFromServer(QString buf, Message msg) {
-  Q_ASSERT(sender());
-  QString net = qobject_cast<Server*>(sender())->getNetwork();
-  emit displayMsg(net, buf, msg);
+  Server *s = qobject_cast<Server*>(sender());
+  Q_ASSERT(s);
+  logMessage(msg);
+  emit displayMsg(s->getNetwork(), buf, msg);
 }
 
 void Core::recvStatusMsgFromServer(QString msg) {
-  Q_ASSERT(sender());
-  QString net = qobject_cast<Server*>(sender())->getNetwork();
-  emit displayStatusMsg(net, msg);
+  Server *s = qobject_cast<Server*>(sender());
+  Q_ASSERT(s);
+  emit displayStatusMsg(s->getNetwork(), msg);
 }
 
+// file name scheme: quassel-backlog-2006-29-10.bin
+void Core::initBackLog() {
+  backLogDir = QDir(Global::quasselDir + "/backlog");
+  if(!backLogDir.exists()) {
+    qWarning(QString("Creating backlog directory \"%1\"...").arg(backLogDir.absolutePath()).toAscii());
+    if(!backLogDir.mkpath(backLogDir.absolutePath())) {
+      qWarning(QString("Could not create backlog directory! Disabling logging...").toAscii());
+      backLogEnabled = false;
+      return;
+    }
+  }
+  backLogDir.refresh();
+  //if(!backLogDir.isReadable()) {
+  //  qWarning(QString("Cannot read directory \"%1\". Disabling logging...").arg(backLogDir.absolutePath()).toAscii());
+  //  backLogEnabled = false;
+  //  return;
+  //}
+  QStringList logs = backLogDir.entryList(QStringList("quassel-backlog-*.bin"), QDir::Files|QDir::Readable, QDir::Name);
+  foreach(QString name, logs) {
+    QFile f(backLogDir.absolutePath() + "/" + name);
+    if(!f.open(QIODevice::ReadOnly)) {
+      qWarning(QString("Could not open \"%1\" for reading!").arg(f.fileName()).toAscii());
+      continue;
+    }
+    QDataStream in(&f);
+    in.setVersion(QDataStream::Qt_4_2);
+    QByteArray verstring; quint8 vernum; in >> verstring >> vernum;
+    if(verstring != BACKLOG_STRING) {
+      qWarning(QString("\"%1\" is not a Quassel backlog file!").arg(f.fileName()).toAscii());
+      f.close(); continue;
+    }
+    if(vernum != BACKLOG_FORMAT) {
+      qWarning(QString("\"%1\": Version mismatch!").arg(f.fileName()).toAscii());
+      f.close(); continue;
+    }
+    qDebug() << "Reading backlog from" << f.fileName();
+    currentLogFileDate = QDate::fromString(f.fileName(), QString("'%1/quassel-backlog-'yyyy-MM-dd'.bin'").arg(backLogDir.absolutePath()));
+    if(!currentLogFileDate.isValid()) {
+      qWarning(QString("\"%1\" has an invalid file name!").arg(f.fileName()).toAscii());
+    }
+    while(!in.atEnd()) {
+      Message m;
+      in >> m;
+      backLog.append(m);
+    }
+    f.close();
+  }
+  backLogEnabled = true;
+}
+
+/** Log a core message (emitted via a displayMsg() signal) to the backlog file.
+ * If a file for the current day does not exist, one will be created. Otherwise, messages will be appended.
+ * The file header is the string defined by BACKLOG_STRING, followed by a quint8 specifying the format
+ * version (BACKLOG_FORMAT). The rest is simply serialized Message objects.
+ */
+void Core::logMessage(Message msg) {
+  backLog.append(msg);
+  if(!currentLogFileDate.isValid() || currentLogFileDate < QDate::currentDate()) {
+    if(currentLogFile.isOpen()) currentLogFile.close();
+    currentLogFileDate = QDate::currentDate();
+  }
+  if(!currentLogFile.isOpen()) {
+    currentLogFile.setFileName(backLogDir.absolutePath() + "/" + currentLogFileDate.toString("'quassel-backlog-'yyyy-MM-dd'.bin'"));
+    if(!currentLogFile.open(QIODevice::WriteOnly|QIODevice::Append)) {
+      qWarning(QString("Could not open \"%1\" for writing: %2").arg(currentLogFile.fileName()).arg(currentLogFile.errorString()).toAscii());
+      return;
+    }
+    logStream.setDevice(&currentLogFile); logStream.setVersion(QDataStream::Qt_4_2);
+    if(!currentLogFile.size()) logStream << BACKLOG_STRING << (quint8)BACKLOG_FORMAT;
+  }
+  logStream << msg;
+}
 
 Core *core = 0;
index 6b7a0ae..f5532c3 100644 (file)
@@ -53,6 +53,15 @@ class Core : public QObject {
 
   private:
     QHash<QString, Server *> servers;
+    QList<Message> backLog;
+    bool backLogEnabled;
+    QDir backLogDir;
+    QFile currentLogFile;
+    QDataStream logStream;
+    QDate currentLogFileDate;
+
+    void initBackLog();
+    void logMessage(Message);
 
 };
 
index abe989b..997c656 100644 (file)
@@ -2,7 +2,7 @@ SET(gui_SRCS channelwidget.cpp channelwidgetinput.cpp mainwin.cpp serverlist.cpp
  identities.cpp coreconnectdlg.cpp guiproxy.cpp)
 SET(gui_HDRS )
 SET(gui_MOCS channelwidget.h channelwidgetinput.h mainwin.h serverlist.h identities.h coreconnectdlg.h guiproxy.h)
-SET(gui_UICS channelwidget.ui identitiesdlg.ui identitieseditdlg.ui networkeditdlg.ui
+SET(gui_UICS channelwidget.ui identitiesdlg.ui identitieseditdlg.ui networkeditdlg.ui mainwin.ui
              nickeditdlg.ui serverlistdlg.ui servereditdlg.ui coreconnectdlg.ui ircwidget.ui)
 
 QT4_WRAP_UI(_UIC ${gui_UICS})
index 84e81b1..8aeb592 100644 (file)
@@ -115,8 +115,8 @@ void ChannelWidget::recvMessage(Message msg) {
       break;
     case Message::Mode:
       c = serverCol;
-      if(nick.isEmpty()) s = tr("* User mode: %1").arg(msg.msg);
-      else s = tr("* Mode %1 by %2").arg(msg.msg).arg(nick);
+      if(nick.isEmpty()) s = tr("*** User mode: %1").arg(msg.msg);
+      else s = tr("*** Mode %1 by %2").arg(msg.msg).arg(nick);
       break;
     default:
       c = stdCol; n = QString("[%1]").arg(msg.sender); s = msg.msg;
@@ -129,8 +129,8 @@ void ChannelWidget::recvMessage(Message msg) {
   if(!n.isEmpty())
     html += QString("<td width=150><div align=right style=\"white-space:pre;margin-left:6px;color:%2;\">%1</div></td>")
         .arg(n).arg("royalblue");
-  html += QString("<td><div style=\"margin-left:6px;color:%2;\">%1</div></td>""</tr></table>").arg(s).arg(c);
-  ui.chatWidget->append(html);
+  html += QString("<td><div style=\"white-space:pre-wrap;margin-left:6px;color:%2;\">%1</div></td>""</tr></table>").arg(s).arg(c);
+  ui.chatWidget->append(html); // qDebug() << html;
   //ui.chatWidget->append(QString("<table border=1 cellspacing=0 cellpadding=0><tr><td>%1</td><td width=100 style=border-right-width:1px;><div style=margin-left:8px; margin-right:8px;>%2</div></td><td style=color:firebrick>&nbsp;%3</td></tr></table>")
       //.arg(msg.timeStamp.toLocalTime().toString("hh:mm:ss")).arg(nick).arg(s));
   ui.chatWidget->ensureCursorVisible();
index 3fefe4d..8a21a9d 100644 (file)
@@ -29,6 +29,7 @@
 #include "coreconnectdlg.h"
 
 MainWin::MainWin() : QMainWindow() {
+  ui.setupUi(this);
 
   setWindowTitle("Quassel IRC");
   setWindowIcon(QIcon(":/qirc-icon.png"));
@@ -60,6 +61,11 @@ MainWin::MainWin() : QMainWindow() {
   cw->setFocus();
 }
 
+void MainWin::setupMenus() {
+  connect(ui.actionNetworkList, SIGNAL(activated()), this, SLOT(showServerList()));
+  connect(ui.actionEditIdentities, SIGNAL(activated()), serverListDlg, SLOT(editIdentities()));
+}
+
 void MainWin::syncToCore() {
   if(global->getData("CoreReady").toBool()) return;
   // ok, apparently we are running as standalone GUI
@@ -81,40 +87,6 @@ void MainWin::syncToCore() {
   }
 }
 
-void MainWin::setupMenus() {
-  fileMenu = menuBar()->addMenu(tr("&File"));
-  serverListAct = fileMenu->addAction(QIcon(":/default/server.png"), tr("&Server List..."), this, SLOT(showServerList()), tr("F7"));
-  fileMenu->addSeparator();
-  quitAct = fileMenu->addAction(QIcon(":/default/exit.png"), tr("&Quit"), qApp, SLOT(quit()), tr("CTRL+Q"));
-
-  editMenu = menuBar()->addMenu(tr("&Edit"));
-  editMenu->setEnabled(0);
-
-  ircMenu = menuBar()->addMenu(tr("&IRC"));
-  ircMenu->setEnabled(0);
-
-  serverMenu = menuBar()->addMenu(tr("Ser&ver"));
-  serverMenu->setEnabled(0);
-
-  windowMenu = menuBar()->addMenu(tr("&Window"));
-  windowMenu->setEnabled(0);
-
-  settingsMenu = menuBar()->addMenu(tr("&Settings"));
-  identitiesAct = settingsMenu->addAction(QIcon(":/default/identity.png"), tr("&Identities..."), serverListDlg, SLOT(editIdentities()));
-  settingsMenu->addSeparator();
-  configAct = settingsMenu->addAction(QIcon(":/default/configure.png"), tr("&Configure Quassel..."));
-  configAct->setEnabled(0);
-
-  helpMenu = menuBar()->addMenu(tr("&Help"));
-  aboutAct = helpMenu->addAction(tr("&About"));
-  aboutAct->setEnabled(0);
-  aboutQtAct = helpMenu->addAction(tr("About &Qt"), qApp, SLOT(aboutQt()));
-
-  //toolBar = new QToolBar("Test", this);
-  //toolBar->addAction(identitiesAct);
-  //addToolBar(Qt::TopToolBarArea, toolBar);
-}
-
 void MainWin::showServerList() {
 //  if(!serverListDlg) {
 //    serverListDlg = new ServerListDlg(this);
index 9d7770f..a6d1e1e 100644 (file)
 #ifndef _MAINWIN_H_
 #define _MAINWIN_H_
 
-#include <QMainWindow>
-
-class QMenu;
-class QWorkspace;
+#include <QtGui>
+#include "gui/ui_mainwin.h"
 
 class ServerListDlg;
 class CoreConnectDlg;
@@ -42,15 +40,12 @@ class MainWin : public QMainWindow {
     void showServerList();
 
   private:
+    Ui::MainWin ui;
+
     void setupMenus();
     void syncToCore();
 
     QWorkspace *workspace;
-    QToolBar *toolBar;
-    QMenu *fileMenu, *editMenu, *ircMenu, *serverMenu, *windowMenu, *helpMenu, *settingsMenu;
-    QAction *quitAct, *serverListAct;
-    QAction *aboutAct, *aboutQtAct;
-    QAction *identitiesAct, *configAct;
 
     ServerListDlg *serverListDlg;
     CoreConnectDlg *coreConnectDlg;
diff --git a/gui/mainwin.ui b/gui/mainwin.ui
new file mode 100644 (file)
index 0000000..169d454
--- /dev/null
@@ -0,0 +1,141 @@
+<ui version="4.0" >
+ <class>MainWin</class>
+ <widget class="QMainWindow" name="MainWin" >
+  <property name="geometry" >
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>800</width>
+    <height>600</height>
+   </rect>
+  </property>
+  <property name="windowTitle" >
+   <string>MainWindow</string>
+  </property>
+  <widget class="QWidget" name="centralwidget" />
+  <widget class="QMenuBar" name="menubar" >
+   <property name="geometry" >
+    <rect>
+     <x>0</x>
+     <y>0</y>
+     <width>800</width>
+     <height>29</height>
+    </rect>
+   </property>
+   <widget class="QMenu" name="menuViews" >
+    <property name="title" >
+     <string>Views</string>
+    </property>
+   </widget>
+   <widget class="QMenu" name="menuHelp" >
+    <property name="title" >
+     <string>Help</string>
+    </property>
+   </widget>
+   <widget class="QMenu" name="menuConnection" >
+    <property name="title" >
+     <string>Connection</string>
+    </property>
+    <addaction name="actionNetworkList" />
+    <addaction name="actionQuickConnect" />
+    <addaction name="separator" />
+    <addaction name="actionDisconnect" />
+    <addaction name="actionReconnect" />
+    <addaction name="separator" />
+    <addaction name="actionJoinChannel" />
+    <addaction name="separator" />
+    <addaction name="actionSetAwayGlobally" />
+    <addaction name="separator" />
+    <addaction name="actionQuit" />
+   </widget>
+   <widget class="QMenu" name="menuSettings" >
+    <property name="title" >
+     <string>Settings</string>
+    </property>
+    <addaction name="actionEditIdentities" />
+   </widget>
+   <addaction name="menuConnection" />
+   <addaction name="menuSettings" />
+   <addaction name="menuViews" />
+   <addaction name="menuHelp" />
+  </widget>
+  <widget class="QStatusBar" name="statusbar" />
+  <action name="actionNetworkList" >
+   <property name="text" >
+    <string>&amp;Network List...</string>
+   </property>
+   <property name="shortcut" >
+    <string>F2</string>
+   </property>
+  </action>
+  <action name="actionQuickConnect" >
+   <property name="enabled" >
+    <bool>false</bool>
+   </property>
+   <property name="text" >
+    <string>Quick &amp;Connect...</string>
+   </property>
+  </action>
+  <action name="actionDisconnect" >
+   <property name="enabled" >
+    <bool>false</bool>
+   </property>
+   <property name="text" >
+    <string>Disconnect</string>
+   </property>
+  </action>
+  <action name="actionReconnect" >
+   <property name="enabled" >
+    <bool>false</bool>
+   </property>
+   <property name="text" >
+    <string>Reconnect</string>
+   </property>
+  </action>
+  <action name="actionJoinChannel" >
+   <property name="enabled" >
+    <bool>false</bool>
+   </property>
+   <property name="text" >
+    <string>Join Channel...</string>
+   </property>
+  </action>
+  <action name="actionSetAwayGlobally" >
+   <property name="enabled" >
+    <bool>false</bool>
+   </property>
+   <property name="text" >
+    <string>Set Away globally</string>
+   </property>
+  </action>
+  <action name="actionQuit" >
+   <property name="text" >
+    <string>Quit...</string>
+   </property>
+  </action>
+  <action name="actionEditIdentities" >
+   <property name="text" >
+    <string>Edit Identities...</string>
+   </property>
+  </action>
+ </widget>
+ <resources/>
+ <connections>
+  <connection>
+   <sender>actionQuit</sender>
+   <signal>activated()</signal>
+   <receiver>MainWin</receiver>
+   <slot>close()</slot>
+   <hints>
+    <hint type="sourcelabel" >
+     <x>-1</x>
+     <y>-1</y>
+    </hint>
+    <hint type="destinationlabel" >
+     <x>399</x>
+     <y>299</y>
+    </hint>
+   </hints>
+  </connection>
+ </connections>
+</ui>
diff --git a/gui/networkwidget.ui b/gui/networkwidget.ui
new file mode 100644 (file)
index 0000000..65f2028
--- /dev/null
@@ -0,0 +1,29 @@
+<ui version="4.0" >
+ <class>NetworkWidget</class>
+ <widget class="QWidget" name="NetworkWidget" >
+  <property name="geometry" >
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>236</width>
+    <height>358</height>
+   </rect>
+  </property>
+  <property name="windowTitle" >
+   <string>Form</string>
+  </property>
+  <layout class="QHBoxLayout" >
+   <property name="margin" >
+    <number>9</number>
+   </property>
+   <property name="spacing" >
+    <number>6</number>
+   </property>
+   <item>
+    <widget class="QTreeWidget" name="tree" />
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
index 39901cc..146203e 100644 (file)
@@ -50,7 +50,6 @@ ServerListDlg::ServerListDlg(QWidget *parent) : QDialog(parent) {
       list << net;
     }
   }
-  qDebug() << "Autoconnect:"<<list;
   if(!list.isEmpty()) emit requestConnect(list);
 }
 
diff --git a/gui/settingsdlg.ui b/gui/settingsdlg.ui
new file mode 100644 (file)
index 0000000..dd7af10
--- /dev/null
@@ -0,0 +1,130 @@
+<ui version="4.0" >
+ <class>SettingsDialog</class>
+ <widget class="QDialog" name="SettingsDialog" >
+  <property name="geometry" >
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>700</width>
+    <height>577</height>
+   </rect>
+  </property>
+  <property name="windowTitle" >
+   <string>Settings</string>
+  </property>
+  <layout class="QHBoxLayout" >
+   <property name="margin" >
+    <number>9</number>
+   </property>
+   <property name="spacing" >
+    <number>6</number>
+   </property>
+   <item>
+    <widget class="QTreeWidget" name="treeWidget" >
+     <property name="sizePolicy" >
+      <sizepolicy>
+       <hsizetype>4</hsizetype>
+       <vsizetype>7</vsizetype>
+       <horstretch>1</horstretch>
+       <verstretch>0</verstretch>
+      </sizepolicy>
+     </property>
+     <column>
+      <property name="text" >
+       <string>Settings</string>
+      </property>
+     </column>
+     <item>
+      <property name="text" >
+       <string>General</string>
+      </property>
+     </item>
+     <item>
+      <property name="text" >
+       <string>Appearance</string>
+      </property>
+     </item>
+     <item>
+      <property name="text" >
+       <string>Connection</string>
+      </property>
+     </item>
+     <item>
+      <property name="text" >
+       <string>Plugins</string>
+      </property>
+     </item>
+    </widget>
+   </item>
+   <item>
+    <layout class="QVBoxLayout" >
+     <property name="margin" >
+      <number>0</number>
+     </property>
+     <property name="spacing" >
+      <number>6</number>
+     </property>
+     <item>
+      <widget class="QStackedWidget" name="stackedWidget" >
+       <property name="sizePolicy" >
+        <sizepolicy>
+         <hsizetype>5</hsizetype>
+         <vsizetype>5</vsizetype>
+         <horstretch>4</horstretch>
+         <verstretch>0</verstretch>
+        </sizepolicy>
+       </property>
+       <widget class="QWidget" name="page" />
+       <widget class="QWidget" name="page_2" />
+      </widget>
+     </item>
+     <item>
+      <widget class="QDialogButtonBox" name="buttonBox" >
+       <property name="orientation" >
+        <enum>Qt::Horizontal</enum>
+       </property>
+       <property name="standardButtons" >
+        <set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok|QDialogButtonBox::RestoreDefaults</set>
+       </property>
+      </widget>
+     </item>
+    </layout>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>accepted()</signal>
+   <receiver>SettingsDialog</receiver>
+   <slot>accept()</slot>
+   <hints>
+    <hint type="sourcelabel" >
+     <x>248</x>
+     <y>254</y>
+    </hint>
+    <hint type="destinationlabel" >
+     <x>157</x>
+     <y>274</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>rejected()</signal>
+   <receiver>SettingsDialog</receiver>
+   <slot>reject()</slot>
+   <hints>
+    <hint type="sourcelabel" >
+     <x>316</x>
+     <y>260</y>
+    </hint>
+    <hint type="destinationlabel" >
+     <x>286</x>
+     <y>274</y>
+    </hint>
+   </hints>
+  </connection>
+ </connections>
+</ui>
index 962ac41..4121806 100644 (file)
@@ -110,3 +110,4 @@ void Global::initIconMap() {
 
 Global *global = 0;
 Global::RunMode Global::runMode;
+QString Global::quasselDir;
index ad4cb1d..1faf4d1 100644 (file)
@@ -24,6 +24,9 @@
 /** The protocol version we use fo the communication between core and GUI */
 #define GUI_PROTOCOL 1
 
+#define BACKLOG_FORMAT 1
+#define BACKLOG_STRING "QuasselIRC Backlog File"
+
 class Global;
 
 #include <QtCore>
@@ -67,6 +70,7 @@ class Global : public QObject {
   public:
     enum RunMode { Monolithic, GUIOnly, CoreOnly };
     static RunMode runMode;
+    static QString quasselDir;
 
   private:
     static void initIconMap();
index 740482b..b7f0a8e 100644 (file)
@@ -36,6 +36,8 @@ int main(int argc, char **argv) {
   QCoreApplication::setOrganizationName("The Quassel Team");
 
   Global::runMode = Global::CoreOnly;
+  Global::quasselDir = QDir::homePath() + "/.quassel";
+
   global = new Global();
   coreProxy = new CoreProxy();
   core = new Core();
index 31f30e6..7dc2d53 100644 (file)
@@ -35,6 +35,8 @@ int main(int argc, char **argv) {
   QApplication::setOrganizationName("The Quassel Team");
 
   Global::runMode = Global::GUIOnly;
+  Global::quasselDir = QDir::homePath() + "/.quassel";
+
   global = new Global();
   guiProxy = new GUIProxy();
 
index 6bd0f33..7700b27 100644 (file)
@@ -36,6 +36,8 @@ int main(int argc, char **argv) {
   QApplication::setOrganizationName("The Quassel Team");
 
   Global::runMode = Global::Monolithic;
+  Global::quasselDir = QDir::homePath() + "/.quassel";
+
   global = new Global();
   guiProxy = new GUIProxy();
   coreProxy = new CoreProxy();
index 53b8170..e19e74c 100644 (file)
 #include <QDataStream>
 
 QDataStream &operator<<(QDataStream &out, const Message &msg) {
-  out << (quint32)msg.timeStamp.toTime_t() << (quint8)msg.type << (quint8)msg.flags << msg.sender << msg.msg;
+  out << (quint32)msg.timeStamp.toTime_t() << (quint8)msg.type << (quint8)msg.flags << msg.sender.toUtf8() << msg.msg.toUtf8();
   return out;
 }
 
 QDataStream &operator>>(QDataStream &in, Message &msg) {
   quint8 t, f;
   quint32 ts;
-  in >> ts >> t >> f >> msg.sender >> msg.msg;
+  QByteArray s, m;
+  in >> ts >> t >> f >> s >> m;
   msg.type = (Message::Type)t;
   msg.flags = (Message::Flags)f;
   msg.timeStamp = QDateTime::fromTime_t(ts);
+  msg.sender = QString::fromUtf8(s);
+  msg.msg = QString::fromUtf8(m);
   return in;
 }
index 7e0d749..c27117e 100644 (file)
@@ -109,7 +109,7 @@ QString Server::updateNickFromMask(QString mask) {
 
 void Server::userInput(QString net, QString buf, QString msg) {
   if(net != network) return; // not me!
-  msg = msg.trimmed(); // remove whitespace from start and end
+  //msg = msg.trimmed(); // remove whitespace from start and end
   if(msg.isEmpty()) return;
   if(!msg.startsWith('/')) {
     msg = QString("/SAY ") + msg;
@@ -131,7 +131,7 @@ void Server::putCmd(QString cmd, QStringList params, QString prefix) {
     m += " " + params[i];
   }
   if(!params.isEmpty()) m += " :" + params.last();
-  qDebug() << "SentCmd: " << m;
+  qDebug() << "Sent: " << m;
   m += "\r\n";
   socket.write(m.toAscii());
 }
@@ -198,12 +198,24 @@ void Server::defaultServerHandler(QString cmd, QString prefix, QStringList param
       case 2: case 3: case 4: case 5: case 251: case 252: case 253: case 254: case 255: case 372: case 375:
         emit displayMsg("", Message(Message::Server, params.join(" "), prefix));
         break;
+      // Server error messages without param, just display them
+      case 409: case 411: case 412: case 422: case 424: case 431: case 445: case 446: case 451: case 462:
+      case 463: case 464: case 465: case 466: case 472: case 481: case 483: case 485: case 491: case 501: case 502:
+        emit displayMsg("", Message(Message::Error, params.join(" "), prefix));
+        break;
       // Server error messages, display them in red. First param will be appended.
-      case 401: case 402: case 403: case 404:
+      case 401: case 402: case 403: case 404: case 406: case 408: case 415: case 421: case 432: case 442:
       { QString p = params.takeFirst();
         emit displayMsg("", Message(Message::Error, params.join(" ") + " " + p, prefix));
         break;
       }
+      // Server error messages which will be displayed with a colon between the first param and the rest
+      case 413: case 414: case 423: case 433: case 436: case 441: case 444: case 461:
+      case 467: case 471: case 473: case 474: case 475: case 476: case 477: case 478: case 482:
+      { QString p = params.takeFirst();
+        emit displayMsg("", Message(Message::Error, p + ": " + params.join(" ")));
+        break;
+      }
       // Ignore these commands.
       case 366: case 376:
         break;
@@ -229,7 +241,7 @@ void Server::handleUserInput(QString bufname, QString usrMsg) {
     }
     */
     QString cmd = usrMsg.section(' ', 0, 0).remove(0, 1).toUpper();
-    QString msg = usrMsg.section(' ', 1).trimmed();
+    QString msg = usrMsg.section(' ', 1);
     QString hname = cmd.toLower();
     hname[0] = hname[0].toUpper();
     hname = "handleUser" + hname;
@@ -302,7 +314,7 @@ void Server::handleUserMode(QString bufname, QString msg) {
 
 void Server::handleUserMsg(QString bufname, QString msg) {
   QString nick = msg.section(" ", 0, 0);
-  msg = msg.section(" ", 1).trimmed();
+  msg = msg.section(" ", 1);
   if(nick.isEmpty() || msg.isEmpty()) return;
   QStringList params;
   params << nick << msg;
@@ -543,6 +555,7 @@ void Server::handleServer005(QString prefix, QStringList params) {
 /* RPL_NOTOPIC */
 void Server::handleServer331(QString prefix, QStringList params) {
   emit topicSet(network, params[0], "");
+  emit displayMsg(params[0], Message(Message::Server, tr("No topic is set for %1.").arg(params[0])));
 }
 
 /* RPL_TOPIC */