Private message bug fixes

This commit is contained in:
Travis Shirk 2006-01-08 23:14:50 +00:00
parent 9a247cdc0d
commit a6bdc39d5d
5 changed files with 29 additions and 40 deletions

View File

@ -747,6 +747,9 @@ class ChatControl(ChatControlBase):
def _update_banner_state_image(self):
contact = gajim.contacts.get_contact_with_highest_priority(self.account,
self.contact.jid)
if not contact:
# For transient contacts
contact = self.contact
show = contact.show
jid = contact.jid
@ -1031,6 +1034,9 @@ class ChatControl(ChatControlBase):
else:
contact = gajim.contacts.get_contact_with_highest_priority(self.account,
self.contact.jid)
if not contact:
# For transient contacts
contact = self.contact
tab_img = img_16[contact.show]
return tab_img

View File

@ -99,7 +99,6 @@ class Contacts:
def create_contact(self, jid='', name='', groups=[], show='', status='',
sub='', ask='', resource='', priority=5, keyID='', our_chatstate=None,
chatstate=None):
print "Creating contact:", jid
return Contact(jid, name, groups, show, status, sub, ask, resource,
priority, keyID, our_chatstate, chatstate)
@ -111,7 +110,6 @@ class Contacts:
our_chatstate = contact.our_chatstate, chatstate = contact.chatstate)
def add_contact(self, account, contact):
print "Adding contact:", contact.jid
# No such account before ?
if not self._contacts.has_key(account):
self._contacts[account] = {contact.jid : [contact]}
@ -132,7 +130,6 @@ class Contacts:
contacts.append(contact)
def remove_contact(self, account, contact):
print "Removing contact:", contact.jid
if not self._contacts.has_key(account):
return
if not self._contacts[account].has_key(contact.jid):
@ -141,7 +138,6 @@ class Contacts:
self._contacts[account][contact.jid].remove(contact)
def remove_jid(self, account, jid):
print "Adding jid:", jid
'''Removes all contacts for a given jid'''
if not self._contacts.has_key(account):
return
@ -169,7 +165,7 @@ class Contacts:
def get_contacts_from_jid(self, account, jid):
''' we may have two or more resources on that jid '''
if jid in self._contacts[account].keys():
if jid in self._contacts[account]:
contacts_instances = self._contacts[account][jid]
return contacts_instances
return []
@ -179,14 +175,17 @@ class Contacts:
return None
prim_contact = contacts[0]
for contact in contacts[1:]:
print "checking priority of", contact.jid
if int(contact.priority) > int(prim_contact.priority):
prim_contact = contact
return prim_contact
def get_contact_with_highest_priority(self, account, jid):
contacts = self.get_contacts_from_jid(account, jid)
print "contacts:", contacts
if not contacts and '/' in jid:
# jid may be a nick jid, try it
room, nick = jid.split('/')
contact = self.get_gc_contact(account, room, nick)
return contact or []
return self.get_highest_prio_contact_from_contacts(contacts)
def get_first_contact_from_jid(self, account, jid):
@ -236,12 +235,10 @@ class Contacts:
def create_gc_contact(self, room_jid='', name='', show='', status='',
role='', affiliation='', jid='', resource=''):
print "Creating GC contact:", room_jid, jid
return GC_Contact(room_jid, name, show, status, role, affiliation, jid,
resource)
def add_gc_contact(self, account, gc_contact):
print "Adding GC contact:", gc_contact.room_jid
# No such account before ?
if not self._gc_contacts.has_key(account):
self._contacts[account] = {gc_contact.room_jid : {gc_contact.name: \
@ -256,7 +253,6 @@ class Contacts:
gc_contact
def remove_gc_contact(self, account, gc_contact):
print "Adding GC contact:", gc_contact.room_jid
if not self._gc_contacts.has_key(account):
return
if not self._gc_contacts[account].has_key(gc_contact.room_jid):
@ -270,22 +266,12 @@ class Contacts:
del self._gc_contacts[account][gc_contact.room_jid]
def remove_room(self, account, room_jid):
print "Removing room:", room_jid
if not self._gc_contacts.has_key(account):
return
if not self._gc_contacts[account].has_key(room_jid):
return
del self._gc_contacts[account][room_jid]
def get_gc_contact(self, account, room_jid, nick):
if not self._gc_contacts.has_key(account):
return
if not self._gc_contacts[account].has_key(room_jid):
return
if not self._gc_contacts[account][room_jid].has_key(nick):
return
del self._gc_contacts[account][room_jid][nick]
def get_gc_list(self, account):
if not self._gc_contacts.has_key(account):
return []

View File

@ -656,8 +656,9 @@ class Interface:
elif resource and gajim.interface.msg_win_mgr.has_window(jid + '/' + resource):
win = gajim.interface.msg_win_mgr.get_window(jid + '/' + resource)
ctl = win.get_control(jid + '/' + resource)
if win:
if win and ctl.type_id != message_control.TYPE_GC:
ctl.show_avatar()
# Show avatar in roster
self.roster.draw_avatar(jid, account)
if self.remote_ctrl:
@ -696,10 +697,15 @@ class Interface:
'status')
ctl.draw_banner()
gc_control = gajim.interface.msg_win_mgr.get_control(room_jid)
if gc_control:
gc_control.chg_contact_status(nick, show, status, array[4], array[5], array[6],
array[7], array[8], array[9], array[10])
# Get the window and control for the updated status, this may be a PrivateChatControl
control = gajim.interface.msg_win_mgr.get_control(room_jid)
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)
if pm_control:
pm_control.parent_win.redraw_tab(pm_control.contact)
if self.remote_ctrl:
self.remote_ctrl.raise_signal('GCPresence', (account, array))

View File

@ -85,6 +85,7 @@ class PrivateChatControl(ChatControl):
ChatControl.send_message(self, message)
class GroupchatControl(ChatControlBase):
TYPE_ID = message_control.TYPE_GC
@ -611,10 +612,12 @@ class GroupchatControl(ChatControlBase):
'''When an occupant changes his or her status'''
if show == 'invisible':
return
if not role:
role = 'visitor'
if not affiliation:
affiliation = 'none'
if show in ('offline', 'error'):
if statusCode == '307':
if actor is None: # do not print 'kicked by None'
@ -676,6 +679,8 @@ class GroupchatControl(ChatControlBase):
c.affiliation = affiliation
c.status = status
self.draw_contact(nick)
self.parent_win.redraw_tab(self.contact)
if (time.time() - self.room_creation) > 30 and \
nick != self.nick and statusCode != '303':
if show == 'offline':
@ -1324,9 +1329,7 @@ class GroupchatControl(ChatControlBase):
win = gajim.interface.msg_win_mgr.get_window(nick_jid)
if not win:
gc_c = gajim.contacts.get_gc_contact(self.account, self.room_jid, nick)
c = gajim.contacts.contact_from_gc_contact(gc_c)
gajim.interface.roster.new_chat(c, self.account)
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.window.present()

View File

@ -127,11 +127,6 @@ class MessageWindow:
self.notebook.set_show_tabs(True)
self.alignment.set_property('top-padding', 2)
# Connect to keyboard events
#if isinstance(control, ChatControlBase):
# control.msg_textview.connect('mykeypress',
# self._on_message_textview_mykeypress_event)
# 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')
@ -524,7 +519,6 @@ class MessageWindowMgr:
opt_height = type + '-msgwin-height'
size = (gajim.config.get(opt_width),
gajim.config.get(opt_height))
print "Window size:", size
gtkgui_helpers.resize_window(win.window, size[0], size[1])
def _position_window(self, win, acct, type):
@ -543,7 +537,6 @@ class MessageWindowMgr:
pos = (gajim.config.get(type + '-msgwin-x-position'),
gajim.config.get(type + '-msgwin-y-position'))
print "Window position:", pos
if pos[0] != -1 and pos[1] != -1:
gtkgui_helpers.move_window(win.window, pos[0], pos[1])
@ -606,11 +599,6 @@ class MessageWindowMgr:
size_width_key = type + "-msgwin-width"
size_height_key = type + "-msgwin-height"
print "saving acct:", acct
print "saving %s=%d" % (pos_x_key, x)
print "saving %s=%d" % (pos_y_key, y)
print "saving %s=%d" % (size_width_key, width)
print "saving %s=%d" % (size_height_key, height)
if acct:
gajim.config.set_per(pos_x_key, x, acct)
gajim.config.set_per(pos_y_key, y, acct)