Provisionally implement -n as -a.
[cnetworkmanager.git] / svc_settings.py
blobaf56e82834ba89259e2e22634b9bd980c14515c5
1 import dbus
2 import dbus.service
3 from svc_connection import Connection
5 # server analog of cApplet
6 class UserSettings(dbus.service.Object):
7 # conmaps is a list
8 def __init__(self, opath, conmaps):
9 bus = dbus.SystemBus()
10 dbus.service.Object.__init__(self, bus, opath)
11 #print "CONMAPS:", conmaps
12 self.conns = map(self.newCon, conmaps)
14 def addCon(self, conmap):
15 c = self.newCon(conmap)
16 self.conns.append(c)
17 return c
19 counter = 1
20 def newCon(self, conmap):
21 cpath = "/MyConnection/%d" % self.counter
22 self.counter = self.counter + 1
23 c = Connection(cpath, conmap)
24 self.NewConnection(cpath) # announce it
25 return c
27 @dbus.service.method(dbus_interface='org.freedesktop.NetworkManagerSettings',
28 in_signature='', out_signature='ao')
29 def ListConnections(self):
30 return [c.__dbus_object_path__ for c in self.conns]
32 #this is for EMITTING a signal, not receiving it
33 @dbus.service.signal(dbus_interface='org.freedesktop.NetworkManagerSettings',
34 signature='o')
35 def NewConnection(self, opath):
36 pass
37 #print "signalling newconn:", opath
39 def GetByNet(self, net_name):
40 "Returns connection, or None"
41 for c in self.conns:
42 if c.isNet(net_name):
43 return c
44 return None