X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=main%2Fquassel.h;h=ad4cb1db9a7d856fefda9b9bd40d0c896be48118;hp=0c2a11b53ce3e83e811fef01ff5f71a5850db7ae;hb=04e21ce26ebabdde9586ca9d2a3168431e448df5;hpb=925b072e5c7bc38949995902cf7af6e4644c2c55 diff --git a/main/quassel.h b/main/quassel.h index 0c2a11b5..ad4cb1db 100644 --- a/main/quassel.h +++ b/main/quassel.h @@ -18,35 +18,74 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#ifndef _QUASSEL_H_ -#define _QUASSEL_H_ +#ifndef _GLOBAL_H_ +#define _GLOBAL_H_ -class Logger; -class QIcon; -class QString; +/** The protocol version we use fo the communication between core and GUI */ +#define GUI_PROTOCOL 1 -#include +class Global; +#include +//#include + +/* Some global stuff */ +typedef QMap VarMap; +extern Global *global; /** - * A static class containing global data. - */ -class Quassel { + * This class is mostly a globally synchronized data store, meant for storing systemwide settings such + * as identities or network lists. This class is a singleton, but not static as we'd like to use signals and + * slots with it. + * The global object is used in both Core and GUI clients. Storing and retrieving data is thread-safe. + * \note While updated data is propagated to all the remote parts of Quassel quite quickly, the synchronization + * protocol is in no way designed to guarantee strict consistency at all times. In other words, it may + * well happen that different instances of global data differ from one another for a little while until + * all update messages have been processed. You should never rely on all global data stores being consistent. +*/ +class Global : public QObject { + Q_OBJECT public: - static void init(); - static Logger *getLogger(); - static void setLogger(Logger *); + Global(); + //static Logger *getLogger(); + //static void setLogger(Logger *); + +// static QIcon *getIcon(QString symbol); + + QVariant getData(QString key, QVariant defaultValue = QVariant()); + QStringList getKeys(); - static QIcon *getIcon(QString symbol); + public slots: + void putData(QString key, QVariant data); ///< Store data changed locally, will be propagated to all other clients and the core + void updateData(QString key, QVariant data); ///< Update stored data if requested by the core or other clients + + signals: + void dataPutLocally(QString key); + void dataUpdatedRemotely(QString key); // sent by remote update only! + + public: + enum RunMode { Monolithic, GUIOnly, CoreOnly }; + static RunMode runMode; private: static void initIconMap(); - - static Logger *logger; - static QString iconPath; - static QHash iconMap; + //static Logger *logger; + +// static QString iconPath; + QHash iconMap; + QMutex mutex; + QHash data; +}; + +class Exception { + public: + Exception(QString msg = "Unknown Exception") : _msg(msg) {}; + virtual inline QString msg() { return _msg; } + + protected: + QString _msg; };