when we're disconnected because of a resource conflict, ask the user another resource. Fixes #3044
This commit is contained in:
parent
aab2e0d14d
commit
31101e5049
|
@ -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
|
||||||
|
|
|
@ -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')
|
||||||
|
|
16
src/gajim.py
16
src/gajim.py
|
@ -546,7 +546,7 @@ class Interface:
|
||||||
if contact1.show in statuss:
|
if contact1.show in statuss:
|
||||||
old_show = statuss.index(contact1.show)
|
old_show = statuss.index(contact1.show)
|
||||||
if old_show == new_show and contact1.status == status_message and \
|
if old_show == new_show and contact1.status == status_message and \
|
||||||
contact1.priority == priority: # no change
|
contact1.priority == priority: # no change
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
contact1 = gajim.contacts.get_first_contact_from_jid(account, ji)
|
contact1 = gajim.contacts.get_first_contact_from_jid(account, ji)
|
||||||
|
@ -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
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue