Tuned the settings dialog a bit, mostly fixing the layout problems we had and adding
[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 typedef QMap<QString, QVariant> VarMap;
39
40 typedef uint UserId;
41 typedef uint MsgId;
42
43 namespace Global {
44   enum RunMode { Monolithic, ClientOnly, CoreOnly };
45   extern RunMode runMode;
46   extern QString quasselDir;
47 }
48
49 struct Exception {
50     Exception(QString msg = "Unknown Exception") : _msg(msg) {};
51     virtual ~Exception() {}; // make gcc happy
52     virtual inline QString msg() { return _msg; }
53
54   protected:
55     QString _msg;
56
57 };
58
59 class BufferId {
60   public:
61     BufferId() { id = gid = 0; } // FIXME
62     BufferId(uint uid, QString net, QString buf, uint gid = 0);
63
64     inline uint uid() const { return id; }
65     inline uint groupId() const { return gid; }
66     inline QString network() const { return net; }
67     QString buffer() const; // nickfrommask?
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 gid;
76     QString net;
77     QString buf;
78
79     friend uint qHash(const BufferId &);
80     friend QDataStream &operator<<(QDataStream &out, const BufferId &bufferId);
81     friend QDataStream &operator>>(QDataStream &in, BufferId &bufferId);
82 };
83
84 QDataStream &operator<<(QDataStream &out, const BufferId &bufferId);
85 QDataStream &operator>>(QDataStream &in, BufferId &bufferId);
86
87 Q_DECLARE_METATYPE(BufferId);
88
89 uint qHash(const BufferId &);
90
91 #endif