1 /***************************************************************************
2 * Copyright (C) 2005-08 by the Quassel Project *
3 * devel@quassel-irc.org *
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. *
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. *
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 ***************************************************************************/
21 #ifndef _BASICHANDLER_H_
22 #define _BASICHANDLER_H_
26 #include <QStringList>
28 #include <QGenericArgument>
32 #include "networkconnection.h"
36 class BasicHandler : public QObject {
40 BasicHandler(NetworkConnection *parent = 0);
42 QStringList providesHandlers();
44 QString serverDecode(const QByteArray &string);
45 QStringList serverDecode(const QList<QByteArray> &stringlist);
46 QString channelDecode(const QString &bufferName, const QByteArray &string);
47 QStringList channelDecode(const QString &bufferName, const QList<QByteArray> &stringlist);
48 QString userDecode(const QString &userNick, const QByteArray &string);
49 QStringList userDecode(const QString &userNick, const QList<QByteArray> &stringlist);
51 QByteArray serverEncode(const QString &string);
52 QList<QByteArray> serverEncode(const QStringList &stringlist);
53 QByteArray channelEncode(const QString &bufferName, const QString &string);
54 QList<QByteArray> channelEncode(const QString &bufferName, const QStringList &stringlist);
55 QByteArray userEncode(const QString &userNick, const QString &string);
56 QList<QByteArray> userEncode(const QString &userNick, const QStringList &stringlist);
59 void displayMsg(Message::Type, BufferInfo::Type, QString target, QString text, QString sender = "", Message::Flags flags = Message::None);
60 void putCmd(const QString &cmd, const QList<QByteArray> ¶ms, const QByteArray &prefix = QByteArray());
61 void putRawLine(const QByteArray &msg);
64 void displayMsg(Message::Type, QString target, QString text, QString sender = "", Message::Flags flags = Message::None);
65 void putCmd(const QString &cmd, const QByteArray ¶m, const QByteArray &prefix = QByteArray());
67 virtual void handle(const QString &member, QGenericArgument val0 = QGenericArgument(0),
68 QGenericArgument val1 = QGenericArgument(), QGenericArgument val2 = QGenericArgument(),
69 QGenericArgument val3 = QGenericArgument(), QGenericArgument val4 = QGenericArgument(),
70 QGenericArgument val5 = QGenericArgument(), QGenericArgument val6 = QGenericArgument(),
71 QGenericArgument val7 = QGenericArgument(), QGenericArgument val8 = QGenericArgument());
74 inline Network *network() const { return _networkConnection->network(); }
75 inline NetworkConnection *networkConnection() const { return _networkConnection; }
76 inline CoreSession *coreSession() const { return _networkConnection->coreSession(); }
78 BufferInfo::Type typeByTarget(const QString &target) const;
81 const QHash<QString, int> &handlerHash();
82 QHash<QString, int> _handlerHash;
84 NetworkConnection *_networkConnection;