From: Shane Synan Date: Mon, 18 Jun 2018 21:13:36 +0000 (-0500) Subject: client: Poll legacy CoreInfo when dialog is open X-Git-Tag: 0.13-rc1~33 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=66082987f41afa5c19d8cfa711f185f9d5fe4bb1 client: Poll legacy CoreInfo when dialog is open On legacy cores (lacking SyncedCoreInfo), when CoreInfoDlg is open, every 15 seconds resynchronize CoreInfo object to update the "Connected Clients" count. This matches expectations set by the counting uptime clock, and shouldn't be a significant data impact as info is only polled while the dialog is open. Modern cores (with SyncedCoreInfo) will not poll, using signals to update immediately as before. --- diff --git a/src/qtui/coreinfodlg.cpp b/src/qtui/coreinfodlg.cpp index 063e7a43..d9527358 100644 --- a/src/qtui/coreinfodlg.cpp +++ b/src/qtui/coreinfodlg.cpp @@ -35,7 +35,7 @@ CoreInfoDlg::CoreInfoDlg(QWidget *parent) : QDialog(parent) { // Update legacy core info for Quassel cores earlier than 0.13. This does nothing on modern // cores. - Client::refreshLegacyCoreInfo(); + refreshLegacyCoreInfo(); // Display existing core info, set up signal handlers coreInfoResynchronized(); @@ -48,6 +48,21 @@ CoreInfoDlg::CoreInfoDlg(QWidget *parent) : QDialog(parent) { } +void CoreInfoDlg::refreshLegacyCoreInfo() { + if (!Client::isConnected() || Client::isCoreFeatureEnabled(Quassel::Feature::SyncedCoreInfo)) { + // If we're not connected, or the core supports SyncedCoreInfo (0.13+), bail out + return; + } + + // Request legacy (pre-0.13) CoreInfo object to be resynchronized (does nothing on modern cores) + Client::refreshLegacyCoreInfo(); + + // On legacy cores, CoreInfo data does not send signals. Periodically poll for information. + // 15 seconds seems like a reasonable trade-off as this only happens while the dialog is open. + QTimer::singleShot(15 * 1000, this, SLOT(refreshLegacyCoreInfo())); +} + + void CoreInfoDlg::coreInfoResynchronized() { // CoreInfo object has been recreated, or this is the first time the dialog's been shown diff --git a/src/qtui/coreinfodlg.h b/src/qtui/coreinfodlg.h index 0636534b..458c6e0b 100644 --- a/src/qtui/coreinfodlg.h +++ b/src/qtui/coreinfodlg.h @@ -39,6 +39,14 @@ protected: void timerEvent(QTimerEvent *) override { updateUptime(); } private slots: + /** + * Requests resynchronization of CoreInfo object for legacy (pre-0.13) cores + * + * This provides compatibility with updating core information for legacy cores, and can be + * removed after protocol break. + */ + void refreshLegacyCoreInfo(); + /** * Handler for recreation of CoreInfo object, including first-time setup *