aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Persch <chpe@cvs.gnome.org>2003-11-22 07:03:32 +0800
committerChristian Persch <chpe@src.gnome.org>2003-11-22 07:03:32 +0800
commitfd4f7ff174621461810cf76597a73250ab2cf6fd (patch)
tree394857e51657d369826ce21a918e8a062472ac36
parentf332569e59ed36ce9f00dc0e9557e8889d0f2651 (diff)
downloadgsoc2013-epiphany-fd4f7ff174621461810cf76597a73250ab2cf6fd.tar
gsoc2013-epiphany-fd4f7ff174621461810cf76597a73250ab2cf6fd.tar.gz
gsoc2013-epiphany-fd4f7ff174621461810cf76597a73250ab2cf6fd.tar.bz2
gsoc2013-epiphany-fd4f7ff174621461810cf76597a73250ab2cf6fd.tar.lz
gsoc2013-epiphany-fd4f7ff174621461810cf76597a73250ab2cf6fd.tar.xz
gsoc2013-epiphany-fd4f7ff174621461810cf76597a73250ab2cf6fd.tar.zst
gsoc2013-epiphany-fd4f7ff174621461810cf76597a73250ab2cf6fd.zip
New interfaces: EphyCookieManager, EphyPermissionManager,
2003-11-21 Christian Persch <chpe@cvs.gnome.org> * embed/Makefile.am: * embed/ephy-cookie-manager.c: (ephy_cookie_get_type), (ephy_cookie_new), (ephy_cookie_copy), (ephy_cookie_free), (ephy_cookie_manager_get_type), (ephy_cookie_manager_base_init), (ephy_cookie_manager_list_cookies), (ephy_cookie_manager_remove_cookie), (ephy_cookie_manager_clear): * embed/ephy-cookie-manager.h: * embed/ephy-embed-single.c: (ephy_embed_single_get_type), (ephy_embed_single_class_init), (ephy_embed_single_clear_cache), (ephy_embed_single_set_offline_mode), (ephy_embed_single_load_proxy_autoconf), (ephy_embed_single_get_font_list): * embed/ephy-embed-single.h: * embed/ephy-password-manager.c: (ephy_password_info_get_type), (ephy_password_info_new), (ephy_password_info_copy), (ephy_password_info_free), (ephy_password_manager_get_type), (ephy_password_manager_add), (ephy_password_manager_remove), (ephy_password_manager_list): * embed/ephy-password-manager.h: * embed/ephy-permission-manager.c: (ephy_permission_info_get_type), (ephy_permission_info_new), (ephy_permission_info_copy), (ephy_permission_info_free), (ephy_permission_manager_get_type), (ephy_permission_manager_base_init), (ephy_permission_manager_add), (ephy_permission_manager_remove), (ephy_permission_manager_clear), (ephy_permission_manager_test), (ephy_permission_manager_list): * embed/ephy-permission-manager.h: * embed/mozilla/mozilla-embed-single.cpp: * embed/mozilla/mozilla-embed-single.h: * embed/mozilla/mozilla-notifiers.cpp: * src/Makefile.am: * src/pdm-dialog.c: (pdm_dialog_get_type), (pdm_dialog_cookie_add), (pdm_dialog_password_add), (pdm_dialog_cookie_remove), (pdm_dialog_password_remove), (pdm_dialog_cookies_free), (pdm_dialog_passwords_free), (pdm_dialog_init), (pdm_dialog_new), (show_cookies_properties), (pdm_dialog_cookies_properties_button_clicked_cb): * src/pdm-dialog.h: New interfaces: EphyCookieManager, EphyPermissionManager, EphyPasswordManager. Port all callers to new interfaces. Change linking order to make it link. Only set autoconf proxy url if it's non-empty.
-rw-r--r--ChangeLog47
-rw-r--r--embed/Makefile.am10
-rw-r--r--embed/ephy-cookie-manager.c262
-rw-r--r--embed/ephy-cookie-manager.h122
-rw-r--r--embed/ephy-embed-single.c168
-rw-r--r--embed/ephy-embed-single.h90
-rw-r--r--embed/ephy-password-manager.c175
-rw-r--r--embed/ephy-password-manager.h87
-rw-r--r--embed/ephy-permission-manager.c295
-rw-r--r--embed/ephy-permission-manager.h121
-rw-r--r--embed/mozilla/mozilla-embed-single.cpp561
-rw-r--r--embed/mozilla/mozilla-embed-single.h16
-rw-r--r--embed/mozilla/mozilla-notifiers.cpp2
-rwxr-xr-xsrc/pdm-dialog.c106
-rw-r--r--src/pdm-dialog.h3
15 files changed, 1644 insertions, 421 deletions
diff --git a/ChangeLog b/ChangeLog
index 522fefb00..de3e0c3b0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,50 @@
+2003-11-21 Christian Persch <chpe@cvs.gnome.org>
+
+ * embed/Makefile.am:
+ * embed/ephy-cookie-manager.c: (ephy_cookie_get_type),
+ (ephy_cookie_new), (ephy_cookie_copy), (ephy_cookie_free),
+ (ephy_cookie_manager_get_type), (ephy_cookie_manager_base_init),
+ (ephy_cookie_manager_list_cookies),
+ (ephy_cookie_manager_remove_cookie), (ephy_cookie_manager_clear):
+ * embed/ephy-cookie-manager.h:
+ * embed/ephy-embed-single.c: (ephy_embed_single_get_type),
+ (ephy_embed_single_class_init), (ephy_embed_single_clear_cache),
+ (ephy_embed_single_set_offline_mode),
+ (ephy_embed_single_load_proxy_autoconf),
+ (ephy_embed_single_get_font_list):
+ * embed/ephy-embed-single.h:
+ * embed/ephy-password-manager.c: (ephy_password_info_get_type),
+ (ephy_password_info_new), (ephy_password_info_copy),
+ (ephy_password_info_free), (ephy_password_manager_get_type),
+ (ephy_password_manager_add), (ephy_password_manager_remove),
+ (ephy_password_manager_list):
+ * embed/ephy-password-manager.h:
+ * embed/ephy-permission-manager.c: (ephy_permission_info_get_type),
+ (ephy_permission_info_new), (ephy_permission_info_copy),
+ (ephy_permission_info_free), (ephy_permission_manager_get_type),
+ (ephy_permission_manager_base_init), (ephy_permission_manager_add),
+ (ephy_permission_manager_remove), (ephy_permission_manager_clear),
+ (ephy_permission_manager_test), (ephy_permission_manager_list):
+ * embed/ephy-permission-manager.h:
+ * embed/mozilla/mozilla-embed-single.cpp:
+ * embed/mozilla/mozilla-embed-single.h:
+ * embed/mozilla/mozilla-notifiers.cpp:
+ * src/Makefile.am:
+ * src/pdm-dialog.c: (pdm_dialog_get_type), (pdm_dialog_cookie_add),
+ (pdm_dialog_password_add), (pdm_dialog_cookie_remove),
+ (pdm_dialog_password_remove), (pdm_dialog_cookies_free),
+ (pdm_dialog_passwords_free), (pdm_dialog_init), (pdm_dialog_new),
+ (show_cookies_properties),
+ (pdm_dialog_cookies_properties_button_clicked_cb):
+ * src/pdm-dialog.h:
+
+ New interfaces: EphyCookieManager, EphyPermissionManager,
+ EphyPasswordManager.
+ Port all callers to new interfaces.
+ Change linking order to make it link.
+
+ Only set autoconf proxy url if it's non-empty.
+
2003-11-21 Marco Pesenti Gritti <marco@gnome.org>
* lib/ephy-stock-icons.c: (ephy_stock_icons_init):
diff --git a/embed/Makefile.am b/embed/Makefile.am
index 30ff743e2..511050639 100644
--- a/embed/Makefile.am
+++ b/embed/Makefile.am
@@ -29,6 +29,7 @@ NOINST_H_FILES = \
INST_H_FILES = \
ephy-command-manager.h \
+ ephy-cookie-manager.h \
ephy-embed.h \
ephy-embed-event.h \
ephy-embed-persist.h \
@@ -36,11 +37,14 @@ INST_H_FILES = \
ephy-embed-single.h \
ephy-embed-shell.h \
ephy-encodings.h \
- ephy-history.h
+ ephy-history.h \
+ ephy-password-manager.h \
+ ephy-permission-manager.h
libephyembed_la_SOURCES = \
downloader-view.c \
ephy-command-manager.c \
+ ephy-cookie-manager.c \
ephy-download.c \
ephy-embed.c \
ephy-embed-dialog.c \
@@ -52,7 +56,11 @@ libephyembed_la_SOURCES = \
ephy-encodings.c \
ephy-favicon-cache.c \
ephy-history.c \
+ ephy-password-manager.c \
+ ephy-permission-manager.c \
find-dialog.c \
print-dialog.c \
$(INST_H_FILES) \
$(NOINST_H_FILES)
+
+libephyembed_la_LIBADD = $(top_builddir)/embed/mozilla/libephymozillaembed.la
diff --git a/embed/ephy-cookie-manager.c b/embed/ephy-cookie-manager.c
new file mode 100644
index 000000000..a2c6805fc
--- /dev/null
+++ b/embed/ephy-cookie-manager.c
@@ -0,0 +1,262 @@
+/*
+ * Copyright (C) 2000-2003 Marco Pesenti Gritti
+ * Copyright (C) 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Id$
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "ephy-cookie-manager.h"
+
+GType
+ephy_cookie_get_type (void)
+{
+ static GType type = 0;
+
+ if (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_new0 (EphyCookie, 1);
+}
+
+/**
+ * ephy_cookie_copy:
+ * @cookie: a #EphyCookie
+ *
+ * Return value: a copy of @cookie.
+ **/
+EphyCookie *
+ephy_cookie_copy (EphyCookie *cookie)
+{
+ EphyCookie *copy = g_new0 (EphyCookie, 1);
+
+ 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;
+ copy->p3p_state = cookie->p3p_state;
+ copy->p3p_policy = cookie->p3p_policy;
+
+ 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_free (cookie);
+ }
+}
+
+/* EphyCookieManager */
+
+static void ephy_cookie_manager_base_init (gpointer base_iface);
+
+GType
+ephy_cookie_manager_get_type (void)
+{
+ static GType type = 0;
+
+ if (type == 0)
+ {
+ static 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::added
+ * @manager: the #EphyCookieManager
+ * @cookie: the added #EphyCookie
+ *
+ * The added signal is emitted when a cookie has been added.
+ **/
+ g_signal_new ("added",
+ EPHY_TYPE_COOKIE_MANAGER,
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (EphyCookieManagerIFace, added),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__POINTER,
+ G_TYPE_NONE,
+ 1,
+ EPHY_TYPE_COOKIE);
+
+ /**
+ * EphyCookieManager::changed
+ * @manager: the #EphyCookieManager
+ * @cookie: the changed #EphyCookie
+ *
+ * The changed signal is emitted when a cookie has been changed.
+ **/
+ g_signal_new ("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);
+
+ /**
+ * EphyCookieManager::deleted
+ * @manager: the #EphyCookieManager
+ * @cookie: the deleted #EphyCookie
+ *
+ * The deleted signal is emitted when a cookie has been deleted.
+ **/
+ g_signal_new ("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);
+
+ /**
+ * EphyCookieManager::rejected
+ * @manager: the #EphyCookieManager
+ * @address: the address of the page that wanted to set the cookie
+ *
+ * The rejected signal is emitted when a cookie has been rejected.
+ **/
+ g_signal_new ("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);
+
+ /**
+ * EphyCookieManager::cleared
+ * @manager: the #EphyCookieManager
+ *
+ * The cleared signal is emitted when the cookie database has been
+ * cleared.
+ **/
+ g_signal_new ("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_CLASS (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,
+ EphyCookie *cookie)
+{
+ EphyCookieManagerIFace *iface = EPHY_COOKIE_MANAGER_GET_CLASS (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_CLASS (manager);
+ iface->clear (manager);
+}
diff --git a/embed/ephy-cookie-manager.h b/embed/ephy-cookie-manager.h
new file mode 100644
index 000000000..f4782d2cf
--- /dev/null
+++ b/embed/ephy-cookie-manager.h
@@ -0,0 +1,122 @@
+/*
+ * Copyright (C) 2003 Marco Pesenti Gritti
+ * Copyright (C) 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Id$
+ */
+
+#ifndef EPHY_COOKIE_MANAGER_H
+#define EPHY_COOKIE_MANAGER_H
+
+#include <glib-object.h>
+#include <glib.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_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), EPHY_TYPE_COOKIE_MANAGER, EphyCookieManagerClass))
+#define EPHY_IS_COOKIE_MANAGER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EPHY_TYPE_COOKIE_MANAGER))
+#define EPHY_IS_COOKIE_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EPHY_TYPE_COOKIE_MANAGER))
+#define EPHY_COOKIE_MANAGER_GET_CLASS(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 enum
+{
+ EPHY_COOKIE_P3P_STATE_UNKNOWN,
+ EPHY_COOKIE_P3P_STATE_ACCEPTED,
+ EPHY_COOKIE_P3P_STATE_DOWNGRADED,
+ EPHY_COOKIE_P3P_STATE_FLAGGED,
+ EPHY_COOKIE_P3P_STATE_REJECTED
+} EphyCookieP3PState;
+
+typedef enum
+{
+ EPHY_COOKIE_P3P_POLICY_UNKNOWN,
+ EPHY_COOKIE_P3P_POLICY_NONE,
+ EPHY_COOKIE_P3P_POLICY_NO_CONSENT,
+ EPHY_COOKIE_P3P_POLICY_IMPLICIT_CONSENT,
+ EPHY_COOKIE_P3P_POLICY_EXPLICIT_CONSENT,
+ EPHY_COOKIE_P3P_POLICY_NO_II,
+} EphyCookieP3PPolicy;
+
+typedef struct
+{
+ char *name;
+ char *value;
+ char *domain;
+ char *path;
+ gulong expires;
+ glong real_expires;
+ guint is_secure : 1;
+ guint is_session : 1;
+ guint p3p_state : 3;
+ guint p3p_policy : 3;
+} 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,
+ EphyCookie *cookie);
+ void (* clear) (EphyCookieManager *manager);
+};
+
+/* EphyCookie */
+
+GType ephy_cookie_get_type (void);
+
+EphyCookie *ephy_cookie_new (void);
+
+EphyCookie *ephy_cookie_copy (EphyCookie *cookie);
+
+void ephy_cookie_free (EphyCookie *cookie);
+
+/* EphyCookieManager */
+
+GType ephy_cookie_manager_get_type (void);
+
+void ephy_cookie_free (EphyCookie *cookie);
+
+GList * ephy_cookie_manager_list_cookies (EphyCookieManager *manager);
+
+void ephy_cookie_manager_remove_cookie (EphyCookieManager *manager,
+ EphyCookie *cookie);
+
+void ephy_cookie_manager_clear (EphyCookieManager *manager);
+
+G_END_DECLS
+
+#endif
diff --git a/embed/ephy-embed-single.c b/embed/ephy-embed-single.c
index e5bfd0f65..efaf2db39 100644
--- a/embed/ephy-embed-single.c
+++ b/embed/ephy-embed-single.c
@@ -22,66 +22,41 @@
#include "config.h"
#endif
-#include "ephy-embed-shell.h"
+#include "ephy-embed-single.h"
#include "ephy-marshal.h"
-#include "ephy-favicon-cache.h"
-#include "mozilla-embed-single.h"
-#include "ephy-debug.h"
-#include "downloader-view.h"
-#include <string.h>
-
-#define EPHY_EMBED_SINGLE_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), EPHY_TYPE_EMBED_SINGLE, EphyEmbedSinglePrivate))
-
-struct EphyEmbedSinglePrivate
-{
- EphyHistory *global_history;
- DownloaderView *downloader_view;
- EphyFaviconCache *favicon_cache;
-};
-
-static void
-ephy_embed_single_class_init (EphyEmbedSingleClass *klass);
-static void
-ephy_embed_single_init (EphyEmbedSingle *ges);
-
-static GObjectClass *parent_class = NULL;
+static void ephy_embed_single_class_init (gpointer g_class);
GType
ephy_embed_single_get_type (void)
{
- static GType ephy_embed_single_type = 0;
+ static GType type = 0;
- if (ephy_embed_single_type == 0)
+ if (type == 0)
{
static const GTypeInfo our_info =
{
sizeof (EphyEmbedSingleClass),
- NULL, /* base_init */
- NULL, /* base_finalize */
- (GClassInitFunc) ephy_embed_single_class_init,
- NULL, /* class_finalize */
- NULL, /* class_data */
- sizeof (EphyEmbedSingle),
- 0, /* n_preallocs */
- (GInstanceInitFunc) ephy_embed_single_init
+ ephy_embed_single_class_init,
+ NULL,
};
- ephy_embed_single_type = g_type_register_static (G_TYPE_OBJECT,
- "EphyEmbedSingle",
- &our_info, 0);
+ type = g_type_register_static (G_TYPE_INTERFACE,
+ "EphyEmbedSingle",
+ &our_info,
+ (GTypeFlags) 0);
}
- return ephy_embed_single_type;
+ return type;
}
static void
-ephy_embed_single_class_init (EphyEmbedSingleClass *klass)
+ephy_embed_single_class_init (gpointer g_class)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- parent_class = (GObjectClass *) g_type_class_peek_parent (klass);
+ static gboolean initialised = FALSE;
+ if (initialised == FALSE)
+ {
g_signal_new ("handle_content",
EPHY_TYPE_EMBED_SINGLE,
G_SIGNAL_RUN_LAST,
@@ -93,118 +68,37 @@ ephy_embed_single_class_init (EphyEmbedSingleClass *klass)
G_TYPE_STRING,
G_TYPE_STRING);
- g_type_class_add_private (object_class, sizeof(EphyEmbedSinglePrivate));
-}
-
-static void
-ephy_embed_single_init (EphyEmbedSingle *ges)
-{
- ges->priv = EPHY_EMBED_SINGLE_GET_PRIVATE (ges);
-
- ges->priv->global_history = NULL;
- ges->priv->downloader_view = NULL;
-
- ges->priv->favicon_cache = NULL;
+ initialised = TRUE;
+ }
}
void
-ephy_embed_single_clear_cache (EphyEmbedSingle *shell)
+ephy_embed_single_clear_cache (EphyEmbedSingle *single)
{
- EphyEmbedSingleClass *klass = EPHY_EMBED_SINGLE_GET_CLASS (shell);
- klass->clear_cache (shell);
+ EphyEmbedSingleClass *klass = EPHY_EMBED_SINGLE_GET_CLASS (single);
+ klass->clear_cache (single);
}
void
-ephy_embed_single_set_offline_mode (EphyEmbedSingle *shell,
- gboolean offline)
+ephy_embed_single_set_offline_mode (EphyEmbedSingle *single,
+ gboolean offline)
{
- EphyEmbedSingleClass *klass = EPHY_EMBED_SINGLE_GET_CLASS (shell);
- klass->set_offline_mode (shell, offline);
+ EphyEmbedSingleClass *klass = EPHY_EMBED_SINGLE_GET_CLASS (single);
+ klass->set_offline_mode (single, offline);
}
void
-ephy_embed_single_load_proxy_autoconf (EphyEmbedSingle *shell,
- const char* url)
+ephy_embed_single_load_proxy_autoconf (EphyEmbedSingle *single,
+ const char* url)
{
- EphyEmbedSingleClass *klass = EPHY_EMBED_SINGLE_GET_CLASS (shell);
- klass->load_proxy_autoconf (shell, url);
+ EphyEmbedSingleClass *klass = EPHY_EMBED_SINGLE_GET_CLASS (single);
+ klass->load_proxy_autoconf (single, url);
}
GList *
-ephy_embed_single_get_font_list (EphyEmbedSingle *shell,
+ephy_embed_single_get_font_list (EphyEmbedSingle *single,
const char *langGroup)
{
- EphyEmbedSingleClass *klass = EPHY_EMBED_SINGLE_GET_CLASS (shell);
- return klass->get_font_list (shell, langGroup);
-}
-
-GList *
-ephy_embed_single_list_cookies (EphyEmbedSingle *shell)
-{
- EphyEmbedSingleClass *klass = EPHY_EMBED_SINGLE_GET_CLASS (shell);
- return klass->list_cookies (shell);
-}
-
-void
-ephy_embed_single_remove_cookies (EphyEmbedSingle *shell,
- GList *cookies)
-{
- EphyEmbedSingleClass *klass = EPHY_EMBED_SINGLE_GET_CLASS (shell);
- klass->remove_cookies (shell, cookies);
-}
-
-GList *
-ephy_embed_single_list_passwords (EphyEmbedSingle *shell,
- PasswordType type)
-{
- EphyEmbedSingleClass *klass = EPHY_EMBED_SINGLE_GET_CLASS (shell);
- return klass->list_passwords (shell, type);
-}
-
-void
-ephy_embed_single_remove_passwords (EphyEmbedSingle *shell,
- GList *passwords,
- PasswordType type)
-{
- EphyEmbedSingleClass *klass = EPHY_EMBED_SINGLE_GET_CLASS (shell);
- klass->remove_passwords (shell, passwords, type);
-}
-
-void
-ephy_embed_single_free_cookies (EphyEmbedSingle *shell,
- GList *cookies)
-{
- GList *l;
-
- for (l = cookies; l != NULL; l = l->next)
- {
- CookieInfo *info = (CookieInfo *)l->data;
-
- g_free (info->domain);
- g_free (info->name);
- g_free (info->value);
- g_free (info->path);
- g_free (info->secure);
- g_free (info->expire);
- g_free (info);
- }
-
- g_list_free (cookies);
-}
-
-void
-ephy_embed_single_free_passwords (EphyEmbedSingle *shell,
- GList *passwords)
-{
- GList *l;
-
- for (l = passwords; l != NULL; l = l->next)
- {
- PasswordInfo *info = (PasswordInfo *)l->data;
- g_free (info->host);
- g_free (info->username);
- g_free (info);
- }
-
- g_list_free (passwords);
+ EphyEmbedSingleClass *klass = EPHY_EMBED_SINGLE_GET_CLASS (single);
+ return klass->get_font_list (single, langGroup);
}
diff --git a/embed/ephy-embed-single.h b/embed/ephy-embed-single.h
index a30eb4194..dac415cc1 100644
--- a/embed/ephy-embed-single.h
+++ b/embed/ephy-embed-single.h
@@ -21,10 +21,6 @@
#ifndef EPHY_EMBED_SINGLE_H
#define EPHY_EMBED_SINGLE_H
-#include "ephy-embed.h"
-#include "ephy-history.h"
-#include "ephy-langs.h"
-
#include <glib-object.h>
#include <glib.h>
@@ -35,60 +31,14 @@ G_BEGIN_DECLS
#define EPHY_EMBED_SINGLE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), EPHY_TYPE_EMBED_SINGLE, EphyEmbedSingleClass))
#define EPHY_IS_EMBED_SINGLE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EPHY_TYPE_EMBED_SINGLE))
#define EPHY_IS_EMBED_SINGLE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EPHY_TYPE_EMBED_SINGLE))
-#define EPHY_EMBED_SINGLE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EPHY_TYPE_EMBED_SINGLE, EphyEmbedSingleClass))
-
-typedef struct EphyEmbedSingleClass EphyEmbedSingleClass;
-typedef struct EphyEmbedSingle EphyEmbedSingle;
-typedef struct EphyEmbedSinglePrivate EphyEmbedSinglePrivate;
+#define EPHY_EMBED_SINGLE_GET_CLASS(i) (G_TYPE_INSTANCE_GET_INTERFACE ((i), EPHY_TYPE_EMBED_SINGLE, EphyEmbedSingleClass))
-/**
- * Cookie: the type of cookies
- */
-typedef struct
-{
- gchar *domain;
- gchar *name;
- gchar *value;
- gchar *path;
- gchar *secure;
- gchar *expire;
-} CookieInfo;
-
-/**
- * Password: a password manager entry
- */
-typedef struct
-{
- gchar *host;
- gchar *username;
-} PasswordInfo;
-
-/**
- * PasswordType: To distinguish actual passwords from blocked password sites
- */
-typedef enum
-{
- PASSWORD_PASSWORD,
- PASSWORD_REJECT
-} PasswordType;
-
-typedef enum
-{
- COOKIES_PERMISSION,
- IMAGES_PERMISSION
-} PermissionType;
-
-struct EphyEmbedSingle
-{
- GObject parent;
-
- /*< private >*/
- EphyEmbedSinglePrivate *priv;
-};
+typedef struct EphyEmbedSingleClass EphyEmbedSingleClass;
+typedef struct EphyEmbedSingle EphyEmbedSingle;
struct EphyEmbedSingleClass
{
- GObjectClass parent_class;
+ GTypeInterface base_iface;
/* Signals */
@@ -103,18 +53,8 @@ struct EphyEmbedSingleClass
gboolean offline);
void (* load_proxy_autoconf) (EphyEmbedSingle *shell,
const char* url);
- void (* show_java_console) (EphyEmbedSingle *shell);
- void (* show_js_console) (EphyEmbedSingle *shell);
GList * (* get_font_list) (EphyEmbedSingle *shell,
const char *langGroup);
- GList * (* list_cookies) (EphyEmbedSingle *shell);
- void (* remove_cookies) (EphyEmbedSingle *shell,
- GList *cookies);
- GList * (* list_passwords) (EphyEmbedSingle *shell,
- PasswordType type);
- void (* remove_passwords) (EphyEmbedSingle *shell,
- GList *passwords,
- PasswordType type);
};
GType ephy_embed_single_get_type (void);
@@ -125,31 +65,11 @@ void ephy_embed_single_set_offline_mode (EphyEmbedSingle *shell,
gboolean offline);
void ephy_embed_single_load_proxy_autoconf (EphyEmbedSingle *shell,
- const char* url);
+ const char* url);
GList *ephy_embed_single_get_font_list (EphyEmbedSingle *shell,
const char *langGroup);
-/* Cookies */
-GList *ephy_embed_single_list_cookies (EphyEmbedSingle *shell);
-
-void ephy_embed_single_remove_cookies (EphyEmbedSingle *shell,
- GList *cookies);
-
-void ephy_embed_single_free_cookies (EphyEmbedSingle *shell,
- GList *cookies);
-
-/* Passwords */
-GList *ephy_embed_single_list_passwords (EphyEmbedSingle *shell,
- PasswordType type);
-
-void ephy_embed_single_free_passwords (EphyEmbedSingle *shell,
- GList *passwords);
-
-void ephy_embed_single_remove_passwords (EphyEmbedSingle *shell,
- GList *passwords,
- PasswordType type);
-
G_END_DECLS
#endif
diff --git a/embed/ephy-password-manager.c b/embed/ephy-password-manager.c
new file mode 100644
index 000000000..d9b7e8dc2
--- /dev/null
+++ b/embed/ephy-password-manager.c
@@ -0,0 +1,175 @@
+/*
+ * Copyright (C) 2003 Marco Pesenti Gritti
+ * Copyright (C) 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Id$
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "ephy-password-manager.h"
+#include "ephy-marshal.h"
+#include "ephy-debug.h"
+
+/* EphyPasswordInfo */
+
+GType
+ephy_password_info_get_type (void)
+{
+ static GType type = 0;
+
+ if (type == 0)
+ {
+ type = g_boxed_type_register_static ("EphyPasswordInfo",
+ (GBoxedCopyFunc) ephy_password_info_copy,
+ (GBoxedFreeFunc) ephy_password_info_free);
+ }
+
+ return type;
+}
+
+/**
+ * ephy_password_info_new:
+ * @host: a host name
+ * @username: a user name
+ * @password: a password, or NULL
+ *
+ * Generates a new #EphyPasswordInfo.
+ *
+ * Return value: the new password info.
+ **/
+EphyPasswordInfo *
+ephy_password_info_new (const char *host,
+ const char *username,
+ const char *password)
+{
+ EphyPasswordInfo *info = g_new0 (EphyPasswordInfo, 1);
+
+ info->host = g_strdup (host);
+ info->username = g_strdup (username);
+ info->password = g_strdup (password);
+
+ return info;
+}
+
+/**
+ * ephy_password_info_copy:
+ * @info: a #EphyPasswordInfo
+ *
+ * Return value: a copy of @info
+ **/
+EphyPasswordInfo *
+ephy_password_info_copy (EphyPasswordInfo *info)
+{
+ EphyPasswordInfo *copy = g_new0 (EphyPasswordInfo, 1);
+
+ copy->host = g_strdup (info->host);
+ copy->username = g_strdup (info->username);
+ copy->password = g_strdup (info->password);
+
+ return copy;
+}
+
+/**
+ * ephy_password_info_free:
+ * @info:
+ *
+ * Frees @info.
+ **/
+void
+ephy_password_info_free (EphyPasswordInfo *info)
+{
+ if (info != NULL)
+ {
+ g_free (info->host);
+ g_free (info->username);
+ g_free (info->password);
+ g_free (info);
+ }
+}
+
+/* EphyPasswordManager */
+
+GType
+ephy_password_manager_get_type (void)
+{
+ static GType type = 0;
+
+ if (type == 0)
+ {
+ static const GTypeInfo our_info =
+ {
+ sizeof (EphyPasswordManagerIFace),
+ NULL,
+ NULL,
+ };
+
+ type = g_type_register_static (G_TYPE_INTERFACE,
+ "EphyPasswordManager",
+ &our_info,
+ (GTypeFlags) 0);
+ }
+
+ return type;
+}
+
+/**
+ * ephy_password_manager_add:
+ * @manager: the #EphyPasswordManager
+ * @info: a #EphyPasswordInfo
+ *
+ * Adds the password entry @info to the the passwords database.
+ **/
+void
+ephy_password_manager_add (EphyPasswordManager *manager,
+ EphyPasswordInfo *info)
+{
+ EphyPasswordManagerIFace *iface = EPHY_PASSWORD_MANAGER_GET_IFACE (manager);
+ iface->add (manager, info);
+}
+
+/**
+ * ephy_password_manager_remove:
+ * @manager: the #EphyPasswordManager
+ * @info: a #EphyPasswordInfo
+ *
+ * Removes the password entry @info from the passwords database.
+ **/
+void
+ephy_password_manager_remove (EphyPasswordManager *manager,
+ EphyPasswordInfo *info)
+{
+ EphyPasswordManagerIFace *iface = EPHY_PASSWORD_MANAGER_GET_IFACE (manager);
+ iface->remove (manager, info);
+}
+
+/**
+ * ephy_password_manager_list:
+ * @manager: the #EphyPasswordManager
+ *
+ * Lists all password entries in the passwords database.
+ *
+ * Return value: the list of password entries
+ **/
+GList *
+ephy_password_manager_list (EphyPasswordManager *manager)
+{
+ EphyPasswordManagerIFace *iface = EPHY_PASSWORD_MANAGER_GET_IFACE (manager);
+ return iface->list (manager);
+}
diff --git a/embed/ephy-password-manager.h b/embed/ephy-password-manager.h
new file mode 100644
index 000000000..34d33b0f9
--- /dev/null
+++ b/embed/ephy-password-manager.h
@@ -0,0 +1,87 @@
+/*
+ * Copyright (C) 2003 Marco Pesenti Gritti
+ * Copyright (C) 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Id$
+ */
+
+#ifndef EPHY_PASSWORD_MANAGER_H
+#define EPHY_PASSWORD_MANAGER_H
+
+#include <glib-object.h>
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+#define EPHY_TYPE_PASSWORD_MANAGER (ephy_password_manager_get_type ())
+#define EPHY_PASSWORD_MANAGER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EPHY_TYPE_PASSWORD_MANAGER, EphyPasswordManager))
+#define EPHY_PASSWORD_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), EPHY_TYPE_PASSWORD_MANAGER, EphyPasswordManagerClass))
+#define EPHY_IS_PASSWORD_MANAGER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EPHY_TYPE_PASSWORD_MANAGER))
+#define EPHY_IS_PASSWORD_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EPHY_TYPE_PASSWORD_MANAGER))
+#define EPHY_PASSWORD_MANAGER_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), EPHY_TYPE_PASSWORD_MANAGER, EphyPasswordManagerIFace))
+
+#define EPHY_TYPE_PASSWORD_INFO (ephy_password_info_get_type ())
+
+typedef struct EphyPasswordManager EphyPasswordManager;
+typedef struct EphyPasswordManagerIFace EphyPasswordManagerIFace;
+
+typedef struct
+{
+ char *host;
+ char *username;
+ char *password;
+} EphyPasswordInfo;
+
+struct EphyPasswordManagerIFace
+{
+ GTypeInterface base_iface;
+
+ /* Methods */
+ void (* add) (EphyPasswordManager *manager,
+ EphyPasswordInfo *info);
+ void (* remove) (EphyPasswordManager *manager,
+ EphyPasswordInfo *info);
+ GList * (* list) (EphyPasswordManager *manager);
+};
+
+/* EphyPasswordInfo */
+
+GType ephy_password_info_get_type (void);
+
+EphyPasswordInfo *ephy_password_info_new (const char *host,
+ const char *username,
+ const char *password);
+
+EphyPasswordInfo *ephy_password_info_copy (EphyPasswordInfo *info);
+
+void ephy_password_info_free (EphyPasswordInfo *info);
+
+/* EphyPasswordManager */
+
+GType ephy_password_manager_get_type (void);
+
+void ephy_password_manager_add (EphyPasswordManager *manager,
+ EphyPasswordInfo *info);
+
+void ephy_password_manager_remove (EphyPasswordManager *manager,
+ EphyPasswordInfo *info);
+
+GList * ephy_password_manager_list (EphyPasswordManager *manager);
+
+G_END_DECLS
+
+#endif
diff --git a/embed/ephy-permission-manager.c b/embed/ephy-permission-manager.c
new file mode 100644
index 000000000..878ead738
--- /dev/null
+++ b/embed/ephy-permission-manager.c
@@ -0,0 +1,295 @@
+/*
+ * Copyright (C) 2003 Marco Pesenti Gritti
+ * Copyright (C) 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Id$
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "ephy-permission-manager.h"
+#include "ephy-marshal.h"
+#include "ephy-debug.h"
+
+/* EphyPermissionInfo */
+
+GType
+ephy_permission_info_get_type (void)
+{
+ static GType type = 0;
+
+ if (type == 0)
+ {
+ type = g_boxed_type_register_static ("EphyPermissionInfo",
+ (GBoxedCopyFunc) ephy_permission_info_copy,
+ (GBoxedFreeFunc) ephy_permission_info_free);
+ }
+
+ return type;
+}
+
+/**
+ * ephy_permission_info_new:
+ * @host: a host name
+ * @type: a #EphyPermissionType
+ * @allowed: whether @host should be allowed to do what @type specifies
+ *
+ * Return value: the new #EphyPermissionInfo
+ **/
+EphyPermissionInfo *
+ephy_permission_info_new (const char *host,
+ EphyPermissionType type,
+ gboolean allowed)
+{
+ EphyPermissionInfo *info = g_new0 (EphyPermissionInfo, 1);
+
+ info->host = g_strdup (host);
+ info->type = type;
+ info->allowed = allowed;
+
+ return info;
+}
+
+/**
+ * ephy_permission_info_copy:
+ * @info: a #EphyPermissionInfo
+ *
+ * Return value: a copy of @info
+ **/
+EphyPermissionInfo *
+ephy_permission_info_copy (EphyPermissionInfo *info)
+{
+ EphyPermissionInfo *copy = g_new0 (EphyPermissionInfo, 1);
+
+ copy->host = g_strdup (info->host);
+ copy->type = info->type;
+ copy->allowed = info->allowed;
+
+ return copy;
+}
+
+/**
+ * ephy_permission_info_free:
+ * @info: a #EphyPermissionInfo
+ *
+ * Frees @info.
+ **/
+void
+ephy_permission_info_free (EphyPermissionInfo *info)
+{
+ if (info != NULL)
+ {
+ g_free (info->host);
+ g_free (info);
+ }
+}
+
+/* EphyPermissionManager */
+
+static void ephy_permission_manager_base_init (gpointer g_class);
+
+GType
+ephy_permission_manager_get_type (void)
+{
+ static GType type = 0;
+
+ if (type == 0)
+ {
+ static const GTypeInfo our_info =
+ {
+ sizeof (EphyPermissionManagerIFace),
+ ephy_permission_manager_base_init,
+ NULL,
+ };
+
+ type = g_type_register_static (G_TYPE_INTERFACE,
+ "EphyPermissionManager",
+ &our_info,
+ (GTypeFlags) 0);
+ }
+
+ return type;
+}
+
+static void
+ephy_permission_manager_base_init (gpointer g_class)
+{
+ static gboolean initialised = FALSE;
+
+ if (initialised == FALSE)
+ {
+ /**
+ * EphyPermissionManager::added
+ * @manager: the #EphyPermissionManager
+ * @info: a #EphyPermissionInfo
+ *
+ * The added signal is emitted when a permission entry has been added.
+ */
+ g_signal_new ("added",
+ EPHY_TYPE_PERMISSION_MANAGER,
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (EphyPermissionManagerIFace, added),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__BOXED,
+ G_TYPE_NONE,
+ 1,
+ EPHY_TYPE_PERMISSION_INFO);
+
+ /**
+ * EphyPermissionManager::changed
+ * @manager: the #EphyPermissionManager
+ * @info: a #EphyPermissionInfo
+ *
+ * The changed signal is emitted when a permission entry has been
+ * changed.
+ */
+ g_signal_new ("changed",
+ EPHY_TYPE_PERMISSION_MANAGER,
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (EphyPermissionManagerIFace, changed),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__BOXED,
+ G_TYPE_NONE,
+ 1,
+ EPHY_TYPE_PERMISSION_INFO);
+
+ /**
+ * EphyPermissionManager::deleted
+ * @manager: the #EphyPermissionManager
+ * @info: a #EphyPermissionInfo
+ *
+ * The deleted signal is emitted when a permission entry has been
+ * deleted.
+ */
+ g_signal_new ("deleted",
+ EPHY_TYPE_PERMISSION_MANAGER,
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (EphyPermissionManagerIFace, deleted),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__BOXED,
+ G_TYPE_NONE,
+ 1,
+ EPHY_TYPE_PERMISSION_INFO);
+
+ /**
+ * EphyPermissionManager::cleared
+ * @manager: the #EphyPermissionManager
+ *
+ * The cleared signal is emitted when the permissions database has
+ * been cleared.
+ */
+ g_signal_new ("cleared",
+ EPHY_TYPE_PERMISSION_MANAGER,
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (EphyPermissionManagerIFace, cleared),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
+
+ initialised = TRUE;
+ }
+}
+
+/**
+ * ephy_permission_manager_add:
+ * @manager: the #EphyPermissionManager
+ * @host: a host name
+ * @type: a #EphyPermissionType
+ * @allow: the permission itself
+ *
+ * Adds the permission @allow of type @type for host @host to the permissions
+ * database.
+ **/
+void
+ephy_permission_manager_add (EphyPermissionManager *manager,
+ const char *host,
+ EphyPermissionType type,
+ gboolean allow)
+{
+ EphyPermissionManagerIFace *iface = EPHY_PERMISSION_MANAGER_GET_IFACE (manager);
+ iface->add (manager, host, type, allow);
+}
+
+/**
+ * ephy_permission_manager_remove:
+ * @manager: the #EphyPermissionManager
+ * @host: a host name
+ * @type: a #EphyPermissionType
+ *
+ * Removes the permission of type @type for host @host from the permissions
+ * database.
+ **/
+void
+ephy_permission_manager_remove (EphyPermissionManager *manager,
+ const char *host,
+ EphyPermissionType type)
+{
+ EphyPermissionManagerIFace *iface = EPHY_PERMISSION_MANAGER_GET_IFACE (manager);
+ iface->remove (manager, host, type);
+}
+
+/**
+ * ephy_permission_manager_clear:
+ * @manager: the #EphyPermissionManager
+ *
+ * Clears the permissions database.
+ **/
+void
+ephy_permission_manager_clear (EphyPermissionManager *manager)
+{
+ EphyPermissionManagerIFace *iface = EPHY_PERMISSION_MANAGER_GET_IFACE (manager);
+ iface->clear (manager);
+}
+
+/**
+ * ephy_permission_manager_test:
+ * @manager: the #EphyPermissionManager
+ * @host: a host name
+ * @type: a #EphyPermissionType
+ *
+ * Tests whether the host @host is allowed to do the action specified by @type.
+ *
+ * Return value: TRUE if allowed
+ **/
+gboolean
+ephy_permission_manager_test (EphyPermissionManager *manager,
+ const char *host,
+ EphyPermissionType type)
+{
+ EphyPermissionManagerIFace *iface = EPHY_PERMISSION_MANAGER_GET_IFACE (manager);
+ return iface->test (manager, host, type);
+}
+
+/**
+ * ephy_permission_manager_list:
+ * @manager: the #EphyPermissionManager
+ * @type: a #EphyPermissionType
+ *
+ * Lists all permission entries of type @type in the permissions database.
+ *
+ * Return value: the list of permission entries
+ **/
+GList *
+ephy_permission_manager_list (EphyPermissionManager *manager,
+ EphyPermissionType type)
+{
+ EphyPermissionManagerIFace *iface = EPHY_PERMISSION_MANAGER_GET_IFACE (manager);
+ return iface->list (manager, type);
+}
diff --git a/embed/ephy-permission-manager.h b/embed/ephy-permission-manager.h
new file mode 100644
index 000000000..e8e2a5fb2
--- /dev/null
+++ b/embed/ephy-permission-manager.h
@@ -0,0 +1,121 @@
+/*
+ * Copyright (C) 2003 Marco Pesenti Gritti
+ * Copyright (C) 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Id$
+ */
+
+#ifndef EPHY_PERMISSION_MANAGER_H
+#define EPHY_PERMISSION_MANAGER_H
+
+#include <glib-object.h>
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+#define EPHY_TYPE_PERMISSION_MANAGER (ephy_permission_manager_get_type ())
+#define EPHY_PERMISSION_MANAGER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EPHY_TYPE_PERMISSION_MANAGER, EphyPermissionManager))
+#define EPHY_PERMISSION_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), EPHY_TYPE_PERMISSION_MANAGER, EphyPermissionManagerClass))
+#define EPHY_IS_PERMISSION_MANAGER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EPHY_TYPE_PERMISSION_MANAGER))
+#define EPHY_IS_PERMISSION_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EPHY_TYPE_PERMISSION_MANAGER))
+#define EPHY_PERMISSION_MANAGER_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), EPHY_TYPE_PERMISSION_MANAGER, EphyPermissionManagerIFace))
+
+#define EPHY_TYPE_PERMISSION_INFO (ephy_permission_info_get_type ())
+
+typedef struct EphyPermissionManager EphyPermissionManager;
+typedef struct EphyPermissionManagerIFace EphyPermissionManagerIFace;
+
+typedef enum
+{
+ EPT_COOKIE,
+ EPT_IMAGE,
+ EPT_PASSWORD
+} EphyPermissionType;
+
+typedef struct
+{
+ char *host;
+ EphyPermissionType type;
+ gboolean allowed;
+} EphyPermissionInfo;
+
+struct EphyPermissionManagerIFace
+{
+ GTypeInterface base_iface;
+
+ /* Signals */
+ void (* added) (EphyPermissionManager *manager,
+ EphyPermissionInfo *info);
+ void (* changed) (EphyPermissionManager *manager,
+ EphyPermissionInfo *info);
+ void (* deleted) (EphyPermissionManager *manager,
+ EphyPermissionInfo *info);
+ void (* cleared) (EphyPermissionManager *manager);
+
+ /* Methods */
+ void (* add) (EphyPermissionManager *manager,
+ const char *host,
+ EphyPermissionType type,
+ gboolean allow);
+ void (* remove) (EphyPermissionManager *manager,
+ const char *host,
+ EphyPermissionType type);
+ void (* clear) (EphyPermissionManager *manager);
+ gboolean (* test) (EphyPermissionManager *manager,
+ const char *host,
+ EphyPermissionType type);
+ GList * (* list) (EphyPermissionManager *manager,
+ EphyPermissionType type);
+};
+
+/* EphyPermissionInfo */
+
+GType ephy_permission_info_get_type (void);
+
+EphyPermissionInfo *ephy_permission_info_new (const char *host,
+ EphyPermissionType type,
+ gboolean allowed);
+
+EphyPermissionInfo *ephy_permission_info_copy (EphyPermissionInfo *info);
+
+void ephy_permission_info_free (EphyPermissionInfo *info);
+
+/* EphyPermissionManager */
+
+GType ephy_permission_manager_get_type (void);
+
+void ephy_permission_manager_add (EphyPermissionManager *manager,
+ const char *host,
+ EphyPermissionType type,
+ gboolean allow);
+
+void ephy_permission_manager_remove (EphyPermissionManager *manager,
+ const char *host,
+ EphyPermissionType type);
+
+void ephy_permission_manager_clear (EphyPermissionManager *manager);
+
+gboolean ephy_permission_manager_test (EphyPermissionManager *manager,
+ const char *host,
+ EphyPermissionType type);
+
+GList * ephy_permission_manager_list (EphyPermissionManager *manager,
+ EphyPermissionType type);
+
+G_END_DECLS
+
+#endif
diff --git a/embed/mozilla/mozilla-embed-single.cpp b/embed/mozilla/mozilla-embed-single.cpp
index 28b1a3b23..4277dfc0a 100644
--- a/embed/mozilla/mozilla-embed-single.cpp
+++ b/embed/mozilla/mozilla-embed-single.cpp
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2000-2003 Marco Pesenti Gritti
+ * Copyright (C) 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
@@ -22,11 +23,16 @@
#include "config.h"
#endif
+#include "mozilla-embed-single.h"
+
+#include "ephy-cookie-manager.h"
+#include "ephy-password-manager.h"
+#include "ephy-permission-manager.h"
+
#include "glib.h"
#include "ephy-debug.h"
#include "gtkmozembed.h"
#include "mozilla-embed.h"
-#include "mozilla-embed-single.h"
#include "ephy-file-helpers.h"
#include "mozilla-notifiers.h"
#include "ephy-langs.h"
@@ -34,7 +40,6 @@
#include "ephy-embed-prefs.h"
#include "MozRegisterComponents.h"
-#include <time.h>
#include <glib/gi18n.h>
#include <libgnomevfs/gnome-vfs-utils.h>
#include <nsICacheService.h>
@@ -48,7 +53,9 @@
#include <nsIFontEnumerator.h>
#include <nsISupportsPrimitives.h>
#include <nsReadableUtils.h>
+#include <nsICookie2.h>
#include <nsICookieManager.h>
+#include <nsIPassword.h>
#include <nsIPasswordManager.h>
#include <nsIPassword.h>
#include <nsICookie.h>
@@ -58,8 +65,12 @@
#include <nsCCookieManager.h>
#endif
#include <nsCPasswordManager.h>
+#include <nsIPermission.h>
+#include <nsIPermissionManager.h>
#include <nsString.h>
#include <nsILocalFile.h>
+#include <nsIURI.h>
+#include <nsNetUtil.h>
// FIXME: For setting the locale. hopefully gtkmozembed will do itself soon
#include <nsIChromeRegistry.h>
@@ -70,13 +81,6 @@
#define MOZILLA_PROFILE_FILE "prefs.js"
#define DEFAULT_PROFILE_FILE SHARE_DIR"/default-prefs.js"
-static void
-mozilla_embed_single_class_init (MozillaEmbedSingleClass *klass);
-static void
-mozilla_embed_single_init (MozillaEmbedSingle *ges);
-static void
-mozilla_embed_single_finalize (GObject *object);
-
#define MOZILLA_EMBED_SINGLE_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), MOZILLA_TYPE_EMBED_SINGLE, MozillaEmbedSinglePrivate))
struct MozillaEmbedSinglePrivate
@@ -87,14 +91,21 @@ struct MozillaEmbedSinglePrivate
GtkWidget *theme_window;
};
+static void mozilla_embed_single_class_init (MozillaEmbedSingleClass *klass);
+static void ephy_embed_single_iface_init (EphyEmbedSingleClass *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);
+static void mozilla_embed_single_init (MozillaEmbedSingle *ges);
+
static GObjectClass *parent_class = NULL;
GType
mozilla_embed_single_get_type (void)
{
- static GType mozilla_embed_single_type = 0;
+ static GType type = 0;
- if (mozilla_embed_single_type == 0)
+ if (type == 0)
{
static const GTypeInfo our_info =
{
@@ -109,12 +120,57 @@ mozilla_embed_single_get_type (void)
(GInstanceInitFunc) mozilla_embed_single_init
};
- mozilla_embed_single_type = g_type_register_static (EPHY_TYPE_EMBED_SINGLE,
- "MozillaEmbedSingle",
- &our_info, (GTypeFlags)0);
- }
+ static const GInterfaceInfo embed_single_info =
+ {
+ (GInterfaceInitFunc) ephy_embed_single_iface_init,
+ NULL,
+ NULL
+ };
+
+ static const GInterfaceInfo cookie_manager_info =
+ {
+ (GInterfaceInitFunc) ephy_cookie_manager_iface_init,
+ NULL,
+ NULL
+ };
+
+ static const GInterfaceInfo password_manager_info =
+ {
+ (GInterfaceInitFunc) ephy_password_manager_iface_init,
+ NULL,
+ NULL
+ };
+
+ static const GInterfaceInfo permission_manager_info =
+ {
+ (GInterfaceInitFunc) ephy_permission_manager_iface_init,
+ NULL,
+ NULL
+ };
+
+ type = g_type_register_static (G_TYPE_OBJECT,
+ "MozillaEmbedSingle",
+ &our_info,
+ (GTypeFlags)0);
+
+ g_type_add_interface_static (type,
+ EPHY_TYPE_EMBED_SINGLE,
+ &embed_single_info);
+
+ g_type_add_interface_static (type,
+ EPHY_TYPE_COOKIE_MANAGER,
+ &cookie_manager_info);
+
+ g_type_add_interface_static (type,
+ EPHY_TYPE_PASSWORD_MANAGER,
+ &password_manager_info);
+
+ g_type_add_interface_static (type,
+ EPHY_TYPE_PERMISSION_MANAGER,
+ &permission_manager_info);
+ }
- return mozilla_embed_single_type;
+ return type;
}
EphyEmbedSingle *
@@ -495,8 +551,9 @@ static void
impl_load_proxy_autoconf (EphyEmbedSingle *shell,
const char* url)
{
- nsresult rv;
+ g_assert (url != NULL);
+ nsresult rv;
nsCOMPtr<nsIProtocolProxyService> pps =
do_GetService ("@mozilla.org/network/protocol-proxy-service;1",
&rv);
@@ -537,174 +594,376 @@ impl_get_font_list (EphyEmbedSingle *shell,
return g_list_reverse (l);
}
+static EphyCookie *
+mozilla_cookie_to_ephy_cookie (nsICookie2 *keks)
+{
+ EphyCookie *cookie;
+
+ cookie = ephy_cookie_new ();
+
+ nsCAutoString transfer;
+
+ keks->GetHost (transfer);
+ cookie->domain = g_strdup (transfer.get());
+ keks->GetName (transfer);
+ cookie->name = g_strdup (transfer.get());
+ keks->GetValue (transfer);
+ cookie->value = g_strdup (transfer.get());
+ keks->GetPath (transfer);
+ cookie->path = g_strdup (transfer.get());
+
+ PRBool isSecure;
+ keks->GetIsSecure (&isSecure);
+ cookie->is_secure = isSecure != PR_FALSE;
+
+ PRUint64 dateTime;
+ keks->GetExpires (&dateTime);
+ cookie->expires = dateTime;
+
+ PRInt64 expiry;
+ keks->GetExpiry (&expiry);
+ cookie->real_expires = expiry;
+
+ nsCookieStatus status;
+ keks->GetStatus (&status);
+ cookie->p3p_state = status;
+
+ nsCookiePolicy policy;
+ keks->GetPolicy (&policy);
+ cookie->p3p_policy = policy;
+
+ PRBool isSession;
+ keks->GetIsSession (&isSession);
+ cookie->is_session = isSession != PR_FALSE;
+
+ return cookie;
+}
+
static GList *
-impl_list_cookies (EphyEmbedSingle *shell)
+impl_list_cookies (EphyCookieManager *manager)
{
- nsresult result;
+ nsresult result;
GList *cookies = NULL;
-
- nsCOMPtr<nsICookieManager> cookieManager =
- do_CreateInstance (NS_COOKIEMANAGER_CONTRACTID);
- nsCOMPtr<nsISimpleEnumerator> cookieEnumerator;
- result =
- cookieManager->GetEnumerator (getter_AddRefs(cookieEnumerator));
- if (NS_FAILED(result)) return NULL;
- PRBool enumResult;
- for (cookieEnumerator->HasMoreElements(&enumResult) ;
- enumResult == PR_TRUE ;
- cookieEnumerator->HasMoreElements(&enumResult))
- {
- CookieInfo *c;
-
- nsCOMPtr<nsICookie> nsCookie;
- result = cookieEnumerator->GetNext (getter_AddRefs(nsCookie));
- if (NS_FAILED(result)) return NULL;
-
- c = g_new0 (CookieInfo, 1);
-
- nsCAutoString transfer;
-
- nsCookie->GetHost (transfer);
- c->domain = g_strdup (transfer.get());
- nsCookie->GetName (transfer);
- c->name = g_strdup (transfer.get());
- nsCookie->GetValue (transfer);
- c->value = g_strdup (transfer.get());
- nsCookie->GetPath (transfer);
- c->path = g_strdup (transfer.get());
-
- PRBool isSecure;
- nsCookie->GetIsSecure (&isSecure);
- if (isSecure == PR_TRUE)
- c->secure = g_strdup (_("Yes"));
- else
- c->secure = g_strdup (_("No"));
-
- PRUint64 dateTime;
- nsCookie->GetExpires (&dateTime);
- if(dateTime == 0)
- c->expire = g_strdup (_("End of current session"));
- else
- c->expire = g_strdup_printf ("%s",ctime((time_t*)&dateTime));
-
- cookies = g_list_prepend (cookies, c);
- }
-
- return g_list_reverse (cookies);
+ nsCOMPtr<nsICookieManager> cookieManager =
+ do_CreateInstance (NS_COOKIEMANAGER_CONTRACTID);
+ nsCOMPtr<nsISimpleEnumerator> cookieEnumerator;
+ result = cookieManager->GetEnumerator (getter_AddRefs(cookieEnumerator));
+ if (NS_FAILED(result) || !cookieEnumerator) return NULL;
+
+ PRBool enumResult;
+ for (cookieEnumerator->HasMoreElements(&enumResult) ;
+ enumResult == PR_TRUE ;
+ cookieEnumerator->HasMoreElements(&enumResult))
+ {
+ nsCOMPtr<nsICookie> keks;
+ result = cookieEnumerator->GetNext (getter_AddRefs(keks));
+ if (NS_FAILED (result) || !keks) continue;
+
+ nsCOMPtr<nsICookie2> keks2 = do_QueryInterface (keks, &result);
+ if (NS_FAILED (result) || !keks2) continue;
+
+ EphyCookie *cookie = mozilla_cookie_to_ephy_cookie (keks2);
+ if (cookie != NULL)
+ {
+ cookies = g_list_prepend (cookies, cookie);
+ }
+ }
+
+ return cookies;
}
static void
-impl_remove_cookies (EphyEmbedSingle *shell,
- GList *cookies)
+impl_remove_cookie (EphyCookieManager *manager,
+ EphyCookie *cookie)
{
- nsresult result;
- GList *cl;
- nsCOMPtr<nsICookieManager> cookieManager =
- do_CreateInstance (NS_COOKIEMANAGER_CONTRACTID);
-
- for (cl = cookies; cl != NULL; cl = cl->next)
- {
- CookieInfo *c = (CookieInfo *)cl->data;
+ nsresult rv;
+ nsCOMPtr<nsICookieManager> cookieManager =
+ do_CreateInstance (NS_COOKIEMANAGER_CONTRACTID, &rv);
+ if (NS_FAILED (rv) || !cookieManager) return;
+
+ cookieManager->Remove (nsDependentCString(cookie->domain),
+ nsDependentCString(cookie->name),
+ nsDependentCString(cookie->path),
+ PR_FALSE /* block */);
+}
- result = cookieManager->Remove (nsDependentCString(c->domain),
- nsDependentCString(c->name),
- nsDependentCString(c->path),
- PR_FALSE);
- };
+static void
+impl_clear_cookies (EphyCookieManager *manager)
+{
+ nsresult rv;
+ nsCOMPtr<nsICookieManager> cookieManager =
+ do_CreateInstance (NS_COOKIEMANAGER_CONTRACTID, &rv);
+ if (NS_SUCCEEDED (rv))
+ {
+ cookieManager->RemoveAll ();
+ }
}
static GList *
-impl_list_passwords (EphyEmbedSingle *shell,
- PasswordType type)
+impl_list_passwords (EphyPasswordManager *manager)
{
- nsresult result = NS_ERROR_FAILURE;
GList *passwords = NULL;
- nsCOMPtr<nsIPasswordManager> passwordManager =
- do_CreateInstance (NS_PASSWORDMANAGER_CONTRACTID);
- nsCOMPtr<nsISimpleEnumerator> passwordEnumerator;
- if (type == PASSWORD_PASSWORD)
- result = passwordManager->GetEnumerator
- (getter_AddRefs(passwordEnumerator));
- else if (type == PASSWORD_REJECT)
- result = passwordManager->GetRejectEnumerator
- (getter_AddRefs(passwordEnumerator));
- if (NS_FAILED(result)) return NULL;
-
- PRBool enumResult;
- for (passwordEnumerator->HasMoreElements(&enumResult) ;
- enumResult == PR_TRUE ;
- passwordEnumerator->HasMoreElements(&enumResult))
- {
- nsCOMPtr<nsIPassword> nsPassword;
- result = passwordEnumerator->GetNext
- (getter_AddRefs(nsPassword));
- if (NS_FAILED(result)) return NULL;
+ nsresult result;
+ nsCOMPtr<nsIPasswordManager> passwordManager =
+ do_CreateInstance (NS_PASSWORDMANAGER_CONTRACTID);
+ if (!passwordManager) return NULL;
+
+ nsCOMPtr<nsISimpleEnumerator> passwordEnumerator;
+ result = passwordManager->GetEnumerator
+ (getter_AddRefs(passwordEnumerator));
+ if (NS_FAILED(result) || !passwordEnumerator) return NULL;
+
+ PRBool enumResult;
+ for (passwordEnumerator->HasMoreElements(&enumResult) ;
+ enumResult == PR_TRUE ;
+ passwordEnumerator->HasMoreElements(&enumResult))
+ {
+ nsCOMPtr<nsIPassword> nsPassword;
+ result = passwordEnumerator->GetNext
+ (getter_AddRefs(nsPassword));
+ if (NS_FAILED(result) || !nsPassword) continue;
- PasswordInfo *p = g_new0 (PasswordInfo, 1);
+ EphyPasswordInfo *p = g_new0 (EphyPasswordInfo, 1);
- nsCAutoString transfer;
- nsPassword->GetHost (transfer);
- p->host = g_strdup (transfer.get());
+ nsCAutoString transfer;
+ nsPassword->GetHost (transfer);
+ p->host = g_strdup (transfer.get());
- if (type == PASSWORD_PASSWORD)
- {
- nsAutoString unicodeName;
- nsPassword->GetUser (unicodeName);
- p->username = g_strdup(NS_ConvertUCS2toUTF8(unicodeName).get());
- }
+ nsAutoString unicodeName;
+ nsPassword->GetUser (unicodeName);
+ p->username = g_strdup(NS_ConvertUCS2toUTF8(unicodeName).get());
- passwords = g_list_prepend (passwords, p);
- }
+ p->password = NULL;
- return g_list_reverse (passwords);
+ passwords = g_list_prepend (passwords, p);
+ }
+
+ return passwords;
}
static void
-impl_remove_passwords (EphyEmbedSingle *shell,
- GList *passwords,
- PasswordType type)
+impl_remove_password (EphyPasswordManager *manager,
+ EphyPasswordInfo *info)
{
- nsresult result = NS_ERROR_FAILURE;
- nsCOMPtr<nsIPasswordManager> passwordManager =
+ nsCOMPtr<nsIPasswordManager> pm =
do_CreateInstance (NS_PASSWORDMANAGER_CONTRACTID);
- GList *l;
+ if (pm)
+ {
+ pm->RemoveUser (nsDependentCString(info->host),
+ NS_ConvertUTF8toUCS2(nsDependentCString(info->username)));
+ }
+}
- for (l = passwords; l != NULL; l = l->next)
- {
- PasswordInfo *p = (PasswordInfo *)l->data;
- if (type == PASSWORD_PASSWORD)
- {
- result = passwordManager->RemoveUser (NS_LITERAL_CSTRING(p->host),
- NS_ConvertUTF8toUCS2(nsDependentCString(p->username)));
- }
- else if (type == PASSWORD_REJECT)
- {
- result = passwordManager->RemoveReject
- (nsDependentCString(p->host));
- };
- };
+static const char *permission_type_string [] =
+{
+ "cookie",
+ "image",
+ "popup"
+};
+
+void
+impl_permission_manager_add (EphyPermissionManager *manager,
+ const char *host,
+ EphyPermissionType type,
+ gboolean allow)
+{
+ nsresult result;
+ nsCOMPtr<nsIPermissionManager> pm
+ (do_CreateInstance (NS_PERMISSIONMANAGER_CONTRACTID, &result));
+ if (NS_FAILED (result) || !pm) return;
+
+ nsCOMPtr<nsIURI> uri;
+ result = NS_NewURI(getter_AddRefs(uri), host);
+ if (NS_FAILED(result) || !uri) return;
+
+ pm->Add (uri,
+#if MOZILLA_SNAPSHOT >= 10
+ permission_type_string [type],
+#else
+ type,
+#endif
+ allow ? (PRUint32) nsIPermissionManager::ALLOW_ACTION :
+ (PRUint32) nsIPermissionManager::DENY_ACTION);
+}
+
+void
+impl_permission_manager_remove (EphyPermissionManager *manager,
+ const char *host,
+ EphyPermissionType type)
+{
+ nsresult result;
+ nsCOMPtr<nsIPermissionManager> pm
+ (do_CreateInstance (NS_PERMISSIONMANAGER_CONTRACTID, &result));
+ if (NS_SUCCEEDED (result))
+ {
+#if MOZILLA_SNAPSHOT >= 10
+ pm->Remove (nsDependentCString (host), permission_type_string [type]);
+#else
+ pm->Remove (nsDependentCString (host), type);
+#endif
+ }
+}
+
+void
+impl_permission_manager_clear (EphyPermissionManager *manager)
+{
+ nsresult result;
+ nsCOMPtr<nsIPermissionManager> pm
+ (do_CreateInstance (NS_PERMISSIONMANAGER_CONTRACTID, &result));
+ if (NS_SUCCEEDED (result))
+ {
+ pm->RemoveAll ();
+ }
+}
+
+gboolean
+impl_permission_manager_test (EphyPermissionManager *manager,
+ const char *host,
+ EphyPermissionType type)
+{
+ nsresult result;
+ nsCOMPtr<nsIPermissionManager> pm
+ (do_CreateInstance (NS_PERMISSIONMANAGER_CONTRACTID, &result));
+ if (NS_FAILED (result) || !pm) return FALSE;
+
+ nsCOMPtr<nsIURI> uri;
+ result = NS_NewURI(getter_AddRefs(uri), host);
+ if (NS_FAILED(result) || !uri) return FALSE;
+
+ PRUint32 action;
+#if MOZILLA_SNAPSHOT >= 10
+ result = pm->TestPermission (uri, permission_type_string [type], &action);
+#else
+ result = pm->TestPermission (uri, type, &action);
+#endif
+ if (NS_FAILED (result)) return FALSE;
+
+ gboolean allow;
+ switch (action)
+ {
+ case nsIPermissionManager::ALLOW_ACTION:
+ allow = TRUE;
+ break;
+ case nsIPermissionManager::DENY_ACTION:
+ case nsIPermissionManager::UNKNOWN_ACTION:
+ default:
+ allow = FALSE;
+ break;
+ }
+
+ return allow;
+}
+
+GList *
+impl_permission_manager_list (EphyPermissionManager *manager,
+ EphyPermissionType type)
+{
+ GList *list = NULL;
+
+ nsresult result;
+ nsCOMPtr<nsIPermissionManager> pm
+ (do_CreateInstance (NS_PERMISSIONMANAGER_CONTRACTID, &result));
+ if (NS_FAILED (result) || !pm) return NULL;
+
+ nsCOMPtr<nsISimpleEnumerator> pe;
+ result = pm->GetEnumerator(getter_AddRefs(pe));
+ if (NS_FAILED(result) || !pe) return NULL;
+
+ PRBool more;
+ for (pe->HasMoreElements (&more); more == PR_TRUE; pe->HasMoreElements (&more))
+ {
+ nsCOMPtr<nsIPermission> perm;
+ result = pe->GetNext(getter_AddRefs(perm));
+ if (NS_FAILED(result) || !perm) continue;
+
+#if MOZILLA_SNAPSHOT >= 10
+ nsCAutoString str;
+ result = perm->GetType(str);
+ if (NS_FAILED (result)) continue;
+
+ if (str.Equals(permission_type_string[type]))
+#else
+ PRUint32 num;
+ result = perm->GetType(&num);
+ if (NS_FAILED (result)) continue;
+
+ if ((PRUint32) num == (PRUint32) type)
+#endif
+ {
+ EphyPermissionInfo *info = g_new0 (EphyPermissionInfo, 1);
+
+ info->type = type;
+
+ nsCString host;
+ perm->GetHost(host);
+ info->host = g_strdup (host.get());
+
+ PRUint32 cap;
+ perm->GetCapability(&cap);
+ switch (cap)
+ {
+ case nsIPermissionManager::ALLOW_ACTION :
+ info->allowed = TRUE;
+ break;
+ case nsIPermissionManager::DENY_ACTION :
+ /* fallthrough */
+ default :
+ info->allowed = FALSE;
+ break;
+ }
+
+ list = g_list_prepend (list, info);
+ }
+ }
+
+ return list;
}
static void
mozilla_embed_single_class_init (MozillaEmbedSingleClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- EphyEmbedSingleClass *shell_class = EPHY_EMBED_SINGLE_CLASS (klass);
-
+
parent_class = (GObjectClass *) g_type_class_peek_parent (klass);
-
- object_class->finalize = mozilla_embed_single_finalize;
- shell_class->clear_cache = impl_clear_cache;
- shell_class->set_offline_mode = impl_set_offline_mode;
- shell_class->load_proxy_autoconf = impl_load_proxy_autoconf;
- shell_class->get_font_list = impl_get_font_list;
- shell_class->list_cookies = impl_list_cookies;
- shell_class->remove_cookies = impl_remove_cookies;
- shell_class->list_passwords = impl_list_passwords;
- shell_class->remove_passwords = impl_remove_passwords;
+ object_class->finalize = mozilla_embed_single_finalize;
g_type_class_add_private (object_class, sizeof(MozillaEmbedSinglePrivate));
}
+
+static void
+ephy_embed_single_iface_init (EphyEmbedSingleClass *iface)
+{
+ iface->clear_cache = impl_clear_cache;
+ iface->set_offline_mode = impl_set_offline_mode;
+ iface->load_proxy_autoconf = impl_load_proxy_autoconf;
+ iface->get_font_list = impl_get_font_list;
+}
+
+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 = NULL; /* not implemented yet */
+ iface->remove = impl_remove_password;
+ iface->list = impl_list_passwords;
+}
+
+static void
+ephy_permission_manager_iface_init (EphyPermissionManagerIFace *iface)
+{
+ iface->add = impl_permission_manager_add;
+ iface->remove = impl_permission_manager_remove;
+ iface->clear = impl_permission_manager_clear;
+ iface->test = impl_permission_manager_test;
+ iface->list = impl_permission_manager_list;
+}
diff --git a/embed/mozilla/mozilla-embed-single.h b/embed/mozilla/mozilla-embed-single.h
index 63ce78267..08732a837 100644
--- a/embed/mozilla/mozilla-embed-single.h
+++ b/embed/mozilla/mozilla-embed-single.h
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2000-2003 Marco Pesenti Gritti
+ * Copyright (C) 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
@@ -21,8 +22,8 @@
#ifndef MOZILLA_EMBED_SINGLE_H
#define MOZILLA_EMBED_SINGLE_H
-#include "glib.h"
-#include "ephy-embed-shell.h"
+#include "ephy-embed-single.h"
+
#include <glib-object.h>
G_BEGIN_DECLS
@@ -34,20 +35,21 @@ G_BEGIN_DECLS
#define MOZILLA_IS_EMBED_SINGLE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), MOZILLA_TYPE_EMBED_SINGLE))
#define MOZILLA_EMBED_SINGLE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), MOZILLA_TYPE_EMBED_SINGLE, MozillaEmbedSingleClass))
-typedef struct MozillaEmbedSingle MozillaEmbedSingle;
-typedef struct MozillaEmbedSinglePrivate MozillaEmbedSinglePrivate;
+typedef struct MozillaEmbedSingle MozillaEmbedSingle;
+typedef struct MozillaEmbedSingleClass MozillaEmbedSingleClass;
+typedef struct MozillaEmbedSinglePrivate MozillaEmbedSinglePrivate;
struct MozillaEmbedSingle
{
- EphyEmbedSingle parent;
+ GObject parent;
/*< private >*/
- MozillaEmbedSinglePrivate *priv;
+ MozillaEmbedSinglePrivate *priv;
};
struct MozillaEmbedSingleClass
{
- EphyEmbedSingleClass parent_class;
+ GObjectClass parent_class;
};
GType mozilla_embed_single_get_type (void);
diff --git a/embed/mozilla/mozilla-notifiers.cpp b/embed/mozilla/mozilla-notifiers.cpp
index 955dc00bb..037fead15 100644
--- a/embed/mozilla/mozilla-notifiers.cpp
+++ b/embed/mozilla/mozilla-notifiers.cpp
@@ -351,7 +351,7 @@ mozilla_proxy_autoconfig_notifier (GConfClient *client,
url = eel_gconf_get_string (entry->key);
- if (url)
+ if (url && url[0] != '\0')
{
ephy_embed_single_load_proxy_autoconf (single, url);
}
diff --git a/src/pdm-dialog.c b/src/pdm-dialog.c
index 31afb651f..dc9b3a4f9 100755
--- a/src/pdm-dialog.c
+++ b/src/pdm-dialog.c
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2002 Jorn Baayen
+ * Copyright (C) 2003 Marco Pesenti Gritti
*
* 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
@@ -15,16 +16,18 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
- * $Id$
+ * $Id$
*/
#ifdef HAVE_CONFIG_H
-#include <config.h>
+#include "config.h"
#endif
#include "pdm-dialog.h"
#include "ephy-shell.h"
#include "ephy-embed-shell.h"
+#include "ephy-cookie-manager.h"
+#include "ephy-password-manager.h"
#include "ephy-gui.h"
#include "ephy-ellipsizing-label.h"
@@ -34,6 +37,8 @@
#include <glib/gi18n.h>
+#include <time.h>
+
typedef struct PdmActionInfo PdmActionInfo;
typedef void (* PDM_add) (PdmActionInfo *info, gpointer data);
@@ -130,9 +135,9 @@ EphyDialogProperty properties [] =
GType
pdm_dialog_get_type (void)
{
- static GType pdm_dialog_type = 0;
+ static GType type = 0;
- if (pdm_dialog_type == 0)
+ if (type == 0)
{
static const GTypeInfo our_info =
{
@@ -147,13 +152,12 @@ pdm_dialog_get_type (void)
(GInstanceInitFunc) pdm_dialog_init
};
- pdm_dialog_type = g_type_register_static (EPHY_TYPE_DIALOG,
- "PdmDialog",
- &our_info, 0);
+ type = g_type_register_static (EPHY_TYPE_DIALOG,
+ "PdmDialog",
+ &our_info, 0);
}
- return pdm_dialog_type;
-
+ return type;
}
static void
@@ -497,7 +501,7 @@ pdm_dialog_cookie_add (PdmActionInfo *info,
{
GtkListStore *store;
GtkTreeIter iter;
- CookieInfo *cinfo = (CookieInfo *)cookie;
+ EphyCookie *cinfo = (EphyCookie *)cookie;
store = GTK_LIST_STORE(gtk_tree_view_get_model
(GTK_TREE_VIEW(info->treeview)));
@@ -517,7 +521,7 @@ pdm_dialog_password_add (PdmActionInfo *info,
{
GtkListStore *store;
GtkTreeIter iter;
- PasswordInfo *pinfo = (PasswordInfo *)password;
+ EphyPasswordInfo *pinfo = (EphyPasswordInfo *)password;
store = GTK_LIST_STORE(gtk_tree_view_get_model
(GTK_TREE_VIEW(info->treeview)));
@@ -536,9 +540,18 @@ pdm_dialog_cookie_remove (PdmActionInfo *info,
GList *data)
{
EphyEmbedSingle *single;
+ GList *l;
+
single = ephy_embed_shell_get_embed_single
- (EPHY_EMBED_SHELL (ephy_shell));
- ephy_embed_single_remove_cookies (single, data);
+ (EPHY_EMBED_SHELL (ephy_shell));
+
+ for (l = data; l != NULL; l = l ->next)
+ {
+ EphyCookie *cookie = (EphyCookie *) l->data;
+
+ ephy_cookie_manager_remove_cookie
+ (EPHY_COOKIE_MANAGER (single), cookie);
+ }
}
static void
@@ -546,11 +559,17 @@ pdm_dialog_password_remove (PdmActionInfo *info,
GList *data)
{
EphyEmbedSingle *single;
+ GList *l;
+
single = ephy_embed_shell_get_embed_single
(EPHY_EMBED_SHELL (ephy_shell));
- ephy_embed_single_remove_passwords (single, data,
- PASSWORD_PASSWORD);
+ for (l = data; l != NULL; l = l->next)
+ {
+ EphyPasswordInfo *info = (EphyPasswordInfo *) l->data;
+
+ ephy_password_manager_remove (EPHY_PASSWORD_MANAGER (single), info);
+ }
}
static void
@@ -558,12 +577,14 @@ pdm_dialog_cookies_free (PdmActionInfo *info,
GList *data)
{
GList *l;
- EphyEmbedSingle *single;
- single = ephy_embed_shell_get_embed_single
- (EPHY_EMBED_SHELL (ephy_shell));
l = data ? data : info->list;
- ephy_embed_single_free_cookies (single, l);
+ for (; l != NULL; l = l->next)
+ {
+ EphyCookie *cookie = (EphyCookie *) l->data;
+
+ ephy_cookie_free (cookie);
+ }
}
static void
@@ -571,12 +592,14 @@ pdm_dialog_passwords_free (PdmActionInfo *info,
GList *data)
{
GList *l;
- EphyEmbedSingle *single;
- single = ephy_embed_shell_get_embed_single
- (EPHY_EMBED_SHELL (ephy_shell));
l = data ? data : info->list;
- ephy_embed_single_free_passwords (single, l);
+ for (; l != NULL; l = l->next)
+ {
+ EphyPasswordInfo *pinfo = (EphyPasswordInfo *) l->data;
+
+ ephy_password_info_free (pinfo);
+ }
}
/* Group all Properties and Remove buttons in the same size group to avoid the
@@ -632,7 +655,8 @@ pdm_dialog_init (PdmDialog *dialog)
passwords_tv = setup_passwords_treeview (dialog);
cookies = g_new0 (PdmActionInfo, 1);
- cookies->list = ephy_embed_single_list_cookies (single);
+ cookies->list =
+ ephy_cookie_manager_list_cookies (EPHY_COOKIE_MANAGER (single));
cookies->dialog = dialog;
cookies->remove_id = PROP_COOKIES_REMOVE;
cookies->add = pdm_dialog_cookie_add;
@@ -643,8 +667,7 @@ pdm_dialog_init (PdmDialog *dialog)
setup_action (cookies);
passwords = g_new0 (PdmActionInfo, 1);
- passwords->list = ephy_embed_single_list_passwords
- (single, PASSWORD_PASSWORD);
+ passwords->list = ephy_password_manager_list (EPHY_PASSWORD_MANAGER (single));
passwords->dialog = dialog;
passwords->remove_id = PROP_PASSWORDS_REMOVE;
passwords->add = pdm_dialog_password_add;
@@ -675,18 +698,14 @@ pdm_dialog_finalize (GObject *object)
EphyDialog *
pdm_dialog_new (GtkWidget *window)
{
- PdmDialog *dialog;
-
- dialog = EPHY_PDM_DIALOG (g_object_new (EPHY_TYPE_PDM_DIALOG,
- "ParentWindow", window,
- NULL));
-
- return EPHY_DIALOG(dialog);
+ return EPHY_DIALOG (g_object_new (EPHY_TYPE_PDM_DIALOG,
+ "ParentWindow", window,
+ NULL));
}
static void
show_cookies_properties (PdmDialog *dialog,
- CookieInfo *info)
+ EphyCookie *info)
{
GtkWidget *gdialog;
GtkWidget *table;
@@ -749,7 +768,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->secure);
+ label = gtk_label_new (info->is_secure ? _("Yes") : _("No") );
gtk_misc_set_alignment (GTK_MISC(label), 0, 0);
gtk_widget_show (label);
gtk_table_attach_defaults (GTK_TABLE (table), label, 1, 2, 2, 3);
@@ -763,7 +782,16 @@ show_cookies_properties (PdmDialog *dialog,
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 3, 4,
GTK_FILL, GTK_FILL, 0, 0);
- label = gtk_label_new (info->expire);
+ if (info->is_session)
+ {
+ str = g_strdup (_("End of current session"));
+ }
+ else
+ {
+ str = g_strdup_printf ("%s",ctime((time_t*)&info->expires));
+ }
+ label = gtk_label_new (str);
+ g_free (str);
gtk_misc_set_alignment (GTK_MISC(label), 0, 0.5);
gtk_widget_show (label);
gtk_table_attach_defaults (GTK_TABLE (table), label, 1, 2, 3, 4);
@@ -786,7 +814,7 @@ pdm_dialog_cookies_properties_button_clicked_cb (GtkWidget *button,
GValue val = {0, };
GtkTreeIter iter;
GtkTreePath *path;
- CookieInfo *info;
+ EphyCookie *cookie;
GList *l;
GtkWidget *treeview = dialog->priv->cookies->treeview;
GtkTreeSelection *selection;
@@ -799,10 +827,10 @@ pdm_dialog_cookies_properties_button_clicked_cb (GtkWidget *button,
gtk_tree_model_get_iter (model, &iter, path);
gtk_tree_model_get_value
(model, &iter, COL_COOKIES_DATA, &val);
- info = (CookieInfo *)g_value_get_pointer (&val);
+ cookie = (EphyCookie *) g_value_get_pointer (&val);
g_value_unset (&val);
- show_cookies_properties (dialog, info);
+ show_cookies_properties (dialog, cookie);
g_list_foreach (l, (GFunc)gtk_tree_path_free, NULL);
g_list_free (l);
diff --git a/src/pdm-dialog.h b/src/pdm-dialog.h
index 1834f716e..d476c714c 100644
--- a/src/pdm-dialog.h
+++ b/src/pdm-dialog.h
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2002 Jorn Baayen
+ * Copyright (C) 2003 Marco Pesenti Gritti
*
* 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
@@ -14,6 +15,8 @@
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Id$
*/
#ifndef PDM_DIALOG_H