From 94be8f57f6c4fc51f0c76e3ce14d8e28a2bd9e45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20M=C3=BCller?= Date: Fri, 17 May 2019 15:18:13 +0200 Subject: [PATCH] Add NmActiveConnectionState --- ActiveConnection.go | 6 +++--- enums.go | 11 +++++++++++ nmactiveconnectionstate_string.go | 27 +++++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 3 deletions(-) create mode 100644 nmactiveconnectionstate_string.go diff --git a/ActiveConnection.go b/ActiveConnection.go index 82f44c2..3c9b5ec 100644 --- a/ActiveConnection.go +++ b/ActiveConnection.go @@ -46,7 +46,7 @@ type ActiveConnection interface { GetDevices() []Device // GetState gets the state of the connection. - GetState() uint32 + GetState() NmActiveConnectionState // GetStateFlags gets the state flags of the connection. GetStateFlags() uint32 @@ -119,8 +119,8 @@ func (a *activeConnection) GetDevices() []Device { return devices } -func (a *activeConnection) GetState() uint32 { - return a.getUint32Property(ActiveConnectionPropertyState) +func (a *activeConnection) GetState() NmActiveConnectionState { + return NmActiveConnectionState(a.getUint32Property(ActiveConnectionPropertyState)) } func (a *activeConnection) GetStateFlags() uint32 { diff --git a/enums.go b/enums.go index b7c60f3..9dea7b0 100644 --- a/enums.go +++ b/enums.go @@ -44,6 +44,17 @@ const ( NmDeviceStateFailed NmDeviceState = 120 ) +//go:generate stringer -type=NmActiveConnectionState +type NmActiveConnectionState uint32 + +const ( + NmActiveConnectionStateUnknown NmActiveConnectionState = 0 // The state of the connection is unknown + NmActiveConnectionStateActivating NmActiveConnectionState = 1 // A network connection is being prepared + NmActiveConnectionStateActivated NmActiveConnectionState = 2 // There is a connection to the network + NmActiveConnectionStateDeactivating NmActiveConnectionState = 3 // The network connection is being torn down and cleaned up + NmActiveConnectionStateDeactivated NmActiveConnectionState = 4 // The network connection is disconnected and will be removed +) + //go:generate stringer -type=NmDeviceType type NmDeviceType uint32 diff --git a/nmactiveconnectionstate_string.go b/nmactiveconnectionstate_string.go new file mode 100644 index 0000000..ad2e4ce --- /dev/null +++ b/nmactiveconnectionstate_string.go @@ -0,0 +1,27 @@ +// Code generated by "stringer -type=NmActiveConnectionState"; DO NOT EDIT. + +package gonetworkmanager + +import "strconv" + +func _() { + // An "invalid array index" compiler error signifies that the constant values have changed. + // Re-run the stringer command to generate them again. + var x [1]struct{} + _ = x[NmActiveConnectionStateUnknown-0] + _ = x[NmActiveConnectionStateActivating-1] + _ = x[NmActiveConnectionStateActivated-2] + _ = x[NmActiveConnectionStateDeactivating-3] + _ = x[NmActiveConnectionStateDeactivated-4] +} + +const _NmActiveConnectionState_name = "NmActiveConnectionStateUnknownNmActiveConnectionStateActivatingNmActiveConnectionStateActivatedNmActiveConnectionStateDeactivatingNmActiveConnectionStateDeactivated" + +var _NmActiveConnectionState_index = [...]uint8{0, 30, 63, 95, 130, 164} + +func (i NmActiveConnectionState) String() string { + if i >= NmActiveConnectionState(len(_NmActiveConnectionState_index)-1) { + return "NmActiveConnectionState(" + strconv.FormatInt(int64(i), 10) + ")" + } + return _NmActiveConnectionState_name[_NmActiveConnectionState_index[i]:_NmActiveConnectionState_index[i+1]] +}