Git init
[profile/ivi/libsoup2.4.git] / libsoup / soup-cache.h
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 #ifdef LIBSOUP_USE_UNSTABLE_REQUEST_API
27
28 #include <libsoup/soup-types.h>
29 #include <gio/gio.h>
30
31 G_BEGIN_DECLS
32
33 #define SOUP_TYPE_CACHE            (soup_cache_get_type ())
34 #define SOUP_CACHE(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), SOUP_TYPE_CACHE, SoupCache))
35 #define SOUP_CACHE_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), SOUP_TYPE_CACHE, SoupCacheClass))
36 #define SOUP_IS_CACHE(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SOUP_TYPE_CACHE))
37 #define SOUP_IS_CACHE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), SOUP_TYPE_CACHE))
38 #define SOUP_CACHE_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), SOUP_TYPE_CACHE, SoupCacheClass))
39
40 typedef struct _SoupCache SoupCache;
41 typedef struct _SoupCachePrivate SoupCachePrivate;
42
43 typedef enum {
44         SOUP_CACHE_CACHEABLE = (1 << 0),
45         SOUP_CACHE_UNCACHEABLE = (1 << 1),
46         SOUP_CACHE_INVALIDATES = (1 << 2),
47         SOUP_CACHE_VALIDATES = (1 << 3)
48 } SoupCacheability;
49
50 typedef enum {
51         SOUP_CACHE_RESPONSE_FRESH,
52         SOUP_CACHE_RESPONSE_NEEDS_VALIDATION,
53         SOUP_CACHE_RESPONSE_STALE
54 } SoupCacheResponse;
55
56 typedef enum {
57         SOUP_CACHE_SINGLE_USER,
58         SOUP_CACHE_SHARED
59 } SoupCacheType;
60
61 struct _SoupCache {
62         GObject parent_instance;
63
64         SoupCachePrivate *priv;
65 };
66
67 typedef struct {
68         GObjectClass parent_class;
69
70         /* methods */
71         SoupCacheability (*get_cacheability) (SoupCache   *cache,
72                                               SoupMessage *msg);
73
74         /* Padding for future expansion */
75         void (*_libsoup_reserved1)(void);
76         void (*_libsoup_reserved2)(void);
77         void (*_libsoup_reserved3)(void);
78 } SoupCacheClass;
79
80 GType      soup_cache_get_type     (void);
81 SoupCache *soup_cache_new          (const char    *cache_dir,
82                                     SoupCacheType  cache_type);
83 void       soup_cache_flush        (SoupCache     *cache);
84 void       soup_cache_clear        (SoupCache     *cache);
85
86 void       soup_cache_dump         (SoupCache     *cache);
87 void       soup_cache_load         (SoupCache     *cache);
88
89 void       soup_cache_set_max_size (SoupCache     *cache,
90                                     guint          max_size);
91 guint      soup_cache_get_max_size (SoupCache     *cache);
92
93 G_END_DECLS
94
95 #endif /* LIBSOUP_USE_UNSTABLE_REQUEST_API */
96
97 #endif /* SOUP_CACHE_H */
98