[danguy] correctly encrypt message in zeroconf network. fixes #3113

This commit is contained in:
Yann Leboulanger 2007-04-22 10:32:26 +00:00
parent 2ef20efac5
commit b15b53b5e2
1 changed files with 13 additions and 9 deletions

View File

@ -346,15 +346,19 @@ class ConnectionZeroconf(ConnectionHandlersZeroconf):
msgtxt = msg
msgenc = ''
if keyID and USE_GPG:
#encrypt
msgenc = self.gpg.encrypt(msg, [keyID])
if msgenc:
# encrypt
msgenc, error = self.gpg.encrypt(msg, [keyID])
if msgenc and not error:
msgtxt = '[This message is encrypted]'
lang = os.getenv('LANG')
if lang is not None or lang != 'en': # we're not english
msgtxt = _('[This message is encrypted]') +\
' ([This message is encrypted])' # one in locale and one en
else:
# Encryption failed, do not send message
tim = time.localtime()
self.dispatch('MSGNOTSENT', (jid, error, msgtxt, tim))
return 3
if type == 'chat':
msg_iq = common.xmpp.Message(to = fjid, body = msgtxt, typ = type)