Setting status buffer active on connection (by creating a BufferId for it in Core
authorManuel Nickschas <sputnick@quassel-irc.org>
Tue, 19 Jun 2007 09:37:08 +0000 (09:37 +0000)
committerManuel Nickschas <sputnick@quassel-irc.org>
Tue, 19 Jun 2007 09:37:08 +0000 (09:37 +0000)
before we try to access the corresponding Buffer in GUI), fixing BR #40.

core/core.cpp
core/core.h
gui/mainwin.cpp
main/main_mono.cpp

index b1815d9..2a8d4cc 100644 (file)
@@ -56,8 +56,11 @@ void Core::init() {
   connect(&server, SIGNAL(newConnection()), this, SLOT(incomingConnection()));
   //startListening(); // FIXME
   if(Global::runMode == Global::Monolithic) {  // TODO Make GUI user configurable
-    guiUser = storage->validateUser("Default", "password");
-    if(!guiUser) guiUser = storage->addUser("Default", "password");
+    try {
+      guiUser = storage->validateUser("Default", "password");
+    } catch(Storage::AuthError) {
+      guiUser = storage->addUser("Default", "password");
+    }
     Q_ASSERT(guiUser);
     Global::setGuiUser(guiUser);
     createSession(guiUser);
@@ -253,8 +256,8 @@ void Core::recvProxySignal(CoreSignal sig, QVariant arg1, QVariant arg2, QVarian
 
 CoreSession::CoreSession(UserId uid, Storage *_storage) : user(uid), storage(_storage) {
   coreProxy = new CoreProxy();
-  connect(coreProxy, SIGNAL(send(CoreSignal, QVariant, QVariant, QVariant)), this, SIGNAL(proxySignal(CoreSignal, QVariant, QVariant, QVariant)));
 
+  connect(coreProxy, SIGNAL(send(CoreSignal, QVariant, QVariant, QVariant)), this, SIGNAL(proxySignal(CoreSignal, QVariant, QVariant, QVariant)));
   connect(coreProxy, SIGNAL(requestServerStates()), this, SIGNAL(serverStateRequested()));
   connect(coreProxy, SIGNAL(gsRequestConnect(QStringList)), this, SLOT(connectToIrc(QStringList)));
   connect(coreProxy, SIGNAL(gsUserInput(BufferId, QString)), this, SLOT(msgFromGui(BufferId, QString)));
@@ -267,7 +270,6 @@ CoreSession::CoreSession(UserId uid, Storage *_storage) : user(uid), storage(_st
   connect(storage, SIGNAL(bufferIdUpdated(BufferId)), coreProxy, SLOT(csUpdateBufferId(BufferId)));
   connect(Global::instance(), SIGNAL(dataUpdatedRemotely(UserId, QString)), this, SLOT(globalDataUpdated(UserId, QString)));
   connect(Global::instance(), SIGNAL(dataPutLocally(UserId, QString)), this, SLOT(globalDataUpdated(UserId, QString)));
-
 }
 
 CoreSession::~CoreSession() {
@@ -299,6 +301,10 @@ void CoreSession::connectToIrc(QStringList networks) {
       connect(this, SIGNAL(connectToIrc(QString)), server, SLOT(connectToIrc(QString)));
       connect(this, SIGNAL(disconnectFromIrc(QString)), server, SLOT(disconnectFromIrc(QString)));
       connect(this, SIGNAL(msgFromGui(QString, QString, QString)), server, SLOT(userInput(QString, QString, QString)));
+
+      connect(server, SIGNAL(connected(QString)), this, SLOT(serverConnected(QString)));
+      connect(server, SIGNAL(disconnected(QString)), this, SLOT(serverDisconnected(QString)));
+
       connect(server, SIGNAL(serverState(QString, VarMap)), coreProxy, SLOT(csServerState(QString, VarMap)));
       //connect(server, SIGNAL(displayMsg(Message)), this, SLOT(recvMessageFromServer(Message)));
       connect(server, SIGNAL(displayMsg(Message::Type, QString, QString, QString, quint8)), this, SLOT(recvMessageFromServer(Message::Type, QString, QString, QString, quint8)));
@@ -313,7 +319,7 @@ void CoreSession::connectToIrc(QStringList networks) {
       connect(server, SIGNAL(queryRequested(QString, QString)), coreProxy, SLOT(csQueryRequested(QString, QString)));
       // TODO add error handling
       connect(server, SIGNAL(connected(QString)), coreProxy, SLOT(csServerConnected(QString)));
-      connect(server, SIGNAL(disconnected(QString)), this, SLOT(serverDisconnected(QString)));
+      connect(server, SIGNAL(disconnected(QString)), coreProxy, SLOT(csServerDisconnected(QString)));
 
       server->start();
       servers[net] = server;
@@ -322,6 +328,10 @@ void CoreSession::connectToIrc(QStringList networks) {
   }
 }
 
+void CoreSession::serverConnected(QString net) {
+  storage->getBufferId(userId(), net); // create status buffer
+}
+
 void CoreSession::serverDisconnected(QString net) {
   delete servers[net];
   servers.remove(net);
index 400c21e..c4a6646 100644 (file)
@@ -109,6 +109,7 @@ class CoreSession : public QObject {
     void globalDataUpdated(UserId, QString);
     void recvStatusMsgFromServer(QString msg);
     void recvMessageFromServer(Message::Type, QString target, QString text, QString sender = "", quint8 flags = Message::None);
+    void serverConnected(QString net);
     void serverDisconnected(QString net);
 
   private:
index 0879203..2b63b17 100644 (file)
@@ -153,7 +153,7 @@ void MainWin::setupMenus() {
 }
 
 void MainWin::setupViews() {
-  BufferTreeModel *model = new BufferTreeModel(this);
+  BufferTreeModel *model = new BufferTreeModel(this); // FIXME Where is the delete for that? :p
   connect(model, SIGNAL(bufferSelected(Buffer *)), this, SLOT(showBuffer(Buffer *)));
   connect(this, SIGNAL(bufferSelected(Buffer *)), model, SLOT(selectBuffer(Buffer *)));
   connect(this, SIGNAL(bufferUpdated(Buffer *)), model, SLOT(bufferUpdated(Buffer *)));
@@ -237,10 +237,10 @@ void MainWin::showBuffer(Buffer *b) {
 
 void MainWin::networkConnected(QString net) {
   connected[net] = true;
-  //BufferId id = getStatusBufferId(net);
-  //Buffer *b = getBuffer(id);
-  //b->setActive(true);
-  //b->displayMsg(Message(id, Message::Server, tr("Connected.")));  FIXME
+  BufferId id = getStatusBufferId(net);
+  Buffer *b = getBuffer(id);
+  b->setActive(true);
+  //b->displayMsg(Message(id, Message::Server, tr("Connected.")));
   // TODO buffersUpdated();
 }
 
index fdfb22f..d9c682f 100644 (file)
@@ -1,7 +1,7 @@
 /***************************************************************************
- *   Copyright (C) 2005 by The Quassel Team                                *
+ *   Copyright (C) 2005-07 by The Quassel IRC Development Team             *
  *   devel@quassel-irc.org                                                 *
- *                                                                          *
+ *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU General Public License as published by  *
  *   the Free Software Foundation; either version 2 of the License, or     *