diff options
author | Xan Lopez <xan@src.gnome.org> | 2009-02-23 19:48:51 +0800 |
---|---|---|
committer | Xan Lopez <xan@src.gnome.org> | 2009-02-23 19:48:51 +0800 |
commit | 6e63719484801e93f2b570d8c416645d71815c8e (patch) | |
tree | 63a6c258190a829d5c65587efe66331f161f0d1b | |
parent | 8256ad318861ef0fa4c4a9f88c915afc56ab09bb (diff) | |
download | gsoc2013-epiphany-6e63719484801e93f2b570d8c416645d71815c8e.tar gsoc2013-epiphany-6e63719484801e93f2b570d8c416645d71815c8e.tar.gz gsoc2013-epiphany-6e63719484801e93f2b570d8c416645d71815c8e.tar.bz2 gsoc2013-epiphany-6e63719484801e93f2b570d8c416645d71815c8e.tar.lz gsoc2013-epiphany-6e63719484801e93f2b570d8c416645d71815c8e.tar.xz gsoc2013-epiphany-6e63719484801e93f2b570d8c416645d71815c8e.tar.zst gsoc2013-epiphany-6e63719484801e93f2b570d8c416645d71815c8e.zip |
Use libsoup, getting the session from webkit, to handle cookies.
Requires libsoup-gnome for SoupCookieJarSQLite storage. Depending on
2.25.91, although we actually need trunk to get working code.
svn path=/trunk/; revision=8811
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | doc/reference/epiphany-sections.txt | 21 | ||||
-rw-r--r-- | doc/reference/tmpl/ephy-cookie-manager.sgml | 101 | ||||
-rw-r--r-- | embed/Makefile.am | 2 | ||||
-rw-r--r-- | embed/ephy-cookie-manager.c | 257 | ||||
-rw-r--r-- | embed/ephy-cookie-manager.h | 104 | ||||
-rw-r--r-- | embed/webkit/webkit-embed-single.c | 45 | ||||
-rw-r--r-- | src/Makefile.am | 2 | ||||
-rw-r--r-- | src/epiphany.defs | 73 | ||||
-rw-r--r-- | src/epiphany.h.in | 1 | ||||
-rw-r--r-- | src/epiphany.override | 13 | ||||
-rw-r--r-- | src/pdm-dialog.c | 204 |
12 files changed, 108 insertions, 717 deletions
diff --git a/configure.ac b/configure.ac index 585b3d09e..b5d602c2f 100644 --- a/configure.ac +++ b/configure.ac @@ -110,6 +110,7 @@ LIBSTARTUP_NOTIFICATION_REQUIRED=0.5 LIBNOTIFY_REQUIRED=0.4 DBUS_GLIB_REQUIRED=0.35 WEBKIT_GTK_REQUIRED=1.1.0 +LIBSOUP_GNOME_REQUIRED=2.25.91 PKG_CHECK_EXISTS([libnotify >= $LIBNOTIFY_REQUIRED],[have_libnotify=yes],[have_libnotify=no]) @@ -142,6 +143,7 @@ PKG_CHECK_MODULES([DEPENDENCIES], [ libstartup-notification-1.0 >= $LIBSTARTUP_NOTIFICATION_REQUIRED $LIBNOTIFY_PACKAGE webkit-1.0 >= $WEBKIT_GTK_REQUIRED + libsoup-gnome-2.4 >= $LIBSOUP_GNOME_REQUIRED ]) AC_SUBST([DEPENDENCIES_CFLAGS]) AC_SUBST([DEPENDENCIES_LIBS]) diff --git a/doc/reference/epiphany-sections.txt b/doc/reference/epiphany-sections.txt index c35f4a01f..1b96a08ea 100644 --- a/doc/reference/epiphany-sections.txt +++ b/doc/reference/epiphany-sections.txt @@ -293,27 +293,6 @@ ephy_password_info_get_type EPHY_PASSWORD_MANAGER_GET_IFACE </SECTION> -<SECTION> -<FILE>ephy-cookie-manager</FILE> -EPHY_COOKIE_MANAGER_IFACE -EPHY_IS_COOKIE_MANAGER_IFACE -EPHY_TYPE_COOKIE -EphyCookieP3PState -EphyCookieP3PPolicy -ephy_cookie_new -ephy_cookie_copy -ephy_cookie_free -ephy_cookie_manager_get_type -ephy_cookie_manager_list_cookies -ephy_cookie_manager_remove_cookie -ephy_cookie_manager_clear -<SUBSECTION Standard> -EPHY_COOKIE_MANAGER -EPHY_IS_COOKIE_MANAGER -EPHY_TYPE_COOKIE_MANAGER -ephy_cookie_get_type -EPHY_COOKIE_MANAGER_GET_IFACE -</SECTION> <SECTION> <FILE>EphyContentPolicy</FILE> diff --git a/doc/reference/tmpl/ephy-cookie-manager.sgml b/doc/reference/tmpl/ephy-cookie-manager.sgml deleted file mode 100644 index 278e4df85..000000000 --- a/doc/reference/tmpl/ephy-cookie-manager.sgml +++ /dev/null @@ -1,101 +0,0 @@ -<!-- ##### SECTION Title ##### --> -ephy-cookie-manager - -<!-- ##### SECTION Short_Description ##### --> - - -<!-- ##### SECTION Long_Description ##### --> -<para> - -</para> - -<!-- ##### SECTION See_Also ##### --> -<para> - -</para> - -<!-- ##### SECTION Stability_Level ##### --> - - -<!-- ##### MACRO EPHY_COOKIE_MANAGER_IFACE ##### --> -<para> - -</para> - -@k: - - -<!-- ##### MACRO EPHY_IS_COOKIE_MANAGER_IFACE ##### --> -<para> - -</para> - -@k: - - -<!-- ##### MACRO EPHY_TYPE_COOKIE ##### --> -<para> - -</para> - - - -<!-- ##### FUNCTION ephy_cookie_new ##### --> -<para> - -</para> - -@Returns: - - -<!-- ##### FUNCTION ephy_cookie_copy ##### --> -<para> - -</para> - -@cookie: -@Returns: - - -<!-- ##### FUNCTION ephy_cookie_free ##### --> -<para> - -</para> - -@cookie: - - -<!-- ##### FUNCTION ephy_cookie_manager_get_type ##### --> -<para> - -</para> - -@Returns: - - -<!-- ##### FUNCTION ephy_cookie_manager_list_cookies ##### --> -<para> - -</para> - -@manager: -@Returns: - - -<!-- ##### FUNCTION ephy_cookie_manager_remove_cookie ##### --> -<para> - -</para> - -@manager: -@cookie: - - -<!-- ##### FUNCTION ephy_cookie_manager_clear ##### --> -<para> - -</para> - -@manager: - - diff --git a/embed/Makefile.am b/embed/Makefile.am index e9486b1fa..e0c8b516f 100644 --- a/embed/Makefile.am +++ b/embed/Makefile.am @@ -21,7 +21,6 @@ INST_H_FILES = \ ephy-adblock-manager.h \ ephy-base-embed.h \ ephy-command-manager.h \ - ephy-cookie-manager.h \ ephy-embed.h \ ephy-embed-container.h \ ephy-embed-event.h \ @@ -45,7 +44,6 @@ libephyembed_la_SOURCES = \ ephy-base-embed.c \ downloader-view.c \ ephy-command-manager.c \ - ephy-cookie-manager.c \ ephy-download.c \ ephy-embed.c \ ephy-embed-container.c \ diff --git a/embed/ephy-cookie-manager.c b/embed/ephy-cookie-manager.c deleted file mode 100644 index 8a8f74605..000000000 --- a/embed/ephy-cookie-manager.c +++ /dev/null @@ -1,257 +0,0 @@ -/* - * Copyright © 2000-2003 Marco Pesenti Gritti - * Copyright © 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#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_slice_new0 (EphyCookie); -} - -/** - * ephy_cookie_copy: - * @cookie: a #EphyCookie - * - * Return value: a copy of @cookie. - **/ -EphyCookie * -ephy_cookie_copy (const EphyCookie *cookie) -{ - EphyCookie *copy = g_slice_new0 (EphyCookie); - - 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_slice_free (EphyCookie, 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)) - { - 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 | G_SIGNAL_TYPE_STATIC_SCOPE); - - /** - * 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 | G_SIGNAL_TYPE_STATIC_SCOPE); - - /** - * 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 | G_SIGNAL_TYPE_STATIC_SCOPE); - - /** - * 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 | G_SIGNAL_TYPE_STATIC_SCOPE); - - /** - * 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); -} diff --git a/embed/ephy-cookie-manager.h b/embed/ephy-cookie-manager.h deleted file mode 100644 index 2f12d4073..000000000 --- a/embed/ephy-cookie-manager.h +++ /dev/null @@ -1,104 +0,0 @@ - /* - * Copyright © 2003 Marco Pesenti Gritti - * Copyright © 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#if !defined (__EPHY_EPIPHANY_H_INSIDE__) && !defined (EPIPHANY_COMPILATION) -#error "Only <epiphany/epiphany.h> can be included directly." -#endif - -#ifndef EPHY_COOKIE_MANAGER_H -#define EPHY_COOKIE_MANAGER_H - -#include <glib-object.h> -#include <glib.h> -#include <time.h> - -G_BEGIN_DECLS - -#define EPHY_TYPE_COOKIE_MANAGER (ephy_cookie_manager_get_type ()) -#define EPHY_COOKIE_MANAGER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EPHY_TYPE_COOKIE_MANAGER, EphyCookieManager)) -#define EPHY_COOKIE_MANAGER_IFACE(k) (G_TYPE_CHECK_CLASS_CAST((k), EPHY_TYPE_COOKIE_MANAGER, EphyCookieManagerIface)) -#define EPHY_IS_COOKIE_MANAGER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EPHY_TYPE_COOKIE_MANAGER)) -#define EPHY_IS_COOKIE_MANAGER_IFACE(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EPHY_TYPE_COOKIE_MANAGER)) -#define EPHY_COOKIE_MANAGER_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), EPHY_TYPE_COOKIE_MANAGER, EphyCookieManagerIface)) - -#define EPHY_TYPE_COOKIE (ephy_cookie_get_type ()) - -typedef struct _EphyCookieManager EphyCookieManager; -typedef struct _EphyCookieManagerIface EphyCookieManagerIface; - -typedef struct -{ - char *name; - char *value; - char *domain; - char *path; - time_t expires; - glong real_expires; - guint is_secure : 1; - guint is_session : 1; - guint is_http_only : 1; -} EphyCookie; - -struct _EphyCookieManagerIface -{ - GTypeInterface base_iface; - - /* Signals */ - void (* added) (EphyCookieManager *manager, - EphyCookie *cookie); - void (* changed) (EphyCookieManager *manager, - EphyCookie *cookie); - void (* deleted) (EphyCookieManager *manager, - EphyCookie *cookie); - void (* rejected) (EphyCookieManager *manager, - const char *url); - void (* cleared) (EphyCookieManager *manager); - - /* Methods */ - GList * (* list) (EphyCookieManager *manager); - void (* remove) (EphyCookieManager *manager, - const EphyCookie *cookie); - void (* clear) (EphyCookieManager *manager); -}; - -/* EphyCookie */ - -GType ephy_cookie_get_type (void); - -EphyCookie *ephy_cookie_new (void); - -EphyCookie *ephy_cookie_copy (const EphyCookie *cookie); - -void ephy_cookie_free (EphyCookie *cookie); - -/* EphyCookieManager */ - -GType ephy_cookie_manager_get_type (void); - -GList * ephy_cookie_manager_list_cookies (EphyCookieManager *manager); - -void ephy_cookie_manager_remove_cookie (EphyCookieManager *manager, - const EphyCookie *cookie); - -void ephy_cookie_manager_clear (EphyCookieManager *manager); - -G_END_DECLS - -#endif diff --git a/embed/webkit/webkit-embed-single.c b/embed/webkit/webkit-embed-single.c index 2aa778c74..849d44127 100644 --- a/embed/webkit/webkit-embed-single.c +++ b/embed/webkit/webkit-embed-single.c @@ -20,11 +20,13 @@ #include "config.h" #include <glib/gi18n.h> #include <webkit/webkit.h> +#include <libsoup/soup.h> +#include <libsoup/soup-gnome.h> #include "webkit-embed-single.h" #include "webkit-embed-prefs.h" #include "ephy-embed-single.h" -#include "ephy-cookie-manager.h" +#include "ephy-file-helpers.h" #include "ephy-password-manager.h" #include "ephy-permission-manager.h" @@ -46,7 +48,6 @@ enum { static void webkit_embed_single_class_init (WebKitEmbedSingleClass *klass); static void webkit_embed_single_init (WebKitEmbedSingle *wes); static void ephy_embed_single_iface_init (EphyEmbedSingleIface *iface); -static void ephy_cookie_manager_iface_init (EphyCookieManagerIface *iface); static void ephy_password_manager_iface_init (EphyPasswordManagerIface *iface); static void ephy_permission_manager_iface_init (EphyPermissionManagerIface *iface); @@ -61,8 +62,6 @@ static void ephy_certificate_manager_iface_init (EphyCertificateManagerIface *if G_DEFINE_TYPE_WITH_CODE (WebKitEmbedSingle, webkit_embed_single, G_TYPE_OBJECT, G_IMPLEMENT_INTERFACE (EPHY_TYPE_EMBED_SINGLE, ephy_embed_single_iface_init) - G_IMPLEMENT_INTERFACE (EPHY_TYPE_COOKIE_MANAGER, - ephy_cookie_manager_iface_init) G_IMPLEMENT_INTERFACE (EPHY_TYPE_PASSWORD_MANAGER, ephy_password_manager_iface_init) G_IMPLEMENT_INTERFACE (EPHY_TYPE_CERTIFICATE_MANAGER, @@ -73,8 +72,6 @@ G_DEFINE_TYPE_WITH_CODE (WebKitEmbedSingle, webkit_embed_single, G_TYPE_OBJECT, G_DEFINE_TYPE_WITH_CODE (WebKitEmbedSingle, webkit_embed_single, G_TYPE_OBJECT, G_IMPLEMENT_INTERFACE (EPHY_TYPE_EMBED_SINGLE, ephy_embed_single_iface_init) - G_IMPLEMENT_INTERFACE (EPHY_TYPE_COOKIE_MANAGER, - ephy_cookie_manager_iface_init) G_IMPLEMENT_INTERFACE (EPHY_TYPE_PASSWORD_MANAGER, ephy_password_manager_iface_init) G_IMPLEMENT_INTERFACE (EPHY_TYPE_PERMISSION_MANAGER, @@ -147,23 +144,6 @@ impl_get_font_list (EphyEmbedSingle *shell, } static GList * -impl_list_cookies (EphyCookieManager *manager) -{ - return NULL; -} - -static void -impl_remove_cookie (EphyCookieManager *manager, - const EphyCookie *cookie) -{ -} - -static void -impl_clear_cookies (EphyCookieManager *manager) -{ -} - -static GList * impl_list_passwords (EphyPasswordManager *manager) { return NULL; @@ -219,8 +199,19 @@ impl_permission_manager_test (EphyPermissionManager *manager, static gboolean impl_init (EphyEmbedSingle *esingle) { + SoupSession *session; + SoupCookieJar *jar; + char *filename; + webkit_embed_prefs_init (); + filename = g_build_filename (ephy_dot_dir (), "cookies.sqlite", NULL); + jar = soup_cookie_jar_sqlite_new (filename, FALSE); + g_free (filename); + + session = webkit_get_default_session (); + soup_session_add_feature (session, SOUP_SESSION_FEATURE(jar)); + return TRUE; } @@ -332,14 +323,6 @@ ephy_embed_single_iface_init (EphyEmbedSingleIface *iface) } static void -ephy_cookie_manager_iface_init (EphyCookieManagerIface *iface) -{ - iface->list = impl_list_cookies; - iface->remove = impl_remove_cookie; - iface->clear = impl_clear_cookies; -} - -static void ephy_password_manager_iface_init (EphyPasswordManagerIface *iface) { iface->add = impl_add_password; diff --git a/src/Makefile.am b/src/Makefile.am index b8ba9210d..a13992832 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -354,7 +354,6 @@ if ENABLE_PYTHON BINDING_HEADERS_SRCDIR_IN = \ embed/ephy-command-manager.h \ - embed/ephy-cookie-manager.h \ embed/ephy-embed-event.h \ embed/ephy-embed-factory.h \ embed/ephy-embed.h \ @@ -522,7 +521,6 @@ endif # ENABLE_PYTHON if ENABLE_INTROSPECTION EPHY_GIR_H_FILES = \ $(top_srcdir)/embed/ephy-command-manager.h \ - $(top_srcdir)/embed/ephy-cookie-manager.h \ $(top_srcdir)/embed/ephy-embed-event.h \ $(top_srcdir)/embed/ephy-embed-factory.h \ $(top_srcdir)/embed/ephy-embed.h \ diff --git a/src/epiphany.defs b/src/epiphany.defs index 833859e1f..a8a7a4305 100644 --- a/src/epiphany.defs +++ b/src/epiphany.defs @@ -20,12 +20,6 @@ (gtype-id "EPHY_TYPE_COMMAND_MANAGER") ) -(define-interface CookieManager - (in-module "Ephy") - (c-name "EphyCookieManager") - (gtype-id "EPHY_TYPE_COOKIE_MANAGER") -) - (define-object Dialog (in-module "Ephy") (parent "GObject") @@ -475,57 +469,6 @@ -;; From ../../embed/ephy-cookie-manager.h - -(define-function ephy_cookie_get_type - (c-name "ephy_cookie_get_type") - (return-type "GType") -) - -(define-function ephy_cookie_new - (c-name "ephy_cookie_new") - (is-constructor-of "EphyCookie") - (return-type "EphyCookie*") -) - -(define-method copy - (of-object "EphyCookie") - (c-name "ephy_cookie_copy") - (return-type "EphyCookie*") -) - -(define-method free - (of-object "EphyCookie") - (c-name "ephy_cookie_free") - (return-type "none") -) - -(define-function ephy_cookie_manager_get_type - (c-name "ephy_cookie_manager_get_type") - (return-type "GType") -) - -(define-method list_cookies - (of-object "EphyCookieManager") - (c-name "ephy_cookie_manager_list_cookies") - (return-type "GList*") -) - -(define-method remove_cookie - (of-object "EphyCookieManager") - (c-name "ephy_cookie_manager_remove_cookie") - (return-type "none") - (parameters - '("const-EphyCookie*" "cookie") - ) -) - -(define-method clear - (of-object "EphyCookieManager") - (c-name "ephy_cookie_manager_clear") - (return-type "none") -) - ;; From ../../embed/ephy-embed-container.h (define-method set_active_child @@ -3511,22 +3454,6 @@ ;; Boxed types ... -(define-boxed Cookie - (in-module "Ephy") - (c-name "EphyCookie") - (gtype-id "EPHY_TYPE_COOKIE") - (fields - '("char*" "name") - '("char*" "value") - '("char*" "domain") - '("char*" "path") - '("gulong" "expires") - '("glong" "real_expires") - '("guint" "is_secure") - '("guint" "is_session") - ) -) - (define-boxed PasswordInfo (in-module "Ephy") (c-name "EphyPasswordInfo") diff --git a/src/epiphany.h.in b/src/epiphany.h.in index 667f84283..e23d1a3a6 100644 --- a/src/epiphany.h.in +++ b/src/epiphany.h.in @@ -39,7 +39,6 @@ #include <epiphany/ephy-bookmarks.h> #include <epiphany/ephy-bookmarks-type-builtins.h> #include <epiphany/ephy-command-manager.h> -#include <epiphany/ephy-cookie-manager.h> #include <epiphany/ephy-dialog.h> #include <epiphany/ephy-embed-container.h> #include <epiphany/ephy-embed-event.h> diff --git a/src/epiphany.override b/src/epiphany.override index 28622fd6c..3b183a171 100644 --- a/src/epiphany.override +++ b/src/epiphany.override @@ -28,7 +28,6 @@ headers #include "ephy-bookmarks.h" #include "ephy-bookmarks-type-builtins.h" #include "ephy-command-manager.h" -#include "ephy-cookie-manager.h" #include "ephy-dialog.h" #include "ephy-embed-event.h" #include "ephy-embed-factory.h" @@ -360,18 +359,6 @@ _wrap_ephy_password_manager_list_passwords (PyGObject *self) return _helper_wrap_boxed_glist (EPHY_TYPE_PASSWORD_INFO, list); } -%% -override ephy_cookie_manager_list_cookies noargs -static PyObject * -_wrap_ephy_cookie_manager_list_cookies(PyGObject *self) -{ - GList *list; - - list = ephy_cookie_manager_list_cookies(EPHY_COOKIE_MANAGER (self->obj)); - - return _helper_wrap_boxed_glist (EPHY_TYPE_COOKIE, list); -} -%% //override ephy_permission_manager_list_permissions kwargs // static PyObject * // _wrap_ephy_permission_manager_list_permissions (PyGObject *self, diff --git a/src/pdm-dialog.c b/src/pdm-dialog.c index 302fe5550..c262fdff4 100644 --- a/src/pdm-dialog.c +++ b/src/pdm-dialog.c @@ -2,6 +2,7 @@ * Copyright © 2002 Jorn Baayen * Copyright © 2003 Marco Pesenti Gritti * Copyright © 2003, 2004 Christian Persch + * Copyright © 2009 Igalia S.L., Author: Xan Lopez <xlopez@igalia.com> * * 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 @@ -23,7 +24,6 @@ #include "pdm-dialog.h" #include "ephy-shell.h" -#include "ephy-cookie-manager.h" #include "ephy-file-helpers.h" #include "ephy-password-manager.h" #include "ephy-gui.h" @@ -38,8 +38,11 @@ #include <gtk/gtk.h> #include <glib/gi18n.h> +#include <libsoup/soup.h> +#include <webkit/webkit.h> #include <string.h> +#include <time.h> typedef struct PdmActionInfo PdmActionInfo; @@ -122,12 +125,12 @@ EphyDialogProperty properties [] = { "pdm_dialog", NULL, PT_NORMAL, 0 }, { "pdm_notebook", NULL, PT_NORMAL, 0 }, - { "cookies_treeview", NULL, PT_NORMAL, 0 }, - { "cookies_remove_button", NULL, PT_NORMAL, 0 }, - { "cookies_properties_button", NULL, PT_NORMAL, 0 }, - { "passwords_treeview", NULL, PT_NORMAL, 0 }, - { "passwords_remove_button", NULL, PT_NORMAL, 0 }, - { "passwords_show_button", NULL, PT_NORMAL, 0 }, + { "cookies_treeview", NULL, PT_NORMAL, 0 }, + { "cookies_remove_button", NULL, PT_NORMAL, 0 }, + { "cookies_properties_button", NULL, PT_NORMAL, 0 }, + { "passwords_treeview", NULL, PT_NORMAL, 0 }, + { "passwords_remove_button", NULL, PT_NORMAL, 0 }, + { "passwords_show_button", NULL, PT_NORMAL, 0 }, { NULL } }; @@ -136,7 +139,7 @@ static void pdm_dialog_class_init (PdmDialogClass *klass); static void pdm_dialog_init (PdmDialog *dialog); static void pdm_dialog_finalize (GObject *object); -static void passwords_changed_cb (EphyPasswordManager *manager, +static void passwords_changed_cb (EphyPasswordManager *manager, PdmDialog *dialog); @@ -185,6 +188,15 @@ typedef struct guint num_checked; } PdmClearAllDialogButtons; +static SoupCookieJar* +get_cookie_jar () +{ + SoupSession* session; + + session = webkit_get_default_session (); + return (SoupCookieJar*)soup_session_get_feature (session, SOUP_TYPE_COOKIE_JAR); +} + static void clear_all_dialog_release_cb (PdmClearAllDialogButtons *data) { @@ -192,6 +204,18 @@ clear_all_dialog_release_cb (PdmClearAllDialogButtons *data) } static void +clear_all_cookies (SoupCookieJar *jar) +{ + GSList *l, *p; + + 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); +} + +static void clear_all_dialog_response_cb (GtkDialog *dialog, int response, PdmClearAllDialogButtons *checkbuttons) @@ -207,7 +231,7 @@ clear_all_dialog_response_cb (GtkDialog *dialog, if (response == GTK_RESPONSE_OK) { if (gtk_toggle_button_get_active - (GTK_TOGGLE_BUTTON (checkbuttons->checkbutton_history))) + (GTK_TOGGLE_BUTTON (checkbuttons->checkbutton_history))) { EphyEmbedShell *shell; EphyHistory *history; @@ -217,17 +241,16 @@ clear_all_dialog_response_cb (GtkDialog *dialog, ephy_history_clear (history); } if (gtk_toggle_button_get_active - (GTK_TOGGLE_BUTTON (checkbuttons->checkbutton_cookies))) + (GTK_TOGGLE_BUTTON (checkbuttons->checkbutton_cookies))) { - EphyCookieManager *manager; + SoupCookieJar *jar; - manager = EPHY_COOKIE_MANAGER (ephy_embed_shell_get_embed_single - (EPHY_EMBED_SHELL (ephy_shell))); + jar = get_cookie_jar (); - ephy_cookie_manager_clear (manager); + clear_all_cookies (jar); } if (gtk_toggle_button_get_active - (GTK_TOGGLE_BUTTON (checkbuttons->checkbutton_passwords))) + (GTK_TOGGLE_BUTTON (checkbuttons->checkbutton_passwords))) { EphyPasswordManager *manager; @@ -261,7 +284,7 @@ clear_all_dialog_response_cb (GtkDialog *dialog, } } if (gtk_toggle_button_get_active - (GTK_TOGGLE_BUTTON (checkbuttons->checkbutton_cache))) + (GTK_TOGGLE_BUTTON (checkbuttons->checkbutton_cache))) { EphyEmbedShell *shell; EphyEmbedSingle *single; @@ -405,7 +428,7 @@ pdm_dialog_show_clear_all_dialog (EphyDialog *edialog, label = gtk_label_new (NULL); gtk_label_set_markup (GTK_LABEL (label), _("<small><i><b>Note:</b> You cannot undo this action. " - "The data you are choosing to clear " + "The data you are choosing to clear " "will be deleted forever.</i></small>")); gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), label, FALSE, FALSE, 0); @@ -587,7 +610,7 @@ setup_action (PdmActionInfo *action) static void show_cookies_properties (PdmDialog *dialog, - EphyCookie *info) + SoupCookie *info) { GtkWidget *gdialog; GtkWidget *table; @@ -658,7 +681,7 @@ show_cookies_properties (PdmDialog *dialog, gtk_table_attach (GTK_TABLE (table), label, 0, 1, 2, 3, GTK_FILL, GTK_FILL, 0, 0); - label = gtk_label_new (info->is_secure ? _("Encrypted connections only") : _("Any type of connection") ); + label = gtk_label_new (info->secure ? _("Encrypted connections only") : _("Any type of connection") ); gtk_label_set_selectable (GTK_LABEL (label), TRUE); gtk_misc_set_alignment (GTK_MISC (label), 0, 0); gtk_widget_show (label); @@ -673,14 +696,16 @@ show_cookies_properties (PdmDialog *dialog, gtk_table_attach (GTK_TABLE (table), label, 0, 1, 3, 4, GTK_FILL, GTK_FILL, 0, 0); - if (info->is_session) + if (info->expires == NULL) { + /* Session cookie */ str = g_strdup (_("End of current session")); } else { struct tm t; - str = eel_strdup_strftime ("%c", localtime_r (&info->expires, &t)); + time_t out = soup_date_to_time_t(info->expires); + str = eel_strdup_strftime ("%c", localtime_r (&out, &t)); } label = gtk_label_new (str); g_free (str); @@ -710,7 +735,7 @@ cookies_properties_clicked_cb (GtkWidget *button, GValue val = {0, }; GtkTreeIter iter; GtkTreePath *path; - EphyCookie *cookie; + SoupCookie *cookie; GList *l; GtkTreeSelection *selection; @@ -722,7 +747,7 @@ cookies_properties_clicked_cb (GtkWidget *button, gtk_tree_model_get_iter (model, &iter, path); gtk_tree_model_get_value (model, &iter, COL_COOKIES_DATA, &val); - cookie = (EphyCookie *) g_value_get_boxed (&val); + cookie = (SoupCookie *) g_value_get_boxed (&val); show_cookies_properties (dialog, cookie); @@ -791,7 +816,7 @@ pdm_dialog_cookies_construct (PdmActionInfo *info) G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, - EPHY_TYPE_COOKIE); + SOUP_TYPE_COOKIE); gtk_tree_view_set_model (treeview, GTK_TREE_MODEL(liststore)); gtk_tree_view_set_headers_visible (treeview, TRUE); selection = gtk_tree_view_get_selection (treeview); @@ -843,19 +868,8 @@ pdm_dialog_cookies_construct (PdmActionInfo *info) } static gboolean -compare_cookies (const EphyCookie *cookie1, - const EphyCookie *cookie2) -{ - g_return_val_if_fail (cookie1 != NULL || cookie2 != NULL, FALSE); - - return (strcmp (cookie1->domain, cookie2->domain) == 0 - && strcmp (cookie1->path, cookie2->path) == 0 - && strcmp (cookie1->name, cookie2->name) == 0); -} - -static gboolean cookie_to_iter (GtkTreeModel *model, - const EphyCookie *cookie, + const SoupCookie *cookie, GtkTreeIter *iter) { gboolean valid; @@ -865,15 +879,15 @@ cookie_to_iter (GtkTreeModel *model, while (valid) { - EphyCookie *data; + SoupCookie *data; gtk_tree_model_get (model, iter, COL_COOKIES_DATA, &data, -1); - found = compare_cookies (cookie, data); + found = soup_cookie_equal ((SoupCookie*)cookie, data); - ephy_cookie_free (data); + soup_cookie_free (data); if (found) break; @@ -884,69 +898,43 @@ cookie_to_iter (GtkTreeModel *model, } static void -cookie_added_cb (EphyCookieManager *manager, - const EphyCookie *cookie, - PdmDialog *dialog) -{ - PdmActionInfo *info = dialog->priv->cookies; - - LOG ("cookie_added_cb"); - - info->add (info, (gpointer) ephy_cookie_copy (cookie)); -} - -static void -cookie_changed_cb (EphyCookieManager *manager, - const EphyCookie *cookie, +cookie_changed_cb (SoupCookieJar *jar, + const SoupCookie *old_cookie, + const SoupCookie *new_cookie, PdmDialog *dialog) { - PdmActionInfo *info = dialog->priv->cookies; + PdmActionInfo *info; GtkTreeIter iter; - LOG ("cookie_changed_cb"); - - if (cookie_to_iter (info->model, cookie, &iter)) - { - gtk_list_store_remove (GTK_LIST_STORE (info->model), &iter); - info->add (info, (gpointer) ephy_cookie_copy (cookie)); - } - else - { - g_warning ("Unable to find changed cookie in list!\n"); - } -} + g_return_if_fail (EPHY_IS_PDM_DIALOG (dialog)); + info = dialog->priv->cookies; -static void -cookie_deleted_cb (EphyCookieManager *manager, - const EphyCookie *cookie, - PdmDialog *dialog) -{ - PdmActionInfo *info = dialog->priv->cookies; - GtkTreeIter iter; + LOG ("cookie_changed_cb"); - LOG ("cookie_deleted_cb"); + g_return_if_fail (info); - if (cookie_to_iter (info->model, cookie, &iter)) + if (old_cookie) { - gtk_list_store_remove (GTK_LIST_STORE (info->model), &iter); + /* Cookie changed or deleted, let's get rid of the old one + in any case */ + if (cookie_to_iter (info->model, old_cookie, &iter)) + { + gtk_list_store_remove (GTK_LIST_STORE (info->model), &iter); + } + else + { + g_warning ("Unable to find changed cookie in list!\n"); + } } - else + + if (new_cookie) { - g_warning ("Unable to find deleted cookie in list!\n"); + /* Cookie changed or added, let's add the new cookie in + any case */ + info->add (info, (gpointer) soup_cookie_copy ((SoupCookie*)new_cookie)); } } -static void -cookies_cleared_cb (EphyCookieManager *manager, - PdmDialog *dialog) -{ - PdmActionInfo *info = dialog->priv->cookies; - - LOG ("cookies_cleared_cb"); - - gtk_list_store_clear (GTK_LIST_STORE (info->model)); -} - static gboolean cookie_host_to_iter (GtkTreeModel *model, const char *key1, @@ -1038,15 +1026,13 @@ compare_cookie_host_keys (GtkTreeModel *model, static void pdm_dialog_fill_cookies_list (PdmActionInfo *info) { - EphyCookieManager *manager; - GList *list, *l; + SoupCookieJar *jar; + GSList *list, *l; g_assert (info->filled == FALSE); - manager = EPHY_COOKIE_MANAGER (ephy_embed_shell_get_embed_single - (EPHY_EMBED_SHELL (ephy_shell))); - - list = ephy_cookie_manager_list_cookies (manager); + jar = get_cookie_jar (); + list = soup_cookie_jar_all_cookies (jar); for (l = list; l != NULL; l = l->next) { @@ -1054,7 +1040,7 @@ pdm_dialog_fill_cookies_list (PdmActionInfo *info) } /* the element data has been consumed, so we need only to free the list */ - g_list_free (list); + g_slist_free (list); /* Now turn on sorting */ gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (info->model), @@ -1067,15 +1053,8 @@ pdm_dialog_fill_cookies_list (PdmActionInfo *info) info->filled = TRUE; - /* Now connect the callbacks on the EphyCookieManager */ - g_signal_connect (manager, "cookie-added", - G_CALLBACK (cookie_added_cb), info->dialog); - g_signal_connect (manager, "cookie-changed", - G_CALLBACK (cookie_changed_cb), info->dialog); - g_signal_connect (manager, "cookie-deleted", - G_CALLBACK (cookie_deleted_cb), info->dialog); - g_signal_connect (manager, "cookies-cleared", - G_CALLBACK (cookies_cleared_cb), info->dialog); + g_signal_connect (jar, "changed", + G_CALLBACK (cookie_changed_cb), info->dialog); info->scroll_to (info); } @@ -1091,7 +1070,7 @@ static void pdm_dialog_cookie_add (PdmActionInfo *info, gpointer data) { - EphyCookie *cookie = (EphyCookie *) data; + SoupCookie *cookie = (SoupCookie *) data; GtkListStore *store; GtkTreeIter iter; int column[4] = { COL_COOKIES_HOST, COL_COOKIES_HOST_KEY, COL_COOKIES_NAME, COL_COOKIES_DATA }; @@ -1108,7 +1087,7 @@ pdm_dialog_cookie_add (PdmActionInfo *info, g_value_init (&value[0], G_TYPE_STRING); g_value_init (&value[1], G_TYPE_STRING); g_value_init (&value[2], G_TYPE_STRING); - g_value_init (&value[3], EPHY_TYPE_COOKIE); + g_value_init (&value[3], SOUP_TYPE_COOKIE); g_value_set_static_string (&value[0], cookie->domain); g_value_take_string (&value[1], ephy_string_collate_key_for_domain (cookie->domain, -1)); @@ -1129,13 +1108,12 @@ static void pdm_dialog_cookie_remove (PdmActionInfo *info, gpointer data) { - EphyCookie *cookie = (EphyCookie *) data; - EphyCookieManager *manager; + SoupCookie *cookie = (SoupCookie *) data; + SoupCookieJar *jar; - manager = EPHY_COOKIE_MANAGER (ephy_embed_shell_get_embed_single - (EPHY_EMBED_SHELL (ephy_shell))); + jar = get_cookie_jar(); - ephy_cookie_manager_remove_cookie (manager, cookie); + soup_cookie_jar_delete_cookie (jar, cookie); } static void @@ -1514,6 +1492,8 @@ pdm_dialog_finalize (GObject *object) g_signal_handlers_disconnect_matched (single, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, object); + g_signal_handlers_disconnect_by_func (get_cookie_jar (), cookie_changed_cb, object); + dialog->priv->cookies->destruct (dialog->priv->cookies); dialog->priv->passwords->destruct (dialog->priv->passwords); |