s,--sputdev,--debug,g
[quassel.git] / src / common / global.cpp
1 /***************************************************************************
2  *   Copyright (C) 2005-08 by the Quassel Project                          *
3  *   devel@quassel-irc.org                                                 *
4  *                                                                         *
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.                                           *
9  *                                                                         *
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.                          *
14  *                                                                         *
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  ***************************************************************************/
20 #include <QObject>
21 #include <QMetaType>
22
23 #include "global.h"
24 #include "logger.h"
25 #include "message.h"
26 #include "identity.h"
27 #include "network.h"
28 #include "bufferinfo.h"
29 #include "types.h"
30 #include "syncableobject.h"
31
32 extern void messageHandler(QtMsgType type, const char *msg);
33
34 /* not done yet */
35 /*
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!";
42     return;
43   } else if(!doc.setContent(&file)) {
44     file.close();
45     qDebug() << "Error parsing iconMap file!";
46   } else {
47     file.close();
48
49   }
50 }
51 */
52
53 /**
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
58  */
59 //
60 //QIcon *Global::getIcon(QString /*symbol*/) {
61   //if(symbol == "connect"
62
63 //  return 0;
64 //}
65
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.
68  *
69  */
70 void Global::registerMetaTypes() {
71   // Complex types
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");
78
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");
85
86   qRegisterMetaType<IdentityId>("IdentityId");
87   qRegisterMetaType<BufferId>("BufferId");
88   qRegisterMetaType<NetworkId>("NetworkId");
89   qRegisterMetaType<UserId>("UserId");
90   qRegisterMetaType<AccountId>("AccountId");
91   qRegisterMetaType<MsgId>("MsgId");
92
93   qRegisterMetaTypeStreamOperators<IdentityId>("IdentityId");
94   qRegisterMetaTypeStreamOperators<BufferId>("BufferId");
95   qRegisterMetaTypeStreamOperators<NetworkId>("NetworkId");
96   qRegisterMetaTypeStreamOperators<UserId>("UserId");
97   qRegisterMetaTypeStreamOperators<AccountId>("AccountId");
98   qRegisterMetaTypeStreamOperators<MsgId>("MsgId");
99
100 }
101
102 // Static variables
103
104 QString Global::quasselVersion;
105 QString Global::quasselDate;
106 uint Global::quasselBuild;
107 uint Global::clientBuildNeeded;
108 QString Global::clientVersionNeeded;
109 uint Global::coreBuildNeeded;
110 QString Global::coreVersionNeeded;
111
112 Global::RunMode Global::runMode;
113 uint Global::defaultPort;
114
115 bool Global::DEBUG;