X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcommon%2Fglobal.cpp;h=cdb337652116171ff5e516883d6943860eacb62d;hp=b92f7959474dbea4f2bb44b8d9614687eb02befe;hb=902c95728306e5ba115de84800fc8d5d239c9d62;hpb=73edffb5f0f6ecae4118c36a7ca2c0d479b7f8c6 diff --git a/src/common/global.cpp b/src/common/global.cpp index b92f7959..cdb33765 100644 --- a/src/common/global.cpp +++ b/src/common/global.cpp @@ -17,97 +17,16 @@ * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ +#include +#include #include "global.h" #include "logger.h" -#include "core.h" #include "message.h" #include "util.h" -#include -#include - extern void messageHandler(QtMsgType type, const char *msg); -Global *Global::instanceptr = 0; - -Global * Global::instance() { - if(instanceptr) return instanceptr; - return instanceptr = new Global(); -} - -void Global::destroy() { - delete instanceptr; - instanceptr = 0; -} - -Global::Global() { - qInstallMsgHandler(messageHandler); - qRegisterMetaType("Message"); - qRegisterMetaTypeStreamOperators("Message"); - qRegisterMetaType("BufferId"); - qRegisterMetaTypeStreamOperators("BufferId"); - - guiUser = 0; -} - -Global::~Global() { - - -} - -void Global::setGuiUser(UserId uid) { - guiUser = uid; -} - -QVariant Global::data(QString key, QVariant defval) { - return data(guiUser, key, defval); -} - -QVariant Global::data(UserId uid, QString key, QVariant defval) { - QVariant d; - mutex.lock(); - if(instance()->datastore[uid].contains(key)) d = instance()->datastore[uid][key]; - else d = defval; - mutex.unlock(); - //qDebug() << "getData("<datastore[uid].keys(); - mutex.unlock(); - return k; -} - -void Global::putData(QString key, QVariant d) { - putData(guiUser, key, d); -} - -void Global::putData(UserId uid, QString key, QVariant d) { - mutex.lock(); - instance()->datastore[uid][key] = d; - mutex.unlock(); - emit instance()->dataPutLocally(uid, key); -} - -void Global::updateData(QString key, QVariant d) { - updateData(guiUser, key, d); -} - -void Global::updateData(UserId uid, QString key, QVariant d) { - mutex.lock(); - instance()->datastore[uid][key] = d; - mutex.unlock(); - emit instance()->dataUpdatedRemotely(uid, key); -} - /* not done yet */ /* void Global::initIconMap() { @@ -127,36 +46,6 @@ void Global::initIconMap() { } */ -/**************************************************************************************/ - - - -BufferId::BufferId(uint _id, QString _net, QString _buf, uint _gid) : id(_id), gid(_gid), net(_net), buf(_buf) { - - -} - -QString BufferId::buffer() const { - if(isChannelName(buf)) return buf; - else return nickFromMask(buf); -} - -QDataStream &operator<<(QDataStream &out, const BufferId &bufferId) { - out << bufferId.id << bufferId.gid << bufferId.net.toUtf8() << bufferId.buf.toUtf8(); -} - -QDataStream &operator>>(QDataStream &in, BufferId &bufferId) { - QByteArray n, b; - BufferId i; - in >> bufferId.id >> bufferId.gid >> n >> b; - bufferId.net = QString::fromUtf8(n); - bufferId.buf = QString::fromUtf8(b); -} - -uint qHash(const BufferId &bid) { - return qHash(bid.id); -} - /** * Retrieves an icon determined by its symbolic name. The mapping shall later * be performed by a theme manager or something like that. @@ -170,7 +59,5 @@ uint qHash(const BufferId &bid) { // return 0; //} -QMutex Global::mutex; Global::RunMode Global::runMode; -UserId Global::guiUser; QString Global::quasselDir;