[libchamplain] Add champlain_cache_get_filename to reduce code duplication
- From: Pierre-Luc Beaudoin <plbeaudoin src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [libchamplain] Add champlain_cache_get_filename to reduce code duplication
- Date: Sun, 24 Jan 2010 20:09:25 +0000 (UTC)
commit 9146eb016d1163a03970c6b043cec0185e45f36d
Author: Simon Wenner <simon wenner ch>
Date: Mon Jul 13 00:41:13 2009 +0200
Add champlain_cache_get_filename to reduce code duplication
champlain/champlain-cache.c | 28 ++++++++++++++++++++++++++++
champlain/champlain-cache.h | 6 ++++++
2 files changed, 34 insertions(+), 0 deletions(-)
---
diff --git a/champlain/champlain-cache.c b/champlain/champlain-cache.c
index 2f5d77f..1420fc7 100644
--- a/champlain/champlain-cache.c
+++ b/champlain/champlain-cache.c
@@ -49,6 +49,8 @@ G_DEFINE_TYPE (ChamplainCache, champlain_cache, G_TYPE_OBJECT)
#define GET_PRIVATE(o) \
(G_TYPE_INSTANCE_GET_PRIVATE ((o), CHAMPLAIN_TYPE_CACHE, ChamplainCachePrivate))
+#define CACHE_SUBDIR "champlain"
+
enum
{
PROP_0,
@@ -774,3 +776,29 @@ champlain_cache_delete_session (ChamplainCache *self, const gchar *session_id)
sqlite3_free (query);
}
+gchar *
+champlain_cache_get_filename (ChamplainCache *self,
+ ChamplainMapSource *source,
+ ChamplainTile *tile,
+ const gchar *session_id)
+{
+ g_return_val_if_fail (CHAMPLAIN_CACHE (self) &&
+ CHAMPLAIN_IS_MAP_SOURCE (source) &&
+ CHAMPLAIN_IS_TILE (tile), NULL);
+
+ if (session_id == NULL)
+ return g_strdup_printf ("%s" G_DIR_SEPARATOR_S "%s" G_DIR_SEPARATOR_S
+ "%s" G_DIR_SEPARATOR_S "%d" G_DIR_SEPARATOR_S
+ "%d" G_DIR_SEPARATOR_S "%d.png", g_get_user_cache_dir (),
+ CACHE_SUBDIR, champlain_map_source_get_id (CHAMPLAIN_MAP_SOURCE (source)),
+ champlain_tile_get_zoom_level (tile),
+ champlain_tile_get_x (tile), champlain_tile_get_y (tile));
+
+ return g_strdup_printf ("%s" G_DIR_SEPARATOR_S "%s" G_DIR_SEPARATOR_S
+ "%s" G_DIR_SEPARATOR_S "%s" G_DIR_SEPARATOR_S
+ "%d" G_DIR_SEPARATOR_S "%d" G_DIR_SEPARATOR_S
+ "%d.png", g_get_user_cache_dir (),
+ CACHE_SUBDIR, champlain_map_source_get_id (CHAMPLAIN_MAP_SOURCE (source)),
+ session_id, champlain_tile_get_zoom_level (tile),
+ champlain_tile_get_x (tile), champlain_tile_get_y (tile));
+}
diff --git a/champlain/champlain-cache.h b/champlain/champlain-cache.h
index feb58c8..4cf880b 100644
--- a/champlain/champlain-cache.h
+++ b/champlain/champlain-cache.h
@@ -22,6 +22,7 @@
#include <champlain/champlain-defines.h>
#include "champlain-tile.h"
+#include "champlain-map-source.h"
#include <glib.h>
@@ -81,6 +82,11 @@ void champlain_cache_purge_on_idle (ChamplainCache *self);
void champlain_cache_delete_session (ChamplainCache *self,
const gchar *session_id);
+gchar * champlain_cache_get_filename (ChamplainCache *self,
+ ChamplainMapSource *source,
+ ChamplainTile *tile,
+ const gchar *session_id);
+
G_END_DECLS
#endif /* CHAMPLAIN_CACHE_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]