Commit 8ab2ff1c authored by Airtower's avatar Airtower
Browse files

[omemo] UI to configure inactivity timeout

The idea is to let the user set after how many days without an OMEMO
message another device will be considered inactive, instead of a fixed
number of messages.

This commit adds only the configuration parameter for the plugin and
UI to set it, it does not change the actual inactivity handling.
parent 00e1bc16
......@@ -17,6 +17,7 @@
# along with OMEMO Gajim Plugin. If not, see <http://www.gnu.org/licenses/>.
import logging
from datetime import timedelta
from gi.repository import Gtk
from gi.repository import Gdk
......@@ -146,6 +147,10 @@ class OMEMOConfigDialog(Gtk.ApplicationWindow):
def _on_blind_trust(self, button):
self._plugin.config['BLIND_TRUST'] = button.get_active()
def _on_inactivity_days(self, adjustment):
self._plugin.config['INACTIVITY_TIMEOUT'] = \
timedelta(days=adjustment.get_value())
def update_context_list(self):
self._ui.deviceid_store.clear()
......@@ -181,3 +186,5 @@ class OMEMOConfigDialog(Gtk.ApplicationWindow):
def update_settings(self):
self._ui.blind_trust_checkbutton.set_active(
self._plugin.config['BLIND_TRUST'])
self._ui.inactivity_days.set_value(
self._plugin.config['INACTIVITY_TIMEOUT'].days)
......@@ -20,6 +20,14 @@
<column type="gchararray"/>
</columns>
</object>
<object class="GtkAdjustment" id="inactivity_days">
<property name="lower">1</property>
<property name="upper">365</property>
<property name="value">7</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
<signal name="value-changed" handler="_on_inactivity_days"/>
</object>
<object class="GtkNotebook" id="notebook1">
<property name="visible">True</property>
<property name="can_focus">True</property>
......@@ -543,9 +551,11 @@ It is advised to go online with all of your actively used devices after clearing
<property name="top_padding">12</property>
<property name="left_padding">12</property>
<child>
<object class="GtkGrid">
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">5</property>
<child>
<object class="GtkCheckButton" id="blind_trust_checkbutton">
<property name="label" translatable="yes">Blind Trust Before Verification</property>
......@@ -556,8 +566,52 @@ It is advised to go online with all of your actively used devices after clearing
<signal name="toggled" handler="_on_blind_trust" swapped="no"/>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">5</property>
<child>
<object class="GtkSpinButton" id="inactivity_days_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="width_chars">3</property>
<property name="progress_pulse_step">1</property>
<property name="input_purpose">number</property>
<property name="adjustment">inactivity_days</property>
<property name="numeric">True</property>
<property name="value">1</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">Days before a device is considered inactive</property>
<property name="track_visited_links">False</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
......
......@@ -19,6 +19,7 @@
import logging
import binascii
import threading
from datetime import timedelta
from enum import IntEnum, unique
from pathlib import Path
from functools import partial
......@@ -119,6 +120,7 @@ class OmemoPlugin(GajimPlugin):
'DISABLED_ACCOUNTS': ([], ''),
'BLIND_TRUST': (True, ''),
'SHOW_HELP_FINGERPRINTS': (True, ''),
'INACTIVITY_TIMEOUT': (timedelta(days=7), ''),
}
for account in self.config['DISABLED_ACCOUNTS']:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment