#include <QDebug>
+#ifdef HAVE_QCA2
+# include "cipher.h"
+#endif
+
IrcServerHandler::IrcServerHandler(CoreNetwork *parent)
: CoreBasicHandler(parent),
_whois(false)
if(!removeModes.isEmpty())
ircUser->removeUserModes(removeModes);
+ if(network()->isMe(ircUser)) {
+ network()->updatePersistentModes(addModes, removeModes);
+ }
+
// FIXME: redirect
emit displayMsg(Message::Mode, BufferInfo::StatusBuffer, "", serverDecode(params).join(" "), prefix);
}
? *targetIter
: senderNick;
+#ifdef HAVE_QCA2
+ msg = decrypt(target, msg);
+#endif
// it's possible to pack multiple privmsgs into one param using ctcp
// - > we let the ctcpHandler do the work
network()->ctcpHandler()->parse(Message::Plain, prefix, target, msg);
return;
QString topic;
- if(params.count() > 1)
- topic = channelDecode(channel->name(), params[1]);
+ if(params.count() > 1) {
+ QByteArray rawTopic = params[1];
+#ifdef HAVE_QCA2
+ rawTopic = decrypt(channel->name(), rawTopic, true);
+#endif
+ topic = channelDecode(channel->name(), rawTopic);
+ }
channel->setTopic(topic);
return;
QString channel = serverDecode(params[0]);
- QString topic = channelDecode(channel, params[1]);
+ QByteArray rawTopic = params[1];
+#ifdef HAVE_QCA2
+ rawTopic = decrypt(channel, rawTopic, true);
+#endif
+ QString topic = channelDecode(channel, rawTopic);
+
IrcChannel *chan = network()->ircChannel(channel);
if(chan)
chan->setTopic(topic);
tryNextNick(errnick);
}
+/* ERR_UNAVAILRESOURCE */
+void IrcServerHandler::handle437(const QString &prefix, const QList<QByteArray> ¶ms) {
+ Q_UNUSED(prefix);
+ if(!checkParamCount("IrcServerHandler::handle437()", params, 1))
+ return;
+
+ QString errnick = serverDecode(params[0]);
+ emit displayMsg(Message::Error, BufferInfo::StatusBuffer, "", tr("Nick/channel is temporarily unavailable: %1").arg(errnick));
+
+ // if there is a problem while connecting to the server -> we handle it
+ // but only if our connection has not been finished yet...
+ if(!network()->currentServer().isEmpty())
+ return;
+
+ if(!network()->isChannelName(errnick))
+ tryNextNick(errnick);
+}
+
/* Handle signals from Netsplit objects */
void IrcServerHandler::handleNetsplitJoin(const QString &channel, const QStringList &users, const QStringList &modes, const QString& quitMessage)
_netsplits.clear();
}
-/***********************************************************************************/
+#ifdef HAVE_QCA2
+QByteArray IrcServerHandler::decrypt(const QString &bufferName, const QByteArray &message_, bool isTopic) {
+ if(message_.isEmpty())
+ return message_;
+ Cipher *cipher = network()->cipher(bufferName);
+ if(!cipher)
+ return message_;
+ QByteArray message = message_;
+ message = isTopic? cipher->decryptTopic(message) : cipher->decrypt(message);
+ return message;
+}
+#endif