From c4f4da5aef9afee290cb951d6572e84ea36274d4 Mon Sep 17 00:00:00 2001 From: Travis Shirk Date: Fri, 6 Jan 2006 02:20:38 +0000 Subject: [PATCH] Tracking trunk changes: Merged revisions 5008-5011 via svnmerge from svn://svn.gajim.org/gajim/trunk ........ r5008 | asterix | 2006-01-05 12:55:22 -0700 (Thu, 05 Jan 2006) | 2 lines new_chat must be called with a Contact instance instead of GC_Contact ........ r5009 | asterix | 2006-01-05 12:56:35 -0700 (Thu, 05 Jan 2006) | 2 lines use new contacts functions in common/gajim.py ........ r5010 | asterix | 2006-01-05 12:59:06 -0700 (Thu, 05 Jan 2006) | 2 lines get_first_contact_from_jid doesn't return a GC_Contact instance ........ r5011 | asterix | 2006-01-05 12:59:35 -0700 (Thu, 05 Jan 2006) | 2 lines check correctly if a contact leaves the groupchat ........ --- src/chat_control.py | 16 ++++++++++------ src/common/contacts.py | 5 ----- src/common/gajim.py | 11 ++++++----- src/groupchat_control.py | 3 ++- src/groupchat_window.py | 10 ++++++---- src/tabbed_chat_window.py | 15 +++++++++------ 6 files changed, 33 insertions(+), 27 deletions(-) diff --git a/src/chat_control.py b/src/chat_control.py index a4379ef8b..a231b0c95 100644 --- a/src/chat_control.py +++ b/src/chat_control.py @@ -310,13 +310,17 @@ class ChatControlBase(MessageControl): message_buffer.set_text('') # clear message buffer (and tv of course) # FIXME GC ONLY # if contact is None: -# # contact was from pm in MUC, and left the room, or we left the room +# # contact was from pm in MUC # room, nick = gajim.get_room_and_nick_from_fjid(jid) -# dialogs.ErrorDialog(_('Sending private message failed'), -# #in second %s code replaces with nickname -# _('You are no longer in room "%s" or "%s" has left.') % \ -# (room, nick)).get_response() -# +# gc_contact = gajim.contacts.get_gc_contact(self.account, room, nick) +# if not gc_contact: +# # contact left the room, or we left the room +# dialogs.ErrorDialog(_('Sending private message failed'), +# #in second %s code replaces with nickname +# _('You are no longer in room "%s" or "%s" has left.') % \ +# (room, nick)).get_response() +# return + def save_sent_message(self, message): #save the message, so user can scroll though the list with key up/down diff --git a/src/common/contacts.py b/src/common/contacts.py index f5049cf02..ad257e617 100644 --- a/src/common/contacts.py +++ b/src/common/contacts.py @@ -187,11 +187,6 @@ class Contacts: def get_first_contact_from_jid(self, account, jid): if jid in self._contacts[account]: return self._contacts[account][jid][0] - else: # it's fake jid - room, nick = common.gajim.get_room_and_nick_from_fjid(jid) - if self._gc_contacts[account].has_key(room) and \ - nick in self._gc_contacts[account][room]: - return self._gc_contacts[account][room][nick] return None def get_parent_contact(self, account, contact): diff --git a/src/common/gajim.py b/src/common/gajim.py index 9c81956f0..2ae16817f 100644 --- a/src/common/gajim.py +++ b/src/common/gajim.py @@ -148,18 +148,19 @@ def get_real_jid_from_fjid(account, fjid): gcs = interface.instances[account]['gc'] if gcs.has_key(room_jid): # It's a pm, so if we have real jid it's in contact.jid - if not gc_contacts[account][room_jid].has_key(nick): + gc_contact = contacts.get_gc_contact(account, room_jid, nick) + if not gc_contact: return - contact = gc_contacts[account][room_jid][nick] - # contact.jid is None when it's not a real jid (we don't know real jid) - real_jid = contact.jid + # gc_contact.jid is None when it's not a real jid (we don't know real jid) + real_jid = gc_contact.jid return real_jid def get_room_from_fjid(jid): return get_room_and_nick_from_fjid(jid)[0] def get_contact_name_from_jid(account, jid): - return contacts[account][jid][0].name + c = contacts.get_first_contact_from_jid(account, jid) + return c.name def get_jid_without_resource(jid): return jid.split('/')[0] diff --git a/src/groupchat_control.py b/src/groupchat_control.py index 8124be9f2..b93a0bd3b 100644 --- a/src/groupchat_control.py +++ b/src/groupchat_control.py @@ -231,7 +231,8 @@ class GroupchatControl(ChatControlBase): self.parent_win.show_title() else: gc_c = gajim.contacts.get_gc_contact(self.account, self.room_jid, nick) - gajim.interface.roster.new_chat(gc_c, self.account) + c = gajim.contacts.contact_from_gc_contact(gc_c) + gajim.interface.roster.new_chat(c, self.account) # Scroll to line self.list_treeview.expand_row(path[0:1], False) self.list_treeview.scroll_to_cell(path) diff --git a/src/groupchat_window.py b/src/groupchat_window.py index 3d2235ab0..63995279a 100644 --- a/src/groupchat_window.py +++ b/src/groupchat_window.py @@ -1519,7 +1519,8 @@ current room topic.') % command, room_jid) self.show_title() else: gc_c = gajim.contacts.get_gc_contact(self.account, room_jid, nick) - gajim.interface.roster.new_chat(gc_c, self.account) + c = gajim.contacts.contact_from_gc_contact(gc_c) + gajim.interface.roster.new_chat(c, self.account) # Scroll to line self.list_treeview[room_jid].expand_row(path[0:1], False) self.list_treeview[room_jid].scroll_to_cell(path) @@ -1631,7 +1632,8 @@ current room topic.') % command, room_jid) if not gajim.interface.instances[self.account]['chats'].has_key(fjid): gc_c = gajim.contacts.get_gc_contact(self.account, room_jid, nick) - gajim.interface.roster.new_chat(gc_c, self.account) + c = gajim.contacts.contact_from_gc_contact(gc_c) + gajim.interface.roster.new_chat(c, self.account) gajim.interface.instances[self.account]['chats'][fjid].set_active_tab(fjid) gajim.interface.instances[self.account]['chats'][fjid].window.present() return True @@ -1675,8 +1677,8 @@ current room topic.') % command, room_jid) # FIXME if not gajim.interface.instances[self.account]['chats'].has_key(jid): gc_c = gajim.contacts.get_gc_contact(self.account, room_jid, nick) - gajim.interface.roster.new_chat(gc_c, self.account) - jid = gc_c.jid + c = gajim.contacts.contact_from_gc_contact(gc_c) + gajim.interface.roster.new_chat(c, self.account) gajim.interface.instances[self.account]['chats'][jid].set_active_tab(jid) gajim.interface.instances[self.account]['chats'][jid].window.present() diff --git a/src/tabbed_chat_window.py b/src/tabbed_chat_window.py index 3e5218cb9..90327b366 100644 --- a/src/tabbed_chat_window.py +++ b/src/tabbed_chat_window.py @@ -745,13 +745,16 @@ class TabbedChatWindow(chat.Chat): jid = self.get_active_jid() contact = gajim.contacts.get_first_contact_from_jid(self.account, jid) if contact is None: - # contact was from pm in MUC, and left the room, or we left the room + # contact was from pm in MUC room, nick = gajim.get_room_and_nick_from_fjid(jid) - dialogs.ErrorDialog(_('Sending private message failed'), - #in second %s code replaces with nickname - _('You are no longer in room "%s" or "%s" has left.') % \ - (room, nick)).get_response() - return + gc_contact = gajim.contacts.get_gc_contact(self.account, room, nick) + if not gc_contact: + # contact left the room, or we left the room + dialogs.ErrorDialog(_('Sending private message failed'), + #in second %s code replaces with nickname + _('You are no longer in room "%s" or "%s" has left.') % \ + (room, nick)).get_response() + return conv_textview = self.conversation_textviews[jid] message_textview = self.message_textviews[jid]