Emit a new signal CoreSession::networkDisconnected(NetworkId)
[quassel.git] / src / core / corebasichandler.h
1 /***************************************************************************
2  *   Copyright (C) 2005-10 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  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, 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   Q_OBJECT
36
37 public:
38   CoreBasicHandler(CoreNetwork *parent = 0);
39
40   QString serverDecode(const QByteArray &string);
41   QStringList serverDecode(const QList<QByteArray> &stringlist);
42   QString channelDecode(const QString &bufferName, const QByteArray &string);
43   QStringList channelDecode(const QString &bufferName, const QList<QByteArray> &stringlist);
44   QString userDecode(const QString &userNick, const QByteArray &string);
45   QStringList userDecode(const QString &userNick, const QList<QByteArray> &stringlist);
46
47   QByteArray serverEncode(const QString &string);
48   QList<QByteArray> serverEncode(const QStringList &stringlist);
49   QByteArray channelEncode(const QString &bufferName, const QString &string);
50   QList<QByteArray> channelEncode(const QString &bufferName, const QStringList &stringlist);
51   QByteArray userEncode(const QString &userNick, const QString &string);
52   QList<QByteArray> userEncode(const QString &userNick, const QStringList &stringlist);
53
54 signals:
55   void displayMsg(Message::Type, BufferInfo::Type, const QString &target, const QString &text, const QString &sender = "", Message::Flags flags = Message::None);
56   void putCmd(const QString &cmd, const QList<QByteArray> &params, const QByteArray &prefix = QByteArray());
57   void putRawLine(const QByteArray &msg);
58
59 protected:
60   void displayMsg(Message::Type, QString target, const QString &text, const QString &sender = "", Message::Flags flags = Message::None);
61   void putCmd(const QString &cmd, const QByteArray &param, const QByteArray &prefix = QByteArray());
62
63   inline CoreNetwork *network() const { return _network; }
64   inline CoreSession *coreSession() const { return _network->coreSession(); }
65
66   BufferInfo::Type typeByTarget(const QString &target) const;
67
68 private:
69   CoreNetwork *_network;
70 };
71 #endif