Add DeviceDummy
This commit is contained in:
parent
13310c5efe
commit
0e793812a6
2 changed files with 41 additions and 0 deletions
|
@ -51,6 +51,8 @@ func DeviceFactory(objectPath dbus.ObjectPath) (Device, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
switch d.GetDeviceType() {
|
switch d.GetDeviceType() {
|
||||||
|
case NmDeviceTypeDummy:
|
||||||
|
return NewDeviceDummy(objectPath)
|
||||||
case NmDeviceTypeWifi:
|
case NmDeviceTypeWifi:
|
||||||
return NewDeviceWireless(objectPath)
|
return NewDeviceWireless(objectPath)
|
||||||
}
|
}
|
||||||
|
|
39
DeviceDummy.go
Normal file
39
DeviceDummy.go
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
package gonetworkmanager
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
|
||||||
|
"github.com/godbus/dbus"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
DeviceDummyInterface = DeviceInterface + ".Dummy"
|
||||||
|
|
||||||
|
DeviceDummyPropertyHwAddress = DeviceDummyInterface + ".HwAddress" // readable s
|
||||||
|
)
|
||||||
|
|
||||||
|
type DeviceDummy interface {
|
||||||
|
Device
|
||||||
|
|
||||||
|
// Hardware address of the device.
|
||||||
|
GetHwAddress() string
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewDeviceDummy(objectPath dbus.ObjectPath) (DeviceDummy, error) {
|
||||||
|
var d deviceDummy
|
||||||
|
return &d, d.init(NetworkManagerInterface, objectPath)
|
||||||
|
}
|
||||||
|
|
||||||
|
type deviceDummy struct {
|
||||||
|
device
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *deviceDummy) GetHwAddress() string {
|
||||||
|
return d.getStringProperty(DeviceDummyPropertyHwAddress)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *deviceDummy) MarshalJSON() ([]byte, error) {
|
||||||
|
m := d.device.marshalMap()
|
||||||
|
m["HwAddress"] = d.GetHwAddress()
|
||||||
|
return json.Marshal(m)
|
||||||
|
}
|
Reference in a new issue