summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVyacheslav Yurkov <uvv.mail@gmail.com>2017-05-12 19:18:26 +0200
committerKjell Ahlstedt <kjellahlstedt@gmail.com>2017-05-12 19:18:26 +0200
commit60e66b9e631c455ee4630b47ddeea198cf243735 (patch)
tree26a7a7a899286b67abf426cc540f0184edeefa53
parent9f3e0a8fba8ebab66698652c764ab208783c5d93 (diff)
downloadglibmm-60e66b9e631c455ee4630b47ddeea198cf243735.tar.gz
Gio::DBus::Proxy: Wrap call() and call_sync() methods. Bug 781818
-rw-r--r--gio/src/dbusproxy.ccg95
-rw-r--r--gio/src/dbusproxy.hg129
-rw-r--r--gio/src/gio_docs_override.xml82
3 files changed, 117 insertions, 189 deletions
diff --git a/gio/src/dbusproxy.ccg b/gio/src/dbusproxy.ccg
index b13f92f0..0855f88e 100644
--- a/gio/src/dbusproxy.ccg
+++ b/gio/src/dbusproxy.ccg
@@ -202,101 +202,6 @@ Proxy::get_cached_property(Glib::VariantBase& property, const Glib::ustring& pro
property.init(g_variant, false /* no extra reference needed */);
}
-void
-Proxy::call(const Glib::ustring& method_name, const SlotAsyncReady& slot,
- const Glib::RefPtr<Cancellable>& cancellable, const Glib::VariantContainerBase& parameters,
- int timeout_msec, CallFlags flags)
-{
- // Create a copy of the slot.
- // A pointer to it will be passed through the callback's data parameter
- // and deleted in the callback.
- auto slot_copy = new SlotAsyncReady(slot);
-
- g_dbus_proxy_call(gobj(), method_name.c_str(), const_cast<GVariant*>(parameters.gobj()),
- static_cast<GDBusCallFlags>(flags), timeout_msec, Glib::unwrap(cancellable),
- &SignalProxy_async_callback, slot_copy);
-}
-
-void
-Proxy::call(const Glib::ustring& method_name, const SlotAsyncReady& slot,
- const Glib::VariantContainerBase& parameters, int timeout_msec, CallFlags flags)
-{
- // Create a copy of the slot.
- // A pointer to it will be passed through the callback's data parameter
- // and deleted in the callback.
- auto slot_copy = new SlotAsyncReady(slot);
-
- g_dbus_proxy_call(gobj(), method_name.c_str(), const_cast<GVariant*>(parameters.gobj()),
- static_cast<GDBusCallFlags>(flags), timeout_msec, nullptr, &SignalProxy_async_callback,
- slot_copy);
-}
-
-Glib::VariantContainerBase
-Proxy::call_sync(const Glib::ustring& method_name, const Glib::RefPtr<Cancellable>& cancellable,
- const Glib::VariantContainerBase& parameters, int timeout_msec, CallFlags flags)
-{
- GError* g_error = nullptr;
-
- GVariant* const gvariant =
- g_dbus_proxy_call_sync(gobj(), method_name.c_str(), const_cast<GVariant*>(parameters.gobj()),
- static_cast<GDBusCallFlags>(flags), timeout_msec, Glib::unwrap(cancellable), &g_error);
-
- if (g_error)
- ::Glib::Error::throw_exception(g_error);
-
- return Glib::VariantContainerBase(gvariant, false); // Dont' take an extra reference.
-}
-
-Glib::VariantContainerBase
-Proxy::call_sync(const Glib::ustring& method_name, const Glib::VariantContainerBase& parameters,
- int timeout_msec, CallFlags flags)
-{
- GError* g_error = nullptr;
-
- GVariant* const gvariant =
- g_dbus_proxy_call_sync(gobj(), method_name.c_str(), const_cast<GVariant*>(parameters.gobj()),
- static_cast<GDBusCallFlags>(flags), timeout_msec, nullptr, &g_error);
-
- if (g_error)
- ::Glib::Error::throw_exception(g_error);
-
- return Glib::VariantContainerBase(gvariant, false); // Dont' take an extra reference.
-}
-
-#ifdef G_OS_UNIX
-// With a UnixFDList.
-void
-Proxy::call(const Glib::ustring& method_name, const Glib::VariantContainerBase& parameters,
- const SlotAsyncReady& slot, const Glib::RefPtr<Cancellable>& cancellable,
- const Glib::RefPtr<UnixFDList>& fd_list, int timeout_msec, CallFlags flags)
-{
- // Create a copy of the slot.
- // A pointer to it will be passed through the callback's data parameter
- // and deleted in the callback.
- auto slot_copy = new SlotAsyncReady(slot);
-
- g_dbus_proxy_call_with_unix_fd_list(gobj(), method_name.c_str(),
- const_cast<GVariant*>(parameters.gobj()), static_cast<GDBusCallFlags>(flags), timeout_msec,
- Glib::unwrap(fd_list), Glib::unwrap(cancellable), &SignalProxy_async_callback, slot_copy);
-}
-
-// Non-cancellable version (with a UnixFDList).
-void
-Proxy::call(const Glib::ustring& method_name, const Glib::VariantContainerBase& parameters,
- const SlotAsyncReady& slot, const Glib::RefPtr<UnixFDList>& fd_list, int timeout_msec,
- CallFlags flags)
-{
- // Create a copy of the slot.
- // A pointer to it will be passed through the callback's data parameter
- // and deleted in the callback.
- auto slot_copy = new SlotAsyncReady(slot);
-
- g_dbus_proxy_call_with_unix_fd_list(gobj(), method_name.c_str(),
- const_cast<GVariant*>(parameters.gobj()), static_cast<GDBusCallFlags>(flags), timeout_msec,
- Glib::unwrap(fd_list), nullptr, &SignalProxy_async_callback, slot_copy);
-}
-#endif // G_OS_UNIX
-
} // namespace DBus
} // namespace Gio
diff --git a/gio/src/dbusproxy.hg b/gio/src/dbusproxy.hg
index a6e74191..1b79db3f 100644
--- a/gio/src/dbusproxy.hg
+++ b/gio/src/dbusproxy.hg
@@ -260,24 +260,17 @@ public:
_WRAP_METHOD(Glib::RefPtr<InterfaceInfo> get_interface_info(), g_dbus_proxy_get_interface_info)
_WRAP_METHOD(Glib::RefPtr<const InterfaceInfo> get_interface_info() const, g_dbus_proxy_get_interface_info, constversion)
- _WRAP_METHOD_DOCS_ONLY(g_dbus_proxy_call)
- void call(
- const Glib::ustring& method_name,
- const SlotAsyncReady& slot,
- const Glib::RefPtr<Cancellable>& cancellable,
- const Glib::VariantContainerBase& parameters = Glib::VariantContainerBase(),
- int timeout_msec = -1,
- CallFlags flags = Gio::DBus::CALL_FLAGS_NONE
- );
-
- /// A non-cancellable version of call().
- void call(
- const Glib::ustring& method_name,
- const SlotAsyncReady& slot,
- const Glib::VariantContainerBase& parameters = Glib::VariantContainerBase(),
- int timeout_msec = -1,
- CallFlags flags = Gio::DBus::CALL_FLAGS_NONE
- );
+ _WRAP_METHOD(
+ void call(
+ const Glib::ustring& method_name{.},
+ const SlotAsyncReady& slot{callback?},
+ const Glib::RefPtr<Cancellable>& cancellable{.?},
+ const Glib::VariantContainerBase& parameters{.} = Glib::VariantContainerBase(),
+ int timeout_msec{.} = -1,
+ CallFlags flags{.} = Gio::DBus::CALL_FLAGS_NONE
+ ),
+ g_dbus_proxy_call, slot_name slot, slot_callback SignalProxy_async_callback
+ )
/** Finishes an operation started with call().
*
@@ -289,81 +282,30 @@ public:
*/
_WRAP_METHOD(Glib::VariantContainerBase call_finish(const Glib::RefPtr<AsyncResult>& res), g_dbus_proxy_call_finish, errthrow)
-//TODO: Use _WRAP_METHOD() for this?
- /** Synchronously invokes the method_name method on proxy.
- * See call(), the asynchronous version of this method for more information.
- *
- * @param method_name Name of method to invoke.
- * @param timeout_msec The timeout in milliseconds or -1 to use the proxy
- * default timeout.
- * @param flags Flags from the CallFlags enumeration.
- * @param parameters A Glib::VariantContainerBase tuple with parameters for the
- * signal.
- * @param cancellable A Cancellable.
- * @result A Variant tuple with return values.
- *
- * @throw Glib::Error.
- */
- Glib::VariantContainerBase call_sync(
- const Glib::ustring& method_name,
- const Glib::RefPtr<Cancellable>& cancellable,
- const Glib::VariantContainerBase& parameters = Glib::VariantContainerBase(),
- int timeout_msec = -1,
- CallFlags flags = Gio::DBus::CALL_FLAGS_NONE
- );
- _IGNORE(g_dbus_proxy_call_sync)
-
- /// A non-cancellable version of call_sync().
- Glib::VariantContainerBase call_sync(
- const Glib::ustring& method_name,
- const Glib::VariantContainerBase& parameters = Glib::VariantContainerBase(),
- int timeout_msec = -1,
- CallFlags flags = Gio::DBus::CALL_FLAGS_NONE
- );
-
-
-#ifdef G_OS_UNIX
-//TODO: Use _WRAP_METHOD() for this?
- /** Like call() but also takes a GUnixFDList object.
- * This method is only available on UNIX.
- *
- * This is an asynchronous method. When the operation is finished, callback
- * will be invoked in the thread-default main loop of the thread you are
- * calling this method from. You can then call call_with_unix_fd_finish() to
- * get the result of the operation. See call_sync() for the synchronous
- * version of this function.
- *
- * @param method_name The name of the method to invoke.
- * @param parameters A Glib::VariantContainerBase tuple with parameters for the
- * method or <tt>0</tt> if not passing parameters.
- * @param slot A SlotAsyncReady to call when the request is satisfied.
- * @param cancellable A Cancellable.
- * @param fd_list A UnixFDList.
- * @param timeout_msec The timeout in milliseconds, -1 to use the default
- * timeout or G_MAXINT for no timeout.
- * @param flags Flags from the Gio::DBus::CallFlags enumeration.
- * @newin{2,34}
- */
- void call(
- const Glib::ustring& method_name,
- const Glib::VariantContainerBase& parameters,
- const SlotAsyncReady& slot,
- const Glib::RefPtr<Cancellable>& cancellable,
- const Glib::RefPtr<UnixFDList>& fd_list,
- int timeout_msec = -1,
- CallFlags flags = Gio::DBus::CALL_FLAGS_NONE);
- _IGNORE(g_dbus_proxy_call_with_unix_fd_list)
-
- /** A non-cancellable version of call() (with a UnixFDList).
- * @newin{2,34}
- */
- void call(
- const Glib::ustring& method_name,
- const Glib::VariantContainerBase& parameters,
- const SlotAsyncReady& slot,
- const Glib::RefPtr<UnixFDList>& fd_list,
- int timeout_msec = -1,
- CallFlags flags = Gio::DBus::CALL_FLAGS_NONE);
+ _WRAP_METHOD(
+ Glib::VariantContainerBase call_sync(
+ const Glib::ustring& method_name{.},
+ const Glib::RefPtr<Cancellable>& cancellable{.?},
+ const Glib::VariantContainerBase& parameters{.} = Glib::VariantContainerBase(),
+ int timeout_msec{.} = -1,
+ CallFlags flags{.} = Gio::DBus::CALL_FLAGS_NONE
+ ),
+ g_dbus_proxy_call_sync, errthrow
+ )
+
+ _WRAP_METHOD(
+ void call(
+ const Glib::ustring& method_name{.},
+ const Glib::VariantContainerBase& parameters{.},
+ const SlotAsyncReady& slot{callback?},
+ const Glib::RefPtr<Cancellable>& cancellable{.?},
+ const Glib::RefPtr<UnixFDList>& fd_list{.},
+ int timeout_msec{.} = -1,
+ CallFlags flags{.} = Gio::DBus::CALL_FLAGS_NONE
+ ),
+ g_dbus_proxy_call_with_unix_fd_list, ifdef G_OS_UNIX,
+ slot_name slot, slot_callback SignalProxy_async_callback
+ )
/** Finishes an operation started with call() (with a UnixFDList).
* @param res A AsyncResult obtained from the SlotAsyncReady passed to
@@ -374,7 +316,6 @@ public:
* @newin{2,34}
*/
_WRAP_METHOD(Glib::VariantContainerBase call_finish(const Glib::RefPtr<AsyncResult>& res{.}, Glib::RefPtr<UnixFDList>& out_fd_list{.>>}), g_dbus_proxy_call_with_unix_fd_list_finish, errthrow, ifdef G_OS_UNIX)
-#endif // G_OS_UNIX
_WRAP_METHOD(
Glib::VariantContainerBase call_sync(
diff --git a/gio/src/gio_docs_override.xml b/gio/src/gio_docs_override.xml
index 5ea862dd..053ef093 100644
--- a/gio/src/gio_docs_override.xml
+++ b/gio/src/gio_docs_override.xml
@@ -1714,4 +1714,86 @@ errors that can happen due to races when you execute the operation.
</return>
</function>
+<function name="g_dbus_proxy_call">
+<parameters>
+<parameter name="proxy">
+<parameter_description> A #GDBusProxy.
+</parameter_description>
+</parameter>
+<parameter name="method_name">
+<parameter_description> Name of method to invoke.
+</parameter_description>
+</parameter>
+<parameter name="parameters">
+<parameter_description> A #GVariant tuple with parameters for the signal or %NULL if not passing parameters.
+</parameter_description>
+</parameter>
+<parameter name="flags">
+<parameter_description> Flags from the #GDBusCallFlags enumeration.
+</parameter_description>
+</parameter>
+<parameter name="timeout_msec">
+<parameter_description> The timeout in milliseconds (with %G_MAXINT meaning
+&quot;infinite&quot;) or -1 to use the proxy default timeout.
+</parameter_description>
+</parameter>
+<parameter name="cancellable">
+<parameter_description> A #GCancellable or %NULL.
+</parameter_description>
+</parameter>
+<parameter name="callback">
+<parameter_description> A #GAsyncReadyCallback to call when the request is satisfied. Use another overload
+without this parameter if your don't care about the result of the method invocation.
+</parameter_description>
+</parameter>
+<parameter name="user_data">
+<parameter_description> The data to pass to @callback.
+</parameter_description>
+</parameter>
+</parameters>
+</function>
+
+<function name="g_dbus_proxy_call_with_unix_fd_list">
+<parameters>
+<parameter name="proxy">
+<parameter_description> A #GDBusProxy.
+</parameter_description>
+</parameter>
+<parameter name="method_name">
+<parameter_description> Name of method to invoke.
+</parameter_description>
+</parameter>
+<parameter name="parameters">
+<parameter_description> A #GVariant tuple with parameters for the signal or %NULL if not passing parameters.
+</parameter_description>
+</parameter>
+<parameter name="flags">
+<parameter_description> Flags from the #GDBusCallFlags enumeration.
+</parameter_description>
+</parameter>
+<parameter name="timeout_msec">
+<parameter_description> The timeout in milliseconds (with %G_MAXINT meaning
+&quot;infinite&quot;) or -1 to use the proxy default timeout.
+</parameter_description>
+</parameter>
+<parameter name="fd_list">
+<parameter_description> A #GUnixFDList or %NULL.
+</parameter_description>
+</parameter>
+<parameter name="cancellable">
+<parameter_description> A #GCancellable or %NULL.
+</parameter_description>
+</parameter>
+<parameter name="callback">
+<parameter_description> A #GAsyncReadyCallback to call when the request is satisfied. Use another overload
+without this parameter if your don't care about the result of the method invocation.
+</parameter_description>
+</parameter>
+<parameter name="user_data">
+<parameter_description> The data to pass to @callback.
+</parameter_description>
+</parameter>
+</parameters>
+</function>
+
</root>