X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fcore%2Fuserinputhandler.cpp;h=1bd29bd3af368686c733b7ef44dad4bba36a3a1a;hb=a33e42aee121185f479667b2104a15fc2033762e;hp=618bc8da34e85819f247a4435b15b6e10b35723e;hpb=eb72c2646d187cf4f79296bf57f5973ab801a515;p=quassel.git diff --git a/src/core/userinputhandler.cpp b/src/core/userinputhandler.cpp index 618bc8da..1bd29bd3 100644 --- a/src/core/userinputhandler.cpp +++ b/src/core/userinputhandler.cpp @@ -55,7 +55,19 @@ void UserInputHandler::handleUserInput(const BufferInfo &bufferInfo, const QStri void UserInputHandler::handleAway(const BufferInfo &bufferInfo, const QString &msg) { Q_UNUSED(bufferInfo) - putCmd("AWAY", serverEncode(msg)); + + QString awayMsg = msg; + IrcUser *me = network()->me(); + + // if there is no message supplied we have to check if we are already away or not + if(msg.isEmpty()) { + if(me && !me->isAway()) + awayMsg = networkConnection()->identity()->awayReason(); + } + if(me) + me->setAwayMessage(awayMsg); + + putCmd("AWAY", serverEncode(awayMsg)); } void UserInputHandler::handleBan(const BufferInfo &bufferInfo, const QString &msg) { @@ -92,7 +104,6 @@ void UserInputHandler::handleBan(const BufferInfo &bufferInfo, const QString &ms } QString banMsg = QString("MODE %1 +b %2").arg(banChannel).arg(banUser); - qDebug() << banMsg; emit putRawLine(serverEncode(banMsg)); } @@ -162,13 +173,16 @@ void UserInputHandler::handleJoin(const BufferInfo &bufferInfo, const QString &m void UserInputHandler::handleKick(const BufferInfo &bufferInfo, const QString &msg) { QString nick = msg.section(' ', 0, 0, QString::SectionSkipEmpty); QString reason = msg.section(' ', 1, -1, QString::SectionSkipEmpty).trimmed(); - if(reason.isEmpty()) reason = networkConnection()->identity()->kickReason(); + if(reason.isEmpty()) + reason = networkConnection()->identity()->kickReason(); + QList params; params << serverEncode(bufferInfo.bufferName()) << serverEncode(nick) << channelEncode(bufferInfo.bufferName(), reason); emit putCmd("KICK", params); } void UserInputHandler::handleKill(const BufferInfo &bufferInfo, const QString &msg) { + Q_UNUSED(bufferInfo) QString nick = msg.section(' ', 0, 0, QString::SectionSkipEmpty); QString pass = msg.section(' ', 1, -1, QString::SectionSkipEmpty); QList params; @@ -182,7 +196,6 @@ void UserInputHandler::handleList(const BufferInfo &bufferInfo, const QString &m emit putCmd("LIST", serverEncode(msg.split(' ', QString::SkipEmptyParts))); } - void UserInputHandler::handleMe(const BufferInfo &bufferInfo, const QString &msg) { if(bufferInfo.bufferName().isEmpty()) return; // server buffer networkConnection()->ctcpHandler()->query(bufferInfo.bufferName(), "ACTION", msg); @@ -191,8 +204,14 @@ void UserInputHandler::handleMe(const BufferInfo &bufferInfo, const QString &msg void UserInputHandler::handleMode(const BufferInfo &bufferInfo, const QString &msg) { Q_UNUSED(bufferInfo) + + QStringList params = msg.split(' ', QString::SkipEmptyParts); + // if the first argument is neither a channel nor us (user modes are only to oneself) the current buffer is assumed to be the target + if(!params.isEmpty() && !network()->isChannelName(params[0]) && !network()->isMyNick(params[0])) + params.prepend(bufferInfo.bufferName()); + // TODO handle correct encoding for buffer modes (channelEncode()) - emit putCmd("MODE", serverEncode(msg.split(' ', QString::SkipEmptyParts))); + emit putCmd("MODE", serverEncode(params)); } // TODO: show privmsgs @@ -223,12 +242,27 @@ void UserInputHandler::handleOp(const BufferInfo &bufferInfo, const QString &msg } void UserInputHandler::handleOper(const BufferInfo &bufferInfo, const QString &msg) { + Q_UNUSED(bufferInfo) emit putRawLine(serverEncode(QString("OPER %1").arg(msg))); } void UserInputHandler::handlePart(const BufferInfo &bufferInfo, const QString &msg) { QList params; - params << serverEncode(bufferInfo.bufferName()) << channelEncode(bufferInfo.bufferName(), msg); + QString partReason; + + // msg might contain either a channel name and/or a reaon, so we have to check if the first word is a known channel + QString channelName = msg.section(' ', 0, 0); + if(channelName.isEmpty() || !network()->ircChannel(channelName)) { + channelName = bufferInfo.bufferName(); + partReason = msg; + } else { + partReason = msg.mid(channelName.length() + 1); + } + + if(partReason.isEmpty()) + partReason = networkConnection()->identity()->partReason(); + + params << serverEncode(channelName) << channelEncode(bufferInfo.bufferName(), partReason); emit putCmd("PART", params); } @@ -246,7 +280,15 @@ void UserInputHandler::handleQuery(const BufferInfo &bufferInfo, const QString & void UserInputHandler::handleQuit(const BufferInfo &bufferInfo, const QString &msg) { Q_UNUSED(bufferInfo) - emit putCmd("QUIT", serverEncode(msg)); + + QString quitReason; + if(msg.isEmpty()) + quitReason = networkConnection()->identity()->quitReason(); + else + quitReason = msg; + + emit putCmd("QUIT", serverEncode(quitReason)); + networkConnection()->disconnectFromIrc(); } void UserInputHandler::handleQuote(const BufferInfo &bufferInfo, const QString &msg) {