+ // 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, &CoreInfoDlg::refreshLegacyCoreInfo);
+}
+
+void CoreInfoDlg::coreInfoResynchronized()
+{
+ // CoreInfo object has been recreated, or this is the first time the dialog's been shown
+
+ CoreInfo* coreInfo = Client::coreInfo();
+ // Listen for changes to core information
+ connect(coreInfo, &CoreInfo::coreDataChanged, this, &CoreInfoDlg::coreInfoChanged);
+
+ // Update with any known core information set before connecting the signal. This is needed for
+ // both modern (0.13+) and legacy cores.
+ coreInfoChanged(coreInfo->coreData());
+}
+
+void CoreInfoDlg::coreInfoChanged(const QVariantMap& coreInfo)
+{
+ if (coreInfo.isEmpty()) {
+ // We're missing data for some reason
+ if (Client::isConnected()) {
+ // Core info is entirely empty despite being connected. Something's probably wrong.
+ ui.labelCoreVersion->setText(tr("Unknown"));
+ ui.labelCoreVersionDate->setText(tr("Unknown"));
+ }
+ else {
+ // We're disconnected. Mark as such.
+ ui.labelCoreVersion->setText(tr("Disconnected from core"));
+ ui.labelCoreVersionDate->setText(tr("Not available"));
+ }
+ ui.labelClientCount->setNum(0);
+ // Don't return, allow the code below to remove any existing session widgets
+ }
+ else {
+ ui.labelCoreVersion->setText(coreInfo["quasselVersion"].toString());
+ // "BuildDate" for compatibility
+ if (coreInfo["quasselBuildDate"].toString().isEmpty()) {
+ ui.labelCoreVersionDate->setText(QString("<i>%1</i>").arg(tr("Unknown date")));
+ }
+ else {
+ ui.labelCoreVersionDate->setText(
+ tryFormatUnixEpoch(coreInfo["quasselBuildDate"].toString(), Qt::DateFormat::DefaultLocaleShortDate));
+ }
+ ui.labelClientCount->setNum(coreInfo["sessionConnectedClients"].toInt());
+ }