QString foo = serverDecode(params.takeFirst());
// with SASL, the command is 'AUTHENTICATE +' and we should check for this here.
+ /* obsolete because of events
if(foo == QString("AUTHENTICATE +")) {
handleAuthenticate();
return;
}
-
+ */
// a colon as the first chars indicates the existence of a prefix
if(foo[0] == ':') {
foo.remove(0, 1);
putCmd("PONG", params);
}
-void IrcServerHandler::handlePong(const QString &prefix, const QList<QByteArray> ¶ms) {
- Q_UNUSED(prefix);
- // the server is supposed to send back what we passed as param. and we send a timestamp
- // but using quote and whatnought one can send arbitrary pings, so we have to do some sanity checks
- if(params.count() < 2)
- return;
-
- QString timestamp = serverDecode(params[1]);
- QTime sendTime = QTime::fromString(timestamp, "hh:mm:ss.zzz");
- if(!sendTime.isValid()) {
- emit displayMsg(Message::Server, BufferInfo::StatusBuffer, "", "PONG " + serverDecode(params).join(" "), prefix);
- return;
- }
-
- network()->setLatency(sendTime.msecsTo(QTime::currentTime()) / 2);
-}
-
void IrcServerHandler::handlePrivmsg(const QString &prefix, const QList<QByteArray> ¶ms) {
if(!checkParamCount("IrcServerHandler::handlePrivmsg()", params, 1))
return;
}
}
-void IrcServerHandler::handleTopic(const QString &prefix, const QList<QByteArray> ¶ms) {
- if(!checkParamCount("IrcServerHandler::handleTopic()", params, 1))
- return;
-
- IrcUser *ircuser = network()->updateNickFromMask(prefix);
- if(!ircuser)
- return;
-
- IrcChannel *channel = network()->ircChannel(serverDecode(params[0]));
- if(!channel)
- return;
-
- QString topic;
- 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);
-
- emit displayMsg(Message::Topic, BufferInfo::ChannelBuffer, channel->name(), tr("%1 has changed topic for %2 to: \"%3\"").arg(ircuser->nick()).arg(channel->name()).arg(topic));
-}
-
-void IrcServerHandler::handleCap(const QString &prefix, const QList<QByteArray> ¶ms) {
- // for SASL, there will only be a single param of 'sasl', however you can check here for
- // additional CAP messages (ls, multi-prefix, et cetera).
-
- Q_UNUSED(prefix);
-
- if(params.size() == 3) {
- QString param = serverDecode(params[2]);
- if(param == QString("sasl")) { // SASL Ready
- network()->putRawLine(serverEncode("AUTHENTICATE PLAIN")); // Only working with PLAIN atm, blowfish later
- }
- }
-}
-
-void IrcServerHandler::handleAuthenticate() {
- QString construct = network()->saslAccount();
- construct.append(QChar(QChar::Null));
- construct.append(network()->saslAccount());
- construct.append(QChar(QChar::Null));
- construct.append(network()->saslPassword());
- QByteArray saslData = QByteArray(construct.toAscii().toBase64());
- saslData.prepend(QString("AUTHENTICATE ").toAscii());
- network()->putRawLine(saslData);
-}
-
-/* RPL_WELCOME */
-void IrcServerHandler::handle001(const QString &prefix, const QList<QByteArray> ¶ms) {
- network()->setCurrentServer(prefix);
-
- if(params.isEmpty()) {
- emit displayMsg(Message::Error, BufferInfo::StatusBuffer, "", QString("%1 didn't supply a valid welcome message... expect some serious issues..."));
- }
- // there should be only one param: "Welcome to the Internet Relay Network <nick>!<user>@<host>"
- QString param = serverDecode(params[0]);
- QString myhostmask = param.section(' ', -1, -1);
-
- network()->setMyNick(nickFromMask(myhostmask));
-
- emit displayMsg(Message::Server, BufferInfo::StatusBuffer, "", param, prefix);
-}
-
/* RPL_ISUPPORT */
// TODO Complete 005 handling, also use sensible defaults for non-sent stuff
void IrcServerHandler::handle005(const QString &prefix, const QList<QByteArray> ¶ms) {
network()->determinePrefixes();
}
-/* RPL_UMODEIS - "<user_modes> [<user_mode_params>]" */
-void IrcServerHandler::handle221(const QString &prefix, const QList<QByteArray> ¶ms) {
- Q_UNUSED(prefix)
- //TODO: save information in network object
- emit displayMsg(Message::Server, BufferInfo::StatusBuffer, "", tr("%1").arg(serverDecode(params).join(" ")));
-}
-
-/* RPL_STATSCONN - "Highest connection cout: 8000 (7999 clients)" */
-void IrcServerHandler::handle250(const QString &prefix, const QList<QByteArray> ¶ms) {
- Q_UNUSED(prefix)
- //TODO: save information in network object
- emit displayMsg(Message::Server, BufferInfo::StatusBuffer, "", tr("%1").arg(serverDecode(params).join(" ")));
-}
-
-/* RPL_LOCALUSERS - "Current local user: 5024 Max: 7999 */
-void IrcServerHandler::handle265(const QString &prefix, const QList<QByteArray> ¶ms) {
- Q_UNUSED(prefix)
- //TODO: save information in network object
- emit displayMsg(Message::Server, BufferInfo::StatusBuffer, "", tr("%1").arg(serverDecode(params).join(" ")));
-}
-
-/* RPL_GLOBALUSERS - "Current global users: 46093 Max: 47650" */
-void IrcServerHandler::handle266(const QString &prefix, const QList<QByteArray> ¶ms) {
- Q_UNUSED(prefix)
- //TODO: save information in network object
- emit displayMsg(Message::Server, BufferInfo::StatusBuffer, "", tr("%1").arg(serverDecode(params).join(" ")));
-}
-
/*
WHOIS-Message:
Replies 311 - 313, 317 - 319 are all replies generated in response to a WHOIS message.
*/
-
-/* RPL_AWAY - "<nick> :<away message>" */
-void IrcServerHandler::handle301(const QString &prefix, const QList<QByteArray> ¶ms) {
- Q_UNUSED(prefix);
- if(!checkParamCount("IrcServerHandler::handle301()", params, 2))
- return;
-
-
- QString nickName = serverDecode(params[0]);
- QString awayMessage = userDecode(nickName, params[1]);
-
- IrcUser *ircuser = network()->ircUser(nickName);
- if(ircuser) {
- ircuser->setAwayMessage(awayMessage);
- ircuser->setAway(true);
- }
-
- // FIXME: proper redirection needed
- if(_whois) {
- emit displayMsg(Message::Server, BufferInfo::StatusBuffer, "", tr("[Whois] %1 is away: \"%2\"").arg(nickName).arg(awayMessage));
- } else {
- if(ircuser) {
- int now = QDateTime::currentDateTime().toTime_t();
- int silenceTime = 60;
- if(ircuser->lastAwayMessage() + silenceTime < now) {
- emit displayMsg(Message::Server, BufferInfo::QueryBuffer, params[0], tr("%1 is away: \"%2\"").arg(nickName).arg(awayMessage));
- }
- ircuser->setLastAwayMessage(now);
- } else {
- // probably should not happen
- emit displayMsg(Message::Server, BufferInfo::QueryBuffer, params[0], tr("%1 is away: \"%2\"").arg(nickName).arg(awayMessage));
- }
- }
-}
-
-// 305 RPL_UNAWAY
-// ":You are no longer marked as being away"
-void IrcServerHandler::handle305(const QString &prefix, const QList<QByteArray> ¶ms) {
- Q_UNUSED(prefix);
- IrcUser *me = network()->me();
- if(me)
- me->setAway(false);
-
- if(!network()->autoAwayActive()) {
- if(!params.isEmpty())
- emit displayMsg(Message::Server, BufferInfo::StatusBuffer, "", serverDecode(params[0]));
- } else {
- network()->setAutoAwayActive(false);
- }
-}
-
-// 306 RPL_NOWAWAY
-// ":You have been marked as being away"
-void IrcServerHandler::handle306(const QString &prefix, const QList<QByteArray> ¶ms) {
- Q_UNUSED(prefix);
- IrcUser *me = network()->me();
- if(me)
- me->setAway(true);
-
- if(!params.isEmpty() && !network()->autoAwayActive())
- emit displayMsg(Message::Server, BufferInfo::StatusBuffer, "", serverDecode(params[0]));
-}
-
/* RPL_WHOISSERVICE - "<user> is registered nick" */
void IrcServerHandler::handle307(const QString &prefix, const QList<QByteArray> ¶ms) {
Q_UNUSED(prefix)