/** * Returns a list of cookies in the cookie jar. * * @return an @c Eina_List with all the cookies in the cookie jar. */ Eina_List* ewk_cookies_get_all(void) { Eina_List* el = 0; #if USE(SOUP) GSList* l; GSList* p; SoupCookieJar* cookieJar = WebCore::defaultCookieJar(); l = soup_cookie_jar_all_cookies(cookieJar); for (p = l; p; p = p->next) { SoupCookie* cookie = static_cast<SoupCookie*>(p->data); Ewk_Cookie* c = static_cast<Ewk_Cookie*>(malloc(sizeof(*c))); c->name = strdup(cookie->name); c->value = strdup(cookie->value); c->domain = strdup(cookie->domain); c->path = strdup(cookie->path); c->expires = soup_date_to_time_t(cookie->expires); c->secure = static_cast<Eina_Bool>(cookie->secure); c->http_only = static_cast<Eina_Bool>(cookie->http_only); el = eina_list_append(el, c); } soup_cookies_free(l); #endif return el; }
Eina_List* ewk_cookies_get_all(void) { Eina_List* result = 0; GSList* list; GSList* p; SoupCookieJar* cookieJar = WebCore::defaultCookieJar(); list = soup_cookie_jar_all_cookies(cookieJar); for (p = list; p; p = p->next) { SoupCookie* cookie = static_cast<SoupCookie*>(p->data); Ewk_Cookie* ewkCookie = new Ewk_Cookie; ewkCookie->name = strdup(cookie->name); ewkCookie->value = strdup(cookie->value); ewkCookie->domain = strdup(cookie->domain); ewkCookie->path = strdup(cookie->path); ewkCookie->expires = soup_date_to_time_t(cookie->expires); ewkCookie->secure = static_cast<Eina_Bool>(cookie->secure); ewkCookie->http_only = static_cast<Eina_Bool>(cookie->http_only); result = eina_list_append(result, ewkCookie); } soup_cookies_free(list); return result; }
JNIEXPORT jintLong JNICALL WebKitGTK_NATIVE(_1soup_1cookie_1jar_1all_1cookies) (JNIEnv *env, jclass that, jintLong arg0) { jintLong rc = 0; WebKitGTK_NATIVE_ENTER(env, that, _1soup_1cookie_1jar_1all_1cookies_FUNC); rc = (jintLong)soup_cookie_jar_all_cookies((SoupCookieJar *)arg0); WebKitGTK_NATIVE_EXIT(env, that, _1soup_1cookie_1jar_1all_1cookies_FUNC); return rc; }
static void do_cookies_accept_policy_test (void) { SoupSession *session; SoupMessage *msg; SoupURI *uri; SoupCookieJar *jar; GSList *l, *p; int i; debug_printf (1, "SoupCookieJarAcceptPolicy test\n"); session = soup_test_session_new (SOUP_TYPE_SESSION_ASYNC, NULL); soup_session_add_feature_by_type (session, SOUP_TYPE_COOKIE_JAR); jar = SOUP_COOKIE_JAR (soup_session_get_feature (session, SOUP_TYPE_COOKIE_JAR)); for (i = 0; i < G_N_ELEMENTS (validResults); i++) { soup_cookie_jar_set_accept_policy (jar, validResults[i].policy); uri = soup_uri_new_with_base (first_party_uri, "/index.html"); msg = soup_message_new_from_uri ("GET", uri); soup_message_set_first_party (msg, first_party_uri); soup_session_send_message (session, msg); soup_uri_free (uri); g_object_unref (msg); /* We can't use two servers due to limitations in * test_server, so let's swap first and third party here * to simulate a cookie coming from a third party. */ uri = soup_uri_new_with_base (first_party_uri, "/foo.jpg"); msg = soup_message_new_from_uri ("GET", uri); soup_message_set_first_party (msg, third_party_uri); soup_session_send_message (session, msg); soup_uri_free (uri); g_object_unref (msg); l = soup_cookie_jar_all_cookies (jar); if (g_slist_length (l) < validResults[i].n_cookies) { debug_printf (1, " accepted less cookies than it should have\n"); errors++; } else if (g_slist_length (l) > validResults[i].n_cookies) { debug_printf (1, " accepted more cookies than it should have\n"); errors++; } for (p = l; p; p = p->next) { soup_cookie_jar_delete_cookie (jar, p->data); soup_cookie_free (p->data); } g_slist_free (l); } soup_test_session_abort_unref (session); }
void deleteAllCookies(const NetworkStorageSession& session) { SoupCookieJar* cookieJar = cookieJarForSession(session); GUniquePtr<GSList> cookies(soup_cookie_jar_all_cookies(cookieJar)); for (GSList* item = cookies.get(); item; item = g_slist_next(item)) { SoupCookie* cookie = static_cast<SoupCookie*>(item->data); soup_cookie_jar_delete_cookie(cookieJar, cookie); soup_cookie_free(cookie); } }
void deleteAllCookies(NetworkingContext* context) { SoupCookieJar* cookieJar = context ? cookieJarForContext(context) : soupCookieJar(); GOwnPtr<GSList> cookies(soup_cookie_jar_all_cookies(cookieJar)); for (GSList* item = cookies.get(); item; item = g_slist_next(item)) { SoupCookie* cookie = static_cast<SoupCookie*>(item->data); soup_cookie_jar_delete_cookie(cookieJar, cookie); soup_cookie_free(cookie); } }
static void migrate_cookies () { const char *cookies_file_sqlite = "cookies.sqlite"; const char *cookies_file_txt = "cookies.txt"; char *src_sqlite = NULL, *src_txt = NULL, *dest = NULL; dest = g_build_filename (ephy_dot_dir (), cookies_file_sqlite, NULL); /* If we already have a cookies.sqlite file, do nothing */ if (g_file_test (dest, G_FILE_TEST_EXISTS)) goto out; src_sqlite = g_build_filename (ephy_dot_dir (), "mozilla", "epiphany", cookies_file_sqlite, NULL); src_txt = g_build_filename (ephy_dot_dir (), "mozilla", "epiphany", cookies_file_txt, NULL); /* First check if we have a cookies.sqlite file in Mozilla */ if (g_file_test (src_sqlite, G_FILE_TEST_EXISTS)) { GFile *gsrc, *gdest; /* Copy the file */ gsrc = g_file_new_for_path (src_sqlite); gdest = g_file_new_for_path (dest); if (!g_file_copy (gsrc, gdest, 0, NULL, NULL, NULL, NULL)) g_warning (_("Failed to copy cookies file from Mozilla.")); g_object_unref (gsrc); g_object_unref (gdest); } else if (g_file_test (src_txt, G_FILE_TEST_EXISTS)) { /* Create a SoupCookieJarSQLite with the contents of the txt file */ GSList *cookies, *p; SoupCookieJar *txt, *sqlite; txt = soup_cookie_jar_text_new (src_txt, TRUE); sqlite = soup_cookie_jar_sqlite_new (dest, FALSE); cookies = soup_cookie_jar_all_cookies (txt); for (p = cookies; p; p = p->next) { SoupCookie *cookie = (SoupCookie*)p->data; /* Cookie is stolen, so we won't free it */ soup_cookie_jar_add_cookie (sqlite, cookie); } g_slist_free (cookies); g_object_unref (txt); g_object_unref (sqlite); } out: g_free (src_sqlite); g_free (src_txt); g_free (dest); }
void getHostnamesWithCookies(NetworkingContext* context, HashSet<String>& hostnames) { SoupCookieJar* cookieJar = context ? cookieJarForContext(context) : soupCookieJar(); GOwnPtr<GSList> cookies(soup_cookie_jar_all_cookies(cookieJar)); for (GSList* item = cookies.get(); item; item = g_slist_next(item)) { GOwnPtr<SoupCookie> cookie(static_cast<SoupCookie*>(item->data)); if (!cookie->domain) continue; hostnames.add(String::fromUTF8(cookie->domain)); } }
static gboolean katze_http_cookies_update_jar (KatzeHttpCookies* http_cookies) { gint fn = 0; FILE* f = NULL; gchar* temporary_filename = NULL; GSList* cookies; http_cookies->timeout = 0; temporary_filename = g_strconcat (http_cookies->filename, ".XXXXXX", NULL); if ((fn = g_mkstemp (temporary_filename)) == -1) goto failed; if (!((f = fdopen (fn, "wb")))) goto failed; cookies = soup_cookie_jar_all_cookies (http_cookies->jar); for (; cookies != NULL; cookies = g_slist_next (cookies)) { SoupCookie* cookie = cookies->data; if (cookie->expires && !soup_date_is_past (cookie->expires)) write_cookie (f, cookie); soup_cookie_free (cookie); } g_slist_free (cookies); if (fclose (f) != 0) { f = NULL; goto failed; } f = NULL; if (g_rename (temporary_filename, http_cookies->filename) == -1) goto failed; g_free (temporary_filename); if (g_getenv ("MIDORI_COOKIES_DEBUG") != NULL) { g_print ("KatzeHttpCookies: %d cookies changed\n", http_cookies->counter); http_cookies->counter = 0; } return FALSE; failed: if (f) fclose (f); g_unlink (temporary_filename); g_free (temporary_filename); if (g_getenv ("MIDORI_COOKIES_DEBUG") != NULL) g_print ("KatzeHttpCookies: Failed to write '%s'\n", http_cookies->filename); return FALSE; }
void getHostnamesWithCookies(const NetworkStorageSession& session, HashSet<String>& hostnames) { SoupCookieJar* cookieJar = cookieJarForSession(session); GUniquePtr<GSList> cookies(soup_cookie_jar_all_cookies(cookieJar)); for (GSList* item = cookies.get(); item; item = g_slist_next(item)) { SoupCookie* cookie = static_cast<SoupCookie*>(item->data); if (cookie->domain) hostnames.add(String::fromUTF8(cookie->domain)); soup_cookie_free(cookie); } }
void deleteCookiesForHostname(NetworkingContext* context, const String& hostname) { CString hostNameString = hostname.utf8(); SoupCookieJar* cookieJar = context ? cookieJarForContext(context) : soupCookieJar(); GOwnPtr<GSList> cookies(soup_cookie_jar_all_cookies(cookieJar)); for (GSList* item = cookies.get(); item; item = g_slist_next(item)) { SoupCookie* cookie = static_cast<SoupCookie*>(item->data); if (soup_cookie_domain_matches(cookie, hostNameString.data())) soup_cookie_jar_delete_cookie(cookieJar, cookie); soup_cookie_free(cookie); } }
void ewk_cookies_clear(void) { GSList* list; GSList* p; SoupCookieJar* cookieJar = WebCore::soupCookieJar(); list = soup_cookie_jar_all_cookies(cookieJar); for (p = list; p; p = p->next) soup_cookie_jar_delete_cookie(cookieJar, (SoupCookie*)p->data); soup_cookies_free(list); }
void deleteCookiesForHostname(const NetworkStorageSession& session, const String& hostname) { CString hostNameString = hostname.utf8(); SoupCookieJar* cookieJar = cookieJarForSession(session); GUniquePtr<GSList> cookies(soup_cookie_jar_all_cookies(cookieJar)); for (GSList* item = cookies.get(); item; item = g_slist_next(item)) { SoupCookie* cookie = static_cast<SoupCookie*>(item->data); if (soup_cookie_domain_matches(cookie, hostNameString.data())) soup_cookie_jar_delete_cookie(cookieJar, cookie); soup_cookie_free(cookie); } }
static void cookie_manager_refresh_store(CookieManager *cm) { GSList *l; GHashTable *parents; GtkTreeIter iter; GtkTreeIter *parent_iter; SoupCookie *cookie; CookieManagerPrivate *priv = cm->priv; g_signal_emit(cm, signals[PRE_COOKIES_CHANGE], 0); gtk_tree_store_clear(priv->store); /* free the old list */ cookie_manager_free_cookie_list(cm); priv->cookies = soup_cookie_jar_all_cookies(priv->jar); /* Hashtable holds domain names as keys, the corresponding tree iters as values */ parents = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); for (l = priv->cookies; l != NULL; l = g_slist_next(l)) { cookie = l->data; /* look for the parent item for the current domain name and create it if it doesn't exist */ if ((parent_iter = (GtkTreeIter*) g_hash_table_lookup(parents, cookie->domain)) == NULL) { parent_iter = g_new0(GtkTreeIter, 1); gtk_tree_store_append(priv->store, parent_iter, NULL); gtk_tree_store_set(priv->store, parent_iter, COOKIE_MANAGER_COL_NAME, cookie->domain, COOKIE_MANAGER_COL_COOKIE, NULL, COOKIE_MANAGER_COL_VISIBLE, TRUE, -1); g_hash_table_insert(parents, g_strdup(cookie->domain), parent_iter); } gtk_tree_store_append(priv->store, &iter, parent_iter); gtk_tree_store_set(priv->store, &iter, COOKIE_MANAGER_COL_NAME, cookie->name, COOKIE_MANAGER_COL_COOKIE, cookie, COOKIE_MANAGER_COL_VISIBLE, TRUE, -1); } g_hash_table_destroy(parents); g_signal_emit(cm, signals[COOKIES_CHANGED], 0); }
/** * Clears all the cookies from the cookie jar. */ void ewk_cookies_clear(void) { #if USE(SOUP) GSList* l; GSList* p; SoupCookieJar* cookieJar = WebCore::defaultCookieJar(); l = soup_cookie_jar_all_cookies(cookieJar); for (p = l; p; p = p->next) soup_cookie_jar_delete_cookie(cookieJar, (SoupCookie*)p->data); soup_cookies_free(l); #endif }
void transfer_cookies(void) { GSList *cf; SoupCookie *sc, *pc; cf = soup_cookie_jar_all_cookies(p_cookiejar); for (;cf; cf = cf->next) { pc = cf->data; sc = soup_cookie_copy(pc); _soup_cookie_jar_add_cookie(s_cookiejar, sc); } soup_cookies_free(cf); }
/* Hide the authentication browser */ void auth_browser_hide (AuthBrowser *browser) { AuthBrowserPrivate *priv = GET_PRIVATE (browser); SoupSession *session = webkit_get_default_session (); SoupCookieJar* jar = (SoupCookieJar*)soup_session_get_feature (session, SOUP_TYPE_COOKIE_JAR); GSList *l, *p; gtk_widget_hide (priv->window); /* clear cookies */ l = soup_cookie_jar_all_cookies (jar); for (p = l; p; p = p->next) soup_cookie_jar_delete_cookie (jar, (SoupCookie*)p->data); soup_cookies_free (l); }
void deleteCookie(NetworkingContext* context, const KURL& url, const String& name) { SoupCookieJar* jar = context ? cookieJarForContext(context) : soupCookieJar(); if (!jar) return; GOwnPtr<GSList> cookies(soup_cookie_jar_all_cookies(jar)); if (!cookies) return; CString cookieName = name.utf8(); GOwnPtr<SoupURI> uri(soup_uri_new(url.string().utf8().data())); for (GSList* iter = cookies.get(); iter; iter = g_slist_next(iter)) { GOwnPtr<SoupCookie> cookie(static_cast<SoupCookie*>(iter->data)); if (!soup_cookie_applies_to_uri(cookie.get(), uri.get())) continue; if (cookieName == cookie->name) soup_cookie_jar_delete_cookie(jar, cookie.get()); } }
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); }
static void create_cookie_jar_for_domain (const char *address, const char *directory) { GSList *cookies, *p; SoupCookieJar *current_jar, *new_jar; char *domain, *filename; SoupURI *uri; /* Create the new cookie jar */ filename = g_build_filename (directory, "cookies.sqlite", NULL); new_jar = (SoupCookieJar*)soup_cookie_jar_sqlite_new (filename, FALSE); g_free (filename); /* The app domain for the current view */ uri = soup_uri_new (address); domain = uri->host; /* The current cookies */ current_jar = get_current_cookie_jar (); if (!current_jar) { soup_uri_free (uri); return; } cookies = soup_cookie_jar_all_cookies (current_jar); for (p = cookies; p; p = p->next) { SoupCookie *cookie = (SoupCookie*)p->data; if (soup_cookie_domain_matches (cookie, domain)) soup_cookie_jar_add_cookie (new_jar, cookie); else soup_cookie_free (cookie); } soup_uri_free (uri); g_slist_free (cookies); g_object_unref (current_jar); g_object_unref (new_jar); }
bool getRawCookies(NetworkingContext* context, const KURL& /*firstParty*/, const KURL& url, Vector<Cookie>& rawCookies) { rawCookies.clear(); SoupCookieJar* jar = context ? cookieJarForContext(context) : soupCookieJar(); if (!jar) return false; GOwnPtr<GSList> cookies(soup_cookie_jar_all_cookies(jar)); if (!cookies) return false; GOwnPtr<SoupURI> uri(soup_uri_new(url.string().utf8().data())); for (GSList* iter = cookies.get(); iter; iter = g_slist_next(iter)) { GOwnPtr<SoupCookie> cookie(static_cast<SoupCookie*>(iter->data)); if (!soup_cookie_applies_to_uri(cookie.get(), uri.get())) continue; rawCookies.append(Cookie(String::fromUTF8(cookie->name), String::fromUTF8(cookie->value), String::fromUTF8(cookie->domain), String::fromUTF8(cookie->path), static_cast<double>(soup_date_to_time_t(cookie->expires)) * 1000, cookie->http_only, cookie->secure, soup_cookie_jar_is_persistent(jar))); } return true; }
/** * 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 }
SoupCookie * ossifer_session_get_cookie (const gchar *name, const gchar *domain, const gchar *path) { GSList *cookies; GSList *item; SoupCookie *found_cookie = NULL; cookies = soup_cookie_jar_all_cookies (ossifer_session_get_cookie_jar ()); for (item = cookies; item != NULL; item = item->next) { SoupCookie *cookie = (SoupCookie *)item->data; if (g_str_equal (name, cookie->name) && g_str_equal (domain, cookie->domain) && g_str_equal (path, cookie->path)) { found_cookie = soup_cookie_copy (cookie); break; } } soup_cookies_free (cookies); return found_cookie; }
int wl_save(struct tab *t, struct karg *args, int list) { char file[PATH_MAX], *lst_str = NULL; FILE *f = NULL; char *line = NULL, *lt = NULL, *dom; size_t linelen; const gchar *uri; struct karg a; struct domain *d; GSList *cf; SoupCookie *ci, *c; if (t == NULL || args == NULL) return (1); if (runtime_settings[0] == '\0') return (1); switch (list) { case XT_WL_JAVASCRIPT: lst_str = "JavaScript"; break; case XT_WL_COOKIE: lst_str = "Cookie"; break; case XT_WL_PLUGIN: lst_str = "Plugin"; break; default: show_oops(t, "Invalid list id: %d", list); return (1); } uri = get_uri(t); dom = find_domain(uri, args->i & XT_WL_TOPLEVEL); if (uri == NULL || dom == NULL || webkit_web_view_get_load_status(t->wv) == WEBKIT_LOAD_FAILED) { show_oops(t, "Can't add domain to %s white list", lst_str); goto done; } switch (list) { case XT_WL_JAVASCRIPT: lt = g_strdup_printf("js_wl=%s", dom); break; case XT_WL_COOKIE: lt = g_strdup_printf("cookie_wl=%s", dom); break; case XT_WL_PLUGIN: lt = g_strdup_printf("pl_wl=%s", dom); break; default: /* can't happen */ show_oops(t, "Invalid list id: %d", list); goto done; } snprintf(file, sizeof file, "%s" PS "%s", work_dir, runtime_settings); if ((f = fopen(file, "r+")) == NULL) { show_oops(t, "can't open file %s"); goto done; } while (!feof(f)) { line = fparseln(f, &linelen, NULL, NULL, 0); if (line == NULL) continue; if (!strcmp(line, lt)) goto done; free(line); line = NULL; } fprintf(f, "%s\n", lt); a.i = XT_WL_ENABLE; a.i |= args->i; switch (list) { case XT_WL_JAVASCRIPT: d = wl_find(dom, &js_wl); if (!d) { settings_add("js_wl", dom); d = wl_find(dom, &js_wl); } toggle_js(t, &a); break; case XT_WL_COOKIE: d = wl_find(dom, &c_wl); if (!d) { settings_add("cookie_wl", dom); d = wl_find(dom, &c_wl); } toggle_cwl(t, &a); /* find and add to persistent jar */ cf = soup_cookie_jar_all_cookies(s_cookiejar); for (;cf; cf = cf->next) { ci = cf->data; if (!strcmp(dom, ci->domain) || !strcmp(&dom[1], ci->domain)) /* deal with leading . */ { c = soup_cookie_copy(ci); _soup_cookie_jar_add_cookie(p_cookiejar, c); } } soup_cookies_free(cf); break; case XT_WL_PLUGIN: d = wl_find(dom, &pl_wl); if (!d) { settings_add("pl_wl", dom); d = wl_find(dom, &pl_wl); } toggle_pl(t, &a); break; default: abort(); /* can't happen */ } if (d) d->handy = 1; done: if (line) free(line); if (dom) g_free(dom); if (lt) g_free(lt); if (f) fclose(f); return (0); }
/* Open database containing policies for cookie domains. * Create database and setup table structure if it does not exist yet. */ static void _cookie_permission_manager_open_database(CookiePermissionManager *self) { CookiePermissionManagerPrivate *priv=self->priv; const gchar *configDir; gchar *error=NULL; gint success; sqlite3_stmt *statement=NULL; /* Close any open database */ if(priv->database) { g_free(priv->databaseFilename); priv->databaseFilename=NULL; sqlite3_close(priv->database); priv->database=NULL; g_object_notify_by_pspec(G_OBJECT(self), CookiePermissionManagerProperties[PROP_DATABASE]); g_object_notify_by_pspec(G_OBJECT(self), CookiePermissionManagerProperties[PROP_DATABASE_FILENAME]); } /* Build path to database file */ configDir=midori_extension_get_config_dir(priv->extension); if(!configDir) return; if(katze_mkdir_with_parents(configDir, 0700)) { g_warning(_("Could not create configuration folder for extension: %s"), g_strerror(errno)); _cookie_permission_manager_error(self, _("Could not create configuration folder for extension.")); return; } /* Open database */ priv->databaseFilename=g_build_filename(configDir, COOKIE_PERMISSION_DATABASE, NULL); success=sqlite3_open(priv->databaseFilename, &priv->database); if(success!=SQLITE_OK) { g_warning(_("Could not open database of extenstion: %s"), sqlite3_errmsg(priv->database)); g_free(priv->databaseFilename); priv->databaseFilename=NULL; if(priv->database) sqlite3_close(priv->database); priv->database=NULL; _cookie_permission_manager_error(self, _("Could not open database of extension.")); return; } /* Create table structure if it does not exist */ success=sqlite3_exec(priv->database, "CREATE TABLE IF NOT EXISTS " "policies(domain text, value integer);", NULL, NULL, &error); if(success==SQLITE_OK) { success=sqlite3_exec(priv->database, "CREATE UNIQUE INDEX IF NOT EXISTS " "domain ON policies (domain);", NULL, NULL, &error); } if(success==SQLITE_OK) { success=sqlite3_exec(priv->database, "PRAGMA journal_mode=TRUNCATE;", NULL, NULL, &error); } if(success!=SQLITE_OK || error) { _cookie_permission_manager_error(self, _("Could not set up database structure of extension.")); if(error) { g_critical(_("Failed to execute database statement: %s"), error); sqlite3_free(error); } g_free(priv->databaseFilename); priv->databaseFilename=NULL; sqlite3_close(priv->database); priv->database=NULL; return; } // Delete all cookies allowed only in one session success=sqlite3_prepare_v2(priv->database, "SELECT domain FROM policies WHERE value=? ORDER BY domain DESC;", -1, &statement, NULL); if(statement && success==SQLITE_OK) success=sqlite3_bind_int(statement, 1, COOKIE_PERMISSION_MANAGER_POLICY_ACCEPT_FOR_SESSION); if(statement && success==SQLITE_OK) { while(sqlite3_step(statement)==SQLITE_ROW) { gchar *domain=(gchar*)sqlite3_column_text(statement, 0); GSList *cookies, *cookie; #ifdef HAVE_LIBSOUP_2_40_0 SoupURI *uri; uri=soup_uri_new(NULL); soup_uri_set_host(uri, domain); soup_uri_set_path(uri, "/"); cookies=soup_cookie_jar_get_cookie_list(priv->cookieJar, uri, TRUE); for(cookie=cookies; cookie; cookie=cookie->next) { soup_cookie_jar_delete_cookie(priv->cookieJar, (SoupCookie*)cookie->data); } soup_cookies_free(cookies); soup_uri_free(uri); #else cookies=soup_cookie_jar_all_cookies(priv->cookieJar); for(cookie=cookies; cookie; cookie=cookie->next) { if(soup_cookie_domain_matches((SoupCookie*)cookie->data, domain)) { soup_cookie_jar_delete_cookie(priv->cookieJar, (SoupCookie*)cookie->data); } } soup_cookies_free(cookies); #endif } } else g_warning(_("SQL fails: %s"), sqlite3_errmsg(priv->database)); sqlite3_finalize(statement); g_object_notify_by_pspec(G_OBJECT(self), CookiePermissionManagerProperties[PROP_DATABASE]); g_object_notify_by_pspec(G_OBJECT(self), CookiePermissionManagerProperties[PROP_DATABASE_FILENAME]); }