/***************************************************************************
- * 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 <QHostAddress>
+#include <QDataStream>
#include <QTcpSocket>
#include "legacypeer.h"
-#include "quassel.h"
+#include "serializers/serializers.h"
/* version.inc is no longer used for this */
const uint protocolVersion = 10;
using namespace Protocol;
-LegacyPeer::LegacyPeer(::AuthHandler *authHandler, QTcpSocket *socket, QObject *parent)
- : RemotePeer(authHandler, socket, Compressor::NoCompression, parent),
+LegacyPeer::LegacyPeer(::AuthHandler *authHandler, QTcpSocket *socket, Compressor::CompressionLevel level, QObject *parent)
+ : RemotePeer(authHandler, socket, level, parent),
_useCompression(false)
{
QVariant item;
if (_useCompression) {
QByteArray rawItem;
- stream >> rawItem;
+ if (!Serializers::deserialize(stream, 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, item)) {
+ close("Peer sent corrupt data: unable to load QVariant!");
+ return;
+ }
+ } else {
+ if (!Serializers::deserialize(stream, 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["UseSsl"].toBool()));
+ handle(RegisterClient(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(), QDateTime()));
+ handle(ClientRegistered(m["CoreFeatures"].toUInt(), m["Configured"].toBool(), m["StorageBackends"].toList(), m["SupportSsl"].toBool()));
}
else if (msgType == "CoreSetupData") {
QVariantMap m;
m["MsgType"] = "ClientInit";
m["ClientVersion"] = msg.clientVersion;
- m["ClientDate"] = Quassel::buildInfo().buildDate;
+ m["ClientDate"] = msg.buildDate;
// 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)
- int uptime = msg.coreStartTime.secsTo(QDateTime::currentDateTime().toUTC());
- int updays = uptime / 86400; uptime %= 86400;
- int uphours = uptime / 3600; uptime %= 3600;
- int upmins = uptime / 60;
- m["CoreInfo"] = tr("<b>Quassel Core Version %1</b><br>"
- "Built: %2<br>"
- "Up %3d%4h%5m (since %6)").arg(Quassel::buildInfo().fancyVersionString)
- .arg(Quassel::buildInfo().buildDate)
- .arg(updays).arg(uphours, 2, 10, QChar('0')).arg(upmins, 2, 10, QChar('0')).arg(msg.coreStartTime.toString(Qt::TextDate));
+ // 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;