Example #1
0
void
soup_cookie_jar_delete_cookie(SoupCookieJar *jar, SoupCookie *c)
{
	GSList			*cf;
	SoupCookie		*ci;

	print_cookie("soup_cookie_jar_delete_cookie", c);

	if (cookies_enabled == 0)
		return;

	if (jar == NULL || c == NULL)
		return;

	/* find and remove from persistent jar */
	cf = soup_cookie_jar_all_cookies(p_cookiejar);

	for (;cf; cf = cf->next) {
		ci = cf->data;
		if (soup_cookie_equal(ci, c)) {
			_soup_cookie_jar_delete_cookie(p_cookiejar, ci);
			break;
		}
	}

	soup_cookies_free(cf);

	/* delete from session jar */
	_soup_cookie_jar_delete_cookie(s_cookiejar, c);
}
static void
delete_cookie (const char *filename, SoupCookie *cookie)
{
	char *contents = NULL, *line, *p;
	gsize length = 0;
	FILE *f;
	SoupCookie *c;
	time_t now = time (NULL);

	if (!g_file_get_contents (filename, &contents, &length, NULL))
		return;

	f = fopen (filename, "w");
	if (!f) {
		g_free (contents);
		return;
	}

	line = contents;
	for (p = contents; *p; p++) {
		/* \r\n comes out as an extra empty line and gets ignored */
		if (*p == '\r' || *p == '\n') {
			*p = '\0';
			c = parse_cookie (line, now);
			line = p + 1;
			if (!c)
				continue;
			if (!soup_cookie_equal (cookie, c))
				write_cookie (f, c);
			soup_cookie_free (c);
		}
	}
	c = parse_cookie (line, now);
	if (c) {
		if (!soup_cookie_equal (cookie, c))
			write_cookie (f, c);
		soup_cookie_free (c);
	}

	g_free (contents);
	fclose (f);
}
Example #3
0
void ewk_cookies_cookie_del(Ewk_Cookie* cookie)
{
    EINA_SAFETY_ON_NULL_RETURN(cookie);
    GSList* list;
    GSList* p;
    SoupCookieJar* cookieJar = WebCore::soupCookieJar();
    SoupCookie* cookie1 = soup_cookie_new(
        cookie->name, cookie->value, cookie->domain, cookie->path, -1);

    list = soup_cookie_jar_all_cookies(cookieJar);
    for (p = list; p; p = p->next) {
        SoupCookie* cookie2 = static_cast<SoupCookie*>(p->data);
        if (soup_cookie_equal(cookie1, cookie2)) {
            soup_cookie_jar_delete_cookie(cookieJar, cookie2);
            break;
        }
    }

    soup_cookie_free(cookie1);
    soup_cookies_free(list);
}
Example #4
0
/**
 * Deletes a cookie from the cookie jar.
 *
 * Note that the fields name, value, domain and path are used to match this
 * cookie in the cookie jar.
 *
 * @param cookie an @c Ewk_Cookie that has the info relative to that cookie.
 */
void ewk_cookies_cookie_del(Ewk_Cookie *cookie)
{
#if USE(SOUP)
    EINA_SAFETY_ON_NULL_RETURN(cookie);
    GSList* l;
    GSList* p;
    SoupCookieJar* cookieJar = WebCore::defaultCookieJar();
    SoupCookie* c1 = soup_cookie_new(
        cookie->name, cookie->value, cookie->domain, cookie->path, -1);

    l = soup_cookie_jar_all_cookies(cookieJar);
    for (p = l; p; p = p->next) {
        SoupCookie* c2 = static_cast<SoupCookie*>(p->data);
        if (soup_cookie_equal(c1, c2)) {
            soup_cookie_jar_delete_cookie(cookieJar, c2);
            break;
        }
    }

    soup_cookie_free(c1);
    soup_cookies_free(l);
#endif
}