handle incoming invite, fixes #961
[quassel.git] / src / core / ircserverhandler.cpp
index b9a2f6c..033d6c8 100644 (file)
@@ -197,6 +197,21 @@ void IrcServerHandler::defaultHandler(QString cmd, const QString &prefix, const
 //******************************/
 // IRC SERVER HANDLER
 //******************************/
+void IrcServerHandler::handleInvite(const QString &prefix, const QList<QByteArray> &params) {
+  if(!checkParamCount("IrcServerHandler::handleInvite()", params, 2))
+    return;
+//   qDebug() << "IrcServerHandler::handleInvite()" << prefix << params;
+
+  IrcUser *ircuser = network()->updateNickFromMask(prefix);
+  if(!ircuser) {
+    return;
+  }
+
+  QString channel = serverDecode(params[1]);
+
+  emit displayMsg(Message::Invite, BufferInfo::StatusBuffer, "", tr("%1 invited you to channel %2").arg(ircuser->nick()).arg(channel));
+}
+
 void IrcServerHandler::handleJoin(const QString &prefix, const QList<QByteArray> &params) {
   if(!checkParamCount("IrcServerHandler::handleJoin()", params, 1))
     return;
@@ -1249,25 +1264,15 @@ void IrcServerHandler::destroyNetsplits() {
 
 #ifdef HAVE_QCA2
 QByteArray IrcServerHandler::decrypt(const QString &bufferName, const QByteArray &message_, bool isTopic) {
-  if(bufferName.isEmpty() || message_.isEmpty())
+  if(message_.isEmpty())
     return message_;
 
-  const QByteArray key = network()->cipherKey(bufferName);
-  if(key.isEmpty())
+  Cipher *cipher = network()->cipher(bufferName);
+  if(!cipher)
     return message_;
 
   QByteArray message = message_;
-
-  CoreIrcChannel *channel = qobject_cast<CoreIrcChannel *>(network()->ircChannel(bufferName));
-  if(channel) {
-    if(channel->cipher()->setKey(key))
-      message = isTopic? channel->cipher()->decryptTopic(message) : channel->cipher()->decrypt(message);
-  } else {
-    CoreIrcUser *user = qobject_cast<CoreIrcUser *>(network()->ircUser(bufferName));
-    if(user && user->cipher()->setKey(key))
-      message = user->cipher()->decrypt(message);
-  }
-
+  message = isTopic? cipher->decryptTopic(message) : cipher->decrypt(message);
   return message;
 }
 #endif