diff options
author | Víctor Manuel Jáquez Leal <vjaquez@igalia.com> | 2010-09-21 20:10:56 +0200 |
---|---|---|
committer | Víctor Manuel Jáquez Leal <vjaquez@igalia.com> | 2010-10-13 12:05:59 +0200 |
commit | 00ccae79dd25109f107e17da9e4b2f0121116ee0 (patch) | |
tree | 16c06beecc6ab52e60be9a0059224e7960897cb5 | |
parent | 641155d47de4ef9427473fe7be7f1f5b38ba9b8e (diff) | |
download | grilo-plugins-00ccae79dd25109f107e17da9e4b2f0121116ee0.tar.gz |
flickr: add GrlNet
Signed-off-by: Víctor Manuel Jáquez Leal <vjaquez@igalia.com>
-rw-r--r-- | configure.ac | 6 | ||||
-rw-r--r-- | src/flickr/Makefile.am | 4 | ||||
-rw-r--r-- | src/flickr/gflickr.c | 57 |
3 files changed, 40 insertions, 27 deletions
diff --git a/configure.ac b/configure.ac index 388f108..a2eb78d 100644 --- a/configure.ac +++ b/configure.ac @@ -362,8 +362,8 @@ AC_ARG_ENABLE(flickr, [ case "$enableval" in yes) - if test "x$HAVE_GIO" = "xno"; then - AC_MSG_ERROR([GIO not found, install it or use --disable-flickr]) + if test "x$HAVE_GRLNET" = "xno"; then + AC_MSG_ERROR([grilo-net not found, install it or use --disable-flickr]) fi if test "x$HAVE_XML" = "xno"; then AC_MSG_ERROR([xml2 not found, install it or use --disable-flickr]) @@ -372,7 +372,7 @@ AC_ARG_ENABLE(flickr, esac ], [ - if test "x$HAVE_GIO" = "xyes" -a "x$HAVE_XML" = "xyes"; then + if test "x$HAVE_GRLNET" = "xyes" -a "x$HAVE_XML" = "xyes"; then enable_flickr=yes else enable_flickr=no diff --git a/src/flickr/Makefile.am b/src/flickr/Makefile.am index c195adb..3371acb 100644 --- a/src/flickr/Makefile.am +++ b/src/flickr/Makefile.am @@ -10,12 +10,12 @@ libplugin_LTLIBRARIES = libgrlflickr.la libgrlflickr_la_CFLAGS = \ $(DEPS_CFLAGS) \ $(XML_CFLAGS) \ - $(GIO_CFLAGS) + $(GRLNET_CFLAGS) libgrlflickr_la_LIBADD = \ $(DEPS_LIBS) \ $(XML_LIBS) \ - $(GIO_LIBS) + $(GRLNET_LIBS) libgrlflickr_la_LDFLAGS = \ -module \ diff --git a/src/flickr/gflickr.c b/src/flickr/gflickr.c index 9a51a68..447ef61 100644 --- a/src/flickr/gflickr.c +++ b/src/flickr/gflickr.c @@ -7,6 +7,7 @@ #include <string.h> #include <grilo.h> +#include <net/grl-net.h> #define G_FLICKR_GET_PRIVATE(object) \ @@ -127,6 +128,8 @@ struct _GFlickrPrivate { gchar *auth_secret; gchar *auth_token; gint per_page; + + GrlNetWc *wc; }; static void g_flickr_finalize (GObject *object); @@ -159,6 +162,9 @@ g_flickr_finalize (GObject *object) g_free (f->priv->auth_token); g_free (f->priv->auth_secret); + if (f->priv->wc) + g_object_unref (f->priv->wc); + G_OBJECT_CLASS (g_flickr_parent_class)->finalize (object); } @@ -567,37 +573,44 @@ process_token_result (const gchar *xml_result, gpointer user_data) xmlFreeDoc (doc); } +inline static GrlNetWc * +get_wc (GFlickr *f) +{ + if (!f->priv->wc) + f->priv->wc = grl_net_wc_new (); + + return f->priv->wc; +} + static void read_done_cb (GObject *source_object, GAsyncResult *res, gpointer user_data) { gchar *content = NULL; + GError *wc_error = NULL; GFlickrData *data = (GFlickrData *) user_data; - g_file_load_contents_finish (G_FILE (source_object), - res, - &content, - NULL, - NULL, - NULL); - - g_object_unref (source_object); + grl_net_wc_request_finish (GRL_NET_WC (source_object), + res, + &content, + NULL, + &wc_error); data->parse_xml (content, user_data); - g_free (content); } static void -read_url_async (const gchar *url, gpointer data) +read_url_async (GFlickr *f, + const gchar *url, + gpointer user_data) { - GVfs *vfs; - GFile *uri; - - vfs = g_vfs_get_default (); GRL_DEBUG ("Opening '%s'", url); - uri = g_vfs_get_file_for_uri (vfs, url); - g_file_load_contents_async (uri, NULL, read_done_cb, data); + grl_net_wc_request_async (get_wc (f), + url, + NULL, + read_done_cb, + user_data); } /* -------------------- PUBLIC API -------------------- */ @@ -651,7 +664,7 @@ g_flickr_photos_getInfo (GFlickr *f, gfd->hashtable_cb = callback; gfd->user_data = user_data; - read_url_async (request, gfd); + read_url_async (f, request, gfd); g_free (request); } @@ -723,7 +736,7 @@ g_flickr_photos_search (GFlickr *f, gfd->list_cb = callback; gfd->user_data = user_data; - read_url_async (request, gfd); + read_url_async (f, request, gfd); g_free (request); } @@ -855,7 +868,7 @@ g_flickr_tags_getHotList (GFlickr *f, gfd->list_cb = callback; gfd->user_data = user_data; - read_url_async (request, gfd); + read_url_async (f, request, gfd); g_free (request); } @@ -906,7 +919,7 @@ g_flickr_photosets_getList (GFlickr *f, gfd->list_cb = callback; gfd->user_data = user_data; - read_url_async (request, gfd); + read_url_async (f, request, gfd); g_free (request); } @@ -963,7 +976,7 @@ g_flickr_photosets_getPhotos (GFlickr *f, gfd->list_cb = callback; gfd->user_data = user_data; - read_url_async (request, gfd); + read_url_async (f, request, gfd); g_free (request); } @@ -1117,6 +1130,6 @@ g_flickr_auth_checkToken (GFlickr *f, gfd->hashtable_cb = callback; gfd->user_data = user_data; - read_url_async (request, gfd); + read_url_async (f, request, gfd); g_free (request); } |