1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; -*- */
3 * Copyright (C) 2008 Xan Lopez <xan@gnome.org>
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library 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 GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 #include "CookieJar.h"
25 #include "PlatformString.h"
26 #include "StringHash.h"
28 #include <libsoup/soup.h>
32 SoupCookieJar* getCookieJar()
34 static SoupCookieJar* jar = NULL;
37 jar = soup_cookie_jar_new();
42 void setCookies(Document* /*document*/, const KURL& url, const KURL& /*policyURL*/, const String& value)
44 SoupCookieJar* jar = getCookieJar();
48 SoupURI* origin = soup_uri_new(url.string().utf8().data());
50 soup_cookie_jar_set_cookie(jar, origin, value.utf8().data());
51 soup_uri_free(origin);
54 String cookies(const Document* /*document*/, const KURL& url)
56 SoupCookieJar* jar = getCookieJar();
60 SoupURI* uri = soup_uri_new(url.string().utf8().data());
61 char* cookies = soup_cookie_jar_get_cookies(jar, uri, FALSE);
64 String result(cookies);
70 bool cookiesEnabled(const Document* /*document*/)
72 return getCookieJar();