diff options
author | Alan F <ajf@eth0.org.uk> | 2014-04-13 17:36:26 +0100 |
---|---|---|
committer | Alan F <ajf@eth0.org.uk> | 2014-04-13 17:36:26 +0100 |
commit | 91356636c1e2d02a76ff31189e106de53b569c49 (patch) | |
tree | 57e56f6fddec9a40451a345727eb3822e2291dd6 | |
parent | ec6a252a019e90ecc6825078ee7d79a24b82770f (diff) |
bundle the libmrss wrapper to make building easier
-rw-r--r-- | Makefile.am | 2 | ||||
-rw-r--r-- | configure.ac | 31 | ||||
-rw-r--r-- | extern/Makefile.am | 3 | ||||
-rw-r--r-- | extern/rss-glib/Makefile.am | 43 | ||||
-rw-r--r-- | extern/rss-glib/rss-document-private.h | 58 | ||||
-rw-r--r-- | extern/rss-glib/rss-document.c | 1085 | ||||
-rw-r--r-- | extern/rss-glib/rss-document.h | 105 | ||||
-rw-r--r-- | extern/rss-glib/rss-glib.h | 9 | ||||
-rw-r--r-- | extern/rss-glib/rss-item-private.h | 46 | ||||
-rw-r--r-- | extern/rss-glib/rss-item.c | 738 | ||||
-rw-r--r-- | extern/rss-glib/rss-item.h | 95 | ||||
-rw-r--r-- | extern/rss-glib/rss-parser-private.h | 45 | ||||
-rw-r--r-- | extern/rss-glib/rss-parser.c | 334 | ||||
-rw-r--r-- | extern/rss-glib/rss-parser.h | 102 | ||||
-rw-r--r-- | extern/rss-glib/rss-version.h | 96 | ||||
-rw-r--r-- | m4/gconf-2.m4 | 44 | ||||
-rw-r--r-- | src/Makefile.am | 15 | ||||
-rw-r--r-- | src/trg-main-window.c | 10 | ||||
-rw-r--r-- | src/trg-menu-bar.c | 12 | ||||
-rw-r--r-- | src/trg-preferences-dialog.c | 4 | ||||
-rw-r--r-- | src/trg-rss-cell-renderer.c | 2 | ||||
-rw-r--r-- | src/trg-rss-cell-renderer.h | 2 | ||||
-rw-r--r-- | src/trg-rss-model.c | 2 | ||||
-rw-r--r-- | src/trg-rss-model.h | 2 | ||||
-rw-r--r-- | src/trg-rss-window.c | 2 | ||||
-rw-r--r-- | src/trg-rss-window.h | 2 |
26 files changed, 2810 insertions, 79 deletions
diff --git a/Makefile.am b/Makefile.am index 137915e..f0b6dfd 100644 --- a/Makefile.am +++ b/Makefile.am @@ -19,7 +19,7 @@ ACLOCAL_AMFLAGS = -I m4 AUTOMAKE_OPTIONS = foreign -SUBDIRS = src po +SUBDIRS = extern src po DISTCLEANFILES = \ intltool-extract \ diff --git a/configure.ac b/configure.ac index 16e7214..8fb7ec4 100644 --- a/configure.ac +++ b/configure.ac @@ -21,12 +21,11 @@ AC_PREREQ(2.63) AC_INIT(transmission-remote-gtk, 1.1.1, alan@eth0.org.uk) AC_CONFIG_SRCDIR(src) -AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION) AM_INIT_AUTOMAKE([foreign]) AC_CONFIG_HEADERS([config.h]) AC_CONFIG_MACRO_DIR([m4]) -m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])]) +#m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])]) AC_PROG_CC AM_PROG_CC_C_O @@ -73,8 +72,8 @@ AM_CONDITIONAL([HAVE_GEOIP], [test "x$have_geoip" = "xyes"]) AC_ARG_WITH([libnotify], AC_HELP_STRING([--without-libnotify], [disable libnotify])) have_libnotify=no -AC_ARG_WITH([librssglib], AC_HELP_STRING([--without-rssglib], [disable rssglib support])) -have_librssglib=no +AC_ARG_WITH([libmrss], AC_HELP_STRING([--without-libmrss], [disable RSS support])) +have_libmrss=no AC_ARG_WITH([libproxy], AC_HELP_STRING([--without-libproxy], [disable libproxy])) have_libproxy=no AC_ARG_WITH([libappindicator], AC_HELP_STRING([--without-libappindicator], [disable libappindicator])) @@ -84,14 +83,26 @@ if test x$with_libnotify != xno; then PKG_CHECK_MODULES([notify], [libnotify], AC_DEFINE(HAVE_LIBNOTIFY, 1, [Define if libnotify is available]), AC_MSG_WARN([libnotify is required for popup desktop notifications])) fi -if test x$with_librssglib != xno; then - PKG_CHECK_MODULES([rssglib], [rss-glib-1.0], AC_DEFINE(HAVE_RSSGLIB, 1, [Define if rss-glib is available]), AC_MSG_WARN([rss-glib is required for RSS viewer functionality])) -fi - +#if test x$with_librssglib != xno; then +# PKG_CHECK_MODULES([rssglib], [rss-glib-1.0], AC_DEFINE(HAVE_RSSGLIB, 1, [Define if rss-glib is available]), AC_MSG_WARN([rss-glib is required for RSS viewer functionality])) +#fi +# if test x$with_libproxy != xno; then PKG_CHECK_MODULES([libproxy], [libproxy-1.0], AC_DEFINE(HAVE_LIBPROXY, 1, [Define if libproxy is available]), AC_MSG_WARN([libproxy is required for HTTP proxy support])) fi +if test x$with_libmrss != xno; then + PKG_CHECK_MODULES([mrss], [mrss >= 0.18], [ have_libmrss="yes" ], [ have_libmrss="no" ]) +fi + +if test x$have_libmrss == xyes; then + AC_DEFINE(HAVE_RSS, 1, [Define if RSS features available]) +else + AC_MSG_WARN([libmrss is required for RSS reader]) +fi + +AM_CONDITIONAL([HAVE_RSS], [test x$have_libmrss == xyes ]) + AC_ARG_ENABLE(debug, [AS_HELP_STRING(--enable-debug, [enable debugging])]) if test x$enable_debug = xyes; then @@ -126,4 +137,6 @@ TRG_GTK3_CONFIGURE() PKG_CHECK_MODULES([libcurl], [libcurl]) PKG_CHECK_MODULES([gio], [gio-2.0 >= 2.22]) -AC_OUTPUT([Makefile po/Makefile.in src/Makefile]) +#AM_PATH_GLIB_2_0 + +AC_OUTPUT([Makefile po/Makefile.in src/Makefile extern/Makefile extern/rss-glib/Makefile]) diff --git a/extern/Makefile.am b/extern/Makefile.am new file mode 100644 index 0000000..f6e94d1 --- /dev/null +++ b/extern/Makefile.am @@ -0,0 +1,3 @@ +if HAVE_RSS +SUBDIRS = rss-glib +endif diff --git a/extern/rss-glib/Makefile.am b/extern/rss-glib/Makefile.am new file mode 100644 index 0000000..c5909e3 --- /dev/null +++ b/extern/rss-glib/Makefile.am @@ -0,0 +1,43 @@ +NULL = + +AM_CFLAGS = \ + -I. \ + -DPREFIX=\""$(prefix)"\" \ + -DLIBDIR=\""$(libdir)"\" \ + -DG_LOG_DOMAIN=\"Rss\" \ + $(gtk_CFLAGS) \ + $(MRSS_CFLAGS) \ + $(NULL) + +source_h = \ + rss-parser.h \ + rss-document.h \ + rss-item.h \ + rss-version.h \ + $(NULL) + +source_h_private = \ + rss-document-private.h \ + rss-item-private.h \ + rss-parser-private.h \ + $(NULL) + +source_c = \ + rss-parser.c \ + rss-document.c \ + rss-item.c \ + $(NULL) + +noinst_LTLIBRARIES = librss.la + +librss_la_LIBADD = $(MRSS_LIBS) +librss_la_SOURCES = \ + $(source_c) \ + $(source_h) \ + $(source_h_private) \ + $(NULL) + +EXTRA_DIST = \ + rss-glib.h + +librss_la_LDFLAGS = $(LDADD) diff --git a/extern/rss-glib/rss-document-private.h b/extern/rss-glib/rss-document-private.h new file mode 100644 index 0000000..84889e9 --- /dev/null +++ b/extern/rss-glib/rss-document-private.h @@ -0,0 +1,58 @@ +/* rss-document-private.h + * + * This file is part of RSS-GLib. + * Copyright (C) 2008 Christian Hergert <chris@dronelabs.com> + * + * This library is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library. If not, see <http://www.gnu.org/licenses/>. + * + * Author: + * Christian Hergert <chris@dronelabs.com> + */ + +#ifndef __RSS_DOCUMENT_PRIVATE_H__ +#define __RSS_DOCUMENT_PRIVATE_H__ + +#include <mrss.h> + +struct _RssDocumentPrivate +{ + gchar *encoding; + gchar *guid; + gchar *title; + gchar *description; + gchar *link; + gchar *language; + gchar *rating; + gchar *copyright; + gchar *pub_date; + gchar *editor; + gchar *editor_email; + gchar *editor_uri; + gint ttl; + gchar *about; + gchar *contributor; + gchar *contributor_email; + gchar *contributor_uri; + gchar *generator; + gchar *generator_uri; + gchar *generator_version; + gchar *image_title; + gchar *image_url; + gchar *image_link; + + GList *items; + GList *categories; +}; + +#endif /* __RSS_DOCUMENT_PRIVATE_H__ */ diff --git a/extern/rss-glib/rss-document.c b/extern/rss-glib/rss-document.c new file mode 100644 index 0000000..c98a2f1 --- /dev/null +++ b/extern/rss-glib/rss-document.c @@ -0,0 +1,1085 @@ +/* rss-document.c + * + * This file is part of RSS-GLib. + * Copyright (C) 2008 Christian Hergert <chris@dronelabs.com> + * + * This library is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library. If not, see <http://www.gnu.org/licenses/>. + * + * Author: + * Christian Hergert <chris@dronelabs.com> + */ + +/** + * SECTION:rss-document + * @short_description: a RSS document representation + * @see_also: rss_parser_get_document() + * + * #RssDocument is the representation of the resource that was parsed. It + * contains a list of #RssItem<!-- -->s which in turn contain article information. + */ + +#include "rss-document.h" +#include "rss-document-private.h" + +G_DEFINE_TYPE (RssDocument, rss_document, G_TYPE_OBJECT); + +enum { + PROP_0, + + PROP_ENCODING, + PROP_GUID, + PROP_TITLE, + PROP_DESCRIPTION, + PROP_LINK, + PROP_LANGUAGE, + PROP_RATING, + PROP_COPYRIGHT, + PROP_PUB_DATE, + PROP_PUB_DATE_PARSED, + PROP_EDITOR, + PROP_EDITOR_EMAIL, + PROP_EDITOR_URI, + PROP_TTL, + PROP_ABOUT, + PROP_CONTRIBUTOR, + PROP_CONTRIBUTOR_EMAIL, + PROP_CONTRIBUTOR_URI, + PROP_GENERATOR, + PROP_GENERATOR_URI, + PROP_GENERATOR_VERSION, + PROP_IMAGE_TITLE, + PROP_IMAGE_URL, + PROP_IMAGE_LINK +}; + +static void +rss_document_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + RssDocumentPrivate *priv = RSS_DOCUMENT (object)->priv; + + switch (property_id) { + case PROP_ENCODING: + g_value_set_string (value, priv->encoding); + break; + case PROP_GUID: + g_value_set_string (value, priv->guid); + break; + case PROP_TITLE: + g_value_set_string (value, priv->title); + break; + case PROP_DESCRIPTION: + g_value_set_string (value, priv->description); + break; + case PROP_LINK: + g_value_set_string (value, priv->link); + break; + case PROP_LANGUAGE: + g_value_set_string (value, priv->language); + break; + case PROP_RATING: + g_value_set_string (value, priv->rating); + break; + case PROP_COPYRIGHT: + g_value_set_string (value, priv->copyright); + break; + case PROP_PUB_DATE: + g_value_set_string (value, priv->pub_date); + break; + case PROP_EDITOR: + g_value_set_string (value, priv->editor); + break; + case PROP_EDITOR_EMAIL: + g_value_set_string (value, priv->editor_email); + break; + case PROP_EDITOR_URI: + g_value_set_string (value, priv->editor_uri); + break; + case PROP_ABOUT: + g_value_set_string (value, priv->about); + break; + case PROP_CONTRIBUTOR: + g_value_set_string (value, priv->contributor); + break; + case PROP_CONTRIBUTOR_EMAIL: + g_value_set_string (value, priv->contributor_email); + break; + case PROP_CONTRIBUTOR_URI: + g_value_set_string (value, priv->contributor_uri); + break; + case PROP_GENERATOR: + g_value_set_string (value, priv->generator); + break; + case PROP_GENERATOR_URI: + g_value_set_string (value, priv->generator_uri); + break; + case PROP_GENERATOR_VERSION: + g_value_set_string (value, priv->generator_version); + break; + case PROP_IMAGE_TITLE: + g_value_set_string (value, priv->image_title); + break; + case PROP_IMAGE_URL: + g_value_set_string (value, priv->image_url); + break; + case PROP_IMAGE_LINK: + g_value_set_string (value, priv->image_link); + break; + case PROP_TTL: + g_value_set_int (value, priv->ttl); + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + } +} + +static void +rss_document_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) +{ + RssDocumentPrivate *priv = RSS_DOCUMENT (object)->priv; + + switch (property_id) { + case PROP_ENCODING: + g_free (priv->encoding); + priv->encoding = g_value_dup_string (value); + break; + case PROP_GUID: + g_free (priv->guid); + priv->guid = g_value_dup_string (value); + break; + case PROP_TITLE: + g_free (priv->title); + priv->title = g_value_dup_string (value); + break; + case PROP_DESCRIPTION: + g_free (priv->description); + priv->description = g_value_dup_string (value); + break; + case PROP_LINK: + g_free (priv->link); + priv->link = g_value_dup_string (value); + break; + case PROP_LANGUAGE: + g_free (priv->language); + priv->language = g_value_dup_string (value); + break; + case PROP_RATING: + g_free (priv->rating); + priv->rating = g_value_dup_string (value); + break; + case PROP_COPYRIGHT: + g_free (priv->copyright); + priv->copyright = g_value_dup_string (value); + break; + case PROP_PUB_DATE: + g_free (priv->pub_date); + priv->pub_date = g_value_dup_string (value); + break; + case PROP_EDITOR: + g_free (priv->editor); + priv->editor = g_value_dup_string (value); + break; + case PROP_EDITOR_EMAIL: + g_free (priv->editor_email); + priv->editor_email = g_value_dup_string (value); + break; + case PROP_EDITOR_URI: + g_free (priv->editor_uri); + priv->editor_uri = g_value_dup_string (value); + break; + case PROP_ABOUT: + g_free (priv->about); + priv->about = g_value_dup_string (value); + break; + case PROP_CONTRIBUTOR: + g_free (priv->contributor); + priv->contributor = g_value_dup_string (value); + break; + case PROP_CONTRIBUTOR_EMAIL: + g_free (priv->contributor_email); + priv->contributor_email = g_value_dup_string (value); + break; + case PROP_CONTRIBUTOR_URI: + g_free (priv->contributor_uri); + priv->contributor_uri = g_value_dup_string (value); + break; + case PROP_GENERATOR: + g_free (priv->generator); + priv->generator = g_value_dup_string (value); + break; + case PROP_GENERATOR_URI: + g_free (priv->generator_uri); + priv->generator_uri = g_value_dup_string (value); + break; + case PROP_GENERATOR_VERSION: + g_free (priv->generator_version); + priv->generator_version = g_value_dup_string (value); + break; + case PROP_IMAGE_TITLE: + g_free (priv->image_title); + priv->image_title = g_value_dup_string (value); + break; + case PROP_IMAGE_URL: + g_free (priv->image_url); + priv->image_url = g_value_dup_string (value); + break; + case PROP_IMAGE_LINK: + g_free (priv->image_link); + priv->image_link = g_value_dup_string (value); + break; + case PROP_TTL: + priv->ttl = g_value_get_int (value); + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + } +} + +static void +rss_document_dispose (GObject *object) +{ + RssDocumentPrivate *priv = RSS_DOCUMENT (object)->priv; + + g_free (priv->encoding); + g_free (priv->guid); + g_free (priv->title); + g_free (priv->description); + g_free (priv->link); + g_free (priv->language); + g_free (priv->rating); + g_free (priv->copyright); + g_free (priv->pub_date); + g_free (priv->editor); + g_free (priv->editor_email); + g_free (priv->editor_uri); + g_free (priv->about); + g_free (priv->contributor); + g_free (priv->contributor_email); + g_free (priv->contributor_uri); + g_free (priv->generator); + g_free (priv->generator_uri); + g_free (priv->generator_version); + g_free (priv->image_title); + g_free (priv->image_url); + g_free (priv->image_link); + + /* free the items */ + g_list_foreach (priv->items, (GFunc) g_object_unref, NULL); + g_list_free (priv->items); + + /* free the category strings */ + g_list_foreach (priv->categories, (GFunc) g_free, NULL); + g_list_free (priv->categories); + + G_OBJECT_CLASS (rss_document_parent_class)->dispose (object); +} + +static void +rss_document_class_init (RssDocumentClass *klass) +{ + GObjectClass *gobject_class = G_OBJECT_CLASS (klass); + GParamSpec *pspec; + + g_type_class_add_private (klass, sizeof (RssDocumentPrivate)); + + gobject_class->get_property = rss_document_get_property; + gobject_class->set_property = rss_document_set_property; + gobject_class->dispose = rss_document_dispose; + + /** + * RssDocument:encoding: + * + * The encoding of the #RssDocument. + */ + pspec = g_param_spec_string ("encoding", + "Encoding", + "Encoding of the document", + NULL, + G_PARAM_READWRITE); + g_object_class_install_property (gobject_class, + PROP_ENCODING, + pspec); + + /** + * RssDocument:guid: + * + * The guid associated with the feed. This is often the url of the + * feed. + */ + pspec = g_param_spec_string ("guid", + "GUID", + "The GUID of the document", + NULL, + G_PARAM_READWRITE); + g_object_class_install_property (gobject_class, + PROP_GUID, + pspec); + + /** + * RssDocument:title: + * + * The title of the #RssDocument. + */ + pspec = g_param_spec_string ("title", + "Title", + "Title of the document", + NULL, + G_PARAM_READWRITE); + g_object_class_install_property (gobject_class, + PROP_TITLE, + pspec); + + /** + * RssDocument:description: + * + * The description of the #RssDocument. + */ + pspec = g_param_spec_string ("description", + "Description", + "Description of the document", + NULL, + G_PARAM_READWRITE); + g_object_class_install_property (gobject_class, + PROP_DESCRIPTION, + pspec); + + /** + * RssDocument:link: + * + * The link to the source document. This is parsed from the actual + * document and can point to whatever the source publisher choses. + */ + pspec = g_param_spec_string ("link", + "Link", + "The link to the source document", + NULL, + G_PARAM_READWRITE); + g_object_class_install_property (gobject_class, + PROP_LINK, + pspec); + + /** + * RssDocument:language: + * + * The language the #RssDocument was published in. + */ + pspec = g_param_spec_string ("language", + "Language", + "Language of the document", + NULL, + G_PARAM_READWRITE); + g_object_class_install_property (gobject_class, + PROP_LANGUAGE, + pspec); + + /** + * RssDocument:rating: + * + * The rating associated with the #RssDocument. + */ + pspec = g_param_spec_string ("rating", + "Rating", + "Rating of the document", + NULL, + G_PARAM_READWRITE); + g_object_class_install_property (gobject_class, + PROP_RATING, + pspec); + + /** + * RssDocument:copyright: + * + * The copyright of the #RssDocument. + */ + pspec = g_param_spec_string ("copyright", + "Copyright", + "Copyright of the document", + NULL, + G_PARAM_READWRITE); + g_object_class_install_property (gobject_class, + PROP_COPYRIGHT, + pspec); + + /** + * RssDocument:pub-date: + * + * The string representation of the date the document was published. + */ + pspec = g_param_spec_string ("pub-date", + "Publication Date", + "Publication date of the document", + NULL, + G_PARAM_READWRITE); + g_object_class_install_property (gobject_class, + PROP_PUB_DATE, + pspec); + + /** + * RssDocument:editor: + * + * The name of the editor. + */ + pspec = g_param_spec_string ("editor", + "Editor", + "Editor of the document", + NULL, + G_PARAM_READWRITE); + g_object_class_install_property (gobject_class, + PROP_EDITOR, + pspec); + + /** + * RssDocument:editor-email: + * + * The email address of the editor. + */ + pspec = g_param_spec_string ("editor-email", + "Editor Email", + "Email of the editor", + NULL, + G_PARAM_READWRITE); + g_object_class_install_property (gobject_class, + PROP_EDITOR_EMAIL, + pspec); + + /** + * RssDocument:editor-uri: + * + * The uri for more information about the editor. + */ + pspec = g_param_spec_string ("editor-uri", + "Editor URI", + "The URI of the editor", + NULL, + G_PARAM_READWRITE); + g_object_class_install_property (gobject_class, + PROP_EDITOR_URI, + pspec); + + /** + * RssDocument:about: + * + * Information about the #RssDocument. + */ + pspec = g_param_spec_string ("about", + "About", + "Information about the document", + NULL, + G_PARAM_READWRITE); + g_object_class_install_property (gobject_class, + PROP_ABOUT, + pspec); + + /** + * RssDocument:contributor: + * + * The name of the particular contributor. + */ + pspec = g_param_spec_string ("contributor", + "Contributor", + "Name of the contributor", + NULL, + G_PARAM_READWRITE); + g_object_class_install_property (gobject_class, + PROP_CONTRIBUTOR, + pspec); + + /** + * RssDocument:contributor-email: + * + * The email of the particular contributor. + */ + pspec = g_param_spec_string ("contributor-email", + "Contributor Email", + "Email of the contributor", + NULL, + G_PARAM_READWRITE); + g_object_class_install_property (gobject_class, + PROP_CONTRIBUTOR_EMAIL, + pspec); + + /** + * RssDocument:contributor-uri: + * + * The uri to more information on the particular contributer. + */ + pspec = g_param_spec_string ("contributor-uri", + "Contributor URI", + "URI of the contributor", + NULL, + G_PARAM_READWRITE); + g_object_class_install_property (gobject_class, + PROP_CONTRIBUTOR_URI, + pspec); + + /** + * RssDocument:generator: + * + * The name of the generator on the server side. + */ + pspec = g_param_spec_string ("generator", + "Generator", + "Name of the document generator", + NULL, + G_PARAM_READWRITE); + g_object_class_install_property (gobject_class, + PROP_GENERATOR, + pspec); + + /** + * RssDocument:generator-uri: + * + * Url to more information about the generator on the server side. + */ + pspec = g_param_spec_string ("generator-uri", + "Generator URI", + "URI of the document generator", + NULL, + G_PARAM_READWRITE); + g_object_class_install_property (gobject_class, + PROP_GENERATOR_URI, + pspec); + + /** + * RssDocument:generator-version: + * + * The version of the server side generator. + */ + pspec = g_param_spec_string ("generator-version", + "Generator Version", + "Version of the document generator", + NULL, + G_PARAM_READWRITE); + g_object_class_install_property (gobject_class, + PROP_GENERATOR_VERSION, + pspec); + + /** + * RssDocument:image-title: + * + * The title for the image. This is often the alt="" tag in HTML. + */ + pspec = g_param_spec_string ("image-title", + "Image Title", + "Title of the image for the document", + NULL, + G_PARAM_READWRITE); + g_object_class_install_property (gobject_class, + PROP_IMAGE_TITLE, + pspec); + + /** + * RssDocument:image-url: + * + * A url to the image for the RssDocument. Use this before checking + * for a favicon.ico. + */ + pspec = g_param_spec_string ("image-url", + "Image URL", + "URL of the image for the document", + NULL, + G_PARAM_READWRITE); + g_object_class_install_property (gobject_class, + PROP_IMAGE_URL, + pspec); + + /** + * RssDocument:image-link: + * + * The url a user should be redirected to when clicking on the image + * for the #RssDocument. Of course, its up to UI designers if they + * wish to implement this in any sort of way. + */ + pspec = g_param_spec_string ("image-link", + "Image Link", + "URL for document image link", + NULL, + G_PARAM_READWRITE); + g_object_class_install_property (gobject_class, + PROP_IMAGE_LINK, + pspec); + + /** + * RssDocument:ttl: + * + * The publisher determined TTL for the source. Readers should try + * to respect this value and not update feeds any more often than + * necessary. + */ + pspec = g_param_spec_int ("ttl", + "TTL", + "Time to live for the document", + 0, G_MAXINT32, 0, + G_PARAM_READWRITE); + g_object_class_install_property (gobject_class, + PROP_TTL, + pspec); +} + +static void +rss_document_init (RssDocument *self) +{ + self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, RSS_TYPE_DOCUMENT, + RssDocumentPrivate); +} + +/** + * rss_document_new: + * + * Creates a new instance of #RssDocument. This isn't incredibly useful + * currently, but is here none-the-less. The desire is to create an + * RSS generator that will allow for building RSS streams out of the + * document hierarchy. + * + * Returns: a new #RssDocument. Use g_object_unref() when you are done. + */ +RssDocument* +rss_document_new (void) +{ + return g_object_new (RSS_TYPE_DOCUMENT, NULL); +} + +/** + * rss_document_get_items: + * @self: a #RssDocument + * + * Creates a #GList of #RssItem<!-- -->s that were found in the syndication. The objects + * in the list are weak references. Consumers of those objects should ref + * them with g_object_ref. + * + * Returns: a new #GList owned by the caller. + */ +GList* +rss_document_get_items (RssDocument *self) +{ + g_return_val_if_fail (RSS_IS_DOCUMENT (self), NULL); + + return g_list_copy (self->priv->items); +} + +/** + * rss_document_get_categories: + * @self: a #RssDocument + * + * Creates a #GList of categories found in the syndication. The strings + * in the list are weak references. Consumers should duplicate them + * with g_strdup(). + * + * Returns: a new #GList owned by the caller + */ +GList* +rss_document_get_categories (RssDocument *self) +{ + g_return_val_if_fail (RSS_IS_DOCUMENT (self), NULL); + + return g_list_copy (self->priv->categories); +} + +/** + * rss_document_get_guid: + * @self: a #RssDocument + * + * Retrieves the #RssDocument:guid field. + * + * Return value: the contents of the field. The returned string is + * owned by the #RssDocument and should never be modified of freed + */ +const gchar * +rss_document_get_guid (RssDocument *self) +{ + g_return_val_if_fail (RSS_IS_DOCUMENT (self), NULL); + + return self->priv->guid; +} + +/** + * rss_document_get_about: + * @self: a #RssDocument + * + * Retrieves the #RssDocument:about field. + * + * Return value: the contents of the field. The returned string is + * owned by the #RssDocument and should never be modified of freed + */ +const gchar * +rss_document_get_about (RssDocument *self) +{ + g_return_val_if_fail (RSS_IS_DOCUMENT (self), NULL); + + return self->priv->about; +} + +/** + * rss_document_get_title: + * @self: a #RssDocument + * + * Retrieves the #RssDocument:title field. + * + * Return value: the contents of the field. The returned string is + * owned by the #RssDocument and should never be modified of freed + */ +const gchar * +rss_document_get_title (RssDocument *self) +{ + g_return_val_if_fail (RSS_IS_DOCUMENT (self), NULL); + + return self->priv->title; +} + +/** + * rss_document_get_description: + * @self: a #RssDocument + * + * Retrieves the #RssDocument:description field. + * + * Return value: the contents of the field. The returned string is + * owned by the #RssDocument and should never be modified of freed + */ +const gchar * +rss_document_get_description (RssDocument *self) +{ + g_return_val_if_fail (RSS_IS_DOCUMENT (self), NULL); + + return self->priv->description; +} + +/** + * rss_document_get_link: + * @self: a #RssDocument + * + * Retrieves the #RssDocument:link field. + * + * Return value: the contents of the field. The returned string is + * owned by the #RssDocument and should never be modified of freed + */ +const gchar * +rss_document_get_link (RssDocument *self) +{ + g_return_val_if_fail (RSS_IS_DOCUMENT (self), NULL); + + return self->priv->link; +} + +/** + * rss_document_get_encoding: + * @self: a #RssDocument + * + * Retrieves the #RssDocument:encoding field. + * + * Return value: the contents of the field. The returned string is + * owned by the #RssDocument and should never be modified of freed + */ +const gchar * +rss_document_get_encoding (RssDocument *self) +{ + g_return_val_if_fail (RSS_IS_DOCUMENT (self), NULL); + + return self->priv->encoding; +} + +/** + * rss_document_get_language: + * @self: a #RssDocument + * + * Retrieves the #RssDocument:language field. + * + * Return value: the contents of the field. The returned string is + * owned by the #RssDocument and should never be modified of freed + */ +const gchar * +rss_document_get_language (RssDocument *self) +{ + g_return_val_if_fail (RSS_IS_DOCUMENT (self), NULL); + + return self->priv->language; +} + +/** + * rss_document_get_rating: + * @self: a #RssDocument + * + * Retrieves the #RssDocument:rating field. + * + * Return value: the contents of the field. The returned string is + * owned by the #RssDocument and should never be modified of freed + */ +const gchar * +rss_document_get_rating (RssDocument *self) +{ + g_return_val_if_fail (RSS_IS_DOCUMENT (self), NULL); + + return self->priv->rating; +} + +/** + * rss_document_get_copyright: + * @self: a #RssDocument + * + * Retrieves the #RssDocument:copyright field. + * + * Return value: the contents of the field. The returned string is + * owned by the #RssDocument and should never be modified of freed + */ +const gchar * +rss_document_get_copyright (RssDocument *self) +{ + g_return_val_if_fail (RSS_IS_DOCUMENT (self), NULL); + + return self->priv->copyright; +} + +/** + * rss_document_get_pub_date: + * @self: a #RssDocument + * + * Retrieves the #RssDocument:pub-date field. + * + * Return value: the contents of the field. The returned string is + * owned by the #RssDocument and should never be modified of freed + */ +const gchar * +rss_document_get_pub_date (RssDocument *self) +{ + g_return_val_if_fail (RSS_IS_DOCUMENT (self), NULL); + + return self->priv->pub_date; +} + +/** + * rss_document_get_editor_name: + * @self: a #RssDocument + * + * Retrieves the #RssDocument:editor field. + * + * Return value: the contents of the field. The returned string is + * owned by the #RssDocument and should never be modified of freed + */ +const gchar * +rss_document_get_editor_name (RssDocument *self) +{ + g_return_val_if_fail (RSS_IS_DOCUMENT (self), NULL); + + return self->priv->editor; +} + +/** + * rss_document_get_editor_email: + * @self: a #RssDocument + * + * Retrieves the #RssDocument:editor-email field. + * + * Return value: the contents of the field. The returned string is + * owned by the #RssDocument and should never be modified of freed + */ +const gchar * +rss_document_get_editor_email (RssDocument *self) +{ + g_return_val_if_fail (RSS_IS_DOCUMENT (self), NULL); + + return self->priv->editor_email; +} + +/** + * rss_document_get_editor_uri: + * @self: a #RssDocument + * + * Retrieves the #RssDocument:editor-uri field. + * + * Return value: the contents of the field. The returned string is + * owned by the #RssDocument and should never be modified of freed + */ +const gchar * +rss_document_get_editor_uri (RssDocument *self) +{ + g_return_val_if_fail (RSS_IS_DOCUMENT (self), NULL); + + return self->priv->editor_uri; +} + +/** + * rss_document_get_contributor: + * @self: a #RssDocument + * + * Retrieves the #RssDocument:contributor field. + * + * Return value: the contents of the field. The returned string is + * owned by the #RssDocument and should never be modified of freed + */ +const gchar * +rss_document_get_contributor_name (RssDocument *self) +{ + g_return_val_if_fail (RSS_IS_DOCUMENT (self), NULL); + + return self->priv->contributor; +} + +/** + * rss_document_get_contributor_email: + * @self: a #RssDocument + * + * Retrieves the #RssDocument:contributor-email field. + * + * Return value: the contents of the field. The returned string is + * owned by the #RssDocument and should never be modified of freed + */ +const gchar * +rss_document_get_contributor_email (RssDocument *self) +{ + g_return_val_if_fail (RSS_IS_DOCUMENT (self), NULL); + + return self->priv->contributor_email; +} + +/** + * rss_document_get_contributor_uri: + * @self: a #RssDocument + * + * Retrieves the #RssDocument:contributor-uri field. + * + * Return value: the contents of the field. The returned string is + * owned by the #RssDocument and should never be modified of freed + */ +const gchar * +rss_document_get_contributor_uri (RssDocument *self) +{ + g_return_val_if_fail (RSS_IS_DOCUMENT (self), NULL); + + return self->priv->contributor_uri; +} + +/** + * rss_document_get_generator_name: + * @self: a #RssDocument + * + * Retrieves the #RssDocument:generator-name field. + * + * Return value: the contents of the field. The returned string is + * owned by the #RssDocument and should never be modified of freed + */ +const gchar * +rss_document_get_generator_name (RssDocument *self) +{ + g_return_val_if_fail (RSS_IS_DOCUMENT (self), NULL); + + return self->priv->generator; +} + +/** + * rss_document_get_generator_uri: + * @self: a #RssDocument + * + * Retrieves the #RssDocument:generator-uri field. + * + * Return value: the contents of the field. The returned string is + * owned by the #RssDocument and should never be modified of freed + */ +const gchar * +rss_document_get_generator_uri (RssDocument *self) +{ + g_return_val_if_fail (RSS_IS_DOCUMENT (self), NULL); + + return self->priv->generator_uri; +} + +/** + * rss_document_get_generator_version: + * @self: a #RssDocument + * + * Retrieves the #RssDocument:generator-version field. + * + * Return value: the contents of the field. The returned string is + * owned by the #RssDocument and should never be modified of freed + */ +const gchar * +rss_document_get_generator_version (RssDocument *self) +{ + g_return_val_if_fail (RSS_IS_DOCUMENT (self), NULL); + + return self->priv->generator_version; +} + +/** + * rss_document_get_image_title: + * @self: a #RssDocument + * + * Retrieves the #RssDocument:image-title field. + * + * Return value: the contents of the field. The returned string is + * owned by the #RssDocument and should never be modified of freed + */ +const gchar * +rss_document_get_image_title (RssDocument *self) +{ + g_return_val_if_fail (RSS_IS_DOCUMENT (self), NULL); + + return self->priv->image_title; +} + +/** + * rss_document_get_image_url: + * @self: a #RssDocument + * + * Retrieves the #RssDocument:image-url field. + * + * Return value: the contents of the field. The returned string is + * owned by the #RssDocument and should never be modified of freed + */ +const gchar * +rss_document_get_image_url (RssDocument *self) +{ + g_return_val_if_fail (RSS_IS_DOCUMENT (self), NULL); + + return self->priv->image_url; +} + +/** + * rss_document_get_image_link: + * @self: a #RssDocument + * + * Retrieves the #RssDocument:image-link field. + * + * Return value: the contents of the field. The returned string is + * owned by the #RssDocument and should never be modified of freed + */ +const gchar * +rss_document_get_image_link (RssDocument *self) +{ + g_return_val_if_fail (RSS_IS_DOCUMENT (self), NULL); + + return self->priv->image_link; +} + +/** + * rss_document_get_ttl: + * @self: a #RssDocument + * + * Retrieves the #RssDocument:ttl field. + * + * Return value: the contents of the field. The returned string is + * owned by the #RssDocument and should never be modified of freed + */ +gint +rss_document_get_ttl (RssDocument *self) +{ + g_return_val_if_fail (RSS_IS_DOCUMENT (self), 0); + + return self->priv->ttl; +} diff --git a/extern/rss-glib/rss-document.h b/extern/rss-glib/rss-document.h new file mode 100644 index 0000000..58c995a --- /dev/null +++ b/extern/rss-glib/rss-document.h @@ -0,0 +1,105 @@ +/* rss-document.h + * + * This file is part of RSS-GLib. + * Copyright (C) 2008 Christian Hergert <chris@dronelabs.com> + * + * This library is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library. If not, see <http://www.gnu.org/licenses/>. + * + * Author: + * Christian Hergert <chris@dronelabs.com> + */ + +#ifndef __RSS_DOCUMENT_H__ +#define __RSS_DOCUMENT_H__ + +#include <glib-object.h> + +G_BEGIN_DECLS + +#define RSS_TYPE_DOCUMENT rss_document_get_type() + +#define RSS_DOCUMENT(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ + RSS_TYPE_DOCUMENT, \ + RssDocument)) + +#define RSS_DOCUMENT_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST ((klass), \ + RSS_TYPE_DOCUMENT, \ + RssDocumentClass)) + +#define RSS_IS_DOCUMENT(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \ + RSS_TYPE_DOCUMENT)) + +#define RSS_IS_DOCUMENT_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE ((klass), \ + RSS_TYPE_DOCUMENT)) + +#define RSS_DOCUMENT_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS ((obj), \ + RSS_TYPE_DOCUMENT, \ + RssDocumentClass)) + +typedef struct _RssDocument RssDocument; +typedef struct _RssDocumentPrivate RssDocumentPrivate; +typedef struct _RssDocumentClass RssDocumentClass; + +struct _RssDocument +{ + /*< private >*/ + GObject parent_instance; + + RssDocumentPrivate *priv; +}; + +struct _RssDocumentClass +{ + /*< private >*/ + GObjectClass parent_class; +}; + +GType rss_document_get_type (void); +RssDocument* rss_document_new (void); + +const gchar *rss_document_get_guid (RssDocument *self); +const gchar *rss_document_get_about (RssDocument *self); +const gchar *rss_document_get_title (RssDocument *self); +const gchar *rss_document_get_description (RssDocument *self); +const gchar *rss_document_get_link (RssDocument *self); +const gchar *rss_document_get_encoding (RssDocument *self); +const gchar *rss_document_get_language (RssDocument *self); +const gchar *rss_document_get_rating (RssDocument *self); +const gchar *rss_document_get_copyright (RssDocument *self); +const gchar *rss_document_get_pub_date (RssDocument *self); +const gchar *rss_document_get_editor_name (RssDocument *self); +const gchar *rss_document_get_editor_email (RssDocument *self); +const gchar *rss_document_get_editor_uri (RssDocument *self); +const gchar *rss_document_get_contributor_name (RssDocument *self); +const gchar *rss_document_get_contributor_email (RssDocument *self); +const gchar *rss_document_get_contributor_uri (RssDocument *self); +const gchar *rss_document_get_generator_name (RssDocument *self); +const gchar *rss_document_get_generator_uri (RssDocument *self); +const gchar *rss_document_get_generator_version (RssDocument *self); +const gchar *rss_document_get_image_title (RssDocument *self); +const gchar *rss_document_get_image_url (RssDocument *self); +const gchar *rss_document_get_image_link (RssDocument *self); +gint rss_document_get_ttl (RssDocument *self); + +GList * rss_document_get_items (RssDocument *self); +GList * rss_document_get_categories (RssDocument *self); + +G_END_DECLS + +#endif /* __RSS_DOCUMENT_H__ */ diff --git a/extern/rss-glib/rss-glib.h b/extern/rss-glib/rss-glib.h new file mode 100644 index 0000000..57667f7 --- /dev/null +++ b/extern/rss-glib/rss-glib.h @@ -0,0 +1,9 @@ +#ifndef __RSS_GLIB_H__ +#define __RSS_GLIB_H__ + +#include <rss-glib/rss-parser.h> +#include <rss-glib/rss-document.h> +#include <rss-glib/rss-item.h> +#include <rss-glib/rss-version.h> + +#endif /* __RSS_GLIB_H__ */ diff --git a/extern/rss-glib/rss-item-private.h b/extern/rss-glib/rss-item-private.h new file mode 100644 index 0000000..9882ac0 --- /dev/null +++ b/extern/rss-glib/rss-item-private.h @@ -0,0 +1,46 @@ +/* rss-item-private.h + * + * This file is part of RSS-GLib. + * Copyright (C) 2008 Christian Hergert <chris@dronelabs.com> + * + * This library is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library. If not, see <http://www.gnu.org/licenses/>. + * + * Author: + * Christian Hergert <chris@dronelabs.com> + */ + +#ifndef __RSS_ITEM_PRIVATE_H__ +#define __RSS_ITEM_PRIVATE_H__ + +struct _RssItemPrivate { + gchar *guid; + gchar *title; + gchar *link; + gchar *description; + gchar *copyright; + gchar *author; + gchar *author_uri; + gchar *author_email; + gchar *contributor; + gchar *contributor_uri; + gchar *contributor_email; + gchar *comments; + gchar *pub_date; + gchar *source; + gchar *source_url; + + GList *categories; +}; + +#endif /* __RSS_ITEM_PRIVATE_H__ */ diff --git a/extern/rss-glib/rss-item.c b/extern/rss-glib/rss-item.c new file mode 100644 index 0000000..0f84661 --- /dev/null +++ b/extern/rss-glib/rss-item.c @@ -0,0 +1,738 @@ +/* rss-item.c + * + * This file is part of RSS-GLib. + * Copyright (C) 2008 Christian Hergert <chris@dronelabs.com> + * + * This library is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library. If not, see <http://www.gnu.org/licenses/>. + * + * Author: + * Christian Hergert <chris@dronelabs.com> + */ + +/** + * SECTION:rss-item + * @short_description: a RSS entry representation + * + * #RssItem is the representation of an individual item parsed from a + * #RssDocument. This would mean an individual article, or note within + * the source feed. + */ + +#include "rss-item.h" +#include "rss-item-private.h" + +G_DEFINE_TYPE (RssItem, rss_item, G_TYPE_OBJECT); + +enum { + PROP_0, + + PROP_TITLE, + PROP_LINK, + PROP_DESCRIPTION, + PROP_COPYRIGHT, + PROP_AUTHOR, + PROP_AUTHOR_URI, + PROP_AUTHOR_EMAIL, + PROP_CONTRIBUTOR, + PROP_CONTRIBUTOR_URI, + PROP_CONTRIBUTOR_EMAIL, + PROP_COMMENTS, + PROP_PUB_DATE, + PROP_GUID, + PROP_SOURCE, + PROP_SOURCE_URL +}; + +static void +rss_item_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + RssItemPrivate *priv = RSS_ITEM (object)->priv; + + switch (property_id) { + case PROP_TITLE: + g_value_set_string (value, priv->title); + break; + case PROP_LINK: + g_value_set_string (value, priv->link); + break; + case PROP_DESCRIPTION: + g_value_set_string (value, priv->description); + break; + case PROP_COPYRIGHT: + g_value_set_string (value, priv->copyright); + break; + case PROP_AUTHOR: + g_value_set_string (value, priv->author); + break; + case PROP_AUTHOR_URI: + g_value_set_string (value, priv->author_uri); + break; + case PROP_AUTHOR_EMAIL: + g_value_set_string (value, priv->author_email); + break; + case PROP_CONTRIBUTOR: + g_value_set_string (value, priv->contributor); + break; + case PROP_CONTRIBUTOR_URI: + g_value_set_string (value, priv->contributor_uri); + break; + case PROP_CONTRIBUTOR_EMAIL: + g_value_set_string (value, priv->contributor_email); + break; + case PROP_COMMENTS: + g_value_set_string (value, priv->comments); + break; + case PROP_PUB_DATE: + g_value_set_string (value, priv->pub_date); + break; + case PROP_GUID: + g_value_set_string (value, priv->guid); + break; + case PROP_SOURCE: + g_value_set_string (value, priv->source); + break; + case PROP_SOURCE_URL: + g_value_set_string (value, priv->source_url); + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + } +} + +static void +rss_item_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) +{ + RssItemPrivate *priv = RSS_ITEM (object)->priv; + + switch (property_id) { + case PROP_TITLE: + g_free (priv->title); + priv->title = g_value_dup_string (value); + break; + case PROP_LINK: + g_free (priv->link); + priv->link = g_value_dup_string (value); + break; + case PROP_DESCRIPTION: + g_free (priv->description); + priv->description = g_value_dup_string (value); + break; + case PROP_COPYRIGHT: + g_free (priv->copyright); + priv->copyright = g_value_dup_string (value); + break; + case PROP_AUTHOR: + g_free (priv->author); + priv->author = g_value_dup_string (value); + break; + case PROP_AUTHOR_URI: + g_free (priv->author_uri); + priv->author_uri = g_value_dup_string (value); + break; + case PROP_AUTHOR_EMAIL: + g_free (priv->author_email); + priv->author_email = g_value_dup_string (value); + break; + case PROP_CONTRIBUTOR: + g_free (priv->contributor); + priv->contributor = g_value_dup_string (value); + break; + case PROP_CONTRIBUTOR_URI: + g_free (priv->contributor_uri); + priv->contributor_uri = g_value_dup_string (value); + break; + case PROP_CONTRIBUTOR_EMAIL: + g_free (priv->contributor_email); + priv->contributor_email = g_value_dup_string (value); + break; + case PROP_COMMENTS: + g_free (priv->comments); + priv->comments = g_value_dup_string (value); + break; + case PROP_PUB_DATE: + g_free (priv->pub_date); + priv->pub_date = g_value_dup_string (value); + break; + case PROP_GUID: + g_free (priv->guid); + priv->guid = g_value_dup_string (value); + break; + case PROP_SOURCE: + g_free (priv->source); + priv->source = g_value_dup_string (value); + break; + case PROP_SOURCE_URL: + g_free (priv->source_url); + priv->source_url = g_value_dup_string (value); + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + } +} + +static void +rss_item_finalize (GObject *object) +{ + RssItemPrivate *priv = RSS_ITEM (object)->priv; + + g_free (priv->guid); + g_free (priv->title); + g_free (priv->link); + g_free (priv->description); + g_free (priv->copyright); + g_free (priv->author); + g_free (priv->author_uri); + g_free (priv->author_email); + g_free (priv->contributor); + g_free (priv->contributor_uri); + g_free (priv->contributor_email); + g_free (priv->comments); + g_free (priv->pub_date); + g_free (priv->source); + g_free (priv->source_url); + + g_list_foreach (priv->categories, (GFunc) g_free, NULL); + g_list_free (priv->categories); + + G_OBJECT_CLASS (rss_item_parent_class)->finalize (object); +} + +static void +rss_item_class_init (RssItemClass *klass) +{ + GObjectClass *gobject_class = G_OBJECT_CLASS (klass); + GParamSpec *pspec; + + g_type_class_add_private (klass, sizeof (RssItemPrivate)); + + gobject_class->get_property = rss_item_get_property; + gobject_class->set_property = rss_item_set_property; + gobject_class->finalize = rss_item_finalize; + + /** + * RssItem:title: + * + * The title of the item. + */ + pspec = g_param_spec_string ("title", + "Title", + "Title of the item", + NULL, + G_PARAM_READWRITE); + g_object_class_install_property (gobject_class, + PROP_TITLE, + pspec); + + /** + * RssItem:link: + * + * The link to the upstream source of the item. + */ + pspec = g_param_spec_string ("link", + "Link", + "Link to the upstream source", + NULL, + G_PARAM_READWRITE); + g_object_class_install_property (gobject_class, + PROP_LINK, + pspec); + + /** + * RssItem:description: + * + * The description of the item. This is often where the actual + * content for the item is stored. + */ + pspec = g_param_spec_string ("description", + "Description", + "Description of the item", + NULL, + G_PARAM_READWRITE); + g_object_class_install_property (gobject_class, + PROP_DESCRIPTION, + pspec); + + /** + * RssItem:copyright: + * + * Any associated copyright that may exist for the content. + */ + pspec = g_param_spec_string ("copyright", + "Copyright", + "Any associated copyright for " + "the content", + NULL, + G_PARAM_READWRITE); + g_object_class_install_property (gobject_class, + PROP_COPYRIGHT, + pspec); + + /** + * RssItem:author: + * + * The author's name. + */ + pspec = g_param_spec_string ("author", + "Author", + "The name of the author", + NULL, + G_PARAM_READWRITE); + g_object_class_install_property (gobject_class, + PROP_AUTHOR, + pspec); + + /** + * RssItem:author-uri: + * + * The authors uri, often a website. + */ + pspec = g_param_spec_string ("author-uri", + "Author URI", + "The URI of the author", + NULL, + G_PARAM_READWRITE); + g_object_class_install_property (gobject_class, + PROP_AUTHOR_URI, + pspec); + + /** + * RssItem:author-email: + * + * The authors email. + */ + pspec = g_param_spec_string ("author-email", + "Author Email", + "The email address of the author", + NULL, + G_PARAM_READWRITE); + g_object_class_install_property (gobject_class, + PROP_AUTHOR_EMAIL, + pspec); + + /** + * RssItem:contributor: + * + * The contributors name. + */ + pspec = g_param_spec_string ("contributor", + "Contributor", + "The name of the contributor", + NULL, + G_PARAM_READWRITE); + g_object_class_install_property (gobject_class, + PROP_CONTRIBUTOR, + pspec); + + /** + * RssItem:contributor-uri: + * + * The contributors uri, often a website. + */ + pspec = g_param_spec_string ("contributor-uri", + "Contributor URI", + "The URI of the contributor", + NULL, + G_PARAM_READWRITE); + g_object_class_install_property (gobject_class, + PROP_CONTRIBUTOR_URI, + pspec); + + /** + * RssItem:contributor-email: + * + * The contributors email. + */ + pspec = g_param_spec_string ("contributor-email", + "Contributor Email", + "The email of the contributor", + NULL, + G_PARAM_READWRITE); + g_object_class_install_property (gobject_class, + PROP_CONTRIBUTOR_EMAIL, + pspec); + + /** + * RssItem:comments: + * + * Any comments that may have been associated with the item. + */ + pspec = g_param_spec_string ("comments", + "Comments", + "Any comment associated to the item", + NULL, + G_PARAM_READWRITE); + g_object_class_install_property (gobject_class, + PROP_COMMENTS, + pspec); + + /** + * RssItem:pub-date: + * + * The string representation of the publish date. + */ + pspec = g_param_spec_string ("pub-date", + "Publication Date", + "The date of publication", + NULL, + G_PARAM_READWRITE); + g_object_class_install_property (gobject_class, + PROP_PUB_DATE, + pspec); + + /** + * RssItem:guid: + * + * The guid of the item. Many feed engines will use the url here + * plus some tag metadata. + */ + pspec = g_param_spec_string ("guid", + "GUID", + "The guid of the item", + NULL, + G_PARAM_READWRITE); + g_object_class_install_property (gobject_class, + PROP_GUID, + pspec); + + /** + * RssItem:source: + * + * The name of the source of the item. + */ + pspec = g_param_spec_string ("source", + "Source", + "Source of the item", + NULL, + G_PARAM_READWRITE); + g_object_class_install_property (gobject_class, + PROP_SOURCE, + pspec); + + /** + * RssItem:source-url: + * + * The url of the source of the item. + */ + pspec = g_param_spec_string ("source-url", + "Source URL", + "URL of the source", + NULL, + G_PARAM_READWRITE); + g_object_class_install_property (gobject_class, + PROP_SOURCE_URL, + pspec); +} + +static void +rss_item_init (RssItem *self) +{ + self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, RSS_TYPE_ITEM, RssItemPrivate); +} + +/** + * rss_item_new: + * + * Creates a new #RssItem. This isn't incredibly useful yet as we do not + * have an RssGenerator written. However, that will come eventuall and + * make creating feeds much simpler. + * + * Returns: a new #RssItem which should be unref'd with g_object_unref(). + */ +RssItem* +rss_item_new (void) +{ + return g_object_new (RSS_TYPE_ITEM, NULL); +} + +/** + * rss_item_get_guid: + * @self: a #RssItem + * + * Retrieves the #RssItem:guid field. + * + * Return value: the value of the field. The returned string is + * owned by the #RssItem and should never be modified or freed. + */ +const gchar * +rss_item_get_guid (RssItem *self) +{ + g_return_val_if_fail (RSS_IS_ITEM (self), NULL); + + return self->priv->guid; +} + +/** + * rss_item_get_title: + * @self: a #RssItem + * + * Retrieves the #RssItem:title field. + * + * Return value: the value of the field. The returned string is + * owned by the #RssItem and should never be modified or freed. + */ +const gchar * +rss_item_get_title (RssItem *self) +{ + g_return_val_if_fail (RSS_IS_ITEM (self), NULL); + + return self->priv->title; +} + +/** + * rss_item_get_link: + * @self: a #RssItem + * + * Retrieves the #RssItem:link field. + * + * Return value: the value of the field. The returned string is + * owned by the #RssItem and should never be modified or freed. + */ +const gchar * +rss_item_get_link (RssItem *self) +{ + g_return_val_if_fail (RSS_IS_ITEM (self), NULL); + + return self->priv->link; +} + +/** + * rss_item_get_description: + * @self: a #RssItem + * + * Retrieves the #RssItem:description field. + * + * Return value: the value of the field. The returned string is + * owned by the #RssItem and should never be modified or freed. + */ +const gchar * +rss_item_get_description (RssItem *self) +{ + g_return_val_if_fail (RSS_IS_ITEM (self), NULL); + + return self->priv->description; +} + +/** + * rss_item_get_copyright: + * @self: a #RssItem + * + * Retrieves the #RssItem:copyright field. + * + * Return value: the value of the field. The returned string is + * owned by the #RssItem and should never be modified or freed. + */ +const gchar * +rss_item_get_copyright (RssItem *self) +{ + g_return_val_if_fail (RSS_IS_ITEM (self), NULL); + + return self->priv->copyright; +} + +/** + * rss_item_get_author_name: + * @self: a #RssItem + * + * Retrieves the #RssItem:author field. + * + * Return value: the value of the field. The returned string is + * owned by the #RssItem and should never be modified or freed. + */ +const gchar * +rss_item_get_author_name (RssItem *self) +{ + g_return_val_if_fail (RSS_IS_ITEM (self), NULL); + + return self->priv->author; +} + +/** + * rss_item_get_author_uri: + * @self: a #RssItem + * + * Retrieves the #RssItem:author-uri field. + * + * Return value: the value of the field. The returned string is + * owned by the #RssItem and should never be modified or freed. + */ +const gchar * +rss_item_get_author_uri (RssItem *self) +{ + g_return_val_if_fail (RSS_IS_ITEM (self), NULL); + + return self->priv->author_uri; +} + +/** + * rss_item_get_author_email: + * @self: a #RssItem + * + * Retrieves the #RssItem:author-email field. + * + * Return value: the value of the field. The returned string is + * owned by the #RssItem and should never be modified or freed. + */ +const gchar * +rss_item_get_author_email (RssItem *self) +{ + g_return_val_if_fail (RSS_IS_ITEM (self), NULL); + + return self->priv->author_email; +} + +/** + * rss_item_get_contributor_name: + * @self: a #RssItem + * + * Retrieves the #RssItem:contributor field. + * + * Return value: the value of the field. The returned string is + * owned by the #RssItem and should never be modified or freed. + */ +const gchar * +rss_item_get_contributor_name (RssItem *self) +{ + g_return_val_if_fail (RSS_IS_ITEM (self), NULL); + + return self->priv->contributor; +} + +/** + * rss_item_get_contributor_uri: + * @self: a #RssItem + * + * Retrieves the #RssItem:contributor-uri field. + * + * Return value: the value of the field. The returned string is + * owned by the #RssItem and should never be modified or freed. + */ +const gchar * +rss_item_get_contributor_uri (RssItem *self) +{ + g_return_val_if_fail (RSS_IS_ITEM (self), NULL); + + return self->priv->contributor_uri; +} + +/** + * rss_item_get_contributor_email: + * @self: a #RssItem + * + * Retrieves the #RssItem:contributor-email field. + * + * Return value: the value of the field. The returned string is + * owned by the #RssItem and should never be modified or freed. + */ +const gchar * +rss_item_get_contributor_email (RssItem *self) +{ + g_return_val_if_fail (RSS_IS_ITEM (self), NULL); + + return self->priv->contributor_email; +} + +/** + * rss_item_get_comments: + * @self: a #RssItem + * + * Retrieves the #RssItem:comments field. + * + * Return value: the value of the field. The returned string is + * owned by the #RssItem and should never be modified or freed. + */ +const gchar * +rss_item_get_comments (RssItem *self) +{ + g_return_val_if_fail (RSS_IS_ITEM (self), NULL); + + return self->priv->comments; +} + +/** + * rss_item_get_pub_date: + * @self: a #RssItem + * + * Retrieves the #RssItem:pub-date field. + * + * Return value: the value of the field. The returned string is + * owned by the #RssItem and should never be modified or freed. + */ +const gchar * +rss_item_get_pub_date (RssItem *self) +{ + g_return_val_if_fail (RSS_IS_ITEM (self), NULL); + + return self->priv->pub_date; +} + +/** + * rss_item_get_source: + * @self: a #RssItem + * + * Retrieves the #RssItem:source field. + * + * Return value: the value of the field. The returned string is + * owned by the #RssItem and should never be modified or freed. + */ +const gchar * +rss_item_get_source (RssItem *self) +{ + g_return_val_if_fail (RSS_IS_ITEM (self), NULL); + + return self->priv->source; +} + +/** + * rss_item_get_source_url: + * @self: a #RssItem + * + * Retrieves the #RssItem:source-url field. + * + * Return value: the value of the field. The returned string is + * owned by the #RssItem and should never be modified or freed. + */ +const gchar * +rss_item_get_source_url (RssItem *self) +{ + g_return_val_if_fail (RSS_IS_ITEM (self), NULL); + + return self->priv->source_url; +} + +/** + * rss_item_get_categories: + * @self: a #RssItem + * + * Returns a copy of the list of categories for the #RssItem. The data + * in the linked list are pointers to strings (char*). They are owned + * by the #RssItem and should not be modified. Use g_strdup() to copy + * the individual strings. + * + * Returns: a new #GList which should be freed with g_list_free(). + */ +GList* +rss_item_get_categories (RssItem *self) +{ + g_return_val_if_fail (RSS_IS_ITEM (self), NULL); + + return g_list_copy (self->priv->categories); +} diff --git a/extern/rss-glib/rss-item.h b/extern/rss-glib/rss-item.h new file mode 100644 index 0000000..678b88e --- /dev/null +++ b/extern/rss-glib/rss-item.h @@ -0,0 +1,95 @@ +/* rss-item.h + * + * This file is part of RSS-GLib. + * Copyright (C) 2008 Christian Hergert <chris@dronelabs.com> + * + * This library is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library. If not, see <http://www.gnu.org/licenses/>. + * + * Author: + * Christian Hergert <chris@dronelabs.com> + */ + +#ifndef __RSS_ITEM_H__ +#define __RSS_ITEM_H__ + +#include <glib-object.h> + +G_BEGIN_DECLS + +#define RSS_TYPE_ITEM rss_item_get_type() + +#define RSS_ITEM(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ + RSS_TYPE_ITEM, \ + RssItem)) + +#define RSS_ITEM_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST ((klass), \ + RSS_TYPE_ITEM, \ + RssItemClass)) + +#define RSS_IS_ITEM(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \ + RSS_TYPE_ITEM)) + +#define RSS_IS_ITEM_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE ((klass), \ + RSS_TYPE_ITEM)) + +#define RSS_ITEM_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS ((obj), \ + RSS_TYPE_ITEM, \ + RssItemClass)) + +typedef struct _RssItem RssItem; +typedef struct _RssItemPrivate RssItemPrivate; +typedef struct _RssItemClass RssItemClass; + +struct _RssItem +{ + /*< private >*/ + GObject parent_instance; + + RssItemPrivate *priv; +}; + +struct _RssItemClass +{ + /*< private >*/ + GObjectClass parent_class; +}; + +GType rss_item_get_type (void); +RssItem* rss_item_new (void); + +const gchar *rss_item_get_guid (RssItem *self); +const gchar *rss_item_get_title (RssItem *self); +const gchar *rss_item_get_link (RssItem *self); +const gchar *rss_item_get_description (RssItem *self); +const gchar *rss_item_get_copyright (RssItem *self); +const gchar *rss_item_get_author_name (RssItem *self); +const gchar *rss_item_get_author_uri (RssItem *self); +const gchar *rss_item_get_author_email (RssItem *self); +const gchar *rss_item_get_contributor_name (RssItem *self); +const gchar *rss_item_get_contributor_uri (RssItem *self); +const gchar *rss_item_get_contributor_email (RssItem *self); +const gchar *rss_item_get_comments (RssItem *self); +const gchar *rss_item_get_pub_date (RssItem *self); +const gchar *rss_item_get_source (RssItem *self); +const gchar *rss_item_get_source_url (RssItem *self); +GList* rss_item_get_categories (RssItem *self); + +G_END_DECLS + +#endif /* __RSS_ITEM_H__ */ diff --git a/extern/rss-glib/rss-parser-private.h b/extern/rss-glib/rss-parser-private.h new file mode 100644 index 0000000..eaddb9e --- /dev/null +++ b/extern/rss-glib/rss-parser-private.h @@ -0,0 +1,45 @@ +/* rss-parser-private.h + * + * This file is part of RSS-GLib. + * Copyright (C) 2008 Christian Hergert <chris@dronelabs.com> + * + * This library is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library. If not, see <http://www.gnu.org/licenses/>. + * + * Author: + * Christian Hergert <chris@dronelabs.com> + */ + +#ifndef __RSS_PARSER_PRIVATE_H__ +#define __RSS_PARSER_PRIVATE_H__ + +#include <glib-object.h> + +G_BEGIN_DECLS + +struct _RssParserPrivate +{ + RssDocument *document; +}; + +typedef enum +{ + RSS_PARSER_ERROR_INVALID_DATA, +} RssParserError; + +#define RSS_PARSER_ERROR rss_parser_error_quark() +GQuark rss_parser_error_quark (void); + +G_END_DECLS + +#endif /* __RSS_PARSER_PRIVATE_H__ */ diff --git a/extern/rss-glib/rss-parser.c b/extern/rss-glib/rss-parser.c new file mode 100644 index 0000000..184db19 --- /dev/null +++ b/extern/rss-glib/rss-parser.c @@ -0,0 +1,334 @@ +/* rss-generator.c + * + * This file is part of RSS-GLib. + * Copyright (C) 2008 Christian Hergert <chris@dronelabs.com> + * + * This library is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library. If not, see <http://www.gnu.org/licenses/>. + * + * Author: + * Christian Hergert <chris@dronelabs.com> + */ + +/** + * SECTION:rss-parser + * @short_description: Parse RSS data streams + * + * #RssParser provides an object for parsing a RSS data stream, either + * inside a file or inside a static buffer. + */ + +#include "rss-parser.h" +#include "rss-parser-private.h" + +#include "rss-item.h" +#include "rss-item-private.h" + +#include "rss-document.h" +#include "rss-document-private.h" + +GQuark +rss_parser_error_quark (void) +{ + return g_quark_from_static_string ("rss_parser_error"); +} + +enum +{ + PARSE_START, + PARSE_END, + + LAST_SIGNAL +}; + +static guint parser_signals[LAST_SIGNAL] = { 0, }; + +G_DEFINE_TYPE (RssParser, rss_parser, G_TYPE_OBJECT); + +static void +rss_parser_dispose (GObject *object) +{ + RssParserPrivate *priv = RSS_PARSER (object)->priv; + + if (priv->document) { + g_object_unref (priv->document); + priv->document = NULL; + } + + G_OBJECT_CLASS (rss_parser_parent_class)->dispose (object); +} + +static void +rss_parser_class_init (RssParserClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + g_type_class_add_private (klass, sizeof (RssParserPrivate)); + object_class->dispose = rss_parser_dispose; + + /** + * RssParser::parse-start: + * @parser: the #RssParser that received the signal + * + * The ::parse-signal is emitted when the parser began parsing + * a RSS data stream. + */ + parser_signals[PARSE_START] = + g_signal_new ("parse-start", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (RssParserClass, parse_start), + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); + + /** + * RssParser::parse-end: + * @parser: the #RssParser that received the signal + * + * The ::parse-end signal is emitted when the parser successfully + * finished parsing a RSS data stream. + */ + parser_signals[PARSE_END] = + g_signal_new ("parse-end", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (RssParserClass, parse_end), + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); +} + +static void +rss_parser_init (RssParser *self) +{ + self->priv = + G_TYPE_INSTANCE_GET_PRIVATE (self, RSS_TYPE_PARSER, + RssParserPrivate); +} + +/** + * rss_parser_new: + * + * Creates a new #RssParser instance. You can use the #RssParser to + * load a RSS stream from either a file or a buffer and then walk the + * items discovered through the resulting RssDocument. + * + * Return value: the new created #RssParser. Use g_object_unref() to + * release all the memory it allocates. + */ +RssParser* +rss_parser_new (void) +{ + return g_object_new (RSS_TYPE_PARSER, NULL); +} + +static RssDocument* +rss_parser_parse (RssParser *self, mrss_t *mrss) +{ + RssDocument *document; + RssItem *rss_item; + GList *list, *list2; + mrss_category_t *cat; + mrss_item_t *item; + + g_return_val_if_fail (RSS_IS_PARSER (self), NULL); + g_return_val_if_fail (mrss != NULL, NULL); + + /* create our document object */ + document = rss_document_new (); + + /* set our document level properties */ + g_object_set (document, + "encoding", mrss->encoding, + "guid", mrss->id, + "title", mrss->title, + "description", mrss->description, + "link", mrss->link, + "language", mrss->language, + "rating", mrss->rating, + "copyright", mrss->copyright, + "pub-date", mrss->pubDate, + "ttl", mrss->ttl, + "about", mrss->about, + "contributor", mrss->contributor, + "contributor-email", mrss->contributor_email, + "contributor-uri", mrss->contributor_uri, + "generator", mrss->generator, + "generator-uri", mrss->generator_uri, + "generator-version", mrss->generator_version, + "image-title", mrss->image_title, + "image-url", mrss->image_url, + "image-link", mrss->image_link, + NULL); + + /* build the list of categories */ + if (NULL != (cat = mrss->category)) { + list = NULL; + do { + list = g_list_prepend (list, g_strdup (cat->category)); + } while (NULL != (cat = cat->next)); + document->priv->categories = list; + } + + /* build the list of items */ + if (NULL != (item = mrss->item)) { + list = NULL; + do { + rss_item = rss_item_new (); + + /* set the rss item properties */ + g_object_set (rss_item, + "guid", item->guid, + "title", item->title, + "link", item->link, + "description", item->description, + "copyright", item->copyright, + "author", item->author, + "author-uri", item->author_uri, + "author-email", item->author_email, + "contributor", item->contributor, + "contributor-uri", item->contributor_uri, + "contributor-email", item->contributor_email, + "comments", item->comments, + "pub-date", item->pubDate, + "source", item->source, + "source-url", item->source_url, + NULL); + + /* parse the items categories */ + if (NULL != (cat = item->category)) { + list2 = NULL; + do { + list2 = g_list_prepend (list2, g_strdup (cat->category)); + } while (NULL != (cat = cat->next)); + rss_item->priv->categories = list2; + } + + list = g_list_prepend (list, rss_item); + } while (NULL != (item = item->next)); + document->priv->items = list; + } + + return document; +} + +/** + * rss_parser_load_from_data: + * @self: a #RssParser + * @data: a buffer containing the syndication data + * @length: the length of the buffer + * @error: a location to place a newly created GError in case of error + * + * Parses the contents found at @data as an rss file. You can retrieve + * the parsed document with rss_parser_get_document(). + * + * Returns: TRUE on success. + */ +gboolean +rss_parser_load_from_data (RssParser *self, + const gchar *data, + gsize length, + GError **error) +{ + mrss_t *mrss; + mrss_error_t res; + + g_signal_emit (self, parser_signals[PARSE_START], 0); + + /* parse the buffer */ + res = mrss_parse_buffer ((char*)data, length, &mrss); + + /* if there was an error parsing, set the error and return false */ + if (MRSS_OK != res) { + if (error) { + g_set_error (error, RSS_PARSER_ERROR, + RSS_PARSER_ERROR_INVALID_DATA, + "Could not parse data contents"); + } + return FALSE; + } + + /* keep a copy of our parsed document */ + self->priv->document = rss_parser_parse (self, mrss); + + /* free our mrss data */ + mrss_free (mrss); + + g_signal_emit (self, parser_signals[PARSE_END], 0); + + return TRUE; +} + +/** + * rss_parser_load_from_file: + * @self: a #RssParser + * @filename: the path to the file to parse + * @error: a location for a newly created #GError + * + * Parses the file found at @filename as an rss file. You can retrieve + * the parsed document with rss_parser_get_document(). + * + * Returns: TRUE if the parse was successful + */ +gboolean +rss_parser_load_from_file (RssParser *self, + gchar *filename, + GError **error) +{ + mrss_t *mrss; + mrss_error_t res; + + g_signal_emit (self, parser_signals[PARSE_START], 0); + + /* parse the buffer */ + res = mrss_parse_file (filename, &mrss); + + /* if there was an error parsing, set the error and return false */ + if (MRSS_OK != res) { + if (error) { + g_set_error (error, RSS_PARSER_ERROR, + RSS_PARSER_ERROR_INVALID_DATA, + "Could not parse file contents"); + } + return FALSE; + } + + /* keep a copy of our parsed document */ + self->priv->document = rss_parser_parse (self, mrss); + + /* free our mrss data */ + mrss_free (mrss); + + g_signal_emit (self, parser_signals[PARSE_END], 0); + + return TRUE; +} + +/** + * rss_parser_get_document: + * @self: a #RssParser + * + * Retreives the document result from parsing rss data from either + * a buffer or a file. The document's ref-count is increased, so + * call g_object_unref when you are done. + * + * Returns: a #RssDocument + */ +RssDocument* +rss_parser_get_document (RssParser *self) +{ + g_return_val_if_fail (RSS_IS_PARSER (self), NULL); + + return g_object_ref (self->priv->document); +} diff --git a/extern/rss-glib/rss-parser.h b/extern/rss-glib/rss-parser.h new file mode 100644 index 0000000..6ab95a3 --- /dev/null +++ b/extern/rss-glib/rss-parser.h @@ -0,0 +1,102 @@ +/* rss-parser.h + * + * This file is part of RSS-GLib. + * Copyright (C) 2008 Christian Hergert <chris@dronelabs.com> + * + * This library is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library. If not, see <http://www.gnu.org/licenses/>. + * + * Author: + * Christian Hergert <chris@dronelabs.com> + */ + +#ifndef __RSS_PARSER_H__ +#define __RSS_PARSER_H__ + +#include <glib-object.h> +#include "rss-document.h" + +G_BEGIN_DECLS + +#define RSS_TYPE_PARSER rss_parser_get_type() + +#define RSS_PARSER(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ + RSS_TYPE_PARSER, \ + RssParser)) + +#define RSS_PARSER_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST ((klass), \ + RSS_TYPE_PARSER, \ + RssParserClass)) + +#define RSS_IS_PARSER(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \ + RSS_TYPE_PARSER)) + +#define RSS_IS_PARSER_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE ((klass), \ + RSS_TYPE_PARSER)) + +#define RSS_PARSER_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS ((obj), \ + RSS_TYPE_PARSER, \ + RssParserClass)) + +typedef struct _RssParser RssParser; +typedef struct _RssParserPrivate RssParserPrivate; +typedef struct _RssParserClass RssParserClass; + +struct _RssParser +{ + /*< private >*/ + GObject parent_instance; + + RssParserPrivate *priv; +}; + +struct _RssParserClass +{ + /*< private >*/ + GObjectClass parent_class; + + /*< public >*/ + void (* parse_start) (RssParser *parser); + void (* parse_end) (RssParser *parser); + + /*< private >*/ + /* padding for future expansion */ + void (* _rss_reserved1) (void); + void (* _rss_reserved2) (void); + void (* _rss_reserved3) (void); + void (* _rss_reserved4) (void); + void (* _rss_reserved5) (void); + void (* _rss_reserved6) (void); + void (* _rss_reserved7) (void); + void (* _rss_reserved8) (void); +}; + +GType rss_parser_get_type (void); +RssParser* rss_parser_new (void); +gboolean rss_parser_load_from_data (RssParser * self, + const gchar *data, + gsize length, + GError **error); +gboolean rss_parser_load_from_file (RssParser *self, + gchar *filename, + GError **error); +RssDocument* rss_parser_get_document (RssParser *self); + +G_END_DECLS + +#endif /* __RSS_PARSER_H__ */ diff --git a/extern/rss-glib/rss-version.h b/extern/rss-glib/rss-version.h new file mode 100644 index 0000000..6a61852 --- /dev/null +++ b/extern/rss-glib/rss-version.h @@ -0,0 +1,96 @@ +/* rss-version.h - RSS-GLib versioning information + * + * This file is part of RSS-GLib. + * Copyright (C) 2008 Christian Hergert <chris@dronelabs.com> + * + * This library is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library. If not, see <http://www.gnu.org/licenses/>. + * + * Author: + * Christian Hergert <chris@dronelabs.com> + */ + +#ifndef __RSS_VERSION_H__ +#define __RSS_VERSION_H__ + +/** + * SECTION:rss-version + * @title: Versioning + * @short_description: RSS-GLib version checking + * + * RSS-GLib provides macros to check the version of the library + * at compile-time + */ + +/** + * RSS_MAJOR_VERSION: + * + * Rss major version component (e.g. 1 if %RSS_VERSION is 1.2.3) + */ +#define RSS_MAJOR_VERSION (0) + +/** + * RSS_MINOR_VERSION: + * + * Rss minor version component (e.g. 2 if %RSS_VERSION is 1.2.3) + */ +#define RSS_MINOR_VERSION (2) + +/** + * RSS_MICRO_VERSION: + * + * Rss micro version component (e.g. 3 if %RSS_VERSION is 1.2.3) + */ +#define RSS_MICRO_VERSION (3) + +/** + * RSS_VERSION + * + * Rss version. + */ +#define RSS_VERSION (0.2.3) + +/** + * RSS_VERSION_S: + * + * Rss version, encoded as a string, useful for printing and + * concatenation. + */ +#define RSS_VERSION_S "0.2.3" + +/** + * RSS_VERSION_HEX: + * + * Rss version, encoded as an hexadecimal number, useful for + * integer comparisons. + */ +#define RSS_VERSION_HEX (RSS_MAJOR_VERSION << 24 | \ + RSS_MINOR_VERSION << 16 | \ + RSS_MICRO_VERSION << 8) + +/** + * RSS_CHECK_VERSION: + * @major: required major version + * @minor: required minor version + * @micro: required micro version + * + * Compile-time version checking. Evaluates to %TRUE if the version + * of Rss is greater than the required one. + */ +#define RSS_CHECK_VERSION(major,minor,micro) \ + (RSS_MAJOR_VERSION > (major) || \ + (RSS_MAJOR_VERSION == (major) && RSS_MINOR_VERSION > (minor)) || \ + (RSS_MAJOR_VERSION == (major) && RSS_MINOR_VERSION == (minor) && \ + RSS_MICRO_VERSION >= (micro))) + +#endif /* __RSS_VERSION_H__ */ diff --git a/m4/gconf-2.m4 b/m4/gconf-2.m4 deleted file mode 100644 index 4a0936e..0000000 --- a/m4/gconf-2.m4 +++ /dev/null @@ -1,44 +0,0 @@ -dnl AM_GCONF_SOURCE_2 -dnl Defines GCONF_SCHEMA_CONFIG_SOURCE which is where you should install schemas -dnl (i.e. pass to gconftool-2 -dnl Defines GCONF_SCHEMA_FILE_DIR which is a filesystem directory where -dnl you should install foo.schemas files -dnl - -AC_DEFUN([AM_GCONF_SOURCE_2], -[ - if test "x$GCONF_SCHEMA_INSTALL_SOURCE" = "x"; then - GCONF_SCHEMA_CONFIG_SOURCE=`gconftool-2 --get-default-source` - else - GCONF_SCHEMA_CONFIG_SOURCE=$GCONF_SCHEMA_INSTALL_SOURCE - fi - - AC_ARG_WITH([gconf-source], - AC_HELP_STRING([--with-gconf-source=sourceaddress], - [Config database for installing schema files.]), - [GCONF_SCHEMA_CONFIG_SOURCE="$withval"],) - - AC_SUBST(GCONF_SCHEMA_CONFIG_SOURCE) - AC_MSG_RESULT([Using config source $GCONF_SCHEMA_CONFIG_SOURCE for schema installation]) - - if test "x$GCONF_SCHEMA_FILE_DIR" = "x"; then - GCONF_SCHEMA_FILE_DIR='$(sysconfdir)/gconf/schemas' - fi - - AC_ARG_WITH([gconf-schema-file-dir], - AC_HELP_STRING([--with-gconf-schema-file-dir=dir], - [Directory for installing schema files.]), - [GCONF_SCHEMA_FILE_DIR="$withval"],) - - AC_SUBST(GCONF_SCHEMA_FILE_DIR) - AC_MSG_RESULT([Using $GCONF_SCHEMA_FILE_DIR as install directory for schema files]) - - AC_ARG_ENABLE(schemas-install, - AC_HELP_STRING([--disable-schemas-install], - [Disable the schemas installation]), - [case ${enableval} in - yes|no) ;; - *) AC_MSG_ERROR([bad value ${enableval} for --enable-schemas-install]) ;; - esac]) - AM_CONDITIONAL([GCONF_SCHEMAS_INSTALL], [test "$enable_schemas_install" != no]) -]) diff --git a/src/Makefile.am b/src/Makefile.am index 7cb7801..ec29eba 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -44,7 +44,7 @@ desktop_DATA = transmission-remote-gtk.desktop endif bin_PROGRAMS = transmission-remote-gtk -INCLUDES = -std=c99 -Wall -I.. -Wno-overflow -DTRGLICENSE=\""$(trglicense)"\" $(libcurl_CFLAGS) $(jsonglib_CFLAGS) $(gthread_CFLAGS) $(gtk_CFLAGS) $(gio_CFLAGS) $(notify_CFLAGS) $(libproxy_CFLAGS) $(libappindicator_CFLAGS) $(rssglib_CFLAGS) +AM_CFLAGS = -std=c99 -Wall -I.. -Wno-overflow -DTRGLICENSE=\""$(trglicense)"\" $(libcurl_CFLAGS) $(jsonglib_CFLAGS) $(gthread_CFLAGS) $(gtk_CFLAGS) $(gio_CFLAGS) $(notify_CFLAGS) $(libproxy_CFLAGS) $(libappindicator_CFLAGS) $(mrss_CFLAGS) -I../extern transmission_remote_gtk_SOURCES = \ trg-cell-renderer-speed.c \ @@ -105,13 +105,16 @@ transmission_remote_gtk_SOURCES = \ trg-client.c \ trg-main-window.c \ main.c \ - trg-rss-model.c \ - trg-rss-window.c \ - trg-rss-cell-renderer.c \ upload.c \ $(NULL) -transmission_remote_gtk_LDFLAGS = -lm $(jsonglib_LIBS) $(gtk_LIBS) $(gthread_LIBS) $(GEOIP_LIBS) $(gio_LIBS) $(notify_LIBS) $(libproxy_LIBS) $(libcurl_LIBS) $(libappindicator_LIBS) $(rssglib_LIBS) +transmission_remote_gtk_LDFLAGS = -lm $(jsonglib_LIBS) $(gtk_LIBS) $(gthread_LIBS) $(GEOIP_LIBS) $(gio_LIBS) $(notify_LIBS) $(libproxy_LIBS) $(libcurl_LIBS) $(libappindicator_LIBS) + +if HAVE_RSS +transmission_remote_gtk_LDFLAGS += $(mrss_LIBS) ../extern/rss-glib/librss.la + +transmission_remote_gtk_SOURCES += trg-rss-model.c trg-rss-window.c trg-rss-cell-renderer.c +endif if WIN32 .rc.o: @@ -122,7 +125,7 @@ if WIN32 CFLAGS += -mms-bitfields -mwin32 -mwindows LDFLAGS += -Wl,--allow-multiple-definition -lws2_32 -lintl transmission_remote_gtk_SOURCES += win32.rc win32-mailslot.c -INCLUDES += -O2 +AM_CFLAGS += -O2 else %.1: %.pod pod2man --release="" --center="Transmission Remote GTK" $< > $@ diff --git a/src/trg-main-window.c b/src/trg-main-window.c index 4cf6047..561dd59 100644 --- a/src/trg-main-window.c +++ b/src/trg-main-window.c @@ -71,7 +71,7 @@ #include "trg-menu-bar.h" #include "trg-status-bar.h" #include "trg-stats-dialog.h" -#ifdef HAVE_RSSGLIB +#ifdef HAVE_RSS #include "trg-rss-window.h" #endif #include "trg-remote-prefs-dialog.h" @@ -930,7 +930,7 @@ static void view_stats_toggled_cb(GtkWidget * w, gpointer data) } } -#ifdef HAVE_RSSGLIB +#ifdef HAVE_RSS static void view_rss_toggled_cb(GtkWidget * w, gpointer data) { TrgMainWindow *win = TRG_MAIN_WINDOW(data); @@ -1766,7 +1766,7 @@ static TrgMenuBar *trg_main_window_menu_bar_new(TrgMainWindow * win) #if TRG_WITH_GRAPH *b_show_graph, #endif -#ifdef HAVE_RSSGLIB +#ifdef HAVE_RSS *b_view_rss, #endif *b_start_now; @@ -1797,7 +1797,7 @@ static TrgMenuBar *trg_main_window_menu_bar_new(TrgMainWindow * win) #if TRG_WITH_GRAPH "show-graph", &b_show_graph, #endif -#ifdef HAVE_RSSGLIB +#ifdef HAVE_RSS "view-rss-button", &b_view_rss, #endif "up-queue", &b_up_queue, "down-queue", &b_down_queue, @@ -1844,7 +1844,7 @@ static TrgMenuBar *trg_main_window_menu_bar_new(TrgMainWindow * win) G_CALLBACK(view_states_toggled_cb), win); g_signal_connect(b_view_stats, "activate", G_CALLBACK(view_stats_toggled_cb), win); -#ifdef HAVE_RSSGLIB +#ifdef HAVE_RSS g_signal_connect(b_view_rss, "activate", G_CALLBACK(view_rss_toggled_cb), win); #endif diff --git a/src/trg-menu-bar.c b/src/trg-menu-bar.c index 37c6c2c..3f724aa 100644 --- a/src/trg-menu-bar.c +++ b/src/trg-menu-bar.c @@ -51,7 +51,7 @@ enum { PROP_LOCAL_PREFS_BUTTON, PROP_ABOUT_BUTTON, PROP_VIEW_STATS_BUTTON, -#ifdef HAVE_RSSGLIB +#ifdef HAVE_RSS PROP_VIEW_RSS_BUTTON, #endif PROP_VIEW_STATES_BUTTON, @@ -101,7 +101,7 @@ struct _TrgMenuBarPrivate { GtkWidget *mb_view_states; GtkWidget *mb_view_notebook; GtkWidget *mb_view_stats; -#ifdef HAVE_RSSGLIB +#ifdef HAVE_RSS GtkWidget *mb_view_rss; #endif GtkWidget *mb_about; @@ -148,7 +148,7 @@ void trg_menu_bar_connected_change(TrgMenuBar * mb, gboolean connected) gtk_widget_set_sensitive(priv->mb_disconnect, connected); gtk_widget_set_sensitive(priv->mb_remote_prefs, connected); gtk_widget_set_sensitive(priv->mb_view_stats, connected); -#ifdef HAVE_RSSGLIB +#ifdef HAVE_RSS gtk_widget_set_sensitive(priv->mb_view_rss, connected); #endif gtk_widget_set_sensitive(priv->mb_resume_all, connected); @@ -284,7 +284,7 @@ trg_menu_bar_get_property(GObject * object, guint property_id, case PROP_VIEW_STATS_BUTTON: g_value_set_object(value, priv->mb_view_stats); break; -#ifdef HAVE_RSSGLIB +#ifdef HAVE_RSS case PROP_VIEW_RSS_BUTTON: g_value_set_object(value, priv->mb_view_rss); break; @@ -558,7 +558,7 @@ static GtkWidget *trg_menu_bar_view_menu_new(TrgMenuBar * mb) gtk_widget_set_sensitive(priv->mb_view_stats, FALSE); gtk_menu_shell_append(GTK_MENU_SHELL(viewMenu), priv->mb_view_stats); -#ifdef HAVE_RSSGLIB +#ifdef HAVE_RSS priv->mb_view_rss = gtk_menu_item_new_with_mnemonic(_("_RSS")); //trg_menu_bar_accel_add(mb, priv->mb_view_rss, GDK_F7, 0); @@ -894,7 +894,7 @@ static void trg_menu_bar_class_init(TrgMenuBarClass * klass) trg_menu_bar_install_widget_prop(object_class, PROP_VIEW_STATS_BUTTON, "view-stats-button", "View stats button"); -#ifdef HAVE_RSSGLIB +#ifdef HAVE_RSS trg_menu_bar_install_widget_prop(object_class, PROP_VIEW_RSS_BUTTON, "view-rss-button", "View rss button"); diff --git a/src/trg-preferences-dialog.c b/src/trg-preferences-dialog.c index 5c0204f..9503005 100644 --- a/src/trg-preferences-dialog.c +++ b/src/trg-preferences-dialog.c @@ -618,7 +618,7 @@ static GtkWidget *trg_prefs_openExecPage(TrgPreferencesDialog * dlg) return t; } -#ifdef HAVE_RSSGLIB +#ifdef HAVE_RSS static GtkWidget *trg_prefs_rss_page(TrgPreferencesDialog * dlg) { TrgPreferencesDialogPrivate *priv = TRG_PREFERENCES_DIALOG_GET_PRIVATE(dlg); @@ -948,7 +948,7 @@ static GObject *trg_preferences_dialog_constructor(GType type, (object)), gtk_label_new(_("Directories"))); -#ifdef HAVE_RSSGLIB +#ifdef HAVE_RSS gtk_notebook_append_page(GTK_NOTEBOOK(notebook), trg_prefs_rss_page(TRG_PREFERENCES_DIALOG (object)), diff --git a/src/trg-rss-cell-renderer.c b/src/trg-rss-cell-renderer.c index 4765f2c..540960e 100644 --- a/src/trg-rss-cell-renderer.c +++ b/src/trg-rss-cell-renderer.c @@ -1,6 +1,6 @@ #include "config.h" -#ifdef HAVE_RSSGLIB +#ifdef HAVE_RSS #include <gtk/gtk.h> #include <gdk/gdk.h> diff --git a/src/trg-rss-cell-renderer.h b/src/trg-rss-cell-renderer.h index a255d90..dbd3a6e 100644 --- a/src/trg-rss-cell-renderer.h +++ b/src/trg-rss-cell-renderer.h @@ -22,7 +22,7 @@ #include "config.h" -#ifdef HAVE_RSSGLIB +#ifdef HAVE_RSS #include <gtk/gtk.h> diff --git a/src/trg-rss-model.c b/src/trg-rss-model.c index 6e95238..c1162f1 100644 --- a/src/trg-rss-model.c +++ b/src/trg-rss-model.c @@ -19,7 +19,7 @@ #include "config.h" -#ifdef HAVE_RSSGLIB +#ifdef HAVE_RSS #include <gtk/gtk.h> #include <json-glib/json-glib.h> diff --git a/src/trg-rss-model.h b/src/trg-rss-model.h index ddecc95..21b5a70 100644 --- a/src/trg-rss-model.h +++ b/src/trg-rss-model.h @@ -22,7 +22,7 @@ #include "config.h" -#ifdef HAVE_RSSGLIB +#ifdef HAVE_RSS #include <glib-object.h> #include <json-glib/json-glib.h> diff --git a/src/trg-rss-window.c b/src/trg-rss-window.c index 15a4c1a..d2a7722 100644 --- a/src/trg-rss-window.c +++ b/src/trg-rss-window.c @@ -19,7 +19,7 @@ #include "config.h" -#ifdef HAVE_RSSGLIB +#ifdef HAVE_RSS #include <gtk/gtk.h> #include <glib/gi18n.h> diff --git a/src/trg-rss-window.h b/src/trg-rss-window.h index 5ce8690..ebf4ca6 100644 --- a/src/trg-rss-window.h +++ b/src/trg-rss-window.h @@ -22,7 +22,7 @@ #include "config.h" -#ifdef HAVE_RSSGLIB +#ifdef HAVE_RSS #include <glib-object.h> #include <gtk/gtk.h> |