aboutsummaryrefslogtreecommitdiffstats
path: root/core/dbus_wrap.h
diff options
context:
space:
mode:
Diffstat (limited to 'core/dbus_wrap.h')
-rw-r--r--core/dbus_wrap.h36
1 files changed, 24 insertions, 12 deletions
diff --git a/core/dbus_wrap.h b/core/dbus_wrap.h
index 298ce09a..09eaacf9 100644
--- a/core/dbus_wrap.h
+++ b/core/dbus_wrap.h
@@ -7,6 +7,9 @@
#include "dynload.h"
+#ifdef HAVE_DYNLOAD
+
+#include <mutex>
#define DBUS_FUNCTIONS(MAGIC) \
MAGIC(dbus_error_init) \
@@ -25,15 +28,29 @@ MAGIC(dbus_message_iter_get_arg_type) \
MAGIC(dbus_message_iter_get_basic) \
MAGIC(dbus_set_error_from_message)
-#ifdef HAVE_DYNLOAD
-
-#include <mutex>
-
extern void *dbus_handle;
#define DECL_FUNC(x) extern decltype(x) *p##x;
DBUS_FUNCTIONS(DECL_FUNC)
#undef DECL_FUNC
+#ifndef IN_IDE_PARSER
+#define dbus_error_init (*pdbus_error_init)
+#define dbus_error_free (*pdbus_error_free)
+#define dbus_bus_get (*pdbus_bus_get)
+#define dbus_connection_set_exit_on_disconnect (*pdbus_connection_set_exit_on_disconnect)
+#define dbus_connection_unref (*pdbus_connection_unref)
+#define dbus_connection_send_with_reply_and_block (*pdbus_connection_send_with_reply_and_block)
+#define dbus_message_unref (*pdbus_message_unref)
+#define dbus_message_new_method_call (*pdbus_message_new_method_call)
+#define dbus_message_append_args (*pdbus_message_append_args)
+#define dbus_message_iter_init (*pdbus_message_iter_init)
+#define dbus_message_iter_next (*pdbus_message_iter_next)
+#define dbus_message_iter_recurse (*pdbus_message_iter_recurse)
+#define dbus_message_iter_get_arg_type (*pdbus_message_iter_get_arg_type)
+#define dbus_message_iter_get_basic (*pdbus_message_iter_get_basic)
+#define dbus_set_error_from_message (*pdbus_set_error_from_message)
+#endif
+
void PrepareDBus();
inline auto HasDBus()
@@ -45,10 +62,6 @@ inline auto HasDBus()
#else
-#define DECL_FUNC(x) constexpr auto p##x = &x;
-DBUS_FUNCTIONS(DECL_FUNC)
-#undef DECL_FUNC
-
constexpr bool HasDBus() noexcept { return true; }
#endif /* HAVE_DYNLOAD */
@@ -56,8 +69,8 @@ constexpr bool HasDBus() noexcept { return true; }
namespace dbus {
struct Error {
- Error() { (*pdbus_error_init)(&mError); }
- ~Error() { (*pdbus_error_free)(&mError); }
+ Error() { dbus_error_init(&mError); }
+ ~Error() { dbus_error_free(&mError); }
DBusError* operator->() { return &mError; }
DBusError &get() { return mError; }
private:
@@ -65,11 +78,10 @@ private:
};
struct ConnectionDeleter {
- void operator()(DBusConnection *c) { (*pdbus_connection_unref)(c); }
+ void operator()(DBusConnection *c) { dbus_connection_unref(c); }
};
using ConnectionPtr = std::unique_ptr<DBusConnection,ConnectionDeleter>;
} // namespace dbus
-
#endif /* CORE_DBUS_WRAP_H */