def __gsm_connect_cb(self, palette, data=None): connection = network.find_gsm_connection() if connection is not None: connection.activate(self._device.object_path, reply_handler=self.__connect_cb, error_handler=self.__connect_error_cb) else: self._palette.add_alert(_('No GSM connection available.'), _('Create a connection in My Settings.'))
def _update_state(self, state, old_state, reason): gsm_state = None if state is network.NM_DEVICE_STATE_ACTIVATED: gsm_state = _GSM_STATE_CONNECTED connection = network.find_gsm_connection() if connection is not None: self._connection_timestamp = time.time() - \ connection.get_settings('connection')['timestamp'] self._connection_time_handler = GObject.timeout_add_seconds( 1, self.__connection_timecount_cb) self._palette.update_connection_time() self._palette.update_stats(0, 0) if self._palette is not None: self._palette.connection_info_box.show() elif state is network.NM_DEVICE_STATE_DISCONNECTED: gsm_state = _GSM_STATE_DISCONNECTED self._connection_timestamp = 0 if self._connection_time_handler is not None: GObject.source_remove(self._connection_time_handler) if self._palette is not None: self._palette.connection_info_box.hide() elif state in [ network.NM_DEVICE_STATE_UNMANAGED, network.NM_DEVICE_STATE_UNAVAILABLE, network.NM_DEVICE_STATE_UNKNOWN ]: gsm_state = _GSM_STATE_NOT_READY elif (state >= network.NM_DEVICE_STATE_PREPARE) and \ (state < network.NM_DEVICE_STATE_ACTIVATED): gsm_state = _GSM_STATE_CONNECTING elif state == network.NM_DEVICE_STATE_FAILED: gsm_state = _GSM_STATE_FAILED if self._palette is not None: self._palette.update_state(gsm_state, reason)
def _update_state(self, state, old_state, reason): gsm_state = None if state is network.NM_DEVICE_STATE_ACTIVATED: gsm_state = _GSM_STATE_CONNECTED connection = network.find_gsm_connection() if connection is not None: self._connection_timestamp = time.time() - \ connection.get_settings('connection')['timestamp'] self._connection_time_handler = GObject.timeout_add_seconds( 1, self.__connection_timecount_cb) self._palette.update_connection_time() self._palette.update_stats(0, 0) if self._palette is not None: self._palette.connection_info_box.show() elif state is network.NM_DEVICE_STATE_DISCONNECTED: gsm_state = _GSM_STATE_DISCONNECTED self._connection_timestamp = 0 if self._connection_time_handler is not None: GObject.source_remove(self._connection_time_handler) if self._palette is not None: self._palette.connection_info_box.hide() elif state in [network.NM_DEVICE_STATE_UNMANAGED, network.NM_DEVICE_STATE_UNAVAILABLE, network.NM_DEVICE_STATE_UNKNOWN]: gsm_state = _GSM_STATE_NOT_READY elif (state >= network.NM_DEVICE_STATE_PREPARE) and \ (state < network.NM_DEVICE_STATE_ACTIVATED): gsm_state = _GSM_STATE_CONNECTING elif state == network.NM_DEVICE_STATE_FAILED: gsm_state = _GSM_STATE_FAILED if self._palette is not None: self._palette.update_state(gsm_state, reason)
def get_connection(): return network.find_gsm_connection()