2 * Copyright (C) 2012, BMW AG
4 * This file is part of GENIVI Project AudioManager.
6 * Contributions are licensed to the GENIVI Alliance under one or more
7 * Contribution License Agreements.
10 * This Source Code Form is subject to the terms of the
11 * Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with
12 * this file, You can obtain one at http://mozilla.org/MPL/2.0/.
15 * \author Aleksandar Donchev, aleksander.donchev@partner.bmw.de BMW 2013
17 * \file CAmNodeStateCommunicatorCAPI.h
18 * For further information see http://www.genivi.org/.
21 #ifndef CAMNODESTATECOMMUNICATORCAPI_H_
22 #define CAMNODESTATECOMMUNICATORCAPI_H_
24 #include <org/genivi/NodeStateManager/Consumer/ConsumerProxy.h>
25 #include "CAmNodeStateCommunicator.h"
26 #include "LifeCycleConsumerStubDefault.h"
30 using namespace CommonAPI;
31 using namespace org::genivi::NodeStateManager::Consumer;
32 using namespace org::genivi::NodeStateManager::LifeCycleConsumer;
35 class CAmCommonAPIWrapper;
36 /** communicates with the NSM
37 * The CAmNodeStateCommunicator communicates with the NodeStateManager via Dbus Common-API's wrapping mechanism. Only works, if CAmCommonAPIWrapper is enabled.
39 class CAmNodeStateCommunicatorCAPI : public CAmNodeStateCommunicator
41 /* A concrete implementation of the life cycle stub.
42 * An object from this class is instantiated from the common-api factory.
43 * It forwards the invocations to its delegate CAmNodeStateCommunicatorCAPI.
45 class CAmNodeStateCommunicatorServiceImpl : public LifeCycleConsumerStubDefault
47 CAmNodeStateCommunicatorCAPI *mpDelegate;
49 CAmNodeStateCommunicatorServiceImpl ():mpDelegate(NULL) {}
50 CAmNodeStateCommunicatorServiceImpl (CAmNodeStateCommunicatorCAPI *aNSCommunicator):mpDelegate(aNSCommunicator) {}
51 ~CAmNodeStateCommunicatorServiceImpl() { mpDelegate = NULL; }
53 CAmNodeStateCommunicatorCAPI *getDelegate() { return mpDelegate; };
54 void setDelegate(CAmNodeStateCommunicatorCAPI *aDelegate) { mpDelegate = aDelegate; };
56 void LifecycleRequest(uint32_t Request, uint32_t RequestId, int32_t& ErrorCode) {
58 mpDelegate->cbReceivedLifecycleRequest(Request, RequestId, ErrorCode);
62 CAmCommonAPIWrapper *mpCAPIWrapper;
63 std::shared_ptr<ConsumerProxy<> > mNSMProxy;
64 std::shared_ptr<CAmNodeStateCommunicatorCAPI::CAmNodeStateCommunicatorServiceImpl> mNSMStub;
66 CAmNodeStateCommunicatorCAPI(CAmCommonAPIWrapper* iCAPIWrapper);
67 virtual ~CAmNodeStateCommunicatorCAPI();
69 am_Error_e nsmGetRestartReasonProperty(NsmRestartReason_e& restartReason) ;
70 am_Error_e nsmGetShutdownReasonProperty(NsmShutdownReason_e& ShutdownReason) ;
71 am_Error_e nsmGetRunningReasonProperty(NsmRunningReason_e& nsmRunningReason) ;
72 NsmErrorStatus_e nsmGetNodeState(NsmNodeState_e& nsmNodeState) ;
73 NsmErrorStatus_e nsmGetSessionState(const std::string& sessionName, const NsmSeat_e& seatID, NsmSessionState_e& sessionState) ;
74 NsmErrorStatus_e nsmGetApplicationMode(NsmApplicationMode_e& applicationMode) ;
75 NsmErrorStatus_e nsmRegisterShutdownClient(const uint32_t shutdownMode, const uint32_t timeoutMs) ;
76 NsmErrorStatus_e nsmUnRegisterShutdownClient(const uint32_t shutdownMode) ;
77 am_Error_e nsmGetInterfaceVersion(uint32_t& version) ;
78 NsmErrorStatus_e nsmSendLifecycleRequestComplete(const uint32_t RequestId, const NsmErrorStatus_e status) ;
80 bool isServiceAvailable();
82 static const char * CLIENT_STRING;
83 static const char * SERVER_STRING;
84 static const char * OBJECT_NAME;
85 static const char * BUS_NAME;
89 void onNodeStateEvent(const int32_t nodeState);
90 void onNodeApplicationModeEvent(const int32_t nodeApplicationMode);
91 void onSessionStateChangedEvent(const std::string & sessionName, const int32_t seatID, const int32_t sessionState);
92 void onServiceStatusEvent(const CommonAPI::AvailabilityStatus& serviceStatus);
93 /* Service callbacks */
94 void cbReceivedLifecycleRequest(uint32_t Request, uint32_t RequestId, int32_t& ErrorCode);
96 bool mIsServiceAvailable;
101 #endif /* CAMNODESTATECOMMUNICATORCAPI_H_ */