From: Manuel Nickschas Date: Thu, 8 Oct 2015 22:06:12 +0000 (+0200) Subject: Merge pull request #149 from Tucos/cipherkeys X-Git-Tag: travis-deploy-test~549 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=df48c9a36377de3c9e9deeaf539e1446ef7bd49b;hp=b50541ba6d7c58322846cc2eb9f023a117d8c47d Merge pull request #149 from Tucos/cipherkeys Store the channel keys in CoreNetwork again --- diff --git a/src/core/coreircchannel.cpp b/src/core/coreircchannel.cpp index ccb82a50..c2745a8e 100644 --- a/src/core/coreircchannel.cpp +++ b/src/core/coreircchannel.cpp @@ -28,6 +28,15 @@ CoreIrcChannel::CoreIrcChannel(const QString &channelname, Network *network) { #ifdef HAVE_QCA2 _cipher = 0; + + // Get the cipher key from CoreNetwork if present + CoreNetwork *coreNetwork = qobject_cast(network); + if (coreNetwork) { + QByteArray key = coreNetwork->readChannelCipherKey(channelname); + if (!key.isEmpty()) { + setEncrypted(cipher()->setKey(key)); + } + } #endif } @@ -35,6 +44,15 @@ CoreIrcChannel::CoreIrcChannel(const QString &channelname, Network *network) CoreIrcChannel::~CoreIrcChannel() { #ifdef HAVE_QCA2 + // Store the cipher key in CoreNetwork, including empty keys if a cipher + // exists. There is no need to store the empty key if no cipher exists; no + // key was present when instantiating and no key was set during the + // channel's lifetime. + CoreNetwork *coreNetwork = qobject_cast(network()); + if (coreNetwork && _cipher) { + coreNetwork->storeChannelCipherKey(name(), _cipher->key()); + } + delete _cipher; #endif } diff --git a/src/core/corenetwork.h b/src/core/corenetwork.h index 05565a47..8073d410 100644 --- a/src/core/corenetwork.h +++ b/src/core/corenetwork.h @@ -84,6 +84,9 @@ public: inline QString channelKey(const QString &channel) const { return _channelKeys.value(channel.toLower(), QString()); } + inline QByteArray readChannelCipherKey(const QString &channel) const { return _cipherKeys.value(channel.toLower()); } + inline void storeChannelCipherKey(const QString &channel, const QByteArray &key) { _cipherKeys[channel.toLower()] = key; } + inline bool isAutoWhoInProgress(const QString &channel) const { return _autoWhoPending.value(channel.toLower(), 0); } inline UserId userId() const { return _coreSession->user(); } @@ -245,6 +248,9 @@ private: QList _msgQueue; QString _requestedUserModes; // 2 strings separated by a '-' character. first part are requested modes to add, the second to remove + + // List of blowfish keys for channels + QHash _cipherKeys; };