SASL support
[quassel.git] / src / core / corenetwork.cpp
index 21415ae..959b3c4 100644 (file)
 #include "corenetworkconfig.h"
 
 #include "ircserverhandler.h"
-#include "userinputhandler.h"
+#include "coreuserinputhandler.h"
 #include "ctcphandler.h"
 
+INIT_SYNCABLE_OBJECT(CoreNetwork)
 CoreNetwork::CoreNetwork(const NetworkId &networkid, CoreSession *session)
   : Network(networkid, session),
     _coreSession(session),
     _ircServerHandler(new IrcServerHandler(this)),
-    _userInputHandler(new UserInputHandler(this)),
+    _userInputHandler(new CoreUserInputHandler(this)),
     _ctcpHandler(new CtcpHandler(this)),
     _autoReconnectCount(0),
     _quitRequested(false),
@@ -70,7 +71,6 @@ CoreNetwork::CoreNetwork(const NetworkId &networkid, CoreSession *session)
   connect(&_autoWhoTimer, SIGNAL(timeout()), this, SLOT(sendAutoWho()));
   connect(&_autoWhoCycleTimer, SIGNAL(timeout()), this, SLOT(startAutoWhoCycle()));
   connect(&_tokenBucketTimer, SIGNAL(timeout()), this, SLOT(fillBucketAndProcessQueue()));
-  connect(this, SIGNAL(connectRequested()), this, SLOT(connectToIrc()));
 
   connect(&socket, SIGNAL(connected()), this, SLOT(socketInitialized()));
   connect(&socket, SIGNAL(disconnected()), this, SLOT(socketDisconnected()));
@@ -333,6 +333,9 @@ void CoreNetwork::socketInitialized() {
   _tokenBucket = _burstSize; // init with a full bucket
   _tokenBucketTimer.start(_messageDelay);
 
+  if(networkInfo().useSasl) {
+    putRawLine(serverEncode(QString("CAP REQ :sasl")));
+  }
   if(!server.password.isEmpty()) {
     putRawLine(serverEncode(QString("PASS %1").arg(server.password)));
   }
@@ -369,6 +372,7 @@ void CoreNetwork::socketDisconnected() {
   setConnected(false);
   emit disconnected(networkId());
   if(_quitRequested) {
+    _quitRequested = false;
     setConnectionState(Network::Disconnected);
     Core::setNetworkConnected(userId(), networkId(), false);
   } else if(_autoReconnectCount != 0) {
@@ -650,7 +654,7 @@ void CoreNetwork::requestConnect() const {
     qWarning() << "Requesting connect while already being connected!";
     return;
   }
-  Network::requestConnect();
+  QMetaObject::invokeMethod(const_cast<CoreNetwork *>(this), "connectToIrc", Qt::QueuedConnection);
 }
 
 void CoreNetwork::requestDisconnect() const {