Daniel Brötzmann pushed to branch public-encryption-button at gajim / gajim

Commits:

4 changed files:

Changes:

  • data/gajim.doap
    ... ... @@ -170,8 +170,9 @@
    170 170
         <implements>
    
    171 171
           <xmpp:SupportedXep>
    
    172 172
             <xmpp:xep rdf:resource="https://xmpp.org/extensions/xep-0071.html"/>
    
    173
    -        <xmpp:status>complete</xmpp:status>
    
    173
    +        <xmpp:status>removed</xmpp:status>
    
    174 174
             <xmpp:version>1.4</xmpp:version>
    
    175
    +        <xmpp:since>1.4.0</xmpp:since>
    
    175 176
           </xmpp:SupportedXep>
    
    176 177
         </implements>
    
    177 178
         <implements>
    
    ... ... @@ -343,8 +344,9 @@
    343 344
         <implements>
    
    344 345
           <xmpp:SupportedXep>
    
    345 346
             <xmpp:xep rdf:resource="https://xmpp.org/extensions/xep-0174.html"/>
    
    346
    -        <xmpp:status>complete</xmpp:status>
    
    347
    +        <xmpp:status>removed</xmpp:status>
    
    347 348
             <xmpp:version>2.0</xmpp:version>
    
    349
    +        <xmpp:since>1.4.0</xmpp:since>
    
    348 350
           </xmpp:SupportedXep>
    
    349 351
         </implements>
    
    350 352
         <implements>
    
    ... ... @@ -673,7 +675,7 @@
    673 675
           <xmpp:SupportedXep>
    
    674 676
             <xmpp:xep rdf:resource="https://xmpp.org/extensions/xep-0441.html"/>
    
    675 677
             <xmpp:status>complete</xmpp:status>
    
    676
    -        <xmpp:version>0.2</xmpp:version>
    
    678
    +        <xmpp:version>0.2.0</xmpp:version>
    
    677 679
           </xmpp:SupportedXep>
    
    678 680
         </implements>
    
    679 681
         <implements>
    

  • gajim/common/modules/contacts.py
    ... ... @@ -671,6 +671,15 @@ def is_irc(self) -> bool:
    671 671
                 return False
    
    672 672
             return disco_info.is_irc
    
    673 673
     
    
    674
    +    @property
    
    675
    +    def encryption_available(self) -> bool:
    
    676
    +        disco_info = self.get_disco()
    
    677
    +        if disco_info is None:
    
    678
    +            return True
    
    679
    +
    
    680
    +        return (disco_info.muc_is_members_only and
    
    681
    +                disco_info.muc_is_nonanonymous)
    
    682
    +
    
    674 683
         def get_config_value(self, field_name: str) -> Any:
    
    675 684
             disco_info = self.get_disco()
    
    676 685
             assert disco_info is not None
    

  • gajim/data/gui/message_actions_box.ui
    1 1
     <?xml version="1.0" encoding="UTF-8"?>
    
    2
    -<!-- Generated with glade 3.38.2 -->
    
    2
    +<!-- Generated with glade 3.40.0 -->
    
    3 3
     <interface>
    
    4 4
       <requires lib="gtk+" version="3.24"/>
    
    5 5
       <object class="GtkBox" id="box">
    
    ... ... @@ -91,7 +91,6 @@
    91 91
             <property name="visible">True</property>
    
    92 92
             <property name="can-focus">True</property>
    
    93 93
             <property name="receives-default">True</property>
    
    94
    -        <property name="tooltip-text" translatable="yes">Choose encryption</property>
    
    95 94
             <property name="relief">none</property>
    
    96 95
             <child>
    
    97 96
               <object class="GtkImage" id="encryption_image">
    

  • gajim/gtk/message_actions_box.py
    ... ... @@ -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()