1 /***************************************************************************
2 * Copyright (C) 2005-07 by the Quassel IRC Team *
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 ***************************************************************************/
20 #include "basichandler.h"
22 #include <QMetaMethod>
26 BasicHandler::BasicHandler(Server *parent)
30 connect(this, SIGNAL(displayMsg(Message::Type, QString, QString, QString, quint8)),
31 server, SIGNAL(displayMsg(Message::Type, QString, QString, QString, quint8)));
33 connect(this, SIGNAL(putCmd(QString, QStringList, QString)),
34 server, SLOT(putCmd(QString, QStringList, QString)));
36 connect(this, SIGNAL(putRawLine(QString)),
37 server, SLOT(putRawLine(QString)));
40 QStringList BasicHandler::providesHandlers() const {
42 for(int i=0; i < metaObject()->methodCount(); i++) {
43 QString methodSignature(metaObject()->method(i).signature());
44 if(!methodSignature.startsWith("handle"))
47 methodSignature = methodSignature.section('(',0,0); // chop the attribute list
48 methodSignature = methodSignature.mid(6); // strip "handle"
49 handlers << methodSignature;
55 void BasicHandler::handle(const QString &member, const QGenericArgument &val0,
56 const QGenericArgument &val1, const QGenericArgument &val2,
57 const QGenericArgument &val3, const QGenericArgument &val4,
58 const QGenericArgument &val5, const QGenericArgument &val6,
59 const QGenericArgument &val7, const QGenericArgument &val8) {
61 // Now we try to find a handler for this message. BTW, I do love the Trolltech guys ;-)
62 QString handler = member.toLower();
63 handler[0] = handler[0].toUpper();
64 handler = "handle" + handler;
66 if(!QMetaObject::invokeMethod(this, handler.toAscii(), val0, val1, val2, val3, val4, val5, val6, val7, val8))
67 // Ok. Default handler it is.
68 QMetaObject::invokeMethod(this, "defaultHandler", Q_ARG(QString, member), val0, val1, val2, val3, val4, val5, val6, val7, val8);
72 // ====================
74 // ====================
75 NetworkInfo *BasicHandler::networkInfo() const {
76 return server->networkInfo();