X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcore%2Fircserverhandler.cpp;h=31d5bec8c24b8537b5d7b75af1b3ffcff39c3df4;hp=335bd3a53303c30509ec1ae85d1addefc670e9e4;hb=f66bc9ecb5ebde376da256035db425d7dc0c74d0;hpb=c0bbc724cda7acf652d9d2ce80605ebb53c4a2ff diff --git a/src/core/ircserverhandler.cpp b/src/core/ircserverhandler.cpp index 335bd3a5..31d5bec8 100644 --- a/src/core/ircserverhandler.cpp +++ b/src/core/ircserverhandler.cpp @@ -162,20 +162,20 @@ void IrcServerHandler::defaultHandler(QString cmd, const QString &prefix, const // IRC SERVER HANDLER //******************************/ void IrcServerHandler::handleJoin(const QString &prefix, const QList ¶ms) { - Q_ASSERT(params.count() == 1); + if(params.count() < 1) return; QString channel = serverDecode(params[0]); IrcUser *ircuser = network()->updateNickFromMask(prefix); emit displayMsg(Message::Join, BufferInfo::ChannelBuffer, channel, channel, prefix); //qDebug() << "IrcServerHandler::handleJoin()" << prefix << params; ircuser->joinChannel(channel); - if(network()->isMe(ircuser)) network()->addPersistentChannel(channel, networkConnection()->channelKey(channel)); + if(network()->isMe(ircuser)) networkConnection()->setChannelJoined(channel); } void IrcServerHandler::handleKick(const QString &prefix, const QList ¶ms) { network()->updateNickFromMask(prefix); IrcUser *victim = network()->ircUser(params[1]); + if(!victim) return; QString channel = serverDecode(params[0]); - Q_ASSERT(victim); victim->partChannel(channel); @@ -228,6 +228,30 @@ void IrcServerHandler::handleMode(const QString &prefix, const QList } else { // pure User Modes + IrcUser *ircUser = network()->newIrcUser(params[0]); + QString modeString(serverDecode(params[1])); + QString addModes; + QString removeModes; + bool add = false; + for(int c = 0; c < modeString.count(); c++) { + if(modeString[c] == '+') { + add = true; + continue; + } + if(modeString[c] == '-') { + add = false; + continue; + } + if(add) + addModes += modeString[c]; + else + removeModes += modeString[c]; + } + if(!addModes.isEmpty()) + ircUser->addUserModes(addModes); + if(!removeModes.isEmpty()) + ircUser->removeUserModes(removeModes); + // FIXME: redirect emit displayMsg(Message::Mode, BufferInfo::StatusBuffer, "", serverDecode(params).join(" "), prefix); } @@ -278,7 +302,7 @@ void IrcServerHandler::handlePart(const QString &prefix, const QList msg = userDecode(ircuser->nick(), params[1]); emit displayMsg(Message::Part, BufferInfo::ChannelBuffer, channel, msg, prefix); - if(network()->isMe(ircuser)) network()->removePersistentChannel(channel); + if(network()->isMe(ircuser)) networkConnection()->setChannelParted(channel); } void IrcServerHandler::handlePing(const QString &prefix, const QList ¶ms) { @@ -312,7 +336,7 @@ void IrcServerHandler::handlePrivmsg(const QString &prefix, const QList ¶ms) { IrcUser *ircuser = network()->updateNickFromMask(prefix); - Q_ASSERT(ircuser); + if(!ircuser) return; QString msg; if(params.count()) @@ -326,9 +350,10 @@ void IrcServerHandler::handleQuit(const QString &prefix, const QList void IrcServerHandler::handleTopic(const QString &prefix, const QList ¶ms) { IrcUser *ircuser = network()->updateNickFromMask(prefix); + if(!ircuser) return; QString channel = serverDecode(params[0]); - QString topic = channelDecode(channel, params[1]); - Q_ASSERT(ircuser); + QString topic; + if(params.count() >= 2) topic = channelDecode(channel, params[1]); network()->ircChannel(channel)->setTopic(topic); @@ -557,6 +582,15 @@ void IrcServerHandler::handle353(const QString &prefix, const QList // 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(); @@ -565,12 +599,11 @@ void IrcServerHandler::handle353(const QString &prefix, const QList nick = nick.mid(1); } - IrcUser *ircuser = network()->newIrcUser(nick); - ircuser->joinChannel(channelname); - - if(!mode.isNull()) - network()->ircChannel(channelname)->addUserMode(ircuser, mode); + nicks << nick; + modes << mode; } + + channel->joinIrcUsers(nicks, modes); } /* RPL_ENDOFWHOWAS - " :End of WHOWAS" */