forked from BellerophonMobile/gonetworkmanager
-
Notifications
You must be signed in to change notification settings - Fork 47
Expand file tree
/
Copy pathDeviceGeneric.go
More file actions
45 lines (34 loc) · 1.02 KB
/
DeviceGeneric.go
File metadata and controls
45 lines (34 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package gonetworkmanager
import (
"encoding/json"
"github.com/godbus/dbus/v5"
)
const (
DeviceGenericInterface = DeviceInterface + ".Generic"
// Properties
DeviceGenericPropertyTypeDescription = DeviceGenericInterface + ".TypeDescription" // readable s
)
type DeviceGeneric interface {
Device
// GetPropertyTypeDescription A (non-localized) description of the interface type, if known.
GetPropertyTypeDescription() (string, error)
}
func NewDeviceGeneric(objectPath dbus.ObjectPath) (DeviceGeneric, error) {
var d deviceGeneric
return &d, d.init(NetworkManagerInterface, objectPath)
}
type deviceGeneric struct {
device
}
func (d *deviceGeneric) GetPropertyTypeDescription() (string, error) {
return d.getStringProperty(DeviceGenericPropertyTypeDescription)
}
func (d *deviceGeneric) MarshalJSON() ([]byte, error) {
m, err := d.device.marshalMap()
if err != nil {
return nil, err
}
m["HwAddress"], _ = d.GetPropertyHwAddress()
m["TypeDescription"], _ = d.GetPropertyTypeDescription()
return json.Marshal(m)
}