summaryrefslogtreecommitdiffstats
path: root/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src
diff options
context:
space:
mode:
authorTadao Tanikawa <tanikawa.tadao@jp.panasonic.com>2020-11-20 23:17:04 +0900
committerTadao Tanikawa <tanikawa.tadao@jp.panasonic.com>2020-11-20 23:17:04 +0900
commit9e86046cdb356913ae026f616e5bf17f6f238aa5 (patch)
tree1bfe1ff416fcd3951dc41828d43f1a397944ec6a /video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src
parent2219d0168f8f8418aee784a7542388ef064fa833 (diff)
Remove unused directories and files in video_in_hal
The directory video_in_hal contained a lot of unnecessary directories and files which supposed to have been accidentally copied from staging/toyota.git druing migration. Signed-off-by: Tadao Tanikawa <tanikawa.tadao@jp.panasonic.com> Change-Id: I12f2d72562bc008080ae866831d966c0b751914c
Diffstat (limited to 'video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src')
-rwxr-xr-xvideo_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_dispatcher.cpp2382
-rwxr-xr-xvideo_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_framework_dispatch.cpp983
-rwxr-xr-xvideo_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_framework_error.cpp130
-rwxr-xr-xvideo_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_framework_logger.cpp575
-rwxr-xr-xvideo_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_framework_message_center.cpp502
-rwxr-xr-xvideo_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_framework_npservice.cpp867
-rwxr-xr-xvideo_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_framework_session.cpp1357
-rwxr-xr-xvideo_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_framework_sync.cpp439
-rwxr-xr-xvideo_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_framework_system.cpp77
-rwxr-xr-xvideo_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_msgprofiler.cpp210
-rwxr-xr-xvideo_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_multithreading.cpp531
-rwxr-xr-xvideo_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_service_if.cpp128
-rwxr-xr-xvideo_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_thread_priority.cpp156
-rwxr-xr-xvideo_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_timer.cpp67
-rwxr-xr-xvideo_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/makefile_PosixBasedOS001214
-rwxr-xr-xvideo_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_action.cpp32
-rwxr-xr-xvideo_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_compositestate.cpp371
-rwxr-xr-xvideo_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_conditionconnector.cpp152
-rwxr-xr-xvideo_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_deephistorystate.cpp79
-rwxr-xr-xvideo_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_dispatcher.cpp240
-rwxr-xr-xvideo_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_externaltransition.cpp225
-rwxr-xr-xvideo_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_finalstate.cpp79
-rwxr-xr-xvideo_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_framework_dispatch.cpp485
-rwxr-xr-xvideo_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_guard.cpp41
-rwxr-xr-xvideo_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_historystate.cpp148
-rwxr-xr-xvideo_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_hsm.cpp529
-rwxr-xr-xvideo_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_hsmframework.cpp1419
-rwxr-xr-xvideo_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_leafstate.cpp78
-rwxr-xr-xvideo_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_localtransition.cpp84
-rwxr-xr-xvideo_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_multithreading.cpp211
-rwxr-xr-xvideo_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_orthogonalstate.cpp337
-rwxr-xr-xvideo_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_shallowhistorystate.cpp74
-rwxr-xr-xvideo_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_state.cpp634
-rwxr-xr-xvideo_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_transition.cpp57
-rwxr-xr-xvideo_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/makefile99
35 files changed, 0 insertions, 13992 deletions
diff --git a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_dispatcher.cpp b/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_dispatcher.cpp
deleted file mode 100755
index 250edce..0000000
--- a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_dispatcher.cpp
+++ /dev/null
@@ -1,2382 +0,0 @@
-/*
- * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-///////////////////////////////////////////////////////////////////////////////
-/// \ingroup tag_NSFramework
-/// \brief
-///
-///
-///
-///////////////////////////////////////////////////////////////////////////////
-
-#include <stdio.h>
-#include <string.h>
-#include <sys/epoll.h>
-#include <sys/eventfd.h>
-#include <sys/time.h>
-#include <sys/resource.h>
-#include <fcntl.h>
-#include <pthread.h>
-
-#include <native_service/ns_logger_if.h>
-#include <native_service/ns_version_if.h>
-#include <native_service/ns_message_center_if.h>
-#include <native_service/frameworkunified_framework_sync.h>
-#include <native_service/frameworkunified_sm_hsmframework.h>
-#include <native_service/frameworkunified_sm_framework_dispatch.h>
-#include <native_service/frameworkunified_thread_priority.h>
-#include <native_service/ns_plogger_if.h>
-#include <native_service/ns_resource_controler.h>
-#include <native_service/frameworkunified_service_protocol.h>
-#include <native_service/frameworkunified_dispatcher.h>
-#include <native_service/frameworkunified_framework_if.h>
-#include <other_service/strlcpy.h>
-
-#include <string>
-#include <utility>
-#include <map>
-
-#include "frameworkunified_framework_core.h"
-#include "frameworkunified_framework_internal.h"
-#include "ns_message_center_internal.h"
-#include "ns_mc_internal.h"
-#include "frameworkunified_framework_error_internal.hpp"
-#include "frameworkunified_framework_utility.h"
-#include "frameworkunified_sm_framework_core.h"
-
-#ifdef DISPATCHER_PROFILER
-#include "frameworkunified_msgprofiler.h"
-#include <boost/bind.hpp>
-#endif
-
-/*
- * static variable
- */
-static FrameworkunifiedDefaultCallbackHandler g_defaultCallbackHandler;
-
-//////////////////////////
-// prototype declaration
-//////////////////////////
-static EFrameworkunifiedStatus GetDispatcherMqFD(HANDLE hApp, int *fd);
-static EFrameworkunifiedStatus CreateMultiWaitingFD(HANDLE hApp);
-static EFrameworkunifiedStatus ProcessMq(HANDLE hApp);
-static EFrameworkunifiedStatus ProcessFd(HANDLE hApp , int fd);
-
-//////////////////////////////////////////
-// Function : ostream &operator<<
-//////////////////////////////////////////
-template <typename K, typename V, class C, class A>
-std::ostream &operator<< (std::ostream &os, const std::map<K, V, C, A> &m) {
- os << "{ ";
- typename std::map<K, V, C, A>::const_iterator p;
- for (p = m.begin(); p != m.end(); ++p) {
- os << p->first << ":" << p->second << ", ";
- }
- return os << "}";
-}
-
-EFrameworkunifiedStatus CreateDispatcher(PCSTR cAppName, HANDLE &hApp, BOOL bIsChildThread) { // NOLINT (readability/nolint)
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
- CFrameworkunifiedFrameworkApp *pApp = new CFrameworkunifiedFrameworkApp; // LCOV_EXCL_BR_LINE 11:except branch
- if (pApp != NULL) { // LCOV_EXCL_BR_LINE 5:fail safe for new
- pApp->checkCode = APP_CHECK_CODE;
- pApp->self = pthread_self();
- // app name size should not exceed the max length
- memset(pApp->cAppName, 0, MAX_NAME_SIZE_APP);
- memset(pApp->sServiceAvailabilityNotification, 0, MAX_SYS_INFO_SIZE);
- pApp->bIsAvailable = FALSE;
- /*
- * todo
- * Setting NULL for arguments causes an Exception
- */
- if (strlen(cAppName) < MAX_NAME_SIZE_APP) {
- memcpy(pApp->cAppName, cAppName, strlen(cAppName));
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, " Error : Aborting ... Exceeds Max App name size MAX_NAME_SIZE_APP : %d ",
- MAX_NAME_SIZE_APP);
- /*
- * Error is set here, but the error is overwritten by the following process
- */
- eStatus = eFrameworkunifiedStatusFail;
- }
-
- FRAMEWORKUNIFIEDLOG0(ZONE_NS_DIS, __FUNCTION__, " Application Created ");
-
- // opening handle to receive message for the application
- pApp->hAppRcvMsgQ = NULL;
- if (NULL == (pApp->hAppRcvMsgQ = McOpenReceiver(pApp->cAppName))) {
- FRAMEWORKUNIFIEDLOG0(ZONE_NS_ERR, __FUNCTION__, " Error : Failed to McOpenReceiver ");
- eStatus = eFrameworkunifiedStatusNullPointer;
- } else {
- if (strcmp(cAppName, "NS_NPPService") != 0) {
- McFlushReceiver(pApp->hAppRcvMsgQ);
- }
- }
-
- // opening socket for abnormal monitoring
- pApp->siMonitorSock = -1;
- if ((eFrameworkunifiedStatusOK == eStatus) && (-1 == (pApp->siMonitorSock = mcOpenMonitor(pApp->cAppName)))) {
- FRAMEWORKUNIFIEDLOG0(ZONE_NS_ERR, __FUNCTION__, " Error : Failed to mcOpenMonitor ");
- eStatus = eFrameworkunifiedStatusFail;
- pApp->siMonitorSock = -1;
- }
-
- // opening handle to send messages to itself
- pApp->hAppSndMsgQ = NULL;
- if ((eFrameworkunifiedStatusOK == eStatus) && (NULL == (pApp->hAppSndMsgQ = McOpenSender(pApp->cAppName)))) {
- // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
- FRAMEWORKUNIFIEDLOG0(ZONE_NS_ERR, __FUNCTION__, " Error : Failed to McOpenSender ");
- // LCOV_EXCL_BR_STOP
- eStatus = eFrameworkunifiedStatusNullPointer;
- }
-
- // opening handles for Notification Persistence Service and Service Directory
- pApp->hNPSndMsgQ = NULL;
- if ((eFrameworkunifiedStatusOK == eStatus) &&
- (NULL == (pApp->hNPSndMsgQ = FrameworkunifiedMcOpenSender(reinterpret_cast<HANDLE>(pApp), FRAMEWORKUNIFIED_NS_NPSERVICE)))) {
- // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, " Error : Failed to FrameworkunifiedMcOpenSender < NS_NPPService >");
- // LCOV_EXCL_BR_STOP
- eStatus = eFrameworkunifiedStatusNullPointer;
- }
-
- // stores the message queue handle of the parent thread.
- // It will set after the dispatcher of child thread is created. And will be NULL for main thread.
- pApp->hParentSndMsgQ = NULL;
-
- if ((eFrameworkunifiedStatusOK == eStatus) && (!bIsChildThread)) {
- // Define any system callback's with the dispatcher.
- if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedAttachSystemCallbacksDispatcher(reinterpret_cast<HANDLE>(pApp)))) {
- // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, " Error :: (%d) Failed to FrameworkunifiedAttachSystemCallbacksDispatcher ", eStatus);
- // LCOV_EXCL_BR_STOP
- }
-
- if (eFrameworkunifiedStatusOK == eStatus) {
- // Define the logger callback's for setting up gets and sets with the dispatcher.
- if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedAttachLoggerCallbacksDispatcher(reinterpret_cast<HANDLE>(pApp)))) {
- // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, " Error :: (%d) Failed to FrameworkunifiedAttachLoggerCallbacksDispatcher ", eStatus);
- // LCOV_EXCL_BR_STOP
- }
- }
- }
-
- // initialize
- pApp->m_pFrameworkunifiedStateMachine = NULL;
- pApp->uiProtocolCmd = 0;
-
- // Clear the Defer'ed message pop flag.
- pApp->fPopDeferedMsg = FALSE;
-
- // Clear the Defer'ed sync response flag.
- pApp->fDeferredSyncResponse = FALSE;
-
- // buffer initialize
- memset(pApp->uiMsgRcvBuffer, 0, MAX_MSGQ_BUFFER);
- memset(pApp->cMsgSrcName, '\0', MAX_NAME_SIZE_APP);
- memset(pApp->cSystemInfo, '\0', MAX_SYS_INFO_SIZE);
-
- pApp->defer_evfd = -1;
- pApp->efd = -1;
- if (eFrameworkunifiedStatusOK == eStatus) {
- eStatus = CreateMultiWaitingFD((HANDLE)pApp);
- if (eFrameworkunifiedStatusOK != eStatus) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR : CreateMultiWaitingFD Failed, status=%d", eStatus);
- }
- }
-
-#ifdef DISPATCHER_PROFILER
- // Assign default value
- pApp->m_pFrameworkunifiedMsgProfiler = NULL;
-#endif
-
- if (eFrameworkunifiedStatusOK != eStatus) {
- if (NULL != pApp->hAppRcvMsgQ) {
- McClose(pApp->hAppRcvMsgQ);
- pApp->hAppRcvMsgQ = NULL;
- }
-
- if (0 < pApp->siMonitorSock) {
- mcCloseMonitor(pApp->cAppName);
- pApp->siMonitorSock = -1;
- }
-
- if (NULL != pApp->hAppSndMsgQ) {
- McClose(pApp->hAppSndMsgQ);
- pApp->hAppSndMsgQ = NULL;
- }
-
- if (NULL != pApp->hNPSndMsgQ) {
- FrameworkunifiedMcClose(pApp->hNPSndMsgQ);
- pApp->hNPSndMsgQ = NULL;
- }
-
- // LCOV_EXCL_BR_START 6:According to line 158, pApp->hParentSndMsgQ is NULL.
- if (NULL != pApp->hParentSndMsgQ) {
- // LCOV_EXCL_BR_STOP
- // LCOV_EXCL_START 6:According to line 158, pApp->hParentSndMsgQ is NULL.
- AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
- McClose(pApp->hParentSndMsgQ);
- pApp->hParentSndMsgQ = NULL;
- // LCOV_EXCL_STOP
- }
-
- if (0 < pApp->defer_evfd) {
- close(pApp->defer_evfd);
- pApp->defer_evfd = -1;
- }
-
- if (0 < pApp->efd) {
- close(pApp->efd);
- pApp->efd = -1;
- }
-
- delete pApp; // LCOV_EXCL_BR_LINE 11:except branch
- pApp = NULL;
- }
- }
-
- hApp = pApp;
-
- return eStatus;
-}
-
-
-//////////////////////////////////////////
-// Function : FrameworkunifiedCreateDispatcher
-//////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedCreateDispatcher(PCSTR cAppName, HANDLE &hApp, BOOL bIsChildThread) { // NOLINT (readability/nolint)
- return CreateDispatcher(cAppName, hApp, bIsChildThread);
-}
-
-
-//////////////////////////////////////////
-// Function : FrameworkunifiedDispatchBlock
-//////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedDispatchBlock(HANDLE hApp) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-// FRAMEWORKUNIFIEDLOG0(ZONE_NS_DIS, __FUNCTION__, "+");
-
- if (frameworkunifiedCheckValidAppHandle(hApp)) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
-
- if (eFrameworkunifiedStatusOK != (eStatus = McReceiveWithSession(pApp->hAppRcvMsgQ, pApp->cMsgSrcName,
- &pApp->uiProtocolCmd, &pApp->uiSessionId, MAX_MSGQ_BUFFER,
- (PVOID)(pApp->uiMsgRcvBuffer)))) {
- // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error :: (%d) Failed on McReceive", eStatus);
- // LCOV_EXCL_BR_STOP
- } else {
-// FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, "Message received on dispatcher:: Source: %s, Cmd: 0x%X, SessionId: %d ",
-// pApp->cMsgSrcName, pApp->uiProtocolCmd, pApp->uiSessionId);
- }
- } else {
- eStatus = eFrameworkunifiedStatusInvldHandle;
- }
-
-// FRAMEWORKUNIFIEDLOG0(ZONE_NS_DIS, __FUNCTION__, "-");
- return eStatus;
-}
-
-
-EFrameworkunifiedStatus FrameworkunifiedProcessServiceProtocolCallback(HANDLE hApp, PCSTR pRequester) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (frameworkunifiedCheckValidAppHandle(hApp)) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- Services::iterator s_iterator;
-
- s_iterator = pApp->services.find(pRequester);
- if (s_iterator != pApp->services.end()) {
- SessionTable::iterator session_iterator;
- session_iterator = (s_iterator->second).find(pApp->uiSessionId);
- if (session_iterator != (s_iterator->second).end()) {
- // FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, " %s found :: (%s) ", pApp->cMsgSrcName, s_iterator->second);
-
- // find the protocol req/ack handler
- ServiceProtocolTable::iterator spt_iterator;
- spt_iterator = (session_iterator->second).find(pApp->uiProtocolCmd);
- if (spt_iterator != (session_iterator->second).end()) {
- // calling the protocol req/ack handler
- eStatus = (*spt_iterator).second(hApp);
- } else if ((session_iterator->second).end() != (spt_iterator =
- (session_iterator->second).find(FRAMEWORKUNIFIED_ANY_COMMAND))) {
- // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
- FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__,
- "Processing callback function for (FRAMEWORKUNIFIED_ANY_COMMAND). "
- "Dispatcher protocol command: (0x%x)", pApp->uiProtocolCmd);
- // LCOV_EXCL_BR_STOP
- eStatus = (*spt_iterator).second(hApp);
- } else {
- eStatus = eFrameworkunifiedStatusMsgNotProcessed;
- }
- } else {
- eStatus = eFrameworkunifiedStatusMsgNotProcessed;
- }
- } else {
- eStatus = eFrameworkunifiedStatusMsgNotProcessed;
- }
- } else {
- eStatus = eFrameworkunifiedStatusInvldHandle;
- }
-
- return eStatus;
-}
-
-EFrameworkunifiedStatus FrameworkunifiedProcessServiceProtocol(HANDLE hApp) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (frameworkunifiedCheckValidAppHandle(hApp)) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
-
- // Check if the callback is associated with the Protocol for message source
- eStatus = FrameworkunifiedProcessServiceProtocolCallback(hApp, const_cast<PCSTR>(pApp->cMsgSrcName));
-
- if (eFrameworkunifiedStatusMsgNotProcessed == eStatus) {
- // Check if the callback is associated with the Protocol for FRAMEWORKUNIFIED_ANY_SOURCE
- eStatus = FrameworkunifiedProcessServiceProtocolCallback(hApp, FRAMEWORKUNIFIED_ANY_SOURCE);
- if (eFrameworkunifiedStatusMsgNotProcessed == eStatus) {
- if (pApp->m_pFrameworkunifiedStateMachine) {
- // Check if the HSM event is associated with the Protocol for message source
- eStatus = FrameworkunifiedProcessServiceProtocolHSMEvent(hApp, const_cast<PCSTR>(pApp->cMsgSrcName));
-
- if (eFrameworkunifiedStatusMsgNotProcessed == eStatus) {
- // Check if the HSM event is associated with the Protocol for FRAMEWORKUNIFIED_ANY_SOURCE
- eStatus = FrameworkunifiedProcessServiceProtocolHSMEvent(hApp, FRAMEWORKUNIFIED_ANY_SOURCE);
- }
- }
- }
- }
- } else {
- eStatus = eFrameworkunifiedStatusInvldHandle;
- }
-
- return eStatus;
-}
-
-
-EFrameworkunifiedStatus FrameworkunifiedSetDeferredSyncResponse(HANDLE hApp) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusInvldBuf;
-
- if (frameworkunifiedCheckValidAppHandle(hApp)) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- pApp->fDeferredSyncResponse = TRUE;
- eStatus = eFrameworkunifiedStatusOK;
- }
-
- return eStatus;
-}
-
-
-static void frameworkunifiedProcessSyncResponse(HANDLE hApp, EFrameworkunifiedStatus retValue) {
- EFrameworkunifiedStatus eStatus;
- CHAR systemInfo[MAX_SYS_INFO_SIZE];
- UI_32 seq_id;
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
-
- if (frameworkunifiedGetIsTypeOfSync(hApp) == TRUE) {
- if (pApp->fDeferredSyncResponse == TRUE) {
- if (pApp->responsedata.size() != 0) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "Response data is ignored for "
- ":: source: %s, Protocol Command: 0x%x, Session Id: %u.",
- pApp->cMsgSrcName != 0 ? pApp->cMsgSrcName : NULL,
- pApp->uiProtocolCmd, pApp->uiSessionId);
- pApp->responsedata.clear();
- }
- } else {
- FrameworkunifiedGetSystemInfo(hApp, systemInfo);
- seq_id = (UI_32)strtoul(systemInfo, NULL, 16);
-
- eStatus = frameworkunifiedSendSyncResponse(hApp, PROTOCOL_FRAMEWORKUNIFIED_ANY_COMMAND, seq_id, retValue, pApp->responsedata.size(),
- pApp->responsedata.data());
- if (eStatus != eFrameworkunifiedStatusOK) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "retValu:%d errno:%d", eStatus, errno);
- }
- pApp->responsedata.clear();
- }
- } else {
- if (pApp->responsedata.size() != 0) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "Response data is ignored for :: "
- "source: %s, Protocol Command: 0x%x, Session Id: %u.",
- pApp->cMsgSrcName != 0 ? pApp->cMsgSrcName : NULL,
- pApp->uiProtocolCmd, pApp->uiSessionId);
- pApp->responsedata.clear();
- }
- }
- pApp->fDeferredSyncResponse = FALSE;
-}
-
-
-inline static time_t frameworkunifiedTimeval2usec(const struct timeval &time) {
- return static_cast<time_t>(time.tv_sec * 1000000 + time.tv_usec);
-}
-
-
-static void frameworkunifiedPrintRusage(HANDLE hApp, const struct rusage &start, const struct rusage &end) {
- UI_32 occupy_time;
- UI_32 average;
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
-
- occupy_time = static_cast<UI_32>(frameworkunifiedTimeval2usec(end.ru_utime) - frameworkunifiedTimeval2usec(start.ru_utime));
- occupy_time += static_cast<UI_32>(frameworkunifiedTimeval2usec(end.ru_stime) - frameworkunifiedTimeval2usec(start.ru_stime));
-
- pApp->total_occupy_time += occupy_time;
- pApp->total_run_count++;
- average = static_cast<UI_32>(pApp->total_occupy_time / pApp->total_run_count);
-
- if (occupy_time > pApp->max_occupy_time) {
- pApp->max_occupy_time = occupy_time;
- }
-
-// FRAMEWORKUNIFIEDLOG(ZONE_NS_DEBUG_DUMP, __FUNCTION__, "cur:%d.%06d avg:%d.%06d max:%d.%06d",
-// occupy_time / 1000000, occupy_time % 1000000,
-// average / 1000000, average % 1000000,
-// pApp->max_occupy_time / 1000000, pApp->max_occupy_time % 1000000);
-}
-
-
-static inline void frameworkunifiedGetRusage(struct rusage *r) {
- if (r == NULL) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "r is NULL");
- return;
- }
- memset(r, 0, sizeof(struct rusage));
- if (getrusage(RUSAGE_THREAD, r) == -1) {
- // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "getrusage errno:%d", errno);
- // LCOV_EXCL_BR_STOP
- }
-}
-
-static int frameworkunifiedPushLostSessionInfo(HANDLE hApp, PCSTR serviceName) {
- int cntFound = 0;
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
-
- ServiceSessionTable::iterator s_iterator = pApp->sessiontable.find(serviceName);
- if (s_iterator != pApp->sessiontable.end()) {
- // LCOV_EXCL_BR_START 11:except branch
- SessionHandleTable::iterator sh_iterator = pApp->sessiontable[serviceName].begin();
- // LCOV_EXCL_BR_STOP
- while (sh_iterator != pApp->sessiontable[serviceName].end()) {
- LostSessionInfo l_info;
- l_info.sServiceName = serviceName;
- l_info.iSessionId = sh_iterator->first;
- pApp->lostSessionQueue.push(l_info);
- cntFound++;
- sh_iterator++;
- }
- }
- return cntFound;
-}
-
-///
-/// Abnormal monitor(server): Client socket close handle
-///
-EFrameworkunifiedStatus frameworkunifiedProcessClientAbnormalState(HANDLE hApp, int sockfd) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- AcceptMonitorTable::iterator it;
-
- if ((it = pApp->acceptMonitorTable.find(sockfd)) == pApp->acceptMonitorTable.end()) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR : %d, Invalid fd", sockfd);
- } else {
- char clientName[16];
- if (mcGetClientNameFromConnectKey((it->second).c_str(), clientName, sizeof(clientName)) < 0) {
- eStatus = eFrameworkunifiedStatusFail;
- // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR : Invlid connectKey:%s", (it->second).c_str());
- // LCOV_EXCL_BR_STOP
- } else {
- if (pApp->lostSessionHandler != NULL) {
- int cntFound = frameworkunifiedPushLostSessionInfo(hApp, clientName);
- if (cntFound) {
- // calling lost session handler
- try {
- eStatus = pApp->lostSessionHandler(hApp);
- } catch (const std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Recovering from: %s", e.what());
- eStatus = eFrameworkunifiedStatusErrOther;
- }
- }
- }
- }
- pApp->acceptMonitorTable.erase(sockfd);
- }
-
- return eStatus; // LCOV_EXCL_BR_LINE 11:except branch
-}
-
-///
-/// Abnormal monitor(server): Add
-///
-EFrameworkunifiedStatus frameworkunifiedAddAcceptMonitor(HANDLE hApp) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- int acceptSock;
-
- if ((acceptSock = mcGetAcceptMonitor(pApp->cAppName, pApp->cMsgSrcName)) < 0) {
- // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR : mcGetAcceptMonitor srv:%s clnt:%s",
- pApp->cAppName != 0 ? pApp->cAppName : NULL, pApp->cMsgSrcName != 0 ? pApp->cMsgSrcName : NULL);
- // LCOV_EXCL_BR_STOP
- eStatus = eFrameworkunifiedStatusFail;
- } else {
- char connectKey[32];
- mcSetConnectKey(connectKey, sizeof(connectKey), pApp->cAppName, pApp->cMsgSrcName);
- pApp->acceptMonitorTable.insert(std::make_pair(acceptSock, connectKey));
- }
-
- return eStatus;
-}
-
-///
-/// Abnormal monitor(server): Del
-///
-EFrameworkunifiedStatus frameworkunifiedDelAcceptMonitor(HANDLE hApp) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- long acceptSock; // NOLINT (readability/nolint)
-
- char connectKey[32];
- mcSetConnectKey(connectKey, sizeof(connectKey), pApp->cAppName, pApp->cMsgSrcName);
- if (frameworkunifiedGetResource(FRAMEWORKUNIFIED_RES_ABNMLMON, connectKey, &acceptSock) < 0) {
- eStatus = eFrameworkunifiedStatusFail;
- } else {
- if (pApp->acceptMonitorTable.find(static_cast<Socket>(acceptSock)) != pApp->acceptMonitorTable.end()) {
- pApp->acceptMonitorTable.erase(static_cast<Socket>(acceptSock));
- }
- }
-
- return eStatus;
-}
-
-///
-/// Abnormal monitor(client): Server socket close handle
-///
-EFrameworkunifiedStatus frameworkunifiedProcessServerAbnormalState(HANDLE hApp, int sockfd) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- ConnectMonitorTable::iterator it;
-
- if ((it = pApp->connectMonitorTable.find(sockfd)) == pApp->connectMonitorTable.end()) {
- // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR : %d, Invalid fd", sockfd);
- // LCOV_EXCL_BR_STOP
- } else {
- char serverName[16];
- if (mcGetServerNameFromConnectKey((it->second).c_str(), serverName, sizeof(serverName)) < 0) {
- eStatus = eFrameworkunifiedStatusFail;
- // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR : Invlid connectKey:%s", (it->second).c_str());
- // LCOV_EXCL_BR_STOP
- } else {
- if (pApp->lostSessionHandler != NULL) {
- int cntFound = frameworkunifiedPushLostSessionInfo(hApp, serverName); // LCOV_EXCL_BR_LINE 11:except branch
- if (cntFound) {
- // calling lost session handler
- try {
- eStatus = pApp->lostSessionHandler(hApp);
- } catch (const std::exception &e) {
- // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Recovering from: %s", e.what());
- // LCOV_EXCL_BR_STOP
- eStatus = eFrameworkunifiedStatusErrOther;
- }
- }
- }
- }
- pApp->connectMonitorTable.erase(sockfd);
- }
-
- return eStatus; // LCOV_EXCL_BR_LINE 11:except branch
-}
-
-///
-/// Abnormal monitor(client): Add
-///
-EFrameworkunifiedStatus frameworkunifiedAddConnectMonitor(HANDLE hApp, PCSTR serverName, PCSTR clientName) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
-
- int connectSock = mcConnectMonitor(serverName, clientName);
- if (connectSock < 0) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error::%s:%s mcConnectMonitor",
- serverName != 0 ? serverName : NULL, pApp->cAppName != 0 ? pApp->cAppName : NULL);
- eStatus = eFrameworkunifiedStatusFail;
- } else {
- if (pApp->connectMonitorTable.find(connectSock) == pApp->connectMonitorTable.end()) {
- char connectKey[32];
- mcSetConnectKey(connectKey, sizeof(connectKey), serverName, clientName);
-
- struct epoll_event event;
- event.events = EPOLLRDHUP;
- event.data.fd = connectSock;
-
- if (epoll_ctl(pApp->efd, EPOLL_CTL_ADD, connectSock, &event) < 0) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR : epoll_ctl:%s", strerror(errno));
- eStatus = eFrameworkunifiedStatusFail;
- }
-
- if (eStatus == eFrameworkunifiedStatusOK) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- pApp->connectMonitorTable.insert(std::make_pair(connectSock, connectKey));
- }
- }
- }
-
- return eStatus;
-}
-
-///
-/// Abnormal monitor(client): Del
-///
-EFrameworkunifiedStatus frameworkunifiedDelConnectMonitor(HANDLE hApp, PCSTR serverName, PCSTR clientName) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
-
- char connectKey[32];
- mcSetConnectKey(connectKey, sizeof(connectKey), serverName, clientName);
-
- long connectSock; // NOLINT (readability/nolint)
- if (frameworkunifiedGetResource(FRAMEWORKUNIFIED_RES_ABNMLMON, connectKey, &connectSock) < 0) {
- eStatus = eFrameworkunifiedStatusFail;
- } else {
- if (pApp->connectMonitorTable.find(static_cast<Socket>(connectSock)) != pApp->connectMonitorTable.end()) {
- pApp->connectMonitorTable.erase(static_cast<Socket>(connectSock));
- }
-
- if (epoll_ctl(pApp->efd, EPOLL_CTL_DEL, static_cast<int>(connectSock), NULL) < 0) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR : epoll_ctl:%s", strerror(errno));
- eStatus = eFrameworkunifiedStatusFail;
- }
- }
-
- return eStatus;
-}
-
-///
-/// Abnormal monitor(common): Attach callback
-///
-EFrameworkunifiedStatus FrameworkunifiedAttachLostSessionCallbackToDispatcher(HANDLE hApp, CbFuncPtr fpLostSession) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (frameworkunifiedCheckValidAppHandle(hApp) == FALSE || fpLostSession == NULL) {
- eStatus = eFrameworkunifiedStatusInvldParam;
- } else {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- pApp->lostSessionHandler = fpLostSession;
- }
-
- return eStatus;
-}
-
-///
-/// Abnormal monitor(common): Get lost session data
-///
-EFrameworkunifiedStatus FrameworkunifiedGetLostSessionData(HANDLE hApp, PSTR pServiceName, PUI_32 puiSessionId) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (frameworkunifiedCheckValidAppHandle(hApp) == FALSE || pServiceName == NULL || puiSessionId == NULL) {
- eStatus = eFrameworkunifiedStatusInvldParam;
- } else {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- if (pApp->lostSessionQueue.empty()) {
- eStatus = eFrameworkunifiedStatusAccessError;
- } else {
- LostSessionInfo info = pApp->lostSessionQueue.front();
- pApp->lostSessionQueue.pop();
- strcpy(pServiceName, info.sServiceName.c_str()); // NOLINT (readability/nolint)
- *puiSessionId = info.iSessionId;
- }
- }
-
- return eStatus;
-}
-
-
-//////////////////////////////////////////
-// Function : FrameworkunifiedDispatchProcess
-//////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedDispatchProcess(HANDLE hApp) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
- // FRAMEWORKUNIFIEDLOG0(ZONE_NS_DIS, __FUNCTION__, "+");
-
- if (frameworkunifiedCheckValidAppHandle(hApp)) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- struct rusage start, end;
- BOOL enable_rusage = NsLogIsZoneSet(ZONE_NS_DEBUG_DUMP);
-
- if (enable_rusage == TRUE) {
- frameworkunifiedGetRusage(&start);
- }
-
- if (0 != strcmp(FRAMEWORKUNIFIED_NS_NPSERVICE, pApp->cMsgSrcName)) { // < if not from NPP service
- switch (pApp->uiProtocolCmd) {
- case PROTOCOL_REGISTER_EVENTS: {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_IMP_INFO, __FUNCTION__, "%s subscribing to session event on sessionid %d",
- pApp->cMsgSrcName != 0 ? pApp->cMsgSrcName : NULL, pApp->uiSessionId);
-
- eStatus = ProcessProtocolEvents(hApp);
- }
- break;
-
- case PROTOCOL_UNREGISTER_EVENTS: {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_IMP_INFO, __FUNCTION__, "%s unsubscribing private event on sessionid %d",
- pApp->cMsgSrcName != 0 ? pApp->cMsgSrcName : NULL, pApp->uiSessionId);
-
- eStatus = UnregisterPrivateEvents(hApp);
- }
- break;
-
- case PROTOCOL_CLOSE_SESSION_REQ:
- case PROTOCOL_CLOSE_SESSION_REQ_SYNC: {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_IMP_INFO, __FUNCTION__, "Close session request received from %s",
- pApp->cMsgSrcName != 0 ? pApp->cMsgSrcName : NULL);
-
- // Handle the session events on the close session request
- (VOID)HandleSessionEventOnCloseSession(hApp);
-
- frameworkunifiedDelAcceptMonitor(hApp);
-
- eStatus = FrameworkunifiedProcessServiceProtocol(hApp);
- }
- break;
-
- case PROTOCOL_OPEN_SESSION_REQ:
- case PROTOCOL_OPEN_SESSION_REQ_SYNC: {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_IMP_INFO, __FUNCTION__, "Open session request received from %s",
- pApp->cMsgSrcName != 0 ? pApp->cMsgSrcName : NULL);
-
- eStatus = FrameworkunifiedProcessServiceProtocol(hApp);
- if (eStatus == eFrameworkunifiedStatusOK) {
- frameworkunifiedAddAcceptMonitor(hApp);
- }
- }
- break;
-
- default: {
- eStatus = FrameworkunifiedProcessServiceProtocol(hApp);
- }
- break;
- }
- } else {
- NotificationTable::iterator n_iterator;
- FrameworkunifiedGetSystemInfo(pApp, pApp->cSystemInfo);
- n_iterator = pApp->notifications.find(static_cast<PSTR>(pApp->cSystemInfo));
- if (n_iterator != pApp->notifications.end()) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, " Notification found in NS_NP :: (%s)."
- " Processing callback function.", n_iterator->first.c_str());
- eStatus = (*n_iterator).second(hApp);
- } else {
- NotificationEventTable::iterator n_iterator;
- FrameworkunifiedGetSystemInfo(pApp, pApp->cSystemInfo);
- n_iterator = pApp->notificationevents.find(static_cast<PSTR>(pApp->cSystemInfo));
- if (n_iterator != pApp->notificationevents.end()) {
- CFrameworkunifiedHSMFramework *l_pStateMachine = FrameworkunifiedGetStateMachine(hApp);
- if (l_pStateMachine) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, " Notification found in NS_NP :: (%s)."
- " Processing HSM event.", n_iterator->first.c_str());
- eStatus = l_pStateMachine->FrameworkunifiedPostEvent(n_iterator->second);
- }
- } else {
- /// Paul A. Dennis (FOUND BUG)
- /// For Persistent Data NS_NP sends the data back as a normal command not via the
- /// notification logic... The Ack's for NPReadPersistedData,NPRegisterFilePath and
- /// NPLoadFileFromPersistentStorage were never getting back
- /// to the requester because its's not looking in the correct location.
- /// So, Check the Services to see if the user has defined the Ack commands via the
- /// services map
- eStatus = FrameworkunifiedProcessServiceProtocol(hApp);
- }
- }
- }
-
- frameworkunifiedProcessSyncResponse(hApp, eStatus);
-
- if ((eStatus != eFrameworkunifiedStatusOK) && (eStatus != eFrameworkunifiedStatusExit) && (eStatus != eFrameworkunifiedStatusMsgNotProcessed)) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, " Error :: %d, (%s) Event Info :: (%s), (%d), (%s)",
- eStatus,
- pApp->cAppName != 0 ? static_cast<PSTR>(pApp->cAppName) : NULL,
- pApp->cMsgSrcName != 0 ? static_cast<PSTR>(pApp->cMsgSrcName) : NULL,
- pApp->uiProtocolCmd,
- pApp->cSystemInfo != 0 ? static_cast<PSTR>(pApp->cSystemInfo) : NULL);
- }
-
- if (eStatus == eFrameworkunifiedStatusMsgNotProcessed) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "WARNING:: No handler found for :: "
- "Source: %s, Protocol Command: 0x%x, Session Id: %u.",
- pApp->cMsgSrcName != 0 ? pApp->cMsgSrcName : NULL,
- pApp->uiProtocolCmd, pApp->uiSessionId);
- FrameworkunifiedClearMsgData(hApp);
- eStatus = eFrameworkunifiedStatusOK;
- } else {
-// FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, "Message processed. Status (0x%X) ::"
-// " Source: %s Command: 0x%x SessionId: %d.",
-// eStatus, pApp->cMsgSrcName != 0 ? pApp->cMsgSrcName : NULL,
-// pApp->uiProtocolCmd, pApp->uiSessionId);
- }
-
- if (enable_rusage == TRUE) {
- frameworkunifiedGetRusage(&end);
- frameworkunifiedPrintRusage(hApp, start, end);
- }
- } else {
- eStatus = eFrameworkunifiedStatusInvldHandle;
- }
-
- // FRAMEWORKUNIFIEDLOG0(ZONE_NS_DIS, __FUNCTION__, "-");
- return eStatus;
-}
-
-
-
-
-//////////////////////////////////////////
-// Function : FrameworkunifiedCloseDispatcher
-//////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedCloseDispatcher(HANDLE hApp) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (frameworkunifiedCheckValidAppHandle(hApp)) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- pApp->checkCode = 0;
-
- if (NULL != pApp->hAppRcvMsgQ) {
- McClose(pApp->hAppRcvMsgQ);
- pApp->hAppRcvMsgQ = NULL;
- }
-
- if (pApp->siMonitorSock) {
- mcCloseMonitor(pApp->cAppName);
- pApp->siMonitorSock = 0;
- }
-
- if (NULL != pApp->hAppSndMsgQ) {
- McClose(pApp->hAppSndMsgQ);
- pApp->hAppSndMsgQ = NULL;
- }
-
- if (NULL != pApp->hNPSndMsgQ) {
- FrameworkunifiedMcClose(pApp->hNPSndMsgQ);
- pApp->hNPSndMsgQ = NULL;
- }
-
- if (NULL != pApp->hParentSndMsgQ) {
- McClose(pApp->hParentSndMsgQ);
- pApp->hParentSndMsgQ = NULL;
- }
-
- if (0 < pApp->defer_evfd) {
- close(pApp->defer_evfd);
- pApp->defer_evfd = 0;
- }
-
- if (0 < pApp->efd) {
- close(pApp->efd);
- pApp->efd = 0;
- }
-
- delete(pApp);
- pApp = NULL; // mb20110110 Added per comment 216
- // NOTE: However, client still needs to set his own pointer to NULL
- } else {
- eStatus = eFrameworkunifiedStatusInvldHandle;
- }
-
- return eStatus;
-}
-
-//////////////////////////////////////////
-// Function : FrameworkunifiedPopedDeferedMessage
-//////////////////////////////////////////
-BOOL FrameworkunifiedPopedDeferedMessage(HANDLE hApp) {
- BOOL rtnFlag = FALSE;
-
- // LCOV_EXCL_BR_START 6:FrameworkunifiedPopedDeferedMessage is internal function, hApp is checked in extenal API
- if (frameworkunifiedCheckValidAppHandle(hApp)) {
- // LCOV_EXCL_BR_STOP
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
-
- // check if the pop flag is send and there is something to pop!
- if (pApp->fPopDeferedMsg && !pApp->deferedMsgQueue.empty()) {
- // get the message at the top\front of the queue
- DeferedMsgInfo defered(pApp->deferedMsgQueue.front());
-
- // remove this item from the queue using pop
- pApp->deferedMsgQueue.pop();
-
- // copy the data into the pApp
- pApp->uiProtocolCmd = defered.uiProtocolCmd;
- strlcpy(pApp->cMsgSrcName, defered.cMsgSrcName, sizeof(pApp->cMsgSrcName));
- std::memcpy(pApp->uiMsgRcvBuffer, defered.uiMsgRcvBuffer, MAX_MSGQ_BUFFER);
-
- // clear the pop flag!
- pApp->fPopDeferedMsg = FALSE;
-
- // set the return flag TRUE, we have pop'ed
- rtnFlag = TRUE;
- }
- }
-
- return rtnFlag;
-}
-
-
-
-//////////////////////////////////////////
-// Function : FrameworkunifiedDispatcher
-//////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedDispatcher(PCSTR cAppName, const FrameworkunifiedDefaultCallbackHandler *CbHandler) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, "In");
- return FrameworkunifiedDispatcherWithArguments(cAppName, 0, NULL, CbHandler);
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-// FrameworkunifiedDispatcherWithArguments
-// Creates, initializes and runs the dispatcher
-///////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedDispatcherWithArguments(PCSTR cAppName, int argc, char *argv[],
- const FrameworkunifiedDefaultCallbackHandler *CbHandler,
- CustomCommandLineOptions *cmdLineOptions) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (cAppName == NULL) {
- return eFrameworkunifiedStatusNullPointer;
- }
-
- NsLogSetProcessName(cAppName);
- PLOG_TEXT("FrameworkunifiedDispatcher Start");
- // set main thread name as provided in dispatcher
- pthread_setname_np(pthread_self(), cAppName);
-
- FRAMEWORKUNIFIEDLOG0(ZONE_NS_DIS, __FUNCTION__, "In");
-
- if ((eStatus = RegistDefaultCbHandler(CbHandler)) != eFrameworkunifiedStatusOK) {
- return eStatus;
- }
-
- try {
- HANDLE hFrameworkApp = NULL;
-
- if (eFrameworkunifiedStatusOK == (eStatus = FrameworkunifiedCreateDispatcher(cAppName, hFrameworkApp, FALSE))) {
- // LCOV_EXCL_BR_START 6:if FrameworkunifiedCreateDispatcher return eFrameworkunifiedStatusOK, hFrameworkApp is not NULL
- if (NULL != hFrameworkApp) {
- // LCOV_EXCL_BR_STOP
- THApp hApp(hFrameworkApp);
-
- /// Parse the Arguments via the FrameworkunifiedArgumentParser
- /// passing an handle to the app and argument list
- eStatus = FrameworkunifiedArgumentParser(hApp, argc, argv, cmdLineOptions);
-
- if (eFrameworkunifiedStatusOK == eStatus) {
- eStatus = FrameworkunifiedDispatcherMain(hApp);
- }
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "hFrameworkApp is NULL");
- eStatus = eFrameworkunifiedStatusNullPointer;
- }
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "FrameworkunifiedCreateDispatcher error, status=%d", eStatus);
- }
- } catch (const std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: Failed to FrameworkunifiedCreateDispatcher: %s", e.what());
- eStatus = eFrameworkunifiedStatusNullPointer;
- }
-
-
- return eStatus;
-}
-
-// required for parsing subargument of -r
-char *g_cPlogSubOpts[] = {
-#define PLOG_OUTPUT 0
- const_cast<PSTR>("output"),
- NULL
-};
-
-EFrameworkunifiedStatus FrameworkunifiedArgumentParser(HANDLE hApp, int argc, char *argv[], CustomCommandLineOptions *cmdLineOptions) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
- TFrameworkunifiedZoneMask mask = {};
- PCHAR l_cMask = NULL;
- UI_32 l_iMaskCount = 0;
- CHAR l_logoutput[MAX_QUEUE_NAME_SIZE];
- CHAR l_tFilePath[MAX_PATH_LENGTH];
-
- BOOL l_bHasConfigFilepath = FALSE;
-
- SI_32 l_iOpt = 0;
- SI_32 l_iPriority = 10;
- PSTR l_cOptions;
- PSTR l_cValue;
-
- FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, "In");
-
- if (frameworkunifiedCheckValidAppHandle(hApp)) {
-#ifdef DISPATCHER_PROFILER
- CFrameworkunifiedFrameworkApp *pApp = reinterpret_cast< CFrameworkunifiedFrameworkApp * >(hApp);
-#endif
-
- if (argc > 0 && argv != NULL) {
- // l:m:t:c: options are reserved for NS Framework and should not be used by other FRAMEWORKUNIFIED Applications.
- CHAR l_cNSOptions[MAX_STRING_SIZE_TAG] = {};
-
- strncpy(l_cNSOptions, "l:m:c:p:qr:s", (MAX_STRING_SIZE_TAG - 1));
- optind = 1;
-
- if (NULL != cmdLineOptions) {
- // append custom options
- strncat(l_cNSOptions, cmdLineOptions->cShortOptions, (MAX_STRING_SIZE_TAG - strlen(l_cNSOptions) - 1));
- }
- while ((eFrameworkunifiedStatusOK == eStatus) && ((l_iOpt = getopt(argc, argv, l_cNSOptions)) != -1)) {
- switch (l_iOpt) {
- case 'm': // mask value..
- FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, "-m (mask value): %s", optarg);
- /*
- * @todo
- * If the second of the command-line arguments is-m and the third is not, an exception occurs.
- */
- char *saveptr;
- l_cMask = strtok_r(optarg, ",", &saveptr);
-
- while (NULL != l_cMask) {
- mask[l_iMaskCount++] = static_cast<TFrameworkunifiedZone>(strtoul(l_cMask, NULL, 16));
- l_cMask = strtok_r(NULL, ",", &saveptr);
- }
- NsLogSetControlMask(mask);
- break;
- case 'l': // log output
- strncpy(l_logoutput, optarg, (MAX_QUEUE_NAME_SIZE - 1));
- FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, "-l (log output option): %s", l_logoutput);
- NsLogSetLogMethod(NsLogDetermineLogMethod(l_logoutput));
- break;
- case 'c': // config file option
- strncpy(l_tFilePath, optarg, (MAX_PATH_LENGTH - 1));
- FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, "-c (set config file): %s", l_tFilePath);
- eStatus = SetConfigHandle(hApp, l_tFilePath);
- l_bHasConfigFilepath = TRUE;
- break;
- case 'p': // priority
- FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, "-p (set priority): %s", optarg);
- if (eFrameworkunifiedStatusOK != frameworkunified::framework::CFrameworkunifiedThreadPriorities::ParseThreadArguments(optarg)) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "WARNING!! Failed to parse sub arguments of -p");
- }
- l_iPriority = frameworkunified::framework::CFrameworkunifiedThreadPriorities::GetPriority(FrameworkunifiedGetAppName(hApp));
- // set only if valid prio, otherwise use the default one
- if (FRAMEWORKUNIFIED_PRIORITY_NOT_FOUND != l_iPriority) {
- pthread_setschedprio(pthread_self(),
- frameworkunified::framework::CFrameworkunifiedThreadPriorities::GetPriority(FrameworkunifiedGetAppName(hApp)));
- }
- break;
- case 'q':
-#ifdef DISPATCHER_PROFILER
- FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, "-q (set msg dispatcher profiler)");
- FrameworkunifiedMsgProfiler::m_bMsgProfilerEnabled = TRUE;
- pApp->m_pFrameworkunifiedMsgProfiler = new(nothrow) FrameworkunifiedMsgProfiler(FrameworkunifiedGetAppName(hApp));
-#endif
- break;
- case 'r':
- NSLogEnablePLog(TRUE);
- l_cOptions = optarg;
- while (*l_cOptions != '\0') {
- switch (getsubopt(&l_cOptions, g_cPlogSubOpts, &l_cValue)) {
- case PLOG_OUTPUT: {
- if (l_cValue != NULL) {
- NSLogSetPlogOutputOptions(static_cast<UI_8>(strtoul(l_cValue, NULL, 16)));
- }
- break;
- }
- default: {
- break;
- }
- }
- }
- break;
- case 's':
- NSLogEnableSysEventLog(TRUE);
- break;
- default:
- if (NULL != cmdLineOptions) {
- // option other than l:m:t:c: is a custom option, therefore let application handle that option.
- if (eFrameworkunifiedStatusOK != cmdLineOptions->callback(l_iOpt, optarg)) {
- // Do not terminate an application even if invalid arguments received
- // eStatus = eFrameworkunifiedStatusFail;
- FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "WARNING!! Invalid cmd line argument received.");
- }
- } else {
- // Do not terminate an application even if invalid arguments received
- // eStatus = eFrameworkunifiedStatusFail;
- FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "WARNING!! Invalid cmd line argument received.");
- }
- break;
- }
- }
- }
-
- // if no config option is selected then use the default config path
- if ((FALSE == l_bHasConfigFilepath) && (eFrameworkunifiedStatusOK == eStatus)) {
- eStatus = SetDefaultConfigFile(hApp);
- }
- } else {
- eStatus = eFrameworkunifiedStatusInvldHandle;
- }
-
- return eStatus;
-}
-
-//////////////////////////////////////////
-// Function : FrameworkunifiedSimpleDispatcher
-//////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedSimpleDispatcher(PCSTR cAppName, const FrameworkunifiedDefaultCallbackHandler *CbHandler, CbFuncPtr CbShutdown,
- BOOL isChildThread) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- // if main thread then set log process name
- if (!isChildThread) {
- NsLogSetProcessName(cAppName);
- }
-
- if ((eStatus = RegistDefaultCbHandler(CbHandler)) != eFrameworkunifiedStatusOK) {
- return eStatus;
- }
-
- FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, "+");
-
- if (NULL != CbShutdown) {
- try {
- HANDLE hFrameworkApp = NULL;
-
- if (eFrameworkunifiedStatusOK == (eStatus = FrameworkunifiedCreateDispatcher(cAppName, hFrameworkApp, isChildThread))) {
- // LCOV_EXCL_BR_START 6:if FrameworkunifiedCreateDispatcher return eFrameworkunifiedStatusOK, hFrameworkApp is not NULL
- if (NULL != hFrameworkApp) {
- // LCOV_EXCL_BR_STOP
- THApp hApp(hFrameworkApp);
-
- // Call application defined start function
- eStatus = FrameworkunifiedOnInitializationInternal(hApp);
-
- if (eFrameworkunifiedStatusOK != eStatus) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "FrameworkunifiedOnInitialization failed ");
- throw happ_error();
- } else {
- while (eFrameworkunifiedStatusExit != eStatus) {
- try {
- // dispatch block: waits on receive message
- if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedDispatchBlock(hApp))) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: FrameworkunifiedDispatchBlock : 0x%x ", eStatus);
- continue;
- }
- // dispatch process: calls respective call back functions
- if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedDispatchProcess(hApp))) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: FrameworkunifiedDispatchProcess : 0x%x ", eStatus);
- }
- } catch (const frameworkunified::framework::error::CSystemError &err) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR :: %s", err.what());
- eStatus = eFrameworkunifiedStatusErrOther;
- FrameworkunifiedSendSystemErrMessage(hApp, err.m_eSystemError);
- } catch (const std::exception &err) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Recovering from: %s", err.what());
- eStatus = eFrameworkunifiedStatusErrOther;
- }
- }
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exiting dispatcher ");
- }
- // Call application defined stop function
- eStatus = CbShutdown(hApp);
- } else {
- FRAMEWORKUNIFIEDLOG0(ZONE_NS_ERR, __FUNCTION__, "hFrameworkApp is NULL");
- eStatus = eFrameworkunifiedStatusNullPointer;
- }
- } else {
- FRAMEWORKUNIFIEDLOG0(ZONE_NS_ERR, __FUNCTION__, "FrameworkunifiedCreateDispatcher error, status=%d", eStatus);
- }
- } catch (const THApp::Exception &) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: Failed to FrameworkunifiedCreateDispatcher ");
- eStatus = eFrameworkunifiedStatusNullPointer;
- }
- } else {
- eStatus = eFrameworkunifiedStatusFail;
- }
-
- FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, "-");
- return eStatus;
-}
-
-EFrameworkunifiedStatus RunDispatcher(HANDLE hApp) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
- int efd;
-
- if (frameworkunifiedCheckValidAppHandle(hApp)) {
-#ifdef DISPATCHER_PROFILER
- // Get the application handle
- CFrameworkunifiedFrameworkApp *pApp = reinterpret_cast< CFrameworkunifiedFrameworkApp * >(hApp);
- if (NULL != pApp->m_pFrameworkunifiedMsgProfiler) {
- FrameworkunifiedAttachMsgProfilerCallbacksDispatcher(hApp);
- }
-#endif
- FrameworkunifiedGetDispatcherFD(hApp, &efd);
-
- while (1) {
- frameworkunifiedFdHandler(hApp, efd);
- }
- } else {
- eStatus = eFrameworkunifiedStatusInvldHandle;
- }
-
- return eStatus;
-}
-
-
-EFrameworkunifiedStatus FrameworkunifiedDispatcherMain(HANDLE hApp) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (frameworkunifiedCheckValidAppHandle(hApp)) {
- try {
- FRAMEWORKUNIFIEDLOG0(ZONE_NS_DIS, __FUNCTION__, "Success: FrameworkunifiedCreateDispatcher ");
-
- // Initialize the global structures
- // register service with service dir
- // register notifications
- FRAMEWORKUNIFIEDLOG_PERFORMANCE_DEBUG("FrameworkunifiedOnInitialization +");
- eStatus = FrameworkunifiedOnInitializationInternal(hApp);
- FRAMEWORKUNIFIEDLOG_PERFORMANCE_DEBUG("FrameworkunifiedOnInitialization -");
-
- if (eFrameworkunifiedStatusOK != eStatus) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "FrameworkunifiedOnInitialization failed ");
- throw happ_error();
- } else {
- eStatus = RunDispatcher(hApp);
- CFrameworkunifiedSyncData::FrameworkunifiedReleaseSyncDataInstance();
- }
- } catch (const frameworkunified::framework::error::CSystemError &err) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR :: %s", err.what());
- eStatus = eFrameworkunifiedStatusErrOther;
- FrameworkunifiedSendSystemErrMessage(hApp, err.m_eSystemError);
- } catch (const THApp::Exception &) {
- FRAMEWORKUNIFIEDLOG0(ZONE_NS_ERR, __FUNCTION__, "Error: Failed to FrameworkunifiedCreateDispatcher ");
- eStatus = eFrameworkunifiedStatusNullPointer;
- }
- } else {
- eStatus = eFrameworkunifiedStatusInvldHandle;
- }
-
- return eStatus;
-}
-
-EFrameworkunifiedStatus FrameworkunifiedCreateDispatcherWithoutLoop(PCSTR cAppName, HANDLE &hApp, int argc, char *argv[], // NOLINT (readability/nolint)
- const FrameworkunifiedDefaultCallbackHandler *CbHandler,
- BOOL bIsConnectSM, CustomCommandLineOptions *cmdLineOptions) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
- THApp *l_hApp = NULL;
-
- if (cAppName == NULL) {
- return eFrameworkunifiedStatusNullPointer;
- }
-
- NsLogSetProcessName(cAppName);
-
- PLOG_TEXT("FrameworkunifiedDispatcher Start");
- // set main thread name as provided in dispatcher
- pthread_setname_np(pthread_self(), cAppName);
-
- if ((eStatus = RegistDefaultCbHandler(CbHandler)) != eFrameworkunifiedStatusOK) {
- return eStatus;
- }
-
- FRAMEWORKUNIFIEDLOG0(ZONE_NS_DIS, __FUNCTION__, "In");
-
- try {
- HANDLE hFrameworkApp = NULL;
-
- if (eFrameworkunifiedStatusOK == (eStatus = FrameworkunifiedCreateDispatcher(cAppName, hFrameworkApp,
- bIsConnectSM == TRUE ? FALSE : TRUE))) {
- // LCOV_EXCL_BR_START 6:if FrameworkunifiedCreateDispatcher return eFrameworkunifiedStatusOK, hFrameworkApp is not NULL
- if (NULL != hFrameworkApp) {
- // LCOV_EXCL_BR_STOP
- l_hApp = new THApp(hFrameworkApp);
- hApp = *l_hApp;
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- pApp->pRsrcMgr = reinterpret_cast<void *>(l_hApp);
-
- eStatus = FrameworkunifiedArgumentParser(hApp, argc, argv, cmdLineOptions);
-
- if (eFrameworkunifiedStatusOK == eStatus) {
- FRAMEWORKUNIFIEDLOG_PERFORMANCE_DEBUG("FrameworkunifiedOnInitialization +");
- eStatus = FrameworkunifiedOnInitializationInternal(hApp);
- FRAMEWORKUNIFIEDLOG_PERFORMANCE_DEBUG("FrameworkunifiedOnInitialization -");
-
- if (eFrameworkunifiedStatusOK != eStatus) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "FrameworkunifiedOnInitialization failed ");
- }
- }
- }
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "FrameworkunifiedCreateDispatcher error, status=%d", eStatus);
- }
- } catch (const THApp::Exception &) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: Failed to FrameworkunifiedCreateDispatcher ");
- eStatus = eFrameworkunifiedStatusNullPointer;
- }
-
- return eStatus;
-}
-
-EFrameworkunifiedStatus FrameworkunifiedDispatchProcessWithoutLoop(HANDLE hApp) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
- int efd; // FD for multi waiting
-
- if (frameworkunifiedCheckValidAppHandle(hApp)) {
- FrameworkunifiedGetDispatcherFD(hApp, &efd);
- eStatus = frameworkunifiedFdHandler(hApp, efd);
- if (eFrameworkunifiedStatusOK != eStatus) {
- eStatus = eFrameworkunifiedStatusFail;
- }
- } else {
- eStatus = eFrameworkunifiedStatusInvldHandle;
- }
-
- return eStatus;
-}
-
-EFrameworkunifiedStatus FrameworkunifiedDestroyDispatcherWithoutLoop(HANDLE hApp) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (frameworkunifiedCheckValidAppHandle(hApp)) {
- try {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- THApp *RsrcMgr = reinterpret_cast<THApp *>(pApp->pRsrcMgr);
- delete RsrcMgr;
- } catch (const std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: %s", e.what());
- eStatus = eFrameworkunifiedStatusNullPointer;
- }
- } else {
- eStatus = eFrameworkunifiedStatusInvldHandle;
- }
-
- return eStatus;
-}
-
-static EFrameworkunifiedStatus GetDispatcherMqFD(HANDLE hApp, int *fd) {
- if (fd == NULL) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "fd is NULL");
- return eFrameworkunifiedStatusNullPointer;
- }
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (frameworkunifiedCheckValidAppHandle(hApp)) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- *fd = McGetQueueFD(pApp->hAppRcvMsgQ);
- } else {
- eStatus = eFrameworkunifiedStatusInvldHandle;
- }
-
- return eStatus;
-}
-
-static EFrameworkunifiedStatus CreateMultiWaitingFD(HANDLE hApp) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
- int efd; // FD for multi waiting
- int q_fd; // FD for Dispatcher's message queue
- int defer_evfd; // FD for receiving Defer events to Dispatcher
- struct epoll_event ev; // Info struct to associate with multiwaiting FD
-
- if (frameworkunifiedCheckValidAppHandle(hApp)) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
-
- // Create efd
- efd = epoll_create1(EPOLL_CLOEXEC);
- if (-1 != efd) {
- pApp->efd = efd;
-
- // get fd to Dispatcher's message queue
- eStatus = GetDispatcherMqFD(hApp, &q_fd);
- if (eFrameworkunifiedStatusOK == eStatus) {
- // efd to monitor the q_fd.
- ev.events = EPOLLIN;
- ev.data.fd = q_fd;
- if (-1 == epoll_ctl(efd, EPOLL_CTL_ADD, q_fd, &ev)) {
- eStatus = eFrameworkunifiedStatusFail;
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR : epoll_ctl(q_fd, ADD) Failed, "
- "status=%d, errno=%d", eStatus, errno);
- }
- } else {
- eStatus = eFrameworkunifiedStatusFail;
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR : GetDispatcherMqFD Failed, status=%d", eStatus);
- }
-
- // create FD for receiving Defer events to Dispatcher
- defer_evfd = eventfd(0, EFD_CLOEXEC);
- if (-1 != defer_evfd) {
- pApp->defer_evfd = defer_evfd;
-
- // efd to monitor the defer_evfd.
- ev.events = EPOLLIN;
- ev.data.fd = defer_evfd;
- if (-1 == epoll_ctl(efd, EPOLL_CTL_ADD, defer_evfd, &ev)) {
- eStatus = eFrameworkunifiedStatusFail;
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR : epoll_ctl(defer_evfd, ADD) Failed,"
- " status=%d, errno=%d", eStatus, errno);
- }
- } else {
- eStatus = eFrameworkunifiedStatusFail;
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR : eventfd Failed, status=%d, errno=%d", eStatus, errno);
- }
-
- // add abnormal monitor socket polling
- if (-1 != pApp->siMonitorSock) {
- ev.events = EPOLLIN;
- ev.data.fd = pApp->siMonitorSock;
- if (-1 == epoll_ctl(efd, EPOLL_CTL_ADD, pApp->siMonitorSock, &ev)) {
- eStatus = eFrameworkunifiedStatusFail;
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR : epoll_ctl:%s", strerror(errno));
- }
- }
- } else {
- eStatus = eFrameworkunifiedStatusFail;
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR : epoll_create1 Failed, status=%d, errno=%d", eStatus, errno);
- }
- } else {
- eStatus = eFrameworkunifiedStatusInvldHandle;
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR : %d, Invalid hApp ", eStatus);
- }
-
- return eStatus;
-}
-
-EFrameworkunifiedStatus FrameworkunifiedGetDispatcherFD(HANDLE hApp, int *efd) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (frameworkunifiedCheckValidAppHandle(hApp)) {
- if (NULL != efd) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- *efd = pApp->efd;
- } else {
- eStatus = eFrameworkunifiedStatusNullPointer;
- }
- } else {
- eStatus = eFrameworkunifiedStatusInvldHandle;
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR : %d, Invalid hApp ", eStatus);
- }
-
- return eStatus;
-}
-
-EFrameworkunifiedStatus FrameworkunifiedOnInitializationInternal(HANDLE hApp) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusFail;
-
- if (g_defaultCallbackHandler.onInitilization != NULL) {
- try {
- eStatus = g_defaultCallbackHandler.onInitilization(hApp);
- } catch (const std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: %s", e.what());
- }
- }
- return eStatus;
-}
-
-EFrameworkunifiedStatus FrameworkunifiedOnDestroyInternal(HANDLE hApp) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusFail;
-
- if (g_defaultCallbackHandler.onDestroy != NULL) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- if (pApp->hParentSndMsgQ == NULL) {
- // main thread
- try {
- eStatus = g_defaultCallbackHandler.onDestroy(hApp);
- } catch (const std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: %s", e.what());
- }
- } else {
- eStatus = eFrameworkunifiedStatusOK;
- }
- }
- return eStatus;
-}
-
-EFrameworkunifiedStatus FrameworkunifiedOnStartInternal(HANDLE hApp) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusFail;
-
- if (g_defaultCallbackHandler.onStart != NULL) {
- try {
- eStatus = g_defaultCallbackHandler.onStart(hApp);
- } catch (const std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: %s", e.what());
- }
- }
- return eStatus;
-}
-
-EFrameworkunifiedStatus FrameworkunifiedOnStopInternal(HANDLE hApp) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusFail;
-
- if (g_defaultCallbackHandler.onStop != NULL) {
- try {
- eStatus = g_defaultCallbackHandler.onStop(hApp);
- } catch (const std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: %s", e.what());
- }
- }
- return eStatus;
-}
-
-EFrameworkunifiedStatus FrameworkunifiedOnPreStartInternal(HANDLE hApp) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusFail;
-
- if (g_defaultCallbackHandler.onPreStart != NULL) {
- try {
- eStatus = g_defaultCallbackHandler.onPreStart(hApp);
- } catch (const std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: %s", e.what());
- }
- }
- return eStatus; // LCOV_EXCL_BR_LINE 11:Excluded due to gcov constraints (others)
-}
-
-EFrameworkunifiedStatus FrameworkunifiedOnPreStopInternal(HANDLE hApp) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusFail;
-
- if (g_defaultCallbackHandler.onPreStop != NULL) {
- try {
- eStatus = g_defaultCallbackHandler.onPreStop(hApp);
- } catch (const std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: %s", e.what());
- }
- }
- return eStatus; // LCOV_EXCL_BR_LINE 11:Excluded due to gcov constraints (others)
-}
-
-EFrameworkunifiedStatus FrameworkunifiedOnBackgroundStartInternal(HANDLE hApp) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusFail;
-
- if (g_defaultCallbackHandler.onBackgroundStart != NULL) {
- try {
- eStatus = g_defaultCallbackHandler.onBackgroundStart(hApp);
- } catch (const std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: %s", e.what());
- }
- }
- return eStatus; // LCOV_EXCL_BR_LINE 11:Excluded due to gcov constraints (others)
-}
-
-EFrameworkunifiedStatus FrameworkunifiedOnBackgroundStopInternal(HANDLE hApp) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusFail;
-
- if (g_defaultCallbackHandler.onBackgroundStop != NULL) {
- try {
- eStatus = g_defaultCallbackHandler.onBackgroundStop(hApp);
- } catch (const std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: %s", e.what());
- }
- }
- return eStatus; // LCOV_EXCL_BR_LINE 11:Excluded due to gcov constraints (others)
-}
-
-EFrameworkunifiedStatus FrameworkunifiedOnDebugDumpInternal(HANDLE hApp) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusFail;
-
- if (g_defaultCallbackHandler.onDebugDump != NULL) {
- try {
- eStatus = g_defaultCallbackHandler.onDebugDump(hApp);
- } catch (const std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: %s", e.what());
- }
- }
- return eStatus;
-}
-
-EFrameworkunifiedStatus FrameworkunifiedCreateStateMachineInternal(HANDLE hApp) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusFail;
-
- if (g_defaultCallbackHandler.createStateMachine != NULL) {
- try {
- eStatus = g_defaultCallbackHandler.createStateMachine(hApp);
- } catch (const std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: %s", e.what());
- }
- }
- return eStatus;
-}
-
-EFrameworkunifiedStatus FrameworkunifiedSSFrameworkInterfaceInternal(HANDLE hApp) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusFail;
-
- if (g_defaultCallbackHandler.ssFrameworkInterface != NULL) {
- try {
- eStatus = g_defaultCallbackHandler.ssFrameworkInterface(hApp);
- } catch (const std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: %s", e.what());
- }
- }
- return eStatus;
-}
-
-EFrameworkunifiedStatus RegistDefaultCbHandler(const FrameworkunifiedDefaultCallbackHandler *CbHandler) {
- if (CbHandler == NULL) {
- return eFrameworkunifiedStatusNullPointer;
- } else if (CbHandler->onInitilization == NULL || CbHandler->onDestroy == NULL || CbHandler->onStart == NULL ||
- CbHandler->onStop == NULL
- || CbHandler->onPreStart == NULL || CbHandler->onPreStop == NULL
- || CbHandler->onBackgroundStart == NULL || CbHandler->onBackgroundStop == NULL
- || CbHandler->onDebugDump == NULL || CbHandler->createStateMachine == NULL
- || CbHandler->ssFrameworkInterface == NULL) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, " [ ABORT ] DefaultCallbackHandler is NULL");
- return eFrameworkunifiedStatusInvldParam;
- }
-
- g_defaultCallbackHandler = *CbHandler;
- return eFrameworkunifiedStatusOK;
-}
-
-EFrameworkunifiedStatus FrameworkunifiedGetDefaultCbHandler(FrameworkunifiedDefaultCallbackHandler *CbHandler) {
- if (CbHandler == NULL) {
- return eFrameworkunifiedStatusNullPointer;
- }
-
- *CbHandler = g_defaultCallbackHandler;
- return eFrameworkunifiedStatusOK;
-}
-
-EFrameworkunifiedStatus frameworkunifiedFdHandler(HANDLE hApp , int efd) {
- struct epoll_event events[MAX_FD_MULTIWAITING];
- int nfds; // The number of events received
- int q_fd; // The FD of events received
- int n; // Loop counter
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
- const char *key;
-
- if (frameworkunifiedCheckValidAppHandle(hApp)) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- eStatus = GetDispatcherMqFD(hApp, &q_fd);
- // LCOV_EXCL_BR_START 6:Because of hApp is valid, GetDispatcherMqFD return eFrameworkunifiedStatusOK.
- if (eFrameworkunifiedStatusOK == eStatus) {
- // LCOV_EXCL_BR_STOP
- nfds = epoll_wait(efd, events, MAX_FD_MULTIWAITING, -1);
- if (-1 != nfds) {
- for (n = 0; n < nfds; ++n) {
- if (pApp->siMonitorSock == events[n].data.fd) {
- // abnormal monitor connect request
- int socket;
-
- if ((socket = mcAcceptMonitor(pApp->cAppName, pApp->siMonitorSock)) >= 0) {
- struct epoll_event event;
-
- event.events = EPOLLRDHUP;
- event.data.fd = socket;
-
- if (epoll_ctl(pApp->efd, EPOLL_CTL_ADD, socket, &event) < 0) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR : epoll_ctl:%s", strerror(errno));
- }
- }
- }
- }
-
- for (n = 0; n < nfds; ++n) {
- // The branch processing by FD on which the message was received
- if (q_fd == events[n].data.fd) {
- // process the message to the Dispatcher's message queue
- eStatus = ProcessMq(hApp);
- } else if (pApp->defer_evfd == events[n].data.fd) {
- // process the Defer event to the Dispatcher
- uint64_t data;
- ssize_t len;
-
- len = read(pApp->defer_evfd, &data, sizeof(uint64_t));
- if (len < 0) {
- // read error
- eStatus = eFrameworkunifiedStatusFail;
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR : read Failed, status=%d, errno=%d, defer_evfd=%d",
- eStatus, errno, pApp->defer_evfd);
- } else {
- while (TRUE == (FrameworkunifiedPopedDeferedMessage(hApp))) {
- try {
- // dispatch process: calls respective call back functions
- if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedDispatchProcess(hApp))) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR : FrameworkunifiedDispatchProcess Status : 0x%x", eStatus);
- }
- } catch (const frameworkunified::framework::error::CSystemError &err) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR : %s", err.what());
- eStatus = eFrameworkunifiedStatusErrOther;
- FrameworkunifiedSendSystemErrMessage(hApp, err.m_eSystemError);
- } catch (const std::exception &err) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Recovering from : %s", err.what());
- eStatus = eFrameworkunifiedStatusErrOther;
- }
- }
- }
- } else if (pApp->siMonitorSock == events[n].data.fd) {
- // do nothing
- } else if (frameworkunifiedSearchResourseKey(FRAMEWORKUNIFIED_RES_ABNMLMON, events[n].data.fd, &key) == 0) {
- if (pApp->acceptMonitorTable.find(events[n].data.fd) != pApp->acceptMonitorTable.end()) {
- // server: accept socket close
- eStatus = frameworkunifiedProcessClientAbnormalState(hApp, events[n].data.fd);
- } else if (pApp->connectMonitorTable.find(events[n].data.fd) != pApp->connectMonitorTable.end()) {
- // client: connect socket close
- eStatus = frameworkunifiedProcessServerAbnormalState(hApp, events[n].data.fd);
- }
-
- if (epoll_ctl(pApp->efd, EPOLL_CTL_DEL, events[n].data.fd, NULL) < 0) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR : epoll_ctl:%s", strerror(errno));
- }
- close(events[n].data.fd);
- frameworkunifiedUnregistResouce(FRAMEWORKUNIFIED_RES_ABNMLMON, key);
- } else {
- // process the message to the FD set by the user
- eStatus = ProcessFd(hApp, events[n].data.fd);
- }
- }
- } else {
- if (errno == EINTR) {
- // signal interrupt
- } else {
- eStatus = eFrameworkunifiedStatusFail;
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR : epoll_wait Failed, status=%d, errno=%d", eStatus, errno);
- }
- }
- } else {
- // LCOV_EXCL_START 6:Because of hApp is valid, GetDispatcherMqFD return eFrameworkunifiedStatusOK.
- AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
- eStatus = eFrameworkunifiedStatusFail;
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR : GetDispatcherMqFD Failed, status=%d", eStatus);
- // LCOV_EXCL_STOP
- }
- } else {
- eStatus = eFrameworkunifiedStatusInvldHandle;
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR : %d, Invalid hApp ", eStatus);
- }
-
- return eStatus;
-}
-
-static EFrameworkunifiedStatus ProcessMq(HANDLE hApp) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (frameworkunifiedCheckValidAppHandle(hApp)) {
-#ifdef DISPATCHER_PROFILER
- CFrameworkunifiedFrameworkApp *pApp = reinterpret_cast< CFrameworkunifiedFrameworkApp * >(hApp);
-#endif
-
- // handle defer'ed message
- if (FALSE == FrameworkunifiedPopedDeferedMessage(hApp)) {
- // dispatch block: waits on receive message
- if ((eStatus = FrameworkunifiedDispatchBlock(hApp)) != eFrameworkunifiedStatusOK) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR : FrameworkunifiedDispatchBlock Status : 0x%x", eStatus);
- }
- #ifdef DISPATCHER_PROFILER
- else if (NULL != pApp->m_pFrameworkunifiedMsgProfiler) { // NOLINT (readability/nolint)
- pApp->m_pFrameworkunifiedMsgProfiler->MsgReceived();
- }
- #endif
- }
- try {
- // dispatch process: calls respective call back functions
- eStatus = FrameworkunifiedDispatchProcess(hApp);
- } catch (const frameworkunified::framework::error::CSystemError &err) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR : %s", err.what());
- eStatus = eFrameworkunifiedStatusErrOther;
- FrameworkunifiedSendSystemErrMessage(hApp, err.m_eSystemError);
- } catch (const std::exception &err) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Recovering from : %s", err.what());
- eStatus = eFrameworkunifiedStatusErrOther;
- }
-#ifdef DISPATCHER_PROFILER
- if (NULL != pApp->m_pFrameworkunifiedMsgProfiler) {
- pApp->m_pFrameworkunifiedMsgProfiler->MsgProcessed();
- }
-#endif
- } else {
- eStatus = eFrameworkunifiedStatusInvldHandle;
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR : %d, Invalid hApp ", eStatus);
- }
-
- return eStatus;
-}
-
-static EFrameworkunifiedStatus ProcessFd(HANDLE hApp , int fd) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (frameworkunifiedCheckValidAppHandle(hApp)) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- FdTable::iterator f_iterator;
- struct rusage start, end;
- BOOL enable_rusage = NsLogIsZoneSet(ZONE_NS_DEBUG_DUMP);
-
- if (enable_rusage == TRUE) {
- frameworkunifiedGetRusage(&start);
- }
-
- // finding callback func associated with FD
- f_iterator = pApp->fds.find(fd);
- if (f_iterator != pApp->fds.end()) {
- try {
- // calling func associated with FD
- eStatus = (*f_iterator).second(hApp);
- } catch (const frameworkunified::framework::error::CSystemError &err) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR :: %s", err.what());
- eStatus = eFrameworkunifiedStatusErrOther;
- FrameworkunifiedSendSystemErrMessage(hApp, err.m_eSystemError);
- } catch (const std::exception &err) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Recovering from: %s", err.what());
- eStatus = eFrameworkunifiedStatusErrOther;
- }
- } else {
- eStatus = eFrameworkunifiedStatusFail;
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR : %d, Callback associated with FD is not found. ", eStatus);
- }
-
- if (enable_rusage == TRUE) {
- frameworkunifiedGetRusage(&end);
- frameworkunifiedPrintRusage(hApp, start, end);
- }
- } else {
- eStatus = eFrameworkunifiedStatusInvldHandle;
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR : %d, Invalid hApp ", eStatus);
- }
-
- return eStatus;
-}
-
-/////////////////////////////////////////////////////////
-/// EFrameworkunifiedStatus SetConfigHandle(HANDLE hApp, PCHAR sFilePath )
-/// This Function opens the file from give path and sets the file handle in hApp
-////////////////////////////////////////////////////////
-EFrameworkunifiedStatus SetConfigHandle(HANDLE hApp, PCHAR sFilePath) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __PRETTY_FUNCTION__, "This function is not implemented");
-
- return eStatus;
-}
-
-/////////////////////////////////////////////////////////
-/// EFrameworkunifiedStatus SetDefaultFilePath(HANDLE hApp)
-/// This Function fetches the file path from Environment variable from PASA_APPCONFIG_FILES and
-/// pass it to the SetConfigHandle function
-////////////////////////////////////////////////////////
-EFrameworkunifiedStatus SetDefaultConfigFile(HANDLE hApp) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (frameworkunifiedCheckValidAppHandle(hApp)) {
- // Get the file path from environment variable
- PCHAR l_strEnvValue = getenv(PASA_APPCONFIG_FILES);
-
- if (l_strEnvValue) {
- // FRAMEWORKUNIFIEDLOG( ZONE_NS_DIS, __FUNCTION__, "Configuration file path %s ",l_strEnvValue);
-
- std::string l_strFilePath(l_strEnvValue);
-
- if (!l_strFilePath.empty()) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, "Configuration file path %s ", l_strFilePath.c_str());
- // Open the configuration file
- SetConfigHandle(hApp, (PCHAR)l_strFilePath.c_str());
- } else {
- eStatus = eFrameworkunifiedStatusFail;
- }
- }
- } else {
- eStatus = eFrameworkunifiedStatusInvldParam;
- }
-
- return eStatus;
-}
-
-EFrameworkunifiedStatus FrameworkunifiedProcessServiceProtocolHSMEvent(HANDLE hApp, PCSTR pRequester) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (frameworkunifiedCheckValidAppHandle(hApp)) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- EventServices::iterator s_iterator;
-
- // finding the service
- s_iterator = pApp->eventservices.find(pRequester);
- if (s_iterator != pApp->eventservices.end()) {
- EventSessionTable::iterator session_iterator;
- session_iterator = (s_iterator->second).find(pApp->uiSessionId);
- if (session_iterator != (s_iterator->second).end()) {
- ServiceEventProtocolTable::iterator spt_iterator;
-
- // FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, " %s found :: (%s) ", pApp->cMsgSrcName, s_iterator->second);
-
- // find the protocol req/ack handler
- spt_iterator = (session_iterator->second).find(pApp->uiProtocolCmd);
- if (spt_iterator != (session_iterator->second).end()) {
- // FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, " Protocol Command :: (0x%x) ", pApp->uiProtocolCmd);
- // Post corresponding event
- CFrameworkunifiedHSMFramework *l_pStateMachine = FrameworkunifiedGetStateMachine(hApp);
- if (l_pStateMachine) {
- eStatus = l_pStateMachine->FrameworkunifiedPostEvent(spt_iterator->second);
- }
- } else if ((session_iterator->second).end() != (spt_iterator =
- (session_iterator->second).find(FRAMEWORKUNIFIED_ANY_COMMAND))) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, "Processing HSM event for (FRAMEWORKUNIFIED_ANY_COMMAND). "
- "Dispatcher protocol command: (0x%x)",
- pApp->uiProtocolCmd);
- // Post corresponding event
- CFrameworkunifiedHSMFramework *l_pStateMachine = FrameworkunifiedGetStateMachine(hApp);
- if (l_pStateMachine) {
- eStatus = l_pStateMachine->FrameworkunifiedPostEvent(spt_iterator->second);
- }
- } else {
- eStatus = eFrameworkunifiedStatusMsgNotProcessed;
- }
-
- // if FrameworkunifiedPostEvent returns NULL
- if (eFrameworkunifiedStatusNullPointer == eStatus) {
- eStatus = eFrameworkunifiedStatusExit;
- }
- } else {
- eStatus = eFrameworkunifiedStatusMsgNotProcessed;
- }
-
- } else {
- eStatus = eFrameworkunifiedStatusMsgNotProcessed;
- }
- } else {
- eStatus = eFrameworkunifiedStatusInvldHandle;
- }
-
- return eStatus;
-}
-
-//////////////////////////////////////////
-// Function : ProcessProtocolEvents
-//////////////////////////////////////////
-EFrameworkunifiedStatus ProcessProtocolEvents(HANDLE hApp) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (frameworkunifiedCheckValidAppHandle(hApp)) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
-
- // common event table iterator
- EventTable::iterator e_iterator;
- ServiceSessionIdListTable::iterator ssidl_iterator;
-
- // public state event table iterator
- PublicStateEventTable::iterator se_iterator;
-
- // private state event table iterator
- PrivateStateEventTable::iterator pse_iterator;
- ServiceSessionEventData::iterator ssed_iterator;
- SessionEventData::iterator sed_iterator;
-
- HANDLE l_pClientHandle = NULL;
-
- // get the name of the service from which message is received
- PCSTR l_cServiceName = pApp->cMsgSrcName;
- const UI_32 l_uiSessionId = pApp->uiSessionId;
-
- // number of events to register
- UI_32 l_uiListSize = static_cast<UI_32>(FrameworkunifiedGetMsgLength(hApp) / sizeof(UI_32));
-
- // check if the received service name and data is valid
- if (NULL != l_cServiceName && 0 < l_uiListSize) {
- PUI_32 l_pData = new UI_32[l_uiListSize];
- UI_32 l_uiEventId = 0;
-
- // get the list of events
- eStatus = FrameworkunifiedGetMsgDataOfSize(hApp, l_pData, static_cast<UI_32>(l_uiListSize * sizeof(UI_32)));
-
- if (NULL != l_pData && eFrameworkunifiedStatusOK == eStatus) {
- for (UI_32 uiCount = 0; uiCount < l_uiListSize; uiCount++) {
- // received event id
- l_uiEventId = l_pData[uiCount];
-
- // find the event in map of EventTable
- e_iterator = pApp->eventtable.find(l_uiEventId);
-
- // if event is registered by any of the clients
- if (pApp->eventtable.end() != e_iterator) {
- // table of services with list of their session id's registering this event
- ServiceSessionIdListTable &l_mServiceSessionIdListTable = e_iterator->second;
-
- // find the service name in map of ServiceSessionIdListTable
- ssidl_iterator = l_mServiceSessionIdListTable.find(l_cServiceName);
-
- // if service have already registered this event with any of its session
- if (l_mServiceSessionIdListTable.end() != ssidl_iterator) {
- // list of sessions id's registering with this event
- SessionIdList &l_vSessionIdList = ssidl_iterator->second;
-
- // event is registered with this session
- if (IsEventAlreadyRegistered(l_vSessionIdList, l_uiSessionId)) {
- // get the message queue handle from map servicesessionhandletable
- l_pClientHandle = GetMsgQueueHandle(hApp, l_cServiceName, l_uiSessionId);
- } else { // event is not registered with this session
- // create new message queue handle and insert it in map servicesessionhandletable
- l_pClientHandle = GetNewHandleAndUpdateEventInfoTable(hApp,
- l_cServiceName, l_uiSessionId, l_uiEventId);
-
- // insert the current session id
- l_vSessionIdList.push_back(l_uiSessionId);
- }
- } else { // if service have not registered this event with any of its session
- // create a list for storing session id's registering this event for this service
- SessionIdList l_vSessionIdList;
-
- // insert the current session id
- l_vSessionIdList.push_back(l_uiSessionId);
-
- // create new message queue handle and insert it in map servicesessionhandletable
- l_pClientHandle = GetNewHandleAndUpdateEventInfoTable(hApp, l_cServiceName, l_uiSessionId, l_uiEventId);
-
- // make a entry for service name and session id's list in map of ServiceSessionIdListTable
- l_mServiceSessionIdListTable.insert(make_pair(l_cServiceName, l_vSessionIdList));
- }
- } else { // if event is not registered by any of the clients
- // create a list for storing session id's registering this event for this service
- SessionIdList l_vSessionIdList;
-
- // insert the current session id
- l_vSessionIdList.push_back(l_uiSessionId);
-
- // create new message queue handle and insert it in map servicesessionhandletable
- l_pClientHandle = GetNewHandleAndUpdateEventInfoTable(hApp, l_cServiceName, l_uiSessionId, l_uiEventId);
-
- // create a table for storing services and its session id list, registering this event
- ServiceSessionIdListTable l_mServiceSessionIdListTable;
-
- // make a entry for service name and session id's list in map of ServiceSessionIdListTable
- l_mServiceSessionIdListTable.insert(make_pair(l_cServiceName, l_vSessionIdList));
-
- // insert the table with event id in EventTable
- pApp->eventtable.insert(make_pair(l_uiEventId, l_mServiceSessionIdListTable));
- }
-
- // check whether event is defined as public state event
- se_iterator = pApp->publicstateeventtable.find(l_uiEventId);
-
- // if event is a state event, publish the event
- if (pApp->publicstateeventtable.end() != se_iterator) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "%d is a public state event", l_uiEventId);
-
- if (NULL != (se_iterator->second)) {
- // send the event data for state event
- eStatus = FrameworkunifiedSendMsg(l_pClientHandle,
- l_uiEventId,
- (se_iterator->second)->uiLength,
- (se_iterator->second)->pData);
- FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "Sending event:%d to service:%s, session:%d, status:%d",
- l_uiEventId,
- l_cServiceName,
- l_uiSessionId,
- eStatus);
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "Event %d yet not published ", l_uiEventId);
- }
- } else { // check whether the event is defined as private state event
- pse_iterator = pApp->privatestateeventtable.find(l_uiEventId);
-
- // if event found, publish the event
- if (pApp->privatestateeventtable.end() != pse_iterator) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "%d is a private state event", l_uiEventId);
-
- ssed_iterator = (pse_iterator->second).find(l_cServiceName);
-
- // check whether the event had been published for this service before subscription
- if ((pse_iterator->second).end() != ssed_iterator) {
- sed_iterator = (ssed_iterator->second).find(l_uiSessionId);
-
- // check whether the event had been published for this service for the same session
- if ((ssed_iterator->second).end() != sed_iterator) {
- if (NULL != (sed_iterator->second)) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, "%d had been published for the "
- "service:%s on sessionId:%d ", l_uiEventId,
- l_cServiceName, l_uiSessionId);
-
- // send the event data for state event
- eStatus = FrameworkunifiedSendMsg(l_pClientHandle,
- l_uiEventId,
- (sed_iterator->second)->uiLength,
- (sed_iterator->second)->pData);
- FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "Sending event:%d to service:%s, session:%d, status:%d",
- l_uiEventId,
- l_cServiceName,
- l_uiSessionId,
- eStatus);
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "Event %d yet not published ", l_uiEventId);
- }
- }
- }
- }
- }
- } // end of for loop of events list
- } else {
- eStatus = eFrameworkunifiedStatusInvldBuf;
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error :: %d, PROTOCOL_REGISTER_EVENTS Invalid data ", eStatus);
- }
-
- if (NULL != l_pData) {
- delete[] l_pData;
- l_pData = NULL;
- }
- } else {
- eStatus = eFrameworkunifiedStatusInvldParam;
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error :: %d, PROTOCOL_REGISTER_EVENTS Service Name invalid ", eStatus);
- }
- } else {
- eStatus = eFrameworkunifiedStatusInvldHandle;
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error :: %d, Invalid hApp ", eStatus);
- }
-
- return eStatus;
-}
-
-//////////////////////////////////////////
-// Function : IsEventAlreadyRegistered
-//////////////////////////////////////////
-BOOL IsEventAlreadyRegistered(const SessionIdList &vSessionIdList, const UI_32 uiSessionId) {
- for (UI_32 uiCount = 0; uiCount < vSessionIdList.size(); uiCount++) {
- if (uiSessionId == vSessionIdList[uiCount]) {
- return TRUE;
- }
- }
-
- return FALSE;
-}
-
-//////////////////////////////////////////
-// Function : GetMsgQueueHandle
-//////////////////////////////////////////
-HANDLE GetMsgQueueHandle(HANDLE hApp, PCSTR serviceName, const UI_32 uiSessionId) {
- HANDLE l_pClientHandle = NULL;
-
- if (frameworkunifiedCheckValidAppHandle(hApp)) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
-
- ServiceSessionHandleTable::iterator ssh_iterator;;
- SessionToEventInfo::iterator sh_iterator;
-
- // find the service name
- ssh_iterator = pApp->servicesessionhandletable.find(serviceName);
-
- if (pApp->servicesessionhandletable.end() != ssh_iterator) {
- // search for session id
- sh_iterator = ssh_iterator->second.find(uiSessionId);
-
- if (ssh_iterator->second.end() != sh_iterator) {
- SessionEventInfo *l_ptSessionEventInfo = sh_iterator->second;
- if (NULL != l_ptSessionEventInfo) {
- l_pClientHandle = l_ptSessionEventInfo->m_hSession;
- FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "Handle found for service: %s, session: %d, handle:%p.",
- serviceName, uiSessionId, l_pClientHandle);
- }
- }
- }
- }
-
- if (NULL == l_pClientHandle) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "Handle NULL for service: %s, session: %d.",
- serviceName != 0 ? serviceName : NULL, uiSessionId);
- }
-
- return l_pClientHandle;
-}
-
-//////////////////////////////////////////
-// Function : GetNewHandleAndUpdateEventInfoTable
-//////////////////////////////////////////
-HANDLE GetNewHandleAndUpdateEventInfoTable(HANDLE hApp, PCSTR serviceName, const UI_32 uiSessionId,
- const UI_32 uiEventId) {
- HANDLE l_pClientHandle = NULL;
-
- if (frameworkunifiedCheckValidAppHandle(hApp)) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
-
- ServiceSessionHandleTable::iterator ssh_iterator;;
- SessionToEventInfo::iterator sh_iterator;
-
- ssh_iterator = pApp->servicesessionhandletable.find(serviceName);
-
- if (pApp->servicesessionhandletable.end() == ssh_iterator) {
- SessionToEventInfo l_mSessionToEventInfoTable;
- pApp->servicesessionhandletable.insert(make_pair(serviceName, l_mSessionToEventInfoTable));
- }
-
- sh_iterator = pApp->servicesessionhandletable[serviceName].find(uiSessionId);
-
- if (pApp->servicesessionhandletable[serviceName].end() == sh_iterator) {
- l_pClientHandle = FrameworkunifiedMcOpenSender(hApp, serviceName);
- if (NULL != l_pClientHandle) {
- (reinterpret_cast<MsgQInfo *>(l_pClientHandle))->sessionId = uiSessionId;
- }
- SessionEventInfo *l_ptSessionEventInfo = new(std::nothrow) SessionEventInfo;
- if (NULL != l_ptSessionEventInfo) { // LCOV_EXCL_BR_LINE 5: new's error case.
- l_ptSessionEventInfo->m_hSession = l_pClientHandle;
- l_ptSessionEventInfo->m_vEvents.push_back(uiEventId);
- pApp->servicesessionhandletable[serviceName].insert(std::make_pair(uiSessionId, l_ptSessionEventInfo));
- } else {
- // LCOV_EXCL_START 5: malloc's error case.
- AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error(NULL) createing new session event info for "
- "service:%s, session:%d, event:%d.",
- serviceName, uiSessionId, uiEventId);
- // LCOV_EXCL_STOP
- }
- } else {
- SessionEventInfo *l_ptSessionEventInfo = sh_iterator->second;
- if (NULL != l_ptSessionEventInfo) {
- if (NULL == l_ptSessionEventInfo->m_hSession) {
- l_ptSessionEventInfo->m_hSession = FrameworkunifiedMcOpenSender(hApp, serviceName);
- if (NULL != l_ptSessionEventInfo->m_hSession) {
- (reinterpret_cast<MsgQInfo *>(l_ptSessionEventInfo->m_hSession))->sessionId = uiSessionId;
- }
- }
- l_pClientHandle = l_ptSessionEventInfo->m_hSession;
- l_ptSessionEventInfo->m_vEvents.push_back(uiEventId);
- }
- }
- }
- return l_pClientHandle;
-}
-
-//////////////////////////////////////////
-// Function : UnregisterPrivateEvents
-//////////////////////////////////////////
-EFrameworkunifiedStatus UnregisterPrivateEvents(HANDLE hApp) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (frameworkunifiedCheckValidAppHandle(hApp)) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
-
- // get the name of the service from which message is received
- PCSTR l_cServiceName = pApp->cMsgSrcName;
- const UI_32 l_uiSessionId = pApp->uiSessionId;
-
- // number of events to unregister
- UI_32 l_uiListSize = static_cast<UI_32>(FrameworkunifiedGetMsgLength(hApp) / sizeof(UI_32));
-
- // check if the received service name and data is valid
- if (NULL != l_cServiceName && 0 < l_uiListSize) {
- PUI_32 l_pData = new(std::nothrow) UI_32[l_uiListSize];
- UI_32 l_uiEventId = 0;
-
- if (NULL != l_pData) { // LCOV_EXCL_BR_LINE 5: new's error case.
- // get the list of events
- eStatus = FrameworkunifiedGetMsgDataOfSize(hApp, l_pData, static_cast<UI_32>(l_uiListSize * sizeof(UI_32)));
-
- if (eFrameworkunifiedStatusOK == eStatus) {
- for (UI_32 uiCount = 0; uiCount < l_uiListSize; uiCount++) {
- // received event id
- l_uiEventId = l_pData[uiCount];
-
- // remove the entry from map of Events and Session id's of services
- eStatus = RemoveEventEntryFromEventTable(hApp, l_uiEventId, l_cServiceName, l_uiSessionId);
- (VOID)RemoveEntryFromSessionEventInfoTable(hApp, l_cServiceName, l_uiSessionId, l_uiEventId);
- }
- } else {
- eStatus = eFrameworkunifiedStatusInvldBuf;
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error :: %d, PROTOCOL_REGISTER_EVENTS Invalid data ", eStatus);
- }
- delete[] l_pData;
- l_pData = NULL;
- } else {
- // LCOV_EXCL_START 5: new's error case.
- AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
- eStatus = eFrameworkunifiedStatusNullPointer;
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error :: PROTOCOL_UNREGISTER_EVENTS: "
- "Unable to allocate memory for l_pData");
- // LCOV_EXCL_STOP
- }
- } else {
- eStatus = eFrameworkunifiedStatusInvldParam;
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error :: %d, PROTOCOL_UNREGISTER_EVENTS Service Name invalid ", eStatus);
- }
- } else {
- eStatus = eFrameworkunifiedStatusInvldParam;
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error :: %d, Invalid hApp ", eStatus);
- }
-
- return eStatus;
-}
-
-//////////////////////////////////////////
-// Function : HandleSessionEventOnCloseSession
-//////////////////////////////////////////
-EFrameworkunifiedStatus HandleSessionEventOnCloseSession(HANDLE hApp) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (frameworkunifiedCheckValidAppHandle(hApp)) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- // close session request structure
- CloseSessionReq tClose = {};
- if (FrameworkunifiedGetMsgLength(hApp) == sizeof(tClose)) {
- if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedGetMsgDataOfSize(hApp, &tClose, sizeof(tClose)))) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error :: %d, FrameworkunifiedGetMsgDataOfSize Failed ", eStatus);
- } else {
- CleanAllEventsOfSession(hApp, pApp->cMsgSrcName, tClose.sessionId);
- }
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Invalid data length received:: Expected: %ld, Received: %d",
- static_cast<long int>(sizeof(tClose)), FrameworkunifiedGetMsgLength(hApp)); // NOLINT (readability/nolint)
- eStatus = eFrameworkunifiedStatusFail;
- }
- } else {
- eStatus = eFrameworkunifiedStatusInvldParam;
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Invalid application handle status.");
- }
-
- return eStatus;
-}
-
-//////////////////////////////////////////
-// Function : FrameworkunifiedOnDummy
-//////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedOnDummy(HANDLE hApp) {
- return eFrameworkunifiedStatusOK;
-}
-
-#ifdef DISPATCHER_PROFILER
-EFrameworkunifiedStatus FrameworkunifiedAttachMsgProfilerCallbacksDispatcher(HANDLE hApp) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (frameworkunifiedCheckValidAppHandle(hApp)) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- if (NULL != pApp->m_pFrameworkunifiedMsgProfiler) {
- eStatus = FrameworkunifiedAttachCallbackToDispatcher(hApp,
- "NSProfileUtil",
- PROTOCOL_DIS_MSGPROFILER,
- boost::bind(&FrameworkunifiedMsgProfiler::PrintProfileInfo,
- pApp->m_pFrameworkunifiedMsgProfiler, hApp));
- if (eFrameworkunifiedStatusOK == eStatus) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, "", "FrameworkunifiedAttachCallbackToDispatcher success for PROTOCOL_DIS_MSGPROFILER.");
- }
- }
- }
- return eStatus;
-}
-
-EFrameworkunifiedStatus FrameworkunifiedAttachChildMsgProfilerCallbacksDispatcher(HANDLE hChildApp) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
- FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, "", "+");
- if (frameworkunifiedCheckValidAppHandle(hChildApp)) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hChildApp);
- if (NULL != pApp->m_pFrameworkunifiedMsgProfiler) {
- eStatus = FrameworkunifiedAttachCallbackToDispatcher(hChildApp,
- pApp->cParentAppName,
- PROTOCOL_DIS_MSGPROFILER,
- boost::bind(&FrameworkunifiedMsgProfiler::PrintProfileInfo,
- pApp->m_pFrameworkunifiedMsgProfiler, hChildApp));
- if (eFrameworkunifiedStatusOK == eStatus) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, "", "FrameworkunifiedAttachCallbackToDispatcher success for PROTOCOL_DIS_MSGPROFILER.");
- }
- }
- }
- FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, "", "-");
- return eStatus;
-}
-#endif
-// EOF
diff --git a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_framework_dispatch.cpp b/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_framework_dispatch.cpp
deleted file mode 100755
index cb573c9..0000000
--- a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_framework_dispatch.cpp
+++ /dev/null
@@ -1,983 +0,0 @@
-/*
- * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-///////////////////////////////////////////////////////////////////////////////
-/// \ingroup tag_NSFramework
-/// \brief
-///
-///
-///
-///////////////////////////////////////////////////////////////////////////////
-#include <sys/epoll.h>
-
-#include <native_service/frameworkunified_framework_if.h>
-#include <native_service/ns_message_center_if.h>
-#include <native_service/ns_logger_if.h>
-#include <native_service/ns_plogger_if.h>
-#include <other_service/strlcpy.h>
-
-#include <map>
-#include <utility>
-
-#include "frameworkunified_framework_core.h"
-///////////////////////////////////////////////////
-// Utility
-///////////////////////////////////////////////////
-
-//////////////////////////////////////////
-// Function : FrameworkunifiedGetAppName
-//////////////////////////////////////////
-PCSTR FrameworkunifiedGetAppName(HANDLE hApp) {
- if (frameworkunifiedCheckValidAppHandle(hApp)) {
- const CFrameworkunifiedFrameworkApp *pApp = reinterpret_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- return ((PCSTR)pApp->cAppName);
- } else {
- return NULL;
- }
-}
-
-//////////////////////////////////////////
-// Function : FrameworkunifiedSetThreadSpecificData
-//////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedSetThreadSpecificData(HANDLE hApp, PVOID data) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusInvldHandle;
-
- if (frameworkunifiedCheckValidAppHandle(hApp)) {
- CFrameworkunifiedFrameworkApp *pApp = reinterpret_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- pApp->FrameworkData = data;
-
- eStatus = eFrameworkunifiedStatusOK;
- }
-
- return eStatus;
-}
-
-//////////////////////////////////////////
-// Function : FrameworkunifiedGetThreadSpecificData
-//////////////////////////////////////////
-PVOID FrameworkunifiedGetThreadSpecificData(HANDLE hApp) {
- if (frameworkunifiedCheckValidAppHandle(hApp)) {
- const CFrameworkunifiedFrameworkApp *pApp = reinterpret_cast< CFrameworkunifiedFrameworkApp * >(hApp);
- return pApp->FrameworkData;
- } else {
- return NULL;
- }
-}
-
-
-
-template <typename K, typename V, class C, class A>
-std::ostream &operator<< (std::ostream &os, std::map<K, V, C, A> const &m) {
- os << "{ ";
- typename std::map<K, V, C, A>::const_iterator p;
- for (p = m.begin(); p != m.end(); ++p) {
- os << p->first << ":" << p->second << ", ";
- }
- return os << "}";
-}
-
-
-
-
-
-
-
-///////////////////////////////////////////////////
-// Service Protocol attach/detach to dispatcher
-///////////////////////////////////////////////////
-
-
-
-
-
-
-
-/////////////////////////////////////////////////////
-// Function : FrameworkunifiedAttachCallbacksToDispatcher
-/////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedAttachCallbacksToDispatcher(HANDLE hApp, PCSTR pServiceName, const FrameworkunifiedProtocolCallbackHandler *handlers,
- UI_32 handlerCount, HANDLE hSession) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (frameworkunifiedCheckValidAppHandle(hApp) && NULL != pServiceName && NULL != handlers && 0 != handlerCount) {
- // setup callbacks
- for (UI_32 i = 0; i < handlerCount; ++i) {
- if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedAttachCallbackToDispatcher(hApp, pServiceName, handlers[ i ].iCmd,
- handlers[ i ].callBack, hSession))) {
- break;
- }
- }
- } else {
- eStatus = eFrameworkunifiedStatusInvldParam;
- }
-
- return eStatus;
-}
-
-
-/////////////////////////////////////////////
-// Function : FrameworkunifiedAttachCallbackToDispatcher
-/////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedAttachCallbackToDispatcher(HANDLE hApp, PCSTR pServiceName, UI_32 iCmd, CbFuncPtr fpOnCmd,
- HANDLE hSession) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (frameworkunifiedCheckValidAppHandle(hApp) && NULL != pServiceName && NULL != fpOnCmd) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- Services::iterator s_iterator;
- SessionTable::iterator session_iterator;
-
- UI_32 uiSessionId = 0;
- if (hSession) {
- uiSessionId = FrameworkunifiedGetSessionId(hSession);
- }
-
- // finding the service
- s_iterator = pApp->services.find(pServiceName);
- if (s_iterator == pApp->services.end()) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, "%s : (New service entry): service name [%s]", pApp->cAppName, pServiceName);
- s_iterator = pApp->services.insert(std::make_pair(pServiceName, SessionTable())).first;
- }
-
- session_iterator = s_iterator->second.find(uiSessionId);
- if (session_iterator == s_iterator->second.end()) {
- session_iterator = s_iterator->second.insert(std::make_pair(uiSessionId, ServiceProtocolTable())).first;
- }
-
- session_iterator->second.insert(std::make_pair(iCmd, fpOnCmd));
- } else {
- eStatus = eFrameworkunifiedStatusInvldParam;
- }
-
- return eStatus;
-}
-
-///////////////////////////////////////////////////
-// Function : FrameworkunifiedAttachCallbacksToDispatcherWithFd
-///////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedAttachCallbacksToDispatcherWithFd(HANDLE hApp, const FrameworkunifiedFdProtocolCallbackHandler *handlers,
- UI_32 handlerCount) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (frameworkunifiedCheckValidAppHandle(hApp) && NULL != handlers && 0 != handlerCount) {
- // setup callbacksWithFd
- for (UI_32 i = 0; i < handlerCount; ++i) {
- if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedAttachCallbackToDispatcherWithFd(hApp, handlers[ i ].fd,
- handlers[ i ].callBack))) {
- break;
- }
- }
- } else {
- eStatus = eFrameworkunifiedStatusInvldParam;
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error : %d, Invalid param ", eStatus);
- }
-
- return eStatus;
-}
-
-///////////////////////////////////////////////////
-// Function : FrameworkunifiedAttachCallbackToDispatcherWithFd
-///////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedAttachCallbackToDispatcherWithFd(HANDLE hApp, int fd, CbFuncPtr fpOnCmd) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
- int efd; // FD for multi waiting
- struct epoll_event ev; // Info struct to associate with multiwaiting FD
-
- if (frameworkunifiedCheckValidAppHandle(hApp) && 0 < fd && NULL != fpOnCmd) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
-
- // attach callbackFuncPtr and FD to FdTable.
- pApp->fds.insert(std::make_pair(fd, fpOnCmd));
-
- // Monitor FD by epoll.
- efd = pApp->efd;
- if (0 < efd) {
- ev.events = EPOLLIN;
- ev.data.fd = fd;
- if (-1 == epoll_ctl(efd, EPOLL_CTL_ADD, fd, &ev)) {
- /**
- * Duplicate registering the same FD in the Dispatcher causes an internal epoll_ctl errno EEXIST(val17) to be returned, which results in an error.
- */
- eStatus = eFrameworkunifiedStatusFail;
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR : epoll_ctl(ADD) Failed, status=%d, errno=%d", eStatus, errno);
- }
- } else {
- eStatus = eFrameworkunifiedStatusFail;
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Multi waiting FD is Invalid , status=%d, efd=%d", eStatus, efd);
- }
- } else {
- eStatus = eFrameworkunifiedStatusInvldParam;
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error : %d, Invalid param ", eStatus);
- }
-
- return eStatus;
-}
-
-/////////////////////////////////////////////////////
-// Function : FrameworkunifiedAttachParentCallbacksToDispatcher
-/////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedAttachParentCallbacksToDispatcher(HANDLE hChildApp, const FrameworkunifiedProtocolCallbackHandler *handlers,
- UI_32 handlerCount) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (frameworkunifiedCheckValidAppHandle(hChildApp) && NULL != handlers && 0 != handlerCount) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hChildApp);
-
- eStatus = FrameworkunifiedAttachCallbacksToDispatcher(hChildApp, pApp->cParentAppName, handlers, handlerCount);
- } else {
- eStatus = eFrameworkunifiedStatusInvldParam;
- }
-
- return eStatus;
-}
-
-
-/////////////////////////////////////////////////////
-// Function : FrameworkunifiedDetachParentCallbacksFromDispatcher
-/////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedDetachParentCallbacksFromDispatcher(HANDLE hChildApp, const PUI_32 puiCmdArray, UI_32 uiCommandCount) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (frameworkunifiedCheckValidAppHandle(hChildApp) && NULL != puiCmdArray && 0 != uiCommandCount) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hChildApp);
-
- eStatus = FrameworkunifiedDetachCallbacksFromDispatcher(hChildApp, pApp->cParentAppName, puiCmdArray, uiCommandCount);
- } else {
- eStatus = eFrameworkunifiedStatusInvldParam;
- }
-
- return eStatus;
-}
-
-/////////////////////////////////////////////////////
-// Function : FrameworkunifiedDetachCallbacksFromDispatcher
-/////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedDetachCallbacksFromDispatcher(HANDLE hApp, PCSTR pServiceName, const PUI_32 puiCmdArray,
- UI_32 uiCommandCount, HANDLE hSession) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (frameworkunifiedCheckValidAppHandle(hApp) && NULL != pServiceName && NULL != puiCmdArray && 0 != uiCommandCount) {
- // setup callbacks
- for (UI_32 i = 0; i < uiCommandCount; ++i) {
- if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedDetachCallbackFromDispatcher(hApp, pServiceName,
- puiCmdArray[ i ], hSession))) {
- break;
- }
- }
- } else {
- eStatus = eFrameworkunifiedStatusInvldParam;
- }
-
- return eStatus;
-}
-
-
-
-////////////////////////////////////////////
-// Function : FrameworkunifiedDetachCallbackFromDispatcher
-/////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedDetachCallbackFromDispatcher(HANDLE hApp, PCSTR pServiceName, UI_32 iCmd, HANDLE hSession) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (frameworkunifiedCheckValidAppHandle(hApp) && NULL != pServiceName) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- Services::iterator s_iterator;
-
- UI_32 uiSessionId = 0;
- if (hSession) {
- uiSessionId = FrameworkunifiedGetSessionId(hSession);
- }
-
- // finding the service
- s_iterator = pApp->services.find(pServiceName);
- if (s_iterator != pApp->services.end()) {
- SessionTable::iterator session_iterator;
- session_iterator = (s_iterator->second).find(uiSessionId);
- if (session_iterator != (s_iterator->second).end()) {
- ServiceProtocolTable::iterator spt_iterator;
- FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, "%s : (found): service [%s]", pApp->cAppName, pServiceName);
-
- spt_iterator = (session_iterator->second).find(iCmd);
- if (spt_iterator != (session_iterator->second).end()) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, "%s : Detaching command [0x%X] service [%s]",
- pApp->cAppName, iCmd, pServiceName);
- (session_iterator->second).erase(spt_iterator);
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "%s : Warning : Cmd NOT found [%d] service [%s]",
- pApp->cAppName, iCmd, pServiceName);
- }
- }
-
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "%s : Warning : Cannot find service [%s]", pApp->cAppName, pServiceName);
- eStatus = eFrameworkunifiedStatusFail;
- }
- } else {
- eStatus = eFrameworkunifiedStatusInvldParam;
- }
-
-
- return eStatus;
-}
-
-/////////////////////////////////////////////////////
-// Function : FrameworkunifiedDetachCallbacksFromDispatcherWithFd
-/////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedDetachCallbacksFromDispatcherWithFd(HANDLE hApp, const int *fdArray, UI_32 uiCommandCount) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (frameworkunifiedCheckValidAppHandle(hApp) && NULL != fdArray && 0 != uiCommandCount) {
- // setup callbacks
- for (UI_32 i = 0; i < uiCommandCount; ++i) {
- if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedDetachCallbackFromDispatcherWithFd(hApp, fdArray[ i ]))) {
- break;
- }
- }
- } else {
- eStatus = eFrameworkunifiedStatusInvldParam;
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error : %d, Invalid param ", eStatus);
- }
-
- return eStatus;
-}
-
-////////////////////////////////////////////////////
-// Function : FrameworkunifiedDetachCallbackFromDispatcherWithFd
-////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedDetachCallbackFromDispatcherWithFd(HANDLE hApp, int fd) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (frameworkunifiedCheckValidAppHandle(hApp) && 0 < fd) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- FdTable::iterator f_iterator;
- int efd; // FD for multi waiting
- struct epoll_event ev; // Info struct to associate with multiwaiting FD
-
- // finding the FD from FD table
- f_iterator = pApp->fds.find(fd);
- if (f_iterator != pApp->fds.end()) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, "%s : Detaching fd [0x%x]", pApp->cAppName, fd);
- pApp->fds.erase(f_iterator);
-
- // Remove the monitoring of FD from multi waiting FD
- efd = pApp->efd;
- if (0 < efd) {
- ev.events = EPOLLIN;
- ev.data.fd = fd;
- if (-1 == epoll_ctl(efd, EPOLL_CTL_DEL, fd, &ev)) {
- eStatus = eFrameworkunifiedStatusFail;
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR : epoll_ctl(DEL) Failed, status=%d, errno=%d", eStatus, errno);
- }
- } else {
- eStatus = eFrameworkunifiedStatusFail;
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Multi waiting FD is Invalid , status=%d, efd=%d", eStatus, efd);
- }
- } else {
- eStatus = eFrameworkunifiedStatusFail;
- FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "%s : Warning : Cannot find fd [0x%x]", pApp->cAppName, fd);
- }
- } else {
- eStatus = eFrameworkunifiedStatusInvldParam;
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error :: %d, Invalid param ", eStatus);
- }
-
-
- return eStatus;
-}
-
-///////////////////////////////////////////////////
-// Function : FrameworkunifiedDetachServiceFromDispatcher
-///////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedDetachServiceFromDispatcher(HANDLE hApp, PCSTR pServiceName) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (frameworkunifiedCheckValidAppHandle(hApp) && NULL != pServiceName) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- Services::iterator s_iterator;
- EventServices::iterator es_iterator;
-
- // finding the service
- s_iterator = pApp->services.find(pServiceName);
- if (s_iterator != pApp->services.end()) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, "%s : (found): service [%s]", pApp->cAppName, pServiceName);
- pApp->services.erase(s_iterator);
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "%s : Warning: Cannot find service [%s]", pApp->cAppName, pServiceName);
- eStatus = eFrameworkunifiedStatusFail;
- }
-
- // finding the service
- es_iterator = pApp->eventservices.find(pServiceName);
- if (es_iterator != pApp->eventservices.end()) {
- eStatus = eFrameworkunifiedStatusOK;
- FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, "%s : (found): service [%s] in event map", pApp->cAppName, pServiceName);
- pApp->eventservices.erase(es_iterator);
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "%s : Warning : Cannot find service [%s] in event map",
- pApp->cAppName, pServiceName);
- }
- } else {
- eStatus = eFrameworkunifiedStatusInvldParam;
- }
-
- return eStatus;
-}
-
-///////////////////////////////////////////////////
-// Notification functions
-///////////////////////////////////////////////////
-
-
-////////////////////////////////////////////////////////
-// Function : FrameworkunifiedAttachNotificationCallbacksToDispatcher
-////////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedSubscribeNotificationsWithCallback(HANDLE hApp, const FrameworkunifiedNotificationCallbackHandler *pNtfyHandler,
- UI_32 uiHandlerCount) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (frameworkunifiedCheckValidAppHandle(hApp) && pNtfyHandler && (uiHandlerCount > 0)) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
-
- /// Deal with handling batch processing of subscriptions.
- if (eFrameworkunifiedStatusOK == (eStatus = FrameworkunifiedNPSubscribeToNotifications(hApp, pNtfyHandler, uiHandlerCount))) {
- for (UI_32 i = 0; i < uiHandlerCount; ++i) {
- // Notification names are character arrays of the MAX_STRING_SIZE_NOTIFICATION byte
- // If there are no NULL characters in the array of Notification names, they will overrun during make_pair,
- // so use a strlcpy that substitutes a trailing NULL character.
- char tmp_notification[MAX_STRING_SIZE_NOTIFICATION] = {0};
- strlcpy(tmp_notification, pNtfyHandler[ i ].cNotification, MAX_STRING_SIZE_NOTIFICATION);
- // service found
- pApp->notifications.insert(std::make_pair(tmp_notification, pNtfyHandler[ i ].callBack));
-
- FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, "%s : attaching call-back for notification [%s]", pApp->cAppName,
- pNtfyHandler[ i ].cNotification);
- }
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "%s : Error : [%d] Unable to Subscribe to batch set of notifications",
- pApp->cAppName, eStatus);
- }
- } else {
- eStatus = eFrameworkunifiedStatusInvldParam;
- }
-
- return eStatus;
-}
-
-////////////////////////////////////////////////////////
-// Function : FrameworkunifiedAttachNotificationCallbackToDispatcher
-////////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedSubscribeNotificationWithCallback(HANDLE hApp, PCSTR pNotification, CbFuncPtr fpOnCmd) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (frameworkunifiedCheckValidAppHandle(hApp) && NULL != pNotification && NULL != fpOnCmd) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- NotificationTableRetStatus mRet;
-
- if (eFrameworkunifiedStatusOK == (eStatus = FrameworkunifiedNPSubscribeToNotification(hApp, pNotification))) {
- // Notification names are character arrays of the MAX_STRING_SIZE_NOTIFICATION byte
- // If there are no NULL characters in the array of Notification names, they will overrun during make_pair,
- // so use a strlcpy that substitutes a trailing NULL character.
- char tmp_notification[MAX_STRING_SIZE_NOTIFICATION] = {0};
- strlcpy(tmp_notification, pNotification, MAX_STRING_SIZE_NOTIFICATION);
-
- // service found
- mRet = pApp->notifications.insert(std::make_pair(tmp_notification, fpOnCmd));
- if (false == mRet.second) {
- eStatus = eFrameworkunifiedStatusDuplicate;
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "%s:Error:[%d] Unable to Subscribe to notification [%s]",
- pApp->cAppName, eStatus, pNotification);
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, "%s:attaching call-back for notification [%s]",
- pApp->cAppName, pNotification);
- }
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "%s:Error:[%d] Unable to Subscribe to notification [%s]",
- pApp->cAppName, eStatus, pNotification);
- }
- } else {
- eStatus = eFrameworkunifiedStatusInvldParam;
- }
-
- return eStatus;
-}
-
-
-
-////////////////////////////////////////////////////////
-// Function : FrameworkunifiedDetachNotificationCallbacksFromDispatcher
-////////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedUnsubscribeNotificationsWithCallback(HANDLE hApp, const FrameworkunifiedNotificationCallbackHandler *pNtfyHandler,
- UI_32 uiHandlerCount) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
- NotificationTable::iterator n_iterator;
- PCSTR pNotification = NULL;
-
- if (frameworkunifiedCheckValidAppHandle(hApp) && NULL != pNtfyHandler && (uiHandlerCount > 0)) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
-
- if (eFrameworkunifiedStatusOK == (eStatus = FrameworkunifiedNPUnsubscribeFromNotifications(hApp, pNtfyHandler, uiHandlerCount))) {
- for (UI_32 l_unCount = 0; l_unCount < uiHandlerCount; ++l_unCount) {
- // When registering using FrameworkunifiedSubscribeNotificationWithCallback, etc., the Nortification names NULL the 64th byte.
- // In response to this, the UnRegister uses a strlcpy that puts a NULL in the 64th byte.
- char tmp_notification[MAX_STRING_SIZE_NOTIFICATION] = {0};
- strlcpy(tmp_notification, pNtfyHandler[ l_unCount ].cNotification, MAX_STRING_SIZE_NOTIFICATION);
-
- n_iterator = pApp->notifications.find(tmp_notification);
- if (n_iterator != pApp->notifications.end()) {
- pApp->notifications.erase(n_iterator);
- FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, "%s : removed notification [%s]", pApp->cAppName, pNotification);
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "%s : Error : Cannot find notification [%s]", pApp->cAppName,
- pNotification != 0 ? pNotification : NULL);
- eStatus = eFrameworkunifiedStatusFail;
- }
- }
-
- FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, "%s : detaching call-back for notification [%s]", pApp->cAppName,
- pNotification != 0 ? pNotification : NULL);
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "%s : Error : [%d] Unable to UnSubscribe from notifications ", pApp->cAppName,
- eFrameworkunifiedStatusOK);
- }
- } else {
- eStatus = eFrameworkunifiedStatusInvldParam;
- }
-
- return eStatus;
-}
-
-
-////////////////////////////////////////////////////////
-// Function : FrameworkunifiedDetachNotificationCallbackToDispatcher
-////////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedUnsubscribeNotificationWithCallback(HANDLE hApp, PCSTR pNotification) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (frameworkunifiedCheckValidAppHandle(hApp) && NULL != pNotification) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- NotificationTable::iterator n_iterator;
-
- if (eFrameworkunifiedStatusOK == (eStatus = FrameworkunifiedNPUnsubscribeFromNotification(hApp, pNotification))) {
- // \todo : error handling on all map function calls
-
- // When registering using FrameworkunifiedSubscribeNotificationWithCallback, etc., the Nortification names NULL the 64th byte.
- // In response to this, the UnRegister uses a strlcpy that puts a NULL in the 64th byte.
- char tmp_notification[MAX_STRING_SIZE_NOTIFICATION] = {0};
- strlcpy(tmp_notification, pNotification, MAX_STRING_SIZE_NOTIFICATION);
-
- n_iterator = pApp->notifications.find(tmp_notification);
- if (n_iterator != pApp->notifications.end()) {
- pApp->notifications.erase(n_iterator);
- FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, "%s:removed notification [%s]", pApp->cAppName, pNotification);
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "%s:Error:Cannot find notification [%s]", pApp->cAppName, pNotification);
- eStatus = eFrameworkunifiedStatusFail;
- }
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "%s:Error:[%d] Unable to UnSubscribe from notification [%s]",
- pApp->cAppName, eStatus, pNotification);
- }
- } else {
- eStatus = eFrameworkunifiedStatusInvldParam;
- }
-
- return eStatus;
-}
-
-///////////////////////////////////////////////////
-// Defer Message functions
-///////////////////////////////////////////////////
-
-////////////////////////////////////////////////////////
-// Function : FrameworkunifiedGetDeferQueueCnt
-////////////////////////////////////////////////////////
-UI_32 FrameworkunifiedGetDeferQueueCnt(HANDLE hApp) {
- UI_32 l_uiCnt = 0;
-
- if (frameworkunifiedCheckValidAppHandle(hApp)) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- l_uiCnt = static_cast<UI_32>(pApp->deferedMsgQueue.size());
- }
-
- return l_uiCnt;
-}
-
-////////////////////////////////////////////////////////
-// Function : FrameworkunifiedIsDeferQueueEmpty
-////////////////////////////////////////////////////////
-BOOL FrameworkunifiedIsDeferQueueEmpty(HANDLE hApp) {
- BOOL l_bIsQEmpty = TRUE;
-
- if (frameworkunifiedCheckValidAppHandle(hApp)) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- l_bIsQEmpty = static_cast<BOOL>(pApp->deferedMsgQueue.empty());
- }
-
- return l_bIsQEmpty;
-}
-
-////////////////////////////////////////////////////////
-// Function : FrameworkunifiedDeferMessage
-////////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedDeferMessage(HANDLE hApp) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (frameworkunifiedCheckValidAppHandle(hApp)) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- DeferedMsgInfo defer(pApp->uiProtocolCmd, pApp->cMsgSrcName, pApp->uiMsgRcvBuffer);
- pApp->deferedMsgQueue.push(defer);
- } else {
- eStatus = eFrameworkunifiedStatusInvldParam;
- }
-
- return eStatus;
-}
-
-////////////////////////////////////////////////////////
-// Function : FrameworkunifiedClearDeferMessages
-////////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedClearDeferMessages(HANDLE hApp) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (frameworkunifiedCheckValidAppHandle(hApp)) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
-
- // clear the pop flag!
- pApp->fPopDeferedMsg = FALSE;
-
- // remove all items from the queue!
- while (!pApp->deferedMsgQueue.empty()) {
- pApp->deferedMsgQueue.pop();
- }
- } else {
- eStatus = eFrameworkunifiedStatusInvldParam;
- }
-
- return eStatus;
-}
-
-////////////////////////////////////////////////////////
-// Function : FrameworkunifiedRetrieveDeferMessage
-////////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedRetrieveDeferMessage(HANDLE hApp) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
- uint64_t data = 1;
- if (frameworkunifiedCheckValidAppHandle(hApp)) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- pApp->fPopDeferedMsg = pApp->deferedMsgQueue.empty() ? FALSE : TRUE;
- if (pApp->fPopDeferedMsg) {
- if (-1 == (write(pApp->defer_evfd, &data, sizeof(uint64_t)))) {
- eStatus = eFrameworkunifiedStatusFail;
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR : write Failed, status=%d, errno=%d, defer_evfd=%d",
- eStatus, errno, pApp->defer_evfd);
- }
- }
-
-
- } else {
- eStatus = eFrameworkunifiedStatusInvldParam;
- }
-
- return eStatus;
-}
-
-
-////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedIsStateMachineApp
-/// Returns TRUE if it's a state machine application else FALSE.
-////////////////////////////////////////////////////////////////////////////////////////////
-BOOL FrameworkunifiedIsStateMachineApp(HANDLE hApp) {
- BOOL l_bIsStateMachine = FALSE;
-
- if (frameworkunifiedCheckValidAppHandle(hApp)) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- if (NULL != pApp->m_pFrameworkunifiedStateMachine) {
- l_bIsStateMachine = TRUE;
- }
- }
-
- return l_bIsStateMachine;
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedGetXMLConfigHandle
-/// Returns the handle to config file handle
-////////////////////////////////////////////////////////////////////////////////////////////
-HANDLE FrameworkunifiedGetXMLConfigHandle(HANDLE hApp) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __PRETTY_FUNCTION__, "This function is not implemented!!!!");
- return NULL;
-}
-
-EFrameworkunifiedStatus FrameworkunifiedSetMandatoryServiceInfo(HANDLE hApp, PCSTR pNotification, UI_32 uiEventId) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (frameworkunifiedCheckValidAppHandle(hApp) && NULL != pNotification) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- ServiceNotificationInfo objNotification = {};
- if (strlen(pNotification) < MAX_STRING_SIZE_NOTIFICATION) {
- strlcpy(objNotification.sNotificationName, pNotification, sizeof(objNotification.sNotificationName));
- objNotification.uiEventId = uiEventId;
- pApp->servicenotificationlist.push_back(objNotification);
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__,
- " Error : Aborting ... Exceeds Max Notification name size MAX_STRING_SIZE_NOTIFICATION : %d ",
- MAX_STRING_SIZE_NOTIFICATION);
- eStatus = eFrameworkunifiedStatusFail;
- }
- } else {
- eStatus = eFrameworkunifiedStatusInvldParam;
- }
-
- return eStatus;
-}
-
-BOOL FrameworkunifiedIsServiceAvailable(HANDLE hApp) {
- BOOL l_bIsServiceAvailable = FALSE;
-
- if (frameworkunifiedCheckValidAppHandle(hApp)) {
- // Publish notification
- ServiceAvailability tServiceAvailability = {};
-
- UI_32 l_uiLength = FrameworkunifiedGetMsgLength(hApp);
-
- if (sizeof(tServiceAvailability) == l_uiLength) {
- // Read the data from the message
- if (eFrameworkunifiedStatusOK != FrameworkunifiedGetMsgDataOfSize(hApp, &tServiceAvailability, sizeof(tServiceAvailability))) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, " FrameworkunifiedGetMsgDataOfSize Failed");
- } else {
- // Check the Service availability
- if (eFrameworkunifiedServiceAvailable == tServiceAvailability.eServiceAvailability) {
- l_bIsServiceAvailable = TRUE;
- }
- }
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, " Error: Received message data size not matched :: %d", l_uiLength);
- }
- }
-
- return l_bIsServiceAvailable;
-}
-
-EFrameworkunifiedStatus FrameworkunifiedPublishServiceAvailability(HANDLE hApp, BOOL bIsAvailable) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (frameworkunifiedCheckValidAppHandle(hApp)) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- if (strlen(pApp->sServiceAvailabilityNotification)) {
- // Publish Service available this can also be published from FrameworkunifiedOnStart callback
- pApp->bIsAvailable = bIsAvailable;
- ServiceAvailability tServiceAvailability = {};
- strlcpy(tServiceAvailability.cServiceName, FrameworkunifiedGetAppName(hApp), sizeof(tServiceAvailability.cServiceName));
-
- if (bIsAvailable) {
- tServiceAvailability.eServiceAvailability = eFrameworkunifiedServiceAvailable;
- } else {
- tServiceAvailability.eServiceAvailability = eFrameworkunifiedServiceNotAvailable;
- }
-
- if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedNPPublishNotification(hApp, pApp->sServiceAvailabilityNotification,
- &tServiceAvailability, sizeof(tServiceAvailability)))) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __PRETTY_FUNCTION__,
- "Failed to Publish notification: %s, status: %d", pApp->sServiceAvailabilityNotification, eStatus);
- FRAMEWORKUNIFIEDLOG_PERFORMANCE("Service Availability Status: %s, ERRORED %d", bIsAvailable ? "TRUE" : "FALSE", eStatus);
- } else {
- FRAMEWORKUNIFIEDLOG_PERFORMANCE("Service Availability Status: %s", bIsAvailable ? "TRUE" : "FALSE");
- FRAMEWORKUNIFIEDLOG(ZONE_NS_IMP_INFO, __FUNCTION__,
- "Publish availability notfn:%s, status:%s", pApp->sServiceAvailabilityNotification,
- bIsAvailable ? "TRUE" : "FALSE");
- }
- } else {
- eStatus = eFrameworkunifiedStatusFail;
- }
- } else {
- eStatus = eFrameworkunifiedStatusInvldParam;
- }
-
- return eStatus;
-}
-
-BOOL FrameworkunifiedGetSelfAvailability(HANDLE hApp) {
- if (frameworkunifiedCheckValidAppHandle(hApp)) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- return pApp->bIsAvailable;
- }
-
- return FALSE;
-}
-
-EFrameworkunifiedStatus FrameworkunifiedRegisterServiceAvailabilityNotification(HANDLE hApp, PCSTR pNotification) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (frameworkunifiedCheckValidAppHandle(hApp) && NULL != pNotification) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- if (strlen(pNotification) < MAX_STRING_SIZE_NOTIFICATION) {
- strlcpy(pApp->sServiceAvailabilityNotification, pNotification, sizeof(pApp->sServiceAvailabilityNotification));
-
- // Register Notifications
- if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedNPRegisterNotification(hApp, pNotification,
- sizeof(ServiceAvailability), eFrameworkunifiedStateVar))) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "FrameworkunifiedNPRegisterNotifications %s Failed Status:0x%x ", pNotification, eStatus);
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "FrameworkunifiedNPRegisterNotifications %s success Status:0x%x ",
- pNotification, eStatus);
- }
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__,
- " Error : Aborting ... Exceeds Max Notification name size MAX_STRING_SIZE_NOTIFICATION : %d ",
- MAX_STRING_SIZE_NOTIFICATION);
- eStatus = eFrameworkunifiedStatusFail;
- }
- } else {
- eStatus = eFrameworkunifiedStatusInvldParam;
- }
-
- return eStatus;
-}
-
-EFrameworkunifiedStatus FrameworkunifiedUnRegisterServiceAvailabilityNotification(HANDLE hApp) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (frameworkunifiedCheckValidAppHandle(hApp)) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
-
- // Register Notifications
- if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedNPUnRegisterNotification(hApp, pApp->sServiceAvailabilityNotification))) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "FrameworkunifiedNPUnRegisterNotifications %s Failed Status:0x%x ",
- pApp->sServiceAvailabilityNotification != 0 ? pApp->sServiceAvailabilityNotification : NULL, eStatus);
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "FrameworkunifiedNPUnRegisterNotifications %s success Status:0x%x ",
- pApp->sServiceAvailabilityNotification, eStatus);
- }
- memset(pApp->sServiceAvailabilityNotification, 0, MAX_SYS_INFO_SIZE);
- pApp->bIsAvailable = FALSE;
- } else {
- eStatus = eFrameworkunifiedStatusInvldParam;
- }
-
- return eStatus;
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedGetServiceNameOnServiceAvailabilityNotification
-/// To be used when client receives service availability notification to get the available
-/// service name.
-////////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedGetServiceNameOnServiceAvailabilityNotification(HANDLE hApp, PSTR pServiceName) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
- // Publish notification
- ServiceAvailability tServiceAvailability;
-
- if (frameworkunifiedCheckValidAppHandle(hApp) && NULL != pServiceName) {
- UI_32 l_uiLength = FrameworkunifiedGetMsgLength(hApp);
-
- if (sizeof(tServiceAvailability) == l_uiLength) {
- // Read the data from the message
- if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedGetMsgDataOfSize(hApp, &tServiceAvailability, sizeof(tServiceAvailability)))) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, " FrameworkunifiedGetMsgDataOfSize Failed");
- eStatus = eFrameworkunifiedStatusFail;
- } else {
- if (NULL == std::strncpy(pServiceName, tServiceAvailability.cServiceName, MAX_NAME_SIZE_APP)) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, " strcpy failed Failed");
- eStatus = eFrameworkunifiedStatusFail;
- }
- }
- } else {
- eStatus = eFrameworkunifiedStatusFail;
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, " Error: Received message data size not matched :: %d", l_uiLength);
- }
- } else {
- eStatus = eFrameworkunifiedStatusInvldParam;
- }
-
- return eStatus;
-}
-
-//////////////////////////////////////////
-// Function : FrameworkunifiedGetCurrentUser
-//////////////////////////////////////////
-HANDLE FrameworkunifiedGetCurrentUser(HANDLE hApp) {
- if (frameworkunifiedCheckValidAppHandle(hApp)) {
- const CFrameworkunifiedFrameworkApp *pApp = reinterpret_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- return pApp->hUser;
- } else {
- return NULL;
- }
-}
-
-//////////////////////////////////////////
-// Function : FrameworkunifiedSetUser
-//////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedSetUser(HANDLE hApp, HANDLE hUser) {
- if (frameworkunifiedCheckValidAppHandle(hApp)) {
- CFrameworkunifiedFrameworkApp *pApp = reinterpret_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- pApp->hUser = hUser;
- return eFrameworkunifiedStatusOK;
- } else {
- return eFrameworkunifiedStatusFail;
- }
-}
-
-//////////////////////////////////////////
-// Function : FrameworkunifiedSetAppData
-//////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedSetAppData(HANDLE hApp, PCSTR pKey, PVOID pData) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusInvldHandle;
- if (frameworkunifiedCheckValidAppHandle(hApp)) {
- CFrameworkunifiedFrameworkApp *pApp = reinterpret_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- // Insert the data element
- std::pair<AppData::iterator, bool> l_tRet = pApp->appdata.insert(std::make_pair(pKey, pData));
- if (false == l_tRet.second) {
- eStatus = eFrameworkunifiedStatusFail;
- } else {
- eStatus = eFrameworkunifiedStatusOK;
- }
- }
- return eStatus;
-}
-
-//////////////////////////////////////////
-// Function : FrameworkunifiedGetAppData
-//////////////////////////////////////////
-PVOID FrameworkunifiedGetAppData(HANDLE hApp, PCSTR pKey) {
- if (frameworkunifiedCheckValidAppHandle(hApp)) {
- CFrameworkunifiedFrameworkApp *pApp = reinterpret_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- AppData::iterator n_iterator = pApp->appdata.find(pKey);
- if (n_iterator != pApp->appdata.end()) {
- return n_iterator->second;
- }
- }
- return NULL;
-}
-
-
-//////////////////////////////////////////
-// Function : FrameworkunifiedRemoveAppData
-//////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedRemoveAppData(HANDLE hApp, PCSTR pKey) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusInvldHandle;
- if (frameworkunifiedCheckValidAppHandle(hApp)) {
- CFrameworkunifiedFrameworkApp *pApp = reinterpret_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- AppData::iterator n_iterator = pApp->appdata.find(pKey);
- if (n_iterator != pApp->appdata.end()) {
- pApp->appdata.erase(n_iterator);
-
- eStatus = eFrameworkunifiedStatusOK;
- } else {
- eStatus = eFrameworkunifiedStatusFail;
- }
- }
- return eStatus;
-}
diff --git a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_framework_error.cpp b/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_framework_error.cpp
deleted file mode 100755
index cf07922..0000000
--- a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_framework_error.cpp
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <native_service/frameworkunified_framework_error.hpp>
-#include <cstdio>
-#include <string>
-#include "frameworkunified_framework_error_internal.hpp"
-
-// using std::snprintf;
-typedef std::string TErrorDesc;
-typedef const TErrorDesc TCErrorDesc;
-
-namespace {
-
-PCSTR FrameworkunifiedStatusDesc(EFrameworkunifiedStatus status) {
- switch (status) {
- case eFrameworkunifiedStatusSessionLimitMaxedOut:
- return "Session limit maxed out";
- case eFrameworkunifiedStatusDbRecNotFound:
- return "Db record not Found";
- case eFrameworkunifiedStatusDbResultError:
- return "Db result error";
- case eFrameworkunifiedStatusDbExecuteFail:
- return "Db execute failure";
- case eFrameworkunifiedStatusSemCloseFail:
- return "Semaphore close failure";
- case eFrameworkunifiedStatusSemUnlockFail:
- return "Semaphore unlock gailure";
- case eFrameworkunifiedStatusSemLockFail:
- return "Semaphore lock failure";
- case eFrameworkunifiedStatusFail:
- return "failure";
- case eFrameworkunifiedStatusOK:
- return "Status OK";
- case eFrameworkunifiedStatusInvldBuf:
- return "Invalid buffer";
- case eFrameworkunifiedStatusInvldHandle:
- return "Invalid handle";
- case eFrameworkunifiedStatusInvldHndlType:
- return "Invalid handle yype";
- case eFrameworkunifiedStatusInvldQName:
- return "Invalid queue name";
- case eFrameworkunifiedStatusMsgQFull:
- return "Message queue full";
- case eFrameworkunifiedStatusInvldNotification:
- return "Invliad notification";
- case eFrameworkunifiedStatusInvldParam:
- return "Invalid parameter";
- case eFrameworkunifiedStatusInvldBufSize:
- return "Invalid buffer size";
- case eFrameworkunifiedStatusInvldID:
- return "Invalid MemID";
- case eFrameworkunifiedStatusCannotRelease:
- return "Cannot release resource";
- case eFrameworkunifiedStatusBadConnection:
- return "Bad connection";
- case eFrameworkunifiedStatusExit:
- return "Exit";
- case eFrameworkunifiedStatusNotImplemented:
- return "Not implemented";
- case eFrameworkunifiedStatusThreadBusy:
- return "Thread busy";
- case eFrameworkunifiedStatusThreadSelfJoin:
- return "Attempted to self-join";
- case eFrameworkunifiedStatusThreadInvalidVal:
- return "Invalid value passed";
- case eFrameworkunifiedStatusThreadNotExist:
- return "Thread does not exist";
- case eFrameworkunifiedStatusFault:
- return "Fault";
- case eFrameworkunifiedStatusServNotFound:
- return "Service not found";
- case eFrameworkunifiedStatusErrOther:
- default:
- return "Other error";
- }
-}
-
-TCErrorDesc BuildFrameworkunifiedErrorDesc(EFrameworkunifiedStatus error, PCSTR errorMsg) {
- CHAR buf[ MAX_QUEUE_MSG_SIZE ] = {};
- snprintf(&buf[ 0 ],
- MAX_QUEUE_MSG_SIZE,
- "Framework Error: %s - %s",
- FrameworkunifiedStatusDesc(error),
- errorMsg != 0 ? errorMsg : NULL);
- return TErrorDesc(&buf[ 0 ]);
-}
-
-TCErrorDesc BuildFrameworkunifiedSystemErrorDesc(EFrameworkunifiedSystemError error, PCSTR errorMsg) {
- TErrorDesc l_cErrorMsg("Framework defined error desc: ");
-
- switch (error) {
- // Commented, because this is product specific error. Must handle by SystemServices only.
- // case eFrameworkunifiedDSPHardwareReset : l_cErrorMsg.append("DSP HW RESET ERROR"); break;
- default:
- l_cErrorMsg.append("Other error");
- break;
- }
-
- l_cErrorMsg.append(" :: Application provided error desc:");
- l_cErrorMsg.append(errorMsg);
- return l_cErrorMsg;
-}
-
-} // end namespace
-
-
-
-frameworkunified::framework::error::error::error(EFrameworkunifiedStatus error, PCSTR errorMsg)
- : std::runtime_error(BuildFrameworkunifiedErrorDesc(error, errorMsg)),
- m_error(error) {
-}
-
-frameworkunified::framework::error::CSystemError::CSystemError(EFrameworkunifiedSystemError error, PCSTR errorMsg)
- : std::runtime_error(BuildFrameworkunifiedSystemErrorDesc(error, errorMsg)),
- m_eSystemError(error) {
-}
diff --git a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_framework_logger.cpp b/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_framework_logger.cpp
deleted file mode 100755
index 2912527..0000000
--- a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_framework_logger.cpp
+++ /dev/null
@@ -1,575 +0,0 @@
-/*
- * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-///////////////////////////////////////////////////////////////////////////////
-/// \ingroup tag_NSFramework
-/// \brief Framework wrapper over the logger interface APIs
-///
-///
-///
-///////////////////////////////////////////////////////////////////////////////
-
-///////////////////////////////////////////////////////////////////////////////
-// Include Files
-///////////////////////////////////////////////////////////////////////////////
-#include <native_service/ns_rcs_logger_types.h>
-#include <native_service/frameworkunified_framework_if.h>
-#include <native_service/ns_logger_if.h>
-#include <native_service/nslogutil_cmd_if.h>
-#include <native_service/ns_message_center_if.h>
-#include <cstdio>
-#include "frameworkunified_framework_core.h"
-#include "frameworkunified_framework_internal.h"
-#include "frameworkunified_framework_utility.h"
-
-FrameworkunifiedProtocolCallbackHandler rcs_logging_callbacks[] = {
- { NSRCS_SET_LOG_SETTINGS_REQ, NSRcsSetLogSettings },
- { NSRCS_GET_LOG_SETTINGS_REQ, NSRcsGetLogSettings },
- { NSRCS_SET_LOG_MASK_REQ, NSRcsSetLogMask },
- { NSRCS_SET_LOG_OUT_OPT_REQ, NSRcsSetOutputLogOpts },
- { NSRCS_SET_LOG_SEVERITY_REQ, NSRcsSetLogSeverity },
-};
-
-
-FrameworkunifiedProtocolCallbackHandler logging_callbacks[] = {
- { SET_LOG_MASK, FrameworkunifiedSetLogMask },
- { GET_LOG_MASK, FrameworkunifiedGetLogMask },
- { SET_LOG_OUT_OPT, FrameworkunifiedSetOutputLogOpts },
- { GET_LOG_OUT_OPT, FrameworkunifiedGetOutputLogOpts },
- // { kDebugDumpRequest, FrameworkunifiedDebugDumpRequest }, /// < Added to help Debug Issues with in CCR Radio
- // Callback attach with frameworkunifieddebug is moved to SystemServices
- { SET_LOG_SEVERITY, FrameworkunifiedSetLogSeverity },
- { GET_LOG_SEVERITY, FrameworkunifiedGetLogSeverity },
-};
-
-
-////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedNPRegisterNotification
-////////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedAttachLoggerCallbacksDispatcher(HANDLE hApp) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (frameworkunifiedCheckValidAppHandle(hApp)) {
- eStatus = FrameworkunifiedAttachCallbacksToDispatcher(hApp, "nslogutil", logging_callbacks,
- static_cast<UI_32>(_countof(logging_callbacks)));
- // Callback attach with of kDebugDumpRequest with frameworkunifieddebug is moved to SystemServices. Keep only nslogutil.
- eStatus = (eStatus != eFrameworkunifiedStatusOK) ? eStatus : FrameworkunifiedAttachCallbackToDispatcher(hApp, "nslogutil", kDebugDumpRequest,
- FrameworkunifiedDebugDumpRequest);
- eStatus = (eStatus != eFrameworkunifiedStatusOK) ? eStatus : FrameworkunifiedAttachCallbacksToDispatcher(hApp,
- "SS_LoggerService",
- logging_callbacks,
- static_cast<UI_32>(_countof(logging_callbacks)));
- eStatus = FrameworkunifiedSubscribeNotificationWithCallback(hApp, NTFY_LOGGER_SETCONTROLMASK, FrameworkunifiedSetLogMask);
-
- // This is optional only for remote control service. Therefore return value not checked
- if (eFrameworkunifiedStatusOK != FrameworkunifiedAttachCallbacksToDispatcher(hApp, FRAMEWORKUNIFIED_NS_REMOTECONTROLSERVICE, rcs_logging_callbacks,
- static_cast<UI_32>(_countof(rcs_logging_callbacks)))) {
- // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
- FRAMEWORKUNIFIEDLOG0(ZONE_NS_WAR, __FUNCTION__,
- " FrameworkunifiedAttachCallbacksToDispatcher failed for rcs_logging_callbacks with FRAMEWORKUNIFIED_NS_REMOTECONTROLSERVICE");
- // LCOV_EXCL_BR_STOP
- }
- } else {
- eStatus = eFrameworkunifiedStatusInvldParam;
- }
- return eStatus;
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedNPRegisterNotification
-////////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedSetLogMask(HANDLE hApp) { // LCOV_EXCL_START 7:debug code
- AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
- CHANGELOGPARAMS chngLogOpts;
- FRAMEWORKUNIFIEDLOG0(ZONE_NS_INFO, __FUNCTION__, "+");
-
- if (FrameworkunifiedGetMsgLength(hApp) == sizeof(CHANGELOGPARAMS)) {
- if (eFrameworkunifiedStatusOK == FrameworkunifiedGetMsgDataOfSize(hApp, (PVOID)&chngLogOpts, sizeof(chngLogOpts))) {
- // Set the mask to the value that was just sent.
- NsLogSetControlMask(chngLogOpts.uiZoneMask);
- } else {
- FRAMEWORKUNIFIEDLOG0(ZONE_NS_ERR, __FUNCTION__, "Retervial of Data Failed");
- eStatus = eFrameworkunifiedStatusErrOther;
- }
- } else {
- FRAMEWORKUNIFIEDLOG0(ZONE_NS_ERR, __FUNCTION__, " Incorrect message sz");
- eStatus = eFrameworkunifiedStatusInvldBuf;
- }
-
- FRAMEWORKUNIFIEDLOG0(ZONE_NS_INFO, __FUNCTION__, "-");
- return eStatus;
-}
-// LCOV_EXCL_STOP
-
-////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedNPRegisterNotification
-////////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedGetLogMask(HANDLE hApp) { // LCOV_EXCL_START 7:debug code
- AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
- FRAMEWORKUNIFIEDLOG0(ZONE_NS_INFO, __FUNCTION__, "+");
-
- if (frameworkunifiedCheckValidAppHandle(hApp)) {
- PCSTR pAppName = FrameworkunifiedGetAppName(hApp);
- PCSTR pSrcName = FrameworkunifiedGetMsgSrc(hApp);
-
- if (NULL != pAppName && NULL != pSrcName) {
- HANDLE echoBack = McOpenSender(pSrcName);
- if (NULL != echoBack) {
- CHANGELOGPARAMS chng_log_params;
-
- NsLogGetControlMask(chng_log_params.uiZoneMask);
- if (eFrameworkunifiedStatusOK != (eStatus = McSend(echoBack, pAppName, GET_LOG_MASK_RESPONSE, sizeof(chng_log_params),
- &chng_log_params))) {
- FRAMEWORKUNIFIEDLOG0(ZONE_NS_ERR, __FUNCTION__, "Error sending message GET_LOG_MASK_RESPONSE");
- }
-
- McClose(echoBack);
- echoBack = NULL;
- } else {
- eStatus = eFrameworkunifiedStatusInvldHandle;
- }
- } else {
- eStatus = eFrameworkunifiedStatusNullPointer;
- }
- } else {
- eStatus = eFrameworkunifiedStatusInvldParam;
- }
-
- FRAMEWORKUNIFIEDLOG0(ZONE_NS_INFO, __FUNCTION__, "-");
- return eStatus;
-}
-// LCOV_EXCL_STOP
-
-////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedNPRegisterNotification
-////////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedSetOutputLogOpts(HANDLE hApp) { // LCOV_EXCL_START 7:debug code
- AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
- CHANGELOGPARAMS chngLogOpts;
- FRAMEWORKUNIFIEDLOG0(ZONE_NS_INFO, __FUNCTION__, "+");
-
- if (FrameworkunifiedGetMsgLength(hApp) == sizeof(CHANGELOGPARAMS)) {
- if (eFrameworkunifiedStatusOK == FrameworkunifiedGetMsgDataOfSize(hApp, (PVOID)&chngLogOpts, sizeof(chngLogOpts))) {
- // Set the logging method to the value that was just received.
- NsLogSetLogMethod(chngLogOpts.uiLogOptions);
- } else {
- FRAMEWORKUNIFIEDLOG0(ZONE_NS_ERR, __FUNCTION__, "Retervial of Data Failed");
- eStatus = eFrameworkunifiedStatusErrOther;
- }
- } else {
- FRAMEWORKUNIFIEDLOG0(ZONE_NS_ERR, __FUNCTION__, " Incorrect message sz");
- eStatus = eFrameworkunifiedStatusInvldBuf;
- }
-
-
- FRAMEWORKUNIFIEDLOG0(ZONE_NS_INFO, __FUNCTION__, "-");
- return eStatus;
-}
-// LCOV_EXCL_STOP
-
-////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedNPRegisterNotification
-////////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedGetOutputLogOpts(HANDLE hApp) { // LCOV_EXCL_START 7:debug code
- AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
- FRAMEWORKUNIFIEDLOG0(ZONE_NS_INFO, __FUNCTION__, "+");
-
- if (frameworkunifiedCheckValidAppHandle(hApp)) {
- PCSTR pAppName = FrameworkunifiedGetAppName(hApp);
- PCSTR pSrcName = FrameworkunifiedGetMsgSrc(hApp);
-
- if (NULL != pAppName && NULL != pSrcName) {
- HANDLE echoBack = McOpenSender(pSrcName);
-
- if (NULL != echoBack) {
- CHANGELOGPARAMS chng_log_params;
-
- chng_log_params.uiLogOptions = NsLogGetLogMethod();
- if (eFrameworkunifiedStatusOK != (eStatus = McSend(echoBack, pAppName, GET_LOG_OUT_OPT_RESPONSE, sizeof(chng_log_params),
- &chng_log_params))) {
- FRAMEWORKUNIFIEDLOG0(ZONE_NS_ERR, __FUNCTION__, "Error sending message GET_LOG_OUT_OPT_RESPONSE");
- }
-
- McClose(echoBack);
- echoBack = NULL;
- } else {
- eStatus = eFrameworkunifiedStatusInvldHandle;
- }
- } else {
- eStatus = eFrameworkunifiedStatusNullPointer;
- }
- } else {
- eStatus = eFrameworkunifiedStatusInvldParam;
- }
-
- FRAMEWORKUNIFIEDLOG0(ZONE_NS_INFO, __FUNCTION__, "-");
- return eStatus;
-}
-// LCOV_EXCL_STOP
-
-////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedSetLogSeverity
-////////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedSetLogSeverity(HANDLE hApp) { // LCOV_EXCL_START 7:debug code
- AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
- CHANGELOGPARAMS l_tChngLogOpts = {};
- FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "+");
-
- if (FrameworkunifiedGetMsgLength(hApp) == sizeof(CHANGELOGPARAMS)) {
- if (eFrameworkunifiedStatusOK == FrameworkunifiedGetMsgDataOfSize(hApp, (PVOID)&l_tChngLogOpts, sizeof(l_tChngLogOpts))) {
- // Set the logging method to the value that was just received.
- NsLogSetSeverity(l_tChngLogOpts.eSeverity);
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Retrieval of log severity data Failed");
- eStatus = eFrameworkunifiedStatusErrOther;
- }
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, " Incorrect message size CHANGELOGPARAMS");
- eStatus = eFrameworkunifiedStatusInvldBuf;
- }
-
- FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "-");
- return eStatus;
-}
-// LCOV_EXCL_STOP
-
-////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedGetLogSeverity
-////////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedGetLogSeverity(HANDLE hApp) { // LCOV_EXCL_START 7:debug code
- AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
- FRAMEWORKUNIFIEDLOG0(ZONE_NS_INFO, __FUNCTION__, "+");
-
- if (frameworkunifiedCheckValidAppHandle(hApp)) {
- PCSTR l_cAppName = FrameworkunifiedGetAppName(hApp);
- PCSTR l_cSrcName = FrameworkunifiedGetMsgSrc(hApp);
-
- if (NULL != l_cAppName && NULL != l_cSrcName) {
- HANDLE l_hEchoBack = McOpenSender(l_cSrcName);
-
- if (NULL != l_hEchoBack) {
- CHANGELOGPARAMS l_tChngLogParams = {};
-
- l_tChngLogParams.eSeverity = NsLogGetSeverity();
- if (eFrameworkunifiedStatusOK != (eStatus = McSend(l_hEchoBack, l_cAppName, GET_LOG_SEVERITY_RESPONSE,
- sizeof(l_tChngLogParams), &l_tChngLogParams))) {
- FRAMEWORKUNIFIEDLOG0(ZONE_NS_ERR, __FUNCTION__, "Error sending message GET_LOG_OUT_OPT_RESPONSE");
- }
-
- McClose(l_hEchoBack);
- l_hEchoBack = NULL;
- } else {
- eStatus = eFrameworkunifiedStatusInvldHandle;
- }
- } else {
- eStatus = eFrameworkunifiedStatusNullPointer;
- }
- } else {
- eStatus = eFrameworkunifiedStatusInvldParam;
- }
-
- FRAMEWORKUNIFIEDLOG0(ZONE_NS_INFO, __FUNCTION__, "-");
- return eStatus;
-}
-// LCOV_EXCL_STOP
-
-////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedDebugDumpRequest: Calls an Applications FrameworkunifiedOnDebugDump method.
-////////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedDebugDumpRequest(HANDLE hApp) { // LCOV_EXCL_START 7:debug code
- AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
- FRAMEWORKUNIFIEDLOG0(ZONE_NS_DEBUG_DUMP, __FUNCTION__, "+");
- eStatus = FrameworkunifiedOnDebugDumpInternal(hApp);
- FRAMEWORKUNIFIEDLOG0(ZONE_NS_DEBUG_DUMP, __FUNCTION__, "+");
- return eStatus;
-}
-// LCOV_EXCL_STOP
-
-EFrameworkunifiedStatus NSRcsSetLogSettings(HANDLE hApp) { // LCOV_EXCL_START 7:debug code
- AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
- FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "+");
- if (frameworkunifiedCheckValidAppHandle(hApp)) {
- if (FrameworkunifiedGetMsgLength(hApp) == sizeof(TNSRCS_SetLogSettingsReq)) {
- TNSRCS_SetLogSettingsReq l_tSetLogSettings = {};
-
- if (eFrameworkunifiedStatusOK == FrameworkunifiedGetMsgDataOfSize(hApp, (PVOID)&l_tSetLogSettings, sizeof(l_tSetLogSettings))) {
- // Set the log mask
- NsLogSetControlMask(l_tSetLogSettings.m_pui32ZoneMask);
- // set the log output option
- NsLogSetLogMethod(l_tSetLogSettings.m_ui8OutputLogOption);
- // set the log severity
- NsLogSetSeverity(l_tSetLogSettings.m_si32Severity);
- FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "Log settings applied");
-
- // send the response back with the current settings
- TNSRCS_SetLogSettingsResp l_tSetLogSettingsResp = {};
- PCSTR l_cAppName = FrameworkunifiedGetAppName(hApp);
- PCSTR l_cSrcName = FrameworkunifiedGetMsgSrc(hApp);
- HANDLE l_hSendTo = McOpenSender(l_cSrcName);
-
- if (NULL != l_hSendTo) {
- l_tSetLogSettingsResp.m_ui8ClientId = l_tSetLogSettings.m_ui8ClientId;
- l_tSetLogSettingsResp.m_ui8SetStatus = static_cast<UI_8>(eFrameworkunifiedStatusOK);
-
- NsLogGetControlMask(l_tSetLogSettingsResp.m_pui32ZoneMask);
- l_tSetLogSettingsResp.m_ui8OutputLogOption = NsLogGetLogMethod();
- l_tSetLogSettingsResp.m_si32Severity = NsLogGetSeverity();
-
- if (eFrameworkunifiedStatusOK !=
- McSend(l_hSendTo, l_cAppName, NSRCS_SET_LOG_SETTINGS_RESP,
- sizeof(TNSRCS_SetLogSettingsResp), &l_tSetLogSettingsResp)) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error sending message "
- "NSRCS_SET_LOG_SETTINGS_RESP to %s", l_cSrcName);
- }
- McClose(l_hSendTo);
- l_hSendTo = NULL;
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Sender handle NULL when sending response to %s", l_cSrcName);
- }
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Retrieval of Data Failed");
- }
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, " Incorrect message size. Received: %d expected: %ld",
- FrameworkunifiedGetMsgLength(hApp),
- static_cast<long int>(sizeof(TNSRCS_SetLogSettingsReq))); // NOLINT (readability/nolint)
- }
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "hApp is NULL");
- }
- FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "-");
- return eFrameworkunifiedStatusOK;
-}
-// LCOV_EXCL_STOP
-
-EFrameworkunifiedStatus NSRcsGetLogSettings(HANDLE hApp) { // LCOV_EXCL_START 7:debug code
- AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
- FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "+");
- if (frameworkunifiedCheckValidAppHandle(hApp)) {
- if (FrameworkunifiedGetMsgLength(hApp) == sizeof(TNSRCS_GetLogSettingsReq)) {
- TNSRCS_GetLogSettingsReq l_tGetLogSettings = {};
-
- if (eFrameworkunifiedStatusOK == FrameworkunifiedGetMsgDataOfSize(hApp, (PVOID)&l_tGetLogSettings, sizeof(l_tGetLogSettings))) {
- // send the response back with the current settings
- TNSRCS_GetLogSettingsResp l_tGetLogSettingsResp = {};
- PCSTR l_cAppName = FrameworkunifiedGetAppName(hApp);
- PCSTR l_cSrcName = FrameworkunifiedGetMsgSrc(hApp);
- HANDLE l_hSendTo = McOpenSender(l_cSrcName);
-
- if (NULL != l_hSendTo) {
- l_tGetLogSettingsResp.m_ui8ClientId = l_tGetLogSettings.m_ui8ClientId;
- NsLogGetZoneTextList(l_tGetLogSettingsResp.m_cZoneList);
- NsLogGetControlMask(l_tGetLogSettingsResp.m_pui32ZoneMask);
- l_tGetLogSettingsResp.m_ui8OutputLogOption = NsLogGetLogMethod();
- l_tGetLogSettingsResp.m_si32Severity = NsLogGetSeverity();
-
- if (eFrameworkunifiedStatusOK !=
- McSend(l_hSendTo, l_cAppName, NSRCS_GET_LOG_SETTINGS_RESP,
- sizeof(TNSRCS_GetLogSettingsResp), &l_tGetLogSettingsResp)) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error sending message "
- "NSRCS_GET_LOG_SETTINGS_RESP to %s", l_cSrcName);
- }
- McClose(l_hSendTo);
- l_hSendTo = NULL;
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Sender handle NULL when sending response to %s", l_cSrcName);
- }
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Retrieval of Data Failed");
- }
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, " Incorrect message size. Received: %d expected: %ld",
- FrameworkunifiedGetMsgLength(hApp),
- static_cast<long int>(sizeof(TNSRCS_GetLogSettingsReq))); // NOLINT (readability/nolint)
- }
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "hApp is NULL");
- }
- FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "-");
- return eFrameworkunifiedStatusOK;
-}
-// LCOV_EXCL_STOP
-
-EFrameworkunifiedStatus NSRcsSetLogMask(HANDLE hApp) { // LCOV_EXCL_START 7:debug code
- AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
- FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "+");
- if (frameworkunifiedCheckValidAppHandle(hApp)) {
- if (FrameworkunifiedGetMsgLength(hApp) == sizeof(TNSRCS_SetLogSettingsReq)) {
- TNSRCS_SetLogSettingsReq l_tSetLogSettings = {};
-
- if (eFrameworkunifiedStatusOK == FrameworkunifiedGetMsgDataOfSize(hApp, (PVOID)&l_tSetLogSettings, sizeof(l_tSetLogSettings))) {
- // Set the log mask
- NsLogSetControlMask(l_tSetLogSettings.m_pui32ZoneMask);
-
- // 11 = number of chars in UI_32, 1 - nul char at the end
- CHAR l_cOutMask[(ZONE_MASK_ARRAY_ELTS * 11) + 1] = {};
- CHAR l_cMask[12] = {}; // 12 = 11+1: 11 = number of chars in UI_32, 1 - nul char at the end
- for (UI_32 zoneIndex = 0; zoneIndex < ZONE_MASK_ARRAY_ELTS; zoneIndex++) {
- std::strncpy(l_cMask, "", 11);
- snprintf(l_cMask, sizeof(l_cMask), "0x%X,", l_tSetLogSettings.m_pui32ZoneMask[zoneIndex]);
- std::strncat(l_cOutMask, l_cMask, (sizeof(l_cOutMask) - std::strlen(l_cMask) - 1));
- }
- FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "Log settings (zone mask) applied: %s", l_cOutMask);
-
- // send the response back with the current settings
- TNSRCS_SetLogMaskResp l_tSetLogMaskResp = {};
- PCSTR l_cAppName = FrameworkunifiedGetAppName(hApp);
- PCSTR l_cSrcName = FrameworkunifiedGetMsgSrc(hApp);
- HANDLE l_hSendTo = McOpenSender(l_cSrcName);
-
- if (NULL != l_hSendTo) {
- l_tSetLogMaskResp.m_ui8ClientId = l_tSetLogSettings.m_ui8ClientId;
- l_tSetLogMaskResp.m_ui8SetStatus = static_cast<UI_8>(eFrameworkunifiedStatusOK);
-
- NsLogGetControlMask(l_tSetLogMaskResp.m_pui32ZoneMask);
-
- if (eFrameworkunifiedStatusOK !=
- McSend(l_hSendTo, l_cAppName, NSRCS_SET_LOG_MASK_RESP,
- sizeof(TNSRCS_SetLogMaskResp), &l_tSetLogMaskResp)) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error sending message "
- "NSRCS_SET_LOG_MASK_RESP to %s", l_cSrcName);
- }
- McClose(l_hSendTo);
- l_hSendTo = NULL;
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Sender handle NULL when sending response to %s", l_cSrcName);
- }
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Retrieval of Data Failed");
- }
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, " Incorrect message size. Received: %d expected: %ld",
- FrameworkunifiedGetMsgLength(hApp),
- static_cast<long int>(sizeof(TNSRCS_SetLogSettingsReq))); // NOLINT (readability/nolint)
- }
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "hApp is NULL");
- }
- FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "-");
- return eFrameworkunifiedStatusOK;
-}
-// LCOV_EXCL_STOP
-
-EFrameworkunifiedStatus NSRcsSetOutputLogOpts(HANDLE hApp) { // LCOV_EXCL_START 7:debug code
- AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
- FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "+");
- if (frameworkunifiedCheckValidAppHandle(hApp)) {
- if (FrameworkunifiedGetMsgLength(hApp) == sizeof(TNSRCS_SetLogSettingsReq)) {
- TNSRCS_SetLogSettingsReq l_tSetLogSettings = {};
-
- if (eFrameworkunifiedStatusOK == FrameworkunifiedGetMsgDataOfSize(hApp, (PVOID)&l_tSetLogSettings, sizeof(l_tSetLogSettings))) {
- // set the log output option
- NsLogSetLogMethod(l_tSetLogSettings.m_ui8OutputLogOption);
- FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "Log settings(log output option) applied: %d.",
- l_tSetLogSettings.m_ui8OutputLogOption);
-
- // send the response back with the current settings
- TNSRCS_SetLogOutOptResp l_tSetLogOutputOptResp = {};
- PCSTR l_cAppName = FrameworkunifiedGetAppName(hApp);
- PCSTR l_cSrcName = FrameworkunifiedGetMsgSrc(hApp);
- HANDLE l_hSendTo = McOpenSender(l_cSrcName);
-
- if (NULL != l_hSendTo) {
- l_tSetLogOutputOptResp.m_ui8ClientId = l_tSetLogSettings.m_ui8ClientId;
- l_tSetLogOutputOptResp.m_ui8SetStatus = static_cast<UI_8>(eFrameworkunifiedStatusOK);
-
- l_tSetLogOutputOptResp.m_ui8OutputLogOption = NsLogGetLogMethod();
-
- if (eFrameworkunifiedStatusOK !=
- McSend(l_hSendTo, l_cAppName, NSRCS_SET_LOG_OUT_OPT_RESP,
- sizeof(TNSRCS_SetLogOutOptResp), &l_tSetLogOutputOptResp)) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error sending message "
- "NSRCS_SET_LOG_OUT_OPT_RESP to %s", l_cSrcName);
- }
- McClose(l_hSendTo);
- l_hSendTo = NULL;
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Sender handle NULL when sending response to %s", l_cSrcName);
- }
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Retrieval of Data Failed");
- }
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, " Incorrect message size. Received: %d expected: %ld",
- FrameworkunifiedGetMsgLength(hApp),
- static_cast<long int>(sizeof(TNSRCS_SetLogSettingsReq))); // NOLINT (readability/nolint)
- }
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "hApp is NULL");
- }
- FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "-");
- return eFrameworkunifiedStatusOK;
-}
-// LCOV_EXCL_STOP
-
-EFrameworkunifiedStatus NSRcsSetLogSeverity(HANDLE hApp) { // LCOV_EXCL_START 7:debug code
- AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
- FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "+");
- if (frameworkunifiedCheckValidAppHandle(hApp)) {
- if (FrameworkunifiedGetMsgLength(hApp) == sizeof(TNSRCS_SetLogSettingsReq)) {
- TNSRCS_SetLogSettingsReq l_tSetLogSettings = {};
-
- if (eFrameworkunifiedStatusOK == FrameworkunifiedGetMsgDataOfSize(hApp, (PVOID)&l_tSetLogSettings, sizeof(l_tSetLogSettings))) {
- // set the log severity
- NsLogSetSeverity(l_tSetLogSettings.m_si32Severity);
- FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "Log settings(log severity) applied: %d.",
- l_tSetLogSettings.m_si32Severity);
-
- // send the response back with the current settings
- TNSRCS_SetLogSeverityResp l_tSetLogSeverityResp = {};
- PCSTR l_cAppName = FrameworkunifiedGetAppName(hApp);
- PCSTR l_cSrcName = FrameworkunifiedGetMsgSrc(hApp);
- HANDLE l_hSendTo = McOpenSender(l_cSrcName);
-
- if (NULL != l_hSendTo) {
- l_tSetLogSeverityResp.m_ui8ClientId = l_tSetLogSettings.m_ui8ClientId;
- l_tSetLogSeverityResp.m_ui8SetStatus = static_cast<UI_8>(eFrameworkunifiedStatusOK);
-
- l_tSetLogSeverityResp.m_si32Severity = NsLogGetSeverity();
-
- if (eFrameworkunifiedStatusOK !=
- McSend(l_hSendTo, l_cAppName, NSRCS_SET_LOG_SEVERITY_RESP,
- sizeof(TNSRCS_SetLogSeverityResp), &l_tSetLogSeverityResp)) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error sending message "
- "NSRCS_SET_LOG_SEVERITY_RESP to %s", l_cSrcName);
- }
- McClose(l_hSendTo);
- l_hSendTo = NULL;
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Sender handle NULL when sending response to %s", l_cSrcName);
- }
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Retrieval of Data Failed");
- }
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, " Incorrect message size. Received: %d expected: %ld",
- FrameworkunifiedGetMsgLength(hApp),
- static_cast<long int>(sizeof(TNSRCS_SetLogSettingsReq))); // NOLINT (readability/nolint)
- }
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "hApp is NULL");
- }
- FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "-");
- return eFrameworkunifiedStatusOK;
-}
-// LCOV_EXCL_STOP
diff --git a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_framework_message_center.cpp b/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_framework_message_center.cpp
deleted file mode 100755
index ea953c9..0000000
--- a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_framework_message_center.cpp
+++ /dev/null
@@ -1,502 +0,0 @@
-/*
- * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-///////////////////////////////////////////////////////////////////////////////
-/// \ingroup tag_NSFramework
-/// \brief
-///
-///
-///
-///////////////////////////////////////////////////////////////////////////////
-#include <native_service/frameworkunified_framework_if.h>
-#include <native_service/ns_message_center_if.h>
-#include <other_service/strlcpy.h>
-#include "frameworkunified_framework_core.h"
-#include "ns_mc_internal.h"
-
-using std::malloc;
-using std::free;
-using std::strcpy;
-using std::strlen;
-using std::memset;
-
-extern __thread HANDLE responseWaitQ;
-
-//////////////////////////////////////////
-// Function : FrameworkunifiedMcOpenSender
-//////////////////////////////////////////
-HANDLE FrameworkunifiedMcOpenSender(HANDLE hApp, PCSTR pName) {
- MsgQInfo *pMsgQ = NULL;
-
- if ((frameworkunifiedCheckValidAppHandle(hApp)) && (NULL != pName)) {
- UI_32 l_ui32SrvNameLen = static_cast<UI_32>(strlen(pName));
- /**
- * @todo
- * CHAR cSessionName[MAX_QUEUE_NAME_SIZE] cannot be determined to be 20 bytes including the termination NULL.
- */
- if ((l_ui32SrvNameLen < MAX_NAME_SIZE_APP) && (l_ui32SrvNameLen > 0)) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- pMsgQ = reinterpret_cast<MsgQInfo *>(malloc(sizeof(MsgQInfo)));
-
- if (NULL != pMsgQ) { // LCOV_EXCL_BR_LINE 5:malloc's error case.
- errno = EOK; // flush previous errors, if any.
- memset(pMsgQ, 0, sizeof(MsgQInfo));
- if (NULL == (pMsgQ->hMsgQ = McOpenSender(pName))) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__,
- "Error::errno:%d, hApp:0x%p, %s failed to McOpenSender",
- errno, hApp, pName);
- free(pMsgQ);
- pMsgQ = NULL;
- } else {
- pMsgQ->checkCode = MSGQ_CHECK_CODE;
- pMsgQ->self = pthread_self();
- strlcpy(pMsgQ->cSrcName, pApp->cAppName, sizeof(pMsgQ->cSrcName));
- strlcpy(pMsgQ->cMsgQName, pName, sizeof(pMsgQ->cMsgQName));
- pMsgQ->sessionId = 0;
- }
- }
- } else {
- // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__,
- "Invalid param. Name:%s, Following must be true: %d > len of passed name(%u) > 0.",
- pName, MAX_NAME_SIZE_APP, l_ui32SrvNameLen);
- // LCOV_EXCL_BR_STOP
- }
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__,
- "Invalid param. hApp:0x%p, name:0x%p",
- hApp, pName); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
- }
-
- return static_cast<HANDLE>(pMsgQ);
-}
-
-
-//////////////////////////////////////////
-// Function : FrameworkunifiedMcClose
-//////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedMcClose(HANDLE hService) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
- if (frameworkunifiedCheckValidMsgQ(hService)) {
- MsgQInfo *pMsgQ = reinterpret_cast<MsgQInfo *>(hService);
- pMsgQ->checkCode = 0;
- if (NULL != pMsgQ->hMsgQ) {
- eStatus = McClose(pMsgQ->hMsgQ);
- pMsgQ->hMsgQ = NULL;
- }
- free(pMsgQ);
- pMsgQ = NULL;
- hService = NULL; // This has no effect because hService is not passed as reference.
- } else {
- eStatus = eFrameworkunifiedStatusInvldHandle;
- }
- return eStatus;
-}
-
-
-//////////////////////////////////////////
-// Function : FrameworkunifiedSendMsg
-//////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedSendMsg(HANDLE hService, UI_32 iCmd, UI_32 length, PCVOID data) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
- if (frameworkunifiedCheckValidMsgQ(hService)) {
- MsgQInfo *pMsgQ = reinterpret_cast<MsgQInfo *>(hService);
-
- if ((NULL != pMsgQ->hMsgQ) && (0 != std::strlen(pMsgQ->cSrcName))) {
- eStatus = McSendWithSession(pMsgQ->hMsgQ, pMsgQ->cSrcName, iCmd, length, data, pMsgQ->sessionId);
- } else {
- eStatus = eFrameworkunifiedStatusInvldHandle;
- }
- } else {
- eStatus = eFrameworkunifiedStatusNullPointer;
- }
- // check if McSendWithSession failed with error destination msg queue full
- // log the information
- if (eFrameworkunifiedStatusMsgQFull == eStatus) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error!! Message queue full of receiver '%s' while sending CmdId = 0x%X",
- FrameworkunifiedGetSessionName(hService), iCmd);
- }
-
- return eStatus;
-}
-
-//////////////////////////////////////////
-// Function : FrameworkunifiedSendPriorityMsg
-//////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedSendPriorityMsg(HANDLE hService, UI_32 iCmd, UI_32 length, PCVOID data) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
- if (frameworkunifiedCheckValidMsgQ(hService)) {
- MsgQInfo *pMsgQ = reinterpret_cast<MsgQInfo *>(hService);
- eStatus = McSendWithPriority(pMsgQ->hMsgQ, pMsgQ->cSrcName, iCmd,
- length, data, eFrameworkunifiedMsgPrioEmergency, pMsgQ->sessionId);
- } else {
- eStatus = eFrameworkunifiedStatusNullPointer;
- }
-
- return eStatus;
-}
-
-//////////////////////////////////////////
-// Function: FrameworkunifiedSendSelf
-//////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedSendSelf(HANDLE hApp, UI_32 iCmd, UI_32 length, PCVOID data) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
- if (frameworkunifiedCheckValidAppHandle(hApp)) {
- CFrameworkunifiedFrameworkApp *pApp = reinterpret_cast< CFrameworkunifiedFrameworkApp * >(hApp);
- eStatus = McSend(pApp->hAppSndMsgQ, &pApp->cAppName[ 0 ], iCmd, length, data);
- } else {
- eStatus = eFrameworkunifiedStatusNullPointer;
- }
- return eStatus;
-}
-
-//////////////////////////////////////////
-// Function : FrameworkunifiedInvokeSync
-//////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedInvokeSync(HANDLE hService, UI_32 iCmd, UI_32 msgLenght, PCVOID msgData, UI_32 responseLength,
- PVOID responseData, UI_32 *receivedLength) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (frameworkunifiedCheckValidMsgQ(hService)) {
- if (NULL != receivedLength) {
- MsgQInfo *pMsgQ = static_cast<MsgQInfo *>(hService);
-
- if (responseWaitQ == NULL) {
- char mc_invoker_name[MAX_QUEUE_NAME_SIZE];
- InvokerName invokerName;
- // LCOV_EXCL_BR_START 11:except branch
- McCreateInvokerName(pMsgQ->cSrcName, pMsgQ->sessionId, mc_invoker_name, sizeof(mc_invoker_name));
- // LCOV_EXCL_BR_STOP
- invokerName = mc_invoker_name;
-
- responseWaitQ = McOpenSyncReceiver(invokerName.c_str());
- if (NULL == responseWaitQ) {
- eStatus = eFrameworkunifiedStatusFail;
- }
- }
-
- if (eStatus == eFrameworkunifiedStatusOK) {
- eStatus = McInvokeSync(pMsgQ->hMsgQ, pMsgQ->cSrcName, iCmd, msgLenght, msgData, pMsgQ->sessionId,
- responseWaitQ, responseLength, responseData, receivedLength);
- }
- } else {
- eStatus = eFrameworkunifiedStatusInvldParam;
- }
- } else {
- eStatus = eFrameworkunifiedStatusNullPointer;
- }
-
- return eStatus;
-}
-
-//////////////////////////////////////////
-// Function : frameworkunifiedSendSyncResponse
-//////////////////////////////////////////
-EFrameworkunifiedStatus frameworkunifiedSendSyncResponse(HANDLE hApp, UI_32 iCmd, UI_32 seq_id, EFrameworkunifiedStatus retValue, UI_32 length, PCVOID data) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (frameworkunifiedCheckValidAppHandle(hApp)) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- HANDLE responseSendQ;
-
- char mc_invoker_name[MAX_QUEUE_NAME_SIZE];
- InvokerName invokerName;
- PVOID rcv_buf = static_cast<PVOID>(pApp->uiMsgRcvBuffer);
- McCreateInvokerName(McGetMsgSrc(rcv_buf), mcGetMsgSsessionId(rcv_buf), mc_invoker_name, sizeof(mc_invoker_name));
- invokerName = mc_invoker_name;
-
- InvokeResponseQTable::iterator s_iterator = pApp->invokeResQTable.find(invokerName);
- if (s_iterator != pApp->invokeResQTable.end()) {
- responseSendQ = s_iterator->second;
- } else {
- responseSendQ = McOpenSyncSender(invokerName.c_str()); // LCOV_EXCL_BR_LINE 11:except branch
- /*
- * @todo
- * FrameworkunifiedSendSyncResponse() uses McOpenSyncSender() to create a synchronous communication response queue handle,
- * but there is no process to release the queue handle after the response.
- */
- if (NULL == responseSendQ) {
- eStatus = eFrameworkunifiedStatusFail;
- } else {
- pApp->invokeResQTable[invokerName] = responseSendQ; // LCOV_EXCL_BR_LINE 11:except branch
- }
- }
-
- if (eStatus == eFrameworkunifiedStatusOK) {
- eStatus = McSendSyncResponse(responseSendQ, pApp->cAppName, iCmd, seq_id, retValue, length, data);
- }
- } else {
- eStatus = eFrameworkunifiedStatusNullPointer;
- }
- return eStatus;
-}
-
-//////////////////////////////////////////
-// Function : FrameworkunifiedDispatchProcess
-//////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedSetSyncResponseData(HANDLE hApp, PVOID data, UI_32 size) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- /*
- * @todo
- * When the response data is 0 bytes, it can be transmitted as SYNC data.
- */
- if (frameworkunifiedCheckValidAppHandle(hApp) && data != NULL) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- try {
- pApp->responsedata.set(data, size); // LCOV_EXCL_BR_LINE 11:except branch
- }
- catch(std::bad_alloc) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __PRETTY_FUNCTION__, "bad_alloc");
- eStatus = eFrameworkunifiedStatusFail;
- }
- } else {
- eStatus = eFrameworkunifiedStatusNullPointer;
- }
-
- return eStatus; // LCOV_EXCL_BR_LINE 11:except branch
-}
-
-//////////////////////////////////////////
-// Function : FrameworkunifiedGetMsgLength
-//////////////////////////////////////////
-UI_32 FrameworkunifiedGetMsgLength(HANDLE hApp) {
- if (frameworkunifiedCheckValidAppHandle(hApp)) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- return McGetLength(static_cast<PVOID>(pApp->uiMsgRcvBuffer));
- }
- return 0;
-}
-
-
-//////////////////////////////////////////
-// Function : FrameworkunifiedGetMsgProtocol
-//////////////////////////////////////////
-UI_32 FrameworkunifiedGetMsgProtocol(HANDLE hApp) {
- if (frameworkunifiedCheckValidAppHandle(hApp)) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- return static_cast<UI_32>(pApp->uiProtocolCmd);
- }
- return 0;
-}
-
-
-//////////////////////////////////////////
-// Function : FrameworkunifiedGetMsgDataOfSize
-//////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedGetMsgDataOfSize(HANDLE hApp, PVOID pData, UI_32 uiSize, ESMRetrieveTypes eRetrieveMethod) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
-
- if (frameworkunifiedCheckValidAppHandle(hApp)) {
- /*
- * @todo
- * The behavior is the same as when "eSMRRetain" is set without getting an error when the ESMRetrieveTypes is not appropriate.
- */
- if (eSMRRelease == eRetrieveMethod) {
- eStatus = McGetDataOfSize(static_cast<PVOID>(pApp->uiMsgRcvBuffer), pData, uiSize);
- } else {
- eStatus = McGetDataOfSizeWithSMRetain(static_cast<PVOID>(pApp->uiMsgRcvBuffer), pData, uiSize);
- }
- } else {
- eStatus = eFrameworkunifiedStatusNullPointer;
- }
-
- return eStatus;
-}
-
-
-//////////////////////////////////////////
-// Function : FrameworkunifiedGetDataPointer
-//////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedGetDataPointer(HANDLE hApp, void **datap) {
- if (frameworkunifiedCheckValidAppHandle(hApp)) {
- if (NULL == datap) {
- return eFrameworkunifiedStatusInvldParam;
- }
-
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- void *dt;
- if ((dt = McGetDataPointer(reinterpret_cast<PVOID>(pApp->uiMsgRcvBuffer))) == NULL) {
- return eFrameworkunifiedStatusInvldBufSize;
- }
-
- *datap = dt;
- return eFrameworkunifiedStatusOK;
- }
- return eFrameworkunifiedStatusInvldHandle;
-}
-
-
-//////////////////////////////////////////
-// Function : FrameworkunifiedGetMsgSrc
-//////////////////////////////////////////
-PCSTR FrameworkunifiedGetMsgSrc(HANDLE hApp) {
- if (frameworkunifiedCheckValidAppHandle(hApp)) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- return (reinterpret_cast<PCSTR>(pApp->cMsgSrcName));
- }
- return NULL;
-}
-
-
-//////////////////////////////////////////
-// Function : FrameworkunifiedGetMsgNotification
-//////////////////////////////////////////
-PCSTR FrameworkunifiedGetMsgNotification(HANDLE hApp) {
- if (frameworkunifiedCheckValidAppHandle(hApp)) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- return (reinterpret_cast<PCSTR>(pApp->cSystemInfo));
- }
- return NULL;
-}
-
-
-//////////////////////////////////////////
-// Function : FrameworkunifiedClearMsgData
-//////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedClearMsgData(HANDLE hApp) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
- if (frameworkunifiedCheckValidAppHandle(hApp)) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- eStatus = McClearData(static_cast<PVOID>(pApp->uiMsgRcvBuffer));
- } else {
- eStatus = eFrameworkunifiedStatusNullPointer;
- }
- return eStatus;
-}
-
-
-//////////////////////////////////////////
-// Function : FrameworkunifiedGetDataUSID
-//////////////////////////////////////////
-TMemID FrameworkunifiedGetDataUSID(HANDLE hApp) {
- if (frameworkunifiedCheckValidAppHandle(hApp)) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- return McGetDataUSID(static_cast<PVOID>(pApp->uiMsgRcvBuffer));
- }
- return BAD_MEM_ID;
-}
-
-
-//////////////////////////////////////////
-// Function : FrameworkunifiedForwardMessage
-//////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedForwardMessage(HANDLE hApp, HANDLE hChildQ, UI_32 iCmd) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusInvldBuf;
-
- if (frameworkunifiedCheckValidAppHandle(hApp) && hChildQ) {
- CFrameworkunifiedFrameworkApp *pApp = reinterpret_cast< CFrameworkunifiedFrameworkApp * >(hApp);
-
- eStatus = McForward(hChildQ, &pApp->cAppName[ 0 ], iCmd, FrameworkunifiedGetDataUSID(hApp));
- } else {
- eStatus = eFrameworkunifiedStatusInvldHandle;
- }
-
- return eStatus;
-}
-
-
-//////////////////////////////////////////
-// Function : FrameworkunifiedGetSystemInfo
-//////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedGetSystemInfo(HANDLE hApp, PVOID pSystemInfo) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusInvldBuf;
-
- if (frameworkunifiedCheckValidAppHandle(hApp) && pSystemInfo != NULL) { // LCOV_EXCL_BR_LINE 11:except branch
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
-
- eStatus = McGetSysInfoData(pApp->uiMsgRcvBuffer, pSystemInfo);
-// memcpy(pSystemInfo, pApp->cSystemInfo, _countof(pApp->cSystemInfo));
-// eStatus = eFrameworkunifiedStatusOK;
- }
- return eStatus;
-}
-
-
-//////////////////////////////////////////
-// Function : frameworkunifiedGetIsTypeOfSync
-//////////////////////////////////////////
-BOOL frameworkunifiedGetIsTypeOfSync(HANDLE hApp) {
- if (frameworkunifiedCheckValidAppHandle(hApp)) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- return mcGetIsTypeOfSync(pApp->uiMsgRcvBuffer);
- }
- return FALSE;
-}
-
-
-////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedGetLastNotification
-/// Returns the last notification string that was received.
-///
-/// \param [in] hApp
-/// HANDLE - Application framework handle
-///
-/// \return pSourceName
-/// PCSTR - the last notification name that has been received.
-///
-/// \see FrameworkunifiedMcOpenSender, FrameworkunifiedMcClose, FrameworkunifiedSendMsg, FrameworkunifiedGetMsgLength, FrameworkunifiedGetMsgDataOfSize,
-/// FrameworkunifiedClearMsgData, FrameworkunifiedGetDataUSID, FrameworkunifiedForwardMessage, FrameworkunifiedGetSystemInfo
-///
-////////////////////////////////////////////////////////////////////////////////////////////
-PCSTR FrameworkunifiedGetLastNotification(HANDLE hApp) {
- if (frameworkunifiedCheckValidAppHandle(hApp)) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- return static_cast<PCSTR>(pApp->cSystemInfo);
- }
-
- return NULL;
-}
-
-
-EFrameworkunifiedStatus FrameworkunifiedSendResponse(HANDLE hApp, UI_32 iCmd, UI_32 length, PCVOID data) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusFail;
- if (frameworkunifiedCheckValidAppHandle(hApp)) {
- HANDLE hSession = FrameworkunifiedGetCurrentSessionHandle(hApp);
-
- if (hSession) {
- // send response
- if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedSendMsg(hSession, iCmd, length, data))) {
- // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __PRETTY_FUNCTION__,
- "Response send Failed Status:0x%x ", eStatus);
- // LCOV_EXCL_BR_STOP
- } else {
- FRAMEWORKUNIFIEDLOG0(ZONE_NS_INFO, __PRETTY_FUNCTION__, "Response sent ");
- }
- }
- }
- return eStatus;
-}
-
-EFrameworkunifiedStatus FrameworkunifiedSendRequest(HANDLE hApp, PCSTR pServerName, UI_32 uiSessionId, UI_32 iCmd,
- UI_32 length, PCVOID data) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusFail;
- if (frameworkunifiedCheckValidAppHandle(hApp)) {
- HANDLE hSession = FrameworkunifiedGetSessionHandle(hApp, pServerName, uiSessionId);
- if (hSession) {
- // send response
- if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedSendMsg(hSession, iCmd, length, data))) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __PRETTY_FUNCTION__,
- "Response send Failed Status:0x%x ", eStatus);
- } else {
- FRAMEWORKUNIFIEDLOG0(ZONE_NS_INFO, __PRETTY_FUNCTION__, "Response sent ");
- }
- }
- }
- return eStatus;
-}
diff --git a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_framework_npservice.cpp b/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_framework_npservice.cpp
deleted file mode 100755
index 063e357..0000000
--- a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_framework_npservice.cpp
+++ /dev/null
@@ -1,867 +0,0 @@
-/*
- * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-///////////////////////////////////////////////////////////////////////////////
-/// \ingroup tag_NSFramework
-/// \brief Framework wrapper over the NPService interface APIs
-///
-///
-///
-///////////////////////////////////////////////////////////////////////////////
-
-///////////////////////////////////////////////////////////////////////////////
-// Include Files
-///////////////////////////////////////////////////////////////////////////////
-#include <string.h>
-
-#include <native_service/frameworkunified_framework_types.h>
-#include <native_service/frameworkunified_framework_if.h>
-#include <native_service/ns_np_service_if.h>
-#include <native_service/ns_np_service_protocol.h>
-#include <other_service/strlcpy.h>
-
-#include "frameworkunified_framework_core.h"
-#include "ns_np_service_internal.h"
-
-////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedNPRegisterNotification
-////////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedNPRegisterNotification(HANDLE hApp, PCSTR pNotification, const UI_32 max_length,
- const EFrameworkunifiedNotificationType persType) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (frameworkunifiedCheckValidAppHandle(hApp) && pNotification) {
- if (strlen(pNotification) && strlen(pNotification) < MAX_STRING_SIZE_NOTIFICATION) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
-
- NotificationInfo notifInfo = {};
- strlcpy(notifInfo.notificationName, pNotification, sizeof(notifInfo.notificationName));
- notifInfo.persType = persType;
- notifInfo.maxLength = max_length;
-
- eStatus = NPRegisterNotifications(pMqInfo->hMsgQ, pApp->cAppName, 1, &notifInfo);
- } else {
- eStatus = eFrameworkunifiedStatusInvldParam;
- }
- } else {
- eStatus = eFrameworkunifiedStatusInvldParam;
- }
-
- return eStatus;
-}
-
-EFrameworkunifiedStatus FrameworkunifiedNPRegisterImmediatePersistNotification(HANDLE hApp, PCSTR pNotification, const UI_32 max_length,
- const UI_32 delay) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (frameworkunifiedCheckValidAppHandle(hApp) && NULL != pNotification) {
- if (strlen(pNotification) && strlen(pNotification) <= MAX_STRING_SIZE_NOTIFICATION) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
-
- ImmediateNotificationInfo notifInfo = {};
- strlcpy(notifInfo.notificationName, pNotification, sizeof(notifInfo.notificationName));
- notifInfo.persType = eFrameworkunifiedImmediatePersistedStateVar;
- notifInfo.maxLength = max_length;
- notifInfo.delay = delay;
-
- eStatus = NPRegisterImmediateNotifications(pMqInfo->hMsgQ, pApp->cAppName, 1, &notifInfo);
- } else {
- eStatus = eFrameworkunifiedStatusInvldParam;
- }
- } else {
- eStatus = eFrameworkunifiedStatusInvldParam;
- }
-
- return eStatus;
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedNPPersistentSync
-////////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedNPPersistentSync(HANDLE hApp) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
- if (frameworkunifiedCheckValidAppHandle(hApp)) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
-
- eStatus = NPPersistentSync(pMqInfo->cSrcName, pMqInfo->hMsgQ, pMqInfo->sessionId, pApp->cAppName);
- } else {
- eStatus = eFrameworkunifiedStatusInvldParam;
- }
- return eStatus;
-}
-////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedNPRegisterNotifications
-////////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedNPRegisterNotifications(HANDLE hApp, const FrameworkunifiedNotificationsList *pList, UI_32 uiListLength) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
- if (frameworkunifiedCheckValidAppHandle(hApp) && pList) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
-
- if (NULL != pMqInfo) {
- NotificationInfo *pNotificationList =
- reinterpret_cast<NotificationInfo *>(malloc(sizeof(NotificationInfo) * uiListLength));
-
- for (UI_32 i = 0; i < uiListLength; ++i) {
- strlcpy(pNotificationList[i].notificationName, pList[i].cNotification,
- sizeof(pNotificationList[i].notificationName));
- pNotificationList[i].maxLength = pList[i].uiLengthData;
- pNotificationList[i].persType = pList[i].persType;
- }
- eStatus = NPRegisterNotifications(pMqInfo->hMsgQ, pApp->cAppName, uiListLength, pNotificationList);
-
- free(pNotificationList);
- pNotificationList = NULL; // mb20110110 Fixed per comment 295
- } else {
- eStatus = eFrameworkunifiedStatusNullPointer;
- }
- } else {
- eStatus = eFrameworkunifiedStatusInvldParam;
- }
-
- return eStatus;
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedNPUnRegisterNotification
-////////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedNPUnRegisterNotification(HANDLE hApp, PCSTR pNotification) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (frameworkunifiedCheckValidAppHandle(hApp) && pNotification && strlen(pNotification)) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
-
- NotificationInfo notifInfo = {};
- strlcpy(notifInfo.notificationName, pNotification, sizeof(notifInfo.notificationName));
-
- eStatus = NPUnRegisterNotifications(pMqInfo->hMsgQ, pApp->cAppName, 1, &notifInfo);
- } else {
- eStatus = eFrameworkunifiedStatusInvldParam;
- }
-
- return eStatus;
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedNPUnRegisterNotifications
-////////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedNPUnRegisterNotifications(HANDLE hApp, const FrameworkunifiedNotificationsList *pList, UI_32 uiListLength) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
- if (frameworkunifiedCheckValidAppHandle(hApp) && pList) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
- if (NULL != pMqInfo) {
- NotificationInfo *pNotificationList =
- reinterpret_cast<NotificationInfo *>(malloc(sizeof(NotificationInfo) * uiListLength));
-
- for (UI_32 i = 0; i < uiListLength; ++i) {
- strlcpy(pNotificationList[i].notificationName, pList[i].cNotification,
- sizeof(pNotificationList[i].notificationName));
- pNotificationList[i].maxLength = pList[i].uiLengthData;
- pNotificationList[i].persType = pList[i].persType;
- }
- eStatus = NPUnRegisterNotifications(pMqInfo->hMsgQ, pApp->cAppName, uiListLength, pNotificationList);
-
- free(pNotificationList);
- } else {
- eStatus = eFrameworkunifiedStatusNullPointer;
- }
- } else {
- eStatus = eFrameworkunifiedStatusInvldParam;
- }
-
- return eStatus;
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedNPPublishNotification
-////////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedNPPublishNotification(HANDLE hApp, PCSTR pNotification,
- PCVOID pData, UI_32 iLength) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (frameworkunifiedCheckValidAppHandle(hApp) && NULL != pNotification) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
-
- if ((NULL != pMqInfo->hMsgQ) && (0 != std::strlen(pApp->cAppName))) {
- eStatus = NPPublishNotification(pMqInfo->hMsgQ, pApp->cAppName, pNotification, pData, iLength);
- } else {
- eStatus = eFrameworkunifiedStatusInvldHandle;
- }
- } else {
- eStatus = eFrameworkunifiedStatusInvldParam;
- }
-
- return eStatus;
-}
-
-
-////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedNPSubscribeToNotification
-////////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedNPSubscribeToNotification(HANDLE hApp, PCSTR pNotification) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (frameworkunifiedCheckValidAppHandle(hApp) && pNotification) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
-
- eStatus = NPSubscribeToNotification(pMqInfo->hMsgQ, pApp->cAppName, pNotification);
- } else {
- eStatus = eFrameworkunifiedStatusInvldParam;
- }
-
- return eStatus;
-}
-
-
-EFrameworkunifiedStatus FrameworkunifiedNPSubscribeToNotifications(HANDLE hApp, const FrameworkunifiedNotificationCallbackHandler *pList,
- UI_32 uiListLength) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (frameworkunifiedCheckValidAppHandle(hApp) && pList) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
-
- SubscribeInfo *pSubscribeList =
- reinterpret_cast<SubscribeInfo *>(malloc(sizeof(SubscribeInfo) * uiListLength));
-
- for (UI_32 i = 0; i < uiListLength; ++i) {
- strlcpy(pSubscribeList[i].notificationName, pList[i].cNotification,
- sizeof(pSubscribeList[i].notificationName));
- }
- eStatus = NPSubscribeToNotifications(pMqInfo->hMsgQ, pApp->cAppName, uiListLength, pSubscribeList);
-
- free(pSubscribeList);
- pSubscribeList = NULL; // mb20110110 Fixed per comment 307
- } else {
- eStatus = eFrameworkunifiedStatusInvldParam;
- }
-
- return eStatus;
-}
-
-
-////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedNPUnSubscribeNotifications
-////////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedNPUnsubscribeFromNotifications(HANDLE hApp, const FrameworkunifiedNotificationCallbackHandler *pList,
- UI_32 uiListLength) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (frameworkunifiedCheckValidAppHandle(hApp) && pList) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
-
- SubscribeInfo *pSubscribeList =
- reinterpret_cast<SubscribeInfo *>(malloc(sizeof(SubscribeInfo) * uiListLength));
-
- for (UI_32 i = 0; i < uiListLength; ++i) {
- strlcpy(pSubscribeList[i].notificationName, pList[i].cNotification, MAX_STRING_SIZE_NOTIFICATION);
- }
- eStatus = NPUnsubscribeFromNotifications(pMqInfo->hMsgQ, pApp->cAppName, uiListLength, pSubscribeList);
-
- free(pSubscribeList);
- pSubscribeList = NULL; // mb20110110 Fixed per comment 307
- } else {
- eStatus = eFrameworkunifiedStatusInvldParam;
- }
-
- return eStatus;
-}
-
-
-////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedNPUnsubscribeFromNotification
-////////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedNPUnsubscribeFromNotification(HANDLE hApp, PCSTR pNotification) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (frameworkunifiedCheckValidAppHandle(hApp) && pNotification) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
-
- eStatus = NPUnsubscribeFromNotification(pMqInfo->hMsgQ, pApp->cAppName, pNotification);
- } else {
- eStatus = eFrameworkunifiedStatusInvldParam;
- }
-
- return eStatus;
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedNPReadPersistedData
-////////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedNPReadPersistedData(HANDLE hApp, PCSTR pNotification) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (frameworkunifiedCheckValidAppHandle(hApp) && pNotification) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
-
- eStatus = NPReadPersistedData(pMqInfo->hMsgQ, pApp->cAppName, pNotification);
- } else {
- eStatus = eFrameworkunifiedStatusInvldParam;
- }
-
- return eStatus;
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedNPSavePersistentData
-////////////////////////////////////////////////////////////////////////////////////////////
-// LCOV_EXCL_START 8: dead code
-EFrameworkunifiedStatus FrameworkunifiedNPSavePersistentData(HANDLE hApp) {
- AGL_ASSERT_NOT_TESTED();
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (frameworkunifiedCheckValidAppHandle(hApp)) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
-
- eStatus = NPSavePersistentData(pMqInfo->hMsgQ, pApp->cAppName);
- } else {
- eStatus = eFrameworkunifiedStatusInvldParam;
- }
-
- return eStatus;
-}
-// LCOV_EXCL_STOP
-
-
-////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedNPRegisterPersistentFile
-////////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedNPRegisterPersistentFile(HANDLE hApp, PCSTR pTag, BOOL bIsUserFile) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
- if (frameworkunifiedCheckValidAppHandle(hApp) && pTag) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
- if (NULL != pMqInfo) {
- eStatus = NPRegisterPersistentFile(pMqInfo->hMsgQ, pApp->cAppName, pTag, bIsUserFile);
- } else {
- eStatus = eFrameworkunifiedStatusNullPointer;
- }
- } else {
- eStatus = eFrameworkunifiedStatusInvldParam;
- }
-
- return eStatus;
-}
-
-
-////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedNPLoadPersistentFile
-////////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedNPLoadPersistentFile(HANDLE hApp, PCSTR pDstFilePath, PCSTR pTag, HANDLE hUser) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (frameworkunifiedCheckValidAppHandle(hApp) && pDstFilePath && pTag) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
-
- if (NULL != pMqInfo) {
- eStatus = NPLoadPersistentFile(pMqInfo->hMsgQ, pApp->cAppName, pDstFilePath, pTag, hUser);
- } else {
- eStatus = eFrameworkunifiedStatusNullPointer;
- }
- } else {
- eStatus = eFrameworkunifiedStatusInvldParam;
- }
-
- return eStatus;
-}
-
-
-////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedNPReleasePersistentFile
-////////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedNPReleasePersistentFile(HANDLE hApp, BOOL bIsPersist, PCSTR pTag,
- PCSTR pFullFilePath, HANDLE hUser) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
- if (frameworkunifiedCheckValidAppHandle(hApp) && pTag && pFullFilePath) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
-
- if (NULL != pMqInfo) {
- EFrameworkunifiedReleaseType eReleaseType = (bIsPersist == FALSE) ? eFrameworkunifiedNotOnRelease : eFrameworkunifiedPersistOnShutdown;
- eStatus = NPReleasePersistentFile(pMqInfo->hMsgQ, pApp->cAppName, eReleaseType, pTag,
- pFullFilePath, hUser);
- } else {
- eStatus = eFrameworkunifiedStatusNullPointer;
- }
- } else {
- eStatus = eFrameworkunifiedStatusInvldParam;
- }
-
- return eStatus;
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedNPReleasePersistentFile
-////////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedNPReleasePersistentFile(HANDLE hApp, EFrameworkunifiedReleaseType eReleaseType, PCSTR pTag,
- PCSTR pFullFilePath, HANDLE hUser) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
- if (frameworkunifiedCheckValidAppHandle(hApp) && pTag && pFullFilePath) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
-
- if (NULL != pMqInfo) {
- eStatus = NPReleasePersistentFile(pMqInfo->hMsgQ, pApp->cAppName, eReleaseType, pTag,
- pFullFilePath, hUser);
- } else {
- eStatus = eFrameworkunifiedStatusNullPointer;
- }
- } else {
- eStatus = eFrameworkunifiedStatusInvldParam;
- }
-
- return eStatus;
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedNPRegisterPersistentFolder
-////////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedNPRegisterPersistentFolder(HANDLE hApp, PCSTR pTag, BOOL bIsUserFolder) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
- if (frameworkunifiedCheckValidAppHandle(hApp) && pTag) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
-
- if (NULL != pMqInfo) {
- eStatus = NPRegisterPersistentFolder(pMqInfo->hMsgQ, pApp->cAppName, pTag, bIsUserFolder);
- } else {
- eStatus = eFrameworkunifiedStatusNullPointer;
- }
- } else {
- eStatus = eFrameworkunifiedStatusInvldParam;
- }
-
- return eStatus;
-}
-
-
-////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedNPLoadPersistentFolder
-////////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedNPLoadPersistentFolder(HANDLE hApp, PCSTR pDstFolderPath, PCSTR pTag, HANDLE hUser) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
- if (frameworkunifiedCheckValidAppHandle(hApp) && pTag && pDstFolderPath) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
- if (NULL != pMqInfo) {
- eStatus = NPLoadPersistentFolder(pMqInfo->hMsgQ, pApp->cAppName, pDstFolderPath, pTag, hUser);
- } else {
- eStatus = eFrameworkunifiedStatusNullPointer;
- }
- } else {
- eStatus = eFrameworkunifiedStatusInvldParam;
- }
-
- return eStatus;
-}
-
-
-////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedNPReleasePersistentFolder
-////////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedNPReleasePersistentFolder(HANDLE hApp, BOOL bIsPersist, PCSTR pTag, PCSTR pFullFolderPath,
- HANDLE hUser) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
- if (frameworkunifiedCheckValidAppHandle(hApp) && pTag && pFullFolderPath) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
- if (NULL != pMqInfo) {
- EFrameworkunifiedReleaseType eReleaseType = (bIsPersist == FALSE) ? eFrameworkunifiedNotOnRelease : eFrameworkunifiedPersistOnShutdown;
- eStatus = NPReleasePersistentFolder(pMqInfo->hMsgQ, pApp->cAppName, eReleaseType, pTag,
- pFullFolderPath, hUser);
- } else {
- eStatus = eFrameworkunifiedStatusNullPointer;
- }
- } else {
- eStatus = eFrameworkunifiedStatusInvldParam;
- }
-
- return eStatus;
-}
-////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedNPReleasePersistentFolder
-////////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedNPReleasePersistentFolder(HANDLE hApp, EFrameworkunifiedReleaseType eReleaseType, PCSTR pTag,
- PCSTR pFullFolderPath,
- HANDLE hUser) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
- if (frameworkunifiedCheckValidAppHandle(hApp) && pTag && pFullFolderPath) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
- if (NULL != pMqInfo) {
- eStatus = NPReleasePersistentFolder(pMqInfo->hMsgQ, pApp->cAppName, eReleaseType, pTag,
- pFullFolderPath, hUser);
- } else {
- eStatus = eFrameworkunifiedStatusNullPointer;
- }
- } else {
- eStatus = eFrameworkunifiedStatusInvldParam;
- }
-
- return eStatus;
-}
-
-// 20110429_brp
-// defined for backward compatibility; will be removed once the persistence feature is finalized
-EFrameworkunifiedStatus FrameworkunifiedRegisterPersistentStorage(HANDLE hApp, PCSTR pFullFilePath) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (frameworkunifiedCheckValidAppHandle(hApp) && pFullFilePath) {
- eStatus = FrameworkunifiedNPRegisterPersistentFile(hApp, pFullFilePath);
- } else {
- eStatus = eFrameworkunifiedStatusInvldParam;
- }
-
- return eStatus;
-}
-EFrameworkunifiedStatus FrameworkunifiedReleaseFileToPersistentStorage(HANDLE hApp, PCSTR pFullFilePath, BOOL persist) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (frameworkunifiedCheckValidAppHandle(hApp) && pFullFilePath) {
- eStatus = FrameworkunifiedNPReleasePersistentFile(hApp, persist, pFullFilePath, pFullFilePath);
- } else {
- eStatus = eFrameworkunifiedStatusInvldParam;
- }
-
- return eStatus;
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedNPHSMRegisterNotificationsEvents
-/// API to send message to Notification Service to register a notification
-////////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedNPHSMRegisterNotificationsEvents(HANDLE hApp, const FrameworkunifiedNotificationsList *pList,
- UI_32 uiListLength) {
- return FrameworkunifiedNPRegisterNotifications(hApp, pList, uiListLength);
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedNPHSMRegisterNotificatsionEvent
-/// API to send message to Notification Service to register a notification
-////////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedNPHSMRegisterNotificatsionEvent(HANDLE hApp, PCSTR pNotification, const UI_32 max_length,
- const EFrameworkunifiedNotificationType persType) {
- return FrameworkunifiedNPRegisterNotification(hApp, pNotification, max_length, persType);
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedNPHSMUnRegisterNotificationEvent
-/// API to send message to Notification Service to remove a notification
-////////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedNPHSMUnRegisterNotificationEvent(HANDLE hApp, PCSTR pNotification) {
- return FrameworkunifiedNPUnRegisterNotification(hApp, pNotification);
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedNPHSMSubscribeToNotificationsEvents
-/// API to send message to Notification Service to add multiple subscriptions list for
-/// that notification
-////////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedNPHSMSubscribeToNotificationsEvents(HANDLE hApp, const FrameworkunifiedNotificationEvent *pList,
- UI_32 uiListLength) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (frameworkunifiedCheckValidAppHandle(hApp) && pList) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
-
- SubscribeInfo *pSubscribeList =
- reinterpret_cast<SubscribeInfo *>(malloc(sizeof(SubscribeInfo) * uiListLength));
-
- for (UI_32 i = 0; i < uiListLength; ++i) {
- strlcpy(pSubscribeList[i].notificationName, pList[i].cNotification,
- sizeof(pSubscribeList[i].notificationName));
- }
- eStatus = NPSubscribeToNotifications(pMqInfo->hMsgQ, pApp->cAppName, uiListLength, pSubscribeList);
-
- free(pSubscribeList);
- pSubscribeList = NULL; // mb20110110 Fixed per comment 307
- } else {
- eStatus = eFrameworkunifiedStatusInvldParam;
- }
-
- return eStatus;
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedNPHSMSubscribeToNotificationEvent
-/// API to send message to Notification Service to add to subscription list for
-/// that notification
-////////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedNPHSMSubscribeToNotificationEvent(HANDLE hApp, PCSTR pNotification) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (frameworkunifiedCheckValidAppHandle(hApp) && pNotification) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
-
- eStatus = NPSubscribeToNotification(pMqInfo->hMsgQ, pApp->cAppName, pNotification);
- } else {
- eStatus = eFrameworkunifiedStatusInvldParam;
- }
-
- return eStatus;
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedNPHSMUnsubscribeFromNotificationEvent
-/// API to send message to Notification Service to remove from subscription list for
-/// that notification
-////////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedNPHSMUnsubscribeFromNotificationEvent(HANDLE hApp, PCSTR pNotification) {
- return FrameworkunifiedNPUnsubscribeFromNotification(hApp, pNotification);
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedNPHSMUnsubscribeFromNotificationEvents
-/// API to send message to Notification Service to remove from subscription list for
-/// that notification
-////////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedNPHSMUnsubscribeFromNotificationEvents(HANDLE hApp, const FrameworkunifiedNotificationEvent *pList,
- UI_32 uiListLength) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (frameworkunifiedCheckValidAppHandle(hApp) && pList) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
-
- SubscribeInfo *pSubscribeList =
- reinterpret_cast<SubscribeInfo *>(malloc(sizeof(SubscribeInfo) * uiListLength));
-
- for (UI_32 i = 0; i < uiListLength; ++i) {
- strlcpy(pSubscribeList[i].notificationName, pList[i].cNotification,
- sizeof(pSubscribeList[i].notificationName));
- }
- eStatus = NPUnsubscribeFromNotifications(pMqInfo->hMsgQ, pApp->cAppName, uiListLength, pSubscribeList);
-
- free(pSubscribeList);
- pSubscribeList = NULL; // mb20110110 Fixed per comment 307
- } else {
- eStatus = eFrameworkunifiedStatusInvldParam;
- }
-
- return eStatus;
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedNPSetPersonality
-////////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedNPSetPersonality(HANDLE hApp, PCSTR pUserName) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (frameworkunifiedCheckValidAppHandle(hApp) && pUserName) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
-
- eStatus = NPSetPersonality(pMqInfo->hMsgQ, pApp->cAppName, pUserName);
- } else {
- eStatus = eFrameworkunifiedStatusInvldParam;
- }
-
- return eStatus;
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedNPChangePersonality
-////////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedNPChangePersonality(HANDLE hApp, PCSTR pUserName) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (frameworkunifiedCheckValidAppHandle(hApp) && pUserName) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
-
- eStatus = NPChangePersonality(pMqInfo->hMsgQ, pApp->cAppName, pUserName);
- } else {
- eStatus = eFrameworkunifiedStatusInvldParam;
- }
-
- return eStatus;
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedSendStopToNSNPP
-////////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedSendStopToNSNPP(HANDLE hApp, EFrameworkunifiedShutdownType eShutdownType, UI_32 uiStopMsgData) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (frameworkunifiedCheckValidAppHandle(hApp)) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
-
- eStatus = SendStopToNSNPP(pMqInfo->hMsgQ, pApp->cAppName, eShutdownType, uiStopMsgData);
- } else {
- eStatus = eFrameworkunifiedStatusInvldParam;
- }
-
- return eStatus;
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedNPGetReadyStatusOfNPP
-////////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedNPGetReadyStatusOfNPP(HANDLE hApp) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (frameworkunifiedCheckValidAppHandle(hApp)) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
-
- eStatus = NPGetReadyStatusOfNPP(pMqInfo->hMsgQ, pApp->cAppName);
- } else {
- eStatus = eFrameworkunifiedStatusInvldParam;
- }
-
- return eStatus;
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedNPClearPersistedData
-////////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedNPClearPersistedData(HANDLE hApp, EFrameworkunifiedClearPersistence eFrameworkunifiedClearPersistenceScope) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- if (frameworkunifiedCheckValidAppHandle(hApp)) {
- MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
- if (NULL != pMqInfo) {
- eStatus = NPClearPersistedData(pMqInfo->hMsgQ, pApp->cAppName, eFrameworkunifiedClearPersistenceScope);
- } else {
- eStatus = eFrameworkunifiedStatusNullPointer;
- }
- } else {
- eStatus = eFrameworkunifiedStatusNullPointer;
- }
-
- return eStatus;
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedNPSetPersistNotfnDefaultValue
-////////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedNPSetPersistNotfnDefaultValue(HANDLE hApp, PCSTR pNotification, PVOID pData,
- const UI_32 uiLength) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if ((frameworkunifiedCheckValidAppHandle(hApp)) && (NULL != pNotification)) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
-
- MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
-
- if (NULL != pMqInfo) {
- eStatus = NPSetPersistNotfnDefaultValue(pMqInfo->hMsgQ,
- pApp->cAppName,
- pNotification,
- pData,
- uiLength);
- } else {
- eStatus = eFrameworkunifiedStatusNullPointer;
- }
- } else {
- eStatus = eFrameworkunifiedStatusInvldParam;
- }
-
- return eStatus;
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedNPSetPersistentNotfnType
-////////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedNPSetPersistentNotfnType(HANDLE hApp, PCSTR pNotification, EFrameworkunifiedPersistCategory ePersistCategory) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if ((frameworkunifiedCheckValidAppHandle(hApp)) && (NULL != pNotification)) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
-
- MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
- if (NULL != pMqInfo) {
- eStatus = NPSetPersistentNotfnType(pMqInfo->hMsgQ,
- pApp->cAppName,
- pNotification,
- ePersistCategory);
- } else {
- eStatus = eFrameworkunifiedStatusNullPointer;
- }
- } else {
- eStatus = eFrameworkunifiedStatusInvldParam;
- }
-
- return eStatus;
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedNPSetFilePersistentType
-////////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedNPSetFilePersistentType(HANDLE hApp, PCSTR pTag, EFrameworkunifiedPersistCategory ePersistCategory) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if ((frameworkunifiedCheckValidAppHandle(hApp)) && (NULL != pTag)) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
-
- MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
-
- if (NULL != pMqInfo) {
- eStatus = NPSetFilePersistentType(pMqInfo->hMsgQ,
- pApp->cAppName,
- pTag,
- ePersistCategory);
- } else {
- eStatus = eFrameworkunifiedStatusNullPointer;
- }
- } else {
- eStatus = eFrameworkunifiedStatusInvldParam;
- }
-
- return eStatus;
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedNPSetFolderPersistentType
-////////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedNPSetFolderPersistentType(HANDLE hApp, PCSTR pTag, EFrameworkunifiedPersistCategory ePersistCategory) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if ((frameworkunifiedCheckValidAppHandle(hApp)) && (NULL != pTag)) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
-
- MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
-
- if (NULL != pMqInfo) {
- eStatus = NPSetFolderPersistentType(pMqInfo->hMsgQ,
- pApp->cAppName,
- pTag,
- ePersistCategory);
- } else {
- eStatus = eFrameworkunifiedStatusNullPointer;
- }
- } else {
- eStatus = eFrameworkunifiedStatusInvldParam;
- }
-
- return eStatus;
-}
-
diff --git a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_framework_session.cpp b/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_framework_session.cpp
deleted file mode 100755
index 7c9935b..0000000
--- a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_framework_session.cpp
+++ /dev/null
@@ -1,1357 +0,0 @@
-/*
- * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-///////////////////////////////////////////////////////////////////////////////
-/// \ingroup tag_NSFramework
-/// \brief Framework service protocol session APIs implementation
-///
-///
-///
-///////////////////////////////////////////////////////////////////////////////
-#include <string.h>
-
-#include <native_service/frameworkunified_framework_if.h>
-#include <native_service/frameworkunified_framework_types.h>
-#include <native_service/frameworkunified_service_protocol.h>
-#include <native_service/ns_logger_if.h>
-#include <other_service/strlcpy.h>
-#include <utility>
-#include "frameworkunified_framework_core.h"
-#include "frameworkunified_framework_internal.h"
-
-//////////////////////////////////////////////////////
-/// FrameworkunifiedOpenService
-//////////////////////////////////////////////////////
-HANDLE FrameworkunifiedOpenService(HANDLE hApp, PCSTR pServiceName) {
- HANDLE hService = NULL;
-
- if (frameworkunifiedCheckValidAppHandle(hApp) && NULL != pServiceName) {
- if (NULL == (hService = FrameworkunifiedMcOpenSender(hApp, pServiceName))) {
- // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error::hApp:0x%p, %s failed to FrameworkunifiedMcOpenSender", hApp, pServiceName);
- // LCOV_EXCL_BR_STOP
- } else {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- frameworkunifiedAddConnectMonitor(hApp, pServiceName, pApp->cAppName);
- }
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__,
- "Invalid param. hApp:0x%p, name:0x%p",
- hApp, pServiceName);
- }
-
- return static_cast<HANDLE>(hService);
-}
-
-//////////////////////////////////////////////////////
-/// FrameworkunifiedCloseService
-//////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedCloseService(HANDLE hApp, HANDLE hService) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (frameworkunifiedCheckValidAppHandle(hApp) && frameworkunifiedCheckValidMsgQ(hService)) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- MsgQInfo *pMsgQ = static_cast<MsgQInfo *>(hService);
-
- if (eFrameworkunifiedStatusOK != frameworkunifiedDelConnectMonitor(hApp, pMsgQ->cMsgQName, pApp->cAppName)) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error : frameworkunifiedDelConnectMonitor(%s, %s) fail",
- pMsgQ->cMsgQName != 0 ? pMsgQ->cMsgQName : NULL, pApp->cAppName != 0 ? pApp->cAppName : NULL);
- }
-
- if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedMcClose(hService))) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error : %s Failed to FrameworkunifiedMcClose",
- pApp->cAppName != 0 ? pApp->cAppName : NULL);
- }
- } else {
- eStatus = eFrameworkunifiedStatusInvldHandle;
- }
-
- return eStatus;
-}
-
-HANDLE FrameworkunifiedGenerateSessionHandle(HANDLE hApp, PCSTR pServiceName) {
- HANDLE l_pSession = NULL;
- if ((frameworkunifiedCheckValidAppHandle(hApp)) && (NULL != pServiceName)) {
- l_pSession = FrameworkunifiedMcOpenSender(hApp, pServiceName);
-
- if (NULL != l_pSession) {
- MsgQInfo *pMsgQ = reinterpret_cast<MsgQInfo *>(l_pSession);
- pMsgQ->sessionId = FrameworkunifiedGenerateNewSessionId();
- }
- }
-
- return l_pSession;
-}
-
-//////////////////////////////////////////////////////
-/// FrameworkunifiedOpenSessionWithData
-//////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedOpenSessionWithData(HANDLE hService, PVOID pData, UI_32 length) {
- return FrameworkunifiedSendMsg(hService, PROTOCOL_OPEN_SESSION_REQ, length, pData);
-}
-
-
-//////////////////////////////////////////////////////
-/// FrameworkunifiedOpenSession
-//////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedOpenSession(HANDLE hService) {
- UI_32 l_uiDummy = 0;
- return FrameworkunifiedSendMsg(hService, PROTOCOL_OPEN_SESSION_REQ, 0, &l_uiDummy);
-}
-
-//////////////////////////////////////////////////////
-/// FrameworkunifiedOpenSessionWithDataSync
-//////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedOpenSessionWithDataSync(HANDLE hService, PVOID pData, UI_32 length, OpenSessionAck *ack) {
- UI_32 rcvLen;
- return FrameworkunifiedInvokeSync(hService, PROTOCOL_OPEN_SESSION_REQ_SYNC, length, pData, sizeof(OpenSessionAck), ack, &rcvLen);
-}
-
-
-//////////////////////////////////////////////////////
-/// FrameworkunifiedOpenSessionSync
-//////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedOpenSessionSync(HANDLE hService, OpenSessionAck *ack) {
- UI_32 l_uiDummy = 0;
- UI_32 rcvLen;
- return FrameworkunifiedInvokeSync(hService, PROTOCOL_OPEN_SESSION_REQ_SYNC, 0, &l_uiDummy, sizeof(OpenSessionAck), ack, &rcvLen);
-}
-
-//////////////////////////////////////////////////////
-/// FrameworkunifiedGetSessionHandle
-//////////////////////////////////////////////////////
-HANDLE FrameworkunifiedGetOpenSessionHandle(HANDLE hApp) {
- HANDLE hSession = NULL;
-
- if (frameworkunifiedCheckValidAppHandle(hApp)) {
- OpenSessionAck tAck;
-
- if (sizeof(OpenSessionAck) == FrameworkunifiedGetMsgLength(hApp)) {
- if (eFrameworkunifiedStatusOK != FrameworkunifiedGetMsgDataOfSize(hApp, &tAck, sizeof(tAck))) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error : FrameworkunifiedGetMsgDataOfSize");
- } else {
- if (eFrameworkunifiedStatusOK == tAck.eStatus) {
- hSession = FrameworkunifiedMcOpenSender(hApp, tAck.cSessionName);
- if (NULL != hSession) {
- (reinterpret_cast<MsgQInfo *>(hSession))->sessionId = tAck.sessionId;
- }
- }
- }
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error : FrameworkunifiedGetOpenSessionHandle");
- }
- }
-
- return hSession;
-}
-
-//////////////////////////////////////////////////////
-/// FrameworkunifiedGetOpenSessionSyncHandle
-//////////////////////////////////////////////////////
-HANDLE FrameworkunifiedGetOpenSessionSyncHandle(HANDLE hApp, OpenSessionAck *tAck) {
- HANDLE hSession = NULL;
-
- if (frameworkunifiedCheckValidAppHandle(hApp) && (NULL != tAck)) {
- if (eFrameworkunifiedStatusOK == tAck->eStatus) {
- hSession = FrameworkunifiedMcOpenSender(hApp, tAck->cSessionName);
- if (NULL != hSession) {
- (reinterpret_cast<MsgQInfo *>(hSession))->sessionId = tAck->sessionId;
- }
- }
- }
-
- return hSession;
-}
-
-//////////////////////////////////////////////////////
-/// frameworkunifiedCloseSessionInner
-//////////////////////////////////////////////////////
-static EFrameworkunifiedStatus frameworkunifiedCloseSessionInner(HANDLE hService, HANDLE hSession, CloseSessionAck *ack) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusInvldHandle;
- CloseSessionReq tClose = {};
-
- if (frameworkunifiedCheckValidMsgQ(hService) && frameworkunifiedCheckValidMsgQ(hSession)) {
- tClose.sessionId = (reinterpret_cast<MsgQInfo *>(hSession))->sessionId;
- strlcpy(tClose.cSessionName, (reinterpret_cast<MsgQInfo *>(hSession))->cMsgQName, sizeof(tClose.cSessionName));
-
- FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "Info : sessionid %d", tClose.sessionId);
-
- if (NULL != ack) {
- UI_32 rcvLen;
- eStatus = FrameworkunifiedInvokeSync(hService, PROTOCOL_CLOSE_SESSION_REQ_SYNC, sizeof(tClose), (PVOID)&tClose,
- sizeof(CloseSessionAck), ack, &rcvLen);
- if (rcvLen != sizeof(CloseSessionAck)) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error : Invalid receive length %d", rcvLen);
- }
- } else {
- eStatus = FrameworkunifiedSendMsg(hService, PROTOCOL_CLOSE_SESSION_REQ, sizeof(tClose), (PVOID)&tClose);
- }
- if (eFrameworkunifiedStatusOK == eStatus) {
- eStatus = FrameworkunifiedMcClose(hSession);
- hSession = NULL;
- }
- }
- return eStatus;
-}
-
-//////////////////////////////////////////////////////
-/// FrameworkunifiedCloseSession
-//////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedCloseSession(HANDLE hService, HANDLE hSession) {
- return frameworkunifiedCloseSessionInner(hService, hSession, NULL);
-}
-
-//////////////////////////////////////////////////////
-/// FrameworkunifiedCloseSessionSync
-//////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedCloseSessionSync(HANDLE hService, HANDLE hSession, CloseSessionAck *ack) {
- if (NULL == ack) {
- return eFrameworkunifiedStatusInvldParam;
- }
- return frameworkunifiedCloseSessionInner(hService, hSession, ack);
-}
-
-//////////////////////////////////////////////////////
-/// FrameworkunifiedGetSessionId -> On Client side
-//////////////////////////////////////////////////////
-UI_32 FrameworkunifiedGetSessionId(HANDLE hSession) {
- if (frameworkunifiedCheckValidMsgQ(hSession)) {
- return ((reinterpret_cast<MsgQInfo *>(hSession))->sessionId);
- } else {
- return MAX_SESSION_ID_VAL;
- }
-}
-
-//////////////////////////////////////////////////////
-/// FrameworkunifiedGetSessionId -> On Client side
-//////////////////////////////////////////////////////
-UI_32 FrameworkunifiedGetMsgSessionId(HANDLE hApp) {
- if (frameworkunifiedCheckValidAppHandle(hApp)) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- return pApp->uiSessionId;
- }
- return MAX_SESSION_ID_VAL;
-}
-
-
-//////////////////////////////////////////////////////
-/// GenerateNewSessionId -> On Server side
-//////////////////////////////////////////////////////
-UI_32 FrameworkunifiedGenerateNewSessionId() {
- static UI_16 lastSessionId = 0;
- lastSessionId++;
- UI_32 sessionId = (lastSessionId % MAX_SESSION_ID_VAL);
- return sessionId;
-}
-
-
-
-//////////////////////////////////////////////////////
-/// FrameworkunifiedRegisterEvents
-//////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedRegisterEvents(HANDLE hSession, PVOID puiEventsArray, UI_32 uiListSize) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (hSession) {
- eStatus = FrameworkunifiedSendMsg(hSession, PROTOCOL_REGISTER_EVENTS,
- static_cast<UI_32>(uiListSize * sizeof(uiListSize)), puiEventsArray);
- } else {
- eStatus = eFrameworkunifiedStatusInvldHandle;
- }
-
- return eStatus;
-}
-
-//////////////////////////////////////////////////////
-/// FrameworkunifiedRegisterEvent
-//////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedRegisterEvent(HANDLE hSession, UI_32 uiEvent) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (hSession) {
- eStatus = FrameworkunifiedSendMsg(hSession, PROTOCOL_REGISTER_EVENTS, sizeof(uiEvent), (PVOID)&uiEvent);
- } else {
- eStatus = eFrameworkunifiedStatusInvldHandle;
- }
-
- return eStatus;
-}
-
-//////////////////////////////////////////////////////
-/// FrameworkunifiedUnRegisterEvents
-//////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedUnRegisterEvents(HANDLE hSession, PVOID puiEventsArray, UI_32 uiListSize) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (hSession) {
- eStatus = FrameworkunifiedSendMsg(hSession, PROTOCOL_UNREGISTER_EVENTS,
- static_cast<UI_32>(uiListSize * sizeof(uiListSize)), puiEventsArray);
- } else {
- eStatus = eFrameworkunifiedStatusInvldHandle;
- }
-
- return eStatus;
-}
-
-//////////////////////////////////////////////////////
-/// FrameworkunifiedUnRegisterEvent
-//////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedUnRegisterEvent(HANDLE hSession, UI_32 uiEvent) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (hSession) {
- eStatus = FrameworkunifiedSendMsg(hSession, PROTOCOL_UNREGISTER_EVENTS, sizeof(uiEvent), (PVOID)&uiEvent);
- } else {
- eStatus = eFrameworkunifiedStatusInvldHandle;
- }
-
- return eStatus;
-}
-
-//////////////////////////////////////////////////////
-/// FrameworkunifiedDefineStateEvents
-//////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedDefineStateEvents(HANDLE hApp, PVOID puiEvents, UI_32 uiListSize) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (frameworkunifiedCheckValidAppHandle(hApp) && puiEvents) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
-
- EventData *l_pEventData = NULL;
-
- UI_32 l_uiEventId;
- PUI_32 l_pEventList = (PUI_32)puiEvents;
-
- for (UI_32 uiCount = 0; uiCount < uiListSize; uiCount++) {
- l_uiEventId = l_pEventList[uiCount];
-
- // checks if event exists in state event list
- if (pApp->publicstateeventtable.end() == pApp->publicstateeventtable.find(l_uiEventId)) {
- // insert the event in state event list, data is passed as NULL as there is no data published
- pApp->publicstateeventtable.insert(std::make_pair(l_uiEventId, l_pEventData));
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "Event %d already registered as state event ", l_uiEventId);
- }
- }
- } else {
- eStatus = eFrameworkunifiedStatusInvldHandle;
- }
-
- return eStatus;
-}
-
-//////////////////////////////////////////////////////
-/// FrameworkunifiedBroadcastEvent
-//////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedBroadcastEvent(HANDLE hApp, UI_32 uiEventId, PCVOID pData, UI_32 uiLength) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (frameworkunifiedCheckValidAppHandle(hApp)) {
- eStatus = FrameworkunifiedPublishEvent(hApp, uiEventId, NULL, pData, uiLength);
- } else {
- eStatus = eFrameworkunifiedStatusNullPointer;
- }
-
- return eStatus;
-}
-
-//////////////////////////////////////////////////////
-/// FrameworkunifiedPublishEvent
-//////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedPublishEvent(HANDLE hApp, UI_32 uiEventId, PCSTR pClientName, PCVOID pData, UI_32 uiLength) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
- EFrameworkunifiedStatus eRetStatus = eFrameworkunifiedStatusOK;
-
- if (frameworkunifiedCheckValidAppHandle(hApp)) {
- EventTable::iterator e_iterator;
- ServiceSessionIdListTable::iterator ssidl_iterator;
-
- PCSTR l_cServiceName = "";
-
- // set the data, if event is a state events
- UpdatePublicStateEventData(hApp, uiEventId, pData, uiLength);
-
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
-
- // check if event is registered by client/s
- e_iterator = pApp->eventtable.find(uiEventId);
-
- if (pApp->eventtable.end() != e_iterator) {
- // for loop for event table
- for (ssidl_iterator = e_iterator->second.begin();
- ssidl_iterator != e_iterator->second.end();
- ssidl_iterator++) {
- l_cServiceName = ssidl_iterator->first.c_str();
-
- if (NULL != pClientName) {
- // send message to only specified client
- if (!std::strcmp(pClientName, l_cServiceName)) {
- eStatus = SendEventMessage(hApp, ssidl_iterator->second, uiEventId, l_cServiceName, pData, uiLength);
- break;
- }
- } else {
- // send message to all registered client
- eRetStatus = SendEventMessage(hApp, ssidl_iterator->second, uiEventId, l_cServiceName, pData, uiLength);
- if (eFrameworkunifiedStatusOK != eRetStatus) {
- eStatus = eRetStatus;
- }
- }
- }
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_IMP_INFO, __FUNCTION__, "No subscriber has subscribed for event %d.", uiEventId);
- }
- } else {
- eStatus = eFrameworkunifiedStatusInvldHandle;
- }
-
- return eStatus;
-}
-
-//////////////////////////////////////////////////////
-/// UpdatePublicStateEventData
-//////////////////////////////////////////////////////
-EFrameworkunifiedStatus UpdatePublicStateEventData(HANDLE hApp, UI_32 uiEventId, PCVOID pData, UI_32 uiLength) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (frameworkunifiedCheckValidAppHandle(hApp)) {
- if ((NULL == pData) && (uiLength > 0)) {
- eStatus = eFrameworkunifiedStatusInvldParam;
- } else {
- PublicStateEventTable::iterator se_iterator;
- EventData *l_pEventData = NULL;
-
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
-
- // set the data, if event is a state events
- se_iterator = pApp->publicstateeventtable.find(uiEventId);
- if (pApp->publicstateeventtable.end() != se_iterator) {
- l_pEventData = se_iterator->second;
- if (NULL != l_pEventData) {
- if (NULL != l_pEventData->pData) {
- delete[](static_cast<PCHAR>(l_pEventData->pData));
- (se_iterator->second)->pData = NULL;
- }
-
- delete l_pEventData;
- se_iterator->second = NULL;
- }
-
- l_pEventData = new(std::nothrow) EventData();
- /*
- * @todo
- * UpdatePublicStateEventData() in the pApp->publicstateeventtable
- * The data area is being created, but there is no process to release.
- */
- if (NULL != l_pEventData) {
- l_pEventData->uiLength = uiLength;
- // LCOV_EXCL_BR_START 6:pData is checked in the top of this function, it should be not NULL here.
- if (NULL == pData) {
- // LCOV_EXCL_BR_STOP
- // LCOV_EXCL_START 6:pData is checked in the top of this function, it should be not NULL here.
- AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
- l_pEventData->pData = NULL;
- // LCOV_EXCL_STOP
- } else {
- l_pEventData->pData = new(std::nothrow) CHAR[uiLength];
- if (NULL != l_pEventData->pData) {
- std::memset(l_pEventData->pData, 0, uiLength);
- std::memcpy(l_pEventData->pData, pData, uiLength);
- } else {
- eStatus = eFrameworkunifiedStatusNullPointer;
- }
- }
-
- se_iterator->second = l_pEventData;
- } else {
- eStatus = eFrameworkunifiedStatusNullPointer;
- }
- }
- }
- } else {
- eStatus = eFrameworkunifiedStatusInvldParam;
- }
-
- return eStatus;
-}
-
-//////////////////////////////////////////////////////
-/// SendEventMessage
-//////////////////////////////////////////////////////
-EFrameworkunifiedStatus SendEventMessage(HANDLE hApp,
- const SessionIdList &vSessionIdList,
- UI_32 uiEventId,
- PCSTR cServiceName,
- PCVOID pData,
- UI_32 uiLength) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
- EFrameworkunifiedStatus eStatusSendMsg = eFrameworkunifiedStatusOK;
-
- UI_32 l_uiSessionId = 0;
- HANDLE l_hClientHandle = NULL;
-
- if ((frameworkunifiedCheckValidAppHandle(hApp)) && (NULL != cServiceName)) {
- for (UI_32 l_uiCount = 0;
- l_uiCount < vSessionIdList.size();
- l_uiCount++) {
- l_uiSessionId = vSessionIdList[l_uiCount];
- l_hClientHandle = GetMsgQueueHandle(hApp, cServiceName, l_uiSessionId);
-
- // send message to all the registered sessions of the service
- if (NULL != l_hClientHandle) {
- if (eFrameworkunifiedStatusOK != (eStatusSendMsg = FrameworkunifiedSendMsg(l_hClientHandle, uiEventId, uiLength, pData))) {
- eStatus = eFrameworkunifiedStatusErrOther;
- FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "FrameworkunifiedSendMsg failed for EventID %d to service %s, status %d",
- uiEventId, cServiceName, eStatusSendMsg);
- }
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "Unable to send event %d to service %s, session %d. NULL handle found.",
- uiEventId, cServiceName, l_uiSessionId);
- eStatus = eFrameworkunifiedStatusErrOther;
- }
- }
- } else {
- eStatus = eFrameworkunifiedStatusInvldParam;
- }
-
- return eStatus;
-}
-
-//////////////////////////////////////////////////////
-/// RemoveEventEntryFromEventTable
-//////////////////////////////////////////////////////
-EFrameworkunifiedStatus RemoveEventEntryFromEventTable(HANDLE hApp, UI_32 uiEventId,
- PCSTR cServiceName, const UI_32 uiSessionId) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if ((frameworkunifiedCheckValidAppHandle(hApp)) && (NULL != cServiceName)) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
-
- EventTable::iterator e_iterator;
- ServiceSessionIdListTable::iterator ssidl_iterator;
-
- // event table = event id, service name, vector of session ids
- // check if event is registered by client/s
- e_iterator = pApp->eventtable.find(uiEventId);
-
- if (pApp->eventtable.end() != e_iterator) {
- ssidl_iterator = e_iterator->second.find(cServiceName);
-
- if (e_iterator->second.end() != ssidl_iterator) {
- // search for the session id in list of registered session of service with the event uiEventId
- for (UI_32 l_uiCount = 0;
- l_uiCount < ssidl_iterator->second.size();
- l_uiCount++) {
- if (uiSessionId == ssidl_iterator->second[l_uiCount]) {
- ssidl_iterator->second.erase(ssidl_iterator->second.begin() + l_uiCount);
- break;
- }
- }
-
- // no other session of service cServiceName is registered with the event uiEventId
- if (ssidl_iterator->second.empty()) {
- e_iterator->second.erase(ssidl_iterator);
-
- // no other session is registered for the event uiEventId
- if (e_iterator->second.empty()) {
- pApp->eventtable.erase(e_iterator);
- }
- }
- }
- }
- } else {
- eStatus = eFrameworkunifiedStatusInvldParam;
- }
-
- return eStatus;
-}
-
-////////////////////////////////////////////
-// Function : CleanAllEventsOfSession
-////////////////////////////////////////////
-EFrameworkunifiedStatus CleanAllEventsOfSession(HANDLE hApp, PCSTR serviceName, UI_32 sessionId) {
- FRAMEWORKUNIFIEDLOG_CUT(ZONE_NS_FUNC, __FUNCTION__, "+");
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if ((frameworkunifiedCheckValidAppHandle(hApp)) && (NULL != serviceName)) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
-
- ServiceSessionHandleTable::iterator ssh_iterator;
- SessionToEventInfo::iterator sh_iterator;
- HANDLE l_pClientHandle = NULL;
- SessionEventInfo *l_ptSessionEventInfo = NULL;
-
- // check whether client has registered for private event/s
- ssh_iterator = pApp->servicesessionhandletable.find(serviceName);
-
- if (pApp->servicesessionhandletable.end() != ssh_iterator) {
- // get the table of session id and session handle of the received service over which private events are
- // registered
- sh_iterator = ssh_iterator->second.find(sessionId);
-
- // client has registered for private event/s over this session
- if (ssh_iterator->second.end() != sh_iterator) {
- l_ptSessionEventInfo = sh_iterator->second;
-
- if (NULL != l_ptSessionEventInfo) {
- l_pClientHandle = l_ptSessionEventInfo->m_hSession;
- if (NULL != l_pClientHandle) {
- // close the session handle
- eStatus = FrameworkunifiedMcClose(l_pClientHandle);
- l_ptSessionEventInfo->m_hSession = NULL;
- }
- // Remove all the event entries from Event registry table
- for (UI_32 l_uiCount = 0;
- l_uiCount < l_ptSessionEventInfo->m_vEvents.size();
- l_uiCount++) {
- (VOID)RemoveEventEntryFromEventTable(hApp,
- l_ptSessionEventInfo->m_vEvents[l_uiCount],
- serviceName,
- sessionId);
- }
- l_ptSessionEventInfo->m_vEvents.clear(); // clear the event list
- delete l_ptSessionEventInfo;
- sh_iterator->second = NULL; // l_ptSessionEventInfo
- }
-
- FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "Deleting session event info entry for service: %s, session id: %d.",
- serviceName, sessionId);
- // remove the entry from SessionHandle table
- ssh_iterator->second.erase(sh_iterator);
-
- // remove the entry from ServiceSessionHandle table if this service have not registered for
- // private events over other session
- if (ssh_iterator->second.empty()) {
- pApp->servicesessionhandletable.erase(ssh_iterator);
- }
- }
- }
- } else {
- eStatus = eFrameworkunifiedStatusInvldParam;
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Invalid application handle or service name NULL");
- }
- FRAMEWORKUNIFIEDLOG_CUT(ZONE_NS_FUNC, __FUNCTION__, "-");
- return eStatus;
-}
-
-//////////////////////////////////////////////////////
-/// RemoveEntryFromSessionEventInfoTable
-//////////////////////////////////////////////////////
-EFrameworkunifiedStatus RemoveEntryFromSessionEventInfoTable(HANDLE hApp, PCSTR serviceName, UI_32 sessionId, UI_32 eventId) {
- FRAMEWORKUNIFIEDLOG_CUT(ZONE_NS_FUNC, __FUNCTION__, "+");
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if ((frameworkunifiedCheckValidAppHandle(hApp)) && (NULL != serviceName)) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
-
- ServiceSessionHandleTable::iterator ssh_iterator;
- SessionToEventInfo::iterator sh_iterator;
- HANDLE l_pClientHandle = NULL;
- SessionEventInfo *l_ptSessionEventInfo = NULL;
-
- // check whether client has registered for private event/s
- ssh_iterator = pApp->servicesessionhandletable.find(serviceName);
-
- if (pApp->servicesessionhandletable.end() != ssh_iterator) {
- // get the table of session id and session handle of the received service over which private events are
- // registered
- sh_iterator = ssh_iterator->second.find(sessionId);
-
- // client has registered for private event/s over this session
- if (ssh_iterator->second.end() != sh_iterator) {
- l_ptSessionEventInfo = sh_iterator->second;
-
- if (NULL != l_ptSessionEventInfo) {
- // Remove event entry from session event info table
- for (UI_32 l_uiCount = 0;
- l_uiCount < l_ptSessionEventInfo->m_vEvents.size();
- l_uiCount++) {
- if (eventId == l_ptSessionEventInfo->m_vEvents[l_uiCount]) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "Removing session event info entry for "
- "service:%s, session id:%d. event:%d",
- serviceName, sessionId, eventId);
- l_ptSessionEventInfo->m_vEvents.erase(l_ptSessionEventInfo->m_vEvents.begin() + l_uiCount);
- break;
- }
- }
-
- if (l_ptSessionEventInfo->m_vEvents.empty()) {
- l_pClientHandle = l_ptSessionEventInfo->m_hSession;
- if (NULL != l_pClientHandle) {
- // close the session handle
- eStatus = FrameworkunifiedMcClose(l_pClientHandle);
- l_ptSessionEventInfo->m_hSession = NULL;
- }
- delete l_ptSessionEventInfo;
- sh_iterator->second = NULL; // l_ptSessionEventInfo
-
- // remove the entry from SessionHandle table
- ssh_iterator->second.erase(sh_iterator);
- }
- }
-
- // remove the entry from ServiceSessionHandle table if this service have not registered for
- // private events over other session
- if (ssh_iterator->second.empty()) {
- pApp->servicesessionhandletable.erase(ssh_iterator);
- }
- }
- }
- } else {
- eStatus = eFrameworkunifiedStatusInvldParam;
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Invalid application handle status:: %d", eStatus);
- }
-
- FRAMEWORKUNIFIEDLOG_CUT(ZONE_NS_FUNC, __FUNCTION__, "-");
- return eStatus;
-}
-
-
-//////////////////////////////////////////////////////
-/// FrameworkunifiedDefinePublicStateEvents
-//////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedDefinePublicStateEvents(HANDLE hApp, PUI_32 puiEvents, UI_32 uiListSize) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (frameworkunifiedCheckValidAppHandle(hApp) && NULL != puiEvents) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
-
- UI_32 l_uiEventId;
-
- for (UI_32 uiCount = 0; uiCount < uiListSize; uiCount++) {
- l_uiEventId = puiEvents[uiCount];
-
- // checks if event exists in state event list
- if (pApp->publicstateeventtable.end() == pApp->publicstateeventtable.find(l_uiEventId)) {
- EventData *l_pEventData = NULL;
- // insert the event in state event list, data is passed as NULL as there is no data published
- pApp->publicstateeventtable.insert(std::make_pair(l_uiEventId, l_pEventData));
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "Event %d already registered as public state event ", l_uiEventId);
- }
- }
- } else {
- eStatus = eFrameworkunifiedStatusInvldHandle;
- }
-
- return eStatus;
-}
-
-//////////////////////////////////////////////////////
-/// FrameworkunifiedDefinePrivateStateEvents
-//////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedDefinePrivateStateEvents(HANDLE hApp, PUI_32 puiEvents, UI_32 uiListSize) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (frameworkunifiedCheckValidAppHandle(hApp) && NULL != puiEvents) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
-
- UI_32 l_uiEventId = 0;
-
- for (UI_32 uiCount = 0; uiCount < uiListSize; uiCount++) {
- l_uiEventId = puiEvents[uiCount];
-
- // checks if event exists in state event list
- if (pApp->privatestateeventtable.end() == pApp->privatestateeventtable.find(l_uiEventId)) {
- ServiceSessionEventData servicesessioneventdata;
- pApp->privatestateeventtable.insert(std::make_pair(l_uiEventId, servicesessioneventdata));
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "Event %d already registered as private state event", l_uiEventId);
- }
- }
- } else {
- eStatus = eFrameworkunifiedStatusInvldHandle;
- }
-
- return eStatus;
-}
-
-//////////////////////////////////////////////////////
-/// FrameworkunifiedSubscribeToSessionEventWithCallback
-//////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedSubscribeToSessionEventWithCallback(HANDLE hApp, UI_32 uiCmd, CbFuncPtr fpOnCmd, HANDLE hSession) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (frameworkunifiedCheckValidAppHandle(hApp) && frameworkunifiedCheckValidMsgQ(hSession)) {
- if (eFrameworkunifiedStatusOK == (eStatus = FrameworkunifiedAttachCallbackToDispatcher(hApp,
- (reinterpret_cast<MsgQInfo *>(hSession))->cMsgQName,
- uiCmd,
- fpOnCmd,
- hSession))) {
- eStatus = FrameworkunifiedSendMsg(hSession, PROTOCOL_REGISTER_EVENTS, sizeof(UI_32), (PVOID)&uiCmd);
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "FrameworkunifiedAttachCallbackToDispatcher for "
- "PROTOCOL_REGISTER_EVENTS Failed Status:: %d", eStatus);
- }
- } else {
- eStatus = eFrameworkunifiedStatusInvldHandle;
- }
-
- return eStatus;
-}
-
-//////////////////////////////////////////////////////
-/// FrameworkunifiedSubscribeToSessionEventsWithCallbacks
-//////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedSubscribeToSessionEventsWithCallbacks(HANDLE hApp, const FrameworkunifiedProtocolCallbackHandler *pMsgHandler,
- UI_32 uiHandlerCount, HANDLE hSession) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (NULL == pMsgHandler) {
- eStatus = eFrameworkunifiedStatusInvldParam;
- } else if (frameworkunifiedCheckValidAppHandle(hApp) && frameworkunifiedCheckValidMsgQ(hSession)) {
- /**
- * @todo
- * If the CbFuncPtr in the pMsgHandler is set to NULL, the expected value is eFrameworkunifiedStatusInvldParam,
- * but eFrameworkunifiedStatusOK is returned in the implementation.
- * [Proposed measures]
- * Exit by referring to the return code of the FrameworkunifiedAttachCallbacksToDispatcher executed in the FrameworkunifiedSubscribeToSessionEventsWithCallbacks.
- */
- /**
- * @todo
- * The behavior when NULL is set for a CbFuncPtr in a pMsgHandler in which more than one callback message is registered
- * is not specified in the specifications.
- * Ex: Prepare a pMsgHandler in which three callback information are registered,
- * and specify NULL as the callback function pointer of the second callback information, and execute it.
- * - Register the first callback function.
- * - The second callback function is not registered with an error.
- * - It is unspecified whether the third callback function is registered.
- * [Proposed measures]
- * Specifies that if there is callback information including NULL in the callback function pointer in pMsgHandler,
- * the callback information will not be registered from the element following that callback function pointer.
- */
- eStatus = FrameworkunifiedAttachCallbacksToDispatcher(hApp,
- (reinterpret_cast<MsgQInfo *>(hSession))->cMsgQName,
- pMsgHandler,
- uiHandlerCount,
- hSession);
- UI_32 l_uiCmdList[uiHandlerCount]; // NOLINT (readability/nolint)
- for (UI_32 l_uiCnt = 0; l_uiCnt < uiHandlerCount; l_uiCnt++) {
- l_uiCmdList[l_uiCnt] = pMsgHandler[l_uiCnt].iCmd;
- }
-
- eStatus = FrameworkunifiedSendMsg(hSession, PROTOCOL_REGISTER_EVENTS,
- static_cast<UI_32>(uiHandlerCount * sizeof(UI_32)), l_uiCmdList);
- } else {
- eStatus = eFrameworkunifiedStatusInvldHandle;
- }
-
- return eStatus;
-}
-
-//////////////////////////////////////////////////////
-/// FrameworkunifiedUnSubscribeSessionEventWithCallback
-//////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedUnSubscribeSessionEventWithCallback(HANDLE hApp, UI_32 uiEvent, HANDLE hSession) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (frameworkunifiedCheckValidAppHandle(hApp) && frameworkunifiedCheckValidMsgQ(hSession)) {
- eStatus = FrameworkunifiedSendMsg(hSession, PROTOCOL_UNREGISTER_EVENTS, sizeof(uiEvent), (PVOID)&uiEvent);
- if (eFrameworkunifiedStatusOK == eStatus) {
- if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedDetachCallbackFromDispatcher(hApp,
- (reinterpret_cast<MsgQInfo *>(hSession))->cMsgQName,
- uiEvent,
- hSession))) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error : FrameworkunifiedDetachCallbackFromDispatcher failed status:: %d", eStatus);
- }
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error : Failed to send PROTOCOL_UNREGISTER_EVENTS request to service:: %d",
- eStatus);
- }
- } else {
- eStatus = eFrameworkunifiedStatusInvldHandle;
- }
-
- return eStatus;
-}
-
-//////////////////////////////////////////////////////
-/// FrameworkunifiedUnSubscribeSessionEventsWithCallbacks
-//////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedUnSubscribeSessionEventsWithCallbacks(HANDLE hApp, PUI_32 puiEventsArray, UI_32 uiListSize,
- HANDLE hSession) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (frameworkunifiedCheckValidAppHandle(hApp) && frameworkunifiedCheckValidMsgQ(hSession)) {
- eStatus = FrameworkunifiedSendMsg(hSession, PROTOCOL_UNREGISTER_EVENTS, static_cast<UI_32>(uiListSize * sizeof(uiListSize)),
- puiEventsArray);
- if (eFrameworkunifiedStatusOK == eStatus) {
- if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedDetachCallbacksFromDispatcher(hApp,
- (reinterpret_cast<MsgQInfo *>(hSession))->cMsgQName,
- puiEventsArray,
- uiListSize,
- hSession))) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error : FrameworkunifiedDetachCallbackFromDispatcher failed status:: %d", eStatus);
- }
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error : Failed to send PROTOCOL_UNREGISTER_EVENTS request to service:: %d",
- eStatus);
- }
- } else {
- eStatus = eFrameworkunifiedStatusInvldHandle;
- }
-
- return eStatus;
-}
-
-//////////////////////////////////////////////////////
-/// FrameworkunifiedPublishPrivateEvent
-//////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedPublishPrivateEvent(HANDLE hApp, UI_32 uiEventId, PCVOID pData, UI_32 uiLength, HANDLE hSession) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (frameworkunifiedCheckValidAppHandle(hApp) && frameworkunifiedCheckValidMsgQ(hSession)) {
- EventTable::iterator e_iterator;
- ServiceSessionIdListTable::iterator ssidl_iterator;
-
- PCSTR l_cServiceName = "";
- BOOL l_bIsPublished = FALSE;
-
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
-
- // set the data, if event is a public state events
- UpdatePrivateStateEventData(hApp,
- uiEventId,
- (reinterpret_cast<MsgQInfo *>(hSession))->cMsgQName,
- (reinterpret_cast<MsgQInfo *>(hSession))->sessionId,
- pData,
- uiLength);
-
- // check if event is registered by client/s
- e_iterator = pApp->eventtable.find(uiEventId);
-
- if (pApp->eventtable.end() != e_iterator) {
- // for loop for event table
- for (ssidl_iterator = e_iterator->second.begin();
- ssidl_iterator != e_iterator->second.end();
- ssidl_iterator++) {
- l_cServiceName = ssidl_iterator->first.c_str();
-
- // send message to only specified client
- if (!std::strcmp(l_cServiceName, (reinterpret_cast<MsgQInfo *>(hSession))->cMsgQName)) {
- for (UI_32 l_uiCount = 0;
- l_uiCount < ssidl_iterator->second.size();
- l_uiCount++) {
- if ((reinterpret_cast<MsgQInfo *>(hSession))->sessionId == ssidl_iterator->second[l_uiCount]) {
- if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedSendMsg(hSession, uiEventId, uiLength, pData))) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "FrameworkunifiedSendMsg Failed for Event %d", uiEventId);
- }
-
- l_bIsPublished = TRUE;
- break;
- }
- }
- }
-
- if (l_bIsPublished) {
- break;
- }
- }
-
- if (!l_bIsPublished) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "Failed to publish event %d to client [%s], session: [%d]. "
- "Client not subscribed to the event on specified session.",
- uiEventId, (reinterpret_cast<MsgQInfo *>(hSession))->cMsgQName != 0 ? \
- (reinterpret_cast<MsgQInfo *>(hSession))->cMsgQName : NULL,
- (reinterpret_cast<MsgQInfo *>(hSession))->sessionId);
- eStatus = eFrameworkunifiedStatusServNotFound;
- }
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "Client %s is not subscribed to Event %d, session: [%d]",
- (reinterpret_cast<MsgQInfo *>(hSession))->cMsgQName, uiEventId,
- (reinterpret_cast<MsgQInfo *>(hSession))->sessionId);
- eStatus = eFrameworkunifiedStatusServNotFound;
- }
- } else {
- eStatus = eFrameworkunifiedStatusInvldParam;
- }
-
- return eStatus;
-}
-
-//////////////////////////////////////////////////////
-/// FrameworkunifiedPublishPublicEvent
-//////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedPublishPublicEvent(HANDLE hApp, UI_32 uiEventId, PCVOID pData, UI_32 uiLength) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
- EFrameworkunifiedStatus eRetStatus = eFrameworkunifiedStatusOK;
-
- if (frameworkunifiedCheckValidAppHandle(hApp)) {
- EventTable::iterator e_iterator;
- ServiceSessionIdListTable::iterator ssidl_iterator;
-
- PCSTR l_cServiceName = "";
-
- // set the data, if event is a state events
- UpdatePublicStateEventData(hApp, uiEventId, pData, uiLength);
-
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
-
- // check if event is registered by client/s
- e_iterator = pApp->eventtable.find(uiEventId);
-
- if (pApp->eventtable.end() != e_iterator) {
- // for loop for event table
- for (ssidl_iterator = e_iterator->second.begin();
- ssidl_iterator != e_iterator->second.end();
- ssidl_iterator++) {
- l_cServiceName = ssidl_iterator->first.c_str();
-
- eRetStatus = SendEventMessage(hApp, ssidl_iterator->second, uiEventId, l_cServiceName, pData, uiLength);
- if (eFrameworkunifiedStatusOK != eRetStatus) {
- eStatus = eRetStatus;
- }
- }
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "No client subscribed to EventID %d.", uiEventId);
- }
- } else {
- eStatus = eFrameworkunifiedStatusInvldHandle;
- }
-
- return eStatus;
-}
-
-//////////////////////////////////////////////////////
-/// UpdatePrivateStateEventData
-//////////////////////////////////////////////////////
-EFrameworkunifiedStatus UpdatePrivateStateEventData(HANDLE hApp, UI_32 uiEventId, PCSTR pClientName, UI_32 uiSessionId,
- PCVOID pData,
- UI_32 uiLength) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if ((NULL == pData) && (uiLength > 0)) {
- eStatus = eFrameworkunifiedStatusInvldParam;
- }
-
- if ((eFrameworkunifiedStatusOK == eStatus) && (frameworkunifiedCheckValidAppHandle(hApp)) && (NULL != pClientName)) {
- PrivateStateEventTable::iterator pse_iterator;
- ServiceSessionEventData::iterator ssed_iterator;
- SessionEventData::iterator sed_iterator;
-
- EventData *l_pEventData = NULL;
-
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
-
- // set the data, if event is a state events
- pse_iterator = pApp->privatestateeventtable.find(uiEventId);
- if (pApp->privatestateeventtable.end() != pse_iterator) {
- ssed_iterator = (pse_iterator->second).find(pClientName);
-
- if ((pse_iterator->second).end() != ssed_iterator) {
- sed_iterator = (ssed_iterator->second).find(uiSessionId);
- if ((ssed_iterator->second).end() != sed_iterator) {
- l_pEventData = sed_iterator->second;
-
- if (NULL != l_pEventData) {
- if (NULL != l_pEventData->pData) {
- delete[](static_cast<PCHAR>(l_pEventData->pData));
- (sed_iterator->second)->pData = NULL;
- }
-
- delete l_pEventData;
- sed_iterator->second = NULL;
- }
-
- l_pEventData = new(std::nothrow) EventData();
-
- if (NULL != l_pEventData) {
- l_pEventData->uiLength = uiLength;
-
- if (NULL == pData) {
- l_pEventData->pData = NULL;
- } else {
- l_pEventData->pData = new(std::nothrow) CHAR[uiLength];
- if (NULL != l_pEventData->pData) {
- std::memset(l_pEventData->pData, 0, uiLength);
- std::memcpy(l_pEventData->pData, pData, uiLength);
- } else {
- eStatus = eFrameworkunifiedStatusNullPointer;
- l_pEventData->uiLength = 0;
- }
- }
-
- sed_iterator->second = l_pEventData;
- } else {
- eStatus = eFrameworkunifiedStatusNullPointer;
- }
- } else { // if client has not yet subscribed to this event over the session uiSessionId
- l_pEventData = new(std::nothrow) EventData();
-
- if (NULL != l_pEventData) {
- l_pEventData->uiLength = uiLength;
-
- if (NULL == pData) {
- l_pEventData->pData = NULL;
- } else {
- l_pEventData->pData = new(std::nothrow) CHAR[uiLength];
- if (NULL != l_pEventData->pData) {
- std::memset(l_pEventData->pData, 0, uiLength);
- std::memcpy(l_pEventData->pData, pData, uiLength);
- } else {
- eStatus = eFrameworkunifiedStatusNullPointer;
- }
- }
-
- (ssed_iterator->second).insert(std::make_pair(uiSessionId, l_pEventData));
- } else {
- eStatus = eFrameworkunifiedStatusNullPointer;
- }
- }
- } else { // if client has not yet subscribed to this event
- SessionEventData sessionEventData;
-
- l_pEventData = new(std::nothrow) EventData();
-
- if (NULL != l_pEventData) {
- l_pEventData->uiLength = uiLength;
-
- if (NULL == pData) {
- l_pEventData->pData = NULL;
- } else {
- l_pEventData->pData = new(std::nothrow) CHAR[uiLength];
- if (NULL != l_pEventData->pData) {
- std::memset(l_pEventData->pData, 0, uiLength);
- std::memcpy(l_pEventData->pData, pData, uiLength);
- } else {
- eStatus = eFrameworkunifiedStatusNullPointer;
- l_pEventData->uiLength = 0;
- }
- }
- sessionEventData.insert(std::make_pair(uiSessionId, l_pEventData));
-
- (pse_iterator->second).insert(std::make_pair(pClientName, sessionEventData));
- } else {
- eStatus = eFrameworkunifiedStatusNullPointer;
- }
- }
- }
- } else {
- eStatus = eFrameworkunifiedStatusInvldParam;
- }
-
- return eStatus;
-}
-
-//////////////////////////////////////////////////////
-/// DeleteSessionEventData
-//////////////////////////////////////////////////////
-EFrameworkunifiedStatus DeleteSessionEventData(HANDLE hApp, PCSTR pClientName, UI_32 uiSessionId) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- // map: eventid -> servicename -> sessionid -> eventdata(data, length)
-
- if (frameworkunifiedCheckValidAppHandle(hApp) && NULL != pClientName) {
- PrivateStateEventTable::iterator pse_iterator;
- ServiceSessionEventData::iterator ssed_iterator;
- SessionEventData::iterator sed_iterator;
-
- EventData *l_pEventData = NULL;
-
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
-
- // delete the private event data associated with the service over this session
- for (pse_iterator = pApp->privatestateeventtable.begin();
- pse_iterator != pApp->privatestateeventtable.end();
- ++pse_iterator) {
- ssed_iterator = (pse_iterator->second).find(pClientName);
-
- if ((pse_iterator->second).end() != ssed_iterator) {
- sed_iterator = (ssed_iterator->second).find(uiSessionId);
- if ((ssed_iterator->second).end() != sed_iterator) {
- l_pEventData = sed_iterator->second;
-
- if (NULL != l_pEventData) {
- if (NULL != l_pEventData->pData) {
- delete[](static_cast<PCHAR>(l_pEventData->pData));
- (sed_iterator->second)->pData = NULL;
- }
-
- delete l_pEventData;
- sed_iterator->second = NULL;
- }
- }
- }
- }
- } else {
- eStatus = eFrameworkunifiedStatusNullPointer;
- }
-
- return eStatus;
-}
-
-//////////////////////////////////////////////////////
-/// Returns the number of session opened by the server for one client
-//////////////////////////////////////////////////////
-UI_32 FrameworkunifiedGetNumberOfSession(HANDLE hApp, PCSTR strServiceName) {
- UI_32 l_uiSessionCount = 0;
-
- if (frameworkunifiedCheckValidAppHandle(hApp)) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- Services::iterator s_iterator = pApp->services.find(strServiceName);
- if (s_iterator != pApp->services.end()) {
- l_uiSessionCount = static_cast<UI_32>((s_iterator->second).size());
- }
- }
-
- return l_uiSessionCount;
-}
-
-//////////////////////////////////////////////////////
-/// Sets the handle in the Application Framework
-//////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedSetSessionHandle(HANDLE hApp, PCSTR strServiceName, HANDLE hSession) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
- UI_32 l_uiSessionId = 0;
- if (frameworkunifiedCheckValidMsgQ(hSession) && NULL != strServiceName && frameworkunifiedCheckValidAppHandle(hApp) &&
- 0 != std::strlen(strServiceName)) {
- MsgQInfo *pMsgQ = reinterpret_cast<MsgQInfo *>(hSession);
-
- // Get session Id
- l_uiSessionId = pMsgQ->sessionId;
-
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- ServiceSessionTable::iterator session_iterator;
- SessionHandleTable::iterator session_handle_iterator;
-
- // Find the service name
- session_iterator = pApp->sessiontable.find(strServiceName);
- if (session_iterator == pApp->sessiontable.end()) {
- pApp->sessiontable.insert(std::make_pair(strServiceName, SessionHandleTable()));
- }
-
- // Find the session id
- session_handle_iterator = pApp->sessiontable[strServiceName].find(l_uiSessionId);
- if (session_handle_iterator != pApp->sessiontable[strServiceName].end()) {
- pApp->sessiontable[strServiceName].erase(l_uiSessionId);
- }
-
- // Set the session handle
- pApp->sessiontable[strServiceName].insert(std::make_pair(l_uiSessionId, hSession));
-
- } else {
- eStatus = eFrameworkunifiedStatusFail;
- }
- return eStatus;
-}
-
-//////////////////////////////////////////////////////
-/// reads the handle from the Application Framework
-//////////////////////////////////////////////////////
-HANDLE FrameworkunifiedGetSessionHandle(HANDLE hApp, PCSTR strServiceName, UI_32 uiSessionId) {
- HANDLE hSession = NULL;
- if (frameworkunifiedCheckValidAppHandle(hApp) && strServiceName) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- ServiceSessionTable::iterator session_iterator;
- SessionHandleTable::iterator session_handle_iterator;
-
- // Find the service name
- session_iterator = pApp->sessiontable.find(strServiceName);
- if (session_iterator != pApp->sessiontable.end()) {
- // Find the session id
- session_handle_iterator = pApp->sessiontable[strServiceName].find(uiSessionId);
- if (session_handle_iterator != pApp->sessiontable[strServiceName].end()) {
- // Fetch the session handle
- hSession = session_handle_iterator->second;
- }
- }
- }
- return hSession;
-}
-//////////////////////////////////////////////////////
-/// Close the handle stored in the Application Framework
-//////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedRemoveSessionHandle(HANDLE hApp, PCSTR strServiceName, UI_32 uiSessionId) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
- if (frameworkunifiedCheckValidAppHandle(hApp) && strServiceName && 0 != std::strlen(strServiceName)) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
-
- pApp->sessiontable[strServiceName].erase(uiSessionId);
- if (0 == pApp->sessiontable[strServiceName].size()) {
- // If no entry is available for current service then remove the servicename
- pApp->sessiontable.erase(strServiceName);
- }
- } else {
- eStatus = eFrameworkunifiedStatusFail;
- }
-
- return eStatus;
-}
-
-//////////////////////////////////////////////////////
-/// FrameworkunifiedGetSession|Name -> On Client side
-//////////////////////////////////////////////////////
-PCSTR FrameworkunifiedGetSessionName(HANDLE hSession) {
- if (frameworkunifiedCheckValidMsgQ(hSession)) {
- return ((reinterpret_cast<MsgQInfo *>(hSession))->cMsgQName);
- } else {
- return NULL;
- }
-}
-
-
-HANDLE FrameworkunifiedGetCurrentSessionHandle(HANDLE hApp) {
- HANDLE hSession = NULL;
- if (frameworkunifiedCheckValidAppHandle(hApp)) {
- UI_32 l_uiSessionId = FrameworkunifiedGetMsgSessionId(hApp);
- PCSTR pRequester = FrameworkunifiedGetMsgSrc(hApp);
-
- hSession = FrameworkunifiedGetSessionHandle(hApp, pRequester, l_uiSessionId);
- }
- return hSession;
-}
-
-HANDLE FrameworkunifiedCreateSession(HANDLE hApp, PCSTR pSessionName) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
- HANDLE hSession = NULL;
- if (frameworkunifiedCheckValidAppHandle(hApp) && pSessionName && strlen(pSessionName)) {
- hSession = FrameworkunifiedGenerateSessionHandle(hApp, pSessionName);
- if (hSession) {
- if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedSetSessionHandle(hApp, pSessionName, hSession))) {
- if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedMcClose(hSession))) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __PRETTY_FUNCTION__, "Close session failed");
- }
- hSession = NULL;
-
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __PRETTY_FUNCTION__, "FrameworkunifiedCreateSession Failed Status:0x%x ", eStatus);
- }
- }
- } else {
- eStatus = eFrameworkunifiedStatusInvldParam;
- }
- return hSession;
-}
-
-EFrameworkunifiedStatus FrameworkunifiedDestroySession(HANDLE hApp, HANDLE hSession) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusFail;
-
- if (frameworkunifiedCheckValidAppHandle(hApp) && frameworkunifiedCheckValidMsgQ(hSession)) {
- UI_32 uiSessionId = (reinterpret_cast<MsgQInfo *>(hSession))->sessionId;
- CHAR pRequester[MAX_NAME_SIZE_APP] = {};
- strncpy(pRequester, (reinterpret_cast<MsgQInfo *>(hSession))->cMsgQName, sizeof(pRequester) - 1);
-
- if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedMcClose(hSession))) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __PRETTY_FUNCTION__, "Close session failed. Status: %d", eStatus);
- }
-
- if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedRemoveSessionHandle(hApp, pRequester, uiSessionId))) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __PRETTY_FUNCTION__, "Remove session failed. Status: %d", eStatus);
- }
-
- DeleteSessionEventData(hApp, pRequester, uiSessionId);
- }
-
- return eStatus;
-}
diff --git a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_framework_sync.cpp b/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_framework_sync.cpp
deleted file mode 100755
index 80eec1f..0000000
--- a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_framework_sync.cpp
+++ /dev/null
@@ -1,439 +0,0 @@
-/*
- * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-///////////////////////////////////////////////////////////////////////////////
-/// \ingroup tag_NativeService
-/// \brief This file contains the implementation for the synchronization
-/// API's class.
-///
-///////////////////////////////////////////////////////////////////////////////
-
-#include <native_service/frameworkunified_multithreading.h>
-#include <native_service/frameworkunified_framework_sync.h>
-#include <native_service/frameworkunified_framework_if.h>
-#include <native_service/ns_logger_if.h>
-#include <string>
-#include <algorithm>
-#include <utility>
-#include "frameworkunified_framework_core.h"
-
-/// initialization of static members of class
-CFrameworkunifiedSyncData *CFrameworkunifiedSyncData::m_psSyncData = NULL;
-
-pthread_spinlock_t CFrameworkunifiedSyncData::m_pSyncLock;
-static pthread_mutex_t g_instance_lock = PTHREAD_MUTEX_INITIALIZER;
-
-// Template function to invoke callback function of CFrameworkunifiedSyncData class
-template <typename C, eFrameworkunifiedStatus(C::*M)(HANDLE)> EFrameworkunifiedStatus SyncDataCallback(HANDLE hThread) {
- EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
-
- C *l_pClass = C::FrameworkunifiedGetSyncDataInstance();
-
- if (NULL != l_pClass) {
- l_eStatus = (l_pClass->*M)(hThread);
- }
-
- return l_eStatus;
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////////////
-/// CFrameworkunifiedSyncData
-/// Constructor of CFrameworkunifiedSyncData class
-////////////////////////////////////////////////////////////////////////////////////////////////////
-CFrameworkunifiedSyncData::CFrameworkunifiedSyncData(): m_bSyncThreadStarted(FALSE),
- m_mSyncDataMap(NULL),
- m_hSyncThreadAppHandle(NULL),
- m_hAppHandle(NULL),
- m_hSyncThreadMsgQHandle(NULL) {
- pthread_spin_init(&m_pSyncLock, 1);
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////////////
-/// CFrameworkunifiedSyncData
-/// Destructor of CFrameworkunifiedSyncData class
-////////////////////////////////////////////////////////////////////////////////////////////////////
-CFrameworkunifiedSyncData::~CFrameworkunifiedSyncData() {
- pthread_spin_destroy(&m_pSyncLock);
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedStartNotificationSync
-/// This method is used to start the synchronization notification thread.
-////////////////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedSyncData::FrameworkunifiedStartNotificationSync(HANDLE hApp) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "+");
- EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
-
- pthread_spin_lock(&m_pSyncLock);
- if (frameworkunifiedCheckValidAppHandle(hApp)) {
- m_hAppHandle = hApp;
- std::string l_cThreadName = FrameworkunifiedGetAppName(hApp);
- // l_cThreadName.append("SyncThread");
- std::reverse(l_cThreadName.begin(), l_cThreadName.end());
-
- if (NULL == m_hSyncThreadMsgQHandle) {
- // Create Sync Thread
- m_hSyncThreadMsgQHandle = FrameworkunifiedCreateChildThread(hApp,
- l_cThreadName.c_str(),
- SyncDataCallback<CFrameworkunifiedSyncData,
- &CFrameworkunifiedSyncData::FrameworkunifiedSyncDataThreadStart>,
- SyncDataCallback<CFrameworkunifiedSyncData,
- &CFrameworkunifiedSyncData::FrameworkunifiedSyncDataThreadStop>);
- if (NULL != m_hSyncThreadMsgQHandle) {
- if (FALSE == m_bSyncThreadStarted) {
- if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedStartChildThread(hApp,
- m_hSyncThreadMsgQHandle,
- 0,
- NULL))) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, " Failed to start Thread.");
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, " Sync Data Thread Started");
- m_bSyncThreadStarted = TRUE;
- }
- } else {
- l_eStatus = eFrameworkunifiedStatusThreadAlreadyRunning;
- }
-
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, " Sync Data Thread Message Queue Null");
- l_eStatus = eFrameworkunifiedStatusNullPointer;
- }
- } else {
- l_eStatus = eFrameworkunifiedStatusThreadAlreadyRunning;
- }
- } else {
- l_eStatus = eFrameworkunifiedStatusNullPointer;
- }
-
- pthread_spin_unlock(&m_pSyncLock);
-
- FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "-");
- return l_eStatus;
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedStartNotificationSync
-/// This method is used to stop the synchronization notification thread.
-////////////////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedSyncData::FrameworkunifiedStopNotificationSync(HANDLE hApp) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "+");
- EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
-
- if (frameworkunifiedCheckValidAppHandle(hApp)) {
- if (NULL != m_hSyncThreadMsgQHandle) {
- pthread_spin_lock(&m_pSyncLock);
- if (eFrameworkunifiedStatusOK != (l_eStatus = (FrameworkunifiedStopChildThread(hApp,
- m_hSyncThreadMsgQHandle,
- 0,
- NULL)))) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "FrameworkunifiedStopChildThread Sync Thread Failed.");
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "FrameworkunifiedStopChildThread Sync Thread Success.");
- m_bSyncThreadStarted = FALSE;
- }
- pthread_spin_unlock(&m_pSyncLock);
- } else {
- l_eStatus = eFrameworkunifiedStatusThreadNotExist;
- }
- } else {
- l_eStatus = eFrameworkunifiedStatusNullPointer;
- }
-
- FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "-");
- return l_eStatus;
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedGetSyncDataInstance
-/// This function is used to get the singleton instance of class.
-////////////////////////////////////////////////////////////////////////////////////////////////////
-CFrameworkunifiedSyncData *CFrameworkunifiedSyncData::FrameworkunifiedGetSyncDataInstance() {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "+");
-
- if (NULL == m_psSyncData) {
- pthread_mutex_lock(&g_instance_lock);
- if (NULL == m_psSyncData) {
- CFrameworkunifiedSyncData *l_pFrameworkunifiedSyncData = new(std::nothrow)CFrameworkunifiedSyncData();
- m_psSyncData = l_pFrameworkunifiedSyncData;
- }
- pthread_mutex_unlock(&g_instance_lock);
- }
-
- FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "-");
- return m_psSyncData;
-}
-
-
-////////////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedReleaseSyncDataInstance
-/// This function is used to release the instance of class.
-////////////////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedSyncData::FrameworkunifiedReleaseSyncDataInstance() {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "+");
- EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
-
- if (NULL != m_psSyncData) {
- pthread_mutex_lock(&g_instance_lock);
- if (NULL != m_psSyncData) {
- delete m_psSyncData;
- m_psSyncData = NULL;
- }
- pthread_mutex_unlock(&g_instance_lock);
- }
-
- FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "-");
- return l_eStatus;
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedSyncDataThreadStart
-/// This function is callback function on the start of the sync thread.
-////////////////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedSyncData::FrameworkunifiedSyncDataThreadStart(HANDLE hThread) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "+");
- EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
-
- if (NULL != hThread) {
- // Set Sync Thread Handle
- m_hSyncThreadAppHandle = hThread;
-
- if (NULL == m_mSyncDataMap) {
- m_mSyncDataMap = new(std::nothrow)TSyncDataPacketList();
- } else {
- l_eStatus = eFrameworkunifiedStatusNullPointer;
- }
- } else {
- l_eStatus = eFrameworkunifiedStatusNullPointer;
- }
- FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "-");
- return l_eStatus;
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedSyncDataThreadStop
-/// This function is callback function on the stop of the sync thread.
-////////////////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedSyncData::FrameworkunifiedSyncDataThreadStop(HANDLE hThread) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "+");
-
- if (NULL != m_mSyncDataMap) {
- for (TSyncDataPacketItr l_itSyncDataPacketItr = m_mSyncDataMap->begin() ;
- l_itSyncDataPacketItr != m_mSyncDataMap->end();) {
- SFrameworkunifiedSyncDataPacket *l_ptDataPacket = l_itSyncDataPacketItr->second;
-
- if (NULL != l_ptDataPacket) {
- if (NULL != l_ptDataPacket->m_pNotificationData) {
- delete[](static_cast<PCHAR>(l_ptDataPacket->m_pNotificationData));
- l_ptDataPacket->m_pNotificationData = NULL;
- }
- delete l_ptDataPacket;
- l_ptDataPacket = NULL;
- m_mSyncDataMap->erase(l_itSyncDataPacketItr++);
- } else {
- l_itSyncDataPacketItr++;
- }
- }
-
- delete m_mSyncDataMap;
- m_mSyncDataMap = NULL;
- }
- FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "-");
- return eFrameworkunifiedStatusExit;
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedSubscribeNotificationWithDataSync
-/// This function is used to subscribe to notifications.
-////////////////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedSyncData::FrameworkunifiedSubscribeNotificationWithDataSync(const std::string &f_cNotification) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "+");
- EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
-
- pthread_spin_lock(&m_pSyncLock);
- if (TRUE != f_cNotification.empty() && NULL != m_hSyncThreadAppHandle) {
- if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedSubscribeNotificationWithCallback(
- m_hSyncThreadAppHandle, // Thread Application handle
- f_cNotification.c_str(), // Notification
- SyncDataCallback<CFrameworkunifiedSyncData,
- &CFrameworkunifiedSyncData::FrameworkunifiedSyncDataNotifCallback>))) { // Callback Function
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "FrameworkunifiedSubscribeNotificationWithCallback Sync Notification Data failed.");
- l_eStatus = eFrameworkunifiedStatusFail;
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "FrameworkunifiedSubscribeNotificationWithCallback Sync Notification Data success.");
- }
- } else {
- l_eStatus = eFrameworkunifiedStatusFail;
- }
- pthread_spin_unlock(&m_pSyncLock);
-
- FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "-");
- return l_eStatus;
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedUnSubscribeNotificationWithDataSync
-/// This function is used to unsubscribe to notifications.
-////////////////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedSyncData::FrameworkunifiedUnSubscribeNotificationWithDataSync(const std::string &f_cNotification) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "+");
- EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
-
- pthread_spin_lock(&m_pSyncLock);
- if (TRUE != f_cNotification.empty() && NULL != m_hSyncThreadAppHandle) {
- if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedUnsubscribeNotificationWithCallback
- (m_hSyncThreadAppHandle, // Thread Application Handle
- f_cNotification.c_str()))) { // Notification
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "FrameworkunifiedUnsubscribeNotificationWithCallback failed.");
- l_eStatus = eFrameworkunifiedStatusFail;
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "FrameworkunifiedUnsubscribeNotificationWithCallback success.");
-
- TSyncDataPacketItr l_itSycDataPacketItr = m_mSyncDataMap->find(f_cNotification);
- // Delete the notification data
- if (m_mSyncDataMap->end() != l_itSycDataPacketItr) {
- SFrameworkunifiedSyncDataPacket *l_ptDataPacket = l_itSycDataPacketItr->second;
- if (NULL != l_ptDataPacket && NULL != l_ptDataPacket->m_pNotificationData) {
- delete[](static_cast<PCHAR>(l_ptDataPacket->m_pNotificationData));
- l_ptDataPacket->m_pNotificationData = NULL;
- delete l_ptDataPacket;
- l_ptDataPacket = NULL;
- m_mSyncDataMap->erase(l_itSycDataPacketItr);
- }
- }
- }
- } else {
- l_eStatus = eFrameworkunifiedStatusFail;
- }
- pthread_spin_unlock(&m_pSyncLock);
-
- FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "-");
- return l_eStatus;
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedSyncDataNotifCallback
-/// This function is callback to notifications on publication of notifications.
-////////////////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedSyncData::FrameworkunifiedSyncDataNotifCallback(HANDLE hThread) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "+");
- EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
-
- if (NULL == hThread) {
- return eFrameworkunifiedStatusInvldHandle;
- }
-
- PCSTR l_pcLastNotification = FrameworkunifiedGetLastNotification(hThread);
-
- if (NULL == l_pcLastNotification || 0 == std::strlen(l_pcLastNotification)) {
- return eFrameworkunifiedStatusInvldNotification;
- }
-
- UI_32 l_uiBufferSize = FrameworkunifiedGetMsgLength(hThread);
- PVOID l_pDataBuffer = new(std::nothrow)CHAR[l_uiBufferSize];
-
- if ((NULL != l_pDataBuffer) &&
- (eFrameworkunifiedStatusOK == FrameworkunifiedGetMsgDataOfSize(hThread, l_pDataBuffer, l_uiBufferSize, eSMRRelease))) {
- SFrameworkunifiedSyncDataPacket *l_ptDataPacket = NULL;
-
- pthread_spin_lock(&m_pSyncLock);
-
- TSyncDataPacketItr l_itSycDataPacketItr = m_mSyncDataMap->find(l_pcLastNotification);
- // Delete the last notification data
- if (m_mSyncDataMap->end() == l_itSycDataPacketItr) {
- l_ptDataPacket = new(std::nothrow)SFrameworkunifiedSyncDataPacket();
- } else {
- l_ptDataPacket = l_itSycDataPacketItr->second;
- if (NULL != l_ptDataPacket && NULL != l_ptDataPacket->m_pNotificationData) {
- delete[](static_cast<PCHAR>(l_ptDataPacket->m_pNotificationData));
- l_ptDataPacket->m_pNotificationData = NULL;
- }
- }
-
- if (NULL != l_ptDataPacket) {
- l_ptDataPacket->m_pNotificationData = l_pDataBuffer;
- l_ptDataPacket->m_uiDataSize = l_uiBufferSize;
- l_ptDataPacket->m_tTimeStamp = time(NULL);
- m_mSyncDataMap->insert(std::make_pair(l_pcLastNotification, l_ptDataPacket));
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "NULL pointer: l_ptDataPacket");
- }
-
- pthread_spin_unlock(&m_pSyncLock);
- } else {
- l_eStatus = eFrameworkunifiedStatusFail;
- }
- FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "-");
- return l_eStatus;
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedGetSyncDataSize
-/// This function is used to get the size of the synchronization data.
-////////////////////////////////////////////////////////////////////////////////////////////////////
-UI_32 CFrameworkunifiedSyncData::FrameworkunifiedGetSyncDataSize(const std::string &f_cNotification) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "+");
- UI_32 l_uiSyncDataSize = 0;
-
- if (TRUE != f_cNotification.empty()) {
- pthread_spin_lock(&m_pSyncLock);
-
- TSyncDataPacketItr l_itSyncDataPacketItr = m_mSyncDataMap->find(f_cNotification);
- SFrameworkunifiedSyncDataPacket *l_ptDataPacket = NULL;
-
- if (m_mSyncDataMap->end() != l_itSyncDataPacketItr) {
- l_ptDataPacket = l_itSyncDataPacketItr->second;
- l_uiSyncDataSize = l_ptDataPacket->m_uiDataSize;
- }
- pthread_spin_unlock(&m_pSyncLock);
- }
-
- FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "-");
- return l_uiSyncDataSize;
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedGetSyncNotificationData
-/// This function is used to get the synchronization notification data for a particular notification .
-////////////////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedSyncData::FrameworkunifiedGetSyncNotificationData(const std::string &f_cNotification, PVOID f_pBuffer,
- UI_16 f_nBufferSize) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "+");
- EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
-
- if (TRUE != f_cNotification.empty() && NULL != f_pBuffer && 0 != f_nBufferSize) {
- pthread_spin_lock(&m_pSyncLock);
- TSyncDataPacketItr l_itSyncDataPacketItr = m_mSyncDataMap->find(f_cNotification);
- if (m_mSyncDataMap->end() != l_itSyncDataPacketItr) {
- if (NULL != l_itSyncDataPacketItr->second) {
- if (NULL != std::memcpy(f_pBuffer, l_itSyncDataPacketItr->second->m_pNotificationData,
- l_itSyncDataPacketItr->second->m_uiDataSize)) {
- l_eStatus = eFrameworkunifiedStatusOK;
- } else {
- l_eStatus = eFrameworkunifiedStatusFail;
- }
- } else {
- l_eStatus = eFrameworkunifiedStatusFail;
- }
- } else {
- l_eStatus = eFrameworkunifiedStatusNullPointer;
- }
- pthread_spin_unlock(&m_pSyncLock);
- } else {
- l_eStatus = eFrameworkunifiedStatusFail;
- }
- FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "-");
- return l_eStatus;
-}
diff --git a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_framework_system.cpp b/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_framework_system.cpp
deleted file mode 100755
index 3a2d434..0000000
--- a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_framework_system.cpp
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-///////////////////////////////////////////////////////////////////////////////
-/// \ingroup tag_NSFramework
-/// \brief Framework wrapper over the service directory interface APIs
-///
-///
-///
-///////////////////////////////////////////////////////////////////////////////
-
-#include <native_service/frameworkunified_framework_if.h>
-#include <native_service/frameworkunified_framework_types.h>
-#include <native_service/frameworkunified_service_protocol.h>
-#include <native_service/ns_logger_if.h>
-#include "frameworkunified_framework_core.h"
-#include "frameworkunified_framework_internal.h"
-
-/// This is a library method in System Services....
-/// Note: Special care has been taken so that Native Services
-/// binaries don't have any circular dependence on System services.
-extern EFrameworkunifiedStatus SendSystemErrorToSystemManager(EFrameworkunifiedSystemError eSystemError) __attribute__((weak));
-
-
-EFrameworkunifiedStatus FrameworkunifiedAttachSystemCallbacksDispatcher(HANDLE hApp) {
- FRAMEWORKUNIFIEDLOG0(ZONE_NS_INFO, __FUNCTION__, "+"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
-
- EFrameworkunifiedStatus eStatus = FrameworkunifiedSSFrameworkInterfaceInternal(hApp);
-
- FRAMEWORKUNIFIEDLOG0(ZONE_NS_INFO, __FUNCTION__, "-"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
-
- return eStatus;
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedSendSystemErrMessage
-/// Sends a request to system manager for hard reset using function SendHardResetRequestToSystemManager
-/// which is defined in SystemServices library.
-///
-/// \param [in] hApp
-/// HANDLE - Application handle
-///
-/// \param [in] eResetReason
-/// EFrameworkunifiedSystemError - Error Type
-///
-/// \return EFrameworkunifiedStatus
-/// EFrameworkunifiedStatus - Returns status of operation
-///
-///////////////////////////////////////////////////////////////////////////////////////////
-// LCOV_EXCL_START 200: System Error can't be tested for UT.
-EFrameworkunifiedStatus FrameworkunifiedSendSystemErrMessage(HANDLE hApp, EFrameworkunifiedSystemError eSystemError) {
- AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
- EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusFail;
- FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "+");
-
- if (SendSystemErrorToSystemManager) {
- l_eStatus = SendSystemErrorToSystemManager(eSystemError);
- }
-
- FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "-");
- return l_eStatus;
-}
-// LCOV_EXCL_STOP
-
diff --git a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_msgprofiler.cpp b/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_msgprofiler.cpp
deleted file mode 100755
index 468478c..0000000
--- a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_msgprofiler.cpp
+++ /dev/null
@@ -1,210 +0,0 @@
-/*
- * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-//////////////////////////////////////////////////////////////////////////////////////////////////
-/// \ingroup tag_NSFramework
-/// \brief File defines FrameworkunifiedMsgProfiler class which keeps profiler information for message dispatcher
-//////////////////////////////////////////////////////////////////////////////////////////////////
-
-/* For FRAMEWORKUNIFIEDLOG*/
-#include <stdio.h>
-#include <time.h>
-#include <errno.h>
-
-#include <native_service/ns_logger_if.h>
-#include <native_service/ns_message_center_if.h>
-/* For PROTOCOL_DIS_MSGPROFILER */
-#include <native_service/frameworkunified_service_protocol.h>
-/* For FrameworkunifiedGetAppName */
-#include <native_service/frameworkunified_framework_if.h>
-
-#include <string>
-#include <vector>
-/* Required for OpenSender, SendMessage, McSend, McOpenSender */
-#include "ns_msg_queue.h"
-#include "frameworkunified_msgprofiler.h"
-
-BOOL FrameworkunifiedMsgProfiler::m_bMsgProfilerEnabled = FALSE;
-
-//////////////////////////////////////////
-// Constructor
-//////////////////////////////////////////
-// LCOV_EXCL_START 8: dead code
-FrameworkunifiedMsgProfiler::FrameworkunifiedMsgProfiler(const std::string &f_cAppName)
- : m_cAppName(f_cAppName),
- m_ui32TotalNoOfMsgsReceived(0),
- m_ui64MinMsgProcessingTime(720575940), // assign some big value
- m_ui64MaxMsgProcessingTime(0),
- m_ui64TotalMsgExecutionTime(0),
- m_ui64LastMsgReceivedTime(0),
- m_ui64AppInitTime(0),
- m_bLastMsgWasPrintProfile(FALSE) {
- AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 8: dead code
- m_ui64AppInitTime = GetClock();
-}
-// LCOV_EXCL_STOP
-
-//////////////////////////////////////////
-// Destructor
-//////////////////////////////////////////
-// LCOV_EXCL_START 8: dead code
-FrameworkunifiedMsgProfiler::~FrameworkunifiedMsgProfiler() {
- AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 8: dead code
-}
-// LCOV_EXCL_STOP
-
-//////////////////////////////////////////
-// Function : GetAppName
-//////////////////////////////////////////
-// LCOV_EXCL_START 8: dead code
-std::string FrameworkunifiedMsgProfiler::GetAppName() {
- AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 8: dead code
- return m_cAppName;
-}
-// LCOV_EXCL_STOP
-
-//////////////////////////////////////////
-// Function : MsgReceived
-//////////////////////////////////////////
-// LCOV_EXCL_START 8: dead code
-VOID FrameworkunifiedMsgProfiler::MsgReceived() {
- AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 8: dead code
- m_ui32TotalNoOfMsgsReceived++;
- m_ui64LastMsgReceivedTime = GetClock();
-}
-// LCOV_EXCL_STOP
-
-//////////////////////////////////////////
-// Function : MsgProcessed
-//////////////////////////////////////////
-// LCOV_EXCL_START 8: dead code
-VOID FrameworkunifiedMsgProfiler::MsgProcessed() {
- AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 8: dead code
- if (!m_bLastMsgWasPrintProfile) {
- UI_64 l_ui64MsgProcessedTime = GetClock() - m_ui64LastMsgReceivedTime;
-
- // set minimum execution time
- if (l_ui64MsgProcessedTime < m_ui64MinMsgProcessingTime) {
- m_ui64MinMsgProcessingTime = l_ui64MsgProcessedTime;
- }
-
- // set maximum execution time
- if (l_ui64MsgProcessedTime > m_ui64MaxMsgProcessingTime) {
- m_ui64MaxMsgProcessingTime = l_ui64MsgProcessedTime;
- }
-
- m_ui64TotalMsgExecutionTime += l_ui64MsgProcessedTime;
- } else {
- m_bLastMsgWasPrintProfile = FALSE;
- }
-
- // reset the last msg received time
- m_ui64LastMsgReceivedTime = 0;
-}
-// LCOV_EXCL_STOP
-
-//////////////////////////////////////////
-// Function : PrintProfileInfo
-//////////////////////////////////////////
-// LCOV_EXCL_START 8: dead code
-EFrameworkunifiedStatus FrameworkunifiedMsgProfiler::PrintProfileInfo(HANDLE f_hApp) {
- AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 8: dead code
- HANDLE l_hProfileQ = OpenSender(FRAMEWORKUNIFIED_NS_MSGPROFILERUTIL);
- FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __PRETTY_FUNCTION__, "Inside");
- CHAR l_cData[MAX_QUEUE_MSG_SIZE] = {};
- m_bLastMsgWasPrintProfile = TRUE;
- // don't consider this message which is profiler specific. So decreasing the msg count by 1
- m_ui32TotalNoOfMsgsReceived--;
- if (NULL != l_hProfileQ) {
- UI_64 l_ui64TimeSinceAppStart = (GetClock() - m_ui64AppInitTime) / 1000;
- UI_64 l_ui64AvgMsgProcessingTime = m_ui64TotalMsgExecutionTime / m_ui32TotalNoOfMsgsReceived;
-
- // MSG FORMAT: Tick, App/ThreadName, TotalMsgs, Freq(msgs/sec),
- // Min MsgProcessingtime(cs,ms),:, Avg MsgProcessingtime (cs,ms) ,:, Max MsgProcessingtime (cs,ms)
- snprintf(l_cData, MAX_QUEUE_MSG_SIZE, "%010lld, %-23s, %9d, %6.3f, "
- "%30lld,%-5lld ,:, %30lld,%-5lld ,:, %30lld,%-5lld\n",
- static_cast<long long int>(l_ui64TimeSinceAppStart), // NOLINT (readability/nolint)
- m_cAppName.c_str(),
- m_ui32TotalNoOfMsgsReceived,
- (F_64)m_ui32TotalNoOfMsgsReceived / (F_64)l_ui64TimeSinceAppStart,
- static_cast<long long int>(m_ui64MinMsgProcessingTime), // NOLINT (readability/nolint)
- static_cast<long long int>(m_ui64MinMsgProcessingTime), // NOLINT (readability/nolint)
- static_cast<long long int>(l_ui64AvgMsgProcessingTime), // NOLINT (readability/nolint)
- static_cast<long long int>(l_ui64AvgMsgProcessingTime), // NOLINT (readability/nolint)
- static_cast<long long int>(m_ui64MaxMsgProcessingTime), // NOLINT (readability/nolint)
- static_cast<long long int>(m_ui64MaxMsgProcessingTime)); // NOLINT (readability/nolint)
-
- SendMessage(l_hProfileQ, MAX_QUEUE_MSG_SIZE, l_cData);
-
- if (eFrameworkunifiedStatusOK == CloseSender(l_hProfileQ)) {
- l_hProfileQ = NULL;
- }
-
- // inform all childs to print msg profiler information.
- std::vector<std::string>::iterator l_itChildList = m_vChildNames.begin();
-
- HANDLE l_hChild = NULL;
- while (m_vChildNames.end() != l_itChildList) {
- if (!((*l_itChildList).empty())) {
- l_hChild = McOpenSender((*l_itChildList).c_str());
- if (NULL != l_hChild) {
- if (eFrameworkunifiedStatusOK != McSend(l_hChild, FrameworkunifiedGetAppName(f_hApp), PROTOCOL_DIS_MSGPROFILER, 0, NULL)) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __PRETTY_FUNCTION__, "Error sending PROTOCOL_DIS_MSGPROFILER to child");
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __PRETTY_FUNCTION__, "Msg PROTOCOL_DIS_MSGPROFILER sent to child");
- }
-
- McClose(l_hChild);
- l_hChild = NULL;
- }
- }
- l_itChildList++;
- }
- }
- FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __PRETTY_FUNCTION__, "Exiting");
- return eFrameworkunifiedStatusOK;
-}
-// LCOV_EXCL_STOP
-
-//////////////////////////////////////////
-// Function : AddChildName
-//////////////////////////////////////////
-// LCOV_EXCL_START 8: dead code
-VOID FrameworkunifiedMsgProfiler::AddChildName(const std::string &f_cChildName) {
- AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 8: dead code
- if (!f_cChildName.empty()) {
- m_vChildNames.push_back(f_cChildName);
- }
-}
-// LCOV_EXCL_STOP
-
-//////////////////////////////////////////
-// Function : GetClock
-//////////////////////////////////////////
-// LCOV_EXCL_START 8: dead code
-UI_64 FrameworkunifiedMsgProfiler::GetClock() {
- AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 8: dead code
- struct timespec tp;
-
- if (clock_gettime(CLOCK_MONOTONIC, &tp) == -1) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __PRETTY_FUNCTION__, "clock_gettime errno:%d", errno);
- return 0;
- }
- return (UI_64)tp.tv_sec * 1000 * 1000 + tp.tv_nsec / 1000;
-}
-// LCOV_EXCL_STOP
-
-// EOF
diff --git a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_multithreading.cpp b/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_multithreading.cpp
deleted file mode 100755
index 986f3b3..0000000
--- a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_multithreading.cpp
+++ /dev/null
@@ -1,531 +0,0 @@
-/*
- * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-///////////////////////////////////////////////////////////////////////////////
-/// \ingroup tag_NSFramework
-/// \brief Framework wrapper over the service directory interface APIs
-///
-///
-///
-///////////////////////////////////////////////////////////////////////////////
-
-#include <pthread.h>
-#include <errno.h>
-#include <string.h>
-#include <sys/prctl.h>
-#include <sys/resource.h>
-#include <sys/syscall.h>
-
-#include <native_service/frameworkunified_dispatcher.h>
-#include <native_service/frameworkunified_multithreading.h>
-#include <native_service/ns_utility.hpp>
-#include <native_service/ns_message_center_if.h>
-#include <native_service/frameworkunified_framework_if.h>
-#include <native_service/ns_system_mode.h>
-#include <native_service/ns_logger_if.h>
-#include <native_service/frameworkunified_sm_hsmframework.h>
-#include <native_service/frameworkunified_sm_framework_dispatch.h>
-
-#include <iostream>
-
-#ifdef DISPATCHER_PROFILER
-#include <boost/bind.hpp>
-#include "frameworkunified_msgprofiler.h"
-#endif
-
-#include "frameworkunified_framework_core.h"
-#include "frameworkunified_framework_utility.h"
-#include "frameworkunified_framework_internal.h"
-#include "frameworkunified_sm_multithreading_internal.h"
-
-__thread HANDLE responseWaitQ = NULL;
-
-////////////////////////////////////////////////////////////////////////////////////////////
-/// IsValidWaitBarrier
-////////////////////////////////////////////////////////////////////////////////////////////
-bool IsValidWaitBarrier(int wbret) {
- return (PTHREAD_BARRIER_SERIAL_THREAD == wbret) ||
- (0 == wbret);
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////
-/// DestroyThread
-////////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus DestroyThread(HANDLE hApp) {
- // terminates the dispatcher loop to destroy the thread
- if (responseWaitQ != NULL) {
- /**
- * @todo
- * The responseWaitQ is set in the FrameworkunifiedInvokeSync and is closed in the callback process (DestroyThread) of the FrameworkunifiedDestroyChildThread.
- * Therefore, the responseWaitQ is not closed when FrameworkunifiedInvokeSync is used on the parent.
- */
- McClose(responseWaitQ);
- responseWaitQ = NULL;
- }
- return eFrameworkunifiedStatusExit;
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////
-/// setChildThreadSched
-////////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus setChildThreadSched(EFrameworkunifiedSchedPolicy policy, SI_32 priority) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
- struct sched_param param;
- int get_policy, set_policy;
- int set_priority;
-
- if (pthread_getschedparam(pthread_self(), &get_policy, &param) != 0) {
- // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: pthread_getschedparam errno:%d", errno);
- // LCOV_EXCL_BR_STOP
- return eFrameworkunifiedStatusFail;
- }
-
- if (policy == eFrameworkunifiedSchedPolicyInherit) {
- set_policy = get_policy;
- } else {
- if (policy == eFrameworkunifiedSchedPolicyFIFO) {
- set_policy = SCHED_FIFO;
- } else if (policy == eFrameworkunifiedSchedPolicyRR) {
- set_policy = SCHED_RR;
- } else {
- set_policy = SCHED_OTHER;
- }
- }
-
- if (priority == INHERIT_PARENT_THREAD_PRIO) {
- if (get_policy != set_policy) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "Warning: Change policy(%d-%d) but inherit priority", get_policy, set_policy);
-
- if (set_policy == SCHED_OTHER) {
- set_priority = 0;
- } else {
- set_priority = sched_get_priority_min(set_policy);
- }
- } else {
- set_priority = param.sched_priority;
- }
- } else {
- set_priority = priority;
- }
-
- switch (set_policy) {
- case SCHED_OTHER:
- param.sched_priority = 0;
- if (pthread_setschedparam(pthread_self(), SCHED_OTHER, &param) != 0) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: pthread_setschedparam errno:%d", errno);
- eStatus = eFrameworkunifiedStatusFail;
- } else {
- if (setpriority(PRIO_PROCESS, static_cast<int>(syscall(__NR_gettid)), set_priority) != 0) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: setpriority errno:%d", errno);
- eStatus = eFrameworkunifiedStatusFail;
- }
- }
- break;
-
- case SCHED_FIFO:
- case SCHED_RR:
- param.sched_priority = set_priority;
- if (pthread_setschedparam(pthread_self(), set_policy, &param) != 0) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: pthread_setschedparam errno:%d", errno);
- eStatus = eFrameworkunifiedStatusFail;
- }
- break;
- }
-
- return eStatus;
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////
-/// child_thread_proc
-////////////////////////////////////////////////////////////////////////////////////////////
-void *child_thread_proc(void *args) {
- if (args == NULL) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "args is NULL");
- return NULL;
- }
- PCData pcdata = *reinterpret_cast< PCData * >(args); // Create a local copy of data
-
- try {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
- HANDLE hApp = NULL;
-
- if (eFrameworkunifiedStatusOK == (eStatus = FrameworkunifiedCreateDispatcherChild(hApp,
- pcdata.childName.c_str(),
- pcdata.parentName.c_str()))) {
- // LCOV_EXCL_BR_START 200: If FrameworkunifiedCreateDispatcherChild return eFrameworkunifiedStatusOK, hApp would also be valid.
- if (frameworkunifiedCheckValidAppHandle(hApp)) {
- // LCOV_EXCL_BR_STOP
- THApp hChildApp(hApp);
-
- const FrameworkunifiedProtocolCallbackHandler pcbhs[] = { { SYSTEM_ON_INITIALIZATION, pcdata.initFn },
- { SYSTEM_ON_SHUTDOWN, pcdata.shdnFn },
- { SYSTEM_ON_DESTROY, DestroyThread }
- }; // LCOV_EXCL_BR_LINE 11:except branch
-
- if (eFrameworkunifiedStatusOK != FrameworkunifiedAttachCallbacksToDispatcher(hChildApp,
- pcdata.parentName.c_str(),
- &pcbhs[ 0 ],
- static_cast<UI_32>(_countof(pcbhs)))) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__,
- "Error: Attaching child callbacks to dispatcher %s", pcdata.childName.c_str());
- }
-
- char thread_name[16];
- strncpy(thread_name, pcdata.childName.c_str(), sizeof(thread_name));
- prctl(PR_SET_NAME, thread_name);
- thread_name[15] = '\0';
-
- setChildThreadSched(pcdata.schedPolicy, pcdata.schedPriority);
-
- *pcdata.childStatus = eFrameworkunifiedStatusOK;
- if (IsValidWaitBarrier(pthread_barrier_wait(pcdata.barrier))) {
- RunChildDispatcher(hChildApp);
- }
- } else {
- // LCOV_EXCL_START 200: If FrameworkunifiedCreateDispatcherChild return eFrameworkunifiedStatusOK, hApp would also be valid.
- AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "hApp is NULL");
- // LCOV_EXCL_STOP
- }
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "FrameworkunifiedCreateDispatcherChild error, status=%d", eStatus);
-
- *pcdata.childStatus = eFrameworkunifiedStatusFail;
- pthread_barrier_wait(pcdata.barrier);
- }
- } catch (const THApp::Exception &) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: Failed to create child %s", pcdata.childName.c_str());
- }
-
- return NULL;
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////
-/// CreateChildThread
-////////////////////////////////////////////////////////////////////////////////////////////
-HANDLE CreateChildThread(HANDLE hApp, PCSTR childName, CbFuncPtr CbInitialize, CbFuncPtr CbShutdown,
- const FrameworkunifiedChildThreadAttr *attr, CbFuncPtr CbCreateStateMachine) {
- HANDLE hChildQ = NULL;
- pthread_attr_t tAttr;
- pthread_attr_t *pAttr = NULL;
- SI_32 l_iThrCreate = 0;
- EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
-
- if (frameworkunifiedCheckValidAppHandle(hApp) && NULL != childName && strlen(childName) < LIMIT_NAME_SIZE_APP &&
- NULL != CbInitialize && NULL != CbShutdown && NULL != attr) {
- if (attr->schedPolicy < eFrameworkunifiedSchedPolicyInherit || attr->schedPolicy >= eFrameworkunifiedSchedPolicyMAX) {
- l_eStatus = eFrameworkunifiedStatusInvldParam;
- } else {
- if (EOK == pthread_attr_init(&tAttr)) {
- if (EOK != pthread_attr_setinheritsched(&tAttr, PTHREAD_INHERIT_SCHED)) {
- l_eStatus = eFrameworkunifiedStatusFail;
- } else {
- pAttr = &tAttr;
- }
- }
- }
-
- if (eFrameworkunifiedStatusOK == l_eStatus) {
- pthread_barrier_t barrier;
- if (EOK == pthread_barrier_init(&barrier, NULL, 2)) {
- PCData pc(&barrier, &l_eStatus, FrameworkunifiedGetAppName(hApp), childName, CbInitialize, CbShutdown,
- attr->schedPolicy, attr->schedPriority, CbCreateStateMachine);
- pthread_t childThread = 0;
-
- if (NULL != CbCreateStateMachine) {
- l_iThrCreate = pthread_create(&childThread, pAttr, child_hsm_thread_proc, &pc);
- } else {
- l_iThrCreate = pthread_create(&childThread, pAttr, child_thread_proc, &pc);
- }
-
- if (EOK == l_iThrCreate) {
- if (IsValidWaitBarrier(pthread_barrier_wait(&barrier))) {
- if (eFrameworkunifiedStatusOK == l_eStatus) {
- hChildQ = McOpenSenderChild(childName, childThread);
- }
- }
- }
- pthread_barrier_destroy(&barrier);
- }
- }
-#ifdef DISPATCHER_PROFILER
- if (TRUE == FrameworkunifiedMsgProfiler::m_bMsgProfilerEnabled) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- if (NULL != pApp->m_pFrameworkunifiedMsgProfiler) {
- pApp->m_pFrameworkunifiedMsgProfiler->AddChildName(childName);
- }
- }
-#endif
- }
- return hChildQ;
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////
-/// CreateChildThreadAttrInit
-////////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus CreateChildThreadAttrInit(FrameworkunifiedChildThreadAttr *attr) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (attr == NULL) {
- eStatus = eFrameworkunifiedStatusNullPointer;
- } else {
- memset(attr, 0, sizeof(FrameworkunifiedChildThreadAttr));
- attr->schedPolicy = eFrameworkunifiedSchedPolicyInherit;
- attr->schedPriority = INHERIT_PARENT_THREAD_PRIO;
- }
-
- return eStatus;
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////
-/// CreateChildThreadAttrSetSched
-////////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus CreateChildThreadAttrSetSched(FrameworkunifiedChildThreadAttr *attr, EFrameworkunifiedSchedPolicy policy, SI_32 priority) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (attr == NULL) {
- eStatus = eFrameworkunifiedStatusNullPointer;
- } else {
- if (policy < eFrameworkunifiedSchedPolicyInherit || policy >= eFrameworkunifiedSchedPolicyMAX) {
- eStatus = eFrameworkunifiedStatusInvldParam;
- } else {
- attr->schedPolicy = policy;
- attr->schedPriority = priority;
- }
- }
-
- return eStatus;
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedCreateChildThreadAttrInit
-////////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedCreateChildThreadAttrInit(FrameworkunifiedChildThreadAttr *attr) {
- return CreateChildThreadAttrInit(attr);
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedCreateChildThreadAttrSetSched
-////////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedCreateChildThreadAttrSetSched(FrameworkunifiedChildThreadAttr *attr, EFrameworkunifiedSchedPolicy policy, SI_32 priority) {
- return CreateChildThreadAttrSetSched(attr, policy, priority);
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedCreateChildThread
-////////////////////////////////////////////////////////////////////////////////////////////
-HANDLE FrameworkunifiedCreateChildThread(HANDLE hApp, PCSTR childName, CbFuncPtr CbInitialize
- , CbFuncPtr CbShutdown) {
- HANDLE hChildQ = NULL;
- FrameworkunifiedChildThreadAttr attr;
-
- if (frameworkunifiedCheckValidAppHandle(hApp) && NULL != childName && strlen(childName) < LIMIT_NAME_SIZE_APP &&
- NULL != CbInitialize && NULL != CbShutdown) {
- CreateChildThreadAttrInit(&attr);
- hChildQ = CreateChildThread(hApp, childName, CbInitialize, CbShutdown, &attr, NULL);
- }
-
- return hChildQ;
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedCreateChildThreadWithPriority
-////////////////////////////////////////////////////////////////////////////////////////////
-HANDLE FrameworkunifiedCreateChildThreadWithPriority(HANDLE hApp, PCSTR childName, CbFuncPtr CbInitialize
- , CbFuncPtr CbShutdown, SI_32 schedPrio) {
- HANDLE hChildQ = NULL;
- FrameworkunifiedChildThreadAttr attr;
-
- if (frameworkunifiedCheckValidAppHandle(hApp) && NULL != childName && strlen(childName) < LIMIT_NAME_SIZE_APP &&
- NULL != CbInitialize && NULL != CbShutdown) {
- CreateChildThreadAttrInit(&attr);
- CreateChildThreadAttrSetSched(&attr, eFrameworkunifiedSchedPolicyFIFO, schedPrio);
- hChildQ = CreateChildThread(hApp, childName, CbInitialize, CbShutdown, &attr, NULL);
- }
-
- return hChildQ;
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedCreateChildThreadWithAttribute
-////////////////////////////////////////////////////////////////////////////////////////////
-HANDLE FrameworkunifiedCreateChildThreadWithAttribute(HANDLE hApp, PCSTR childName, CbFuncPtr CbInitialize
- , CbFuncPtr CbShutdown, const FrameworkunifiedChildThreadAttr *attr) {
- HANDLE hChildQ = NULL;
-
- if (frameworkunifiedCheckValidAppHandle(hApp) && NULL != childName && strlen(childName) < LIMIT_NAME_SIZE_APP &&
- NULL != CbInitialize && NULL != CbShutdown && NULL != attr) {
- hChildQ = CreateChildThread(hApp, childName, CbInitialize, CbShutdown, attr, NULL);
- }
-
- return hChildQ;
-}
-
-
-////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedDestroyChildThread
-////////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedDestroyChildThread(HANDLE hApp, HANDLE hChildQ) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (frameworkunifiedCheckValidAppHandle(hApp) && NULL != hChildQ) {
- eStatus = FrameworkunifiedSendChild(hApp, hChildQ, PROTOCOL_THREAD_DESTROY, 0, NULL);
-
- if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedJoinChild(hChildQ))) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "FrameworkunifiedJoinChild Error. status: %d", eStatus);
- }
-
- // close the child message queue handle
- eStatus = McClose(hChildQ);
- hChildQ = NULL;
- } else {
- eStatus = eFrameworkunifiedStatusInvldParam;
- }
-
- return eStatus;
-}
-
-
-////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedStartChildThread
-////////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedStartChildThread(HANDLE hApp, HANDLE hChildQ, UI_32 length, PCVOID data) {
- return FrameworkunifiedSendChild(hApp, hChildQ, SYSTEM_ON_INITIALIZATION, length, data);
-}
-
-
-////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedStopChildThread
-////////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedStopChildThread(HANDLE hApp, HANDLE hChildQ, UI_32 length, PCVOID data) {
- return FrameworkunifiedSendChild(hApp, hChildQ, SYSTEM_ON_SHUTDOWN, length, data);
-}
-
-
-////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedSendChild
-////////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedSendChild(HANDLE hApp, HANDLE hChildQ, UI_32 iCmd, UI_32 length, PCVOID data) {
- if (frameworkunifiedCheckValidAppHandle(hApp)) {
- CFrameworkunifiedFrameworkApp *pApp = reinterpret_cast< CFrameworkunifiedFrameworkApp * >(hApp);
- return McSend(hChildQ, &pApp->cAppName[ 0 ], iCmd, length, data);
- }
- return eFrameworkunifiedStatusInvldHandle;
-}
-
-
-////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedSendParent
-////////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedSendParent(HANDLE hChildApp, UI_32 iCmd, UI_32 length, PCVOID data) {
- if (frameworkunifiedCheckValidAppHandle(hChildApp)) {
- CFrameworkunifiedFrameworkApp *pApp = reinterpret_cast< CFrameworkunifiedFrameworkApp * >(hChildApp);
- return McSend(pApp->hParentSndMsgQ, &pApp->cAppName[ 0 ], iCmd, length, data);
- }
- return eFrameworkunifiedStatusInvldHandle;
-}
-
-
-
-////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedCreateDispatcherChild
-////////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedCreateDispatcherChild(HANDLE &hChildApp, // NOLINT (readability/nolint)
- PCSTR childName,
- PCSTR parentName) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if ((NULL != childName) && (NULL != parentName) && (LIMIT_NAME_SIZE_APP > strlen(parentName)) &&
- (LIMIT_NAME_SIZE_APP > strlen(parentName))) {
- if (eFrameworkunifiedStatusOK == (eStatus = FrameworkunifiedCreateDispatcher(childName, hChildApp, TRUE))) {
- // LCOV_EXCL_BR_START 200: If FrameworkunifiedCreateDispatcher return eFrameworkunifiedStatusOK, hChildApp would also be valid.
- if (frameworkunifiedCheckValidAppHandle(hChildApp)) {
- // LCOV_EXCL_BR_STOP
- CFrameworkunifiedFrameworkApp *pApp = reinterpret_cast< CFrameworkunifiedFrameworkApp * >(hChildApp);
-
- memset(pApp->cParentAppName, 0, sizeof(pApp->cParentAppName));
- memcpy(pApp->cParentAppName, parentName, strlen(parentName));
-
- pApp->hParentSndMsgQ = McOpenSender(parentName);
- if (NULL == pApp->hParentSndMsgQ) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "McOpenSender is NULL");
- eStatus = eFrameworkunifiedStatusNullPointer;
- return eStatus;
- }
- pApp->uiSessionId = THREAD_SESSION_ID;
- } else {
- // LCOV_EXCL_START 200: If FrameworkunifiedCreateDispatcher return eFrameworkunifiedStatusOK, hChildApp would also be valid.
- AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "hChildApp is NULL");
- eStatus = eFrameworkunifiedStatusNullPointer;
- // LCOV_EXCL_STOP
- }
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "FrameworkunifiedCreateDispatcher error, status=%d", eStatus);
- }
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Invalid parameter received");
- eStatus = eFrameworkunifiedStatusInvldParam;
- }
- return eStatus;
-}
-
-
-////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedJoinChild
-////////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedJoinChild(HANDLE hChildApp) {
- return McJoinChild(hChildApp);
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedGetChildThreadPriority
-////////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedGetChildThreadPriority(HANDLE hChildApp, PSI_32 threadPrio) {
- return McGetChildThreadPriority(hChildApp, threadPrio);
-}
-
-EFrameworkunifiedStatus RunChildDispatcher(HANDLE hChildApp) {
- EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
- int efd;
- // LCOV_EXCL_BR_START 6: RunChildDispatcher is a internal function, hChildApp would checked in child_thread_proc.
- if (frameworkunifiedCheckValidAppHandle(hChildApp)) {
- // LCOV_EXCL_BR_STOP
-#ifdef DISPATCHER_PROFILER
- // Get the application handle
- CFrameworkunifiedFrameworkApp *pApp = reinterpret_cast< CFrameworkunifiedFrameworkApp * >(hChildApp);
- if (TRUE == FrameworkunifiedMsgProfiler::m_bMsgProfilerEnabled) {
- pApp->m_pFrameworkunifiedMsgProfiler = new(std::nothrow) FrameworkunifiedMsgProfiler(FrameworkunifiedGetAppName(hChildApp));
- if (NULL != pApp->m_pFrameworkunifiedMsgProfiler) {
- FrameworkunifiedAttachChildMsgProfilerCallbacksDispatcher(hChildApp);
- }
- }
-#endif
- FrameworkunifiedGetDispatcherFD(hChildApp, &efd);
-
- while (eFrameworkunifiedStatusExit != l_eStatus) {
- l_eStatus = frameworkunifiedFdHandler(hChildApp, efd);
- }
- } else {
- // LCOV_EXCL_START 6: RunChildDispatcher is a internal function, hChildApp would checked in child_thread_proc.
- AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
- l_eStatus = eFrameworkunifiedStatusInvldHandle;
- // LCOV_EXCL_STOP
- }
-
- return l_eStatus;
-}
diff --git a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_service_if.cpp b/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_service_if.cpp
deleted file mode 100755
index dccffa8..0000000
--- a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_service_if.cpp
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-////////////////////////////////////////////////////////////////////////////////
-/// \ingroup tag_HMI_CWORD77_Controller
-/// \brief
-///
-////////////////////////////////////////////////////////////////////////////////
-
-#include <native_service/frameworkunified_service_if.h>
-#include <string>
-//////////////////////////////////////////
-/// Function : CFrameworkunifiedServiceInterface
-//////////////////////////////////////////
-CFrameworkunifiedServiceInterface::CFrameworkunifiedServiceInterface() {
-}
-//////////////////////////////////////////
-/// Function : ~CFrameworkunifiedServiceInterface
-//////////////////////////////////////////
-CFrameworkunifiedServiceInterface::~CFrameworkunifiedServiceInterface() {
-}
-//////////////////////////////////////////
-/// Function : OpenService
-//////////////////////////////////////////
-HANDLE CFrameworkunifiedServiceInterface::OpenService(const HANDLE f_hApp, std::string f_sServiceName) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "+");
- HANDLE l_hService = NULL;
- if (NULL == (l_hService = FrameworkunifiedOpenService(f_hApp, f_sServiceName.c_str()))) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, " Failed to open Service [%s]", f_sServiceName.c_str());
- }
- FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "-");
- return l_hService;
-}
-//////////////////////////////////////////
-/// Function : CloseService
-//////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedServiceInterface::CloseService(const HANDLE f_hApp, const HANDLE f_hService) {
- EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusFail;
- FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "+");
- if ((NULL == f_hApp) || (NULL == f_hService)) {
- return eFrameworkunifiedStatusInvldParam;
- }
-
- if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedCloseService(f_hApp, f_hService))) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "CloseService Failed");
- }
-
- FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "-");
- return l_eStatus;
-}
-//////////////////////////////////////////
-/// Function : OpenSession
-//////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedServiceInterface::OpenSession(const HANDLE f_hApp, UI_32 f_uisessionType) {
- EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusFail;
- FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "+");
- if (NULL == f_hApp) {
- return eFrameworkunifiedStatusInvldParam;
- }
-
- l_eStatus = FrameworkunifiedOpenSessionWithData(f_hApp, (PVOID)&f_uisessionType, sizeof(UI_32));
- if (eFrameworkunifiedStatusOK != l_eStatus) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "FrameworkunifiedOpenSession Failed, eFrameworkunifiedStatusOK = 0x%x, l_eStatus = 0x%x", eFrameworkunifiedStatusOK,
- l_eStatus);
- }
- FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "-");
- return l_eStatus;
-}
-//////////////////////////////////////////
-/// Function : OpenSessionAcknowledge
-//////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedServiceInterface::OpenSessionAcknowledge(const HANDLE f_hApp, HANDLE &hSession) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "+");
- EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
- FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "-");
- return l_eStatus;
-}
-//////////////////////////////////////////
-/// Function : CloseSession
-//////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedServiceInterface::CloseSession(const HANDLE f_hService, const HANDLE f_hSession) {
- EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
- FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "+");
- if ((NULL == f_hService) || (NULL == f_hSession)) {
- return eFrameworkunifiedStatusInvldParam;
- }
-
- if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedCloseSession(f_hService, f_hSession))) {
- FRAMEWORKUNIFIEDLOG0(ZONE_NS_ERR, __FUNCTION__, " Failed to send session close request");
- } else {
- FRAMEWORKUNIFIEDLOG0(ZONE_NS__CWORD77_, __FUNCTION__, " Session close request sent successfully");
- }
- FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "-");
- return l_eStatus;
-}
-//////////////////////////////////////////
-/// Function : CloseSessionAcknowledge
-//////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedServiceInterface::CloseSessionAcknowledge(const HANDLE hClient) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "+");
- EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
- CloseSessionAck tCloseAck;
- if (NULL == hClient) {
- return eFrameworkunifiedStatusNullPointer;
- }
- if (eFrameworkunifiedStatusOK == (l_eStatus = FrameworkunifiedGetMsgDataOfSize(hClient, &tCloseAck, sizeof(tCloseAck)))) {
- l_eStatus = tCloseAck.eStatus;
- } else {
- FRAMEWORKUNIFIEDLOG0(ZONE_NS_ERR,
- __FUNCTION__,
- "Failed to get message data:%x", l_eStatus);
- }
- FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "-");
- return l_eStatus;
-}
diff --git a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_thread_priority.cpp b/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_thread_priority.cpp
deleted file mode 100755
index 88b5c50..0000000
--- a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_thread_priority.cpp
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-//////////////////////////////////////////////////////////////////////////////////////////////////
-/// \ingroup
-/// \brief <INSERT INFO HERE>.
-///
-//////////////////////////////////////////////////////////////////////////////////////////////////
-#include <stdlib.h>
-#include <string.h>
-
-#include <native_service/frameworkunified_thread_priority.h>
-#include <native_service/ns_logger_if.h>
-
-#include <string>
-
-char *priopts[] = {
-#define THREAD 0
- const_cast<PSTR>("thrd"),
- NULL
-};
-
-namespace frameworkunified {
-namespace framework {
-
-CFrameworkunifiedThreadPriorities::TThreadPriorityList CFrameworkunifiedThreadPriorities::ms_mapThreadPritories;
-
-//////////////////////////////////////////
-// Constructor
-//////////////////////////////////////////
-CFrameworkunifiedThreadPriorities::CFrameworkunifiedThreadPriorities() { // LCOV_EXCL_START 200:only use static function of this class
- AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
-}
-// LCOV_EXCL_STOP
-
-//////////////////////////////////////////
-// Destructor
-//////////////////////////////////////////
-CFrameworkunifiedThreadPriorities::~CFrameworkunifiedThreadPriorities() { // LCOV_EXCL_START 200:only use static function of this class
- AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
-}
-// LCOV_EXCL_STOP
-
-//////////////////////////////////////////
-// GetPriority
-//////////////////////////////////////////
-SI_32 CFrameworkunifiedThreadPriorities::GetPriority(const std::string &f_cThreadName) {
- SI_32 l_si32Prio = FRAMEWORKUNIFIED_PRIORITY_NOT_FOUND;
- ThreadPrioMapIter iter = ms_mapThreadPritories.find(f_cThreadName);
- if (iter != ms_mapThreadPritories.end() && (FRAMEWORKUNIFIED_PRIORITY_NOT_FOUND == l_si32Prio)) {
- l_si32Prio = iter->second;
- }
-
- return l_si32Prio;
-}
-
-//////////////////////////////////////////
-// AddPriority
-//////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedThreadPriorities::AddPriority(const std::string &f_cThreadName, SI_32 f_si32Priority) {
- ms_mapThreadPritories[f_cThreadName] = f_si32Priority;
- return eFrameworkunifiedStatusOK;
-}
-
-//////////////////////////////////////////
-// PrintPriorites
-//////////////////////////////////////////
-VOID CFrameworkunifiedThreadPriorities::PrintPriorites() { // LCOV_EXCL_START 7: debug code
- AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
- ThreadPrioMapIter iter = ms_mapThreadPritories.begin();
- for (; iter != ms_mapThreadPritories.end(); iter++) {
- std::string name = iter->first;
- FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, "Thread name: %s Priority: %d", name.data(), iter->second);
- }
-}
-// LCOV_EXCL_STOP
-
-//////////////////////////////////////////
-// ParseThreadArguments
-//////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedThreadPriorities::ParseThreadArguments(PCHAR f_cArgumentValue) {
- EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
- PCHAR l_cData = NULL;
- PSTR l_cOptions;
- PSTR l_cValue;
- PCHAR saveptr;
-
- if (NULL != f_cArgumentValue) {
- l_cOptions = f_cArgumentValue;
- FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, "args of -p: %s", l_cOptions); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
-
- while (*l_cOptions != '\0' && (eFrameworkunifiedStatusOK == l_eStatus)) {
- switch (getsubopt(&l_cOptions, priopts, &l_cValue)) {
- case THREAD: {
- if (l_cValue == NULL) {
- l_eStatus = eFrameworkunifiedStatusFail;
- } else {
- std::string l_cName("");
- std::string l_cPriority(""); // LCOV_EXCL_BR_LINE 11: except branch
- int at = static_cast<int>(frameworkunified::framework::args::name);
-
- l_cData = strtok_r(l_cValue, ":", &saveptr); // NOLINT (readability/nolint)
- while (NULL != l_cData) {
- switch (at) {
- case frameworkunified::framework::args::name:
- l_cName = l_cData;
- break;
- case frameworkunified::framework::args::priority:
- l_cPriority = l_cData;
- break;
- default:
- break;
- }
-
- if (!l_cName.empty() && !l_cPriority.empty()) {
- frameworkunified::framework::CFrameworkunifiedThreadPriorities::AddPriority(l_cName, atoi(l_cPriority.data()));
- at = static_cast<int>(frameworkunified::framework::args::name);
- l_cName.clear();
- l_cPriority.clear();
- } else {
- at++;
- }
-
- l_cData = strtok_r(NULL, ":", &saveptr); // NOLINT (readability/nolint)
- }
- }
- break;
- }
- default: {
- l_eStatus = eFrameworkunifiedStatusFail;
- break;
- }
- }
- }
- }
- return l_eStatus;
-}
-
-} // namespace framework
-}; // namespace frameworkunified
-/// EOF
-
-
diff --git a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_timer.cpp b/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_timer.cpp
deleted file mode 100755
index 0663b85..0000000
--- a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_timer.cpp
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-#include <native_service/frameworkunified_timer.h>
-#include <native_service/frameworkunified_framework_if.h>
-#include <native_service/ns_timer_if.h>
-#include "frameworkunified_framework_core.h"
-
-const UI_32 TIMER_CALLBACK_CMD_ID = 42; // The answer to life, the universe, and everything
-const PCSTR TIMER_SERVICE_NAME = "TIMER";
-
-
-HANDLE FrameworkunifiedAttachTimerCallback(HANDLE hApp, UI_32 initMS, UI_32 repeatMS, CbFuncPtr CbFn) {
- HANDLE timer = NULL;
-
- if ((frameworkunifiedCheckValidAppHandle(hApp)) && (NULL != CbFn)) {
- FrameworkunifiedAttachCallbackToDispatcher(hApp, TIMER_SERVICE_NAME, TIMER_CALLBACK_CMD_ID, CbFn);
-
- CFrameworkunifiedFrameworkApp *pApp = const_cast<CFrameworkunifiedFrameworkApp *>(reinterpret_cast<const CFrameworkunifiedFrameworkApp *>(hApp));
- NSTimerInfo ti = { WholeSeconds(initMS),
- MSToNS(RemainderMs(initMS)),
- TIMER_CALLBACK_CMD_ID,
- WholeSeconds(repeatMS),
- MSToNS(RemainderMs(repeatMS))
- };
- timer = NS_TimerCreate(ti, CALLBACK_MESSAGE, pApp->hAppSndMsgQ);
- }
-
- return timer;
-}
-
-EFrameworkunifiedStatus FrameworkunifiedDetachTimerCallback(HANDLE hApp, HANDLE hTimer) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (frameworkunifiedCheckValidAppHandle(hApp) && NULL != hTimer) {
- EFrameworkunifiedStatus sDel = NS_TimerDelete(hTimer);
- hTimer = NULL;
-
- EFrameworkunifiedStatus sDet = FrameworkunifiedDetachCallbackFromDispatcher(hApp,
- TIMER_SERVICE_NAME,
- TIMER_CALLBACK_CMD_ID);
-
- // out of coverage
- // Since the above frameworkunifiedCheckValidAppHandle(hApp) && NULL != hTimer have been confirmed,
- // the condition will not be satisfied.
- if (eFrameworkunifiedStatusOK != sDel || eFrameworkunifiedStatusOK != sDet) {
- eStatus = eFrameworkunifiedStatusFail;
- }
- } else {
- eStatus = eFrameworkunifiedStatusInvldParam;
- }
- return eStatus;
-}
diff --git a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/makefile_PosixBasedOS001 b/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/makefile_PosixBasedOS001
deleted file mode 100755
index 025ec70..0000000
--- a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/makefile_PosixBasedOS001
+++ /dev/null
@@ -1,214 +0,0 @@
-#
-# @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-#
-# Standard Module Makefile version 2.0
-#
-
-# Name of the componet (team/domain prefix '_' component name)
-COMPONENT_NAME = NS_FrameworkCore
-
-ifndef PRJ_ROOT
-export PRJ_ROOT = $(CURDIR)/../
-endif
-include $(PRJ_ROOT)cfg/depends.mk
-
-# Name of the componet (team/domain prefix '_' component name)
-# This must be the same as the RTC Component name and Eclipse Project Name
-COMPONENT_NAME = NS_FrameworkCore
-
-
-# Additive Compile Flags (Flags from initiating make process will still apply)
-DEFS += -D DISPATCHER_PROFILER
-
-# Set local includes and then the reference includes (priority order determines search path)
-# Default pattern are any configuration includes (which would be things like PosixBasedOS001), local (Team) component directories,
-# dependencies includes (other teams)
-# Local (current component references should be in the form of
-# $(CC_IFLAG)$(TEAM_ROOT)$(COMPONENT_NAME)/directory
-# Example your public include directory would be
-# $(CC_IFLAG)$(TEAM_ROOT)$(COMPONENT_NAME)/inc
-# Team references should only be to other's public includes such as
-# $(CC_IFLAG)$(TEAM_ROOT)NS_MessageCenter/inc
-# Global (non-team) references should be only to other's public includes such
-# these are found in the depends include file and captured in the (DEPENDS_INCLUDES) variable
-INCLUDES = \
- $(CFG_INCS) \
- $(CC_IFLAG)./ \
- $(CC_IFLAG)$(TEAM_ROOT)NS_MessageQueue/inc \
- $(CC_IFLAG)$(TEAM_ROOT)NS_MessageCenter/inc \
- $(CC_IFLAG)$(TEAM_ROOT)NS_UtilityCenter/inc \
- $(CC_IFLAG)$(TEAM_ROOT)$(COMPONENT_NAME)/inc \
- $(CC_IFLAG)$(TEAM_ROOT)$(COMPONENT_NAME)/inc/statemachine \
- $(DEPENDS_INCLUDES) \
-
-# Libraries should be exported to the Domain Root. However if there is a
-# local static library (3rd Party) go ahead and add it here.
-LIB_PATHS += \
- $(DEPENDS_LIB_PATHS) \
-
-
-
-# Define binary outputs. These can be libraries or executables.
-# Name a variable for each deliverable. Suffixes should be
-# EXEC - For Executables -> output to the bin directory
-#TIME_EXEC = $(BIN_PATH)time
-# LIB - For Static Libraries -> output to lib directory with specific naming
-#MATH_LIB = $(LIB_PATH)$(LIB_PREFIX)math.$(LIB_EXT)
-# SLIB - For Shared Objects
-#FRMWRK_SLIB = $(SLIB_PATH)frmwrk.$(SO_EXT)
-# LIB - Define the static library for Message Queue
-#
-#
-ifdef DYNAMIC
- COMPONENT_LIB = $(SLIB_PATH)$(LIB_PREFIX)$(COMPONENT_NAME)$(DEBUG_EXT).$(SO_EXT)
-else
- COMPONENT_LIB = $(LIB_PATH)$(LIB_PREFIX)$(COMPONENT_NAME)$(DEBUG_EXT).$(LIB_EXT)
-endif
-
-
-## Sources Section
-
-# Define Library & Executable Sources (on a per deliverable basis)
-# This includes sources located in subdirectories.
-
-# Define generic line that pulls all c, cc, cpp files
-# since your in the src folder is pull only files from there
-COMPONENT_SRCS = \
- $(wildcard *.c) \
- $(wildcard *.cpp)
-
-# Define sources that my not be local to your component
-# here, you can define indivial files or wildcard from
-# a different folder.
-NON_LOCAL_SRCS = \
- $(wildcard statemachine/*.cpp)
-
-# List of all sources to be built. Can be assembled from the other defintitions.
-# This only defines sources for the current directory, so if there are subdirectories
-# those are not included. (Those are found in simple subdirectory makefiles that only
-# direct the building of sources, but no linking into a binary)
-SOURCES = \
- $(COMPONENT_SRCS) \
-
-
-#
-# Convert the source files to object files with correct folder location.
-#
-#
-C_LANG_OBJECTS = $(addprefix $(BLD_PATH),$(addsuffix .$(OBJ_EXT),$(basename $(filter %.c ,$(SOURCES) ) ) ) )
-CPP_LANG_OBJECTS = $(addprefix $(BLD_PATH),$(addsuffix .$(OBJ_EXT),$(basename $(filter %.cpp %.cc %.cxx,$(SOURCES) ) ) ) )
-
-
-# List of all sources to be generated. Can be assembled from the other defintitions.
-OBJECTS = \
- $(C_LANG_OBJECTS) \
- $(CPP_LANG_OBJECTS)
-
-# assuming all objects should be included in the library.
-ALL_OBJECTS = $(addprefix $(BLD_PATH),$(addsuffix .$(OBJ_EXT),$(notdir $(basename $(NON_LOCAL_SRCS) )) ) ) \
- $(OBJECTS)
-
-# All headers that are dependencies. Wildcard is easy to pickup local headers.
-# This is only to automate the rebuilding, all builds on the servers are cleans
-# So this is not a huge deal when building on a component level.
-HEADERS = \
- $(wildcard *.h) \
- $(wildcard $(TEAM_ROOT)$(COMPONENT_NAME)/inc/*.h) \
- $(wildcard $(TEAM_ROOT)NativeServices/inc/*.h) \
- $(wildcard $(TEAM_ROOT)NativeServices/inc/native/*.h) \
- $(wildcard $(TEAM_ROOT)NativeServices/inc/framework/*.h) \
-
-LIBRARIES = \
- $(COMPONENT_LIB) \
-
-ifdef DYNAMIC
- DYNAMIC_LIBS += \
- NS_MessageCenter$(DEBUG_EXT) \
- NS_ConfigParser$(DEBUG_EXT) \
- NS_NPServiceIf$(DEBUG_EXT) \
- NS_Timer$(DEBUG_EXT)
-else
- STATIC_LIBS +=
-endif
-
-# Make targets
-# Standard
-all: banner module_dirs subdirs local library binary
-
-debug:
- $(MAKE) TARGET=arm DEBUG=TRUE all
-
-base: banner module_dirs subdirs local
-
-# Standard Building of Source Files (Default builds for all objects defined above)
-$(C_LANG_OBJECTS): $(SOURCES) $(HEADERS)
- $(CC_CMD)
-
-$(CPP_LANG_OBJECTS): $(SOURCES) $(HEADERS)
- $(CPP_CMD)
-
-local: $(OBJECTS)
-
-# Defines specific for each deliverable
-
-# For a static library
-$(COMPONENT_LIB): $(OBJECTS) $(ALL_OBJECTS)
-ifdef DYNAMIC
-# For a dynamic library
- $(SLIB_CMD)
- $(HIDE_ECHO_FLAG)$(OBJCPY) --only-keep-debug $(@) $(@).debug
- $(HIDE_ECHO_FLAG)$(OBJCPY) --strip-all $(@)
- $(HIDE_ECHO_FLAG)$(OBJCPY) --add-gnu-debuglink=$(@).debug $(@)
-else
-# For a static library
- $(AR_CMD)
-endif
-
-# Standard set of derived targets
-library: base \
- $(LIBRARIES)
- @echo "***** `date` Done building library: $(COMPONENT_NAME) ******"
-
-binary: base \
- $(BINARIES)
-
-# Subdirs should be to jump to subdirectories
-# standard form is of
-# $(MAKE) -C subdirectory_name $(MAKECMDGOALS)
-subdirs:
- $(MAKE) -C statemachine $(MAKECMDGOALS)
-clean:
- -rm -f $(BINARIES)
- -rm -f $(LIBRARIES)
- -rm -f $(OBJECTS)
- -rm -f $(ALL_OBJECTS)
- -rm -f $(COMPONENT_LIB).map
- -rm -f $(COMPONENT_LIB).debug
-
--v:
- @echo "objs: --> $(OBJECTS)"
- @echo "sources: --> $(SOURCES)"
- @echo "headers: --> $(HEADERS)"
- @echo "includes: --> $(INCLUDES)"
- @echo "lib paths: --> $(LIB_PATHS)"
- @echo "static libs: --> $(LD_STATIC_LIBS)"
- @echo "dynamic libs: --> $(LD_DYNAMIC_LIBS)"
- @echo "lib: --> $(LIBRARIES)"
- @echo "bin: --> $(BINARIES)"
-
-
-module_dirs: build_dirs
diff --git a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_action.cpp b/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_action.cpp
deleted file mode 100755
index 0cb4d67..0000000
--- a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_action.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-/// \ingroup tag_NSFramework
-/// \brief
-/// This file has class declaration of the CFrameworkunifiedAction. This is an interface class that defines
-/// interfaces for implementing action
-///
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-#include <native_service/frameworkunified_sm_action.h>
-#include <string>
-///////////////////////////////////////////////////////////////////////////////////////////
-/// CFrameworkunifiedAction
-/// Parameterized constructor
-///////////////////////////////////////////////////////////////////////////////////////////
-CFrameworkunifiedAction::CFrameworkunifiedAction(std::string f_strName): m_strName(f_strName) {
-}
diff --git a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_compositestate.cpp b/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_compositestate.cpp
deleted file mode 100755
index d975e93..0000000
--- a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_compositestate.cpp
+++ /dev/null
@@ -1,371 +0,0 @@
-/*
- * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-/// \defgroup <<Group Tag>> <<Group Name>>
-/// \ingroup tag_NSFramework
-/// .
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-/// \ingroup tag_NSFramework
-/// \brief
-///
-/// This file has the CFrameworkunifiedCompositeState class definitions. CFrameworkunifiedCompositeState is derived from C
-/// FrameworkunifiedState class.This class implements the additional functionality supported by HSM Composite
-/// state. It provides the standard interfaces for adding state.
-///
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-// Include Files
-///////////////////////////////////////////////////////////////////////////////////////////////////
-#include <native_service/frameworkunified_sm_compositestate.h>
-#include <native_service/frameworkunified_sm_framework_types.h>
-#include <native_service/frameworkunified_sm_hsm.h>
-#include <native_service/frameworkunified_sm_historystate.h>
-
-#include <sstream>
-#include <string>
-#include <map>
-#include <utility>
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// CFrameworkunifiedCompositeState
-/// Parameterized constructor
-///////////////////////////////////////////////////////////////////////////////////////////
-CFrameworkunifiedCompositeState::CFrameworkunifiedCompositeState(std::string f_pName): CFrameworkunifiedState(f_pName) {
- try {
- // ChildState map stores the pointers to sub state, key is state name
- m_pChildStates = new ChildStateList();
-
- m_pDefaultState = NULL;
-
- m_pActiveState = NULL;
- } catch (std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: Failed in %s state ", f_pName.c_str());
- }
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// ~CFrameworkunifiedState
-/// Class destructor
-///////////////////////////////////////////////////////////////////////////////////////////
-CFrameworkunifiedCompositeState::~CFrameworkunifiedCompositeState() {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_DEV_INFO, __FUNCTION__, "CFrameworkunifiedCompositeState destructor");
- StateIterator l_objStateIterator;
- try {
- CHKNULL(m_pChildStates);
-
- // Deleting the States
- for (l_objStateIterator = m_pChildStates->begin();
- l_objStateIterator != m_pChildStates->end(); l_objStateIterator++) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_DEV_INFO, __FUNCTION__, " deleting the state %s in state %s ",
- (reinterpret_cast<CFrameworkunifiedState *>((*l_objStateIterator).second))->m_strStateName.c_str(),
- m_strStateName.c_str());
-
- CHKNULL((*l_objStateIterator).second);
-
- delete(*l_objStateIterator).second;
- (*l_objStateIterator).second = NULL;
- }
- m_pChildStates->clear();
- delete m_pChildStates;
- m_pChildStates = NULL;
- } catch (std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: Failed to delete state %s",
- ((reinterpret_cast<CFrameworkunifiedState *>((*l_objStateIterator).second))->m_strStateName).c_str());
- }
-}
-///////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedAddState
-/// sets the given state as a substate of the current state. If the f_eStateType is
-/// eFrameworkunifiedDefaultState then substate is default state for current state.
-///////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedCompositeState::FrameworkunifiedAddState(CFrameworkunifiedState *f_pState,
- FRAMEWORKUNIFIED_STATE_TYPE f_eStateType) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
- std::map<std::string, CFrameworkunifiedState *>::iterator l_itChildStates;
- CFrameworkunifiedHistoryState *l_pHistoryState = NULL;
- try {
- CHKNULL(f_pState);
-
- CHKNULL(m_pChildStates);
-
- // Set current state as the parent state of given state object
- f_pState->m_pParentState = this;
-
- // if given state is default state then set it as the default and active state of parent
- // state
- if (eFrameworkunifiedDefaultState == f_eStateType) {
- m_pDefaultState = f_pState;
- m_pActiveState = f_pState;
-
- // set default shallow history state
- l_itChildStates = m_pChildStates->find(SHALLOWHISTORYSTATE);
- if (m_pChildStates->end() != l_itChildStates) {
- l_pHistoryState = static_cast<CFrameworkunifiedHistoryState *>((*l_itChildStates).second);
- CHKNULL(l_pHistoryState);
- eStatus = l_pHistoryState->SetDefaultHistory();
- }
-
- // set default deep history state
- l_itChildStates = m_pChildStates->find(DEEPHISTORYSTATE);
- if (m_pChildStates->end() != l_itChildStates) {
- l_pHistoryState = static_cast<CFrameworkunifiedHistoryState *>((*l_itChildStates).second);
- CHKNULL(l_pHistoryState);
- eStatus = l_pHistoryState->SetDefaultHistory();
- }
- }
-
- // Insert the state in the map with key as state name
- m_pChildStates->insert(std::pair<std::string, CFrameworkunifiedState *>(f_pState->m_strStateName, f_pState));
-
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " %s state added in the state %s "
- , (f_pState->m_strStateName).c_str(), (this->m_strStateName).c_str());
- } catch (std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: Failed to add state %s",
- f_pState->m_strStateName.c_str());
-
- eStatus = eFrameworkunifiedStatusNullPointer;
- }
-
- return eStatus;
-}
-///////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedGetDefaultState
-/// Returns the default state of the current composite state.
-///////////////////////////////////////////////////////////////////////////////////////////
-CFrameworkunifiedState *CFrameworkunifiedCompositeState::FrameworkunifiedGetDefaultState() {
- return m_pDefaultState;
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedOnEntry
-/// state initialization can be performed in this function.
-///////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedCompositeState::FrameworkunifiedOnEntry(CEventDataPtr f_pEventData) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Entering state %s ", m_strStateName.c_str());
- return eFrameworkunifiedStatusOK;
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedOnExit
-/// state cleanup can be performed in this function.
-///////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedCompositeState::FrameworkunifiedOnExit(CEventDataPtr f_pEventData) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Leaving state %s ", m_strStateName.c_str());
- return eFrameworkunifiedStatusOK;
-}
-
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedPrintStates
-/// This logs the state name and events associated with the state
-///////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedCompositeState::FrameworkunifiedPrintStates() {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
- StateIterator l_objStateIterator;
- EventReactionIterator l_objEventIterator;
- try {
- CHKNULL(m_pEventList);
-
- if (m_pParentState) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "%s:%s",
- (m_pParentState->m_strStateName).c_str(), m_strStateName.c_str());
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "NULL:%s", m_strStateName.c_str());
- }
-
- // print event
- for (l_objEventIterator = m_pEventList->begin();
- l_objEventIterator != m_pEventList->end(); l_objEventIterator++) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "event %d %s", ((*l_objEventIterator).first),
- (m_pEventName->find((*l_objEventIterator).first)->second).c_str());
- }
- CHKNULL(m_pDeferredEventList);
- // print deferred events
- for (UI_32 l_uiCount = 0; l_uiCount < m_pDeferredEventList->size(); l_uiCount++) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "deferred event %d %s", m_pDeferredEventList->at(l_uiCount),
- (m_pEventName->find(m_pDeferredEventList->at(l_uiCount))->second).c_str());
- }
- CHKNULL(m_pChildStates);
- // print states
- for (l_objStateIterator = m_pChildStates->begin();
- l_objStateIterator != m_pChildStates->end(); l_objStateIterator++) {
- (reinterpret_cast<CFrameworkunifiedState *>((*l_objStateIterator).second))->FrameworkunifiedPrintStates();
- }
- } catch (std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: Failed to print in state %s",
- m_strStateName.c_str());
- eStatus = eFrameworkunifiedStatusNullPointer;
- }
- return eStatus;;
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedHasSubStates
-/// This indicates if the state has sub states. It returns TRUE only in the CompositeState
-/// where this function is overridden
-///////////////////////////////////////////////////////////////////////////////////////////
-BOOL CFrameworkunifiedCompositeState::FrameworkunifiedHasSubStates() {
- return TRUE;
-}
-
-CFrameworkunifiedState *CFrameworkunifiedCompositeState::FrameworkunifiedGetActiveState() {
- CFrameworkunifiedState *l_pActiveState = NULL;
- if (NULL != m_pActiveState) {
- l_pActiveState = m_pActiveState->FrameworkunifiedGetActiveState();
- } else {
- l_pActiveState = this;
- }
- return l_pActiveState;
-}
-
-EFrameworkunifiedStatus CFrameworkunifiedCompositeState::FrameworkunifiedSetHSM(CFrameworkunifiedHSM *f_pStatemachine) {
- EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
- StateIterator l_objStateIterator;
- try {
- CHKNULL(f_pStatemachine);
- // iterate child states
- for (l_objStateIterator = m_pChildStates->begin();
- l_objStateIterator != m_pChildStates->end(); l_objStateIterator++) {
- (reinterpret_cast<CFrameworkunifiedState *>((*l_objStateIterator).second))->FrameworkunifiedSetHSM(f_pStatemachine);
- }
- m_pStateMachine = f_pStatemachine;
- } catch (std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
- l_eStatus = eFrameworkunifiedStatusNullPointer;
- }
- return l_eStatus;
-}
-
-EFrameworkunifiedStatus CFrameworkunifiedCompositeState::FrameworkunifiedPrintXML(std::ostringstream &f_strXMLString) {
- EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
- EventReactionIterator l_objEventIterator;
- StateIterator l_objStateIterator;
- try {
- CHKNULL(m_pEventList);
- CHKNULL(m_pEventName);
- CHKNULL(m_pDeferredEventList);
-
- f_strXMLString << "<" << m_strStateName.c_str() << ">";
-
- CHKNULL(m_pChildStates);
- f_strXMLString << "<ChildStates>";
- // print states
- for (l_objStateIterator = m_pChildStates->begin();
- l_objStateIterator != m_pChildStates->end(); l_objStateIterator++) {
- (reinterpret_cast<CFrameworkunifiedState *>((*l_objStateIterator).second))->FrameworkunifiedPrintXML(f_strXMLString);
- }
-
- f_strXMLString << "</ChildStates>";
-
- f_strXMLString << "<EventList>";
- // print events
- for (l_objEventIterator = m_pEventList->begin();
- l_objEventIterator != m_pEventList->end(); l_objEventIterator++) {
- std::string l_strEventName =
- (m_pEventName->find((*l_objEventIterator).first)->second);
-
- UI_32 l_uiEventId = (*l_objEventIterator).first;
-
- f_strXMLString << "<Event " << "Id = " << "\"" << l_uiEventId << "\">";
-
- f_strXMLString << "<Name>" << l_strEventName.c_str() << "</Name>";
-
- f_strXMLString << "</Event>";
- }
- f_strXMLString << "</EventList>";
-
- // print deferred events
- f_strXMLString << "<DeferredEventList>";
- for (UI_32 l_uiCount = 0; l_uiCount < m_pDeferredEventList->size(); l_uiCount++) {
- UI_32 l_uiEventId = m_pDeferredEventList->at(l_uiCount);
-
- std::string l_strEventName = (m_pEventName->find(l_uiEventId)->second);
-
- f_strXMLString << "<Event " << "Id = " << "\"" << l_uiEventId << "\">";
-
- f_strXMLString << "<Name>" << l_strEventName.c_str() << "</Name>";
-
- f_strXMLString << "</Event>";
- }
-
- f_strXMLString << "</DeferredEventList>";
- f_strXMLString << "</" << m_strStateName.c_str() << ">";
- } catch (std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: Failed to print in state %s", m_strStateName.c_str());
- l_eStatus = eFrameworkunifiedStatusNullPointer;
- }
- return l_eStatus;
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////////////
-/// UpdateHistory
-/// This function stores the last active state
-////////////////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedCompositeState::UpdateHistory() {
- EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
-
- // update shallow history state
- l_eStatus = CheckHistory(SHALLOWHISTORYSTATE);
-
- if (eFrameworkunifiedStatusOK != l_eStatus) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "%s Shallow History Update Failed", m_strStateName.c_str());
- return l_eStatus;
- }
-
- // update deep history state
- l_eStatus = CheckHistory(DEEPHISTORYSTATE);
-
- if (eFrameworkunifiedStatusOK != l_eStatus) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "%s Deep History Update Failed", m_strStateName.c_str());
- return l_eStatus;
- }
-
- return l_eStatus;
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////////////
-/// CheckHistory
-/// This function searches for history state in this composite state and updates it.
-////////////////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedCompositeState::CheckHistory(std::string l_cHistoryType) {
- EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
-
- CHKNULL(m_pChildStates);
-
- CFrameworkunifiedState *l_pHistoryState = NULL;
-
- std::map<std::string, CFrameworkunifiedState *>::iterator l_itChildStates;
-
- // update history state
- l_itChildStates = m_pChildStates->find(l_cHistoryType);
-
- if (m_pChildStates->end() != l_itChildStates) {
- l_pHistoryState = (*l_itChildStates).second;
- CHKNULL(l_pHistoryState);
- l_eStatus = l_pHistoryState->UpdateHistory();
- }
-
- return l_eStatus;
-}
diff --git a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_conditionconnector.cpp b/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_conditionconnector.cpp
deleted file mode 100755
index 6f27319..0000000
--- a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_conditionconnector.cpp
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-//////////////////////////////////////////////////////////////////////////////////////////////////
-/// \defgroup <<Group Tag>> <<Group Name>>
-/// \ingroup tag_NSFramework
-/// .
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-/// \ingroup tag_NSFramework
-/// \brief
-///
-/// This file has class definition of the CFrameworkunifiedConditionConnector. This class is responsible for
-/// implementing interfaces required to use condition connector in statemachine.
-///
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-// Include Files
-///////////////////////////////////////////////////////////////////////////////////////////////////
-#include <native_service/frameworkunified_sm_conditionconnector.h>
-#include <native_service/frameworkunified_sm_state.h>
-#include <native_service/frameworkunified_sm_framework_types.h>
-#include <native_service/frameworkunified_sm_guard.h>
-
-#include <vector>
-#include <string>
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// CFrameworkunifiedConditionConnector
-/// Parameterized constructor
-///////////////////////////////////////////////////////////////////////////////////////////
-CFrameworkunifiedConditionConnector::CFrameworkunifiedConditionConnector(std::string f_strName): CFrameworkunifiedExternalTransition(NULL),
- m_strName(f_strName) {
- // Create the condition list
- m_pConditionList = new std::vector<CCondition * >();
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// ~CFrameworkunifiedConditionConnector
-/// destructor
-///////////////////////////////////////////////////////////////////////////////////////////
-CFrameworkunifiedConditionConnector::~CFrameworkunifiedConditionConnector() {
- if (m_pConditionList) {
- TConditionIterator l_itConditionList = m_pConditionList->begin();
-
- while (m_pConditionList->end() != l_itConditionList) {
- delete *l_itConditionList;
- l_itConditionList++;
- }
- // clear condition list
- m_pConditionList->clear();
- delete m_pConditionList;
- }
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// CCondition
-/// Parameterized constructor
-///////////////////////////////////////////////////////////////////////////////////////////
-CFrameworkunifiedConditionConnector::CCondition::CCondition(CFrameworkunifiedGuard *f_pGuard, CFrameworkunifiedState *f_pTargetState)
- : m_pGuard(f_pGuard), m_pTargetState(f_pTargetState) {
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedReaction
-/// This API evaluates the guards added in the condition list. If the guard is evaluated as
-/// true then statemachine transitions to target state associated with guard.
-//////////////////////////////////////////////////////////////////////////////////////////////
-CFrameworkunifiedState *CFrameworkunifiedConditionConnector::FrameworkunifiedReaction(CFrameworkunifiedState *f_pSourceState, CEventDataPtr f_pData) {
- CFrameworkunifiedState *l_pActiveState = NULL;
- BOOL l_bAllowTransition = FALSE;
- try {
- CHKNULL(f_pSourceState);
- CHKNULL(m_pConditionList);
- TConditionIterator l_itConditionList
- = m_pConditionList->begin();
-
- // iterate condition list and set the target state
- while (m_pConditionList->end() != l_itConditionList) {
- CCondition *l_pCondition = *l_itConditionList;
- CHKNULL(l_pCondition);
-
- CFrameworkunifiedGuard *l_pGuard = l_pCondition->m_pGuard;
- CFrameworkunifiedState *l_pTargetState = l_pCondition->m_pTargetState;
-
- CHKNULL(l_pGuard);
- CHKNULL(l_pTargetState);
-
- if (l_pGuard->FrameworkunifiedEvaluate()) {
- m_pTargetState = l_pTargetState;
- l_bAllowTransition = TRUE;
- break;
- }
- l_itConditionList++;
- }
-
- if (l_bAllowTransition) {
- // Transition to target state
- l_pActiveState = ExecuteTransition(f_pSourceState, f_pData);
-
- } else {
- // No state changed
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__,
- "Guard condition for External Transition from state %s to condition connector %s failed",
- f_pSourceState->m_strStateName.c_str(), m_strName.c_str());
-
- l_pActiveState = f_pSourceState;
- }
- } catch (std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
- return NULL;
- }
- return l_pActiveState;
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedAddCondition
-/// Adds condition to condition list
-//////////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedConditionConnector::FrameworkunifiedAddCondition(CFrameworkunifiedGuard *f_pGuard, CFrameworkunifiedState *f_pTargetState) {
- EFrameworkunifiedStatus l_eFrameworkunifiedStatus = eFrameworkunifiedStatusOK;
- try {
- CHKNULL(m_pConditionList);
- CHKNULL(f_pGuard);
- CHKNULL(f_pTargetState);
-
- CCondition *l_pCondition = new CCondition(f_pGuard, f_pTargetState);
-
- m_pConditionList->push_back(l_pCondition);
- } catch (std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
- l_eFrameworkunifiedStatus = eFrameworkunifiedStatusNullPointer;
- }
-
-
- return l_eFrameworkunifiedStatus;
-}
diff --git a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_deephistorystate.cpp b/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_deephistorystate.cpp
deleted file mode 100755
index baac0d4..0000000
--- a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_deephistorystate.cpp
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-/// \defgroup <<Group Tag>> <<Group Name>>
-/// \ingroup tag_NSFramework
-/// .
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-/// \ingroup tag_NSFramework
-/// \brief
-///
-/// This file has the CFrameworkunifiedDeepHistoryState class definitions. CFrameworkunifiedDeepHistoryState is derived
-/// from CFrameworkunifiedHistoryState class.This class implements the additional functionality supported by
-/// HSM DeepHistory state.
-///
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-#include <native_service/frameworkunified_sm_deephistorystate.h>
-#include <native_service/frameworkunified_sm_framework_types.h>
-#include <string>
-
-// define static members of class
-const UI_32 CFrameworkunifiedDeepHistoryState::m_suievDeepHistory = 72;
-
-////////////////////////////////////////////////////////////////////////////////////////////////////
-/// CFrameworkunifiedDeepHistoryState
-/// Parameterized constructor
-////////////////////////////////////////////////////////////////////////////////////////////////////
-CFrameworkunifiedDeepHistoryState::CFrameworkunifiedDeepHistoryState(std::string f_pName): CFrameworkunifiedHistoryState(f_pName) {
- m_uiEventId = m_suievDeepHistory;
- m_cEventName = "evDeepHistory";
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////////////
-/// ~CFrameworkunifiedDeepHistoryState
-/// Class destructor
-////////////////////////////////////////////////////////////////////////////////////////////////////
-CFrameworkunifiedDeepHistoryState::~CFrameworkunifiedDeepHistoryState() {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_DEV_INFO, __FUNCTION__, "CFrameworkunifiedDeepHistoryState destructor");
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////////////
-/// UpdateHistory
-/// This function stores the last active state
-////////////////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedDeepHistoryState::UpdateHistory() {
- EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
-
- CFrameworkunifiedState *l_pActiveState = NULL;
-
- try {
- CHKNULL(m_pParentState);
- l_pActiveState = m_pParentState->m_pActiveState;
-
- while (NULL != l_pActiveState) {
- m_pLastActiveState = l_pActiveState;
- l_pActiveState = l_pActiveState->m_pActiveState;
- }
- } catch (std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
- l_eStatus = eFrameworkunifiedStatusNullPointer;
- }
- return l_eStatus;
-}
diff --git a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_dispatcher.cpp b/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_dispatcher.cpp
deleted file mode 100755
index a73408a..0000000
--- a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_dispatcher.cpp
+++ /dev/null
@@ -1,240 +0,0 @@
-/*
- * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-///////////////////////////////////////////////////////////////////////////////
-/// \ingroup tag_NSFramework
-/// \brief
-///
-///
-///
-///////////////////////////////////////////////////////////////////////////////
-#include <pthread.h>
-
-#include <native_service/ns_logger_if.h>
-#include <native_service/ns_plogger_if.h>
-#include <native_service/ns_message_center_if.h>
-#include <native_service/frameworkunified_sm_hsmframework.h>
-#include <native_service/frameworkunified_framework_if.h>
-#include <native_service/frameworkunified_sm_dispatcher.h>
-
-#include "frameworkunified_framework_core.h"
-#include "frameworkunified_framework_error_internal.hpp"
-#include "frameworkunified_sm_framework_core.h"
-#include "frameworkunified_framework_utility.h"
-
-static HSMConfigOptions s_tHSMConfigOptions = {eUserchangeIgnore, TRUE, FALSE};
-
-EFrameworkunifiedStatus FrameworkunifiedHSMDispatcherMain(HANDLE hApp);
-//////////////////////////////////////////
-// Function : FrameworkunifiedCreateDispatcher
-//////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedCreateHSMDispatcher(PCSTR cAppName,
- HANDLE &hFrameworkApp, // NOLINT (readability/nolint)
- BOOL bIsThread, CFrameworkunifiedHSMFramework *f_pFrameworkunifiedHSM) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (NULL != cAppName) {
- if (eFrameworkunifiedStatusOK == (eStatus = CreateDispatcher(cAppName, hFrameworkApp, bIsThread))) {
- if (NULL != hFrameworkApp) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hFrameworkApp);
-
- if (NULL != f_pFrameworkunifiedHSM) {
- pApp->m_pFrameworkunifiedStateMachine = f_pFrameworkunifiedHSM;
- pApp->m_pFrameworkunifiedStateMachine->m_pHApp = pApp;
- } else {
- if (bIsThread) {
- pApp->m_pFrameworkunifiedStateMachine = new CFrameworkunifiedHSMChildFramework(pApp);
- } else {
- pApp->m_pFrameworkunifiedStateMachine = new CFrameworkunifiedHSMParentFramework(pApp);
- }
- }
-
- if (NULL != pApp->m_pFrameworkunifiedStateMachine) {
- pApp->m_pFrameworkunifiedStateMachine->FrameworkunifiedCreate(&s_tHSMConfigOptions);
- }
- } else {
- FRAMEWORKUNIFIEDLOG0(ZONE_NS_ERR, __FUNCTION__, "hFrameworkApp is NULL");
- eStatus = eFrameworkunifiedStatusNullPointer;
- }
- } else {
- // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
- FRAMEWORKUNIFIEDLOG0(ZONE_NS_ERR, __FUNCTION__, "CreateDispatcher returned error, status=%d", eStatus);
- // LCOV_EXCL_BR_STOP
- }
- } else {
- FRAMEWORKUNIFIEDLOG0(ZONE_NS_ERR, __FUNCTION__, "AppName is NULL");
- eStatus = eFrameworkunifiedStatusInvldParam;
- }
-
- return eStatus;
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedDispatcherWithArguments
-/// Creates, initializes and runs the dispatcher
-///
-/// \param [in] cAppname
-/// PCSTR - Application/ thread name
-///
-/// \return Never does, main loop for your application.
-///
-/// \see FrameworkunifiedCreateDispatcher, FrameworkunifiedDispatchBlock,
-/// FrameworkunifiedDispatchProcess, FrameworkunifiedCloseDispatcher,
-///
-////////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedHSMDispatcherWithArguments(PCSTR cAppName, int argc, char *argv[],
- const FrameworkunifiedDefaultCallbackHandler *CbHandler, CFrameworkunifiedHSMFramework *f_pFrameworkunifiedHSM,
- CustomCommandLineOptions *cmdLineOptions) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (cAppName == NULL) {
- return eFrameworkunifiedStatusNullPointer;
- }
-
- NsLogSetProcessName(cAppName);
- PLOG_TEXT("FrameworkunifiedHSMDispatcher Start");
- // set main thread name as provided in dispatcher
- pthread_setname_np(pthread_self(), cAppName);
-
- if ((eStatus = RegistDefaultCbHandler(CbHandler)) != eFrameworkunifiedStatusOK) {
- return eStatus;
- }
-
- FRAMEWORKUNIFIEDLOG0(ZONE_NS_DIS, __FUNCTION__, "In"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
- try {
- HANDLE hFrameworkApp = NULL;
-
- if (eFrameworkunifiedStatusOK == (eStatus = FrameworkunifiedCreateHSMDispatcher(cAppName, hFrameworkApp, FALSE, f_pFrameworkunifiedHSM))) {
- if (NULL != hFrameworkApp) {
- THApp hApp(hFrameworkApp);
-
- /// Parse the Arguments via the FrameworkunifiedArgumentParser
- /// passing an handle to the app and argument list
- eStatus = FrameworkunifiedArgumentParser(hApp, argc, argv, cmdLineOptions);
-
- if (eFrameworkunifiedStatusOK == eStatus) {
- eStatus = FrameworkunifiedHSMDispatcherMain(hApp);
- }
- } else {
- eStatus = eFrameworkunifiedStatusNullPointer;
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "hFrameworkApp is NULL");
- }
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "FrameworkunifiedCreateHSMDispatcher error, status=%d", eStatus);
- }
- } catch (const THApp::Exception &) {
- /**
- * @todo
- * When an exception error occurs in a FrameworkunifiedCreateHSMDispatcher,
- * the caller cannot detect the exception because the exception becomes the eFrameworkunifiedStatusOK return code.
- */
- FRAMEWORKUNIFIEDLOG0(ZONE_NS_ERR, __FUNCTION__, "Error: Failed to FrameworkunifiedHSMCreateDispatcher ");
- }
-
-
- return eStatus;
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////
-/// Function : FrameworkunifiedHSMDispatcherMain
-////////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedHSMDispatcherMain(HANDLE hApp) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- try {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, "Success: FrameworkunifiedCreateDispatcher ");
-
- if (frameworkunifiedCheckValidAppHandle(hApp)) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
-
- CFrameworkunifiedHSMFramework *l_pStateMachine = pApp->m_pFrameworkunifiedStateMachine;
-
- if (l_pStateMachine) {
- eStatus = l_pStateMachine->FrameworkunifiedStart();
-
- if (eFrameworkunifiedStatusOK != eStatus) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "FrameworkunifiedOnInitialization failed ");
- l_pStateMachine->FrameworkunifiedClose();
- throw happ_error();
- } else {
- eStatus = RunDispatcher(hApp);
- }
-
- l_pStateMachine->FrameworkunifiedClose();
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "l_pStateMachine is NULL");
- eStatus = eFrameworkunifiedStatusNullPointer;
- }
- }
- } catch (const frameworkunified::framework::error::CSystemError &err) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR :: %s", err.what());
-
- FrameworkunifiedSendSystemErrMessage(hApp, err.m_eSystemError);
- } catch (const THApp::Exception &) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: Failed to FrameworkunifiedCreateDispatcher ");
- }
-
- return eStatus;
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////
-/// Function : FrameworkunifiedSetHSMType
-////////////////////////////////////////////////////////////////////////////////////////////
-void FrameworkunifiedSetHSMType(EUserChangeOptions f_eHSMType) {
- s_tHSMConfigOptions.eUserChange = f_eHSMType;
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////
-/// Function : FrameworkunifiedEnableAutoPublishServiceAvailable
-////////////////////////////////////////////////////////////////////////////////////////////
-void FrameworkunifiedEnableAutoPublishServiceAvailable() {
- s_tHSMConfigOptions.bAutoPublishServiceAvaialble = TRUE;
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////
-/// Function : FrameworkunifiedDisableAutoPublishServiceAvailable
-////////////////////////////////////////////////////////////////////////////////////////////
-void FrameworkunifiedDisableAutoPublishServiceAvailable() {
- s_tHSMConfigOptions.bAutoPublishServiceAvaialble = FALSE;
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////
-/// Function : FrameworkunifiedIsAutoPublishServiceAvailableEnabled
-////////////////////////////////////////////////////////////////////////////////////////////
-BOOL FrameworkunifiedIsAutoPublishServiceAvailableEnabled() {
- return s_tHSMConfigOptions.bAutoPublishServiceAvaialble;
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedHSMEnableWaitInStoppingState
-////////////////////////////////////////////////////////////////////////////////////////////
-VOID FrameworkunifiedHSMEnableWaitInStoppingState() {
- s_tHSMConfigOptions.bWaitInStoppingState = TRUE;
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedHSMDisableWaitInStoppingState
-////////////////////////////////////////////////////////////////////////////////////////////
-VOID FrameworkunifiedHSMDisableWaitInStoppingState() {
- s_tHSMConfigOptions.bWaitInStoppingState = FALSE;
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedIsWaitInStoppingStateEnabled
-////////////////////////////////////////////////////////////////////////////////////////////
-BOOL FrameworkunifiedIsWaitInStoppingStateEnabled() {
- return s_tHSMConfigOptions.bWaitInStoppingState;
-}
diff --git a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_externaltransition.cpp b/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_externaltransition.cpp
deleted file mode 100755
index 294dcf5..0000000
--- a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_externaltransition.cpp
+++ /dev/null
@@ -1,225 +0,0 @@
-/*
- * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-/// \defgroup <<Group Tag>> <<Group Name>>
-/// \ingroup tag_NSFramework
-/// .
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-/// \ingroup tag_NSFramework
-/// \brief
-///
-/// This file has the CFrameworkunifiedExternalTransition class definitions. CFrameworkunifiedExternalTransition is derived
-/// from CFrameworkunifiedTransition class.This class implements the FrameworkunifiedReaction interface to support transition
-/// from one state to another state.
-///
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-// Include Files
-///////////////////////////////////////////////////////////////////////////////////////////////////
-#include <native_service/frameworkunified_sm_externaltransition.h>
-#include <native_service/frameworkunified_sm_state.h>
-#include <native_service/frameworkunified_sm_framework_types.h>
-#include <native_service/frameworkunified_sm_guard.h>
-#include <native_service/frameworkunified_sm_action.h>
-#include <vector>
-///////////////////////////////////////////////////////////////////////////////////////////
-/// CFrameworkunifiedState
-/// Parameterized constructor
-///////////////////////////////////////////////////////////////////////////////////////////
-CFrameworkunifiedExternalTransition::CFrameworkunifiedExternalTransition(CFrameworkunifiedState *f_pTargetState): CFrameworkunifiedTransition(f_pTargetState) {
- m_pGuard = NULL;
-
- // Create the condition list
- m_pActionList = new std::vector<CFrameworkunifiedAction * >(); // LCOV_EXCL_BR_LINE 11:except branch
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// ~CFrameworkunifiedState
-/// Class destructor
-///////////////////////////////////////////////////////////////////////////////////////////
-CFrameworkunifiedExternalTransition::~CFrameworkunifiedExternalTransition() {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "+");
- if (m_pActionList) {
- TActionListIterator l_itActionList = m_pActionList->begin();
-
- while (m_pActionList->end() != l_itActionList) {
- if (NULL != *l_itActionList) {
- delete *l_itActionList;
- *l_itActionList = NULL;
- }
- l_itActionList++;
- }
- // clear condition list
- m_pActionList->clear();
- delete m_pActionList;
- m_pActionList = NULL;
- }
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedReaction
-/// The reaction for an event is implemented in this function. For external transition, Exit
-/// of the source state is called and entry of the target state is called recursively.
-///////////////////////////////////////////////////////////////////////////////////////////
-CFrameworkunifiedState *CFrameworkunifiedExternalTransition::FrameworkunifiedReaction(CFrameworkunifiedState *f_pSourceState, CEventDataPtr f_pData) {
- CFrameworkunifiedState *l_pActiveState = NULL;
- BOOL l_bAllowTransition = FALSE;
-
- try {
- CHKNULL(f_pSourceState);
- CHKNULL(m_pTargetState);
-
- // Check if External transition has Guard condition
- if (m_pGuard) {
- // Evaluate guard condition
- l_bAllowTransition = m_pGuard->FrameworkunifiedEvaluate();
- } else {
- // If Guard is not available then allow transition
- l_bAllowTransition = TRUE;
- }
-
- if (l_bAllowTransition) {
- l_pActiveState = ExecuteTransition(f_pSourceState, f_pData); // LCOV_EXCL_BR_LINE 11:except branch
-
- } else {
- // No state changed
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "Guard condition for External Transition "
- "from state %s to state %s failed"
- , f_pSourceState->m_strStateName.c_str(), m_pTargetState->m_strStateName.c_str());
-
- l_pActiveState = f_pSourceState;
- }
- } catch (std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
- return NULL;
- }
-
- return l_pActiveState;
-}
-
-EFrameworkunifiedStatus CFrameworkunifiedExternalTransition::FrameworkunifiedSetGuard(CFrameworkunifiedGuard *f_pGuard) {
- EFrameworkunifiedStatus l_eFrameworkunifiedStatus = eFrameworkunifiedStatusOK;
- try {
- CHKNULL(f_pGuard);
- m_pGuard = f_pGuard;
- } catch (std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
- l_eFrameworkunifiedStatus = eFrameworkunifiedStatusNullPointer;
- }
-
- return l_eFrameworkunifiedStatus;
-}
-
-CFrameworkunifiedState *CFrameworkunifiedExternalTransition::ExecuteTransition(CFrameworkunifiedState *f_pSourceState, CEventDataPtr f_pData) {
- CFrameworkunifiedState *l_pActiveState = NULL;
- try {
- CHKNULL(m_pTargetState);
- CHKNULL(f_pSourceState);
- CFrameworkunifiedState *l_pTargetState = m_pTargetState;
- CFrameworkunifiedState *l_pCurrentState = f_pSourceState;
-
-
-
-
- // Find the common parent of the source and target state
- // and then call recursively OnExit on source state and
- // OnEntry on parent state
- BOOL l_bFoundCommonParent = FALSE;
- while (l_pCurrentState->m_pParentState) {
- while (l_pTargetState->m_pParentState) {
- // Check if current source state and target state has common parent
- if (l_pCurrentState->m_pParentState == l_pTargetState->m_pParentState) {
- l_bFoundCommonParent = TRUE;
- break;
- } else {
- // Set the next target parent state
- l_pTargetState = l_pTargetState->m_pParentState;
- }
- }
-
- if (l_bFoundCommonParent) {
- break;
- } else {
- // Set the next source parent state
- l_pCurrentState = l_pCurrentState->m_pParentState;
- l_pTargetState = m_pTargetState;
- }
- }
-
- if (l_bFoundCommonParent) {
- // recursively execute the exit on the current state
- l_pCurrentState->FrameworkunifiedOnHSMStop(f_pData);
-
- // execute actions associated with the external transition
- CHKNULL(m_pActionList);
- TActionListIterator l_itActionList = m_pActionList->begin();
-
- // iterate action list and execute actions
- while (m_pActionList->end() != l_itActionList) {
- CFrameworkunifiedAction *l_pAction = *l_itActionList;
- CHKNULL(l_pAction);
-
- l_pAction->FrameworkunifiedAction(f_pSourceState, l_pTargetState, f_pData);
-
- l_itActionList++;
- }
-
- // Set the target state as a active state
- CFrameworkunifiedState *l_pState = m_pTargetState;
- while (l_pState->m_pParentState != l_pTargetState->m_pParentState) {
- CHKNULL(l_pState->m_pParentState);
-
- l_pState->m_pParentState->m_pActiveState = l_pState;
- l_pState = l_pState->m_pParentState;
- }
-
-
- // recursively execute the entry on the target state
- l_pActiveState = l_pTargetState->FrameworkunifiedOnHSMStart(f_pData);
-
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "External Transition from state %s to state %s"
- , f_pSourceState->m_strStateName.c_str(), m_pTargetState->m_strStateName.c_str());
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "External Transition from state %s to state %s failed"
- , f_pSourceState->m_strStateName.c_str(), m_pTargetState->m_strStateName.c_str());
- return NULL;
- }
- } catch (std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
- }
-
- return l_pActiveState;
-}
-
-EFrameworkunifiedStatus CFrameworkunifiedExternalTransition::FrameworkunifiedAddAction(CFrameworkunifiedAction *f_pAction) {
- EFrameworkunifiedStatus l_eFrameworkunifiedStatus = eFrameworkunifiedStatusOK;
- try {
- CHKNULL(m_pActionList);
-
- CHKNULL(f_pAction);
-
- m_pActionList->push_back(f_pAction);
- } catch (std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
- l_eFrameworkunifiedStatus = eFrameworkunifiedStatusNullPointer;
- }
-
- return l_eFrameworkunifiedStatus;
-}
diff --git a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_finalstate.cpp b/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_finalstate.cpp
deleted file mode 100755
index 8b361fa..0000000
--- a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_finalstate.cpp
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-/// \defgroup <<Group Tag>> <<Group Name>>
-/// \ingroup tag_NSFramework
-/// .
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-/// \ingroup tag_NSFramework
-/// \brief
-///
-/// This file has the CFrameworkunifiedFinalState class definitions. CFrameworkunifiedFinalState is derived from C
-/// FrameworkunifiedState class.This class implements the additional functionality supported by HSM Final
-/// state.
-///
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-#include <native_service/frameworkunified_sm_hsm.h>
-#include <string>
-#include "frameworkunified_sm_finalstate.h"
-///////////////////////////////////////////////////////////////////////////////////////////
-/// ~CFrameworkunifiedFinalState
-/// Class destructor
-///////////////////////////////////////////////////////////////////////////////////////////
-CFrameworkunifiedFinalState::~CFrameworkunifiedFinalState() {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "CFrameworkunifiedFinalState destructor");
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// CFrameworkunifiedFinalState
-/// Parameterized constructor
-///////////////////////////////////////////////////////////////////////////////////////////
-CFrameworkunifiedFinalState::CFrameworkunifiedFinalState(std::string f_pName): CFrameworkunifiedState(f_pName) {
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedOnEntry
-/// state initialization can be performed in this function.
-///////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedFinalState::FrameworkunifiedOnEntry(CEventDataPtr f_pEventData) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Entering state %s ", m_strStateName.c_str());
- return eFrameworkunifiedStatusOK;
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedOnExit
-/// state cleanup can be performed in this function.
-///////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedFinalState::FrameworkunifiedOnExit(CEventDataPtr f_pEventData) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Leaving state %s ", m_strStateName.c_str());
- return eFrameworkunifiedStatusOK;
-}
-
-CFrameworkunifiedState *CFrameworkunifiedFinalState::FrameworkunifiedGetActiveState() {
- return this;
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////////////
-/// UpdateHistory
-/// This function stores the last active state
-////////////////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedFinalState::UpdateHistory() {
- return eFrameworkunifiedStatusOK;
-}
diff --git a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_framework_dispatch.cpp b/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_framework_dispatch.cpp
deleted file mode 100755
index dfb2d5c..0000000
--- a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_framework_dispatch.cpp
+++ /dev/null
@@ -1,485 +0,0 @@
-/*
- * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-//////////////////////////////////////////////////////////////////////////////////////////////////
-/// \ingroup tag_NSFramework
-/// \brief
-///
-///
-//////////////////////////////////////////////////////////////////////////////////////////////////
-
-#include <native_service/frameworkunified_sm_framework_dispatch.h>
-#include <native_service/frameworkunified_framework_if.h>
-#include <native_service/frameworkunified_service_protocol.h>
-#include <native_service/ns_message_center_if.h>
-#include <native_service/ns_logger_if.h>
-#include <map>
-#include <utility>
-#include "frameworkunified_framework_core.h"
-
-////////////////////////////////////////////////////////////////////////////////////////////
-/// Registers a single event with the dispatcher for a given service.
-////////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedAttachHSMEventToDispatcher(HANDLE hApp,
- PCSTR pServiceName,
- UI_32 iCmd,
- UI_32 iEvent,
- HANDLE hSession) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (frameworkunifiedCheckValidAppHandle(hApp) && pServiceName) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- EventServices::iterator s_iterator;
- EventSessionTable::iterator session_iterator;
-
- UI_32 uiSessionId = 0;
- if (hSession) {
- uiSessionId = FrameworkunifiedGetSessionId(hSession);
- }
-
- // finding the service
- s_iterator = pApp->eventservices.find(pServiceName);
- if (s_iterator == pApp->eventservices.end()) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, "%s : (service NOT found): service name [%s]", pApp->cAppName, pServiceName);
- pApp->eventservices.insert(std::make_pair(pServiceName, EventSessionTable()));
- }
-
- session_iterator = pApp->eventservices[pServiceName].find(uiSessionId);
- if (session_iterator == pApp->eventservices[pServiceName].end()) {
- pApp->eventservices[pServiceName].insert
- (std::make_pair(uiSessionId, ServiceEventProtocolTable()));
- }
-
- (pApp->eventservices[pServiceName].find(uiSessionId)->second).insert(std::make_pair(iCmd, iEvent));
- } else {
- eStatus = eFrameworkunifiedStatusInvldHandle;
- }
-
- return eStatus;
-}
-
-
-////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedAttachHSMEventsToDispatcher
-/// Registers a multiple event with the dispatcher for a given service.
-////////////////////////////////////////////////////////////////////////////////////////////
-
-EFrameworkunifiedStatus FrameworkunifiedAttachHSMEventsToDispatcher(HANDLE hApp, PCSTR pServiceName,
- const FrameworkunifiedProtocolEvent *pEventIds, UI_32 uiEventCount, HANDLE hSession) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (frameworkunifiedCheckValidAppHandle(hApp) && pServiceName && pEventIds) {
- // setup callbacks
- for (UI_32 i = 0; i < uiEventCount; ++i) {
- if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedAttachHSMEventToDispatcher(hApp,
- pServiceName,
- pEventIds[ i ].iCmd,
- pEventIds[ i ].iEventId,
- hSession))) {
- break;
- }
- }
- } else {
- eStatus = eFrameworkunifiedStatusInvldHandle;
- }
-
- return eStatus;
-}
-
-/////////////////////////////////////////////////////
-// Function : FrameworkunifiedAttachParentCallbacksToDispatcher
-/////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedAttachParentHSMEventsToDispatcher(HANDLE hChildApp, const FrameworkunifiedProtocolEvent *pEventIds,
- UI_32 uiEventCount) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (frameworkunifiedCheckValidAppHandle(hChildApp)) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hChildApp);
-
- eStatus = FrameworkunifiedAttachHSMEventsToDispatcher(hChildApp, pApp->cParentAppName, pEventIds, uiEventCount);
- } else {
- eStatus = eFrameworkunifiedStatusInvldHandle;
- }
-
- return eStatus;
-}
-
-/////////////////////////////////////////////////////
-// Function : FrameworkunifiedDetachParentCallbacksFromDispatcher
-/////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedDetachParentHSMEventsFromDispatcher(HANDLE hChildApp,
- const PUI_32 puiEventArray, UI_32 uiEventCount) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (frameworkunifiedCheckValidAppHandle(hChildApp)) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hChildApp);
-
- eStatus = FrameworkunifiedDetachHSMEventsFromDispatcher(hChildApp, pApp->cParentAppName, puiEventArray, uiEventCount);
- } else {
- eStatus = eFrameworkunifiedStatusInvldHandle;
- }
-
- return eStatus;
-}
-
-
-/////////////////////////////////////////////////////
-// Function : FrameworkunifiedDetachHSMEventsFromDispatcher
-/////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedDetachHSMEventsFromDispatcher(HANDLE hApp, PCSTR pServiceName, const PUI_32 puiEventArray,
- UI_32 uiEventCount, HANDLE hSession) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (frameworkunifiedCheckValidAppHandle(hApp) && pServiceName) {
- // setup callbacks
- for (UI_32 i = 0; i < uiEventCount; ++i) {
- /**
- * @todo
- * When an event-struct pointer is turned NULL, the array is accessed without NULL checking,
- * and a segmentation fault occurs.
- */
- if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedDetachHSMEventFromDispatcher(hApp, pServiceName,
- puiEventArray[ i ], hSession))) {
- break;
- }
- }
- } else {
- eStatus = eFrameworkunifiedStatusInvldHandle;
- }
-
- return eStatus;
-}
-
-
-/////////////////////////////////////////////
-// Function : FrameworkunifiedDetachHSMEventFromDispatcher
-/////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedDetachHSMEventFromDispatcher(HANDLE hApp, PCSTR pServiceName, UI_32 iEvent, HANDLE hSession) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
- if (frameworkunifiedCheckValidAppHandle(hApp) && pServiceName) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- EventServices::iterator s_iterator;
-
- UI_32 uiSessionId = 0;
- if (hSession) {
- uiSessionId = FrameworkunifiedGetSessionId(hSession);
- }
-
- // finding the service
- s_iterator = pApp->eventservices.find(pServiceName);
- if (s_iterator != pApp->eventservices.end()) {
- EventSessionTable::iterator session_iterator;
- session_iterator = (s_iterator->second).find(uiSessionId);
- if (session_iterator != (s_iterator->second).end()) {
- ServiceEventProtocolTable::iterator spt_iterator;
- FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, "%s : (found): service [%s]", pApp->cAppName, pServiceName);
-
- spt_iterator = (session_iterator->second).find(iEvent);
- if (spt_iterator != (session_iterator->second).end()) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, "%s : Cmd found [%d] service [%s]",
- pApp->cAppName, iEvent, pServiceName);
- (session_iterator->second).erase(spt_iterator);
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, "%s : Error : Cmd NOT found [%d] service [%s]",
- pApp->cAppName, iEvent, pServiceName);
- }
- }
-
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "%s : Error : Cannot find service [%s]", pApp->cAppName, pServiceName);
- eStatus = eFrameworkunifiedStatusFail;
- }
-
- } else {
- eStatus = eFrameworkunifiedStatusInvldHandle;
- }
-
- return eStatus;
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedAttachNotificationEventsToDispatcher
-/// API to attach a event to the dispatcher on receiving a specific notification.
-////////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedSubscribeNotificationsWithHSMEvent(HANDLE hApp, const FrameworkunifiedNotificationEvent *pNtfyEvent,
- UI_32 uiEventCount) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (frameworkunifiedCheckValidAppHandle(hApp) && pNtfyEvent) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
-
- /// Deal with handling batch processing of subscriptions.
- if (eFrameworkunifiedStatusOK == (eStatus = FrameworkunifiedNPHSMSubscribeToNotificationsEvents(hApp, pNtfyEvent, uiEventCount))) {
- for (UI_32 i = 0; i < uiEventCount; ++i) {
- // service found
- pApp->notificationevents.insert(std::make_pair(pNtfyEvent[ i ].cNotification, pNtfyEvent[ i ].iEventId));
-
- FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, "%s : attaching call-back for notification [%s]", pApp->cAppName,
- pNtfyEvent[ i ].cNotification);
- }
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "%s : Error : [%d] Unable to Subscribe "
- "to batch set of notifications", pApp->cAppName,
- eStatus);
- }
- } else {
- eStatus = eFrameworkunifiedStatusInvldParam;
- }
-
- return eStatus;
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedAttachNotificationEventToDispatcher
-/// API to attach a event to the dispatcher on receiving a specific notification.
-////////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedSubscribeNotificationWithHSMEvent(HANDLE hApp, PCSTR pNotification, UI_32 iEventId) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (frameworkunifiedCheckValidAppHandle(hApp) && pNotification) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
-
- if (eFrameworkunifiedStatusOK == (eStatus = FrameworkunifiedNPHSMSubscribeToNotificationEvent(hApp, pNotification))) {
- // service found
- pApp->notificationevents.insert(std::make_pair(pNotification, iEventId));
-
- FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, "%s : attaching call-back for notification [%s]",
- pApp->cAppName, pNotification);
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "%s : Error : [%d] Unable to Subscribe "
- "to notification [%s]", pApp->cAppName, eFrameworkunifiedStatusOK, pNotification);
- }
- } else {
- eStatus = eFrameworkunifiedStatusInvldHandle;
- }
-
- return eStatus;
-}
-
-
-
-////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedDetachNotificationEventsFromDispatcher
-/// API to detach a notification event from the dispatcher.
-////////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedUnsubscribeNotificationsWithHSMEvent(HANDLE hApp, const FrameworkunifiedNotificationEvent *pNtfyEvent,
- UI_32 uiEventCount) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (frameworkunifiedCheckValidAppHandle(hApp) && pNtfyEvent) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
-
- NotificationEventTable::iterator n_iterator;
- PCSTR pNotification = NULL;
-
- if (eFrameworkunifiedStatusOK == (eStatus = FrameworkunifiedNPHSMUnsubscribeFromNotificationEvents(hApp, pNtfyEvent, uiEventCount))) {
- for (UI_32 l_unCount = 0; l_unCount < uiEventCount; ++l_unCount) {
- pNotification = pNtfyEvent[ l_unCount ].cNotification;
- n_iterator = pApp->notificationevents.find(pNotification);
- if (n_iterator != pApp->notificationevents.end()) {
- pApp->notificationevents.erase(n_iterator);
- FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, "%s : removed notification [%s]", pApp->cAppName, pNotification);
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "%s : Error : Cannot find notification [%s]",
- pApp->cAppName, pNotification);
- eStatus = eFrameworkunifiedStatusFail;
- }
- }
-
- FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, "%s : detaching call-back for notification [%s]",
- pApp->cAppName, pNotification);
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "%s : Error : [%d] Unable to UnSubscribe from notifications ",
- pApp->cAppName, eFrameworkunifiedStatusOK);
- }
- } else {
- eStatus = eFrameworkunifiedStatusInvldHandle;
- }
-
- return eStatus;
-}
-
-
-////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedDetachNotificationEventsFromDispatcher
-/// API to detach a notification event from the dispatcher.
-////////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedUnsubscribeNotificationWithHSMEvent(HANDLE hApp, PCSTR pNotification) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (frameworkunifiedCheckValidAppHandle(hApp) && pNotification) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- NotificationEventTable::iterator n_iterator;
-
- if (eFrameworkunifiedStatusOK == (eStatus = FrameworkunifiedNPHSMUnsubscribeFromNotificationEvent(hApp, pNotification))) {
- // \todo : error handling on all map function calls
- n_iterator = pApp->notificationevents.find(pNotification);
- if (n_iterator != pApp->notificationevents.end()) {
- pApp->notificationevents.erase(n_iterator);
- FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, "%s : removed notification [%s]", pApp->cAppName, pNotification);
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "%s : Error : Cannot find notification [%s]",
- pApp->cAppName, pNotification);
- eStatus = eFrameworkunifiedStatusFail;
- }
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "%s : Error : [%d] Unable to UnSubscribe from notification [%s]",
- pApp->cAppName, eFrameworkunifiedStatusOK, pNotification);
- }
- } else {
- eStatus = eFrameworkunifiedStatusInvldHandle;
- }
-
- return eStatus;
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedGetStateMachine
-/// returns the pointer to the statemachine object
-////////////////////////////////////////////////////////////////////////////////////////////
-CFrameworkunifiedHSMFramework *FrameworkunifiedGetStateMachine(HANDLE hApp) {
- CFrameworkunifiedHSMFramework *l_pHSMFramework = NULL;
-
- if (frameworkunifiedCheckValidAppHandle(hApp)) {
- CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
- l_pHSMFramework = pApp->m_pFrameworkunifiedStateMachine;
- }
-
- return l_pHSMFramework;
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedSetStateMachine
-/// sets the statemachine object
-////////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedSetStateMachine(HANDLE hApp,
- CFrameworkunifiedHSM *f_pFrameworkunifiedHSM) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (frameworkunifiedCheckValidAppHandle(hApp)) {
- if (NULL != f_pFrameworkunifiedHSM) {
- (reinterpret_cast<CFrameworkunifiedFrameworkApp *>(hApp))->m_pFrameworkunifiedStateMachine =
- reinterpret_cast<CFrameworkunifiedHSMFramework *>(f_pFrameworkunifiedHSM);
- } else {
- eStatus = eFrameworkunifiedStatusNullPointer;
- }
- } else {
- eStatus = eFrameworkunifiedStatusInvldHandle;
- }
-
- return eStatus;
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedSubscribeToSessionEventWithHSMEvent
-/// This API is used for subscribing to single event of a service.
-/// This API also attaches the session event with HSM events.
-////////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedSubscribeToSessionEventWithHSMEvent(HANDLE hApp,
- UI_32 uiEventId,
- UI_32 uiHSMEventId,
- HANDLE hSession) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (frameworkunifiedCheckValidAppHandle(hApp) && frameworkunifiedCheckValidMsgQ(hSession)) {
- if (eFrameworkunifiedStatusOK == (eStatus = FrameworkunifiedAttachHSMEventToDispatcher(hApp,
- (reinterpret_cast<MsgQInfo *>(hSession))->cMsgQName, uiEventId,
- uiHSMEventId, hSession))) {
- eStatus = FrameworkunifiedSendMsg(hSession, PROTOCOL_REGISTER_EVENTS, sizeof(UI_32), (PVOID)&uiEventId);
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "FrameworkunifiedAttachCallbackToDispatcher "
- "for PROTOCOL_REGISTER_EVENTS Failed Status:: %d", eStatus);
- }
- } else {
- eStatus = eFrameworkunifiedStatusInvldHandle;
- }
-
- return eStatus;
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedSubscribeToSessionEventsWithHSMEvents
-/// This API is used for subscribing to multiple events of a service.
-/// This API also attaches the session events with hsm events.
-////////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedSubscribeToSessionEventsWithHSMEvents(HANDLE hApp, const FrameworkunifiedProtocolEvent *pEventIds,
- UI_32 uiEventCount,
- HANDLE hSession) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (frameworkunifiedCheckValidAppHandle(hApp) && frameworkunifiedCheckValidMsgQ(hSession) && NULL != pEventIds) {
- eStatus = FrameworkunifiedAttachHSMEventsToDispatcher(hApp,
- (reinterpret_cast<MsgQInfo *>(hSession))->cMsgQName, pEventIds,
- uiEventCount, hSession);
-
- UI_32 l_uiCmdList[uiEventCount]; // NOLINT (readability/nolint)
- for (UI_32 l_uiCnt = 0; l_uiCnt < uiEventCount; l_uiCnt++) {
- l_uiCmdList[l_uiCnt] = pEventIds[l_uiCnt].iCmd;
- }
-
- eStatus = FrameworkunifiedSendMsg(hSession, PROTOCOL_REGISTER_EVENTS, static_cast<UI_32>(uiEventCount * sizeof(UI_32)),
- l_uiCmdList);
- } else {
- eStatus = eFrameworkunifiedStatusInvldHandle;
- }
-
- return eStatus;
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedUnSubscribeSessionEventWithHSMEvent
-/// API to unsubscribe from event of a service. Also detaches HSM event.
-////////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedUnSubscribeSessionEventWithHSMEvent(HANDLE hApp, UI_32 uiEventId, HANDLE hSession) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (frameworkunifiedCheckValidAppHandle(hApp) && frameworkunifiedCheckValidMsgQ(hSession)) {
- eStatus = FrameworkunifiedSendMsg(hSession, PROTOCOL_UNREGISTER_EVENTS, sizeof(uiEventId), (PVOID)&uiEventId);
-
- if (eFrameworkunifiedStatusOK != FrameworkunifiedDetachHSMEventFromDispatcher(hApp,
- (reinterpret_cast<MsgQInfo *>(hSession))->cMsgQName, uiEventId, hSession)) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error : FrameworkunifiedDetachCallbackFromDispatcher failed status:: %d", eStatus);
- }
- } else {
- eStatus = eFrameworkunifiedStatusInvldHandle;
- }
-
- return eStatus;
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedUnSubscribeSessionEventsWithHSMEvents
-/// API to unsubscribe from multiple events of a service. Also detaches HSM events.
-////////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedUnSubscribeSessionEventsWithHSMEvents(HANDLE hApp, PUI_32 pEventsArray, UI_32 uiListSize,
- HANDLE hSession) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if (frameworkunifiedCheckValidAppHandle(hApp) && frameworkunifiedCheckValidMsgQ(hSession) && NULL != pEventsArray) {
- eStatus = FrameworkunifiedSendMsg(hSession, PROTOCOL_UNREGISTER_EVENTS,
- static_cast<UI_32>(uiListSize * sizeof(uiListSize)), pEventsArray);
-
- if (eFrameworkunifiedStatusOK != FrameworkunifiedDetachHSMEventsFromDispatcher(hApp,
- (reinterpret_cast<MsgQInfo *>(hSession))->cMsgQName, pEventsArray,
- uiListSize)) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error : FrameworkunifiedDetachCallbackFromDispatcher failed status:: %d", eStatus);
- }
- } else {
- eStatus = eFrameworkunifiedStatusInvldHandle;
- }
-
- return eStatus;
-}
diff --git a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_guard.cpp b/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_guard.cpp
deleted file mode 100755
index 7afabdb..0000000
--- a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_guard.cpp
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-/// \defgroup <<Group Tag>> <<Group Name>>
-/// \ingroup tag_NSFramework
-/// .
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-/// \ingroup tag_NSFramework
-/// \brief
-///
-/// This file has the CFrameworkunifiedGuard class definitions. This is an interface that defines the Evaluate
-/// interface for guard condition validation.
-///
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-// Include Files
-///////////////////////////////////////////////////////////////////////////////////////////////////
-#include <native_service/frameworkunified_sm_guard.h>
-#include <string>
-CFrameworkunifiedGuard::~CFrameworkunifiedGuard() {
-}
-
-CFrameworkunifiedGuard::CFrameworkunifiedGuard(std::string f_strName): m_strName(f_strName) {
-}
diff --git a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_historystate.cpp b/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_historystate.cpp
deleted file mode 100755
index 9640276..0000000
--- a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_historystate.cpp
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-/// \defgroup <<Group Tag>> <<Group Name>>
-/// \ingroup tag_NSFramework
-/// .
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-/// \ingroup tag_NSFramework
-/// \brief
-///
-/// This file has the CFrameworkunifiedHistoryState class definitions. CFrameworkunifiedHistoryState is derived from
-/// CFrameworkunifiedState class.This class implements the additional functionality supported by HSM History
-/// state.
-///
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-#include <native_service/frameworkunified_sm_hsm.h>
-#include <native_service/frameworkunified_sm_historystate.h>
-#include <native_service/frameworkunified_sm_framework_types.h>
-#include <native_service/frameworkunified_framework_if.h>
-
-#include <string>
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// CFrameworkunifiedHistoryState
-/// Parameterized constructor
-///////////////////////////////////////////////////////////////////////////////////////////
-CFrameworkunifiedHistoryState::CFrameworkunifiedHistoryState(std::string f_pName): CFrameworkunifiedState(f_pName), m_pLastActiveState(NULL), m_uiEventId(0) { // LCOV_EXCL_BR_LINE 11:except branch
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// ~CFrameworkunifiedHistoryState
-/// Class destructor
-///////////////////////////////////////////////////////////////////////////////////////////
-CFrameworkunifiedHistoryState::~CFrameworkunifiedHistoryState() {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_DEV_INFO, __FUNCTION__, "CFrameworkunifiedHistoryState destructor");
-}
-
-CFrameworkunifiedState *CFrameworkunifiedHistoryState::FrameworkunifiedGetActiveState() {
- return this;
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedOnEntry
-/// state initialization can be performed in this function.
-///////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedHistoryState::FrameworkunifiedOnEntry(CEventDataPtr f_pEventData) {
- EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Entering state %s ", m_strStateName.c_str());
-
- try {
- CHKNULL(m_pLastActiveState);
- CHKNULL(m_pEventList);
-
- CFrameworkunifiedExternalTransition *l_pTrnTargetState = new CFrameworkunifiedExternalTransition(m_pLastActiveState);
-
- m_pActiveState = l_pTrnTargetState->FrameworkunifiedReaction(this, f_pEventData);
- CHKNULL(m_pActiveState);
- } catch (std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
-
- l_eStatus = eFrameworkunifiedStatusNullPointer;
- }
- return l_eStatus;
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedOnExit
-/// state cleanup can be performed in this function.
-///////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedHistoryState::FrameworkunifiedOnExit(CEventDataPtr f_pEventData) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Leaving state %s ", m_strStateName.c_str());
- return eFrameworkunifiedStatusOK;
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// SetDefaultHistory
-/// This function sets the default active state in history state
-///////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedHistoryState::SetDefaultHistory() {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- try {
- CHKNULL(m_pParentState); // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h
- m_pLastActiveState = m_pParentState->m_pDefaultState;
- } catch (std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
- eStatus = eFrameworkunifiedStatusNullPointer;
- }
-
- return eStatus; // LCOV_EXCL_BR_LINE 11: except branch
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedOnHSMStart
-/// This function internally calls the Entry function of the current state.
-///////////////////////////////////////////////////////////////////////////////////////////
-CFrameworkunifiedState *CFrameworkunifiedHistoryState::FrameworkunifiedOnHSMStart(CEventDataPtr f_pEventData) {
- CFrameworkunifiedState *l_pActiveState = this;
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- try {
- // Call Entry method of the current state. Entry method of state is called in the order of
- // Hierarchy from Outer state to Inner state
- if (eFrameworkunifiedStatusOK == (eStatus = FrameworkunifiedOnEntry(f_pEventData))) {
- l_pActiveState = m_pActiveState;
- } else {
- // If FrameworkunifiedOnEntry failed then statemachine should report the error
- // We can throw an exception but for now as a quick fix we are setting
- // l_pActiveState as NULL which will stop the statemachine
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error:%d in state %s", eStatus,
- l_pActiveState->m_strStateName.c_str());
- // l_pActiveState = NULL;
- /* Commenting it, because it was making state machine inactive. This should not be the expected behavior.
- * Just log and take no action, if user return non-ok value.
- * User defined error values should be handled separately */
- }
- } catch (std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
- return NULL;
- }
-
- return l_pActiveState;
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedOnHSMStop
-/// This function internally calls the Exit function of the current state.
-///////////////////////////////////////////////////////////////////////////////////////////
-CFrameworkunifiedState *CFrameworkunifiedHistoryState::FrameworkunifiedOnHSMStop(CEventDataPtr f_pEventData) {
- return this;
-}
diff --git a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_hsm.cpp b/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_hsm.cpp
deleted file mode 100755
index f6cdb09..0000000
--- a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_hsm.cpp
+++ /dev/null
@@ -1,529 +0,0 @@
-/*
- * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-//////////////////////////////////////////////////////////////////////////////////////////////////
-/// \defgroup <<Group Tag>> <<Group Name>>
-/// \ingroup tag_NSFramework
-/// .
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-/// \ingroup tag_NSFramework
-/// \brief
-///
-/// This file has the CFrameworkunifiedHSM class definitions. CFrameworkunifiedHSM is base class for HSM Framework.
-/// This class implements interfaces for connecting child states to parent states, connecting events
-/// to state.
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-#include <native_service/frameworkunified_sm_hsm.h>
-#include <native_service/frameworkunified_sm_reaction.h>
-#include <native_service/frameworkunified_sm_state.h>
-#include <native_service/frameworkunified_sm_compositestate.h>
-#include <native_service/frameworkunified_sm_framework_types.h>
-#include <native_service/frameworkunified_sm_orthogonalstate.h>
-#include <native_service/frameworkunified_framework_if.h>
-
-#include <cstdio>
-#include <sstream>
-#include <string>
-
-#include "frameworkunified_framework_internal.h"
-#include "frameworkunified_sm_framework_core.h"
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// CFrameworkunifiedHSM
-/// Class constructor
-///////////////////////////////////////////////////////////////////////////////////////////
-CFrameworkunifiedHSM::CFrameworkunifiedHSM(PVOID f_pHApp): m_uiCurrentEvent(0), m_pHApp(f_pHApp), m_pActiveState(NULL), m_pRootState(NULL),
- m_bIsTransitioning(FALSE) {
- // PostEventList stores the list of events posted in the state
- m_pPostEventList = new EventInfoList();
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// CFrameworkunifiedHSM
-/// Class constructor
-///////////////////////////////////////////////////////////////////////////////////////////
-CFrameworkunifiedHSM::CFrameworkunifiedHSM(): m_uiCurrentEvent(0), m_pHApp(NULL), m_pActiveState(NULL), m_pRootState(NULL),
- m_bIsTransitioning(FALSE) {
- // PostEventList stores the list of events posted in the state
- m_pPostEventList = new EventInfoList();
- m_pHApp = NULL;
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// ~CFrameworkunifiedHSM
-/// Class destructor
-///////////////////////////////////////////////////////////////////////////////////////////
-CFrameworkunifiedHSM::~CFrameworkunifiedHSM() {
- if (NULL != m_pPostEventList) {
- delete m_pPostEventList;
- m_pPostEventList = NULL;
- }
-
- if (m_pRootState) {
- FrameworkunifiedClose();
- }
-
- // we are not deleting this pointer because memory pointed by this pointer
- // had already been deleted in above step.
- m_pActiveState = NULL;
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedGetActiveState
-/// Returns the active state of the statemachine
-///////////////////////////////////////////////////////////////////////////////////////////
-CFrameworkunifiedState *CFrameworkunifiedHSM::FrameworkunifiedGetActiveState() {
- CFrameworkunifiedState *l_pCurrentState = m_pRootState;
- CFrameworkunifiedState *l_pActiveState = NULL;
-
- try {
- // Iterate till the current state is leafstate or orthogonal state
- while (l_pCurrentState != l_pActiveState) {
- l_pActiveState = l_pCurrentState;
- l_pCurrentState = l_pCurrentState->FrameworkunifiedGetActiveState();
- CHKNULL(l_pCurrentState);
- }
-
- // Set active state
- m_pActiveState = l_pActiveState;
-
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Active state is %s "
- , m_pActiveState->m_strStateName.c_str());
- } catch (std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
- l_pActiveState = NULL;
- }
-
-
- return l_pActiveState;
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedStart
-/// This starts the state machine
-///////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedHSM::FrameworkunifiedStart(CEventDataPtr f_pEventData) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- try {
- CHKNULL(m_pActiveState); // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h
-
- m_bIsTransitioning = TRUE;
-
- // Start the state machine execution on current state
- m_pActiveState = m_pActiveState->FrameworkunifiedOnHSMStart(f_pEventData); // LCOV_EXCL_BR_LINE 11:except branch
-
- // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Active state is %s "
- , m_pActiveState->m_strStateName.c_str());
- // LCOV_EXCL_BR_STOP
- // post the event from events list
- eStatus = ProcessEventQueue(); // LCOV_EXCL_BR_LINE 11:except branch
-
- m_bIsTransitioning = FALSE;
- } catch (std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
- eStatus = eFrameworkunifiedStatusNullPointer;
- }
-
- return eStatus;
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedConnect
-/// This connects the reaction to event and add event to child states then add child state
-///////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedHSM::CFrameworkunifiedHSM::FrameworkunifiedConnect(CFrameworkunifiedState *f_pParentState, CFrameworkunifiedState *f_pChildState,
- UI_32 f_uiEventId, CFrameworkunifiedReaction *f_pReaction,
- BOOL f_bIsDefaultState, BOOL f_bIsDeferredEventType,
- std::string f_strEventName) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- try {
- // attach reaction to event and add it to the child state
- eStatus = FrameworkunifiedConnect(f_pChildState, f_uiEventId, f_pReaction, f_strEventName, f_bIsDeferredEventType);
- if (eFrameworkunifiedStatusOK == eStatus) {
- // add child state to parent state
- eStatus = FrameworkunifiedConnect(f_pParentState, f_pChildState, f_bIsDefaultState);
- }
- } catch (std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
-
- eStatus = eFrameworkunifiedStatusNullPointer;
- }
- return eStatus;
-}
-///////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedConnect
-/// This add child state to parent state.
-///////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedHSM::FrameworkunifiedConnect(CFrameworkunifiedState *f_pParentState, CFrameworkunifiedState *f_pChildState,
- BOOL f_bIsDefaultState) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
- try {
- CHKNULL(f_pParentState); // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h
- CHKNULL(f_pChildState); // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h
- // Check if the state is composite state
- if (f_pParentState->FrameworkunifiedHasSubStates()) {
- // Check if the child state is default state
- if (f_bIsDefaultState) {
- // Add child state as default state
- (reinterpret_cast<CFrameworkunifiedCompositeState *>(f_pParentState))->FrameworkunifiedAddState(f_pChildState,
- CFrameworkunifiedCompositeState::eFrameworkunifiedDefaultState); // LCOV_EXCL_BR_LINE 11: except branch
- } else {
- // Add state as regular state
- (reinterpret_cast<CFrameworkunifiedCompositeState *>(f_pParentState))->FrameworkunifiedAddState(f_pChildState); // LCOV_EXCL_BR_LINE 11: except branch
- }
-
- f_pChildState->FrameworkunifiedSetHSM(this); // LCOV_EXCL_BR_LINE 11: except branch
-
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error %s is not a composite state",
- f_pParentState->m_strStateName.c_str());
- }
- } catch (std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
-
- eStatus = eFrameworkunifiedStatusNullPointer;
- }
-
- return eStatus; //LCOV_EXCL_BR_LINE 11:except branch
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedConnect
-/// This connects the reaction to event and add event to child states
-///////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedHSM::FrameworkunifiedConnect(CFrameworkunifiedState *f_pState, UI_32 f_uiEventId, CFrameworkunifiedReaction *f_pReaction,
- std::string f_strEventName , BOOL f_bIsDeferredEventType) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
- try {
- CHKNULL(f_pState); // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h
- // check if the event is deferred event
- if (f_bIsDeferredEventType) {
- // Add event as deferred event
- f_pState->FrameworkunifiedAddDeferredEvent(f_uiEventId, f_strEventName); // LCOV_EXCL_BR_LINE 11: except branch
- // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Deferred Event %d %s is "
- "associated with Reaction and added to state %s "
- , f_uiEventId, f_strEventName.c_str(), (f_pState->m_strStateName).c_str());
- // LCOV_EXCL_BR_STOP
- } else {
- CHKNULL(f_pReaction); // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h
- // Add event as regular event
- f_pState->FrameworkunifiedAddEvent(f_uiEventId, f_pReaction, f_strEventName); // LCOV_EXCL_BR_LINE 11: except branch
-
- // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Event %d %s is associated with Reaction and added to state %s "
- , f_uiEventId, f_strEventName.c_str(), (f_pState->m_strStateName).c_str());
- // LCOV_EXCL_BR_STOP
- }
- } catch (std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: Failed to add event %d in %s", f_uiEventId,
- (f_pState->m_strStateName).c_str());
-
- eStatus = eFrameworkunifiedStatusNullPointer;
- }
-
- return eStatus;;
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedPostEvent
-/// This creates the default event data and sends the event to the active HSM state.
-///////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedHSM::FrameworkunifiedPostEvent(UI_32 f_uiEventId) {
- EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK; // LCOV_EXCL_BR_LINE 11: except branch
- try {
- CEventDataPtr l_pEventData(new CEventData(f_uiEventId)); // LCOV_EXCL_BR_LINE 11:except branch
- CHKNULL(l_pEventData); // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h
-
- l_eStatus = FrameworkunifiedPostEvent(l_pEventData); // LCOV_EXCL_BR_LINE 11: except branch
- } catch (std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
- l_eStatus = eFrameworkunifiedStatusNullPointer;
- }
- return l_eStatus;
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedPostEvent
-/// This sends the event to the active HSM state
-///////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedHSM::FrameworkunifiedPostEvent(CEventDataPtr f_pEventData) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
- try {
- CHKNULL(f_pEventData); // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h
-
- if (m_bIsTransitioning) {
- eStatus = FrameworkunifiedQueueEvent(f_pEventData); // LCOV_EXCL_BR_LINE 11: except branch
- } else {
- m_bIsTransitioning = TRUE;
-
- eStatus = ProcessEvent(f_pEventData); // LCOV_EXCL_BR_LINE 11: except branch
-
- m_bIsTransitioning = FALSE;
-
- CHKNULL(m_pActiveState);
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Active state is %s ", m_pActiveState->m_strStateName.c_str()); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
- }
- } catch (std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
-
- eStatus = eFrameworkunifiedStatusNullPointer;
- }
- return eStatus;
-}
-
-EFrameworkunifiedStatus CFrameworkunifiedHSM::ProcessEvent(CEventDataPtr f_pEventData) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
- try {
- CHKNULL(m_pActiveState); // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h
- CHKNULL(f_pEventData); // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h
- CHKNULL(m_pActiveState->m_pEventName); // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h
-
- EventNameList::iterator l_itEventName;
- l_itEventName = m_pActiveState->m_pEventName->find(f_pEventData->m_uiEventId);
-
- if (m_pActiveState->m_pEventName->end() != l_itEventName) {
- // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Posting event %d %s to state %s",
- f_pEventData->m_uiEventId,
- l_itEventName->second.c_str(),
- m_pActiveState->m_strStateName.c_str());
- // LCOV_EXCL_BR_STOP
- }
-
- m_uiCurrentEvent = f_pEventData->m_uiEventId;
-
- // Send event to active state for processing
- m_pActiveState = m_pActiveState->FrameworkunifiedOnEvent(f_pEventData); // LCOV_EXCL_BR_LINE 11:except branch
-
- CHKNULL(m_pActiveState);
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Active state is %s ", m_pActiveState->m_strStateName.c_str()); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
-
- // post the event from events list
- eStatus = ProcessEventQueue(); // LCOV_EXCL_BR_LINE 11:except branch
- } catch (std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what()); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
-
- eStatus = eFrameworkunifiedStatusNullPointer;
- }
- return eStatus;
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedClose
-/// This stops the state machine and destroys all states and events
-///////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedHSM::FrameworkunifiedClose(CEventDataPtr f_pEventData) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
- try {
- CHKNULL(m_pRootState);
- delete m_pRootState;
- m_pRootState = NULL;
- } catch (std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
-
- eStatus = eFrameworkunifiedStatusNullPointer;
- }
- return eStatus;
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedConnect
-/// This sets the givens state as root state in the state machine
-///////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedHSM::FrameworkunifiedConnect(CFrameworkunifiedState *f_pRootState) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
- try {
- CHKNULL(f_pRootState); // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h
-
- m_pActiveState = f_pRootState;
- m_pRootState = f_pRootState;
-
- m_pRootState->FrameworkunifiedSetHSM(this); // LCOV_EXCL_BR_LINE 11:except branch
- } catch (std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
-
- eStatus = eFrameworkunifiedStatusNullPointer;
- }
- return eStatus; // LCOV_EXCL_BR_LINE 11:except branch
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedPrintAllStates
-/// This prints all states and events associated with every state on console.
-///////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedHSM::FrameworkunifiedPrintAllStates() {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
- try {
- CHKNULL(m_pRootState); // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h
- // Print the states
- m_pRootState->FrameworkunifiedPrintStates();
- } catch (std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
-
- eStatus = eFrameworkunifiedStatusNullPointer;
- }
- return eStatus; // LCOV_EXCL_BR_LINE 11:except branch
-}
-
-EFrameworkunifiedStatus CFrameworkunifiedHSM::FrameworkunifiedConnectOrthogonal(CFrameworkunifiedOrthogonalState *f_pOrthogonalState,
- CFrameworkunifiedCompositeState *f_pOrthogonalRegion) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
- try {
- CHKNULL(f_pOrthogonalState) // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h
- CHKNULL(f_pOrthogonalRegion) // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h
-
- f_pOrthogonalState->FrameworkunifiedAddOrthogonalRegion(f_pOrthogonalRegion);
- } catch (std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
- eStatus = eFrameworkunifiedStatusNullPointer;
- }
- return eStatus;
-}
-
-HANDLE CFrameworkunifiedHSM::FrameworkunifiedGetAppHandle() {
- return m_pHApp;
-}
-
-EFrameworkunifiedStatus CFrameworkunifiedHSM::FrameworkunifiedPrintXML() {
- EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
- try {
- std::ostringstream l_strXMLString;
- l_strXMLString << "<Statemachine>";
-
- CHKNULL(m_pRootState); // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h
-
- // Write statemachine information in XML stream
- m_pRootState->FrameworkunifiedPrintXML(l_strXMLString);
- l_strXMLString << "</Statemachine>";
-
- // Write a stream to XML file
- if (m_pHApp) {
- size_t l_uiLength = static_cast<size_t>(l_strXMLString.str().length());
-
- PCHAR l_pStream = new CHAR[l_uiLength + 1];
- if (NULL != l_pStream) {
- std::FILE *l_pFile = NULL;
-
- std::memset(l_pStream, 0, l_uiLength + 1);
- std::strncpy(l_pStream, l_strXMLString.str().c_str(), l_uiLength);
-
- std::ostringstream l_strFileName;
-
- l_strFileName << "StatemachineXML_";
-
- l_strFileName << FrameworkunifiedGetAppName(m_pHApp) << ".xml";
-
- l_pFile = std::fopen(l_strFileName.str().c_str(), "wbe");
-
- if (l_pFile) {
- std::fwrite(l_pStream, l_uiLength, 1, l_pFile);
- std::fclose(l_pFile);
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "%s File Created"
- , l_strFileName.str().c_str());
- }
- delete[] l_pStream;
- l_pStream = NULL;
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: StatemachineXML_%s.xml file not created", FrameworkunifiedGetAppName(m_pHApp));
- }
- }
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, l_strXMLString.str().c_str());
- } catch (std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
- }
- return l_eStatus;
-}
-
-EFrameworkunifiedStatus CFrameworkunifiedHSM::FrameworkunifiedQueueEvent(CEventDataPtr f_pEventData) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
- try {
- CHKNULL(m_pPostEventList); // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h
- CHKNULL(m_pActiveState); // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h
- CHKNULL(f_pEventData); // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h
-
- // Push the event in the post event list(FIFO)
- m_pPostEventList->push_back(f_pEventData); // LCOV_EXCL_BR_LINE 11:except branch
- } catch (std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
- eStatus = eFrameworkunifiedStatusNullPointer;
- }
- return eStatus; // LCOV_EXCL_BR_LINE 11:except branch
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// ProcessEventQueue
-/// This post the event from events list
-///////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedHSM::ProcessEventQueue() {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- try {
- CHKNULL(m_pPostEventList); // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h
-
- if (!m_pPostEventList->empty()) {
- CEventDataPtr l_pEventData = m_pPostEventList->front(); // LCOV_EXCL_BR_LINE 11:except branch
- CHKNULL(l_pEventData); // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h
-
- CHKNULL(m_pActiveState); // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h
- // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_DEV_INFO, __FUNCTION__, "Processing posted event %d in state %s",
- l_pEventData->m_uiEventId, m_pActiveState->m_strStateName.c_str());
- // LCOV_EXCL_BR_STOP
- m_pPostEventList->erase(m_pPostEventList->begin());
-
- eStatus = ProcessEvent(l_pEventData); // LCOV_EXCL_BR_LINE 11:except branch
- }
- } catch (std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
- eStatus = eFrameworkunifiedStatusNullPointer;
- }
- return eStatus;
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// RemoveEventFromPostedEventQueue
-/// This API is used to remove the all events of eventId f_uiEventId from event queue of statemachine
-///////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedHSM::RemoveEventFromPostedEventQueue(const UI_32 f_uiEventId) {
- EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusInvldID;
- FRAMEWORKUNIFIEDLOG_CUT(ZONE_NS_FUNC, __FUNCTION__, "+");
-
- if (NULL != m_pPostEventList) {
- int32_t l_siCnt = static_cast<int32_t>(m_pPostEventList->size() - 1);
-
- for (; l_siCnt >= 0; l_siCnt--) {
- if (NULL != m_pPostEventList->at(l_siCnt).get()) {
- if (f_uiEventId == m_pPostEventList->at(l_siCnt).get()->m_uiEventId) {
- m_pPostEventList->erase(m_pPostEventList->begin() + l_siCnt);
- l_eStatus = eFrameworkunifiedStatusOK;
- }
- }
- }
- } else {
- l_eStatus = eFrameworkunifiedStatusNullPointer;
- }
-
- FRAMEWORKUNIFIEDLOG_CUT(ZONE_NS_FUNC, __FUNCTION__, "-");
- return l_eStatus;
-}
diff --git a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_hsmframework.cpp b/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_hsmframework.cpp
deleted file mode 100755
index da060f2..0000000
--- a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_hsmframework.cpp
+++ /dev/null
@@ -1,1419 +0,0 @@
-/*
- * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-/// \defgroup <<Group Tag>> <<Group Name>>
-/// \ingroup tag_NSFramework
-/// .
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-/// \ingroup tag_NSFramework
-/// \brief
-///
-/// This file has the CFrameworkunifiedHSMParentFramework class definitions. CFrameworkunifiedHSMParentFramework is derived from
-/// CFrameworkunifiedHSM class. It defines the states required for NS statemachine framework, it creates the NS
-/// statemachine and implements the reaction associated with the events
-///
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-// Include Files
-///////////////////////////////////////////////////////////////////////////////////////////////////
-#include <native_service/frameworkunified_sm_hsmframework.h>
-#include <native_service/frameworkunified_framework_if.h>
-#include <native_service/frameworkunified_framework_types.h>
-#include <native_service/ns_np_service_protocol.h>
-#include <native_service/ns_np_service_notification.h>
-#include <native_service/frameworkunified_sm_framework_dispatch.h>
-#include <native_service/ns_plogger_if.h>
-
-#include <map>
-#include <string>
-
-#include "frameworkunified_framework_core.h"
-#include "frameworkunified_framework_internal.h"
-#include "frameworkunified_framework_utility.h"
-#include "frameworkunified_sm_framework_core.h"
-
-extern EFrameworkunifiedStatus FrameworkunifiedHSMOnLoadData(HANDLE hApp) __attribute__((weak));
-extern EFrameworkunifiedStatus FrameworkunifiedHSMOnStopInsFrameworkunifiedRun(HANDLE hApp) __attribute__((weak));
-
-CFrameworkunifiedHSMFramework::CFrameworkunifiedHSMFramework(): CFrameworkunifiedHSM() {
-}
-CFrameworkunifiedHSMFramework::CFrameworkunifiedHSMFramework(PVOID f_pHApp): CFrameworkunifiedHSM(f_pHApp) {
-}
-CFrameworkunifiedHSMParentFramework::CFrameworkunifiedHSMParentFramework(): CFrameworkunifiedHSMFramework() {
- try {
- m_pFrameworkunifiedStateList = new std::map<UI_32, CFrameworkunifiedState *>();
- } catch (std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
- }
-}
-///////////////////////////////////////////////////////////////////////////////////////////
-/// CFrameworkunifiedHSMParentFramework
-/// default constructor
-///////////////////////////////////////////////////////////////////////////////////////////
-CFrameworkunifiedHSMParentFramework::CFrameworkunifiedHSMParentFramework(PVOID f_pHApp): CFrameworkunifiedHSMFramework(f_pHApp) {
- try {
- m_pFrameworkunifiedStateList = new std::map<UI_32, CFrameworkunifiedState *>();
- } catch (std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
- }
-}
-///////////////////////////////////////////////////////////////////////////////////////////
-/// ~CFrameworkunifiedHSMParentFramework
-/// Class destructor
-///////////////////////////////////////////////////////////////////////////////////////////
-CFrameworkunifiedHSMParentFramework::~CFrameworkunifiedHSMParentFramework() {
- // TODO(framework_unifeid) Auto-generated destructor stub
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedCreate
-/// Statemachine states and events created and connected in this interface.
-///////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::FrameworkunifiedCreate(PVOID f_pEventData) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
- HSMConfigOptions *l_tHSMConfig = NULL;
- try {
- if (f_pEventData) {
- l_tHSMConfig = reinterpret_cast<HSMConfigOptions *>(f_pEventData);
- }
-
- // Create states
- CREATE_STATE(sFrameworkunifiedRoot)
- CREATE_STATE(sFrameworkunifiedApp)
- CREATE_STATE(sFrameworkunifiedInitialization)
- CREATE_STATE(sFrameworkunifiedLoadData)
- CREATE_STATE(sFrameworkunifiedRun)
- CREATE_STATE(sFrameworkunifiedLoadSessions)
- CREATE_STATE(sFrameworkunifiedReady)
- CREATE_STATE(sFrameworkunifiedStop)
- CREATE_STATE(sFrameworkunifiedStopping)
- CREATE_STATE(sFrameworkunifiedPre) // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions
- CREATE_STATE(sFrameworkunifiedBackground) // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions
-
- // connect states as per the statemachine
- CONNECT_DEFAULTSTATE(sFrameworkunifiedRoot, sFrameworkunifiedApp)
- CONNECT_STATE(sFrameworkunifiedRoot, sFrameworkunifiedStop)
-
- CONNECT_DEFAULTSTATE(sFrameworkunifiedApp, sFrameworkunifiedInitialization)
- CONNECT_STATE(sFrameworkunifiedApp, sFrameworkunifiedRun)
-
- CONNECT_DEFAULTSTATE(sFrameworkunifiedInitialization, sFrameworkunifiedLoadData)
- CONNECT_STATE(sFrameworkunifiedInitialization, sFrameworkunifiedPre) // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions
- CONNECT_STATE(sFrameworkunifiedInitialization, sFrameworkunifiedBackground) // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions
-
- CONNECT_DEFAULTSTATE(sFrameworkunifiedRun, sFrameworkunifiedLoadSessions)
- CONNECT_STATE(sFrameworkunifiedRun, sFrameworkunifiedReady)
-
- CONNECT_DEFAULTSTATE(sFrameworkunifiedStop, sFrameworkunifiedStopping)
-
- // Create External Transition
- CREATE_EXTERNALTRANSITION(sFrameworkunifiedApp)
- CREATE_EXTERNALTRANSITION(sFrameworkunifiedStop)
-
- CREATE_EXTERNALTRANSITION(sFrameworkunifiedLoadSessions)
- CREATE_EXTERNALTRANSITION(sFrameworkunifiedReady)
-
- CREATE_EXTERNALTRANSITION(sFrameworkunifiedPre) // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions
- CREATE_EXTERNALTRANSITION(sFrameworkunifiedBackground) // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions
-
- // CREATE_ACTION(aFrameworkunifiedOnStart)
-
- // this is a patch, this code will be fixed once we change the macro for CONNECT_ACTION
- CFrameworkunifiedExternalTransition *l_pTrnsFrameworkunifiedRunevFrameworkunifiedStart = new CFrameworkunifiedExternalTransition(l_psFrameworkunifiedRun);
-
- // CONNECT_ACTION(sFrameworkunifiedRunevFrameworkunifiedStart,aFrameworkunifiedOnStart)
-
- // Connecting events to sFrameworkunifiedInitialization state
- CONNECT_EVENT(sFrameworkunifiedInitialization, evFrameworkunifiedStart, sFrameworkunifiedRunevFrameworkunifiedStart)
- CONNECT_EVENT(sFrameworkunifiedInitialization, evFrameworkunifiedPreStart, sFrameworkunifiedPre) // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions // NOLINT(whitespace/line_length)
- CONNECT_EVENT(sFrameworkunifiedInitialization, evFrameworkunifiedBackgroundStart, sFrameworkunifiedBackground) // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions // NOLINT(whitespace/line_length)
-
- // Create Local transitions
- CREATE_LOCALTRANSITION(sFrameworkunifiedInitialization);
- CREATE_LOCALTRANSITION(sFrameworkunifiedStop);
-
- // Connect events to state
-
- // Connecting events to sFrameworkunifiedLoadData state
- CONNECT_DEFERREDEVENT(sFrameworkunifiedLoadData, evFrameworkunifiedStart)
- CONNECT_DEFERREDEVENT(sFrameworkunifiedLoadData, evFrameworkunifiedUserChange)
- CONNECT_LOCAL_EVENT(sFrameworkunifiedLoadData, evFrameworkunifiedLoadComplete, sFrameworkunifiedInitialization)
-
- // Connecting events to App state
- CONNECT_EVENT(sFrameworkunifiedApp, evFrameworkunifiedStop, sFrameworkunifiedStop)
- CONNECT_LOCAL_EVENT(sFrameworkunifiedStopping, evFrameworkunifiedStopComplete, sFrameworkunifiedStop)
- CONNECT_DEFERREDEVENT(sFrameworkunifiedStopping, evFrameworkunifiedStart)
-
- // Connecting events to Connecting state
- CONNECT_EVENT(sFrameworkunifiedLoadSessions, evFrameworkunifiedReady, sFrameworkunifiedReady)
- // CONNECT_EVENT(sFrameworkunifiedReady,evFrameworkunifiedLoadSessions,sFrameworkunifiedRun)
- CONNECT_EVENT(sFrameworkunifiedReady, evFrameworkunifiedLoadSessions, sFrameworkunifiedLoadSessions)
-
- // Connecting events to Stop state
- CONNECT_EVENT(sFrameworkunifiedStop, evFrameworkunifiedInit, sFrameworkunifiedApp)
-
- // Create internal transitions
- CREATE_INTERNALTRANSITION(OnEventStartInStopState)
- CONNECT_EVENT(sFrameworkunifiedStop, evFrameworkunifiedStart, OnEventStartInStopState)
-
- CREATE_INTERNALTRANSITION(OnEventStopInStoppingState)
- CONNECT_EVENT(sFrameworkunifiedStopping, evFrameworkunifiedStop, OnEventStopInStoppingState)
-
- // Connecting events to sFrameworkunifiedRun state
- CONNECT_EVENT(sFrameworkunifiedRun, evFrameworkunifiedPreStop, sFrameworkunifiedPre) // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions
- CONNECT_EVENT(sFrameworkunifiedRun, evFrameworkunifiedBackgroundStop, sFrameworkunifiedBackground) // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions // NOLINT(whitespace/line_length)
-
- // Connecting events to sFrameworkunifiedBackground state
- CONNECT_EVENT(sFrameworkunifiedBackground, evFrameworkunifiedPreStop, sFrameworkunifiedPre) // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions
-
- if (NULL != l_tHSMConfig) {
- if (eUserchangeIgnore != l_tHSMConfig->eUserChange) {
- if (eUserchangeReInit == l_tHSMConfig->eUserChange) {
- // Create Internal Transition
- CREATE_INTERNALTRANSITION(OnEventUserChangeInInitializationState)
- CONNECT_EVENT(sFrameworkunifiedInitialization, evFrameworkunifiedUserChange, OnEventUserChangeInInitializationState)
-
- // Create Internal Transition
- CREATE_INTERNALTRANSITION(OnEventUserChangeInRunState)
- CONNECT_EVENT(sFrameworkunifiedRun, evFrameworkunifiedUserChange, OnEventUserChangeInRunState)
-
- CREATE_ACTION(aFrameworkunifiedOnStop)
-
- // this is a patch, this code will be fixed once we change the macro for CONNECT_ACTION
- CFrameworkunifiedExternalTransition *l_pTrnsFrameworkunifiedAppevFrameworkunifiedInit = new CFrameworkunifiedExternalTransition(l_psFrameworkunifiedApp);
-
- CONNECT_ACTION(sFrameworkunifiedAppevFrameworkunifiedInit, aFrameworkunifiedOnStop)
-
- CONNECT_EVENT(sFrameworkunifiedApp, evFrameworkunifiedInit, sFrameworkunifiedAppevFrameworkunifiedInit)
-
- } else if (eUserchangeRetPrevState == l_tHSMConfig->eUserChange) {
- CREATE_STATE(sFrameworkunifiedUserChange)
-
- CONNECT_STATE(sFrameworkunifiedRoot, sFrameworkunifiedUserChange)
-
- CREATE_EXTERNALTRANSITION(sFrameworkunifiedUserChange)
-
- CONNECT_EVENT(sFrameworkunifiedApp, evFrameworkunifiedUserChange, sFrameworkunifiedUserChange)
- CONNECT_EVENT(sFrameworkunifiedUserChange, evFrameworkunifiedStop, sFrameworkunifiedStop)
-
- CONNECT_DEFERREDEVENT(sFrameworkunifiedUserChange, evFrameworkunifiedStart)
- CONNECT_DEFERREDEVENT(sFrameworkunifiedUserChange, evFrameworkunifiedUserChange)
-
- // add shallow history state in state sFrameworkunifiedApp
- ADD_SHALLOWHISTORYSTATE(sFrameworkunifiedApp)
-
- // create transition to shallow history state in state sFrameworkunifiedApp
- CREATE_SHALLOWHISTORYTRANSITION(sFrameworkunifiedApp)
-
- // Connecting events to UserChange State
- CONNECT_SHALLOWHISTORYEVENT(sFrameworkunifiedUserChange, evFrameworkunifiedUserChangeComplete, sFrameworkunifiedApp)
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "Incorrect Userchange config option %d", l_tHSMConfig->eUserChange);
- }
- }
- }
-
- // Connecting FrameworkRoot to statemachine
- CONNECTROOT(sFrameworkunifiedRoot)
-
- // Creating the application specific statemachine
- CHKNULL(m_pHApp);
- FrameworkunifiedCreateStateMachineInternal(m_pHApp);
-
- // Print statemachine xml
- PRINT_HSM();
- } catch (std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
-
- eStatus = eFrameworkunifiedStatusNullPointer;
- }
-
- return eStatus;
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedFrameworkConnect
-/// This adds the given state as a sub state of sReady state of the Framework
-///////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::FrameworkunifiedFrameworkConnect(CFrameworkunifiedState *f_pAppState, BOOL f_bIsDefaultState) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
- try {
- CHKNULL(m_pFrameworkunifiedStateList);
- CHKNULL(f_pAppState);
-
- if (m_pFrameworkunifiedStateList->find(esFrameworkunifiedReady) == m_pFrameworkunifiedStateList->end()) {
- throw CNullPointerException();
- }
- CFrameworkunifiedState *l_pReady = reinterpret_cast<CFrameworkunifiedCompositeState *>(m_pFrameworkunifiedStateList->find(esFrameworkunifiedReady)->second);
- CHKNULL(l_pReady);
-
- eStatus = FrameworkunifiedConnect(l_pReady, f_pAppState, f_bIsDefaultState);
- } catch (std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
-
- eStatus = eFrameworkunifiedStatusNullPointer;
- }
-
- return eStatus;
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedFrameworkConnect
-/// This connects the reaction to event and add event to states
-///////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::FrameworkunifiedFrameworkConnect(FRAMEWORKUNIFIED_HSM_STATES f_eFrameworkunifiedState, UI_32 f_uiEventId,
- CFrameworkunifiedReaction *f_pReaction, std::string f_strEventName,
- BOOL f_bIsDeferredEvent) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
- try {
- CHKNULL(m_pFrameworkunifiedStateList);
-
- if (m_pFrameworkunifiedStateList->find(f_eFrameworkunifiedState) == m_pFrameworkunifiedStateList->end()) {
- throw CNullPointerException();
- }
- CFrameworkunifiedState *l_pFrameworkunifiedState = reinterpret_cast<CFrameworkunifiedCompositeState *>(m_pFrameworkunifiedStateList->find(f_eFrameworkunifiedState)->second);
-
- CHKNULL(l_pFrameworkunifiedState);
-
- eStatus = FrameworkunifiedConnect(l_pFrameworkunifiedState, f_uiEventId, f_pReaction, f_strEventName, f_bIsDeferredEvent);
- } catch (std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
-
- eStatus = eFrameworkunifiedStatusNullPointer;
- }
- return eStatus;
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// CsFrameworkunifiedRoot
-/// Parameterized constructor
-///////////////////////////////////////////////////////////////////////////////////////////
-CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedRoot::CsFrameworkunifiedRoot(std::string f_pName): CFrameworkunifiedCompositeState(f_pName) {
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// ~CsFrameworkunifiedRoot
-/// class destructor
-///////////////////////////////////////////////////////////////////////////////////////////
-CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedRoot::~CsFrameworkunifiedRoot() {
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedOnEntry
-/// Initializes the application and registers the service availability notification
-///////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedRoot::FrameworkunifiedOnEntry(CEventDataPtr f_pEventData) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Entering state %s ", m_strStateName.c_str());
-
- HANDLE l_pHApp = FrameworkunifiedGetAppHandle();
- CHKNULL(l_pHApp);
-
- FRAMEWORKUNIFIEDLOG_PERFORMANCE_DEBUG("FrameworkunifiedOnInitialization +");
- if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedOnInitializationInternal(l_pHApp))) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "Warning:Failed to Initialize application:0x%x ", eStatus);
- }
- FRAMEWORKUNIFIEDLOG_PERFORMANCE_DEBUG("FrameworkunifiedOnInitialization -");
-
- // Publish service unavailability
- if (FrameworkunifiedIsAutoPublishServiceAvailableEnabled()) {
- if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedPublishServiceAvailability(l_pHApp, FALSE))) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "Warning:Failed to set service availability notification:0x%x ", eStatus);
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Service unavailable published");
- }
- }
-
- return eStatus;
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedOnExit
-/// state cleanup can be performed in this function.
-///////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedRoot::FrameworkunifiedOnExit(CEventDataPtr f_pEventData) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Leaving state %s ", m_strStateName.c_str());
- return eFrameworkunifiedStatusOK;
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// CsFrameworkunifiedApp
-/// Parameterized constructor
-///////////////////////////////////////////////////////////////////////////////////////////
-CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedApp::CsFrameworkunifiedApp(std::string f_pName): CFrameworkunifiedCompositeState(f_pName) {
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// ~CsFrameworkunifiedRoot
-/// class destructor
-///////////////////////////////////////////////////////////////////////////////////////////
-CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedApp::~CsFrameworkunifiedApp() {
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedOnEntry
-/// Initializes the application and registers the service availability notification
-///////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedApp::FrameworkunifiedOnEntry(CEventDataPtr f_pEventData) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Entering state %s ", m_strStateName.c_str());
- return eStatus;
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedOnExit
-/// state cleanup can be performed in this function.
-///////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedApp::FrameworkunifiedOnExit(CEventDataPtr f_pEventData) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
- try {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Entering state %s ", m_strStateName.c_str());
- } catch (std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
- eStatus = eFrameworkunifiedStatusNullPointer;
- }
-
- return eStatus;
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// CsFrameworkunifiedUserChange
-/// Parameterized constructor
-///////////////////////////////////////////////////////////////////////////////////////////
-CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedUserChange::CsFrameworkunifiedUserChange(std::string f_pName): CFrameworkunifiedLeafState(f_pName) {
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// ~CsFrameworkunifiedRoot
-/// class destructor
-///////////////////////////////////////////////////////////////////////////////////////////
-CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedUserChange::~CsFrameworkunifiedUserChange() {
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedOnEntry
-/// Initializes the application and registers the service availability notification
-///////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedUserChange::FrameworkunifiedOnEntry(CEventDataPtr f_pEventData) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Entering state %s ", m_strStateName.c_str());
-
- if (!FrameworkunifiedIsReactionAvailable(FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedLoadUserData))) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_DEV_INFO, __FUNCTION__, " Reaction not available for evFrameworkunifiedUserChangeComplete");
- FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, " No reaction for loading user specific data ");
-
- FrameworkunifiedPostEvent(FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedUserChangeComplete));
- } else {
- FrameworkunifiedPostEvent(FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedLoadUserData));
- }
-
- return eStatus;
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedOnExit
-/// state cleanup can be performed in this function.
-///////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedUserChange::FrameworkunifiedOnExit(CEventDataPtr f_pEventData) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Leaving state %s ", m_strStateName.c_str());
- return eFrameworkunifiedStatusOK;
-}
-
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// CsFrameworkunifiedInitialization
-/// Parameterized constructor
-///////////////////////////////////////////////////////////////////////////////////////////
-CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedInitialization::CsFrameworkunifiedInitialization(std::string f_pName): CFrameworkunifiedCompositeState(f_pName) {
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// ~CsFrameworkunifiedInitialization
-/// class destructor
-///////////////////////////////////////////////////////////////////////////////////////////
-CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedInitialization::~CsFrameworkunifiedInitialization() {
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedOnEntry
-/// state initialization can be performed in this function.
-///////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedInitialization::FrameworkunifiedOnEntry(CEventDataPtr f_pEventData) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
- try {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Entering state %s ", m_strStateName.c_str());
- } catch (std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
-
- eStatus = eFrameworkunifiedStatusNullPointer;
- }
-
- return eStatus;
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedOnExit
-/// state cleanup can be performed in this function.
-///////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedInitialization::FrameworkunifiedOnExit(CEventDataPtr f_pEventData) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Leaving state %s ", m_strStateName.c_str());
- return eFrameworkunifiedStatusOK;
-}
-
-CFrameworkunifiedState *CFrameworkunifiedHSMParentFramework::COnEventUserChangeInInitializationState::FrameworkunifiedReaction(CFrameworkunifiedState *f_pSourceState,
- CEventDataPtr f_pEventData) {
- try {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "In Reaction OnEventUserChangeInInitializationState");
- CHKNULL(f_pSourceState);
-
- // post the event to move to sFrameworkunifiedApp state
- f_pSourceState->FrameworkunifiedPostEvent(FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedInit));
- } catch (std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
- return NULL;
- }
-
- return f_pSourceState;
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// CsFrameworkunifiedLoadData
-/// Parameterized constructor
-///////////////////////////////////////////////////////////////////////////////////////////
-CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedLoadData::CsFrameworkunifiedLoadData(std::string f_pName): CFrameworkunifiedLeafState(f_pName) {
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// CsFrameworkunifiedLoadData
-/// Parameterized constructor
-///////////////////////////////////////////////////////////////////////////////////////////
-CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedLoadData::~CsFrameworkunifiedLoadData() {
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedOnEntry
-/// state initialization can be performed in this function.
-///////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedLoadData::FrameworkunifiedOnEntry(CEventDataPtr f_pEventData) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Entering state %s ", m_strStateName.c_str());
- try {
- HANDLE l_pHApp = FrameworkunifiedGetAppHandle();
- CHKNULL(l_pHApp);
-
- CHKNULL(FrameworkunifiedGetStateMachine(l_pHApp));
-
- UI_32 l_uiCurrentEventId = FrameworkunifiedGetStateMachine(l_pHApp)->m_uiCurrentEvent;
- if (!(FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedUserChangeComplete) == l_uiCurrentEventId)) {
- if (FrameworkunifiedHSMOnLoadData) {
- if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedHSMOnLoadData(l_pHApp))) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "Warning:Failed to load application data:0x%X ", eStatus);
- }
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "Warning: FrameworkunifiedHSMOnLoadData not defined by the application");
- }
-
- if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedSubscribeNotificationWithHSMEvent(l_pHApp,
- NTFY_NPPService_UserChange,
- FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedUserChange)))) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "FrameworkunifiedSubscribeNotificationWithHSMEvent "
- "NTFY_NPPService_UserChange Failed Status:0x%x ", eStatus);
- return eStatus;
- }
- // Attach callback : Event to start the StateMachine
- if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedAttachHSMEventToDispatcher(l_pHApp,
- FRAMEWORKUNIFIED_ANY_SOURCE,
- NPS_GET_PERS_FILE_ACK,
- FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedLoadFileAck)))) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__,
- "FrameworkunifiedAttachCallbackToDispatcher NPS_GET_PERS_FILE_ACK (FRAMEWORKUNIFIED_ANY_SOURCE) Failed Status:0x%x ", eStatus);
- return eStatus;
- }
- if (!FrameworkunifiedIsReactionAvailable(FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedLoadFileAck))) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, " Reaction not available for evFrameworkunifiedLoadFileAck");
-
- FrameworkunifiedPostEvent(FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedLoadComplete));
- }
- } else {
- FrameworkunifiedPostEvent(FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedLoadComplete));
- }
- } catch (std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
-
- eStatus = eFrameworkunifiedStatusNullPointer;
- }
-
- return eStatus;
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedOnExit
-/// state cleanup can be performed in this function.
-///////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedLoadData::FrameworkunifiedOnExit(CEventDataPtr f_pEventData) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Leaving state %s ", m_strStateName.c_str());
- try {
- HANDLE l_pHApp = FrameworkunifiedGetAppHandle();
- CHKNULL(l_pHApp);
-
- CFrameworkunifiedHSM *l_pHSM = FrameworkunifiedGetStateMachine(l_pHApp);
- CHKNULL(l_pHSM);
-
- UI_32 l_uiCurrentEventId = l_pHSM->m_uiCurrentEvent;
-
- if (FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedStop) == l_uiCurrentEventId) {
- l_pHSM->RemoveEventFromPostedEventQueue(FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedStart));
- }
- } catch (std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
-
- eStatus = eFrameworkunifiedStatusNullPointer;
- }
- return eStatus;
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// CsFrameworkunifiedPre
-/// Parameterized constructor
-///////////////////////////////////////////////////////////////////////////////////////////
-CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedPre::CsFrameworkunifiedPre(std::string f_pName): CFrameworkunifiedCompositeState(f_pName) { // LCOV_EXCL_BR_LINE 11:Excluded due to gcov constraints (others) // NOLINT(whitespace/line_length)
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// ~CsFrameworkunifiedPre
-/// class destructor
-///////////////////////////////////////////////////////////////////////////////////////////
-CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedPre::~CsFrameworkunifiedPre() {
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedOnEntry
-/// state initialization can be performed in this function.
-///////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedPre::FrameworkunifiedOnEntry(CEventDataPtr f_pEventData) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Entering state %s ", m_strStateName.c_str());
-
- HANDLE l_pHApp = FrameworkunifiedGetAppHandle();
- CHKNULL(l_pHApp); // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions
- CHKNULL(f_pEventData); // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions
-
- // Only evFrameworkunifiedPreStart or evFrameworkunifiedPreStop events occur when functions are executed.
- if (f_pEventData->m_uiEventId == FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedPreStart)) {
- FRAMEWORKUNIFIEDLOG_PERFORMANCE_DEBUG("FrameworkunifiedOnPreStartInternal +"); // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions
- eStatus = FrameworkunifiedOnPreStartInternal(l_pHApp);
- if (eFrameworkunifiedStatusOK != eStatus) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "Warning:Failed to pre start application:0x%x ", eStatus);
- }
- FRAMEWORKUNIFIEDLOG_PERFORMANCE_DEBUG("FrameworkunifiedOnPreStartInternal -"); // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions
- } else {
- FRAMEWORKUNIFIEDLOG_PERFORMANCE_DEBUG("FrameworkunifiedOnPreStopInternal +"); // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions
- eStatus = FrameworkunifiedOnPreStopInternal(l_pHApp);
- if (eFrameworkunifiedStatusOK != eStatus) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "Warning:Failed to pre stop application:0x%x ", eStatus);
- }
- FRAMEWORKUNIFIEDLOG_PERFORMANCE_DEBUG("FrameworkunifiedOnPreStopInternal -"); // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions
- }
-
- return eStatus;
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedOnExit
-/// state cleanup can be performed in this function.
-///////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedPre::FrameworkunifiedOnExit(CEventDataPtr f_pEventData) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Leaving state %s ", m_strStateName.c_str());
- return eFrameworkunifiedStatusOK;
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// CsFrameworkunifiedBackground
-/// Parameterized constructor
-///////////////////////////////////////////////////////////////////////////////////////////
-CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedBackground::CsFrameworkunifiedBackground(std::string f_pName): CFrameworkunifiedCompositeState(f_pName) { // LCOV_EXCL_BR_LINE 11:Excluded due to gcov constraints (others) // NOLINT(whitespace/line_length)
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// ~CsFrameworkunifiedBackground
-/// class destructor
-///////////////////////////////////////////////////////////////////////////////////////////
-CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedBackground::~CsFrameworkunifiedBackground() {
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedOnEntry
-/// state initialization can be performed in this function.
-///////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedBackground::FrameworkunifiedOnEntry(CEventDataPtr f_pEventData) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Entering state %s ", m_strStateName.c_str());
-
- HANDLE l_pHApp = FrameworkunifiedGetAppHandle();
- CHKNULL(l_pHApp); // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions
- CHKNULL(f_pEventData); // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions
-
- // Only evFrameworkunifiedBackgroundStart or evFrameworkunifiedBackgroundStop events occur when functions are executed.
- if (f_pEventData->m_uiEventId == FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedBackgroundStart)) {
- FRAMEWORKUNIFIEDLOG_PERFORMANCE_DEBUG("FrameworkunifiedOnBackgroundStartInternal +"); // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions // NOLINT(whitespace/line_length)
- eStatus = FrameworkunifiedOnBackgroundStartInternal(l_pHApp);
- if (eFrameworkunifiedStatusOK != eStatus) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "Warning:Failed to background start application:0x%x ", eStatus);
- }
- FRAMEWORKUNIFIEDLOG_PERFORMANCE_DEBUG("FrameworkunifiedOnBackgroundStartInternal -"); // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions // NOLINT(whitespace/line_length)
- } else {
- FRAMEWORKUNIFIEDLOG_PERFORMANCE_DEBUG("FrameworkunifiedOnBackgroundStopInternal +"); // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions // NOLINT(whitespace/line_length)
- eStatus = FrameworkunifiedOnBackgroundStopInternal(l_pHApp);
- if (eFrameworkunifiedStatusOK != eStatus) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "Warning:Failed to background stop application:0x%x ", eStatus);
- }
- FRAMEWORKUNIFIEDLOG_PERFORMANCE_DEBUG("FrameworkunifiedOnBackgroundStopInternal -"); // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions // NOLINT(whitespace/line_length)
- }
-
- return eStatus;
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedOnExit
-/// state cleanup can be performed in this function.
-///////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedBackground::FrameworkunifiedOnExit(CEventDataPtr f_pEventData) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Leaving state %s ", m_strStateName.c_str());
- return eFrameworkunifiedStatusOK;
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// CsFrameworkunifiedRun
-/// Parameterized constructor
-///////////////////////////////////////////////////////////////////////////////////////////
-CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedRun::CsFrameworkunifiedRun(std::string f_pName): CFrameworkunifiedCompositeState(f_pName) {
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// ~CsFrameworkunifiedRun
-/// class destructor
-///////////////////////////////////////////////////////////////////////////////////////////
-CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedRun::~CsFrameworkunifiedRun() {
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedOnEntry
-/// Subscribes for the service availability notification and calls FrameworkunifiedOnStart
-///////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedRun::FrameworkunifiedOnEntry(CEventDataPtr f_pEventData) {
- EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Entering state %s ", m_strStateName.c_str());
-
- try {
- HANDLE hApp = FrameworkunifiedGetAppHandle();
-
- if (frameworkunifiedCheckValidAppHandle(hApp)) {
- FrameworkunifiedOnStartInternal(hApp);
-
- CFrameworkunifiedFrameworkApp *pApp = reinterpret_cast<CFrameworkunifiedFrameworkApp *>(hApp);
-
- for (UI_32 l_uiCount = 0; l_uiCount < pApp->servicenotificationlist.size(); l_uiCount++) {
- ServiceNotificationInfo objNotification = pApp->servicenotificationlist.at(l_uiCount);
-
- if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedSubscribeNotificationWithHSMEvent
- (hApp, objNotification.sNotificationName, objNotification.uiEventId))) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "failed to subscribe notification %s"
- , objNotification.sNotificationName);
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "successfully subscribe notification %s"
- , objNotification.sNotificationName);
- }
- }
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __PRETTY_FUNCTION__, "Application handle is NULL");
- }
- } catch (std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
-
- l_eStatus = eFrameworkunifiedStatusNullPointer;
- }
-
- return l_eStatus;
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedOnExit
-/// state cleanup can be performed in this function.
-///////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedRun::FrameworkunifiedOnExit(CEventDataPtr f_pEventData) {
- EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Leaving state %s ", m_strStateName.c_str());
-
- try {
- HANDLE hApp = FrameworkunifiedGetAppHandle();
- CFrameworkunifiedFrameworkApp *pApp = reinterpret_cast<CFrameworkunifiedFrameworkApp *>(hApp);
-
- if (frameworkunifiedCheckValidAppHandle(hApp)) {
- // Let application also handle exit of sFrameworkunifiedRun state
- if (FrameworkunifiedHSMOnStopInsFrameworkunifiedRun) {
- if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedHSMOnStopInsFrameworkunifiedRun(hApp))) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "Warning: FrameworkunifiedHSMOnStopInsFrameworkunifiedRun returned: 0x%X ", l_eStatus);
- }
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "Warning: FrameworkunifiedHSMOnStopInsFrameworkunifiedRun not defined by the application");
- }
-
- for (UI_32 l_uiCount = 0; l_uiCount < pApp->servicenotificationlist.size(); l_uiCount++) {
- ServiceNotificationInfo objNotification = pApp->servicenotificationlist.at(l_uiCount);
-
- if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedUnsubscribeNotificationWithHSMEvent(hApp,
- objNotification.sNotificationName))) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "failed to unsubscribe notification %s",
- objNotification.sNotificationName);
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "successfully unsubscribed from notification %s",
- objNotification.sNotificationName);
- }
- }
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __PRETTY_FUNCTION__, "Application handle is NULL");
- }
- } catch (std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
-
- l_eStatus = eFrameworkunifiedStatusNullPointer;
- }
- return l_eStatus;
-}
-
-CFrameworkunifiedState *CFrameworkunifiedHSMParentFramework::COnEventUserChangeInRunState::FrameworkunifiedReaction(CFrameworkunifiedState *f_pSourceState,
- CEventDataPtr f_pEventData) {
- try {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "In Reaction OnEventUserChangeInRunState");
- CHKNULL(f_pSourceState);
-
- // post the event to move to sFrameworkunifiedApp state
- f_pSourceState->FrameworkunifiedPostEvent(FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedInit));
-
- CHKNULL(f_pSourceState);
-
- // post the event to move to sFrameworkunifiedRun state
- f_pSourceState->FrameworkunifiedPostEvent(FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedStart));
- } catch (std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
- return NULL;
- }
- return f_pSourceState;
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// CsFrameworkunifiedLoadSessions
-/// Parameterized constructor
-///////////////////////////////////////////////////////////////////////////////////////////
-CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedLoadSessions::CsFrameworkunifiedLoadSessions(std::string f_pName): CFrameworkunifiedLeafState(f_pName) {
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// ~CsFrameworkunifiedLoadSessions
-/// class destructor
-///////////////////////////////////////////////////////////////////////////////////////////
-CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedLoadSessions::~CsFrameworkunifiedLoadSessions() {
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedOnEntry
-/// state initialization can be performed in this function.
-///////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedLoadSessions::FrameworkunifiedOnEntry(CEventDataPtr f_pEventData) {
- EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
- try {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, " Entering state %s ", m_strStateName.c_str());
-
- HANDLE hApp = FrameworkunifiedGetAppHandle();
- CHKNULL(hApp);
-
- CFrameworkunifiedFrameworkApp *pApp = reinterpret_cast<CFrameworkunifiedFrameworkApp *>(hApp);
-
- if (!pApp->servicenotificationlist.size()) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, " No Mandatory services set ");
-
- FrameworkunifiedPostEvent(FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedReady));
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_DEV_INFO, __FUNCTION__, " Wait for service availability of mandatory services ");
- }
- } catch (std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
-
- l_eStatus = eFrameworkunifiedStatusNullPointer;
- }
-
- return l_eStatus;
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedOnExit
-/// state cleanup can be performed in this function.
-///////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedLoadSessions::FrameworkunifiedOnExit(CEventDataPtr f_pEventData) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Leaving state %s ", m_strStateName.c_str());
- return eFrameworkunifiedStatusOK;
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// CsFrameworkunifiedReady
-/// Parameterized constructor
-///////////////////////////////////////////////////////////////////////////////////////////
-CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedReady::CsFrameworkunifiedReady(std::string f_pName): CFrameworkunifiedCompositeState(f_pName) {
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// ~CsFrameworkunifiedReady
-/// class destructor
-///////////////////////////////////////////////////////////////////////////////////////////
-CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedReady::~CsFrameworkunifiedReady() {
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedOnEntry
-/// state initialization can be performed in this function.
-///////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedReady::FrameworkunifiedOnEntry(CEventDataPtr f_pEventData) {
- EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Entering state %s ", m_strStateName.c_str());
- try {
- HANDLE l_pHApp = FrameworkunifiedGetAppHandle();
- CHKNULL(l_pHApp);
- if (FrameworkunifiedIsAutoPublishServiceAvailableEnabled()) { // LCOV_EXCL_BR_LINE 11:Excluded due to gcov constraints (others)
- // Publish Service available this can also be published from FrameworkunifiedOnStart callback
- if (eFrameworkunifiedStatusOK != (FrameworkunifiedPublishServiceAvailability(l_pHApp, TRUE))) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "warning:Failed to Publish service availability notification:0x%x ",
- l_eStatus);
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Service available published");
- }
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Auto Service available published feature disabled");
- }
- } catch (std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
-
- l_eStatus = eFrameworkunifiedStatusNullPointer;
- }
- return l_eStatus;
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedOnExit
-/// state cleanup can be performed in this function.
-///////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedReady::FrameworkunifiedOnExit(CEventDataPtr f_pEventData) {
- EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Leaving state %s ", m_strStateName.c_str());
- try {
- ServiceSessionTable::iterator session_iterator;
- SessionHandleTable::iterator session_handle_iterator;
-
- HANDLE l_pHApp = FrameworkunifiedGetAppHandle();
- CHKNULL(l_pHApp);
-
- if (FrameworkunifiedIsAutoPublishServiceAvailableEnabled()) { // LCOV_EXCL_BR_LINE 11:Excluded due to gcov constraints (others)
- // Publish Service available this can also be published from FrameworkunifiedOnStart callback
- if (eFrameworkunifiedStatusOK != (FrameworkunifiedPublishServiceAvailability(l_pHApp, FALSE))) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "Warning:Failed to set service availability notification:0x%x ", l_eStatus);
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Service unavailable published");
- }
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Auto Service available published feature disabled");
- }
- } catch (std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
-
- l_eStatus = eFrameworkunifiedStatusNullPointer;
- }
- return l_eStatus;
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// CsFrameworkunifiedStop
-/// Parameterized constructor
-///////////////////////////////////////////////////////////////////////////////////////////
-CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedStop::CsFrameworkunifiedStop(std::string f_pName): CFrameworkunifiedCompositeState(f_pName) {
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// ~CsFrameworkunifiedStop
-/// class destructor
-///////////////////////////////////////////////////////////////////////////////////////////
-CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedStop::~CsFrameworkunifiedStop() {
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedOnEntry
-/// state initialization can be performed in this function.
-///////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedStop::FrameworkunifiedOnEntry(CEventDataPtr f_pEventData) {
- EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Entering state %s ", m_strStateName.c_str());
- try {
- HANDLE l_pHApp = FrameworkunifiedGetAppHandle();
- CHKNULL(l_pHApp);
-
- // every application need to implement this function
- // all the resource deallocation like file release,etc should be done in this callback
- l_eStatus = FrameworkunifiedOnStopInternal(l_pHApp);
- if (eFrameworkunifiedStatusOK != l_eStatus) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "WARNING: FrameworkunifiedOnStop returned %d", l_eStatus);
- // We just need to print the error.
- // Returning this status to state machine is not required.
- // Currently, If not OK is sent to state machine while FrameworkunifiedOnEntry, then state machine becomes dead.
- l_eStatus = eFrameworkunifiedStatusOK; // Therefore assign ok.
- }
- } catch (std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
- l_eStatus = eFrameworkunifiedStatusNullPointer;
- }
- return l_eStatus;
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedOnExit
-/// state cleanup can be performed in this function.
-///////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedStop::FrameworkunifiedOnExit(CEventDataPtr f_pEventData) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Leaving state %s ", m_strStateName.c_str());
- return eFrameworkunifiedStatusOK;
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// CsFrameworkunifiedStopping
-/// Parameterized constructor
-///////////////////////////////////////////////////////////////////////////////////////////
-CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedStopping::CsFrameworkunifiedStopping(std::string f_pName): CFrameworkunifiedLeafState(f_pName) {
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// ~CsFrameworkunifiedStopping
-/// class destructor
-///////////////////////////////////////////////////////////////////////////////////////////
-CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedStopping::~CsFrameworkunifiedStopping() {
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedOnEntry
-/// state initialization can be performed in this function.
-///////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedStopping::FrameworkunifiedOnEntry(CEventDataPtr f_pEventData) {
- EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Entering state %s ", m_strStateName.c_str());
- try {
- if (FrameworkunifiedIsWaitInStoppingStateEnabled()) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "Event evFrameworkunifiedStopComplete not posted. User has to post it.");
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Reaction not available for evFrameworkunifiedStopAck");
- FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "Posting event evFrameworkunifiedStopComplete");
- FrameworkunifiedPostEvent(FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedStopComplete));
- }
- } catch (std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
- l_eStatus = eFrameworkunifiedStatusNullPointer;
- }
- return l_eStatus;
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedOnExit
-/// state cleanup can be performed in this function.
-///////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedStopping::FrameworkunifiedOnExit(CEventDataPtr f_pEventData) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Leaving state %s ", m_strStateName.c_str());
- return eFrameworkunifiedStatusOK;
-}
-
-CFrameworkunifiedState *CFrameworkunifiedHSMParentFramework::COnEventStopInStoppingState::FrameworkunifiedReaction(CFrameworkunifiedState *f_pSourceState,
- CEventDataPtr f_pEventData) {
- try {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "In Reaction OnEventStopInStoppingState");
- CHKNULL(f_pSourceState);
-
- (VOID)f_pSourceState->FrameworkunifiedRemoveEventFromDeferredEventList(FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedStart));
- } catch (std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
- return NULL;
- }
- return f_pSourceState;
-}
-
-CFrameworkunifiedState *CFrameworkunifiedHSMParentFramework::COnEventStartInStopState::FrameworkunifiedReaction(CFrameworkunifiedState *f_pSourceState,
- CEventDataPtr f_pEventData) {
- try {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "In Reaction OnEventStartInStopState");
- CHKNULL(f_pSourceState);
-
- // post the event to move to sFrameworkunifiedApp state
- f_pSourceState->FrameworkunifiedPostEvent(FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedInit));
-
- CHKNULL(f_pSourceState);
-
- // post the event to transit to sFrameworkunifiedRun state
- f_pSourceState->FrameworkunifiedPostEvent(FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedStart));
- } catch (std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
- return NULL;
- }
- return f_pSourceState;
-}
-
-VOID CFrameworkunifiedHSMParentFramework::CaFrameworkunifiedOnStop::FrameworkunifiedAction(CFrameworkunifiedState *f_pSourceState, CFrameworkunifiedState *f_pTargetState,
- CEventDataPtr f_pData) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "In Action %s", m_strName.c_str());
-
- HANDLE l_pHApp = f_pSourceState->FrameworkunifiedGetAppHandle();
- if (NULL != l_pHApp) {
- FrameworkunifiedOnStopInternal(l_pHApp);
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Application handle is NULL in Action %s", m_strName.c_str());
- }
-}
-
-CFrameworkunifiedHSMChildFramework::CFrameworkunifiedHSMChildFramework(): CFrameworkunifiedHSMFramework() {
-}
-
-
-CFrameworkunifiedHSMChildFramework::CFrameworkunifiedHSMChildFramework(PVOID f_pHApp): CFrameworkunifiedHSMFramework(f_pHApp) {
- try {
- m_pFrameworkunifiedStateList = new std::map<UI_32, CFrameworkunifiedState *>();
- } catch (std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
- }
-}
-
-CFrameworkunifiedHSMChildFramework::~CFrameworkunifiedHSMChildFramework() {
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedCreate
-/// Statemachine states and events created and connected in this interface.
-///////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedHSMChildFramework::FrameworkunifiedCreate(PVOID f_pEventData) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
- try {
- // Create states
- CREATE_STATE(sFrameworkunifiedThreadRoot)
- CREATE_STATE(sFrameworkunifiedThreadIdle)
- CREATE_STATE(sFrameworkunifiedThreadStart)
- CREATE_STATE(sFrameworkunifiedThreadReady)
- CREATE_STATE(sFrameworkunifiedThreadStop)
-
- // connect states as per the statemachine
- CONNECT_DEFAULTSTATE(sFrameworkunifiedThreadRoot, sFrameworkunifiedThreadIdle)
- CONNECT_STATE(sFrameworkunifiedThreadRoot, sFrameworkunifiedThreadStart)
- CONNECT_STATE(sFrameworkunifiedThreadRoot, sFrameworkunifiedThreadStop)
- CONNECT_STATE(sFrameworkunifiedThreadRoot, sFrameworkunifiedThreadReady)
-
- // Create External Transition
- CREATE_EXTERNALTRANSITION(sFrameworkunifiedThreadIdle)
- CREATE_EXTERNALTRANSITION(sFrameworkunifiedThreadStart)
- CREATE_EXTERNALTRANSITION(sFrameworkunifiedThreadReady)
- CREATE_EXTERNALTRANSITION(sFrameworkunifiedThreadStop)
-
- // Connect events to state
- CONNECT_EVENT(sFrameworkunifiedThreadIdle, evFrameworkunifiedStart, sFrameworkunifiedThreadStart)
- CONNECT_EVENT(sFrameworkunifiedThreadStart, evFrameworkunifiedReady, sFrameworkunifiedThreadReady)
- CONNECT_EVENT(sFrameworkunifiedThreadStart, evFrameworkunifiedError, sFrameworkunifiedThreadIdle)
- CONNECT_EVENT(sFrameworkunifiedThreadReady, evFrameworkunifiedStop, sFrameworkunifiedThreadStop)
- CONNECT_EVENT(sFrameworkunifiedThreadStop, evFrameworkunifiedStart, sFrameworkunifiedThreadStart)
-
- // Create Internal Transition
- CREATE_INTERNALTRANSITION(OnDestroyThread)
- CONNECT_EVENT(sFrameworkunifiedThreadRoot, evFrameworkunifiedDestroy, OnDestroyThread)
-
- // Connecting AppRoot to statemachine
- CONNECTROOT(sFrameworkunifiedThreadRoot)
- } catch (std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
-
- eStatus = eFrameworkunifiedStatusNullPointer;
- }
- return eStatus;
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// COnDestroyThread::FrameworkunifiedReaction
-/// This reaction is executed when request for terminating the thread is received.
-///////////////////////////////////////////////////////////////////////////////////////////
-CFrameworkunifiedState *CFrameworkunifiedHSMChildFramework::COnDestroyThread::FrameworkunifiedReaction(CFrameworkunifiedState *f_pSourceState,
- CEventDataPtr f_pEventData) {
- // return the NULL to exit the dispatcher loop of thread
- return NULL;
-}
-
-EFrameworkunifiedStatus CFrameworkunifiedHSMChildFramework::FrameworkunifiedFrameworkConnect(CFrameworkunifiedState *f_pAppState, BOOL f_bIsDefaultState) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
- try {
- CHKNULL(m_pFrameworkunifiedStateList);
- CHKNULL(f_pAppState);
-
- if (m_pFrameworkunifiedStateList->find(esFrameworkunifiedThreadReady) == m_pFrameworkunifiedStateList->end()) {
- throw CNullPointerException();
- }
- CFrameworkunifiedState *l_pReady = reinterpret_cast<CFrameworkunifiedCompositeState *>(m_pFrameworkunifiedStateList->find(esFrameworkunifiedThreadReady)->second);
- CHKNULL(l_pReady);
-
- eStatus = FrameworkunifiedConnect(l_pReady, f_pAppState, f_bIsDefaultState);
- } catch (std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
-
- eStatus = eFrameworkunifiedStatusNullPointer;
- }
- return eStatus;
-}
-
-EFrameworkunifiedStatus CFrameworkunifiedHSMChildFramework::FrameworkunifiedFrameworkConnect(FRAMEWORKUNIFIED_HSM_STATES f_eFrameworkunifiedState, UI_32 f_uiEventId,
- CFrameworkunifiedReaction *f_pReaction,
- std::string f_strEventName, BOOL f_bIsDeferredEvent) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
- try {
- CHKNULL(m_pFrameworkunifiedStateList);
-
- if (m_pFrameworkunifiedStateList->find(f_eFrameworkunifiedState) == m_pFrameworkunifiedStateList->end()) {
- throw CNullPointerException();
- }
- CFrameworkunifiedState *l_pFrameworkunifiedState = reinterpret_cast<CFrameworkunifiedCompositeState *>(m_pFrameworkunifiedStateList->find(f_eFrameworkunifiedState)->second);
-
- CHKNULL(l_pFrameworkunifiedState);
-
- eStatus = FrameworkunifiedConnect(l_pFrameworkunifiedState, f_uiEventId, f_pReaction, f_strEventName, f_bIsDeferredEvent);
- } catch (std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
-
- eStatus = eFrameworkunifiedStatusNullPointer;
- }
- return eStatus;
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// CFrameworkunifiedThreadRoot
-/// Parameterized constructor
-///////////////////////////////////////////////////////////////////////////////////////////
-CFrameworkunifiedHSMChildFramework::CsFrameworkunifiedThreadRoot::CsFrameworkunifiedThreadRoot(std::string f_pName)
- : CFrameworkunifiedCompositeState(f_pName) {
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// ~CsFrameworkunifiedThreadRoot
-/// class destructor
-///////////////////////////////////////////////////////////////////////////////////////////
-CFrameworkunifiedHSMChildFramework::CsFrameworkunifiedThreadRoot::~CsFrameworkunifiedThreadRoot() {
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedOnEntry
-/// publishes the service availability notification
-///////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedHSMChildFramework::CsFrameworkunifiedThreadRoot::FrameworkunifiedOnEntry(CEventDataPtr f_pEventData) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Entering state %s ", m_strStateName.c_str());
- return eStatus;
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedOnExit
-/// state cleanup can be performed in this function.
-///////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedHSMChildFramework::CsFrameworkunifiedThreadRoot::FrameworkunifiedOnExit(CEventDataPtr f_pEventData) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Leaving state %s ", m_strStateName.c_str());
- return eFrameworkunifiedStatusOK;
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// CFrameworkunifiedThreadIdle
-/// Parameterized constructor
-///////////////////////////////////////////////////////////////////////////////////////////
-CFrameworkunifiedHSMChildFramework::CsFrameworkunifiedThreadIdle::CsFrameworkunifiedThreadIdle(std::string f_pName)
- : CFrameworkunifiedCompositeState(f_pName) {
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// ~CsFrameworkunifiedThreadIdle
-/// class destructor
-///////////////////////////////////////////////////////////////////////////////////////////
-CFrameworkunifiedHSMChildFramework::CsFrameworkunifiedThreadIdle::~CsFrameworkunifiedThreadIdle() {
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedOnEntry
-/// publishes the service availability notification
-///////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedHSMChildFramework::CsFrameworkunifiedThreadIdle::FrameworkunifiedOnEntry(CEventDataPtr f_pEventData) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Entering state %s ", m_strStateName.c_str());
- return eStatus;
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedOnExit
-/// state cleanup can be performed in this function.
-///////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedHSMChildFramework::CsFrameworkunifiedThreadIdle::FrameworkunifiedOnExit(CEventDataPtr f_pEventData) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Leaving state %s ", m_strStateName.c_str());
- return eFrameworkunifiedStatusOK;
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// CFrameworkunifiedThreadStart
-/// Parameterized constructor
-///////////////////////////////////////////////////////////////////////////////////////////
-CFrameworkunifiedHSMChildFramework::CsFrameworkunifiedThreadStart::CsFrameworkunifiedThreadStart(std::string f_pName)
- : CFrameworkunifiedCompositeState(f_pName) {
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// ~CsFrameworkunifiedThreadStart
-/// class destructor
-///////////////////////////////////////////////////////////////////////////////////////////
-CFrameworkunifiedHSMChildFramework::CsFrameworkunifiedThreadStart::~CsFrameworkunifiedThreadStart() {
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedOnEntry
-/// publishes the service availability notification
-///////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedHSMChildFramework::CsFrameworkunifiedThreadStart::FrameworkunifiedOnEntry(CEventDataPtr f_pEventData) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- try {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Entering state %s ", m_strStateName.c_str());
-
- CFrameworkunifiedFrameworkApp *pApp = reinterpret_cast< CFrameworkunifiedFrameworkApp * >
- (FrameworkunifiedGetAppHandle());
- CHKNULL(reinterpret_cast<CFrameworkunifiedHSMChildFramework *>(pApp->m_pFrameworkunifiedStateMachine));
- CHKNULL((reinterpret_cast<CFrameworkunifiedHSMChildFramework *>(pApp->m_pFrameworkunifiedStateMachine))->m_fpStartThread);
- if (eFrameworkunifiedStatusOK ==
- (reinterpret_cast<CFrameworkunifiedHSMChildFramework *>(pApp->m_pFrameworkunifiedStateMachine))->m_fpStartThread(pApp)) {
- FrameworkunifiedPostEvent(FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedReady));
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, " Thread start Failed: %s", m_strStateName.c_str());
- }
- } catch (std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
-
- eStatus = eFrameworkunifiedStatusNullPointer;
- }
-
- return eStatus;
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedOnExit
-/// state cleanup can be performed in this function.
-///////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedHSMChildFramework::CsFrameworkunifiedThreadStart::FrameworkunifiedOnExit(CEventDataPtr f_pEventData) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Leaving state %s ", m_strStateName.c_str());
- return eFrameworkunifiedStatusOK;
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// CFrameworkunifiedThreadReady
-/// Parameterized constructor
-///////////////////////////////////////////////////////////////////////////////////////////
-CFrameworkunifiedHSMChildFramework::CsFrameworkunifiedThreadReady::CsFrameworkunifiedThreadReady(std::string f_pName)
- : CFrameworkunifiedCompositeState(f_pName) {
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// ~CsFrameworkunifiedThreadReady
-/// class destructor
-///////////////////////////////////////////////////////////////////////////////////////////
-CFrameworkunifiedHSMChildFramework::CsFrameworkunifiedThreadReady::~CsFrameworkunifiedThreadReady() {
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedOnEntry
-/// publishes the service availability notification
-///////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedHSMChildFramework::CsFrameworkunifiedThreadReady::FrameworkunifiedOnEntry(CEventDataPtr f_pEventData) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Entering state %s ", m_strStateName.c_str());
- return eStatus;
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedOnExit
-/// state cleanup can be performed in this function.
-///////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedHSMChildFramework::CsFrameworkunifiedThreadReady::FrameworkunifiedOnExit(CEventDataPtr f_pEventData) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, " Leaving state %s ", m_strStateName.c_str());
- return eFrameworkunifiedStatusOK;
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// CFrameworkunifiedThreadStop
-/// Parameterized constructor
-///////////////////////////////////////////////////////////////////////////////////////////
-CFrameworkunifiedHSMChildFramework::CsFrameworkunifiedThreadStop::CsFrameworkunifiedThreadStop(std::string f_pName)
- : CFrameworkunifiedLeafState(f_pName) {
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// ~CsFrameworkunifiedThreadStop
-/// class destructor
-///////////////////////////////////////////////////////////////////////////////////////////
-CFrameworkunifiedHSMChildFramework::CsFrameworkunifiedThreadStop::~CsFrameworkunifiedThreadStop() {
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedOnEntry
-/// publishes the service availability notification
-///////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedHSMChildFramework::CsFrameworkunifiedThreadStop::FrameworkunifiedOnEntry(CEventDataPtr f_pEventData) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
- try {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Entering state %s ", m_strStateName.c_str());
-
- HANDLE hApp = FrameworkunifiedGetAppHandle();
- CHKNULL(hApp);
- CFrameworkunifiedFrameworkApp *pApp = reinterpret_cast< CFrameworkunifiedFrameworkApp * >
- (hApp);
- CHKNULL(reinterpret_cast<CFrameworkunifiedHSMChildFramework *>(pApp->m_pFrameworkunifiedStateMachine));
- CHKNULL((reinterpret_cast<CFrameworkunifiedHSMChildFramework *>(pApp->m_pFrameworkunifiedStateMachine))->m_fpStopThread);
-
- eStatus = (reinterpret_cast<CFrameworkunifiedHSMChildFramework *>(pApp->m_pFrameworkunifiedStateMachine))->m_fpStopThread(pApp);
-
- if (eFrameworkunifiedStatusOK != eStatus) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "WARNING: Thread stop function returned %d", eStatus);
- // We just need to print the error.
- // Returning this status to state machine is not required.
- // Currently, If not OK is sent to state machine while FrameworkunifiedOnEntry, then state machine becomes dead.
- eStatus = eFrameworkunifiedStatusOK; // Therefore assign ok.
- }
- } catch (std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
-
- eStatus = eFrameworkunifiedStatusNullPointer;
- }
-
- return eStatus;
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedOnExit
-/// state cleanup can be performed in this function.
-///////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedHSMChildFramework::CsFrameworkunifiedThreadStop::FrameworkunifiedOnExit(CEventDataPtr f_pEventData) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Leaving state %s ", m_strStateName.c_str());
- return eFrameworkunifiedStatusOK;
-}
diff --git a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_leafstate.cpp b/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_leafstate.cpp
deleted file mode 100755
index 6c44ebb..0000000
--- a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_leafstate.cpp
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-/// \defgroup <<Group Tag>> <<Group Name>>
-/// \ingroup tag_NSFramework
-/// .
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-/// \ingroup tag_NSFramework
-/// \brief
-///
-/// This file has the CFrameworkunifiedLeafState class definitions. CFrameworkunifiedLeafState is derived from C
-/// FrameworkunifiedState class.This class implements the additional functionality supported by HSM Leafstate.
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-#include <native_service/frameworkunified_sm_leafstate.h>
-#include <native_service/frameworkunified_sm_framework_types.h>
-#include <string>
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// CFrameworkunifiedState
-/// Parameterized constructor
-///////////////////////////////////////////////////////////////////////////////////////////
-CFrameworkunifiedLeafState::CFrameworkunifiedLeafState(std::string f_pName): CFrameworkunifiedState(f_pName) { // LCOV_EXCL_BR_LINE 11:Unexpected branch
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// ~CFrameworkunifiedState
-/// Class destructor
-///////////////////////////////////////////////////////////////////////////////////////////
-CFrameworkunifiedLeafState::~CFrameworkunifiedLeafState() {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "CFrameworkunifiedLeafState destructor");
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedOnEntry
-/// state initialization can be performed in this function.
-///////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedLeafState::FrameworkunifiedOnEntry(CEventDataPtr f_pEventData) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Entering state %s ", m_strStateName.c_str());
- return eFrameworkunifiedStatusOK;
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedOnExit
-/// state cleanup can be performed in this function.
-///////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedLeafState::FrameworkunifiedOnExit(CEventDataPtr f_pEventData) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Leaving state %s ", m_strStateName.c_str());
- return eFrameworkunifiedStatusOK;
-}
-
-CFrameworkunifiedState *CFrameworkunifiedLeafState::FrameworkunifiedGetActiveState() {
- return this;
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////////////
-/// UpdateHistory
-/// This function stores the last active state
-////////////////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedLeafState::UpdateHistory() {
- return eFrameworkunifiedStatusOK;
-}
diff --git a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_localtransition.cpp b/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_localtransition.cpp
deleted file mode 100755
index b5f9c0a..0000000
--- a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_localtransition.cpp
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-// Include Files
-///////////////////////////////////////////////////////////////////////////////////////////////////
-#include <native_service/frameworkunified_sm_localtransition.h>
-#include <native_service/frameworkunified_sm_state.h>
-#include <native_service/frameworkunified_sm_framework_types.h>
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// CFrameworkunifiedExternalTransition
-/// Parameterized constructor
-///////////////////////////////////////////////////////////////////////////////////////////
-CFrameworkunifiedLocalTransition::CFrameworkunifiedLocalTransition(CFrameworkunifiedState *f_pTargetState): CFrameworkunifiedTransition(f_pTargetState) {
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// ~CFrameworkunifiedExternalTransition
-/// Class destructor
-///////////////////////////////////////////////////////////////////////////////////////////
-CFrameworkunifiedLocalTransition::~CFrameworkunifiedLocalTransition() {
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedReaction
-/// The reaction for an event is implemented in this function. For local transition from inner
-/// state to outer state exit of the inner state is invoked, but entry of outer state is not
-/// invoked and from outer state to inner state entry of the inner state is invoked but exit of
-/// outer state is not invoked
-///////////////////////////////////////////////////////////////////////////////////////////
-CFrameworkunifiedState *CFrameworkunifiedLocalTransition::FrameworkunifiedReaction(CFrameworkunifiedState *f_pSourceState, CEventDataPtr f_pData) {
- CFrameworkunifiedState *l_pActiveState = NULL;
- CFrameworkunifiedState *l_pCurrentState = NULL;
- try {
- CHKNULL(f_pSourceState); // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h
- CHKNULL(m_pTargetState); // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h
-
- // Local transition from inner state to outer state
- if (f_pSourceState->m_pParentState == m_pTargetState) {
- // Source is child of target
- l_pCurrentState = f_pSourceState->FrameworkunifiedOnHSMStop(f_pData);
-
- if (l_pCurrentState == f_pSourceState) {
- l_pActiveState = m_pTargetState;
-
- } else {
- l_pActiveState = l_pCurrentState;
- }
-
- /**
- * @todo
- * If the parent state is registered and OnEvent is performed without OrthogonalReigonList, illegal accesses occur.
- */
- l_pActiveState->m_pActiveState = NULL;
-
- // Local transition from outer state to inner state
- } else if (f_pSourceState == m_pTargetState->m_pParentState) {
- // Source is parent to target state
- l_pActiveState = m_pTargetState->FrameworkunifiedOnHSMStart(f_pData);
- }
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "Local Transition from state %s to state %s"
- , f_pSourceState->m_strStateName.c_str(), m_pTargetState->m_strStateName.c_str());
- } catch (std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
-
- return NULL;
- }
-
- return l_pActiveState;
-}
diff --git a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_multithreading.cpp b/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_multithreading.cpp
deleted file mode 100755
index 33dab56..0000000
--- a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_multithreading.cpp
+++ /dev/null
@@ -1,211 +0,0 @@
-/*
- * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-//////////////////////////////////////////////////////////////////////////////////////////////////
-/// \ingroup tag_NSFramework
-/// \brief This file has the function implementation for creating state machine child thread
-///
-///
-//////////////////////////////////////////////////////////////////////////////////////////////////
-#include <sys/prctl.h>
-
-#include <native_service/frameworkunified_sm_hsmframework.h>
-#include <native_service/frameworkunified_sm_framework_dispatch.h>
-#include <native_service/frameworkunified_framework_if.h>
-#include <native_service/ns_utility.hpp>
-#include <native_service/ns_system_mode.h>
-#include <native_service/frameworkunified_sm_multithreading.h>
-#include <native_service/frameworkunified_multithreading.h>
-
-#include <iostream>
-#include <string>
-
-#include "frameworkunified_framework_utility.h"
-#include "frameworkunified_framework_core.h"
-#include "frameworkunified_framework_internal.h"
-
-////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedCreateHSMDispatcherChild
-////////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus FrameworkunifiedCreateHSMDispatcherChild(PCSTR childName,
- PCSTR parentName,
- HANDLE &hChildApp, // NOLINT (readability/nolint)
- CbFuncPtr pOnThreadStart,
- CbFuncPtr pOnThreadStop) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- if ((NULL != childName) && (NULL != parentName) && (strlen(childName) <= MAX_NAME_SIZE_APP) &&
- (strlen(parentName) <= MAX_NAME_SIZE_APP)) {
- if (eFrameworkunifiedStatusOK == (eStatus = FrameworkunifiedCreateHSMDispatcher(childName, hChildApp, TRUE))) {
- if (frameworkunifiedCheckValidAppHandle(hChildApp)) {
- CFrameworkunifiedFrameworkApp *pApp = reinterpret_cast< CFrameworkunifiedFrameworkApp * >(hChildApp);
-
- (reinterpret_cast<CFrameworkunifiedHSMChildFramework *>(pApp->m_pFrameworkunifiedStateMachine))->m_fpStartThread
- = pOnThreadStart;
-
- (reinterpret_cast<CFrameworkunifiedHSMChildFramework *>(pApp->m_pFrameworkunifiedStateMachine))->m_fpStopThread
- = pOnThreadStop;
-
- pApp->hParentSndMsgQ = McOpenSender(parentName);
- if (NULL == pApp->hParentSndMsgQ) {
- eStatus = eFrameworkunifiedStatusNullPointer;
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "McOpenSender failed");
- return eStatus;
- }
- pApp->uiSessionId = THREAD_SESSION_ID;
-
- memset(pApp->cParentAppName, 0, sizeof(pApp->cParentAppName));
- memcpy(pApp->cParentAppName, parentName, strlen(parentName));
- } else {
- eStatus = eFrameworkunifiedStatusNullPointer;
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "hChildApp is NULL");
- }
- } else {
- // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "FrameworkunifiedCreateHSMDispatcher error, status=%d", eStatus);
- // LCOV_EXCL_BR_STOP
- }
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Invalid Param received"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
- eStatus = eFrameworkunifiedStatusInvldParam;
- }
-
- return eStatus;
-}
-
-void *child_hsm_thread_proc(void *args) {
- if (args == NULL) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "args is NULL");
- return NULL;
- }
- PCData pcdata = *reinterpret_cast< PCData * >(args); // Create a local copy of data
-
- try {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- HANDLE hFrameworkApp = NULL;
-
- if (eFrameworkunifiedStatusOK == (eStatus = FrameworkunifiedCreateHSMDispatcherChild(pcdata.childName.c_str(),
- pcdata.parentName.c_str(),
- hFrameworkApp,
- pcdata.initFn,
- pcdata.shdnFn))) {
- if (NULL != hFrameworkApp) {
- THApp hChildApp(hFrameworkApp);
-
- if (pcdata.CbCreateStateMachine) {
- pcdata.CbCreateStateMachine(hChildApp);
- FRAMEWORKUNIFIED_PRINT_HSM(hChildApp)
- }
- const FrameworkunifiedProtocolEvent pcbhs[] = { { SYSTEM_ON_INITIALIZATION, FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedStart) },
- { SYSTEM_ON_SHUTDOWN, FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedStop) },
- { SYSTEM_ON_DESTROY, FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedDestroy) }
- };
-
- if (eFrameworkunifiedStatusOK != FrameworkunifiedAttachHSMEventsToDispatcher(hChildApp,
- pcdata.parentName.c_str(),
- &pcbhs[ 0 ],
- static_cast<UI_32>(_countof(pcbhs)),
- NULL)) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: Failed to attach hsm events to child thread %s",
- pcdata.childName.c_str());
- }
-
- // set child thread name
- char thread_name[16];
- strncpy(thread_name, pcdata.childName.c_str(), sizeof(thread_name));
- prctl(PR_SET_NAME, thread_name);
- thread_name[15] = '\0';
-
- setChildThreadSched(pcdata.schedPolicy, pcdata.schedPriority);
-
- (FrameworkunifiedGetStateMachine(hChildApp))->FrameworkunifiedStart();
-
- *pcdata.childStatus = eFrameworkunifiedStatusOK;
- if (IsValidWaitBarrier(pthread_barrier_wait(pcdata.barrier))) {
- RunChildDispatcher(hChildApp);
- }
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "hFrameworkApp is NULL");
- }
- } else {
- // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "FrameworkunifiedCreateHSMDispatcherChild error, status=%d", eStatus);
- // LCOV_EXCL_BR_STOP
-
- *pcdata.childStatus = eFrameworkunifiedStatusFail;
- pthread_barrier_wait(pcdata.barrier);
- }
- } catch (const THApp::Exception &) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: Failed to create child %s", pcdata.childName.c_str());
- }
-
- return NULL;
-}
-
-
-
-////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedCreateHSMChildThread
-////////////////////////////////////////////////////////////////////////////////////////////
-HANDLE FrameworkunifiedCreateHSMChildThread(HANDLE hApp, PCSTR childName, CbFuncPtr CbInitialize,
- CbFuncPtr CbShutdown, CbFuncPtr CbCreateStateMachine) {
- HANDLE hChildQ = NULL;
- FrameworkunifiedChildThreadAttr attr;
-
- if (frameworkunifiedCheckValidAppHandle(hApp) && NULL != childName && NULL != CbInitialize && NULL != CbShutdown &&
- NULL != CbCreateStateMachine) {
- CreateChildThreadAttrInit(&attr);
- hChildQ = CreateChildThread(hApp, childName, CbInitialize, CbShutdown, &attr, CbCreateStateMachine);
- }
-
- return hChildQ;
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedCreateHSMChildThreadWithPriority
-////////////////////////////////////////////////////////////////////////////////////////////
-HANDLE FrameworkunifiedCreateHSMChildThreadWithPriority(HANDLE hApp, PCSTR childName, CbFuncPtr CbInitialize,
- CbFuncPtr CbShutdown, CbFuncPtr CbCreateStateMachine, SI_32 schedPrio) {
- HANDLE hChildQ = NULL;
- FrameworkunifiedChildThreadAttr attr;
-
- if (frameworkunifiedCheckValidAppHandle(hApp) && NULL != childName && NULL != CbInitialize && NULL != CbShutdown &&
- NULL != CbCreateStateMachine) {
- CreateChildThreadAttrInit(&attr);
- CreateChildThreadAttrSetSched(&attr, eFrameworkunifiedSchedPolicyRR, schedPrio);
- hChildQ = CreateChildThread(hApp, childName, CbInitialize, CbShutdown, &attr, CbCreateStateMachine);
- }
- return hChildQ;
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedCreateHSMChildThreadWithAttribute
-////////////////////////////////////////////////////////////////////////////////////////////
-HANDLE FrameworkunifiedCreateHSMChildThreadWithAttribute(HANDLE hApp,
- PCSTR childName,
- CbFuncPtr CbInitialize,
- CbFuncPtr CbShutdown,
- CbFuncPtr CbCreateStateMachine,
- const FrameworkunifiedChildThreadAttr *attr) {
- HANDLE hChildQ = NULL;
-
- if (frameworkunifiedCheckValidAppHandle(hApp) && NULL != childName && NULL != CbInitialize && NULL != CbShutdown &&
- NULL != CbCreateStateMachine) {
- hChildQ = CreateChildThread(hApp, childName, CbInitialize, CbShutdown, attr, CbCreateStateMachine);
- }
- return hChildQ;
-}
diff --git a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_orthogonalstate.cpp b/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_orthogonalstate.cpp
deleted file mode 100755
index a8289a0..0000000
--- a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_orthogonalstate.cpp
+++ /dev/null
@@ -1,337 +0,0 @@
-/*
- * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-/// \defgroup <<Group Tag>> <<Group Name>>
-/// \ingroup tag_NSFramework
-/// .
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-/// \ingroup tag_NSFramework
-/// \brief
-///
-/// This file has the CFrameworkunifiedOrthogonalState class definitions. CFrameworkunifiedOrthogonalState is derived from
-/// CFrameworkunifiedCompositeState class.This class implements the additional functionality supported by HSM
-/// Orthogonal state. It provides the standard interfaces for adding orthogonal state machines.
-///
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-#include <native_service/frameworkunified_sm_orthogonalstate.h>
-#include <native_service/frameworkunified_sm_compositestate.h>
-#include <native_service/frameworkunified_sm_framework_types.h>
-#include <native_service/frameworkunified_sm_hsm.h>
-#include <sstream>
-#include <string>
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// CFrameworkunifiedCompositeState
-/// Parameterized constructor
-///////////////////////////////////////////////////////////////////////////////////////////
-CFrameworkunifiedOrthogonalState::CFrameworkunifiedOrthogonalState(std::string f_pName): CFrameworkunifiedState(f_pName) {
- try {
- m_pOrthogonalReigonList = new OrthogonalRegionList();
- } catch (std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
- }
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// ~CFrameworkunifiedOrthogonalState
-/// Class destructor
-///////////////////////////////////////////////////////////////////////////////////////////
-CFrameworkunifiedOrthogonalState::~CFrameworkunifiedOrthogonalState() {
- for (UI_32 l_uiCount = 0; l_uiCount < m_pOrthogonalReigonList->size(); l_uiCount++) {
- if (m_pOrthogonalReigonList->at(l_uiCount)) {
- delete m_pOrthogonalReigonList->at(l_uiCount);
- }
- }
- m_pOrthogonalReigonList->clear();
- FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "CFrameworkunifiedOrthogonalState destructor");
-}
-///////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedOnEntry
-/// state initialization can be performed in this function.
-///////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedOrthogonalState::FrameworkunifiedOnEntry(CEventDataPtr f_pEventData) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Entering state %s ", m_strStateName.c_str());
- return eFrameworkunifiedStatusOK;
-}
-///////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedOnExit
-/// state cleanup can be performed in this function.
-///////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedOrthogonalState::FrameworkunifiedOnExit(CEventDataPtr f_pEventData) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Leaving state %s ", m_strStateName.c_str());
- return eFrameworkunifiedStatusOK;
-}
-
-EFrameworkunifiedStatus CFrameworkunifiedOrthogonalState::FrameworkunifiedAddOrthogonalRegion(CFrameworkunifiedCompositeState *f_pOrthogonalRegion) {
- try {
- CHKNULL(f_pOrthogonalRegion);
- CHKNULL(m_pOrthogonalReigonList);
- f_pOrthogonalRegion->m_pParentState = this;
- m_pOrthogonalReigonList->push_back(f_pOrthogonalRegion);
- } catch (std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
- return eFrameworkunifiedStatusNullPointer;
- }
-
- return eFrameworkunifiedStatusOK;
-}
-
-CFrameworkunifiedState *CFrameworkunifiedOrthogonalState::FrameworkunifiedOnHSMStart(CEventDataPtr f_pEventData) {
- CFrameworkunifiedState *l_pCurrentState = NULL;
- CFrameworkunifiedState *l_pActiveState = NULL;
-
- try {
- FrameworkunifiedOnEntry(f_pEventData);
-
- CHKNULL(m_pOrthogonalReigonList);
- for (UI_32 l_uiCount = 0; l_uiCount < m_pOrthogonalReigonList->size(); l_uiCount++) {
- if (m_pOrthogonalReigonList->at(l_uiCount)) {
- l_pActiveState = (m_pOrthogonalReigonList->at(l_uiCount));
- CHKNULL(l_pActiveState);
-
- l_pCurrentState = l_pActiveState->FrameworkunifiedOnHSMStart(f_pEventData);
- CHKNULL(l_pCurrentState);
-
- if (!IsOrthogonalChildState(l_pCurrentState)) {
- break;
- } else {
- l_pCurrentState = this;
- }
- }
- }
-
- // set current state as the active state of its parent state to maintain the Hierarchy
- if (m_pParentState) {
- m_pParentState->m_pActiveState = l_pCurrentState;
- }
- } catch (std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
- return NULL;
- }
-
- return l_pCurrentState;
-}
-
-CFrameworkunifiedState *CFrameworkunifiedOrthogonalState::FrameworkunifiedOnHSMStop(CEventDataPtr f_pEventData) {
- CFrameworkunifiedState *l_pCurrentState = NULL;
- CFrameworkunifiedState *l_pActiveState = NULL;
-
- try {
- CHKNULL(m_pOrthogonalReigonList);
- for (UI_32 l_uiCount = 0; l_uiCount < m_pOrthogonalReigonList->size(); l_uiCount++) {
- if (m_pOrthogonalReigonList->at(l_uiCount)) {
- l_pActiveState = (m_pOrthogonalReigonList->at(l_uiCount));
- CHKNULL(l_pActiveState);
-
- l_pCurrentState = l_pActiveState->FrameworkunifiedOnHSMStop(f_pEventData);
- CHKNULL(l_pCurrentState);
-
- if (!IsOrthogonalChildState(l_pCurrentState)) {
- break;
- } else {
- l_pCurrentState = this;
- }
- }
- }
- FrameworkunifiedOnExit(f_pEventData);
- } catch (std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
- return NULL;
- }
-
- return l_pCurrentState;
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedOnEvent
-/// This function processes the event. If the reaction for event is available in the current
-/// state within eventlist and deferred eventlist then it is consumed in the current state
-/// otherwise forwarded to the parent state. Event forwarding is done recursively till either
-/// event is consumed or the root state has encountered. This also process the events posted
-/// in the reactions recursively till all posted events are cleared.
-///////////////////////////////////////////////////////////////////////////////////////////
-CFrameworkunifiedState *CFrameworkunifiedOrthogonalState::FrameworkunifiedOnEvent(CEventDataPtr f_pEventData) {
- CFrameworkunifiedState *l_pCurrentState = NULL;
- CFrameworkunifiedState *l_pStateIterator = NULL;
- CFrameworkunifiedState *l_pOrthogonalRegion = NULL;
- BOOL l_bReactionAvailable = FALSE;
- BOOL l_bIsEventProcessed = FALSE;
-
- try {
- for (UI_32 l_uiCount = 0; l_uiCount < m_pOrthogonalReigonList->size(); l_uiCount++) {
- l_pOrthogonalRegion = m_pOrthogonalReigonList->at(l_uiCount);
-
- if (l_pOrthogonalRegion) {
- // get the current active state
- l_pCurrentState = l_pOrthogonalRegion->FrameworkunifiedGetActiveState();
- CHKNULL(l_pCurrentState);
-
- l_pStateIterator = l_pCurrentState;
-
- // checks whether the reaction for the event is available in this orthogonal region
- while (this != l_pStateIterator) {
- if (l_pStateIterator->FrameworkunifiedIsReactionAvailable(f_pEventData->m_uiEventId)) {
- l_bReactionAvailable = TRUE;
- l_bIsEventProcessed = TRUE;
- break;
- }
-
- // iterate to parent state in orthogonal region
- l_pStateIterator = l_pStateIterator->m_pParentState;
- }
-
- // if reaction is found, post the event
- if (l_bReactionAvailable) {
- l_bReactionAvailable = FALSE;
-
- l_pCurrentState = l_pCurrentState->FrameworkunifiedOnEvent(f_pEventData);
- CHKNULL(l_pCurrentState);
-
- // check whether current active state is within the orthogonal state
- if (IsOrthogonalChildState(l_pCurrentState)) {
- l_pCurrentState = this;
- }
-
- break;
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "Reaction not available in orthogonal region %s",
- l_pOrthogonalRegion->m_strStateName.c_str());
- l_pCurrentState = this;
- }
- }
- }
-
- // if event is not processed in any of orthogonal region, post the event to orthogonal state
- if (!l_bIsEventProcessed) {
- l_pCurrentState = CFrameworkunifiedState::FrameworkunifiedOnEvent(f_pEventData);
-
- // check whether current active state is within the orthogonal state
- if (IsOrthogonalChildState(l_pCurrentState)) {
- l_pCurrentState = this;
- }
- }
- } catch (std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
- return NULL;
- }
-
- return l_pCurrentState;
-}
-
-BOOL CFrameworkunifiedOrthogonalState::FrameworkunifiedHasOrthogoanlRegions() {
- try {
- CHKNULL(m_pOrthogonalReigonList);
-
- if (m_pOrthogonalReigonList->size()) {
- return TRUE;
- } else {
- return FALSE;
- }
- } catch (std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
- return FALSE;
- }
-}
-
-EFrameworkunifiedStatus CFrameworkunifiedOrthogonalState::FrameworkunifiedPrintStates() {
- EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
-
- try {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "%s:%s",
- (m_pParentState->m_strStateName).c_str(), m_strStateName.c_str());
-
- for (UI_32 l_uiCount = 0; l_uiCount < m_pOrthogonalReigonList->size(); l_uiCount++) {
- if (m_pOrthogonalReigonList->at(l_uiCount)) {
- m_pOrthogonalReigonList->at(l_uiCount)->FrameworkunifiedPrintStates();
- }
- }
- } catch (std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
- return eFrameworkunifiedStatusNullPointer;
- }
- return l_eStatus;
-}
-
-BOOL CFrameworkunifiedOrthogonalState::IsOrthogonalChildState(CFrameworkunifiedState *f_pChildState) {
- CFrameworkunifiedState *l_pParentState = f_pChildState;
- BOOL l_bIsOrthgonalChild = FALSE;
- while (l_pParentState) {
- if (this == l_pParentState) {
- l_bIsOrthgonalChild = TRUE;
- break;
- }
-
- l_pParentState = l_pParentState->m_pParentState;
- }
-
- return l_bIsOrthgonalChild;
-}
-
-CFrameworkunifiedState *CFrameworkunifiedOrthogonalState::FrameworkunifiedGetActiveState() {
- return this;
-}
-
-EFrameworkunifiedStatus CFrameworkunifiedOrthogonalState::FrameworkunifiedSetHSM(CFrameworkunifiedHSM *f_pStatemachine) {
- EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
- try {
- CHKNULL(f_pStatemachine);
- for (UI_32 l_uiCount = 0; l_uiCount < m_pOrthogonalReigonList->size();
- l_uiCount++) {
- if (m_pOrthogonalReigonList->at(l_uiCount)) {
- m_pOrthogonalReigonList->at(l_uiCount)->FrameworkunifiedSetHSM(f_pStatemachine);
- }
- }
- m_pStateMachine = f_pStatemachine;
- } catch (std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
- l_eStatus = eFrameworkunifiedStatusNullPointer;
- }
- return l_eStatus;
-}
-
-EFrameworkunifiedStatus CFrameworkunifiedOrthogonalState::FrameworkunifiedPrintXML(std::ostringstream &f_strXMLString) {
- EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
-
- try {
- f_strXMLString << "<" << m_strStateName.c_str() << ">";
- f_strXMLString << "<OrthogonalRegions>";
-
- for (UI_32 l_uiCount = 0; l_uiCount < m_pOrthogonalReigonList->size(); l_uiCount++) {
- if (m_pOrthogonalReigonList->at(l_uiCount)) {
- m_pOrthogonalReigonList->at(l_uiCount)->FrameworkunifiedPrintXML(f_strXMLString);
- }
- }
-
- f_strXMLString << "</OrthogonalRegions>";
- f_strXMLString << "</" << m_strStateName.c_str() << ">";
- } catch (std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
- return eFrameworkunifiedStatusNullPointer;
- }
- return l_eStatus;
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////////////
-/// UpdateHistory
-/// This function stores the last active state
-////////////////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedOrthogonalState::UpdateHistory() {
- return eFrameworkunifiedStatusOK;
-}
diff --git a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_shallowhistorystate.cpp b/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_shallowhistorystate.cpp
deleted file mode 100755
index 97b6e3b..0000000
--- a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_shallowhistorystate.cpp
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-/// \defgroup <<Group Tag>> <<Group Name>>
-/// \ingroup tag_NSFramework
-/// .
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-/// \ingroup tag_NSFramework
-/// \brief
-///
-/// This file has the CFrameworkunifiedShallowHistoryState class definitions. CFrameworkunifiedShallowHistoryState is derived
-/// from CFrameworkunifiedHistoryState class.This class implements the additional functionality supported by
-/// HSM ShallowHistory state.
-///
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-#include <native_service/frameworkunified_sm_shallowhistorystate.h>
-#include <native_service/frameworkunified_sm_framework_types.h>
-#include <string>
-
-// define static members of class
-const UI_32 CFrameworkunifiedShallowHistoryState::m_suievShallowHistory = 71;
-
-////////////////////////////////////////////////////////////////////////////////////////////////////
-/// CFrameworkunifiedShallowHistoryState
-/// Parameterized constructor
-////////////////////////////////////////////////////////////////////////////////////////////////////
-CFrameworkunifiedShallowHistoryState::CFrameworkunifiedShallowHistoryState(std::string f_pName): CFrameworkunifiedHistoryState(f_pName) {
- m_uiEventId = m_suievShallowHistory;
- m_cEventName = "evShallowHistory";
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////////////
-/// ~CFrameworkunifiedShallowHistoryState
-/// Class destructor
-////////////////////////////////////////////////////////////////////////////////////////////////////
-CFrameworkunifiedShallowHistoryState::~CFrameworkunifiedShallowHistoryState() {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_DEV_INFO, __FUNCTION__, "CFrameworkunifiedShallowHistoryState destructor");
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////////////
-/// UpdateHistory
-/// This function stores the last active state
-////////////////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedShallowHistoryState::UpdateHistory() {
- EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
-
- try {
- CHKNULL(m_pParentState);
-
- m_pLastActiveState = m_pParentState->m_pActiveState;
- } catch (std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
- l_eStatus = eFrameworkunifiedStatusNullPointer;
- }
-
- return l_eStatus;
-}
diff --git a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_state.cpp b/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_state.cpp
deleted file mode 100755
index af90583..0000000
--- a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_state.cpp
+++ /dev/null
@@ -1,634 +0,0 @@
-/*
- * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-/// \defgroup <<Group Tag>> <<Group Name>>
-/// \ingroup tag_NSFramework
-/// .
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-/// \ingroup tag_NSFramework
-/// \brief
-///
-/// This file has the CFrameworkunifiedState class implementation. CFrameworkunifiedState is base class for all types of
-/// state classes.This class implements the basic functionality required for HSM state.
-/// It provides the standard interfaces for entering, exiting and reacting in a state.
-///
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-// Include Files
-///////////////////////////////////////////////////////////////////////////////////////////////////
-#include <native_service/frameworkunified_sm_state.h>
-#include <native_service/frameworkunified_sm_reaction.h>
-#include <native_service/frameworkunified_sm_framework_types.h>
-#include <native_service/frameworkunified_sm_hsm.h>
-#include <sstream>
-#include <string>
-#include <utility>
-#include "frameworkunified_sm_framework_core.h"
-#include "frameworkunified_framework_internal.h"
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// CFrameworkunifiedState
-/// Parameterized constructor
-///////////////////////////////////////////////////////////////////////////////////////////
-CFrameworkunifiedState::CFrameworkunifiedState(std::string f_pName): m_strStateName(f_pName) {
- try {
- // EventList stores the list of events associated with the state
- m_pEventList = new EventReactionList(); // LCOV_EXCL_BR_LINE 11:except branch
-
- // Deferred eventlist stores the list of deferred events associated
- // with the state
- m_pDeferredEventList = new DeferredEventList(); // LCOV_EXCL_BR_LINE 11:except branch
-
- // Deferred PostEventList stores the list of posted deferred events posted
- // in the state
- m_pDeferredPostEventList = new EventInfoList(); // LCOV_EXCL_BR_LINE 11:except branch
-
- // EventName map stores the Name of event against event id, The event name is
- // only used for debugging so this can be disbaled in case of release build
- m_pEventName = new EventNameList(); // LCOV_EXCL_BR_LINE 11:except branch
-
- m_pDefaultState = NULL;
- m_pActiveState = NULL;
- m_pParentState = NULL;
- m_pStateMachine = NULL;
-
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "%s state created ", f_pName.c_str()); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
- } catch (std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: Failed in %s state ", f_pName.c_str());
- }
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// ~CFrameworkunifiedState
-/// Class destructor
-///////////////////////////////////////////////////////////////////////////////////////////
-CFrameworkunifiedState::~CFrameworkunifiedState() {
- EventReactionIterator l_objEventIterator;
- EventReactionIterator l_objDeferredEventIterator;
-
- try {
- // Delete the event list
- CHKNULL(m_pEventList);
- for (l_objEventIterator = m_pEventList->begin();
- l_objEventIterator != m_pEventList->end();
- l_objEventIterator++) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_DEV_INFO, __FUNCTION__, " deleting the event %d in state %s",
- (*l_objEventIterator).first , m_strStateName.c_str());
-
- if (NULL != (*l_objEventIterator).second) {
- (*l_objEventIterator).second->m_ucRefCount--;
-
- if (0 == ((*l_objEventIterator).second->m_ucRefCount)) {
- delete(*l_objEventIterator).second;
- (*l_objEventIterator).second = NULL;
- }
- }
- }
-
- // Delete the eventlist
- m_pEventList->clear();
- delete m_pEventList;
- m_pEventList = NULL;
-
- // Delete the deferred eventlist
- CHKNULL(m_pDeferredEventList);
- m_pDeferredEventList->clear();
- delete m_pDeferredEventList;
- m_pDeferredEventList = NULL;
-
- // delete deferred Post event list
- CHKNULL(m_pDeferredPostEventList);
- m_pDeferredPostEventList->clear();
- delete m_pDeferredPostEventList;
- m_pDeferredPostEventList = NULL;
-
- // delete event name list
- CHKNULL(m_pEventName);
- m_pEventName->clear();
- delete m_pEventName;
- m_pEventName = NULL;
- } catch (std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
- }
-}
-///////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedAddEvent
-/// Associates the event id with the reaction in the state. When the event is posted to the
-/// state the associated reaction is executed. This also adds the event name to the map
-/// which is used for debugging.
-///////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedState::FrameworkunifiedAddEvent(UI_32 f_uiEventId, CFrameworkunifiedReaction *f_pReaction, std::string f_strEventName) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- try {
- // LCOV_EXCL_BR_START 15:marco defined in frameworkunified_sm_framework_types.h
- CHKNULL(m_pEventName);
- CHKNULL(m_pEventList);
- CHKNULL(f_pReaction);
- // LCOV_EXCL_BR_STOP
- // associate the eventname with event id (debugging only)
- m_pEventName->insert(std::pair<UI_32, std::string>(f_uiEventId, f_strEventName));
-
- f_pReaction->m_ucRefCount++;
-
- // associate the reaction with event id
- m_pEventList->insert(std::pair<UI_32, CFrameworkunifiedReaction *>(f_uiEventId, f_pReaction));
-
- // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "Reaction associated with the event %d %s in the state %s "
- , f_uiEventId, (m_pEventName->find(f_uiEventId)->second).c_str(), m_strStateName.c_str());
- // LCOV_EXCL_BR_STOP
- } catch (std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: Failed to add event %d %s in state %s",
- f_uiEventId , (m_pEventName->find(f_uiEventId)->second).c_str(), m_strStateName.c_str());
- eStatus = eFrameworkunifiedStatusNullPointer;
- }
-
- return eStatus;
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedOnEvent
-/// This function processes the event. If the reaction for event is available in the current
-/// state within eventlist and deferred eventlist then it is consumed in the current state
-/// otherwise forwarded to the parent state. Event forwarding is done recursively till either
-/// event is consumed or the root state has encountered. This also process the events posted
-/// in the reactions recursively till all posted events are cleared.
-///////////////////////////////////////////////////////////////////////////////////////////
-CFrameworkunifiedState *CFrameworkunifiedState::FrameworkunifiedOnEvent(CEventDataPtr f_pEventData) {
- CFrameworkunifiedState *l_pCurrentState = this;
- CFrameworkunifiedReaction *l_pEventReaction = NULL;
-
- try {
- // LCOV_EXCL_BR_START 15:marco defined in frameworkunified_sm_framework_types.h
- CHKNULL(m_pEventList);
- CHKNULL(m_pDeferredEventList);
- // LCOV_EXCL_BR_STOP
- // Find the reaction object for given event id
-
- /**
- * @todo
- * Unauthorized accesses will occur if NULL is specified for the event data.
- */
- if (m_pEventList->end() != m_pEventList->find(f_pEventData->m_uiEventId)) {
- l_pEventReaction = reinterpret_cast<CFrameworkunifiedReaction *>((m_pEventList->find(f_pEventData->m_uiEventId))->second);
- }
-
- if (l_pEventReaction) {
- // execute the reaction associated with the event
- l_pCurrentState = l_pEventReaction->FrameworkunifiedReaction(this, f_pEventData); // LCOV_EXCL_BR_LINE 11:except branch
-
- // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_DEV_INFO, __FUNCTION__, "Reaction completed for event %d %s in state %s "
- , f_pEventData->m_uiEventId, (m_pEventName->find(f_pEventData->m_uiEventId)->second).c_str(),
- m_strStateName.c_str());
- // LCOV_EXCL_BR_STOP
- } else if (IsEventDeferred(f_pEventData->m_uiEventId)) {
- // If given event is deferred event then handle defer event
- CHKNULL(m_pDeferredPostEventList);
-
- m_pDeferredPostEventList->push_back(f_pEventData);
-
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "deferred event %d %s posted to state %s ",
- f_pEventData->m_uiEventId,
- (m_pEventName->find(f_pEventData->m_uiEventId)->second).c_str(),
- m_strStateName.c_str());
-
- } else {
- // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_DEV_INFO, __FUNCTION__, "Reaction not available or event %d not found in state %s"
- , f_pEventData->m_uiEventId, m_strStateName.c_str());
- // LCOV_EXCL_BR_STOP
- // check if the current state has parent state
- if (m_pParentState) {
- // No reaction available fot given event in the current state
- // then forward event to parent state
- // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "Forwarding an event %d to %s"
- , f_pEventData->m_uiEventId, m_pParentState->m_strStateName.c_str());
- // LCOV_EXCL_BR_STOP
- l_pCurrentState = m_pParentState->FrameworkunifiedOnEvent(f_pEventData); // LCOV_EXCL_BR_LINE 11:except branch
-
- } else {
- // No parent is available then reached root state,
- // No reaction available in the statemachine then discard the event
- // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "Discarding an event %d ", f_pEventData->m_uiEventId);
- // LCOV_EXCL_BR_STOP
- }
-
- CHKNULL(l_pCurrentState);
-
- // This is a recursive function that recurse in parent states till the event is
- // consumed or discarded So Setting the current state as the active state of the
- // returned state, as the return state is parent state
- if (l_pCurrentState->m_pActiveState) {
- l_pCurrentState = l_pCurrentState->m_pActiveState;
-
- } else {
- // do nothing in leaf state, as current state is active state
- }
- }
- } catch (std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
- return NULL;
- }
- return l_pCurrentState;
-}
-
-//////////////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedAddDeferredEvent
-/// When the event is posted to the state the event is deferred and stored in the state.
-/// In case of implicit recall of the deferred events, events are processed before exiting the state.
-/// The deferred events can also be recalled explicitly in the state.
-/// This also adds the event name to the map which is used for debugging.
-//////////////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedState::FrameworkunifiedAddDeferredEvent(UI_32 f_uiEventId, std::string f_strEventName) {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- try {
- // LCOV_EXCL_BR_START 15:marco defined in frameworkunified_sm_framework_types.h
- CHKNULL(m_pEventName);
-
- CHKNULL(m_pDeferredEventList);
- // LCOV_EXCL_BR_STOP
- // associate the deferred eventname with event id (debugging only)
- m_pEventName->insert(std::pair<UI_32, std::string>(f_uiEventId, f_strEventName));
-
- // associate the reaction with deferred event id
- m_pDeferredEventList->push_back(f_uiEventId); // LCOV_EXCL_BR_LINE 11:except branch
- // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "Added deferred event %d %s in the state %s "
- , f_uiEventId, (m_pEventName->find(f_uiEventId)->second).c_str(), m_strStateName.c_str());
- // LCOV_EXCL_BR_STOP
- } catch (std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: Failed to add event %d %s in state %s",
- f_uiEventId, (m_pEventName->find(f_uiEventId)->second).c_str(), m_strStateName.c_str());
-
- eStatus = eFrameworkunifiedStatusNullPointer;
- }
-
- return eStatus;
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedPostEvent
-/// This function creates new eventdata object and add the to event queue of the state.
-/// The events are posted in the reaction which are executed in the state.
-/// The event queue is processed once the execution of the reaction is completed.
-///////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedState::FrameworkunifiedPostEvent(UI_32 f_uiEventId) {
- EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
- try {
- CHKNULL(m_pStateMachine); // LCOV_EXCL_BR_LINE 15:marco defined in frameworkunified_sm_framework_types.h
-
- CEventDataPtr l_pEventData(new CEventData(f_uiEventId)); // LCOV_EXCL_BR_LINE 11:except branch
-
- l_eStatus = m_pStateMachine->FrameworkunifiedPostEvent(l_pEventData); // LCOV_EXCL_BR_LINE 11:except branch // LCOV_EXCL_BR_LINE 11:except branch
- } catch (std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
- l_eStatus = eFrameworkunifiedStatusNullPointer;
- }
-
- return l_eStatus;
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedPostEvent
-/// This function adds the event queue of the state. The events are posted in the reaction
-/// which are executed in the state. The event queue is processed once the execution of the
-/// reaction is completed.
-///////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedState::FrameworkunifiedPostEvent(CEventDataPtr f_pEventData) {
- EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
-
- try {
- CHKNULL(m_pStateMachine);
- CHKNULL(f_pEventData);
-
- l_eStatus = m_pStateMachine->FrameworkunifiedPostEvent(f_pEventData);
- } catch (std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
- l_eStatus = eFrameworkunifiedStatusNullPointer;
- }
-
- return l_eStatus;
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedOnHSMStart
-/// This function is called recursively till the leaf state is reached. This internally
-/// calls the Entry function of the current state.
-///////////////////////////////////////////////////////////////////////////////////////////
-CFrameworkunifiedState *CFrameworkunifiedState::FrameworkunifiedOnHSMStart(CEventDataPtr f_pEventData) {
- CFrameworkunifiedState *l_pActiveState = this;
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
-
- try {
- // Call Entry method of the current state. Entry method of state is called in the order of
- // Hierarchy from Outer state to Inner state
- if (eFrameworkunifiedStatusOK == (eStatus = FrameworkunifiedOnEntry(f_pEventData))) {
- // If current state has sub states then enter into active state for state entry
- // active state is same as the default state. In this case the FrameworkunifiedOnStart is called
- // recursively and recursion breaks when the current state is leafstate that does not have
- // any active/default state.
- if (m_pActiveState) {
- l_pActiveState = m_pActiveState->FrameworkunifiedOnHSMStart(f_pEventData); // LCOV_EXCL_BR_LINE 11:except branch
- } else {
- l_pActiveState = this;
- }
-
- // set current state as the active state of its parent state to maintain the Hierarchy
- if (m_pParentState) {
- m_pParentState->m_pActiveState = this;
- }
- } else {
- // If FrameworkunifiedOnEntry failed then statemachine should report the error
- // We can throw an exception but for now as a quick fix we are setting
- // l_pActiveState as NULL which will stop the statemachine
- // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error:%d in FrameworkunifiedOnEntry of state %s", eStatus,
- l_pActiveState->m_strStateName.c_str());
- // LCOV_EXCL_BR_STOP
- // l_pActiveState = NULL;
- /* Commenting it, because it was making state machine inactive. This should not be the expected behavior.
- * Just log and take no action, if user return non-ok value.
- * User defined error values should be handled separately */
- }
- } catch (std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
- return NULL;
- }
-
- return l_pActiveState;
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedOnHSMStop
-/// This function is called recursively till the required parent state is reached. This
-/// internally calls the Exit function of the current state.
-///////////////////////////////////////////////////////////////////////////////////////////
-CFrameworkunifiedState *CFrameworkunifiedState::FrameworkunifiedOnHSMStop(CEventDataPtr f_pEventData) {
- CFrameworkunifiedState *l_pActiveState = this;
- try {
- // if active state is composite state, update the shallow and deep history state(if exists)
- UpdateHistory(); // LCOV_EXCL_BR_LINE 11:except branch
-
- // if current state has active state then recursively call the FrameworkunifiedOnHSMStop till current
- // state has no active state i.e. current state is leaf state
- if (m_pActiveState) {
- m_pActiveState->FrameworkunifiedOnHSMStop(f_pEventData);
- }
-
- m_pActiveState = m_pDefaultState;
-
- // Post deferred events to statemachine event queue
- CHKNULL(m_pDeferredPostEventList); // LCOV_EXCL_BR_LINE 15:marco defined in frameworkunified_sm_framework_types.h
-
- // recall deferred events till the vector is empty
- while (!m_pDeferredPostEventList->empty()) {
- // get the first event list object
- CEventDataPtr l_pEventData = m_pDeferredPostEventList->front();
-
- CHKNULL(l_pEventData);
- CHKNULL(m_pEventName);
-
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "Recalling event %d %s in state %s"
- , l_pEventData->m_uiEventId,
- (m_pEventName->find(l_pEventData->m_uiEventId)->second).c_str(), m_strStateName.c_str());
-
- m_pDeferredPostEventList->erase(m_pDeferredPostEventList->begin());
-
- // recall the event stored in the eventinfo object
- FrameworkunifiedPostEvent(l_pEventData);
- }
-
- FrameworkunifiedOnExit(f_pEventData);
- } catch (std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
- return NULL;
- }
-
- return l_pActiveState;
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// IsEventDeferred
-/// This checks if the given event is marked as deferred in the state.
-///////////////////////////////////////////////////////////////////////////////////////////
-BOOL CFrameworkunifiedState::IsEventDeferred(UI_32 f_uiEventId) {
- BOOL bStatus = FALSE;
- try {
- CHKNULL(m_pDeferredEventList); // LCOV_EXCL_BR_LINE 15:marco defined in frameworkunified_sm_framework_types.h
- for (UI_32 l_uiCount = 0; l_uiCount < m_pDeferredEventList->size(); l_uiCount++) {
- if (f_uiEventId == m_pDeferredEventList->at(l_uiCount)) {
- bStatus = TRUE;
- break;
- }
- }
- } catch (std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
- }
-
- return bStatus; // LCOV_EXCL_BR_LINE 15:marco defined in frameworkunified_sm_framework_types.h
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedRemoveEventFromDeferredEventList
-/// This function removes the event from the posted deferred queue list of the state.
-///////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedState::FrameworkunifiedRemoveEventFromDeferredEventList(UI_32 f_uiEventId) {
- EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusInvldID;
- FRAMEWORKUNIFIEDLOG_CUT(ZONE_NS_FUNC, __FUNCTION__, "+");
-
- try {
- CHKNULL(m_pDeferredPostEventList);
- int32_t l_siCnt = static_cast<int32_t>(m_pDeferredPostEventList->size() - 1);
-
- for (; l_siCnt >= 0; l_siCnt--) {
- if (NULL != m_pDeferredPostEventList->at(l_siCnt).get()) {
- if (f_uiEventId == m_pDeferredPostEventList->at(l_siCnt).get()->m_uiEventId) {
- m_pDeferredPostEventList->erase(m_pDeferredPostEventList->begin() + l_siCnt);
- l_eStatus = eFrameworkunifiedStatusOK;
- }
- }
- }
- } catch (std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
- l_eStatus = eFrameworkunifiedStatusNullPointer;
- }
- FRAMEWORKUNIFIEDLOG_CUT(ZONE_NS_FUNC, __FUNCTION__, "-");
- return l_eStatus;
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedRecallEvent
-/// This indicates if the state has sub states. It returns TRUE only in the CompositeState
-/// where this function is overridden
-///////////////////////////////////////////////////////////////////////////////////////////
-BOOL CFrameworkunifiedState::FrameworkunifiedHasSubStates() {
- return FALSE;
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// FrameworkunifiedPrintStates
-/// This logs the state name and events associated with the state
-///////////////////////////////////////////////////////////////////////////////////////////
-EFrameworkunifiedStatus CFrameworkunifiedState::FrameworkunifiedPrintStates() {
- EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
- EventReactionIterator l_objEventIterator;
- try {
- CHKNULL(m_pEventList);
- CHKNULL(m_pDeferredEventList);
- CHKNULL(m_pEventName);
-
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "%s:%s",
- (m_pParentState->m_strStateName).c_str(), m_strStateName.c_str());
-
- // print events
- for (l_objEventIterator = m_pEventList->begin();
- l_objEventIterator != m_pEventList->end(); l_objEventIterator++) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "event %d %s", ((*l_objEventIterator).first),
- (m_pEventName->find((*l_objEventIterator).first)->second).c_str());
- }
-
- // print deferred events
- for (UI_32 l_uiCount = 0; l_uiCount < m_pDeferredEventList->size(); l_uiCount++) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "deferred event %d %s", m_pDeferredEventList->at(l_uiCount),
- (m_pEventName->find(m_pDeferredEventList->at(l_uiCount))->second).c_str());
- }
- } catch (std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: Failed to print in state %s", m_strStateName.c_str());
- eStatus = eFrameworkunifiedStatusNullPointer;
- }
-
- return eStatus;
-}
-
-BOOL CFrameworkunifiedState::FrameworkunifiedHasOrthogoanlRegions() {
- return FALSE;
-}
-
-BOOL CFrameworkunifiedState::FrameworkunifiedIsReactionAvailable(UI_32 f_uiEventId) {
- BOOL IsReactionAvailable = FALSE;
- CFrameworkunifiedReaction *l_pEventReaction = NULL;
-
- try {
- // LCOV_EXCL_BR_START 15:marco defined in frameworkunified_sm_framework_types.h
- CHKNULL(m_pEventList);
- CHKNULL(m_pDeferredEventList);
- // LCOV_EXCL_BR_STOP
- if (m_pEventList->end() != m_pEventList->find(f_uiEventId)) {
- // Find the reaction object for given event id
- l_pEventReaction = reinterpret_cast<CFrameworkunifiedReaction *>((m_pEventList->find(f_uiEventId))->second);
- }
-
- if (l_pEventReaction) {
- IsReactionAvailable = TRUE;
- } else {
- if (IsEventDeferred(f_uiEventId)) {
- IsReactionAvailable = TRUE;
- }
- }
- } catch (std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
- }
-
- return IsReactionAvailable; // LCOV_EXCL_BR_LINE 11:except branch
-}
-
-EFrameworkunifiedStatus CFrameworkunifiedState::FrameworkunifiedSetHSM(CFrameworkunifiedHSM *f_pStatemachine) {
- EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
-
- try {
- CHKNULL(f_pStatemachine); // LCOV_EXCL_BR_LINE 15:marco defined in frameworkunified_sm_framework_types.h
- m_pStateMachine = f_pStatemachine;
- } catch (std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
- l_eStatus = eFrameworkunifiedStatusNullPointer;
- }
- return l_eStatus; // LCOV_EXCL_BR_LINE 11:except branch
-}
-
-HANDLE CFrameworkunifiedState:: FrameworkunifiedGetAppHandle() {
- HANDLE l_pHApp = NULL;
- try {
- CHKNULL(m_pStateMachine); // LCOV_EXCL_BR_LINE 15:marco defined in frameworkunified_sm_framework_types.h
- l_pHApp = m_pStateMachine->FrameworkunifiedGetAppHandle(); // LCOV_EXCL_BR_LINE 11:except branch
- } catch (std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
- }
- return l_pHApp; // LCOV_EXCL_BR_LINE 11:except branch
-}
-
-EFrameworkunifiedStatus CFrameworkunifiedState::FrameworkunifiedPrintXML(std::ostringstream &f_strXMLString) {
- EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
- EventReactionIterator l_objEventIterator;
- try {
- CHKNULL(m_pEventList);
- CHKNULL(m_pDeferredEventList);
- CHKNULL(m_pEventName);
-
- f_strXMLString << "<" << m_strStateName.c_str() << ">";
-
- f_strXMLString << "<EventList>";
- // print events
- for (l_objEventIterator = m_pEventList->begin();
- l_objEventIterator != m_pEventList->end(); l_objEventIterator++) {
- std::string l_strEventName =
- (m_pEventName->find((*l_objEventIterator).first)->second);
-
- UI_32 l_uiEventId = (*l_objEventIterator).first;
-
- f_strXMLString << "<Event " << "Id = " << "\"" << l_uiEventId << "\">";
-
- f_strXMLString << "<Name>" << l_strEventName.c_str() << "</Name>";
-
- f_strXMLString << "</Event>";
- }
- f_strXMLString << "</EventList>";
-
- // print deferred events
- f_strXMLString << "<DeferredEventList>";
- for (UI_32 l_uiCount = 0; l_uiCount < m_pDeferredEventList->size(); l_uiCount++) {
- UI_32 l_uiEventId = m_pDeferredEventList->at(l_uiCount);
-
- std::string l_strEventName = (m_pEventName->find(l_uiEventId)->second);
-
- f_strXMLString << "<Event " << "Id = " << "\"" << l_uiEventId << "\">";
-
- f_strXMLString << "<Name>" << l_strEventName.c_str() << "</Name>";
-
- f_strXMLString << "</Event>";
- }
-
- f_strXMLString << "</DeferredEventList>";
- f_strXMLString << "</" << m_strStateName.c_str() << ">";
- } catch (std::exception &e) {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
- FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: Failed to print in state %s", m_strStateName.c_str());
- l_eStatus = eFrameworkunifiedStatusNullPointer;
- }
- return l_eStatus;
-}
diff --git a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_transition.cpp b/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_transition.cpp
deleted file mode 100755
index 1162f61..0000000
--- a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_transition.cpp
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-/// \defgroup <<Group Tag>> <<Group Name>>
-/// \ingroup tag_NSFramework
-/// .
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-/// \ingroup tag_NSFramework
-/// \brief
-///
-/// This file has the CFrameworkunifiedTransition class definitions.This class provides the interface
-/// for reacting local transition and external transition
-///
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-// Include Files
-///////////////////////////////////////////////////////////////////////////////////////////////////
-#include <native_service/frameworkunified_sm_transition.h>
-#include <native_service/frameworkunified_sm_state.h>
-
-///////////////////////////////////////////////////////////////////////////////////////////
-/// CFrameworkunifiedTransition
-/// Parameterized constructor
-///////////////////////////////////////////////////////////////////////////////////////////
-CFrameworkunifiedTransition::CFrameworkunifiedTransition(CFrameworkunifiedState *f_pTargetState): m_pTargetState(f_pTargetState) {
- if (m_pTargetState) {
- // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
- FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "Transition created with Target %s ",
- (m_pTargetState->m_strStateName).c_str());
- // LCOV_EXCL_BR_STOP
- }
-}
-///////////////////////////////////////////////////////////////////////////////////////////
-/// ~CFrameworkunifiedTransition
-/// Class destructor
-///////////////////////////////////////////////////////////////////////////////////////////
-CFrameworkunifiedTransition::~CFrameworkunifiedTransition() {
- FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "+");
-}
-
diff --git a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/makefile b/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/makefile
deleted file mode 100755
index 964a1f5..0000000
--- a/video_in_hal/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/makefile
+++ /dev/null
@@ -1,99 +0,0 @@
-#
-# @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-#
-# Standard Module Makefile version 2.0
-#
-
-COMPONENT_NAME = NS_FrameworkCore
-
-include $(PRJ_ROOT)cfg/depends.mk
-
-# Additive Compile Flags (Flags from initiating make process will still apply)
-DEFS +=
-
-
-INCLUDES = \
- $(CFG_INCS) \
- $(CC_IFLAG). \
- $(CC_IFLAG)../../inc \
- $(CC_IFLAG)../../inc/statemachine \
- $(DEPENDS_INCLUDES) \
-
-
-## Sources Section
-
-SOURCES = \
- $(wildcard *.c*)
-
-#
-# Convert the source files to object files with correct folder location.
-#
-#
-C_LANG_OBJECTS = $(addprefix $(BLD_PATH),$(addsuffix .$(OBJ_EXT),$(basename $(filter %.c ,$(SOURCES) ) ) ) )
-CPP_LANG_OBJECTS = $(addprefix $(BLD_PATH),$(addsuffix .$(OBJ_EXT),$(basename $(filter %.cpp %.cc %.cxx,$(SOURCES) ) ) ) )
-
-
-# List of all sources to be generated. Can be assembled from the other defintitions.
-OBJECTS = \
- $(C_LANG_OBJECTS) \
- $(CPP_LANG_OBJECTS)
-
-
-# All headers that are dependencies. Wildcard is easy to pickup local headers.
-# This is only to automate the rebuilding, all builds on the servers are cleans
-# So this is not a huge deal when building on a component level.
-HEADERS = \
- $(wildcard *.h) \
- $(wildcard ../../inc/*.h) \
- $(wildcard ../../inc/NS_Statemachine/*.h) \
- $(wildcard $(REPOSITORY_ROOT)NativeServices/inc/*.h) \
-
-# Make targets
-# Standard
-all: banner module_dirs local
-
-base: banner module_dirs subdirs local
-
-binary: base
-
-local: $(OBJECTS)
-
-# Standard set of derived targets
-library: base \
- $(LIBRARIES)
- @echo "***** `date` Done building library: $(COMPONENT_NAME) ******"
-
-# Defines specific for each deliverable
-
-
-# Default source file build rules
-$(OBJECTS): $(HEADERS)
-
-# Standard Building of Source Files (Default builds for all objects defined above)
-$(C_LANG_OBJECTS): $(SOURCES) $(HEADERS)
- $(CC_CMD)
-
-$(CPP_LANG_OBJECTS): $(SOURCES) $(HEADERS)
- $(CPP_CMD)
-
-
-clean:
- -rm -f $(BINARIES)
- -rm -f $(LIBRARIES)
- -rm -f $(OBJECTS)
-
-module_dirs: build_dirs