X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcommon%2Fglobal.cpp;h=8941d5b8d30e14e51ee12064ce2ae15761c3dac6;hp=ed2d1df8b78ec2fa5f50edd3e6f716cdf9539eee;hb=3982589b93aa14c3cede148b8a5158b63055d65c;hpb=d064f62ec2f316f17c3aac3c31184376380ef098 diff --git a/src/common/global.cpp b/src/common/global.cpp index ed2d1df8..8941d5b8 100644 --- a/src/common/global.cpp +++ b/src/common/global.cpp @@ -1,11 +1,11 @@ /*************************************************************************** - * Copyright (C) 2005-07 by The Quassel IRC Development Team * + * Copyright (C) 2005-08 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * + * (at your option) version 3. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * @@ -18,12 +18,16 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #include -#include +#include #include "global.h" #include "logger.h" #include "message.h" -#include "util.h" +#include "identity.h" +#include "network.h" +#include "bufferinfo.h" +#include "types.h" +#include "syncableobject.h" extern void messageHandler(QtMsgType type, const char *msg); @@ -46,47 +50,6 @@ void Global::initIconMap() { } */ -/**************************************************************************************/ -BufferId::BufferId() - : _id(0), - _netid(0), - _gid(0), - _networkName(QString()), - _bufferName(QString()) { -} - -BufferId::BufferId(uint id, uint networkid, uint gid, QString net, QString buf) - : _id(id), - _netid(networkid), - _gid(gid), - _networkName(net), - _bufferName(buf) { -} - -QString BufferId::buffer() const { - if(isChannelName(_bufferName)) - return _bufferName; - else - return nickFromMask(_bufferName); -} - -QDataStream &operator<<(QDataStream &out, const BufferId &bufferId) { - out << bufferId._id << bufferId._netid << bufferId._gid << bufferId._networkName.toUtf8() << bufferId._bufferName.toUtf8(); - return out; -} - -QDataStream &operator>>(QDataStream &in, BufferId &bufferId) { - QByteArray n, b; - in >> bufferId._id >> bufferId._netid >> bufferId._gid >> n >> b; - bufferId._networkName = QString::fromUtf8(n); - bufferId._bufferName = QString::fromUtf8(b); - return in; -} - -uint qHash(const BufferId &bufferid) { - return qHash(bufferid._id); -} - /** * Retrieves an icon determined by its symbolic name. The mapping shall later * be performed by a theme manager or something like that. @@ -100,5 +63,72 @@ uint qHash(const BufferId &bufferid) { // return 0; //} +//! Register our custom types with Qt's Meta Object System. +/** This makes them available for QVariant and in signals/slots, among other things. + * + */ +void Global::registerMetaTypes() { + // Complex types + qRegisterMetaType("QVariant"); + qRegisterMetaType("Message"); + qRegisterMetaType("BufferInfo"); + qRegisterMetaType("NetworkInfo"); + qRegisterMetaType("Identity"); + qRegisterMetaType("Network::ConnectionState"); + + qRegisterMetaTypeStreamOperators("QVariant"); + qRegisterMetaTypeStreamOperators("Message"); + qRegisterMetaTypeStreamOperators("BufferInfo"); + qRegisterMetaTypeStreamOperators("NetworkInfo"); + qRegisterMetaTypeStreamOperators("Identity"); + qRegisterMetaTypeStreamOperators("Network::ConnectionState"); + + qRegisterMetaType("IdentityId"); + qRegisterMetaType("BufferId"); + qRegisterMetaType("NetworkId"); + qRegisterMetaType("UserId"); + qRegisterMetaType("AccountId"); + qRegisterMetaType("MsgId"); + + qRegisterMetaTypeStreamOperators("IdentityId"); + qRegisterMetaTypeStreamOperators("BufferId"); + qRegisterMetaTypeStreamOperators("NetworkId"); + qRegisterMetaTypeStreamOperators("UserId"); + qRegisterMetaTypeStreamOperators("AccountId"); + qRegisterMetaTypeStreamOperators("MsgId"); +} + +//! This includes version.inc and possibly version.gen and sets up our version numbers. +void Global::setupVersion() { + +# include "version.inc" +# ifdef HAVE_VERSION_GEN +# include "version.gen" +# endif + + if(quasselGeneratedVersion.isEmpty()) { + quasselVersion = QString("v%1 (unknown rev)").arg(quasselBaseVersion); + } else { + QStringList parts = quasselGeneratedVersion.split(':'); + quasselVersion = QString("v%1").arg(parts[0]); + if(parts.count() >= 2) quasselVersion.append(QString(" (%1)").arg(parts[1])); + } + quasselBuildDate = __DATE__; + quasselBuildTime = __TIME__; +} + +// Static variables + +QString Global::quasselVersion; +QString Global::quasselBaseVersion; +QString Global::quasselGeneratedVersion; +QString Global::quasselBuildDate; +QString Global::quasselBuildTime; +uint Global::protocolVersion; +uint Global::clientNeedsProtocol; +uint Global::coreNeedsProtocol; + Global::RunMode Global::runMode; -QString Global::quasselDir; +uint Global::defaultPort; + +bool Global::DEBUG;