r1610 - trunk/src/target/OM-2007/applications/openmoko-rssreader/src

zecke at sita.openmoko.org zecke at sita.openmoko.org
Mon Apr 2 00:53:41 CEST 2007


Author: zecke
Date: 2007-04-02 00:53:41 +0200 (Mon, 02 Apr 2007)
New Revision: 1610

Added:
   trunk/src/target/OM-2007/applications/openmoko-rssreader/src/rfcdate.c
   trunk/src/target/OM-2007/applications/openmoko-rssreader/src/rfcdate.h
Modified:
   trunk/src/target/OM-2007/applications/openmoko-rssreader/src/Makefile.am
Log:
RSS Reader: start creating a GObject to store the RSS Date

    The RSS Date is from RFC822 and glib lacks something
    like QDateTime. This class creates something similiar. It
    will be used inside the GtkTreeModelSort to allow fast
    sorting by date.
    Using a custom cell renderer we can then exchange the
    date to "today", "yesterday".
    But this commit only adds the GObject skeleton...


Modified: trunk/src/target/OM-2007/applications/openmoko-rssreader/src/Makefile.am
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-rssreader/src/Makefile.am	2007-04-01 21:26:01 UTC (rev 1609)
+++ trunk/src/target/OM-2007/applications/openmoko-rssreader/src/Makefile.am	2007-04-01 22:53:41 UTC (rev 1610)
@@ -7,8 +7,8 @@
 
 bin_PROGRAMS = openmoko-rssreader
 
-EXTRA_DIST = application-data.h callbacks.h
+EXTRA_DIST = application-data.h callbacks.h rfcdate.h
 
-openmoko_rssreader_SOURCES = main.c callbacks.c
+openmoko_rssreader_SOURCES = main.c callbacks.c rfcdate.c
 openmoko_rssreader_LDADD = @OPENMOKO_LIBS@ @MRSS_LIBS@ @GTHREAD_LIBS@
 

Added: trunk/src/target/OM-2007/applications/openmoko-rssreader/src/rfcdate.c
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-rssreader/src/rfcdate.c	2007-04-01 21:26:01 UTC (rev 1609)
+++ trunk/src/target/OM-2007/applications/openmoko-rssreader/src/rfcdate.c	2007-04-01 22:53:41 UTC (rev 1610)
@@ -0,0 +1,100 @@
+/*
+ *  RSS Reader, a simple RSS reader
+ *  RFC822 date parser implementation
+ *
+ *  Copyright (C) 2007 Holger Hans Peter Freyther
+ *
+ *  Permission is hereby granted, free of charge, to any person obtaining a
+ *  copy of this software and associated documentation files (the "Software"),
+ *  to deal in the Software without restriction, including without limitation
+ *  the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ *  and/or sell copies of the Software, and to permit persons to whom the
+ *  Software is furnished to do so, subject to the following conditions:
+ *
+ *  The above copyright notice and this permission notice shall be included
+ *  in all copies or substantial portions of the Software.
+ *
+ *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ *  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ *  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ *  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ *  OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ *  ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ *  OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *  Current Version: $Rev$ ($Date$) [$Author$]
+ */
+
+#include "rfcdate.h"
+
+#include <malloc.h>
+
+G_DEFINE_TYPE(RSSRFCDate, rss_rfc_date, G_TYPE_OBJECT)
+
+#define RSS_RFC_DATE_GET_PRIVATE(o)   (G_TYPE_INSTANCE_GET_PRIVATE((o), RSS_TYPE_RFC_DATE, RSSRFCDatePrivate))
+
+typedef struct _RSSRFCDatePrivate RSSRFCDatePrivate;
+struct _RSSRFCDatePrivate {
+    gchar *string_cache;
+};
+
+static void
+rss_rfc_date_finalize (GObject *object)
+{
+    if ( RSS_RFC_DATE_GET_PRIVATE(object)->string_cache )
+        free (RSS_RFC_DATE_GET_PRIVATE(object)->string_cache);
+
+    G_OBJECT_CLASS(rss_rfc_date_parent_class)->finalize (object);
+}
+
+static void
+rss_rfc_date_class_init (RSSRFCDateClass *klass)
+{
+    g_type_class_add_private (klass, sizeof (RSSRFCDatePrivate));
+
+    /*
+     * virtual functions
+     */
+    G_OBJECT_CLASS(klass)->finalize = rss_rfc_date_finalize;
+}
+
+static void
+rss_rfc_date_init(RSSRFCDate *self)
+{
+    /* I don't know if memset gets called */
+    RSS_RFC_DATE_GET_PRIVATE(self)->string_cache = NULL;
+}
+
+GObject*
+rss_rfc_date_new ()
+{
+    return G_OBJECT(g_object_new(RSS_TYPE_RFC_DATE, NULL));
+}
+
+void
+rss_rfc_date_set (RSSRFCDate *self, const gchar* rfc822date)
+{
+    if ( RSS_RFC_DATE_GET_PRIVATE(self)->string_cache ) {
+        free ( RSS_RFC_DATE_GET_PRIVATE(self)->string_cache );
+        RSS_RFC_DATE_GET_PRIVATE(self)->string_cache = NULL;
+    }
+
+
+    /*
+     * XXX parse the date
+     */
+}
+
+gint
+rss_rfc_date_compare (RSSRFCDate *left, RSSRFCDate *right)
+{
+    /* XXX, FIXME do the comparsion */
+    return 0;
+}
+
+gchar*
+rss_rfc_date_as_string (RSSRFCDate *self)
+{
+    /* XXX, FIXME */
+    return "";
+}

Added: trunk/src/target/OM-2007/applications/openmoko-rssreader/src/rfcdate.h
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-rssreader/src/rfcdate.h	2007-04-01 21:26:01 UTC (rev 1609)
+++ trunk/src/target/OM-2007/applications/openmoko-rssreader/src/rfcdate.h	2007-04-01 22:53:41 UTC (rev 1610)
@@ -0,0 +1,37 @@
+
+#ifndef OPENMOKO_RSS_RFC_DATE_H
+#define OPENMOKO_RSS_RFC_DATE_H
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define RSS_TYPE_RFC_DATE            (rss_rfc_date_get_type())
+#define RSS_RFC_DATE(obj)            (G_TYPE_CHECK_INSTANCE_CAST((obj), RSS_TYPE_RFC_DATE, RSSRFCDate))
+#define RSS_RFC_DATE_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((obj),    RSS_TYPE_RFC_DATE, RSSRFCDateClass))
+#define RSS_IS_RFC_DATE(obj)         (G_TYPE_CHECK_INSTANCE_TYPE((obj), RSS_TYPE_RFC_DATE))
+#define RSS_IS_RFC_DATE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),  RSS_TYPE_RFC_DATE))
+#define RSS_RFC_DATE_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS((obj),  RSS_TYPE_RFC_DATE, RSSRFCDateClass))
+
+typedef struct _RSSRFCDate RSSRFCDate;
+typedef struct _RSSRFCDateClass RSSRFCDateClass;
+
+struct _RSSRFCDate {
+    GObject parent;
+    gint64  date;
+};
+
+struct _RSSRFCDateClass {
+    GObjectClass parent;
+};
+
+GType     rss_rfc_date_get_type ();
+GObject*  rss_rfc_date_new      ();
+void      rss_rfc_date_set      (RSSRFCDate* self, const gchar* rfc822_date);
+gint      rss_rfc_date_compare  (RSSRFCDate* self, RSSRFCDate *other);
+gchar*    rss_rfc_date_as_string(RSSRFCDate* self);
+
+
+G_END_DECLS
+
+#endif





More information about the commitlog mailing list