e62a43069f38fa952d724a281faa4f59d94b1e28
[geeqie.git] / src / cache.h
1 /*
2  * Geeqie
3  * (C) 2004 John Ellis
4  * Copyright (C) 2008 - 2012 The Geeqie Team
5  *
6  * Author: John Ellis
7  *
8  * This software is released under the GNU General Public License (GNU GPL).
9  * Please read the included file COPYING for more information.
10  * This software comes with no warranty of any kind, use at your own risk!
11  */
12
13
14 #ifndef CACHE_H
15 #define CACHE_H
16
17
18 #include "similar.h"
19
20
21 #define GQ_CACHE_THUMB          "thumbnails"
22 #define GQ_CACHE_METADATA       "metadata"
23
24 #define GQ_CACHE_LOCAL_THUMB    ".thumbnails"
25 #define GQ_CACHE_LOCAL_METADATA ".metadata"
26
27 #define GQ_CACHE_EXT_THUMB      ".png"
28 #define GQ_CACHE_EXT_SIM        ".sim"
29 #define GQ_CACHE_EXT_METADATA   ".meta"
30 #define GQ_CACHE_EXT_XMP_METADATA   ".gq.xmp"
31
32
33 typedef enum {
34         CACHE_TYPE_THUMB,
35         CACHE_TYPE_SIM,
36         CACHE_TYPE_METADATA,
37         CACHE_TYPE_XMP_METADATA
38 } CacheType;
39
40 typedef struct _CacheData CacheData;
41 struct _CacheData
42 {
43         gchar *path;
44         gint width;
45         gint height;
46         time_t date;
47         guchar md5sum[16];
48         ImageSimilarityData *sim;
49
50         gboolean dimensions;
51         gboolean have_date;
52         gboolean have_md5sum;
53         gboolean similarity;
54 };
55
56 gboolean cache_time_valid(const gchar *cache, const gchar *path);
57
58
59 CacheData *cache_sim_data_new(void);
60 void cache_sim_data_free(CacheData *cd);
61
62 gboolean cache_sim_data_save(CacheData *cd);
63 CacheData *cache_sim_data_load(const gchar *path);
64
65 void cache_sim_data_set_dimensions(CacheData *cd, gint w, gint h);
66 void cache_sim_data_set_date(CacheData *cd, time_t date);
67 void cache_sim_data_set_md5sum(CacheData *cd, guchar digest[16]);
68 void cache_sim_data_set_similarity(CacheData *cd, ImageSimilarityData *sd);
69 gint cache_sim_data_filled(ImageSimilarityData *sd);
70
71 gchar *cache_get_location(CacheType type, const gchar *source, gint include_name, mode_t *mode);
72 gchar *cache_find_location(CacheType type, const gchar *source);
73
74 const gchar *get_thumbnails_cache_dir(void);
75 const gchar *get_metadata_cache_dir(void);
76
77 #endif
78 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */