Add NetworkManager.GetAllDevices
This commit is contained in:
parent
3400f94b66
commit
ab586e0f32
1 changed files with 22 additions and 2 deletions
|
@ -11,6 +11,7 @@ const (
|
||||||
NetworkManagerObjectPath = "/org/freedesktop/NetworkManager"
|
NetworkManagerObjectPath = "/org/freedesktop/NetworkManager"
|
||||||
|
|
||||||
NetworkManagerGetDevices = NetworkManagerInterface + ".GetDevices"
|
NetworkManagerGetDevices = NetworkManagerInterface + ".GetDevices"
|
||||||
|
NetworkManagerGetAllDevices = NetworkManagerInterface + ".GetAllDevices"
|
||||||
NetworkManagerActivateConnection = NetworkManagerInterface + ".ActivateConnection"
|
NetworkManagerActivateConnection = NetworkManagerInterface + ".ActivateConnection"
|
||||||
NetworkManagerAddAndActivateConnection = NetworkManagerInterface + ".AddAndActivateConnection"
|
NetworkManagerAddAndActivateConnection = NetworkManagerInterface + ".AddAndActivateConnection"
|
||||||
NetworkManagerPropertyState = NetworkManagerInterface + ".State"
|
NetworkManagerPropertyState = NetworkManagerInterface + ".State"
|
||||||
|
@ -18,10 +19,12 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
type NetworkManager interface {
|
type NetworkManager interface {
|
||||||
|
// Get the list of realized network devices.
|
||||||
// GetDevices gets the list of network devices.
|
|
||||||
GetDevices() []Device
|
GetDevices() []Device
|
||||||
|
|
||||||
|
// Get the list of all network devices.
|
||||||
|
GetAllDevices() []Device
|
||||||
|
|
||||||
// GetState returns the overall networking state as determined by the
|
// GetState returns the overall networking state as determined by the
|
||||||
// NetworkManager daemon, based on the state of network devices under it's
|
// NetworkManager daemon, based on the state of network devices under it's
|
||||||
// management.
|
// management.
|
||||||
|
@ -79,6 +82,23 @@ func (n *networkManager) GetDevices() []Device {
|
||||||
return devices
|
return devices
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (n *networkManager) GetAllDevices() []Device {
|
||||||
|
var devicePaths []dbus.ObjectPath
|
||||||
|
|
||||||
|
n.call(&devicePaths, NetworkManagerGetAllDevices)
|
||||||
|
devices := make([]Device, len(devicePaths))
|
||||||
|
|
||||||
|
var err error
|
||||||
|
for i, path := range devicePaths {
|
||||||
|
devices[i], err = DeviceFactory(path)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return devices
|
||||||
|
}
|
||||||
|
|
||||||
func (n *networkManager) GetState() NmState {
|
func (n *networkManager) GetState() NmState {
|
||||||
return NmState(n.getUint32Property(NetworkManagerPropertyState))
|
return NmState(n.getUint32Property(NetworkManagerPropertyState))
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue