diff --git a/src/common/config.py b/src/common/config.py index 0327bb146..0e8282daf 100644 --- a/src/common/config.py +++ b/src/common/config.py @@ -273,6 +273,7 @@ class Config: 'active': [ opt_bool, True], 'proxy': [ opt_str, '', '', True ], 'keyid': [ opt_str, '', '', True ], + 'gpg_sign_presence': [ opt_bool, True, _('If disabled, don\'t sign presences with GPG key, even if GPG is configured.') ], 'keyname': [ opt_str, '', '', True ], 'usessl': [ opt_bool, False, '', True ], 'ssl_fingerprint_sha1': [ opt_str, '', '', True ], diff --git a/src/common/connection.py b/src/common/connection.py index 3b7bf061b..71b8840a8 100644 --- a/src/common/connection.py +++ b/src/common/connection.py @@ -748,6 +748,11 @@ class Connection(ConnectionHandlers): self.gpg.password = None return signed != 'BAD_PASSPHRASE' + def get_signed_presence(self, msg, callback = None): + if gajim.config.get_per('accounts', self.name, 'gpg_sign_presence'): + return self.get_signed_msg(msg, callback) + return '' + def get_signed_msg(self, msg, callback = None): '''returns the signed message if possible or an empty string if gpg is not used @@ -805,7 +810,7 @@ class Connection(ConnectionHandlers): if msg: p.setStatus(msg) else: - signed = self.get_signed_msg(msg) + signed = self.get_signed_presence(msg) priority = unicode(gajim.get_priority(self.name, sshow)) p = common.xmpp.Presence(typ = None, priority = priority, show = sshow, to = jid) @@ -866,7 +871,7 @@ class Connection(ConnectionHandlers): was_invisible = self.connected == STATUS_LIST.index('invisible') self.connected = STATUS_LIST.index(show) if show == 'invisible': - signed = self.get_signed_msg(msg) + signed = self.get_signed_presence(msg) self.send_invisible_presence(msg, signed) return if was_invisible and self.privacy_rules_supported: @@ -878,7 +883,7 @@ class Connection(ConnectionHandlers): p = self.add_sha(p) if msg: p.setStatus(msg) - signed = self.get_signed_msg(msg) + signed = self.get_signed_presence(msg) if signed: p.setTag(common.xmpp.NS_SIGNED + ' x').setData(signed) if self.connection: diff --git a/src/common/connection_handlers.py b/src/common/connection_handlers.py index da3da52bd..baea7e087 100644 --- a/src/common/connection_handlers.py +++ b/src/common/connection_handlers.py @@ -2137,7 +2137,7 @@ returns the session that we last sent a message to.''' sign_msg = self.continue_connect_info[2] signed = '' if sign_msg: - signed = self.get_signed_msg(msg, self._send_first_presence) + signed = self.get_signed_presence(msg, self._send_first_presence) if signed is None: self.dispatch('GPG_PASSWORD_REQUIRED', (self._send_first_presence,)) @@ -2150,7 +2150,7 @@ returns the session that we last sent a message to.''' msg = self.continue_connect_info[1] sign_msg = self.continue_connect_info[2] if sign_msg and not signed: - signed = self.get_signed_msg(msg) + signed = self.get_signed_presence(msg) if signed is None: self.dispatch('ERROR', (_('OpenPGP passphrase was not given'), #%s is the account name here