use NEC to handle anonymous jid changment

This commit is contained in:
Yann Leboulanger 2010-10-26 21:25:41 +02:00
parent 538fec1571
commit 75b6872064
4 changed files with 15 additions and 10 deletions

View File

@ -1312,7 +1312,8 @@ class Connection(CommonConnection, ConnectionHandlers):
old_jid = gajim.get_jid_from_account(self.name)
gajim.config.set_per('accounts', self.name, 'name', con.User)
new_jid = gajim.get_jid_from_account(self.name)
self.dispatch('NEW_JID', (old_jid, new_jid))
gajim.nec.push_incoming_event(AnonymousAuthEvent(None,
conn=self, old_jid=old_jid, new_jid=new_jid))
if auth:
self.last_io = gajim.idlequeue.current_time()
self.connected = 2

View File

@ -1109,3 +1109,7 @@ class GcMessageReceivedEvent(nec.NetworkIncomingEvent):
return
return True
class AnonymousAuthEvent(nec.NetworkIncomingEvent):
name = 'anonymous-auth'
base_network_events = []

View File

@ -257,14 +257,6 @@ class Interface:
if self.remote_ctrl:
self.remote_ctrl.raise_signal('AccountPresence', (show, account))
def handle_event_new_jid(self, account, data):
#('NEW_JID', account, (old_jid, new_jid))
"""
This event is raised when our JID changed (most probably because we use
anonymous account. We update contact and roster entry in this case
"""
self.roster.rename_self_contact(data[0], data[1], account)
def edit_own_details(self, account):
jid = gajim.get_jid_from_account(account)
if 'profile' not in self.instances[account]:
@ -1851,7 +1843,6 @@ class Interface:
'DB_ERROR': [self.handle_event_db_error],
'INFORMATION': [self.handle_event_information],
'STATUS': [self.handle_event_status],
'NEW_JID': [self.handle_event_new_jid],
'MSGERROR': [self.handle_event_msgerror],
'MSGSENT': [self.handle_event_msgsent],
'MSGNOTSENT': [self.handle_event_msgnotsent],

View File

@ -2477,6 +2477,13 @@ class RosterWindow:
self.add_account_contacts(obj.conn.name)
self.fire_up_unread_messages_events(obj.conn.name)
def _nec_anonymous_auth(self, obj):
"""
This event is raised when our JID changed (most probably because we use
anonymous account. We update contact and roster entry in this case
"""
self.rename_self_contact(obj.old_jid, obj.new_jid, obj.conn.name)
################################################################################
### Menu and GUI callbacks
### FIXME: order callbacks in itself...
@ -6208,3 +6215,5 @@ class RosterWindow:
self._nec_presence_received)
gajim.ged.register_event_handler('roster-received', ged.GUI1,
self._nec_roster_received)
gajim.ged.register_event_handler('anonymous-auth', ged.GUI1,
self._nec_anonymous_auth)