diff --git a/data/pixmaps/events/connection_lost.png b/data/pixmaps/events/connection_lost.png new file mode 100644 index 000000000..671efdb72 Binary files /dev/null and b/data/pixmaps/events/connection_lost.png differ diff --git a/src/common/connection.py b/src/common/connection.py index 9a0cfebdd..f270cceef 100644 --- a/src/common/connection.py +++ b/src/common/connection.py @@ -137,22 +137,21 @@ class Connection(ConnectionHandlers): if not self.on_purpose: self.disconnect() if gajim.config.get_per('accounts', self.name, 'autoreconnect') \ - and self.retrycount <= 10: + and self.retrycount <= 10: self.connected = 1 self.dispatch('STATUS', 'connecting') - self.time_to_reconnect = 10 # this check has moved from _reconnect method if self.retrycount > 5: self.time_to_reconnect = 20 else: self.time_to_reconnect = 10 - gajim.idlequeue.set_alarm(self._reconnect_alarm, - self.time_to_reconnect) + gajim.idlequeue.set_alarm(self._reconnect_alarm, + self.time_to_reconnect) elif self.on_connect_failure: self.on_connect_failure() self.on_connect_failure = None else: - # show error dialog + # show error dialog self._connection_lost() else: self.disconnect() @@ -162,9 +161,9 @@ class Connection(ConnectionHandlers): def _connection_lost(self): self.disconnect(on_purpose = False) self.dispatch('STATUS', 'offline') - self.dispatch('ERROR', - (_('Connection with account "%s" has been lost') % self.name, - _('To continue sending and receiving messages, you will need to reconnect.'))) + self.dispatch('CONNECTION_LOST', + (_('Connection with account "%s" has been lost') % self.name, + _('To continue sending and receiving messages, you will need to reconnect.'))) def _event_dispatcher(self, realm, event, data): if realm == common.xmpp.NS_REGISTER: @@ -388,7 +387,8 @@ class Connection(ConnectionHandlers): if not self.retrycount and self.connected != 0: self.disconnect(on_purpose = True) 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.'))) def _connect_success(self, con, con_type): @@ -424,7 +424,8 @@ class Connection(ConnectionHandlers): if not con: self.disconnect(on_purpose = True) 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'))) if self.on_connect_auth: self.on_connect_auth(None) diff --git a/src/gajim.py b/src/gajim.py index 4459293a4..8fa3d1c76 100755 --- a/src/gajim.py +++ b/src/gajim.py @@ -309,6 +309,14 @@ class Interface: gajim.con_types[account] = con_type 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): gajim.block_signed_in_notifications[account] = False @@ -1676,6 +1684,7 @@ class Interface: 'ROSTER_INFO': self.handle_event_roster_info, 'BOOKMARKS': self.handle_event_bookmarks, 'CON_TYPE': self.handle_event_con_type, + 'CONNECTION_LOST': self.handle_event_connection_lost, 'FILE_REQUEST': self.handle_event_file_request, 'GMAIL_NOTIFY': self.handle_event_gmail_notify, 'FILE_REQUEST_ERROR': self.handle_event_file_request_error, diff --git a/src/notify.py b/src/notify.py index a99479864..908ff25d9 100644 --- a/src/notify.py +++ b/src/notify.py @@ -382,6 +382,8 @@ class DesktopNotification: ntype = 'im.invitation' elif event_type == _('Contact Changed Status'): ntype = 'presence.status' + elif event_type == _('Connection Failed'): + ntype = 'connection.failed' else: # default failsafe values self.path_to_image = os.path.abspath(