X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=network%2Fmessages.h;fp=network%2Fmessages.h;h=566e0d41493acb54b0540e7686f0a8bad80a0efa;hp=0000000000000000000000000000000000000000;hb=46ec32173bb8e4fac0b6a161f9cce875875159a5;hpb=a975272aca8f0deb25c395532b189141979304e5 diff --git a/network/messages.h b/network/messages.h new file mode 100644 index 00000000..566e0d41 --- /dev/null +++ b/network/messages.h @@ -0,0 +1,85 @@ +/*************************************************************************** + * Copyright (C) 2005/06 by The Quassel Team * + * devel@quassel-irc.org * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef _MESSAGES_H_ +#define _MESSAGES_H_ + +#include +#include +#include + +class Message; + +typedef void (Message::* cmdhandler)(QStringList); + +/** + * This contains information that depends (solely) on the message type, such as the handler function and help texts. + * Most of these are defined at compile time, but more may be added at runtime. + */ +struct CmdType { + QString cmd; + QString cmdDescr; + QString args; + QString argsDescr; + cmdhandler handler; + +}; + +/** + * +*/ +class Message { + public: + uint type; + QString prefix; + QString cmd; + QStringList params; + + Message(QString cmd, QStringList args = 0); + + virtual ~Message() {}; + + static void init(); + //static registerCmd(); + //static unregisterCmd(); + + cmdhandler getCmdHandler(); + + void test1(QStringList); + void test2(QStringList); + + protected: + static QHash cmdTypes; +}; + + +/** This is only used to have a nice way for defining builtin commands. + * We create an array of these in builtin_cmds.cpp and read this to fill our + * command hash. + */ +struct BuiltinCmd { + QString cmd; + QString cmdDescr; + QString args; + QString argsDescr; + cmdhandler handler; +}; + +#endif