Add NetworkManager.AdAndActivateConnection

This commit is contained in:
Christian Müller 2019-06-05 08:33:01 +02:00
parent 84f8864a22
commit cda635bea4

View file

@ -2,7 +2,6 @@ package gonetworkmanager
import ( import (
"encoding/json" "encoding/json"
"github.com/godbus/dbus" "github.com/godbus/dbus"
) )
@ -75,6 +74,9 @@ type NetworkManager interface {
// Activate a connection using the supplied device. // Activate a connection using the supplied device.
ActivateConnection(connection Connection, device Device) ActiveConnection ActivateConnection(connection Connection, device Device) ActiveConnection
// Adds a new connection using the given details (if any) as a template (automatically filling in missing settings with the capabilities of the given device), then activate the new connection. Cannot be used for VPN connections at this time.
AddAndActivateConnection(connection map[string]map[string]interface{}, device Device) (ac ActiveConnection, err error)
// ActivateWirelessConnection requests activating access point to network device // ActivateWirelessConnection requests activating access point to network device
ActivateWirelessConnection(connection Connection, device Device, accessPoint AccessPoint) ActiveConnection ActivateWirelessConnection(connection Connection, device Device, accessPoint AccessPoint) ActiveConnection
@ -175,6 +177,22 @@ func (n *networkManager) ActivateConnection(c Connection, d Device) ActiveConnec
return activeConnection return activeConnection
} }
func (n *networkManager) AddAndActivateConnection(connection map[string]map[string]interface{}, d Device) (ac ActiveConnection, err error) {
var opath1 dbus.ObjectPath
var opath2 dbus.ObjectPath
err = n.callWithReturn2(&opath1, &opath2, NetworkManagerAddAndActivateConnection, connection, d.GetPath())
if err != nil {
return
}
ac, err = NewActiveConnection(opath2)
if err != nil {
return
}
return
}
func (n *networkManager) ActivateWirelessConnection(c Connection, d Device, ap AccessPoint) ActiveConnection { func (n *networkManager) ActivateWirelessConnection(c Connection, d Device, ap AccessPoint) ActiveConnection {
var opath dbus.ObjectPath var opath dbus.ObjectPath
n.callWithReturnAndPanic(&opath, NetworkManagerActivateConnection, c.GetPath(), d.GetPath(), ap.GetPath()) n.callWithReturnAndPanic(&opath, NetworkManagerActivateConnection, c.GetPath(), d.GetPath(), ap.GetPath())