client: Poll legacy CoreInfo when dialog is open
authorShane Synan <digitalcircuit36939@gmail.com>
Mon, 18 Jun 2018 21:13:36 +0000 (16:13 -0500)
committerManuel Nickschas <sputnick@quassel-irc.org>
Tue, 19 Jun 2018 00:02:15 +0000 (02:02 +0200)
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.

src/qtui/coreinfodlg.cpp
src/qtui/coreinfodlg.h

index 063e7a4..d952735 100644 (file)
@@ -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
 
index 0636534..458c6e0 100644 (file)
@@ -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
      *