From 3eddf987a881fec167469091641723558afe58b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20M=C3=BCller?= Date: Thu, 16 May 2019 17:10:52 +0200 Subject: [PATCH] Add 1.16 Methods and Properties path definitions --- AccessPoint.go | 28 +++++++++++++----------- ActiveConnection.go | 44 ++++++++++++++++++++----------------- Connection.go | 15 ++++++++++++- Device.go | 46 ++++++++++++++++++++++++++++++--------- IP4Config.go | 18 +++++++++++---- NetworkManager.go | 53 +++++++++++++++++++++++++++++++++++++++------ Settings.go | 18 ++++++++++----- 7 files changed, 162 insertions(+), 60 deletions(-) diff --git a/AccessPoint.go b/AccessPoint.go index dd03b83..5851642 100644 --- a/AccessPoint.go +++ b/AccessPoint.go @@ -9,15 +9,17 @@ import ( const ( AccessPointInterface = NetworkManagerInterface + ".AccessPoint" - AccessPointPropertyFlags = AccessPointInterface + ".Flags" - AccessPointPropertyWPAFlags = AccessPointInterface + ".WpaFlags" - AccessPointPropertyRSNFlags = AccessPointInterface + ".RsnFlags" - AccessPointPropertySSID = AccessPointInterface + ".Ssid" - AccessPointPropertyFrequency = AccessPointInterface + ".Frequency" - AccessPointPropertyHWAddress = AccessPointInterface + ".HwAddress" - AccessPointPropertyMode = AccessPointInterface + ".Mode" - AccessPointPropertyMaxBitrate = AccessPointInterface + ".MaxBitrate" - AccessPointPropertyStrength = AccessPointInterface + ".Strength" + /* Property */ + AccessPointPropertyFlags = AccessPointInterface + ".Flags" // readable u + AccessPointPropertyWpaFlags = AccessPointInterface + ".WpaFlags" // readable u + AccessPointPropertyRsnFlags = AccessPointInterface + ".RsnFlags" // readable u + AccessPointPropertySsid = AccessPointInterface + ".Ssid" // readable ay + AccessPointPropertyFrequency = AccessPointInterface + ".Frequency" // readable u + AccessPointPropertyHwAddress = AccessPointInterface + ".HwAddress" // readable s + AccessPointPropertyMode = AccessPointInterface + ".Mode" // readable u + AccessPointPropertyMaxBitrate = AccessPointInterface + ".MaxBitrate" // readable u + AccessPointPropertyStrength = AccessPointInterface + ".Strength" // readable y + AccessPointPropertyLastSeen = AccessPointInterface + ".LastSeen" // readable i ) type AccessPoint interface { @@ -76,15 +78,15 @@ func (a *accessPoint) GetFlags() uint32 { } func (a *accessPoint) GetWPAFlags() uint32 { - return a.getUint32Property(AccessPointPropertyWPAFlags) + return a.getUint32Property(AccessPointPropertyWpaFlags) } func (a *accessPoint) GetRSNFlags() uint32 { - return a.getUint32Property(AccessPointPropertyRSNFlags) + return a.getUint32Property(AccessPointPropertyRsnFlags) } func (a *accessPoint) GetSSID() string { - return string(a.getSliceByteProperty(AccessPointPropertySSID)) + return string(a.getSliceByteProperty(AccessPointPropertySsid)) } func (a *accessPoint) GetFrequency() uint32 { @@ -92,7 +94,7 @@ func (a *accessPoint) GetFrequency() uint32 { } func (a *accessPoint) GetHWAddress() string { - return a.getStringProperty(AccessPointPropertyHWAddress) + return a.getStringProperty(AccessPointPropertyHwAddress) } func (a *accessPoint) GetMode() Nm80211Mode { diff --git a/ActiveConnection.go b/ActiveConnection.go index 2ec5d4d..0e3412f 100644 --- a/ActiveConnection.go +++ b/ActiveConnection.go @@ -5,21 +5,25 @@ import ( ) const ( - ActiveConnectionInterface = NetworkManagerInterface + ".Connection.Active" - ActiveConnectionProperyConnection = ActiveConnectionInterface + ".Connection" - ActiveConnectionProperySpecificObject = ActiveConnectionInterface + ".SpecificObject" - ActiveConnectionProperyID = ActiveConnectionInterface + ".Id" - ActiveConnectionProperyUUID = ActiveConnectionInterface + ".Uuid" - ActiveConnectionProperyType = ActiveConnectionInterface + ".Type" - ActiveConnectionProperyDevices = ActiveConnectionInterface + ".Devices" - ActiveConnectionProperyState = ActiveConnectionInterface + ".State" - ActiveConnectionProperyStateFlags = ActiveConnectionInterface + ".StateFlags" - ActiveConnectionProperyDefault = ActiveConnectionInterface + ".Default" - ActiveConnectionProperyIP4Config = ActiveConnectionInterface + ".Ip4Config" - ActiveConnectionProperyDHCP4Config = ActiveConnectionInterface + ".Dhcp4Config" - ActiveConnectionProperyDefault6 = ActiveConnectionInterface + ".Default6" - ActiveConnectionProperyVPN = ActiveConnectionInterface + ".Vpn" - ActiveConnectionProperyMaster = ActiveConnectionInterface + ".Master" + ActiveConnectionInterface = NetworkManagerInterface + ".Connection.Active" + + /* Property */ + ActiveConnectionProperyConnection = ActiveConnectionInterface + ".Connection" // readable o + ActiveConnectionProperySpecificObject = ActiveConnectionInterface + ".SpecificObject" // readable o + ActiveConnectionProperyId = ActiveConnectionInterface + ".Id" // readable s + ActiveConnectionProperyUuid = ActiveConnectionInterface + ".Uuid" // readable s + ActiveConnectionProperyType = ActiveConnectionInterface + ".Type" // readable s + ActiveConnectionProperyDevices = ActiveConnectionInterface + ".Devices" // readable ao + ActiveConnectionProperyState = ActiveConnectionInterface + ".State" // readable u + ActiveConnectionProperyStateFlags = ActiveConnectionInterface + ".StateFlags" // readable u + ActiveConnectionProperyDefault = ActiveConnectionInterface + ".Default" // readable b + ActiveConnectionProperyIp4Config = ActiveConnectionInterface + ".Ip4Config" // readable o + ActiveConnectionProperyDhcp4Config = ActiveConnectionInterface + ".Dhcp4Config" // readable o + ActiveConnectionProperyDefault6 = ActiveConnectionInterface + ".Default6" // readable b + ActiveConnectionProperyIp6Config = ActiveConnectionInterface + ".Ip6Config" // readable o + ActiveConnectionProperyDhcp6Config = ActiveConnectionInterface + ".Dhcp6Config" // readable o + ActiveConnectionProperyVpn = ActiveConnectionInterface + ".Vpn" // readable b + ActiveConnectionProperyMaster = ActiveConnectionInterface + ".Master" // readable o ) type ActiveConnection interface { @@ -91,11 +95,11 @@ func (a *activeConnection) GetSpecificObject() AccessPoint { } func (a *activeConnection) GetID() string { - return a.getStringProperty(ActiveConnectionProperyID) + return a.getStringProperty(ActiveConnectionProperyId) } func (a *activeConnection) GetUUID() string { - return a.getStringProperty(ActiveConnectionProperyUUID) + return a.getStringProperty(ActiveConnectionProperyUuid) } func (a *activeConnection) GetType() string { @@ -129,7 +133,7 @@ func (a *activeConnection) GetDefault() bool { } func (a *activeConnection) GetIP4Config() IP4Config { - path := a.getObjectProperty(ActiveConnectionProperyIP4Config) + path := a.getObjectProperty(ActiveConnectionProperyIp4Config) r, err := NewIP4Config(path) if err != nil { panic(err) @@ -138,7 +142,7 @@ func (a *activeConnection) GetIP4Config() IP4Config { } func (a *activeConnection) GetDHCP4Config() DHCP4Config { - path := a.getObjectProperty(ActiveConnectionProperyDHCP4Config) + path := a.getObjectProperty(ActiveConnectionProperyDhcp4Config) r, err := NewDHCP4Config(path) if err != nil { panic(err) @@ -147,7 +151,7 @@ func (a *activeConnection) GetDHCP4Config() DHCP4Config { } func (a *activeConnection) GetVPN() bool { - ret := a.getProperty(ActiveConnectionProperyVPN) + ret := a.getProperty(ActiveConnectionProperyVpn) return ret.(bool) } diff --git a/Connection.go b/Connection.go index cf8081a..896a51c 100644 --- a/Connection.go +++ b/Connection.go @@ -9,7 +9,20 @@ import ( const ( ConnectionInterface = SettingsInterface + ".Connection" - ConnectionGetSettings = ConnectionInterface + ".GetSettings" + /* Methods */ + ConnectionUpdate = ConnectionInterface + ".Update" + ConnectionUpdateUnsaved = ConnectionInterface + ".UpdateUnsaved" + ConnectionDelete = ConnectionInterface + ".Delete" + ConnectionGetSettings = ConnectionInterface + ".GetSettings" + ConnectionGetSecrets = ConnectionInterface + ".GetSecrets" + ConnectionClearSecrets = ConnectionInterface + ".ClearSecrets" + ConnectionSave = ConnectionInterface + ".Save" + ConnectionUpdate2 = ConnectionInterface + ".Update2" + + /* Properties */ + ConnectionPropertyUnsaved = ConnectionInterface + ".Unsaved" // readable b + ConnectionPropertyFlags = ConnectionInterface + ".Flags" // readable u + ConnectionPropertyFilename = ConnectionInterface + ".Filename" // readable s ) //type ConnectionSettings map[string]map[string]interface{} diff --git a/Device.go b/Device.go index 83a5ee3..1995c7c 100644 --- a/Device.go +++ b/Device.go @@ -9,15 +9,34 @@ import ( const ( DeviceInterface = NetworkManagerInterface + ".Device" - DevicePropertyUdi = DeviceInterface + ".Udi" - DevicePropertyInterface = DeviceInterface + ".Interface" - DevicePropertyIpInterface = DeviceInterface + ".IpInterface" - DevicePropertyState = DeviceInterface + ".State" - DevicePropertyManaged = DeviceInterface + ".Managed" - DevicePropertyIP4Config = DeviceInterface + ".Ip4Config" - DevicePropertyDeviceType = DeviceInterface + ".DeviceType" - DevicePropertyAvailableConnections = DeviceInterface + ".AvailableConnections" - DevicePropertyDhcp4Config = DeviceInterface + ".Dhcp4Config" + /* Properties */ + DevicePropertyUdi = DeviceInterface + ".Udi" // readable s + DevicePropertyInterface = DeviceInterface + ".Interface" // readable s + DevicePropertyIpInterface = DeviceInterface + ".IpInterface" // readable s + DevicePropertyDriver = DeviceInterface + ".Driver" // readable s + DevicePropertyDriverVersion = DeviceInterface + ".DriverVersion" // readable s + DevicePropertyFirmwareVersion = DeviceInterface + ".FirmwareVersion" // readable s + DevicePropertyCapabilities = DeviceInterface + ".Capabilities" // readable u + DevicePropertyIp4Address = DeviceInterface + ".Ip4Address" // readable u + DevicePropertyState = DeviceInterface + ".State" // readable u + DevicePropertyStateReason = DeviceInterface + ".StateReason" // readable (uu) + DevicePropertyActiveConnection = DeviceInterface + ".ActiveConnection" // readable o + DevicePropertyIp4Config = DeviceInterface + ".Ip4Config" // readable o + DevicePropertyDhcp4Config = DeviceInterface + ".Dhcp4Config" // readable o + DevicePropertyIp6Config = DeviceInterface + ".Ip6Config" // readable o + DevicePropertyDhcp6Config = DeviceInterface + ".Dhcp6Config" // readable o + DevicePropertyManaged = DeviceInterface + ".Managed" // readwrite b + DevicePropertyAutoconnect = DeviceInterface + ".Autoconnect" // readwrite b + DevicePropertyFirmwareMissing = DeviceInterface + ".FirmwareMissing" // readable b + DevicePropertyNmPluginMissing = DeviceInterface + ".NmPluginMissing" // readable b + DevicePropertyDeviceType = DeviceInterface + ".DeviceType" // readable u + DevicePropertyAvailableConnections = DeviceInterface + ".AvailableConnections" // readable ao + DevicePropertyPhysicalPortId = DeviceInterface + ".PhysicalPortId" // readable s + DevicePropertyMtu = DeviceInterface + ".Mtu" // readable u + DevicePropertyMetered = DeviceInterface + ".Metered" // readable u + DevicePropertyLldpNeighbors = DeviceInterface + ".LldpNeighbors" // readable aa{sv} + DevicePropertyReal = DeviceInterface + ".Real" // readable b + DevicePropertyIp4Connectivity = DeviceInterface + ".Ip4Connectivity" // readable u ) func DeviceFactory(objectPath dbus.ObjectPath) (Device, error) { @@ -84,6 +103,9 @@ type Device interface { // are not persistent and lost after NetworkManager restart. GetManaged() bool + // If TRUE, indicates the device is allowed to autoconnect. If FALSE, manual intervention is required before the device will automatically connect to a known network, such as activating a connection using the device, or setting this property to TRUE. This property cannot be set to TRUE for default-unmanaged devices, since they never autoconnect. + GetAutoConnect() bool + MarshalJSON() ([]byte, error) } @@ -117,7 +139,7 @@ func (d *device) GetState() NmDeviceState { } func (d *device) GetIP4Config() IP4Config { - path := d.getObjectProperty(DevicePropertyIP4Config) + path := d.getObjectProperty(DevicePropertyIp4Address) if path == "/" { return nil } @@ -167,6 +189,10 @@ func (d *device) GetManaged() bool { return d.getBoolProperty(DevicePropertyManaged) } +func (d *device) GetAutoConnect() bool { + return d.getBoolProperty(DevicePropertyAutoconnect) +} + func (d *device) marshalMap() map[string]interface{} { return map[string]interface{}{ "Interface": d.GetInterface(), diff --git a/IP4Config.go b/IP4Config.go index e265b74..b932b4b 100644 --- a/IP4Config.go +++ b/IP4Config.go @@ -9,10 +9,20 @@ import ( const ( IP4ConfigInterface = NetworkManagerInterface + ".IP4Config" - IP4ConfigPropertyAddresses = IP4ConfigInterface + ".Addresses" - IP4ConfigPropertyRoutes = IP4ConfigInterface + ".Routes" - IP4ConfigPropertyNameservers = IP4ConfigInterface + ".Nameservers" - IP4ConfigPropertyDomains = IP4ConfigInterface + ".Domains" + /* Properties */ + IP4ConfigPropertyAddresses = IP4ConfigInterface + ".Addresses" // readable aau + IP4ConfigPropertyAddressData = IP4ConfigInterface + ".AddressData" // readable aa{sv} + IP4ConfigPropertyGateway = IP4ConfigInterface + ".Gateway" // readable s + IP4ConfigPropertyRoutes = IP4ConfigInterface + ".Routes" // readable aau + IP4ConfigPropertyRouteData = IP4ConfigInterface + ".RouteData" // readable aa{sv} + IP4ConfigPropertyNameservers = IP4ConfigInterface + ".Nameservers" // readable au + IP4ConfigPropertyNameserverData = IP4ConfigInterface + ".NameserverData" // readable aa{sv} + IP4ConfigPropertyDomains = IP4ConfigInterface + ".Domains" // readable as + IP4ConfigPropertySearches = IP4ConfigInterface + ".Searches" // readable as + IP4ConfigPropertyDnsOptions = IP4ConfigInterface + ".DnsOptions" // readable as + IP4ConfigPropertyDnsPriority = IP4ConfigInterface + ".DnsPriority" // readable i + IP4ConfigPropertyWinsServers = IP4ConfigInterface + ".WinsServers" // readable au + IP4ConfigPropertyWinsServerData = IP4ConfigInterface + ".WinsServerData" // readable as ) type IP4Address struct { diff --git a/NetworkManager.go b/NetworkManager.go index bcb4a3f..34a657f 100644 --- a/NetworkManager.go +++ b/NetworkManager.go @@ -10,12 +10,51 @@ const ( NetworkManagerInterface = "org.freedesktop.NetworkManager" NetworkManagerObjectPath = "/org/freedesktop/NetworkManager" - NetworkManagerGetDevices = NetworkManagerInterface + ".GetDevices" - NetworkManagerGetAllDevices = NetworkManagerInterface + ".GetAllDevices" - NetworkManagerActivateConnection = NetworkManagerInterface + ".ActivateConnection" - NetworkManagerAddAndActivateConnection = NetworkManagerInterface + ".AddAndActivateConnection" - NetworkManagerPropertyState = NetworkManagerInterface + ".State" - NetworkManagerPropertyActiveConnection = NetworkManagerInterface + ".ActiveConnections" + /* Methods */ + NetworkManagerReload = NetworkManagerInterface + ".Reload" + NetworkManagerGetDevices = NetworkManagerInterface + ".GetDevices" + NetworkManagerGetAllDevices = NetworkManagerInterface + ".GetAllDevices" + NetworkManagerGetDeviceByIpIface = NetworkManagerInterface + ".GetDeviceByIpIface" + NetworkManagerActivateConnection = NetworkManagerInterface + ".ActivateConnection" + NetworkManagerAddAndActivateConnection = NetworkManagerInterface + ".AddAndActivateConnection" + NetworkManagerAddAndActivateConnection2 = NetworkManagerInterface + ".AddAndActivateConnection2" + NetworkManagerDeactivateConnection = NetworkManagerInterface + ".DeactivateConnection" + NetworkManagerSleep = NetworkManagerInterface + ".Sleep" + NetworkManagerEnable = NetworkManagerInterface + ".Enable" + NetworkManagerGetPermissions = NetworkManagerInterface + ".GetPermissions" + NetworkManagerSetLogging = NetworkManagerInterface + ".SetLogging" + NetworkManagerGetLogging = NetworkManagerInterface + ".GetLogging" + NetworkManagerCheckConnectivity = NetworkManagerInterface + ".CheckConnectivity" + NetworkManagerstate = NetworkManagerInterface + ".state" + NetworkManagerCheckpointCreate = NetworkManagerInterface + ".CheckpointCreate" + NetworkManagerCheckpointDestroy = NetworkManagerInterface + ".CheckpointDestroy" + NetworkManagerCheckpointRollback = NetworkManagerInterface + ".CheckpointRollback" + NetworkManagerCheckpointAdjustRollbackTimeout = NetworkManagerInterface + ".CheckpointAdjustRollbackTimeout" + + /* Property */ + NetworkManagerPropertyDevices = NetworkManagerInterface + ".Devices" // readable ao + NetworkManagerPropertyAllDevices = NetworkManagerInterface + ".AllDevices" // readable ao + NetworkManagerPropertyCheckpoints = NetworkManagerInterface + ".Checkpoints" // readable ao + NetworkManagerPropertyNetworkingEnabled = NetworkManagerInterface + ".NetworkingEnabled" // readable b + NetworkManagerPropertyWirelessEnabled = NetworkManagerInterface + ".WirelessEnabled" // readwrite b + NetworkManagerPropertyWirelessHardwareEnabled = NetworkManagerInterface + ".WirelessHardwareEnabled" // readable b + NetworkManagerPropertyWwanEnabled = NetworkManagerInterface + ".WwanEnabled" // readwrite b + NetworkManagerPropertyWwanHardwareEnabled = NetworkManagerInterface + ".WwanHardwareEnabled" // readable b + NetworkManagerPropertyWimaxEnabled = NetworkManagerInterface + ".WimaxEnabled" // readwrite b + NetworkManagerPropertyWimaxHardwareEnabled = NetworkManagerInterface + ".WimaxHardwareEnabled" // readable b + NetworkManagerPropertyActiveConnections = NetworkManagerInterface + ".ActiveConnections" // readable ao + NetworkManagerPropertyPrimaryConnection = NetworkManagerInterface + ".PrimaryConnection" // readable o + NetworkManagerPropertyPrimaryConnectionType = NetworkManagerInterface + ".PrimaryConnectionType" // readable s + NetworkManagerPropertyMetered = NetworkManagerInterface + ".Metered" // readable u + NetworkManagerPropertyActivatingConnection = NetworkManagerInterface + ".ActivatingConnection" // readable o + NetworkManagerPropertyStartup = NetworkManagerInterface + ".Startup" // readable b + NetworkManagerPropertyVersion = NetworkManagerInterface + ".Version" // readable s + NetworkManagerPropertyCapabilities = NetworkManagerInterface + ".Capabilities" // readable au + NetworkManagerPropertyState = NetworkManagerInterface + ".State" // readable u + NetworkManagerPropertyConnectivity = NetworkManagerInterface + ".Connectivity" // readable u + NetworkManagerPropertyConnectivityCheckAvailable = NetworkManagerInterface + ".ConnectivityCheckAvailable" // readable b + NetworkManagerPropertyConnectivityCheckEnabled = NetworkManagerInterface + ".ConnectivityCheckEnabled" // readwrite b + NetworkManagerPropertyGlobalDnsConfiguration = NetworkManagerInterface + ".GlobalDnsConfiguration" // readwrite a{sv} ) type NetworkManager interface { @@ -104,7 +143,7 @@ func (n *networkManager) GetState() NmState { } func (n *networkManager) GetActiveConnections() []ActiveConnection { - acPaths := n.getSliceObjectProperty(NetworkManagerPropertyActiveConnection) + acPaths := n.getSliceObjectProperty(NetworkManagerPropertyActiveConnections) ac := make([]ActiveConnection, len(acPaths)) var err error diff --git a/Settings.go b/Settings.go index 8972c69..44b8d24 100644 --- a/Settings.go +++ b/Settings.go @@ -8,11 +8,19 @@ const ( SettingsInterface = NetworkManagerInterface + ".Settings" SettingsObjectPath = NetworkManagerObjectPath + "/Settings" - SettingsListConnections = SettingsInterface + ".ListConnections" - SettingsAddConnection = SettingsInterface + ".AddConnection" - SettingsSaveHostname = SettingsInterface + ".SaveHostname" + /* Methods */ + SettingsListConnections = SettingsInterface + ".ListConnections" + SettingsGetConnectionByUuid = SettingsInterface + ".GetConnectionByUuid" + SettingsAddConnection = SettingsInterface + ".AddConnection" + SettingsAddConnectionUnsaved = SettingsInterface + ".AddConnectionUnsaved" + SettingsLoadConnections = SettingsInterface + ".LoadConnections" + SettingsReloadConnections = SettingsInterface + ".ReloadConnections" + SettingsSaveHostname = SettingsInterface + ".SaveHostname" - SettingsHostnameProperty = SettingsInterface + ".Hostname" + /* Properties */ + SettingsPropertyConnections = SettingsInterface + "Connections" // readable ao + SettingsPropertyHostname = SettingsInterface + "Hostname" // readable s + SettingsPropertyCanModify = SettingsInterface + "CanModify" // readable b ) type Settings interface { @@ -73,7 +81,7 @@ func (s *settings) SaveHostname(hostname string) { } func (s *settings) Hostname() string { - hostname := s.getStringProperty(SettingsHostnameProperty) + hostname := s.getStringProperty(SettingsPropertyHostname) return hostname }