Simplify vflist_get_formatted()
[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
26 #include "similar.h"
27
28
29 #define GQ_CACHE_THUMB          "thumbnails"
30 #define GQ_CACHE_METADATA       "metadata"
31
32 #define GQ_CACHE_LOCAL_THUMB    ".thumbnails"
33 #define GQ_CACHE_LOCAL_METADATA ".metadata"
34
35 #define GQ_CACHE_EXT_THUMB      ".png"
36 #define GQ_CACHE_EXT_SIM        ".sim"
37 #define GQ_CACHE_EXT_METADATA   ".meta"
38 #define GQ_CACHE_EXT_XMP_METADATA   ".gq.xmp"
39
40
41 typedef enum {
42         CACHE_TYPE_THUMB,
43         CACHE_TYPE_SIM,
44         CACHE_TYPE_METADATA,
45         CACHE_TYPE_XMP_METADATA
46 } CacheType;
47
48 typedef struct _CacheData CacheData;
49 struct _CacheData
50 {
51         gchar *path;
52         gint width;
53         gint height;
54         time_t date;
55         guchar md5sum[16];
56         ImageSimilarityData *sim;
57
58         gboolean dimensions;
59         gboolean have_date;
60         gboolean have_md5sum;
61         gboolean similarity;
62 };
63
64 gboolean cache_time_valid(const gchar *cache, const gchar *path);
65
66
67 CacheData *cache_sim_data_new(void);
68 void cache_sim_data_free(CacheData *cd);
69
70 gboolean cache_sim_data_save(CacheData *cd);
71 CacheData *cache_sim_data_load(const gchar *path);
72
73 void cache_sim_data_set_dimensions(CacheData *cd, gint w, gint h);
74 void cache_sim_data_set_date(CacheData *cd, time_t date);
75 void cache_sim_data_set_md5sum(CacheData *cd, 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(void);
83 const gchar *get_thumbnails_standard_cache_dir(void);
84 const gchar *get_metadata_cache_dir(void);
85
86 #endif
87 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */