* removed all documentation to new place
[profile/ivi/genivi/genivi-audio-manager.git] / PluginCommandInterfaceDbus / include / CAmCommandSenderDbus.h
1 /**
2  *  Copyright (c) 2012 BMW
3  *
4  *  \author Christian Mueller, christian.ei.mueller@bmw.de BMW 2011,2012
5  *
6  *  \copyright
7  *  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,
8  *  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,
9  *  subject to the following conditions:
10  *  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
11  *  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.
12  *  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
13  *  THE USE OR OTHER DEALINGS IN THE SOFTWARE.
14  *
15  *  For further information see http://www.genivi.org/.
16  */
17
18 #ifndef DBUSCOMMANDSENDER_H_
19 #define DBUSCOMMANDSENDER_H_
20
21 #include <dbus/dbus.h>
22 #include <map>
23 #include "shared/CAmDbusWrapper.h"
24 #include "CAmDbusMessageHandler.h"
25 #include "IAmCommandReceiverShadow.h"
26 #include "command/IAmCommandSend.h"
27
28 #ifdef UNIT_TEST
29 #include  "../test/CAmCommandSenderDbusBackdoor.h"
30 #endif
31
32
33
34 namespace am
35 {
36
37 const char MY_NODE[] = "CommandInterface";
38
39 /**
40  * Dbus Implementation of CommandSendInterface
41  */
42 class CAmCommandSenderDbus: public IAmCommandSend
43 {
44 public:
45     CAmCommandSenderDbus();
46     virtual ~CAmCommandSenderDbus();
47     am_Error_e startupInterface(IAmCommandReceive* commandreceiveinterface);
48     void setCommandReady(const uint16_t handle);
49     void setCommandRundown(const uint16_t handle);
50     void cbNewMainConnection(const am_MainConnectionType_s mainConnection);
51     void cbRemovedMainConnection(const am_mainConnectionID_t mainConnection);
52     void cbNewSink(const am_SinkType_s& sink);
53     void cbRemovedSink(const am_sinkID_t sinkID);
54     void cbNewSource(const am_SourceType_s& source);
55     void cbRemovedSource(const am_sourceID_t source);
56     void cbNumberOfSinkClassesChanged();
57     void cbNumberOfSourceClassesChanged();
58     void cbMainConnectionStateChanged(const am_mainConnectionID_t connectionID, const am_ConnectionState_e connectionState);
59     void cbMainSinkSoundPropertyChanged(const am_sinkID_t sinkID, const am_MainSoundProperty_s& soundProperty);
60     void cbMainSourceSoundPropertyChanged(const am_sourceID_t sourceID, const am_MainSoundProperty_s& soundProperty);
61     void cbSinkAvailabilityChanged(const am_sinkID_t sinkID, const am_Availability_s& availability);
62     void cbSourceAvailabilityChanged(const am_sourceID_t sourceID, const am_Availability_s& availability);
63     void cbVolumeChanged(const am_sinkID_t sinkID, const am_mainVolume_t volume);
64     void cbSinkMuteStateChanged(const am_sinkID_t sinkID, const am_MuteState_e muteState);
65     void cbSystemPropertyChanged(const am_SystemProperty_s& systemProperty);
66     void cbTimingInformationChanged(const am_mainConnectionID_t mainConnectionID, const am_timeSync_t time);
67     void getInterfaceVersion(std::string& version) const;
68
69 #ifdef UNIT_TEST
70     friend class CAmCommandSenderDbusBackdoor;
71 #endif
72 private:
73     CAmDbusMessageHandler mCAmDbusMessageHandler; ///< ! instance of message handler
74     IAmCommandReceiverShadow mIAmCommandReceiverShadow; ///< ! instance of shadow
75     CAmDbusWrapper* mpCAmDbusWrapper; ///< ! pointer to dbus wrapper
76     IAmCommandReceive* mpIAmCommandReceive; ///< ! pointer to commandReceive Interface
77     bool mReady; ///< ! if false, calls shall be ignored.
78
79     /**
80      * list of sinks, needed to send out only deltas
81      */
82     std::vector<am_SinkType_s> mlistSinks;
83
84     /**
85      * list of sources, needed to send out only deltas
86      */
87     std::vector<am_SourceType_s> mlistSources;
88
89     /**
90      * used as comparison function for am_SinkType_s
91      */
92     struct sortBySinkID
93     {
94         bool operator()(const am_SinkType_s & a, const am_SinkType_s & b)
95         {
96             return (a.sinkID < b.sinkID);
97         }
98     };
99
100     /**
101      * used as comparison function for am_SourceType_s
102      */
103     struct sortBySourceID
104     {
105         bool operator()(const am_SourceType_s & a, const am_SourceType_s & b)
106         {
107             return (a.sourceID < b.sourceID);
108         }
109     };
110
111 };
112
113 }
114
115 #endif /* DBUSCOMMANDSENDER_H_ */