X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fclient%2Fclientuserinputhandler.cpp;h=3ecf3c420d43e52577b05618036366d722771d18;hp=296fc1cb344dc9089fb3088d6b3b28be587d8cfa;hb=b619ad78665f63b798389d0f7a33a22da7d93718;hpb=bc00bc7bc6137f5f14e53fbaac6c4a0ccdffd8a3 diff --git a/src/client/clientuserinputhandler.cpp b/src/client/clientuserinputhandler.cpp index 296fc1cb..3ecf3c42 100644 --- a/src/client/clientuserinputhandler.cpp +++ b/src/client/clientuserinputhandler.cpp @@ -20,13 +20,18 @@ #include +#include "buffermodel.h" #include "client.h" +#include "clientaliasmanager.h" #include "clientuserinputhandler.h" #include "clientsettings.h" +#include "execwrapper.h" #include "ircuser.h" #include "network.h" -ClientUserInputHandler::ClientUserInputHandler(QObject *parent) : QObject(parent) { +ClientUserInputHandler::ClientUserInputHandler(QObject *parent) +: QObject(parent) +{ TabCompletionSettings s; s.notify("CompletionSuffix", this, SLOT(completionSuffixChanged(QVariant))); completionSuffixChanged(s.completionSuffix()); @@ -41,16 +46,39 @@ void ClientUserInputHandler::completionSuffixChanged(const QVariant &v) { // this would be the place for a client-side hook void ClientUserInputHandler::handleUserInput(const BufferInfo &bufferInfo, const QString &msg) { - // check if we addressed a user and update its timestamp in that case - if(bufferInfo.type() == BufferInfo::ChannelBuffer) { - if(!msg.startsWith('/')) { - if(_nickRx.indexIn(msg) == 0) { - const Network *net = Client::network(bufferInfo.networkId()); - IrcUser *user = net ? net->ircUser(_nickRx.cap(1)) : 0; - if(user) - user->setLastSpokenTo(bufferInfo.bufferId(), QDateTime::currentDateTime().toUTC()); + + if(!msg.startsWith('/')) { + if(_nickRx.indexIn(msg) == 0) { + const Network *net = Client::network(bufferInfo.networkId()); + IrcUser *user = net ? net->ircUser(_nickRx.cap(1)) : 0; + if(user) + user->setLastSpokenTo(bufferInfo.bufferId(), QDateTime::currentDateTime().toUTC()); + } + } + + AliasManager::CommandList clist = Client::aliasManager()->processInput(bufferInfo, msg); + + for(int i = 0; i < clist.count(); i++) { + QString cmd = clist.at(i).second.section(' ', 0, 0).remove(0, 1).toUpper(); + QString args = clist.at(i).second.section(' ', 1); + if(cmd == "EXEC") + handleExec(clist.at(i).first, args); + else { + if(cmd == "JOIN" || cmd == "QUERY") { + BufferId newBufId = Client::networkModel()->bufferId(bufferInfo.networkId(), args.section(' ', 0, 0)); + if(!newBufId.isValid()) { + Client::bufferModel()->switchToBufferAfterCreation(bufferInfo.networkId(), args.section(' ', 0, 0)); + } + else { + Client::bufferModel()->switchToBuffer(newBufId); + } } + emit sendInput(clist.at(i).first, clist.at(i).second); } } - emit sendInput(bufferInfo, msg); +} + +void ClientUserInputHandler::handleExec(const BufferInfo &bufferInfo, const QString &execString) { + ExecWrapper *exec = new ExecWrapper(this); // gets suicidal when it's done + exec->start(bufferInfo, execString); }