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

Commits:

7 changed files:

Changes:

  • .gitlab-ci.yml
    ... ... @@ -62,7 +62,9 @@ test-unittest:
    62 62
       coverage: "/TOTAL.+ ([0-9]{1,3}%)/"
    
    63 63
       artifacts:
    
    64 64
         reports:
    
    65
    -      cobertura: coverage.xml
    
    65
    +      coverage_report: 
    
    66
    +        coverage_format: cobertura
    
    67
    +        path: coverage.xml
    
    66 68
       interruptible: true
    
    67 69
     
    
    68 70
     build-linux:
    

  • debian/compat
    1
    +13

  • debian/control
    ... ... @@ -3,7 +3,7 @@ Section: net
    3 3
     Priority: optional
    
    4 4
     Maintainer: Gajim Maintainers <ci@gajim.org>
    
    5 5
     Build-Depends:
    
    6
    -    debhelper-compat (= 13),
    
    6
    +    debhelper (>= 13),
    
    7 7
         dh-python,
    
    8 8
         gettext (>= 0.17-4),
    
    9 9
         libglib2.0-dev,
    
    ... ... @@ -13,6 +13,7 @@ Build-Depends:
    13 13
         python3-gi-cairo,
    
    14 14
         python3-nbxmpp-nightly (>=20220727),
    
    15 15
         python3-setuptools,
    
    16
    +    python3-packaging,
    
    16 17
         python3-pil,
    
    17 18
         gir1.2-gtk-3.0 (>=3.24.30),
    
    18 19
     Rules-Requires-Root: no
    

  • 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/data/style/gajim.css
    ... ... @@ -95,7 +95,7 @@ .conversation-call-box label {
    95 95
         font-size: 90%;
    
    96 96
     }
    
    97 97
     .conversation-meta {
    
    98
    -    color: @insensitive_fg_color;
    
    98
    +    opacity: 0.6;
    
    99 99
         font-size: 90%;
    
    100 100
     }
    
    101 101
     .conversation-read-marker {
    

  • gajim/gtk/message_actions_box.py
    ... ... @@ -219,9 +219,22 @@ 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
    +        encryption_available = True
    
    223
    +        if isinstance(self._contact, GroupchatContact):
    
    224
    +            encryption_available = self._contact.encryption_available
    
    225
    +            if not encryption_available:
    
    226
    +                self._update_encryption_button(
    
    227
    +                    False,
    
    228
    +                    _('This is a public group chat. '
    
    229
    +                      'Encryption is not available.'),
    
    230
    +                    'channel-insecure-symbolic')
    
    231
    +
    
    232
    +                self._update_encryption_details_button(False)
    
    233
    +
    
    234
    +        if encryption_available:
    
    235
    +            encryption = self._contact.settings.get('encryption')
    
    236
    +            self._set_encryption_state(encryption)
    
    237
    +            self._set_encryption_details(encryption)
    
    225 238
     
    
    226 239
             self._set_chatstate(True)
    
    227 240
     
    
    ... ... @@ -295,8 +308,10 @@ def _set_encryption_state(self, state: str) -> None:
    295 308
             else:
    
    296 309
                 icon_name = 'channel-insecure-symbolic'
    
    297 310
     
    
    298
    -        self._ui.encryption_image.set_from_icon_name(icon_name,
    
    299
    -                                                     Gtk.IconSize.MENU)
    
    311
    +        self._update_encryption_button(
    
    312
    +            True,
    
    313
    +            _('Choose encryption'),
    
    314
    +            icon_name)
    
    300 315
     
    
    301 316
         def _change_encryption(self,
    
    302 317
                                action: Gio.SimpleAction,
    
    ... ... @@ -341,19 +356,38 @@ def _set_encryption_details(self, state: str) -> None:
    341 356
     
    
    342 357
             if authenticated:
    
    343 358
                 authenticated_string = _('and authenticated')
    
    344
    -            self._ui.encryption_details_image.set_from_icon_name(
    
    345
    -                'security-high-symbolic', Gtk.IconSize.MENU)
    
    359
    +            icon_name = 'security-high-symbolic'
    
    346 360
             else:
    
    347 361
                 authenticated_string = _('and NOT authenticated')
    
    348
    -            self._ui.encryption_details_image.set_from_icon_name(
    
    349
    -                'security-low-symbolic', Gtk.IconSize.MENU)
    
    362
    +            icon_name = 'security-low-symbolic'
    
    350 363
     
    
    351 364
             tooltip = _('%(type)s encryption is active %(authenticated)s.') % {
    
    352
    -            'type': enc_type, 'authenticated': authenticated_string}
    
    365
    +            'type': enc_type,
    
    366
    +            'authenticated': authenticated_string}
    
    367
    +
    
    368
    +        self._update_encryption_details_button(visible, tooltip, icon_name)
    
    369
    +
    
    370
    +    def _update_encryption_button(self,
    
    371
    +                                  sensitive: bool,
    
    372
    +                                  tooltip: str,
    
    373
    +                                  icon_name: str
    
    374
    +                                  ) -> None:
    
    375
    +
    
    376
    +        self._ui.encryption_menu_button.set_sensitive(sensitive)
    
    377
    +        self._ui.encryption_menu_button.set_tooltip_text(tooltip)
    
    378
    +        self._ui.encryption_image.set_from_icon_name(
    
    379
    +            icon_name, Gtk.IconSize.MENU)
    
    380
    +
    
    381
    +    def _update_encryption_details_button(self,
    
    382
    +                                          visible: bool,
    
    383
    +                                          tooltip: Optional[str] = None,
    
    384
    +                                          icon_name: Optional[str] = None
    
    385
    +                                          ) -> None:
    
    353 386
     
    
    354
    -        self._ui.encryption_details_button.set_tooltip_text(tooltip)
    
    355 387
             self._ui.encryption_details_button.set_visible(visible)
    
    356
    -        self._ui.encryption_details_image.set_sensitive(visible)
    
    388
    +        self._ui.encryption_details_button.set_tooltip_text(tooltip)
    
    389
    +        self._ui.encryption_details_image.set_from_icon_name(
    
    390
    +            icon_name, Gtk.IconSize.MENU)
    
    357 391
     
    
    358 392
         def _on_encryption_details_clicked(self, _button: Gtk.Button) -> None:
    
    359 393
             contact = self.get_current_contact()