blob: a286bf846f09941394f0de0fa10092afd152d771 [file] [log] [blame]
Vitaly Buka1175a9b2015-08-15 10:42:17 -07001// Copyright 2015 The Chromium OS Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef BUFFET_BUFFET_CONFIG_H_
6#define BUFFET_BUFFET_CONFIG_H_
7
Vitaly Bukabecd4612015-08-16 23:31:55 -07008#include <map>
Vitaly Buka1175a9b2015-08-15 10:42:17 -07009#include <set>
10#include <string>
11#include <vector>
12
13#include <base/callback.h>
14#include <base/files/file_path.h>
15#include <chromeos/key_value_store.h>
Alex Vakulenkoe32375b2015-09-28 08:55:40 -070016#include <weave/provider/config_store.h>
Vitaly Buka1175a9b2015-08-15 10:42:17 -070017
18namespace buffet {
19
20class StorageInterface;
21
22// Handles reading buffet config and state files.
Alex Vakulenkoe32375b2015-09-28 08:55:40 -070023class BuffetConfig final : public weave::provider::ConfigStore {
Vitaly Buka1175a9b2015-08-15 10:42:17 -070024 public:
Alex Vakulenko0022b752015-10-02 11:09:59 -070025 struct Options {
Alex Vakulenko2915a7b2015-10-07 17:04:00 -070026 std::string client_id;
27 std::string client_secret;
28 std::string api_key;
29 std::string oauth_url;
30 std::string service_url;
31
Alex Vakulenko0022b752015-10-02 11:09:59 -070032 base::FilePath defaults;
33 base::FilePath settings;
34
35 base::FilePath definitions;
36 base::FilePath test_definitions;
37
38 bool disable_security{false};
39 std::string test_privet_ssid;
40 };
41
Vitaly Buka1175a9b2015-08-15 10:42:17 -070042 ~BuffetConfig() override = default;
43
Alex Vakulenko0022b752015-10-02 11:09:59 -070044 explicit BuffetConfig(const Options& options);
Vitaly Buka1175a9b2015-08-15 10:42:17 -070045
46 // Config overrides.
47 bool LoadDefaults(weave::Settings* settings) override;
48 std::string LoadSettings() override;
49 void SaveSettings(const std::string& settings) override;
Vitaly Buka1175a9b2015-08-15 10:42:17 -070050
Vitaly Buka1175a9b2015-08-15 10:42:17 -070051 bool LoadDefaults(const chromeos::KeyValueStore& store,
52 weave::Settings* settings);
53
54 private:
Alex Vakulenko0022b752015-10-02 11:09:59 -070055 Options options_;
Vitaly Buka1175a9b2015-08-15 10:42:17 -070056
57 DISALLOW_COPY_AND_ASSIGN(BuffetConfig);
58};
59
60} // namespace buffet
61
62#endif // BUFFET_BUFFET_CONFIG_H_