1 /***************************************************************************
2 * Copyright (C) 2005-2018 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 ***************************************************************************/
25 #include <QVariantList>
31 const quint32 magic = 0x42b33f00;
34 InternalProtocol = 0x00,
35 LegacyProtocol = 0x01,
36 DataStreamProtocol = 0x02
52 /*** Handshake, handled by AuthHandler ***/
54 struct HandshakeMessage {
55 inline Handler handler() const { return Handler::AuthHandler; }
59 struct RegisterClient : public HandshakeMessage
61 inline RegisterClient(Quassel::Features clientFeatures, const QString &clientVersion, const QString &buildDate, bool sslSupported = false)
62 : features(std::move(clientFeatures))
63 , clientVersion(clientVersion)
64 , buildDate(buildDate)
65 , sslSupported(sslSupported)
68 Quassel::Features features;
69 QString clientVersion;
72 // this is only used by the LegacyProtocol in compat mode
77 struct ClientDenied : public HandshakeMessage
79 inline ClientDenied(const QString &errorString)
80 : errorString(errorString) {}
86 struct ClientRegistered : public HandshakeMessage
88 inline ClientRegistered(Quassel::Features coreFeatures, bool coreConfigured, const QVariantList &backendInfo, const QVariantList &authenticatorInfo, bool sslSupported)
89 : features(std::move(coreFeatures))
90 , coreConfigured(coreConfigured)
91 , backendInfo(backendInfo)
92 , authenticatorInfo(authenticatorInfo)
93 , sslSupported(sslSupported)
96 Quassel::Features features;
98 QVariantList backendInfo; // TODO: abstract this better
100 // The authenticatorInfo should be optional!
101 QVariantList authenticatorInfo;
103 // this is only used by the LegacyProtocol in compat mode
108 struct SetupData : public HandshakeMessage
110 inline SetupData(const QString &adminUser, const QString &adminPassword, const QString &backend,
111 const QVariantMap &setupData, const QString &authenticator = QString(),
112 const QVariantMap &authSetupData = QVariantMap())
113 : adminUser(adminUser)
114 , adminPassword(adminPassword)
116 , setupData(setupData)
117 , authenticator(authenticator)
118 , authSetupData(authSetupData)
122 QString adminPassword;
124 QVariantMap setupData;
125 QString authenticator;
126 QVariantMap authSetupData;
130 struct SetupFailed : public HandshakeMessage
132 inline SetupFailed(const QString &errorString)
133 : errorString(errorString) {}
139 struct SetupDone : public HandshakeMessage
141 inline SetupDone() {}
145 struct Login : public HandshakeMessage
147 inline Login(const QString &user, const QString &password)
148 : user(user), password(password) {}
155 struct LoginFailed : public HandshakeMessage
157 inline LoginFailed(const QString &errorString)
158 : errorString(errorString) {}
164 struct LoginSuccess : public HandshakeMessage
166 inline LoginSuccess() {}
170 // TODO: more generic format
171 struct SessionState : public HandshakeMessage
173 inline SessionState() {} // needed for QMetaType (for the mono client)
174 inline SessionState(const QVariantList &identities, const QVariantList &bufferInfos, const QVariantList &networkIds)
175 : identities(identities), bufferInfos(bufferInfos), networkIds(networkIds) {}
177 QVariantList identities;
178 QVariantList bufferInfos;
179 QVariantList networkIds;
182 /*** handled by SignalProxy ***/
184 struct SignalProxyMessage
186 inline Handler handler() const { return Handler::SignalProxy; }
190 struct SyncMessage : public SignalProxyMessage
192 SyncMessage() = default;
193 SyncMessage(const QByteArray &className, const QString &objectName, const QByteArray &slotName, const QVariantList ¶ms)
194 : className(className), objectName(objectName), slotName(slotName), params(params) {}
196 QByteArray className;
203 struct RpcCall : public SignalProxyMessage
206 RpcCall(const QByteArray &slotName, const QVariantList ¶ms)
207 : slotName(slotName), params(params) {}
214 struct InitRequest : public SignalProxyMessage
216 InitRequest() = default;
217 InitRequest(const QByteArray &className, const QString &objectName)
218 : className(className), objectName(objectName) {}
220 QByteArray className;
225 struct InitData : public SignalProxyMessage
227 InitData() = default;
228 InitData(const QByteArray &className, const QString &objectName, const QVariantMap &initData)
229 : className(className), objectName(objectName), initData(initData) {}
231 QByteArray className;
233 QVariantMap initData;
237 /*** handled by RemoteConnection ***/
241 inline HeartBeat(const QDateTime ×tamp) : timestamp(timestamp) {}
247 struct HeartBeatReply
249 inline HeartBeatReply(const QDateTime ×tamp) : timestamp(timestamp) {}
257 // Required for InternalPeer
258 Q_DECLARE_METATYPE(Protocol::SyncMessage)
259 Q_DECLARE_METATYPE(Protocol::RpcCall)
260 Q_DECLARE_METATYPE(Protocol::InitRequest)
261 Q_DECLARE_METATYPE(Protocol::InitData)