-
-void Core::processClientMessage(const QVariant &data)
-{
- RemotePeer *peer = qobject_cast<RemotePeer *>(sender());
- if (!peer) {
- qWarning() << Q_FUNC_INFO << "Message not sent by RemoteConnection!";
- return;
- }
-
- QVariantMap msg = data.toMap();
- if (!msg.contains("MsgType")) {
- // Client is way too old, does not even use the current init format
- qWarning() << qPrintable(tr("Antique client trying to connect... refusing."));
- peer->close();
- return;
- }
-
- // OK, so we have at least an init message format we can understand
- if (msg["MsgType"] == "ClientInit") {
- QVariantMap reply;
-
- // Just version information -- check it!
- uint ver = msg["ProtocolVersion"].toUInt();
- if (ver < Quassel::buildInfo().coreNeedsProtocol) {
- reply["MsgType"] = "ClientInitReject";
- reply["Error"] = tr("<b>Your Quassel Client is too old!</b><br>"
- "This core needs at least client/core protocol version %1.<br>"
- "Please consider upgrading your client.").arg(Quassel::buildInfo().coreNeedsProtocol);
- peer->writeSocketData(reply);
- qWarning() << qPrintable(tr("Client")) << peer->description() << qPrintable(tr("too old, rejecting."));
- peer->close();
- return;
- }
-
- reply["ProtocolVersion"] = Quassel::buildInfo().protocolVersion;
- reply["CoreVersion"] = Quassel::buildInfo().fancyVersionString;
- reply["CoreDate"] = Quassel::buildInfo().buildDate;
- reply["CoreStartTime"] = startTime(); // v10 clients don't necessarily parse this, see below
-
- // FIXME: newer clients no longer use the hardcoded CoreInfo (for now), since it gets the
- // time zone wrong. With the next protocol bump (10 -> 11), we should remove this
- // or make it properly configurable.
-
- int uptime = startTime().secsTo(QDateTime::currentDateTime().toUTC());
- int updays = uptime / 86400; uptime %= 86400;
- int uphours = uptime / 3600; uptime %= 3600;
- int upmins = uptime / 60;
- reply["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(startTime().toString(Qt::TextDate));
-
- reply["CoreFeatures"] = (int)Quassel::features();
-
-#ifdef HAVE_SSL
- SslServer *sslServer = qobject_cast<SslServer *>(&_server);
- QSslSocket *sslSocket = qobject_cast<QSslSocket *>(peer->socket());
- bool supportSsl = sslServer && sslSocket && sslServer->isCertValid();
-#else
- bool supportSsl = false;
-#endif
-
-#ifndef QT_NO_COMPRESS
- bool supportsCompression = true;
-#else
- bool supportsCompression = false;
-#endif
-
- reply["SupportSsl"] = supportSsl;
- reply["SupportsCompression"] = supportsCompression;
- // switch to ssl/compression after client has been informed about our capabilities (see below)
-
- reply["LoginEnabled"] = true;
-
- // check if we are configured, start wizard otherwise