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): |
774 | 774 | '/', |
775 | 775 | reply_handler=self.__connect_cb, |
776 | 776 | error_handler=self.__connect_error_cb) |
| 777 | else: |
| 778 | raise RuntimeError('There is no gsm connection available') |
777 | 779 | |
778 | 780 | def __connect_cb(self, active_connection): |
779 | 781 | logging.debug('Connected successfully to gsm device, %s', |
diff --git a/src/jarabe/model/network.py b/src/jarabe/model/network.py
index f3a1fc6..03d48c4 100644
a
|
b
|
def load_wifi_connections(): |
661 | 661 | def load_gsm_connection(): |
662 | 662 | client = gconf.client_get_default() |
663 | 663 | |
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 '' |
668 | 665 | 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 '' |
669 | 670 | |
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: |
674 | 672 | |
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 |
681 | 689 | |
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") |
686 | 696 | |
687 | 697 | def load_connections(): |
688 | 698 | load_wifi_connections() |