From 778579ec214548f4e0daeb7aff7894948bdbf990 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Tue, 21 Jun 2005 00:30:20 +0000 Subject: 2005-06-20 Colin Walters * dbus/dbus-glib.h: * glib/dbus-gproxy.c: Rename dbus_g_proxy_invoke to dbus_g_proxy_call. * glib/dbus-binding-tool-glib.c: * doc/dbus-tutorial.xml: * test/glib/test-dbus-glib.c: Update for rename. --- ChangeLog | 10 ++++++++ dbus/dbus-glib.h | 30 ++++++++++++---------- doc/dbus-tutorial.xml | 60 +++++++++++++++++++++---------------------- glib/dbus-binding-tool-glib.c | 2 +- glib/dbus-gproxy.c | 18 +++++++------ test/glib/test-dbus-glib.c | 34 ++++++++++++------------ 6 files changed, 84 insertions(+), 70 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1e524652..6479d73f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2005-06-20 Colin Walters + + * dbus/dbus-glib.h: + * glib/dbus-gproxy.c: Rename dbus_g_proxy_invoke to + dbus_g_proxy_call. + + * glib/dbus-binding-tool-glib.c: + * doc/dbus-tutorial.xml: + * test/glib/test-dbus-glib.c: Update for rename. + 2005-06-20 Colin Walters Patch suggested by Ross Burton diff --git a/dbus/dbus-glib.h b/dbus/dbus-glib.h index 7d03058e..2d5005bb 100644 --- a/dbus/dbus-glib.h +++ b/dbus/dbus-glib.h @@ -116,8 +116,8 @@ struct _DBusGObjectInfo const char *exported_properties; /**< Exported properties */ }; -void dbus_g_object_type_install_info (GType object_type, - const DBusGObjectInfo *info); +void dbus_g_object_type_install_info (GType object_type, + const DBusGObjectInfo *info); void dbus_g_connection_register_g_object (DBusGConnection *connection, const char *at_path, @@ -246,6 +246,18 @@ void dbus_g_proxy_disconnect_signal (DBusGProxy *proxy, const char *signal_name, GCallback handler, void *data); + +gboolean dbus_g_proxy_call (DBusGProxy *proxy, + const char *method, + GError **error, + GType first_arg_type, + ...); + +void dbus_g_proxy_call_no_reply (DBusGProxy *proxy, + const char *method, + GType first_arg_type, + ...); + DBusGPendingCall* dbus_g_proxy_begin_call (DBusGProxy *proxy, const char *method, GType first_arg_type, @@ -255,10 +267,6 @@ gboolean dbus_g_proxy_end_call (DBusGProxy *proxy, GError **error, GType first_arg_type, ...); -void dbus_g_proxy_call_no_reply (DBusGProxy *proxy, - const char *method, - GType first_arg_type, - ...); const char* dbus_g_proxy_get_path (DBusGProxy *proxy); @@ -266,17 +274,11 @@ const char* dbus_g_proxy_get_bus_name (DBusGProxy *proxy); const char* dbus_g_proxy_get_interface (DBusGProxy *proxy); -gboolean dbus_g_proxy_invoke (DBusGProxy *proxy, - const char *method, - GError **error, - GType first_arg_type, - ...); - typedef struct _DBusGMethodInvocation DBusGMethodInvocation; -void dbus_g_method_return (DBusGMethodInvocation *context, ...); +void dbus_g_method_return (DBusGMethodInvocation *context, ...); -void dbus_g_method_return_error (DBusGMethodInvocation *context, GError *error); +void dbus_g_method_return_error (DBusGMethodInvocation *context, GError *error); typedef struct { DBusGProxy *proxy; diff --git a/doc/dbus-tutorial.xml b/doc/dbus-tutorial.xml index 6ee32927..304d0d70 100644 --- a/doc/dbus-tutorial.xml +++ b/doc/dbus-tutorial.xml @@ -769,8 +769,8 @@ main (int argc, char **argv) /* Call ListNames method, wait for reply */ error = NULL; - if (!dbus_g_proxy_invoke (proxy, "ListNames", &error, G_TYPE_INVALID, - G_TYPE_STRV, &name_list, G_TYPE_INVALID)) + if (!dbus_g_proxy_call (proxy, "ListNames", &error, G_TYPE_INVALID, + G_TYPE_STRV, &name_list, G_TYPE_INVALID)) { g_printerr ("Failed to complete ListNames call: %s\n", error->message); @@ -810,7 +810,7 @@ main (int argc, char **argv) Understanding method invocation You have a number of choices for method invocation. First, as - used above, dbus_g_proxy_invoke sends a + used above, dbus_g_proxy_call sends a method call to the remote object, and blocks until reply is recieved. The outgoing arguments are specified in the varargs array, terminated with G_TYPE_INVALID. @@ -845,10 +845,10 @@ main (int argc, char **argv) GArray *arr; error = NULL; - if (!dbus_g_proxy_invoke (proxy, "Foobar", &error, - G_TYPE_INT, 42, G_TYPE_STRING, "hello", - G_TYPE_INVALID, - DBUS_TYPE_G_UCHAR_ARRAY, &arr, G_TYPE_INVALID)) + if (!dbus_g_proxy_call (proxy, "Foobar", &error, + G_TYPE_INT, 42, G_TYPE_STRING, "hello", + G_TYPE_INVALID, + DBUS_TYPE_G_UCHAR_ARRAY, &arr, G_TYPE_INVALID)) { g_printerr ("Failed to complete Foobar: %s\n", error->message); @@ -871,9 +871,9 @@ main (int argc, char **argv) g_hash_table_insert (hash, "baz", "whee"); error = NULL; - if (!dbus_g_proxy_invoke (proxy, "HashSize", &error, - DBUS_TYPE_G_STRING_STRING_HASH, hash, G_TYPE_INVALID, - G_TYPE_UINT, &ret, G_TYPE_INVALID)) + if (!dbus_g_proxy_call (proxy, "HashSize", &error, + DBUS_TYPE_G_STRING_STRING_HASH, hash, G_TYPE_INVALID, + G_TYPE_UINT, &ret, G_TYPE_INVALID)) { g_printerr ("Failed to complete HashSize: %s\n", error->message); @@ -893,11 +893,11 @@ main (int argc, char **argv) char *strret; error = NULL; - if (!dbus_g_proxy_invoke (proxy, "GetStuff", &error, - G_TYPE_INVALID, - G_TYPE_BOOLEAN, &boolret, - G_TYPE_STRING, &strret, - G_TYPE_INVALID)) + if (!dbus_g_proxy_call (proxy, "GetStuff", &error, + G_TYPE_INVALID, + G_TYPE_BOOLEAN, &boolret, + G_TYPE_STRING, &strret, + G_TYPE_INVALID)) { g_printerr ("Failed to complete GetStuff: %s\n", error->message); @@ -927,11 +927,11 @@ main (int argc, char **argv) strs_dynamic[3] = NULL; error = NULL; - if (!dbus_g_proxy_invoke (proxy, "TwoStrArrays", &error, - G_TYPE_STRV, strs_static_p, - G_TYPE_STRV, strs_dynamic, - G_TYPE_INVALID, - G_TYPE_INVALID)) + if (!dbus_g_proxy_call (proxy, "TwoStrArrays", &error, + G_TYPE_STRV, strs_static_p, + G_TYPE_STRV, strs_dynamic, + G_TYPE_INVALID, + G_TYPE_INVALID)) { g_printerr ("Failed to complete TwoStrArrays: %s\n", error->message); @@ -952,11 +952,11 @@ main (int argc, char **argv) error = NULL; blah = TRUE; - if (!dbus_g_proxy_invoke (proxy, "GetStrs", &error, - G_TYPE_BOOLEAN, blah, - G_TYPE_INVALID, - G_TYPE_STRV, &strs, - G_TYPE_INVALID)) + if (!dbus_g_proxy_call (proxy, "GetStrs", &error, + G_TYPE_BOOLEAN, blah, + G_TYPE_INVALID, + G_TYPE_STRV, &strs, + G_TYPE_INVALID)) { g_printerr ("Failed to complete GetStrs: %s\n", error->message); @@ -979,9 +979,9 @@ main (int argc, char **argv) g_value_set_string (&val, "hello world"); error = NULL; - if (!dbus_g_proxy_invoke (proxy, "SendVariant", &error, - G_TYPE_VALUE, &val, G_TYPE_INVALID, - G_TYPE_INVALID)) + if (!dbus_g_proxy_call (proxy, "SendVariant", &error, + G_TYPE_VALUE, &val, G_TYPE_INVALID, + G_TYPE_INVALID)) { g_printerr ("Failed to complete SendVariant: %s\n", error->message); @@ -1000,8 +1000,8 @@ main (int argc, char **argv) GValue val = {0, }; error = NULL; - if (!dbus_g_proxy_invoke (proxy, "GetVariant", &error, G_TYPE_INVALID, - G_TYPE_VALUE, &val, G_TYPE_INVALID)) + if (!dbus_g_proxy_call (proxy, "GetVariant", &error, G_TYPE_INVALID, + G_TYPE_VALUE, &val, G_TYPE_INVALID)) { g_printerr ("Failed to complete GetVariant: %s\n", error->message); diff --git a/glib/dbus-binding-tool-glib.c b/glib/dbus-binding-tool-glib.c index fd849a86..373faaff 100644 --- a/glib/dbus-binding-tool-glib.c +++ b/glib/dbus-binding-tool-glib.c @@ -1333,7 +1333,7 @@ generate_client_glue (BaseInfo *base, DBusBindingToolCData *data, GError **error WRITE_OR_LOSE ("{\n"); - if (!write_printf_to_iochannel (" return dbus_g_proxy_invoke (proxy, \"%s\", ", channel, error, + if (!write_printf_to_iochannel (" return dbus_g_proxy_call (proxy, \"%s\", ", channel, error, method_info_get_name (method))) goto io_lose; diff --git a/glib/dbus-gproxy.c b/glib/dbus-gproxy.c index 143b9a2b..f4fcc31f 100644 --- a/glib/dbus-gproxy.c +++ b/glib/dbus-gproxy.c @@ -1592,9 +1592,11 @@ dbus_g_proxy_end_call (DBusGProxy *proxy, } /** - * Function for invoking a method and receiving reply values. - * Normally this is not used directly - calls to it are generated - * from client-side wrappers (see dbus-binding-tool). + * Function for synchronously invoking a method and receiving reply + * values. This function is equivalent to dbus_g_proxy_begin_call + * followed by dbus_g_proxy_end_call. All of the input arguments are + * specified first, followed by G_TYPE_INVALID, followed by all of the + * output values, followed by G_TYPE_INVALID. * * @param proxy a proxy for a remote interface * @param method method to invoke @@ -1603,11 +1605,11 @@ dbus_g_proxy_end_call (DBusGProxy *proxy, * @returns #FALSE if an error is set, TRUE otherwise */ gboolean -dbus_g_proxy_invoke (DBusGProxy *proxy, - const char *method, - GError **error, - GType first_arg_type, - ...) +dbus_g_proxy_call (DBusGProxy *proxy, + const char *method, + GError **error, + GType first_arg_type, + ...) { gboolean ret; DBusGPendingCall *pending; diff --git a/test/glib/test-dbus-glib.c b/test/glib/test-dbus-glib.c index 1f979a27..ba979cb6 100644 --- a/test/glib/test-dbus-glib.c +++ b/test/glib/test-dbus-glib.c @@ -268,14 +268,14 @@ main (int argc, char **argv) /* Activate test servie */ g_print ("Activating TestSuiteGLibService\n"); error = NULL; - if (!dbus_g_proxy_invoke (driver, "StartServiceByName", &error, - G_TYPE_STRING, - "org.freedesktop.DBus.TestSuiteGLibService", - G_TYPE_UINT, - 0, - G_TYPE_INVALID, - G_TYPE_UINT, &result, - G_TYPE_INVALID)) { + if (!dbus_g_proxy_call (driver, "StartServiceByName", &error, + G_TYPE_STRING, + "org.freedesktop.DBus.TestSuiteGLibService", + G_TYPE_UINT, + 0, + G_TYPE_INVALID, + G_TYPE_UINT, &result, + G_TYPE_INVALID)) { lose_gerror ("Failed to complete Activate call", error); } @@ -304,11 +304,11 @@ main (int argc, char **argv) lose_gerror ("Failed to complete DoNothing call", error); error = NULL; - if (!dbus_g_proxy_invoke (proxy, "Increment", &error, - G_TYPE_UINT, 42, - G_TYPE_INVALID, - G_TYPE_UINT, &v_UINT32_2, - G_TYPE_INVALID)) + if (!dbus_g_proxy_call (proxy, "Increment", &error, + G_TYPE_UINT, 42, + G_TYPE_INVALID, + G_TYPE_UINT, &v_UINT32_2, + G_TYPE_INVALID)) lose_gerror ("Failed to complete Increment call", error); if (v_UINT32_2 != 43) @@ -678,8 +678,8 @@ main (int argc, char **argv) G_CALLBACK (frobnicate_signal_handler), NULL, NULL); - if (!dbus_g_proxy_invoke (proxy, "EmitFrobnicate", &error, - G_TYPE_INVALID, G_TYPE_INVALID)) + if (!dbus_g_proxy_call (proxy, "EmitFrobnicate", &error, + G_TYPE_INVALID, G_TYPE_INVALID)) lose_gerror ("Failed to complete EmitFrobnicate call", error); @@ -690,8 +690,8 @@ main (int argc, char **argv) if (n_times_frobnicate_received != 1) lose ("Frobnicate signal received %d times, should have been 1", n_times_frobnicate_received); - if (!dbus_g_proxy_invoke (proxy, "EmitFrobnicate", &error, - G_TYPE_INVALID, G_TYPE_INVALID)) + if (!dbus_g_proxy_call (proxy, "EmitFrobnicate", &error, + G_TYPE_INVALID, G_TYPE_INVALID)) lose_gerror ("Failed to complete EmitFrobnicate call", error); dbus_g_connection_flush (connection); -- cgit