X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=main%2Fglobal.h;h=fa961f2f8ab0382bb7cea69a5d9873bbab9bd9e8;hb=0d5499deed248902ce2341208cbc33acd8cace19;hp=ad4cb1db9a7d856fefda9b9bd40d0c896be48118;hpb=ba8f57d654b07d77cc91a2b901ad3b664a31ffcf;p=quassel.git diff --git a/main/global.h b/main/global.h index ad4cb1db..fa961f2f 100644 --- a/main/global.h +++ b/main/global.h @@ -22,7 +22,10 @@ #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" class Global; @@ -31,7 +34,9 @@ class Global; /* Some global stuff */ typedef QMap VarMap; -extern Global *global; + +typedef uint UserId; +typedef uint MsgId; /** * This class is mostly a globally synchronized data store, meant for storing systemwide settings such @@ -47,40 +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; } @@ -89,4 +106,35 @@ class Exception { }; +class BufferId { + public: + BufferId() { id = gid = 0; } // FIXME + BufferId(uint uid, QString net, QString buf, uint gid = 0); + + inline uint uid() { return id; } + inline uint groupId() { return gid; } + inline QString network() { return net; } + QString buffer(); // nickfrommask? + + void setGroupId(uint _gid) { gid = _gid; } + + inline bool operator==(const BufferId &other) const { return id == other.id; } + private: + uint id; + uint gid; + QString net; + QString buf; + + friend uint qHash(const BufferId &); + friend QDataStream &operator<<(QDataStream &out, const BufferId &bufferId); + friend QDataStream &operator>>(QDataStream &in, BufferId &bufferId); +}; + +QDataStream &operator<<(QDataStream &out, const BufferId &bufferId); +QDataStream &operator>>(QDataStream &in, BufferId &bufferId); + +Q_DECLARE_METATYPE(BufferId); + +uint qHash(const BufferId &); + #endif