Adding settings properties and methods

This commit is contained in:
Christian Müller 2019-05-29 08:30:44 +02:00
parent 4e0c045d1d
commit ca7c1e2942

View file

@ -30,9 +30,15 @@ type Settings interface {
// AddConnection callWithReturnAndPanic new connection and save it to disk. // AddConnection callWithReturnAndPanic new connection and save it to disk.
AddConnection(settings ConnectionSettings) Connection 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. // Save the hostname to persistent configuration.
SaveHostname(hostname string) SaveHostname(hostname string)
// If true, adding and modifying connections is supported.
CanModify() bool
// The machine hostname stored in persistent configuration. // The machine hostname stored in persistent configuration.
Hostname() string Hostname() string
} }
@ -73,6 +79,16 @@ func (s *settings) AddConnection(settings ConnectionSettings) Connection {
return con 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) { func (s *settings) SaveHostname(hostname string) {
err := s.call(SettingsSaveHostname, hostname) err := s.call(SettingsSaveHostname, hostname)
if err != nil { if err != nil {
@ -85,3 +101,7 @@ func (s *settings) Hostname() string {
return hostname return hostname
} }
func (s *settings) CanModify() bool {
return s.getBoolProperty(SettingsPropertyCanModify)
}