Show
Ignore:
Timestamp:
05/09/08 14:35:25 (7 months ago)
Author:
js
Message:

Added OTR support.
Work done by Kjell Braden <fnord@…>.
Some fixes done by me.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/message_control.py

    r9178 r9602  
    144144                ''' 
    145145                jid = self.contact.jid 
     146                original_message = message 
    146147 
    147148                if not self.session: 
     
    151152                        self.set_session(new_session) 
    152153 
     154                if gajim.otr_module: 
     155                        if type == 'chat' and isinstance(message, unicode): 
     156                                d = {'kwargs':{'keyID':keyID, 'type':type, 
     157                                                'chatstate':chatstate, 'msg_id':msg_id, 
     158                                                'composing_xep':composing_xep, 'resource':self.resource, 
     159                                                'user_nick':user_nick, 'session':self.session, 
     160                                                'original_message':original_message}, 'account':self.account} 
     161         
     162                                new_msg = gajim.otr_module.otrl_message_sending( 
     163                                        gajim.otr_userstates[self.account], 
     164                                        (gajim.otr_ui_ops, d), 
     165                                        gajim.get_jid_from_account(self.account).encode(), gajim.OTR_PROTO, 
     166                                        self.contact.get_full_jid().encode(), message.encode(), None) 
     167 
     168                                context = gajim.otr_module.otrl_context_find( 
     169                                                gajim.otr_userstates[self.account], 
     170                                                self.contact.get_full_jid().encode(), 
     171                                                gajim.get_jid_from_account(self.account).encode(), 
     172                                                gajim.OTR_PROTO, 1)[0] 
     173 
     174                                print repr(context.accountname), repr(context.username) 
     175 
     176                                # we send all because inject_message can filter on HTML stuff then 
     177                                gajim.otr_module.otrl_message_fragment_and_send( 
     178                                                (gajim.otr_ui_ops, d), 
     179                                                context, new_msg, gajim.otr_module.OTRL_FRAGMENT_SEND_ALL) 
     180                                return 
     181 
    153182                # Send and update history 
    154183                return gajim.connections[self.account].send_message(jid, message, keyID, 
    155184                        type = type, chatstate = chatstate, msg_id = msg_id, 
    156185                        composing_xep = composing_xep, resource = self.resource, 
    157                         user_nick = user_nick, session = self.session) 
     186                        user_nick = user_nick, session = self.session, original_message = original_message)