diff options
author | Timm Bäder <mail@baedert.org> | 2016-04-22 14:01:09 +0200 |
---|---|---|
committer | Christophe Fergeau <cfergeau@redhat.com> | 2016-06-20 12:39:44 +0200 |
commit | f8c2ab720de6f7741f4af10f43b95d27c27ecc8e (patch) | |
tree | cb9654e290547d4a832da37a5db6e884ef5b5467 /examples | |
parent | 9cca799e77aaf60561c303dbb0dac3ce9d78a3dc (diff) | |
download | librest-f8c2ab720de6f7741f4af10f43b95d27c27ecc8e.tar.gz |
Adapt tests and examples to API change
Diffstat (limited to 'examples')
-rw-r--r-- | examples/test-raw.c | 23 | ||||
-rw-r--r-- | examples/test-xml.c | 42 |
2 files changed, 31 insertions, 34 deletions
diff --git a/examples/test-raw.c b/examples/test-raw.c index d8daa93..3e6a437 100644 --- a/examples/test-raw.c +++ b/examples/test-raw.c @@ -4,7 +4,7 @@ * * Authors: Rob Bradford <rob@linux.intel.com> * Ross Burton <ross@linux.intel.com> - * + * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU Lesser General Public License, * version 2.1, as published by the Free Software Foundation. @@ -24,18 +24,18 @@ #include <unistd.h> static void -proxy_call_async_cb (RestProxyCall *call, - const GError *error, - GObject *weak_object, - gpointer userdata) +proxy_call_async_cb (GObject *source_object, + GAsyncResult *result, + gpointer user_data) { + RestProxyCall *call = REST_PROXY_CALL (source_object); const gchar *payload; goffset len; payload = rest_proxy_call_get_payload (call); len = rest_proxy_call_get_payload_length (call); write (1, payload, len); - g_main_loop_quit ((GMainLoop *)userdata); + g_main_loop_quit ((GMainLoop *)user_data); } gint @@ -56,15 +56,14 @@ main (gint argc, gchar **argv) "api_key", "314691be2e63a4d58994b2be01faacfb", "format", "json", NULL); - rest_proxy_call_async (call, - proxy_call_async_cb, - NULL, - loop, - NULL); + rest_proxy_call_invoke_async (call, + NULL, + proxy_call_async_cb, + loop); g_main_loop_run (loop); - rest_proxy_call_run (call, NULL, NULL); + rest_proxy_call_sync (call, NULL); payload = rest_proxy_call_get_payload (call); len = rest_proxy_call_get_payload_length (call); diff --git a/examples/test-xml.c b/examples/test-xml.c index 79f76aa..e3833de 100644 --- a/examples/test-xml.c +++ b/examples/test-xml.c @@ -4,7 +4,7 @@ * * Authors: Rob Bradford <rob@linux.intel.com> * Ross Burton <ross@linux.intel.com> - * + * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU Lesser General Public License, * version 2.1, as published by the Free Software Foundation. @@ -64,11 +64,11 @@ _rest_xml_node_output (RestXmlNode *node, gint depth) do { attrs_output = _generate_attrs_output (node->attrs); - g_print ("%*s[%s, %s, %s]\n", - depth, - "", - node->name, - node->content, + g_print ("%*s[%s, %s, %s]\n", + depth, + "", + node->name, + node->content, attrs_output); g_free (attrs_output); values = g_hash_table_get_values (node->children); @@ -83,11 +83,11 @@ _rest_xml_node_output (RestXmlNode *node, gint depth) } static void -proxy_call_raw_async_cb (RestProxyCall *call, - const GError *error, - GObject *weak_object, - gpointer userdata) +proxy_call_raw_async_cb (GObject *source_object, + GAsyncResult *result, + gpointer user_data) { + RestProxyCall *call = REST_PROXY_CALL (source_object); RestXmlParser *parser; RestXmlNode *node; const gchar *payload; @@ -103,7 +103,7 @@ proxy_call_raw_async_cb (RestProxyCall *call, _rest_xml_node_output (node, 0); rest_xml_node_unref (node); g_object_unref (parser); - g_main_loop_quit ((GMainLoop *)userdata); + g_main_loop_quit ((GMainLoop *)user_data); } gint @@ -123,11 +123,10 @@ main (gint argc, gchar **argv) "api_key", "314691be2e63a4d58994b2be01faacfb", "photo_id", "2658808091", NULL); - rest_proxy_call_async (call, - proxy_call_raw_async_cb, - NULL, - loop, - NULL); + rest_proxy_call_invoke_async (call, + NULL, + proxy_call_raw_async_cb, + loop); g_main_loop_run (loop); g_object_unref (call); @@ -137,13 +136,12 @@ main (gint argc, gchar **argv) rest_proxy_call_add_params (call, "method", "flickr.people.getPublicPhotos", "api_key", "314691be2e63a4d58994b2be01faacfb", - "user_id","66598853@N00", + "user_id","66598853@N00", NULL); - rest_proxy_call_async (call, - proxy_call_raw_async_cb, - NULL, - loop, - NULL); + rest_proxy_call_invoke_async (call, + NULL, + proxy_call_raw_async_cb, + loop); g_main_loop_run (loop); g_object_unref (call); |