+#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<CoreIrcChannel *>(ircChannel(target));
+ if(channel) {
+ if(channel->cipher()->setKey(key))
+ return channel->cipher();
+ } else {
+ CoreIrcUser *user = qobject_cast<CoreIrcUser *>(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());
+}
+
+void CoreNetwork::setCipherKey(const QString &recipient, const QByteArray &key) {
+ if(!key.isEmpty())
+ _cipherKeys[recipient.toLower()] = key;
+ else
+ _cipherKeys.remove(recipient.toLower());
+}
+#endif /* HAVE_QCA2 */
+