Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <mpgritti@gmail.com>2008-10-22 12:23:39 (GMT)
committer Marco Pesenti Gritti <mpgritti@gmail.com>2008-10-22 12:23:39 (GMT)
commitd44b488b4459c5139e1dc14f75e35898f5e85511 (patch)
tree54eb8c0feb9807c5dbbc6169cd611b4217237964 /src
parentcf8efed575efa4fbd5f97a522259eb351317845f (diff)
Reuse settings
Diffstat (limited to 'src')
-rw-r--r--src/jarabe/desktop/meshbox.py17
-rw-r--r--src/jarabe/model/network.py24
2 files changed, 26 insertions, 15 deletions
diff --git a/src/jarabe/desktop/meshbox.py b/src/jarabe/desktop/meshbox.py
index e37dc57..8e7d5b7 100644
--- a/src/jarabe/desktop/meshbox.py
+++ b/src/jarabe/desktop/meshbox.py
@@ -125,8 +125,9 @@ class AccessPointView(CanvasPulsingIcon):
return p
def __device_state_changed_cb(self, old_state, new_state, reason):
+ print new_state
self._device_state = new_state
- self._update()
+ self._update_state()
def __ap_properties_changed_cb(self, properties):
self._update_properties(properties)
@@ -236,12 +237,14 @@ class AccessPointView(CanvasPulsingIcon):
pass
def _activate_cb(self, icon):
- info = { 'connection': { 'id' : 'Auto ' + self._name,
- 'uuid' : unique_id(),
- 'type' : '802-11-wireless' } ,
- '802-11-wireless' : { 'ssid': self._name }
- }
- conn = network.add_connection(info)
+ conn = network.find_connection(self._name)
+ if conn is None:
+ info = { 'connection': { 'id' : 'Auto ' + self._name,
+ 'uuid' : unique_id(),
+ 'type' : '802-11-wireless' } ,
+ '802-11-wireless' : { 'ssid': self._name }
+ }
+ conn = network.add_connection(self._name, info)
obj = self._bus.get_object(_NM_SERVICE, _NM_PATH)
netmgr = dbus.Interface(obj, _NM_IFACE)
diff --git a/src/jarabe/model/network.py b/src/jarabe/model/network.py
index f5e1796..f64ff08 100644
--- a/src/jarabe/model/network.py
+++ b/src/jarabe/model/network.py
@@ -44,25 +44,23 @@ NM_SECRETS_IFACE = 'org.freedesktop.NetworkManagerSettings.Connection.Secrets'
_nm_settings = None
class NMSettings(dbus.service.Object):
- connections = []
-
def __init__(self):
bus = dbus.SystemBus()
bus_name = dbus.service.BusName(SETTINGS_SERVICE, bus=bus)
dbus.service.Object.__init__(self, bus_name, NM_SETTINGS_PATH)
- connections = []
+ self.connections = {}
@dbus.service.method(dbus_interface=NM_SETTINGS_IFACE,
in_signature='', out_signature='ao')
def ListConnections(self):
- return self.connections
+ return self.connections.values()
@dbus.service.signal(NM_SETTINGS_IFACE, signature='o')
def NewConnection(self, connection_path):
pass
- def add_connection(self, conn):
- self.connections.append(conn)
+ def add_connection(self, ssid, conn):
+ self.connections[ssid] = conn
self.NewConnection(conn.path)
class NMSettingsConnection(dbus.service.Object):
@@ -94,13 +92,23 @@ class NMSettingsConnection(dbus.service.Object):
return self._secrets
-def add_connection(settings, secrets=None):
+def get_settings():
global _nm_settings
if _nm_settings is None:
_nm_settings = NMSettings()
+ return _nm_settings
+
+def find_connection(ssid):
+ connections = get_settings().connections
+ if ssid in connections:
+ return connections[ssid]
+ else:
+ return None
+
+def add_connection(ssid, settings, secrets=None):
conn = NMSettingsConnection(settings, secrets)
- _nm_settings.add_connection(conn)
+ _nm_settings.add_connection(ssid, conn)
return conn