use new contacts functions everywhere

This commit is contained in:
Yann Leboulanger 2005-12-30 09:58:34 +00:00
parent 349c69d5b3
commit d571d9ce8b
3 changed files with 9 additions and 23 deletions

View File

@ -190,7 +190,7 @@ class Chat:
add = _('Group Chat') add = _('Group Chat')
elif len(self.xmls) == 1: # just one tab elif len(self.xmls) == 1: # just one tab
if self.widget_name == 'tabbed_chat_window': if self.widget_name == 'tabbed_chat_window':
c = gajim.get_first_contact_instance_from_jid(self.account, jid) c = gajim.contacts.get_first_contact_from_jid(self.account, jid)
if c is None: if c is None:
add = '' add = ''
else: else:

View File

@ -158,19 +158,6 @@ def get_real_jid_from_fjid(account, fjid):
def get_room_from_fjid(jid): def get_room_from_fjid(jid):
return get_room_and_nick_from_fjid(jid)[0] return get_room_and_nick_from_fjid(jid)[0]
def get_first_contact_instance_from_jid(account, jid):
contact = None
if jid in contacts[account]:
contact = contacts[account][jid][0]
else: # it's fake jid
#FIXME: problem see comment in next line
room, nick = \
get_room_and_nick_from_fjid(jid) # if we ban/kick we now real jid
if gc_contacts[account].has_key(room) and \
nick in gc_contacts[account][room]:
contact = gc_contacts[account][room][nick]
return contact
def get_contact_name_from_jid(account, jid): def get_contact_name_from_jid(account, jid):
return contacts[account][jid][0].name return contacts[account][jid][0].name

View File

@ -338,9 +338,8 @@ class TabbedChatWindow(chat.Chat):
def set_state_image(self, jid): def set_state_image(self, jid):
prio = 0 prio = 0
if gajim.contacts[self.account].has_key(jid): contact_list = gajim.contacts.get_contact(self.account, jid)
contacts_list = gajim.contacts[self.account][jid] if contact_list:
else:
contacts_list = [self.contacts[jid]] contacts_list = [self.contacts[jid]]
contact = contacts_list[0] contact = contacts_list[0]
@ -436,7 +435,7 @@ class TabbedChatWindow(chat.Chat):
def on_send_file_menuitem_activate(self, widget): def on_send_file_menuitem_activate(self, widget):
jid = self.get_active_jid() jid = self.get_active_jid()
contact = gajim.get_first_contact_instance_from_jid(self.account, jid) contact = gajim.contacts.get_first_contact_from_jid(self.account, jid)
gajim.interface.instances['file_transfers'].show_file_send_request( gajim.interface.instances['file_transfers'].show_file_send_request(
self.account, contact) self.account, contact)
@ -532,7 +531,7 @@ class TabbedChatWindow(chat.Chat):
in the last 5 seconds? in the last 5 seconds?
if yes we go active for mouse, composing for kbd if yes we go active for mouse, composing for kbd
if no we go paused if we were previously composing ''' if no we go paused if we were previously composing '''
contact = gajim.get_first_contact_instance_from_jid(self.account, jid) contact = gajim.contacts.get_first_contact_from_jid(self.account, jid)
if jid not in self.xmls or contact is None: if jid not in self.xmls or contact is None:
# the tab with jid is no longer open or contact left # the tab with jid is no longer open or contact left
# stop timer # stop timer
@ -564,7 +563,7 @@ class TabbedChatWindow(chat.Chat):
in the last 30 seconds? in the last 30 seconds?
if yes we go active if yes we go active
if no we go inactive ''' if no we go inactive '''
contact = gajim.get_first_contact_instance_from_jid(self.account, jid) contact = gajim.contacts.get_first_contact_from_jid(self.account, jid)
if jid not in self.xmls or contact is None: if jid not in self.xmls or contact is None:
# the tab with jid is no longer open or contact left # the tab with jid is no longer open or contact left
return False # stop looping return False # stop looping
@ -691,7 +690,7 @@ class TabbedChatWindow(chat.Chat):
if jid is None: if jid is None:
jid = self.get_active_jid() jid = self.get_active_jid()
contact = gajim.get_first_contact_instance_from_jid(self.account, jid) contact = gajim.contacts.get_first_contact_from_jid(self.account, jid)
if contact is None: if contact is None:
# contact was from pm in MUC, and left the room so contact is None # contact was from pm in MUC, and left the room so contact is None
@ -748,7 +747,7 @@ class TabbedChatWindow(chat.Chat):
return return
jid = self.get_active_jid() jid = self.get_active_jid()
contact = gajim.get_first_contact_instance_from_jid(self.account, jid) contact = gajim.contacts.get_first_contact_from_jid(self.account, jid)
if contact is None: 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, and left the room, or we left the room
room, nick = gajim.get_room_and_nick_from_fjid(jid) room, nick = gajim.get_room_and_nick_from_fjid(jid)
@ -877,7 +876,7 @@ class TabbedChatWindow(chat.Chat):
if (contact.show == 'offline' or contact.show == 'error'): if (contact.show == 'offline' or contact.show == 'error'):
showOffline = gajim.config.get('showoffline') showOffline = gajim.config.get('showoffline')
if not showOffline and typ == 'chat' and \ if not showOffline and typ == 'chat' and \
len(gajim.contacts[self.account][jid]) == 1: len(gajim.contacts.get_contact(self.account, jid)) == 1:
gajim.interface.roster.really_remove_contact(contact, self.account) gajim.interface.roster.really_remove_contact(contact, self.account)
elif typ == 'pm': elif typ == 'pm':
gcs[room_jid].remove_contact(room_jid, nick) gcs[room_jid].remove_contact(room_jid, nick)