Commit dd9fd681 authored by Yann Leboulanger's avatar Yann Leboulanger

[Elmar Hoffmann] Advanced option to disable presence signing. fixes #3601

parent 002556db
......@@ -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 ],
......
......@@ -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:
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment