[PATCH plugins 12/14] podcasts: use GrlNet
- From: Víctor Manuel Jáquez Leal <vjaquez igalia com>
- To: grilo-list gnome org
- Subject: [PATCH plugins 12/14] podcasts: use GrlNet
- Date: Mon, 4 Oct 2010 21:16:22 +0200
Signed-off-by: Víctor Manuel Jáquez Leal <vjaquez igalia com>
---
configure.ac | 6 ++--
src/podcasts/Makefile.am | 6 ++--
src/podcasts/grl-podcasts.c | 48 ++++++++++++++++++++++++------------------
3 files changed, 33 insertions(+), 27 deletions(-)
diff --git a/configure.ac b/configure.ac
index b78780c..17d1e67 100644
--- a/configure.ac
+++ b/configure.ac
@@ -400,8 +400,8 @@ AC_ARG_ENABLE(podcasts,
[
case "$enableval" in
yes)
- if test "x$HAVE_GIO" = "xno"; then
- AC_MSG_ERROR([GIO not found, install it or use --disable-podcasts])
+ if test "x$HAVE_GRLNET" = "xno"; then
+ AC_MSG_ERROR([grilo-net not found, install it or use --disable-podcasts])
fi
if test "x$HAVE_XML" = "xno"; then
AC_MSG_ERROR([xml2 not found, install it or use --disable-podcasts])
@@ -413,7 +413,7 @@ AC_ARG_ENABLE(podcasts,
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
if test "x$HAVE_SQLITE" = "xyes"; then
enable_podcasts=yes
else
diff --git a/src/podcasts/Makefile.am b/src/podcasts/Makefile.am
index 9404254..09d5913 100644
--- a/src/podcasts/Makefile.am
+++ b/src/podcasts/Makefile.am
@@ -9,19 +9,19 @@ lib_LTLIBRARIES = libgrlpodcasts.la
libgrlpodcasts_la_CFLAGS = \
$(DEPS_CFLAGS) \
- $(GIO_CFLAGS) \
+ $(GRLNET_CFLAGS) \
$(XML_CFLAGS) \
$(SQLITE_CFLAGS)
libgrlpodcasts_la_LIBADD = \
$(DEPS_LIBS) \
- $(GIO_LIBS) \
+ $(GRLNET_LIBS) \
$(XML_LIBS) \
$(SQLITE_LIBS)
libgrlpodcasts_la_SOURCES = grl-podcasts.c grl-podcasts.h
-libdir=$(GRL_PLUGINS_DIR)
+libdir = $(GRL_PLUGINS_DIR)
podcastsxmldir = $(GRL_PLUGINS_CONF_DIR)
podcastsxml_DATA = $(PODCASTS_PLUGIN_ID).xml
diff --git a/src/podcasts/grl-podcasts.c b/src/podcasts/grl-podcasts.c
index 74629f2..ba6451a 100644
--- a/src/podcasts/grl-podcasts.c
+++ b/src/podcasts/grl-podcasts.c
@@ -25,7 +25,7 @@
#endif
#include <grilo.h>
-#include <gio/gio.h>
+#include <net/grl-net.h>
#include <libxml/parser.h>
#include <libxml/xpath.h>
#include <sqlite3.h>
@@ -187,6 +187,7 @@ typedef struct {
struct _GrlPodcastsPrivate {
sqlite3 *db;
+ GrlNetWc *wc;
};
typedef struct {
@@ -351,6 +352,9 @@ grl_podcasts_source_finalize (GObject *object)
source = GRL_PODCASTS_SOURCE (object);
+ if (source->priv->wc)
+ g_object_unref (source->priv->wc);
+
sqlite3_close (source->priv->db);
G_OBJECT_CLASS (grl_podcasts_source_parent_class)->finalize (object);
@@ -388,21 +392,19 @@ read_done_cb (GObject *source_object,
gpointer user_data)
{
AsyncReadCb *arc = (AsyncReadCb *) user_data;
- GError *vfs_error = NULL;
+ GError *wc_error = NULL;
gchar *content = NULL;
GRL_DEBUG (" Done");
- g_file_load_contents_finish (G_FILE (source_object),
- res,
- &content,
- NULL,
- NULL,
- &vfs_error);
- g_object_unref (source_object);
- if (vfs_error) {
- GRL_WARNING ("Failed to open '%s': %s", arc->url, vfs_error->message);
- g_error_free (vfs_error);
+ grl_net_wc_request_finish (GRL_NET_WC (source_object),
+ res,
+ &content,
+ NULL,
+ &wc_error);
+ if (wc_error) {
+ GRL_WARNING ("Failed to open '%s': %s", arc->url, wc_error->message);
+ g_error_free (wc_error);
} else {
arc->callback (content, arc->user_data);
}
@@ -411,24 +413,29 @@ read_done_cb (GObject *source_object,
}
static void
-read_url_async (const gchar *url,
+read_url_async (GrlPodcastsSource *source,
+ const gchar *url,
AsyncReadCbFunc callback,
gpointer user_data)
{
- GVfs *vfs;
- GFile *uri;
AsyncReadCb *arc;
- vfs = g_vfs_get_default ();
-
GRL_DEBUG ("Opening async '%s'", url);
arc = g_slice_new0 (AsyncReadCb);
arc->url = g_strdup (url);
arc->callback = callback;
arc->user_data = user_data;
- uri = g_vfs_get_file_for_uri (vfs, url);
- g_file_load_contents_async (uri, NULL, read_done_cb, arc);
+
+ /* We would need a different Wc if we change of URL.
+ * In this case, as we don't know the previous URL,
+ * we ditch the Wc and create another. It's cheap.
+ */
+ if (!source->priv->wc)
+ g_object_unref (source->priv->wc);
+
+ source->priv->wc = grl_net_wc_new ();
+ grl_net_wc_request_async (source->priv->wc, url, NULL, read_done_cb, arc);
}
static gint
@@ -1074,7 +1081,6 @@ read_feed_cb (gchar *xmldata, gpointer user_data)
"Failed to read data from podcast");
} else {
parse_feed (os, xmldata, &error);
- g_free (xmldata);
}
if (error) {
@@ -1149,7 +1155,7 @@ produce_podcast_contents (OperationSpec *os)
/* We have to read the podcast feed again */
GRL_DEBUG ("Refreshing podcast '%s'...", os->media_id);
url = g_strdup ((gchar *) sqlite3_column_text (sql_stmt, PODCAST_URL));
- read_url_async (url, read_feed_cb, os);
+ read_url_async (GRL_PODCASTS_SOURCE (os->source), url, read_feed_cb, os);
g_free (url);
} else {
/* We can read the podcast entries from the database cache */
--
1.7.1
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]