From a63132500bc2817559a5c0110dcf3d08dd74cbb1 Mon Sep 17 00:00:00 2001 From: Travis Shirk Date: Wed, 25 Jan 2006 02:43:55 +0000 Subject: [PATCH] Pass account to window/control lookup methods --- src/chat_control.py | 2 +- src/common/gajim.py | 2 +- src/gajim.py | 68 +++++++++++++++++++++------------------- src/groupchat_control.py | 14 ++++----- src/message_window.py | 54 ++++++++++++++++--------------- src/remote_control.py | 4 +-- src/roster_window.py | 57 +++++++++++++++++---------------- src/systray.py | 8 ++--- 8 files changed, 106 insertions(+), 103 deletions(-) diff --git a/src/chat_control.py b/src/chat_control.py index 65d7726eb..225c93571 100644 --- a/src/chat_control.py +++ b/src/chat_control.py @@ -1313,7 +1313,7 @@ class ChatControl(ChatControlBase): # Is it a pm ? is_pm = False room_jid, nick = gajim.get_room_and_nick_from_fjid(jid) - control = gajim.interface.msg_win_mgr.get_control(room_jid) + control = gajim.interface.msg_win_mgr.get_control(room_jid, self.account) if control.type_id == message_control.TYPE_GC: is_pm = True events_to_keep = [] diff --git a/src/common/gajim.py b/src/common/gajim.py index f2b1c186f..33ba4511f 100644 --- a/src/common/gajim.py +++ b/src/common/gajim.py @@ -153,7 +153,7 @@ def get_real_jid_from_fjid(account, fjid): if not nick: # It's not a fake_jid, it is a real jid return fjid # we return the real jid real_jid = fjid - if interface.msg_win_mgr.get_control(room_jid): + if interface.msg_win_mgr.get_control(room_jid, account): # It's a pm, so if we have real jid it's in contact.jid gc_contact = contacts.get_gc_contact(account, room_jid, nick) if not gc_contact: diff --git a/src/gajim.py b/src/gajim.py index ed82aeee5..1ec6d2dbe 100755 --- a/src/gajim.py +++ b/src/gajim.py @@ -178,7 +178,7 @@ class Interface: title = data[1] prompt = data[2] proposed_nick = data[3] - gc_control = gajim.interface.msg_win_mgr.get_control(room_jid) + gc_control = gajim.interface.msg_win_mgr.get_control(room_jid, account) if gc_control: # user may close the window before we are here gc_control.show_change_nick_input_dialog(title, prompt, proposed_nick) @@ -220,7 +220,7 @@ class Interface: (jid_from, file_props)) conn.disconnect_transfer(file_props) return - ctrl = gajim.interface.msg_win_mgr.get_control(jid_from) + ctrl = gajim.interface.msg_win_mgr.get_control(jid_from, account) if ctrl and ctrl.type_id == message_control.TYPE_GC: ctrl.print_conversation('Error %s: %s' % (array[2], array[1])) @@ -241,7 +241,7 @@ class Interface: if not gajim.gc_connected.has_key(account): return for room_jid in gajim.gc_connected[account]: - gc_control = gajim.interface.msg_win_mgr.get_control(room_jid) + gc_control = gajim.interface.msg_win_mgr.get_control(room_jid, account) if gc_control: gc_control.got_disconnected() else: @@ -348,7 +348,7 @@ class Interface: if gajim.config.get_per('soundevents', 'contact_connected', 'enabled') and gajim.allow_notifications[account]: helpers.play_sound('contact_connected') - if not gajim.interface.msg_win_mgr.has_window(jid) and \ + if not gajim.interface.msg_win_mgr.has_window(jid, account) and \ not gajim.awaiting_events[account].has_key(jid) and \ gajim.config.get('notify_on_signin') and \ gajim.allow_notifications[account]: @@ -373,7 +373,7 @@ class Interface: if gajim.config.get_per('soundevents', 'contact_disconnected', 'enabled'): helpers.play_sound('contact_disconnected') - if not gajim.interface.msg_win_mgr.has_window(jid) and \ + if not gajim.interface.msg_win_mgr.has_window(jid, account) and \ not gajim.awaiting_events[account].has_key(jid) and \ gajim.config.get('notify_on_signout'): show_notification = False @@ -416,12 +416,12 @@ class Interface: elif gajim.connections[account].connected in (2, 3): # we're online or chat show_notification = True - chat_control = gajim.interface.msg_win_mgr.get_control(jid) + chat_control = gajim.interface.msg_win_mgr.get_control(jid, account) if chat_control and chat_control.type_id == message_control.TYPE_GC: # it's a Private Message nick = gajim.get_nick_from_fjid(array[0]) fjid = array[0] - if not gajim.interface.msg_win_mgr.has_window(fjid) and \ + if not gajim.interface.msg_win_mgr.has_window(fjid, account) and \ not gajim.awaiting_events[account].has_key(fjid): if show_notification: room_jid, nick = gajim.get_room_and_nick_from_fjid(fjid) @@ -435,6 +435,7 @@ class Interface: chat_control.on_private_message(nick, array[1], array[2]) return + # FIXME: This should happen first if gajim.config.get('ignore_unknown_contacts') and \ not gajim.contacts.get_contact(account, jid): return @@ -442,13 +443,14 @@ class Interface: # Handle chat states contact = gajim.contacts.get_first_contact_from_jid(account, jid) if chat_control and chat_control.type_id == message_control.TYPE_CHAT: - ctrl = gajim.interface.msg_win_mgr.get_control(jid) + # FIXME: Why is this here? + #ctrl = gajim.interface.msg_win_mgr.get_control(jid,) if chatstate is not None: # he or she sent us reply, so he supports jep85 contact.chatstate = chatstate if contact.our_chatstate == 'ask': # we were jep85 disco? contact.our_chatstate = 'active' # no more - ctrl.handle_incoming_chatstate() + chat_control.handle_incoming_chatstate() elif contact.chatstate != 'active': # got no valid jep85 answer, peer does not support it contact.chatstate = False @@ -461,7 +463,7 @@ class Interface: return first = False - if not gajim.interface.msg_win_mgr.has_window(jid) and \ + if not gajim.interface.msg_win_mgr.has_window(jid, account) and \ not gajim.awaiting_events[account].has_key(jid): first = True if gajim.config.get('notify_on_new_message'): @@ -506,7 +508,7 @@ class Interface: if jid == gc_control.contact.jid: if len(jids) > 1: # it's a pm nick = jids[1] - if not gajim.interface.msg_win_mgr.get_control(fjid): + if not gajim.interface.msg_win_mgr.get_control(fjid, account): tv = gc_control.list_treeview model = tv.get_model() i = gc_control.get_contact_iter(nick) @@ -518,7 +520,7 @@ class Interface: name = nick, show = show) c = gajim.contacts.contact_from_gc_contct(c) self.roster.new_chat(c, account, private_chat = True) - ctrl = gajim.interface.msg_win_mgr.get_control(fjid) + ctrl = gajim.interface.msg_win_mgr.get_control(fjid, account) ctrl.print_conversation('Error %s: %s' % (array[1], array[2]), 'status') return @@ -676,12 +678,12 @@ class Interface: # show avatar in chat win = None ctrl = None - if gajim.interface.msg_win_mgr.has_window(jid): - win = gajim.interface.msg_win_mgr.get_window(jid) - ctrl = win.get_control(jid) - elif resource and gajim.interface.msg_win_mgr.has_window(jid + '/' + resource): - win = gajim.interface.msg_win_mgr.get_window(jid + '/' + resource) - ctrl = win.get_control(jid + '/' + resource) + if gajim.interface.msg_win_mgr.has_window(jid, account): + win = gajim.interface.msg_win_mgr.get_window(jid, account) + ctrl = win.get_control(jid, account) + elif resource and gajim.interface.msg_win_mgr.has_window(jid + '/' + resource, account): + win = gajim.interface.msg_win_mgr.get_window(jid + '/' + resource, account) + ctrl = win.get_control(jid + '/' + resource, account) if win and ctrl.type_id != message_control.TYPE_GC: ctrl.show_avatar() @@ -712,8 +714,8 @@ class Interface: show = array[1] status = array[2] # print status in chat window and update status/GPG image - if gajim.interface.msg_win_mgr.has_window(fjid): - ctrl = gajim.interface.msg_win_mgr.get_control(fjid) + if gajim.interface.msg_win_mgr.has_window(fjid, account): + ctrl = gajim.interface.msg_win_mgr.get_control(fjid, account) contact = ctrl.contact contact.show = show contact.status = status @@ -724,12 +726,12 @@ class Interface: ctrl.draw_banner() # Get the window and control for the updated status, this may be a PrivateChatControl - control = gajim.interface.msg_win_mgr.get_control(room_jid) + control = gajim.interface.msg_win_mgr.get_control(room_jid, account) if control: control.chg_contact_status(nick, show, status, array[4], array[5], array[6], array[7], array[8], array[9], array[10]) # Find any PM chat through this room, and tell it to update. - pm_control = gajim.interface.msg_win_mgr.get_control(fjid) + pm_control = gajim.interface.msg_win_mgr.get_control(fjid, account) if pm_control: pm_control.parent_win.redraw_tab(pm_control.contact) if self.remote_ctrl: @@ -739,7 +741,7 @@ class Interface: # ('GC_MSG', account, (jid, msg, time)) jids = array[0].split('/', 1) room_jid = jids[0] - gc_control = gajim.interface.msg_win_mgr.get_control(room_jid) + gc_control = gajim.interface.msg_win_mgr.get_control(room_jid, account) if not gc_control: return if len(jids) == 1: @@ -756,7 +758,7 @@ class Interface: #('GC_SUBJECT', account, (jid, subject, body)) jids = array[0].split('/', 1) jid = jids[0] - gc_control = gajim.interface.msg_win_mgr.get_control(jid) + gc_control = gajim.interface.msg_win_mgr.get_control(jid, account) if not gc_control: return gc_control.set_subject(array[1]) @@ -1364,17 +1366,17 @@ class Interface: def handle_event(self, account, jid, typ): w = None if typ == message_control.TYPE_GC: - w = gajim.interface.msg_win_mgr.get_window(jid) + w = gajim.interface.msg_win_mgr.get_window(jid, account) elif typ == message_control.TYPE_CHAT: - if gajim.interface.msg_win_mgr.has_window(jid): - w = gajim.interface.msg_win_mgr.get_window(jid) + if gajim.interface.msg_win_mgr.has_window(jid, account): + w = gajim.interface.msg_win_mgr.get_window(jid, account) else: contact = gajim.contacts.get_first_contact_from_jid(account, jid) self.roster.new_chat(contact, account) - w = gajim.interface.msg_win_mgr.get_window(jid) + w = gajim.interface.msg_win_mgr.get_window(jid, account) elif typ == message_control.TYPE_PM: - if gajim.interface.msg_win_mgr.has_window(jid): - w = gajim.interface.msg_win_mgr.get_window(jid) + if gajim.interface.msg_win_mgr.has_window(jid, account): + w = gajim.interface.msg_win_mgr.get_window(jid, account) else: room_jid, nick = jid.split('/', 1) gc_contact = gajim.contacts.get_gc_contact(account, room_jid, @@ -1387,7 +1389,7 @@ class Interface: name = nick, show = show) c = gajim.contacts.contact_from_gc_contact(gc_contact) self.roster.new_chat(c, account, private_chat = True) - w = gajim.interface.msg_win_mgr.get_window(jid) + w = gajim.interface.msg_win_mgr.get_window(jid, account) elif typ in ('normal', 'file-request', 'file-request-error', 'file-send-error', 'file-error', 'file-stopped', 'file-completed'): # Get the first single message event @@ -1401,10 +1403,10 @@ class Interface: url = ('http://mail.google.com/') helpers.launch_browser_mailer('url', url) if w: - w.set_active_tab(jid) + w.set_active_tab(jid, account) w.window.present() w.window.window.focus() - ctrl = w.get_control(jid) + ctrl = w.get_control(jid, account) # Using isinstance here because we want to catch all derived types if isinstance(ctrl, ChatControlBase): tv = ctrl.conv_textview diff --git a/src/groupchat_control.py b/src/groupchat_control.py index 16bcc1f93..6560b5919 100644 --- a/src/groupchat_control.py +++ b/src/groupchat_control.py @@ -305,7 +305,7 @@ class GroupchatControl(ChatControlBase): no_queue = False # We print if window is opened - pm_control = gajim.interface.msg_win_mgr.get_control(fjid) + pm_control = gajim.interface.msg_win_mgr.get_control(fjid, self.account) if pm_control: pm_control.print_conversation(msg, tim = tim) return @@ -422,7 +422,7 @@ class GroupchatControl(ChatControlBase): and does not already have it as last event. If it goes to add this line it removes previous line first''' - win = gajim.interface.msg_win_mgr.get_window(self.room_jid) + win = gajim.interface.msg_win_mgr.get_window(self.room_jid, self.account) if self.room_jid == win.get_active_jid() and\ win.window.get_property('has-toplevel-focus'): # it's the current room and it's the focused window. @@ -556,7 +556,7 @@ class GroupchatControl(ChatControlBase): self._start_private_message(nick) if msg: - gajim.interface.msg_win_mgr.get_control(fjid).send_message(msg) + gajim.interface.msg_win_mgr.get_control(fjid, self.account).send_message(msg) def draw_contact(self, nick, selected=False, focus=False): iter = self.get_contact_iter(nick) @@ -860,7 +860,7 @@ class GroupchatControl(ChatControlBase): reason = message_array.pop(0) gajim.connections[self.account].send_gc_status(self.nick, self.room_jid, show='offline', status=reason) - self.parent_win.remove_tab(self.contact) + self.parent_win.remove_tab(self) return True elif command == 'ban': if len(message_array): @@ -1312,11 +1312,11 @@ class GroupchatControl(ChatControlBase): c = gajim.contacts.contact_from_gc_contact(gc_c) nick_jid = c.jid - win = gajim.interface.msg_win_mgr.get_window(nick_jid) + win = gajim.interface.msg_win_mgr.get_window(nick_jid, self.account) if not win: gajim.interface.roster.new_chat(c, self.account, private_chat = True) - win = gajim.interface.msg_win_mgr.get_window(nick_jid) - win.set_active_tab(nick_jid) + win = gajim.interface.msg_win_mgr.get_window(nick_jid, self.account) + win.set_active_tab(nick_jid, self.account) win.window.present() def on_list_treeview_row_activated(self, widget, path, col = 0): diff --git a/src/message_window.py b/src/message_window.py index 871bdf05b..bc973cbf3 100644 --- a/src/message_window.py +++ b/src/message_window.py @@ -131,8 +131,8 @@ class MessageWindow: # Add notebook page and connect up to the tab's close button xml = gtk.glade.XML(GTKGUI_GLADE, 'chat_tab_ebox', APP) tab_label_box = xml.get_widget('chat_tab_ebox') - xml.signal_connect('on_close_button_clicked', self.on_close_button_clicked, - control.contact) + xml.signal_connect('on_close_button_clicked', self._on_close_button_clicked, + control) xml.signal_connect('on_tab_eventbox_button_press_event', self.on_tab_eventbox_button_press_event, control.widget) self.notebook.append_page(control.widget, tab_label_box) @@ -173,9 +173,9 @@ class MessageWindow: elif event.keyval == gtk.keysyms.Page_Up: # CTRL + PAGE UP self.notebook.emit('key_press_event', event) - def on_close_button_clicked(self, button, contact): + def _on_close_button_clicked(self, button, control): '''When close button is pressed: close a tab''' - self.remove_tab(contact) + self.remove_tab(control) def show_title(self, urgent = True, control = None): '''redraw the window's title''' @@ -209,28 +209,28 @@ class MessageWindow: else: gtkgui_helpers.set_unset_urgency_hint(self.window, False) - def set_active_tab(self, jid): + def set_active_tab(self, jid, acct): + # FIXME: Use acct ctrl = self._controls[jid] ctrl_page = self.notebook.page_num(ctrl.widget) self.notebook.set_current_page(ctrl_page) - def remove_tab(self, contact): + def remove_tab(self, ctrl): # Shutdown the MessageControl - ctrl = self.get_control(contact.jid) if not ctrl.allow_shutdown(): return ctrl.shutdown() # Update external state if gajim.interface.systray_enabled: - gajim.interface.systray.remove_jid(contact.jid, ctrl.account, + gajim.interface.systray.remove_jid(ctrl.contact.jid, ctrl.account, ctrl.type_id) del gajim.last_message_time[ctrl.account][ctrl.contact.jid] self.disconnect_tab_dnd(ctrl.widget) self.notebook.remove_page(self.notebook.page_num(ctrl.widget)) - del self._controls[contact.jid] + del self._controls[ctrl.contact.jid] if len(self._controls) == 1: # we are going from two tabs to one show_tabs_if_one_tab = gajim.config.get('tabs_always_visible') self.notebook.set_show_tabs(show_tabs_if_one_tab) @@ -319,8 +319,10 @@ class MessageWindow: for ctrl in self.controls(): ctrl.update_tags() - def get_control(self, key): - '''Return the MessageControl for jid or n, where n is the notebook page index''' + def get_control(self, key, acct): + '''Return the MessageControl for jid or n, where n is a notebook page index. + When key is an int index acct may be None''' + # FIXME: Use acct if isinstance(key, str): key = unicode(key, 'utf-8') @@ -371,7 +373,7 @@ class MessageWindow: ind = self.notebook.get_n_pages() - 1 if ind == current: break # a complete cycle without finding an unread tab - ctrl = self.get_control(ind) + ctrl = self.get_control(ind, None) if ctrl.nb_unread > 0: found = True break # found @@ -403,7 +405,8 @@ class MessageWindow: gtk.ICON_SIZE_MENU) item.set_image(img) item.connect('activate', - lambda obj, jid:self.set_active_tab(jid), jid) + lambda obj, jid:self.set_active_tab(jid, ctrl.account), + jid) menu.append(item) # show the menu menu.popup(None, None, None, event.button, event.time) @@ -433,9 +436,9 @@ class MessageWindow: elif event.keyval == gtk.keysyms.Tab: # CTRL + TAB self.move_to_next_unread_tab(True) elif event.keyval == gtk.keysyms.F4: # CTRL + F4 - self.remove_tab(contact) + self.remove_tab(ctrl) elif event.keyval == gtk.keysyms.w: # CTRL + W - self.remove_tab(contact) + self.remove_tab(ctrl) # MOD1 (ALT) mask elif event.state & gtk.gdk.MOD1_MASK: @@ -457,7 +460,7 @@ class MessageWindow: ctrl.set_compact_view(not ctrl.compact_view_current) # Close tab bindings elif event.keyval == gtk.keysyms.Escape: # ESCAPE - self.remove_tab(contact) + self.remove_tab(ctrl) else: # If the active control has a message_textview pass the event to it active_ctrl = self.get_active_control() @@ -572,14 +575,14 @@ class MessageWindowMgr: return w return None - def get_window(self, jid): + def get_window(self, jid, acct): for win in self.windows(): - if win.get_control(jid): + if win.get_control(jid, acct): return win return None - def has_window(self, jid): - return self.get_window(jid) + def has_window(self, jid, acct): + return self.get_window(jid, acct) def one_window_opened(self, contact, acct, type): try: @@ -679,14 +682,15 @@ class MessageWindowMgr: del self._windows[k] return - def get_control(self, jid): + def get_control(self, jid, acct): '''Amongst all windows, return the MessageControl for jid''' - win = self.get_window(jid) + win = self.get_window(jid, acct) if win: - return win.get_control(jid) + return win.get_control(jid, acct) return None def get_controls(self, type): + # FIXME: Optionally accept an account arg ctrls = [] for c in self.controls(): if c.type_id == type: @@ -774,12 +778,10 @@ class MessageWindowMgr: controls.append(ctrl) w.window.destroy() - for k in self._windows.keys(): - del self._windows[k] self._windows = {} for ctrl in controls: - mw = self.get_window(ctrl.contact.jid) + mw = self.get_window(ctrl.contact.jid, ctr.account) if not mw: mw = self.create_window(ctrl.contact, ctrl.account, ctrl.type_id) ctrl.parent_win = mw diff --git a/src/remote_control.py b/src/remote_control.py index 7806926d1..8c08fbd5d 100644 --- a/src/remote_control.py +++ b/src/remote_control.py @@ -233,7 +233,7 @@ class SignalObject(DbusPrototype): for acct in accounts: if gajim.connections[acct].connected > 1: # account is online contact = gajim.contacts.get_first_contact_from_jid(acct, jid) - if gajim.interface.msg_win_mgr.has_window(jid): + if gajim.interface.msg_win_mgr.has_window(jid, acct): connected_account = acct break # jid is in roster @@ -254,7 +254,7 @@ class SignalObject(DbusPrototype): if connected_account: gajim.interface.roster.new_chat_from_jid(connected_account, jid) # preserve the 'steal focus preservation' - win = gajim.interface.msg_win_mgr.get_window(jid).window + win = gajim.interface.msg_win_mgr.get_window(jid, connected_account).window if win.get_property('visible'): win.window.focus() return True diff --git a/src/roster_window.py b/src/roster_window.py index 79dc6b785..c284e6d87 100644 --- a/src/roster_window.py +++ b/src/roster_window.py @@ -333,8 +333,8 @@ class RosterWindow: def join_gc_room(self, account, room_jid, nick, password): '''joins the room immediatelly''' - if gajim.interface.msg_win_mgr.has_window(room_jid) and \ - gajim.gc_connected[account][room_jid]: + if gajim.interface.msg_win_mgr.has_window(room_jid, account) and \ + gajim.gc_connected[account][room_jid]: dialogs.ErrorDialog(_('You are already in room %s') % room_jid ).get_response() return @@ -344,10 +344,10 @@ class RosterWindow: ).get_response() return room, server = room_jid.split('@') - if not gajim.interface.msg_win_mgr.has_window(room_jid): + if not gajim.interface.msg_win_mgr.has_window(room_jid, account): self.new_room(room_jid, nick, account) - gc_win = gajim.interface.msg_win_mgr.get_window(room_jid) - gc_win.set_active_tab(room_jid) + gc_win = gajim.interface.msg_win_mgr.get_window(room_jid, account) + gc_win.set_active_tab(room_jid, account) gc_win.window.present() gajim.connections[account].join_gc(nick, room, server, password) if password: @@ -726,10 +726,10 @@ class RosterWindow: self.add_contact_to_roster(contact.jid, account) self.draw_contact(contact.jid, account) # print status in chat window and update status/GPG image - if gajim.interface.msg_win_mgr.has_window(contact.jid): + if gajim.interface.msg_win_mgr.has_window(contact.jid, account): jid = contact.jid - win = gajim.interface.msg_win_mgr.get_window(contact.jid) - ctl = win.get_control(jid) + win = gajim.interface.msg_win_mgr.get_window(contact.jid, account) + ctl = win.get_control(jid, account) ctl.update_ui() win.redraw_tab(contact) @@ -923,8 +923,8 @@ class RosterWindow: keys[contact.jid] = keyID[0] for u in gajim.contacts.get_contact(account, contact.jid): u.keyID = keyID[0] - if gajim.interface.msg_win_mgr.has_window(contact.jid): - ctl = gajim.interface.msg_win_mgr.get_control(contact.jid) + if gajim.interface.msg_win_mgr.has_window(contact.jid, account): + ctl = gajim.interface.msg_win_mgr.get_control(contact.jid, account) ctl.update_ui() keys_str = '' for jid in keys: @@ -1389,12 +1389,12 @@ _('If "%s" accepts this request you will know his or her status.') % jid) jid = model[iter][C_JID].decode('utf-8') win = None c = gajim.contacts.get_contact_with_highest_priority(account, jid) - if gajim.interface.msg_win_mgr.has_window(c.jid): - win = gajim.interface.msg_win_mgr.get_window(c.jid) + if gajim.interface.msg_win_mgr.has_window(c.jid, account): + win = gajim.interface.msg_win_mgr.get_window(c.jid, account) elif c: self.new_chat(c, account) - win = gajim.interface.msg_win_mgr.get_window(jid) - win.set_active_tab(jid) + win = gajim.interface.msg_win_mgr.get_window(jid, account) + win.set_active_tab(jid, account) win.window.present() elif type == 'account': account = model[iter][C_ACCOUNT] @@ -1451,7 +1451,7 @@ _('If "%s" accepts this request you will know his or her status.') % jid) for u in gajim.contacts.get_contact(account, contact.jid): self.remove_contact(u, account) gajim.contacts.remove_jid(account, u.jid) - if gajim.interface.msg_win_mgr.has_window(contact.jid): + if gajim.interface.msg_win_mgr.has_window(contact.jid, account): c = gajim.contacts.create_contact(jid = contact.jid, name = contact.name, groups = [_('Not in Roster')], show = 'Not in Roster', status = '', ask = 'none', @@ -1548,8 +1548,7 @@ _('If "%s" accepts this request you will know his or her status.') % jid) passphrase) gajim.connections[account].gpg_passphrase(passphrase) - for gc_control in gajim.interface.msg_win_mgr.get_controls( - message_control.TYPE_GC): + for gc_control in gajim.interface.msg_win_mgr.get_controls(message_control.TYPE_GC): if gc_control.account == account: gajim.connections[account].send_gc_status(gc_control.nick, gc_control.room_jid, status, txt) @@ -1698,7 +1697,7 @@ _('If "%s" accepts this request you will know his or her status.') % jid) else: type = message_control.TYPE_PM - mw = gajim.interface.msg_win_mgr.get_window(contact.jid) + mw = gajim.interface.msg_win_mgr.get_window(contact.jid, account) if not mw: mw = gajim.interface.msg_win_mgr.create_window(contact, account, type) @@ -1728,16 +1727,16 @@ _('If "%s" accepts this request you will know his or her status.') % jid) gajim.contacts.add_contact(account, contact) self.add_contact_to_roster(contact.jid, account) - if not gajim.interface.msg_win_mgr.has_window(contact.jid): + if not gajim.interface.msg_win_mgr.has_window(contact.jid, account): self.new_chat(contact, account) - mw = gajim.interface.msg_win_mgr.get_window(contact.jid) - mw.set_active_tab(jid) + mw = gajim.interface.msg_win_mgr.get_window(contact.jid, account) + mw.set_active_tab(jid, account) mw.window.present() def new_room(self, room_jid, nick, account): # Get target window, create a control, and associate it with the window contact = gajim.contacts.create_contact(jid = room_jid, name = nick) - mw = gajim.interface.msg_win_mgr.get_window(contact.jid) + mw = gajim.interface.msg_win_mgr.get_window(contact.jid, account) if not mw: mw = gajim.interface.msg_win_mgr.create_window(contact, account, GroupchatControl.TYPE_ID) @@ -1786,11 +1785,11 @@ _('If "%s" accepts this request you will know his or her status.') % jid) return # We print if window is opened and it's not a single message - if gajim.interface.msg_win_mgr.has_window(jid) and msg_type != 'normal': + if gajim.interface.msg_win_mgr.has_window(jid, account) and msg_type != 'normal': typ = '' if msg_type == 'error': typ = 'status' - ctl = gajim.interface.msg_win_mgr.get_control(jid) + ctl = gajim.interface.msg_win_mgr.get_control(jid, account) ctl.print_conversation(msg, typ, tim = tim, encrypted = encrypted, subject = subject) return @@ -1804,7 +1803,7 @@ _('If "%s" accepts this request you will know his or her status.') % jid) qs[jid].append((kind, (msg, subject, msg_type, tim, encrypted, resource))) self.nb_unread += 1 if popup: - if not gajim.interface.msg_win_mgr.has_window(jid): + if not gajim.interface.msg_win_mgr.has_window(jid, account): self.new_chat(contact, account) if path: self.tree.expand_row(path[0:1], False) @@ -2062,13 +2061,13 @@ _('If "%s" accepts this request you will know his or her status.') % jid) return c = gajim.contacts.get_contact_with_highest_priority(account, jid) # Get the window containing the chat - win = gajim.interface.msg_win_mgr.get_window(jid) + win = gajim.interface.msg_win_mgr.get_window(jid, account) if win: - win.set_active_tab(jid) + win.set_active_tab(jid, account) elif c: self.new_chat(c, account) - win = gajim.interface.msg_win_mgr.get_window(jid) - win.set_active_tab(jid) + win = gajim.interface.msg_win_mgr.get_window(jid, account) + win.set_active_tab(jid, account) win.window.present() def on_roster_treeview_row_expanded(self, widget, iter, path): diff --git a/src/systray.py b/src/systray.py index 32d9e269a..d64630004 100644 --- a/src/systray.py +++ b/src/systray.py @@ -101,13 +101,13 @@ class Systray: def start_chat(self, widget, account, jid): contact = gajim.contacts.get_first_contact_from_jid(account, jid) - if gajim.interface.msg_win_mgr.has_window(jid): - gajim.interface.msg_win_mgr.get_window(jid).set_active_tab(jid) - gajim.interface.msg_win_mgr.get_window(jid).present() + if gajim.interface.msg_win_mgr.has_window(jid, account): + gajim.interface.msg_win_mgr.get_window(jid, account).set_active_tab(jid, account) + gajim.interface.msg_win_mgr.get_window(jid, account).present() elif contact: gajim.interface.roster.new_chat(gajim.contacts[account][jid][0], account) - gajim.interface.msg_win_mgr.get_window(jid).set_active_tab(jid) + gajim.interface.msg_win_mgr.get_window(jid, account).set_active_tab(jid, account) def on_new_message_menuitem_activate(self, widget, account): """When new message menuitem is activated: