This provides a client-side hook for every input that goes through via input line
or Client::userInput(). For now, this checks if we addressed an IrcUser and updates its
lastSpokenTo timestamp.
clientirclisthelper.cpp
clientsettings.cpp
clientsyncer.cpp
+ clientuserinputhandler.cpp
irclistmodel.cpp
messagefilter.cpp
messagemodel.cpp
clientcoreinfo.h
clientidentity.h
clientirclisthelper.h
+ clientuserinputhandler.h
clientsyncer.h
irclistmodel.h
messagefilter.h
#include "clientbufferviewmanager.h"
#include "clientirclisthelper.h"
#include "clientidentity.h"
+#include "clientuserinputhandler.h"
#include "ircchannel.h"
#include "ircuser.h"
#include "message.h"
_backlogManager(new ClientBacklogManager(this)),
_bufferViewManager(0),
_ircListHelper(new ClientIrcListHelper(this)),
+ _inputHandler(new ClientUserInputHandler(this)),
_messageModel(0),
_messageProcessor(0),
_connectedToCore(false),
p->attachSlot(SIGNAL(displayStatusMsg(QString, QString)), this, SLOT(recvStatusMsg(QString, QString)));
p->attachSlot(SIGNAL(bufferInfoUpdated(BufferInfo)), _networkModel, SLOT(bufferUpdated(BufferInfo)));
- p->attachSignal(this, SIGNAL(sendInput(BufferInfo, QString)));
+ p->attachSignal(inputHandler(), SIGNAL(sendInput(BufferInfo, QString)));
p->attachSignal(this, SIGNAL(requestNetworkStates()));
p->attachSignal(this, SIGNAL(requestCreateIdentity(const Identity &, const QVariantMap &)), SIGNAL(createIdentity(const Identity &, const QVariantMap &)));
}
/*** ***/
-void Client::userInput(BufferInfo bufferInfo, QString message) {
- emit instance()->sendInput(bufferInfo, message);
+void Client::userInput(const BufferInfo &bufferInfo, const QString &message) {
+ inputHandler()->handleUserInput(bufferInfo, message);
}
/*** core connection stuff ***/
class BufferModel;
class BufferSyncer;
class ClientBacklogManager;
+class ClientBufferViewManager;
class ClientIrcListHelper;
class ClientSyncer;
-class ClientBufferViewManager;
+class ClientUserInputHandler;
class IrcUser;
class IrcChannel;
class SignalProxy;
static inline ClientBacklogManager *backlogManager() { return instance()->_backlogManager; }
static inline ClientIrcListHelper *ircListHelper() { return instance()->_ircListHelper; }
static inline ClientBufferViewManager *bufferViewManager() { return instance()->_bufferViewManager; }
+ static inline ClientUserInputHandler *inputHandler() { return instance()->_inputHandler; }
static AccountId currentCoreAccount();
static bool isSynced();
static inline bool internalCore() { return instance()->_internalCore; }
- static void userInput(BufferInfo bufferInfo, QString message);
+ static void userInput(const BufferInfo &bufferInfo, const QString &message);
static void setBufferLastSeenMsg(BufferId id, const MsgId &msgId); // this is synced to core and other clients
static void removeBuffer(BufferId id);
static inline void registerClientSyncer(ClientSyncer *syncer) { emit instance()->newClientSyncer(syncer); }
signals:
- void sendInput(BufferInfo, QString message);
void requestNetworkStates();
void showConfigWizard(const QVariantMap &coredata);
void logUpdated(const QString &msg);
public slots:
- //void selectBuffer(Buffer *);
-
void disconnectFromCore();
void bufferRemoved(BufferId bufferId);
ClientBacklogManager *_backlogManager;
ClientBufferViewManager *_bufferViewManager;
ClientIrcListHelper *_ircListHelper;
+ ClientUserInputHandler *_inputHandler;
MessageModel *_messageModel;
AbstractMessageProcessor *_messageProcessor;
--- /dev/null
+/***************************************************************************
+* Copyright (C) 2005-09 by the Quassel Project *
+* devel@quassel-irc.org *
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) version 3. *
+* *
+* This program is distributed in the hope that it will be useful, *
+* but WITHOUT ANY WARRANTY; without even the implied warranty of *
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+* GNU General Public License for more details. *
+* *
+* You should have received a copy of the GNU General Public License *
+* along with this program; if not, write to the *
+* Free Software Foundation, Inc., *
+* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+***************************************************************************/
+
+#include <QDateTime>
+
+#include "client.h"
+#include "clientuserinputhandler.h"
+#include "clientsettings.h"
+#include "ircuser.h"
+#include "network.h"
+
+ClientUserInputHandler::ClientUserInputHandler(QObject *parent) : QObject(parent) {
+ NickCompletionSettings s;
+ s.notify("CompletionSuffix", this, SLOT(completionSuffixChanged(QVariant)));
+ completionSuffixChanged(s.completionSuffix());
+}
+
+void ClientUserInputHandler::completionSuffixChanged(const QVariant &v) {
+ QString suffix = v.toString();
+ QString letter = "A-Za-z";
+ QString special = "\x5b-\x60\x7b-\x7d";
+ _nickRx = QRegExp(QString("^([%1%2][%1%2\\d-]*)%3").arg(letter, special, suffix).trimmed());
+}
+
+// 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());
+ }
+ }
+ }
+ emit sendInput(bufferInfo, msg);
+}
--- /dev/null
+/***************************************************************************
+* Copyright (C) 2005-09 by the Quassel Project *
+* devel@quassel-irc.org *
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) version 3. *
+* *
+* This program is distributed in the hope that it will be useful, *
+* but WITHOUT ANY WARRANTY; without even the implied warranty of *
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+* GNU General Public License for more details. *
+* *
+* You should have received a copy of the GNU General Public License *
+* along with this program; if not, write to the *
+* Free Software Foundation, Inc., *
+* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+***************************************************************************/
+
+#ifndef CLIENTUSERINPUTHANDLER_H_
+#define CLIENTUSERINPUTHANDLER_H_
+
+#include "bufferinfo.h"
+
+class ClientUserInputHandler : public QObject {
+ Q_OBJECT
+
+public:
+ ClientUserInputHandler(QObject *parent = 0);
+
+public slots:
+ void handleUserInput(const BufferInfo &bufferInfo, const QString &msg);
+
+signals:
+ void sendInput(const BufferInfo &, const QString &);
+
+private slots:
+ void completionSuffixChanged(const QVariant &);
+
+private:
+ QRegExp _nickRx;
+};
+
+#endif