+
+CoreIrcChannel::~CoreIrcChannel() {
+#ifdef HAVE_QCA2
+ delete _cipher;
+#endif
+}
+
+#ifdef HAVE_QCA2
+Cipher *CoreIrcChannel::cipher() const {
+ if(!_cipher)
+ _cipher = new Cipher();
+
+ return _cipher;
+}
+
+void CoreIrcChannel::setEncrypted(bool e) {
+ if(!Cipher::neededFeaturesAvailable())
+ return;
+
+ if(e) {
+ if(topic().isEmpty())
+ return;
+
+ QByteArray key = qobject_cast<CoreNetwork *>(network())->cipherKey(name());
+ if(key.isEmpty())
+ return;
+
+ if(!cipher()->setKey(key))
+ return;
+
+ QByteArray decrypted = cipher()->decryptTopic(topic().toAscii());
+ setTopic(decodeString(decrypted));
+ }
+}
+
+#endif