Move standard commands and state definitions into separate file BUG:25304415 Change-Id: Ifdf78ca3b467f6c04d66770d1859d6abc7f48841 Reviewed-on: https://weave-review.googlesource.com/1421 Reviewed-by: Alex Vakulenko <avakulenko@google.com>
diff --git a/libweave/libweave.gypi b/libweave/libweave.gypi index 1e42f83..d481996 100644 --- a/libweave/libweave.gypi +++ b/libweave/libweave.gypi
@@ -18,6 +18,7 @@ 'src/commands/prop_values.cc', 'src/commands/schema_constants.cc', 'src/commands/schema_utils.cc', + 'src/commands/standard_definitions.cc', 'src/config.cc', 'src/data_encoding.cc', 'src/device_manager.cc',
diff --git a/libweave/src/commands/standard_definitions.cc b/libweave/src/commands/standard_definitions.cc new file mode 100644 index 0000000..b6f839a --- /dev/null +++ b/libweave/src/commands/standard_definitions.cc
@@ -0,0 +1,65 @@ +// Copyright 2015 The Weave Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "src/commands/standard_definitions.h" + +namespace weave { + +const char kStandardCommandDefs[] = R"({ + "base": { + "updateBaseConfiguration": { + "minimalRole": "manager", + "parameters": { + "localDiscoveryEnabled": "boolean", + "localAnonymousAccessMaxRole": [ "none", "viewer", "user" ], + "localPairingEnabled": "boolean" + }, + "results": {} + }, + "reboot": { + "minimalRole": "user", + "parameters": {}, + "results": {} + }, + "identify": { + "minimalRole": "user", + "parameters": {}, + "results": {} + }, + "updateDeviceInfo": { + "minimalRole": "manager", + "parameters": { + "description": "string", + "name": "string", + "location": "string" + }, + "results": {} + } + } +})"; + +const char kStandardStateDefs[] = R"({ + "base": { + "firmwareVersion": "string", + "localDiscoveryEnabled": "boolean", + "localAnonymousAccessMaxRole": [ "none", "viewer", "user" ], + "localPairingEnabled": "boolean", + "network": { + "properties": { + "name": "string" + } + } + } +})"; + +const char kStandardStateDefaults[] = R"({ + "base": { + "firmwareVersion": "unknown", + "localDiscoveryEnabled": false, + "localAnonymousAccessMaxRole": "none", + "localPairingEnabled": false + } +})"; + +} // namespace weave
diff --git a/libweave/src/commands/standard_definitions.h b/libweave/src/commands/standard_definitions.h new file mode 100644 index 0000000..eeba38a --- /dev/null +++ b/libweave/src/commands/standard_definitions.h
@@ -0,0 +1,16 @@ +// Copyright 2015 The Weave Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef LIBWEAVE_SRC_COMMANDS_STANDARD_DEFINITIONS_H_ +#define LIBWEAVE_SRC_COMMANDS_STANDARD_DEFINITIONS_H_ + +namespace weave { + +extern const char kStandardCommandDefs[]; +extern const char kStandardStateDefs[]; +extern const char kStandardStateDefaults[]; + +} // namespace weave + +#endif // LIBWEAVE_SRC_COMMANDS_STANDARD_DEFINITIONS_H_
diff --git a/libweave/src/states/state_manager.cc b/libweave/src/states/state_manager.cc index 52a92a6..e13babc 100644 --- a/libweave/src/states/state_manager.cc +++ b/libweave/src/states/state_manager.cc
@@ -7,6 +7,7 @@ #include <base/logging.h> #include <base/values.h> +#include "src/commands/standard_definitions.h" #include "src/json_error_codes.h" #include "src/states/error_codes.h" #include "src/states/state_change_queue_interface.h" @@ -15,32 +16,6 @@ namespace weave { -namespace { - -const char kStandardStateDefs[] = R"({ - "base": { - "firmwareVersion": "string", - "localDiscoveryEnabled": "boolean", - "localAnonymousAccessMaxRole": [ "none", "viewer", "user" ], - "localPairingEnabled": "boolean", - "network": { - "properties": { - "name": "string" - } - } - } -})"; - -const char kStandardStateDefaults[] = R"({ - "base": { - "firmwareVersion": "unknown", - "localDiscoveryEnabled": false, - "localAnonymousAccessMaxRole": "none", - "localPairingEnabled": false - } -})"; -} - StateManager::StateManager(StateChangeQueueInterface* state_change_queue) : state_change_queue_(state_change_queue) { CHECK(state_change_queue_) << "State change queue not specified";