Do properties in DBusMio.
[cnetworkmanager.git] / networkmanager / networkmanager.py
bloba1c5aa74e845196844acd9891cc2323c406dba49
1 # -*- coding: utf-8 -*-
3 import dbus
4 from dbusclient import DBusClient, object_path
5 from device import Device
6 from util import Enum
7 from func import *
9 # need better/shorter names? or hide them?
10 SYSTEM_SERVICE = "org.freedesktop.NetworkManagerSystemSettings"
11 USER_SERVICE = "org.freedesktop.NetworkManagerUserSettings"
13 class NetworkManager(DBusClient):
14 """networkmanager
16 The NM client library
18 Methods:
19 GetDevices ( ) → ao
20 ActivateConnection ( s: service_name, o: connection, o: device, o: specific_object ) → o
21 DeactivateConnection ( o: active_connection ) → nothing
22 Sleep ( b: sleep ) → nothing
24 Signals:
25 StateChanged ( u: state )
26 PropertiesChanged ( a{sv}: properties )
27 DeviceAdded ( o: device_path )
28 DeviceRemoved ( o: device_path )
30 Properties:
31 WirelessEnabled - b - (readwrite)
32 WirelessHardwareEnabled - b - (read)
33 ActiveConnections - ao - (read)
34 State - u - (read) (NM_STATE)
36 Enumerated types:
37 NM_STATE
38 """
40 SERVICE = "org.freedesktop.NetworkManager"
41 OPATH = "/org/freedesktop/NetworkManager"
42 IFACE = "org.freedesktop.NetworkManager"
44 def __init__(self):
45 super(NetworkManager, self).__init__(dbus.SystemBus(), self.SERVICE, self.OPATH, default_interface=self.IFACE)
48 class State(Enum):
49 UNKNOWN = 0
50 ASLEEP = 1
51 CONNECTING = 2
52 CONNECTED = 3
53 DISCONNECTED = 4
55 "TODO find a good term for 'adaptor'"
56 _adaptors = {
57 "methods": {
58 "GetDevices": seq_adaptor(Device._create),
59 "ActivateConnection": (identity, [identity, object_path, object_path, object_path], {}),
60 "DeactivateConnection": (identity, [object_path], {})
62 "properties": {
63 "State": State,
64 "WirelessEnabled": bool,
65 "WirelessHardwareEnabled": bool,
66 "ActiveConnections": seq_adaptor(identity), # TODO
68 "signals": {
69 "StateChanged": (identity, [State], {}),