def _load_settings(self, settings):
        try:
            self.uuid = settings['connection']['uuid']
            self.name = settings['connection']['id']
            self.apn = settings['gsm'].get('apn', '')
            self.username = settings['gsm'].get('username', '')
            self.autoconnect = settings['connection'].get('autoconnect', False)
            self.static_dns = settings.get('ipv4',
                                           {}).get('ignore-auto-dns',
                                                   self.static_dns)
            dns = settings.get('ipv4', {}).get('dns')
            if dns:
                self.primary_dns = dns[0]
                if len(dns) > 1:
                    self.secondary_dns = dns[1]

            self.network_pref = settings['gsm'].get('network-type')
            self.band = settings['gsm'].get('band')
            self.refuse_chap = settings.get('ppp', {}).get('refuse-chap')
            self.refuse_pap = settings.get('ppp', {}).get('refuse-pap')

            if not self.refuse_pap and self.refuse_chap:
                self.auth = GUI_NETWORK_AUTH_PAP
            elif not self.refuse_chap and self.refuse_pap:
                self.auth = GUI_NETWORK_AUTH_CHAP
            else:
                self.auth = GUI_NETWORK_AUTH_ANY

            # the last one
            if settings['gsm'].get('password') is not None:
                self.password = settings['gsm']['password']

        except KeyError, e:
            logger.error("Missing required key '%s' in %s" % (e, settings))
    def _load_settings(self, settings):
        try:
            self.uuid = settings['connection']['uuid']
            self.name = settings['connection']['id']
            self.apn = settings['gsm'].get('apn', '')
            self.username = settings['gsm'].get('username', '')
            self.autoconnect = settings['connection'].get('autoconnect', False)
            self.static_dns = settings.get('ipv4', {}).get('ignore-auto-dns',
                                                           self.static_dns)
            dns = settings.get('ipv4', {}).get('dns')
            if dns:
                self.primary_dns = dns[0]
                if len(dns) > 1:
                    self.secondary_dns = dns[1]

            self.network_pref = settings['gsm'].get('network-type')
            self.band = settings['gsm'].get('band')
            self.refuse_chap = settings.get('ppp', {}).get('refuse-chap')
            self.refuse_pap = settings.get('ppp', {}).get('refuse-pap')

            if not self.refuse_pap and self.refuse_chap:
                self.auth = GUI_NETWORK_AUTH_PAP
            elif not self.refuse_chap and self.refuse_pap:
                self.auth = GUI_NETWORK_AUTH_CHAP
            else:
                self.auth = GUI_NETWORK_AUTH_ANY

            # the last one
            if settings['gsm'].get('password') is not None:
                self.password = settings['gsm']['password']

        except KeyError, e:
            logger.error("Missing required key '%s' in %s" % (e, settings))
Esempio n. 3
0
    def setup_view(self, view):
        if self.model.name:
            self.view['profile_name_entry'].set_text(self.model.name)
        if self.model.username:
            self.view['username_entry'].set_text(self.model.username)
        if self.model.apn:
            self.view['apn_entry'].set_text(self.model.apn)
        if self.model.primary_dns:
            dns1 = convert_int_to_ip(self.model.primary_dns)
            self.view['primary_dns_entry'].set_text(dns1)
        if self.model.secondary_dns:
            dns2 = convert_int_to_ip(self.model.secondary_dns)
            self.view['secondary_dns_entry'].set_text(dns2)

        if self.model.static_dns:
            self.view['static_dns_check'].set_active(self.model.static_dns)
            self.view.enable_static_dns()
        else:
            self.view['static_dns_check'].set_active(False)

        if not self.model.password:

            def load_secrets(secrets):
                self.model.password = secrets['gsm'].get('passwd', '')
                self.view['password_entry'].set_text(self.model.password)

            try:
                self.model.load_password(load_secrets)
            except KeyringNoMatchError, e:
                logger.error("Error while loading connection password: %s" % e)
                title = _("Error while getting connection password")
                details = _("NoMatchError: No password was retrieved "
                            "from connection, please set one again")
                show_error_dialog(title, details)
                return
        def enable_pin_eb(e):
            logger.error("EnablePin failed %s" % get_error_msg(e))
            eb(enable)

            if 'SimPukRequired' in get_error_msg(e):
                self.sim_auth_required = GUI_SIM_AUTH_PUK

            if 'SimPuk2Required' in get_error_msg(e):
                self.sim_auth_required = GUI_SIM_AUTH_PUK2
        def change_pin_eb(e):
            logger.error("ChangePin failed %s" % get_error_msg(e))
            eb()

            if 'SimPukRequired' in get_error_msg(e):
                self.sim_auth_required = GUI_SIM_AUTH_PUK

            if 'SimPuk2Required' in get_error_msg(e):
                self.sim_auth_required = GUI_SIM_AUTH_PUK2
Esempio n. 6
0
    def _network_register_eb(self, error):
        logger.error("Error while registering to home network %s" % error)
        try:
            self.net_error = E.error_to_human(error)
        except KeyError:
            self.net_error = error

        # fake a +CREG: 0,3
        self._get_registration_info_cb((3, '', ''))
Esempio n. 7
0
        def change_pin_eb(e):
            logger.error("ChangePin failed %s" % get_error_msg(e))
            eb()

            if 'SimPukRequired' in get_error_msg(e):
                self.sim_auth_required = VMB_SIM_AUTH_PUK

            if 'SimPuk2Required' in get_error_msg(e):
                self.sim_auth_required = VMB_SIM_AUTH_PUK2
    def _network_register_eb(self, error):
        logger.error("Error while registering to home network %s" % error)
        try:
            self.net_error = E.error_to_human(error)
        except KeyError:
            self.net_error = error

        # fake a +CREG: 0,3
        self._get_registration_info_cb((3, '', ''))
Esempio n. 9
0
        def enable_pin_eb(e):
            logger.error("EnablePin failed %s" % get_error_msg(e))
            eb(enable)

            if 'SimPukRequired' in get_error_msg(e):
                self.sim_auth_required = VMB_SIM_AUTH_PUK

            if 'SimPuk2Required' in get_error_msg(e):
                self.sim_auth_required = VMB_SIM_AUTH_PUK2
 def load_password(self, callback=None):
     if self.profile:
         if self.profile.secrets.is_open():
             secrets = self.profile.secrets.get(ask=True)
             try:
                 self.password = secrets['gsm']['passwd']
             except KeyError:
                 uuid = self.profile.secrets.uuid
                 logger.error("Connection %s has no secrets" % uuid)
                 self.password = ''
         else:
             # keyring needs to be opened
             self.main_model.on_keyring_key_needed_cb(self.profile.opath,
                                                         callback=callback)
 def submit_cb(error):
     if not error:
         logger.info("PAYT SIM submit voucher success")
         # ok we established his voucher code is good, let's cause the
         # system to update the UI with his new credit. To do that we
         # need to fire off another request
         self.get_current_sim_credit()
         self.model.payt_submit_busy = False
         self.view.clear_voucher_entry_view()
     else:
         logger.error("PAYT SIM submit voucher failed")
         self.model.payt_submit_busy = False
         show_warning_dialog(_("PAYT submit voucher"),
             _("PAYT submit voucher failed\n\'%s\'") % error)
 def load_password(self, callback=None):
     if self.profile:
         if self.profile.secrets.is_open():
             secrets = self.profile.secrets.get(ask=True)
             try:
                 self.password = secrets['gsm']['passwd']
             except KeyError:
                 uuid = self.profile.secrets.uuid
                 logger.error("Connection %s has no secrets" % uuid)
                 self.password = ''
         else:
             # keyring needs to be opened
             self.main_model.on_keyring_key_needed_cb(self.profile.opath,
                                                      callback=callback)
Esempio n. 13
0
 def submit_cb(error):
     if not error:
         logger.info("PAYT SIM submit voucher success")
         # ok we established his voucher code is good, let's cause the
         # system to update the UI with his new credit. To do that we
         # need to fire off another request
         self.get_current_sim_credit()
         self.model.payt_submit_busy = False
         self.view.clear_voucher_entry_view()
     else:
         logger.error("PAYT SIM submit voucher failed")
         self.model.payt_submit_busy = False
         show_warning_dialog(
             _("PAYT submit voucher"),
             _("PAYT submit voucher failed\n\'%s\'") % error)
Esempio n. 14
0
 def _send_puk_eb(e):
     logger.error("SendPuk failed: %s" % get_error_msg(e))
     self._check_pin_status()
Esempio n. 15
0
 def _send_pin_eb(e):
     logger.error("SendPin failed %s" % get_error_msg(e))
     if self.manage_pin:
         self.delete_pin_from_keyring()
     self._check_pin_status()
 def quit_eb(e):
     logger.error("Error while removing device: %s" % get_error_msg(e))
     quit_cb()
Esempio n. 17
0
 def _get_devices_eb(self, error):
     logger.error(error)
     # connecting to signals is safe now
     self._connect_to_signals()
Esempio n. 18
0
 def get_msisdn_eb(failure):
     msg = "MSISDN Error fetching via USSD"
     logger.error(msg)
     cb(None)
 def _send_puk_eb(e):
     logger.error("SendPuk failed: %s" % get_error_msg(e))
     self._check_pin_status()
Esempio n. 20
0
 def ussd_eb(error):
     logger.error("PAYT SIM error submitting voucher via USSD: %s" %
                  error)
     cb(error)
 def get_imsi_eb(failure):
     msg = "Error while getting IMSI for device %s"
     logger.error(msg % self.device_opath)
     cb(None)
 def ussd_eb(error):
     logger.error("PAYT SIM error submitting voucher via USSD: %s"
                  % error)
     cb(error)
 def get_credit_eb(error):
     logger.error("PAYT SIM error fetching via USSD: %s" % error)
     cb(None)
 def error(e):
     logger.error("Error while getting IMSI: %s" % get_error_msg(e))
 def get_msisdn_eb(failure):
     msg = "MSISDN Error fetching via USSD"
     logger.error(msg)
     cb(None)
 def _get_devices_eb(self, error):
     logger.error(error)
     # connecting to signals is safe now
     self._connect_to_signals()
 def error(e):
     logger.error("Error while getting IMSI: %s" % get_error_msg(e))
Esempio n. 28
0
 def get_credit_eb(error):
     logger.error("PAYT SIM error fetching via USSD: %s" % error)
     cb(None)
Esempio n. 29
0
 def quit_eb(e):
     logger.error("Error while removing device: %s" % get_error_msg(e))
     quit_cb()
Esempio n. 30
0
 def get_imsi_eb(failure):
     msg = "Error while getting IMSI for device %s"
     logger.error(msg % self.device_opath)
     cb(None)
 def _send_pin_eb(e):
     logger.error("SendPin failed %s" % get_error_msg(e))
     if self.manage_pin:
         self.delete_pin_from_keyring()
     self._check_pin_status()