Implement password changing from client.
[quassel.git] / src / core / coresession.cpp
index 508e2b9..1f6345d 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2005-2014 by the Quassel Project                        *
+ *   Copyright (C) 2005-2015 by the Quassel Project                        *
  *   devel@quassel-irc.org                                                 *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
 #include "ircuser.h"
 #include "logger.h"
 #include "messageevent.h"
+#include "remotepeer.h"
 #include "storage.h"
 #include "util.h"
 
-#include "protocols/legacy/legacypeer.h"
 
 class ProcessMessagesEvent : public QEvent
 {
@@ -100,6 +100,8 @@ CoreSession::CoreSession(UserId uid, bool restoreState, QObject *parent)
     p->attachSlot(SIGNAL(createNetwork(const NetworkInfo &, const QStringList &)), this, SLOT(createNetwork(const NetworkInfo &, const QStringList &)));
     p->attachSlot(SIGNAL(removeNetwork(NetworkId)), this, SLOT(removeNetwork(NetworkId)));
 
+    p->attachSlot(SIGNAL(clientChangePassword(QString)), this, SLOT(changePassword(QString)));
+
     loadSettings();
     initScriptEngine();
 
@@ -321,8 +323,8 @@ void CoreSession::processMessages()
             bufferInfo = Core::bufferInfo(user(), rawMsg.networkId, BufferInfo::StatusBuffer, "");
         }
         Message msg(bufferInfo, rawMsg.type, rawMsg.text, rawMsg.sender, rawMsg.flags);
-        Core::storeMessage(msg);
-        emit displayMsg(msg);
+        if(Core::storeMessage(msg))
+            emit displayMsg(msg);
     }
     else {
         QHash<NetworkId, QHash<QString, BufferInfo> > bufferInfoCache;
@@ -364,10 +366,11 @@ void CoreSession::processMessages()
             messages << msg;
         }
 
-        Core::storeMessages(messages);
-        // FIXME: extend protocol to a displayMessages(MessageList)
-        for (int i = 0; i < messages.count(); i++) {
-            emit displayMsg(messages[i]);
+        if(Core::storeMessages(messages)) {
+            // FIXME: extend protocol to a displayMessages(MessageList)
+            for (int i = 0; i < messages.count(); i++) {
+                emit displayMsg(messages[i]);
+            }
         }
     }
     _processMessages = false;
@@ -637,3 +640,8 @@ void CoreSession::globalAway(const QString &msg)
         net->userInputHandler()->issueAway(msg, false /* no force away */);
     }
 }
+
+void CoreSession::changePassword(QString password)
+{
+    emit passwordChangeRequested(_user, password);
+}