settings: Add server-time to Network Features tab
authorShane Synan <digitalcircuit36939@gmail.com>
Wed, 26 Aug 2020 22:28:56 +0000 (18:28 -0400)
committerManuel Nickschas <sputnick@quassel-irc.org>
Sat, 28 Nov 2020 12:42:31 +0000 (13:42 +0100)
Add the IRCv3 "server-time" capability to the Features UI to make it
simple to disable.

Reasoning:
IRC networks with improperly configured time may result in the wrong
time showing in Quassel.  This.. really shouldn't happen in Year 2020,
but it's come up in the freenode/#kiwiirc support channel.
(In the future, Quassel should add intelligent detection of time-sync
issues, mimicking Kiwi IRC's timedelta feature.)

src/qtui/settingspages/networkssettingspage.cpp
src/qtui/settingspages/networkssettingspage.ui

index c9de1ac..0f67de2 100644 (file)
@@ -91,7 +91,8 @@ NetworksSettingsPage::NetworksSettingsPage(QWidget* parent)
                                     ui.sendEncoding,         ui.recvEncoding,         ui.serverEncoding,
                                     ui.autoReconnect,        ui.reconnectInterval,    ui.reconnectRetries,
                                     ui.unlimitedRetries,     ui.rejoinOnReconnect,    ui.useCustomMessageRate,
-                                    ui.messageRateBurstSize, ui.messageRateDelay,     ui.unlimitedMessageRate},
+                                    ui.messageRateBurstSize, ui.messageRateDelay,     ui.unlimitedMessageRate,
+                                    ui.enableCapServerTime},
                                    this,
                                    &NetworksSettingsPage::widgetHasChanged);
 
@@ -641,6 +642,8 @@ void NetworksSettingsPage::displayNetwork(NetworkId id)
         ui.messageRateBurstSize->setValue(info.messageRateBurstSize);
         // Convert milliseconds (integer) into seconds (double)
         ui.messageRateDelay->setValue(info.messageRateDelay / 1000.0f);
+        // Skipped IRCv3 capabilities
+        ui.enableCapServerTime->setChecked(!info.skipCaps.contains(IrcCap::SERVER_TIME));
     }
     else {
         // just clear widgets
@@ -693,6 +696,14 @@ void NetworksSettingsPage::saveToNetworkInfo(NetworkInfo& info)
     // Convert seconds (double) into milliseconds (integer)
     info.messageRateDelay = static_cast<quint32>((ui.messageRateDelay->value() * 1000));
     info.unlimitedMessageRate = ui.unlimitedMessageRate->isChecked();
+    // Skipped IRCv3 capabilities
+    if (ui.enableCapServerTime->isChecked()) {
+        // Capability enabled, remove it from the skip list
+        info.skipCaps.removeAll(IrcCap::SERVER_TIME);
+    } else if (!info.skipCaps.contains(IrcCap::SERVER_TIME)) {
+        // Capability disabled and not in the skip list, add it
+        info.skipCaps.append(IrcCap::SERVER_TIME);
+    }
 }
 
 void NetworksSettingsPage::clientNetworkCapsUpdated()
index e56a7fc..03a8321 100644 (file)
@@ -952,6 +952,24 @@ Note that Quassel IRC automatically rejoins channels, so /join will rarely be ne
              <property name="bottomMargin">
               <number>0</number>
              </property>
+             <item>
+              <widget class="QCheckBox" name="enableCapServerTime">
+               <property name="sizePolicy">
+                <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+                 <horstretch>0</horstretch>
+                 <verstretch>0</verstretch>
+                </sizepolicy>
+               </property>
+               <property name="toolTip">
+                <string>&lt;p&gt;Let the IRC network control the timestamps for messages, such as when viewing messages from the past.&lt;/p&gt;
+&lt;p&gt;This is useful when connecting to bouncers, IRC bridges, or networks that send messages you've missed when reconnecting.&lt;/p&gt;
+&lt;p&gt;&lt;i&gt;Toggles the IRCv3 'server-time' capability.&lt;/i&gt;&lt;/p&gt;</string>
+               </property>
+               <property name="text">
+                <string>Use network timestamps for messages</string>
+               </property>
+              </widget>
+             </item>
              <item>
               <layout class="QHBoxLayout" name="horizontalLayout_9">
                <item>
@@ -1170,6 +1188,7 @@ This setting defines the encoding for messages that are not UTF-8.</string>
   <tabstop>autoIdentifyService</tabstop>
   <tabstop>autoIdentifyPassword</tabstop>
   <tabstop>enableCapsStatusDetails</tabstop>
+  <tabstop>enableCapServerTime</tabstop>
   <tabstop>enableCapsAdvanced</tabstop>
   <tabstop>useCustomEncodings</tabstop>
   <tabstop>sendEncoding</tabstop>