rendered paste body=== modified file 'src/gajim.py'--- src/gajim.py 2008-05-11 01:07:38 +0000+++ src/gajim.py 2008-05-11 12:01:49 +0000@@ -286,17 +286,37 @@ tim = time.localtime() if not no_print:- ctrl = gajim.interface.msg_win_mgr.get_control(- gajim.get_jid_without_resource(fjid), account)+ 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=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])+ + def get_control(self, fjid, account):+ # first try to get the window with the full jid+ ctrl = gajim.interface.msg_win_mgr.get_control(fjid, account)+ if ctrl:+ # got one, be happy+ return ctrl+ + # otherwise try without the resource+ ctrl = gajim.interface.msg_win_mgr.get_control(+ gajim.get_jid_without_resource(fjid), account)+ # but only use it when it is not a GC window+ if ctrl and ctrl.TYPE_ID == message_control.TYPE_CHAT:+ return ctrl def policy(self, opdata=None, context=None):- policy = gajim.config.get_per("contacts",- gajim.get_jid_without_resource(context.username), "otr_flags")+ policy = gajim.config.get_per("contacts", context.username,+ "otr_flags")+ if policy <= 0:+ policy = gajim.config.get_per("contacts",+ gajim.get_jid_without_resource(context.username),+ "otr_flags") if policy <= 0: policy = gajim.config.get_per("accounts", opdata['account'], "otr_flags") return policy@@ -387,25 +407,20 @@ trust = "unverified" self.gajim_log("%s secured OTR connection started"%trust, opdata['account'], context.username, no_print=True)- - ctrl = gajim.interface.msg_win_mgr.get_control(- unicode(context.username), opdata['account'])++ ctrl = self.get_control(context.username, opdata['account']) if ctrl: ctrl.update_otr(True) def gone_insecure(self, opdata="", context=None): self.gajim_log("Private conversation with %s lost.", opdata['account'], context.username) - ctrl = gajim.interface.msg_win_mgr.get_control(- gajim.get_jid_without_resource(unicode(context.username)),- opdata['account'])+ ctrl = self.get_control(context.username, opdata['account']) if ctrl:- ctrl.update_otr()+ ctrl.update_otr(True) def still_secure(self, opdata=None, context=None, is_reply=0):- ctrl = gajim.interface.msg_win_mgr.get_control(- gajim.get_jid_without_resource(unicode(context.username)),- opdata['account'])+ ctrl = self.get_control(context.username, opdata['account']) if ctrl: ctrl.update_otr(True) === modified file 'src/otr_windows.py'--- src/otr_windows.py 2008-05-10 21:29:47 +0000+++ src/otr_windows.py 2008-05-11 10:45:21 +0000@@ -224,7 +224,7 @@ otr_flags = gajim.config.get_per("contacts", self.contact.jid, "otr_flags") - if otr_flags > 0:+ if otr_flags > -1: self.gw("otr_default_checkbutton").set_active(0) for w in self.gw("otr_settings_vbox").get_children(): w.set_sensitive(True)