1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
|
/*
* Copyright (C) 2000-2003 Marco Pesenti Gritti
* Copyright (C) 2003 Christian Persch
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
*/
#include "config.h"
#include "ephy-cookie-manager.h"
GType
ephy_cookie_get_type (void)
{
static GType type = 0;
if (G_UNLIKELY (type == 0))
{
type = g_boxed_type_register_static ("EphyCookie",
(GBoxedCopyFunc) ephy_cookie_copy,
(GBoxedFreeFunc) ephy_cookie_free);
}
return type;
}
/**
* ephy_cookie_new:
*
* Return value: a new #EphyCookie.
**/
EphyCookie *
ephy_cookie_new (void)
{
return g_new0 (EphyCookie, 1);
}
/**
* ephy_cookie_copy:
* @cookie: a #EphyCookie
*
* Return value: a copy of @cookie.
**/
EphyCookie *
ephy_cookie_copy (const EphyCookie *cookie)
{
EphyCookie *copy = g_new0 (EphyCookie, 1);
copy->name = g_strdup (cookie->name);
copy->value = g_strdup (cookie->value);
copy->domain = g_strdup (cookie->domain);
copy->path = g_strdup (cookie->path);
copy->expires = cookie->expires;
copy->real_expires = cookie->real_expires;
copy->is_secure = cookie->is_secure;
copy->is_session = cookie->is_session;
return copy;
}
/**
* ephy_cookie_free:
* @cookie: a #EphyCookie
*
* Frees @cookie.
**/
void
ephy_cookie_free (EphyCookie *cookie)
{
if (cookie != NULL)
{
g_free (cookie->name);
g_free (cookie->value);
g_free (cookie->domain);
g_free (cookie->path);
g_free (cookie);
}
}
/* EphyCookieManager */
static void ephy_cookie_manager_base_init (gpointer base_iface);
GType
ephy_cookie_manager_get_type (void)
{
static GType type = 0;
if (G_UNLIKELY (type == 0))
{
static const GTypeInfo our_info =
{
sizeof (EphyCookieManagerIface),
ephy_cookie_manager_base_init,
NULL,
};
type = g_type_register_static (G_TYPE_INTERFACE,
"EphyCookieManager",
&our_info,
(GTypeFlags) 0);
}
return type;
}
static void
ephy_cookie_manager_base_init (gpointer base_iface)
{
static gboolean initialised = FALSE;
if (initialised == FALSE)
{
/**
* EphyCookieManager::cookie-added
* @manager: the #EphyCookieManager
* @cookie: the added #EphyCookie
*
* The cookie-added signal is emitted when a cookie has been added.
**/
g_signal_new ("cookie-added",
EPHY_TYPE_COOKIE_MANAGER,
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (EphyCookieManagerIface, added),
NULL, NULL,
g_cclosure_marshal_VOID__BOXED,
G_TYPE_NONE,
1,
EPHY_TYPE_COOKIE);
/**
* EphyCookieManager::cookie-changed
* @manager: the #EphyCookieManager
* @cookie: the changed #EphyCookie
*
* The cookie-changed signal is emitted when a cookie has been changed.
**/
g_signal_new ("cookie-changed",
EPHY_TYPE_COOKIE_MANAGER,
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (EphyCookieManagerIface, changed),
NULL, NULL,
g_cclosure_marshal_VOID__BOXED,
G_TYPE_NONE,
1,
EPHY_TYPE_COOKIE);
/**
* EphyCookieManager::cookie-deleted
* @manager: the #EphyCookieManager
* @cookie: the deleted #EphyCookie
*
* The cookie-deleted signal is emitted when a cookie has been deleted.
**/
g_signal_new ("cookie-deleted",
EPHY_TYPE_COOKIE_MANAGER,
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (EphyCookieManagerIface, deleted),
NULL, NULL,
g_cclosure_marshal_VOID__BOXED,
G_TYPE_NONE,
1,
EPHY_TYPE_COOKIE);
/**
* EphyCookieManager::cookie-rejected
* @manager: the #EphyCookieManager
* @address: the address of the page that wanted to set the cookie
*
* The cookie-rejected signal is emitted when a cookie has been rejected.
**/
g_signal_new ("cookie-rejected",
EPHY_TYPE_COOKIE_MANAGER,
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (EphyCookieManagerIface, rejected),
NULL, NULL,
g_cclosure_marshal_VOID__STRING,
G_TYPE_NONE,
1,
G_TYPE_STRING);
/**
* EphyCookieManager::cookies-cleared
* @manager: the #EphyCookieManager
*
* The cookies-cleared signal is emitted when the cookie database has
* been cleared.
**/
g_signal_new ("cookies-cleared",
EPHY_TYPE_COOKIE_MANAGER,
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (EphyCookieManagerIface, cleared),
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE,
0);
initialised = TRUE;
}
}
/**
* ephy_cookie_manager_list_cookies:
* @manager: the #EphyCookieManager
*
* Lists all cookies in the cookies database.
*
* Return value: the cookies list
**/
GList *
ephy_cookie_manager_list_cookies (EphyCookieManager *manager)
{
EphyCookieManagerIface *iface = EPHY_COOKIE_MANAGER_GET_IFACE (manager);
return iface->list (manager);
}
/**
* ephy_cookie_manager_remove_cookie:
* @manager: the #EphyCookieManager
* @cookie: a #EphyCookie
*
* Removes @cookie from the cookies database. You must free @cookie yourself.
**/
void
ephy_cookie_manager_remove_cookie (EphyCookieManager *manager,
const EphyCookie *cookie)
{
EphyCookieManagerIface *iface = EPHY_COOKIE_MANAGER_GET_IFACE (manager);
iface->remove (manager, cookie);
}
/**
* ephy_cookie_manager_clear:
* @manager: the #EphyCookieManager
*
* Clears the cookies database.
**/
void
ephy_cookie_manager_clear (EphyCookieManager *manager)
{
EphyCookieManagerIface *iface = EPHY_COOKIE_MANAGER_GET_IFACE (manager);
iface->clear (manager);
}
|