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 Christian Linke, christian.linke@bmw.de BMW 2012
17 * \file CAmNodeStateCommunicator.h
18 * For further information see http://www.genivi.org/.
21 #ifndef CAMNODESTATECOMMUNICATOR_H_
22 #define CAMNODESTATECOMMUNICATOR_H_
24 #include "shared/CAmDbusWrapper.h"
25 #include "NodeStateManager.h"
30 class CAmControlSender;
32 /** communicates with the NSM
33 * The CAmNodeStateCommunicator communicates with the NodeStateManager via Dbus. Only works, if CAmDBusWrapper is enabled.
34 * The CAmNodeStateCommunicator is triggered via CAmControlReceiver, so you can communicate from the ControllerPlugin with it.
35 * Most if the interfaces are passive, so you get the information you need via retrieving it. If you need to register the AudioManager
36 * as LifeCycleConsumer, you need to call CAmNodeStateCommunicator::nsmRegisterShutdownClient which can be undone with CAmNodeStateCommunicator::nsmUnRegisterShutdownClient.
37 * After you have registered, you will get hookSystemLifecycleRequest on the ControlSendInterface of the controller.
38 * You should answer this within your set timeout with CAmNodeStateCommunicator::nsmSendLifecycleRequestComplete.
40 class CAmNodeStateCommunicator
43 CAmNodeStateCommunicator(CAmDbusWrapper* iDbusWrapper);
44 virtual ~CAmNodeStateCommunicator();
45 am_Error_e nsmGetRestartReasonProperty(NsmRestartReason_e& restartReason) ;
46 am_Error_e nsmGetShutdownReasonProperty(NsmShutdownReason_e& ShutdownReason) ;
47 am_Error_e nsmGetRunningReasonProperty(NsmRunningReason_e& nsmRunningReason) ;
48 NsmErrorStatus_e nsmGetNodeState(NsmNodeState_e& nsmNodeState) ;
49 NsmErrorStatus_e nsmGetSessionState(const std::string& sessionName, const NsmSeat_e& seatID, NsmSessionState_e& sessionState) ;
50 NsmErrorStatus_e nsmGetApplicationMode(NsmApplicationMode_e& applicationMode) ;
51 NsmErrorStatus_e nsmRegisterShutdownClient(const uint32_t shutdownMode, const uint32_t timeoutMs) ;
52 NsmErrorStatus_e nsmUnRegisterShutdownClient(const uint32_t shutdownMode) ;
53 am_Error_e nsmGetInterfaceVersion(uint32_t& version) ;
54 NsmErrorStatus_e nsmSendLifecycleRequestComplete(const uint32_t RequestId, const NsmErrorStatus_e status) ;
56 void registerControlSender(CAmControlSender* iControlSender);
57 static DBusHandlerResult receiveCallback(DBusConnection *conn, DBusMessage *msg, void *user_data);
58 static DBusHandlerResult signalCallback(DBusConnection *conn, DBusMessage *msg, void *user_data);
62 void sendIntrospection(DBusConnection* conn, DBusMessage* msg);
63 void sendMessage(DBusMessage* message, DBusMessage* origMessage);
64 DBusHandlerResult receiveCallbackDelegate(DBusConnection *conn, DBusMessage *msg);
65 am_Error_e readIntegerProperty(const std::string property, int32_t &value);
66 CAmDbusWrapper* mpDbusWrapper;
67 CAmControlSender* mpControlSender;
68 DBusConnection* mpDBusConnection;
72 #endif /* CAMNODESTATECOMMUNICATOR_H_ */