def ask_puk2_dialog(parent): logger.debug("Asking for PUK2") return generic_puk_dialog( _("PUK2 required"), _("Please, insert the PUK2 and PIN of your SIM card"), parent, puk_regexp=re.compile('^\d{8}$'), pin_regexp=re.compile('^\d{4,8}$'))
def new_profile_cb(path): self.profile_path = path logger.debug("Profile added: %s" % self.profile_path) self.profile = self.manager.get_profile_by_uuid(uuid) secrets = {'password': self.password} self.profile.secrets.update(secrets, ask=True) self.parent_model.profile_added(self) sm.remove() # remove SignalMatch handler
def _enable_device_eb(self, e): if dbus_error_is(e, E.SimPinRequired): self.pin_required = True elif dbus_error_is(e, E.SimPukRequired): self.puk_required = True elif dbus_error_is(e, E.SimPuk2Required): self.puk2_required = True else: self.sim_error = get_error_msg(e) logger.debug("Error enabling device:\n%s" % get_error_msg(e))
def show_warning_dialog(title, message): logger.debug("Warning dialog: %s" % message) buttons = (gtk.STOCK_OK, gtk.RESPONSE_OK) dialog, box = make_basic_dialog(title, buttons, gtk.STOCK_DIALOG_WARNING) box.add(gtk.Label(message)) dialog.set_default_response(gtk.RESPONSE_OK) dialog.show_all() ret = dialog.run() dialog.destroy() return ret
def quit(self, quit_cb): def quit_eb(e): logger.error("Error while removing device: %s" % get_error_msg(e)) quit_cb() if self.device_opath and self.obj: logger.debug("Removing device %s before quit." % self.device_opath) self.device.Enable(False, dbus_interface=MDM_INTFACE, reply_handler=quit_cb, error_handler=quit_eb) else: quit_cb()
def show_error_dialog(title, message): logger.debug("Error dialog: %s" % message) buttons = (gtk.STOCK_OK, gtk.RESPONSE_OK) dialog, box = make_basic_dialog(title, buttons, gtk.STOCK_DIALOG_ERROR) label = gtk.Label(message) label.set_width_chars(80) label.set_line_wrap(True) label.set_justify(gtk.JUSTIFY_FILL) box.add(label) dialog.set_default_response(gtk.RESPONSE_OK) dialog.show_all() ret = dialog.run() dialog.destroy() return ret
def ask_password_dialog(parent): logger.debug("Asking for password") return generic_auth_dialog( _("Password required"), _("Please, insert the password of your connection"), parent, regexp=None)
def ask_pin_dialog(parent): logger.debug("Asking for PIN") return generic_auth_dialog( _("PIN required"), _("Please, insert the PIN of your SIM card"), parent, regexp=re.compile('^\d{4,8}$'))
def save(self): props = { 'connection': {'id': self.name, 'type': 'gsm', 'name': 'connection', 'uuid': self.uuid, 'autoconnect': self.autoconnect}, 'gsm': {'band': self.band, 'username': self.username, 'number': '*99#', 'network-type': self.network_type, 'apn': self.apn, 'name': 'gsm'}, 'ppp': {'name': 'ppp'}, 'serial': {'baud': 115200, 'name': 'serial'}, 'ipv4': {'addresses': [], 'method': 'auto', 'ignore-auto-dns': self.static_dns, 'name': 'ipv4', 'routes': []}, } if not props['ipv4']['ignore-auto-dns']: props['ipv4']['dns'] = [] else: dns = [i for i in [self.primary_dns, self.secondary_dns] if i] props['ipv4']['dns'] = map(convert, dns) props = patch_list_signature(props) if self.profile: self.manager.update_profile(self.profile, props) # store password associated to this connection secrets = {'password': self.password} self.profile.secrets.update(secrets, ask=True) logger.debug("Profile modified: %s" % self.profile) else: uuid = props['connection']['uuid'] if self.parent_model.profiles_model.has_profile(uuid=uuid): msg = _('A profile with uuid "%s" exists') % uuid raise RuntimeError(msg) sm = None # SignalMatch object def new_profile_cb(path): self.profile_path = path logger.debug("Profile added: %s" % self.profile_path) self.profile = self.manager.get_profile_by_uuid(uuid) secrets = {'password': self.password} self.profile.secrets.update(secrets, ask=True) self.parent_model.profile_added(self) sm.remove() # remove SignalMatch handler sm = self.bus.add_signal_receiver(new_profile_cb, "NewConnection", WADER_PROFILES_INTFACE) self.manager.add_profile(props) if self.state == DISCONNECTED and self.device_callable: # only perform this operations if we are disconnected and # a device is available device = self.device_callable() if not device: return if self.band is not None: device.SetBand(self.band, dbus_interface=NET_INTFACE, reply_handler=lambda: True, error_handler=logger.error) if self.network_type is not None: device.SetNetworkMode(self.network_type, dbus_interface=NET_INTFACE, reply_handler=lambda: True, error_handler=logger.error)