soup-cache.h 3.1 KB

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