1 /***************************************************************************
2 * Copyright (C) 2005-08 by the Quassel Project *
3 * devel@quassel-irc.org *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) version 3. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
28 #include "bufferinfo.h"
30 #include "syncableobject.h"
32 extern void messageHandler(QtMsgType type, const char *msg);
36 void Global::initIconMap() {
37 // Do not depend on GUI in core!
38 QDomDocument doc("IconMap");
39 QFile file("images/iconmap.xml");
40 if(!file.open(QIODevice::ReadOnly)) {
41 qDebug() << "Error opening iconMap file!";
43 } else if(!doc.setContent(&file)) {
45 qDebug() << "Error parsing iconMap file!";
54 * Retrieves an icon determined by its symbolic name. The mapping shall later
55 * be performed by a theme manager or something like that.
56 * @param symbol Symbol of requested icon
57 * @return Pointer to a newly created QIcon
60 //QIcon *Global::getIcon(QString /*symbol*/) {
61 //if(symbol == "connect"
66 //! Register our custom types with Qt's Meta Object System.
67 /** This makes them available for QVariant and in signals/slots, among other things.
70 void Global::registerMetaTypes() {
72 qRegisterMetaType<QVariant>("QVariant");
73 qRegisterMetaType<Message>("Message");
74 qRegisterMetaType<BufferInfo>("BufferInfo");
75 qRegisterMetaType<NetworkInfo>("NetworkInfo");
76 qRegisterMetaType<Identity>("Identity");
77 qRegisterMetaType<Network::ConnectionState>("Network::ConnectionState");
79 qRegisterMetaTypeStreamOperators<QVariant>("QVariant");
80 qRegisterMetaTypeStreamOperators<Message>("Message");
81 qRegisterMetaTypeStreamOperators<BufferInfo>("BufferInfo");
82 qRegisterMetaTypeStreamOperators<NetworkInfo>("NetworkInfo");
83 qRegisterMetaTypeStreamOperators<Identity>("Identity");
84 qRegisterMetaTypeStreamOperators<qint8>("Network::ConnectionState");
86 qRegisterMetaType<IdentityId>("IdentityId");
87 qRegisterMetaType<BufferId>("BufferId");
88 qRegisterMetaType<NetworkId>("NetworkId");
89 qRegisterMetaType<UserId>("UserId");
90 qRegisterMetaType<AccountId>("AccountId");
91 qRegisterMetaType<MsgId>("MsgId");
93 qRegisterMetaTypeStreamOperators<IdentityId>("IdentityId");
94 qRegisterMetaTypeStreamOperators<BufferId>("BufferId");
95 qRegisterMetaTypeStreamOperators<NetworkId>("NetworkId");
96 qRegisterMetaTypeStreamOperators<UserId>("UserId");
97 qRegisterMetaTypeStreamOperators<AccountId>("AccountId");
98 qRegisterMetaTypeStreamOperators<MsgId>("MsgId");
101 //! This includes version.inc and possibly version.gen and sets up our version numbers.
102 void Global::setupVersion() {
104 # include "version.inc"
105 # include "version.gen"
107 if(quasselGeneratedVersion.isEmpty()) {
108 if(quasselCommit.isEmpty())
109 quasselVersion = QString("v%1 (unknown rev)").arg(quasselBaseVersion);
111 quasselVersion = QString("v%1 (dist-%2, %3)").arg(quasselBaseVersion).arg(quasselCommit.left(7))
112 .arg(QDateTime::fromTime_t(quasselArchiveDate).toLocalTime().toString("yyyy-MM-dd"));
114 QStringList parts = quasselGeneratedVersion.split(':');
115 quasselVersion = QString("v%1").arg(parts[0]);
116 if(parts.count() >= 2) quasselVersion.append(QString(" (%1)").arg(parts[1]));
118 quasselBuildDate = __DATE__;
119 quasselBuildTime = __TIME__;
124 QString Global::quasselVersion;
125 QString Global::quasselBaseVersion;
126 QString Global::quasselGeneratedVersion;
127 QString Global::quasselBuildDate;
128 QString Global::quasselBuildTime;
129 QString Global::quasselCommit;
130 uint Global::quasselArchiveDate;
131 uint Global::protocolVersion;
132 uint Global::clientNeedsProtocol;
133 uint Global::coreNeedsProtocol;
135 Global::RunMode Global::runMode;
136 uint Global::defaultPort;
139 CliParser Global::parser;