From: Manuel Nickschas Date: Fri, 11 Sep 2009 15:41:37 +0000 (+0200) Subject: Display correct core timezone in core connection dialog X-Git-Tag: 0.5-rc2~63 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=9b394f92cb61b759d18f9acc6a1125e2396b8cb7 Display correct core timezone in core connection dialog For this to work, the CoreInfo string is generated client-side for now, from the information new enough cores send. Older cores and/or clients will continue to use the core-side generated string. --- diff --git a/src/client/clientsyncer.cpp b/src/client/clientsyncer.cpp index 64d909fa..1af95b8f 100644 --- a/src/client/clientsyncer.cpp +++ b/src/client/clientsyncer.cpp @@ -197,7 +197,7 @@ void ClientSyncer::clientInitAck(const QVariantMap &msg) { disconnectFromCore(); return; } - emit connectionMsg(msg["CoreInfo"].toString()); + emit connectionMsg(coreInfoString(msg)); #ifndef QT_NO_COMPRESS if(msg["SupportsCompression"].toBool()) { @@ -345,6 +345,28 @@ void ClientSyncer::resetConnection() { 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("Quassel Core Version %1
" + "Built: %2
" + "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(_socket); @@ -358,7 +380,7 @@ void ClientSyncer::ignoreSslWarnings(bool permanently) { else KnownHostsSettings().saveKnownHost(sock); } - emit connectionMsg(_coreMsgBuffer["CoreInfo"].toString()); + emit connectionMsg(coreInfoString(_coreMsgBuffer)); connectionReady(); } diff --git a/src/client/clientsyncer.h b/src/client/clientsyncer.h index aa8d786a..8689279c 100644 --- a/src/client/clientsyncer.h +++ b/src/client/clientsyncer.h @@ -117,6 +117,8 @@ private: QSet netsToSync; int numNetsToSync; + + QString coreInfoString(const QVariantMap &); }; #endif diff --git a/src/core/core.cpp b/src/core/core.cpp index b2e3ee43..ebe1b08a 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -509,10 +509,15 @@ void Core::processClientMessage(QTcpSocket *socket, const QVariantMap &msg) { 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; diff --git a/src/qtui/ui/coreconnectdlg.ui b/src/qtui/ui/coreconnectdlg.ui index 395c95a7..f876bb7f 100644 --- a/src/qtui/ui/coreconnectdlg.ui +++ b/src/qtui/ui/coreconnectdlg.ui @@ -36,7 +36,7 @@ - 1 + 0