X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=main%2Fglobal.h;fp=main%2Fglobal.h;h=fa961f2f8ab0382bb7cea69a5d9873bbab9bd9e8;hp=a662fd77ed32f5927cccb3ba7f15dbe672111018;hb=7ec4585cecc74ce8d9a94b0e52f00a96d105e79e;hpb=62f292ad143923a3b774b9bd14f83f3b640c0cb8 diff --git a/main/global.h b/main/global.h index a662fd77..fa961f2f 100644 --- a/main/global.h +++ b/main/global.h @@ -22,7 +22,7 @@ #define _GLOBAL_H_ /** The protocol version we use fo the communication between core and GUI */ -#define GUI_PROTOCOL 1 +#define GUI_PROTOCOL 2 #define BACKLOG_FORMAT 2 #define BACKLOG_STRING "QuasselIRC Backlog File" @@ -34,7 +34,6 @@ class Global; /* Some global stuff */ typedef QMap VarMap; -extern Global *global; typedef uint UserId; typedef uint MsgId; @@ -53,41 +52,52 @@ class Global : public QObject { Q_OBJECT public: - Global(); //static Logger *getLogger(); //static void setLogger(Logger *); // static QIcon *getIcon(QString symbol); - QVariant getData(QString key, QVariant defaultValue = QVariant()); - QStringList getKeys(); + static Global *instance(); + static void destroy(); + static void setGuiUser(UserId); + + static QVariant data(QString key, QVariant defaultValue = QVariant()); + static QVariant data(UserId, QString key, QVariant defaultValue = QVariant()); + static QStringList keys(); + static QStringList keys(UserId); + + static void putData(QString key, QVariant data); ///< Store data changed locally, will be propagated to all other clients and the core + static void putData(UserId, QString key, QVariant data); - 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 + static void updateData(QString key, QVariant data); ///< Update stored data if requested by the core or other clients + static void updateData(UserId, QString key, QVariant data); signals: - void dataPutLocally(QString key); - void dataUpdatedRemotely(QString key); // sent by remote update only! + void dataPutLocally(UserId, QString key); + void dataUpdatedRemotely(UserId, QString key); // sent by remote update only! public: - enum RunMode { Monolithic, GUIOnly, CoreOnly }; + enum RunMode { Monolithic, GuiOnly, CoreOnly }; static RunMode runMode; static QString quasselDir; private: - static void initIconMap(); + Global(); + ~Global(); + static Global *instanceptr; + + static UserId guiUser; + //static void initIconMap(); //static Logger *logger; // static QString iconPath; - QHash iconMap; - QMutex mutex; - QHash data; + //QHash iconMap; + static QMutex mutex; + QHash > datastore; }; -class Exception { - public: +struct Exception { Exception(QString msg = "Unknown Exception") : _msg(msg) {}; virtual inline QString msg() { return _msg; }