diff options
author | Rob Bradford <rob@linux.intel.com> | 2008-11-20 12:08:14 +0000 |
---|---|---|
committer | Rob Bradford <rob@linux.intel.com> | 2008-11-20 12:08:14 +0000 |
commit | a33e86af319e0e533dcf21822d2ade1064b5636a (patch) | |
tree | cdeee1e2057e937f407cb4d71c118dcca5b2eef9 /examples | |
parent | daf5d9b64987530abf631066254f0a16414520d3 (diff) | |
download | librest-a33e86af319e0e533dcf21822d2ade1064b5636a.tar.gz |
Remove use of deprecated functions
Diffstat (limited to 'examples')
-rw-r--r-- | examples/test-raw.c | 67 | ||||
-rw-r--r-- | examples/test-xml.c | 76 |
2 files changed, 65 insertions, 78 deletions
diff --git a/examples/test-raw.c b/examples/test-raw.c index 3be6680..5ca2e2a 100644 --- a/examples/test-raw.c +++ b/examples/test-raw.c @@ -2,15 +2,16 @@ #include <unistd.h> static void -proxy_call_raw_async_cb (RestProxy *proxy, - guint status_code, - const gchar *response_message, - GHashTable *headers, - const gchar *payload, - gssize len, - GObject *weak_object, - gpointer userdata) +proxy_call_async_cb (RestProxyCall *call, + GError *error, + GObject *weak_object, + gpointer userdata) { + 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); } @@ -19,8 +20,9 @@ gint main (gint argc, gchar **argv) { RestProxy *proxy; + RestProxyCall *call; GMainLoop *loop; - gchar *payload; + const gchar *payload; gssize len; g_type_init (); @@ -29,39 +31,26 @@ main (gint argc, gchar **argv) loop = g_main_loop_new (NULL, FALSE); proxy = rest_proxy_new ("http://www.flickr.com/services/rest/", FALSE); - rest_proxy_call_raw_async (proxy, - NULL, - "GET", - proxy_call_raw_async_cb, - NULL, - loop, - NULL, - "method", - "flickr.test.echo", - "api_key", - "314691be2e63a4d58994b2be01faacfb", - "format", - "json", - NULL); + call = rest_proxy_new_call (proxy); + rest_proxy_call_add_params (call, + "method", "flickr.test.echo", + "api_key", "314691be2e63a4d58994b2be01faacfb", + "format", "json", + NULL); + rest_proxy_call_async (call, + proxy_call_async_cb, + NULL, + loop, + NULL); g_main_loop_run (loop); - rest_proxy_run_raw (proxy, - NULL, - "GET", - NULL, - NULL, - NULL, - &payload, - &len, - NULL, - "method", - "flickr.test.echo", - "api_key", - "314691be2e63a4d58994b2be01faacfb", - "format", - "json", - NULL); + rest_proxy_call_run (call, NULL, NULL); + payload = rest_proxy_call_get_payload (call); + len = rest_proxy_call_get_payload_length (call); write (1, payload, len); + + g_object_unref (call); + g_object_unref (proxy); } diff --git a/examples/test-xml.c b/examples/test-xml.c index 5c87483..0650fed 100644 --- a/examples/test-xml.c +++ b/examples/test-xml.c @@ -61,20 +61,21 @@ _rest_xml_node_output (RestXmlNode *node, gint depth) } static void -proxy_call_raw_async_cb (RestProxy *proxy, - guint status_code, - const gchar *response_message, - GHashTable *headers, - const gchar *payload, - goffset len, - GObject *weak_object, - gpointer userdata) +proxy_call_raw_async_cb (RestProxyCall *call, + GError *error, + GObject *weak_object, + gpointer userdata) { RestXmlParser *parser; RestXmlNode *node; + const gchar *payload; + goffset len; write (1, payload, len); parser = rest_xml_parser_new (); + + payload = rest_proxy_call_get_payload (call); + len = rest_proxy_call_get_payload_length (call); node = rest_xml_parser_parse_from_data (parser, payload, len); _rest_xml_node_output (node, 0); @@ -87,6 +88,7 @@ gint main (gint argc, gchar **argv) { RestProxy *proxy; + RestProxyCall *call; GMainLoop *loop; gchar *payload; gssize len; @@ -97,41 +99,37 @@ main (gint argc, gchar **argv) loop = g_main_loop_new (NULL, FALSE); proxy = rest_proxy_new ("http://www.flickr.com/services/rest/", FALSE); - rest_proxy_call_raw_async (proxy, - NULL, - "GET", - proxy_call_raw_async_cb, - NULL, - loop, - NULL, - "method", - "flickr.photos.getInfo", - "api_key", - "314691be2e63a4d58994b2be01faacfb", - "photo_id", - "2658808091", - NULL); + call = rest_proxy_new_call (proxy); + rest_proxy_call_set_method (call, "GET"); + rest_proxy_call_add_params (call, + "method", "flickr.photos.getInfo", + "api_key", "314691be2e63a4d58994b2be01faacfb", + "photo_id", "2658808091", + NULL); + rest_proxy_call_async (call, + proxy_call_raw_async_cb, + NULL, + loop, + NULL); g_main_loop_run (loop); - g_object_unref (proxy); - - proxy = rest_proxy_new ("http://www.flickr.com/services/rest/", FALSE); - rest_proxy_call_raw_async (proxy, - NULL, - "GET", - proxy_call_raw_async_cb, - NULL, - loop, - NULL, - "method", - "flickr.people.getPublicPhotos", - "api_key", - "314691be2e63a4d58994b2be01faacfb", - "user_id", - "66598853@N00", - NULL); + g_object_unref (call); + + call = rest_proxy_new_call (proxy); + rest_proxy_call_set_method (call, "GET"); + rest_proxy_call_add_params (call, + "method", "flickr.people.getPublicPhotos", + "api_key", "314691be2e63a4d58994b2be01faacfb", + "user_id","66598853@N00", + NULL); + rest_proxy_call_async (call, + proxy_call_raw_async_cb, + NULL, + loop, + NULL); g_main_loop_run (loop); + g_object_unref (call); g_object_unref (proxy); g_main_loop_unref (loop); |