diff options
Diffstat (limited to 'src/components/application_manager/src/mobile_message_handler.cc')
-rw-r--r-- | src/components/application_manager/src/mobile_message_handler.cc | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/src/components/application_manager/src/mobile_message_handler.cc b/src/components/application_manager/src/mobile_message_handler.cc index 22260e214..a1c838554 100644 --- a/src/components/application_manager/src/mobile_message_handler.cc +++ b/src/components/application_manager/src/mobile_message_handler.cc @@ -50,9 +50,36 @@ const uint8_t kUnknown = 0xF; } namespace application_manager { +using protocol_handler::Extract; CREATE_LOGGERPTR_GLOBAL(logger_, "MobileMessageHandler") +application_manager::Message* MobileMessageHandler::HandleIncomingMessageProtocol( + const protocol_handler::RawMessagePtr message) { + if (message->protocol_version() == ProtocolVersion::kV1) { + return MobileMessageHandler::HandleIncomingMessageProtocolV1(message); + } + if ((message->protocol_version() == ProtocolVersion::kV2) || + (message->protocol_version() == ProtocolVersion::kV3) || + (message->protocol_version() == ProtocolVersion::kV4)) { + return MobileMessageHandler::HandleIncomingMessageProtocolV2(message); + } + return NULL; +} + +protocol_handler::RawMessage* MobileMessageHandler::HandleOutgoingMessageProtocol( + const MobileMessage& message) { + if (message->protocol_version() == application_manager::kV1) { + return MobileMessageHandler::HandleOutgoingMessageProtocolV1(message); + } + if ((message->protocol_version() == application_manager::kV2) || + (message->protocol_version() == application_manager::kV3) || + (message->protocol_version() == application_manager::kV4)) { + return MobileMessageHandler::HandleOutgoingMessageProtocolV2(message); + } + return NULL; +} + application_manager::Message* MobileMessageHandler::HandleIncomingMessageProtocolV1( @@ -78,6 +105,7 @@ MobileMessageHandler::HandleIncomingMessageProtocolV1( message->data_size())); if (outgoing_message->json_message().empty()) { + delete outgoing_message; return NULL; } @@ -112,7 +140,7 @@ MobileMessageHandler::HandleIncomingMessageProtocolV2( outgoing_message->set_function_id(payload.header.rpc_function_id); outgoing_message->set_message_type( MessageTypeFromRpcType(payload.header.rpc_type)); - outgoing_message->set_correlation_id(int32_t(payload.header.corellation_id)); + outgoing_message->set_correlation_id(int32_t(payload.header.correlation_id)); outgoing_message->set_connection_key(message->connection_key()); outgoing_message->set_protocol_version( static_cast<application_manager::ProtocolVersion>(message @@ -145,6 +173,8 @@ MobileMessageHandler::HandleOutgoingMessageProtocolV1( protocol_handler::RawMessage* result = new protocol_handler::RawMessage( message->connection_key(), 1, rawMessage, messageString.length() + 1); + delete [] rawMessage; + return result; } @@ -216,6 +246,8 @@ MobileMessageHandler::HandleOutgoingMessageProtocolV2( dataForSending, dataForSendingSize); + delete [] dataForSending; + return msgToProtocolHandler; } } // namespace application_manager |