2016-03-24 01:09:13 -07:00
|
|
|
// Copyright (C) 2016 The Syncthing Authors.
|
|
|
|
//
|
|
|
|
// This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
2017-02-08 23:52:18 -07:00
|
|
|
// You can obtain one at https://mozilla.org/MPL/2.0/.
|
2016-03-24 01:09:13 -07:00
|
|
|
|
2019-03-26 12:53:58 -07:00
|
|
|
package api
|
2016-03-24 01:09:13 -07:00
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/syncthing/syncthing/lib/config"
|
|
|
|
"github.com/syncthing/syncthing/lib/protocol"
|
2017-02-06 03:27:11 -07:00
|
|
|
"github.com/syncthing/syncthing/lib/util"
|
2016-03-24 01:09:13 -07:00
|
|
|
)
|
|
|
|
|
2016-04-18 13:24:38 -07:00
|
|
|
type mockedConfig struct {
|
|
|
|
gui config.GUIConfiguration
|
|
|
|
}
|
2016-03-24 01:09:13 -07:00
|
|
|
|
|
|
|
func (c *mockedConfig) GUI() config.GUIConfiguration {
|
2016-04-18 13:24:38 -07:00
|
|
|
return c.gui
|
2016-03-24 01:09:13 -07:00
|
|
|
}
|
|
|
|
|
2016-05-04 12:38:12 -07:00
|
|
|
func (c *mockedConfig) ListenAddresses() []string {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2018-09-11 14:25:24 -07:00
|
|
|
func (c *mockedConfig) LDAP() config.LDAPConfiguration {
|
|
|
|
return config.LDAPConfiguration{}
|
|
|
|
}
|
|
|
|
|
2016-11-12 02:34:18 -07:00
|
|
|
func (c *mockedConfig) RawCopy() config.Configuration {
|
2017-02-06 03:27:11 -07:00
|
|
|
cfg := config.Configuration{}
|
2019-02-02 04:16:27 -07:00
|
|
|
util.SetDefaults(&cfg.Options)
|
2017-02-06 03:27:11 -07:00
|
|
|
return cfg
|
2016-03-24 01:09:13 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
func (c *mockedConfig) Options() config.OptionsConfiguration {
|
|
|
|
return config.OptionsConfiguration{}
|
|
|
|
}
|
|
|
|
|
2017-12-07 00:08:24 -07:00
|
|
|
func (c *mockedConfig) Replace(cfg config.Configuration) (config.Waiter, error) {
|
2018-10-05 01:26:25 -07:00
|
|
|
return noopWaiter{}, nil
|
2016-03-24 01:09:13 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
func (c *mockedConfig) Subscribe(cm config.Committer) {}
|
|
|
|
|
2019-02-26 01:09:25 -07:00
|
|
|
func (c *mockedConfig) Unsubscribe(cm config.Committer) {}
|
|
|
|
|
2016-03-24 01:09:13 -07:00
|
|
|
func (c *mockedConfig) Folders() map[string]config.FolderConfiguration {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *mockedConfig) Devices() map[protocol.DeviceID]config.DeviceConfiguration {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2017-12-07 00:08:24 -07:00
|
|
|
func (c *mockedConfig) SetDevice(config.DeviceConfiguration) (config.Waiter, error) {
|
2018-10-05 01:26:25 -07:00
|
|
|
return noopWaiter{}, nil
|
2016-12-21 11:41:25 -07:00
|
|
|
}
|
|
|
|
|
2017-12-07 00:08:24 -07:00
|
|
|
func (c *mockedConfig) SetDevices([]config.DeviceConfiguration) (config.Waiter, error) {
|
2018-10-05 01:26:25 -07:00
|
|
|
return noopWaiter{}, nil
|
2017-03-04 00:54:13 -07:00
|
|
|
}
|
|
|
|
|
2016-03-24 01:09:13 -07:00
|
|
|
func (c *mockedConfig) Save() error {
|
|
|
|
return nil
|
|
|
|
}
|
2016-07-04 13:32:34 -07:00
|
|
|
|
|
|
|
func (c *mockedConfig) RequiresRestart() bool {
|
|
|
|
return false
|
|
|
|
}
|
2018-10-05 01:26:25 -07:00
|
|
|
|
2019-02-26 01:09:25 -07:00
|
|
|
func (c *mockedConfig) AddOrUpdatePendingDevice(device protocol.DeviceID, name, address string) {}
|
|
|
|
|
|
|
|
func (c *mockedConfig) AddOrUpdatePendingFolder(id, label string, device protocol.DeviceID) {}
|
|
|
|
|
|
|
|
func (m *mockedConfig) MyName() string {
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *mockedConfig) ConfigPath() string {
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *mockedConfig) SetGUI(gui config.GUIConfiguration) (config.Waiter, error) {
|
|
|
|
return noopWaiter{}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *mockedConfig) SetOptions(opts config.OptionsConfiguration) (config.Waiter, error) {
|
|
|
|
return noopWaiter{}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *mockedConfig) Folder(id string) (config.FolderConfiguration, bool) {
|
|
|
|
return config.FolderConfiguration{}, false
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *mockedConfig) FolderList() []config.FolderConfiguration {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *mockedConfig) SetFolder(fld config.FolderConfiguration) (config.Waiter, error) {
|
|
|
|
return noopWaiter{}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *mockedConfig) Device(id protocol.DeviceID) (config.DeviceConfiguration, bool) {
|
|
|
|
return config.DeviceConfiguration{}, false
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *mockedConfig) RemoveDevice(id protocol.DeviceID) (config.Waiter, error) {
|
|
|
|
return noopWaiter{}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *mockedConfig) IgnoredDevice(id protocol.DeviceID) bool {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *mockedConfig) IgnoredFolder(device protocol.DeviceID, folder string) bool {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *mockedConfig) GlobalDiscoveryServers() []string {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2018-10-05 01:26:25 -07:00
|
|
|
type noopWaiter struct{}
|
|
|
|
|
|
|
|
func (noopWaiter) Wait() {}
|