From 55ef232a8989da14de7a524bb9a00956275bb24c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Fri, 25 Sep 2015 17:20:57 +0200 Subject: glib::Object: add SetMethodsCallsHandlerFull to get all call parameters (bzr r4008.7.1) --- UnityCore/GLibDBusServer.cpp | 13 ++++++++++--- UnityCore/GLibDBusServer.h | 8 +++++--- 2 files changed, 15 insertions(+), 6 deletions(-) (limited to 'UnityCore') diff --git a/UnityCore/GLibDBusServer.cpp b/UnityCore/GLibDBusServer.cpp index 6d01f5994..00f956503 100644 --- a/UnityCore/GLibDBusServer.cpp +++ b/UnityCore/GLibDBusServer.cpp @@ -87,7 +87,7 @@ struct DBusObject::Impl if (self->method_cb_) { - ret = self->method_cb_(method_name ? method_name : "", parameters); + ret = self->method_cb_(gchar_to_string(method_name), parameters, gchar_to_string(sender), gchar_to_string(object_path)); LOG_INFO(logger_o) << "Called method: '" << method_name << " " << parameters << "' on object '" << object_path << "' with interface '" @@ -401,7 +401,7 @@ struct DBusObject::Impl } DBusObject* object_; - MethodCallback method_cb_; + MethodCallbackFull method_cb_; PropertyGetterCallback property_get_cb_; PropertySetterCallback property_set_cb_; @@ -420,7 +420,14 @@ DBusObject::~DBusObject() void DBusObject::SetMethodsCallsHandler(MethodCallback const& func) { - impl_->method_cb_ = func; + impl_->method_cb_ = nullptr; + + if (func) + { + impl_->method_cb_ = [func] (std::string const& method, GVariant* parameters, std::string const&, std::string const&) { + return func(method, parameters); + }; + } } void DBusObject::SetPropertyGetter(PropertyGetterCallback const& func) diff --git a/UnityCore/GLibDBusServer.h b/UnityCore/GLibDBusServer.h index 8957861be..e4778c09e 100644 --- a/UnityCore/GLibDBusServer.h +++ b/UnityCore/GLibDBusServer.h @@ -40,11 +40,13 @@ public: DBusObject(std::string const& introspection_xml, std::string const& interface_name); virtual ~DBusObject(); - typedef std::function MethodCallback; - typedef std::function PropertyGetterCallback; - typedef std::function PropertySetterCallback; + typedef std::function MethodCallback; + typedef std::function MethodCallbackFull; + typedef std::function PropertyGetterCallback; + typedef std::function PropertySetterCallback; void SetMethodsCallsHandler(MethodCallback const&); + void SetMethodsCallsHandlerFull(MethodCallbackFull const&); void SetPropertyGetter(PropertyGetterCallback const&); void SetPropertySetter(PropertySetterCallback const&); -- cgit v1.2.3