From: Manuel Nickschas Date: Sun, 15 Oct 2006 10:40:20 +0000 (+0000) Subject: (no commit message) X-Git-Tag: 0.1.0~288 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=46ec32173bb8e4fac0b6a161f9cce875875159a5 --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 8fa82df8..f04e5667 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,7 +27,7 @@ ENDIF(NOT BUILD_MONO AND NOT BUILD_CORE AND NOT BUILD_GUI) SET(quassel_mono_SRCS main/main_mono.cpp) SET(quassel_core_SRCS main/main_core.cpp) SET(quassel_RCCS images/icons.qrc) -SET(quassel_DIRS gui core) +SET(quassel_DIRS gui core network) # Build correct absolute paths for subdirs to include SET(SDIRS "") @@ -44,12 +44,13 @@ SET(QT_USE_QTXML true) SET(QT_DONT_USE_QTGUI true) # This is added later if GUI is requested INCLUDE(${QT_USE_FILE}) +ADD_SUBDIRECTORY(network) ADD_SUBDIRECTORY(core) QT4_ADD_RESOURCES(_RCCS ${quassel_RCCS}) IF(BUILD_CORE) ADD_EXECUTABLE(quasselcore ${quassel_core_SRCS} ${_RCCS}) - TARGET_LINK_LIBRARIES(quasselcore core ${QT_LIBRARIES}) + TARGET_LINK_LIBRARIES(quasselcore core network ${QT_LIBRARIES}) ENDIF(BUILD_CORE) IF(BUILD_GUI OR BUILD_MONO) # OK, now we need QtGui! @@ -62,7 +63,7 @@ IF(BUILD_GUI OR BUILD_MONO) # OK, now we need QtGui! IF(BUILD_MONO) ADD_SUBDIRECTORY(gui) ADD_EXECUTABLE(quassel ${quassel_mono_SRCS} ${_RCCS}) - TARGET_LINK_LIBRARIES(quassel gui core ${QT_LIBRARIES}) + TARGET_LINK_LIBRARIES(quassel gui core network ${QT_LIBRARIES}) ENDIF(BUILD_MONO) IF(BUILD_GUI) diff --git a/core/quassel.cpp b/core/quassel.cpp index eb9d236a..f7fe6b36 100644 --- a/core/quassel.cpp +++ b/core/quassel.cpp @@ -21,12 +21,14 @@ #include "quassel.h" #include "logger.h" #include "proxy.h" +#include "messages.h" #include #include void Quassel::init() { //initIconMap(); + Message::init(); } void Quassel::setLogger(Logger *) { diff --git a/main/main_mono.cpp b/main/main_mono.cpp index b935a128..6755a50e 100644 --- a/main/main_mono.cpp +++ b/main/main_mono.cpp @@ -28,6 +28,7 @@ #include "proxy.h" #include "mainwin.h" +#include "messages.h" int main(int argc, char **argv) { @@ -35,6 +36,11 @@ int main(int argc, char **argv) { Logger *logger = new Logger(); Quassel::setLogger(logger); + Message *m = new Message("admin"); + //m->*(m->getCmdHandler())(QStringList("")); + (m->*(m->getCmdHandler()))(QStringList()); + exit(0); + QApplication app(argc, argv); QApplication::setOrganizationDomain("quassel-irc.org"); diff --git a/network/CMakeLists.txt b/network/CMakeLists.txt new file mode 100644 index 00000000..d8f9219f --- /dev/null +++ b/network/CMakeLists.txt @@ -0,0 +1,6 @@ +SET(network_SRCS messages.cpp builtin_cmds.cpp builtin_handlers.cpp server.cpp) +SET(network_HDRS messages.h server.h) +SET(network_MOCS ) + +QT4_WRAP_CPP(_MOC ${network_MOCS}) +ADD_LIBRARY(network ${_MOC} ${network_SRCS} ${network_HDRS}) diff --git a/network/builtin_cmds.cpp b/network/builtin_cmds.cpp new file mode 100644 index 00000000..3bffb1f0 --- /dev/null +++ b/network/builtin_cmds.cpp @@ -0,0 +1,40 @@ +/*************************************************************************** + * 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. * + ***************************************************************************/ + +#include +#include "messages.h" + + +#define _(str) QT_TR_NOOP(str) + +/** Defines the message codes according to RFCs 1495/281x. + * Named commands have a negative enum value. + */ + +BuiltinCmd builtins[] = { + { _("admin"), _("Get information about the administrator of a server."), + _("[server]"), _("server: Server"), + &Message::test1 }, + + + { 0, 0, 0, 0, 0 } +}; + + diff --git a/network/builtin_handlers.cpp b/network/builtin_handlers.cpp new file mode 100644 index 00000000..bb9e8d10 --- /dev/null +++ b/network/builtin_handlers.cpp @@ -0,0 +1,22 @@ +/*************************************************************************** + * 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. * + ***************************************************************************/ + +#include "messages.h" + diff --git a/network/messages.cpp b/network/messages.cpp new file mode 100644 index 00000000..e0fc29b3 --- /dev/null +++ b/network/messages.cpp @@ -0,0 +1,71 @@ +/*************************************************************************** + * 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. * + ***************************************************************************/ + +#include "messages.h" +#include + +extern BuiltinCmd builtins[]; + +QHash Message::cmdTypes; + +Message::Message(QString _cmd, QStringList args) { + cmd = _cmd; qDebug() << "cmd: " << cmd; + params = args; +} + +void Message::init() { + // Register builtin commands + for(int i = 0; ; i++) { + if(!builtins[i].handler) break; + CmdType c; + c.cmd = builtins[i].cmd.toLower(); + c.cmdDescr = builtins[i].cmdDescr; + c.args = builtins[i].args; + c.argsDescr = builtins[i].argsDescr; + c.handler = builtins[i].handler; + cmdTypes.insert(c.cmd, c); + } + +} + +cmdhandler Message::getCmdHandler() { + CmdType c = cmdTypes[cmd]; + if(c.handler) return c.handler; + qDebug() << "No handler defined for " << cmd << "!"; + return 0; +} + +/* +void Message::parseParams(QString str) { + QString left = str.section(':', 0, 0); + QString trailing = str.section(':', 1); + if(left.size()) { + params << left.split(' ', QString::SkipEmptyParts); + } + if(trailing.size()) { + params << trailing; + } + qDebug() << params; + +} +*/ +void Message::test1(QStringList foo) { qDebug() << "Test 1! " << cmd; }; + +void Message::test2(QStringList bar) { qDebug() << "Test 2!"; }; 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 diff --git a/network/msgcodes.h b/network/msgcodes.h new file mode 100644 index 00000000..2ac196b9 --- /dev/null +++ b/network/msgcodes.h @@ -0,0 +1,29 @@ +/*************************************************************************** + * 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 _MSGCODES_H_ +#define _MSGCODES_H_ + + + + + + +#endif diff --git a/network/server.cpp b/network/server.cpp new file mode 100644 index 00000000..e204ef82 --- /dev/null +++ b/network/server.cpp @@ -0,0 +1,19 @@ +/*************************************************************************** + * 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. * + ***************************************************************************/ diff --git a/network/server.h b/network/server.h new file mode 100644 index 00000000..cc46899a --- /dev/null +++ b/network/server.h @@ -0,0 +1,43 @@ +/*************************************************************************** + * 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 _SERVER_H_ +#define _SERVER_H_ + +#include +#include + +class Server { + Q_OBJECT + + + + private: + +}; + +class Connection : public QThread { + + + +}; + + +#endif diff --git a/templates/cpp b/templates/cpp new file mode 100644 index 00000000..e204ef82 --- /dev/null +++ b/templates/cpp @@ -0,0 +1,19 @@ +/*************************************************************************** + * 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. * + ***************************************************************************/ diff --git a/templates/h b/templates/h new file mode 100644 index 00000000..5c252274 --- /dev/null +++ b/templates/h @@ -0,0 +1,20 @@ +/*************************************************************************** + * 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. * + ***************************************************************************/ +