Cleaned up namespace: networkmanager.applet.
[cnetworkmanager.git] / networkmanager / activeconnection.py
blob8c453bcc596c6854036dd1d4eb989865bd22f324
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 OPATH = "/org/freedesktop/NetworkManager"
30 IFACE = "org.freedesktop.NetworkManager.Connection.Active"
32 def __init__(self, opath):
33 super(ActiveConnection, self).__init__(dbus.SystemBus(), self.SERVICE, opath, default_interface=self.IFACE)
35 class State(Enum):
36 UNKNOWN = 0
37 ACTIVATING = 1
38 ACTIVATED = 2
40 def __getitem__(self, key):
41 "Implement Connection by adding the required ServiceName"
43 v = super(ActiveConnection, self).__getitem__(key)
44 if key == "Connection":
45 sn = self.__getitem__("ServiceName")
46 v = Connection(sn, v)
47 return v
49 ActiveConnection._add_adaptors(
50 signals = {
51 # "PropertiesChanged": [void, [identity]],
53 properties = {
54 # "ServiceName": identity,
55 # "Connection": Connection, # implemented in __getitem__
56 "SpecificObject": AccessPoint, #in most cases. figure out.
57 "Devices": seq_adaptor(Device._create),
58 "State": ActiveConnection.State,
59 "Default": bool,