1 | /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ |
2 | /* |
3 | * soup-cache.h: |
4 | * |
5 | * Copyright (C) 2009, 2010 Igalia, S.L. |
6 | * |
7 | * This library is free software; you can redistribute it and/or |
8 | * modify it under the terms of the GNU Library General Public |
9 | * License as published by the Free Software Foundation; either |
10 | * version 2 of the License, or (at your option) any later version. |
11 | * |
12 | * This library 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 GNU |
15 | * Library General Public License for more details. |
16 | * |
17 | * You should have received a copy of the GNU Library General Public License |
18 | * along with this library; see the file COPYING.LIB. If not, write to |
19 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
20 | * Boston, MA 02110-1301, USA. |
21 | */ |
22 | |
23 | #ifndef __SOUP_CACHE_H__ |
24 | #define __SOUP_CACHE_H__ 1 |
25 | |
26 | #include <libsoup/soup-types.h> |
27 | #include <gio/gio.h> |
28 | |
29 | G_BEGIN_DECLS |
30 | |
31 | #define SOUP_TYPE_CACHE (soup_cache_get_type ()) |
32 | #define SOUP_CACHE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SOUP_TYPE_CACHE, SoupCache)) |
33 | #define SOUP_CACHE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SOUP_TYPE_CACHE, SoupCacheClass)) |
34 | #define SOUP_IS_CACHE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SOUP_TYPE_CACHE)) |
35 | #define SOUP_IS_CACHE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), SOUP_TYPE_CACHE)) |
36 | #define SOUP_CACHE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SOUP_TYPE_CACHE, SoupCacheClass)) |
37 | |
38 | typedef struct _SoupCache SoupCache; |
39 | typedef struct _SoupCachePrivate SoupCachePrivate; |
40 | |
41 | typedef enum { |
42 | SOUP_CACHE_CACHEABLE = (1 << 0), |
43 | SOUP_CACHE_UNCACHEABLE = (1 << 1), |
44 | SOUP_CACHE_INVALIDATES = (1 << 2), |
45 | SOUP_CACHE_VALIDATES = (1 << 3) |
46 | } SoupCacheability; |
47 | |
48 | typedef enum { |
49 | SOUP_CACHE_RESPONSE_FRESH, |
50 | SOUP_CACHE_RESPONSE_NEEDS_VALIDATION, |
51 | SOUP_CACHE_RESPONSE_STALE |
52 | } SoupCacheResponse; |
53 | |
54 | typedef enum { |
55 | SOUP_CACHE_SINGLE_USER, |
56 | SOUP_CACHE_SHARED |
57 | } SoupCacheType; |
58 | |
59 | struct _SoupCache { |
60 | GObject parent_instance; |
61 | |
62 | SoupCachePrivate *priv; |
63 | }; |
64 | |
65 | typedef struct { |
66 | GObjectClass parent_class; |
67 | |
68 | /* methods */ |
69 | SoupCacheability (*get_cacheability) (SoupCache *cache, |
70 | SoupMessage *msg); |
71 | |
72 | /* Padding for future expansion */ |
73 | void (*_libsoup_reserved1)(void); |
74 | void (*_libsoup_reserved2)(void); |
75 | void (*_libsoup_reserved3)(void); |
76 | } SoupCacheClass; |
77 | |
78 | SOUP_AVAILABLE_IN_2_34 |
79 | GType soup_cache_get_type (void); |
80 | SOUP_AVAILABLE_IN_2_34 |
81 | SoupCache *soup_cache_new (const char *cache_dir, |
82 | SoupCacheType cache_type); |
83 | SOUP_AVAILABLE_IN_2_34 |
84 | void soup_cache_flush (SoupCache *cache); |
85 | SOUP_AVAILABLE_IN_2_34 |
86 | void soup_cache_clear (SoupCache *cache); |
87 | |
88 | SOUP_AVAILABLE_IN_2_34 |
89 | void soup_cache_dump (SoupCache *cache); |
90 | SOUP_AVAILABLE_IN_2_34 |
91 | void soup_cache_load (SoupCache *cache); |
92 | |
93 | SOUP_AVAILABLE_IN_2_34 |
94 | void soup_cache_set_max_size (SoupCache *cache, |
95 | guint max_size); |
96 | SOUP_AVAILABLE_IN_2_34 |
97 | guint soup_cache_get_max_size (SoupCache *cache); |
98 | |
99 | G_END_DECLS |
100 | |
101 | #endif /* __SOUP_CACHE_H__ */ |
102 | |
103 | |