-/* RPL_??? - "<channel> <homepage> */
-void IrcServerHandler::handle328(const QString &prefix, const QList<QByteArray> ¶ms) {
- Q_UNUSED(prefix);
- if(!checkParamCount("IrcServerHandler::handle328()", params, 2))
- return;
-
- QString channel = serverDecode(params[0]);
- QString homepage = serverDecode(params[1]);
-
- emit displayMsg(Message::Server, BufferInfo::ChannelBuffer, channel, tr("Homepage for %1 is %2").arg(channel, homepage));
-}
-
-
-/* RPL_??? - "<channel> <creation time (unix)>" */
-void IrcServerHandler::handle329(const QString &prefix, const QList<QByteArray> ¶ms) {
- Q_UNUSED(prefix);
- if(!checkParamCount("IrcServerHandler::handle329()", params, 2))
- return;
-
- QString channel = serverDecode(params[0]);
- uint unixtime = params[1].toUInt();
- if(!unixtime) {
- qWarning() << Q_FUNC_INFO << "received invalid timestamp:" << params[1];
- return;
- }
- QDateTime time = QDateTime::fromTime_t(unixtime);
-
- emit displayMsg(Message::Server, BufferInfo::ChannelBuffer, channel, tr("Channel %1 created on %2").arg(channel, time.toString()));
-}
-
-/* RPL_NOTOPIC */
-void IrcServerHandler::handle331(const QString &prefix, const QList<QByteArray> ¶ms) {
- Q_UNUSED(prefix);
- if(!checkParamCount("IrcServerHandler::handle331()", params, 1))
- return;
-
- QString channel = serverDecode(params[0]);
- IrcChannel *chan = network()->ircChannel(channel);
- if(chan)
- chan->setTopic(QString());
-
- emit displayMsg(Message::Topic, BufferInfo::ChannelBuffer, channel, tr("No topic is set for %1.").arg(channel));
-}
-
-/* RPL_TOPIC */
-void IrcServerHandler::handle332(const QString &prefix, const QList<QByteArray> ¶ms) {
- Q_UNUSED(prefix);
- if(!checkParamCount("IrcServerHandler::handle332()", params, 2))
- return;
-
- QString channel = serverDecode(params[0]);
- 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);
-
- emit displayMsg(Message::Topic, BufferInfo::ChannelBuffer, channel, tr("Topic for %1 is \"%2\"").arg(channel, topic));
-}
-
-/* Topic set by... */
-void IrcServerHandler::handle333(const QString &prefix, const QList<QByteArray> ¶ms) {
- Q_UNUSED(prefix);
- if(!checkParamCount("IrcServerHandler::handle333()", params, 3))
- return;
-
- QString channel = serverDecode(params[0]);
- emit displayMsg(Message::Topic, BufferInfo::ChannelBuffer, channel,
- tr("Topic set by %1 on %2") .arg(serverDecode(params[1]), QDateTime::fromTime_t(channelDecode(channel, params[2]).toUInt()).toString()));
-}
-
-/* RPL_INVITING - "<nick> <channel>*/
-void IrcServerHandler::handle341(const QString &prefix, const QList<QByteArray> ¶ms) {
- Q_UNUSED(prefix);
- if(!checkParamCount("IrcServerHandler::handle341()", params, 2))
- return;
-
- QString nick = serverDecode(params[0]);
-
- IrcChannel *channel = network()->ircChannel(serverDecode(params[1]));
- if(!channel) {
- qWarning() << "IrcServerHandler::handle341(): unknown channel:" << params[1];
- return;
- }
-
- emit displayMsg(Message::Server, BufferInfo::ChannelBuffer, channel->name(), tr("%1 has been invited to %2").arg(nick).arg(channel->name()));
-}
-
-/* RPL_WHOREPLY: "<channel> <user> <host> <server> <nick>
- ( "H" / "G" > ["*"] [ ( "@" / "+" ) ] :<hopcount> <real name>" */
-void IrcServerHandler::handle352(const QString &prefix, const QList<QByteArray> ¶ms) {
- Q_UNUSED(prefix)
- if(!checkParamCount("IrcServerHandler::handle352()", params, 6))
- return;
-
- QString channel = serverDecode(params[0]);
- IrcUser *ircuser = network()->ircUser(serverDecode(params[4]));
- if(ircuser) {
- ircuser->setUser(serverDecode(params[1]));
- ircuser->setHost(serverDecode(params[2]));
-
- bool away = serverDecode(params[5]).startsWith("G") ? true : false;
- ircuser->setAway(away);
- ircuser->setServer(serverDecode(params[3]));
- ircuser->setRealName(serverDecode(params.last()).section(" ", 1));
- }
-
- if(!network()->isAutoWhoInProgress(channel)) {
- emit displayMsg(Message::Server, BufferInfo::StatusBuffer, "", tr("[Who] %1").arg(serverDecode(params).join(" ")));
- }
-}
-
-/* RPL_NAMREPLY */
-void IrcServerHandler::handle353(const QString &prefix, const QList<QByteArray> ¶ms) {
- Q_UNUSED(prefix);
- if(!checkParamCount("IrcServerHandler::handle353()", params, 3))
- return;
-
- // param[0] is either "=", "*" or "@" indicating a public, private or secret channel
- // we don't use this information at the time beeing
- QString channelname = serverDecode(params[1]);
-
- IrcChannel *channel = network()->ircChannel(channelname);
- if(!channel) {
- qWarning() << "IrcServerHandler::handle353(): received unknown target channel:" << channelname;
- return;
- }
-
- QStringList nicks;
- QStringList modes;
-
- foreach(QString nick, serverDecode(params[2]).split(' ')) {
- QString mode = QString();
-
- if(network()->prefixes().contains(nick[0])) {
- mode = network()->prefixToMode(nick[0]);
- nick = nick.mid(1);
- }
-
- nicks << nick;
- modes << mode;
- }
-
- channel->joinIrcUsers(nicks, modes);
-}
-
-/* RPL_ENDOFWHOWAS - "<nick> :End of WHOWAS" */
-void IrcServerHandler::handle369(const QString &prefix, const QList<QByteArray> ¶ms) {
- Q_UNUSED(prefix)
- emit displayMsg(Message::Server, BufferInfo::StatusBuffer, "", tr("[Whowas] %1").arg(serverDecode(params).join(" ")));
-}
-
-/* ERR_ERRONEUSNICKNAME */
-void IrcServerHandler::handle432(const QString &prefix, const QList<QByteArray> ¶ms) {
- Q_UNUSED(prefix);
-
- QString errnick;
- if(params.size() < 2) {
- // handle unreal-ircd bug, where unreal ircd doesnt supply a TARGET in ERR_ERRONEUSNICKNAME during registration phase:
- // nick @@@
- // :irc.scortum.moep.net 432 @@@ :Erroneous Nickname: Illegal characters
- // correct server reply:
- // :irc.scortum.moep.net 432 * @@@ :Erroneous Nickname: Illegal characters
- errnick = target();
- } else {
- errnick = params[0];
- }
- emit displayMsg(Message::Error, BufferInfo::StatusBuffer, "", tr("Nick %1 contains illegal characters").arg(errnick));
- tryNextNick(errnick, true /* erroneus */);
-}
-
-/* ERR_NICKNAMEINUSE */
-void IrcServerHandler::handle433(const QString &prefix, const QList<QByteArray> ¶ms) {
- Q_UNUSED(prefix);
- if(!checkParamCount("IrcServerHandler::handle433()", params, 1))
- return;
-
- QString errnick = serverDecode(params[0]);
- emit displayMsg(Message::Error, BufferInfo::StatusBuffer, "", tr("Nick already in use: %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;
-
- 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);
-}
-