Add Settings.Hostname

This commit is contained in:
Christian Müller 2019-05-15 17:38:35 +02:00
parent a5d97dddcc
commit 517b97cad2

View file

@ -10,15 +10,23 @@ const (
SettingsListConnections = SettingsInterface + ".ListConnections" SettingsListConnections = SettingsInterface + ".ListConnections"
SettingsAddConnection = SettingsInterface + ".AddConnection" SettingsAddConnection = SettingsInterface + ".AddConnection"
SettingsSaveHostname = SettingsInterface + ".SaveHostname"
SettingsHostnameProperty = SettingsInterface + ".Hostname"
) )
type Settings interface { type Settings interface {
// ListConnections gets list the saved network connections known to NetworkManager // ListConnections gets list the saved network connections known to NetworkManager
ListConnections() []Connection ListConnections() []Connection
// AddConnection call new connection and save it to disk. // AddConnection callAndPanic new connection and save it to disk.
AddConnection(settings ConnectionSettings) Connection AddConnection(settings ConnectionSettings) Connection
// Save the hostname to persistent configuration.
SaveHostname(hostname string)
// The machine hostname stored in persistent configuration.
Hostname() string
} }
func NewSettings() (Settings, error) { func NewSettings() (Settings, error) {
@ -56,3 +64,16 @@ func (s *settings) AddConnection(settings ConnectionSettings) Connection {
} }
return con return con
} }
func (s *settings) SaveHostname(hostname string) {
err := s.call(SettingsSaveHostname, hostname)
if err != nil {
panic(err)
}
}
func (s *settings) Hostname() string {
hostname := s.getStringProperty(SettingsHostnameProperty)
return hostname
}