* remove some warnings
[profile/ivi/genivi/genivi-audio-manager.git] / PluginCommandInterfaceDbus / include / IAmCommandReceiverShadow.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 COMMANDRECEIVERSHADOW_H_
19 #define COMMANDRECEIVERSHADOW_H_
20
21
22
23 #include <dbus/dbus.h>
24 #include <map>
25 #include "config.h"
26 #include "command/IAmCommandReceive.h"
27 #include "CAmDbusMessageHandler.h"
28 #include "shared/CAmDbusWrapper.h"
29
30 namespace am
31 {
32
33 class IAmCommandReceiverShadow;
34
35 typedef void (IAmCommandReceiverShadow::*CallBackMethod)(DBusConnection *connection, DBusMessage *message);
36
37 /**
38  * receives the DBus Callbacks, marhsalls and demarshalls the parameters and calls CommandReceive
39  */
40 class IAmCommandReceiverShadow
41 {
42 public:
43     IAmCommandReceiverShadow();
44     virtual ~IAmCommandReceiverShadow();
45     void connect(DBusConnection *conn, DBusMessage *msg);
46     void disconnect(DBusConnection *conn, DBusMessage *msg);
47     void setVolume(DBusConnection *conn, DBusMessage *msg);
48     void volumeStep(DBusConnection *conn, DBusMessage *msg);
49     void setSinkMuteState(DBusConnection *conn, DBusMessage *msg);
50     void setMainSinkSoundProperty(DBusConnection *conn, DBusMessage *msg);
51     void setMainSourceSoundProperty(DBusConnection *conn, DBusMessage *msg);
52     void setSystemProperty(DBusConnection *conn, DBusMessage *msg);
53     void getListMainConnections(DBusConnection *conn, DBusMessage *msg);
54     void getListMainSinks(DBusConnection *conn, DBusMessage *msg);
55     void getListMainSources(DBusConnection *conn, DBusMessage *msg);
56     void getListMainSinkSoundProperties(DBusConnection *conn, DBusMessage *msg);
57     void getListMainSourceSoundProperties(DBusConnection *conn, DBusMessage *msg);
58     void getListSourceClasses(DBusConnection *conn, DBusMessage *msg);
59     void getListSinkClasses(DBusConnection *conn, DBusMessage *msg);
60     void getListSystemProperties(DBusConnection *conn, DBusMessage *msg);
61     void getTimingInformation(DBusConnection *conn, DBusMessage *msg);
62     void getListSinkMainNotificationConfigurations(DBusConnection *conn, DBusMessage *msg);
63     void getListSourceMainNotificationConfigurations(DBusConnection *conn, DBusMessage *msg);
64     void setSinkMainNotificationConfiguration(DBusConnection *conn, DBusMessage *msg);
65     void setSourceMainNotificationConfiguration(DBusConnection *conn, DBusMessage *msg);
66
67     /**
68      * sets the pointer to the CommandReceiveInterface and registers Callback
69      * @param receiver
70      */
71     void setCommandReceiver(IAmCommandReceive*& receiver);
72 private:
73     typedef std::map<std::string, CallBackMethod> functionMap_t;
74     functionMap_t mFunctionMap;
75     CAmDbusMessageHandler mDBUSMessageHandler;
76     IAmCommandReceive* mpIAmCommandReceive;
77     CAmDbusWrapper* mpCAmDbusWrapper;
78
79     /**
80      * receives a callback whenever the path of the plugin is called
81      */
82     static DBusHandlerResult receiveCallback(DBusConnection *conn, DBusMessage *msg, void *user_data);
83
84     /**
85      * dynamic delegate that handles the Callback of the static receiveCallback
86      * @param conn DBus connection
87      * @param msg DBus message
88      * @param user_data pointer to instance of CommandReceiverShadow
89      * @return
90      */
91     DBusHandlerResult receiveCallbackDelegate(DBusConnection *conn, DBusMessage *msg);
92
93     /**
94      * sends out introspectiondata read from an xml file.
95      * @param conn
96      * @param msg
97      */
98     void sendIntrospection(DBusConnection* conn, DBusMessage* msg);
99
100     /**
101      * creates the function map needed to combine DBus messages and function adresses
102      * @return the map
103      */
104     functionMap_t createMap();
105 };
106
107 }
108
109 #endif /* COMMANDRECEIVERSHADOW_H_ */