Quassel IRC  Pre-Release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
coreuserinputhandler.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005-2015 by the Quassel Project *
3  * devel@quassel-irc.org *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) version 3. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19  ***************************************************************************/
20 
21 #ifndef COREUSERINPUTHANDLER_H
22 #define COREUSERINPUTHANDLER_H
23 
24 #include "corebasichandler.h"
25 #include "corenetwork.h"
26 
27 class Cipher;
28 class Server;
29 
31 {
32  Q_OBJECT
33 
34 public:
35  CoreUserInputHandler(CoreNetwork *parent = 0);
36  inline CoreNetwork *coreNetwork() const { return qobject_cast<CoreNetwork *>(parent()); }
37 
38  void handleUserInput(const BufferInfo &bufferInfo, const QString &text);
39  int lastParamOverrun(const QString &cmd, const QList<QByteArray> &params);
40 
41 public slots:
42  void handleAway(const BufferInfo &bufferInfo, const QString &text);
43  void handleBan(const BufferInfo &bufferInfo, const QString &text);
44  void handleUnban(const BufferInfo &bufferInfo, const QString &text);
45  void handleCtcp(const BufferInfo &bufferInfo, const QString &text);
46  void handleDelkey(const BufferInfo &bufferInfo, const QString &text);
47  void handleDeop(const BufferInfo& bufferInfo, const QString &nicks);
48  void handleDehalfop(const BufferInfo& bufferInfo, const QString &nicks);
49  void handleDevoice(const BufferInfo& bufferInfo, const QString &nicks);
50  void handleInvite(const BufferInfo &bufferInfo, const QString &text);
51  void handleJoin(const BufferInfo &bufferInfo, const QString &text);
52  void handleKeyx(const BufferInfo &bufferInfo, const QString &text);
53  void handleKick(const BufferInfo &bufferInfo, const QString &text);
54  void handleKill(const BufferInfo &bufferInfo, const QString &text);
55  void handleList(const BufferInfo &bufferInfo, const QString &text);
56  void handleMe(const BufferInfo &bufferInfo, const QString &text);
57  void handleMode(const BufferInfo &bufferInfo, const QString &text);
58  void handleMsg(const BufferInfo &bufferInfo, const QString &text);
59  void handleNick(const BufferInfo &bufferInfo, const QString &text);
60  void handleNotice(const BufferInfo &bufferInfo, const QString &text);
61  void handleOper(const BufferInfo &bufferInfo, const QString &text);
62  void handleOp(const BufferInfo& bufferInfo, const QString &nicks);
63  void handleHalfop(const BufferInfo& bufferInfo, const QString &nicks);
64  void handlePart(const BufferInfo &bufferInfo, const QString &text);
65  void handlePing(const BufferInfo &bufferInfo, const QString &text);
66  void handlePrint(const BufferInfo &bufferInfo, const QString &text);
67  void handleQuery(const BufferInfo &bufferInfo, const QString &text);
68  void handleQuit(const BufferInfo &bufferInfo, const QString &text);
69  void handleQuote(const BufferInfo &bufferInfo, const QString &text);
70  void handleSay(const BufferInfo &bufferInfo, const QString &text);
71  void handleSetkey(const BufferInfo &bufferInfo, const QString &text);
72  void handleShowkey(const BufferInfo &bufferInfo, const QString &text);
73  void handleTopic(const BufferInfo &bufferInfo, const QString &text);
74  void handleVoice(const BufferInfo &bufferInfo, const QString &text);
75  void handleWait(const BufferInfo &bufferInfo, const QString &text);
76  void handleWho(const BufferInfo &bufferInfo, const QString &text);
77  void handleWhois(const BufferInfo &bufferInfo, const QString &text);
78  void handleWhowas(const BufferInfo &bufferInfo, const QString &text);
79 
80  void defaultHandler(QString cmd, const BufferInfo &bufferInfo, const QString &text);
81 
82  void issueQuit(const QString &reason);
83  void issueAway(const QString &msg, bool autoCheck = true);
84 
85 protected:
86  void timerEvent(QTimerEvent *event);
87 
88 private:
89  void doMode(const BufferInfo& bufferInfo, const QChar &addOrRemove, const QChar &mode, const QString &nickList);
90  void banOrUnban(const BufferInfo &bufferInfo, const QString &text, bool ban);
91  void putPrivmsg(const QString &target, const QString &message, std::function<QByteArray(const QString &, const QString &)> encodeFunc, Cipher *cipher = 0);
92 
93 #ifdef HAVE_QCA2
94  QByteArray encrypt(const QString &target, const QByteArray &message, bool *didEncrypt = 0) const;
95 #endif
96 
97  struct Command {
99  QString command;
100  Command(const BufferInfo &info, const QString &command) : bufferInfo(info), command(command) {}
101  Command() {}
102  };
103 
104  QHash<int, Command> _delayedCommands;
105 };
106 
107 
108 #endif