qa: Remove lots of superfluous semicolons
[quassel.git] / src / core / corebasichandler.h
1 /***************************************************************************
2  *   Copyright (C) 2005-2018 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 COREBASICHANDLER_H
22 #define COREBASICHANDLER_H
23
24 #include <QString>
25 #include <QStringList>
26
27 #include "basichandler.h"
28 #include "message.h"
29
30 #include "corenetwork.h"
31
32 class CoreSession;
33
34 class CoreBasicHandler : public BasicHandler
35 {
36     Q_OBJECT
37
38 public:
39     CoreBasicHandler(CoreNetwork *parent = 0);
40
41     QString serverDecode(const QByteArray &string);
42     QStringList serverDecode(const QList<QByteArray> &stringlist);
43     QString channelDecode(const QString &bufferName, const QByteArray &string);
44     QStringList channelDecode(const QString &bufferName, const QList<QByteArray> &stringlist);
45     QString userDecode(const QString &userNick, const QByteArray &string);
46     QStringList userDecode(const QString &userNick, const QList<QByteArray> &stringlist);
47
48     QByteArray serverEncode(const QString &string);
49     QList<QByteArray> serverEncode(const QStringList &stringlist);
50     QByteArray channelEncode(const QString &bufferName, const QString &string);
51     QList<QByteArray> channelEncode(const QString &bufferName, const QStringList &stringlist);
52     QByteArray userEncode(const QString &userNick, const QString &string);
53     QList<QByteArray> userEncode(const QString &userNick, const QStringList &stringlist);
54
55 signals:
56     void displayMsg(Message::Type, BufferInfo::Type, const QString &target, const QString &text, const QString &sender = "", Message::Flags flags = Message::None);
57
58     /**
59      * Sends the raw (encoded) line, adding to the queue if needed, optionally with higher priority.
60      *
61      * @see CoreNetwork::putRawLine()
62      */
63     void putRawLine(const QByteArray &msg, const bool prepend = false);
64
65     /**
66      * Sends the command with encoded parameters, with optional prefix or high priority.
67      *
68      * @see CoreNetwork::putCmd(const QString &cmd, const QList<QByteArray> &params, const QByteArray &prefix = QByteArray(), const bool prepend = false)
69      */
70     void putCmd(const QString &cmd, const QList<QByteArray> &params, const QByteArray &prefix = QByteArray(), const bool prepend = false);
71
72     /**
73      * Sends the command for each set of encoded parameters, with optional prefix or high priority.
74      *
75      * @see CoreNetwork::putCmd(const QString &cmd, const QList<QList<QByteArray>> &params, const QByteArray &prefix = QByteArray(), const bool prepend = false)
76      */
77     void putCmd(const QString &cmd, const QList<QList<QByteArray>> &params, const QByteArray &prefix = QByteArray(), const bool prepend = false);
78
79 protected:
80     /**
81      * Sends the command with one parameter, with optional prefix or high priority.
82      *
83      * @param[in] cmd      Command to send, ignoring capitalization
84      * @param[in] param    Parameter for the command, encoded within a QByteArray
85      * @param[in] prefix   Optional command prefix
86      * @param[in] prepend
87      * @parmblock
88      * If true, the command is prepended into the start of the queue, otherwise, it's appended to
89      * the end.  This should be used sparingly, for if either the core or the IRC server cannot
90      * maintain PING/PONG replies, the other side will close the connection.
91      * @endparmblock
92      */
93     void putCmd(const QString &cmd, const QByteArray &param, const QByteArray &prefix = QByteArray(), const bool prepend = false);
94
95     inline CoreNetwork *network() const { return _network; }
96     inline CoreSession *coreSession() const { return _network->coreSession(); }
97
98     BufferInfo::Type typeByTarget(const QString &target) const;
99
100 private:
101     CoreNetwork *_network;
102 };
103
104
105 #endif