1 /***************************************************************************
2 * Copyright (C) 2005/06 by The Quassel 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) any later version. *
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 ***************************************************************************/
24 extern BuiltinCmd builtins[];
26 QHash<QString, CmdType> Message::cmdTypes;
28 Message::Message(QString _cmd, QStringList args) {
29 cmd = _cmd; qDebug() << "cmd: " << cmd;
33 void Message::init() {
34 // Register builtin commands
35 for(int i = 0; ; i++) {
36 if(!builtins[i].handler) break;
38 c.cmd = builtins[i].cmd.toLower();
39 c.cmdDescr = builtins[i].cmdDescr;
40 c.args = builtins[i].args;
41 c.argsDescr = builtins[i].argsDescr;
42 c.handler = builtins[i].handler;
43 cmdTypes.insert(c.cmd, c);
48 cmdhandler Message::getCmdHandler() {
49 CmdType c = cmdTypes[cmd];
50 if(c.handler) return c.handler;
51 qDebug() << "No handler defined for " << cmd << "!";
56 void Message::parseParams(QString str) {
57 QString left = str.section(':', 0, 0);
58 QString trailing = str.section(':', 1);
60 params << left.split(' ', QString::SkipEmptyParts);
69 void Message::test1(QStringList foo) { qDebug() << "Test 1! " << cmd; };
71 void Message::test2(QStringList bar) { qDebug() << "Test 2!"; };