status message in the banner instaed of jid; remove_user => remove_contact

This commit is contained in:
Nikos Kouremenos 2005-07-21 17:54:58 +00:00
parent 4ec127aa92
commit ef6643b24d
5 changed files with 43 additions and 42 deletions

View File

@ -63,7 +63,7 @@ class EditGroupsDialog:
self.user.name, self.user.groups)
def update_contact(self):
self.plugin.roster.remove_user(self.user, self.account)
self.plugin.roster.remove_contact(self.user, self.account)
self.plugin.roster.add_contact_to_roster(self.user.jid, self.account)
def on_add_button_clicked(self, widget):

View File

@ -280,7 +280,7 @@ class Interface:
gajim.newly_added[account].remove(user1.jid)
self.roster.draw_contact(user1.jid, account)
if not gajim.awaiting_messages[account].has_key(jid):
gobject.timeout_add(5000, self.roster.really_remove_user, \
gobject.timeout_add(5000, self.roster.really_remove_contact, \
user1, account)
user1.show = array[1]
user1.status = array[2]
@ -478,7 +478,7 @@ class Interface:
if gajim.contacts[account].has_key(jid):
u = gajim.contacts[account][jid][0]
u.resource = array[1]
self.roster.remove_user(u, account)
self.roster.remove_contact(u, account)
if _('not in the roster') in u.groups:
u.groups.remove(_('not in the roster'))
if len(u.groups) == 0:
@ -653,7 +653,7 @@ class Interface:
return
users = gajim.contacts[account][jid]
if not (array[2] or array[3]):
self.roster.remove_user(users[0], account)
self.roster.remove_contact(users[0], account)
del gajim.contacts[account][jid]
#TODO if it was the only one in its group, remove the group
return

View File

@ -207,7 +207,7 @@ class GroupchatWindow(chat.Chat):
'''get nicks of contacts in a room'''
return self.contacts[room_jid].keys()
def remove_user(self, room_jid, nick):
def remove_contact(self, room_jid, nick):
"""Remove a user from the contacts_list"""
model = self.list_treeview[room_jid].get_model()
iter = self.get_contact_iter(room_jid, nick)
@ -299,7 +299,7 @@ class GroupchatWindow(chat.Chat):
new_nick), room_jid)
if nick == self.nicks[room_jid]: # We changed our nick
self.nicks[room_jid] = new_nick
self.remove_user(room_jid, nick)
self.remove_contact(room_jid, nick)
if nick == self.nicks[room_jid] and statusCode != '303': # We became offline
model.clear()
self.contacts[room_jid] = {}
@ -310,7 +310,7 @@ class GroupchatWindow(chat.Chat):
else:
actual_role = self.get_role(room_jid, nick)
if role != actual_role:
self.remove_user(room_jid, nick)
self.remove_contact(room_jid, nick)
self.add_contact_to_roster(room_jid, nick, show, role, jid,
affiliation)
else:

View File

@ -158,7 +158,7 @@ class RosterWindow:
False)
self.draw_contact(jid, account)
def really_remove_user(self, user, account):
def really_remove_contact(self, user, account):
if user.jid in gajim.newly_added[account]:
return
if user.jid.find('@') < 1 and gajim.connections[account].connected > 1: # It's an agent
@ -168,9 +168,9 @@ class RosterWindow:
if gajim.config.get('showoffline'):
self.draw_contact(user.jid, account)
return
self.remove_user(user, account)
self.remove_contact(user, account)
def remove_user(self, user, account):
def remove_contact(self, user, account):
'''Remove a user from the roster'''
if user.jid in gajim.to_be_removed[account]:
return
@ -593,36 +593,39 @@ class RosterWindow:
ishidden = True
gajim.groups[account][g] = { 'expand': ishidden }
def chg_contact_status(self, user, show, status, account):
def chg_contact_status(self, contact, show, status, account):
'''When a contact changes his status'''
showOffline = gajim.config.get('showoffline')
model = self.tree.get_model()
luser = gajim.contacts[account][user.jid]
user.show = show
user.status = status
contact_instances = gajim.contacts[account][contact.jid]
contact.show = show
contact.status = status
if (show == 'offline' or show == 'error') and \
not gajim.awaiting_messages[account].has_key(user.jid):
if len(luser) > 1:
luser.remove(user)
self.draw_contact(user.jid, account)
not gajim.awaiting_messages[account].has_key(contact.jid):
if len(contact_instances) > 1: # if multiple resources
contact_instances.remove(contact)
self.draw_contact(contact.jid, account)
elif not showOffline:
self.remove_user(user, account)
self.remove_contact(contact, account)
else:
self.draw_contact(user.jid, account)
self.draw_contact(contact.jid, account)
else:
if not self.get_contact_iter(user.jid, account):
self.add_contact_to_roster(user.jid, account)
self.draw_contact(user.jid, account)
if not self.get_contact_iter(contact.jid, account):
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 self.plugin.windows[account]['chats'].has_key(user.jid):
jid = user.jid
if self.plugin.windows[account]['chats'].has_key(contact.jid):
jid = contact.jid
self.plugin.windows[account]['chats'][jid].set_state_image(jid)
name = user.name
if user.resource != '':
name += '/' + user.resource
name = contact.name
if contact.resource != '':
name += '/' + contact.resource
uf_show = helpers.get_uf_show(show)
self.plugin.windows[account]['chats'][jid].print_conversation(
_('%s is now %s (%s)') % (name, uf_show, status), jid, 'status')
self.plugin.windows[account]['chats'][jid].draw_name_banner(
contact, chatstate = None)
def on_info(self, widget, user, account):
'''Call vcard_information_window class to display user's information'''
@ -684,7 +687,7 @@ class RosterWindow:
gajim.connections[account].unsubscribe_agent(contact.jid + '/' \
+ contact.resource)
# remove transport from treeview
self.remove_user(contact, account)
self.remove_contact(contact, account)
# remove transport's contacts from treeview
for jid, contacts in gajim.contacts[account].items():
contact = contacts[0]
@ -692,7 +695,7 @@ class RosterWindow:
gajim.log.debug(
'Removing contact %s due to unregistered transport %s'\
% (contact.jid, contact.name))
self.remove_user(contact, account)
self.remove_contact(contact, account)
del gajim.contacts[account][contact.jid]
def on_rename(self, widget, iter, path):
@ -1021,7 +1024,7 @@ _('If "%s" accepts this request you will know his status.') %jid).get_response()
return
user1.groups = [group]
user1.name = pseudo
self.remove_user(user1, account)
self.remove_contact(user1, account)
self.add_contact_to_roster(jid, account)
def on_roster_treeview_scroll_event(self, widget, event):
@ -1146,7 +1149,7 @@ _('If "%s" accepts this request you will know his status.') %jid).get_response()
if window.get_response() == gtk.RESPONSE_OK:
gajim.connections[account].unsubscribe(user.jid)
for u in gajim.contacts[account][user.jid]:
self.remove_user(u, account)
self.remove_contact(u, account)
del gajim.contacts[account][u.jid]
if user.jid in self.plugin.windows[account]['chats']:
user1 = Contact(jid = user.jid, name = user.name,
@ -1663,7 +1666,7 @@ _('If "%s" accepts this request you will know his status.') %jid).get_response()
user = gajim.contacts[account][jid][0]
if old_name in user.groups:
#set them in the new one and remove it from the old
self.remove_user(user, account)
self.remove_contact(user, account)
user.groups.remove(old_name)
user.groups.append(new_text)
self.add_contact_to_roster(user.jid, account)

View File

@ -117,6 +117,10 @@ class TabbedChatWindow(chat.Chat):
'<','&lt;')
jid = contact.jid
status = contact.status
if status is None:
status = ''
#FIXME: uncomment me when we support sending messages to specific resource
# composing full jid
@ -128,10 +132,10 @@ class TabbedChatWindow(chat.Chat):
if chatstate:
label_text = '<span weight="heavy" size="x-large">%s</span> (chat state: %s)\n%s' \
% (name, chatstate, jid)
% (name, chatstate, status)
else:
label_text = '<span weight="heavy" size="x-large">%s</span>\n%s' \
% (name, jid)
% (name, status)
# setup the label that holds name and jid
banner_name_label = self.xmls[jid].get_widget('banner_name_label')
@ -293,12 +297,6 @@ class TabbedChatWindow(chat.Chat):
chat.Chat.new_tab(self, contact.jid)
self.redraw_tab(contact.jid)
self.draw_widgets(contact)
uf_show = helpers.get_uf_show(contact.show)
s = _('%s is %s') % (contact.name, uf_show)
if contact.status:
s += ' (' + contact.status + ')'
self.print_conversation(s, contact.jid, 'status')
#restore previous conversation
self.restore_conversation(contact.jid)
@ -567,7 +565,7 @@ class TabbedChatWindow(chat.Chat):
if (user.show == 'offline' or user.show == 'error') and \
not showOffline:
if len(gajim.contacts[self.account][jid]) == 1:
self.plugin.roster.really_remove_user(user, self.account)
self.plugin.roster.really_remove_contact(user, self.account)
def print_conversation(self, text, jid, contact = '', tim = None,
encrypted = False, subject = None):