def __request_button_cb(self, widget, data): self.progress = tgcm.ui.MSD.MSDProgressWindow() self.progress.set_show_buttons(False) self.progress.show(_("Please wait a minute..."), _("Please wait a minute...")) self.progress.progressbar.hide() gtk_sleep(0.5) mainloop = gobject.MainLoop(is_running=True) context = mainloop.get_context() while context.pending(): context.iteration() dev = self.mcontroller.get_main_device() cover_key = "" if ( dev != None and dev.get_type() == tgcm.core.DeviceManager.DEVICE_MODEM and dev.get_card_status() == CARD_STATUS_READY ): if dev.has_capability(MOBILE_MANAGER_DEVICE_STATE_INTERFACE_URI): tgcm.debug("Sending ussd code : %s" % self._get_conf_key_value("ussd")) cover_key = dev.get_cover_key( self._get_conf_key_value("ussd"), self.__cover_key_func, self.__cover_key_error_func ) return self.progress.hide()
def __request_button_cb(self, widget, data): self.progress = tgcm.ui.MSD.MSDProgressWindow() self.progress.set_show_buttons(False) self.progress.show(_("Please wait a minute..."), _("Please wait a minute...")) self.progress.progressbar.hide() gtk_sleep(0.5) mainloop = gobject.MainLoop(is_running=True) context = mainloop.get_context() while context.pending(): context.iteration() dev = self.mcontroller.get_main_device() cover_key = "" if dev != None and dev.get_type( ) == tgcm.core.DeviceManager.DEVICE_MODEM and dev.get_card_status( ) == CARD_STATUS_READY: if dev.has_capability(MOBILE_MANAGER_DEVICE_STATE_INTERFACE_URI): tgcm.debug("Sending ussd code : %s" % self._get_conf_key_value("ussd")) cover_key = dev.get_cover_key(self._get_conf_key_value("ussd"), self.__cover_key_func, self.__cover_key_error_func) return self.progress.hide()
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 __remove_contacts(self, contacts, dlg): ARBITRARY_WAIT = 0.5 # -- Give the dialog some time otherwise it remains blocked gtk_sleep(ARBITRARY_WAIT) for contact in contacts: contact.destroySelf(notify=False) selection = self.contact_treeview.get_selection() selection.handler_block(self.__contact_treeview_cursor_changed_cb_h) self._addr_manager.update_model() selection.handler_unblock(self.__contact_treeview_cursor_changed_cb_h) self.contact_treeview.set_cursor(0) self.__check_button_sensitivity() gtk_sleep(ARBITRARY_WAIT) dlg.destroy()
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 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 __run(self): # -- First remove the old error message and grab the focus to the PUK field entry self.puk_entry.grab_focus() self.__error_hbox_clear() try: odev = self.device_manager.get_main_device() if odev == None: print "ERROR: There is no Main device" return status = odev.pin_status() # -- We must stop the device checker as the modem normally doesn't respond when the PUK is requested if status == MobileManager.PIN_STATUS_WAITING_PUK: odev.stop_checker() self.__clean_dialog_fields() while status == MobileManager.PIN_STATUS_WAITING_PUK: response = self.dialog.run() # -- This response is received when the modem was removed if response == gtk.RESPONSE_REJECT: break elif response != gtk.RESPONSE_OK: self.__error_dialog( _("PUK authentication cancel"), _("You have canceled the PUK authentication process, the card will be turn off" )) # -- Turn the modem off only if it has not changed before if self.__state != self.STATE_MODEM_CHANGED: odev.turn_off() break # -- We dont need to check for the entries as they are validated when a entry change is detected puk = self.puk_entry.get_text() new_pin = self.new_pin_entry.get_text() new_pin_confirm = self.new_pin_confirm_entry.get_text() # -- While the PUK is sent, the modem could be removed so we need to check for the state flag send_puk_result = odev.send_puk(puk, new_pin) # -- First check if the modem was probably removed during the PUK was sent to the device. In that # -- case no error message is required as the Dock shows that no device is available if self.__state == self.STATE_MODEM_CHANGED: break if send_puk_result is False: self.__error_hbox_show( _("PUK authentication failed, please verify the number." )) continue # -- Now we need to wait until the card is ready. Using an arbitrary timeout for avoding a deadlock loop_time = 0.25 timeout = int(4 / loop_time) while timeout > 0: timeout -= 1 gtk_sleep(loop_time) status = odev.pin_status() if status == MobileManager.PIN_STATUS_READY: odev.start_checker() return self.__error_dialog( _("PUK authentication failure"), _("Timeout waiting for PIN ready status. Please try reconnecting the modem." )) break except Exception, err: print "@FIXME: PukDialog error, %s" % err