Screenshots to show off (in HTML).
[cnetworkmanager.git] / networkmanager / networkmanager.py
blobffa721d949530f58c05ca00a259c3e87dca3be68
1 # -*- coding: utf-8 -*-
3 import dbus
4 from dbusclient import DBusClient, object_path
5 from dbusclient.func import *
6 from device import Device
7 from activeconnection import ActiveConnection
8 from util import Enum
10 # gratuitous convertor to test writable properties
11 def english_to_bool(v):
12 if v == "yes":
13 return True
14 elif v == "no":
15 return False
16 return v
18 class NetworkManager(DBusClient):
19 """networkmanager
21 The NM client library
23 Methods:
24 GetDevices ( ) → ao
25 ActivateConnection ( s: service_name, o: connection, o: device, o: specific_object ) → o
26 DeactivateConnection ( o: active_connection ) → nothing
27 Sleep ( b: sleep ) → nothing
29 Signals:
30 StateChanged ( u: state )
31 PropertiesChanged ( a{sv}: properties )
32 DeviceAdded ( o: device_path )
33 DeviceRemoved ( o: device_path )
35 Properties:
36 WirelessEnabled - b - (readwrite)
37 WirelessHardwareEnabled - b - (read)
38 ActiveConnections - ao - (read)
39 State - u - (read) (NM_STATE)
41 Enumerated types:
42 NM_STATE
43 """
45 SERVICE = "org.freedesktop.NetworkManager"
46 OPATH = "/org/freedesktop/NetworkManager"
47 IFACE = "org.freedesktop.NetworkManager"
49 def __init__(self):
50 super(NetworkManager, self).__init__(dbus.SystemBus(), self.SERVICE, self.OPATH, default_interface=self.IFACE)
53 class State(Enum):
54 UNKNOWN = 0
55 ASLEEP = 1
56 CONNECTING = 2
57 CONNECTED = 3
58 DISCONNECTED = 4
60 "TODO find a good term for 'adaptor'"
62 #from dbusclient.adaptors import *
64 NetworkManager._add_adaptors(
65 GetDevices = MA(seq_adaptor(Device._create)),
66 ActivateConnection = MA(ActiveConnection, identity, object_path, object_path, object_path),
67 DeactivateConnection = MA(void, object_path),
69 State = PA(NetworkManager.State),
70 WirelessEnabled = PA(bool, english_to_bool),
71 WirelessHardwareEnabled = PA(bool),
72 ActiveConnections = PA(seq_adaptor(ActiveConnection)),
74 StateChanged = SA(NetworkManager.State),