def __is_imsi_allowed(self, device, status=None): # By default every IMSI is allowed to use TGCM is_allowed = True # sim-locks is a whitelist of IMSI numbers allowed to connect to # a WWAN network using TGCM sim_whitelist = self._config.get_sim_locks() if status is None: status = device.get_card_status() if status == CARD_STATUS_READY: try: imsi = device.get_imsi() # Some countries have a whitelist of allowed IMSI numbers # to connect to a WWAN network using TGCM. If a IMSI is not listed # TGCM won't allow the user to connect to the network if (len(sim_whitelist) > 0) and (imsi is not None) and (len(imsi) > 0): is_allowed = False for sim in sim_whitelist: if imsi.startswith(sim): is_allowed = True break except DeviceHasNotCapability: pass if not is_allowed: msg = _("The Mobile Internet Device does not have a valid SIM card.\nPlease check to see that the device contains a SIM of your network operator.") markup = _('<b>Invalid SIM</b>') error_dialog(msg, markup) device.turn_off() return is_allowed
def _unlock_device(self, unlock_code): try: self.device.unlock_operator(unlock_code) title = _('Unlocking succeeded') markup = '<b>%s</b>' % title message = _('You succeed in unlocking your device network lock.') info_dialog(message, title=title, markup=markup, parent=self) return True # Incorrect password case except DeviceIncorrectPassword: title = _('Error unlocking network PIN') markup = '<b>%s</b>' % title message = _( 'The network PIN code entered is incorrect. Please try again.') error_dialog(message, title=title, markup=markup, parent=self) # Unknown case, e.g. device locked except: title = _('Error unlocking network PIN') markup = '<b>%s</b>' % title message = _( 'It is not possible to unlock the device. Please contact your operator.' ) error_dialog(message, title=title, markup=markup, parent=self) return False
def __on_settings_closing(self, settings): try: number = self.cell_number_entry.get_text() if len(number) != 0: number = Validate.Spain.mobile_phone(number) except ValidationError, err: error_dialog(str(err), markup = _('Services - User details'), parent = self._parent) return True
def connect_to_bus(self): success = self._connection_manager.connect_to_bus(self) if not success: tgcm.error("No se ha encontrado el ppp manager") error_dialog(markup=MSG_CONN_MANAGER_NO_PPP_MANAGER_TITLE, \ msg=MSG_CONN_MANAGER_NO_PPP_MANAGER) return False else: return True
def connect_to_bus (self): success = self._connection_manager.connect_to_bus(self) if not success: tgcm.error("No se ha encontrado el ppp manager") error_dialog(markup=MSG_CONN_MANAGER_NO_PPP_MANAGER_TITLE, \ msg=MSG_CONN_MANAGER_NO_PPP_MANAGER) return False else: return True
def __show_request_error(self, msg=None): ''' DeviceModem.sms_send() Error handler: BAM SMS could not be delivered, the user must be informed about that. ''' if msg is None: markup = _('Unexpected error') msg = _('We\'re sorry, but it was not possible to query your Broadband Mobile Number. Please try again later.') error_dialog(msg, markup = markup, parent = self.__parent)
def __on_settings_closing(self, settings): try: number = self.cell_number_entry.get_text() if len(number) != 0: number = Validate.Spain.mobile_phone(number) except ValidationError, err: error_dialog(str(err), markup=_('Services - User details'), parent=self._parent) return True
def close_app(self): _close = True main_modem = tgcm.core.MainModem.MainModem() if main_modem.is_connected(): app_name = self._conf.get_app_name() response = warning_dialog( \ msg=MSG_CONN_MANAGER_APP_CLOSE % (app_name, app_name), \ title=MSG_CONN_MANAGER_APP_CLOSE_TITLE, \ buttons=gtk.BUTTONS_OK_CANCEL) # -- If the user responds with OK we will close the application # -- even some failures are detected. This is the behavior under # -- windows too. if response == gtk.RESPONSE_OK: # -- Avoid the automatic reconnection as we are going to exit self.reconnect_on_disconnect = False # -- Get the reference to the NM object for disconnecting correctly nm_dev = main_modem.current_device().nm_dev nm_dev.Disconnect() # -- Wait until the modem is off but use a timeout for the worst case! time_start = time.time() timeout = 10 # -- Arbitrary timeout value time_end = (time_start + timeout) while (time_end > time.time()) and (main_modem.is_connected()): while gtk.events_pending(): gtk.main_iteration() # -- If the modem is still connected we have a problem. In that # -- case show an error message but go ahead closing # -- the Tgcm so that the user disconnects the modem manually if main_modem.is_connected(): if tgcm.country_support == 'de': msgInfo = _( "Please try removing the Mobile Internet Device for assuring\nthat the WWAN connection is down." ) else: msgInfo = _( "Please try removing the Mobile Internet Device for assuring\nthat the 2G/3G/4G connection is down." ) error_dialog(markup=_("Unexpected disconnection failure"), \ msg=msgInfo) else: main_modem.turn_off() _close = True else: _close = False else: main_modem.turn_off() _close = True return _close
def __send_email_button_wait_proc(self, proc, widget): proc.wait() if proc.returncode != 0: msg = _('A client application for sending email can not be found.') mark = _('Error starting email client') error_dialog(msg, markup = mark, parent = self.dialog) else: # -- Give the application some time before enabling the button gtk_sleep(1.0) widget.set_sensitive(True)
def __check_destiny_country(self, filepath, parent=None): try: if self.importer.get_destiny_country(filepath) != tgcm.country_support: destiny_country = self.importer.get_destiny_country(filepath) markup = _("The selected file cannot be imported in your country.") msg = _("The selected file must be installed in \"%s\".") % destiny_country error_dialog(markup=markup, msg=msg, parent=parent) return False else: return True except: error_dialog(_("Malformed file, the profile cannot be imported."), parent=parent) return False
def close_app(self): _close = True main_modem = tgcm.core.MainModem.MainModem() if main_modem.is_connected(): app_name = self._conf.get_app_name() response = warning_dialog( \ msg=MSG_CONN_MANAGER_APP_CLOSE % (app_name, app_name), \ title=MSG_CONN_MANAGER_APP_CLOSE_TITLE, \ buttons=gtk.BUTTONS_OK_CANCEL) # -- If the user responds with OK we will close the application # -- even some failures are detected. This is the behavior under # -- windows too. if response == gtk.RESPONSE_OK: # -- Avoid the automatic reconnection as we are going to exit self.reconnect_on_disconnect = False # -- Get the reference to the NM object for disconnecting correctly nm_dev = main_modem.current_device().nm_dev nm_dev.Disconnect() # -- Wait until the modem is off but use a timeout for the worst case! time_start = time.time() timeout = 10 # -- Arbitrary timeout value time_end = (time_start + timeout) while (time_end > time.time()) and (main_modem.is_connected()): while gtk.events_pending(): gtk.main_iteration() # -- If the modem is still connected we have a problem. In that # -- case show an error message but go ahead closing # -- the Tgcm so that the user disconnects the modem manually if main_modem.is_connected(): if tgcm.country_support == 'de': msgInfo=_("Please try removing the Mobile Internet Device for assuring\nthat the WWAN connection is down.") else: msgInfo=_("Please try removing the Mobile Internet Device for assuring\nthat the 2G/3G/4G connection is down.") error_dialog(markup=_("Unexpected disconnection failure"), \ msg=msgInfo) else: main_modem.turn_off() _close = True else: _close = False else: main_modem.turn_off() _close = True return _close
def __on_dialog_close(self, *args): # Request the phone query area to validate its contents and save them try: self.__phonequery_area.do_save() # Only hide the dialog if the dialog fields are correct and have # been saved successfully self.__dialog.hide() # Seems there was a problem saving the BAM phone query area, warn the # user about the problem except RecargaSaldoSaveError, err: self.__phonequery_area.grab_focus() error_dialog(err.details, markup = err.msg, parent = self.__dialog)
def __on_settings_is_closing(self, settings): is_ok = False # Request the phone query area to validate its contents and save them try: self.__phonequery_area.do_save() is_ok = True # Everything went all right # Seems there was a problem saving the BAM phone query area, change # the displayed tab in settings to 'My Details' and warn the user # about the problem except tgcm.ui.windows.RecargaSaldoSaveError, err: self.__settings.show_section('General>1') self.__phonequery_area.grab_focus() error_dialog(err.details, markup = err.msg, parent = self.__settings.get_dialog())
def __check_destiny_country(self, filepath, parent=None): try: if self.importer.get_destiny_country( filepath) != tgcm.country_support: destiny_country = self.importer.get_destiny_country(filepath) markup = _( "The selected file cannot be imported in your country.") msg = _("The selected file must be installed in \"%s\"." ) % destiny_country error_dialog(markup=markup, msg=msg, parent=parent) return False else: return True except: error_dialog(_("Malformed file, the profile cannot be imported."), parent=parent) return False
def __on_settings_is_closing(self, settings): is_ok = False # Request the phone query area to validate its contents and save them try: self.__phonequery_area.do_save() is_ok = True # Everything went all right # Seems there was a problem saving the BAM phone query area, change # the displayed tab in settings to 'My Details' and warn the user # about the problem except tgcm.ui.windows.RecargaSaldoSaveError, err: self.__settings.show_section('General>1') self.__phonequery_area.grab_focus() error_dialog(err.details, markup=err.msg, parent=self.__settings.get_dialog())
def __import_bookmark(self, bookmark, filepath, parent=None): if bookmark["url"] == None: markup = _("This favourite cannot be imported") msg = _( "Error when importing the favourite. Probably the associated file does not exist in your system." ) error_dialog(markup=markup, msg=msg) if not self.conf.exists_bookmark(bookmark["name"]): self.import_conditions = "BOOKMARK_NOT_EXISTS" self.import_filename_label.set_markup("%s" % os.path.basename(filepath)) self.import_bookmark_label.set_markup( _("<b>Favourite: '%s'</b>") % bookmark["name"]) self.__show_parts_of_import_dialog(book_label=True) self.import_dialog.show() self.__check_import_conditions() self.import_dialog.set_transient_for(parent) ret = self.import_dialog.run() self.import_dialog.hide() if ret != gtk.RESPONSE_OK: return False self.importer.import_bookmark_from_file(filepath) else: self.import_conditions = "OW_BOOKMARK" self.import_filename_label.set_markup("%s" % os.path.basename(filepath)) self.import_bookmark_label.set_markup( _("<b>Favourite: '%s'</b>") % bookmark["name"]) self.__show_parts_of_import_dialog(book_label=True, book_ow=True) self.import_dialog.show() self.__check_import_conditions() self.import_dialog.set_transient_for(parent) ret = self.import_dialog.run() self.import_dialog.hide() if ret != gtk.RESPONSE_OK: return self.importer.import_bookmark_from_file(filepath, overwrite=True)
def __is_imsi_allowed(self, device, status=None): # By default every IMSI is allowed to use TGCM is_allowed = True # sim-locks is a whitelist of IMSI numbers allowed to connect to # a WWAN network using TGCM sim_whitelist = self._config.get_sim_locks() if status is None: status = device.get_card_status() if status == CARD_STATUS_READY: try: imsi = device.get_imsi() # Some countries have a whitelist of allowed IMSI numbers # to connect to a WWAN network using TGCM. If a IMSI is not listed # TGCM won't allow the user to connect to the network if (len(sim_whitelist) > 0) and (imsi is not None) and (len(imsi) > 0): is_allowed = False for sim in sim_whitelist: if imsi.startswith(sim): is_allowed = True break except DeviceHasNotCapability: pass if not is_allowed: msg = _( "The Mobile Internet Device does not have a valid SIM card.\nPlease check to see that the device contains a SIM of your network operator." ) markup = _('<b>Invalid SIM</b>') error_dialog(msg, markup) device.turn_off() return is_allowed
def __import_bookmark(self, bookmark, filepath, parent=None): if bookmark["url"] == None: markup = _("This favourite cannot be imported") msg = _("Error when importing the favourite. Probably the associated file does not exist in your system.") error_dialog(markup=markup, msg=msg) if not self.conf.exists_bookmark(bookmark["name"]) : self.import_conditions = "BOOKMARK_NOT_EXISTS" self.import_filename_label.set_markup("%s" % os.path.basename (filepath)) self.import_bookmark_label.set_markup(_("<b>Favourite: '%s'</b>") % bookmark["name"]) self.__show_parts_of_import_dialog(book_label=True) self.import_dialog.show() self.__check_import_conditions() self.import_dialog.set_transient_for(parent) ret = self.import_dialog.run() self.import_dialog.hide() if ret != gtk.RESPONSE_OK: return False self.importer.import_bookmark_from_file (filepath) else: self.import_conditions = "OW_BOOKMARK" self.import_filename_label.set_markup("%s" % os.path.basename (filepath)) self.import_bookmark_label.set_markup(_("<b>Favourite: '%s'</b>") % bookmark["name"]) self.__show_parts_of_import_dialog(book_label=True, book_ow=True) self.import_dialog.show() self.__check_import_conditions() self.import_dialog.set_transient_for(parent) ret = self.import_dialog.run() self.import_dialog.hide() if ret != gtk.RESPONSE_OK: return self.importer.import_bookmark_from_file (filepath, overwrite=True)
def _unlock_device(self, unlock_code): try: self.device.unlock_operator(unlock_code) title = _("Unlocking succeeded") markup = "<b>%s</b>" % title message = _("You succeed in unlocking your device network lock.") info_dialog(message, title=title, markup=markup, parent=self) return True # Incorrect password case except DeviceIncorrectPassword: title = _("Error unlocking network PIN") markup = "<b>%s</b>" % title message = _("The network PIN code entered is incorrect. Please try again.") error_dialog(message, title=title, markup=markup, parent=self) # Unknown case, e.g. device locked except: title = _("Error unlocking network PIN") markup = "<b>%s</b>" % title message = _("It is not possible to unlock the device. Please contact your operator.") error_dialog(message, title=title, markup=markup, parent=self) return False
def __error_dialog(self, title, msg, parent, focus_widget=None): error_dialog(msg, parent=parent, title=title) if focus_widget is not None: focus_widget.set_can_focus(True) focus_widget.grab_focus()
def __active_device_card_status_changed(self, mcontroller, status): device = self._device_manager.get_main_device() if status == CARD_STATUS_DETECTED: pass elif status == CARD_STATUS_CONFIGURED: pass elif (status == CARD_STATUS_NO_SIM) or (status == CARD_STATUS_ERROR): self._connection_logger.register_invalid_imsi() self._is_on_startup = False self.startup_time = 0 if self.is_showing_no_sim_dialog == True: return self.is_showing_no_sim_dialog = True # -- Turn the device off before opening the error dialog otherwise the device checker remains triggering # -- AT commands to the Mobile Manager if device is not None: device.turn_off() msg = _( "The Internet Mobile Device does not have a valid SIM card. Please, check that the SIM card is correctly inserted in the Internet Mobile Device." ) markup = _("<b>SIM not found</b>") error_dialog(msg, markup) self.is_showing_no_sim_dialog = False elif status == CARD_STATUS_PIN_REQUIRED: if (time.time() - self.startup_time) < STARTUP_SECS: self._is_on_startup = True rstatus = device.pin_status() device.stop_checker() self._device_manager.emit("active-dev-pin-act-status-changed", True) if rstatus != PIN_STATUS_WAITING_PIN: tgcm.info("PIN REQUIRED ... not") return pin_dialog = tgcm.ui.windows.AskPinDialog() pin_dialog.run() elif status == CARD_STATUS_PUK_REQUIRED: if (time.time() - self.startup_time) < STARTUP_SECS: self._is_on_startup = True tgcm.info("PUK REQUIRED") if device.is_on() == False: return rstatus = device.pin_status() device.stop_checker() if rstatus != PIN_STATUS_WAITING_PUK: tgcm.info("PUK REQUIRED ... not") return self._device_manager.emit("active-dev-pin-act-status-changed", True) ask_puk = tgcm.ui.windows.PukDialog() ask_puk.request() elif status == CARD_STATUS_OFF: self._is_on_startup = False self.startup_time = 0 elif status == CARD_STATUS_ATTACHING: # Check if device is not network locked for this card if device.is_operator_locked(): # Prompt the user to remove the network lock self.__ask_network_pin_code(device) elif status == CARD_STATUS_READY: # Register the device in the connection log self._connection_logger.register_new_device(device) try: self._device_manager.emit("active-dev-roaming-status-changed", device.is_roaming()) self._device_manager.emit("active-dev-pin-act-status-changed", device.is_pin_active()) # Check if the IMSI has been blacklisted is_imsi_allowed = self.__is_imsi_allowed(device) # NOTE: # Originally the following code was used to ensure that the device was registered # in the network with the values established by the operator in the file # 'regional-info.xml': # # if dev.has_domain_preferred: # gobject.timeout_add(3000, self.__set_current_mode_domain) # # Unfortunately we don't know the reason why the function '__set_current_mode_domain' # was being called with a delay of 3 seconds. Calling it directly seems to work # well. if is_imsi_allowed: # Attempt to establish the correct device mode and domain self.__set_current_mode_domain(device) # Unknown connection procedure if ((time.time() - self.startup_time) < STARTUP_SECS) \ or self._is_on_startup: self._is_on_startup = False self.startup_time = 0 self._connect_on_startup() except DeviceHasNotCapability: pass elif status == CARD_STATUS_PH_NET_PIN_REQUIRED: self.__ask_network_pin_code(device) elif status == CARD_STATUS_PH_NET_PUK_REQUIRED: pass
def __active_device_card_status_changed(self, mcontroller, status): device = self._device_manager.get_main_device() if status == CARD_STATUS_DETECTED: pass elif status == CARD_STATUS_CONFIGURED: pass elif (status == CARD_STATUS_NO_SIM) or (status == CARD_STATUS_ERROR): self._connection_logger.register_invalid_imsi() self._is_on_startup = False self.startup_time = 0 if self.is_showing_no_sim_dialog == True: return self.is_showing_no_sim_dialog = True # -- Turn the device off before opening the error dialog otherwise the device checker remains triggering # -- AT commands to the Mobile Manager if device is not None: device.turn_off() msg = _("The Internet Mobile Device does not have a valid SIM card. Please, check that the SIM card is correctly inserted in the Internet Mobile Device.") markup = _("<b>SIM not found</b>") error_dialog(msg, markup) self.is_showing_no_sim_dialog = False elif status == CARD_STATUS_PIN_REQUIRED: if (time.time() - self.startup_time) < STARTUP_SECS: self._is_on_startup = True rstatus = device.pin_status() device.stop_checker() self._device_manager.emit("active-dev-pin-act-status-changed",True) if rstatus != PIN_STATUS_WAITING_PIN: tgcm.info("PIN REQUIRED ... not") return pin_dialog = tgcm.ui.windows.AskPinDialog() pin_dialog.run() elif status == CARD_STATUS_PUK_REQUIRED: if (time.time() - self.startup_time) < STARTUP_SECS: self._is_on_startup = True tgcm.info("PUK REQUIRED") if device.is_on() == False: return rstatus = device.pin_status() device.stop_checker() if rstatus != PIN_STATUS_WAITING_PUK: tgcm.info("PUK REQUIRED ... not") return self._device_manager.emit("active-dev-pin-act-status-changed", True) ask_puk = tgcm.ui.windows.PukDialog() ask_puk.request() elif status == CARD_STATUS_OFF: self._is_on_startup = False self.startup_time = 0 elif status == CARD_STATUS_ATTACHING: # Check if device is not network locked for this card if device.is_operator_locked(): # Prompt the user to remove the network lock self.__ask_network_pin_code(device) elif status == CARD_STATUS_READY: # Register the device in the connection log self._connection_logger.register_new_device(device) try: self._device_manager.emit("active-dev-roaming-status-changed", device.is_roaming()) self._device_manager.emit("active-dev-pin-act-status-changed", device.is_pin_active()) # Check if the IMSI has been blacklisted is_imsi_allowed = self.__is_imsi_allowed(device) # NOTE: # Originally the following code was used to ensure that the device was registered # in the network with the values established by the operator in the file # 'regional-info.xml': # # if dev.has_domain_preferred: # gobject.timeout_add(3000, self.__set_current_mode_domain) # # Unfortunately we don't know the reason why the function '__set_current_mode_domain' # was being called with a delay of 3 seconds. Calling it directly seems to work # well. if is_imsi_allowed: # Attempt to establish the correct device mode and domain self.__set_current_mode_domain(device) # Unknown connection procedure if ((time.time() - self.startup_time) < STARTUP_SECS) \ or self._is_on_startup: self._is_on_startup = False self.startup_time = 0 self._connect_on_startup() except DeviceHasNotCapability: pass elif status == CARD_STATUS_PH_NET_PIN_REQUIRED: self.__ask_network_pin_code(device) elif status == CARD_STATUS_PH_NET_PUK_REQUIRED: pass
def _check_values(self): is_error = False title = None message = None # Name check name = self.connection_name_entry.get_text() if (not is_error) and (len(name) == 0): is_error = True title = MSG_NO_CONNECTION_NAME_TITLE message = MSG_NO_CONNECTION_NAME # Username check username = self.username_entry.get_text() if (not is_error) and (len(username) == 0): is_error = True title = MSG_NO_CONNECTION_USER_TITLE message = MSG_NO_CONNECTION_USER # APN check apn_name = self.apn_entry.get_text() if (not is_error) and (len(apn_name) == 0): is_error = True title = MSG_NO_CONNECTION_APN_TITLE message = MSG_NO_CONNECTION_APN # Only perform proxy checks if proxy support is enabled is_proxy_server = self.use_proxy_radiobutton.get_active() if is_proxy_server: # Proxy address check proxy_address = self.proxy_address_entry.get_text() if (not is_error) and (len(proxy_address) == 0): is_error = True title = MSG_NO_CONNECTION_PROXY_IP_TITLE message = MSG_NO_CONNECTION_PROXY_IP # Proxy port check proxy_port = self.proxy_port_entry.get_value() if (not is_error) and (proxy_port < 0): is_error = True title = MSG_NO_CONNECTION_PROXY_PORT_TITLE message = MSG_NO_CONNECTION_PROXY_PORT # Only perform DNS checks if custom DNS support is enabled is_custom_dns = self.dns_user_radiobutton.get_active() if (not is_error) and is_custom_dns: # Check primary DNS is not empty and correctly formatted primary_dns = self.primary_dns_entry.get_text() try: socket.inet_aton(primary_dns) except: is_error = True title = MSG_NO_CONNECTION_DNS_TITLE message = MSG_NO_CONNECTION_DNS # Check secondary DNS is correctly formatted secondary_dns = self.secondary_dns_entry.get_text() if len(secondary_dns) > 0: try: socket.inet_aton(secondary_dns) except: is_error = True title = MSG_NO_CONNECTION_DNS_TITLE message = MSG_NO_CONNECTION_DNS # Show an error message if an error has been detected if is_error: error_dialog(parent=self, markup=title, msg=message) return not is_error
def show_no_available_device_error(self): error_dialog(markup=MSG_CONN_MANAGER_NO_CARDMANAGER_TITLE, \ msg=MSG_CONN_MANAGER_NO_CARDMANAGER)
def error_on_connection(self): self.reconnect_on_disconnect = False error_dialog(markup=MSG_CONN_MANAGER_CONNECTION_ERROR_TITLE, \ msg=MSG_CONN_MANAGER_CONNECTION_ERROR)
def connect_to_connection(self, connection_settings = None, force_connection = False, \ action = None, bookmark_info = None, url = None, smart_connector = False): self.abort_now_flag = False self.smart_connector=smart_connector device_type=connection_settings["deviceType"] connection_name=connection_settings["name"] tgcm.info("Trying to connect to %s" % connection_name) if self.connect_to_bus() != True: return -1 network_connection_status = self._connection_manager.ppp_manager.nmConnectionState() if (device_type==tgcm.core.FreeDesktop.DEVICE_WLAN or device_type==tgcm.core.FreeDesktop.DEVICE_WLAN_PROFILE): odev = self.mcontroller.get_wifi_device() if odev == None: return -1 if self._connection_settings_manager.is_wifi_ap_available(connection_settings)==False: return -1 if (device_type==tgcm.core.FreeDesktop.DEVICE_WIRED): odev = self.mcontroller.get_wired_device() if odev == None: return -1 elif (device_type==tgcm.core.FreeDesktop.DEVICE_MODEM): if self._connection_manager.is_device_selected() == False: return -1 odev = self.mcontroller.get_main_device() if odev.get_card_status() is not CARD_STATUS_READY: return -1 if odev == None or odev.get_type() != tgcm.core.DeviceManager.DEVICE_MODEM: self.show_no_available_device_error() return -1 if odev.is_roaming() and bool(self._conf.check_policy('show-roaming-warning')): if tgcm.country_support == "es": message = _("You are about to connect you in roaming and your customary data fares do not apply for the traffic that consummate abroad. Inform yourself of your roaming data fares in the 22119 (free call cost in the European Union; from other countries applicable price to calls with destination Spain according to roaming fare of the line). To control your bill you can define alerts in Escritorio Movistar and will receive notifications when reaching a certain amount of data spent.") else: message = _("You're about to connect while abroad. Network operators have different charges for data usage and costs can soon mount up. To set up alerts so you know approximately how much data you have used go to Settings / Alerts.") title = _("Roaming alert") response = warning_dialog(msg=message, title=title) if response != gtk.RESPONSE_OK: return -2 if not odev.has_capability(MOBILE_MANAGER_DEVICE_STATE_INTERFACE_URI) : self.cardmanager = None else: self.cardmanager = odev if network_connection_status == PPP_STATUS_DISCONNECTED: if self.cardmanager.get_card_status() != CARD_STATUS_READY: if smart_connector == False: error_dialog(markup=MSG_CONN_MANAGER_NO_CARDMANAGER_TITLE, \ msg=MSG_CONN_MANAGER_NO_CARDMANAGER) return -1 if action != None: self.action = action if bookmark_info != None: self.bookmark_info = bookmark_info if url != None: self.url = url if network_connection_status == NetworkManager.State.CONNECTED : if self.actual_connection is not None and connection_settings["uuid"]==self.actual_connection["uuid"]: self.launch_service() return 0 if force_connection == False: ret = self.__detect_active_connection_dialog(connection_name, action, bookmark_info) else: ret = 3 if ret == 1 or ret < 0: return 0 #Cancelled by the user elif ret == 2 : self.launch_service() return 0 elif ret == 3: self._connection_manager.ppp_manager.stop() gtk_sleep(0.1); self.waiting_connection = connection_settings self.reconnect_on_disconnect=None password=None if connection_settings["ask_password"] == True: password = self._ask_password (connection_name) if password is None: return 0 #Cancelled by the user #Reload connection info from gconf based on SIM characteristics try: if (connection_settings["origin"]!="networkmanager" or connection_settings["ask_password"]==True): connection_settings=self._connection_settings_manager.get_connection_info_dict_from_gconf(connection_settings['gconf_path']) self._connection_settings_manager.add_wwan_connection(connection_settings,write_gconf_if_required=False,update_if_possible=True,password=password) gtk_sleep(1.5); #time.sleep(1) #We must give some time to update the connection except (RuntimeError, TypeError, NameError): tgcm.error("Error in update") pass self._conf.set_proxy(connection_settings) ret=self._connection_manager.ppp_manager.start(connection_settings,odev) if ret!=0: self.action = None self.bookmark_info =None return ret
def __show_error_dialog(self, message, markup): error_dialog(message, markup=markup, parent=self.dialog)
def __main_modem_fatal_error(self, device_manager): title = _("Mobile Internet Device connection failed") markup = _("Please remove the Mobile Internet Device and connect again") msg = _("The connection with the Mobile Internet Device has failed. It is not possible to establish a new connection until the device is removed and inserted again.") error_dialog(msg, markup='<b>%s</b>' % markup, title=title)
def connect_to_connection(self, connection_settings = None, force_connection = False, \ action = None, bookmark_info = None, url = None, smart_connector = False): self.abort_now_flag = False self.smart_connector = smart_connector device_type = connection_settings["deviceType"] connection_name = connection_settings["name"] tgcm.info("Trying to connect to %s" % connection_name) if self.connect_to_bus() != True: return -1 network_connection_status = self._connection_manager.ppp_manager.nmConnectionState( ) if (device_type == tgcm.core.FreeDesktop.DEVICE_WLAN or device_type == tgcm.core.FreeDesktop.DEVICE_WLAN_PROFILE): odev = self.mcontroller.get_wifi_device() if odev == None: return -1 if self._connection_settings_manager.is_wifi_ap_available( connection_settings) == False: return -1 if (device_type == tgcm.core.FreeDesktop.DEVICE_WIRED): odev = self.mcontroller.get_wired_device() if odev == None: return -1 elif (device_type == tgcm.core.FreeDesktop.DEVICE_MODEM): if self._connection_manager.is_device_selected() == False: return -1 odev = self.mcontroller.get_main_device() if odev.get_card_status() is not CARD_STATUS_READY: return -1 if odev == None or odev.get_type( ) != tgcm.core.DeviceManager.DEVICE_MODEM: self.show_no_available_device_error() return -1 if odev.is_roaming() and bool( self._conf.check_policy('show-roaming-warning')): if tgcm.country_support == "es": message = _( "You are about to connect you in roaming and your customary data fares do not apply for the traffic that consummate abroad. Inform yourself of your roaming data fares in the 22119 (free call cost in the European Union; from other countries applicable price to calls with destination Spain according to roaming fare of the line). To control your bill you can define alerts in Escritorio Movistar and will receive notifications when reaching a certain amount of data spent." ) else: message = _( "You're about to connect while abroad. Network operators have different charges for data usage and costs can soon mount up. To set up alerts so you know approximately how much data you have used go to Settings / Alerts." ) title = _("Roaming alert") response = warning_dialog(msg=message, title=title) if response != gtk.RESPONSE_OK: return -2 if not odev.has_capability( MOBILE_MANAGER_DEVICE_STATE_INTERFACE_URI): self.cardmanager = None else: self.cardmanager = odev if network_connection_status == PPP_STATUS_DISCONNECTED: if self.cardmanager.get_card_status() != CARD_STATUS_READY: if smart_connector == False: error_dialog(markup=MSG_CONN_MANAGER_NO_CARDMANAGER_TITLE, \ msg=MSG_CONN_MANAGER_NO_CARDMANAGER) return -1 if action != None: self.action = action if bookmark_info != None: self.bookmark_info = bookmark_info if url != None: self.url = url if network_connection_status == NetworkManager.State.CONNECTED: if self.actual_connection is not None and connection_settings[ "uuid"] == self.actual_connection["uuid"]: self.launch_service() return 0 if force_connection == False: ret = self.__detect_active_connection_dialog( connection_name, action, bookmark_info) else: ret = 3 if ret == 1 or ret < 0: return 0 #Cancelled by the user elif ret == 2: self.launch_service() return 0 elif ret == 3: self._connection_manager.ppp_manager.stop() gtk_sleep(0.1) self.waiting_connection = connection_settings self.reconnect_on_disconnect = None password = None if connection_settings["ask_password"] == True: password = self._ask_password(connection_name) if password is None: return 0 #Cancelled by the user #Reload connection info from gconf based on SIM characteristics try: if (connection_settings["origin"] != "networkmanager" or connection_settings["ask_password"] == True): connection_settings = self._connection_settings_manager.get_connection_info_dict_from_gconf( connection_settings['gconf_path']) self._connection_settings_manager.add_wwan_connection( connection_settings, write_gconf_if_required=False, update_if_possible=True, password=password) gtk_sleep(1.5) #time.sleep(1) #We must give some time to update the connection except (RuntimeError, TypeError, NameError): tgcm.error("Error in update") pass self._conf.set_proxy(connection_settings) ret = self._connection_manager.ppp_manager.start( connection_settings, odev) if ret != 0: self.action = None self.bookmark_info = None return ret
class HotSpotsService(gobject.GObject): __metaclass__ = Singleton.Singleton __gsignals__ = { 'hotspots-updated': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()), } VALUE_ALL = _('All') class _InitCheck(): def __init__(self, retval): self.__retval = retval def __call__(self, func): default_return_value = self.__retval def newf(self, *args, **kwargs): if self.hotspots_db is None: return default_return_value return func(self, *args, **kwargs) return newf def __init__(self): gobject.GObject.__init__(self) self.hotspots_db = None self.hotspots_db_file = os.path.join( tgcm.config_dir, "hotspot-%s.db" % tgcm.country_support) if os.path.exists(self.hotspots_db_file): self.hotspots_db = sqlite3.connect(self.hotspots_db_file) self.hotspots_db.create_function("regexp", 2, regexp) else: regional_hotspot_file = os.path.join(tgcm.regional_info_dir, tgcm.country_support, "hotspot-list.xml") if os.path.exists(regional_hotspot_file): self.register_new_hotspot_file(regional_hotspot_file, self.hotspots_db_file) self.hotspots_db = sqlite3.connect(self.hotspots_db_file) self.hotspots_db.create_function("regexp", 2, regexp) def register_new_hotspot_file(self, in_file, out_file=None): out_file = self.hotspots_db_file if (out_file is None) else out_file try: tree = ElementTree() tree.parse(in_file) except (xml.etree.ElementTree.ParseError, sqlite3.OperationalError), err: # -- This failure appears when importing an empty file. In that case ignore the failure # -- but don't forget to create the database! tgcm.warning("@WARNING: Importing hotspots file '%s', %s" % (in_file, err)) return False except Exception, err: config = Config.Config() srv_name = config.get_wifi_service_name() error_dialog(_("The hotspots list of %s will not be available due an import error.") % srv_name, \ markup = _("Unexpected error reading hotspots"), \ threaded = False) return False