From ca7c1e2942e41d15e3107040ebbc5ec7105bd662 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20M=C3=BCller?= Date: Wed, 29 May 2019 08:30:44 +0200 Subject: [PATCH] Adding settings properties and methods --- Settings.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Settings.go b/Settings.go index 2d94ec1..7e1e8e6 100644 --- a/Settings.go +++ b/Settings.go @@ -30,9 +30,15 @@ type Settings interface { // AddConnection callWithReturnAndPanic new connection and save it to disk. AddConnection(settings ConnectionSettings) Connection + // Add new connection but do not save it to disk immediately. This operation does not start the network connection unless (1) device is idle and able to connect to the network described by the new connection, and (2) the connection is allowed to be started automatically. Use the 'Save' method on the connection to save these changes to disk. Note that unsaved changes will be lost if the connection is reloaded from disk (either automatically on file change or due to an explicit ReloadConnections call). + AddConnectionUnsaved(settings ConnectionSettings) Connection + // Save the hostname to persistent configuration. SaveHostname(hostname string) + // If true, adding and modifying connections is supported. + CanModify() bool + // The machine hostname stored in persistent configuration. Hostname() string } @@ -73,6 +79,16 @@ func (s *settings) AddConnection(settings ConnectionSettings) Connection { return con } +func (s *settings) AddConnectionUnsaved(settings ConnectionSettings) Connection { + var path dbus.ObjectPath + s.callWithReturnAndPanic(&path, SettingsAddConnectionUnsaved, settings) + con, err := NewConnection(path) + if err != nil { + panic(err) + } + return con +} + func (s *settings) SaveHostname(hostname string) { err := s.call(SettingsSaveHostname, hostname) if err != nil { @@ -85,3 +101,7 @@ func (s *settings) Hostname() string { return hostname } + +func (s *settings) CanModify() bool { + return s.getBoolProperty(SettingsPropertyCanModify) +}