small cleanup
[cnetworkmanager.git] / networkmanager / activeconnection.py
blobc01b9ccd6b90303451097afc3ab2e323e63fc4c5
1 # -*- coding: utf-8 -*-
3 import dbus
4 from dbusclient import DBusClient, object_path
5 from dbusclient.func import *
6 from applet import Connection
7 from device import Device
8 from accesspoint import AccessPoint
9 from util import Enum
11 class ActiveConnection(DBusClient):
12 """
13 Signals:
14 PropertiesChanged ( a{sv}: properties )
16 Properties:
17 ServiceName - s - (read)
18 Connection - o - (read)
19 SpecificObject - o - (read)
20 Devices - ao - (read)
21 State - u - (read) (NM_ACTIVE_CONNECTION_STATE)
22 Default - b - (read)
24 Enumerated types:
25 NM_ACTIVE_CONNECTION_STATE
26 """
28 SERVICE = "org.freedesktop.NetworkManager"
29 IFACE = "org.freedesktop.NetworkManager.Connection.Active"
31 def __init__(self, opath):
32 super(ActiveConnection, self).__init__(dbus.SystemBus(), self.SERVICE, opath, default_interface=self.IFACE)
34 class State(Enum):
35 UNKNOWN = 0
36 ACTIVATING = 1
37 ACTIVATED = 2
39 def __getitem__(self, key):
40 "Implement Connection by adding the required ServiceName"
42 v = super(ActiveConnection, self).__getitem__(key)
43 if key == "Connection":
44 sn = self.__getitem__("ServiceName")
45 v = Connection(sn, v)
46 return v
48 ActiveConnection._add_adaptors(
49 PropertiesChanged = SA(identity),
50 # ServiceName = PA(identity),
51 # Connection = PA(Connection), # implemented in __getitem__
52 SpecificObject = PA(AccessPoint), #in most cases. figure out.
53 Devices = PA(seq_adaptor(Device._create)),
54 State = PA(ActiveConnection.State),
55 Default = PA(bool),