Vitaly Buka | 4615e0d | 2015-10-14 15:35:12 -0700 | [diff] [blame] | 1 | // Copyright 2015 The Weave Authors. All rights reserved. |
Vitaly Buka | 0fa51e5 | 2015-07-10 00:12:25 -0700 | [diff] [blame] | 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 LIBWEAVE_SRC_DEVICE_MANAGER_H_ |
| 6 | #define LIBWEAVE_SRC_DEVICE_MANAGER_H_ |
| 7 | |
Vitaly Buka | 8b4ab96 | 2015-07-14 19:19:39 -0700 | [diff] [blame] | 8 | #include <base/memory/weak_ptr.h> |
Vitaly Buka | 7b382ac | 2015-08-03 13:50:01 -0700 | [diff] [blame] | 9 | #include <weave/device.h> |
Vitaly Buka | 0fa51e5 | 2015-07-10 00:12:25 -0700 | [diff] [blame] | 10 | |
Vitaly Buka | 0fa51e5 | 2015-07-10 00:12:25 -0700 | [diff] [blame] | 11 | namespace weave { |
| 12 | |
Vitaly Buka | 5a7c4f5 | 2016-01-21 15:09:34 -0800 | [diff] [blame] | 13 | class AccessApiHandler; |
Vitaly Buka | ebde3c1 | 2016-02-23 18:50:42 -0800 | [diff] [blame] | 14 | class AccessRevocationManager; |
Vitaly Buka | 0fa51e5 | 2015-07-10 00:12:25 -0700 | [diff] [blame] | 15 | class BaseApiHandler; |
Vitaly Buka | c11a17d | 2015-08-15 10:36:10 -0700 | [diff] [blame] | 16 | class Config; |
Alex Vakulenko | e79fa91 | 2015-12-04 17:24:15 -0800 | [diff] [blame] | 17 | class ComponentManager; |
Vitaly Buka | 0fa51e5 | 2015-07-10 00:12:25 -0700 | [diff] [blame] | 18 | class DeviceRegistrationInfo; |
Vitaly Buka | 0fa51e5 | 2015-07-10 00:12:25 -0700 | [diff] [blame] | 19 | |
| 20 | namespace privet { |
Vitaly Buka | 3d851b4 | 2015-12-08 16:17:01 -0800 | [diff] [blame] | 21 | class AuthManager; |
Vitaly Buka | 0fa51e5 | 2015-07-10 00:12:25 -0700 | [diff] [blame] | 22 | class Manager; |
| 23 | } // namespace privet |
| 24 | |
| 25 | class DeviceManager final : public Device { |
| 26 | public: |
Vitaly Buka | c5bdd17 | 2015-10-01 19:48:51 -0700 | [diff] [blame] | 27 | DeviceManager(provider::ConfigStore* config_store, |
| 28 | provider::TaskRunner* task_runner, |
| 29 | provider::HttpClient* http_client, |
| 30 | provider::Network* network, |
| 31 | provider::DnsServiceDiscovery* dns_sd, |
| 32 | provider::HttpServer* http_server, |
| 33 | provider::Wifi* wifi, |
| 34 | provider::Bluetooth* bluetooth); |
Vitaly Buka | 0fa51e5 | 2015-07-10 00:12:25 -0700 | [diff] [blame] | 35 | ~DeviceManager() override; |
| 36 | |
Vitaly Buka | ae6b35d | 2015-09-29 23:16:54 -0700 | [diff] [blame] | 37 | // Device implementation. |
Vitaly Buka | a8ece8f | 2015-10-05 13:30:23 -0700 | [diff] [blame] | 38 | const Settings& GetSettings() const override; |
Vitaly Buka | ae6b35d | 2015-09-29 23:16:54 -0700 | [diff] [blame] | 39 | void AddSettingsChangedCallback( |
| 40 | const SettingsChangedCallback& callback) override; |
Alex Vakulenko | e79fa91 | 2015-12-04 17:24:15 -0800 | [diff] [blame] | 41 | void AddTraitDefinitionsFromJson(const std::string& json) override; |
| 42 | void AddTraitDefinitions(const base::DictionaryValue& dict) override; |
| 43 | const base::DictionaryValue& GetTraits() const override; |
Alex Vakulenko | ec9d848 | 2015-12-10 10:16:21 -0800 | [diff] [blame] | 44 | void AddTraitDefsChangedCallback(const base::Closure& callback) override; |
Alex Vakulenko | e79fa91 | 2015-12-04 17:24:15 -0800 | [diff] [blame] | 45 | bool AddComponent(const std::string& name, |
| 46 | const std::vector<std::string>& traits, |
| 47 | ErrorPtr* error) override; |
Alex Vakulenko | ce850b5 | 2016-01-04 09:27:50 -0800 | [diff] [blame] | 48 | bool RemoveComponent(const std::string& name, ErrorPtr* error) override; |
Alex Vakulenko | e79fa91 | 2015-12-04 17:24:15 -0800 | [diff] [blame] | 49 | void AddComponentTreeChangedCallback(const base::Closure& callback) override; |
| 50 | const base::DictionaryValue& GetComponents() const override; |
| 51 | bool SetStatePropertiesFromJson(const std::string& component, |
| 52 | const std::string& json, |
| 53 | ErrorPtr* error) override; |
| 54 | bool SetStateProperties(const std::string& component, |
| 55 | const base::DictionaryValue& dict, |
| 56 | ErrorPtr* error) override; |
| 57 | const base::Value* GetStateProperty(const std::string& component, |
| 58 | const std::string& name, |
| 59 | ErrorPtr* error) const override; |
| 60 | bool SetStateProperty(const std::string& component, |
| 61 | const std::string& name, |
| 62 | const base::Value& value, |
| 63 | ErrorPtr* error) override; |
| 64 | void AddCommandHandler(const std::string& component, |
| 65 | const std::string& command_name, |
| 66 | const CommandHandlerCallback& callback) override; |
Vitaly Buka | a8ece8f | 2015-10-05 13:30:23 -0700 | [diff] [blame] | 67 | bool AddCommand(const base::DictionaryValue& command, |
| 68 | std::string* id, |
| 69 | ErrorPtr* error) override; |
| 70 | Command* FindCommand(const std::string& id) override; |
Alex Vakulenko | e79fa91 | 2015-12-04 17:24:15 -0800 | [diff] [blame] | 71 | void AddStateChangedCallback(const base::Closure& callback) override; |
Vitaly Buka | 03ee8ac | 2016-02-05 11:40:33 -0800 | [diff] [blame] | 72 | void Register(const RegistrationData& registration_data, |
Alex Vakulenko | e79fa91 | 2015-12-04 17:24:15 -0800 | [diff] [blame] | 73 | const DoneCallback& callback) override; |
| 74 | GcdState GetGcdState() const override; |
| 75 | void AddGcdStateChangedCallback( |
| 76 | const GcdStateChangedCallback& callback) override; |
| 77 | void AddPairingChangedCallbacks( |
| 78 | const PairingBeginCallback& begin_callback, |
| 79 | const PairingEndCallback& end_callback) override; |
| 80 | |
Vitaly Buka | c11a17d | 2015-08-15 10:36:10 -0700 | [diff] [blame] | 81 | Config* GetConfig(); |
| 82 | |
Vitaly Buka | 0fa51e5 | 2015-07-10 00:12:25 -0700 | [diff] [blame] | 83 | private: |
Vitaly Buka | 41a90d6 | 2015-09-29 16:58:39 -0700 | [diff] [blame] | 84 | void StartPrivet(provider::TaskRunner* task_runner, |
Vitaly Buka | 1e36367 | 2015-09-25 14:01:16 -0700 | [diff] [blame] | 85 | provider::Network* network, |
| 86 | provider::DnsServiceDiscovery* dns_sd, |
| 87 | provider::HttpServer* http_server, |
| 88 | provider::Wifi* wifi, |
| 89 | provider::Bluetooth* bluetooth); |
Vitaly Buka | 0fa51e5 | 2015-07-10 00:12:25 -0700 | [diff] [blame] | 90 | |
Vitaly Buka | 666b43e | 2015-12-08 16:35:47 -0800 | [diff] [blame] | 91 | std::unique_ptr<Config> config_; |
Vitaly Buka | 3d851b4 | 2015-12-08 16:17:01 -0800 | [diff] [blame] | 92 | std::unique_ptr<privet::AuthManager> auth_manager_; |
Alex Vakulenko | e79fa91 | 2015-12-04 17:24:15 -0800 | [diff] [blame] | 93 | std::unique_ptr<ComponentManager> component_manager_; |
Vitaly Buka | 0fa51e5 | 2015-07-10 00:12:25 -0700 | [diff] [blame] | 94 | std::unique_ptr<DeviceRegistrationInfo> device_info_; |
| 95 | std::unique_ptr<BaseApiHandler> base_api_handler_; |
Vitaly Buka | ebde3c1 | 2016-02-23 18:50:42 -0800 | [diff] [blame] | 96 | std::unique_ptr<AccessRevocationManager> access_revocation_manager_; |
Vitaly Buka | 5a7c4f5 | 2016-01-21 15:09:34 -0800 | [diff] [blame] | 97 | std::unique_ptr<AccessApiHandler> access_api_handler_; |
Vitaly Buka | 0fa51e5 | 2015-07-10 00:12:25 -0700 | [diff] [blame] | 98 | std::unique_ptr<privet::Manager> privet_; |
| 99 | |
| 100 | base::WeakPtrFactory<DeviceManager> weak_ptr_factory_{this}; |
| 101 | DISALLOW_COPY_AND_ASSIGN(DeviceManager); |
| 102 | }; |
| 103 | |
| 104 | } // namespace weave |
| 105 | |
| 106 | #endif // LIBWEAVE_SRC_DEVICE_MANAGER_H_ |