disconnectFromCore();
return;
}
- emit connectionMsg(msg["CoreInfo"].toString());
+ emit connectionMsg(coreInfoString(msg));
#ifndef QT_NO_COMPRESS
if(msg["SupportsCompression"].toBool()) {
numNetsToSync = 0;
}
+QString ClientSyncer::coreInfoString(const QVariantMap &coreData) {
+ // check if we use a new enough core
+ // FIXME: this can go away after v11 protocol bump
+ if(!coreData.contains("CoreStartTime"))
+ return coreData.value("CoreInfo").toString();
+
+ QDateTime startTime = coreData.value("CoreStartTime").toDateTime().toLocalTime();
+ int uptime = startTime.secsTo(QDateTime::currentDateTime());
+ int updays = uptime / 86400; uptime %= 86400;
+ int uphours = uptime / 3600; uptime %= 3600;
+ int upmins = uptime / 60; uptime %= 60;
+
+ QString reply = tr("<b>Quassel Core Version %1</b><br>"
+ "Built: %2<br>"
+ "Up %3d%4h%5m (since %6)")
+ .arg(coreData.value("CoreVersion").toString())
+ .arg(coreData.value("CoreDate").toString())
+ .arg(updays).arg(uphours,2,10,QChar('0')).arg(upmins,2,10,QChar('0')).arg(startTime.toString(Qt::TextDate));
+
+ return reply;
+}
+
#ifdef HAVE_SSL
void ClientSyncer::ignoreSslWarnings(bool permanently) {
QSslSocket *sock = qobject_cast<QSslSocket *>(_socket);
else
KnownHostsSettings().saveKnownHost(sock);
}
- emit connectionMsg(_coreMsgBuffer["CoreInfo"].toString());
+ emit connectionMsg(coreInfoString(_coreMsgBuffer));
connectionReady();
}
socket->close(); return;
}
+ reply["ProtocolVersion"] = Quassel::buildInfo().protocolVersion;
reply["CoreVersion"] = Quassel::buildInfo().fancyVersionString;
reply["CoreDate"] = Quassel::buildInfo().buildDate;
- reply["ProtocolVersion"] = Quassel::buildInfo().protocolVersion;
- // TODO: Make the core info configurable
+ 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;