Index: gajim.py =================================================================== --- gajim.py (Revision 9768) +++ gajim.py (Arbeitskopie) @@ -287,26 +287,36 @@ widget.destroy() class OtrlMessageAppOps: - def gajim_log(self, msg, account, fjid, no_print=False): + def gajim_log(self, msg, account, fjid, no_print=False, + is_status_message=True, thread_id=None): if not isinstance(fjid, unicode): fjid = unicode(fjid) if not isinstance(account, unicode): account = unicode(account) - resource=gajim.get_resource_from_jid(fjid) + resource = gajim.get_resource_from_jid(fjid) + jid = gajim.get_jid_without_resource(fjid) tim = time.localtime() - if not no_print: - ctrl = self.get_control(fjid, account) - if ctrl: - ctrl.print_conversation_line(u'[OTR] %s' % \ - msg, 'status', '', None) - id = gajim.logger.write('chat_msg_recv', fjid, - message='[OTR: %s]' % msg, tim=tim) - # gajim.logger.write() only marks a message as unread - # (and so only returns an id) when fjid is a real contact - # (NOT if it's a GC private chat) - if id: - gajim.logger.set_read_messages([id]) + if is_status_message is True: + if not no_print: + ctrl = self.get_control(fjid, account) + if ctrl: + ctrl.print_conversation_line(u'[OTR] %s' % \ + msg, 'status', '', None) + id = gajim.logger.write('chat_msg_recv', fjid, + message='[OTR: %s]' % msg, tim=tim) + # gajim.logger.write() only marks a message as unread + # (and so only returns an id) when fjid is a real contact + # (NOT if it's a GC private chat) + if id: + gajim.logger.set_read_messages([id]) + else: + session = gajim.connections[account].\ + get_or_create_session(fjid, thread_id) + session.roster_message(jid, msg, tim=tim, + msg_type="chat", resource=resource) + id = gajim.logger.write('chat_msg_recv', fjid, + message='[OTR: %s]' % msg, tim=tim) def get_control(self, fjid, account): # first try to get the window with the full jid @@ -414,7 +424,8 @@ def display_otr_message(self, opdata=None, username="", msg="", **kwargs): self.gajim_log('OTR Message: ' + msg, opdata['account'], - username) + username, is_status_message=False, + thread_id=opdata['thread_id']) return 0 def update_context_list(self, **kwargs): Index: common/connection_handlers.py =================================================================== --- common/connection_handlers.py (Revision 9768) +++ common/connection_handlers.py (Arbeitskopie) @@ -1705,24 +1705,19 @@ receipt.setThread(thread_id) con.send(receipt) - # We don't trust libotr, that's why we only pass the message - # to it if necessary. otrl_proto_message_type does this check. if gajim.otr_module and not xep_200_encrypted \ - and isinstance(msgtxt, unicode) and \ - gajim.otr_module.otrl_proto_message_type(msgtxt.encode()) != \ - gajim.otr_module.OTRL_MSGTYPE_NOTOTR: - # set to encrypted if it's really encrypted. - if gajim.otr_module.otrl_proto_message_type( - msgtxt.encode()) != \ - gajim.otr_module.OTRL_MSGTYPE_TAGGEDPLAINTEXT: - encrypted = True + and isinstance(msgtxt, unicode): + ## set to encrypted if it's really encrypted. + #if gajim.otr_module.otrl_proto_message_type( + #msgtxt.encode()) != \ + #gajim.otr_module.OTRL_MSGTYPE_TAGGEDPLAINTEXT: + # encrypted = True - # TODO: Do we really need .encode()? - # yes we do. OTR can't handle unicode. otr_msg_tuple = \ gajim.otr_module.otrl_message_receiving( self.otr_userstates, - (gajim.otr_ui_ops, {'account': self.name}), + (gajim.otr_ui_ops, {'account': self.name, + 'thread_id':thread_id}), gajim.get_jid_from_account(self.name).encode(), gajim.OTR_PROTO, frm.encode(), @@ -1764,8 +1759,6 @@ if msgtxt == '': return elif msgtxt != None and msgtxt != '': - gajim.otr_dont_append_tag[frm] = True - # We're also here if we just don't # support OTR. Thus, we should strip # the tags from plaintext messages Index: common/gajim.py =================================================================== --- common/gajim.py (Revision 9768) +++ common/gajim.py (Arbeitskopie) @@ -169,9 +169,6 @@ otr_userstates = {} otr_policy = {} -# list of (full) jids not to attempt OTR with -otr_dont_append_tag = {} - gajim_identity = {'type': 'pc', 'category': 'client', 'name': 'Gajim'} gajim_common_features = [xmpp.NS_BYTESTREAM, xmpp.NS_SI, xmpp.NS_FILE, xmpp.NS_MUC, xmpp.NS_MUC_USER, Index: chat_control.py =================================================================== --- chat_control.py (Revision 9768) +++ chat_control.py (Arbeitskopie) @@ -1662,15 +1662,6 @@ 'NOT encrypted') ChatControlBase.print_conversation_line( self, msg, 'status', '', tim) - elif gajim.otr_module and self.get_otr_status() > 0: - # OTR - # TODO: This is not shown when the window - # isn't open - needs fixing! - if not encrypted and frm == '': - msg = _('The following message was ' + \ - 'NOT encrypted') - ChatControlBase.print_conversation_line( - self, msg, 'status', '', tim) else: # GPG encryption if encrypted and not self.gpg_is_active: Index: message_control.py =================================================================== --- message_control.py (Revision 9768) +++ message_control.py (Arbeitskopie) @@ -165,7 +165,7 @@ xep_200 = bool(self.session) and self.session.enable_encryption - if gajim.otr_module and not xep_200 and (jid not in gajim.otr_dont_append_tag): + if gajim.otr_module and not xep_200: if type == 'chat' and isinstance(message, unicode): d = {'kwargs': {'keyID': keyID, 'type': type, 'chatstate': chatstate, @@ -175,7 +175,8 @@ 'user_nick': user_nick, 'session': self.session, 'original_message': original_message}, - 'account': self.account} + 'account': self.account, + 'thread_id':self.session.thread_id} new_msg = gajim.otr_module.otrl_message_sending( self.session.conn.otr_userstates,