X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcommon%2Fglobal.h;h=1d1d3759421ba2e2ff3024dce5e5e4078e8c697b;hp=2723b66bb1d25a53e3571a786ee6a8d11a04556b;hb=d064f62ec2f316f17c3aac3c31184376380ef098;hpb=0ac9ce4d7cf768d13993d6aa1d6b791c4149a843 diff --git a/src/common/global.h b/src/common/global.h index 2723b66b..1d1d3759 100644 --- a/src/common/global.h +++ b/src/common/global.h @@ -27,7 +27,7 @@ #define BACKLOG_FORMAT 2 #define BACKLOG_STRING "QuasselIRC Backlog File" -class Global; +#define DEFAULT_PORT 4242 #include #include @@ -35,69 +35,15 @@ class Global; #include /* Some global stuff */ -typedef QMap VarMap; typedef uint UserId; typedef uint MsgId; -/** - * 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 Logger *getLogger(); - //static void setLogger(Logger *); - -// static QIcon *getIcon(QString symbol); - - 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); - - 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(UserId, QString key); - void dataUpdatedRemotely(UserId, QString key); // sent by remote update only! - - public: - enum RunMode { Monolithic, ClientOnly, CoreOnly }; - static RunMode runMode; - static QString quasselDir; - - private: - Global(); - ~Global(); - static Global *instanceptr; - - static UserId guiUser; - //static void initIconMap(); - - //static Logger *logger; - -// static QString iconPath; - //QHash iconMap; - static QMutex mutex; - QHash > datastore; -}; +namespace Global { + enum RunMode { Monolithic, ClientOnly, CoreOnly }; + extern RunMode runMode; + extern QString quasselDir; +} struct Exception { Exception(QString msg = "Unknown Exception") : _msg(msg) {}; @@ -110,28 +56,30 @@ struct Exception { }; class BufferId { - public: - BufferId() { id = gid = 0; } // FIXME - BufferId(uint uid, QString net, QString buf, uint gid = 0); - - inline uint uid() const { return id; } - inline uint groupId() const { return gid; } - inline QString network() const { return net; } - QString buffer() const; // 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); +public: + BufferId(); + BufferId(uint _id, uint _networkid, uint _gid = 0, QString _net = QString(), QString _buf = QString()); + + inline uint uid() const { return _id; } + inline uint networkId() const { return _netid; } + inline uint groupId() const { return _gid; } + inline QString network() const { return _networkName; } + QString buffer() const; + + void setGroupId(uint gid) { _gid = gid; } + + inline bool operator==(const BufferId &other) const { return _id == other._id; } + +private: + uint _id; + uint _netid; + uint _gid; + QString _networkName; // WILL BE REMOVED + QString _bufferName; // IS this actually needed? + + 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);