r1872 - in trunk/src/target/OM-2007/applications/openmoko-rssreader: . src
zecke at sita.openmoko.org
zecke at sita.openmoko.org
Sun Apr 29 22:43:07 CEST 2007
Author: zecke
Date: 2007-04-29 22:43:06 +0200 (Sun, 29 Apr 2007)
New Revision: 1872
Added:
trunk/src/target/OM-2007/applications/openmoko-rssreader/src/moko_cache.c
trunk/src/target/OM-2007/applications/openmoko-rssreader/src/moko_cache.h
Modified:
trunk/src/target/OM-2007/applications/openmoko-rssreader/ChangeLog
trunk/src/target/OM-2007/applications/openmoko-rssreader/src/Makefile.am
Log:
2007-04-29 Holger Hans Peter Freyther <zecke at selfish.org>
Add a class to handle caching of feeds while making sure not consuming
too much space. This class is meant to be copied to mokocore once done
* src/Makefile.am: Add moko_cache.[h,c]
* src/moko_cache.c: Added.
(moko_cache_finalize): Clean the filename
(moko_cache_class_init): Make sure to clean the filename
(moko_cache_init): Initialize it
(moko_cache_new): Copy the profile name
(moko_cache_get_allowed_size): not implemented
(moko_cache_get_utilized_size): not implemtned
(moko_cache_write_object): not implemented
(moko_cache_read_object): not implemented
Modified: trunk/src/target/OM-2007/applications/openmoko-rssreader/ChangeLog
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-rssreader/ChangeLog 2007-04-29 16:43:19 UTC (rev 1871)
+++ trunk/src/target/OM-2007/applications/openmoko-rssreader/ChangeLog 2007-04-29 20:43:06 UTC (rev 1872)
@@ -1,5 +1,21 @@
2007-04-29 Holger Hans Peter Freyther <zecke at selfish.org>
+ Add a class to handle caching of feeds while making sure not consuming
+ too much space. This class is meant to be copied to mokocore once done
+
+ * src/Makefile.am: Add moko_cache.[h,c]
+ * src/moko_cache.c: Added.
+ (moko_cache_finalize): Clean the filename
+ (moko_cache_class_init): Make sure to clean the filename
+ (moko_cache_init): Initialize it
+ (moko_cache_new): Copy the profile name
+ (moko_cache_get_allowed_size): not implemented
+ (moko_cache_get_utilized_size): not implemtned
+ (moko_cache_write_object): not implemented
+ (moko_cache_read_object): not implemented
+
+2007-04-29 Holger Hans Peter Freyther <zecke at selfish.org>
+
* src/rfcdate.c: Handle wrong dates
(rss_rfc_date_set): If we can't parse set it to 26.01.1983
(rss_rfc_date_compare): Check if the dates we pass to g_date_compae
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-29 16:43:19 UTC (rev 1871)
+++ trunk/src/target/OM-2007/applications/openmoko-rssreader/src/Makefile.am 2007-04-29 20:43:06 UTC (rev 1872)
@@ -7,8 +7,8 @@
bin_PROGRAMS = openmoko-rssreader
-EXTRA_DIST = application-data.h callbacks.h rfcdate.h
+EXTRA_DIST = application-data.h callbacks.h rfcdate.h moko_cache.h
-openmoko_rssreader_SOURCES = main.c callbacks.c rfcdate.c
+openmoko_rssreader_SOURCES = main.c callbacks.c rfcdate.c moko_cache.c
openmoko_rssreader_LDADD = @OPENMOKO_LIBS@ @MRSS_LIBS@ @GTHREAD_LIBS@
Added: trunk/src/target/OM-2007/applications/openmoko-rssreader/src/moko_cache.c
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-rssreader/src/moko_cache.c 2007-04-29 16:43:19 UTC (rev 1871)
+++ trunk/src/target/OM-2007/applications/openmoko-rssreader/src/moko_cache.c 2007-04-29 20:43:06 UTC (rev 1872)
@@ -0,0 +1,101 @@
+/*
+ * RSS Reader, a simple RSS reader
+ *
+ * A simple secondory/tertiary caching solution to limit the amount of data
+ * stored. This is meant to be pushed to the mokocore library.
+ *
+ * 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 "moko_cache.h"
+
+G_DEFINE_TYPE(MokoCache, moko_cache, G_TYPE_OBJECT)
+
+#define MOKO_CACHE_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), MOKO_TYPE_CACHE, MokoCachePrivate))
+
+typedef struct _MokoCachePrivate MokoCachePrivate;
+struct _MokoCachePrivate {
+ gint allowed_size;
+};
+
+static void
+moko_cache_finalize (GObject *object)
+{
+ MokoCache *cache = MOKO_CACHE (object);
+ g_free (cache->cache_name);
+ cache->cache_name = NULL;
+
+ G_OBJECT_CLASS(moko_cache_parent_class)->finalize (object);
+}
+
+static void
+moko_cache_class_init (MokoCacheClass *klass)
+{
+ g_type_class_add_private (klass, sizeof (MokoCachePrivate));
+
+ /*
+ * virtual functions
+ */
+ G_OBJECT_CLASS(klass)->finalize = moko_cache_finalize;
+}
+
+static void
+moko_cache_init (MokoCache *self)
+{
+ self->cache_name = NULL;
+}
+
+GObject*
+moko_cache_new (gchar *name)
+{
+ MokoCache *cache = MOKO_CACHE(g_object_new (MOKO_TYPE_CACHE, NULL));
+ cache->cache_name = g_strdup(name);
+
+
+ return G_OBJECT(cache);
+}
+
+gint
+moko_cache_get_allowed_size (MokoCache *self)
+{
+ return MOKO_CACHE_UNLIMITED;
+}
+
+gint
+moko_cache_get_utilized_size(MokoCache *self)
+{
+ return 0;
+}
+
+gint
+moko_cache_write_object (MokoCache *self, gchar *object_name, gchar *content, guint size)
+{
+ return MOKO_CACHE_WRITE_UNKNOWN_ERROR;
+}
+
+gchar*
+moko_cache_read_object (MokoCache *self, gchar *object_name, gint *size)
+{
+ *size = -1;
+ return NULL;
+}
Property changes on: trunk/src/target/OM-2007/applications/openmoko-rssreader/src/moko_cache.c
___________________________________________________________________
Name: svn:eol-style
+ native
Added: trunk/src/target/OM-2007/applications/openmoko-rssreader/src/moko_cache.h
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-rssreader/src/moko_cache.h 2007-04-29 16:43:19 UTC (rev 1871)
+++ trunk/src/target/OM-2007/applications/openmoko-rssreader/src/moko_cache.h 2007-04-29 20:43:06 UTC (rev 1872)
@@ -0,0 +1,115 @@
+/*
+ * RSS Reader, a simple RSS reader
+ *
+ * A simple secondory/tertiary caching solution to limit the amount of data
+ * stored. This is meant to be pushed to the mokocore library.
+ *
+ * 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$]
+ */
+#ifndef OPENMOKO_RSS_MOKO_CACHE_H
+#define OPENMOKO_RSS_MOKO_CACHE_H
+
+
+#include <glib.h>
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define MOKO_TYPE_CACHE (moko_cache_get_type())
+#define MOKO_CACHE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), MOKO_TYPE_CACHE, MokoCache))
+#define MOKO_CACHE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((obj), MOKO_TYPE_CACHE, MokoCacheClass))
+#define MOKO_IS_CACHE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), MOKO_TYPE_CACHE))
+#define MOKO_IS_CACHE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), MOKO_TYPE_CACHE))
+#define MOKO_CACHE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), MOKO_TYPE_CACHE, MokoCacheClass))
+
+typedef struct _MokoCache MokoCache;
+typedef struct _MokoCacheClass MokoCacheClass;
+
+struct _MokoCache {
+ GObject parent;
+
+ gchar *cache_name;
+};
+
+struct _MokoCacheClass {
+ GObjectClass parent;
+};
+
+enum MokoCacheAllowedSize {
+ MOKO_CACHE_UNLIMITED = 0
+};
+
+enum MokoCacheWriteResult {
+ MOKO_CACHE_WRITE_SUCCESS,
+ MOKO_CACHE_WRITE_OUT_OF_SPACE,
+ MOKO_CACHE_WRITE_LIMIT_EXCEEDED,
+ MOKO_CACHE_WRITE_UNKNOWN_ERROR
+};
+
+GType moko_cache_get_type (void);
+GObject* moko_cache_new (gchar *cache_policy_name);
+gint moko_cache_get_allowed_size (MokoCache *self);
+gint moko_cache_get_utilized_size(MokoCache *self);
+
+gint moko_cache_write_object (MokoCache *self, gchar *object_name, gchar *content, guint size);
+gchar* moko_cache_read_object (MokoCache *self, gchar *object_name, gint *size);
+
+/**
+ * \fn moko_cache_new(gchar *cache_policy_name)
+ * @param cache_policy_name Name of the policy, e.g. "openmoko-rssreader"
+ *
+ * The policy defines the storage path and the amount of storage available
+ */
+
+/**
+ * \fn moko_cache_get_allowed_size (MokoCache* self)
+ *
+ * @return This method returns the number of bytes this object
+ * may safe. As a special case MOKO_CACHE_UNLIMITED might be returned.
+ */
+
+/**
+ * \fn moko_cache_get_utilized_size (MokoCache *self)
+ *
+ * @return Return the size currently used.
+ */
+
+/**
+ * \fn moko_cache_write_object (MokoCache *self, gchar *object_name, gchar *content, guint size);
+ * @param object_name The name of the object. E.g. http://www.heise.de/atom.xml
+ * @param content The actual content to be written to the cache
+ * @param size The size of the content. If it is -1 strlen will be used to determine the size
+ */
+
+/**
+ * \fn moko_cache_read_object (MokoCache *self, gchar *object_name, gint *size)
+ * @param object_name The name of the object to be retrieved
+ * @param size Out parameter. The size of the object will be returned
+ *
+ * @return NULL in case of error, otherwise a pointer to the object. You are responsible
+ * to delete it! size can be -1 in case of error or >= 0.
+ */
+
+G_END_DECLS
+
+#endif
Property changes on: trunk/src/target/OM-2007/applications/openmoko-rssreader/src/moko_cache.h
___________________________________________________________________
Name: svn:eol-style
+ native
More information about the commitlog
mailing list