aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--examples/daemon/sample/sample.cc2
-rw-r--r--include/weave/device.h12
-rw-r--r--include/weave/export.h4
-rw-r--r--include/weave/test/mock_device.h2
-rw-r--r--src/device_manager.cc4
-rw-r--r--src/device_manager.h1
6 files changed, 20 insertions, 5 deletions
diff --git a/examples/daemon/sample/sample.cc b/examples/daemon/sample/sample.cc
index 97cef61..2ab4b27 100644
--- a/examples/daemon/sample/sample.cc
+++ b/examples/daemon/sample/sample.cc
@@ -104,7 +104,7 @@ class SampleHandler {
device_->SetStateProperty(kComponent, "_sample._ping_count",
base::FundamentalValue{++ping_count_}, nullptr);
- LOG(INFO) << "New state: " << device_->GetState();
+ LOG(INFO) << "New component state: " << device_->GetComponents();
base::DictionaryValue result;
cmd->Complete(result, nullptr);
diff --git a/include/weave/device.h b/include/weave/device.h
index 2d7aaff..99035f4 100644
--- a/include/weave/device.h
+++ b/include/weave/device.h
@@ -53,6 +53,10 @@ class Device {
// Returns the full JSON dictionary containing trait definitions.
virtual const base::DictionaryValue& GetTraits() const = 0;
+ // Sets callback which is called when new trait definitions are added.
+ virtual void AddTraitDefsChangedCallback(
+ const base::Closure& callback) = 0;
+
// Adds a new component instance to device. Traits used by this component
// must be already defined.
virtual bool AddComponent(const std::string& name,
@@ -172,6 +176,7 @@ class Device {
// 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(
@@ -182,6 +187,7 @@ class Device {
// "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;
@@ -189,6 +195,7 @@ class Device {
// 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(
@@ -201,6 +208,7 @@ class Device {
// 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;
@@ -210,19 +218,21 @@ class Device {
// 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/include/weave/export.h b/include/weave/export.h
index f698176..6a658f9 100644
--- a/include/weave/export.h
+++ b/include/weave/export.h
@@ -8,8 +8,6 @@
#define LIBWEAVE_EXPORT __attribute__((__visibility__("default")))
#define LIBWEAVE_PRIVATE __attribute__((__visibility__("hidden")))
-// TODO(avakulenko): Once all the sample clients are migrated to new APIs,
-// mark the old one officially deprecated by uncomment the following attribute.
-#define LIBWEAVE_DEPRECATED // __attribute__((deprecated))
+#define LIBWEAVE_DEPRECATED __attribute__((deprecated))
#endif // LIBWEAVE_INCLUDE_WEAVE_EXPORT_H_
diff --git a/include/weave/test/mock_device.h b/include/weave/test/mock_device.h
index 88cc5e0..612afb9 100644
--- a/include/weave/test/mock_device.h
+++ b/include/weave/test/mock_device.h
@@ -24,6 +24,8 @@ class MockDevice : public Device {
MOCK_METHOD1(AddTraitDefinitionsFromJson, void(const std::string& json));
MOCK_METHOD1(AddTraitDefinitions, void(const base::DictionaryValue& dict));
MOCK_CONST_METHOD0(GetTraits, const base::DictionaryValue&());
+ MOCK_METHOD1(AddTraitDefsChangedCallback,
+ void(const base::Closure& callback));
MOCK_METHOD3(AddComponent, bool(const std::string& name,
const std::vector<std::string>& traits,
ErrorPtr* error));
diff --git a/src/device_manager.cc b/src/device_manager.cc
index e99ca4d..cb575b8 100644
--- a/src/device_manager.cc
+++ b/src/device_manager.cc
@@ -105,6 +105,10 @@ const base::DictionaryValue& DeviceManager::GetTraits() const {
return component_manager_->GetTraits();
}
+void DeviceManager::AddTraitDefsChangedCallback(const base::Closure& callback) {
+ component_manager_->AddTraitDefChangedCallback(callback);
+}
+
bool DeviceManager::AddComponent(const std::string& name,
const std::vector<std::string>& traits,
ErrorPtr* error) {
diff --git a/src/device_manager.h b/src/device_manager.h
index bf641e2..d21f398 100644
--- a/src/device_manager.h
+++ b/src/device_manager.h
@@ -39,6 +39,7 @@ class DeviceManager final : public Device {
void AddTraitDefinitionsFromJson(const std::string& json) override;
void AddTraitDefinitions(const base::DictionaryValue& dict) override;
const base::DictionaryValue& GetTraits() const override;
+ void AddTraitDefsChangedCallback(const base::Closure& callback) override;
bool AddComponent(const std::string& name,
const std::vector<std::string>& traits,
ErrorPtr* error) override;