From 91356636c1e2d02a76ff31189e106de53b569c49 Mon Sep 17 00:00:00 2001 From: Alan F Date: Sun, 13 Apr 2014 17:36:26 +0100 Subject: bundle the libmrss wrapper to make building easier --- extern/rss-glib/Makefile.am | 43 ++ extern/rss-glib/rss-document-private.h | 58 ++ extern/rss-glib/rss-document.c | 1085 ++++++++++++++++++++++++++++++++ extern/rss-glib/rss-document.h | 105 ++++ extern/rss-glib/rss-glib.h | 9 + extern/rss-glib/rss-item-private.h | 46 ++ extern/rss-glib/rss-item.c | 738 ++++++++++++++++++++++ extern/rss-glib/rss-item.h | 95 +++ extern/rss-glib/rss-parser-private.h | 45 ++ extern/rss-glib/rss-parser.c | 334 ++++++++++ extern/rss-glib/rss-parser.h | 102 +++ extern/rss-glib/rss-version.h | 96 +++ 12 files changed, 2756 insertions(+) create mode 100644 extern/rss-glib/Makefile.am create mode 100644 extern/rss-glib/rss-document-private.h create mode 100644 extern/rss-glib/rss-document.c create mode 100644 extern/rss-glib/rss-document.h create mode 100644 extern/rss-glib/rss-glib.h create mode 100644 extern/rss-glib/rss-item-private.h create mode 100644 extern/rss-glib/rss-item.c create mode 100644 extern/rss-glib/rss-item.h create mode 100644 extern/rss-glib/rss-parser-private.h create mode 100644 extern/rss-glib/rss-parser.c create mode 100644 extern/rss-glib/rss-parser.h create mode 100644 extern/rss-glib/rss-version.h (limited to 'extern/rss-glib') 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 + * + * 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 . + * + * Author: + * Christian Hergert + */ + +#ifndef __RSS_DOCUMENT_PRIVATE_H__ +#define __RSS_DOCUMENT_PRIVATE_H__ + +#include + +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 + * + * 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 . + * + * Author: + * Christian Hergert + */ + +/** + * 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 #RssItems 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 #RssItems 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 + * + * 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 . + * + * Author: + * Christian Hergert + */ + +#ifndef __RSS_DOCUMENT_H__ +#define __RSS_DOCUMENT_H__ + +#include + +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 +#include +#include +#include + +#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 + * + * 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 . + * + * Author: + * Christian Hergert + */ + +#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 + * + * 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 . + * + * Author: + * Christian Hergert + */ + +/** + * 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 + * + * 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 . + * + * Author: + * Christian Hergert + */ + +#ifndef __RSS_ITEM_H__ +#define __RSS_ITEM_H__ + +#include + +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 + * + * 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 . + * + * Author: + * Christian Hergert + */ + +#ifndef __RSS_PARSER_PRIVATE_H__ +#define __RSS_PARSER_PRIVATE_H__ + +#include + +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 + * + * 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 . + * + * Author: + * Christian Hergert + */ + +/** + * 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 + * + * 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 . + * + * Author: + * Christian Hergert + */ + +#ifndef __RSS_PARSER_H__ +#define __RSS_PARSER_H__ + +#include +#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 + * + * 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 . + * + * Author: + * Christian Hergert + */ + +#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__ */ -- cgit v1.2.3