1 /***************************************************************************
2 * Copyright (C) 2005-2014 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;
49 /*** Handshake, handled by AuthHandler ***/
51 struct HandshakeMessage {
52 inline Handler handler() const { return AuthHandler; }
56 struct RegisterClient : public HandshakeMessage
58 inline RegisterClient(const QString &clientVersion, bool sslSupported = false)
59 : clientVersion(clientVersion)
60 , sslSupported(sslSupported) {}
62 QString clientVersion;
64 // this is only used by the LegacyProtocol in compat mode
69 struct ClientDenied : public HandshakeMessage
71 inline ClientDenied(const QString &errorString)
72 : errorString(errorString) {}
78 struct ClientRegistered : public HandshakeMessage
80 inline ClientRegistered(quint32 coreFeatures, bool coreConfigured, const QVariantList &backendInfo, bool sslSupported, const QDateTime &coreStartTime)
81 : coreFeatures(coreFeatures)
82 , coreConfigured(coreConfigured)
83 , backendInfo(backendInfo)
84 , sslSupported(sslSupported)
85 , coreStartTime(coreStartTime)
90 QVariantList backendInfo; // TODO: abstract this better
92 // this is only used by the LegacyProtocol in compat mode
94 QDateTime coreStartTime;
98 struct SetupData : public HandshakeMessage
100 inline SetupData(const QString &adminUser, const QString &adminPassword, const QString &backend, const QVariantMap &setupData)
101 : adminUser(adminUser), adminPassword(adminPassword), backend(backend), setupData(setupData) {}
104 QString adminPassword;
106 QVariantMap setupData;
110 struct SetupFailed : public HandshakeMessage
112 inline SetupFailed(const QString &errorString)
113 : errorString(errorString) {}
119 struct SetupDone : public HandshakeMessage
121 inline SetupDone() {}
125 struct Login : public HandshakeMessage
127 inline Login(const QString &user, const QString &password)
128 : user(user), password(password) {}
135 struct LoginFailed : public HandshakeMessage
137 inline LoginFailed(const QString &errorString)
138 : errorString(errorString) {}
144 struct LoginSuccess : public HandshakeMessage
146 inline LoginSuccess() {}
150 // TODO: more generic format
151 struct SessionState : public HandshakeMessage
153 inline SessionState() {} // needed for QMetaType (for the mono client)
154 inline SessionState(const QVariantList &identities, const QVariantList &bufferInfos, const QVariantList &networkIds)
155 : identities(identities), bufferInfos(bufferInfos), networkIds(networkIds) {}
157 QVariantList identities;
158 QVariantList bufferInfos;
159 QVariantList networkIds;
162 /*** handled by SignalProxy ***/
164 struct SignalProxyMessage
166 inline Handler handler() const { return SignalProxy; }
170 struct SyncMessage : public SignalProxyMessage
172 inline SyncMessage(const QByteArray &className, const QString &objectName, const QByteArray &slotName, const QVariantList ¶ms)
173 : className(className), objectName(objectName), slotName(slotName), params(params) {}
175 QByteArray className;
182 struct RpcCall : public SignalProxyMessage
184 inline RpcCall(const QByteArray &slotName, const QVariantList ¶ms)
185 : slotName(slotName), params(params) {}
192 struct InitRequest : public SignalProxyMessage
194 inline InitRequest(const QByteArray &className, const QString &objectName)
195 : className(className), objectName(objectName) {}
197 QByteArray className;
202 struct InitData : public SignalProxyMessage
204 inline InitData(const QByteArray &className, const QString &objectName, const QVariantMap &initData)
205 : className(className), objectName(objectName), initData(initData) {}
207 QByteArray className;
209 QVariantMap initData;
213 /*** handled by RemoteConnection ***/
217 inline HeartBeat(const QDateTime ×tamp) : timestamp(timestamp) {}
223 struct HeartBeatReply
225 inline HeartBeatReply(const QDateTime ×tamp) : timestamp(timestamp) {}