1 /***************************************************************************
2 * Copyright (C) 2005-2019 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 ***************************************************************************/
27 #include <QVariantList>
33 const quint32 magic = 0x42b33f00;
37 InternalProtocol = 0x00,
38 LegacyProtocol = 0x01,
39 DataStreamProtocol = 0x02
54 /*** Handshake, handled by AuthHandler ***/
56 struct HandshakeMessage
58 inline Handler handler() const { return Handler::AuthHandler; }
61 struct RegisterClient : public HandshakeMessage
63 inline RegisterClient(Quassel::Features clientFeatures, QString clientVersion, QString buildDate, bool sslSupported = false)
64 : features(std::move(clientFeatures))
65 , clientVersion(std::move(clientVersion))
66 , buildDate(std::move(buildDate))
67 , sslSupported(sslSupported)
70 Quassel::Features features;
71 QString clientVersion;
74 // this is only used by the LegacyProtocol in compat mode
78 struct ClientDenied : public HandshakeMessage
80 inline ClientDenied(QString errorString)
81 : errorString(std::move(errorString))
87 struct ClientRegistered : public HandshakeMessage
89 inline ClientRegistered(
90 Quassel::Features coreFeatures, bool coreConfigured, QVariantList backendInfo, QVariantList authenticatorInfo, bool sslSupported)
91 : features(std::move(coreFeatures))
92 , coreConfigured(coreConfigured)
93 , backendInfo(std::move(backendInfo))
94 , authenticatorInfo(std::move(authenticatorInfo))
95 , sslSupported(sslSupported)
98 Quassel::Features features;
100 QVariantList backendInfo; // TODO: abstract this better
102 // The authenticatorInfo should be optional!
103 QVariantList authenticatorInfo;
105 // this is only used by the LegacyProtocol in compat mode
109 struct SetupData : public HandshakeMessage
111 inline SetupData(QString adminUser,
112 QString adminPassword,
114 QVariantMap setupData,
115 QString authenticator = QString(),
116 QVariantMap authSetupData = QVariantMap())
117 : adminUser(std::move(adminUser))
118 , adminPassword(std::move(adminPassword))
119 , backend(std::move(backend))
120 , setupData(std::move(setupData))
121 , authenticator(std::move(authenticator))
122 , authSetupData(std::move(authSetupData))
126 QString adminPassword;
128 QVariantMap setupData;
129 QString authenticator;
130 QVariantMap authSetupData;
133 struct SetupFailed : public HandshakeMessage
135 inline SetupFailed(QString errorString)
136 : errorString(std::move(errorString))
142 struct SetupDone : public HandshakeMessage
145 struct Login : public HandshakeMessage
147 inline Login(QString user, QString password)
148 : user(std::move(user))
149 , password(std::move(password))
156 struct LoginFailed : public HandshakeMessage
158 inline LoginFailed(QString errorString)
159 : errorString(std::move(errorString))
165 struct LoginSuccess : public HandshakeMessage
168 // TODO: more generic format
169 struct SessionState : public HandshakeMessage
171 inline SessionState() = default; // needed for QMetaType (for the mono client)
172 inline SessionState(QVariantList identities, QVariantList bufferInfos, QVariantList networkIds)
173 : identities(std::move(identities))
174 , bufferInfos(std::move(bufferInfos))
175 , networkIds(std::move(networkIds))
178 QVariantList identities;
179 QVariantList bufferInfos;
180 QVariantList networkIds;
183 /*** handled by SignalProxy ***/
185 struct SignalProxyMessage
187 inline Handler handler() const { return Handler::SignalProxy; }
190 struct SyncMessage : public SignalProxyMessage
192 SyncMessage() = default;
193 SyncMessage(QByteArray className, QString objectName, QByteArray slotName, QVariantList params)
194 : className(std::move(className))
195 , objectName(std::move(objectName))
196 , slotName(std::move(slotName))
197 , params(std::move(params))
200 QByteArray className;
206 struct RpcCall : public SignalProxyMessage
209 RpcCall(QByteArray signalName, QVariantList params)
210 : signalName(std::move(signalName))
211 , params(std::move(params))
214 QByteArray signalName;
218 struct InitRequest : public SignalProxyMessage
220 InitRequest() = default;
221 InitRequest(QByteArray className, QString objectName)
222 : className(std::move(className))
223 , objectName(std::move(objectName))
226 QByteArray className;
230 struct InitData : public SignalProxyMessage
232 InitData() = default;
233 InitData(QByteArray className, QString objectName, QVariantMap initData)
234 : className(std::move(className))
235 , objectName(std::move(objectName))
236 , initData(std::move(initData))
239 QByteArray className;
241 QVariantMap initData;
244 /*** handled by RemoteConnection ***/
248 inline HeartBeat(QDateTime timestamp)
249 : timestamp(std::move(timestamp))
255 struct HeartBeatReply
257 inline HeartBeatReply(QDateTime timestamp)
258 : timestamp(std::move(timestamp))
264 } // namespace Protocol
266 // Required for InternalPeer
267 Q_DECLARE_METATYPE(Protocol::SyncMessage)
268 Q_DECLARE_METATYPE(Protocol::RpcCall)
269 Q_DECLARE_METATYPE(Protocol::InitRequest)
270 Q_DECLARE_METATYPE(Protocol::InitData)