/***************************************************************************
- * Copyright (C) 2005-2014 by the Quassel Project *
+ * Copyright (C) 2005-2018 by the Quassel Project *
* devel@quassel-irc.org *
* *
* This program is free software; you can redistribute it and/or modify *
#include <QTcpSocket>
#include "legacypeer.h"
+#include "quassel.h"
+#include "serializers/serializers.h"
/* version.inc is no longer used for this */
const uint protocolVersion = 10;
QVariant item;
if (_useCompression) {
QByteArray rawItem;
- stream >> rawItem;
+ if (!Serializers::deserialize(stream, features(), rawItem)) {
+ close("Peer sent corrupt data: unable to load QVariant!");
+ return;
+ }
int nbytes = rawItem.size();
if (nbytes <= 4) {
QDataStream itemStream(&rawItem, QIODevice::ReadOnly);
itemStream.setVersion(QDataStream::Qt_4_2);
- itemStream >> item;
- }
- else {
- stream >> item;
+ if (!Serializers::deserialize(itemStream, features(), item)) {
+ close("Peer sent corrupt data: unable to load QVariant!");
+ return;
+ }
+ } else {
+ if (!Serializers::deserialize(stream, features(), item)) {
+ close("Peer sent corrupt data: unable to load QVariant!");
+ return;
+ }
}
if (stream.status() != QDataStream::Ok || !item.isValid()) {
socket()->setProperty("UseCompression", true);
}
#endif
- handle(RegisterClient(m["ClientVersion"].toString(), m["ClientDate"].toString(), m["UseSsl"].toBool()));
+ handle(RegisterClient{Quassel::Features{m["FeatureList"].toStringList(), Quassel::LegacyFeatures(m["Features"].toUInt())},
+ m["ClientVersion"].toString(),
+ m["ClientDate"].toString(),
+ m["UseSsl"].toBool()});
}
else if (msgType == "ClientInitReject") {
socket()->setProperty("UseCompression", true);
#endif
- handle(ClientRegistered(m["CoreFeatures"].toUInt(), m["Configured"].toBool(), m["StorageBackends"].toList(), m["SupportSsl"].toBool(), QString()));
+ handle(ClientRegistered{Quassel::Features{m["FeatureList"].toStringList(), Quassel::LegacyFeatures(m["CoreFeatures"].toUInt())},
+ m["Configured"].toBool(),
+ m["StorageBackends"].toList(),
+ m["Authenticators"].toList(),
+ m["SupportSsl"].toBool()});
}
else if (msgType == "CoreSetupData") {
QVariantMap map = m["SetupData"].toMap();
- handle(SetupData(map["AdminUser"].toString(), map["AdminPasswd"].toString(), map["Backend"].toString(), map["ConnectionProperties"].toMap()));
+ handle(SetupData(map["AdminUser"].toString(), map["AdminPasswd"].toString(), map["Backend"].toString(), map["ConnectionProperties"].toMap(), map["Authenticator"].toString(), map["AuthProperties"].toMap()));
}
else if (msgType == "CoreSetupReject") {
void LegacyPeer::dispatch(const RegisterClient &msg) {
QVariantMap m;
m["MsgType"] = "ClientInit";
+ m["Features"] = static_cast<quint32>(msg.features.toLegacyFeatures());
+ m["FeatureList"] = msg.features.toStringList();
m["ClientVersion"] = msg.clientVersion;
m["ClientDate"] = msg.buildDate;
void LegacyPeer::dispatch(const ClientRegistered &msg) {
QVariantMap m;
m["MsgType"] = "ClientInitAck";
- m["CoreFeatures"] = msg.coreFeatures;
+ if (hasFeature(Quassel::Feature::ExtendedFeatures)) {
+ m["FeatureList"] = msg.features.toStringList();
+ }
+ else {
+ m["CoreFeatures"] = static_cast<quint32>(msg.features.toLegacyFeatures());
+ }
m["StorageBackends"] = msg.backendInfo;
+ if (hasFeature(Quassel::Feature::Authenticators)) {
+ m["Authenticators"] = msg.authenticatorInfo;
+ }
// FIXME only in compat mode
m["ProtocolVersion"] = protocolVersion;
m["SupportSsl"] = msg.sslSupported;
m["SupportsCompression"] = socket()->property("UseCompression").toBool(); // this property gets already set in the ClientInit handler
- // This is only used for old v10 clients (pre-0.5)
- m["CoreInfo"] = msg.coreInfo;
+ // This is only used for display by really old v10 clients (pre-0.5), and we no longer set this
+ m["CoreInfo"] = QString();
m["LoginEnabled"] = m["Configured"] = msg.coreConfigured;
map["Backend"] = msg.backend;
map["ConnectionProperties"] = msg.setupData;
+ // Auth backend properties.
+ map["Authenticator"] = msg.authenticator;
+ map["AuthProperties"] = msg.authSetupData;
+
QVariantMap m;
m["MsgType"] = "CoreSetupData";
m["SetupData"] = map;