aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Vakulenko <avakulenko@google.com>2016-02-23 15:46:29 -0800
committerAlex Vakulenko <avakulenko@google.com>2016-02-24 00:08:50 +0000
commit89b3495b6bce7f8a2545ba983ca6dfda29026555 (patch)
tree3c1e50043c6f9dfae23e648b4da21c65e0b5389f
parent1054d3edba8943ed2b949fae387a07f6efa4b704 (diff)
downloadlibweave-89b3495b6bce7f8a2545ba983ca6dfda29026555.tar.gz
Removing legacy API from libweave
It's been awhile since we switched to the new components/traits model. Removing the legacy state/commandDef APIs now. BUG:25917432 Change-Id: I824e65248ceebc3624fb1e1ea0d32bbc1b8513c0 Reviewed-on: https://weave-review.googlesource.com/2720 Reviewed-by: Vitaly Buka <vitalybuka@google.com>
-rw-r--r--include/weave/device.h62
-rw-r--r--src/component_manager.h11
-rw-r--r--src/component_manager_impl.cc134
-rw-r--r--src/component_manager_impl.h21
-rw-r--r--src/component_manager_unittest.cc217
-rw-r--r--src/device_manager.cc87
-rw-r--r--src/device_manager.h16
-rw-r--r--src/privet/cloud_delegate.cc8
-rw-r--r--src/privet/cloud_delegate.h6
-rw-r--r--src/privet/mock_delegates.h5
-rw-r--r--src/privet/privet_handler.cc26
-rw-r--r--src/privet/privet_handler_unittest.cc20
-rw-r--r--src/test/mock_component_manager.h7
-rw-r--r--src/weave_unittest.cc2
14 files changed, 0 insertions, 622 deletions
diff --git a/include/weave/device.h b/include/weave/device.h
index 9a29574..b79e6a3 100644
--- a/include/weave/device.h
+++ b/include/weave/device.h
@@ -193,68 +193,6 @@ class Device {
provider::HttpServer* http_server,
provider::Wifi* wifi,
provider::Bluetooth* bluetooth_provider);
-
- //========================== Deprecated APIs =========================
-
- // Adds provided commands definitions. Can be called multiple times with
- // condition that definitions do not conflict.
- // Invalid value is fatal.
- // DO NOT USE IN YOUR CODE: use AddTraitDefinitions() instead.
- LIBWEAVE_DEPRECATED virtual void AddCommandDefinitionsFromJson(
- const std::string& json) = 0;
- LIBWEAVE_DEPRECATED virtual void AddCommandDefinitions(
- const base::DictionaryValue& dict) = 0;
-
- // Sets handler for new commands added to the queue.
- // |command_name| is the full command name of the command to handle. e.g.
- // "base.reboot". Each command can have no more than one handler.
- // Empty |command_name| sets default handler for all unhanded commands.
- // No new command handlers can be set after default handler was set.
- // DO NOT USE IN YOUR CODE: use AddCommandHandler() with component parameter.
- LIBWEAVE_DEPRECATED virtual void AddCommandHandler(
- const std::string& command_name,
- const CommandHandlerCallback& callback) = 0;
-
- // Adds provided state definitions. Can be called multiple times with
- // condition that definitions do not conflict.
- // Invalid value is fatal.
- // DO NOT USE IN YOUR CODE: use AddTraitDefinitions() instead.
- LIBWEAVE_DEPRECATED virtual void AddStateDefinitionsFromJson(
- const std::string& json) = 0;
- LIBWEAVE_DEPRECATED virtual void AddStateDefinitions(
- const base::DictionaryValue& dict) = 0;
-
- // Sets value of multiple properties of the state.
- // It's recommended to call this to initialize state defined by
- // AddStateDefinitions.
- // Example:
- // device->SetStatePropertiesFromJson("{'base':{'firmwareVersion':'123'}}")
- // Method completely replaces properties included |json| or |dict|.
- // Properties of the state not included |json| or |dict| will stay unchanged.
- // DO NOT USE IN YOUR CODE: use SetStateProperties() with component parameter.
- LIBWEAVE_DEPRECATED virtual bool SetStatePropertiesFromJson(
- const std::string& json,
- ErrorPtr* error) = 0;
- LIBWEAVE_DEPRECATED virtual bool SetStateProperties(
- const base::DictionaryValue& dict,
- ErrorPtr* error) = 0;
-
- // Returns value of the single property.
- // |name| is full property name, including package name. e.g. "base.network".
- // DO NOT USE IN YOUR CODE: use GetStateProperty() with component parameter.
- LIBWEAVE_DEPRECATED virtual const base::Value* GetStateProperty(
- const std::string& name) const = 0;
-
- // Sets value of the single property.
- // |name| is full property name, including package name. e.g. "base.network".
- // DO NOT USE IN YOUR CODE: use SetStateProperty() with component parameter.
- LIBWEAVE_DEPRECATED virtual bool SetStateProperty(const std::string& name,
- const base::Value& value,
- ErrorPtr* error) = 0;
-
- // Returns aggregated state properties across all registered packages.
- // DO NOT USE IN YOUR CODE: use GetComponents() instead.
- LIBWEAVE_DEPRECATED virtual const base::DictionaryValue& GetState() const = 0;
};
} // namespace weave
diff --git a/src/component_manager.h b/src/component_manager.h
index 832b274..cea5569 100644
--- a/src/component_manager.h
+++ b/src/component_manager.h
@@ -209,17 +209,6 @@ class ComponentManager {
virtual std::string FindComponentWithTrait(
const std::string& trait) const = 0;
- // Support for legacy APIs. Setting command and state definitions.
- // This translates into modifying a trait definition.
- virtual bool AddLegacyCommandDefinitions(const base::DictionaryValue& dict,
- ErrorPtr* error) = 0;
- virtual bool AddLegacyStateDefinitions(const base::DictionaryValue& dict,
- ErrorPtr* error) = 0;
- // Returns device state for legacy APIs.
- virtual const base::DictionaryValue& GetLegacyState() const = 0;
- // Returns command definitions for legacy APIs.
- virtual const base::DictionaryValue& GetLegacyCommandDefinitions() const = 0;
-
DISALLOW_COPY_AND_ASSIGN(ComponentManager);
};
diff --git a/src/component_manager_impl.cc b/src/component_manager_impl.cc
index 6e609a2..3ea1f46 100644
--- a/src/component_manager_impl.cc
+++ b/src/component_manager_impl.cc
@@ -506,140 +506,6 @@ std::string ComponentManagerImpl::FindComponentWithTrait(
return std::string{};
}
-bool ComponentManagerImpl::AddLegacyCommandDefinitions(
- const base::DictionaryValue& dict,
- ErrorPtr* error) {
- bool result = true;
- bool modified = false;
- for (base::DictionaryValue::Iterator it(dict); !it.IsAtEnd(); it.Advance()) {
- const base::DictionaryValue* command_dict = nullptr;
- if (!it.value().GetAsDictionary(&command_dict)) {
- Error::AddToPrintf(error, FROM_HERE, errors::commands::kTypeMismatch,
- "Package '%s' must be an object", it.key().c_str());
- result = false;
- continue;
- }
- AddTraitToLegacyComponent(it.key());
- for (base::DictionaryValue::Iterator it_def(*command_dict);
- !it_def.IsAtEnd(); it_def.Advance()) {
- std::string key = base::StringPrintf("%s.commands.%s", it.key().c_str(),
- it_def.key().c_str());
- if (traits_.GetDictionary(key, nullptr)) {
- Error::AddToPrintf(error, FROM_HERE,
- errors::commands::kInvalidPropValue,
- "Redefining command '%s.%s'", it.key().c_str(),
- it_def.key().c_str());
- result = false;
- continue;
- }
- traits_.Set(key, it_def.value().DeepCopy());
- modified = true;
- }
- }
-
- if (modified) {
- for (const auto& cb : on_trait_changed_)
- cb.Run();
- }
- return result;
-}
-
-bool ComponentManagerImpl::AddLegacyStateDefinitions(
- const base::DictionaryValue& dict,
- ErrorPtr* error) {
- bool result = true;
- bool modified = false;
- for (base::DictionaryValue::Iterator it(dict); !it.IsAtEnd(); it.Advance()) {
- const base::DictionaryValue* state_dict = nullptr;
- if (!it.value().GetAsDictionary(&state_dict)) {
- Error::AddToPrintf(error, FROM_HERE, errors::commands::kTypeMismatch,
- "Package '%s' must be an object", it.key().c_str());
- result = false;
- continue;
- }
- AddTraitToLegacyComponent(it.key());
- for (base::DictionaryValue::Iterator it_def(*state_dict); !it_def.IsAtEnd();
- it_def.Advance()) {
- std::string key = base::StringPrintf("%s.state.%s", it.key().c_str(),
- it_def.key().c_str());
- if (traits_.GetDictionary(key, nullptr)) {
- Error::AddToPrintf(error, FROM_HERE,
- errors::commands::kInvalidPropValue,
- "Redefining state property '%s.%s'",
- it.key().c_str(), it_def.key().c_str());
- result = false;
- continue;
- }
- traits_.Set(key, it_def.value().DeepCopy());
- modified = true;
- }
- }
-
- if (modified) {
- for (const auto& cb : on_trait_changed_)
- cb.Run();
- }
- return result;
-}
-
-const base::DictionaryValue& ComponentManagerImpl::GetLegacyState() const {
- legacy_state_.Clear();
- // Build state from components.
- for (base::DictionaryValue::Iterator it(components_); !it.IsAtEnd();
- it.Advance()) {
- const base::DictionaryValue* component_dict = nullptr;
- const base::DictionaryValue* component_state = nullptr;
- if (it.value().GetAsDictionary(&component_dict) &&
- component_dict->GetDictionary("state", &component_state)) {
- legacy_state_.MergeDictionary(component_state);
- }
- }
- return legacy_state_;
-}
-
-const base::DictionaryValue& ComponentManagerImpl::GetLegacyCommandDefinitions()
- const {
- legacy_command_defs_.Clear();
- // Build commandDefs from traits.
- for (base::DictionaryValue::Iterator it(traits_); !it.IsAtEnd();
- it.Advance()) {
- const base::DictionaryValue* trait_dict = nullptr;
- const base::DictionaryValue* trait_commands = nullptr;
- if (it.value().GetAsDictionary(&trait_dict) &&
- trait_dict->GetDictionary("commands", &trait_commands)) {
- base::DictionaryValue dict;
- dict.Set(it.key(), trait_commands->DeepCopy());
- legacy_command_defs_.MergeDictionary(&dict);
- }
- }
- return legacy_command_defs_;
-}
-
-void ComponentManagerImpl::AddTraitToLegacyComponent(const std::string& trait) {
- // First check if we already have a component supporting this trait.
- if (!FindComponentWithTrait(trait).empty())
- return;
-
- // If not, add this trait to the first component available.
- base::DictionaryValue* component = nullptr;
- base::DictionaryValue::Iterator it(components_);
- if (it.IsAtEnd()) {
- // No components at all. Create a new one with dummy name.
- // This normally wouldn't happen since libweave creates its own component
- // at startup.
- component = new base::DictionaryValue;
- components_.Set("__weave__", component);
- } else {
- CHECK(components_.GetDictionary(it.key(), &component));
- }
- base::ListValue* traits = nullptr;
- if (!component->GetList("traits", &traits)) {
- traits = new base::ListValue;
- component->Set("traits", traits);
- }
- traits->AppendString(trait);
-}
-
base::DictionaryValue* ComponentManagerImpl::FindComponentGraftNode(
const std::string& path,
ErrorPtr* error) {
diff --git a/src/component_manager_impl.h b/src/component_manager_impl.h
index f3c5451..5b8201a 100644
--- a/src/component_manager_impl.h
+++ b/src/component_manager_impl.h
@@ -174,17 +174,6 @@ class ComponentManagerImpl final : public ComponentManager {
// tree. No sub-components are searched.
std::string FindComponentWithTrait(const std::string& trait) const override;
- // Support for legacy APIs. Setting command and state definitions.
- // This translates into modifying a trait definition.
- bool AddLegacyCommandDefinitions(const base::DictionaryValue& dict,
- ErrorPtr* error) override;
- bool AddLegacyStateDefinitions(const base::DictionaryValue& dict,
- ErrorPtr* error) override;
- // Returns device state for legacy APIs.
- const base::DictionaryValue& GetLegacyState() const override;
- // Returns command definitions for legacy APIs.
- const base::DictionaryValue& GetLegacyCommandDefinitions() const override;
-
private:
// A helper method to find a JSON element of component at |path| to add new
// sub-components to.
@@ -193,12 +182,6 @@ class ComponentManagerImpl final : public ComponentManager {
base::DictionaryValue* FindMutableComponent(const std::string& path,
ErrorPtr* error);
- // Legacy API support: Helper function to support state/command definitions.
- // Adds the given trait to at least one component.
- // Searches for available components and if none of them already supports this
- // trait, it adds it to the first available component.
- void AddTraitToLegacyComponent(const std::string& trait);
-
// Helper method to find a sub-component given a root node and a relative path
// from the root to the target component.
static const base::DictionaryValue* FindComponentAt(
@@ -225,10 +208,6 @@ class ComponentManagerImpl final : public ComponentManager {
uint32_t next_command_id_{0};
std::map<std::string, std::unique_ptr<StateChangeQueue>> state_change_queues_;
- // Legacy API support.
- mutable base::DictionaryValue legacy_state_; // Device state.
- mutable base::DictionaryValue legacy_command_defs_; // Command definitions.
-
DISALLOW_COPY_AND_ASSIGN(ComponentManagerImpl);
};
diff --git a/src/component_manager_unittest.cc b/src/component_manager_unittest.cc
index c56567c..291ace8 100644
--- a/src/component_manager_unittest.cc
+++ b/src/component_manager_unittest.cc
@@ -1262,223 +1262,6 @@ TEST_F(ComponentManagerTest, FindComponentWithTrait) {
EXPECT_EQ("", manager_.FindComponentWithTrait("trait4"));
}
-TEST_F(ComponentManagerTest, AddLegacyCommandAndStateDefinitions) {
- const char kCommandDefs1[] = R"({
- "package1": {
- "command1": {
- "minimalRole": "user",
- "parameters": {"height": {"type": "integer"}}
- },
- "command2": {
- "minimalRole": "owner",
- "parameters": {}
- }
- },
- "package2": {
- "command1": { "minimalRole": "user" },
- "command2": { "minimalRole": "owner" }
- }
- })";
- auto json = CreateDictionaryValue(kCommandDefs1);
- EXPECT_TRUE(manager_.AddLegacyCommandDefinitions(*json, nullptr));
- const char kExpected1[] = R"({
- "package1": {
- "commands": {
- "command1": {
- "minimalRole": "user",
- "parameters": {"height": {"type": "integer"}}
- },
- "command2": {
- "minimalRole": "owner",
- "parameters": {}
- }
- }
- },
- "package2": {
- "commands": {
- "command1": { "minimalRole": "user" },
- "command2": { "minimalRole": "owner" }
- }
- }
- })";
- EXPECT_JSON_EQ(kExpected1, manager_.GetTraits());
- const char kExpectedComponents1[] = R"({
- "__weave__": { "traits": ["package1", "package2"] }
- })";
- EXPECT_JSON_EQ(kExpectedComponents1, manager_.GetComponents());
-
- const char kCommandDefs2[] = R"({
- "package2": {
- "command3": { "minimalRole": "user" }
- },
- "package3": {
- "command1": { "minimalRole": "user" },
- "command2": { "minimalRole": "owner" }
- }
- })";
- json = CreateDictionaryValue(kCommandDefs2);
- EXPECT_TRUE(manager_.AddLegacyCommandDefinitions(*json, nullptr));
- const char kExpected2[] = R"({
- "package1": {
- "commands": {
- "command1": {
- "minimalRole": "user",
- "parameters": {"height": {"type": "integer"}}
- },
- "command2": {
- "minimalRole": "owner",
- "parameters": {}
- }
- }
- },
- "package2": {
- "commands": {
- "command1": { "minimalRole": "user" },
- "command2": { "minimalRole": "owner" },
- "command3": { "minimalRole": "user" }
- }
- },
- "package3": {
- "commands": {
- "command1": { "minimalRole": "user" },
- "command2": { "minimalRole": "owner" }
- }
- }
- })";
- EXPECT_JSON_EQ(kExpected2, manager_.GetTraits());
- const char kExpectedComponents2[] = R"({
- "__weave__": { "traits": ["package1", "package2", "package3"] }
- })";
- EXPECT_JSON_EQ(kExpectedComponents2, manager_.GetComponents());
-
- // Redefining existing commands.
- EXPECT_FALSE(manager_.AddLegacyCommandDefinitions(*json, nullptr));
-
- const char kStateDefs1[] = R"({
- "package1": {
- "prop1": { "type": "string" },
- "prop2": { "type": "string" }
- },
- "package4": {
- "prop3": { "type": "string" },
- "prop4": { "type": "string" }
- }
- })";
- json = CreateDictionaryValue(kStateDefs1);
- EXPECT_TRUE(manager_.AddLegacyStateDefinitions(*json, nullptr));
- const char kExpectedComponents3[] = R"({
- "__weave__": { "traits": ["package1", "package2", "package3", "package4"] }
- })";
- EXPECT_JSON_EQ(kExpectedComponents3, manager_.GetComponents());
-
- const char kExpected3[] = R"({
- "package1": {
- "commands": {
- "command1": {
- "minimalRole": "user",
- "parameters": {"height": {"type": "integer"}}
- },
- "command2": {
- "minimalRole": "owner",
- "parameters": {}
- }
- },
- "state": {
- "prop1": { "type": "string" },
- "prop2": { "type": "string" }
- }
- },
- "package2": {
- "commands": {
- "command1": { "minimalRole": "user" },
- "command2": { "minimalRole": "owner" },
- "command3": { "minimalRole": "user" }
- }
- },
- "package3": {
- "commands": {
- "command1": { "minimalRole": "user" },
- "command2": { "minimalRole": "owner" }
- }
- },
- "package4": {
- "state": {
- "prop3": { "type": "string" },
- "prop4": { "type": "string" }
- }
- }
- })";
- EXPECT_JSON_EQ(kExpected3, manager_.GetTraits());
- const char kExpectedComponents4[] = R"({
- "__weave__": { "traits": ["package1", "package2", "package3", "package4"] }
- })";
- EXPECT_JSON_EQ(kExpectedComponents4, manager_.GetComponents());
-
- // Redefining existing commands.
- EXPECT_FALSE(manager_.AddLegacyStateDefinitions(*json, nullptr));
-
- const char kExpected4[] = R"({
- "package1": {
- "command1": {
- "minimalRole": "user",
- "parameters": {"height": {"type": "integer"}}
- },
- "command2": {
- "minimalRole": "owner",
- "parameters": {}
- }
- },
- "package2": {
- "command1": { "minimalRole": "user" },
- "command2": { "minimalRole": "owner" },
- "command3": { "minimalRole": "user" }
- },
- "package3": {
- "command1": { "minimalRole": "user" },
- "command2": { "minimalRole": "owner" }
- }
- })";
- EXPECT_JSON_EQ(kExpected4, manager_.GetLegacyCommandDefinitions());
-}
-
-TEST_F(ComponentManagerTest, GetLegacyState) {
- const char kTraits[] = R"({
- "trait1": {
- "state": {
- "prop1": { "type": "string" },
- "prop2": { "type": "string" }
- }
- },
- "trait2": {
- "state": {
- "prop3": { "type": "string" },
- "prop4": { "type": "string" }
- }
- }
- })";
- auto traits = CreateDictionaryValue(kTraits);
- ASSERT_TRUE(manager_.LoadTraits(*traits, nullptr));
- ASSERT_TRUE(manager_.AddComponent("", "comp1", {"trait1"}, nullptr));
- ASSERT_TRUE(manager_.AddComponent("", "comp2", {"trait2"}, nullptr));
-
- ASSERT_TRUE(manager_.SetStatePropertiesFromJson(
- "comp1", R"({"trait1": {"prop1": "foo", "prop2": "bar"}})", nullptr));
- ASSERT_TRUE(manager_.SetStatePropertiesFromJson(
- "comp2", R"({"trait2": {"prop3": "baz", "prop4": "quux"}})", nullptr));
-
- const char kExpected[] = R"({
- "trait1": {
- "prop1": "foo",
- "prop2": "bar"
- },
- "trait2": {
- "prop3": "baz",
- "prop4": "quux"
- }
- })";
- EXPECT_JSON_EQ(kExpected, manager_.GetLegacyState());
-}
-
TEST_F(ComponentManagerTest, TestMockComponentManager) {
// Check that all the virtual methods are mocked out.
test::MockComponentManager mock;
diff --git a/src/device_manager.cc b/src/device_manager.cc
index aebda67..7e72b31 100644
--- a/src/device_manager.cc
+++ b/src/device_manager.cc
@@ -156,16 +156,6 @@ void DeviceManager::AddCommandHandler(const std::string& component,
component_manager_->AddCommandHandler(component, command_name, callback);
}
-void DeviceManager::AddCommandDefinitionsFromJson(const std::string& json) {
- auto dict = LoadJsonDict(json, nullptr);
- CHECK(dict);
- AddCommandDefinitions(*dict);
-}
-
-void DeviceManager::AddCommandDefinitions(const base::DictionaryValue& dict) {
- CHECK(component_manager_->AddLegacyCommandDefinitions(dict, nullptr));
-}
-
bool DeviceManager::AddCommand(const base::DictionaryValue& command,
std::string* id,
ErrorPtr* error) {
@@ -181,87 +171,10 @@ Command* DeviceManager::FindCommand(const std::string& id) {
return component_manager_->FindCommand(id);
}
-void DeviceManager::AddCommandHandler(const std::string& command_name,
- const CommandHandlerCallback& callback) {
- if (command_name.empty())
- return component_manager_->AddCommandHandler("", "", callback);
-
- auto trait = SplitAtFirst(command_name, ".", true).first;
- std::string component = component_manager_->FindComponentWithTrait(trait);
- CHECK(!component.empty());
- component_manager_->AddCommandHandler(component, command_name, callback);
-}
-
void DeviceManager::AddStateChangedCallback(const base::Closure& callback) {
component_manager_->AddStateChangedCallback(callback);
}
-void DeviceManager::AddStateDefinitionsFromJson(const std::string& json) {
- auto dict = LoadJsonDict(json, nullptr);
- CHECK(dict);
- AddStateDefinitions(*dict);
-}
-
-void DeviceManager::AddStateDefinitions(const base::DictionaryValue& dict) {
- CHECK(component_manager_->AddLegacyStateDefinitions(dict, nullptr));
-}
-
-bool DeviceManager::SetStatePropertiesFromJson(const std::string& json,
- ErrorPtr* error) {
- auto dict = LoadJsonDict(json, error);
- return dict && SetStateProperties(*dict, error);
-}
-
-bool DeviceManager::SetStateProperties(const base::DictionaryValue& dict,
- ErrorPtr* error) {
- for (base::DictionaryValue::Iterator it(dict); !it.IsAtEnd(); it.Advance()) {
- std::string component =
- component_manager_->FindComponentWithTrait(it.key());
- if (component.empty()) {
- Error::AddToPrintf(error, FROM_HERE, "unrouted_state",
- "Unable to set property value because there is no "
- "component supporting "
- "trait '%s'",
- it.key().c_str());
- return false;
- }
- base::DictionaryValue trait_state;
- trait_state.Set(it.key(), it.value().DeepCopy());
- if (!component_manager_->SetStateProperties(component, trait_state, error))
- return false;
- }
- return true;
-}
-
-const base::Value* DeviceManager::GetStateProperty(
- const std::string& name) const {
- auto trait = SplitAtFirst(name, ".", true).first;
- std::string component = component_manager_->FindComponentWithTrait(trait);
- if (component.empty())
- return nullptr;
- return component_manager_->GetStateProperty(component, name, nullptr);
-}
-
-bool DeviceManager::SetStateProperty(const std::string& name,
- const base::Value& value,
- ErrorPtr* error) {
- auto trait = SplitAtFirst(name, ".", true).first;
- std::string component = component_manager_->FindComponentWithTrait(trait);
- if (component.empty()) {
- Error::AddToPrintf(
- error, FROM_HERE, "unrouted_state",
- "Unable set value of state property '%s' because there is no component "
- "supporting trait '%s'",
- name.c_str(), trait.c_str());
- return false;
- }
- return component_manager_->SetStateProperty(component, name, value, error);
-}
-
-const base::DictionaryValue& DeviceManager::GetState() const {
- return component_manager_->GetLegacyState();
-}
-
void DeviceManager::Register(const RegistrationData& registration_data,
const DoneCallback& callback) {
device_info_->RegisterDevice(registration_data, callback);
diff --git a/src/device_manager.h b/src/device_manager.h
index f0ad464..a089e7a 100644
--- a/src/device_manager.h
+++ b/src/device_manager.h
@@ -78,22 +78,6 @@ class DeviceManager final : public Device {
const PairingBeginCallback& begin_callback,
const PairingEndCallback& end_callback) override;
- void AddCommandDefinitionsFromJson(const std::string& json) override;
- void AddCommandDefinitions(const base::DictionaryValue& dict) override;
- void AddCommandHandler(const std::string& command_name,
- const CommandHandlerCallback& callback) override;
- void AddStateDefinitionsFromJson(const std::string& json) override;
- void AddStateDefinitions(const base::DictionaryValue& dict) override;
- bool SetStatePropertiesFromJson(const std::string& json,
- ErrorPtr* error) override;
- bool SetStateProperties(const base::DictionaryValue& dict,
- ErrorPtr* error) override;
- const base::Value* GetStateProperty(const std::string& name) const override;
- bool SetStateProperty(const std::string& name,
- const base::Value& value,
- ErrorPtr* error) override;
- const base::DictionaryValue& GetState() const override;
-
Config* GetConfig();
private:
diff --git a/src/privet/cloud_delegate.cc b/src/privet/cloud_delegate.cc
index 0b4400f..f565687 100644
--- a/src/privet/cloud_delegate.cc
+++ b/src/privet/cloud_delegate.cc
@@ -151,14 +151,6 @@ class CloudDelegateImpl : public CloudDelegate {
return device_->GetSettings().xmpp_endpoint;
}
- const base::DictionaryValue& GetLegacyCommandDef() const override {
- return component_manager_->GetLegacyCommandDefinitions();
- }
-
- const base::DictionaryValue& GetLegacyState() const override {
- return component_manager_->GetLegacyState();
- }
-
const base::DictionaryValue& GetComponents() const override {
return component_manager_->GetComponents();
}
diff --git a/src/privet/cloud_delegate.h b/src/privet/cloud_delegate.h
index 37ed723..43b8904 100644
--- a/src/privet/cloud_delegate.h
+++ b/src/privet/cloud_delegate.h
@@ -100,12 +100,6 @@ class CloudDelegate {
virtual std::string GetServiceUrl() const = 0;
virtual std::string GetXmppEndpoint() const = 0;
- // Returns dictionary with device state (for legacy APIs).
- virtual const base::DictionaryValue& GetLegacyState() const = 0;
-
- // Returns dictionary with commands definitions (for legacy APIs).
- virtual const base::DictionaryValue& GetLegacyCommandDef() const = 0;
-
// Returns dictionary with component tree.
virtual const base::DictionaryValue& GetComponents() const = 0;
diff --git a/src/privet/mock_delegates.h b/src/privet/mock_delegates.h
index 108e450..f04fb37 100644
--- a/src/privet/mock_delegates.h
+++ b/src/privet/mock_delegates.h
@@ -188,8 +188,6 @@ class MockCloudDelegate : public CloudDelegate {
MOCK_CONST_METHOD0(GetOAuthUrl, std::string());
MOCK_CONST_METHOD0(GetServiceUrl, std::string());
MOCK_CONST_METHOD0(GetXmppEndpoint, std::string());
- MOCK_CONST_METHOD0(GetLegacyState, const base::DictionaryValue&());
- MOCK_CONST_METHOD0(GetLegacyCommandDef, const base::DictionaryValue&());
MOCK_CONST_METHOD0(GetComponents, const base::DictionaryValue&());
MOCK_CONST_METHOD2(FindComponent,
const base::DictionaryValue*(const std::string& path,
@@ -229,9 +227,6 @@ class MockCloudDelegate : public CloudDelegate {
EXPECT_CALL(*this, GetSetupState()).WillRepeatedly(ReturnRef(setup_state_));
EXPECT_CALL(*this, GetCloudId()).WillRepeatedly(Return("TestCloudId"));
test_dict_.Set("test", new base::DictionaryValue);
- EXPECT_CALL(*this, GetLegacyState()).WillRepeatedly(ReturnRef(test_dict_));
- EXPECT_CALL(*this, GetLegacyCommandDef())
- .WillRepeatedly(ReturnRef(test_dict_));
EXPECT_CALL(*this, GetTraits()).WillRepeatedly(ReturnRef(test_dict_));
EXPECT_CALL(*this, GetComponents()).WillRepeatedly(ReturnRef(test_dict_));
EXPECT_CALL(*this, FindComponent(_, _)).Times(0);
diff --git a/src/privet/privet_handler.cc b/src/privet/privet_handler.cc
index 05b6e0a..8bfe753 100644
--- a/src/privet/privet_handler.cc
+++ b/src/privet/privet_handler.cc
@@ -421,10 +421,6 @@ PrivetHandler::PrivetHandler(CloudDelegate* cloud,
AuthScope::kManager);
AddSecureHandler("/privet/v3/setup/status", &PrivetHandler::HandleSetupStatus,
AuthScope::kManager);
- AddSecureHandler("/privet/v3/state", &PrivetHandler::HandleState,
- AuthScope::kViewer);
- AddSecureHandler("/privet/v3/commandDefs", &PrivetHandler::HandleCommandDefs,
- AuthScope::kViewer);
AddSecureHandler("/privet/v3/commands/execute",
&PrivetHandler::HandleCommandsExecute, AuthScope::kViewer);
AddSecureHandler("/privet/v3/commands/status",
@@ -875,16 +871,6 @@ void PrivetHandler::ReplyWithSetupStatus(
callback.Run(http::kOk, output);
}
-void PrivetHandler::HandleState(const base::DictionaryValue& input,
- const UserInfo& user_info,
- const RequestCallback& callback) {
- base::DictionaryValue output;
- output.Set(kStateKey, cloud_->GetLegacyState().DeepCopy());
- output.SetString(kFingerprintKey, std::to_string(state_fingerprint_));
-
- callback.Run(http::kOk, output);
-}
-
void PrivetHandler::HandleTraits(const base::DictionaryValue& input,
const UserInfo& user_info,
const RequestCallback& callback) {
@@ -931,18 +917,6 @@ void PrivetHandler::HandleComponents(const base::DictionaryValue& input,
callback.Run(http::kOk, output);
}
-void PrivetHandler::HandleCommandDefs(const base::DictionaryValue& input,
- const UserInfo& user_info,
- const RequestCallback& callback) {
- base::DictionaryValue output;
- output.Set(kCommandsKey, cloud_->GetLegacyCommandDef().DeepCopy());
- // Use traits fingerprint since right now we treat traits and command defs
- // as being equivalent.
- output.SetString(kFingerprintKey, std::to_string(traits_fingerprint_));
-
- callback.Run(http::kOk, output);
-}
-
void PrivetHandler::HandleCommandsExecute(const base::DictionaryValue& input,
const UserInfo& user_info,
const RequestCallback& callback) {
diff --git a/src/privet/privet_handler_unittest.cc b/src/privet/privet_handler_unittest.cc
index eb9ab28..ecf4797 100644
--- a/src/privet/privet_handler_unittest.cc
+++ b/src/privet/privet_handler_unittest.cc
@@ -727,26 +727,6 @@ TEST_F(PrivetHandlerTestWithAuth, ConfirmAccessControl) {
R"({"clientToken": "DerivedClientAuthToken"})"));
}
-TEST_F(PrivetHandlerTestWithAuth, State) {
- EXPECT_JSON_EQ(R"({"state": {"test": {}}, "fingerprint": "1"})",
- HandleRequest("/privet/v3/state", "{}"));
-
- cloud_.NotifyOnStateChanged();
-
- EXPECT_JSON_EQ(R"({"state": {"test": {}}, "fingerprint": "2"})",
- HandleRequest("/privet/v3/state", "{}"));
-}
-
-TEST_F(PrivetHandlerTestWithAuth, CommandsDefs) {
- EXPECT_JSON_EQ(R"({"commands": {"test":{}}, "fingerprint": "1"})",
- HandleRequest("/privet/v3/commandDefs", "{}"));
-
- cloud_.NotifyOnTraitDefsChanged();
-
- EXPECT_JSON_EQ(R"({"commands": {"test":{}}, "fingerprint": "2"})",
- HandleRequest("/privet/v3/commandDefs", "{}"));
-}
-
TEST_F(PrivetHandlerTestWithAuth, Traits) {
EXPECT_JSON_EQ(R"({"traits": {"test": {}}, "fingerprint": "1"})",
HandleRequest("/privet/v3/traits", "{}"));
diff --git a/src/test/mock_component_manager.h b/src/test/mock_component_manager.h
index 1f470c2..2c1d695 100644
--- a/src/test/mock_component_manager.h
+++ b/src/test/mock_component_manager.h
@@ -97,13 +97,6 @@ class MockComponentManager : public ComponentManager {
const base::Callback<void(UpdateID)>& callback));
MOCK_CONST_METHOD1(FindComponentWithTrait,
std::string(const std::string& trait));
- MOCK_METHOD2(AddLegacyCommandDefinitions,
- bool(const base::DictionaryValue& dict, ErrorPtr* error));
- MOCK_METHOD2(AddLegacyStateDefinitions,
- bool(const base::DictionaryValue& dict, ErrorPtr* error));
- MOCK_CONST_METHOD0(GetLegacyState, const base::DictionaryValue&());
- MOCK_CONST_METHOD0(GetLegacyCommandDefinitions,
- const base::DictionaryValue&());
private:
void AddCommand(std::unique_ptr<CommandInstance> command_instance) override {
diff --git a/src/weave_unittest.cc b/src/weave_unittest.cc
index 452ac78..3b28001 100644
--- a/src/weave_unittest.cc
+++ b/src/weave_unittest.cc
@@ -294,7 +294,6 @@ class WeaveTest : public ::testing::Test {
"/privet/v3/accessControl/confirm",
"/privet/v3/auth",
"/privet/v3/checkForUpdates",
- "/privet/v3/commandDefs",
"/privet/v3/commands/cancel",
"/privet/v3/commands/execute",
"/privet/v3/commands/list",
@@ -305,7 +304,6 @@ class WeaveTest : public ::testing::Test {
"/privet/v3/pairing/start",
"/privet/v3/setup/start",
"/privet/v3/setup/status",
- "/privet/v3/state",
"/privet/v3/traits",
// clang-format on
}),