show connection lost error in popups instead of error dialogs. Fixes #2138
This commit is contained in:
parent
5c73441078
commit
746a0bf98e
4 changed files with 22 additions and 10 deletions
BIN
data/pixmaps/events/connection_lost.png
Normal file
BIN
data/pixmaps/events/connection_lost.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.1 KiB |
|
@ -137,22 +137,21 @@ class Connection(ConnectionHandlers):
|
||||||
if not self.on_purpose:
|
if not self.on_purpose:
|
||||||
self.disconnect()
|
self.disconnect()
|
||||||
if gajim.config.get_per('accounts', self.name, 'autoreconnect') \
|
if gajim.config.get_per('accounts', self.name, 'autoreconnect') \
|
||||||
and self.retrycount <= 10:
|
and self.retrycount <= 10:
|
||||||
self.connected = 1
|
self.connected = 1
|
||||||
self.dispatch('STATUS', 'connecting')
|
self.dispatch('STATUS', 'connecting')
|
||||||
self.time_to_reconnect = 10
|
|
||||||
# this check has moved from _reconnect method
|
# this check has moved from _reconnect method
|
||||||
if self.retrycount > 5:
|
if self.retrycount > 5:
|
||||||
self.time_to_reconnect = 20
|
self.time_to_reconnect = 20
|
||||||
else:
|
else:
|
||||||
self.time_to_reconnect = 10
|
self.time_to_reconnect = 10
|
||||||
gajim.idlequeue.set_alarm(self._reconnect_alarm,
|
gajim.idlequeue.set_alarm(self._reconnect_alarm,
|
||||||
self.time_to_reconnect)
|
self.time_to_reconnect)
|
||||||
elif self.on_connect_failure:
|
elif self.on_connect_failure:
|
||||||
self.on_connect_failure()
|
self.on_connect_failure()
|
||||||
self.on_connect_failure = None
|
self.on_connect_failure = None
|
||||||
else:
|
else:
|
||||||
# show error dialog
|
# show error dialog
|
||||||
self._connection_lost()
|
self._connection_lost()
|
||||||
else:
|
else:
|
||||||
self.disconnect()
|
self.disconnect()
|
||||||
|
@ -162,9 +161,9 @@ class Connection(ConnectionHandlers):
|
||||||
def _connection_lost(self):
|
def _connection_lost(self):
|
||||||
self.disconnect(on_purpose = False)
|
self.disconnect(on_purpose = False)
|
||||||
self.dispatch('STATUS', 'offline')
|
self.dispatch('STATUS', 'offline')
|
||||||
self.dispatch('ERROR',
|
self.dispatch('CONNECTION_LOST',
|
||||||
(_('Connection with account "%s" has been lost') % self.name,
|
(_('Connection with account "%s" has been lost') % self.name,
|
||||||
_('To continue sending and receiving messages, you will need to reconnect.')))
|
_('To continue sending and receiving messages, you will need to reconnect.')))
|
||||||
|
|
||||||
def _event_dispatcher(self, realm, event, data):
|
def _event_dispatcher(self, realm, event, data):
|
||||||
if realm == common.xmpp.NS_REGISTER:
|
if realm == common.xmpp.NS_REGISTER:
|
||||||
|
@ -388,7 +387,8 @@ class Connection(ConnectionHandlers):
|
||||||
if not self.retrycount and self.connected != 0:
|
if not self.retrycount and self.connected != 0:
|
||||||
self.disconnect(on_purpose = True)
|
self.disconnect(on_purpose = True)
|
||||||
self.dispatch('STATUS', 'offline')
|
self.dispatch('STATUS', 'offline')
|
||||||
self.dispatch('ERROR', (_('Could not connect to "%s"') % self._hostname,
|
self.dispatch('CONNECTION_LOST',
|
||||||
|
(_('Could not connect to "%s"') % self._hostname,
|
||||||
_('Check your connection or try again later.')))
|
_('Check your connection or try again later.')))
|
||||||
|
|
||||||
def _connect_success(self, con, con_type):
|
def _connect_success(self, con, con_type):
|
||||||
|
@ -424,7 +424,8 @@ class Connection(ConnectionHandlers):
|
||||||
if not con:
|
if not con:
|
||||||
self.disconnect(on_purpose = True)
|
self.disconnect(on_purpose = True)
|
||||||
self.dispatch('STATUS', 'offline')
|
self.dispatch('STATUS', 'offline')
|
||||||
self.dispatch('ERROR', (_('Could not connect to "%s"') % self._hostname,
|
self.dispatch('CONNECTION_LOST',
|
||||||
|
(_('Could not connect to "%s"') % self._hostname,
|
||||||
_('Check your connection or try again later')))
|
_('Check your connection or try again later')))
|
||||||
if self.on_connect_auth:
|
if self.on_connect_auth:
|
||||||
self.on_connect_auth(None)
|
self.on_connect_auth(None)
|
||||||
|
|
|
@ -309,6 +309,14 @@ class Interface:
|
||||||
gajim.con_types[account] = con_type
|
gajim.con_types[account] = con_type
|
||||||
self.roster.draw_account(account)
|
self.roster.draw_account(account)
|
||||||
|
|
||||||
|
def handle_event_connection_lost(self, account, array):
|
||||||
|
# ('CONNECTION_LOST', account, [title, text])
|
||||||
|
path = os.path.join(gajim.DATA_DIR, 'pixmaps', 'events',
|
||||||
|
'connection_lost.png')
|
||||||
|
path = gtkgui_helpers.get_path_to_generic_or_avatar(path)
|
||||||
|
notify.popup(_('Connection Failed'), account, account,
|
||||||
|
'connection_failed', path, array[0], array[1])
|
||||||
|
|
||||||
def unblock_signed_in_notifications(self, account):
|
def unblock_signed_in_notifications(self, account):
|
||||||
gajim.block_signed_in_notifications[account] = False
|
gajim.block_signed_in_notifications[account] = False
|
||||||
|
|
||||||
|
@ -1676,6 +1684,7 @@ class Interface:
|
||||||
'ROSTER_INFO': self.handle_event_roster_info,
|
'ROSTER_INFO': self.handle_event_roster_info,
|
||||||
'BOOKMARKS': self.handle_event_bookmarks,
|
'BOOKMARKS': self.handle_event_bookmarks,
|
||||||
'CON_TYPE': self.handle_event_con_type,
|
'CON_TYPE': self.handle_event_con_type,
|
||||||
|
'CONNECTION_LOST': self.handle_event_connection_lost,
|
||||||
'FILE_REQUEST': self.handle_event_file_request,
|
'FILE_REQUEST': self.handle_event_file_request,
|
||||||
'GMAIL_NOTIFY': self.handle_event_gmail_notify,
|
'GMAIL_NOTIFY': self.handle_event_gmail_notify,
|
||||||
'FILE_REQUEST_ERROR': self.handle_event_file_request_error,
|
'FILE_REQUEST_ERROR': self.handle_event_file_request_error,
|
||||||
|
|
|
@ -382,6 +382,8 @@ class DesktopNotification:
|
||||||
ntype = 'im.invitation'
|
ntype = 'im.invitation'
|
||||||
elif event_type == _('Contact Changed Status'):
|
elif event_type == _('Contact Changed Status'):
|
||||||
ntype = 'presence.status'
|
ntype = 'presence.status'
|
||||||
|
elif event_type == _('Connection Failed'):
|
||||||
|
ntype = 'connection.failed'
|
||||||
else:
|
else:
|
||||||
# default failsafe values
|
# default failsafe values
|
||||||
self.path_to_image = os.path.abspath(
|
self.path_to_image = os.path.abspath(
|
||||||
|
|
Loading…
Add table
Reference in a new issue