2 * Copyright (C) 2008 Xan Lopez <xan@gnome.org>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 #include "CookieJar.h"
24 #include "PlatformString.h"
25 #include "StringHash.h"
27 #include <libsoup/soup.h>
31 SoupCookieJar* getCookieJar()
33 static SoupCookieJar* jar = NULL;
36 jar = soup_cookie_jar_new();
41 void setCookies(Document* /*document*/, const KURL& url, const KURL& /*policyURL*/, const String& value)
43 SoupCookieJar* jar = getCookieJar();
47 SoupURI* origin = soup_uri_new(url.string().utf8().data());
49 soup_cookie_jar_set_cookie(jar, origin, value.utf8().data());
50 soup_uri_free(origin);
53 String cookies(const Document* /*document*/, const KURL& url)
55 SoupCookieJar* jar = getCookieJar();
59 SoupURI* uri = soup_uri_new(url.string().utf8().data());
60 char* cookies = soup_cookie_jar_get_cookies(jar, uri, FALSE);
63 String result(cookies);
69 bool cookiesEnabled(const Document* /*document*/)
71 return getCookieJar();