X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcore%2Fcorenetwork.cpp;h=b7ec55d253fff98e5e2bb07f23fa9d7fe04855db;hp=ccb5600fdf2c01316e324645392a9f08b8bfcb5b;hb=14281719026a2d9d30667f63f3659c2c4e7e0cca;hpb=6f0a153a674317d77233139fc50a2985af86e36e;ds=sidebyside diff --git a/src/core/corenetwork.cpp b/src/core/corenetwork.cpp index ccb5600f..b7ec55d2 100644 --- a/src/core/corenetwork.cpp +++ b/src/core/corenetwork.cpp @@ -277,6 +277,26 @@ void CoreNetwork::removeChannelKey(const QString &channel) { } #ifdef HAVE_QCA2 +Cipher *CoreNetwork::cipher(const QString &target) const { + if(target.isEmpty()) + return 0; + + QByteArray key = cipherKey(target); + if(key.isEmpty()) + return 0; + + CoreIrcChannel *channel = qobject_cast(ircChannel(target)); + if(channel) { + if(channel->cipher()->setKey(key)) + return channel->cipher(); + } else { + CoreIrcUser *user = qobject_cast(ircUser(target)); + if(user && user->cipher()->setKey(key)) + return user->cipher(); + } + return 0; +} + QByteArray CoreNetwork::cipherKey(const QString &recipient) const { return _cipherKeys.value(recipient.toLower(), QByteArray()); }