Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBruno Coudoin <bcoudoin@src.gnome.org>2006-09-30 22:44:55 (GMT)
committer Bruno Coudoin <bcoudoin@src.gnome.org>2006-09-30 22:44:55 (GMT)
commit9d186015a1abaef915e70d1daeb50341544581be (patch)
tree1d040b98bb0de63eeec2eaf04d332dfcb652e2c5
parent23410a9d7036b44c87500a45aa552d7a7c0f9893 (diff)
Do not compile it if network mode is not enabled
* src/gcompris/cache.c: (_cache_init), (gc_cache_init), (gc_cache_end), (gc_cache_clear), (gc_cache_get), (gc_cache_insert): Do not compile it if network mode is not enabled
-rw-r--r--ChangeLog6
-rw-r--r--src/gcompris/cache.c22
2 files changed, 26 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index d166390..4d528b9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2006-10-01 Bruno coudoin <bruno.coudoin@free.fr>
+
+ * src/gcompris/cache.c: (_cache_init), (gc_cache_init),
+ (gc_cache_end), (gc_cache_clear), (gc_cache_get),
+ (gc_cache_insert): Do not compile it if network mode is not enabled
+
2006-09-30 Bruno coudoin <bruno.coudoin@free.fr>
* boards/dataset/misc.xml: added a tux image set with our tux images
diff --git a/src/gcompris/cache.c b/src/gcompris/cache.c
index ce88357..5eac982 100644
--- a/src/gcompris/cache.c
+++ b/src/gcompris/cache.c
@@ -31,12 +31,15 @@
* 0 = NO LIMITS
* -1 = NO CACHE
*/
+#ifdef USE_GNET
static int cache_max_size = 1000;
static GHashTable *hash_cache = NULL;
+#endif
/** For debug only
*/
+#ifdef USE_GNET
static void
_dump_cache(gchar *key,
gchar *value,
@@ -51,12 +54,14 @@ static void dump_cache(void)
(GHFunc) _dump_cache,
NULL);
}
+#endif
/**
* recursively parse the cache and fill up the hash with files there
*/
void _cache_init(const gchar *basedir, const gchar *currentdir)
{
+#ifdef USE_GNET
GcomprisProperties *properties = gc_prop_get();
GDir *dir;
const gchar *file;
@@ -92,6 +97,7 @@ void _cache_init(const gchar *basedir, const gchar *currentdir)
}
g_dir_close(dir);
+#endif
}
/** Initialize the cache system
@@ -101,6 +107,7 @@ void _cache_init(const gchar *basedir, const gchar *currentdir)
*/
void gc_cache_init(int max_size)
{
+#ifdef USE_GNET
cache_max_size = max_size;
/* No server defined, the cache is useless */
@@ -118,12 +125,12 @@ void gc_cache_init(int max_size)
{
g_error("Failed to create the cache directory");
}
-
printf(" opened top directory\n");
/* Load the previous cache directory if any */
_cache_init(gc_prop_get()->cache_dir, NULL);
dump_cache();
+#endif
}
/** End the cache system
@@ -131,15 +138,18 @@ void gc_cache_init(int max_size)
*/
void gc_cache_end()
{
+#ifdef USE_GNET
if(!hash_cache)
return;
g_hash_table_destroy (hash_cache);
hash_cache = NULL;
+#endif
}
+#ifdef USE_GNET
static void
_clear_cache(gchar *key,
gchar *value,
@@ -147,16 +157,19 @@ _clear_cache(gchar *key,
{
printf("NOT IMPLEMENTED: Clearing chache %s:%s\n", key, value);
}
+#endif
/** Clear the cache. All files in the cache are removed
*
*/
void gc_cache_clear()
{
+#ifdef USE_GNET
g_hash_table_foreach(hash_cache,
(GHFunc) _clear_cache,
NULL);
+#endif
}
/** Get a file from the cache based on it's URL
@@ -164,7 +177,11 @@ void gc_cache_clear()
*/
gchar *gc_cache_get(gchar *url)
{
+#ifdef USE_GNET
return((char *)g_hash_table_lookup(hash_cache, url));
+#else
+ return NULL;
+#endif
}
/** Put and Get a file from the cache. The data in 'buffer' are saved in the
@@ -178,9 +195,10 @@ gchar *gc_cache_get(gchar *url)
*/
gchar *gc_cache_insert(const gchar *url, const char *buffer, gssize length)
{
+#ifdef USE_GNET
/* Save the buffer in the cache */
if(g_file_set_contents("TBD", buffer, length, NULL))
g_hash_table_replace(hash_cache, (gpointer) url, (gpointer) "TBD");
-
+#endif
return("TBD");
}