Ticket #1738: 0001-Do-not-load-empty-gsm-connection-configuration.patch

File 0001-Do-not-load-empty-gsm-connection-configuration.patch, 3.3 KB (added by tch, 14 years ago)
  • extensions/deviceicon/network.py

    From 39032c83475fa4e49e5554e9f465bea986955819 Mon Sep 17 00:00:00 2001
    From: tch <mabente@paraguayeduca.org>
    Date: Tue, 23 Feb 2010 10:52:47 -0300
    Subject: [PATCH] Do not load empty gsm connection configuration
    
    ---
     extensions/deviceicon/network.py |    2 +
     src/jarabe/model/network.py      |   46 +++++++++++++++++++++++--------------
     2 files changed, 30 insertions(+), 18 deletions(-)
    
    diff --git a/extensions/deviceicon/network.py b/extensions/deviceicon/network.py
    index 94a4293..fc72b6d 100644
    a b class GsmDeviceView(TrayIcon): 
    774774                                        '/',
    775775                                        reply_handler=self.__connect_cb,
    776776                                        error_handler=self.__connect_error_cb)
     777        else:
     778            raise RuntimeError('There is no gsm connection available')
    777779
    778780    def __connect_cb(self, active_connection):
    779781        logging.debug('Connected successfully to gsm device, %s',
  • src/jarabe/model/network.py

    diff --git a/src/jarabe/model/network.py b/src/jarabe/model/network.py
    index f3a1fc6..03d48c4 100644
    a b def load_wifi_connections(): 
    661661def load_gsm_connection():
    662662    client = gconf.client_get_default()
    663663
    664     settings = SettingsGsm()
    665     settings.gsm.username = client.get_string(GSM_USERNAME_PATH) or ''
    666     settings.gsm.number = client.get_string(GSM_NUMBER_PATH) or ''
    667     settings.gsm.apn = client.get_string(GSM_APN_PATH) or ''
     664    username = client.get_string(GSM_USERNAME_PATH) or ''
    668665    password = client.get_string(GSM_PASSWORD_PATH) or ''
     666    number = client.get_string(GSM_NUMBER_PATH) or ''
     667    apn = client.get_string(GSM_APN_PATH) or ''
     668    pin = client.get_string(GSM_PIN_PATH) or ''
     669    puk = client.get_string(GSM_PUK_PATH) or ''
    669670
    670     secrets = SecretsGsm()
    671     secrets.pin = client.get_string(GSM_PIN_PATH) or ''
    672     secrets.puk = client.get_string(GSM_PUK_PATH) or ''
    673     secrets.password = password
     671    if username and number and apn:
    674672
    675     settings.connection.id = 'gsm'
    676     settings.connection.type = NM_CONNECTION_TYPE_GSM
    677     uuid = settings.connection.uuid = unique_id()
    678     settings.connection.autoconnect = False
    679     settings.ip4_config.method = 'auto'
    680     settings.serial.baud = 115200
     673        settings = SettingsGsm()
     674        settings.gsm.username = username
     675        settings.gsm.number = number
     676        settings.gsm.apn = apn
     677       
     678        secrets = SecretsGsm()
     679        secrets.pin = pin
     680        secrets.puk = puk
     681        secrets.password = password
     682
     683        settings.connection.id = 'gsm'
     684        settings.connection.type = NM_CONNECTION_TYPE_GSM
     685        uuid = settings.connection.uuid = unique_id()
     686        settings.connection.autoconnect = False
     687        settings.ip4_config.method = 'auto'
     688        settings.serial.baud = 115200
    681689
    682     try:
    683         add_connection(uuid, settings, secrets)
    684     except Exception:
    685         logging.exception('While adding gsm connection')
     690        try:
     691            add_connection(uuid, settings, secrets)
     692        except Exception:
     693            logging.exception('While adding gsm connection')
     694    else:
     695      logging.exception("Could not load gsm connection")
    686696
    687697def load_connections():
    688698    load_wifi_connections()