1 /***************************************************************************
2 * Copyright (C) 2005-2022 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;
35 const quint32 proxyMagic = 0x50524f58;
39 InternalProtocol = 0x00,
40 LegacyProtocol = 0x01,
41 DataStreamProtocol = 0x02
56 /*** Handshake, handled by AuthHandler ***/
58 struct HandshakeMessage
60 inline Handler handler() const { return Handler::AuthHandler; }
63 struct RegisterClient : public HandshakeMessage
65 inline RegisterClient(Quassel::Features clientFeatures, QString clientVersion, QString buildDate, bool sslSupported = false)
66 : features(std::move(clientFeatures))
67 , clientVersion(std::move(clientVersion))
68 , buildDate(std::move(buildDate))
69 , sslSupported(sslSupported)
72 Quassel::Features features;
73 QString clientVersion;
76 // this is only used by the LegacyProtocol in compat mode
80 struct ClientDenied : public HandshakeMessage
82 inline ClientDenied(QString errorString)
83 : errorString(std::move(errorString))
89 struct ClientRegistered : public HandshakeMessage
91 inline ClientRegistered(
92 Quassel::Features coreFeatures, bool coreConfigured, QVariantList backendInfo, QVariantList authenticatorInfo, bool sslSupported)
93 : features(std::move(coreFeatures))
94 , coreConfigured(coreConfigured)
95 , backendInfo(std::move(backendInfo))
96 , authenticatorInfo(std::move(authenticatorInfo))
97 , sslSupported(sslSupported)
100 Quassel::Features features;
102 QVariantList backendInfo; // TODO: abstract this better
104 // The authenticatorInfo should be optional!
105 QVariantList authenticatorInfo;
107 // this is only used by the LegacyProtocol in compat mode
111 struct SetupData : public HandshakeMessage
113 inline SetupData(QString adminUser,
114 QString adminPassword,
116 QVariantMap setupData,
117 QString authenticator = QString(),
118 QVariantMap authSetupData = QVariantMap())
119 : adminUser(std::move(adminUser))
120 , adminPassword(std::move(adminPassword))
121 , backend(std::move(backend))
122 , setupData(std::move(setupData))
123 , authenticator(std::move(authenticator))
124 , authSetupData(std::move(authSetupData))
128 QString adminPassword;
130 QVariantMap setupData;
131 QString authenticator;
132 QVariantMap authSetupData;
135 struct SetupFailed : public HandshakeMessage
137 inline SetupFailed(QString errorString)
138 : errorString(std::move(errorString))
144 struct SetupDone : public HandshakeMessage
147 struct Login : public HandshakeMessage
149 inline Login(QString user, QString password)
150 : user(std::move(user))
151 , password(std::move(password))
158 struct LoginFailed : public HandshakeMessage
160 inline LoginFailed(QString errorString)
161 : errorString(std::move(errorString))
167 struct LoginSuccess : public HandshakeMessage
170 // TODO: more generic format
171 struct SessionState : public HandshakeMessage
173 inline SessionState() = default; // needed for QMetaType (for the mono client)
174 inline SessionState(QVariantList identities, QVariantList bufferInfos, QVariantList networkIds)
175 : identities(std::move(identities))
176 , bufferInfos(std::move(bufferInfos))
177 , networkIds(std::move(networkIds))
180 QVariantList identities;
181 QVariantList bufferInfos;
182 QVariantList networkIds;
185 /*** handled by SignalProxy ***/
187 struct SignalProxyMessage
189 inline Handler handler() const { return Handler::SignalProxy; }
192 struct SyncMessage : public SignalProxyMessage
194 SyncMessage() = default;
195 SyncMessage(QByteArray className, QString objectName, QByteArray slotName, QVariantList params)
196 : className(std::move(className))
197 , objectName(std::move(objectName))
198 , slotName(std::move(slotName))
199 , params(std::move(params))
202 QByteArray className;
208 struct RpcCall : public SignalProxyMessage
211 RpcCall(QByteArray signalName, QVariantList params)
212 : signalName(std::move(signalName))
213 , params(std::move(params))
216 QByteArray signalName;
220 struct InitRequest : public SignalProxyMessage
222 InitRequest() = default;
223 InitRequest(QByteArray className, QString objectName)
224 : className(std::move(className))
225 , objectName(std::move(objectName))
228 QByteArray className;
232 struct InitData : public SignalProxyMessage
234 InitData() = default;
235 InitData(QByteArray className, QString objectName, QVariantMap initData)
236 : className(std::move(className))
237 , objectName(std::move(objectName))
238 , initData(std::move(initData))
241 QByteArray className;
243 QVariantMap initData;
246 /*** handled by RemoteConnection ***/
250 inline HeartBeat(QDateTime timestamp)
251 : timestamp(std::move(timestamp))
257 struct HeartBeatReply
259 inline HeartBeatReply(QDateTime timestamp)
260 : timestamp(std::move(timestamp))
266 } // namespace Protocol
268 // Required for InternalPeer
269 Q_DECLARE_METATYPE(Protocol::SyncMessage)
270 Q_DECLARE_METATYPE(Protocol::RpcCall)
271 Q_DECLARE_METATYPE(Protocol::InitRequest)
272 Q_DECLARE_METATYPE(Protocol::InitData)