Changeset 9222

Show
Ignore:
Timestamp:
12/30/07 17:30:37 (11 months ago)
Author:
steve-e
Message:

Do not allow enabling GPG if E2E is active and vice versa. Lazily fixes #3633.
Do not try to send encrypted messages when we don't use GPG, though it is enabled per user.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/chat_control.py

    r9217 r9222  
    10541054 
    10551055                # Enable ecryption if needed 
     1056                e2e_is_active = hasattr(self, 'session') and self.session and self.session.enable_encryption 
     1057                self.gpg_is_active = False 
    10561058                gpg_pref = gajim.config.get_per('contacts', contact.jid, 
    10571059                                'gpg_enabled') 
    1058                 if gpg_pref and gajim.config.get_per('accounts', self.account, 'keyid') and\ 
     1060                if not e2e_is_active and gpg_pref and gajim.config.get_per('accounts', self.account, 'keyid') and\ 
    10591061                gajim.connections[self.account].USE_GPG: 
     1062                        self.gpg_is_active = True 
    10601063                        gajim.encrypted_chats[self.account].append(contact.jid) 
    10611064                        msg = _('GPG encryption enabled') 
     
    12571260        def _toggle_gpg(self): 
    12581261                ec = gajim.encrypted_chats[self.account] 
    1259                 if self.contact.jid in ec: 
     1262                if self.gpg_is_active: 
    12601263                        # Disable encryption 
    12611264                        ec.remove(self.contact.jid) 
    1262                         gpg_is_active = False 
     1265                        self.gpg_is_active = False 
    12631266                        msg = _('GPG encryption disabled') 
    12641267                else: 
    12651268                        # Enable encryption 
    12661269                        ec.append(self.contact.jid) 
    1267                         gpg_is_active = True 
     1270                        self.gpg_is_active = True 
    12681271                        msg = _('GPG encryption enabled') 
    12691272 
     
    12731276                        gajim.config.add_per('contacts', self.contact.jid) 
    12741277                gajim.config.set_per('contacts', self.contact.jid, 'gpg_enabled', 
    1275                         gpg_is_active) 
     1278                        self.gpg_is_active) 
    12761279                ChatControlBase.print_conversation_line(self, msg, 'status', '', None) 
    12771280 
     
    13621365 
    13631366                keyID = '' 
    1364                 gpg_pref = gajim.config.get_per('contacts', contact.jid, 
    1365                         'gpg_enabled') 
    1366                 if gpg_pref: 
     1367                if self.gpg_is_active: 
    13671368                        keyID = contact.keyID 
    13681369                        encrypted = True 
     
    15071508                        else: 
    15081509                                # GPG encryption 
    1509                                 ec = gajim.encrypted_chats[self.account] 
    1510                                 if encrypted and jid not in ec: 
     1510                                if encrypted and not self.gpg_is_active: 
    15111511                                        msg = _('The following message was encrypted') 
    15121512                                        ChatControlBase.print_conversation_line(self, msg,  
    15131513                                                'status', '', tim) 
    15141514                                        self._toggle_gpg() 
    1515                                 elif not encrypted and jid in ec: 
     1515                                elif not encrypted and self.gpg_is_active: 
    15161516                                        msg = _('The following message was NOT encrypted') 
    15171517                                        ChatControlBase.print_conversation_line(self, msg, 
     
    16501650                        toggle_gpg_menuitem.set_sensitive(False) 
    16511651                else: 
    1652                         toggle_gpg_menuitem.set_sensitive(True) 
    1653                         gpg_pref = gajim.config.get_per('contacts', jid, 
    1654                                 'gpg_enabled') 
    1655                         toggle_gpg_menuitem.set_active(bool(gpg_pref)) 
     1652                        e2e_is_active = int(self.session != None and self.session.enable_encryption) 
     1653                        toggle_gpg_menuitem.set_sensitive(not e2e_is_active) 
     1654                        toggle_gpg_menuitem.set_active(self.gpg_is_active) 
    16561655 
    16571656                # TODO: check that the remote client supports e2e 
     
    16611660                        isactive = int(self.session != None and self.session.enable_encryption) 
    16621661                        toggle_e2e_menuitem.set_active(isactive) 
     1662                        toggle_e2e_menuitem.set_sensitive(not self.gpg_is_active) 
    16631663 
    16641664                # If we don't have resource, we can't do file transfer