changeset 9f506f74a70b in /home/hg/repos/gajim
details:http://hg.gajim.org/gajim?cmd=changeset;node=9f506f74a70b
description: handle correctly groupchat presences. Fixes #6047
diffstat:
src/groupchat_control.py | 48 +++++++++++++++++++++++++++++
src/gui_interface.py | 79 ------------------------------------------------
src/roster_window.py | 14 ++++++++
3 files changed, 62 insertions(+), 79 deletions(-)
diffs (197 lines):
diff -r 44730c1b5813 -r 9f506f74a70b src/groupchat_control.py
--- a/src/groupchat_control.py Tue Nov 23 22:40:10 2010 +0300
+++ b/src/groupchat_control.py Tue Nov 23 23:10:43 2010 +0100
@@ -148,11 +148,17 @@
self.gc_contact = gc_contact
ChatControl.__init__(self, parent_win, contact, account, session)
self.TYPE_ID = 'pm'
+ gajim.ged.register_event_handler('caps-received', ged.GUI1,
+ self._nec_caps_received)
+ gajim.ged.register_event_handler('gc-presence-received', ged.GUI1,
+ self._nec_gc_presence_received)
def shutdown(self):
super(PrivateChatControl, self).shutdown()
gajim.ged.remove_event_handler('caps-received', ged.GUI1,
self._nec_caps_received)
+ gajim.ged.remove_event_handler('gc-presence-received', ged.GUI1,
+ self._nec_gc_presence_received)
def _nec_caps_received(self, obj):
if obj.conn.name != self.account or \
@@ -160,6 +166,48 @@
return
self.update_contact()
+ def _nec_gc_presence_received(self, obj):
+ if obj.conn.name != self.account:
+ return
+ if obj.fjid != self.full_jid:
+ return
+ if '303' in obj.status_code:
+ self.print_conversation(_('%(nick)s is now known as '
+ '%(new_nick)s') % {'nick': obj.nick, 'new_nick': obj.new_nick},
+ 'status')
+ gc_c = gajim.contacts.get_gc_contact(obj.conn.name, obj.room_jid,
+ obj.new_nick)
+ c = gc_c.as_contact()
+ self.gc_contact = gc_c
+ self.contact = c
+ if self.session:
+ # stop e2e
+ if self.session.enable_encryption:
+ thread_id = self.session.thread_id
+ self.session.terminate_e2e()
+ obj.conn.delete_session(obj.fjid, thread_id)
+ self.no_autonegotiation = False
+ self.draw_banner()
+ old_jid = obj.room_jid + '/' + obj.nick
+ new_jid = obj.room_jid + '/' + obj.new_nick
+ gajim.interface.msg_win_mgr.change_key(old_jid, new_jid,
+ obj.conn.name)
+ else:
+ self.contact.show = obj.show
+ self.contact.status = obj.status
+ self.gc_contact.show = obj.show
+ self.gc_contact.status = obj.status
+ uf_show = helpers.get_uf_show(obj.show)
+ self.print_conversation(_('%(nick)s is now %(status)s') % {
+ 'nick': obj.nick, 'status': uf_show}, 'status')
+ if obj.status:
+ self.print_conversation(' (', 'status', simple=True)
+ self.print_conversation('%s' % (obj.status), 'status',
+ simple=True)
+ self.print_conversation(')', 'status', simple=True)
+ self.parent_win.redraw_tab(self)
+ self.update_ui()
+
def send_message(self, message, xhtml=None, process_commands=True):
"""
Call this method to send the message
diff -r 44730c1b5813 -r 9f506f74a70b src/gui_interface.py
--- a/src/gui_interface.py Tue Nov 23 22:40:10 2010 +0300
+++ b/src/gui_interface.py Tue Nov 23 23:10:43 2010 +0100
@@ -638,84 +638,6 @@
if self.roster.tooltip.id and self.roster.tooltip.win:
self.roster.tooltip.update_last_time(last_time)
- def handle_event_gc_notify(self, account, array):
- #'GC_NOTIFY' (account, (room_jid, show, status, nick,
- # role, affiliation, jid, reason, actor, statusCode, newNick,
- # avatar_sha))
- nick = array[3]
- if not nick:
- return
- room_jid = array[0]
- fjid = room_jid + '/' + nick
- show = array[1]
- status = array[2]
- conn = gajim.connections[account]
-
- # Get the window and control for the updated status, this may be a
- # PrivateChatControl
- control = self.msg_win_mgr.get_gc_control(room_jid, account)
-
- if not control and \
- room_jid in self.minimized_controls[account]:
- control = self.minimized_controls[account][room_jid]
-
- if not control or (control and \
- control.type_id != message_control.TYPE_GC):
- return
-
- control.chg_contact_status(nick, show, status, array[4], array[5],
- array[6], array[7], array[8], array[9], array[10], array[11])
-
- contact = gajim.contacts.get_contact_with_highest_priority(account,
- room_jid)
- if contact:
- self.roster.draw_contact(room_jid, account)
-
- # print status in chat window and update status/GPG image
- ctrl = self.msg_win_mgr.get_control(fjid, account)
- if ctrl:
- statusCode = array[9]
- if '303' in statusCode:
- new_nick = array[10]
- ctrl.print_conversation(_('%(nick)s is now known as '
- '%(new_nick)s') % {'nick': nick, 'new_nick': new_nick},
- 'status')
- gc_c = gajim.contacts.get_gc_contact(account, room_jid,
- new_nick)
- c = gc_c.as_contact()
- ctrl.gc_contact = gc_c
- ctrl.contact = c
- if ctrl.session:
- # stop e2e
- if ctrl.session.enable_encryption:
- thread_id = ctrl.session.thread_id
- ctrl.session.terminate_e2e()
- conn.delete_session(fjid, thread_id)
- ctrl.no_autonegotiation = False
- ctrl.draw_banner()
- old_jid = room_jid + '/' + nick
- new_jid = room_jid + '/' + new_nick
- self.msg_win_mgr.change_key(old_jid, new_jid, account)
- else:
- contact = ctrl.contact
- contact.show = show
- contact.status = status
- gc_contact = ctrl.gc_contact
- gc_contact.show = show
- gc_contact.status = status
- uf_show = helpers.get_uf_show(show)
- ctrl.print_conversation(_('%(nick)s is now %(status)s') % {
- 'nick': nick, 'status': uf_show}, 'status')
- if status:
- ctrl.print_conversation(' (', 'status', simple=True)
- ctrl.print_conversation('%s' % (status), 'status',
- simple=True)
- ctrl.print_conversation(')', 'status', simple=True)
- ctrl.parent_win.redraw_tab(ctrl)
- ctrl.update_ui()
- if self.remote_ctrl:
- self.remote_ctrl.raise_signal('GCPresence', (account, array))
-
def handle_event_gc_subject(self, account, array):
#('GC_SUBJECT', account, (jid, subject, body, has_timestamp))
jids = array[0].split('/', 1)
@@ -1707,7 +1629,6 @@
'AGENT_INFO_ITEMS': [self.handle_event_agent_info_items],
'MYVCARD': [self.handle_event_myvcard],
'VCARD': [self.handle_event_vcard],
- 'GC_NOTIFY': [self.handle_event_gc_notify],
'GC_SUBJECT': [self.handle_event_gc_subject],
'GC_CONFIG_CHANGE': [self.handle_event_gc_config_change],
'FILE_REQUEST': [self.handle_event_file_request],
diff -r 44730c1b5813 -r 9f506f74a70b src/roster_window.py
--- a/src/roster_window.py Tue Nov 23 22:40:10 2010 +0300
+++ b/src/roster_window.py Tue Nov 23 23:10:43 2010 +0100
@@ -2451,6 +2451,18 @@
self.chg_contact_status(obj.contact, obj.show, obj.status, account)
+ def _nec_gc_presence_received(self, obj):
+ account = obj.conn.name
+ if obj.room_jid in gajim.interface.minimized_controls[account]:
+ gc_ctrl = gajim.interface.minimized_controls[account][obj.room_jid]
+ else:
+ return
+
+ contact = gajim.contacts.get_contact_with_highest_priority(account,
+ obj.room_jid)
+ if contact:
+ self.draw_contact(obj.room_jid, account)
+
def _nec_roster_received(self, obj):
self.fill_contacts_and_groups_dicts(obj.roster, obj.conn.name)
self.add_account_contacts(obj.conn.name)
@@ -6219,6 +6231,8 @@
gajim.ged.register_event_handler('presence-received', ged.GUI1,
self._nec_presence_received)
+ gajim.ged.register_event_handler('gc-presence-received', ged.GUI1,
+ self._nec_gc_presence_received)
gajim.ged.register_event_handler('roster-received', ged.GUI1,
self._nec_roster_received)
gajim.ged.register_event_handler('anonymous-auth', ged.GUI1,
_______________________________________________
Commits mailing list
[email protected]
http://lists.gajim.org/cgi-bin/listinfo/commits