diff --git a/AccessPoint.go b/AccessPoint.go index 9381c6d..dd03b83 100644 --- a/AccessPoint.go +++ b/AccessPoint.go @@ -21,6 +21,8 @@ const ( ) type AccessPoint interface { + GetPath() dbus.ObjectPath + // GetFlags gets flags describing the capabilities of the access point. GetFlags() uint32 @@ -65,6 +67,10 @@ type accessPoint struct { dbusBase } +func (a *accessPoint) GetPath() dbus.ObjectPath { + return a.obj.Path() +} + func (a *accessPoint) GetFlags() uint32 { return a.getUint32Property(AccessPointPropertyFlags) } diff --git a/Connection.go b/Connection.go index 5f8c123..692def0 100644 --- a/Connection.go +++ b/Connection.go @@ -16,6 +16,8 @@ const ( type ConnectionSettings map[string]map[string]interface{} type Connection interface { + GetPath() dbus.ObjectPath + // GetSettings gets the settings maps describing this network configuration. // This will never include any secrets required for connection to the // network, as those are often protected. Secrets must be requested @@ -34,6 +36,10 @@ type connection struct { dbusBase } +func (c *connection) GetPath() dbus.ObjectPath { + return c.obj.Path() +} + func (c *connection) GetSettings() ConnectionSettings { var settings map[string]map[string]dbus.Variant c.call(&settings, ConnectionGetSettings) diff --git a/Device.go b/Device.go index a78e0ee..f257722 100644 --- a/Device.go +++ b/Device.go @@ -33,6 +33,8 @@ func DeviceFactory(objectPath dbus.ObjectPath) (Device, error) { } type Device interface { + GetPath() dbus.ObjectPath + // GetInterface gets the name of the device's control (and often data) // interface. GetInterface() string @@ -73,6 +75,10 @@ type device struct { dbusBase } +func (d *device) GetPath() dbus.ObjectPath { + return d.obj.Path() +} + func (d *device) GetInterface() string { return d.getStringProperty(DevicePropertyInterface) } diff --git a/NetworkManager.go b/NetworkManager.go index 7cd89ac..6457671 100644 --- a/NetworkManager.go +++ b/NetworkManager.go @@ -11,6 +11,7 @@ const ( NetworkManagerObjectPath = "/org/freedesktop/NetworkManager" NetworkManagerGetDevices = NetworkManagerInterface + ".GetDevices" + NetworkManagerActivateConnection = NetworkManagerInterface + ".ActivateConnection" NetworkManagerPropertyState = NetworkManagerInterface + ".State" NetworkManagerPropertyActiveConnection = NetworkManagerInterface + ".ActiveConnections" ) @@ -25,8 +26,12 @@ type NetworkManager interface { // management. GetState() NmState + // GetActiveConnections returns the active connection of network devices. GetActiveConnections() []ActiveConnection + // ActivateWirelessConnection requests activating access point to network device + ActivateWirelessConnection(connection Connection, device Device, accessPoint AccessPoint) ActiveConnection + Subscribe() <-chan *dbus.Signal Unsubscribe() @@ -80,6 +85,12 @@ func (n *networkManager) GetActiveConnections() []ActiveConnection { return ac } +func (n *networkManager) ActivateWirelessConnection(c Connection, d Device, ap AccessPoint) ActiveConnection { + var opath dbus.ObjectPath + n.call(&opath, NetworkManagerActivateConnection, c.GetPath(), d.GetPath(), ap.GetPath()) + return nil +} + func (n *networkManager) Subscribe() <-chan *dbus.Signal { if n.sigChan != nil { return n.sigChan diff --git a/WirelessDevice.go b/WirelessDevice.go index 00e729e..9c4adab 100644 --- a/WirelessDevice.go +++ b/WirelessDevice.go @@ -10,6 +10,7 @@ const ( WirelessDeviceInterface = DeviceInterface + ".Wireless" WirelessDeviceGetAccessPoints = WirelessDeviceInterface + ".GetAccessPoints" + WirelessDeviceRequestScan = WirelessDeviceInterface + ".RequestScan" ) type WirelessDevice interface { @@ -20,6 +21,8 @@ type WirelessDevice interface { // To retrieve a list of all access points (including hidden ones) use the // GetAllAccessPoints() method. GetAccessPoints() []AccessPoint + + RequestScan() } func NewWirelessDevice(objectPath dbus.ObjectPath) (WirelessDevice, error) { @@ -48,6 +51,11 @@ func (d *wirelessDevice) GetAccessPoints() []AccessPoint { return aps } +func (d *wirelessDevice) RequestScan() { + var options map[string]interface{} + d.obj.Call(WirelessDeviceRequestScan, 0, options).Store() +} + func (d *wirelessDevice) MarshalJSON() ([]byte, error) { m := d.device.marshalMap() m["AccessPoints"] = d.GetAccessPoints()