Show
Ignore:
Timestamp:
08/30/07 02:00:58 (15 months ago)
Author:
roidelapluie
Message:

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

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/gajim_0.11.1/src/common/zeroconf/connection_zeroconf.py

    r7501 r8622  
    332332        user_nick = None): 
    333333                fjid = jid 
    334                  
     334 
    335335                if not self.connection: 
    336336                        return 
    337337                if not msg and chatstate is None: 
    338338                        return 
    339                  
     339 
    340340                if self.status in ('invisible', 'offline'): 
    341341                        self.dispatch('MSGERROR', [unicode(jid), '-1', _('You are not connected or not visible to others. Your message could not be sent.'), None, None]) 
     
    345345                msgenc = '' 
    346346                if keyID and USE_GPG: 
    347                         #encrypt 
    348                         msgenc = self.gpg.encrypt(msg, [keyID]) 
    349                         if msgenc: 
     347                        # encrypt 
     348                        msgenc, error = self.gpg.encrypt(msg, [keyID]) 
     349                        if msgenc and not error: 
    350350                                msgtxt = '[This message is encrypted]' 
    351351                                lang = os.getenv('LANG') 
     
    353353                                        msgtxt = _('[This message is encrypted]') +\ 
    354354                                                ' ([This message is encrypted])' # one  in locale and one en 
    355  
    356                  
     355                        else: 
     356                                # Encryption failed, do not send message 
     357                                tim = time.localtime() 
     358                                self.dispatch('MSGNOTSENT', (jid, error, msgtxt, tim)) 
     359                                return 3 
     360 
    357361                if type == 'chat': 
    358362                        msg_iq = common.xmpp.Message(to = fjid, body = msgtxt, typ = type) 
    359                          
     363 
    360364                else: 
    361365                        if subject: 
     
    368372                if msgenc: 
    369373                        msg_iq.setTag(common.xmpp.NS_ENCRYPTED + ' x').setData(msgenc) 
    370                  
     374 
    371375                # chatstates - if peer supports jep85 or jep22, send chatstates 
    372376                # please note that the only valid tag inside a message containing a <body> 
     
    386390                                if chatstate is 'composing' or msgtxt:  
    387391                                        chatstate_node.addChild(name = 'composing')  
    388                  
     392 
    389393                if not self.connection.send(msg_iq, msg != None): 
    390394                        return