(no commit message)
authorManuel Nickschas <sputnick@quassel-irc.org>
Sun, 15 Oct 2006 10:40:20 +0000 (10:40 +0000)
committerManuel Nickschas <sputnick@quassel-irc.org>
Sun, 15 Oct 2006 10:40:20 +0000 (10:40 +0000)
13 files changed:
CMakeLists.txt
core/quassel.cpp
main/main_mono.cpp
network/CMakeLists.txt [new file with mode: 0644]
network/builtin_cmds.cpp [new file with mode: 0644]
network/builtin_handlers.cpp [new file with mode: 0644]
network/messages.cpp [new file with mode: 0644]
network/messages.h [new file with mode: 0644]
network/msgcodes.h [new file with mode: 0644]
network/server.cpp [new file with mode: 0644]
network/server.h [new file with mode: 0644]
templates/cpp [new file with mode: 0644]
templates/h [new file with mode: 0644]

index 8fa82df..f04e566 100644 (file)
@@ -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)
index eb9d236..f7fe6b3 100644 (file)
 #include "quassel.h"
 #include "logger.h"
 #include "proxy.h"
+#include "messages.h"
 
 #include <QString>
 #include <QDomDocument>
 
 void Quassel::init() {
   //initIconMap();
+  Message::init();
 }
 
 void Quassel::setLogger(Logger *) {
index b935a12..6755a50 100644 (file)
@@ -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 (file)
index 0000000..d8f9219
--- /dev/null
@@ -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 (file)
index 0000000..3bffb1f
--- /dev/null
@@ -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 <QtGlobal>
+#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 (file)
index 0000000..bb9e8d1
--- /dev/null
@@ -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 (file)
index 0000000..e0fc29b
--- /dev/null
@@ -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 <QtDebug>
+
+extern BuiltinCmd builtins[];
+
+QHash<QString, CmdType> 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 (file)
index 0000000..566e0d4
--- /dev/null
@@ -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 <QHash>
+#include <QString>
+#include <QStringList>
+
+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<QString, CmdType> 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 (file)
index 0000000..2ac196b
--- /dev/null
@@ -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 (file)
index 0000000..e204ef8
--- /dev/null
@@ -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 (file)
index 0000000..cc46899
--- /dev/null
@@ -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 <QtCore>
+#include <QtNetwork>
+
+class Server {
+  Q_OBJECT
+
+
+
+  private:
+
+};
+
+class Connection : public QThread {
+
+
+
+};
+
+
+#endif
diff --git a/templates/cpp b/templates/cpp
new file mode 100644 (file)
index 0000000..e204ef8
--- /dev/null
@@ -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 (file)
index 0000000..5c25227
--- /dev/null
@@ -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.             *
+ ***************************************************************************/
+