Added basic stuff for localization/internationalization (i18n).
[quassel.git] / src / common / global.h
1 /***************************************************************************
2  *   Copyright (C) 2005 by The Quassel Team                                *
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) any later version.                                   *
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
21 #ifndef _GLOBAL_H_
22 #define _GLOBAL_H_
23
24 /** The protocol version we use fo the communication between core and GUI */
25 #define GUI_PROTOCOL 3
26
27 #define BACKLOG_FORMAT 2
28 #define BACKLOG_STRING "QuasselIRC Backlog File"
29
30 #define DEFAULT_PORT 4242
31
32 #include <QHash>
33 #include <QMutex>
34 #include <QString>
35 #include <QVariant>
36
37 /* Some global stuff */
38
39 typedef uint UserId;
40 typedef uint MsgId;
41
42 namespace Global {
43   enum RunMode { Monolithic, ClientOnly, CoreOnly };
44   extern RunMode runMode;
45   extern QString quasselDir;
46 }
47
48 struct Exception {
49     Exception(QString msg = "Unknown Exception") : _msg(msg) {};
50     virtual ~Exception() {}; // make gcc happy
51     virtual inline QString msg() { return _msg; }
52
53   protected:
54     QString _msg;
55
56 };
57
58 class BufferId {
59 public:
60   BufferId();
61   BufferId(uint _id, uint _networkid, uint _gid = 0, QString _net = QString(), QString _buf = QString());
62   
63   inline uint uid() const { return _id; }
64   inline uint networkId() const { return _netid; }
65   inline uint groupId() const { return _gid; }
66   inline QString network() const { return _networkName; }
67   QString buffer() const;
68   
69   void setGroupId(uint gid) { _gid = gid; }
70   
71   inline bool operator==(const BufferId &other) const { return _id == other._id; }
72
73 private:
74   uint _id;
75   uint _netid;
76   uint _gid;
77   QString _networkName; // WILL BE REMOVED
78   QString _bufferName; // IS this actually needed?
79   
80   friend uint qHash(const BufferId &);
81   friend QDataStream &operator<<(QDataStream &out, const BufferId &bufferId);
82   friend QDataStream &operator>>(QDataStream &in, BufferId &bufferId);
83 };
84
85 QDataStream &operator<<(QDataStream &out, const BufferId &bufferId);
86 QDataStream &operator>>(QDataStream &in, BufferId &bufferId);
87
88 Q_DECLARE_METATYPE(BufferId);
89
90 uint qHash(const BufferId &);
91
92 #endif