_codecForDecoding(0)
{
setObjectName(QString::number(network->networkId().toInt()) + "/" + channelname);
+
+ #ifdef HAVE_QCA2
+ _cipher = 0;
+ #endif
}
IrcChannel::~IrcChannel() {
else
return QString("+%1 %2").arg(modeString).arg(params.join(" "));
}
+
+#ifdef HAVE_QCA2
+Cipher* IrcChannel::cipher() {
+ if(!_cipher)
+ _cipher = new Cipher();
+ return _cipher;
+}
+#endif
+
+void IrcChannel::setEncrypted(bool e) {
+ if(e) {
+ #ifdef HAVE_QCA2
+ if(topic().isEmpty())
+ return;
+
+ QByteArray key = network->bufferKey(name());
+ if (key.isEmpty())
+ return;
+
+ if(!cipher()->setKey(key))
+ return;
+
+ //only send encrypted text to decrypter
+ int index = topic().indexOf(":",topic().indexOf(":")+1);
+
+ QString backup = topic().mid(0,index+1);
+ QString decrypted = cipher()->decryptTopic(topic().mid(index+1).toAscii());;
+ decrypted.prepend(backup);
+
+ setTopic(decodeString(decrypted.toAscii()));
+ #endif
+ }
+}
\ No newline at end of file
#include "syncableobject.h"
+#ifdef HAVE_QCA2
+#include "cipher.h"
+#endif
+
class IrcUser;
class Network;
QString decodeString(const QByteArray &text) const;
QByteArray encodeString(const QString &string) const;
+
+ #ifdef HAVE_QCA2
+ Cipher* cipher();
+ #endif
+
+ void setEncrypted(bool);
public slots:
void setTopic(const QString &topic);
void addChannelMode(const QChar &mode, const QString &value);
void removeChannelMode(const QChar &mode, const QString &value);
-
+
// init geters
QVariantMap initUserModes() const;
QVariantMap initChanModes() const;
// init seters
void initSetUserModes(const QVariantMap &usermodes);
void initSetChanModes(const QVariantMap &chanModes);
-
+
signals:
void topicSet(const QString &topic); // needed by NetworkModel
// void passwordSet(const QString &password);
QString _name;
QString _topic;
QString _password;
-
+
QHash<IrcUser *, QString> _userModes;
Network *network;
QHash<QChar, QString> _C_channelModes;
QSet<QChar> _D_channelModes;
+ #ifdef HAVE_QCA2
+ Cipher *_cipher;
+ #endif
};
#endif
_codecForDecoding(0)
{
updateObjectName();
+
+ #ifdef HAVE_QCA2
+ _cipher = 0;
+ #endif
}
IrcUser::~IrcUser() {
_lastSpokenTo[buffer] = time;
emit lastSpokenToUpdated(buffer, time);
}
+
+#ifdef HAVE_QCA2
+Cipher* IrcUser::cipher() {
+ if(!_cipher)
+ _cipher = new Cipher();
+ return _cipher;
+}
+#endif
+
+void IrcUser::setEncrypted(bool e) {
+ Q_UNUSED(e);
+ // TODO
+}
\ No newline at end of file
#include "syncableobject.h"
#include "types.h"
+#ifdef HAVE_QCA2
+#include "cipher.h"
+#endif
+
class SignalProxy;
class Network;
class IrcChannel;
inline QDateTime lastSpokenTo(BufferId id) const { return _lastSpokenTo.value(id); }
void setLastSpokenTo(BufferId id, const QDateTime &time);
+ #ifdef HAVE_QCA2
+ Cipher* cipher();
+ #endif
+
+ void setEncrypted(bool);
+
public slots:
void setUser(const QString &user);
void setHost(const QString &host);
void addUserModes(const QString &modes);
void removeUserModes(const QString &modes);
-
+
signals:
// void userSet(QString user);
// void hostSet(QString host);
QHash<BufferId, QDateTime> _lastActivity;
QHash<BufferId, QDateTime> _lastSpokenTo;
+
+ #ifdef HAVE_QCA2
+ Cipher *_cipher;
+ #endif
};
#endif