if (dbus_g_type_is_map (gtype))
return "GHashTable";
- if (g_type_is_a (gtype, G_TYPE_STRING)
- || g_type_is_a (gtype, DBUS_TYPE_G_OBJECT_PATH))
+ if (g_type_is_a (gtype, G_TYPE_STRING))
return "char *";
/* This one is even more hacky...we get an extra *
*/
if (g_type_is_a (gtype, G_TYPE_STRV))
return "char *";
+ if (g_type_is_a (gtype, DBUS_TYPE_G_OBJECT_PATH))
+ return "char";
return g_type_name (gtype);
}
method_name = compute_client_method_name (iface_prefix, method);
/* Write the typedef for the client callback */
- if (!write_printf_to_iochannel ("typedef void (*%s_reply) (", channel, error, method_name))
+ if (!write_printf_to_iochannel ("typedef void (*%s_reply) (DBusGProxy *proxy, ", channel, error, method_name))
goto io_lose;
{
GSList *args;
/* Write the callback when the call returns */
WRITE_OR_LOSE ("static void\n");
- if (!write_printf_to_iochannel ("%s_async_callback (DBusGPendingCall *pending, DBusGAsyncData *data)\n", channel, error, method_name))
+ if (!write_printf_to_iochannel ("%s_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)\n", channel, error, method_name))
goto io_lose;
WRITE_OR_LOSE ("{\n");
- WRITE_OR_LOSE (" GError *error = NULL;\n");
+ WRITE_OR_LOSE (" DBusGAsyncData *data = user_data;\n GError *error = NULL;\n");
if (!write_formal_declarations_for_direction (interface, method, channel, ARG_OUT, error))
goto io_lose;
- WRITE_OR_LOSE (" dbus_g_proxy_end_call (data->proxy, pending, &error, ");
+ /* TODO: handle return boolean of end_call */
+ WRITE_OR_LOSE (" dbus_g_proxy_end_call (proxy, call, &error, ");
if (!write_typed_args_for_direction (interface, method, channel, ARG_OUT, error))
goto io_lose;
WRITE_OR_LOSE("G_TYPE_INVALID);\n");
- if (!write_printf_to_iochannel (" (*(%s_reply)data->cb) (", channel, error, method_name))
+ if (!write_printf_to_iochannel (" (*(%s_reply)data->cb) (proxy, ", channel, error, method_name))
goto io_lose;
if (!write_untyped_out_args (interface, method, channel, error))
goto io_lose;
/* Write the main wrapper function */
- WRITE_OR_LOSE ("static\n#ifdef G_HAVE_INLINE\ninline\n#endif\ngboolean\n");
+ WRITE_OR_LOSE ("static\n#ifdef G_HAVE_INLINE\ninline\n#endif\nDBusGProxyCall*\n");
if (!write_printf_to_iochannel ("%s_async (DBusGProxy *proxy", channel, error,
method_name))
goto io_lose;
goto io_lose;
WRITE_OR_LOSE ("{\n");
- WRITE_OR_LOSE (" DBusGPendingCall *pending;\n DBusGAsyncData *stuff;\n stuff = g_new (DBusGAsyncData, 1);\n stuff->proxy = proxy;\n stuff->cb = callback;\n stuff->userdata = userdata;\n");
- if (!write_printf_to_iochannel (" pending = dbus_g_proxy_begin_call (proxy, \"%s\", ", channel, error, method_info_get_name (method)))
+ WRITE_OR_LOSE (" DBusGAsyncData *stuff;\n stuff = g_new (DBusGAsyncData, 1);\n stuff->cb = G_CALLBACK (callback);\n stuff->userdata = userdata;\n");
+ if (!write_printf_to_iochannel (" return dbus_g_proxy_begin_call (proxy, \"%s\", %s_async_callback, stuff, g_free, ", channel, error, method_info_get_name (method), method_name))
goto io_lose;
if (!write_args_for_direction (interface, method, channel, ARG_IN, error))
goto io_lose;
- WRITE_OR_LOSE ("G_TYPE_INVALID);\n");
-
- if (!write_printf_to_iochannel (" dbus_g_pending_call_set_notify(pending, (DBusGPendingCallNotify)%s_async_callback, stuff, g_free);\n", channel, error, method_name))
- goto io_lose;
-
- WRITE_OR_LOSE (" return TRUE;\n}\n\n");
+ WRITE_OR_LOSE ("G_TYPE_INVALID);\n}\n");
g_free (method_name);
return TRUE;
WRITE_OR_LOSE ("G_TYPE_INVALID);\n}\n\n");
-#if 0
write_async_method_client (channel, interface, method, error);
-#endif
}
if (!write_printf_to_iochannel ("#endif /* defined DBUS_GLIB_CLIENT_WRAPPERS_%s */\n\n", channel, error, iface_prefix))
G_TYPE_INVALID))
lose_gerror ("Failed to complete async Echo", error);
g_assert (echo_data != NULL);
- g_print ("Async echo gave \"%s\"", echo_data);
+ g_print ("Async echo gave \"%s\"\n", echo_data);
g_free (echo_data);
g_main_loop_quit (loop);
g_source_remove (exit_timeout);
if (val != 43)
lose ("Increment call returned %d, should be 43", val);
- g_print ("Async increment gave \"%d\"", val);
+ g_print ("Async increment gave \"%d\"\n", val);
g_main_loop_quit (loop);
g_source_remove (exit_timeout);
}
static void
+increment_async_cb (DBusGProxy *proxy, guint val, GError *error, gpointer data)
+{
+ if (error)
+ lose_gerror ("Failed to complete (wrapped async) Increment call", error);
+
+ if (data != NULL)
+ lose ("(wrapped async) Increment call gave unexpected data");
+ if (val != 43)
+ lose ("(wrapped async) Increment call returned %d, should be 43", val);
+
+ g_print ("(wrapped async) increment gave \"%d\"\n", val);
+ g_main_loop_quit (loop);
+ g_source_remove (exit_timeout);
+}
+
+
+static void
lose (const char *str, ...)
{
va_list args;
if (v_UINT32_2 != 43)
lose ("(wrapped) increment call returned %d, should be 43", v_UINT32_2);
+ g_print ("Calling (wrapped async) increment\n");
+ if (!org_freedesktop_DBus_Tests_MyObject_increment_async (proxy, 42, increment_async_cb, NULL))
+ lose_gerror ("Failed to complete (wrapped) Increment call", error);
+ dbus_g_connection_flush (connection);
+ exit_timeout = g_timeout_add (5000, timed_exit, loop);
+ g_main_loop_run (loop);
+
v_UINT32_2 = 0;
if (!org_freedesktop_DBus_Tests_MyObject_async_increment (proxy, 42, &v_UINT32_2, &error))
lose_gerror ("Failed to complete (wrapped) AsyncIncrement call", error);