1 /* Copyright (c) 2006, Nokia Corporation
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * * Neither the name of the Nokia Corporation nor the names of its
14 * contributors may be used to endorse or promote products derived from
15 * this software without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
18 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
20 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
21 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
24 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 #ifndef __MODEST_CACHE_MGR_H__
32 #define __MODEST_CACHE_MGR_H__
34 #include <glib-object.h>
37 /* convenience macros */
38 #define MODEST_TYPE_CACHE_MGR (modest_cache_mgr_get_type())
39 #define MODEST_CACHE_MGR(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),MODEST_TYPE_CACHE_MGR,ModestCacheMgr))
40 #define MODEST_CACHE_MGR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),MODEST_TYPE_CACHE_MGR,GObject))
41 #define MODEST_IS_CACHE_MGR(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),MODEST_TYPE_CACHE_MGR))
42 #define MODEST_IS_CACHE_MGR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),MODEST_TYPE_CACHE_MGR))
43 #define MODEST_CACHE_MGR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj),MODEST_TYPE_CACHE_MGR,ModestCacheMgrClass))
45 typedef struct _ModestCacheMgr ModestCacheMgr;
46 typedef struct _ModestCacheMgrClass ModestCacheMgrClass;
48 struct _ModestCacheMgr {
50 /* insert public members, if any */
53 struct _ModestCacheMgrClass {
54 GObjectClass parent_class;
58 * the caches managed by this class
61 MODEST_CACHE_MGR_CACHE_TYPE_DATE_STRING, /* time_t => string */
62 MODEST_CACHE_MGR_CACHE_TYPE_DISPLAY_STRING, /* gchar* => gchar* */
63 MODEST_CACHE_MGR_CACHE_TYPE_PIXBUF, /* gchar* => GdkPixbuf */
64 MODEST_CACHE_MGR_CACHE_TYPE_SEND_QUEUE, /* TnyAccount* => TnySendQueue* */
66 MODEST_CACHE_MGR_CACHE_TYPE_NUM
67 } ModestCacheMgrCacheType;
71 * modest_cache_mgr_get_type:
73 * get the GType for ModestCacheMgr
77 GType modest_cache_mgr_get_type (void) G_GNUC_CONST;
81 * modest_cache_mgr_new:
83 * instantiate a new cache_mgr object
85 * Returns: a new cache_mgr or NULL in case of error
87 ModestCacheMgr* modest_cache_mgr_new (void);
90 * modest_cache_mgr_get_cache:
91 * @self: a valid cache mgr obj
92 * @type: a valid cache mgr cache type
94 * get the cache (GHashTable) of the requested type
96 * Returns: the requested cache (GHashTable)
97 * the returned hashtable should NOT be destroyed or unref'd.
99 GHashTable* modest_cache_mgr_get_cache (ModestCacheMgr* self, ModestCacheMgrCacheType type);
103 * modest_cache_mgr_flush
104 * @self: a valid cache mgr obj
105 * @type: a valid cache mgr cache type
107 * flush the cache (hashtable) of the given type
109 void modest_cache_mgr_flush (ModestCacheMgr *self, ModestCacheMgrCacheType type);
113 * modest_cache_mgr_flush
114 * @self: a valid cache mgr obj
118 void modest_cache_mgr_flush_all (ModestCacheMgr *self);
122 * modest_cache_mgr_get_size
123 * @self: a valid cache mgr obj
124 * @type: a valid cache mgr cache type
126 * get the size (number of [key,value]-pairs) in the cache
128 * Returns: the size of the give cache type
130 guint modest_cache_mgr_get_size (ModestCacheMgr *self, ModestCacheMgrCacheType type);
134 #endif /* __MODEST_CACHE_MGR_H__ */