2 * Copyright © 2000-2003 Marco Pesenti Gritti
3 * Copyright © 2003 Christian Persch
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24 #include "ephy-cookie-manager.h"
27 ephy_cookie_get_type (void)
29 static GType type = 0;
31 if (G_UNLIKELY (type == 0))
33 type = g_boxed_type_register_static ("EphyCookie",
34 (GBoxedCopyFunc) ephy_cookie_copy,
35 (GBoxedFreeFunc) ephy_cookie_free);
44 * Return value: a new #EphyCookie.
47 ephy_cookie_new (void)
49 return g_new0 (EphyCookie, 1);
54 * @cookie: a #EphyCookie
56 * Return value: a copy of @cookie.
59 ephy_cookie_copy (const EphyCookie *cookie)
61 EphyCookie *copy = g_new0 (EphyCookie, 1);
63 copy->name = g_strdup (cookie->name);
64 copy->value = g_strdup (cookie->value);
65 copy->domain = g_strdup (cookie->domain);
66 copy->path = g_strdup (cookie->path);
67 copy->expires = cookie->expires;
68 copy->real_expires = cookie->real_expires;
69 copy->is_secure = cookie->is_secure;
70 copy->is_session = cookie->is_session;
77 * @cookie: a #EphyCookie
82 ephy_cookie_free (EphyCookie *cookie)
86 g_free (cookie->name);
87 g_free (cookie->value);
88 g_free (cookie->domain);
89 g_free (cookie->path);
95 /* EphyCookieManager */
97 static void ephy_cookie_manager_base_init (gpointer base_iface);
100 ephy_cookie_manager_get_type (void)
102 static GType type = 0;
104 if (G_UNLIKELY (type == 0))
106 const GTypeInfo our_info =
108 sizeof (EphyCookieManagerIface),
109 ephy_cookie_manager_base_init,
113 type = g_type_register_static (G_TYPE_INTERFACE,
123 ephy_cookie_manager_base_init (gpointer base_iface)
125 static gboolean initialised = FALSE;
127 if (initialised == FALSE)
130 * EphyCookieManager::cookie-added
131 * @manager: the #EphyCookieManager
132 * @cookie: the added #EphyCookie
134 * The cookie-added signal is emitted when a cookie has been added.
136 g_signal_new ("cookie-added",
137 EPHY_TYPE_COOKIE_MANAGER,
139 G_STRUCT_OFFSET (EphyCookieManagerIface, added),
141 g_cclosure_marshal_VOID__BOXED,
144 EPHY_TYPE_COOKIE | G_SIGNAL_TYPE_STATIC_SCOPE);
147 * EphyCookieManager::cookie-changed
148 * @manager: the #EphyCookieManager
149 * @cookie: the changed #EphyCookie
151 * The cookie-changed signal is emitted when a cookie has been changed.
153 g_signal_new ("cookie-changed",
154 EPHY_TYPE_COOKIE_MANAGER,
156 G_STRUCT_OFFSET (EphyCookieManagerIface, changed),
158 g_cclosure_marshal_VOID__BOXED,
161 EPHY_TYPE_COOKIE | G_SIGNAL_TYPE_STATIC_SCOPE);
164 * EphyCookieManager::cookie-deleted
165 * @manager: the #EphyCookieManager
166 * @cookie: the deleted #EphyCookie
168 * The cookie-deleted signal is emitted when a cookie has been deleted.
170 g_signal_new ("cookie-deleted",
171 EPHY_TYPE_COOKIE_MANAGER,
173 G_STRUCT_OFFSET (EphyCookieManagerIface, deleted),
175 g_cclosure_marshal_VOID__BOXED,
178 EPHY_TYPE_COOKIE | G_SIGNAL_TYPE_STATIC_SCOPE);
181 * EphyCookieManager::cookie-rejected
182 * @manager: the #EphyCookieManager
183 * @address: the address of the page that wanted to set the cookie
185 * The cookie-rejected signal is emitted when a cookie has been rejected.
187 g_signal_new ("cookie-rejected",
188 EPHY_TYPE_COOKIE_MANAGER,
190 G_STRUCT_OFFSET (EphyCookieManagerIface, rejected),
192 g_cclosure_marshal_VOID__STRING,
195 G_TYPE_STRING | G_SIGNAL_TYPE_STATIC_SCOPE);
198 * EphyCookieManager::cookies-cleared
199 * @manager: the #EphyCookieManager
201 * The cookies-cleared signal is emitted when the cookie database has
204 g_signal_new ("cookies-cleared",
205 EPHY_TYPE_COOKIE_MANAGER,
207 G_STRUCT_OFFSET (EphyCookieManagerIface, cleared),
209 g_cclosure_marshal_VOID__VOID,
218 * ephy_cookie_manager_list_cookies:
219 * @manager: the #EphyCookieManager
221 * Lists all cookies in the cookies database.
223 * Return value: the cookies list
226 ephy_cookie_manager_list_cookies (EphyCookieManager *manager)
228 EphyCookieManagerIface *iface = EPHY_COOKIE_MANAGER_GET_IFACE (manager);
229 return iface->list (manager);
233 * ephy_cookie_manager_remove_cookie:
234 * @manager: the #EphyCookieManager
235 * @cookie: a #EphyCookie
237 * Removes @cookie from the cookies database. You must free @cookie yourself.
240 ephy_cookie_manager_remove_cookie (EphyCookieManager *manager,
241 const EphyCookie *cookie)
243 EphyCookieManagerIface *iface = EPHY_COOKIE_MANAGER_GET_IFACE (manager);
244 iface->remove (manager, cookie);
248 * ephy_cookie_manager_clear:
249 * @manager: the #EphyCookieManager
251 * Clears the cookies database.
254 ephy_cookie_manager_clear (EphyCookieManager *manager)
256 EphyCookieManagerIface *iface = EPHY_COOKIE_MANAGER_GET_IFACE (manager);
257 iface->clear (manager);