AudioManager  7.6.6
Native Application Runtime Environment
CAmDbusWrapper.h
Go to the documentation of this file.
1 
21 #ifndef DBUSWRAPPER_H_
22 #define DBUSWRAPPER_H_
23 
24 #include <dbus/dbus.h>
25 #include <string>
26 #include <list>
27 #include <map>
28 #include "audiomanagerconfig.h"
29 #include "CAmSocketHandler.h"
30 
31 namespace am
32 {
33 
38 {
39 public:
40  CAmDbusWrapper(CAmSocketHandler* socketHandler,DBusBusType type=DBUS_BUS_SESSION,
41  const std::string& prefix = DBUS_SERVICE_PREFIX, const std::string& objectPath = DBUS_SERVICE_OBJECT_PATH);
42  virtual ~CAmDbusWrapper();
43 
44  void registerCallback(const DBusObjectPathVTable* vtable, const std::string& path, void* userdata, const std::string& prefix = DBUS_SERVICE_OBJECT_PATH);
45  void registerSignalWatch(DBusHandleMessageFunction handler, const std::string& rule, void* userdata);
46  void getDBusConnection(DBusConnection*& connection) const;
47 
48  static dbus_bool_t addWatch(DBusWatch *watch, void *userData);
49  static void removeWatch(DBusWatch *watch, void *userData);
50  static void toogleWatch(DBusWatch *watch, void *userData);
51 
52  static dbus_bool_t addTimeout(DBusTimeout *timeout, void* userData);
53  static void removeTimeout(DBusTimeout *timeout, void* userData);
54  static void toggleTimeout(DBusTimeout *timeout, void* userData);
55 
56  void dbusPrepareCallback(const sh_pollHandle_t handle, void* userData);
58 
59  bool dbusDispatchCallback(const sh_pollHandle_t handle, void* userData);
61 
62  void dbusFireCallback(const pollfd pollfd, const sh_pollHandle_t handle, void* userData);
64 
65  bool dbusCheckCallback(const sh_pollHandle_t handle, void* userData);
67 
68  void dbusTimerCallback(sh_timerHandle_t handle, void* userData);
70 
71 private:
72  static CAmDbusWrapper* mpReference;
73  static DBusHandlerResult cbRootIntrospection(DBusConnection *conn, DBusMessage *msg, void *reference);
74  dbus_bool_t addWatchDelegate(DBusWatch * watch, void* userData);
75  void removeWatchDelegate(DBusWatch *watch, void *userData);
76  void toogleWatchDelegate(DBusWatch *watch, void *userData);
77  dbus_bool_t addTimeoutDelegate(DBusTimeout *timeout, void* userData);
78  void removeTimeoutDelegate(DBusTimeout *timeout, void* userData);
79  void toggleTimeoutDelegate(DBusTimeout *timeout, void* userData);
80  DBusObjectPathVTable mObjectPathVTable;
81  DBusConnection* mpDbusConnection;
82  DBusError mDBusError;
83  std::vector<std::string> mListNodes;
84  std::vector<sh_timerHandle_t*> mpListTimerhandles;
85  CAmSocketHandler *mpSocketHandler;
86  std::map<DBusWatch*, sh_pollHandle_t> mMapHandleWatch;
87  DBusBusType mDbusType;
88 };
89 
90 }
91 
92 #endif /* DBUSWRAPPER_H_ */
void registerCallback(const DBusObjectPathVTable *vtable, const std::string &path, void *userdata, const std::string &prefix=DBUS_SERVICE_OBJECT_PATH)
registers a callback that is entered as path below the main path.
A Common-API wrapper class, which loads the common-api runtime and instantiates all necessary objects...
TAmShTimerCallBack< CAmDbusWrapper > pDbusTimerCallback
bool dbusDispatchCallback(const sh_pollHandle_t handle, void *userData)
template for a callback
void dbusTimerCallback(sh_timerHandle_t handle, void *userData)
make private, not public template for a callback
TAmShPollFired< CAmDbusWrapper > pDbusFireCallback
The am::CAmSocketHandler implements a mainloop for the AudioManager.
static void toggleTimeout(DBusTimeout *timeout, void *userData)
TAmShPollPrepare< CAmDbusWrapper > pDbusPrepareCallback
uint16_t sh_pollHandle_t
this is a handle for a filedescriptor to be used with the SocketHandler
template for a callback
static void toogleWatch(DBusWatch *watch, void *userData)
template for a callback
CAmDbusWrapper(CAmSocketHandler *socketHandler, DBusBusType type=DBUS_BUS_SESSION, const std::string &prefix=DBUS_SERVICE_PREFIX, const std::string &objectPath=DBUS_SERVICE_OBJECT_PATH)
void registerSignalWatch(DBusHandleMessageFunction handler, const std::string &rule, void *userdata)
register signal watch callback to matching rule
TAmShPollDispatch< CAmDbusWrapper > pDbusDispatchCallback
SPDX license identifier: MPL-2.0.
bool dbusCheckCallback(const sh_pollHandle_t handle, void *userData)
static void removeWatch(DBusWatch *watch, void *userData)
This wraps dbus and provides everything needed to anyone who wants to use dbus (including plugins)...
static dbus_bool_t addTimeout(DBusTimeout *timeout, void *userData)
static dbus_bool_t addWatch(DBusWatch *watch, void *userData)
void dbusFireCallback(const pollfd pollfd, const sh_pollHandle_t handle, void *userData)
static void removeTimeout(DBusTimeout *timeout, void *userData)
void getDBusConnection(DBusConnection *&connection) const
returns the dbus connection
TAmShPollCheck< CAmDbusWrapper > pDbusCheckCallback
void dbusPrepareCallback(const sh_pollHandle_t handle, void *userData)
sh_pollHandle_t sh_timerHandle_t
this is a handle for a timer to be used with the SocketHandler
template to create the functor for a class