shumate-file-cache.h 4.81 KB
Newer Older
Marcus Lundblad's avatar
Marcus Lundblad committed
1
2
3
/*
 * Copyright (C) 2009 Pierre-Luc Beaudoin <pierre-luc@pierlux.com>
 * Copyright (C) 2010-2013 Jiri Techet <techet@gmail.com>
Marcus Lundblad's avatar
Marcus Lundblad committed
4
 * Copyright (C) 2019 Marcus Lundblad <ml@update.uu.se>
Marcus Lundblad's avatar
Marcus Lundblad committed
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */

#if !defined (__SHUMATE_SHUMATE_H_INSIDE__) && !defined (SHUMATE_COMPILATION)
#error "Only <shumate/shumate.h> can be included directly."
#endif

#ifndef _SHUMATE_FILE_CACHE_H_
#define _SHUMATE_FILE_CACHE_H_

#include <glib-object.h>
James Westman's avatar
James Westman committed
29
#include <gio/gio.h>
Marcus Lundblad's avatar
Marcus Lundblad committed
30
31
32

G_BEGIN_DECLS

33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/**
 * SHUMATE_FILE_CACHE_ERROR:
 *
 * Error domain for errors that may occur while storing or retrieving tiles
 * from a #ShumateFileCache. Errors in this domain will be from the
 * #ShumateFileCacheError enum.
 */
#define SHUMATE_FILE_CACHE_ERROR shumate_file_cache_error_quark ()
GQuark shumate_file_cache_error_quark (void);

/**
 * ShumateFileCacheError:
 * @SHUMATE_FILE_CACHE_ERROR_FAILED: An unspecified error occurred during the operation.
 *
 * Error codes in the #SHUMATE_FILE_CACHE_ERROR domain.
 */
typedef enum {
  SHUMATE_FILE_CACHE_ERROR_FAILED,
} ShumateFileCacheError;

Marcus Lundblad's avatar
Marcus Lundblad committed
53
#define SHUMATE_TYPE_FILE_CACHE shumate_file_cache_get_type ()
54
G_DECLARE_DERIVABLE_TYPE (ShumateFileCache, shumate_file_cache, SHUMATE, FILE_CACHE, GObject)
Marcus Lundblad's avatar
Marcus Lundblad committed
55
56
57

struct _ShumateFileCacheClass
{
58
  GObjectClass parent_class;
Marcus Lundblad's avatar
Marcus Lundblad committed
59
60
61
};

ShumateFileCache *shumate_file_cache_new_full (guint size_limit,
62
    const char *cache_key,
63
    const char *cache_dir);
Marcus Lundblad's avatar
Marcus Lundblad committed
64
65
66
67
68

guint shumate_file_cache_get_size_limit (ShumateFileCache *file_cache);
void shumate_file_cache_set_size_limit (ShumateFileCache *file_cache,
    guint size_limit);

69
const char *shumate_file_cache_get_cache_dir (ShumateFileCache *file_cache);
70
const char *shumate_file_cache_get_cache_key (ShumateFileCache *file_cache);
Marcus Lundblad's avatar
Marcus Lundblad committed
71

72
73
74
75
76
77
78
void shumate_file_cache_purge_cache_async (ShumateFileCache *self,
                                           GCancellable *cancellable,
                                           GAsyncReadyCallback callback,
                                           gpointer user_data);
gboolean shumate_file_cache_purge_cache_finish (ShumateFileCache *self,
                                                GAsyncResult *result,
                                                GError **error);
Marcus Lundblad's avatar
Marcus Lundblad committed
79

James Westman's avatar
James Westman committed
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
void shumate_file_cache_get_tile_async (ShumateFileCache    *self,
                                        int                  x,
                                        int                  y,
                                        int                  zoom_level,
                                        GCancellable        *cancellable,
                                        GAsyncReadyCallback  callback,
                                        gpointer             user_data);
GBytes *shumate_file_cache_get_tile_finish (ShumateFileCache  *self,
                                            char             **etag,
                                            GDateTime        **modtime,
                                            GAsyncResult      *result,
                                            GError           **error);

void shumate_file_cache_store_tile_async (ShumateFileCache    *self,
                                          int                  x,
                                          int                  y,
                                          int                  zoom_level,
                                          GBytes              *bytes,
                                          const char          *etag,
                                          GCancellable        *cancellable,
                                          GAsyncReadyCallback  callback,
                                          gpointer             user_data);
102
103
104
105
gboolean shumate_file_cache_store_tile_finish (ShumateFileCache *self,
                                               GAsyncResult *result,
                                               GError **error);

106
void shumate_file_cache_mark_up_to_date (ShumateFileCache *self,
James Westman's avatar
James Westman committed
107
108
109
                                         int               x,
                                         int               y,
                                         int               zoom_level);
110

Marcus Lundblad's avatar
Marcus Lundblad committed
111
112
113
G_END_DECLS

#endif /* _SHUMATE_FILE_CACHE_H_ */