summaryrefslogtreecommitdiff
path: root/AudioManagerDaemon
diff options
context:
space:
mode:
authorChristian Linke <christian.linke@bmw.de>2015-09-22 17:32:01 +0100
committerChristian Linke <christian.linke@bmw.de>2015-09-22 17:32:01 +0100
commitbd7ec24a2abe47ae4398b23282e8288e00eaec47 (patch)
tree778cf5ffa440b44752bb1cbcfd4c75d950bd48c4 /AudioManagerDaemon
parenta9f86b94f3cc83a9474e8a0d7e21de4c8e452526 (diff)
downloadaudiomanager-bd7ec24a2abe47ae4398b23282e8288e00eaec47.tar.gz
Remove nodestatemanager7.2
Make audiomanager compile with Dbus and CommonAPI Wrapper at the same time Signed-off-by: Christian Linke <christian.linke@bmw.de>
Diffstat (limited to 'AudioManagerDaemon')
-rw-r--r--AudioManagerDaemon/CMakeLists.txt68
-rw-r--r--AudioManagerDaemon/docx/02_license.dox1
-rw-r--r--AudioManagerDaemon/docx/14_z_nodeStateManagement.dox39
-rw-r--r--AudioManagerDaemon/fidls/NodeStateManager.fdepl6
-rw-r--r--AudioManagerDaemon/fidls/NodeStateManager.fidl152
-rw-r--r--AudioManagerDaemon/include/CAmControlReceiver.h10
-rw-r--r--AudioManagerDaemon/include/CAmControlSender.h6
-rw-r--r--AudioManagerDaemon/include/CAmNodeStateCommunicator.h74
-rw-r--r--AudioManagerDaemon/include/CAmNodeStateCommunicatorCAPI.h113
-rw-r--r--AudioManagerDaemon/include/CAmNodeStateCommunicatorDBus.h65
-rw-r--r--AudioManagerDaemon/src/CAmControlReceiver.cpp154
-rw-r--r--AudioManagerDaemon/src/CAmControlSender.cpp24
-rw-r--r--AudioManagerDaemon/src/CAmNodeStateCommunicatorCAPI.cpp386
-rw-r--r--AudioManagerDaemon/src/CAmNodeStateCommunicatorDBus.cpp778
-rwxr-xr-xAudioManagerDaemon/src/main.cpp27
-rw-r--r--AudioManagerDaemon/test/AmNodeStateCommunicatorCAPITest/CAmNodeStateCommunicatorTest.cpp266
-rw-r--r--AudioManagerDaemon/test/AmNodeStateCommunicatorCAPITest/CAmNodeStateCommunicatorTest.h67
-rw-r--r--AudioManagerDaemon/test/AmNodeStateCommunicatorCAPITest/CMakeLists.txt113
-rw-r--r--AudioManagerDaemon/test/AmNodeStateCommunicatorCAPITest/nsm.py179
-rw-r--r--AudioManagerDaemon/test/AmNodeStateCommunicatorCAPITest/org.genivi.NodeStateManager.Consumer.xml259
-rw-r--r--AudioManagerDaemon/test/AmNodeStateCommunicatorCAPITest/send2nsm.py68
-rw-r--r--AudioManagerDaemon/test/AmNodeStateCommunicatorDBusTest/CAmNodeStateCommunicatorTest.cpp250
-rw-r--r--AudioManagerDaemon/test/AmNodeStateCommunicatorDBusTest/CAmNodeStateCommunicatorTest.h63
-rw-r--r--AudioManagerDaemon/test/AmNodeStateCommunicatorDBusTest/CMakeLists.txt103
-rw-r--r--AudioManagerDaemon/test/AmNodeStateCommunicatorDBusTest/nsm.py179
-rw-r--r--AudioManagerDaemon/test/AmNodeStateCommunicatorDBusTest/org.genivi.NodeStateManager.Consumer.xml259
-rw-r--r--AudioManagerDaemon/test/AmNodeStateCommunicatorDBusTest/send2nsm.py68
-rw-r--r--AudioManagerDaemon/test/CMakeLists.txt8
-rw-r--r--AudioManagerDaemon/test/MockIAmControlSend.h8
29 files changed, 9 insertions, 3784 deletions
diff --git a/AudioManagerDaemon/CMakeLists.txt b/AudioManagerDaemon/CMakeLists.txt
index 6ad0aff..ff8b70e 100644
--- a/AudioManagerDaemon/CMakeLists.txt
+++ b/AudioManagerDaemon/CMakeLists.txt
@@ -50,8 +50,7 @@ if(WITH_DBUS_WRAPPER)
endif(WITH_DBUS_WRAPPER)
if(WITH_CAPI_WRAPPER)
- INCLUDE (CommonAPI)
- LOAD_COMMONAPI()
+ find_package(CommonAPI REQUIRED)
endif(WITH_CAPI_WRAPPER)
set (AM_LINK_LIBS
@@ -103,33 +102,10 @@ if(WITH_DBUS_WRAPPER)
endif(WITH_DBUS_WRAPPER)
if(WITH_CAPI_WRAPPER)
- set (AUDIOMAN_SRCS_CXX ${AUDIOMAN_SRCS_CXX} "${AUDIOMANAGER_UTILITIES_SRC}/CAmCommonAPIWrapper.cpp")
+ set (AUDIOMAN_SRCS_CXX ${AUDIOMAN_SRCS_CXX} "${AUDIOMANAGER_UTILITIES_SRC}/CAmCommonAPIWrapper.cpp")
set (AM_LINK_LIBS ${AM_LINK_LIBS} ${CommonAPI_LIBRARY})
- if(${COMMONAPI_USED_BINDING} EQUAL 0)
- set (AM_LINK_LIBS ${AM_LINK_LIBS}
- ${CommonAPI-DBus_LIBRARY}
- ${DBUS_LIBRARIES}
- ${CommonAPI_LIBRARY})
- else()
- set (AM_LINK_LIBS ${AM_LINK_LIBS}
- ${CommonAPI-SomeIP_LIBRARY}
- ${CommonAPI_LIBRARY})
- endif()
-
endif(WITH_CAPI_WRAPPER)
-if(WITH_NSM)
- if(WITH_DBUS_WRAPPER)
- set (AUDIOMAN_SRCS_CXX
- ${AUDIOMAN_SRCS_CXX}
- src/CAmNodeStateCommunicatorDBus.cpp)
- else(WITH_DBUS_WRAPPER)
- set (AUDIOMAN_SRCS_CXX
- ${AUDIOMAN_SRCS_CXX}
- src/CAmNodeStateCommunicatorCAPI.cpp)
- endif(WITH_DBUS_WRAPPER)
-endif(WITH_NSM)
-
if(WITH_DATABASE_STORAGE)
set (AUDIOMAN_SRCS_CXX
${AUDIOMAN_SRCS_CXX}
@@ -150,47 +126,13 @@ INCLUDE_DIRECTORIES(
${AUDIOMANAGER_INCLUDE_FOLDER}
${AUDIOMANAGER_UTILITIES_INCLUDE}
${INCLUDE_FOLDER}
- ${NSM_INCLUDE_DIR}
${TCLAP_INCLUDE_DIR}
)
if(WITH_CAPI_WRAPPER)
- if(WITH_NSM)
- IF(${COMMONAPI_USED_BINDING} EQUAL 1)#SomeIP
- SET(SRC_GEN src-gen/v${COMMONAPI_SOMEIP_VERSION_NUMBER}/someip)
- ELSE()#Dbus
- SET(SRC_GEN src-gen/v${COMMONAPI_DBUS_VERSION_NUMBER}/dbus)
- ENDIF()
- COMMON_API_GENERATE_SOURCES(
- TARGET COMMON_API
- # A list with fidls for the generic generator.
- FIDLS_GENERIC fidls/NodeStateManager.fdepl
- # A list with fidls for the binding generator.
- FIDLS_BINDING fidls/NodeStateManager.fdepl
- # A relative path to the build directory or an absolute path.
- DESTINATION ${SRC_GEN}
- # An alternative relative/absolute path with common-api sources, usually in the source tree.
- ALT_DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/src-gen
- )
-
- set(AUDIOMAN_SRCS_CXX
- ${AUDIOMAN_SRCS_CXX}
- ${COMMON_API_GEN_SOURCES})
- endif(WITH_NSM)
-
- if(${COMMONAPI_USED_BINDING} EQUAL 0)
- INCLUDE_DIRECTORIES(${INCLUDE_DIRECTORIES}
- ${COMMONAPI_DBUS_INCLUDE_DIRS}
- ${COMMONAPI_INCLUDE_DIRS}
- ${COMMON_API_GEN_INCLUDE_DIR}
- ${DBUS_INCLUDE_DIRS})
- else()
- INCLUDE_DIRECTORIES(${INCLUDE_DIRECTORIES}
- ${VSOMEIP_INCLUDE_DIRS}
- ${COMMONAPI_INCLUDE_DIRS}
- ${COMMONAPI_SOMEIP_INCLUDE_DIRS}
- ${COMMON_API_GEN_INCLUDE_DIR})
- endif()
+
+INCLUDE_DIRECTORIES(${INCLUDE_DIRECTORIES}
+ ${COMMONAPI_INCLUDE_DIRS})
endif(WITH_CAPI_WRAPPER)
if(WITH_DLT)
diff --git a/AudioManagerDaemon/docx/02_license.dox b/AudioManagerDaemon/docx/02_license.dox
index c54190e..d7fc220 100644
--- a/AudioManagerDaemon/docx/02_license.dox
+++ b/AudioManagerDaemon/docx/02_license.dox
@@ -21,7 +21,6 @@
The AudioManger comes with some open source software distributed in the source tree:
- Google Mock (in \googleMock), licensed under MIT license
- Tclap ( in \tclap-1.2.1), licensed under MIT license
-- The headers of the NSM, licensed under MPL 2.0
\section split License Split
The licenses of this project are split into two parts:\n
1. the AudioManagerDaemon, licensed under MPL 2.0\n
diff --git a/AudioManagerDaemon/docx/14_z_nodeStateManagement.dox b/AudioManagerDaemon/docx/14_z_nodeStateManagement.dox
deleted file mode 100644
index e149310..0000000
--- a/AudioManagerDaemon/docx/14_z_nodeStateManagement.dox
+++ /dev/null
@@ -1,39 +0,0 @@
- /*
- * Copyright (C) 2012, BMW AG
- *
- * This file is part of GENIVI Project AudioManager.
- *
- * Contributions are licensed to the GENIVI Alliance under one or more
- * Contribution License Agreements.
- *
- * \copyright
- * This Source Code Form is subject to the terms of the
- * Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with
- * this file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * \\author Christian Linke (christian.linke@bmw.de)
- *
- */
-
-/*!
-\page nsm The Node state management
-\section The Node state managemer
-The nodestatemanager is part of the GENIVI compliance. It basically handles startup and rundown of components in the IVI context.\n
-For more information, please go to http://projects.genivi.org
-
-The Nodestatemanagement will either work with CommonAPI or DBus native.
-
-\section nsmiact The Interaction between the NodeStateManager and the AudioManager
-It is the job of am::CAmNodeStateCommunicator to interact with the nodestatemanager via DBUS.\n
-The ControllerPlugin can register by the NSM to be informed when a shutdown will occour. For this, the Audiomanager presents an DBus interface, defined in LifeCycleConsumer.xml that will be called from the NSM during a shutdown,
-but only after the Controller registered by the NSM via am::CAmNodeStateCommunicator::nsmRegisterShutdownClient.\n
-The controller has to answer this request during the timeout with am::CAmNodeStateCommunicator::nsmSendLifecycleRequestComplete .
-For more information, check am::CAmNodeStateCommunicator and http://projects.genivi.org\n
-\section nsm_overview Overview of the relations between AudioManager and NSM:
-\image html NodeStateManagementRelations.png
-\section nsm_reg Registering at startup
-\image html Registrations.png
-\section nsm_lifec Handling of Lifecyclerequests:
-\image html Lifecylerequest.png
-
- */
diff --git a/AudioManagerDaemon/fidls/NodeStateManager.fdepl b/AudioManagerDaemon/fidls/NodeStateManager.fdepl
deleted file mode 100644
index e772022..0000000
--- a/AudioManagerDaemon/fidls/NodeStateManager.fdepl
+++ /dev/null
@@ -1,6 +0,0 @@
-import "platform:/plugin/org.genivi.commonapi.dbus/deployment/CommonAPI-DBus_deployment_spec.fdepl"
-import "NodeStateManager.fidl"
-
-define org.genivi.commonapi.dbus.deployment for interface org.genivi.NodeStateManager.Consumer {
- DBusDefaultAttributeType=freedesktop
-}
diff --git a/AudioManagerDaemon/fidls/NodeStateManager.fidl b/AudioManagerDaemon/fidls/NodeStateManager.fidl
deleted file mode 100644
index 84d8d26..0000000
--- a/AudioManagerDaemon/fidls/NodeStateManager.fidl
+++ /dev/null
@@ -1,152 +0,0 @@
-package org.genivi.NodeStateManager
-
-<**
- @author : Christian Linke
-**>
-
-interface Consumer {
- version {
- major 1
- minor 0
- }
-
- attribute Int32 BootMode readonly noSubscriptions
-
- attribute Int32 RestartReason readonly noSubscriptions
-
- attribute Int32 ShutdownReason readonly noSubscriptions
-
- attribute Int32 WakeUpReason readonly noSubscriptions
-
- method GetAppHealthCount {
- out {
- UInt32 Count
- }
- }
- method LifecycleRequestComplete {
- in {
- UInt32 RequestId
- Int32 Status
- }
- out {
- Int32 ErrorCode
- }
- }
- method GetInterfaceVersion {
- out {
- UInt32 Version
- }
- }
- method GetApplicationMode {
- out {
- Int32 ErrorCode
- Int32 ApplicationModeId
- }
- }
- method UnRegisterSession {
- in {
- String SessionName
- String SessionOwner
- Int32 SeatID
- }
- out {
- Int32 ErrorCode
- }
- }
- method RegisterSession {
- in {
- String SessionName
- String SessionOwner
- Int32 SeatID
- Int32 SessionState
- }
- out {
- Int32 ErrorCode
- }
- }
- method UnRegisterShutdownClient {
- in {
- String BusName
- String ObjName
- UInt32 ShutdownMode
- }
- out {
- Int32 ErrorCode
- }
- }
- method RegisterShutdownClient {
- in {
- String BusName
- String ObjName
- UInt32 ShutdownMode
- UInt32 TimeoutMs
- }
- out {
- Int32 ErrorCode
- }
- }
- method GetNodeState {
- out {
- Int32 ErrorCode
- Int32 NodeStateId
- }
- }
- method GetSessionState {
- in {
- String SessionName
- Int32 SeatID
- }
- out {
- Int32 SessionState
- Int32 ErrorCode
- }
- }
- method SetSessionState {
- in {
- String SessionName
- String SessionOwner
- Int32 SessionState
- Int32 SeatID
- }
- out {
- Int32 ErrorCode
- }
- }
- broadcast NodeApplicationMode {
- out {
- Int32 ApplicationModeId
- }
- }
- broadcast SessionStateChanged {
- out {
- String SessionStateName
- Int32 SeatID
- Int32 SessionState
- }
- }
- broadcast NodeState {
- out {
- Int32 NodeState
- }
- }
-}
-
-<**
- @author : Christian Linke
-**>
-
-interface LifeCycleConsumer {
- version {
- major 1
- minor 0
- }
- method LifecycleRequest {
- in {
- UInt32 Request
- UInt32 RequestId
- }
- out {
- Int32 ErrorCode
- }
- }
-} \ No newline at end of file
diff --git a/AudioManagerDaemon/include/CAmControlReceiver.h b/AudioManagerDaemon/include/CAmControlReceiver.h
index 029845c..88ba507 100644
--- a/AudioManagerDaemon/include/CAmControlReceiver.h
+++ b/AudioManagerDaemon/include/CAmControlReceiver.h
@@ -133,16 +133,6 @@ public:
void sendMainSourceNotificationPayload(const am_sourceID_t sourceID, const am_NotificationPayload_s& notificationPayload) ;
am_Error_e changeMainSinkNotificationConfigurationDB(const am_sinkID_t sinkID, const am_NotificationConfiguration_s& mainNotificationConfiguration) ;
am_Error_e changeMainSourceNotificationConfigurationDB(const am_sourceID_t sourceID, const am_NotificationConfiguration_s& mainNotificationConfiguration) ;
- am_Error_e getRestartReasonPropertyNSM(NsmRestartReason_e& restartReason) ;
- am_Error_e getShutdownReasonPropertyNSM(NsmShutdownReason_e& ShutdownReason) ;
- am_Error_e getRunningReasonPropertyNSM(NsmRunningReason_e& nsmRunningReason) ;
- NsmErrorStatus_e getNodeStateNSM(NsmNodeState_e& nsmNodeState) ;
- NsmErrorStatus_e getSessionStateNSM(const std::string& sessionName, const NsmSeat_e seatID, NsmSessionState_e& sessionState) ;
- NsmErrorStatus_e getApplicationModeNSM(NsmApplicationMode_e& applicationMode) ;
- NsmErrorStatus_e registerShutdownClientNSM(const uint32_t shutdownMode, const uint32_t timeoutMs) ;
- NsmErrorStatus_e unRegisterShutdownClientNSM(const uint32_t shutdownMode) ;
- am_Error_e getInterfaceVersionNSM(uint32_t& version) ;
- NsmErrorStatus_e sendLifecycleRequestCompleteNSM(const uint32_t RequestId, const NsmErrorStatus_e status) ;
am_Error_e getListMainSinkSoundProperties(const am_sinkID_t sinkID, std::vector<am_MainSoundProperty_s>& listSoundproperties) const;
am_Error_e getListMainSourceSoundProperties(const am_sourceID_t sourceID, std::vector<am_MainSoundProperty_s>& listSoundproperties) const;
am_Error_e getListSinkSoundProperties(const am_sinkID_t sinkID, std::vector<am_SoundProperty_s>& listSoundproperties) const;
diff --git a/AudioManagerDaemon/include/CAmControlSender.h b/AudioManagerDaemon/include/CAmControlSender.h
index e709155..40ab379 100644
--- a/AudioManagerDaemon/include/CAmControlSender.h
+++ b/AudioManagerDaemon/include/CAmControlSender.h
@@ -104,10 +104,6 @@ public:
void hookSourceNotificationDataChanged(const am_sourceID_t sourceID, const am_NotificationPayload_s& payload) ;
am_Error_e hookUserSetMainSinkNotificationConfiguration(const am_sinkID_t sinkID, const am_NotificationConfiguration_s& notificationConfiguration) ;
am_Error_e hookUserSetMainSourceNotificationConfiguration(const am_sourceID_t sourceID, const am_NotificationConfiguration_s& notificationConfiguration) ;
- void hookSystemNodeStateChanged(const NsmNodeState_e NodeStateId) ;
- void hookSystemNodeApplicationModeChanged(const NsmApplicationMode_e ApplicationModeId) ;
- void hookSystemSessionStateChanged(const std::string& sessionName, const NsmSeat_e seatID, const NsmSessionState_e sessionStateID) ;
- NsmErrorStatus_e hookSystemLifecycleRequest(const uint32_t Request, const uint32_t RequestId) ;
void hookSystemSingleTimingInformationChanged(const am_connectionID_t connectionID, const am_timeSync_t time);
void receiverCallback(const pollfd pollfd, const sh_pollHandle_t handle, void* userData);
@@ -125,8 +121,6 @@ public:
TAmShPollCheck<CAmControlSender> checkerCallbackT;
TAmShPollDispatch<CAmControlSender> dispatcherCallbackT;
- //todo: add getSessionstate, interface nachbilden von org.genivi.NodeStateManager.LifeCycleConsumer, antwort nach NSM
- //chek interface version RegisterShutdownClient, UnRegisterShutdownClient, GetSessionState, GetApplicationMode, GetNodeState
//we need this here to call the rundown from the signal handler. In case everything screwed up
static void CallsetControllerRundown(int16_t signal)
diff --git a/AudioManagerDaemon/include/CAmNodeStateCommunicator.h b/AudioManagerDaemon/include/CAmNodeStateCommunicator.h
deleted file mode 100644
index e0805ad..0000000
--- a/AudioManagerDaemon/include/CAmNodeStateCommunicator.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/**
- * SPDX license identifier: MPL-2.0
- *
- * Copyright (C) 2012, BMW AG
- *
- * This file is part of GENIVI Project AudioManager.
- *
- * Contributions are licensed to the GENIVI Alliance under one or more
- * Contribution License Agreements.
- *
- * \copyright
- * This Source Code Form is subject to the terms of the
- * Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with
- * this file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- *
- * \author Christian Linke, christian.linke@bmw.de BMW 2012
- * \author Aleksandar Donchev, aleksander.donchev@partner.bmw.de BMW 2013
- *
- * \file CAmNodeStateCommunicator.h
- * For further information see http://www.genivi.org/.
- *
- */
-
-#ifndef CAMNODESTATECOMMUNICATORBASE_H_
-#define CAMNODESTATECOMMUNICATORBASE_H_
-
-#include <assert.h>
-#include "audiomanagerconfig.h"
-#include "NodeStateManager.h"
-#include "audiomanagertypes.h"
-
-
-
-namespace am
-{
-
-class CAmControlSender;
-
-/** communicates with the NSM
- * The CAmNodeStateCommunicator communicates with the NodeStateManager.
- * The CAmNodeStateCommunicator is triggered via CAmControlReceiver, so you can communicate from the ControllerPlugin with it.
- * Most of the interfaces are passive, so you get the information you need via retrieving it. If you need to register the AudioManager
- * as LifeCycleConsumer, you need to call CAmNodeStateCommunicator::nsmRegisterShutdownClient which can be undone with CAmNodeStateCommunicator::nsmUnRegisterShutdownClient.
- * After you have registered, you will get hookSystemLifecycleRequest on the ControlSendInterface of the controller.
- * You should answer this within your set timeout with CAmNodeStateCommunicator::nsmSendLifecycleRequestComplete.
- */
-
-class CAmNodeStateCommunicator
-{
-protected:
- CAmControlSender* mpControlSender;
-public:
- CAmNodeStateCommunicator():mpControlSender(NULL) {}
- virtual ~CAmNodeStateCommunicator() {}
- virtual am_Error_e nsmGetRestartReasonProperty(NsmRestartReason_e& restartReason) = 0;
- virtual am_Error_e nsmGetShutdownReasonProperty(NsmShutdownReason_e& ShutdownReason) = 0;
- virtual am_Error_e nsmGetRunningReasonProperty(NsmRunningReason_e& nsmRunningReason) = 0;
- virtual NsmErrorStatus_e nsmGetNodeState(NsmNodeState_e& nsmNodeState) = 0;
- virtual NsmErrorStatus_e nsmGetSessionState(const std::string& sessionName, const NsmSeat_e& seatID, NsmSessionState_e& sessionState) = 0;
- virtual NsmErrorStatus_e nsmGetApplicationMode(NsmApplicationMode_e& applicationMode) = 0;
- virtual NsmErrorStatus_e nsmRegisterShutdownClient(const uint32_t shutdownMode, const uint32_t timeoutMs) = 0;
- virtual NsmErrorStatus_e nsmUnRegisterShutdownClient(const uint32_t shutdownMode) = 0;
- virtual am_Error_e nsmGetInterfaceVersion(uint32_t& version) = 0;
- virtual NsmErrorStatus_e nsmSendLifecycleRequestComplete(const uint32_t RequestId, const NsmErrorStatus_e status) = 0;
- virtual void registerControlSender(CAmControlSender* iControlSender) {
- assert(NULL!=iControlSender);
- mpControlSender = iControlSender;
- }
-};
-
-}
-
-#endif /* CAMNODESTATECOMMUNICATORBASE_H_ */
diff --git a/AudioManagerDaemon/include/CAmNodeStateCommunicatorCAPI.h b/AudioManagerDaemon/include/CAmNodeStateCommunicatorCAPI.h
deleted file mode 100644
index ab89526..0000000
--- a/AudioManagerDaemon/include/CAmNodeStateCommunicatorCAPI.h
+++ /dev/null
@@ -1,113 +0,0 @@
-/**
- * SPDX license identifier: MPL-2.0
- *
- * Copyright (C) 2012, BMW AG
- *
- * This file is part of GENIVI Project AudioManager.
- *
- * Contributions are licensed to the GENIVI Alliance under one or more
- * Contribution License Agreements.
- *
- * \copyright
- * This Source Code Form is subject to the terms of the
- * Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with
- * this file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- *
- * \author Aleksandar Donchev, aleksander.donchev@partner.bmw.de BMW 2013
- *
- * \file CAmNodeStateCommunicatorCAPI.h
- * For further information see http://www.genivi.org/.
- *
- */
-#ifndef CAMNODESTATECOMMUNICATORCAPI_H_
-#define CAMNODESTATECOMMUNICATORCAPI_H_
-
-#include "CAmNodeStateCommunicator.h"
-#include "CAmCommonAPIWrapper.h"
-#include <v1_0/org/genivi/NodeStateManager/ConsumerProxy.hpp>
-#include <v1_0/org/genivi/NodeStateManager/LifeCycleConsumerStubDefault.hpp>
-
-
-namespace am
-{
-
-#define am_nodestatemanager v1_0::org::genivi::NodeStateManager
-
-
-class CAmCommonAPIWrapper;
-/** communicates with the NSM
- * The CAmNodeStateCommunicator communicates with the NodeStateManager via Common-API wrapping mechanism. It works only, if CAmCommonAPIWrapper is enabled.
- */
-class CAmNodeStateCommunicatorCAPI : public CAmNodeStateCommunicator
-{
- static const char * DEFAULT_DOMAIN_STRING;
- static const char * CLIENT_INSTANCE_STRING;
- static const char * CLIENT_INTERFACE_STRING;
- static const char * LIFECYCLE_SERVICE_INSTANCE_STRING;
- static const char * LIFECYCLE_SERVICE_INTERFACE_STRING;
- static const char * OBJECT_NAME;
- static const char * BUS_NAME;
-
- /* A concrete implementation of the life cycle stub.
- * An object from this class is instantiated from the common-api factory.
- * It forwards the invocations to its delegate CAmNodeStateCommunicatorCAPI.
- */
- class CAmNodeStateCommunicatorServiceImpl : public am_nodestatemanager::LifeCycleConsumerStubDefault
- {
- CAmNodeStateCommunicatorCAPI *mpDelegate;
- public:
- CAmNodeStateCommunicatorServiceImpl ():mpDelegate(NULL) {}
- CAmNodeStateCommunicatorServiceImpl (CAmNodeStateCommunicatorCAPI *aNSCommunicator):mpDelegate(aNSCommunicator) {}
- ~CAmNodeStateCommunicatorServiceImpl() { mpDelegate = NULL; }
-
- CAmNodeStateCommunicatorCAPI *getDelegate() { return mpDelegate; };
- void setDelegate(CAmNodeStateCommunicatorCAPI *aDelegate) { mpDelegate = aDelegate; };
-
- void LifecycleRequest(uint32_t Request, uint32_t RequestId, int32_t& ErrorCode) {
- if(mpDelegate)
- mpDelegate->cbReceivedLifecycleRequest(Request, RequestId, ErrorCode);
- }
-
- void LifecycleRequest(const std::shared_ptr<CommonAPI::ClientId> client, uint32_t Request, uint32_t RequestId, LifecycleRequestReply_t reply){
- int32_t ErrorCode;
- LifecycleRequest(Request, RequestId, ErrorCode);
- reply(ErrorCode);
- }
- };
-
- CAmCommonAPIWrapper *mpCAPIWrapper;
- std::shared_ptr<am_nodestatemanager::ConsumerProxy<> > mNSMProxy;
- std::shared_ptr<CAmNodeStateCommunicatorCAPI::CAmNodeStateCommunicatorServiceImpl> mNSMStub;
-
- /* Client events */
- void onNodeStateEvent(const int32_t nodeState);
- void onNodeApplicationModeEvent(const int32_t nodeApplicationMode);
- void onSessionStateChangedEvent(const std::string & sessionName, const int32_t seatID, const int32_t sessionState);
- void onServiceStatusEvent(const CommonAPI::AvailabilityStatus& serviceStatus);
- /* Service callbacks */
- void cbReceivedLifecycleRequest(uint32_t Request, uint32_t RequestId, int32_t& ErrorCode);
-
-protected:
- bool mIsServiceAvailable;
-
-public:
- CAmNodeStateCommunicatorCAPI(CAmCommonAPIWrapper* iCAPIWrapper);
- virtual ~CAmNodeStateCommunicatorCAPI();
-
- am_Error_e nsmGetRestartReasonProperty(NsmRestartReason_e& restartReason) ;
- am_Error_e nsmGetShutdownReasonProperty(NsmShutdownReason_e& ShutdownReason) ;
- am_Error_e nsmGetRunningReasonProperty(NsmRunningReason_e& nsmRunningReason) ;
- NsmErrorStatus_e nsmGetNodeState(NsmNodeState_e& nsmNodeState) ;
- NsmErrorStatus_e nsmGetSessionState(const std::string& sessionName, const NsmSeat_e& seatID, NsmSessionState_e& sessionState) ;
- NsmErrorStatus_e nsmGetApplicationMode(NsmApplicationMode_e& applicationMode) ;
- NsmErrorStatus_e nsmRegisterShutdownClient(const uint32_t shutdownMode, const uint32_t timeoutMs) ;
- NsmErrorStatus_e nsmUnRegisterShutdownClient(const uint32_t shutdownMode) ;
- am_Error_e nsmGetInterfaceVersion(uint32_t& version) ;
- NsmErrorStatus_e nsmSendLifecycleRequestComplete(const uint32_t RequestId, const NsmErrorStatus_e status) ;
- bool isServiceAvailable();
-};
-
-}
-/* namespace am */
-#endif /* CAMNODESTATECOMMUNICATORCAPI_H_ */
diff --git a/AudioManagerDaemon/include/CAmNodeStateCommunicatorDBus.h b/AudioManagerDaemon/include/CAmNodeStateCommunicatorDBus.h
deleted file mode 100644
index 62eafbf..0000000
--- a/AudioManagerDaemon/include/CAmNodeStateCommunicatorDBus.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/**
- * SPDX license identifier: MPL-2.0
- *
- * Copyright (C) 2012, BMW AG
- *
- * This file is part of GENIVI Project AudioManager.
- *
- * Contributions are licensed to the GENIVI Alliance under one or more
- * Contribution License Agreements.
- *
- * \copyright
- * This Source Code Form is subject to the terms of the
- * Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with
- * this file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- *
- * \author Christian Linke, christian.linke@bmw.de BMW 2012
- *
- * \file CAmNodeStateCommunicatorDBus.h
- * For further information see http://www.genivi.org/.
- *
- */
-#ifndef CAMNODESTATECOMMUNICATORDBUS_H_
-#define CAMNODESTATECOMMUNICATORDBUS_H_
-
-#include "CAmDbusWrapper.h"
-#include "CAmNodeStateCommunicator.h"
-
-namespace am
-{
-/** communicates with the NSM
- * The CAmNodeStateCommunicator communicates with the NodeStateManager via Dbus. Only works, if CAmDbusWrapper is enabled.
- */
-
-class CAmNodeStateCommunicatorDBus : public CAmNodeStateCommunicator
-{
-public:
- CAmNodeStateCommunicatorDBus(CAmDbusWrapper* iDbusWrapper);
- virtual ~CAmNodeStateCommunicatorDBus();
- am_Error_e nsmGetRestartReasonProperty(NsmRestartReason_e& restartReason) ;
- am_Error_e nsmGetShutdownReasonProperty(NsmShutdownReason_e& ShutdownReason) ;
- am_Error_e nsmGetRunningReasonProperty(NsmRunningReason_e& nsmRunningReason) ;
- NsmErrorStatus_e nsmGetNodeState(NsmNodeState_e& nsmNodeState) ;
- NsmErrorStatus_e nsmGetSessionState(const std::string& sessionName, const NsmSeat_e& seatID, NsmSessionState_e& sessionState) ;
- NsmErrorStatus_e nsmGetApplicationMode(NsmApplicationMode_e& applicationMode) ;
- NsmErrorStatus_e nsmRegisterShutdownClient(const uint32_t shutdownMode, const uint32_t timeoutMs) ;
- NsmErrorStatus_e nsmUnRegisterShutdownClient(const uint32_t shutdownMode) ;
- am_Error_e nsmGetInterfaceVersion(uint32_t& version) ;
- NsmErrorStatus_e nsmSendLifecycleRequestComplete(const uint32_t RequestId, const NsmErrorStatus_e status) ;
-
- static DBusHandlerResult receiveCallback(DBusConnection *conn, DBusMessage *msg, void *user_data);
- static DBusHandlerResult signalCallback(DBusConnection *conn, DBusMessage *msg, void *user_data);
-
-
-private:
- void sendIntrospection(DBusConnection* conn, DBusMessage* msg);
- void sendMessage(DBusMessage* message, DBusMessage* origMessage);
- DBusHandlerResult receiveCallbackDelegate(DBusConnection *conn, DBusMessage *msg);
- am_Error_e readIntegerProperty(const std::string property, int32_t &value);
- CAmDbusWrapper* mpDbusWrapper;
- DBusConnection* mpDBusConnection;
-};
-
-} /* namespace am */
-#endif /* CAMNODESTATECOMMUNICATORDBUS_H_ */
diff --git a/AudioManagerDaemon/src/CAmControlReceiver.cpp b/AudioManagerDaemon/src/CAmControlReceiver.cpp
index 2915f5e..198109d 100644
--- a/AudioManagerDaemon/src/CAmControlReceiver.cpp
+++ b/AudioManagerDaemon/src/CAmControlReceiver.cpp
@@ -32,30 +32,9 @@
#include "CAmRouter.h"
#include "CAmDltWrapper.h"
#include "CAmSocketHandler.h"
-#ifdef WITH_NSM
- #include "CAmNodeStateCommunicator.h"
-#endif
-
-
namespace am {
-CAmControlReceiver::CAmControlReceiver(IAmDatabaseHandler *iDatabaseHandler, CAmRoutingSender *iRoutingSender, CAmCommandSender *iCommandSender, CAmSocketHandler *iSocketHandler, CAmRouter* iRouter, CAmNodeStateCommunicator* iNodeStateCommunicator) :
- mDatabaseHandler(iDatabaseHandler), //
- mRoutingSender(iRoutingSender), //
- mCommandSender(iCommandSender), //
- mSocketHandler(iSocketHandler), //
- mRouter(iRouter), //
- mNodeStateCommunicator(iNodeStateCommunicator)
-{
- assert(mDatabaseHandler!=NULL);
- assert(mRoutingSender!=NULL);
- assert(mCommandSender!=NULL);
- assert(mSocketHandler!=NULL);
- assert(mRouter!=NULL);
- assert(iNodeStateCommunicator!=NULL);
-}
-
CAmControlReceiver::CAmControlReceiver(IAmDatabaseHandler *iDatabaseHandler, CAmRoutingSender *iRoutingSender, CAmCommandSender *iCommandSender, CAmSocketHandler *iSocketHandler, CAmRouter* iRouter) :
mDatabaseHandler(iDatabaseHandler), //
mRoutingSender(iRoutingSender), //
@@ -456,7 +435,6 @@ void CAmControlReceiver::setRoutingReady()
void CAmControlReceiver::confirmControllerReady(const am_Error_e error)
{
- //todo: one time implement here system interaction with NSM
if (error!=E_OK)
logError("CAmControlReceiver::confirmControllerReady controller reported error", error);
}
@@ -565,138 +543,6 @@ am_Error_e CAmControlReceiver::changeMainSourceNotificationConfigurationDB(const
return (mDatabaseHandler->changeMainSourceNotificationConfigurationDB(sourceID,mainNotificationConfiguration));
}
-am_Error_e CAmControlReceiver::getRestartReasonPropertyNSM(NsmRestartReason_e& restartReason)
-{
- if (!mNodeStateCommunicator)
- return (E_NON_EXISTENT);
-#ifdef WITH_NSM
- return (mNodeStateCommunicator->nsmGetRestartReasonProperty(restartReason));
-#else
- (void)restartReason;
- return (E_NON_EXISTENT);
-#endif
-}
-
-am_Error_e CAmControlReceiver::getShutdownReasonPropertyNSM(NsmShutdownReason_e& ShutdownReason)
-{
- if (!mNodeStateCommunicator)
- return (E_NON_EXISTENT);
-#ifdef WITH_NSM
- return (mNodeStateCommunicator->nsmGetShutdownReasonProperty(ShutdownReason));
-#else
- (void)ShutdownReason;
- return (E_NON_EXISTENT);
-#endif
-
-}
-
-am_Error_e CAmControlReceiver::getRunningReasonPropertyNSM(NsmRunningReason_e& nsmRunningReason)
-{
- if (!mNodeStateCommunicator)
- return (E_NON_EXISTENT);
-#ifdef WITH_NSM
- return (mNodeStateCommunicator->nsmGetRunningReasonProperty(nsmRunningReason));
-#else
- (void)nsmRunningReason;
- return (E_NON_EXISTENT);
-#endif
-
-}
-
-NsmErrorStatus_e CAmControlReceiver::getNodeStateNSM(NsmNodeState_e& nsmNodeState)
-{
- if (!mNodeStateCommunicator)
- return (NsmErrorStatus_Error);
-#ifdef WITH_NSM
- return (mNodeStateCommunicator->nsmGetNodeState(nsmNodeState));
-#else
- (void) nsmNodeState;
- return (NsmErrorStatus_Error);
-#endif
-}
-
-NsmErrorStatus_e CAmControlReceiver::getSessionStateNSM(const std::string& sessionName, const NsmSeat_e seatID, NsmSessionState_e& sessionState)
-{
- if (!mNodeStateCommunicator)
- return (NsmErrorStatus_Error);
-#ifdef WITH_NSM
- return (mNodeStateCommunicator->nsmGetSessionState(sessionName,seatID,sessionState));
-#else
- (void) sessionName;
- (void) seatID;
- (void) sessionState;
- return (NsmErrorStatus_Error);
-#endif
-
-}
-
-NsmErrorStatus_e CAmControlReceiver::getApplicationModeNSM(NsmApplicationMode_e& applicationMode)
-{
- if (!mNodeStateCommunicator)
- return (NsmErrorStatus_Error);
-#ifdef WITH_NSM
- return (mNodeStateCommunicator->nsmGetApplicationMode(applicationMode));
-#else
- (void) applicationMode;
- return (NsmErrorStatus_Error);
-#endif
-
-}
-
-NsmErrorStatus_e CAmControlReceiver::registerShutdownClientNSM(const uint32_t shutdownMode, const uint32_t timeoutMs)
-{
- if (!mNodeStateCommunicator)
- return (NsmErrorStatus_Error);
-#ifdef WITH_NSM
- return (mNodeStateCommunicator->nsmRegisterShutdownClient(shutdownMode,timeoutMs));
-#else
- (void) shutdownMode;
- (void) timeoutMs;
- return (NsmErrorStatus_Error);
-#endif
-
-}
-
-NsmErrorStatus_e CAmControlReceiver::unRegisterShutdownClientNSM(const uint32_t shutdownMode)
-{
- if (!mNodeStateCommunicator)
- return (NsmErrorStatus_Error);
-#ifdef WITH_NSM
- return (mNodeStateCommunicator->nsmUnRegisterShutdownClient(shutdownMode));
-#else
- (void) shutdownMode;
- return (NsmErrorStatus_Error);
-#endif
-
-}
-
-am_Error_e CAmControlReceiver::getInterfaceVersionNSM(uint32_t& version)
-{
- if (!mNodeStateCommunicator)
- return (E_NON_EXISTENT);
-#ifdef WITH_NSM
- return (mNodeStateCommunicator->nsmGetInterfaceVersion(version));
-#else
- (void) version;
- return (E_NON_EXISTENT);
-#endif
-
-}
-
-NsmErrorStatus_e CAmControlReceiver::sendLifecycleRequestCompleteNSM(const uint32_t RequestId, const NsmErrorStatus_e status)
-{
- if (!mNodeStateCommunicator)
- return (NsmErrorStatus_Error);
-#ifdef WITH_NSM
- return (mNodeStateCommunicator->nsmSendLifecycleRequestComplete(RequestId,status));
-#else
- (void) RequestId;
- (void) status;
- return (NsmErrorStatus_Error);
-#endif
-
-}
-
am_Error_e CAmControlReceiver::getListMainSinkSoundProperties(const am_sinkID_t sinkID, std::vector<am_MainSoundProperty_s>& listSoundproperties) const
{
logInfo("CAmControlReceiver::getListMainSinkSoundProperties was called, sinkID", sinkID);
diff --git a/AudioManagerDaemon/src/CAmControlSender.cpp b/AudioManagerDaemon/src/CAmControlSender.cpp
index c85bd57..672c2d5 100644
--- a/AudioManagerDaemon/src/CAmControlSender.cpp
+++ b/AudioManagerDaemon/src/CAmControlSender.cpp
@@ -398,18 +398,6 @@ void CAmControlSender::confirmRoutingRundown(const am_Error_e error)
mController->confirmRoutingRundown(error);
}
-void CAmControlSender::hookSystemNodeStateChanged(const NsmNodeState_e NodeStateId)
-{
- assert(mController);
- mController->hookSystemNodeStateChanged(NodeStateId);
-}
-
-void CAmControlSender::hookSystemNodeApplicationModeChanged(const NsmApplicationMode_e ApplicationModeId)
-{
- assert(mController);
- mController->hookSystemNodeApplicationModeChanged(ApplicationModeId);
-}
-
am_Error_e CAmControlSender::hookSystemUpdateSink(const am_sinkID_t sinkID, const am_sinkClass_t sinkClassID, const std::vector<am_SoundProperty_s>& listSoundProperties, const std::vector<am_CustomConnectionFormat_t>& listConnectionFormats, const std::vector<am_MainSoundProperty_s>& listMainSoundProperties)
{
assert(mController);
@@ -491,18 +479,6 @@ bool CAmControlSender::checkerCallback(const sh_pollHandle_t handle, void* userD
return (true);
}
-void CAmControlSender::hookSystemSessionStateChanged(const std::string& sessionName, const NsmSeat_e seatID, const NsmSessionState_e sessionStateID)
-{
- assert(mController);
- mController->hookSystemSessionStateChanged(sessionName,seatID,sessionStateID);
-}
-
-NsmErrorStatus_e CAmControlSender::hookSystemLifecycleRequest(const uint32_t Request, const uint32_t RequestId)
-{
- assert(mController);
- return (mController->hookSystemLifecycleRequest(Request,RequestId));
-}
-
void CAmControlSender::hookSystemSingleTimingInformationChanged(const am_connectionID_t connectionID, const am_timeSync_t time)
{
assert(mController);
diff --git a/AudioManagerDaemon/src/CAmNodeStateCommunicatorCAPI.cpp b/AudioManagerDaemon/src/CAmNodeStateCommunicatorCAPI.cpp
deleted file mode 100644
index 07c8b1f..0000000
--- a/AudioManagerDaemon/src/CAmNodeStateCommunicatorCAPI.cpp
+++ /dev/null
@@ -1,386 +0,0 @@
-/**
- * SPDX license identifier: MPL-2.0
- *
- * Copyright (C) 2012, BMW AG
- *
- * This file is part of GENIVI Project AudioManager.
- *
- * Contributions are licensed to the GENIVI Alliance under one or more
- * Contribution License Agreements.
- *
- * \copyright
- * This Source Code Form is subject to the terms of the
- * Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with
- * this file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- *
- * \author Aleksandar Donchev, aleksander.donchev@partner.bmw.de BMW 2013
- *
- * \file CAmNodeStateCommunicatorCAPI.cpp
- * For further information see http://www.genivi.org/.
- *
- */
-
-#include <assert.h>
-#include <string>
-#include <fstream>
-#include <sstream>
-#include <stdexcept>
-#include <functional>
-#include <memory>
-#include "audiomanagerconfig.h"
-#include "CAmDltWrapper.h"
-#include "CAmNodeStateCommunicatorCAPI.h"
-#include "CAmControlSender.h"
-#include <v1_0/org/genivi/NodeStateManager/LifeCycleConsumerProxy.hpp>
-
-
-namespace am
-{
-
-#define LIFECYCLE_SERVICE_INTERFACE NSM_BUS_INTERFACE ".LifeCycleConsumer"
-
-const char * CAmNodeStateCommunicatorCAPI::DEFAULT_DOMAIN_STRING = "local";
-
-const char * CAmNodeStateCommunicatorCAPI::CLIENT_INSTANCE_STRING = NSM_BUS_INTERFACE;
-const char * CAmNodeStateCommunicatorCAPI::CLIENT_INTERFACE_STRING = NSM_INTERFACE;
-
-const char * CAmNodeStateCommunicatorCAPI::LIFECYCLE_SERVICE_INSTANCE_STRING = DBUS_SERVICE_PREFIX;
-const char * CAmNodeStateCommunicatorCAPI::LIFECYCLE_SERVICE_INTERFACE_STRING = LIFECYCLE_SERVICE_INTERFACE;
-
-const char * CAmNodeStateCommunicatorCAPI::OBJECT_NAME = DBUS_SERVICE_OBJECT_PATH;
-const char * CAmNodeStateCommunicatorCAPI::BUS_NAME = LIFECYCLE_SERVICE_INTERFACE "_" DBUS_SERVICE_PREFIX;
-
-
-#define IF_NOT_AVAILABLE_RETURN(error) \
-if(!mIsServiceAvailable) { logError(__PRETTY_FUNCTION__, "Node State Manager not available yet"); return error; }
-
-/**
- * Retrieves the value from given attribute wrapper.
- */
-template <typename TValueReturnType, class TValueClass> am_Error_e getAttributeValue(CommonAPI::Attribute<TValueClass>* attribute, TValueReturnType & resultValue)
-{
- CommonAPI::CallStatus status;
- typename CommonAPI::Attribute<TValueClass>::ValueType value;
- attribute->getValue(status, value);
- std::cout << std::endl << "CallStatus : " << static_cast<int>(status) << std::endl;
- if( CommonAPI::CallStatus::SUCCESS == status)
- {
- resultValue = static_cast<TValueReturnType>(value);
- return E_OK;
- }
- return E_UNKNOWN;
-}
-
-
-CAmNodeStateCommunicatorCAPI::CAmNodeStateCommunicatorCAPI(CAmCommonAPIWrapper* iCAPIWrapper) :
- CAmNodeStateCommunicator(),
- mpCAPIWrapper(iCAPIWrapper),
- mIsServiceAvailable(false)
-{
- assert(mpCAPIWrapper);
- logInfo("CAmNodeStateCommunicatorCAPI::CAmNodeStateCommunicatorCAPI started");
-
- //Gets the factory pointer and build a proxy object
- mNSMProxy = iCAPIWrapper->buildProxy<am_nodestatemanager::ConsumerProxy>( CAmNodeStateCommunicatorCAPI::DEFAULT_DOMAIN_STRING,
- CAmNodeStateCommunicatorCAPI::CLIENT_INSTANCE_STRING);
- //Makes subscriptions to the following 3 events
- mNSMProxy->getNodeStateEvent().subscribe(
- std::bind(&CAmNodeStateCommunicatorCAPI::onNodeStateEvent, this, std::placeholders::_1)
- );
- mNSMProxy->getNodeApplicationModeEvent().subscribe(
- std::bind(&CAmNodeStateCommunicatorCAPI::onNodeApplicationModeEvent, this, std::placeholders::_1)
- );
- mNSMProxy->getSessionStateChangedEvent().subscribe(
- std::bind(&CAmNodeStateCommunicatorCAPI::onSessionStateChangedEvent, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)
- );
- mNSMProxy->getProxyStatusEvent().subscribe(std::bind(&CAmNodeStateCommunicatorCAPI::onServiceStatusEvent,this,std::placeholders::_1));
- //Instantiates the concrete stub implementation
- mNSMStub = std::make_shared<CAmNodeStateCommunicatorCAPI::CAmNodeStateCommunicatorServiceImpl>(this);
-
- //Registers the service
- if(!iCAPIWrapper->registerService(mNSMStub,CAmNodeStateCommunicatorCAPI::DEFAULT_DOMAIN_STRING,CAmNodeStateCommunicatorCAPI::LIFECYCLE_SERVICE_INSTANCE_STRING))
- logError("AudioManager can't register service");
-}
-
-CAmNodeStateCommunicatorCAPI::~CAmNodeStateCommunicatorCAPI()
-{
- mNSMProxy.reset();
- mpCAPIWrapper->unregisterService(CAmNodeStateCommunicatorCAPI::DEFAULT_DOMAIN_STRING,
- CAmNodeStateCommunicatorCAPI::LIFECYCLE_SERVICE_INTERFACE_STRING,
- CAmNodeStateCommunicatorCAPI::LIFECYCLE_SERVICE_INSTANCE_STRING);
- mNSMStub->setDelegate(NULL);
- mNSMStub.reset();
- mpCAPIWrapper = NULL;
-}
-
-bool CAmNodeStateCommunicatorCAPI::isServiceAvailable()
-{
- return mIsServiceAvailable;
-}
-
-/** retrieves the actual restart reason
- *
- * @param restartReason
- * @return E_OK on success
- */
-am_Error_e CAmNodeStateCommunicatorCAPI::nsmGetRestartReasonProperty(NsmRestartReason_e& restartReason)
-{
- //Check the service via the proxy object is available
- IF_NOT_AVAILABLE_RETURN(E_NOT_POSSIBLE)
- //Get the attribute
- int32_t value;
- CommonAPI::CallStatus status;
- mNSMProxy->getRestartReasonAttribute().getValue(status,value);
- if (status!=CommonAPI::CallStatus::SUCCESS)
- return (E_UNKNOWN);
- restartReason=static_cast<NsmRestartReason_e>(value);
- return (E_OK);
-}
-
-/** retrieves the actual shutdown reason
- *
- * @param ShutdownReason
- * @return E_OK on success
- */
-am_Error_e CAmNodeStateCommunicatorCAPI::nsmGetShutdownReasonProperty(NsmShutdownReason_e& ShutdownReason)
-{
- //Check the service via the proxy object is available
- IF_NOT_AVAILABLE_RETURN(E_NOT_POSSIBLE)
- //Get the attribute
- int32_t value;
- CommonAPI::CallStatus status;
- mNSMProxy->getShutdownReasonAttribute().getValue(status,value);
- if (status!=CommonAPI::CallStatus::SUCCESS)
- return (E_UNKNOWN);
- ShutdownReason=static_cast<NsmShutdownReason_e>(value);
- return (E_OK);
-}
-
-/** retrieves the actual running reason
- *
- * @param nsmRunningReason
- * @return E_OK on success
- */
-am_Error_e CAmNodeStateCommunicatorCAPI::nsmGetRunningReasonProperty(NsmRunningReason_e& nsmRunningReason)
-{
- //Check the service via the proxy object is available
- IF_NOT_AVAILABLE_RETURN(E_NOT_POSSIBLE)
- //Get the attribute
- int32_t value;
- CommonAPI::CallStatus status;
- mNSMProxy->getWakeUpReasonAttribute().getValue(status,value);
- if (status!=CommonAPI::CallStatus::SUCCESS)
- return (E_UNKNOWN);
- nsmRunningReason=static_cast<NsmRunningReason_e>(value);
- return (E_OK);
-}
-
-/** gets the node state
- *
- * @param nsmNodeState
- * @return NsmErrorStatus_Ok on success
- */
-NsmErrorStatus_e CAmNodeStateCommunicatorCAPI::nsmGetNodeState(NsmNodeState_e& nsmNodeState)
-{
- //Check the service via the proxy object is available
- IF_NOT_AVAILABLE_RETURN(NsmErrorStatus_Error)
-
- CommonAPI::CallStatus callStatus;
- int32_t tmpNodeState = 0, errorCode = 0;
- mNSMProxy->GetNodeState(callStatus, tmpNodeState, errorCode);
- if( CommonAPI::CallStatus::SUCCESS == callStatus )
- {
- nsmNodeState = static_cast<NsmNodeState_e>(tmpNodeState);
- return (static_cast<NsmErrorStatus_e>(errorCode));
- }
- return NsmErrorStatus_Error;
-}
-
-/** gets the session state for a session and seatID
- *
- * @param sessionName the name of the session
- * @param seatID the seatID
- * @param sessionState
- * @return NsmErrorStatus_Ok on success
- */
-NsmErrorStatus_e CAmNodeStateCommunicatorCAPI::nsmGetSessionState(const std::string& sessionName, const NsmSeat_e& seatID, NsmSessionState_e& sessionState)
-{
- //Check the service via the proxy object is available
- IF_NOT_AVAILABLE_RETURN(NsmErrorStatus_Error)
-
- CommonAPI::CallStatus callStatus;
- int32_t tmpSessionState = 0 , errorCode = 0;
- mNSMProxy->GetSessionState(sessionName,seatID,callStatus, tmpSessionState, errorCode);
-
- if( CommonAPI::CallStatus::SUCCESS == callStatus)
- {
- sessionState = static_cast<NsmSessionState_e>(tmpSessionState);
- return (static_cast<NsmErrorStatus_e>(errorCode));
- }
- return NsmErrorStatus_Error;
-}
-
-/** gets the application mode
- *
- * @param applicationMode
- * @return NsmErrorStatus_Ok on success
- */
-NsmErrorStatus_e CAmNodeStateCommunicatorCAPI::nsmGetApplicationMode(NsmApplicationMode_e& applicationMode)
-{
- //Check the service via the proxy object is available
- IF_NOT_AVAILABLE_RETURN(NsmErrorStatus_Error)
-
- CommonAPI::CallStatus callStatus;
- int32_t tmpAppMode = 0 , errorCode = 0;
- mNSMProxy->GetApplicationMode(callStatus, tmpAppMode, errorCode);
- if( CommonAPI::CallStatus::SUCCESS == callStatus)
- {
- applicationMode = static_cast<NsmApplicationMode_e>(tmpAppMode);
- return (static_cast<NsmErrorStatus_e>(errorCode));
- }
- return NsmErrorStatus_Dbus;
-}
-
-/** this function registers the AudioManager as shutdown client at the NSM
- * for more information check the Nodestatemanager
- * @param shutdownMode the shutdownmode you wish to set
- * @param timeoutMs the timeout you need to have
- * @return NsmErrorStatus_Ok on success
- */
-NsmErrorStatus_e CAmNodeStateCommunicatorCAPI::nsmRegisterShutdownClient(const uint32_t shutdownMode, const uint32_t timeoutMs)
-{
- //Check the service via the proxy object is available
- IF_NOT_AVAILABLE_RETURN(NsmErrorStatus_Error)
-
- CommonAPI::CallStatus callStatus;
- int32_t errorCode = 0;
- std::string objName = std::string(CAmNodeStateCommunicatorCAPI::OBJECT_NAME);
- std::string busName = std::string(CAmNodeStateCommunicatorCAPI::BUS_NAME);
- mNSMProxy->RegisterShutdownClient(busName, objName, shutdownMode, timeoutMs, callStatus, errorCode);
- if( CommonAPI::CallStatus::SUCCESS == callStatus)
- return (static_cast<NsmErrorStatus_e>(errorCode));
- return NsmErrorStatus_Dbus;
-
-}
-
-/** this function unregisters the AudioManager as shutdown client at the NSM
- *
- * @param shutdownMode
- * @return NsmErrorStatus_Ok on success
- */
-NsmErrorStatus_e CAmNodeStateCommunicatorCAPI::nsmUnRegisterShutdownClient(const uint32_t shutdownMode)
-{
- //Check the service via the proxy object is available
- IF_NOT_AVAILABLE_RETURN(NsmErrorStatus_Error)
-
- CommonAPI::CallStatus callStatus;
- int32_t errorCode = 0;
- std::string objName = std::string(CAmNodeStateCommunicatorCAPI::OBJECT_NAME);
- std::string busName = std::string(CAmNodeStateCommunicatorCAPI::BUS_NAME);
- mNSMProxy->UnRegisterShutdownClient(busName, objName, shutdownMode, callStatus, errorCode);
- if( CommonAPI::CallStatus::SUCCESS == callStatus)
- return (static_cast<NsmErrorStatus_e>(errorCode));
- return NsmErrorStatus_Dbus;
-}
-
-/** returns the interface version
- *
- * @param version
- * @return E_OK on success
- */
-am_Error_e CAmNodeStateCommunicatorCAPI::nsmGetInterfaceVersion(uint32_t& version)
-{
- //Check the service via the proxy object is available
- IF_NOT_AVAILABLE_RETURN(E_NOT_POSSIBLE)
-
- CommonAPI::CallStatus callStatus;
- mNSMProxy->GetInterfaceVersion(callStatus, version);
- if( CommonAPI::CallStatus::SUCCESS == callStatus)
- return E_OK;
- return E_UNKNOWN;
-}
-
-/** sends out the Lifecycle request complete message
- *
- * @param RequestId
- * @param status
- * @return NsmErrorStatus_Ok on success
- */
-NsmErrorStatus_e CAmNodeStateCommunicatorCAPI::nsmSendLifecycleRequestComplete(const uint32_t RequestId, const NsmErrorStatus_e status)
-{
- //Check the service via the proxy object is available
- IF_NOT_AVAILABLE_RETURN(NsmErrorStatus_Error)
-
- CommonAPI::CallStatus callStatus;
- int32_t errorCode = 0;
- mNSMProxy->LifecycleRequestComplete(RequestId, status, callStatus, errorCode);
- if( CommonAPI::CallStatus::SUCCESS == callStatus)
- {
- return (static_cast<NsmErrorStatus_e>(errorCode));
- }
- return NsmErrorStatus_Dbus;
-}
-
-/** notification handler for changed node state
- *
- * @param nodeState
- * @return none
- */
-void CAmNodeStateCommunicatorCAPI::onNodeStateEvent(const int32_t nodeState)
-{
- logInfo(__PRETTY_FUNCTION__, " got signal NodeState, with nodeState",nodeState);
- assert(mpControlSender);
- mpControlSender->hookSystemNodeStateChanged(static_cast<NsmNodeState_e>(nodeState));
-}
-
-/** notification handler for changed node application mode
- *
- * @param nodeApplicationMode
- * @return none
- */
-void CAmNodeStateCommunicatorCAPI::onNodeApplicationModeEvent(const int32_t nodeApplicationMode)
-{
- logInfo(__PRETTY_FUNCTION__, " got signal nodeApplicationMode, with applicationMode",nodeApplicationMode);
- assert(mpControlSender);
- mpControlSender->hookSystemNodeApplicationModeChanged(static_cast<NsmApplicationMode_e>(nodeApplicationMode));
-}
-
-/** notification handler for changed session state
- *
- * @param sessionName
- * @param seatID
- * @param sessionState
- * @return none
- */
-void CAmNodeStateCommunicatorCAPI::onSessionStateChangedEvent(const std::string & sessionName, const int32_t seatID, const int32_t sessionState)
-{
- logInfo(__PRETTY_FUNCTION__, " got signal sessionStateChanged, with session",sessionName,"seatID=",seatID,"sessionState",sessionState);
- assert(mpControlSender);
- mpControlSender->hookSystemSessionStateChanged(sessionName, static_cast<NsmSeat_e>(seatID), static_cast<NsmSessionState_e>(sessionState));
-}
-
-void CAmNodeStateCommunicatorCAPI::onServiceStatusEvent(const CommonAPI::AvailabilityStatus& serviceStatus)
-{
- std::stringstream avail;
- avail << "(" << static_cast<int>(serviceStatus) << ")";
-
- logInfo("Service Status of the NSM changed to ", avail.str());
- std::cout << std::endl << "Service Status of the NSM changed to " << avail.str();
- mIsServiceAvailable = (serviceStatus==CommonAPI::AvailabilityStatus::AVAILABLE);
-}
-
-/** implements the service part, which is invoked from the node state manager
- *
- * @param sessionName
- * @param seatID
- * @param sessionState
- * @return none
- */
-void CAmNodeStateCommunicatorCAPI::cbReceivedLifecycleRequest(uint32_t Request, uint32_t RequestId, int32_t& ErrorCode)
-{
- assert(mpControlSender);
- ErrorCode = mpControlSender->hookSystemLifecycleRequest(Request, RequestId);
-}
-
-} /* namespace am */
diff --git a/AudioManagerDaemon/src/CAmNodeStateCommunicatorDBus.cpp b/AudioManagerDaemon/src/CAmNodeStateCommunicatorDBus.cpp
deleted file mode 100644
index 501dfd8..0000000
--- a/AudioManagerDaemon/src/CAmNodeStateCommunicatorDBus.cpp
+++ /dev/null
@@ -1,778 +0,0 @@
-/**
- * SPDX license identifier: MPL-2.0
- *
- * Copyright (C) 2012, BMW AG
- *
- * This file is part of GENIVI Project AudioManager.
- *
- * Contributions are licensed to the GENIVI Alliance under one or more
- * Contribution License Agreements.
- *
- * \copyright
- * This Source Code Form is subject to the terms of the
- * Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with
- * this file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- *
- * \author Christian Linke, christian.linke@bmw.de BMW 2012
- *
- * \file CAmNodeStateCommunicatorDBus.cpp
- * For further information see http://www.genivi.org/.
- *
- */
-
-#include "CAmNodeStateCommunicatorDBus.h"
-#include <assert.h>
-#include <string>
-#include <fstream>
-#include <sstream>
-#include <stdexcept>
-#include "CAmControlSender.h"
-#include "CAmDltWrapper.h"
-#include "audiomanagerconfig.h"
-
-namespace am
-{
-
-static DBusObjectPathVTable gObjectPathVTable;
-
-CAmNodeStateCommunicatorDBus::CAmNodeStateCommunicatorDBus(CAmDbusWrapper* iDbusWrapper) : CAmNodeStateCommunicator(),
- mpDbusWrapper(iDbusWrapper), //
- mpDBusConnection(NULL)
-{
- assert(mpDbusWrapper);
- logInfo("CAmNodeStateCommunicator::CAmNodeStateCommunicator started");
-
- //save the DBusConnection
- mpDbusWrapper->getDBusConnection(mpDBusConnection);
- assert(mpDBusConnection!=NULL);
-
- //register the path and the callback for receiving messages
- std::string path("LifeCycleConsumer");
- gObjectPathVTable.message_function=CAmNodeStateCommunicatorDBus::receiveCallback;
- mpDbusWrapper->registerCallback(&gObjectPathVTable, path, this);
-
- //now we need to make sure we catch the signals from the NSM:
- dbus_bus_add_match(mpDBusConnection, "type=\'signal\',path=\'/org/genivi/NodeStateManager\'", NULL);
- if (!dbus_connection_add_filter(mpDBusConnection, CAmNodeStateCommunicatorDBus::signalCallback, this, NULL))
- {
- logError("CAmNodeStateCommunicator::CAmNodeStateCommunicator not enought memory!");
- throw std::runtime_error("CAmNodeStateCommunicator::CAmNodeStateCommunicator not enought memory!");
- }
- dbus_connection_flush(mpDBusConnection);
-}
-
-CAmNodeStateCommunicatorDBus::~CAmNodeStateCommunicatorDBus()
-{}
-
-/** retrieves the actual restartReason
- *
- * @param restartReason
- * @return E_OK on success
- */
-am_Error_e CAmNodeStateCommunicatorDBus::nsmGetRestartReasonProperty(NsmRestartReason_e& restartReason)
-{
- int32_t answer(0);
- am_Error_e error=readIntegerProperty("RestartReason",answer);
- restartReason=static_cast<NsmRestartReason_e>(answer);
- return(error);
-}
-
-/** retrieves the actual shutdownreason
- *
- * @param ShutdownReason
- * @return E_OK on success
- */
-am_Error_e CAmNodeStateCommunicatorDBus::nsmGetShutdownReasonProperty(NsmShutdownReason_e& ShutdownReason)
-{
- int32_t answer(0);
- am_Error_e error=readIntegerProperty("ShutdownReason",answer);
- ShutdownReason=static_cast<NsmShutdownReason_e>(answer);
- return(error);
-}
-
-/** retrieves the actual runnuing reason
- *
- * @param nsmRunningReason
- * @return E_OK on success
- */
-am_Error_e CAmNodeStateCommunicatorDBus::nsmGetRunningReasonProperty(NsmRunningReason_e& nsmRunningReason)
-{
- int32_t answer(0);
- am_Error_e error=readIntegerProperty("WakeUpReason",answer);
- nsmRunningReason=static_cast<NsmRunningReason_e>(answer);
- return(error);
-}
-
-/** gets the node state
- *
- * @param nsmNodeState
- * @return NsmErrorStatus_Ok on success
- */
-NsmErrorStatus_e CAmNodeStateCommunicatorDBus::nsmGetNodeState(NsmNodeState_e& nsmNodeState)
-{
- DBusError error;
- dbus_error_init(&error);
-
- uint32_t nodeStateID;
- uint32_t returnedError;
-
- DBusMessage * message = dbus_message_new_method_call(NSM_BUS_INTERFACE, NSM_PATH, NSM_INTERFACE, "GetNodeState");
-
- if (!message)
- {
- logError("CAmNodeStateCommunicatorDBus::nsmGetNodeState dbus error:", error.message);
- return (NsmErrorStatus_Dbus);
- }
-
- DBusMessage* reply(dbus_connection_send_with_reply_and_block(mpDBusConnection, message, -1, &error));
- if (!reply)
- {
- logError("CAmNodeStateCommunicatorDBus::nsmGetNodeState failed, dbus error", error.message);
- return (NsmErrorStatus_Dbus);
- }
-
- if(!dbus_message_get_args(reply, &error, DBUS_TYPE_INT32, &nodeStateID, DBUS_TYPE_INT32, &returnedError, DBUS_TYPE_INVALID))
- return (NsmErrorStatus_Dbus);
-
- dbus_message_unref(reply);
-
- nsmNodeState=static_cast<NsmNodeState_e>(nodeStateID);
- return (static_cast<NsmErrorStatus_e>(returnedError));
-}
-
-/** gets the session state for a session and seatID
- *
- * @param sessionName the name of the session
- * @param seatID the seatID
- * @param sessionState
- * @return NsmErrorStatus_Ok on success
- */
-NsmErrorStatus_e CAmNodeStateCommunicatorDBus::nsmGetSessionState(const std::string& sessionName, const NsmSeat_e& seatID, NsmSessionState_e& sessionState)
-{
- DBusError error;
- dbus_error_init(&error);
- DBusMessageIter iter;
-
- uint32_t returnedError;
- int32_t BsessionState(0);
-
- DBusMessage * message = dbus_message_new_method_call(NSM_BUS_INTERFACE, NSM_PATH, NSM_INTERFACE, "GetSessionState");
-
- if (!message)
- {
- logError("CAmNodeStateCommunicatorDBus::nsmGetSessionState dbus error:", error.message);
- return (NsmErrorStatus_Dbus);
- }
-
- dbus_message_iter_init_append(message, &iter);
-
- if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &sessionName))
- {
- logError( "CAmNodeStateCommunicatorDBus::nsmGetSessionState no more memory");
- return (NsmErrorStatus_Dbus);
- }
-
- if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &seatID))
- {
- logError( "CAmNodeStateCommunicatorDBus::nsmGetSessionState no more memory");
- return (NsmErrorStatus_Dbus);
- }
-
- DBusMessage* reply(dbus_connection_send_with_reply_and_block(mpDBusConnection, message, -1, &error));
- if (!reply)
- {
- logError("CAmNodeStateCommunicatorDBus::nsmGetSessionState failed, dbus error", error.message);
- return (NsmErrorStatus_Dbus);
- }
-
- if(!dbus_message_get_args(reply, &error,
- DBUS_TYPE_INT32, &BsessionState,
- DBUS_TYPE_INT32, &returnedError,DBUS_TYPE_INVALID))
- return (NsmErrorStatus_Dbus);
-
- dbus_message_unref(reply);
-
- sessionState=static_cast<NsmSessionState_e>(BsessionState);
- return (static_cast<NsmErrorStatus_e>(returnedError));
-}
-
-/** gets the application mode
- *
- * @param applicationMode
- * @return NsmErrorStatus_Ok on success
- */
-NsmErrorStatus_e CAmNodeStateCommunicatorDBus::nsmGetApplicationMode(NsmApplicationMode_e& applicationMode)
-{
- DBusError error;
- dbus_error_init(&error);
-
- uint32_t BapplicationMode(0),returnedError(0);
-
- DBusMessage * message = dbus_message_new_method_call(NSM_BUS_INTERFACE, NSM_PATH, NSM_INTERFACE, "GetApplicationMode");
-
- if (!message)
- {
- logError("CAmNodeStateCommunicatorDBus::nsmGetApplicationMode dbus error:", error.message);
- return (NsmErrorStatus_Dbus);
- }
-
- DBusMessage* reply(dbus_connection_send_with_reply_and_block(mpDBusConnection, message, -1, &error));
- if (!reply)
- {
- logError("CAmNodeStateCommunicatorDBus::nsmGetApplicationMode failed, dbus error", error.message);
- return (NsmErrorStatus_Dbus);
- }
-
- if(!dbus_message_get_args(reply, &error, DBUS_TYPE_INT32, &BapplicationMode, DBUS_TYPE_INT32, &returnedError, DBUS_TYPE_INVALID))
- return (NsmErrorStatus_Dbus);
-
- dbus_message_unref(reply);
-
- applicationMode=static_cast<NsmApplicationMode_e>(BapplicationMode);
- return (static_cast<NsmErrorStatus_e>(returnedError));
-}
-
-/** this function registers the AudioManager as shutdown client at the NSM
- * for more information check the Nodestatemanager
- * @param shutdownMode the shutdownmode you wish to set
- * @param timeoutMs the timeout you need to have
- * @return NsmErrorStatus_Ok on success
- */
-NsmErrorStatus_e CAmNodeStateCommunicatorDBus::nsmRegisterShutdownClient(const uint32_t shutdownMode, const uint32_t timeoutMs)
-{
- DBusError error;
- DBusMessageIter iter;
- dbus_error_init(&error);
- int32_t returnError(0);
- std::string path = std::string(DBUS_SERVICE_OBJECT_PATH) + "/LifeCycleConsumer";
- const char* charPath = path.c_str();
- const char* service =DBUS_SERVICE_PREFIX;
- DBusMessage * message = dbus_message_new_method_call(NSM_BUS_INTERFACE, NSM_PATH, NSM_INTERFACE, "RegisterShutdownClient");
-
- if (!message)
- {
- logError( "CAmNodeStateCommunicatorDBus::nsmRegisterShutdownClient dbus error:", error.message);
- return (NsmErrorStatus_Dbus);
- }
- dbus_message_iter_init_append(message, &iter);
-
- if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &service))
- {
- logError( "CAmNodeStateCommunicatorDBus::nsmRegisterShutdownClient no more memory");
- return (NsmErrorStatus_Dbus);
- }
-
- if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &charPath))
- {
- logError( "CAmNodeStateCommunicatorDBus::nsmRegisterShutdownClient no more memory");
- return (NsmErrorStatus_Dbus);
- }
-
- if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_UINT32, &shutdownMode))
- {
- logError( "CAmNodeStateCommunicatorDBus::nsmRegisterShutdownClient no more memory");
- return (NsmErrorStatus_Dbus);
- }
-
- if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_UINT32, &timeoutMs))
- {
- logError( "CAmNodeStateCommunicatorDBus::nsmRegisterShutdownClient no more memory");
- return (NsmErrorStatus_Dbus);
- }
-
- DBusMessage* reply(dbus_connection_send_with_reply_and_block(mpDBusConnection, message, -1, &error));
- dbus_message_unref(message);
-
- if (!reply)
- {
- logError( "CAmRoutingDbusSend::send failed, dbus error", error.message);
- return (NsmErrorStatus_Dbus);
- }
-
- if(!dbus_message_get_args(reply, &error, DBUS_TYPE_INT32, &returnError,DBUS_TYPE_INVALID))
- {
- logError( "CAmRoutingDbusSend::send failed, dbus error", error.message);
- return (NsmErrorStatus_Dbus);
- }
- dbus_message_unref(reply);
-
- return (static_cast<NsmErrorStatus_e>(returnError));
-
-}
-
-/** this function unregisters the AudioManager as shutdown client at the NSM
- *
- * @param shutdownMode
- * @return NsmErrorStatus_Ok on success
- */
-NsmErrorStatus_e CAmNodeStateCommunicatorDBus::nsmUnRegisterShutdownClient(const uint32_t shutdownMode)
-{
- DBusError error;
- DBusMessageIter iter;
- dbus_error_init(&error);
- int32_t returnError(0);
- std::string path = std::string(DBUS_SERVICE_OBJECT_PATH) + "/LifeCycleConsumer";
- const char* charPath = path.c_str();
- const char* service =DBUS_SERVICE_PREFIX;
- DBusMessage * message = dbus_message_new_method_call(NSM_BUS_INTERFACE, NSM_PATH, NSM_INTERFACE, "UnRegisterShutdownClient");
-
- if (!message)
- {
- logError( "CAmNodeStateCommunicatorDBus::nsmUnRegisterShutdownClient dbus error:", error.message);
- return (NsmErrorStatus_Dbus);
- }
- dbus_message_iter_init_append(message, &iter);
-
- if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &service))
- {
- logError( "CAmNodeStateCommunicatorDBus::nsmUnRegisterShutdownClient no more memory");
- return (NsmErrorStatus_Dbus);
- }
-
- if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &charPath))
- {
- logError( "CAmNodeStateCommunicatorDBus::nsmUnRegisterShutdownClient no more memory");
- return (NsmErrorStatus_Dbus);
- }
-
- if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_UINT32, &shutdownMode))
- {
- logError( "CAmNodeStateCommunicatorDBus::nsmUnRegisterShutdownClient no more memory");
- return (NsmErrorStatus_Dbus);
- }
-
- DBusMessage* reply(dbus_connection_send_with_reply_and_block(mpDBusConnection, message, -1, &error));
- dbus_message_unref(message);
-
- if (!reply)
- {
- logError( "CAmNodeStateCommunicatorDBus::nsmUnRegisterShutdownClient failed, dbus error", error.message);
- return (NsmErrorStatus_Dbus);
- }
-
- if(!dbus_message_get_args(reply, &error, DBUS_TYPE_INT32, &returnError, DBUS_TYPE_INVALID))
- {
- logError( "CAmNodeStateCommunicatorDBus::nsmUnRegisterShutdownClient failed, dbus error", error.message);
- return (NsmErrorStatus_Dbus);
- }
- dbus_message_unref(reply);
-
- return (static_cast<NsmErrorStatus_e>(returnError));
-}
-
-/** returns the interface version
- *
- * @param version
- * @return E_OK on success
- */
-am_Error_e CAmNodeStateCommunicatorDBus::nsmGetInterfaceVersion(uint32_t& version)
-{
- DBusError error;
- dbus_error_init(&error);
-
- DBusMessage * message = dbus_message_new_method_call(NSM_BUS_INTERFACE, NSM_PATH, NSM_INTERFACE, "GetInterfaceVersion");
-
- if (!message)
- {
- logError("CAmNodeStateCommunicatorDBus::nsmGetInterfaceVersion dbus error:", error.message);
- return (E_UNKNOWN);
- }
-
- DBusMessage* reply(dbus_connection_send_with_reply_and_block(mpDBusConnection, message, -1, &error));
-
- dbus_message_unref(message);
-
- if (!reply)
- {
- logError("CAmNodeStateCommunicatorDBus::nsmGetInterfaceVersion failed, dbus error", error.message);
- return (E_UNKNOWN);
- }
-
- if(!dbus_message_get_args(reply, &error, DBUS_TYPE_UINT32, &version, DBUS_TYPE_INVALID))
- {
- logError("CAmNodeStateCommunicatorDBus::nsmGetInterfaceVersion failed, dbus error", error.message);
- return (E_UNKNOWN);
- }
-
- dbus_message_unref(reply);
-
- return (E_OK);
-}
-
-/** sends out the Lifecycle request complete message
- *
- * @param RequestId
- * @param status
- * @return NsmErrorStatus_Ok on success
- */
-NsmErrorStatus_e CAmNodeStateCommunicatorDBus::nsmSendLifecycleRequestComplete(const uint32_t RequestId, const NsmErrorStatus_e status)
-{
- DBusError error;
- DBusMessageIter iter;
- dbus_error_init(&error);
- int32_t returnError(0);
- DBusMessage * message = dbus_message_new_method_call(NSM_BUS_INTERFACE, NSM_PATH, NSM_INTERFACE, "LifecycleRequestComplete");
-
- if (!message)
- {
- logError( "CAmNodeStateCommunicatorDBus::nsmSendLifecycleRequestComplete dbus error:", error.message);
- return (NsmErrorStatus_Dbus);
- }
- dbus_message_iter_init_append(message, &iter);
-
- if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_UINT32, &RequestId))
- {
- logError( "CAmNodeStateCommunicatorDBus::nsmSendLifecycleRequestComplete no more memory");
- return (NsmErrorStatus_Dbus);
- }
-
- if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32,&status))
- {
- logError( "CAmNodeStateCommunicatorDBus::nsmSendLifecycleRequestComplete no more memory");
- return (NsmErrorStatus_Dbus);
- }
-
- DBusMessage* reply(dbus_connection_send_with_reply_and_block(mpDBusConnection, message, -1, &error));
- dbus_message_unref(message);
-
- if (!reply)
- {
- logError( "CAmNodeStateCommunicatorDBus::nsmSendLifecycleRequestComplete failed, dbus error", error.message);
- return (NsmErrorStatus_Dbus);
- }
-
- if(!dbus_message_get_args(reply, &error,DBUS_TYPE_INT32, &returnError, DBUS_TYPE_INVALID))
- {
- logError( "CAmNodeStateCommunicatorDBus::nsmSendLifecycleRequestComplete failed, dbus error", error.message);
- return (NsmErrorStatus_Dbus);
- }
- dbus_message_unref(reply);
-
- return (static_cast<NsmErrorStatus_e>(returnError));
-}
-
-DBusHandlerResult CAmNodeStateCommunicatorDBus::receiveCallback(DBusConnection* conn, DBusMessage* msg, void* user_data)
-{
- CAmNodeStateCommunicatorDBus* instance = static_cast<CAmNodeStateCommunicatorDBus*>(user_data);
- assert(instance);
- return (instance->receiveCallbackDelegate(conn,msg));
-}
-
-DBusHandlerResult CAmNodeStateCommunicatorDBus::receiveCallbackDelegate(DBusConnection* conn, DBusMessage* msg)
-{
- if (dbus_message_is_method_call(msg, DBUS_INTERFACE_INTROSPECTABLE, "Introspect"))
- {
- sendIntrospection(conn, msg);
- return (DBUS_HANDLER_RESULT_HANDLED);
- }
- else
- {
- DBusMessage * returnMessage;
- dbus_uint32_t Request(0),RequestId(0);
- //no introspection - ok. So we are only interested in out LifecycleRequest message...
- std::string method(dbus_message_get_member(msg));
- if (method=="LifecycleRequest")
- {
- DBusMessageIter iter,replyIter;
- if (!dbus_message_iter_init(msg, &iter))
- {
- logError("CAmNodeStateCommunicatorDBus::receiveCallbackDelegate DBus Message has no arguments!");
- returnMessage = dbus_message_new_error(msg,DBUS_ERROR_INVALID_ARGS, "DBUS Message has no arguments!");
- sendMessage(returnMessage,msg);
- return (DBUS_HANDLER_RESULT_HANDLED);
- }
-
- if (dbus_message_iter_get_arg_type(&iter)!=DBUS_TYPE_UINT32)
- {
- logError("CAmNodeStateCommunicatorDBus::receiveCallbackDelegate DBus Message has invalid arguments!");
- returnMessage = dbus_message_new_error(msg,DBUS_ERROR_INVALID_ARGS,"DBus argument is not uint32_t!");
- sendMessage(returnMessage,msg);
- return (DBUS_HANDLER_RESULT_HANDLED);
- }
-
- dbus_message_iter_get_basic(&iter, &Request);
- dbus_message_iter_next(&iter);
-
- if (dbus_message_iter_get_arg_type(&iter)!=DBUS_TYPE_UINT32)
- {
- logError("CAmNodeStateCommunicatorDBus::receiveCallbackDelegate DBus Message has invalid arguments!");
- returnMessage = dbus_message_new_error(msg,DBUS_ERROR_INVALID_ARGS,"DBus argument is not uint32_t!");
- sendMessage(returnMessage,msg);
- return (DBUS_HANDLER_RESULT_HANDLED);
- }
-
- dbus_message_iter_get_basic(&iter, &RequestId);
-
- assert(mpControlSender);
- NsmErrorStatus_e returnError = mpControlSender->hookSystemLifecycleRequest(static_cast<uint32_t>(Request),static_cast<uint32_t>(RequestId));
-
- returnMessage = dbus_message_new_method_return(msg);
-
- if (returnMessage == NULL)
- {
- logError("CAmNodeStateCommunicatorDBus::receiveCallbackDelegate Cannot allocate DBus message!");
- returnMessage = dbus_message_new_error(msg,DBUS_ERROR_NO_MEMORY,"Cannot create reply!");
- sendMessage(returnMessage,msg);
- return (DBUS_HANDLER_RESULT_HANDLED);
- }
-
- dbus_message_iter_init_append(returnMessage, &replyIter);
-
- if (!dbus_message_iter_append_basic(&replyIter, DBUS_TYPE_INT32, &returnError))
- {
- logError("CAmNodeStateCommunicatorDBus::receiveCallbackDelegate Cannot allocate DBus message!");
- returnMessage = dbus_message_new_error(msg,DBUS_ERROR_NO_MEMORY,"Cannot create reply!");
- }
- sendMessage(returnMessage,msg);
- return (DBUS_HANDLER_RESULT_HANDLED);
- }
- }
- return (DBUS_HANDLER_RESULT_NOT_YET_HANDLED);
-}
-
-void CAmNodeStateCommunicatorDBus::sendIntrospection(DBusConnection* conn, DBusMessage* msg)
-{
- assert(conn != NULL);
- assert(msg != NULL);
- DBusMessage* reply;
- DBusMessageIter args;
- dbus_uint32_t serial = 0;
-
- // create a reply from the message
- reply = dbus_message_new_method_return(msg);
- std::string fullpath(NSM_INTROSPECTION_FILE);
- std::ifstream in(fullpath.c_str(), std::ifstream::in);
- if (!in)
- {
- logError("IAmCommandReceiverShadow::sendIntrospection could not load xml file ",fullpath);
- throw std::runtime_error("IAmCommandReceiverShadow::sendIntrospection Could not load introspecton XML");
- }
- std::stringstream buffer;
- buffer << in.rdbuf();
- std::string introspect = buffer.str();
- const char* string = introspect.c_str();
-
- // add the arguments to the reply
- dbus_message_iter_init_append(reply, &args);
- if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &string))
- {
- logError( "CAmNodeStateCommunicatorDBus::sendIntrospection DBUS handler Out Of Memory!");
- }
-
- // send the reply && flush the connection
- if (!dbus_connection_send(conn, reply, &serial))
- {
- logError( "CAmNodeStateCommunicatorDBus::sendIntrospection DBUS handler Out Of Memory!");
- }
- dbus_connection_flush(conn);
-
- // free the reply
- dbus_message_unref(reply);
-}
-
-void CAmNodeStateCommunicatorDBus::sendMessage(DBusMessage* message, DBusMessage* origMessage)
-{
- dbus_uint32_t serial = dbus_message_get_serial(origMessage);
-
- if(!dbus_connection_send(mpDBusConnection, message, &serial))
- {
- logError( "CAmNodeStateCommunicatorDBus::sendMessage DBUS handler Out Of Memory!");
- }
- dbus_connection_flush(mpDBusConnection);
- dbus_message_unref(message);
-}
-
-DBusHandlerResult CAmNodeStateCommunicatorDBus::signalCallback(DBusConnection* conn, DBusMessage* msg, void* user_data)
-{
- (void) conn;
- CAmNodeStateCommunicatorDBus* instance(static_cast<CAmNodeStateCommunicatorDBus*>(user_data));
-
- const char* iface = dbus_message_get_interface(msg);
- if (iface==NULL)
- return (DBUS_HANDLER_RESULT_NOT_YET_HANDLED);
- std::string interface(iface);
- std::string member = dbus_message_get_member(msg);
-
- if (interface=="org.genivi.NodeStateManager.Consumer")
- {
- if (member=="NodeState")
- {
- int32_t nodeState;
- DBusMessageIter iter;
- if (!dbus_message_iter_init(msg, &iter))
- {
- logError("CAmNodeStateCommunicatorDBus::signalCallback NodeState DBus Message has no arguments!");
- return (DBUS_HANDLER_RESULT_HANDLED);
- }
-
- if (dbus_message_iter_get_arg_type(&iter)!=DBUS_TYPE_INT32)
- {
- logError("CAmNodeStateCommunicatorDBus::signalCallback NodeState DBus Message has invalid arguments!");
- return (DBUS_HANDLER_RESULT_HANDLED);
- }
-
- dbus_message_iter_get_basic(&iter, &nodeState);
-
- logInfo("CAmNodeStateCommunicatorDBus::signalCallback got signal NodeState, with nodeState",nodeState);
-
- assert(instance->mpControlSender);
- instance->mpControlSender->hookSystemNodeStateChanged(static_cast<NsmNodeState_e>(nodeState));
- return (DBUS_HANDLER_RESULT_HANDLED);
- }
-
- else if (member=="NodeApplicationMode")
- {
- int32_t nodeApplicationMode;
- DBusMessageIter iter;
- if (!dbus_message_iter_init(msg, &iter))
- {
- logError("CAmNodeStateCommunicatorDBus::signalCallback nodeApplicationMode DBus Message has no arguments!");
- return (DBUS_HANDLER_RESULT_HANDLED);
- }
-
- if (dbus_message_iter_get_arg_type(&iter)!=DBUS_TYPE_INT32)
- {
- logError("CAmNodeStateCommunicatorDBus::signalCallback nodeApplicationMode DBus Message has invalid arguments!");
- return (DBUS_HANDLER_RESULT_HANDLED);
- }
-
- dbus_message_iter_get_basic(&iter, &nodeApplicationMode);
-
- logInfo("CAmNodeStateCommunicatorDBus::signalCallback got signal nodeApplicationMode, with applicationMode",nodeApplicationMode);
-
- assert(instance->mpControlSender);
- instance->mpControlSender->hookSystemNodeApplicationModeChanged(static_cast<NsmApplicationMode_e>(nodeApplicationMode));
- return (DBUS_HANDLER_RESULT_HANDLED);
- }
-
- else if (member=="SessionStateChanged")
- {
- std::string sessionName;
- NsmSeat_e seatID;
- NsmSessionState_e sessionState;
- DBusMessageIter iter;
- if (!dbus_message_iter_init(msg, &iter))
- {
- logError("CAmNodeStateCommunicatorDBus::signalCallback nodeApplicationMode DBus Message has no arguments!");
- return (DBUS_HANDLER_RESULT_HANDLED);
- }
-
- if (dbus_message_iter_get_arg_type(&iter)!=DBUS_TYPE_STRING)
- {
- logError("CAmNodeStateCommunicatorDBus::signalCallback nodeApplicationMode DBus Message has invalid arguments!");
- return (DBUS_HANDLER_RESULT_HANDLED);
- }
-
- char * sessionNameChar;
- dbus_message_iter_get_basic(&iter, &sessionNameChar);
- sessionName=std::string(sessionNameChar);
- dbus_message_iter_next(&iter);
-
- if (dbus_message_iter_get_arg_type(&iter)!=DBUS_TYPE_INT32)
- {
- logError("CAmNodeStateCommunicatorDBus::signalCallback nodeApplicationMode DBus Message has invalid arguments!");
- return (DBUS_HANDLER_RESULT_HANDLED);
- }
-
- dbus_message_iter_get_basic(&iter, &seatID);
- dbus_message_iter_next(&iter);
-
- if (dbus_message_iter_get_arg_type(&iter)!=DBUS_TYPE_INT32)
- {
- logError("CAmNodeStateCommunicatorDBus::signalCallback nodeApplicationMode DBus Message has invalid arguments!");
- return (DBUS_HANDLER_RESULT_HANDLED);
- }
-
- dbus_message_iter_get_basic(&iter, &sessionState);
-
-
- logInfo("CAmNodeStateCommunicatorDBus::signalCallback got signal sessionStateChanged, with session",sessionName,"seatID=",seatID,"sessionState",sessionState);
-
- assert(instance->mpControlSender);
- instance->mpControlSender->hookSystemSessionStateChanged(sessionName,seatID,sessionState);
- return (DBUS_HANDLER_RESULT_HANDLED);
- }
-
- else
- {
- return (DBUS_HANDLER_RESULT_NOT_YET_HANDLED);
- }
- }
-
- return (DBUS_HANDLER_RESULT_NOT_YET_HANDLED);
-}
-
-am_Error_e CAmNodeStateCommunicatorDBus::readIntegerProperty(const std::string property, int32_t& value)
-{
- DBusError error;
- dbus_error_init(&error);
- DBusMessageIter iter,iterVariant;
-
- DBusMessage * message = dbus_message_new_method_call(NSM_BUS_INTERFACE, NSM_PATH, "org.freedesktop.DBus.Properties", "Get");
-
- if (!message)
- {
- logError("CAmNodeStateCommunicatorDBus::readIntegerProperty dbus error:", error.message);
- dbus_message_unref(message);
- return (E_UNKNOWN);
- }
-
-
- dbus_message_iter_init_append(message, &iter);
- const char *interface=NSM_INTERFACE;
- const char *propertyChar=property.c_str();
- if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &interface))
- {
- logError("CAmNodeStateCommunicatorDBus::readIntegerProperty append error");
- dbus_message_unref(message);
- return (E_UNKNOWN);
- }
-
- if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &propertyChar))
- {
- logError("CAmNodeStateCommunicatorDBus::readIntegerProperty append error");
- dbus_message_unref(message);
- return (E_UNKNOWN);
- }
-
- DBusMessage* reply(dbus_connection_send_with_reply_and_block(mpDBusConnection, message, -1, &error));
- if (!reply)
- {
- logError("CAmNodeStateCommunicatorDBus::readIntegerProperty failed, dbus error", error.message);
- dbus_message_unref(message);
- return (E_UNKNOWN);
- }
-
- if(!dbus_message_iter_init(reply,&iterVariant))
- {
- logError("CAmNodeStateCommunicatorDBus::readIntegerProperty failed, dbus error", error.message);
- dbus_message_unref(message);
- dbus_message_unref(reply);
- return (E_UNKNOWN);
- }
- if (dbus_message_iter_get_arg_type (&iterVariant)!= DBUS_TYPE_VARIANT)
- {
- logError("CAmNodeStateCommunicatorDBus::readIntegerProperty failed, dbus return type wrong");
- dbus_message_unref(reply);
- dbus_message_unref(message);
- return (E_UNKNOWN);
- }
- DBusMessageIter subiter;
- dbus_message_iter_recurse (&iterVariant, &subiter);
- if (dbus_message_iter_get_arg_type (&subiter)!= DBUS_TYPE_INT32)
- {
- logError("CAmNodeStateCommunicatorDBus::readIntegerProperty failed, dbus return type wrong");
- dbus_message_unref(reply);
- dbus_message_unref(message);
- return (E_UNKNOWN);
- }
-
- dbus_message_iter_get_basic(&subiter,&value);
- dbus_message_unref(reply);
- dbus_message_unref(message);
-
- return (E_OK);
-}
-
-} /* namespace am */
diff --git a/AudioManagerDaemon/src/main.cpp b/AudioManagerDaemon/src/main.cpp
index 6db7715..5942e18 100755
--- a/AudioManagerDaemon/src/main.cpp
+++ b/AudioManagerDaemon/src/main.cpp
@@ -30,20 +30,13 @@
#ifdef WITH_CAPI_WRAPPER
#include "CAmCommonAPIWrapper.h"
-#else
- #ifdef WITH_DBUS_WRAPPER
- #include "CAmDbusWrapper.h"
- #endif
#endif
-#ifdef WITH_NSM
- #ifdef WITH_DBUS_WRAPPER
- #include "CAmNodeStateCommunicatorDBus.h"
- #else
- #include "CAmNodeStateCommunicatorCAPI.h"
- #endif
+#ifdef WITH_DBUS_WRAPPER
+ #include "CAmDbusWrapper.h"
#endif
+
#ifdef WITH_DATABASE_STORAGE
#include "CAmDatabaseHandlerSQLite.h"
#else
@@ -336,19 +329,12 @@ void mainProgram(int argc, char *argv[])
#ifdef WITH_CAPI_WRAPPER
//We instantiate a singleton with the current socket handler, which loads the common-api runtime.
CAmCommonAPIWrapper *pCAPIWrapper = CAmCommonAPIWrapper::instantiateOnce(&iSocketHandler, "AudioManager");
- CAmCommonAPIWrapper iDBusWrapper = *pCAPIWrapper;
-#ifdef WITH_NSM
- CAmNodeStateCommunicatorCAPI iNodeStateCommunicator(&iDBusWrapper);
-#endif /*WITH_NSM*/
#endif /*WITH_CAPI_WRAPPER */
#ifdef WITH_DBUS_WRAPPER
if (dbusWrapperTypeBool.getValue())
dbusWrapperType=DBUS_BUS_SYSTEM;
CAmDbusWrapper iDBusWrapper(&iSocketHandler,dbusWrapperType);
-#ifdef WITH_NSM
- CAmNodeStateCommunicatorDBus iNodeStateCommunicator(&iDBusWrapper);
-#endif /*WITH_NSM*/
#endif /*WITH_DBUS_WRAPPER */
#ifdef WITH_SYSTEMD_WATCHDOG
@@ -371,12 +357,7 @@ void mainProgram(int argc, char *argv[])
CAmRoutingReceiver iRoutingReceiver(pDatabaseHandler,&iRoutingSender,&iControlSender,&iSocketHandler);
#endif /*WITH_DBUS_WRAPPER*/
-#ifdef WITH_NSM
- CAmControlReceiver iControlReceiver(pDatabaseHandler,&iRoutingSender,&iCommandSender,&iSocketHandler, &iRouter, &iNodeStateCommunicator);
- iNodeStateCommunicator.registerControlSender(&iControlSender);
-#else /*WITH_NSM*/
- CAmControlReceiver iControlReceiver(pDatabaseHandler,&iRoutingSender,&iCommandSender,&iSocketHandler, &iRouter);
-#endif /*WITH_NSM*/
+CAmControlReceiver iControlReceiver(pDatabaseHandler,&iRoutingSender,&iCommandSender,&iSocketHandler, &iRouter);
#ifdef WITH_TELNET
CAmTelnetServer iTelnetServer(&iSocketHandler, &iCommandSender, &iCommandReceiver, &iRoutingSender, &iRoutingReceiver, &iControlSender, &iControlReceiver, pDatabaseHandler, &iRouter, telnetPort.getValue(), maxConnections.getValue());
diff --git a/AudioManagerDaemon/test/AmNodeStateCommunicatorCAPITest/CAmNodeStateCommunicatorTest.cpp b/AudioManagerDaemon/test/AmNodeStateCommunicatorCAPITest/CAmNodeStateCommunicatorTest.cpp
deleted file mode 100644
index d9e0fd0..0000000
--- a/AudioManagerDaemon/test/AmNodeStateCommunicatorCAPITest/CAmNodeStateCommunicatorTest.cpp
+++ /dev/null
@@ -1,266 +0,0 @@
-/**
- * SPDX license identifier: MPL-2.0
- *
- * Copyright (C) 2012, BMW AG
- *
- * This file is part of GENIVI Project AudioManager.
- *
- * Contributions are licensed to the GENIVI Alliance under one or more
- * Contribution License Agreements.
- *
- * \copyright
- * This Source Code Form is subject to the terms of the
- * Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with
- * this file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- *
-* \author Aleksandar Donchev, aleksander.donchev@partner.bmw.de BMW 2013
- *
- * \file CAmNodeStateCommunicatorTest.cpp
- * For further information see http://www.genivi.org/.
- *
- */
-
-#include "CAmNodeStateCommunicatorTest.h"
-#include "CAmDltWrapper.h"
-#include "CAmSocketHandler.h"
-
-#include <unistd.h>
-
-using namespace testing;
-using namespace am;
-
-static CAmEnvironment* env;
-
-
-CAmNodeStateCommunicatorTest::CAmNodeStateCommunicatorTest()
-{
- std::cout<<"Exec path : " << EXECUTABLE_OUTPUT_PATH <<std::endl;
-}
-
-CAmNodeStateCommunicatorTest::~CAmNodeStateCommunicatorTest()
-{
- // TODO Auto-generated destructor stub
-}
-
-/**This is the thread for the nsm python fake
- *
- * @param
- */
-void* nsmThread (void*)
-{
- if(-1 == system("python nsm.py"))
- logError("Something went wrong with nsm.py!");
- return (NULL);
-}
-
-/**this is the thread the mainloop runs in
- *
- * @param importHandler
- */
-void* mainLoop(void* importHandler)
-{
- CAmSocketHandler* handler=static_cast<CAmSocketHandler*>(importHandler);
- handler->start_listenting();
- return (NULL);
-}
-
-
-TEST_F(CAmNodeStateCommunicatorTest, nsmChangeNodeState)
-{
- assert(true == env->pControlInterfaceBackdoor.replaceController(&env->pControlSender,&pMockControlInterface));
- NsmNodeState_e newstate(NsmNodeState_BaseRunning) ;
- EXPECT_CALL(pMockControlInterface,hookSystemNodeStateChanged(newstate));
- std::ostringstream send;
- send<<"python send2nsm.py nodeState "<<static_cast<std::int32_t>(newstate);
- system(send.str().c_str());
-}
-
-TEST_F(CAmNodeStateCommunicatorTest, nsmChangeApplicationMode)
-{
- env->pControlInterfaceBackdoor.replaceController(&env->pControlSender,&pMockControlInterface);
- NsmApplicationMode_e appmode(NsmApplicationMode_Swl) ;
- EXPECT_CALL(pMockControlInterface,hookSystemNodeApplicationModeChanged(appmode));
- std::ostringstream send;
- send<<"python send2nsm.py appMode "<<static_cast<std::int32_t>(appmode);
- system(send.str().c_str());
-}
-
-TEST_F(CAmNodeStateCommunicatorTest, nsmChangeSessionState)
-{
- env->pControlInterfaceBackdoor.replaceController(&env->pControlSender,&pMockControlInterface);
- std::string sessionName("mySession");
- NsmSeat_e seatID(NsmSeat_CoDriver);
- NsmSessionState_e sessionState(NsmSessionState_Inactive) ;
- EXPECT_CALL(pMockControlInterface,hookSystemSessionStateChanged(sessionName,seatID,sessionState));
- std::ostringstream send;
- send<<"python send2nsm.py sessionState "<<sessionName<<" "<<static_cast<std::int32_t>(seatID)<<" "<<static_cast<int32_t>(sessionState);
- system(send.str().c_str());
-}
-
-TEST_F(CAmNodeStateCommunicatorTest, getRestartReason)
-{
- env->pControlInterfaceBackdoor.replaceController(&env->pControlSender,&pMockControlInterface);
- NsmRestartReason_e restartReason;
- ASSERT_EQ(E_OK,env->nsmController.nsmGetRestartReasonProperty(restartReason));
- ASSERT_EQ(restartReason,1);
-}
-
-TEST_F(CAmNodeStateCommunicatorTest, getShutdownReason)
-{
- env->pControlInterfaceBackdoor.replaceController(&env->pControlSender,&pMockControlInterface);
- NsmShutdownReason_e ShutdownReason;
- ASSERT_EQ(E_OK,env->nsmController.nsmGetShutdownReasonProperty(ShutdownReason));
- ASSERT_EQ(ShutdownReason,2);
-}
-
-TEST_F(CAmNodeStateCommunicatorTest, getWakeUpReason)
-{
- env->pControlInterfaceBackdoor.replaceController(&env->pControlSender,&pMockControlInterface);
- NsmRunningReason_e WakeUpReason;
- ASSERT_EQ(E_OK,env->nsmController.nsmGetRunningReasonProperty(WakeUpReason));
- ASSERT_EQ(WakeUpReason,3);
-}
-
-TEST_F(CAmNodeStateCommunicatorTest, getNodeState)
-{
- env->pControlInterfaceBackdoor.replaceController(&env->pControlSender,&pMockControlInterface);
- NsmNodeState_e nodeState;
- ASSERT_EQ(NsmErrorStatus_e::NsmErrorStatus_Ok,env->nsmController.nsmGetNodeState(nodeState));
- ASSERT_EQ(nodeState,1);
-}
-
-TEST_F(CAmNodeStateCommunicatorTest, getApplicationMode)
-{
- env->pControlInterfaceBackdoor.replaceController(&env->pControlSender,&pMockControlInterface);
- NsmApplicationMode_e applicationMode;
- ASSERT_EQ(NsmErrorStatus_e::NsmErrorStatus_Error,env->nsmController.nsmGetApplicationMode(applicationMode));
- ASSERT_EQ(applicationMode,5);
-}
-
-TEST_F(CAmNodeStateCommunicatorTest, getSessionState)
-{
- env->pControlInterfaceBackdoor.replaceController(&env->pControlSender,&pMockControlInterface);
- std::string sessionName("mySession");
- NsmSeat_e seatID(NsmSeat_Driver);
- NsmSessionState_e sessionState;
- ASSERT_EQ(NsmErrorStatus_e::NsmErrorStatus_Ok,env->nsmController.nsmGetSessionState(sessionName,seatID,sessionState));
- ASSERT_EQ(sessionState,5);
-}
-
-TEST_F(CAmNodeStateCommunicatorTest, RegisterShutdownClient)
-{
- env->pControlInterfaceBackdoor.replaceController(&env->pControlSender,&pMockControlInterface);
- uint32_t shutdownmode(1), timeoutMs(100);
- ASSERT_EQ(NsmErrorStatus_e::NsmErrorStatus_Ok,env->nsmController.nsmRegisterShutdownClient(shutdownmode,timeoutMs));
-}
-
-TEST_F(CAmNodeStateCommunicatorTest, receiveLifecycleRequest)
-{
- env->pControlInterfaceBackdoor.replaceController(&env->pControlSender,&pMockControlInterface);
- uint32_t shutdownmode(1);
- uint32_t timeoutMs(100);
- int32_t Request(1);
- int32_t RequestID(4);
- EXPECT_CALL(pMockControlInterface,hookSystemLifecycleRequest(_,RequestID)).WillOnce(Return(NsmErrorStatus_e::NsmErrorStatus_Ok));
- ASSERT_EQ(NsmErrorStatus_e::NsmErrorStatus_Ok,env->nsmController.nsmRegisterShutdownClient(shutdownmode,timeoutMs));
- std::ostringstream send;
- send << "python send2nsm.py LifecycleRequest "<<Request<<" "<<RequestID;
- system(send.str().c_str());
- sleep(2);
-}
-
-TEST_F(CAmNodeStateCommunicatorTest, UnRegisterShutdownClient)
-{
- env->pControlInterfaceBackdoor.replaceController(&env->pControlSender,&pMockControlInterface);
- uint32_t shutdownmode(1),timeoutMs(100);
- ASSERT_EQ(NsmErrorStatus_e::NsmErrorStatus_Ok,env->nsmController.nsmRegisterShutdownClient(shutdownmode,timeoutMs));
- ASSERT_EQ(NsmErrorStatus_e::NsmErrorStatus_Ok,env->nsmController.nsmUnRegisterShutdownClient(shutdownmode));
-
-}
-
-TEST_F(CAmNodeStateCommunicatorTest, sendLifecycleRequestComplete)
-{
- env->pControlInterfaceBackdoor.replaceController(&env->pControlSender,&pMockControlInterface);
- uint32_t RequestID(22);
- NsmErrorStatus_e errorStatus(NsmErrorStatus_Internal);
- ASSERT_EQ(NsmErrorStatus_e::NsmErrorStatus_Ok,env->nsmController.nsmSendLifecycleRequestComplete(RequestID,errorStatus));
-}
-
-TEST_F(CAmNodeStateCommunicatorTest, getInterfaceVersion)
-{
- env->pControlInterfaceBackdoor.replaceController(&env->pControlSender,&pMockControlInterface);
- uint32_t version(0);
- ASSERT_EQ(E_OK,env->nsmController.nsmGetInterfaceVersion(version));
- ASSERT_EQ(version,static_cast<uint32_t>(23));
-}
-
-void CAmNodeStateCommunicatorTest::SetUp()
-{
-}
-
-void CAmNodeStateCommunicatorTest::TearDown()
-{
-}
-
-int main(int argc, char **argv)
-{
- CAmDltWrapper::instance()->registerApp("nsm", "nsmtest");
- logInfo("nsmtest Test started ");
- ::testing::InitGoogleTest(&argc, argv);
- ::testing::Environment* const env = ::testing::AddGlobalTestEnvironment(new CAmEnvironment);
- (void) env;
- return RUN_ALL_TESTS();
-}
-
-CAmEnvironment::CAmEnvironment() :
- pControlInterfaceBackdoor(),
- pControlSender(),
- iSocketHandler(),
- wrapper(CAmCommonAPIWrapper::instantiateOnce(&iSocketHandler)),
- nsmController(wrapper),
- pNsmThread(0),
- pMainLoopThread(0)
-{
- env=this;
-}
-
-CAmEnvironment::~CAmEnvironment()
-{
-}
-
-void CAmEnvironment::waitUntilAvailable(unsigned short seconds = 10)
-{
- int countTries = 0;
- printf("\nWaiting for service");
- while( countTries++<seconds )
- {
- printf(".");
- if(nsmController.isServiceAvailable())
- break;
- else
- sleep(1);
- }
- printf("\n");
-}
-
-void CAmEnvironment::SetUp()
-{
- //create the nsm thread
- pthread_create(&pNsmThread, NULL, nsmThread, NULL);
- nsmController.registerControlSender(&pControlSender);
- //create the mainloop thread
- pthread_create(&pMainLoopThread, NULL, mainLoop, (void*)&iSocketHandler);
- printf("[----------] Waiting for interface to be ready....\r\n");
- waitUntilAvailable(10);
-}
-
-void CAmEnvironment::TearDown()
-{
- //end the nsm per dbus
- system("python send2nsm.py finish");
- pthread_join(pNsmThread, NULL);
- //end the mainloop
- iSocketHandler.exit_mainloop();
- pthread_join(pMainLoopThread, NULL);
-}
diff --git a/AudioManagerDaemon/test/AmNodeStateCommunicatorCAPITest/CAmNodeStateCommunicatorTest.h b/AudioManagerDaemon/test/AmNodeStateCommunicatorCAPITest/CAmNodeStateCommunicatorTest.h
deleted file mode 100644
index b00a27a..0000000
--- a/AudioManagerDaemon/test/AmNodeStateCommunicatorCAPITest/CAmNodeStateCommunicatorTest.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/**
- * SPDX license identifier: MPL-2.0
- *
- * Copyright (C) 2012, BMW AG
- *
- * This file is part of GENIVI Project AudioManager.
- *
- * Contributions are licensed to the GENIVI Alliance under one or more
- * Contribution License Agreements.
- *
- * \copyright
- * This Source Code Form is subject to the terms of the
- * Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with
- * this file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- *
-* \author Aleksandar Donchev, aleksander.donchev@partner.bmw.de BMW 2013
- *
- * \file CAmNodeStateCommunicatorTest.h
- * For further information see http://www.genivi.org/.
- *
- */
-
-
-#ifndef CAMNODESTATECOMMUNICATORTEST_H_
-#define CAMNODESTATECOMMUNICATORTEST_H_
-
-#include "CAmNodeStateCommunicatorCAPI.h"
-#include "CAmControlSender.h"
-#include "gtest/gtest.h"
-#include "gmock/gmock.h"
-#include "../IAmControlBackdoor.h"
-#include "../MockIAmControlSend.h"
-#include "CAmCommonAPIWrapper.h"
-
-using namespace testing;
-using namespace am;
-
-class CAmEnvironment : public ::testing::Environment
-{
-public:
- IAmControlBackdoor pControlInterfaceBackdoor;
- CAmControlSender pControlSender;
- CAmSocketHandler iSocketHandler;
- CAmCommonAPIWrapper *wrapper;
- CAmNodeStateCommunicatorCAPI nsmController;
- pthread_t pNsmThread, pMainLoopThread;
- CAmEnvironment();
- ~CAmEnvironment();
- void SetUp();
- // Override this to define how to tear down the environment.
- void TearDown();
- void waitUntilAvailable(unsigned short seconds);
-};
-
-class CAmNodeStateCommunicatorTest:public ::testing::Test
-{
-public:
- MockIAmControlSend pMockControlInterface;
- CAmNodeStateCommunicatorTest();
- virtual ~CAmNodeStateCommunicatorTest();
- void SetUp();
- void TearDown();
-};
-
-
-#endif /* CAMNODESTATECOMMUNICATORTEST_H_ */
diff --git a/AudioManagerDaemon/test/AmNodeStateCommunicatorCAPITest/CMakeLists.txt b/AudioManagerDaemon/test/AmNodeStateCommunicatorCAPITest/CMakeLists.txt
deleted file mode 100644
index 12032ab..0000000
--- a/AudioManagerDaemon/test/AmNodeStateCommunicatorCAPITest/CMakeLists.txt
+++ /dev/null
@@ -1,113 +0,0 @@
-# Copyright (c) 2012 GENIVI Alliance
-# Copyright (c) 2012 BMW
-#
-# author Aleksandar Donchev, aleksander.donchev@partner.bmw.de BMW 2013
-#
-# copyright
-# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction,
-# including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
-# subject to the following conditions:
-# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
-# THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-#
-# For further information see http://www.genivi.org/.
-#
-
-cmake_minimum_required(VERSION 2.8.8)
-
-project(AmNodeStateCommunicatorCAPITest)
-
-set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -DUNIT_TEST=1")
-
-find_package(Threads)
-find_package(PythonLibs REQUIRED)
-
-set (AM_LINK_LIBS
- ${CMAKE_DL_LIBS}
- rt)
-
-if(WITH_DLT)
- pkg_check_modules(DLT REQUIRED automotive-dlt>=2.2.0)
- set (AM_LINK_LIBS
- ${AM_LINK_LIBS}
- ${DLT_LIBRARIES})
-endif(WITH_DLT)
-
-INCLUDE_DIRECTORIES(
- ${CMAKE_SOURCE_DIR}
- ${CMAKE_CURRENT_BINARY_DIR}
- ${AUDIO_INCLUDE_FOLDER}
- ${PYTHON_INCLUDE_DIRS}
- ${GOOGLE_TEST_INCLUDE_DIR}
- ${GMOCK_INCLUDE_DIR}
- ${COMMONAPI_DBUS_INCLUDE_DIRS}
- ${COMMONAPI_INCLUDE_DIRS}
- ${COMMON_API_GEN_INCLUDE_DIR}
- ${DBUS_INCLUDE_DIRS}
-)
-
-if(WITH_DLT)
-INCLUDE_DIRECTORIES(
- ${INCLUDE_DIRECTORIES}
- ${DLT_INCLUDE_DIRS})
-endif(WITH_DLT)
-
-
-file(GLOB NODESTATECOMMUNICATORCAPI_SRCS_CXX
- "${AUDIOMANAGER_DAEMON_FOLDER}/src/CAmDatabaseHandler.cpp"
- "${AUDIOMANAGER_DAEMON_FOLDER}/src/CAmDatabaseObserver.cpp"
- "${AUDIOMANAGER_DAEMON_FOLDER}/src/CAmRoutingSender.cpp"
- "${AUDIOMANAGER_DAEMON_FOLDER}/src/CAmRoutingReceiver.cpp"
- "${AUDIOMANAGER_DAEMON_FOLDER}/src/CAmNodeStateCommunicatorCAPI.cpp"
- "${AUDIOMANAGER_DAEMON_FOLDER}/src/CAmControlSender.cpp"
- "${AUDIOMANAGER_DAEMON_FOLDER}/src/CAmCommandSender.cpp"
- "${AUDIOMANAGER_DAEMON_FOLDER}/src/CAmCommandReceiver.cpp"
- "${AUDIOMANAGER_DAEMON_FOLDER}/src/CAmRouter.cpp"
- "${AUDIOMANAGER_UTILITIES_SRC}/CAmCommonAPIWrapper.cpp"
- "${AUDIOMANAGER_UTILITIES_SRC}/CAmDltWrapper.cpp"
- "${AUDIOMANAGER_UTILITIES_SRC}/CAmSocketHandler.cpp"
- "../CAmCommonFunctions.cpp"
- "*.cpp")
-
-ADD_EXECUTABLE(AmNodeStateCommunicatorCAPITest ${NODESTATECOMMUNICATORCAPI_SRCS_CXX} ${COMMON_API_GEN_SOURCES})
-
-TARGET_LINK_LIBRARIES(AmNodeStateCommunicatorCAPITest
- ${AM_LINK_LIBS}
- ${CMAKE_THREAD_LIBS_INIT}
- ${PYTHON_LIBRARY}
- ${CommonAPI-DBus_LIBRARY}
- ${CommonAPI_LIBRARY}
- ${DBUS_LIBRARIES}
- gtest
- gmock
-)
-
-ADD_DEPENDENCIES(AmNodeStateCommunicatorCAPITest gtest gmock)
-
-INSTALL(TARGETS AmNodeStateCommunicatorCAPITest
- DESTINATION ${TEST_EXECUTABLE_INSTALL_PATH}
- PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_EXECUTE WORLD_READ
- COMPONENT tests
-)
-
-INSTALL(FILES
- ${CMAKE_CURRENT_SOURCE_DIR}/org.genivi.NodeStateManager.Consumer.xml
- ${CMAKE_CURRENT_SOURCE_DIR}/nsm.py
- ${CMAKE_CURRENT_SOURCE_DIR}/send2nsm.py
- DESTINATION ${TEST_EXECUTABLE_INSTALL_PATH}
- PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_EXECUTE WORLD_READ
- COMPONENT tests
-)
-
-if(USE_BUILD_LIBS)
- execute_process(
- COMMAND mkdir -p ${EXECUTABLE_OUTPUT_PATH}
- COMMAND cp "${CMAKE_CURRENT_SOURCE_DIR}/org.genivi.NodeStateManager.Consumer.xml" ${EXECUTABLE_OUTPUT_PATH}/org.genivi.NodeStateManager.Consumer.xml
- COMMAND cp "${CMAKE_CURRENT_SOURCE_DIR}/nsm.py" ${EXECUTABLE_OUTPUT_PATH}/nsm.py
- COMMAND cp "${CMAKE_CURRENT_SOURCE_DIR}/send2nsm.py" ${EXECUTABLE_OUTPUT_PATH}/send2nsm.py
-# COMMAND cp "${AUDIOMANAGER_DAEMON_FOLDER}/fidls/NodeStateManager_dbus.conf" ${EXECUTABLE_OUTPUT_PATH}/AmNodeStateCommunicatorCAPITest_dbus.conf
- )
-endif(USE_BUILD_LIBS)
-
diff --git a/AudioManagerDaemon/test/AmNodeStateCommunicatorCAPITest/nsm.py b/AudioManagerDaemon/test/AmNodeStateCommunicatorCAPITest/nsm.py
deleted file mode 100644
index c648484..0000000
--- a/AudioManagerDaemon/test/AmNodeStateCommunicatorCAPITest/nsm.py
+++ /dev/null
@@ -1,179 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2012, BMW AG
-#
-# This file is part of GENIVI Project AudioManager.
-#
-# Contributions are licensed to the GENIVI Alliance under one or more
-# Contribution License Agreements.
-#
-# \copyright
-# This Source Code Form is subject to the terms of the
-# Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with
-# this file, You can obtain one at http://mozilla.org/MPL/2.0/.
-#
-#
-# \author Christian Linke, christian.linke@bmw.de BMW 2012
-#
-# For further information see http://www.genivi.org/.
-#
-
-import sys
-import traceback
-import gobject
-import math
-import dbus
-import dbus.service
-import dbus.mainloop.glib
-
-loop = gobject.MainLoop()
-dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
-
-class NodeStateManager(dbus.service.Object):
- def __init__(self, loop):
- busName = dbus.service.BusName('org.genivi.NodeStateManager.Consumer_org.genivi.NodeStateManager', bus = dbus.SessionBus())
- dbus.service.Object.__init__(self, busName, '/org/genivi/NodeStateManager')
- self.properties = {'RestartReason': 1, 'ShutdownReason': 2, 'WakeUpReason' :3, 'BootMode' :4}
- self.ABus=""
- self.APath=""
- self.loop=loop
-
- @dbus.service.method(dbus_interface='org.freedesktop.DBus.Introspectable', out_signature = 's')
- def Introspect(self):
- f = open('org.genivi.NodeStateManager.Consumer.xml', "r")
- text = f.read()
- return text
-
- @dbus.service.method(dbus_interface='org.genivi.NodeStateManager.Consumer', out_signature = 'ii')
- def GetNodeState(self):
- NodeStateId=1
- ErrorCode=1
- print('[-----nsm-----] send out nodeState' + str(NodeStateId) + ' ErrorCode '+ str(1))
- return NodeStateId, ErrorCode
-
- @dbus.service.method('org.genivi.NodeStateManager.Consumer', out_signature = 'ii')
- def GetApplicationMode(self):
- ApplicationModeId=5
- ErrorCode=2
- print('[-----nsm-----] send out ApplicationMode' + str(ApplicationModeId) + ' ErrorCode '+ str(2))
- return ApplicationModeId, ErrorCode
-
- @dbus.service.method('org.genivi.NodeStateManager.Consumer', in_signature='si', out_signature = 'ii')
- def GetSessionState(self,SessionName,seatID):
- SessionState=0
- ErrorCode=2
-
- if SessionName=="mySession" and seatID==1:
- SessionState=5
- ErrorCode=1
-
- print('[-----nsm-----] GetSessionState for session ' + SessionName + ' seatID '+ str(seatID) + ' returnState ' + str (SessionState))
- return SessionState, ErrorCode
-
- @dbus.service.method('org.genivi.NodeStateManager.Consumer', in_signature='ssuu', out_signature = 'i')
- def RegisterShutdownClient(self,BName,ObjName,ShutdownMode,TimeoutMs):
- print('[-----nsm-----] Busname: ' + BName)
- print('[-----nsm-----] ObjName: ' + ObjName)
- print('[-----nsm-----] ShutdownMode: ' + str(ShutdownMode))
- print('[-----nsm-----] TimeoutMs: ' + str(TimeoutMs))
- ErrorCode=1
- if TimeoutMs!=100:
- ErrorCode=3
- if BName!="org.genivi.NodeStateManager.LifeCycleConsumer_org.genivi.audiomanager":
- ErrorCode=4
- if ShutdownMode!=1:
- ErrorCode=5
- if ObjName!="/org/genivi/audiomanager":
- ErrorCode=6
- self.ABus=BName
- self.APath=ObjName
- return ErrorCode
-
- @dbus.service.method('org.genivi.NodeStateManager.Consumer', in_signature='ssu', out_signature = 'i')
- def UnRegisterShutdownClient(self,BusName,ObjName,ShutdownMode):
- print('[-----nsm-----] Busname: ' + str(BusName))
- print('[-----nsm-----] ObjName: ' + str(ObjName))
- print('[-----nsm-----] ShutdownMode: ' + str(ShutdownMode))
- ErrorCode=1
- if BusName!=self.ABus:
- ErrorCode=2
- if ObjName!=self.APath:
- ErrorCode=2
- if ShutdownMode!=1:
- ErrorCode=2
- return ErrorCode
-
- @dbus.service.method(dbus_interface='org.genivi.NodeStateManager.Consumer', out_signature = 'u')
- def GetInterfaceVersion(self):
- version=23
- return version
-
- @dbus.service.method('org.genivi.NodeStateManager.Consumer', in_signature='ui', out_signature='i')
- def LifecycleRequestComplete(self,RequestID,Status):
- print('[-----nsm-----] RequestId: ' + str(RequestID))
- print('[-----nsm-----] Status: ' + str(Status))
- ErrorCode=1
- if RequestID!=22:
- ErrorCode=2
- if Status!=4:
- ErrorCode=2
- return ErrorCode
-
- @dbus.service.method(dbus.PROPERTIES_IFACE, in_signature='ss', out_signature='v')
- def Get(self, interface, prop):
- if prop in self.properties:
- print('[-----nsm-----] send out ' + str(self.properties[prop]) + ' for property '+ prop)
- return self.properties[prop]
- return 0
-
- @dbus.service.method(dbus.PROPERTIES_IFACE, in_signature='ssv')
- def Set(self, interface, prop, value):
- return 3
-
- @dbus.service.method(dbus.PROPERTIES_IFACE, in_signature='s', out_signature='a{sv}')
- def GetAll(self, interface):
- return self.properties
-
- @dbus.service.signal(dbus_interface='org.genivi.NodeStateManager.Consumer', signature='i')
- def NodeApplicationMode(self, ApplicationModeId):
- print "[-----nsm-----] Send out application mode ID %d" % (ApplicationModeId)
-
- @dbus.service.signal(dbus_interface='org.genivi.NodeStateManager.Consumer', signature='i')
- def NodeState(self, NodeState):
- print "[-----nsm-----] Send out NodeState %d" % (NodeState)
-
- @dbus.service.signal(dbus_interface='org.genivi.NodeStateManager.Consumer', signature='sii')
- def SessionStateChanged(self, SessionStateName,SeatID,SessionState):
- print "[-----nsm-----] Send out SessionStateChanged " + SessionStateName
-
- @dbus.service.method('org.genivi.NodeStateManager.Control', in_signature='i')
- def sendNodeApplicationMode(self, input):
- self.NodeApplicationMode(input)
- return input
-
- @dbus.service.method('org.genivi.NodeStateManager.Control', in_signature='i')
- def sendNodeState(self, input):
- self.NodeState(input)
- return input
-
- @dbus.service.method('org.genivi.NodeStateManager.Control', in_signature='sii')
- def sendSessionState(self, SessionStateName,SeatID,SessionState):
- self.SessionStateChanged (SessionStateName,SeatID,SessionState)
- return SeatID
-
- @dbus.service.method('org.genivi.NodeStateManager.Control', in_signature='uu', out_signature='i')
- def sendLifeCycleRequest(self, request, requestID):
- bus = dbus.SessionBus()
- remote_object = bus.get_object(self.ABus,self.APath)
- iface = dbus.Interface(remote_object, 'org.genivi.NodeStateManager.LifeCycleConsumer')
- iface.LifecycleRequest(request,requestID)
- return 42
-
- @dbus.service.method('org.genivi.NodeStateManager.Control')
- def finish(self):
- print '[-----nsm-----] Going to exit now!'
- self.loop.quit()
- return 0
-
-nsm = NodeStateManager(loop)
-loop.run()
diff --git a/AudioManagerDaemon/test/AmNodeStateCommunicatorCAPITest/org.genivi.NodeStateManager.Consumer.xml b/AudioManagerDaemon/test/AmNodeStateCommunicatorCAPITest/org.genivi.NodeStateManager.Consumer.xml
deleted file mode 100644
index bb40a96..0000000
--- a/AudioManagerDaemon/test/AmNodeStateCommunicatorCAPITest/org.genivi.NodeStateManager.Consumer.xml
+++ /dev/null
@@ -1,259 +0,0 @@
-<!-- Auto-Generated interface from Rhapsody: 'Repository::ssw_LifecycleSupport::NodeStateManagement::Concept::Interface::INSM_Consumer' -->
-<!-- Created at 2012-06-01 09:36:05 by uid65904 -->
-<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
- "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
-<node>
-<interface name="org.freedesktop.DBus.Introspectable">
- <method name="Introspect">
- <arg name="data" direction="out" type="s"/>
- </method>
-</interface>
-<interface name="org.freedesktop.DBus.Properties">
- <method name="Get">
- <arg name="interface" direction="in" type="s"/>
- <arg name="propname" direction="in" type="s"/>
- <arg name="value" direction="out" type="v"/>
- </method>
-
- <method name="Set">
- <arg name="interface" direction="in" type="s"/>
- <arg name="propname" direction="in" type="s"/>
- <arg name="value" direction="in" type="v"/>
- </method>
-
- <method name="GetAll">
- <arg name="interface" direction="in" type="s"/>
- <arg name="props" direction="out" type="a{sv}"/>
- </method>
-</interface>
- <!--
- org.genivi.NodeStateManager.Consumer:
- @short_description: "Consumer" interface of the NodeStateManager.
-
- This interface contains functions which are not safety critical and can be accessed by "every" client without further restrictions.
- -->
- <interface name="org.genivi.NodeStateManager.Consumer">
- <!--
- RestartReason: This property informs clients about the reason for the last restart. The values are based upon the enummeration NsmRestartReason_e. Note: The value is only set once at start-up.
- -->
- <property name="RestartReason" type="i" access="read"/>
-
- <!--
- ShutdownReason: This property informs clients about the reason for the last shutdown. The values are based upon the enummeration NsmShutdownReason_e. Note: The value is only set once at start-up.
- -->
- <property name="ShutdownReason" type="i" access="read"/>
-
- <!--
- WakeUpReason: This property informs clients about the recent reason for waking up the target. The values are based upon the enummeration NsmWakeUpReason_e. Note: The value is only set once at start-up.
- -->
- <property name="WakeUpReason" type="i" access="read"/>
-
- <!--
- BootMode: This property informs clients about the recent BootMode of the target. The values will be defined by a third party header, which has not been delivered yet. The description needs to be updated as soon as the header is available.
- -->
- <property name="BootMode" type="i" access="read"/>
-
- <!--
- NodeState:
- @NodeState: Numeric value for the current NodeState, defined in NsmNodeState_e.
-
- Clients can register for notifications when the NodeState is updated inside the NodeStateManager. This signal is sent to registered clients and will include the current NodeState as a parameter.
- -->
- <signal name="NodeState">
- <arg name="NodeState" type="i"/>
- </signal>
-
- <!--
- NodeApplicationMode:
- @ApplicationModeId: Numeric value for the current ApplicationMode, defined in NsmAplicationMode_e.
-
- Clients can register for notifications when the NodeApplicationMode is updated inside the NodeStateManager. This signal is sent to registered clients and will include the current NodeApplicationMode as a parameter.
- -->
- <signal name="NodeApplicationMode">
- <arg name="ApplicationModeId" type="i"/>
- </signal>
-
- <!--
- SessionStateChanged:
- @SessionStateName: The SessionName will be based upon either the pre-defined platform SessionNames or using a newly added product defined session name.
- @SeatID: This parameter will be based upon the enum NsmSeat_e.
- @SessionState: This parameter will be based upon the NsmSessionState_e but it will not be bounded by the values in that enumeration. The listed values are the default values that are mandatory for platform sessions, but product sessions may have additional session states.
-
- This signal is sent to registered clients when a particular session is state is changed. The client can register for notification about a specific session through the use of the SessionName, as a "match rule".
- -->
- <signal name="SessionStateChanged">
- <arg name="SessionStateName" type="s"/>
- <arg name="SeatID" type="i"/>
- <arg name="SessionState" type="i"/>
- </signal>
-
- <!--
- GetNodeState:
- @NodeStateId: Will be based on the NsmNodeState_e.
- @ErrorCode: Return value passed to the caller, based upon NsmErrorStatus_e.
-
- The method is used by other applications to get the NodeState without the need of registration to the signal.
- -->
- <method name="GetNodeState">
- <arg name="NodeStateId" direction="out" type="i"/>
- <arg name="ErrorCode" direction="out" type="i"/>
- </method>
-
- <!--
- SetSessionState:
- @SessionName: The SessionName will be based upon either the pre-defined platform SessionNames (see NSM content page) or using a newly added product defined session name.
- @SessionOwner: This parameter defines the name of the application that is setting the state of the session. This must be the applications systemd unit filename.
- @SeatID: This parameter will be based upon the enum NsmSeat_e
- @SessionState: This parameter will be based upon the NsmSessionState_e but it will not be bounded by the values in that enumeration. The listed values are the default values that are mandatory for platform sessions, but product sessions may have additional SessionStates.
- @ErrorCode: Return value passed to the caller, based upon NsmErrorStatus_e.
-
- The method is used by applications to set the state of a session.
- -->
- <method name="SetSessionState">
- <arg name="SessionName" direction="in" type="s"/>
- <arg name="SessionOwner" direction="in" type="s"/>
- <arg name="SeatID" direction="in" type="i"/>
- <arg name="SessionState" direction="in" type="i"/>
- <arg name="ErrorCode" direction="out" type="i"/>
- </method>
-
- <!--
- GetSessionState:
- @SessionName: The SessionName will be based upon either the pre-defined platform session names (see NSM content page) or using a newly added product defined SessionName.
- @SeatID: This parameter will be based upon the enum NsmSeat_e.
- @SessionState: This parameter will be based upon the NsmSessionState_e but it will not be bounded by the values in that enumeration. The listed values are the default values that are mandatory for platform sessions, but product sessions may have additional SessionStates.
- @ErrorCode: Return value passed to the caller, based upon NsmErrorStatus_e.
-
- The method is used by applications to get the state of a session.
- -->
- <method name="GetSessionState">
- <arg name="SessionName" direction="in" type="s"/>
- <arg name="SeatID" direction="in" type="i"/>
- <arg name="SessionState" direction="out" type="i"/>
- <arg name="ErrorCode" direction="out" type="i"/>
- </method>
-
- <!--
- GetApplicationMode:
- @ApplicationModeId: This parameter will be based upon the NsmNodeApplicationMode_e.
- @ErrorCode: Return value passed to the caller, based upon NsmErrorStatus_e.
-
- The method is used by other applications to get the application mode.
- -->
- <method name="GetApplicationMode">
- <arg name="ApplicationModeId" direction="out" type="i"/>
- <arg name="ErrorCode" direction="out" type="i"/>
- </method>
-
- <!--
- RegisterShutdownClient:
- @BusName: Bus name of remote application.
- @ObjName: Object name of remote object that provides the shutdown interface.
- @ShutdownMode: Shutdown mode for which client wants to be informed (i.e normal, fast etc).
- @TimeoutMs: Max. Timeout to wait for response from shutdown client in ms.
- @ErrorCode: Return value passed to the caller, based upon NsmErrorStatus_e.
-
- The method is used by other applications to register themselves as shutdown client. Any client that registers must provide a method in their D-Bus object called "LifecycleRequest". This method will take one parameter which is the RequestType (NSM_SHUTDOWNTYPE_NORMAL, NSM_SHUTDOWNTYPE_FAST). For an example of the required client interface please see the BootManager component who will be a client of the NSM.
- -->
- <method name="RegisterShutdownClient">
- <arg name="BusName" direction="in" type="s"/>
- <arg name="ObjName" direction="in" type="s"/>
- <arg name="ShutdownMode" direction="in" type="u"/>
- <arg name="TimeoutMs" direction="in" type="u"/>
- <arg name="ErrorCode" direction="out" type="i"/>
- </method>
-
- <!--
- UnRegisterShutdownClient:
- @BusName: Bus name of remote application.
- @ObjName: Object name of remote object that provides the shutdown interface.
- @ShutdownMode: Shutdown mode for which client wants to unregister (NSM_SHUTDOWNTYPE_NORMAL, NSM_SHUTDOWNTYPE_FAST).
- @ErrorCode: Return value passed to the caller, based upon NsmErrorStatus_e.
-
- The method is used by other applications to unregister themselves as shutdown client.
- -->
- <method name="UnRegisterShutdownClient">
- <arg name="BusName" direction="in" type="s"/>
- <arg name="ObjName" direction="in" type="s"/>
- <arg name="ShutdownMode" direction="in" type="u"/>
- <arg name="ErrorCode" direction="out" type="i"/>
- </method>
-
- <!--
- RegisterSession:
- @SessionName: The SessionName will be based upon either the pre-defined platform session names (see NSM content page) or using a newly added product defined SessionName.
- @SessionOwner: This is the name of the application that is registering the new session (this must be the applications systemd unit filename).
- @SeatID: This parameter will be based upon the enum NsmSeatId_e
- @SessionState: This parameter will be based upon the NsmSessionState_e but it will not be bounded by the values in that enumeration. The listed values are the default values that are mandatory for platform sessions, but product sessions may have additional session states.
- @ErrorCode: Return value passed to the caller, based upon NsmErrorStatus_e.
-
- The method is used by other applications to register a new session whose state should be observed and distributed by the NSM.
- -->
- <method name="RegisterSession">
- <arg name="SessionName" direction="in" type="s"/>
- <arg name="SessionOwner" direction="in" type="s"/>
- <arg name="SeatID" direction="in" type="i"/>
- <arg name="SessionState" direction="in" type="i"/>
- <arg name="ErrorCode" direction="out" type="i"/>
- </method>
-
- <!--
- UnRegisterSession:
- @SessionName: The SessionName will be based upon either the pre-defined platform session names (see NSM content page) or using a newly added product defined SessionName.
- @SessionOwner: This is the name of the application that originally registered the session. It will be validated that this value matches the stored value from the registration.
- @SeatID: This parameter will be based upon the enum NsmSeat_e.
- @ErrorCode: Return value passed to the caller, based upon NsmErrorStatus_e.
-
- The method is used by other applications to remove a new session from the session list hosted by NSM.
- -->
- <method name="UnRegisterSession">
- <arg name="SessionName" direction="in" type="s"/>
- <arg name="SessionOwner" direction="in" type="s"/>
- <arg name="SeatID" direction="in" type="i"/>
- <arg name="ErrorCode" direction="out" type="i"/>
- </method>
-
- <!--
- GetAppHealthCount:
- @Count: Return value passed to the caller. Number of applications that crashed or terminated accidentally.
-
- The method returns the number of applications that crashed or terminated accidentally, within the current life cycle. It can be used to observe the system state.
- -->
- <method name="GetAppHealthCount">
- <arg name="Count" direction="out" type="u"/>
- </method>
-
- <!--
- GetInterfaceVersion:
- @Version: Unsigned integer that represents the version number of the Node State Manager.
-
- The method returns the version number of the Node State Manager. The number is organized in four bytes:
-
- Version: VVV.RRR.PPP.BBB
-
- <literallayout>
- VVV => Version [1..255]
- RRR => Release [0..255]
- PPP => Patch [0..255]
- BBB => Build [0..255]
- </literallayout>
- -->
- <method name="GetInterfaceVersion">
- <arg name="Version" direction="out" type="u"/>
- </method>
-
- <!--
- LifecycleRequestComplete:
- @RequestId: The request Id of the called life cycle client. The value has been passed when "LifecycleRequest" was called.
- @Status: The result of the call to "LifecycleRequest". NsmErrorStatus_Ok: Request successfully processed. NsmErrorStatus_Error: An error occured while processing the "LifecycleRequest".
- @ErrorCode: Return value passed to the caller, based upon NsmErrorStatus_e.
-
- The function has to be called by a "asynchrounous" lifecycle client, when he processed the "LifecycleRequest".
- -->
- <method name="LifecycleRequestComplete">
- <arg name="RequestId" direction="in" type="u"/>
- <arg name="Status" direction="in" type="i"/>
- <arg name="ErrorCode" direction="out" type="i"/>
- </method>
- </interface>
-</node>
diff --git a/AudioManagerDaemon/test/AmNodeStateCommunicatorCAPITest/send2nsm.py b/AudioManagerDaemon/test/AmNodeStateCommunicatorCAPITest/send2nsm.py
deleted file mode 100644
index 5ed6c0c..0000000
--- a/AudioManagerDaemon/test/AmNodeStateCommunicatorCAPITest/send2nsm.py
+++ /dev/null
@@ -1,68 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2012, BMW AG
-#
-# This file is part of GENIVI Project AudioManager.
-#
-# Contributions are licensed to the GENIVI Alliance under one or more
-# Contribution License Agreements.
-#
-# \copyright
-# This Source Code Form is subject to the terms of the
-# Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with
-# this file, You can obtain one at http://mozilla.org/MPL/2.0/.
-#
-#
-# \author Christian Linke, christian.linke@bmw.de BMW 2012
-#
-# For further information see http://www.genivi.org/.
-#
-
-import sys
-import traceback
-import gobject
-import math
-import dbus
-import dbus.service
-
-def nodeState (nodeState):
- bus = dbus.SessionBus()
- remote_object = bus.get_object('org.genivi.NodeStateManager.Consumer_org.genivi.NodeStateManager','/org/genivi/NodeStateManager')
- iface = dbus.Interface(remote_object, 'org.genivi.NodeStateManager.Control')
- iface.sendNodeState(int(nodeState))
-
-def appMode (appMode):
- bus = dbus.SessionBus()
- remote_object = bus.get_object('org.genivi.NodeStateManager.Consumer_org.genivi.NodeStateManager','/org/genivi/NodeStateManager')
- iface = dbus.Interface(remote_object, 'org.genivi.NodeStateManager.Control')
- iface.sendNodeApplicationMode(int(appMode))
-
-def sessionState (SessionStateName,SeatID,SessionState):
- bus = dbus.SessionBus()
- remote_object = bus.get_object('org.genivi.NodeStateManager.Consumer_org.genivi.NodeStateManager','/org/genivi/NodeStateManager')
- iface = dbus.Interface(remote_object, 'org.genivi.NodeStateManager.Control')
- iface.sendSessionState(SessionStateName,int(SeatID),int(SessionState))
-
-def finish():
- bus = dbus.SessionBus()
- remote_object = bus.get_object('org.genivi.NodeStateManager.Consumer_org.genivi.NodeStateManager','/org/genivi/NodeStateManager')
- iface = dbus.Interface(remote_object, 'org.genivi.NodeStateManager.Control')
- iface.finish()
-
-def LifecycleRequest(Request,RequestID):
- bus = dbus.SessionBus()
- remote_object = bus.get_object('org.genivi.NodeStateManager.Consumer_org.genivi.NodeStateManager','/org/genivi/NodeStateManager')
- iface = dbus.Interface(remote_object, 'org.genivi.NodeStateManager.Control')
- iface.sendLifeCycleRequest(dbus.UInt32(Request),dbus.UInt32(RequestID))
-
-command=sys.argv[1]
-if command=="nodeState":
- nodeState(sys.argv[2])
-if command=="finish":
- finish()
-if command=="appMode":
- appMode(sys.argv[2])
-if command=="sessionState":
- sessionState(sys.argv[2],sys.argv[3],sys.argv[4])
-if command=="LifecycleRequest":
- LifecycleRequest(sys.argv[2],sys.argv[3])
diff --git a/AudioManagerDaemon/test/AmNodeStateCommunicatorDBusTest/CAmNodeStateCommunicatorTest.cpp b/AudioManagerDaemon/test/AmNodeStateCommunicatorDBusTest/CAmNodeStateCommunicatorTest.cpp
deleted file mode 100644
index 6acce61..0000000
--- a/AudioManagerDaemon/test/AmNodeStateCommunicatorDBusTest/CAmNodeStateCommunicatorTest.cpp
+++ /dev/null
@@ -1,250 +0,0 @@
-/**
- * SPDX license identifier: MPL-2.0
- *
- * Copyright (C) 2012, BMW AG
- *
- * This file is part of GENIVI Project AudioManager.
- *
- * Contributions are licensed to the GENIVI Alliance under one or more
- * Contribution License Agreements.
- *
- * \copyright
- * This Source Code Form is subject to the terms of the
- * Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with
- * this file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- *
- * \author Christian Linke, christian.linke@bmw.de BMW 2012
- *
- * \file CAmNodeStateCommunicatorTest.cpp
- * For further information see http://www.genivi.org/.
- *
- */
-
-#include "CAmNodeStateCommunicatorTest.h"
-#include "CAmDltWrapper.h"
-#include "CAmSocketHandler.h"
-#include "CAmDbusWrapper.h"
-
-#include <unistd.h>
-
-using namespace testing;
-using namespace am;
-
-static CAmEnvironment* env;
-
-
-
-CAmNodeStateCommunicatorTest::CAmNodeStateCommunicatorTest()
-{
-
-}
-
-CAmNodeStateCommunicatorTest::~CAmNodeStateCommunicatorTest()
-{
- // TODO Auto-generated destructor stub
-}
-
-/**This is the thread for the nsm python fake
- *
- * @param
- */
-void* nsmThread (void*)
-{
- system("python nsm.py");
- return (NULL);
-}
-
-/**this is the thread the mainloop runs in
- *
- * @param importHandler
- */
-void* mainLoop(void* importHandler)
-{
- CAmSocketHandler* handler=static_cast<CAmSocketHandler*>(importHandler);
- handler->start_listenting();
- return (NULL);
-}
-
-
-
-TEST_F(CAmNodeStateCommunicatorTest, nsmChangeNodeState)
-{
- assert(true == env->pControlInterfaceBackdoor.replaceController(&env->pControlSender,&pMockControlInterface));
- NsmNodeState_e newstate(NsmNodeState_BaseRunning) ;
- EXPECT_CALL(pMockControlInterface,hookSystemNodeStateChanged(newstate));
- std::ostringstream send;
- send<<"python send2nsm.py nodeState "<<static_cast<std::int32_t>(newstate);
- system(send.str().c_str());
-}
-
-TEST_F(CAmNodeStateCommunicatorTest, nsmChangeApplicationMode)
-{
- env->pControlInterfaceBackdoor.replaceController(&env->pControlSender,&pMockControlInterface);
- NsmApplicationMode_e appmode(NsmApplicationMode_Swl) ;
- EXPECT_CALL(pMockControlInterface,hookSystemNodeApplicationModeChanged(appmode));
- std::ostringstream send;
- send<<"python send2nsm.py appMode "<<static_cast<std::int32_t>(appmode);
- system(send.str().c_str());
-}
-
-TEST_F(CAmNodeStateCommunicatorTest, nsmChangeSessionState)
-{
- env->pControlInterfaceBackdoor.replaceController(&env->pControlSender,&pMockControlInterface);
- std::string sessionName("mySession");
- NsmSeat_e seatID(NsmSeat_CoDriver);
- NsmSessionState_e sessionState(NsmSessionState_Inactive) ;
- EXPECT_CALL(pMockControlInterface,hookSystemSessionStateChanged(sessionName,seatID,sessionState));
- std::ostringstream send;
- send<<"python send2nsm.py sessionState "<<sessionName<<" "<<static_cast<std::int32_t>(seatID)<<" "<<static_cast<int32_t>(sessionState);
- system(send.str().c_str());
-}
-
-TEST_F(CAmNodeStateCommunicatorTest, getRestartReason)
-{
- env->pControlInterfaceBackdoor.replaceController(&env->pControlSender,&pMockControlInterface);
- NsmRestartReason_e restartReason;
- ASSERT_EQ(E_OK,env->nsmController.nsmGetRestartReasonProperty(restartReason));
- ASSERT_EQ(restartReason,1);
-}
-
-TEST_F(CAmNodeStateCommunicatorTest, getShutdownReason)
-{
- env->pControlInterfaceBackdoor.replaceController(&env->pControlSender,&pMockControlInterface);
- NsmShutdownReason_e ShutdownReason;
- ASSERT_EQ(E_OK,env->nsmController.nsmGetShutdownReasonProperty(ShutdownReason));
- ASSERT_EQ(ShutdownReason,2);
-}
-
-TEST_F(CAmNodeStateCommunicatorTest, getWakeUpReason)
-{
- env->pControlInterfaceBackdoor.replaceController(&env->pControlSender,&pMockControlInterface);
- NsmRunningReason_e WakeUpReason;
- ASSERT_EQ(E_OK,env->nsmController.nsmGetRunningReasonProperty(WakeUpReason));
- ASSERT_EQ(WakeUpReason,3);
-}
-
-TEST_F(CAmNodeStateCommunicatorTest, getNodeState)
-{
- env->pControlInterfaceBackdoor.replaceController(&env->pControlSender,&pMockControlInterface);
- NsmNodeState_e nodeState;
- ASSERT_EQ(NsmErrorStatus_e::NsmErrorStatus_Ok,env->nsmController.nsmGetNodeState(nodeState));
- ASSERT_EQ(nodeState,1);
-}
-
-TEST_F(CAmNodeStateCommunicatorTest, getApplicationMode)
-{
- env->pControlInterfaceBackdoor.replaceController(&env->pControlSender,&pMockControlInterface);
- NsmApplicationMode_e applicationMode;
- ASSERT_EQ(NsmErrorStatus_e::NsmErrorStatus_Error,env->nsmController.nsmGetApplicationMode(applicationMode));
- ASSERT_EQ(applicationMode,5);
-}
-
-TEST_F(CAmNodeStateCommunicatorTest, getSessionState)
-{
- env->pControlInterfaceBackdoor.replaceController(&env->pControlSender,&pMockControlInterface);
- std::string sessionName("mySession");
- NsmSeat_e seatID(NsmSeat_Driver);
- NsmSessionState_e sessionState;
- ASSERT_EQ(NsmErrorStatus_e::NsmErrorStatus_Ok,env->nsmController.nsmGetSessionState(sessionName,seatID,sessionState));
- ASSERT_EQ(sessionState,5);
-}
-
-TEST_F(CAmNodeStateCommunicatorTest, RegisterShutdownClient)
-{
- env->pControlInterfaceBackdoor.replaceController(&env->pControlSender,&pMockControlInterface);
- uint32_t shutdownmode(1), timeoutMs(100);
- ASSERT_EQ(NsmErrorStatus_e::NsmErrorStatus_Ok,env->nsmController.nsmRegisterShutdownClient(shutdownmode,timeoutMs));
-}
-
-TEST_F(CAmNodeStateCommunicatorTest, receiveLifecycleRequest)
-{
- env->pControlInterfaceBackdoor.replaceController(&env->pControlSender,&pMockControlInterface);
- uint32_t shutdownmode(1);
- uint32_t timeoutMs(100);
- int32_t Request(1);
- int32_t RequestID(4);
- EXPECT_CALL(pMockControlInterface,hookSystemLifecycleRequest(_,RequestID)).WillOnce(Return(NsmErrorStatus_e::NsmErrorStatus_Ok));
- ASSERT_EQ(NsmErrorStatus_e::NsmErrorStatus_Ok,env->nsmController.nsmRegisterShutdownClient(shutdownmode,timeoutMs));
- std::ostringstream send;
- send << "python send2nsm.py LifecycleRequest "<<Request<<" "<<RequestID;
- system(send.str().c_str());
-}
-
-TEST_F(CAmNodeStateCommunicatorTest, UnRegisterShutdownClient)
-{
- env->pControlInterfaceBackdoor.replaceController(&env->pControlSender,&pMockControlInterface);
- uint32_t shutdownmode(1),timeoutMs(100);
- ASSERT_EQ(NsmErrorStatus_e::NsmErrorStatus_Ok,env->nsmController.nsmRegisterShutdownClient(shutdownmode,timeoutMs));
- ASSERT_EQ(NsmErrorStatus_e::NsmErrorStatus_Ok,env->nsmController.nsmUnRegisterShutdownClient(shutdownmode));
-
-}
-
-TEST_F(CAmNodeStateCommunicatorTest, sendLifecycleRequestComplete)
-{
- env->pControlInterfaceBackdoor.replaceController(&env->pControlSender,&pMockControlInterface);
- uint32_t RequestID(22);
- NsmErrorStatus_e errorStatus(NsmErrorStatus_Internal);
- ASSERT_EQ(NsmErrorStatus_e::NsmErrorStatus_Ok,env->nsmController.nsmSendLifecycleRequestComplete(RequestID,errorStatus));
-}
-
-TEST_F(CAmNodeStateCommunicatorTest, getInterfaceVersion)
-{
- env->pControlInterfaceBackdoor.replaceController(&env->pControlSender,&pMockControlInterface);
- uint32_t version(0);
- ASSERT_EQ(E_OK,env->nsmController.nsmGetInterfaceVersion(version));
- ASSERT_EQ(version,static_cast<uint32_t>(23));
-}
-
-void CAmNodeStateCommunicatorTest::SetUp()
-{
-}
-
-void CAmNodeStateCommunicatorTest::TearDown()
-{
-}
-
-int main(int argc, char **argv)
-{
- CAmDltWrapper::instance()->registerApp("nsm", "nsmtest");
- logInfo("nsmtest Test started ");
- ::testing::InitGoogleTest(&argc, argv);
- ::testing::Environment* const env = ::testing::AddGlobalTestEnvironment(new CAmEnvironment);
- (void) env;
- return RUN_ALL_TESTS();
-}
-
-CAmEnvironment::CAmEnvironment() :
- pControlInterfaceBackdoor(),
- pControlSender(),
- iSocketHandler(),
- wrapper(&iSocketHandler,DBusBusType::DBUS_BUS_SESSION),
- nsmController(&wrapper)
-{
- env=this;
-}
-
-CAmEnvironment::~CAmEnvironment()
-{
-}
-
-void CAmEnvironment::SetUp()
-{
- //create the nsm thread
- pthread_create(&pNsmThread, NULL, nsmThread, NULL);
- nsmController.registerControlSender(&pControlSender);
- //create the mainloop thread
- pthread_create(&pMainLoopThread, NULL, mainLoop, (void*)&iSocketHandler);
- printf("[----------] Waiting for interface to be ready....\r\n");
- sleep(2);
-}
-
-void CAmEnvironment::TearDown()
-{
- //end the nsm per dbus
- system("python send2nsm.py finish");
- pthread_join(pNsmThread, NULL);
- //end the mainloop
- iSocketHandler.exit_mainloop();
- pthread_join(pMainLoopThread, NULL);
-}
diff --git a/AudioManagerDaemon/test/AmNodeStateCommunicatorDBusTest/CAmNodeStateCommunicatorTest.h b/AudioManagerDaemon/test/AmNodeStateCommunicatorDBusTest/CAmNodeStateCommunicatorTest.h
deleted file mode 100644
index 985d594..0000000
--- a/AudioManagerDaemon/test/AmNodeStateCommunicatorDBusTest/CAmNodeStateCommunicatorTest.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/**
- * SPDX license identifier: MPL-2.0
- *
- * Copyright (C) 2012, BMW AG
- *
- * This file is part of GENIVI Project AudioManager.
- *
- * Contributions are licensed to the GENIVI Alliance under one or more
- * Contribution License Agreements.
- *
- * \copyright
- * This Source Code Form is subject to the terms of the
- * Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with
- * this file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- *
- * \author Christian Linke, christian.linke@bmw.de BMW 2012
- *
- * \file CAmNodeStateCommunicatorTest.h
- * For further information see http://www.genivi.org/.
- *
- */
-#ifndef CAMNODESTATECOMMUNICATORTEST_H_
-#define CAMNODESTATECOMMUNICATORTEST_H_
-
-#include "CAmNodeStateCommunicatorDBus.h"
-#include "CAmControlSender.h"
-#include "gtest/gtest.h"
-#include "gmock/gmock.h"
-#include "../IAmControlBackdoor.h"
-#include "../MockIAmControlSend.h"
-
-using namespace testing;
-using namespace am;
-
-class CAmEnvironment : public ::testing::Environment
-{
-public:
- IAmControlBackdoor pControlInterfaceBackdoor;
- CAmControlSender pControlSender;
- CAmSocketHandler iSocketHandler;
- CAmDbusWrapper wrapper;
- CAmNodeStateCommunicatorDBus nsmController;
- pthread_t pNsmThread, pMainLoopThread;
- CAmEnvironment();
- ~CAmEnvironment();
- void SetUp();
- // Override this to define how to tear down the environment.
- void TearDown();
-};
-
-class CAmNodeStateCommunicatorTest:public ::testing::Test
-{
-public:
- MockIAmControlSend pMockControlInterface;
- CAmNodeStateCommunicatorTest();
- virtual ~CAmNodeStateCommunicatorTest();
- void SetUp();
- void TearDown();
-};
-
-
-#endif /* CAMNODESTATECOMMUNICATORTEST_H_ */
diff --git a/AudioManagerDaemon/test/AmNodeStateCommunicatorDBusTest/CMakeLists.txt b/AudioManagerDaemon/test/AmNodeStateCommunicatorDBusTest/CMakeLists.txt
deleted file mode 100644
index 29e0e4e..0000000
--- a/AudioManagerDaemon/test/AmNodeStateCommunicatorDBusTest/CMakeLists.txt
+++ /dev/null
@@ -1,103 +0,0 @@
-# Copyright (c) 2012 GENIVI Alliance
-# Copyright (c) 2012 BMW
-#
-# author Christian Linke, christian.linke@bmw.de BMW 2011,2012
-#
-# copyright
-# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction,
-# including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
-# subject to the following conditions:
-# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
-# THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-#
-# For further information see http://www.genivi.org/.
-#
-
-cmake_minimum_required(VERSION 2.8.8)
-
-project(AmNodeStateCommunicatorDBusTest)
-
-set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -DUNIT_TEST=1")
-
-find_package(Threads)
-find_package(CommonAPI REQUIRED)
-find_package(PythonLibs REQUIRED)
-
-set (AM_LINK_LIBS
- ${CMAKE_DL_LIBS}
- rt)
-
-if(WITH_DLT)
- pkg_check_modules(DLT REQUIRED automotive-dlt>=2.2.0)
- set (AM_LINK_LIBS
- ${AM_LINK_LIBS}
- ${DLT_LIBRARIES})
-endif(WITH_DLT)
-
-INCLUDE_DIRECTORIES(
- ${CMAKE_SOURCE_DIR}
- ${CMAKE_CURRENT_BINARY_DIR}
- ${AUDIO_INCLUDE_FOLDER}
- ${PYTHON_INCLUDE_DIRS}
- ${GOOGLE_TEST_INCLUDE_DIR}
- ${GMOCK_INCLUDE_DIR}
- ${DBUS_ARCH_INCLUDE_DIR}
- ${DBUS_INCLUDE_FOLDER}
-)
-
-file(GLOB NODESTATECOMMUNICATOR
- "${AUDIOMANAGER_DAEMON_FOLDER}/src/CAmDatabaseHandler.cpp"
- "${AUDIOMANAGER_DAEMON_FOLDER}/src/CAmDatabaseObserver.cpp"
- "${AUDIOMANAGER_DAEMON_FOLDER}/src/CAmRoutingSender.cpp"
- "${AUDIOMANAGER_DAEMON_FOLDER}/src/CAmRoutingReceiver.cpp"
- "${AUDIOMANAGER_DAEMON_FOLDER}/src/CAmDbusWrapper.cpp"
- "${AUDIOMANAGER_UTILITIES_SRC}/CAmDltWrapper.cpp"
- "${AUDIOMANAGER_UTILITIES_SRC}/CAmSocketHandler.cpp"
- "${AUDIOMANAGER_DAEMON_FOLDER}/src/CAmNodeStateCommunicatorDBus.cpp"
- "${AUDIOMANAGER_DAEMON_FOLDER}/src/CAmControlSender.cpp"
- "${AUDIOMANAGER_DAEMON_FOLDER}/src/CAmCommandSender.cpp"
- "${AUDIOMANAGER_DAEMON_FOLDER}/src/CAmCommandReceiver.cpp"
- "${AUDIOMANAGER_DAEMON_FOLDER}/src/CAmRouter.cpp"
- "../CAmCommonFunctions.cpp"
- "*.cpp"
- )
-
-ADD_EXECUTABLE(AmNodeStateCommunicatorDBusTest ${NODESTATECOMMUNICATOR})
-
-TARGET_LINK_LIBRARIES(AmNodeStateCommunicatorCAPITest
- ${AM_LINK_LIBS}
- ${CMAKE_THREAD_LIBS_INIT}
- ${PYTHON_LIBRARY}
- ${COMMON_API_LIBRARIES}
- ${COMMON_API_DBUS_LIBRARIES}
- gtest
- gmock
-)
-
-ADD_DEPENDENCIES(AmNodeStateCommunicatorDBusTest gtest gmock)
-
-INSTALL(TARGETS AmNodeStateCommunicatorDBusTest
- DESTINATION ${TEST_EXECUTABLE_INSTALL_PATH}
- PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_EXECUTE WORLD_READ
- COMPONENT tests
-)
-
-INSTALL(FILES
- ${CMAKE_CURRENT_SOURCE_DIR}/org.genivi.NodeStateManager.Consumer.xml
- ${CMAKE_CURRENT_SOURCE_DIR}/nsm.py
- ${CMAKE_CURRENT_SOURCE_DIR}/send2nsm.py
- DESTINATION ${TEST_EXECUTABLE_INSTALL_PATH}
- PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_EXECUTE WORLD_READ
- COMPONENT tests
-)
-
-IF(USE_BUILD_LIBS)
- execute_process(
- COMMAND mkdir -p ${EXECUTABLE_OUTPUT_PATH}
- COMMAND cp "${CMAKE_CURRENT_SOURCE_DIR}/org.genivi.NodeStateManager.Consumer.xml" ${EXECUTABLE_OUTPUT_PATH}/org.genivi.NodeStateManager.Consumer.xml
- COMMAND cp "${CMAKE_CURRENT_SOURCE_DIR}/nsm.py" ${EXECUTABLE_OUTPUT_PATH}/nsm.py
- COMMAND cp "${CMAKE_CURRENT_SOURCE_DIR}/send2nsm.py" ${EXECUTABLE_OUTPUT_PATH}/send2nsm.py)
-ENDIF(USE_BUILD_LIBS)
-
diff --git a/AudioManagerDaemon/test/AmNodeStateCommunicatorDBusTest/nsm.py b/AudioManagerDaemon/test/AmNodeStateCommunicatorDBusTest/nsm.py
deleted file mode 100644
index 7a02d05..0000000
--- a/AudioManagerDaemon/test/AmNodeStateCommunicatorDBusTest/nsm.py
+++ /dev/null
@@ -1,179 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2012, BMW AG
-#
-# This file is part of GENIVI Project AudioManager.
-#
-# Contributions are licensed to the GENIVI Alliance under one or more
-# Contribution License Agreements.
-#
-# \copyright
-# This Source Code Form is subject to the terms of the
-# Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with
-# this file, You can obtain one at http://mozilla.org/MPL/2.0/.
-#
-#
-# \author Christian Linke, christian.linke@bmw.de BMW 2012
-#
-# For further information see http://www.genivi.org/.
-#
-
-import sys
-import traceback
-import gobject
-import math
-import dbus
-import dbus.service
-import dbus.mainloop.glib
-
-loop = gobject.MainLoop()
-dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
-
-class NodeStateManager(dbus.service.Object):
- def __init__(self, loop):
- busName = dbus.service.BusName('org.genivi.NodeStateManager', bus = dbus.SessionBus())
- dbus.service.Object.__init__(self, busName, '/org/genivi/NodeStateManager')
- self.properties = {'RestartReason': 1, 'ShutdownReason': 2, 'WakeUpReason' :3, 'BootMode' :4}
- self.ABus=""
- self.APath=""
- self.loop=loop
-
- @dbus.service.method(dbus_interface='org.freedesktop.DBus.Introspectable', out_signature = 's')
- def Introspect(self):
- f = open('org.genivi.NodeStateManager.Consumer.xml', "r")
- text = f.read()
- return text
-
- @dbus.service.method(dbus_interface='org.genivi.NodeStateManager.Consumer', out_signature = 'ii')
- def GetNodeState(self):
- NodeStateId=1
- ErrorCode=1
- print('[----------] send out nodeState' + str(NodeStateId) + ' ErrorCode '+ str(1))
- return NodeStateId, ErrorCode
-
- @dbus.service.method('org.genivi.NodeStateManager.Consumer', out_signature = 'ii')
- def GetApplicationMode(self):
- ApplicationModeId=5
- ErrorCode=2
- print('[----------] send out ApplicationMode' + str(ApplicationModeId) + ' ErrorCode '+ str(2))
- return ApplicationModeId, ErrorCode
-
- @dbus.service.method('org.genivi.NodeStateManager.Consumer', in_signature='si', out_signature = 'ii')
- def GetSessionState(self,SessionName,seatID):
- SessionState=0
- ErrorCode=2
-
- if SessionName=="mySession" and seatID==1:
- SessionState=5
- ErrorCode=1
-
- print('[----------] GetSessionState for session ' + SessionName + ' seatID '+ str(seatID) + ' returnState ' + str (SessionState))
- return SessionState, ErrorCode
-
- @dbus.service.method('org.genivi.NodeStateManager.Consumer', in_signature='ssuu', out_signature = 'i')
- def RegisterShutdownClient(self,BName,ObjName,ShutdownMode,TimeoutMs):
- print('[----------] Busname: ' + BName)
- print('[----------] ObjName: ' + ObjName)
- print('[----------] ShutdownMode: ' + str(ShutdownMode))
- print('[----------] TimeoutMs: ' + str(TimeoutMs))
- ErrorCode=1
- if TimeoutMs!=100:
- ErrorCode=3
- if BName!="org.genivi.audiomanager":
- ErrorCode=4
- if ShutdownMode!=1:
- ErrorCode=5
- if ObjName!="/org/genivi/audiomanager/LifeCycleConsumer":
- ErrorCode=6
- self.ABus=BName
- self.APath=ObjName
- return ErrorCode
-
- @dbus.service.method('org.genivi.NodeStateManager.Consumer', in_signature='ssu', out_signature = 'i')
- def UnRegisterShutdownClient(self,BusName,ObjName,ShutdownMode):
- print('[----------] Busname: ' + str(BusName))
- print('[----------] ObjName: ' + str(ObjName))
- print('[----------] ShutdownMode: ' + str(ShutdownMode))
- ErrorCode=1
- if BusName!=self.ABus:
- ErrorCode=2
- if ObjName!=self.APath:
- ErrorCode=2
- if ShutdownMode!=1:
- ErrorCode=2
- return ErrorCode
-
- @dbus.service.method(dbus_interface='org.genivi.NodeStateManager.Consumer', out_signature = 'u')
- def GetInterfaceVersion(self):
- version=23
- return version
-
- @dbus.service.method('org.genivi.NodeStateManager.Consumer', in_signature='ui', out_signature='i')
- def LifecycleRequestComplete(self,RequestID,Status):
- print('[----------] RequestId: ' + str(RequestID))
- print('[----------] Status: ' + str(Status))
- ErrorCode=1
- if RequestID!=22:
- ErrorCode=2
- if Status!=4:
- ErrorCode=2
- return ErrorCode
-
- @dbus.service.method(dbus.PROPERTIES_IFACE, in_signature='ss', out_signature='v')
- def Get(self, interface, prop):
- if prop in self.properties:
- print('[----------] send out ' + str(self.properties[prop]) + ' for property '+ prop)
- return self.properties[prop]
- return 0
-
- @dbus.service.method(dbus.PROPERTIES_IFACE, in_signature='ssv')
- def Set(self, interface, prop, value):
- return 3
-
- @dbus.service.method(dbus.PROPERTIES_IFACE, in_signature='s', out_signature='a{sv}')
- def GetAll(self, interface):
- return self.properties
-
- @dbus.service.signal(dbus_interface='org.genivi.NodeStateManager.Consumer', signature='i')
- def NodeApplicationMode(self, ApplicationModeId):
- print "[----------] Send out application mode ID %d" % (ApplicationModeId)
-
- @dbus.service.signal(dbus_interface='org.genivi.NodeStateManager.Consumer', signature='i')
- def NodeState(self, NodeState):
- print "[----------] Send out NodeState %d" % (NodeState)
-
- @dbus.service.signal(dbus_interface='org.genivi.NodeStateManager.Consumer', signature='sii')
- def SessionStateChanged(self, SessionStateName,SeatID,SessionState):
- print "[----------] Send out SessionStateChanged " + SessionStateName
-
- @dbus.service.method('org.genivi.NodeStateManager.Control', in_signature='i')
- def sendNodeApplicationMode(self, input):
- self.NodeApplicationMode(input)
- return input
-
- @dbus.service.method('org.genivi.NodeStateManager.Control', in_signature='i')
- def sendNodeState(self, input):
- self.NodeState(input)
- return input
-
- @dbus.service.method('org.genivi.NodeStateManager.Control', in_signature='sii')
- def sendSessionState(self, SessionStateName,SeatID,SessionState):
- self.SessionStateChanged (SessionStateName,SeatID,SessionState)
- return SeatID
-
- @dbus.service.method('org.genivi.NodeStateManager.Control', in_signature='uu', out_signature='i')
- def sendLifeCycleRequest(self, request, requestID):
- bus = dbus.SessionBus()
- remote_object = bus.get_object(self.ABus,self.APath)
- iface = dbus.Interface(remote_object, 'org.genivi.NodeStateManager.LifeCycleConsumer')
- iface.LifecycleRequest(request,requestID)
- return 42
-
- @dbus.service.method('org.genivi.NodeStateManager.Control')
- def finish(self):
- print '[----------] Going to exit now!'
- self.loop.quit()
- return 0
-
-nsm = NodeStateManager(loop)
-loop.run()
diff --git a/AudioManagerDaemon/test/AmNodeStateCommunicatorDBusTest/org.genivi.NodeStateManager.Consumer.xml b/AudioManagerDaemon/test/AmNodeStateCommunicatorDBusTest/org.genivi.NodeStateManager.Consumer.xml
deleted file mode 100644
index bb40a96..0000000
--- a/AudioManagerDaemon/test/AmNodeStateCommunicatorDBusTest/org.genivi.NodeStateManager.Consumer.xml
+++ /dev/null
@@ -1,259 +0,0 @@
-<!-- Auto-Generated interface from Rhapsody: 'Repository::ssw_LifecycleSupport::NodeStateManagement::Concept::Interface::INSM_Consumer' -->
-<!-- Created at 2012-06-01 09:36:05 by uid65904 -->
-<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
- "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
-<node>
-<interface name="org.freedesktop.DBus.Introspectable">
- <method name="Introspect">
- <arg name="data" direction="out" type="s"/>
- </method>
-</interface>
-<interface name="org.freedesktop.DBus.Properties">
- <method name="Get">
- <arg name="interface" direction="in" type="s"/>
- <arg name="propname" direction="in" type="s"/>
- <arg name="value" direction="out" type="v"/>
- </method>
-
- <method name="Set">
- <arg name="interface" direction="in" type="s"/>
- <arg name="propname" direction="in" type="s"/>
- <arg name="value" direction="in" type="v"/>
- </method>
-
- <method name="GetAll">
- <arg name="interface" direction="in" type="s"/>
- <arg name="props" direction="out" type="a{sv}"/>
- </method>
-</interface>
- <!--
- org.genivi.NodeStateManager.Consumer:
- @short_description: "Consumer" interface of the NodeStateManager.
-
- This interface contains functions which are not safety critical and can be accessed by "every" client without further restrictions.
- -->
- <interface name="org.genivi.NodeStateManager.Consumer">
- <!--
- RestartReason: This property informs clients about the reason for the last restart. The values are based upon the enummeration NsmRestartReason_e. Note: The value is only set once at start-up.
- -->
- <property name="RestartReason" type="i" access="read"/>
-
- <!--
- ShutdownReason: This property informs clients about the reason for the last shutdown. The values are based upon the enummeration NsmShutdownReason_e. Note: The value is only set once at start-up.
- -->
- <property name="ShutdownReason" type="i" access="read"/>
-
- <!--
- WakeUpReason: This property informs clients about the recent reason for waking up the target. The values are based upon the enummeration NsmWakeUpReason_e. Note: The value is only set once at start-up.
- -->
- <property name="WakeUpReason" type="i" access="read"/>
-
- <!--
- BootMode: This property informs clients about the recent BootMode of the target. The values will be defined by a third party header, which has not been delivered yet. The description needs to be updated as soon as the header is available.
- -->
- <property name="BootMode" type="i" access="read"/>
-
- <!--
- NodeState:
- @NodeState: Numeric value for the current NodeState, defined in NsmNodeState_e.
-
- Clients can register for notifications when the NodeState is updated inside the NodeStateManager. This signal is sent to registered clients and will include the current NodeState as a parameter.
- -->
- <signal name="NodeState">
- <arg name="NodeState" type="i"/>
- </signal>
-
- <!--
- NodeApplicationMode:
- @ApplicationModeId: Numeric value for the current ApplicationMode, defined in NsmAplicationMode_e.
-
- Clients can register for notifications when the NodeApplicationMode is updated inside the NodeStateManager. This signal is sent to registered clients and will include the current NodeApplicationMode as a parameter.
- -->
- <signal name="NodeApplicationMode">
- <arg name="ApplicationModeId" type="i"/>
- </signal>
-
- <!--
- SessionStateChanged:
- @SessionStateName: The SessionName will be based upon either the pre-defined platform SessionNames or using a newly added product defined session name.
- @SeatID: This parameter will be based upon the enum NsmSeat_e.
- @SessionState: This parameter will be based upon the NsmSessionState_e but it will not be bounded by the values in that enumeration. The listed values are the default values that are mandatory for platform sessions, but product sessions may have additional session states.
-
- This signal is sent to registered clients when a particular session is state is changed. The client can register for notification about a specific session through the use of the SessionName, as a "match rule".
- -->
- <signal name="SessionStateChanged">
- <arg name="SessionStateName" type="s"/>
- <arg name="SeatID" type="i"/>
- <arg name="SessionState" type="i"/>
- </signal>
-
- <!--
- GetNodeState:
- @NodeStateId: Will be based on the NsmNodeState_e.
- @ErrorCode: Return value passed to the caller, based upon NsmErrorStatus_e.
-
- The method is used by other applications to get the NodeState without the need of registration to the signal.
- -->
- <method name="GetNodeState">
- <arg name="NodeStateId" direction="out" type="i"/>
- <arg name="ErrorCode" direction="out" type="i"/>
- </method>
-
- <!--
- SetSessionState:
- @SessionName: The SessionName will be based upon either the pre-defined platform SessionNames (see NSM content page) or using a newly added product defined session name.
- @SessionOwner: This parameter defines the name of the application that is setting the state of the session. This must be the applications systemd unit filename.
- @SeatID: This parameter will be based upon the enum NsmSeat_e
- @SessionState: This parameter will be based upon the NsmSessionState_e but it will not be bounded by the values in that enumeration. The listed values are the default values that are mandatory for platform sessions, but product sessions may have additional SessionStates.
- @ErrorCode: Return value passed to the caller, based upon NsmErrorStatus_e.
-
- The method is used by applications to set the state of a session.
- -->
- <method name="SetSessionState">
- <arg name="SessionName" direction="in" type="s"/>
- <arg name="SessionOwner" direction="in" type="s"/>
- <arg name="SeatID" direction="in" type="i"/>
- <arg name="SessionState" direction="in" type="i"/>
- <arg name="ErrorCode" direction="out" type="i"/>
- </method>
-
- <!--
- GetSessionState:
- @SessionName: The SessionName will be based upon either the pre-defined platform session names (see NSM content page) or using a newly added product defined SessionName.
- @SeatID: This parameter will be based upon the enum NsmSeat_e.
- @SessionState: This parameter will be based upon the NsmSessionState_e but it will not be bounded by the values in that enumeration. The listed values are the default values that are mandatory for platform sessions, but product sessions may have additional SessionStates.
- @ErrorCode: Return value passed to the caller, based upon NsmErrorStatus_e.
-
- The method is used by applications to get the state of a session.
- -->
- <method name="GetSessionState">
- <arg name="SessionName" direction="in" type="s"/>
- <arg name="SeatID" direction="in" type="i"/>
- <arg name="SessionState" direction="out" type="i"/>
- <arg name="ErrorCode" direction="out" type="i"/>
- </method>
-
- <!--
- GetApplicationMode:
- @ApplicationModeId: This parameter will be based upon the NsmNodeApplicationMode_e.
- @ErrorCode: Return value passed to the caller, based upon NsmErrorStatus_e.
-
- The method is used by other applications to get the application mode.
- -->
- <method name="GetApplicationMode">
- <arg name="ApplicationModeId" direction="out" type="i"/>
- <arg name="ErrorCode" direction="out" type="i"/>
- </method>
-
- <!--
- RegisterShutdownClient:
- @BusName: Bus name of remote application.
- @ObjName: Object name of remote object that provides the shutdown interface.
- @ShutdownMode: Shutdown mode for which client wants to be informed (i.e normal, fast etc).
- @TimeoutMs: Max. Timeout to wait for response from shutdown client in ms.
- @ErrorCode: Return value passed to the caller, based upon NsmErrorStatus_e.
-
- The method is used by other applications to register themselves as shutdown client. Any client that registers must provide a method in their D-Bus object called "LifecycleRequest". This method will take one parameter which is the RequestType (NSM_SHUTDOWNTYPE_NORMAL, NSM_SHUTDOWNTYPE_FAST). For an example of the required client interface please see the BootManager component who will be a client of the NSM.
- -->
- <method name="RegisterShutdownClient">
- <arg name="BusName" direction="in" type="s"/>
- <arg name="ObjName" direction="in" type="s"/>
- <arg name="ShutdownMode" direction="in" type="u"/>
- <arg name="TimeoutMs" direction="in" type="u"/>
- <arg name="ErrorCode" direction="out" type="i"/>
- </method>
-
- <!--
- UnRegisterShutdownClient:
- @BusName: Bus name of remote application.
- @ObjName: Object name of remote object that provides the shutdown interface.
- @ShutdownMode: Shutdown mode for which client wants to unregister (NSM_SHUTDOWNTYPE_NORMAL, NSM_SHUTDOWNTYPE_FAST).
- @ErrorCode: Return value passed to the caller, based upon NsmErrorStatus_e.
-
- The method is used by other applications to unregister themselves as shutdown client.
- -->
- <method name="UnRegisterShutdownClient">
- <arg name="BusName" direction="in" type="s"/>
- <arg name="ObjName" direction="in" type="s"/>
- <arg name="ShutdownMode" direction="in" type="u"/>
- <arg name="ErrorCode" direction="out" type="i"/>
- </method>
-
- <!--
- RegisterSession:
- @SessionName: The SessionName will be based upon either the pre-defined platform session names (see NSM content page) or using a newly added product defined SessionName.
- @SessionOwner: This is the name of the application that is registering the new session (this must be the applications systemd unit filename).
- @SeatID: This parameter will be based upon the enum NsmSeatId_e
- @SessionState: This parameter will be based upon the NsmSessionState_e but it will not be bounded by the values in that enumeration. The listed values are the default values that are mandatory for platform sessions, but product sessions may have additional session states.
- @ErrorCode: Return value passed to the caller, based upon NsmErrorStatus_e.
-
- The method is used by other applications to register a new session whose state should be observed and distributed by the NSM.
- -->
- <method name="RegisterSession">
- <arg name="SessionName" direction="in" type="s"/>
- <arg name="SessionOwner" direction="in" type="s"/>
- <arg name="SeatID" direction="in" type="i"/>
- <arg name="SessionState" direction="in" type="i"/>
- <arg name="ErrorCode" direction="out" type="i"/>
- </method>
-
- <!--
- UnRegisterSession:
- @SessionName: The SessionName will be based upon either the pre-defined platform session names (see NSM content page) or using a newly added product defined SessionName.
- @SessionOwner: This is the name of the application that originally registered the session. It will be validated that this value matches the stored value from the registration.
- @SeatID: This parameter will be based upon the enum NsmSeat_e.
- @ErrorCode: Return value passed to the caller, based upon NsmErrorStatus_e.
-
- The method is used by other applications to remove a new session from the session list hosted by NSM.
- -->
- <method name="UnRegisterSession">
- <arg name="SessionName" direction="in" type="s"/>
- <arg name="SessionOwner" direction="in" type="s"/>
- <arg name="SeatID" direction="in" type="i"/>
- <arg name="ErrorCode" direction="out" type="i"/>
- </method>
-
- <!--
- GetAppHealthCount:
- @Count: Return value passed to the caller. Number of applications that crashed or terminated accidentally.
-
- The method returns the number of applications that crashed or terminated accidentally, within the current life cycle. It can be used to observe the system state.
- -->
- <method name="GetAppHealthCount">
- <arg name="Count" direction="out" type="u"/>
- </method>
-
- <!--
- GetInterfaceVersion:
- @Version: Unsigned integer that represents the version number of the Node State Manager.
-
- The method returns the version number of the Node State Manager. The number is organized in four bytes:
-
- Version: VVV.RRR.PPP.BBB
-
- <literallayout>
- VVV => Version [1..255]
- RRR => Release [0..255]
- PPP => Patch [0..255]
- BBB => Build [0..255]
- </literallayout>
- -->
- <method name="GetInterfaceVersion">
- <arg name="Version" direction="out" type="u"/>
- </method>
-
- <!--
- LifecycleRequestComplete:
- @RequestId: The request Id of the called life cycle client. The value has been passed when "LifecycleRequest" was called.
- @Status: The result of the call to "LifecycleRequest". NsmErrorStatus_Ok: Request successfully processed. NsmErrorStatus_Error: An error occured while processing the "LifecycleRequest".
- @ErrorCode: Return value passed to the caller, based upon NsmErrorStatus_e.
-
- The function has to be called by a "asynchrounous" lifecycle client, when he processed the "LifecycleRequest".
- -->
- <method name="LifecycleRequestComplete">
- <arg name="RequestId" direction="in" type="u"/>
- <arg name="Status" direction="in" type="i"/>
- <arg name="ErrorCode" direction="out" type="i"/>
- </method>
- </interface>
-</node>
diff --git a/AudioManagerDaemon/test/AmNodeStateCommunicatorDBusTest/send2nsm.py b/AudioManagerDaemon/test/AmNodeStateCommunicatorDBusTest/send2nsm.py
deleted file mode 100644
index c7e8bf5..0000000
--- a/AudioManagerDaemon/test/AmNodeStateCommunicatorDBusTest/send2nsm.py
+++ /dev/null
@@ -1,68 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2012, BMW AG
-#
-# This file is part of GENIVI Project AudioManager.
-#
-# Contributions are licensed to the GENIVI Alliance under one or more
-# Contribution License Agreements.
-#
-# \copyright
-# This Source Code Form is subject to the terms of the
-# Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with
-# this file, You can obtain one at http://mozilla.org/MPL/2.0/.
-#
-#
-# \author Christian Linke, christian.linke@bmw.de BMW 2012
-#
-# For further information see http://www.genivi.org/.
-#
-
-import sys
-import traceback
-import gobject
-import math
-import dbus
-import dbus.service
-
-def nodeState (nodeState):
- bus = dbus.SessionBus()
- remote_object = bus.get_object('org.genivi.NodeStateManager','/org/genivi/NodeStateManager')
- iface = dbus.Interface(remote_object, 'org.genivi.NodeStateManager.Control')
- iface.sendNodeState(int(nodeState))
-
-def appMode (appMode):
- bus = dbus.SessionBus()
- remote_object = bus.get_object('org.genivi.NodeStateManager','/org/genivi/NodeStateManager')
- iface = dbus.Interface(remote_object, 'org.genivi.NodeStateManager.Control')
- iface.sendNodeApplicationMode(int(appMode))
-
-def sessionState (SessionStateName,SeatID,SessionState):
- bus = dbus.SessionBus()
- remote_object = bus.get_object('org.genivi.NodeStateManager','/org/genivi/NodeStateManager')
- iface = dbus.Interface(remote_object, 'org.genivi.NodeStateManager.Control')
- iface.sendSessionState(SessionStateName,int(SeatID),int(SessionState))
-
-def finish():
- bus = dbus.SessionBus()
- remote_object = bus.get_object('org.genivi.NodeStateManager','/org/genivi/NodeStateManager')
- iface = dbus.Interface(remote_object, 'org.genivi.NodeStateManager.Control')
- iface.finish()
-
-def LifecycleRequest(Request,RequestID):
- bus = dbus.SessionBus()
- remote_object = bus.get_object('org.genivi.NodeStateManager','/org/genivi/NodeStateManager')
- iface = dbus.Interface(remote_object, 'org.genivi.NodeStateManager.Control')
- iface.sendLifeCycleRequest(dbus.UInt32(Request),dbus.UInt32(RequestID))
-
-command=sys.argv[1]
-if command=="nodeState":
- nodeState(sys.argv[2])
-if command=="finish":
- finish()
-if command=="appMode":
- appMode(sys.argv[2])
-if command=="sessionState":
- sessionState(sys.argv[2],sys.argv[3],sys.argv[4])
-if command=="LifecycleRequest":
- LifecycleRequest(sys.argv[2],sys.argv[3])
diff --git a/AudioManagerDaemon/test/CMakeLists.txt b/AudioManagerDaemon/test/CMakeLists.txt
index 5460897..a52f5ae 100644
--- a/AudioManagerDaemon/test/CMakeLists.txt
+++ b/AudioManagerDaemon/test/CMakeLists.txt
@@ -36,14 +36,6 @@ add_subdirectory (AmRouterMapTest)
add_subdirectory (AmRoutingInterfaceTest)
add_subdirectory (AmSocketHandlerTest)
-IF(WITH_NSM)
- IF(WITH_DBUS_WRAPPER)
- add_subdirectory (AmNodeStateCommunicatorDBusTest)
- ELSEIF(WITH_CAPI_WRAPPER)
- add_subdirectory (AmNodeStateCommunicatorCAPITest)
- ENDIF()
-ENDIF(WITH_NSM)
-
IF(WITH_TELNET)
add_subdirectory (AmTelnetServerTest)
ENDIF(WITH_TELNET)
diff --git a/AudioManagerDaemon/test/MockIAmControlSend.h b/AudioManagerDaemon/test/MockIAmControlSend.h
index 46329e1..e628068 100644
--- a/AudioManagerDaemon/test/MockIAmControlSend.h
+++ b/AudioManagerDaemon/test/MockIAmControlSend.h
@@ -151,14 +151,6 @@ class MockIAmControlSend : public IAmControlSend {
am_Error_e(const am_sinkID_t sinkID, const am_NotificationConfiguration_s& notificationConfiguration));
MOCK_METHOD2(hookUserSetMainSourceNotificationConfiguration,
am_Error_e(const am_sourceID_t sourceID, const am_NotificationConfiguration_s& notificationConfiguration));
- MOCK_METHOD1(hookSystemNodeStateChanged,
- void(const NsmNodeState_e NodeStateId));
- MOCK_METHOD1(hookSystemNodeApplicationModeChanged,
- void(const NsmApplicationMode_e ApplicationModeId));
- MOCK_METHOD3(hookSystemSessionStateChanged,
- void(const std::string& sessionName, const NsmSeat_e seatID, const NsmSessionState_e sessionStateID));
- MOCK_METHOD2(hookSystemLifecycleRequest,
- NsmErrorStatus_e(const uint32_t Request, const uint32_t RequestId));
MOCK_METHOD2(hookSystemSingleTimingInformationChanged,
void(const am_connectionID_t connectionID, const am_timeSync_t time));
};