Changeset 9830

Show
Ignore:
Timestamp:
06/21/08 21:12:58 (5 months ago)
Author:
bct
Message:

hopefully fix some has_window bugs

Location:
trunk/src
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/gajim.py

    r9829 r9830  
    10261026                        resource = vcard['resource'] 
    10271027 
     1028                fjid = jid + '/' + str(resource) 
     1029 
    10281030                # vcard window 
    10291031                win = None 
    10301032                if self.instances[account]['infos'].has_key(jid): 
    10311033                        win = self.instances[account]['infos'][jid] 
    1032                 elif resource and self.instances[account]['infos'].has_key( 
    1033                         jid + '/' + resource): 
    1034                         win = self.instances[account]['infos'][jid + '/' + resource] 
     1034                elif resource and self.instances[account]['infos'].has_key(fjid): 
     1035                        win = self.instances[account]['infos'][fjid] 
    10351036                if win: 
    10361037                        win.set_values(vcard) 
     
    10381039                # show avatar in chat 
    10391040                ctrls = [] 
    1040                 if resource and self.msg_win_mgr.has_window( 
    1041                 jid + '/' + resource, account): 
    1042                         win = self.msg_win_mgr.get_window(jid + '/' + resource, 
    1043                                 account) 
    1044                         ctrls = win.get_controls(jid + '/' + resource, account) 
     1041                if resource and self.msg_win_mgr.has_window(fjid, account): 
     1042                        win = self.msg_win_mgr.get_window(fjid, account) 
     1043                        ctrls = win.get_controls(fjid, account) 
    10451044                elif self.msg_win_mgr.has_window(jid, account): 
    10461045                        win = self.msg_win_mgr.get_window(jid, account) 
     
    21272126                                session = event.parameters[8] 
    21282127                                ctrl = session.control 
    2129  
    2130                         if type_ == '' and self.msg_win_mgr.has_window(fjid, account): 
    2131                                 ctrl = self.msg_win_mgr.get_chat_controls(fjid, account)[0] 
    2132                         elif not ctrl: 
     2128                        elif type_ == '': 
     2129                                ctrls = self.msg_win_mgr.get_chat_controls(fjid, account) 
     2130 
     2131                                if ctrls: 
     2132                                        ctrl = ctrls[0] 
     2133 
     2134                        if not ctrl: 
    21332135                                highest_contact = gajim.contacts.get_contact_with_highest_priority( 
    21342136                                        account, jid) 
     
    24442446                self.emoticons_menu = self.prepare_emoticons_menu() 
    24452447 
    2446 ################################################################################                 
     2448################################################################################ 
    24472449### Methods for opening new messages controls 
    24482450################################################################################ 
     
    25752577                                resource=resource) 
    25762578 
    2577                 if self.msg_win_mgr.has_window(fjid, account): 
    2578                         ctrl = self.msg_win_mgr.get_chat_controls(fjid, account)[0] 
     2579                ctrls = self.msg_win_mgr.get_chat_controls(fjid, account) 
     2580                if ctrls: 
     2581                        ctrl = ctrls[0] 
    25792582                else: 
    25802583                        ctrl = self.new_chat(contact, account, 
  • trunk/src/message_window.py

    r9761 r9830  
    621621                        nth_child = notebook.get_nth_page(page_num) 
    622622                        return self._widget_to_control(nth_child) 
     623 
     624        def has_control(self, jid, acct): 
     625                sessioned = (acct in self._controls and jid in self._controls[acct] \ 
     626                        and self._controls[acct][jid]) 
     627 
     628                return sessioned or self.sessionless_controls(acct, jid) 
    623629 
    624630        def get_gc_control(self, jid, acct): 
     
    925931        def get_window(self, jid, acct): 
    926932                for win in self.windows(): 
    927                         if (acct in win._controls and jid in win._controls[acct]) or \ 
    928                         (acct in win.sessionless_ctrls and jid in win.sessionless_ctrls[acct]): 
    929                                         return win 
     933                        if win.has_control(jid, acct): 
     934                                return win 
    930935 
    931936                return None