diff options
Diffstat (limited to 'src/jarabe/model/network.py')
-rw-r--r-- | src/jarabe/model/network.py | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/src/jarabe/model/network.py b/src/jarabe/model/network.py index d76e408..20fd192 100644 --- a/src/jarabe/model/network.py +++ b/src/jarabe/model/network.py @@ -34,6 +34,7 @@ from sugar import dispatch from sugar import env from sugar.util import unique_id + DEVICE_TYPE_802_3_ETHERNET = 1 DEVICE_TYPE_802_11_WIRELESS = 2 DEVICE_TYPE_GSM_MODEM = 3 @@ -147,6 +148,7 @@ _conn_counter = 0 _nm_device_state_reason_description = None + def get_error_by_reason(reason): global _nm_device_state_reason_description @@ -242,7 +244,6 @@ def get_error_by_reason(reason): return _nm_device_state_reason_description[reason] - def frequency_to_channel(frequency): """Returns the channel matching a given radio channel frequency. If a frequency is not in the dictionary channel 1 will be returned. @@ -263,6 +264,7 @@ def frequency_to_channel(frequency): return 1 return ftoc[frequency] + def is_sugar_adhoc_network(ssid): """Checks whether an access point is a sugar Ad-hoc network. @@ -294,6 +296,7 @@ class WirelessSecurity(object): wireless_security['group'] = self.group return wireless_security + class Wireless(object): nm_name = "802-11-wireless" @@ -352,6 +355,7 @@ class Connection(object): connection['timestamp'] = self.timestamp return connection + class IP4Config(object): def __init__(self): self.method = None @@ -362,6 +366,7 @@ class IP4Config(object): ip4_config['method'] = self.method return ip4_config + class Serial(object): def __init__(self): self.baud = None @@ -374,6 +379,7 @@ class Serial(object): return serial + class Ppp(object): def __init__(self): pass @@ -382,6 +388,7 @@ class Ppp(object): ppp = {} return ppp + class Gsm(object): def __init__(self): self.apn = None @@ -400,6 +407,7 @@ class Gsm(object): return gsm + class Settings(object): def __init__(self, wireless_cfg=None): self.connection = Connection() @@ -422,6 +430,7 @@ class Settings(object): settings['ipv4'] = self.ip4_config.get_dict() return settings + class Secrets(object): def __init__(self, settings): self.settings = settings @@ -447,6 +456,7 @@ class Secrets(object): return settings + class SettingsGsm(object): def __init__(self): self.connection = Connection() @@ -466,6 +476,7 @@ class SettingsGsm(object): return settings + class SecretsGsm(object): def __init__(self): self.password = None @@ -482,6 +493,7 @@ class SecretsGsm(object): secrets['puk'] = self.puk return {'gsm': secrets} + class NMSettings(dbus.service.Object): def __init__(self): bus = dbus.SystemBus() @@ -509,6 +521,7 @@ class NMSettings(dbus.service.Object): self.secrets_request.send(self, connection=sender, response=kwargs['response']) + class SecretsResponse(object): ''' Intermediate object to report the secrets from the dialog back to the connection object and which will inform NM @@ -525,6 +538,7 @@ class SecretsResponse(object): def set_error(self, error): self._error_cb(error) + class NMSettingsConnection(dbus.service.Object): def __init__(self, path, settings, secrets): bus = dbus.SystemBus() @@ -649,6 +663,7 @@ class NMSettingsConnection(dbus.service.Object): else: raise Exception('The stored GSM secret has already been supplied ') + class AccessPoint(gobject.GObject): __gsignals__ = { 'props-changed': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, @@ -757,6 +772,7 @@ class AccessPoint(gobject.GObject): path=self.model.object_path, dbus_interface=NM_ACCESSPOINT_IFACE) + def get_settings(): global _nm_settings if _nm_settings is None: @@ -767,6 +783,7 @@ def get_settings(): load_connections() return _nm_settings + def find_connection_by_ssid(ssid): connections = get_settings().connections @@ -778,6 +795,7 @@ def find_connection_by_ssid(ssid): return None + def add_connection(uuid, settings, secrets=None): global _conn_counter @@ -788,6 +806,7 @@ def add_connection(uuid, settings, secrets=None): _nm_settings.add_connection(uuid, conn) return conn + def load_wifi_connections(): profile_path = env.get_profile_path() config_path = os.path.join(profile_path, 'nm', 'connections.cfg') @@ -893,10 +912,12 @@ def load_gsm_connection(): else: logging.exception("No gsm connection was set in GConf.") + def load_connections(): load_wifi_connections() load_gsm_connection() + def find_gsm_connection(): connections = get_settings().connections |