-
-QString IrcServerHandler::decryptTopic(const QString &bufferName, QString &topic) {
- if(bufferName.isEmpty())
- return topic;
-
- if(topic.isEmpty())
- return topic;
-
- const QByteArray key = network()->bufferKey(bufferName);
- if(key.isEmpty())
- return topic;
-
- IrcChannel *channel = network()->ircChannel(bufferName);
- IrcUser *user = network()->ircUser(bufferName);
-
- //only send encrypted text to decrypter
- int index = topic.indexOf(":",topic.indexOf(":")+1);
-
- QString backup = topic.mid(0,index+1);
-
- if (channel && channel->cipher()->setKey(key))
- topic = channel->cipher()->decryptTopic(topic.mid(index+1).toAscii());
- else if (user && user->cipher()->setKey(key))
- topic = user->cipher()->decryptTopic(topic.mid(index+1).toAscii());
-
- topic.prepend(backup);
- topic = channelDecode(bufferName, topic.toAscii());
-
- return topic;
-}