always register the jid when connecting

This commit is contained in:
Dan Williams 2007-02-26 15:38:50 -05:00
parent ca8f3a0484
commit abf84970b5

View File

@ -54,7 +54,6 @@ class ServerPlugin(gobject.GObject):
self._online_contacts = set() # handles of online contacts self._online_contacts = set() # handles of online contacts
self._account = self._get_account_info() self._account = self._get_account_info()
self._ever_connected = False
self._conn = self._init_connection() self._conn = self._init_connection()
def _get_account_info(self): def _get_account_info(self):
@ -85,12 +84,11 @@ class ServerPlugin(gobject.GObject):
return item return item
return None return None
def _init_connection(self, register=False): def _init_connection(self):
conn = self._find_existing_connection() conn = self._find_existing_connection()
if not conn: if not conn:
acct = self._account.copy() acct = self._account.copy()
if register: acct['register'] = True
acct['register'] = True
# Create a new connection # Create a new connection
print acct print acct
@ -119,8 +117,6 @@ class ServerPlugin(gobject.GObject):
return channel return channel
def _connected_cb(self): def _connected_cb(self):
self._ever_connected = True
# the group of contacts who may receive your presence # the group of contacts who may receive your presence
publish = self._request_list_channel('publish') publish = self._request_list_channel('publish')
publish_handles, local_pending, remote_pending = publish[CHANNEL_INTERFACE_GROUP].GetAllMembers() publish_handles, local_pending, remote_pending = publish[CHANNEL_INTERFACE_GROUP].GetAllMembers()
@ -190,13 +186,9 @@ class ServerPlugin(gobject.GObject):
elif state == CONNECTION_STATUS_DISCONNECTED: elif state == CONNECTION_STATUS_DISCONNECTED:
print 'disconnected: %r' % reason print 'disconnected: %r' % reason
self.emit('status', state, int(reason)) self.emit('status', state, int(reason))
if reason == CONNECTION_STATUS_REASON_AUTHENTICATION_FAILED and \ if reason == CONNECTION_STATUS_REASON_AUTHENTICATION_FAILED:
not self._ever_connected: # FIXME: handle connection failure; retry later?
# Hmm; probably aren't registered on the server, try reconnecting pass
# and registering
del self._conn
self._conn = self._init_connection(register=True)
self.start()
return False return False
def start(self): def start(self):