when we're disconnected because of a resource conflict, ask the user another resource. Fixes #3044

This commit is contained in:
Yann Leboulanger 2007-05-09 20:59:29 +00:00
parent aab2e0d14d
commit 31101e5049
3 changed files with 22 additions and 2 deletions

View File

@ -780,7 +780,7 @@ class Connection(ConnectionHandlers):
'resource') 'resource')
self.connect_and_init(show, msg, signed) self.connect_and_init(show, msg, signed)
elif show == 'offline' and self.connected: elif show == 'offline':
self.connected = 0 self.connected = 0
if self.connection: if self.connection:
self.on_purpose = True self.on_purpose = True

View File

@ -1957,6 +1957,11 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
df[i.getName()] = i.getData() df[i.getName()] = i.getData()
self.dispatch('SEARCH_FORM', (jid, df, False)) self.dispatch('SEARCH_FORM', (jid, df, False))
def _StreamCB(self, con, obj):
if obj.getTag('conflict'):
# disconnected because of a resource conflict
self.dispatch('RESOURCE_CONFLICT', ())
def _register_handlers(self, con, con_type): def _register_handlers(self, con, con_type):
# try to find another way to register handlers in each class # try to find another way to register handlers in each class
# that defines handlers # that defines handlers
@ -2031,3 +2036,4 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
con.RegisterHandler('iq', self._ResultCB, 'result') con.RegisterHandler('iq', self._ResultCB, 'result')
con.RegisterHandler('presence', self._StanzaArrivedCB) con.RegisterHandler('presence', self._StanzaArrivedCB)
con.RegisterHandler('message', self._StanzaArrivedCB) con.RegisterHandler('message', self._StanzaArrivedCB)
con.RegisterHandler('unknown', self._StreamCB, 'urn:ietf:params:xml:ns:xmpp-streams', xmlns='http://etherx.jabber.org/streams')

View File

@ -1743,6 +1743,19 @@ class Interface:
self.instances[account]['search'][data[0]].on_result_arrived(data[1], self.instances[account]['search'][data[0]].on_result_arrived(data[1],
data[2]) data[2])
def handle_event_resource_conflict(self, account, data):
# ('RESOURCE_CONFLICT', account, ())
# First we go offline, but we don't overwrite status message
self.roster.send_status(account, 'offline',
gajim.connections[account].status)
def on_ok(new_resource):
gajim.config.set_per('accounts', account, 'resource', new_resource)
self.roster.send_status(account, gajim.connections[account].old_show,
gajim.connections[account].status)
dlg = dialogs.InputDialog(_('Resource Conflict'),
_('You are already connected to this account with the same resource. Please type a new one'), input_str = gajim.connections[account].server_resource,
is_modal = False, ok_handler = on_ok)
def read_sleepy(self): def read_sleepy(self):
'''Check idle status and change that status if needed''' '''Check idle status and change that status if needed'''
if not self.sleeper.poll(): if not self.sleeper.poll():
@ -2066,6 +2079,7 @@ class Interface:
'PING_ERROR': self.handle_event_ping_error, 'PING_ERROR': self.handle_event_ping_error,
'SEARCH_FORM': self.handle_event_search_form, 'SEARCH_FORM': self.handle_event_search_form,
'SEARCH_RESULT': self.handle_event_search_result, 'SEARCH_RESULT': self.handle_event_search_result,
'RESOURCE_CONFLICT': self.handle_event_resource_conflict,
} }
gajim.handlers = self.handlers gajim.handlers = self.handlers