From a975272aca8f0deb25c395532b189141979304e5 Mon Sep 17 00:00:00 2001 From: Manuel Nickschas Date: Mon, 10 Jul 2006 13:40:46 +0000 Subject: [PATCH] New Build System --- CMakeLists.txt | 87 ++++++++++++++++++++++++--------------------- core/CMakeLists.txt | 4 +-- core/core.cpp | 38 ++++++++++++++++++++ core/core.h | 41 +++++++++++++++++++++ core/proxy.cpp | 54 ++++++++++++++++++++++++++++ core/proxy.h | 51 ++++++++++++++++++++++++++ core/quassel.cpp | 12 ++++--- core/quassel.h | 5 ++- gui/CMakeLists.txt | 3 +- gui/serverlist.cpp | 11 +++--- main/main_core.cpp | 51 ++++++++++++++++++++++++++ main/main_mono.cpp | 15 ++++++++ 12 files changed, 316 insertions(+), 56 deletions(-) create mode 100644 core/core.cpp create mode 100644 core/core.h create mode 100644 core/proxy.cpp create mode 100644 core/proxy.h create mode 100644 main/main_core.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 59487d1c..8fa82df8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,40 +3,29 @@ PROJECT(Quassel) # CMAKE_MINIMUM_REQUIRED(VERSION 2.4.2) # Select if Quassel should be built in client, server or monolithic mode -SET(BUILD "mono" CACHE STRING "Defines which Quassel parts are to be built. Can contain 'server', 'client' and/or 'monolithic' (which is the default).") -SET(BUILD_SERVER ) -SET(BUILD_CLIENT ) +SET(BUILD "mono" CACHE STRING "Defines which Quassel parts are to be built. Can contain 'core', 'gui' and/or 'monolithic' (which is the default).") +SET(BUILD_CORE ) +SET(BUILD_GUI ) SET(BUILD_MONO ) -IF(BUILD MATCHES "server") - SET(BUILD_SERVER true) - MESSAGE(STATUS "Building Quassel server.") -ENDIF(BUILD MATCHES "server") -IF(BUILD MATCHES "client") - SET(BUILD_CLIENT true) - MESSAGE(STATUS "Building Quassel client.") -ENDIF(BUILD MATCHES "client") +IF(BUILD MATCHES "core") + SET(BUILD_CORE true) + MESSAGE(STATUS "Building Quassel core.") +ENDIF(BUILD MATCHES "core") +IF(BUILD MATCHES "gui") + SET(BUILD_GUI true) + MESSAGE(STATUS "Building Quassel GUI.") +ENDIF(BUILD MATCHES "gui") IF(BUILD MATCHES "mono") SET(BUILD_MONO true) MESSAGE(STATUS "Building monolithic Quassel.") ENDIF(BUILD MATCHES "mono") -IF(NOT BUILD_MONO AND NOT BUILD_SERVER AND NOT BUILD_CLIENT) - MESSAGE(FATAL_ERROR "You have not selected which parts of Quassel I should build. Aborting.\nRun 'cmake -DBUILD=', where contains one or more of 'server', 'client' or 'monolithic'.") -ENDIF(NOT BUILD_MONO AND NOT BUILD_SERVER AND NOT BUILD_CLIENT) - -# We need Qt4 support. -FIND_PACKAGE(Qt4 REQUIRED) - -# Set needed libraries -SET(QT_USE_QTXML true) -IF(NOT BUILD_CLIENT AND NOT BUILD_MONO) - SET(QT_DONT_USE_QTGUI true) - MESSAGE(STATUS "Disabling GUI support.") -ENDIF(NOT BUILD_CLIENT AND NOT BUILD_MONO) -INCLUDE(${QT_USE_FILE}) -ADD_DEFINITIONS(${QT_DEFINITIONS}) +IF(NOT BUILD_MONO AND NOT BUILD_CORE AND NOT BUILD_GUI) + MESSAGE(FATAL_ERROR "You have not selected which parts of Quassel I should build. Aborting.\nRun 'cmake -DBUILD=', where contains one or more of 'core', 'gui' or 'monolithic'.") +ENDIF(NOT BUILD_MONO AND NOT BUILD_CORE AND NOT BUILD_GUI) # Define files 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) @@ -45,24 +34,40 @@ SET(SDIRS "") FOREACH(dir ${quassel_DIRS}) SET(SDIRS ${SDIRS} "${CMAKE_CURRENT_SOURCE_DIR}/${dir}") ENDFOREACH(dir) -INCLUDE_DIRECTORIES(${SDIRS} ${QT_INCLUDES}) +INCLUDE_DIRECTORIES(${SDIRS}) -ADD_SUBDIRECTORY(gui) -ADD_SUBDIRECTORY(core) +# We need Qt4 support. +FIND_PACKAGE(Qt4 REQUIRED) + +# Set needed libraries +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(core) QT4_ADD_RESOURCES(_RCCS ${quassel_RCCS}) -IF(BUILD_MONO) - ADD_EXECUTABLE(quassel ${quassel_mono_SRCS} ${_RCCS}) - TARGET_LINK_LIBRARIES(quassel gui core ${QT_LIBRARIES}) -ENDIF(BUILD_MONO) +IF(BUILD_CORE) + ADD_EXECUTABLE(quasselcore ${quassel_core_SRCS} ${_RCCS}) + TARGET_LINK_LIBRARIES(quasselcore core ${QT_LIBRARIES}) +ENDIF(BUILD_CORE) + +IF(BUILD_GUI OR BUILD_MONO) # OK, now we need QtGui! + REMOVE_DEFINITIONS(-DQT_CORE_LIB -DQT_GUI_LIB ${QT_DEFINITIONS}) + SET(QT_DONT_USE_QTGUI "") + SET(QT_INCLUDE_DIR "") + SET(QT_LIBRARIES "") + INCLUDE(${QT_USE_FILE}) + + IF(BUILD_MONO) + ADD_SUBDIRECTORY(gui) + ADD_EXECUTABLE(quassel ${quassel_mono_SRCS} ${_RCCS}) + TARGET_LINK_LIBRARIES(quassel gui core ${QT_LIBRARIES}) + ENDIF(BUILD_MONO) -IF(BUILD_SERVER) -# MESSAGE(FATAL_ERROR "Server mode not yet supported.") - ADD_EXECUTABLE(quasselserver ${quassel_mono_SRCS} ${_RCCS}) - TARGET_LINK_LIBRARIES(quasselserver gui core ${QT_LIBRARIES}) -ENDIF(BUILD_SERVER) + IF(BUILD_GUI) + ADD_SUBDIRECTORY(gui) + MESSAGE(FATAL_ERROR "Client mode not yet supported.") + ENDIF(BUILD_GUI) -IF(BUILD_CLIENT) - MESSAGE(FATAL_ERROR "Client mode not yet supported.") -ENDIF(BUILD_CLIENT) +ENDIF(BUILD_GUI OR BUILD_MONO) diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index 71f620c2..4c00fa9f 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -1,5 +1,5 @@ -SET(core_SRCS logger.cpp quassel.cpp) -SET(core_HDRS quassel.h) +SET(core_SRCS logger.cpp quassel.cpp proxy.cpp core.cpp) +SET(core_HDRS quassel.h proxy.h core.h) SET(core_MOCS logger.h) QT4_WRAP_CPP(_MOC ${core_MOCS}) diff --git a/core/core.cpp b/core/core.cpp new file mode 100644 index 00000000..4d144023 --- /dev/null +++ b/core/core.cpp @@ -0,0 +1,38 @@ +/*************************************************************************** + * 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 "core.h" + +#include + +void Core::init() { + + +} + +VarMap Core::loadIdentities() { + QSettings s; + return s.value("Network/Identities").toMap(); +} + +void Core::storeIdentities(VarMap identities) { + QSettings s; + s.setValue("Network/Identities", identities); +} diff --git a/core/core.h b/core/core.h new file mode 100644 index 00000000..4220056d --- /dev/null +++ b/core/core.h @@ -0,0 +1,41 @@ +/*************************************************************************** + * 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 _CORE_H_ +#define _CORE_H_ + +#include +#include +#include + +typedef QMap VarMap; + +class Core { + + public: + static void init(); + static VarMap loadNetworks(); + static void storeNetworks(VarMap); + static VarMap loadIdentities(); + static void storeIdentities(VarMap); + +}; + +#endif diff --git a/core/proxy.cpp b/core/proxy.cpp new file mode 100644 index 00000000..acf0f78c --- /dev/null +++ b/core/proxy.cpp @@ -0,0 +1,54 @@ +/*************************************************************************** + * 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 "proxy.h" + +#include + +using namespace Proxy; + +VarMap CoreProxy::loadIdentities() { + return Core::loadIdentities(); +} + +void CoreProxy::storeIdentities(VarMap id) { + Core::storeIdentities(id); +} + + + +VarMap GuiProxy::loadIdentities() { + return proxyConnect(LOAD_IDENTITIES).toMap(); +} + +void GuiProxy::storeIdentities(VarMap arg) { + proxyConnect(STORE_IDENTITIES, arg); +} + +/* +QVariant proxyConnect(uint func, QVariant arg) { + switch(func) { + case LOAD_IDENTITIES: return (QVariant) CoreProxy::loadIdentities(); + case STORE_IDENTITIES: CoreProxy::storeIdentities(arg.toMap()); return 0; + + } + return 0; +} +*/ \ No newline at end of file diff --git a/core/proxy.h b/core/proxy.h new file mode 100644 index 00000000..ca0319bd --- /dev/null +++ b/core/proxy.h @@ -0,0 +1,51 @@ +/*************************************************************************** + * 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 _PROXY_H_ +#define _PROXY_H_ + +#include "core.h" + +namespace Proxy { + enum { LOAD_IDENTITIES, STORE_IDENTITIES }; +}; + +class CoreProxy { + Q_OBJECT + + public: + static VarMap loadIdentities(); + static void storeIdentities(VarMap); + +}; + + +class GuiProxy { + Q_OBJECT + + public: + static VarMap loadIdentities(); + static void storeIdentities(VarMap); + +}; + +extern QVariant proxyConnect(uint func, QVariant arg = QVariant()); + +#endif diff --git a/core/quassel.cpp b/core/quassel.cpp index 91492639..eb9d236a 100644 --- a/core/quassel.cpp +++ b/core/quassel.cpp @@ -20,8 +20,8 @@ #include "quassel.h" #include "logger.h" +#include "proxy.h" -#include #include #include @@ -37,6 +37,8 @@ void Quassel::setLogger(Logger *) { /* not done yet */ void Quassel::initIconMap() { +// Do not depend on GUI in core! +/* QDomDocument doc("IconMap"); QFile file("images/iconmap.xml"); if(!file.open(QIODevice::ReadOnly)) { @@ -49,6 +51,7 @@ void Quassel::initIconMap() { file.close(); } +*/ } @@ -58,8 +61,9 @@ void Quassel::initIconMap() { * @param symbol Symbol of requested icon * @return Pointer to a newly created QIcon */ -QIcon *Quassel::getIcon(QString /*symbol*/) { +// +//QIcon *Quassel::getIcon(QString /*symbol*/) { //if(symbol == "connect" - return 0; -} +// return 0; +//} diff --git a/core/quassel.h b/core/quassel.h index 0c2a11b5..08a72d50 100644 --- a/core/quassel.h +++ b/core/quassel.h @@ -22,7 +22,6 @@ #define _QUASSEL_H_ class Logger; -class QIcon; class QString; #include @@ -38,14 +37,14 @@ class Quassel { static Logger *getLogger(); static void setLogger(Logger *); - static QIcon *getIcon(QString symbol); +// static QIcon *getIcon(QString symbol); private: static void initIconMap(); static Logger *logger; - static QString iconPath; +// static QString iconPath; static QHash iconMap; }; diff --git a/gui/CMakeLists.txt b/gui/CMakeLists.txt index 0415a01f..35eebf6d 100644 --- a/gui/CMakeLists.txt +++ b/gui/CMakeLists.txt @@ -7,8 +7,7 @@ QT4_WRAP_UI(_UIC ${gui_UICS}) QT4_WRAP_CPP(_MOC ${gui_MOCS}) # We need to workaround a dependency bug with out-of-source builds... -SET_SOURCE_FILES_PROPERTIES(${gui_SRCS} PROPERTIES -OBJECT_DEPENDS "${_UIC}") +SET_SOURCE_FILES_PROPERTIES(${gui_SRCS} PROPERTIES OBJECT_DEPENDS "${_UIC}") INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}) ADD_LIBRARY(gui ${gui_HDRS} ${gui_SRCS} ${_MOC} ${_UIC}) diff --git a/gui/serverlist.cpp b/gui/serverlist.cpp index 221eb2a5..b194c606 100644 --- a/gui/serverlist.cpp +++ b/gui/serverlist.cpp @@ -19,6 +19,7 @@ ***************************************************************************/ #include "serverlist.h" +#include "proxy.h" /* NOTE: This dialog holds not only the server list, but also the identities. * This makes perfect sense given the fact that connections are initiated from @@ -113,9 +114,10 @@ void ServerListDlg::storeNetworks() { } void ServerListDlg::loadIdentities() { - QSettings s; + //QSettings s; //s.beginGroup("Identities"); - identities = s.value("Network/Identities").toMap(); + //identities = s.value("Network/Identities").toMap(); + identities = GuiProxy::loadIdentities(); while(!identities.contains("Default")) { identities = VarMap(); editIdentities(); @@ -123,8 +125,9 @@ void ServerListDlg::loadIdentities() { } void ServerListDlg::storeIdentities() { - QSettings s; - s.setValue("Network/Identities", identities); + //QSettings s; + //s.setValue("Network/Identities", identities); + GuiProxy::storeIdentities(identities); } void ServerListDlg::editIdentities() { diff --git a/main/main_core.cpp b/main/main_core.cpp new file mode 100644 index 00000000..f8e6630b --- /dev/null +++ b/main/main_core.cpp @@ -0,0 +1,51 @@ +/*************************************************************************** + * 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 + +#include "quassel.h" +#include "logger.h" +#include "proxy.h" + +int main(int argc, char **argv) { + + Core::init(); + Quassel::init(); + Logger *logger = new Logger(); + Quassel::setLogger(logger); + + QCoreApplication app(argc, argv); + + QCoreApplication::setOrganizationDomain("quassel-irc.org"); + QCoreApplication::setApplicationName("Quassel IRC"); + QCoreApplication::setOrganizationName("The Quassel Team"); + + return app.exec(); +} + +QVariant proxyConnect(uint func, QVariant arg) { + switch(func) { + case LOAD_IDENTITIES: return (QVariant) CoreProxy::loadIdentities(); + case STORE_IDENTITIES: CoreProxy::storeIdentities(arg.toMap()); return 0; + + } + return 0; +} diff --git a/main/main_mono.cpp b/main/main_mono.cpp index 620084b2..b935a128 100644 --- a/main/main_mono.cpp +++ b/main/main_mono.cpp @@ -22,8 +22,10 @@ #include +#include "core.h" #include "quassel.h" #include "logger.h" +#include "proxy.h" #include "mainwin.h" @@ -39,7 +41,20 @@ int main(int argc, char **argv) { QApplication::setApplicationName("Quassel IRC"); QApplication::setOrganizationName("The Quassel Team"); + Core::init(); + MainWin mainWin; mainWin.show(); return app.exec(); } + +QVariant proxyConnect(uint func, QVariant arg) { + using namespace Proxy; + + switch(func) { + case LOAD_IDENTITIES: return (QVariant) CoreProxy::loadIdentities(); + case STORE_IDENTITIES: CoreProxy::storeIdentities(arg.toMap()); return 0; + + } + return 0; +} -- 2.20.1