| ... |
... |
@@ -219,9 +219,8 @@ def switch_contact(self, contact: ChatContactT) -> None: |
|
219
|
219
|
|
|
220
|
220
|
self._set_settings_menu(contact)
|
|
221
|
221
|
|
|
222
|
|
- encryption = self._contact.settings.get('encryption')
|
|
223
|
|
- self._set_encryption_state(encryption)
|
|
224
|
|
- self._set_encryption_details(encryption)
|
|
|
222
|
+ self._update_encryption_button()
|
|
|
223
|
+ self._update_encryption_details_button()
|
|
225
|
224
|
|
|
226
|
225
|
self._set_chatstate(True)
|
|
227
|
226
|
|
| ... |
... |
@@ -286,18 +285,6 @@ def _set_chatstate(self, state: bool) -> None: |
|
286
|
285
|
self._client.get_module('Chatstate').set_chatstate(
|
|
287
|
286
|
self._contact, Chatstate.INACTIVE)
|
|
288
|
287
|
|
|
289
|
|
- def _set_encryption_state(self, state: str) -> None:
|
|
290
|
|
- action = app.window.get_action('set-encryption')
|
|
291
|
|
- action.set_state(GLib.Variant('s', state))
|
|
292
|
|
-
|
|
293
|
|
- if state in ('OMEMO', 'OpenPGP', 'PGP'):
|
|
294
|
|
- icon_name = 'channel-secure-symbolic'
|
|
295
|
|
- else:
|
|
296
|
|
- icon_name = 'channel-insecure-symbolic'
|
|
297
|
|
-
|
|
298
|
|
- self._ui.encryption_image.set_from_icon_name(icon_name,
|
|
299
|
|
- Gtk.IconSize.MENU)
|
|
300
|
|
-
|
|
301
|
288
|
def _change_encryption(self,
|
|
302
|
289
|
action: Gio.SimpleAction,
|
|
303
|
290
|
param: GLib.Variant
|
| ... |
... |
@@ -319,13 +306,43 @@ def _change_encryption(self, |
|
319
|
306
|
if not plugin.activate_encryption(app.window.get_control()):
|
|
320
|
307
|
return
|
|
321
|
308
|
|
|
322
|
|
- self._set_encryption_state(new_state)
|
|
323
|
309
|
contact = self.get_current_contact()
|
|
324
|
310
|
contact.settings.set('encryption', new_state)
|
|
325
|
311
|
|
|
326
|
|
- self._set_encryption_details(new_state)
|
|
|
312
|
+ self._update_encryption_button()
|
|
|
313
|
+ self._update_encryption_details_button()
|
|
|
314
|
+
|
|
|
315
|
+ def _update_encryption_button(self) -> None:
|
|
|
316
|
+ contact = self.get_current_contact()
|
|
|
317
|
+ state = contact.settings.get('encryption')
|
|
|
318
|
+
|
|
|
319
|
+ action = app.window.get_action('set-encryption')
|
|
|
320
|
+ action.set_state(GLib.Variant('s', state))
|
|
|
321
|
+
|
|
|
322
|
+ sensitive = True
|
|
|
323
|
+ tooltip = _('Choose encryption')
|
|
|
324
|
+
|
|
|
325
|
+ if state in ('OMEMO', 'OpenPGP', 'PGP'):
|
|
|
326
|
+ icon_name = 'channel-secure-symbolic'
|
|
|
327
|
+ else:
|
|
|
328
|
+ icon_name = 'channel-insecure-symbolic'
|
|
|
329
|
+
|
|
|
330
|
+ if isinstance(self._contact, GroupchatContact):
|
|
|
331
|
+ if not self._contact.encryption_available:
|
|
|
332
|
+ sensitive = False
|
|
|
333
|
+ tooltip = _('This is a public group chat. '
|
|
|
334
|
+ 'Encryption is not available.')
|
|
|
335
|
+ icon_name = 'channel-insecure-symbolic'
|
|
|
336
|
+
|
|
|
337
|
+ self._ui.encryption_menu_button.set_sensitive(sensitive)
|
|
|
338
|
+ self._ui.encryption_menu_button.set_tooltip_text(tooltip)
|
|
|
339
|
+ self._ui.encryption_image.set_from_icon_name(
|
|
|
340
|
+ icon_name, Gtk.IconSize.MENU)
|
|
|
341
|
+
|
|
|
342
|
+ def _update_encryption_details_button(self) -> None:
|
|
|
343
|
+ contact = self.get_current_contact()
|
|
|
344
|
+ state = contact.settings.get('encryption')
|
|
327
|
345
|
|
|
328
|
|
- def _set_encryption_details(self, state: str) -> None:
|
|
329
|
346
|
encryption_state = {'visible': bool(state),
|
|
330
|
347
|
'enc_type': state,
|
|
331
|
348
|
'authenticated': False}
|
| ... |
... |
@@ -341,19 +358,22 @@ def _set_encryption_details(self, state: str) -> None: |
|
341
|
358
|
|
|
342
|
359
|
if authenticated:
|
|
343
|
360
|
authenticated_string = _('and authenticated')
|
|
344
|
|
- self._ui.encryption_details_image.set_from_icon_name(
|
|
345
|
|
- 'security-high-symbolic', Gtk.IconSize.MENU)
|
|
|
361
|
+ icon_name = 'security-high-symbolic'
|
|
346
|
362
|
else:
|
|
347
|
363
|
authenticated_string = _('and NOT authenticated')
|
|
348
|
|
- self._ui.encryption_details_image.set_from_icon_name(
|
|
349
|
|
- 'security-low-symbolic', Gtk.IconSize.MENU)
|
|
|
364
|
+ icon_name = 'security-low-symbolic'
|
|
350
|
365
|
|
|
351
|
366
|
tooltip = _('%(type)s encryption is active %(authenticated)s.') % {
|
|
352
|
|
- 'type': enc_type, 'authenticated': authenticated_string}
|
|
|
367
|
+ 'type': enc_type,
|
|
|
368
|
+ 'authenticated': authenticated_string}
|
|
|
369
|
+
|
|
|
370
|
+ if isinstance(self._contact, GroupchatContact) and visible:
|
|
|
371
|
+ visible = self._contact.encryption_available
|
|
353
|
372
|
|
|
354
|
|
- self._ui.encryption_details_button.set_tooltip_text(tooltip)
|
|
355
|
373
|
self._ui.encryption_details_button.set_visible(visible)
|
|
356
|
|
- self._ui.encryption_details_image.set_sensitive(visible)
|
|
|
374
|
+ self._ui.encryption_details_button.set_tooltip_text(tooltip)
|
|
|
375
|
+ self._ui.encryption_details_image.set_from_icon_name(
|
|
|
376
|
+ icon_name, Gtk.IconSize.MENU)
|
|
357
|
377
|
|
|
358
|
378
|
def _on_encryption_details_clicked(self, _button: Gtk.Button) -> None:
|
|
359
|
379
|
contact = self.get_current_contact()
|