Quassel IRC  Pre-Release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
protocol.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005-2015 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  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19  ***************************************************************************/
20 
21 #ifndef PROTOCOL_H_
22 #define PROTOCOL_H_
23 
24 #include <QByteArray>
25 #include <QDateTime>
26 #include <QVariantList>
27 
28 namespace Protocol {
29 
30 const quint32 magic = 0x42b33f00;
31 
32 enum Type {
36 };
37 
38 
39 enum Feature {
40  Encryption = 0x01,
41  Compression = 0x02
42 };
43 
44 
45 enum Handler {
48 };
49 
50 
51 /*** Handshake, handled by AuthHandler ***/
52 
54  inline Handler handler() const { return AuthHandler; }
55 };
56 
57 
59 {
60  inline RegisterClient(const QString &clientVersion, const QString &buildDate, bool sslSupported = false)
61  : clientVersion(clientVersion)
62  , buildDate(buildDate)
64 
65  QString clientVersion;
66  QString buildDate;
67 
68  // this is only used by the LegacyProtocol in compat mode
70 };
71 
72 
74 {
75  inline ClientDenied(const QString &errorString)
76  : errorString(errorString) {}
77 
78  QString errorString;
79 };
80 
81 
83 {
84  inline ClientRegistered(quint32 coreFeatures, bool coreConfigured, const QVariantList &backendInfo, bool sslSupported, const QString &coreInfo)
85  : coreFeatures(coreFeatures)
86  , coreConfigured(coreConfigured)
87  , backendInfo(backendInfo)
88  , sslSupported(sslSupported)
89  , coreInfo(coreInfo)
90  {}
91 
92  quint32 coreFeatures;
94  QVariantList backendInfo; // TODO: abstract this better
95 
96  // this is only used by the LegacyProtocol in compat mode
98  QString coreInfo;
99 };
100 
101 
103 {
104  inline SetupData(const QString &adminUser, const QString &adminPassword, const QString &backend, const QVariantMap &setupData)
105  : adminUser(adminUser), adminPassword(adminPassword), backend(backend), setupData(setupData) {}
106 
107  QString adminUser;
108  QString adminPassword;
109  QString backend;
110  QVariantMap setupData;
111 };
112 
113 
115 {
116  inline SetupFailed(const QString &errorString)
117  : errorString(errorString) {}
118 
119  QString errorString;
120 };
121 
122 
124 {
125  inline SetupDone() {}
126 };
127 
128 
129 struct Login : public HandshakeMessage
130 {
131  inline Login(const QString &user, const QString &password)
132  : user(user), password(password) {}
133 
134  QString user;
135  QString password;
136 };
137 
138 
140 {
141  inline LoginFailed(const QString &errorString)
142  : errorString(errorString) {}
143 
144  QString errorString;
145 };
146 
147 
149 {
150  inline LoginSuccess() {}
151 };
152 
153 
154 // TODO: more generic format
156 {
157  inline SessionState() {} // needed for QMetaType (for the mono client)
158  inline SessionState(const QVariantList &identities, const QVariantList &bufferInfos, const QVariantList &networkIds)
159  : identities(identities), bufferInfos(bufferInfos), networkIds(networkIds) {}
160 
161  QVariantList identities;
162  QVariantList bufferInfos;
163  QVariantList networkIds;
164 };
165 
166 /*** handled by SignalProxy ***/
167 
169 {
170  inline Handler handler() const { return SignalProxy; }
171 };
172 
173 
175 {
176  inline SyncMessage(const QByteArray &className, const QString &objectName, const QByteArray &slotName, const QVariantList &params)
177  : className(className), objectName(objectName), slotName(slotName), params(params) {}
178 
179  QByteArray className;
180  QString objectName;
181  QByteArray slotName;
182  QVariantList params;
183 };
184 
185 
187 {
188  inline RpcCall(const QByteArray &slotName, const QVariantList &params)
189  : slotName(slotName), params(params) {}
190 
191  QByteArray slotName;
192  QVariantList params;
193 };
194 
195 
197 {
198  inline InitRequest(const QByteArray &className, const QString &objectName)
199  : className(className), objectName(objectName) {}
200 
201  QByteArray className;
202  QString objectName;
203 };
204 
205 
207 {
208  inline InitData(const QByteArray &className, const QString &objectName, const QVariantMap &initData)
209  : className(className), objectName(objectName), initData(initData) {}
210 
211  QByteArray className;
212  QString objectName;
213  QVariantMap initData;
214 };
215 
216 
217 /*** handled by RemoteConnection ***/
218 
219 struct HeartBeat
220 {
221  inline HeartBeat(const QDateTime &timestamp) : timestamp(timestamp) {}
222 
223  QDateTime timestamp;
224 };
225 
226 
228 {
229  inline HeartBeatReply(const QDateTime &timestamp) : timestamp(timestamp) {}
230 
231  QDateTime timestamp;
232 };
233 
234 
235 };
236 
237 #endif