summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJackLivio <jack@livio.io>2018-08-15 11:33:26 -0400
committerJackLivio <jack@livio.io>2018-08-15 11:33:26 -0400
commit9c18b2f1bb5194f0f1c8d1b1e34aa8db69f2d186 (patch)
tree24c3092b302dbe600f2963013f7611287ab6249f
parent26bc93ce70dfad33d8e367e4fddcea1c0c0d34fd (diff)
parent406f491b7db0123351e3851d130bb334cf275023 (diff)
downloadsdl_core-feature/choice_vr_optional.tar.gz
Merge remote-tracking branch 'origin/develop' into feature/choice_vr_optionalfeature/choice_vr_optional
-rw-r--r--src/components/application_manager/include/application_manager/rpc_handler_impl.h10
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc6
-rw-r--r--src/components/application_manager/src/rpc_handler_impl.cc42
-rw-r--r--src/components/formatters/include/formatters/CSmartFactory.h22
-rw-r--r--src/components/hmi_message_handler/src/mb_controller.cc2
-rw-r--r--src/components/include/utils/semantic_version.h115
-rw-r--r--src/components/interfaces/HMI_API.xml10
-rw-r--r--src/components/interfaces/MOBILE_API.xml86
-rw-r--r--src/components/protocol_handler/include/protocol_handler/handshake_handler.h8
-rw-r--r--src/components/protocol_handler/include/protocol_handler/protocol_handler_impl.h5
-rw-r--r--src/components/protocol_handler/include/protocol_handler/protocol_packet.h52
-rw-r--r--src/components/protocol_handler/src/handshake_handler.cc15
-rw-r--r--src/components/protocol_handler/src/protocol_handler_impl.cc43
-rw-r--r--src/components/protocol_handler/src/protocol_packet.cc43
-rw-r--r--src/components/protocol_handler/test/protocol_handler_tm_test.cc9
-rw-r--r--src/components/smart_objects/include/smart_objects/always_false_schema_item.h12
-rw-r--r--src/components/smart_objects/include/smart_objects/always_true_schema_item.h11
-rw-r--r--src/components/smart_objects/include/smart_objects/array_schema_item.h14
-rw-r--r--src/components/smart_objects/include/smart_objects/default_shema_item.h23
-rw-r--r--src/components/smart_objects/include/smart_objects/enum_schema_item.h145
-rw-r--r--src/components/smart_objects/include/smart_objects/number_schema_item.h23
-rw-r--r--src/components/smart_objects/include/smart_objects/object_schema_item.h22
-rw-r--r--src/components/smart_objects/include/smart_objects/schema_item.h19
-rw-r--r--src/components/smart_objects/include/smart_objects/smart_object.h13
-rw-r--r--src/components/smart_objects/include/smart_objects/smart_schema.h14
-rw-r--r--src/components/smart_objects/include/smart_objects/string_schema_item.h12
-rw-r--r--src/components/smart_objects/src/always_false_schema_item.cc6
-rw-r--r--src/components/smart_objects/src/always_true_schema_item.cc5
-rw-r--r--src/components/smart_objects/src/array_schema_item.cc42
-rw-r--r--src/components/smart_objects/src/object_schema_item.cc130
-rw-r--r--src/components/smart_objects/src/schema_item.cc5
-rw-r--r--src/components/smart_objects/src/smart_object.cc4
-rw-r--r--src/components/smart_objects/src/smart_schema.cc5
-rw-r--r--src/components/smart_objects/src/string_schema_item.cc13
-rwxr-xr-xtools/InterfaceGenerator/generator/generators/SmartFactoryBase.py40
-rwxr-xr-xtools/InterfaceGenerator/generator/parsers/RPCBase.py1
36 files changed, 372 insertions, 655 deletions
diff --git a/src/components/application_manager/include/application_manager/rpc_handler_impl.h b/src/components/application_manager/include/application_manager/rpc_handler_impl.h
index 7f61c7b034..8f1d454c3b 100644
--- a/src/components/application_manager/include/application_manager/rpc_handler_impl.h
+++ b/src/components/application_manager/include/application_manager/rpc_handler_impl.h
@@ -143,6 +143,16 @@ class RPCHandlerImpl : public RPCHandler,
void SetTelemetryObserver(AMTelemetryObserver* observer) OVERRIDE;
#endif // TELEMETRY_MONITOR
+ /**
+ * @brief Extracts and validates the syncMsgVersion included in
+ * a RegisterAppInterfaceRequest
+ *
+ * @param output - SmartObject Message received from mobile
+ * @param messageVersion - message version to be updated
+ */
+ void GetMessageVersion(NsSmartDeviceLink::NsSmartObjects::SmartObject& output,
+ utils::SemanticVersion& message_version);
+
private:
void ProcessMessageFromMobile(const std::shared_ptr<Message> message);
void ProcessMessageFromHMI(const std::shared_ptr<Message> message);
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc
index 4284b97786..164c854f18 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc
@@ -621,11 +621,11 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile(
utils::SemanticVersion negotiated_version = application->msg_version();
response_params[strings::sync_msg_version][strings::major_version] =
- negotiated_version.major_version;
+ negotiated_version.major_version_;
response_params[strings::sync_msg_version][strings::minor_version] =
- negotiated_version.minor_version;
+ negotiated_version.minor_version_;
response_params[strings::sync_msg_version][strings::patch_version] =
- negotiated_version.patch_version;
+ negotiated_version.patch_version_;
const smart_objects::SmartObject& msg_params =
(*message_)[strings::msg_params];
diff --git a/src/components/application_manager/src/rpc_handler_impl.cc b/src/components/application_manager/src/rpc_handler_impl.cc
index 37319738f9..bf1ff78d36 100644
--- a/src/components/application_manager/src/rpc_handler_impl.cc
+++ b/src/components/application_manager/src/rpc_handler_impl.cc
@@ -194,6 +194,36 @@ void RPCHandlerImpl::SetTelemetryObserver(AMTelemetryObserver* observer) {
#endif // TELEMETRY_MONITOR
+void RPCHandlerImpl::GetMessageVersion(
+ NsSmartDeviceLink::NsSmartObjects::SmartObject& output,
+ utils::SemanticVersion& message_version) {
+ if (output.keyExists(
+ NsSmartDeviceLink::NsJSONHandler::strings::S_MSG_PARAMS) &&
+ output[NsSmartDeviceLink::NsJSONHandler::strings::S_MSG_PARAMS].keyExists(
+ strings::sync_msg_version)) {
+ // SyncMsgVersion exists, check if it is valid.
+ auto sync_msg_version =
+ output[NsSmartDeviceLink::NsJSONHandler::strings::S_MSG_PARAMS]
+ [strings::sync_msg_version];
+ uint16_t major = 0;
+ uint16_t minor = 0;
+ uint16_t patch = 0;
+ if (sync_msg_version.keyExists(strings::major_version)) {
+ major = sync_msg_version[strings::major_version].asUInt();
+ }
+ if (sync_msg_version.keyExists(strings::minor_version)) {
+ minor = sync_msg_version[strings::minor_version].asUInt();
+ }
+ if (sync_msg_version.keyExists(strings::patch_version)) {
+ patch = sync_msg_version[strings::patch_version].asUInt();
+ }
+ utils::SemanticVersion temp_version(major, minor, patch);
+ if (temp_version.isValid()) {
+ message_version = temp_version;
+ }
+ }
+}
+
bool RPCHandlerImpl::ConvertMessageToSO(
const Message& message,
NsSmartDeviceLink::NsSmartObjects::SmartObject& output) {
@@ -220,26 +250,20 @@ bool RPCHandlerImpl::ConvertMessageToSO(
// Attach RPC version to SmartObject if it does not exist yet.
auto app_ptr = app_manager_.application(message.connection_key());
- utils::SemanticVersion msg_version(2, 0, 0);
+ utils::SemanticVersion msg_version(0, 0, 0);
if (app_ptr &&
(output[NsSmartDeviceLink::NsJSONHandler::strings::S_PARAMS]
.keyExists(NsSmartDeviceLink::NsJSONHandler::strings::
S_RPC_MSG_VERSION) == false)) {
msg_version = app_ptr->msg_version();
- output[NsSmartDeviceLink::NsJSONHandler::strings::S_PARAMS]
- [NsSmartDeviceLink::NsJSONHandler::strings::S_RPC_MSG_VERSION] =
- msg_version.toString();
} else if (mobile_apis::FunctionID::RegisterAppInterfaceID ==
static_cast<mobile_apis::FunctionID::eType>(
output[strings::params][strings::function_id].asInt())) {
- // Assume default version 1.0.0 until properly set in RAI
- output[NsSmartDeviceLink::NsJSONHandler::strings::S_PARAMS]
- [NsSmartDeviceLink::NsJSONHandler::strings::S_RPC_MSG_VERSION] =
- msg_version.toString();
+ GetMessageVersion(output, msg_version);
}
if (!conversion_result ||
- !mobile_so_factory().attachSchema(output, true) ||
+ !mobile_so_factory().attachSchema(output, true, msg_version) ||
((output.validate(&report, msg_version) !=
smart_objects::Errors::OK))) {
LOG4CXX_WARN(logger_,
diff --git a/src/components/formatters/include/formatters/CSmartFactory.h b/src/components/formatters/include/formatters/CSmartFactory.h
index d66dc56d8b..a459f179c0 100644
--- a/src/components/formatters/include/formatters/CSmartFactory.h
+++ b/src/components/formatters/include/formatters/CSmartFactory.h
@@ -153,8 +153,10 @@ class CSmartFactory {
*
* @return True if operation was successful or false otherwise.
*/
- bool attachSchema(NsSmartDeviceLink::NsSmartObjects::SmartObject& object,
- const bool RemoveFakeParameters);
+ bool attachSchema(
+ NsSmartDeviceLink::NsSmartObjects::SmartObject& object,
+ const bool RemoveFakeParameters,
+ const utils::SemanticVersion& MessageVersion = utils::SemanticVersion());
/**
* @brief Attach schema to the struct SmartObject.
@@ -273,7 +275,8 @@ CSmartFactory<FunctionIdEnum, MessageTypeEnum, StructIdEnum>::CSmartFactory(
template <class FunctionIdEnum, class MessageTypeEnum, class StructIdEnum>
bool CSmartFactory<FunctionIdEnum, MessageTypeEnum, StructIdEnum>::attachSchema(
NsSmartDeviceLink::NsSmartObjects::SmartObject& object,
- const bool RemoveFakeParameters) {
+ const bool RemoveFakeParameters,
+ const utils::SemanticVersion& MessageVersion) {
if (false == object.keyExists(strings::S_PARAMS))
return false;
if (false == object[strings::S_PARAMS].keyExists(strings::S_MESSAGE_TYPE))
@@ -300,17 +303,8 @@ bool CSmartFactory<FunctionIdEnum, MessageTypeEnum, StructIdEnum>::attachSchema(
object.setSchema(schemaIterator->second);
- // Initialize msg_version to 0.0.0, an invalid value until properly set.
- utils::SemanticVersion msg_version(0, 0, 0);
- if (object[NsSmartDeviceLink::NsJSONHandler::strings::S_PARAMS].keyExists(
- NsSmartDeviceLink::NsJSONHandler::strings::S_RPC_MSG_VERSION)) {
- msg_version =
- object[NsSmartDeviceLink::NsJSONHandler::strings::S_PARAMS]
- [NsSmartDeviceLink::NsJSONHandler::strings::S_RPC_MSG_VERSION]
- .asString();
- }
-
- schemaIterator->second.applySchema(object, RemoveFakeParameters, msg_version);
+ schemaIterator->second.applySchema(
+ object, RemoveFakeParameters, MessageVersion);
return true;
}
diff --git a/src/components/hmi_message_handler/src/mb_controller.cc b/src/components/hmi_message_handler/src/mb_controller.cc
index 8d3b11add5..4f46026039 100644
--- a/src/components/hmi_message_handler/src/mb_controller.cc
+++ b/src/components/hmi_message_handler/src/mb_controller.cc
@@ -222,7 +222,7 @@ void CMessageBrokerController::exitReceivingThread() {
it;
for (it = mConnectionList.begin(); it != mConnectionList.end();) {
(*it)->Shutdown();
- mConnectionList.erase(it++);
+ it = mConnectionList.erase(it);
}
mConnectionListLock.Release();
diff --git a/src/components/include/utils/semantic_version.h b/src/components/include/utils/semantic_version.h
index a67cf6d2d1..7b9ec0eb96 100644
--- a/src/components/include/utils/semantic_version.h
+++ b/src/components/include/utils/semantic_version.h
@@ -33,93 +33,88 @@
#ifndef SRC_COMPONENTS_INCLUDE_UTILS_SEMANTIC_VERSION_H_
#define SRC_COMPONENTS_INCLUDE_UTILS_SEMANTIC_VERSION_H_
-#include <boost/algorithm/string.hpp>
-
namespace utils {
struct SemanticVersion {
SemanticVersion(uint16_t major = 0, uint16_t minor = 0, uint16_t patch = 0) {
- major_version = major;
- minor_version = minor;
- patch_version = patch;
+ major_version_ = major;
+ minor_version_ = minor;
+ patch_version_ = patch;
+ }
+
+ SemanticVersion(const SemanticVersion& other) {
+ major_version_ = other.major_version_;
+ minor_version_ = other.minor_version_;
+ patch_version_ = other.patch_version_;
}
- SemanticVersion(const std::string& str_version) {
- std::vector<std::string> str_array;
- boost::split(str_array, str_version, boost::is_any_of("."));
- if (str_array.size() == 3) {
- major_version = atoi(str_array[0].c_str());
- minor_version = atoi(str_array[1].c_str());
- patch_version = atoi(str_array[2].c_str());
+ SemanticVersion(const std::string& versionString)
+ : major_version_(0), minor_version_(0), patch_version_(0) {
+ unsigned int major_int, minor_int, patch_int;
+ int readElements = sscanf(
+ versionString.c_str(), "%u.%u.%u", &major_int, &minor_int, &patch_int);
+ if (readElements != 3) {
+ // LOG4CXX_WARN(logger_,
+ // "Error while parsing version string: " << versionString);
} else {
- // Invalid case
- major_version = 0;
- minor_version = 0;
- patch_version = 0;
+ major_version_ = static_cast<uint8_t>(major_int);
+ minor_version_ = static_cast<uint8_t>(minor_int);
+ patch_version_ = static_cast<uint8_t>(patch_int);
}
}
- bool operator==(const SemanticVersion& version) const {
- return (major_version == version.major_version &&
- minor_version == version.minor_version &&
- patch_version == version.patch_version);
+ static inline int16_t cmp(const SemanticVersion& version1,
+ const SemanticVersion& version2) {
+ int16_t diff =
+ static_cast<int16_t>(version1.major_version_ - version2.major_version_);
+ if (diff == 0) {
+ diff = static_cast<int16_t>(version1.minor_version_ -
+ version2.minor_version_);
+ if (diff == 0) {
+ diff = static_cast<int16_t>(version1.patch_version_ -
+ version2.patch_version_);
+ }
+ }
+ return diff;
}
- bool operator<(const SemanticVersion& version) const {
- return (major_version < version.major_version) ||
- ((major_version == version.major_version) &&
- (minor_version < version.minor_version)) ||
- ((major_version == version.major_version) &&
- (minor_version == version.minor_version) &&
- (patch_version < version.patch_version));
+ bool operator==(const SemanticVersion& other) const {
+ return SemanticVersion::cmp(*this, other) == 0;
}
-
- bool operator<=(const SemanticVersion& version) const {
- if (this->operator==(version)) {
- return true;
- } else if (this->operator<(version)) {
- return true;
- } else {
- return false;
- }
+ bool operator<(const SemanticVersion& other) const {
+ return SemanticVersion::cmp(*this, other) < 0;
}
-
- bool operator>(const SemanticVersion& version) const {
- return (major_version > version.major_version) ||
- ((major_version == version.major_version) &&
- (minor_version > version.minor_version)) ||
- ((major_version == version.major_version) &&
- (minor_version == version.minor_version) &&
- (patch_version > version.patch_version));
+ bool operator>(const SemanticVersion& other) const {
+ return SemanticVersion::cmp(*this, other) > 0;
}
-
- bool operator>=(const SemanticVersion& version) const {
- if (this->operator==(version)) {
- return true;
- } else if (this->operator>(version)) {
- return true;
- } else {
- return false;
- }
+ bool operator<=(const SemanticVersion& other) const {
+ return SemanticVersion::cmp(*this, other) <= 0;
+ }
+ bool operator>=(const SemanticVersion& other) const {
+ return SemanticVersion::cmp(*this, other) >= 0;
+ }
+ static inline SemanticVersion* min(SemanticVersion& version1,
+ SemanticVersion& version2) {
+ return (version1 < version2) ? &version1 : &version2;
}
const std::string toString() const {
std::string result = "";
- result += std::to_string(major_version);
+ result += std::to_string(major_version_);
result += ".";
- result += std::to_string(minor_version);
+ result += std::to_string(minor_version_);
result += ".";
- result += std::to_string(patch_version);
+ result += std::to_string(patch_version_);
return result;
}
bool isValid() const {
- return major_version > 0 || minor_version > 0 || patch_version > 0;
+ return major_version_ > 0 || minor_version_ > 0 || patch_version_ > 0;
}
- uint16_t major_version = 0;
- uint16_t minor_version = 0;
- uint16_t patch_version = 0;
+ uint16_t major_version_ = 0;
+ uint16_t minor_version_ = 0;
+ uint16_t patch_version_ = 0;
};
}
diff --git a/src/components/interfaces/HMI_API.xml b/src/components/interfaces/HMI_API.xml
index bdbb60f98a..da25d28369 100644
--- a/src/components/interfaces/HMI_API.xml
+++ b/src/components/interfaces/HMI_API.xml
@@ -2499,9 +2499,9 @@
<struct name="GPSData">
<description>Struct with the GPS data.</description>
- <param name="longitudeDegrees" type="Float" minvalue="-180" maxvalue="180" mandatory="false">
+ <param name="longitudeDegrees" type="Float" minvalue="-180" maxvalue="180" mandatory="true">
</param>
- <param name="latitudeDegrees" type="Float" minvalue="-90" maxvalue="90" mandatory="false">
+ <param name="latitudeDegrees" type="Float" minvalue="-90" maxvalue="90" mandatory="true">
</param>
<param name="utcYear" type="Integer" minvalue="2010" maxvalue="2100" mandatory="false">
<description>The current UTC year.</description>
@@ -2524,13 +2524,13 @@
<param name="compassDirection" type="Common.CompassDirection" mandatory="false">
<description>See CompassDirection.</description>
</param>
- <param name="pdop" type="Float" minvalue="0" maxvalue="10" mandatory="false">
+ <param name="pdop" type="Float" minvalue="0" maxvalue="1000" mandatory="false">
<description>PDOP.</description>
</param>
- <param name="hdop" type="Float" minvalue="0" maxvalue="10" mandatory="false">
+ <param name="hdop" type="Float" minvalue="0" maxvalue="1000" mandatory="false">
<description>HDOP.</description>
</param>
- <param name="vdop" type="Float" minvalue="0" maxvalue="10" mandatory="false">
+ <param name="vdop" type="Float" minvalue="0" maxvalue="1000" mandatory="false">
<description>VDOP.</description>
</param>
<param name="actual" type="Boolean" mandatory="false">
diff --git a/src/components/interfaces/MOBILE_API.xml b/src/components/interfaces/MOBILE_API.xml
index b63316b899..b820550c1a 100644
--- a/src/components/interfaces/MOBILE_API.xml
+++ b/src/components/interfaces/MOBILE_API.xml
@@ -1851,56 +1851,104 @@
</param>
<param name="latitudeDegrees" type="Float" minvalue="-90" maxvalue="90" mandatory="true">
</param>
- <param name="utcYear" type="Integer" minvalue="2010" maxvalue="2100" mandatory="true">
+ <param name="utcYear" type="Integer" minvalue="2010" maxvalue="2100" mandatory="false" since="5.0">
<description>The current UTC year.</description>
+ <history>
+ <param name="utcYear" type="Integer" minvalue="2010" maxvalue="2100" mandatory="true" since="2.0" until="5.0"/>
+ </history>
</param>
- <param name="utcMonth" type="Integer" minvalue="1" maxvalue="12" mandatory="true">
+ <param name="utcMonth" type="Integer" minvalue="1" maxvalue="12" mandatory="false" since="5.0">
<description>The current UTC month.</description>
+ <history>
+ <param name="utcMonth" type="Integer" minvalue="1" maxvalue="12" mandatory="true" since="2.0" until="5.0"/>
+ </history>
</param>
- <param name="utcDay" type="Integer" minvalue="1" maxvalue="31" mandatory="true">
+ <param name="utcDay" type="Integer" minvalue="1" maxvalue="31" mandatory="false" since="5.0">
<description>The current UTC day.</description>
+ <history>
+ <param name="utcDay" type="Integer" minvalue="1" maxvalue="31" mandatory="true" since="2.0" until="5.0"/>
+ </history>
</param>
- <param name="utcHours" type="Integer" minvalue="0" maxvalue="23" mandatory="true">
+ <param name="utcHours" type="Integer" minvalue="0" maxvalue="23" mandatory="false" since="5.0">
<description>The current UTC hour.</description>
+ <history>
+ <param name="utcHours" type="Integer" minvalue="0" maxvalue="23" mandatory="true" since="2.0" until="5.0"/>
+ </history>
</param>
- <param name="utcMinutes" type="Integer" minvalue="0" maxvalue="59" mandatory="true">
+ <param name="utcMinutes" type="Integer" minvalue="0" maxvalue="59" mandatory="false" since="5.0">
<description>The current UTC minute.</description>
+ <history>
+ <param name="utcMinutes" type="Integer" minvalue="0" maxvalue="59" mandatory="true" since="2.0" until="5.0"/>
+ </history>
</param>
- <param name="utcSeconds" type="Integer" minvalue="0" maxvalue="59" mandatory="true">
+ <param name="utcSeconds" type="Integer" minvalue="0" maxvalue="59" mandatory="false" since="5.0">
<description>The current UTC second.</description>
+ <history>
+ <param name="utcSeconds" type="Integer" minvalue="0" maxvalue="59" mandatory="true" since="2.0" until="5.0"/>
+ </history>
</param>
- <param name="compassDirection" type="CompassDirection" mandatory="true">
+ <param name="compassDirection" type="CompassDirection" mandatory="false" since="5.0">
<description>See CompassDirection.</description>
+ <history>
+ <param name="compassDirection" type="CompassDirection" mandatory="true" since="2.0" until="5.0"/>
+ </history>
</param>
- <param name="pdop" type="Float" minvalue="0" maxvalue="10" defvalue="0" mandatory="true">
- <description>PDOP. If undefined or unavailable, then value shall be set to 0.</description>
+ <param name="pdop" type="Float" minvalue="0" maxvalue="1000" mandatory="false" since="5.0">
+ <description>PDOP.</description>
+ <history>
+ <param name="pdop" type="Float" minvalue="0" maxvalue="10" defvalue="0" mandatory="true" since="2.0" until="5.0"/>
+ </history>
</param>
- <param name="hdop" type="Float" minvalue="0" maxvalue="10" defvalue="0" mandatory="true">
- <description>HDOP. If value is unknown, value shall be set to 0.</description>
+ <param name="hdop" type="Float" minvalue="0" maxvalue="1000" mandatory="false" since="5.0">
+ <description>HDOP.</description>
+ <history>
+ <param name="hdop" type="Float" minvalue="0" maxvalue="10" defvalue="0" mandatory="true" since="2.0" until="5.0"/>
+ </history>
</param>
- <param name="vdop" type="Float" minvalue="0" maxvalue="10" defvalue="0" mandatory="true">
- <description>VDOP. If value is unknown, value shall be set to 0.</description>
+ <param name="vdop" type="Float" minvalue="0" maxvalue="1000" mandatory="false" since="5.0">
+ <description>VDOP.</description>
+ <history>
+ <param name="vdop" type="Float" minvalue="0" maxvalue="10" defvalue="0" mandatory="true" since="2.0" until="5.0"/>
+ </history>
</param>
- <param name="actual" type="Boolean" mandatory="true">
+ <param name="actual" type="Boolean" mandatory="false" since="5.0">
<description>
True, if actual.
False, if inferred.
</description>
+ <history>
+ <param name="actual" type="Boolean" mandatory="true" since="2.0" until="5.0"/>
+ </history>
</param>
- <param name="satellites" type="Integer" minvalue="0" maxvalue="31" mandatory="true">
+ <param name="satellites" type="Integer" minvalue="0" maxvalue="31" mandatory="false" since="5.0">
<description>Number of satellites in view</description>
+ <history>
+ <param name="satellites" type="Integer" minvalue="0" maxvalue="31" mandatory="true" since="2.0" until="5.0"/>
+ </history>
</param>
- <param name="dimension" type="Dimension" mandatory="true">
+ <param name="dimension" type="Dimension" mandatory="false" since="5.0">
<description>See Dimension</description>
+ <history>
+ <param name="dimension" type="Dimension" mandatory="true" since="2.0" until="5.0"/>
+ </history>
</param>
- <param name="altitude" type="Float" minvalue="-10000" maxvalue="10000" mandatory="true">
+ <param name="altitude" type="Float" minvalue="-10000" maxvalue="10000" mandatory="false" since="5.0">
<description>Altitude in meters</description>
+ <history>
+ <param name="altitude" type="Float" minvalue="-10000" maxvalue="10000" mandatory="true" since="2.0" until="5.0"/>
+ </history>
</param>
- <param name="heading" type="Float" minvalue="0" maxvalue="359.99" mandatory="true">
+ <param name="heading" type="Float" minvalue="0" maxvalue="359.99" mandatory="false" since="5.0">
<description>The heading. North is 0. Resolution is 0.01</description>
+ <history>
+ <param name="heading" type="Float" minvalue="0" maxvalue="359.99" mandatory="true" since="2.0" until="5.0"/>
+ </history>
</param>
- <param name="speed" type="Float" minvalue="0" maxvalue="500" mandatory="true">
+ <param name="speed" type="Float" minvalue="0" maxvalue="500" mandatory="false" since="5.0">
<description>The speed in KPH</description>
+ <history>
+ <param name="speed" type="Float" minvalue="0" maxvalue="500" mandatory="true" since="2.0" until="5.0"/>
+ </history>
</param>
</struct>
diff --git a/src/components/protocol_handler/include/protocol_handler/handshake_handler.h b/src/components/protocol_handler/include/protocol_handler/handshake_handler.h
index 8b7f28d50e..be81493e7a 100644
--- a/src/components/protocol_handler/include/protocol_handler/handshake_handler.h
+++ b/src/components/protocol_handler/include/protocol_handler/handshake_handler.h
@@ -40,6 +40,8 @@
#include "protocol_handler/session_observer.h"
#include "security_manager/security_manager_listener.h"
+#include "utils/semantic_version.h"
+
namespace protocol_handler {
class ProtocolHandlerImpl;
@@ -60,12 +62,12 @@ class HandshakeHandler : public security_manager::SecurityManagerListener {
ServiceType service_type,
const std::vector<int>& force_protected_service,
const bool is_new_service,
- ProtocolPacket::ProtocolVersion& full_version,
+ utils::SemanticVersion& full_version,
std::shared_ptr<BsonObject> payload);
HandshakeHandler(ProtocolHandlerImpl& protocol_handler,
SessionObserver& session_observer,
- ProtocolPacket::ProtocolVersion& full_version,
+ utils::SemanticVersion& full_version,
const SessionContext& context,
const uint8_t protocol_version,
std::shared_ptr<BsonObject> payload);
@@ -124,7 +126,7 @@ class HandshakeHandler : public security_manager::SecurityManagerListener {
ProtocolHandlerImpl& protocol_handler_;
SessionObserver& session_observer_;
SessionContext context_;
- ProtocolPacket::ProtocolVersion full_version_;
+ utils::SemanticVersion full_version_;
const uint8_t protocol_version_;
std::shared_ptr<BsonObject> payload_;
};
diff --git a/src/components/protocol_handler/include/protocol_handler/protocol_handler_impl.h b/src/components/protocol_handler/include/protocol_handler/protocol_handler_impl.h
index 58877ac611..e763be8c1b 100644
--- a/src/components/protocol_handler/include/protocol_handler/protocol_handler_impl.h
+++ b/src/components/protocol_handler/include/protocol_handler/protocol_handler_impl.h
@@ -45,6 +45,7 @@
#include "utils/messagemeter.h"
#include "utils/custom_string.h"
+#include "utils/semantic_version.h"
#include "protocol_handler/protocol_handler.h"
#include "protocol_handler/protocol_packet.h"
@@ -313,7 +314,7 @@ class ProtocolHandlerImpl
uint32_t hash_code,
uint8_t service_type,
bool protection,
- ProtocolPacket::ProtocolVersion& full_version);
+ utils::SemanticVersion& full_version);
/**
* \brief Sends acknowledgement of starting session to mobile application
@@ -337,7 +338,7 @@ class ProtocolHandlerImpl
uint32_t hash_code,
uint8_t service_type,
bool protection,
- ProtocolPacket::ProtocolVersion& full_version,
+ utils::SemanticVersion& full_version,
BsonObject& params);
const ProtocolHandlerSettings& get_settings() const OVERRIDE {
diff --git a/src/components/protocol_handler/include/protocol_handler/protocol_packet.h b/src/components/protocol_handler/include/protocol_handler/protocol_packet.h
index ff084beff8..de4af84915 100644
--- a/src/components/protocol_handler/include/protocol_handler/protocol_packet.h
+++ b/src/components/protocol_handler/include/protocol_handler/protocol_packet.h
@@ -64,58 +64,6 @@ class ProtocolPacket {
};
/**
- * \class ProtocolVersion
- * \brief Used for storing the full protocol version of a service
- * (major.minor.patch).
- */
- class ProtocolVersion {
- public:
- ProtocolVersion();
- ProtocolVersion(uint8_t majorVersion,
- uint8_t minorVersion,
- uint8_t patchVersion);
- ProtocolVersion(ProtocolVersion& other);
- ProtocolVersion(std::string versionString);
- uint8_t majorVersion;
- uint8_t minorVersion;
- uint8_t patchVersion;
- static inline int16_t cmp(const ProtocolVersion& version1,
- const ProtocolVersion& version2) {
- int16_t diff =
- static_cast<int16_t>(version1.majorVersion - version2.majorVersion);
- if (diff == 0) {
- diff =
- static_cast<int16_t>(version1.minorVersion - version2.minorVersion);
- if (diff == 0) {
- diff = static_cast<int16_t>(version1.patchVersion -
- version2.patchVersion);
- }
- }
- return diff;
- }
- inline bool operator==(const ProtocolVersion& other) {
- return ProtocolVersion::cmp(*this, other) == 0;
- }
- inline bool operator<(const ProtocolVersion& other) {
- return ProtocolVersion::cmp(*this, other) < 0;
- }
- bool operator>(const ProtocolVersion& other) {
- return ProtocolVersion::cmp(*this, other) > 0;
- }
- inline bool operator<=(const ProtocolVersion& other) {
- return ProtocolVersion::cmp(*this, other) <= 0;
- }
- bool operator>=(const ProtocolVersion& other) {
- return ProtocolVersion::cmp(*this, other) >= 0;
- }
- static inline ProtocolVersion* min(ProtocolVersion& version1,
- ProtocolVersion& version2) {
- return (version1 < version2) ? &version1 : &version2;
- }
- std::string to_string();
- };
-
- /**
* \class ProtocolHeader
* \brief Used for storing protocol header of a message.
*/
diff --git a/src/components/protocol_handler/src/handshake_handler.cc b/src/components/protocol_handler/src/handshake_handler.cc
index 8db551cfd6..f6ab08319e 100644
--- a/src/components/protocol_handler/src/handshake_handler.cc
+++ b/src/components/protocol_handler/src/handshake_handler.cc
@@ -54,7 +54,7 @@ HandshakeHandler::HandshakeHandler(
ServiceType service_type,
const std::vector<int>& force_protected_service,
const bool is_new_service,
- ProtocolPacket::ProtocolVersion& full_version,
+ utils::SemanticVersion& full_version,
std::shared_ptr<BsonObject> payload)
: protocol_handler_(protocol_handler)
, session_observer_(session_observer)
@@ -63,13 +63,12 @@ HandshakeHandler::HandshakeHandler(
, protocol_version_(protocol_version)
, payload_(payload) {}
-HandshakeHandler::HandshakeHandler(
- ProtocolHandlerImpl& protocol_handler,
- SessionObserver& session_observer,
- ProtocolPacket::ProtocolVersion& full_version,
- const SessionContext& context,
- const uint8_t protocol_version,
- std::shared_ptr<BsonObject> payload)
+HandshakeHandler::HandshakeHandler(ProtocolHandlerImpl& protocol_handler,
+ SessionObserver& session_observer,
+ utils::SemanticVersion& full_version,
+ const SessionContext& context,
+ const uint8_t protocol_version,
+ std::shared_ptr<BsonObject> payload)
: protocol_handler_(protocol_handler)
, session_observer_(session_observer)
, context_(context)
diff --git a/src/components/protocol_handler/src/protocol_handler_impl.cc b/src/components/protocol_handler/src/protocol_handler_impl.cc
index 872a8dc755..0e49e28397 100644
--- a/src/components/protocol_handler/src/protocol_handler_impl.cc
+++ b/src/components/protocol_handler/src/protocol_handler_impl.cc
@@ -61,8 +61,8 @@ std::string ConvertPacketDataToString(const uint8_t* data,
const size_t kStackSize = 65536;
-ProtocolPacket::ProtocolVersion defaultProtocolVersion(5, 1, 0);
-ProtocolPacket::ProtocolVersion minMultipleTransportsVersion(5, 1, 0);
+utils::SemanticVersion defaultProtocolVersion(5, 1, 0);
+utils::SemanticVersion minMultipleTransportsVersion(5, 1, 0);
ProtocolHandlerImpl::ProtocolHandlerImpl(
const ProtocolHandlerSettings& settings,
@@ -199,7 +199,7 @@ void ProtocolHandlerImpl::SendStartSessionAck(ConnectionID connection_id,
uint8_t service_type,
bool protection) {
LOG4CXX_AUTO_TRACE(logger_);
- ProtocolPacket::ProtocolVersion fullVersion;
+ utils::SemanticVersion fullVersion;
SendStartSessionAck(connection_id,
session_id,
input_protocol_version,
@@ -216,7 +216,7 @@ void ProtocolHandlerImpl::SendStartSessionAck(
uint32_t hash_id,
uint8_t service_type,
bool protection,
- ProtocolPacket::ProtocolVersion& full_version) {
+ utils::SemanticVersion& full_version) {
LOG4CXX_AUTO_TRACE(logger_);
BsonObject empty_param;
@@ -241,7 +241,7 @@ void ProtocolHandlerImpl::SendStartSessionAck(
uint32_t hash_id,
uint8_t service_type,
bool protection,
- ProtocolPacket::ProtocolVersion& full_version,
+ utils::SemanticVersion& full_version,
BsonObject& params) {
LOG4CXX_AUTO_TRACE(logger_);
@@ -252,7 +252,7 @@ void ProtocolHandlerImpl::SendStartSessionAck(
const bool proxy_supports_v5_protocol =
input_protocol_version >= PROTOCOL_VERSION_5 ||
(ServiceTypeFromByte(service_type) == kRpc &&
- full_version.majorVersion >= PROTOCOL_VERSION_5);
+ full_version.major_version_ >= PROTOCOL_VERSION_5);
if (kRpc != service_type) {
// In case if input protocol version os bigger then supported, SDL should
@@ -307,13 +307,13 @@ void ProtocolHandlerImpl::SendStartSessionAck(
&params, strings::hash_id)));
// Minimum protocol version supported by both
- ProtocolPacket::ProtocolVersion* minVersion =
- (full_version.majorVersion < PROTOCOL_VERSION_5)
+ utils::SemanticVersion* minVersion =
+ (full_version.major_version_ < PROTOCOL_VERSION_5)
? &defaultProtocolVersion
- : ProtocolPacket::ProtocolVersion::min(full_version,
- defaultProtocolVersion);
+ : utils::SemanticVersion::min(full_version,
+ defaultProtocolVersion);
char protocolVersionString[256];
- strncpy(protocolVersionString, (*minVersion).to_string().c_str(), 255);
+ strncpy(protocolVersionString, (*minVersion).toString().c_str(), 255);
const bool protocol_ver_written = bson_object_put_string(
&params, strings::protocol_version, protocolVersionString);
@@ -1608,22 +1608,22 @@ RESULT_CODE ProtocolHandlerImpl::HandleControlMessageStartSession(
PROTECTION_OFF);
return RESULT_OK;
}
- ProtocolPacket::ProtocolVersion* fullVersion;
+ utils::SemanticVersion* fullVersion;
std::vector<std::string> rejectedParams(0, std::string(""));
// Can't check protocol_version because the first packet is v1, but there
// could still be a payload, in which case we can get the real protocol
// version
if (packet.service_type() == kRpc && packet.data_size() != 0) {
BsonObject obj = bson_object_from_bytes(packet.data());
- fullVersion = new ProtocolPacket::ProtocolVersion(
+ fullVersion = new utils::SemanticVersion(
std::string(bson_object_get_string(&obj, "protocolVersion")));
bson_object_deinitialize(&obj);
// Constructed payloads added in Protocol v5
- if (fullVersion->majorVersion < PROTOCOL_VERSION_5) {
+ if (fullVersion->major_version_ < PROTOCOL_VERSION_5) {
rejectedParams.push_back(std::string("protocolVersion"));
}
} else {
- fullVersion = new ProtocolPacket::ProtocolVersion();
+ fullVersion = new utils::SemanticVersion();
}
if (!rejectedParams.empty()) {
SendStartSessionNAck(connection_id,
@@ -1670,11 +1670,11 @@ RESULT_CODE ProtocolHandlerImpl::HandleControlMessageStartSession(
#endif // ENABLE_SECURITY
if (packet.service_type() == kRpc && packet.data_size() != 0) {
BsonObject obj = bson_object_from_bytes(packet.data());
- ProtocolPacket::ProtocolVersion fullVersion(
+ utils::SemanticVersion fullVersion(
bson_object_get_string(&obj, "protocolVersion"));
bson_object_deinitialize(&obj);
- if (fullVersion.majorVersion >= PROTOCOL_VERSION_5) {
+ if (fullVersion.major_version_ >= PROTOCOL_VERSION_5) {
// Start service without protection
SendStartSessionAck(connection_id,
session_id,
@@ -1880,7 +1880,7 @@ void ProtocolHandlerImpl::NotifySessionStarted(
bson_object_deinitialize(&req_param);
}
- std::shared_ptr<ProtocolPacket::ProtocolVersion> fullVersion;
+ std::shared_ptr<utils::SemanticVersion> fullVersion;
// Can't check protocol_version because the first packet is v1, but there
// could still be a payload, in which case we can get the real protocol
@@ -1890,15 +1890,14 @@ void ProtocolHandlerImpl::NotifySessionStarted(
char* version_param =
bson_object_get_string(&request_params, strings::protocol_version);
std::string version_string(version_param == NULL ? "" : version_param);
- fullVersion =
- std::make_shared<ProtocolPacket::ProtocolVersion>(version_string);
+ fullVersion = std::make_shared<utils::SemanticVersion>(version_string);
// Constructed payloads added in Protocol v5
- if (fullVersion->majorVersion < PROTOCOL_VERSION_5) {
+ if (fullVersion->major_version_ < PROTOCOL_VERSION_5) {
rejected_params.push_back(std::string(strings::protocol_version));
}
bson_object_deinitialize(&request_params);
} else {
- fullVersion = std::make_shared<ProtocolPacket::ProtocolVersion>();
+ fullVersion = std::make_shared<utils::SemanticVersion>();
}
#ifdef ENABLE_SECURITY
diff --git a/src/components/protocol_handler/src/protocol_packet.cc b/src/components/protocol_handler/src/protocol_packet.cc
index 3cd9e7f781..d5422e11bc 100644
--- a/src/components/protocol_handler/src/protocol_packet.cc
+++ b/src/components/protocol_handler/src/protocol_packet.cc
@@ -41,6 +41,7 @@
#include "protocol_handler/protocol_packet.h"
#include "utils/macro.h"
#include "utils/byte_order.h"
+#include "utils/semantic_version.h"
namespace protocol_handler {
@@ -52,48 +53,6 @@ ProtocolPacket::ProtocolData::~ProtocolData() {
delete[] data;
}
-ProtocolPacket::ProtocolVersion::ProtocolVersion()
- : majorVersion(0), minorVersion(0), patchVersion(0) {}
-
-ProtocolPacket::ProtocolVersion::ProtocolVersion(uint8_t majorVersion,
- uint8_t minorVersion,
- uint8_t patchVersion)
- : majorVersion(majorVersion)
- , minorVersion(minorVersion)
- , patchVersion(patchVersion) {}
-
-ProtocolPacket::ProtocolVersion::ProtocolVersion(ProtocolVersion& other) {
- this->majorVersion = other.majorVersion;
- this->minorVersion = other.minorVersion;
- this->patchVersion = other.patchVersion;
-}
-
-ProtocolPacket::ProtocolVersion::ProtocolVersion(std::string versionString)
- : majorVersion(0), minorVersion(0), patchVersion(0) {
- unsigned int majorInt, minorInt, patchInt;
- int readElements = sscanf(
- versionString.c_str(), "%u.%u.%u", &majorInt, &minorInt, &patchInt);
- if (readElements != 3) {
- LOG4CXX_WARN(logger_,
- "Error while parsing version string: " << versionString);
- } else {
- majorVersion = static_cast<uint8_t>(majorInt);
- minorVersion = static_cast<uint8_t>(minorInt);
- patchVersion = static_cast<uint8_t>(patchInt);
- }
-}
-
-std::string ProtocolPacket::ProtocolVersion::to_string() {
- char versionString[256];
- snprintf(versionString,
- 255,
- "%u.%u.%u",
- static_cast<unsigned int>(majorVersion),
- static_cast<unsigned int>(minorVersion),
- static_cast<unsigned int>(patchVersion));
- return std::string(versionString);
-}
-
ProtocolPacket::ProtocolHeader::ProtocolHeader()
: version(0x00)
, protection_flag(PROTECTION_OFF)
diff --git a/src/components/protocol_handler/test/protocol_handler_tm_test.cc b/src/components/protocol_handler/test/protocol_handler_tm_test.cc
index cfda0a550a..615900c7fa 100644
--- a/src/components/protocol_handler/test/protocol_handler_tm_test.cc
+++ b/src/components/protocol_handler/test/protocol_handler_tm_test.cc
@@ -48,6 +48,7 @@
#endif // ENABLE_SECURITY
#include "transport_manager/mock_transport_manager.h"
#include "utils/mock_system_time_handler.h"
+#include "utils/semantic_version.h"
#include "utils/test_async_waiter.h"
#include <bson_object.h>
@@ -1539,7 +1540,7 @@ void ProtocolHandlerImplTest::VerifySecondaryTransportParamsInStartSessionAck(
const uint8_t input_protocol_version = 5;
const uint32_t hash_id = 123456;
- ProtocolPacket::ProtocolVersion full_version(5, 1, 0);
+ utils::SemanticVersion full_version(5, 1, 0);
char full_version_string[] = "5.1.0";
// configuration setup
@@ -2030,7 +2031,7 @@ TEST_F(ProtocolHandlerImplTest,
const uint8_t input_protocol_version = 5;
const uint32_t hash_id = 123456;
- ProtocolPacket::ProtocolVersion full_version(5, 0, 0);
+ utils::SemanticVersion full_version(5, 0, 0);
char full_version_string[] = "5.0.0";
const size_t maximum_rpc_payload_size = 1500;
@@ -2190,7 +2191,7 @@ TEST_F(ProtocolHandlerImplTest,
const uint8_t input_protocol_version = 5;
const uint32_t hash_id = 123456;
- ProtocolPacket::ProtocolVersion full_version(5, 1, 0);
+ utils::SemanticVersion full_version(5, 1, 0);
const size_t maximum_rpc_payload_size = 1500;
EXPECT_CALL(protocol_handler_settings_mock, maximum_rpc_payload_size())
@@ -2313,7 +2314,7 @@ TEST_F(ProtocolHandlerImplTest,
const uint8_t input_protocol_version = 5;
const uint32_t hash_id = 123456;
- ProtocolPacket::ProtocolVersion full_version(5, 1, 0);
+ utils::SemanticVersion full_version(5, 1, 0);
const size_t maximum_rpc_payload_size = 1500;
EXPECT_CALL(protocol_handler_settings_mock, maximum_rpc_payload_size())
diff --git a/src/components/smart_objects/include/smart_objects/always_false_schema_item.h b/src/components/smart_objects/include/smart_objects/always_false_schema_item.h
index 87e5d31ae9..a7b93012bb 100644
--- a/src/components/smart_objects/include/smart_objects/always_false_schema_item.h
+++ b/src/components/smart_objects/include/smart_objects/always_false_schema_item.h
@@ -54,14 +54,7 @@ class CAlwaysFalseSchemaItem : public ISchemaItem {
* @return Errors::ERROR
**/
Errors::eType validate(const SmartObject& Object) OVERRIDE;
- /**
- * @brief Validate smart object.
- * @param Object Object to validate.
- * @param report__ object for reporting errors during validation
- * @return Errors::ERROR
- **/
- Errors::eType validate(const SmartObject& Object,
- rpc::ValidationReport* report__) OVERRIDE;
+
/**
* @brief Validate smart object.
* @param Object Object to validate.
@@ -71,7 +64,8 @@ class CAlwaysFalseSchemaItem : public ISchemaItem {
**/
Errors::eType validate(const SmartObject& Object,
rpc::ValidationReport* report__,
- const utils::SemanticVersion& MessageVersion) OVERRIDE;
+ const utils::SemanticVersion& MessageVersion =
+ utils::SemanticVersion()) OVERRIDE;
private:
CAlwaysFalseSchemaItem();
diff --git a/src/components/smart_objects/include/smart_objects/always_true_schema_item.h b/src/components/smart_objects/include/smart_objects/always_true_schema_item.h
index ca590fecca..b025723ea6 100644
--- a/src/components/smart_objects/include/smart_objects/always_true_schema_item.h
+++ b/src/components/smart_objects/include/smart_objects/always_true_schema_item.h
@@ -54,14 +54,6 @@ class CAlwaysTrueSchemaItem : public ISchemaItem {
* @return NsSmartObjects::Errors::eType
**/
Errors::eType validate(const SmartObject& Object) OVERRIDE;
- /**
- * @brief Validate smart object.
- * @param Object Object to validate.
- * @param report__ object for reporting errors during validation
- * @return NsSmartObjects::Errors::eType
- **/
- Errors::eType validate(const SmartObject& Object,
- rpc::ValidationReport* report__) OVERRIDE;
/**
* @brief Validate smart object.
@@ -72,7 +64,8 @@ class CAlwaysTrueSchemaItem : public ISchemaItem {
**/
Errors::eType validate(const SmartObject& Object,
rpc::ValidationReport* report__,
- const utils::SemanticVersion& MessageVersion) OVERRIDE;
+ const utils::SemanticVersion& MessageVersion =
+ utils::SemanticVersion()) OVERRIDE;
private:
CAlwaysTrueSchemaItem();
diff --git a/src/components/smart_objects/include/smart_objects/array_schema_item.h b/src/components/smart_objects/include/smart_objects/array_schema_item.h
index 69a546b558..4dc416007a 100644
--- a/src/components/smart_objects/include/smart_objects/array_schema_item.h
+++ b/src/components/smart_objects/include/smart_objects/array_schema_item.h
@@ -76,17 +76,6 @@ class CArraySchemaItem : public ISchemaItem {
/**
* @brief Validate smart object.
- *
- * @param Object Object to validate.
- * @param report__ object for reporting errors during validation
- * message if an error occurs
- *
- * @return NsSmartObjects::Errors::eType
- **/
- Errors::eType validate(const SmartObject& Object,
- rpc::ValidationReport* report__) OVERRIDE;
- /**
- * @brief Validate smart object.
* @param Object Object to validate.
* @param report__ object for reporting errors during validation
* @param MessageVersion to check mobile RPC version against RPC Spec History
@@ -94,7 +83,8 @@ class CArraySchemaItem : public ISchemaItem {
**/
Errors::eType validate(const SmartObject& Object,
rpc::ValidationReport* report__,
- const utils::SemanticVersion& MessageVersion) OVERRIDE;
+ const utils::SemanticVersion& MessageVersion =
+ utils::SemanticVersion()) OVERRIDE;
/**
* @brief Apply schema.
diff --git a/src/components/smart_objects/include/smart_objects/default_shema_item.h b/src/components/smart_objects/include/smart_objects/default_shema_item.h
index b094091336..7d5b33b1a6 100644
--- a/src/components/smart_objects/include/smart_objects/default_shema_item.h
+++ b/src/components/smart_objects/include/smart_objects/default_shema_item.h
@@ -55,14 +55,6 @@ class CDefaultSchemaItem : public ISchemaItem {
* @return Errors::ERROR
**/
Errors::eType validate(const SmartObject& Object) OVERRIDE;
- /**
- * @brief Validate smart object.
- * @param Object Object to validate.
- * @param report__ object for reporting errors during validation
- * @return Errors::ERROR
- **/
- Errors::eType validate(const SmartObject& Object,
- rpc::ValidationReport* report__) OVERRIDE;
/**
* @brief Validate smart object.
@@ -73,7 +65,8 @@ class CDefaultSchemaItem : public ISchemaItem {
**/
Errors::eType validate(const SmartObject& Object,
rpc::ValidationReport* report__,
- const utils::SemanticVersion& MessageVersion) OVERRIDE;
+ const utils::SemanticVersion& MessageVersion =
+ utils::SemanticVersion()) OVERRIDE;
/**
* @brief Set default value to an object.
@@ -124,7 +117,9 @@ Errors::eType CDefaultSchemaItem<Type>::validate(const SmartObject& Object) {
template <typename Type>
Errors::eType CDefaultSchemaItem<Type>::validate(
- const SmartObject& Object, rpc::ValidationReport* report__) {
+ const SmartObject& Object,
+ rpc::ValidationReport* report__,
+ const utils::SemanticVersion& MessageVersion) {
if (getSmartType() != Object.getType()) {
std::string validation_info = "Incorrect type, expected: " +
SmartObject::typeToString(getSmartType()) +
@@ -138,14 +133,6 @@ Errors::eType CDefaultSchemaItem<Type>::validate(
}
template <typename Type>
-Errors::eType CDefaultSchemaItem<Type>::validate(
- const SmartObject& Object,
- rpc::ValidationReport* report__,
- const utils::SemanticVersion& MessageVersion) {
- return validate(Object, report__);
-}
-
-template <typename Type>
bool CDefaultSchemaItem<Type>::setDefaultValue(SmartObject& Object) {
Type value;
if (mDefaultValue.getValue(value)) {
diff --git a/src/components/smart_objects/include/smart_objects/enum_schema_item.h b/src/components/smart_objects/include/smart_objects/enum_schema_item.h
index 54de61d4e5..41102933f3 100644
--- a/src/components/smart_objects/include/smart_objects/enum_schema_item.h
+++ b/src/components/smart_objects/include/smart_objects/enum_schema_item.h
@@ -47,12 +47,6 @@
namespace NsSmartDeviceLink {
namespace NsSmartObjects {
-// Element Signature for enums. Fields represent "since", "until", and "removed"
-// typedef boost::optional<std::string> OptionalString;
-// typedef boost::optional<bool> OptionalBool;
-// typedef std::tuple<OptionalString, OptionalString, OptionalBool>
-// ElementSignature;
-
struct ElementSignature {
boost::optional<utils::SemanticVersion> mSince;
boost::optional<utils::SemanticVersion> mUntil;
@@ -76,9 +70,6 @@ struct ElementSignature {
}
};
-// typedef std::map<OptionalString, OptionalString, OptionalBool>
-// ElementSignature;
-
template <typename EnumType>
class EnumConversionHelper;
/**
@@ -118,14 +109,6 @@ class TEnumSchemaItem : public CDefaultSchemaItem<EnumType> {
* @return NsSmartObjects::Errors::eType
**/
Errors::eType validate(const SmartObject& Object) OVERRIDE;
- /**
- * @brief Validate smart object.
- * @param Object Object to validate.
- * @param report__ object for reporting errors during validation
- * @return NsSmartObjects::Errors::eType
- **/
- Errors::eType validate(const SmartObject& Object,
- rpc::ValidationReport* report__) OVERRIDE;
/**
* @brief Validate smart object.
@@ -136,7 +119,17 @@ class TEnumSchemaItem : public CDefaultSchemaItem<EnumType> {
**/
Errors::eType validate(const SmartObject& Object,
rpc::ValidationReport* report__,
- const utils::SemanticVersion& MessageVersion) OVERRIDE;
+ const utils::SemanticVersion& MessageVersion =
+ utils::SemanticVersion()) OVERRIDE;
+ /**
+ * @brief Return the correct history signature based on message version.
+ * @param signatures Vector reference of enums history items.
+ * @param MessageVersion RPC Version of mobile app.
+ **/
+ const ElementSignature getSignature(
+ const std::vector<ElementSignature>& signatures,
+ const utils::SemanticVersion& MessageVersion);
+
/**
* @brief Apply schema.
* This implementation checks if enumeration is represented as string
@@ -299,30 +292,28 @@ Errors::eType TEnumSchemaItem<EnumType>::validate(const SmartObject& Object) {
}
template <typename EnumType>
-Errors::eType TEnumSchemaItem<EnumType>::validate(
- const SmartObject& Object, rpc::ValidationReport* report__) {
- if (SmartType_Integer != Object.getType()) {
- std::string validation_info;
- if (SmartType_String == Object.getType()) {
- validation_info = "Invalid enum value: " + Object.asString();
- } else {
- validation_info = "Incorrect type, expected: " +
- SmartObject::typeToString(SmartType_Integer) +
- " (enum), got: " +
- SmartObject::typeToString(Object.getType());
+const ElementSignature TEnumSchemaItem<EnumType>::getSignature(
+ const std::vector<ElementSignature>& signatures,
+ const utils::SemanticVersion& MessageVersion) {
+ for (uint i = 0; i < signatures.size(); i++) {
+ ElementSignature signature = signatures[i];
+ // Check if signature matches message version
+ if (signature.mSince != boost::none &&
+ MessageVersion < signature.mSince.get()) {
+ // Msg version predates 'since' field, check next entry
+ continue;
}
- report__->set_validation_info(validation_info);
- return Errors::INVALID_VALUE;
- }
- if (mAllowedElements.find(static_cast<EnumType>(Object.asInt())) ==
- mAllowedElements.end()) {
- std::stringstream stream;
- stream << "Invalid enum value: " << Object.asInt();
- std::string validation_info = stream.str();
- report__->set_validation_info(validation_info);
- return Errors::OUT_OF_RANGE;
+ if (signature.mUntil != boost::none &&
+ (MessageVersion >= signature.mUntil.get())) {
+ continue; // Msg version newer than `until` field, check next entry
+ }
+ // Found correct signature
+ return signature;
}
- return Errors::OK;
+
+ // Could not match msg version to element siganture
+ ElementSignature ret;
+ return ret;
}
template <typename EnumType>
@@ -361,60 +352,27 @@ Errors::eType TEnumSchemaItem<EnumType>::validate(
auto signatures_it = mElementSignatures.find(value);
if (signatures_it != mElementSignatures.end()) {
if (!signatures_it->second.empty()) {
- for (uint i = 0; i < signatures_it->second.size(); i++) {
- ElementSignature signature = signatures_it->second[i];
- // Check if signature matches message version
- if (signature.mSince.is_initialized()) {
- if (MessageVersion < signature.mSince.get()) {
- // Msg version predates 'since' field, check next entry
- continue;
- } else {
- if (signature.mUntil.is_initialized() &&
- (MessageVersion >= signature.mUntil.get())) {
- continue; // Msg version newer than `until` field
- } else {
- // Found correct version
- if (signature.mRemoved) {
- // Element was removed for this version
- std::string validation_info = "Invalid enum value: " +
- Object.asString() +
- " removed for SyncMsgVersion " +
- MessageVersion.toString();
- report__->set_validation_info(validation_info);
- return Errors::INVALID_VALUE;
- }
- return Errors::OK; // Mobile msg version falls within specified
- // version range and is not removed
- }
- }
- } // end if signature.mSince.is_initialized()
-
- if (signature.mUntil.is_initialized() &&
- (MessageVersion >= signature.mUntil.get())) {
- continue; // Msg version newer than `until` field, check next entry
- } else {
- // Found correct version
- if (signature.mRemoved) {
- // Element was removed for this version
- std::string validation_info =
- "Enum value : " + Object.asString() +
- " removed for SyncMsgVersion " + MessageVersion.toString();
- report__->set_validation_info(validation_info);
- return Errors::INVALID_VALUE;
- }
- return Errors::OK; // Mobile msg version falls within specified
- // version range and is not removed
- }
- } // End For Loop Version not found.
- std::string validation_info =
- "Invalid enum value: " + Object.asString() +
- " for SyncMsgVersion " + MessageVersion.toString();
- report__->set_validation_info(validation_info);
- return Errors::INVALID_VALUE;
+ ElementSignature signature =
+ getSignature(signatures_it->second, MessageVersion);
+ if (signature.mRemoved) {
+ // Element was removed for this version
+ std::string validation_info = "Enum value : " + Object.asString() +
+ " removed for SyncMsgVersion " +
+ MessageVersion.toString();
+ report__->set_validation_info(validation_info);
+ return Errors::INVALID_VALUE;
+ } else if (signature.mSince == boost::none &&
+ signature.mUntil == boost::none) {
+ // Element does not exist for this version
+ std::string validation_info = "Enum value : " + Object.asString() +
+ " does not exist for SyncMsgVersion " +
+ MessageVersion.toString();
+ report__->set_validation_info(validation_info);
+ return Errors::INVALID_VALUE;
+ }
}
}
}
-
return Errors::OK;
}
@@ -464,9 +422,8 @@ TEnumSchemaItem<EnumType>::TEnumSchemaItem(
const TSchemaItemParameter<EnumType>& DefaultValue,
const std::map<EnumType, std::vector<ElementSignature> >& ElementSignatures)
: CDefaultSchemaItem<EnumType>(DefaultValue)
- , mAllowedElements(AllowedElements) {
- mElementSignatures = ElementSignatures;
-}
+ , mAllowedElements(AllowedElements)
+ , mElementSignatures(ElementSignatures) {}
} // namespace NsSmartObjects
} // namespace NsSmartDeviceLink
diff --git a/src/components/smart_objects/include/smart_objects/number_schema_item.h b/src/components/smart_objects/include/smart_objects/number_schema_item.h
index ee82b87241..0f3246ef5f 100644
--- a/src/components/smart_objects/include/smart_objects/number_schema_item.h
+++ b/src/components/smart_objects/include/smart_objects/number_schema_item.h
@@ -72,14 +72,6 @@ class TNumberSchemaItem : public CDefaultSchemaItem<NumberType> {
* @return Errors::ERROR
**/
Errors::eType validate(const SmartObject& Object) OVERRIDE;
- /**
- * @brief Validate smart object.
- * @param Object Object to validate.
- * @param report__ object for reporting errors during validation
- * @return Errors::ERROR
- **/
- Errors::eType validate(const SmartObject& Object,
- rpc::ValidationReport* report__) OVERRIDE;
/**
* @brief Validate smart object.
@@ -90,7 +82,8 @@ class TNumberSchemaItem : public CDefaultSchemaItem<NumberType> {
**/
Errors::eType validate(const SmartObject& Object,
rpc::ValidationReport* report__,
- const utils::SemanticVersion& MessageVersion) OVERRIDE;
+ const utils::SemanticVersion& MessageVersion =
+ utils::SemanticVersion()) OVERRIDE;
private:
/**
@@ -157,7 +150,9 @@ Errors::eType TNumberSchemaItem<NumberType>::validate(
template <typename NumberType>
Errors::eType TNumberSchemaItem<NumberType>::validate(
- const SmartObject& Object, rpc::ValidationReport* report__) {
+ const SmartObject& Object,
+ rpc::ValidationReport* report__,
+ const utils::SemanticVersion& MessageVersion) {
if (!isValidNumberType(Object.getType())) {
SmartType expectedType = (typeid(double) == typeid(Object.getType()))
? SmartType_Double
@@ -205,14 +200,6 @@ Errors::eType TNumberSchemaItem<NumberType>::validate(
}
template <typename NumberType>
-Errors::eType TNumberSchemaItem<NumberType>::validate(
- const SmartObject& Object,
- rpc::ValidationReport* report__,
- const utils::SemanticVersion& MessageVersion) {
- return validate(Object, report__);
-}
-
-template <typename NumberType>
TNumberSchemaItem<NumberType>::TNumberSchemaItem(
const TSchemaItemParameter<NumberType>& MinValue,
const TSchemaItemParameter<NumberType>& MaxValue,
diff --git a/src/components/smart_objects/include/smart_objects/object_schema_item.h b/src/components/smart_objects/include/smart_objects/object_schema_item.h
index 4a36f06f3c..4785211694 100644
--- a/src/components/smart_objects/include/smart_objects/object_schema_item.h
+++ b/src/components/smart_objects/include/smart_objects/object_schema_item.h
@@ -64,7 +64,6 @@ class CObjectSchemaItem : public ISchemaItem {
* @param IsMandatory true if member is mandatory, false
* otherwise. Defaults to true.
**/
- // SMember(const ISchemaItemPtr SchemaItem, const bool IsMandatory = true);
SMember(const ISchemaItemPtr SchemaItem,
const bool IsMandatory = true,
@@ -111,14 +110,7 @@ class CObjectSchemaItem : public ISchemaItem {
* @return NsSmartObjects::Errors::eType
**/
Errors::eType validate(const SmartObject& Object) OVERRIDE;
- /**
- * @brief Validate smart object.
- * @param Object Object to validate.
- * @param report__ object for reporting errors during validation
- * @return NsSmartObjects::Errors::eType
- **/
- Errors::eType validate(const SmartObject& Object,
- rpc::ValidationReport* report__) OVERRIDE;
+
/**
* @brief Validate smart object.
* @param Object Object to validate.
@@ -128,7 +120,8 @@ class CObjectSchemaItem : public ISchemaItem {
**/
Errors::eType validate(const SmartObject& Object,
rpc::ValidationReport* report__,
- const utils::SemanticVersion& MessageVersion) OVERRIDE;
+ const utils::SemanticVersion& MessageVersion =
+ utils::SemanticVersion()) OVERRIDE;
/**
* @brief Apply schema.
* @param Object Object to apply schema.
@@ -174,11 +167,12 @@ class CObjectSchemaItem : public ISchemaItem {
const utils::SemanticVersion& MessageVersion);
/**
- * @brief Checks mandatory and version fields to see
- * if a member is required.
- * @param Object Object to remove fake parameters.
+ * @brief Returns the correct schema item based on message version.
+ * @param member Schema member
+ * @param MmessageVersion Semantic Version of mobile message.
**/
- bool IsMandatory(const SMember& member);
+ const CObjectSchemaItem::SMember& GetCorrectMember(
+ const SMember& member, const utils::SemanticVersion& messageVersion);
/**
* @brief Map of member name to SMember structure describing the object
diff --git a/src/components/smart_objects/include/smart_objects/schema_item.h b/src/components/smart_objects/include/smart_objects/schema_item.h
index 828dac33f0..2e951f7f9f 100644
--- a/src/components/smart_objects/include/smart_objects/schema_item.h
+++ b/src/components/smart_objects/include/smart_objects/schema_item.h
@@ -68,24 +68,13 @@ class ISchemaItem {
* @param Object Object to validate.
* @param report__ object for reporting errors during validation
* message if an error occurs
- *
- * @return NsSmartObjects::Errors::eType
- **/
- virtual Errors::eType validate(const SmartObject& Object,
- rpc::ValidationReport* report__);
-
- /**
- * @brief Validate smart object.
- *
- * @param Object Object to validate.
- * @param report__ object for reporting errors during validation
- * message if an error occurs
* @param MessageVersion to check mobile RPC version against RPC Spec Histor
* @return NsSmartObjects::Errors::eType
**/
- virtual Errors::eType validate(const SmartObject& Object,
- rpc::ValidationReport* report__,
- const utils::SemanticVersion& MessageVersion);
+ virtual Errors::eType validate(
+ const SmartObject& Object,
+ rpc::ValidationReport* report__,
+ const utils::SemanticVersion& MessageVersion = utils::SemanticVersion());
/**
* @brief Set default value to an object.
diff --git a/src/components/smart_objects/include/smart_objects/smart_object.h b/src/components/smart_objects/include/smart_objects/smart_object.h
index f594ad9820..d81e18569f 100644
--- a/src/components/smart_objects/include/smart_objects/smart_object.h
+++ b/src/components/smart_objects/include/smart_objects/smart_object.h
@@ -682,19 +682,12 @@ class SmartObject FINAL {
* @brief Validates object according to attached schema.
*
* @param report__ object for reporting errors during validation
- * @return Result of validation.
- */
- Errors::eType validate(rpc::ValidationReport* report__);
-
- /**
- * @brief Validates object according to attached schema.
- *
- * @param report__ object for reporting errors during validation
* @param messageVersion of the mobile app to check against RPC Spec Schema
* @return Result of validation.
*/
- Errors::eType validate(rpc::ValidationReport* report__,
- const utils::SemanticVersion& MessageVersion);
+ Errors::eType validate(
+ rpc::ValidationReport* report__,
+ const utils::SemanticVersion& MessageVersion = utils::SemanticVersion());
/**
* @brief Sets new schema
diff --git a/src/components/smart_objects/include/smart_objects/smart_schema.h b/src/components/smart_objects/include/smart_objects/smart_schema.h
index 5ab96e82bd..d3fcc0e28d 100644
--- a/src/components/smart_objects/include/smart_objects/smart_schema.h
+++ b/src/components/smart_objects/include/smart_objects/smart_schema.h
@@ -76,23 +76,13 @@ class CSmartSchema FINAL {
*
* @param Object Object to validate.
* @param report__ object for reporting errors during validation
- *
- * @return NsSmartObjects::Errors::eType
- **/
- Errors::eType validate(const SmartObject& Object,
- rpc::ValidationReport* report__) const;
-
- /**
- * @brief Validate smart object.
- *
- * @param Object Object to validate.
- * @param report__ object for reporting errors during validation
* @param MessageVersion to check mobile RPC version against RPC Spec History
* @return NsSmartObjects::Errors::eType
**/
Errors::eType validate(const SmartObject& Object,
rpc::ValidationReport* report__,
- const utils::SemanticVersion& messageVersion) const;
+ const utils::SemanticVersion& messageVersion =
+ utils::SemanticVersion()) const;
/**
* @brief Set new root schema item.
diff --git a/src/components/smart_objects/include/smart_objects/string_schema_item.h b/src/components/smart_objects/include/smart_objects/string_schema_item.h
index 4d5f18f711..dcaad364b2 100644
--- a/src/components/smart_objects/include/smart_objects/string_schema_item.h
+++ b/src/components/smart_objects/include/smart_objects/string_schema_item.h
@@ -66,14 +66,7 @@ class CStringSchemaItem : public CDefaultSchemaItem<std::string> {
* @return NsSmartObjects::Errors::eType
**/
Errors::eType validate(const SmartObject& Object) OVERRIDE;
- /**
- * @brief Validate smart object.
- * @param Object Object to validate.
- * @param report__ object for reporting errors during validation
- * @return NsSmartObjects::Errors::eType
- **/
- Errors::eType validate(const SmartObject& Object,
- rpc::ValidationReport* report__) OVERRIDE;
+
/**
* @brief Validate smart object.
* @param Object Object to validate.
@@ -83,7 +76,8 @@ class CStringSchemaItem : public CDefaultSchemaItem<std::string> {
**/
Errors::eType validate(const SmartObject& Object,
rpc::ValidationReport* report__,
- const utils::SemanticVersion& MessageVersion) OVERRIDE;
+ const utils::SemanticVersion& MessageVersion =
+ utils::SemanticVersion()) OVERRIDE;
private:
/**
diff --git a/src/components/smart_objects/src/always_false_schema_item.cc b/src/components/smart_objects/src/always_false_schema_item.cc
index acbe15485b..db16640265 100644
--- a/src/components/smart_objects/src/always_false_schema_item.cc
+++ b/src/components/smart_objects/src/always_false_schema_item.cc
@@ -47,12 +47,6 @@ Errors::eType CAlwaysFalseSchemaItem::validate(const SmartObject& object) {
}
Errors::eType CAlwaysFalseSchemaItem::validate(
- const SmartObject& object, rpc::ValidationReport* report__) {
- report__->set_validation_info("Generic error");
- return Errors::ERROR;
-}
-
-Errors::eType CAlwaysFalseSchemaItem::validate(
const SmartObject& Object,
rpc::ValidationReport* report__,
const utils::SemanticVersion& MessageVersion) {
diff --git a/src/components/smart_objects/src/always_true_schema_item.cc b/src/components/smart_objects/src/always_true_schema_item.cc
index 8a72d606a0..0a3b8be134 100644
--- a/src/components/smart_objects/src/always_true_schema_item.cc
+++ b/src/components/smart_objects/src/always_true_schema_item.cc
@@ -43,11 +43,6 @@ Errors::eType CAlwaysTrueSchemaItem::validate(const SmartObject& object) {
return Errors::OK;
}
-Errors::eType CAlwaysTrueSchemaItem::validate(const SmartObject& object,
- rpc::ValidationReport* report__) {
- return Errors::OK;
-}
-
Errors::eType CAlwaysTrueSchemaItem::validate(
const SmartObject& Object,
rpc::ValidationReport* report__,
diff --git a/src/components/smart_objects/src/array_schema_item.cc b/src/components/smart_objects/src/array_schema_item.cc
index 108bccce11..60081c5222 100644
--- a/src/components/smart_objects/src/array_schema_item.cc
+++ b/src/components/smart_objects/src/array_schema_item.cc
@@ -47,48 +47,6 @@ Errors::eType CArraySchemaItem::validate(const SmartObject& Object) {
return validate(Object, &report);
}
-Errors::eType CArraySchemaItem::validate(const SmartObject& Object,
- rpc::ValidationReport* report__) {
- if (SmartType_Array != Object.getType()) {
- std::string validation_info = "Incorrect type, expected: " +
- SmartObject::typeToString(SmartType_Array) +
- ", got: " +
- SmartObject::typeToString(Object.getType());
- report__->set_validation_info(validation_info);
- return Errors::INVALID_VALUE;
- }
- size_t sizeLimit;
- const size_t array_len = Object.length();
-
- if (mMinSize.getValue(sizeLimit) && (array_len < sizeLimit)) {
- std::stringstream stream;
- stream << "Got array of size: " << array_len
- << ", minimum allowed: " << sizeLimit;
- std::string validation_info = stream.str();
- report__->set_validation_info(validation_info);
- return Errors::OUT_OF_RANGE;
- }
- if (mMaxSize.getValue(sizeLimit) && (array_len > sizeLimit)) {
- std::stringstream stream;
- stream << "Got array of size: " << array_len
- << ", maximum allowed: " << sizeLimit;
- std::string validation_info = stream.str();
- report__->set_validation_info(validation_info);
- return Errors::OUT_OF_RANGE;
- }
-
- for (size_t i = 0u; i < array_len; ++i) {
- std::stringstream strVal;
- strVal << i;
- const Errors::eType result = mElementSchemaItem->validate(
- Object.getElement(i), &report__->ReportSubobject(strVal.str()));
- if (Errors::OK != result) {
- return result;
- }
- }
- return Errors::OK;
-}
-
Errors::eType CArraySchemaItem::validate(
const SmartObject& Object,
rpc::ValidationReport* report__,
diff --git a/src/components/smart_objects/src/object_schema_item.cc b/src/components/smart_objects/src/object_schema_item.cc
index d046e49bcd..879c280a67 100644
--- a/src/components/smart_objects/src/object_schema_item.cc
+++ b/src/components/smart_objects/src/object_schema_item.cc
@@ -109,44 +109,6 @@ Errors::eType CObjectSchemaItem::validate(const SmartObject& object) {
return validate(object, &report);
}
-Errors::eType CObjectSchemaItem::validate(const SmartObject& object,
- rpc::ValidationReport* report__) {
- if (SmartType_Map != object.getType()) {
- std::string validation_info = "Incorrect type, expected: " +
- SmartObject::typeToString(SmartType_Map) +
- ", got: " +
- SmartObject::typeToString(object.getType());
- report__->set_validation_info(validation_info);
- return Errors::INVALID_VALUE;
- }
-
- std::set<std::string> object_keys = object.enumerate();
-
- for (Members::const_iterator it = mMembers.begin(); it != mMembers.end();
- ++it) {
- const std::string& key = it->first;
- const SMember& member = it->second;
-
- std::set<std::string>::const_iterator key_it = object_keys.find(key);
- if (object_keys.end() == key_it) {
- if (member.mIsMandatory) {
- std::string validation_info = "Missing mandatory parameter: " + key;
- report__->set_validation_info(validation_info);
- return Errors::MISSING_MANDATORY_PARAMETER;
- }
- continue;
- }
- const SmartObject& field = object.getElement(key);
- const Errors::eType result =
- member.mSchemaItem->validate(field, &report__->ReportSubobject(key));
- if (Errors::OK != result) {
- return result;
- }
- object_keys.erase(key_it);
- }
- return Errors::OK;
-}
-
Errors::eType CObjectSchemaItem::validate(
const SmartObject& object,
rpc::ValidationReport* report__,
@@ -166,45 +128,12 @@ Errors::eType CObjectSchemaItem::validate(
++it) {
const std::string& key = it->first;
const SMember& member = it->second;
+ const SMember& correct_member = GetCorrectMember(member, MessageVersion);
+
std::set<std::string>::const_iterator key_it = object_keys.find(key);
if (object_keys.end() == key_it) {
- if (member.mSince != boost::none &&
- MessageVersion < member.mSince.get() &&
- member.mHistoryVector.size() > 0) {
- // Message version predates parameter and a history vector exists.
- for (uint i = 0; i < member.mHistoryVector.size(); i++) {
- if (member.mHistoryVector[i].mSince != boost::none &&
- MessageVersion >= member.mHistoryVector[i].mSince.get()) {
- if (member.mHistoryVector[i].mUntil != boost::none &&
- MessageVersion >= member.mHistoryVector[i].mUntil.get()) {
- // MessageVersion is newer than the specified "Until" version
- continue;
- } else {
- if (member.mHistoryVector[i].mIsMandatory == true &&
- (member.mHistoryVector[i].mIsRemoved == false)) {
- std::string validation_info =
- "Missing mandatory parameter since and until: " + key;
- report__->set_validation_info(validation_info);
- return Errors::MISSING_MANDATORY_PARAMETER;
- }
- break;
- }
- } else if (member.mHistoryVector[i].mSince == boost::none &&
- member.mHistoryVector[i].mUntil != boost::none &&
- MessageVersion < member.mHistoryVector[i].mUntil.get()) {
- if (member.mHistoryVector[i].mIsMandatory == true &&
- (member.mHistoryVector[i].mIsRemoved == false)) {
- std::string validation_info =
- "Missing mandatory parameter until: " + key;
- report__->set_validation_info(validation_info);
- return Errors::MISSING_MANDATORY_PARAMETER;
- }
- break;
- }
- }
- } else if (member.mIsMandatory &&
- member.CheckHistoryFieldVersion(MessageVersion) &&
- (member.mIsMandatory == false)) {
+ if (correct_member.mIsMandatory == true &&
+ correct_member.mIsRemoved == false) {
std::string validation_info = "Missing mandatory parameter: " + key;
report__->set_validation_info(validation_info);
return Errors::MISSING_MANDATORY_PARAMETER;
@@ -215,19 +144,8 @@ Errors::eType CObjectSchemaItem::validate(
Errors::eType result = Errors::OK;
// Check if MessageVersion matches schema version
- if (member.CheckHistoryFieldVersion(MessageVersion) ||
- member.mHistoryVector.empty()) {
- result = member.mSchemaItem->validate(
- field, &report__->ReportSubobject(key), MessageVersion);
- } else if (member.mHistoryVector.size() > 0) { // Check for history
- for (uint i = 0; i < member.mHistoryVector.size(); i++) {
- if (member.mHistoryVector[i].CheckHistoryFieldVersion(MessageVersion)) {
- // Found the correct history schema. Call validate
- result = member.mHistoryVector[i].mSchemaItem->validate(
- field, &report__->ReportSubobject(key), MessageVersion);
- }
- }
- }
+ result = correct_member.mSchemaItem->validate(
+ field, &report__->ReportSubobject(key), MessageVersion);
if (Errors::OK != result) {
return result;
}
@@ -328,30 +246,34 @@ void CObjectSchemaItem::RemoveFakeParams(
key.compare(app_id) != 0) {
++it;
Object.erase(key);
- } else if (mMembers.end() != members_it && members_it->second.mIsRemoved &&
- members_it->second.CheckHistoryFieldVersion(MessageVersion)) {
- ++it;
- Object.erase(key);
+
} else if (mMembers.end() != members_it &&
- members_it->second.mHistoryVector.size() > 0) {
- for (uint i = 0; i < members_it->second.mHistoryVector.size(); i++) {
- if (members_it->second.mHistoryVector[i].CheckHistoryFieldVersion(
- MessageVersion) &&
- members_it->second.mHistoryVector[i].mIsRemoved) {
- ++it;
- Object.erase(key);
- break;
- }
- }
+ GetCorrectMember(members_it->second, MessageVersion)
+ .mIsRemoved) {
++it;
+ Object.erase(key);
} else {
++it;
}
}
}
-bool CObjectSchemaItem::IsMandatory(const SMember& member) {
- return true;
+const CObjectSchemaItem::SMember& CObjectSchemaItem::GetCorrectMember(
+ const SMember& member, const utils::SemanticVersion& messageVersion) {
+ // Check if member is the correct version
+ if (member.CheckHistoryFieldVersion(messageVersion)) {
+ return member;
+ }
+ // Check for history tag items
+ if (!member.mHistoryVector.empty()) {
+ for (uint i = 0; i < member.mHistoryVector.size(); i++) {
+ if (member.mHistoryVector[i].CheckHistoryFieldVersion(messageVersion)) {
+ return member.mHistoryVector[i];
+ }
+ }
+ }
+ // Return member as default
+ return member;
}
} // namespace NsSmartObjects
diff --git a/src/components/smart_objects/src/schema_item.cc b/src/components/smart_objects/src/schema_item.cc
index 001aa5fc5d..ae7f3665bb 100644
--- a/src/components/smart_objects/src/schema_item.cc
+++ b/src/components/smart_objects/src/schema_item.cc
@@ -39,11 +39,6 @@ Errors::eType ISchemaItem::validate(const SmartObject& Object) {
return Errors::ERROR;
}
-Errors::eType ISchemaItem::validate(const SmartObject& object,
- rpc::ValidationReport* report__) {
- return Errors::ERROR;
-}
-
Errors::eType ISchemaItem::validate(
const SmartObject& object,
rpc::ValidationReport* report__,
diff --git a/src/components/smart_objects/src/smart_object.cc b/src/components/smart_objects/src/smart_object.cc
index 527a4308f8..691f45f63b 100644
--- a/src/components/smart_objects/src/smart_object.cc
+++ b/src/components/smart_objects/src/smart_object.cc
@@ -878,10 +878,6 @@ Errors::eType SmartObject::validate() {
return validate(&report);
}
-Errors::eType SmartObject::validate(rpc::ValidationReport* report__) {
- return m_schema.validate(*this, report__);
-}
-
Errors::eType SmartObject::validate(
rpc::ValidationReport* report__,
const utils::SemanticVersion& MessageVersion) {
diff --git a/src/components/smart_objects/src/smart_schema.cc b/src/components/smart_objects/src/smart_schema.cc
index 154f9e116f..3ab94caf85 100644
--- a/src/components/smart_objects/src/smart_schema.cc
+++ b/src/components/smart_objects/src/smart_schema.cc
@@ -45,11 +45,6 @@ Errors::eType CSmartSchema::validate(const SmartObject& Object) const {
return validate(Object, &report);
}
-Errors::eType CSmartSchema::validate(const SmartObject& object,
- rpc::ValidationReport* report__) const {
- return mSchemaItem->validate(object, report__);
-}
-
Errors::eType CSmartSchema::validate(
const SmartObject& object,
rpc::ValidationReport* report__,
diff --git a/src/components/smart_objects/src/string_schema_item.cc b/src/components/smart_objects/src/string_schema_item.cc
index cc6bf79f60..f3c39eff8f 100644
--- a/src/components/smart_objects/src/string_schema_item.cc
+++ b/src/components/smart_objects/src/string_schema_item.cc
@@ -51,8 +51,10 @@ Errors::eType CStringSchemaItem::validate(const SmartObject& Object) {
return validate(Object, &report);
}
-Errors::eType CStringSchemaItem::validate(const SmartObject& Object,
- rpc::ValidationReport* report__) {
+Errors::eType CStringSchemaItem::validate(
+ const SmartObject& Object,
+ rpc::ValidationReport* report__,
+ const utils::SemanticVersion& MessageVersion) {
if (SmartType_String != Object.getType()) {
std::string validation_info = "Incorrect type, expected: " +
SmartObject::typeToString(SmartType_String) +
@@ -84,13 +86,6 @@ Errors::eType CStringSchemaItem::validate(const SmartObject& Object,
return Errors::OK;
}
-Errors::eType CStringSchemaItem::validate(
- const SmartObject& Object,
- rpc::ValidationReport* report__,
- const utils::SemanticVersion& MessageVersion) {
- return validate(Object, report__);
-}
-
SmartType CStringSchemaItem::getSmartType() const {
return SmartType_String;
}
diff --git a/tools/InterfaceGenerator/generator/generators/SmartFactoryBase.py b/tools/InterfaceGenerator/generator/generators/SmartFactoryBase.py
index 47a2e92c79..6546b0ea89 100755
--- a/tools/InterfaceGenerator/generator/generators/SmartFactoryBase.py
+++ b/tools/InterfaceGenerator/generator/generators/SmartFactoryBase.py
@@ -706,9 +706,6 @@ class CodeGenerator(object):
"""
result_array = []
result_array.append(self._impl_code_shared_ptr_vector_template.substitute(var_name = name))
- '''for item in history_list:
- result_array.append(self._impl_code_append_history_vector_template.substitute(vector_name=name, item_name=item.name))
-'''
result = u"\n".join(result_array)
return result
@@ -911,6 +908,33 @@ class CodeGenerator(object):
raise GenerateError("Unexpected call to the unimplemented function.")
+ def _check_member_history(self, member):
+ """
+ Checks set of rules that history items are valid
+ Raises error if rules are violated
+ """
+ if (member.since is None and
+ member.until is None and
+ member.deprecated is None and
+ member.removed is None and
+ member.history is None):
+ return
+ if (member.history is not None and member.since is None):
+ raise GenerateError("Error: Missing since version parameter for " + member.name)
+ if (member.until is not None):
+ raise GenerateError("Error: Until should only exist in history tag for " + member.name)
+ if (member.history is None):
+ if(member.until is not None or
+ member.deprecated is not None or
+ member.removed is not None):
+ raise GenerateError("Error: No history present for " + member.name)
+ if (member.deprecated is not None and member.removed is not None):
+ raise GenerateError("Error: Deprecated and removed should not be present together for " + member.name)
+ if(member.history is not None):
+ for item in member.history:
+ if item.since is None or item.until is None:
+ raise GenerateError("Error: History items require since and until parameters for " + member.name)
+
def _gen_schema_item_fill(self, member, since, until, deprecated, removed):
"""Generate schema item fill code.
@@ -923,14 +947,10 @@ class CodeGenerator(object):
String with schema item fill code.
"""
+ self._check_member_history(member)
+
if (since is not None or
- until is not None or
- deprecated is not None or
- removed is not None or
- member.since is not None or
- member.until is not None or
- member.deprecated is not None or
- member.removed is not None):
+ member.since is not None):
if member.history is not None:
return self._impl_code_item_fill_template_with_version_and_history_vector.substitute(
name=member.name,
diff --git a/tools/InterfaceGenerator/generator/parsers/RPCBase.py b/tools/InterfaceGenerator/generator/parsers/RPCBase.py
index ffb54fdbfc..21f07e6ac5 100755
--- a/tools/InterfaceGenerator/generator/parsers/RPCBase.py
+++ b/tools/InterfaceGenerator/generator/parsers/RPCBase.py
@@ -889,7 +889,6 @@ class Parser(object):
return dot_str.join(version_array)
def _parse_history(self, history, prefix, parent):
- print "Pare History of Size: %d" % len(history)
if history.tag != "history":
raise ParseError("Invalid history tag: " + interface.tag)