1 /***************************************************************************
2 * Copyright (C) 2005-2016 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 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19 ***************************************************************************/
26 #include <QVariantList>
30 const quint32 magic = 0x42b33f00;
33 InternalProtocol = 0x00,
34 LegacyProtocol = 0x01,
35 DataStreamProtocol = 0x02
51 /*** Handshake, handled by AuthHandler ***/
53 struct HandshakeMessage {
54 inline Handler handler() const { return Handler::AuthHandler; }
58 struct RegisterClient : public HandshakeMessage
60 inline RegisterClient(const QString &clientVersion, const QString &buildDate, bool sslSupported = false)
61 : clientVersion(clientVersion)
62 , buildDate(buildDate)
63 , sslSupported(sslSupported) {}
65 QString clientVersion;
68 // this is only used by the LegacyProtocol in compat mode
73 struct ClientDenied : public HandshakeMessage
75 inline ClientDenied(const QString &errorString)
76 : errorString(errorString) {}
82 struct ClientRegistered : public HandshakeMessage
84 inline ClientRegistered(quint32 coreFeatures, bool coreConfigured, const QVariantList &backendInfo, bool sslSupported, const QVariantList &authenticatorInfo)
85 : coreFeatures(coreFeatures)
86 , coreConfigured(coreConfigured)
87 , backendInfo(backendInfo)
88 , authenticatorInfo(authenticatorInfo)
89 , sslSupported(sslSupported)
95 // The authenticatorInfo should be optional!
96 QVariantList backendInfo; // TODO: abstract this better
97 QVariantList authenticatorInfo;
99 // this is only used by the LegacyProtocol in compat mode
104 struct SetupData : public HandshakeMessage
106 inline SetupData(const QString &adminUser, const QString &adminPassword, const QString &backend,
107 const QVariantMap &setupData, const QString &authenticator = QString(),
108 const QVariantMap &authSetupData = QVariantMap())
109 : adminUser(adminUser)
110 , adminPassword(adminPassword)
112 , setupData(setupData)
113 , authenticator(authenticator)
114 , authSetupData(authSetupData)
118 QString adminPassword;
120 QVariantMap setupData;
121 QString authenticator;
122 QVariantMap authSetupData;
126 struct SetupFailed : public HandshakeMessage
128 inline SetupFailed(const QString &errorString)
129 : errorString(errorString) {}
135 struct SetupDone : public HandshakeMessage
137 inline SetupDone() {}
141 struct Login : public HandshakeMessage
143 inline Login(const QString &user, const QString &password)
144 : user(user), password(password) {}
151 struct LoginFailed : public HandshakeMessage
153 inline LoginFailed(const QString &errorString)
154 : errorString(errorString) {}
160 struct LoginSuccess : public HandshakeMessage
162 inline LoginSuccess() {}
166 // TODO: more generic format
167 struct SessionState : public HandshakeMessage
169 inline SessionState() {} // needed for QMetaType (for the mono client)
170 inline SessionState(const QVariantList &identities, const QVariantList &bufferInfos, const QVariantList &networkIds)
171 : identities(identities), bufferInfos(bufferInfos), networkIds(networkIds) {}
173 QVariantList identities;
174 QVariantList bufferInfos;
175 QVariantList networkIds;
178 /*** handled by SignalProxy ***/
180 struct SignalProxyMessage
182 inline Handler handler() const { return Handler::SignalProxy; }
186 struct SyncMessage : public SignalProxyMessage
188 inline SyncMessage(const QByteArray &className, const QString &objectName, const QByteArray &slotName, const QVariantList ¶ms)
189 : className(className), objectName(objectName), slotName(slotName), params(params) {}
191 QByteArray className;
198 struct RpcCall : public SignalProxyMessage
200 inline RpcCall(const QByteArray &slotName, const QVariantList ¶ms)
201 : slotName(slotName), params(params) {}
208 struct InitRequest : public SignalProxyMessage
210 inline InitRequest(const QByteArray &className, const QString &objectName)
211 : className(className), objectName(objectName) {}
213 QByteArray className;
218 struct InitData : public SignalProxyMessage
220 inline InitData(const QByteArray &className, const QString &objectName, const QVariantMap &initData)
221 : className(className), objectName(objectName), initData(initData) {}
223 QByteArray className;
225 QVariantMap initData;
229 /*** handled by RemoteConnection ***/
233 inline HeartBeat(const QDateTime ×tamp) : timestamp(timestamp) {}
239 struct HeartBeatReply
241 inline HeartBeatReply(const QDateTime ×tamp) : timestamp(timestamp) {}