Compile modules based on HAVE_* features
[geeqie.git] / src / cache.h
1 /*
2  * Copyright (C) 2004 John Ellis
3  * Copyright (C) 2008 - 2016 The Geeqie Team
4  *
5  * Author: John Ellis
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along
18  * with this program; if not, write to the Free Software Foundation, Inc.,
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20  */
21
22 #ifndef CACHE_H
23 #define CACHE_H
24
25 #include <sys/types.h>
26
27 #include <glib.h>
28
29 struct ImageSimilarityData;
30
31 #define GQ_CACHE_THUMB          "thumbnails"
32 #define GQ_CACHE_METADATA       "metadata"
33
34 #define GQ_CACHE_LOCAL_THUMB    ".thumbnails"
35 #define GQ_CACHE_LOCAL_METADATA ".metadata"
36
37 #define GQ_CACHE_EXT_THUMB      ".png"
38 #define GQ_CACHE_EXT_SIM        ".sim"
39 #define GQ_CACHE_EXT_METADATA   ".meta"
40 #define GQ_CACHE_EXT_XMP_METADATA   ".gq.xmp"
41
42
43 enum CacheType {
44         CACHE_TYPE_THUMB,
45         CACHE_TYPE_SIM,
46         CACHE_TYPE_METADATA,
47         CACHE_TYPE_XMP_METADATA
48 };
49
50 struct CacheData
51 {
52         gchar *path;
53         gint width;
54         gint height;
55         time_t date;
56         guchar md5sum[16];
57         ImageSimilarityData *sim;
58
59         gboolean dimensions;
60         gboolean have_date;
61         gboolean have_md5sum;
62         gboolean similarity;
63 };
64
65 gboolean cache_time_valid(const gchar *cache, const gchar *path);
66
67
68 CacheData *cache_sim_data_new();
69 void cache_sim_data_free(CacheData *cd);
70
71 gboolean cache_sim_data_save(CacheData *cd);
72 CacheData *cache_sim_data_load(const gchar *path);
73
74 void cache_sim_data_set_dimensions(CacheData *cd, gint w, gint h);
75 void cache_sim_data_set_md5sum(CacheData *cd, const guchar digest[16]);
76 void cache_sim_data_set_similarity(CacheData *cd, ImageSimilarityData *sd);
77 gint cache_sim_data_filled(ImageSimilarityData *sd);
78
79 gchar *cache_get_location(CacheType type, const gchar *source, gint include_name, mode_t *mode);
80 gchar *cache_find_location(CacheType type, const gchar *source);
81
82 const gchar *get_thumbnails_cache_dir();
83 const gchar *get_thumbnails_standard_cache_dir();
84 const gchar *get_metadata_cache_dir();
85
86 #endif
87 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */