diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Makefile.am | 5 | ||||
-rw-r--r-- | lib/ephy-module.c | 222 | ||||
-rw-r--r-- | lib/ephy-module.h | 52 | ||||
-rw-r--r-- | lib/ephy-prefs.h | 1 | ||||
-rw-r--r-- | lib/ephy-shlib-loader.c | 245 | ||||
-rw-r--r-- | lib/ephy-shlib-loader.h | 60 |
6 files changed, 0 insertions, 585 deletions
diff --git a/lib/Makefile.am b/lib/Makefile.am index 62508b194..5992bf5f3 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -14,13 +14,11 @@ NOINST_H_FILES = \ ephy-file-helpers.h \ ephy-gui.h \ ephy-langs.h \ - ephy-module.h \ ephy-node-filter.h \ ephy-node-common.h \ ephy-object-helpers.h \ ephy-prefs.h \ ephy-profile-utils.h \ - ephy-shlib-loader.h \ ephy-signal-accumulator.h \ ephy-smaps.h \ ephy-sqlite.h \ @@ -53,7 +51,6 @@ libephymisc_la_SOURCES = \ ephy-gui.c \ ephy-langs.c \ ephy-loader.c \ - ephy-module.c \ ephy-node.c \ ephy-node.h \ ephy-node-filter.c \ @@ -64,7 +61,6 @@ libephymisc_la_SOURCES = \ ephy-profile-utils.c \ ephy-profile-utils.h \ ephy-settings.c \ - ephy-shlib-loader.c \ ephy-signal-accumulator.c \ ephy-smaps.c \ ephy-snapshot-service.c \ @@ -88,7 +84,6 @@ libephymisc_la_CPPFLAGS = \ -DSHARE_DIR=\"$(pkgdatadir)\" \ -DTOP_SRC_DATADIR=\"$(top_srcdir)/data\" \ -DABS_TOP_BUILD_DIR=\"$(abs_top_builddir)\" \ - -DEXTENSIONS_DIR=\""$(pkglibdir)/$(EPIPHANY_API_VERSION)/extensions"\" \ $(AM_CPPFLAGS) libephymisc_la_CFLAGS = \ diff --git a/lib/ephy-module.c b/lib/ephy-module.c deleted file mode 100644 index 08c0f86a1..000000000 --- a/lib/ephy-module.c +++ /dev/null @@ -1,222 +0,0 @@ -/* - * Copyright © 2003 Marco Pesenti Gritti - * Copyright © 2003, 2004 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-module.h" -#include "ephy-file-helpers.h" -#include "ephy-debug.h" - -#include <gmodule.h> - -typedef struct _EphyModuleClass EphyModuleClass; - -struct _EphyModuleClass -{ - GTypeModuleClass parent_class; -}; - -struct _EphyModule -{ - GTypeModule parent_instance; - - GModule *library; - - char *path; - GType type; - guint resident : 1; -}; - -typedef GType (*EphyModuleRegisterFunc) (GTypeModule *); - -static void ephy_module_init (EphyModule *action); -static void ephy_module_class_init (EphyModuleClass *class); - -G_DEFINE_TYPE (EphyModule, ephy_module, G_TYPE_TYPE_MODULE) - -static gboolean -ephy_module_load (GTypeModule *gmodule) -{ - EphyModule *module = EPHY_MODULE (gmodule); - EphyModuleRegisterFunc register_func; - gboolean is_absolute; - GModuleFlags flags = G_MODULE_BIND_LOCAL | G_MODULE_BIND_LAZY; - - LOG ("Loading %s", module->path); - - /* In debug builds, we bind immediately so we can find missing - * symbols in extensions on load; otherwise we bind lazily - */ -#ifdef GNOME_ENABLE_DEBUG - flags &= ~G_MODULE_BIND_LAZY; -#endif - - is_absolute = g_path_is_absolute (module->path); - - if (module->library == NULL && ! is_absolute) - { - char *path = g_build_filename (EXTENSIONS_DIR, module->path, NULL); - - module->library = g_module_open (path, flags); - - g_free (path); - } - - if (module->library == NULL && ! is_absolute) - { - char *path = g_build_filename (ephy_dot_dir(), "extensions", module->path, NULL); - - module->library = g_module_open (path, flags); - - g_free (path); - } - - if (module->library == NULL) - { - module->library = g_module_open (module->path, flags); - } - - if (module->library == NULL) - { - g_warning ("%s", g_module_error()); - - return FALSE; - } - - /* extract symbols from the lib */ - if (!g_module_symbol (module->library, "register_module", - (void *) ®ister_func)) - { - g_warning ("%s", g_module_error()); - g_module_close (module->library); - - return FALSE; - } - - /* symbol can still be NULL even though g_module_symbol returned TRUE */ - if (!register_func) - { - g_warning ("Symbol 'register_module' is NULL!"); - g_module_close (module->library); - - return FALSE; - } - - module->type = register_func (gmodule); - - if (module->type == 0) - { - g_warning ("Failed to register the GType(s)!"); - g_module_close (module->library); - - return FALSE; - } - - if (module->resident) - { - g_module_make_resident (module->library); - } - - return TRUE; -} - -static void -ephy_module_unload (GTypeModule *gmodule) -{ - EphyModule *module = EPHY_MODULE (gmodule); - - LOG ("Unloading %s", module->path); - - g_module_close (module->library); - - module->library = NULL; - module->type = 0; -} - -const char * -ephy_module_get_path (EphyModule *module) -{ - g_return_val_if_fail (EPHY_IS_MODULE (module), NULL); - - return module->path; -} - -GObject * -ephy_module_new_object (EphyModule *module) -{ - LOG ("Creating object of type %s", g_type_name (module->type)); - - if (module->type == 0) - { - return NULL; - } - - return g_object_new (module->type, NULL); -} - -static void -ephy_module_init (EphyModule *module) -{ - LOG ("EphyModule %p initialising", module); -} - -static void -ephy_module_finalize (GObject *object) -{ - EphyModule *module = EPHY_MODULE (object); - - LOG ("EphyModule %p finalising", module); - - g_free (module->path); - - G_OBJECT_CLASS (ephy_module_parent_class)->finalize (object); -} - -static void -ephy_module_class_init (EphyModuleClass *class) -{ - GObjectClass *object_class = G_OBJECT_CLASS (class); - GTypeModuleClass *module_class = G_TYPE_MODULE_CLASS (class); - - object_class->finalize = ephy_module_finalize; - - module_class->load = ephy_module_load; - module_class->unload = ephy_module_unload; -} - -EphyModule * -ephy_module_new (const char *path, - gboolean resident) -{ - EphyModule *result; - - if (path == NULL || path[0] == '\0') - { - return NULL; - } - - result = g_object_new (EPHY_TYPE_MODULE, NULL); - - g_type_module_set_name (G_TYPE_MODULE (result), path); - result->path = g_strdup (path); - result->resident = resident != FALSE; - - return result; -} diff --git a/lib/ephy-module.h b/lib/ephy-module.h deleted file mode 100644 index b4e0006ac..000000000 --- a/lib/ephy-module.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright © 2003 Marco Pesenti Gritti - * Copyright © 2003, 2004 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_MODULE_H -#define EPHY_MODULE_H - -#include <glib-object.h> - -G_BEGIN_DECLS - -#define EPHY_TYPE_MODULE (ephy_module_get_type ()) -#define EPHY_MODULE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EPHY_TYPE_MODULE, EphyModule)) -#define EPHY_MODULE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EPHY_TYPE_MODULE, EphyModuleClass)) -#define EPHY_IS_MODULE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EPHY_TYPE_MODULE)) -#define EPHY_IS_MODULE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), EPHY_TYPE_MODULE)) -#define EPHY_MODULE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), EPHY_TYPE_MODULE, EphyModuleClass)) - -typedef struct _EphyModule EphyModule; - -GType ephy_module_get_type (void); - -EphyModule *ephy_module_new (const char *path, - gboolean resident); - -const char *ephy_module_get_path (EphyModule *module); - -GObject *ephy_module_new_object (EphyModule *module); - -G_END_DECLS - -#endif diff --git a/lib/ephy-prefs.h b/lib/ephy-prefs.h index ccc7238d8..b95458310 100644 --- a/lib/ephy-prefs.h +++ b/lib/ephy-prefs.h @@ -122,7 +122,6 @@ typedef enum #define EPHY_PREFS_MANAGED_NETWORK "managed-network" #define EPHY_PREFS_ENABLE_SMOOTH_SCROLLING "enable-smooth-scrolling" #define EPHY_PREFS_ENABLE_CARET_BROWSING "enable-caret-browsing" -#define EPHY_PREFS_ENABLED_EXTENSIONS "enabled-extensions" #define EPHY_PREFS_INTERNAL_VIEW_SOURCE "internal-view-source" #define EPHY_PREFS_RESTORE_SESSION_POLICY "restore-session-policy" diff --git a/lib/ephy-shlib-loader.c b/lib/ephy-shlib-loader.c deleted file mode 100644 index 2ae2b1d4e..000000000 --- a/lib/ephy-shlib-loader.c +++ /dev/null @@ -1,245 +0,0 @@ -/* - * Copyright © 2003 Marco Pesenti Gritti - * Copyright © 2003, 2004 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-shlib-loader.h" -#include "ephy-loader.h" -#include "ephy-module.h" -#include "ephy-debug.h" - -#include <string.h> - -#define DATA_KEY "EphyShlibLoader::LoaderData" - -typedef struct -{ - EphyModule *module; - GObject *object; -} LoaderData; - -#define EPHY_SHLIB_LOADER_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), EPHY_TYPE_SHLIB_LOADER, EphyShlibLoaderPrivate)) - -struct _EphyShlibLoaderPrivate -{ - GSList *data; -}; - -static void ephy_shlib_loader_class_init (EphyShlibLoaderClass *klass); -static void ephy_shlib_loader_iface_init (EphyLoaderIface *iface); -static void ephy_shlib_loader_init (EphyShlibLoader *loader); - -static GObjectClass *parent_class = NULL; - -GType -ephy_shlib_loader_get_type (void) -{ - static GType type = 0; - - if (G_UNLIKELY (type == 0)) - { - const GTypeInfo our_info = - { - sizeof (EphyShlibLoaderClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) ephy_shlib_loader_class_init, - NULL, - NULL, /* class_data */ - sizeof (EphyShlibLoader), - 0, /* n_preallocs */ - (GInstanceInitFunc) ephy_shlib_loader_init - }; - - const GInterfaceInfo loader_info = - { - (GInterfaceInitFunc) ephy_shlib_loader_iface_init, - NULL, - NULL - }; - - type = g_type_register_static (G_TYPE_OBJECT, - "EphyShlibLoader", - &our_info, 0); - - g_type_add_interface_static (type, - EPHY_TYPE_LOADER, - &loader_info); - } - - return type; -} - -static void -free_loader_data (LoaderData *data) -{ - g_return_if_fail (data != NULL); - - /* data->module must NOT be unreffed! */ - - if (data->object != NULL) - { - g_object_unref (data->object); - } - - g_free (data); -} - -static void -ephy_shlib_loader_init (EphyShlibLoader *loader) -{ - loader->priv = EPHY_SHLIB_LOADER_GET_PRIVATE (loader); - - LOG ("EphyShlibLoader initialising"); -} - -static void -ephy_shlib_loader_finalize (GObject *object) -{ - EphyShlibLoader *loader = EPHY_SHLIB_LOADER (object); - - LOG ("EphyShlibLoader finalising"); - - g_slist_foreach (loader->priv->data, (GFunc) free_loader_data, NULL); - g_slist_free (loader->priv->data); - - parent_class->finalize (object); -} - -static int -find_library (const LoaderData *data, - const char *library) -{ - return strcmp (ephy_module_get_path (data->module), library); -} - -static int -find_object (const LoaderData *data, - const GObject *object) -{ - return data->object != object; -} - -static GObject * -impl_get_object (EphyLoader *eloader, - GKeyFile *keyfile) -{ - EphyShlibLoader *loader = EPHY_SHLIB_LOADER (eloader); - GSList *l; - LoaderData *data = NULL; - char *library; - gboolean resident; - - g_return_val_if_fail (keyfile != NULL, NULL); - - library = g_key_file_get_string (keyfile, "Loader", "Library", NULL); - if (library == NULL) - { - g_warning ("NULL library name!\n"); - return NULL; - } - - resident = g_key_file_get_boolean (keyfile, "Loader", "Resident", NULL); - - l = g_slist_find_custom (loader->priv->data, library, - (GCompareFunc) find_library); - - if (l != NULL) - { - data = l->data; - g_return_val_if_fail (data != NULL, NULL); - - if (data->object != NULL) - { - g_free (library); - return g_object_ref (data->object); - } - } - else - { - data = g_new0 (LoaderData, 1); - loader->priv->data = g_slist_prepend (loader->priv->data, data); - } - - if (data->module == NULL) - { - data->module = ephy_module_new (library, resident); - } - - g_return_val_if_fail (data->object == NULL, data->object); - - if (g_type_module_use (G_TYPE_MODULE (data->module)) == FALSE) - { - g_free (library); - g_warning ("Could not load extension file at %s\n", - ephy_module_get_path (data->module)); - return NULL; - } - - data->object = ephy_module_new_object (data->module); - - g_type_module_unuse (G_TYPE_MODULE (data->module)); - - if (data->object != NULL) - { - g_object_set_data (G_OBJECT (data->object), DATA_KEY, data); - } - - g_free (library); - - return data->object; -} - -static void -impl_release_object (EphyLoader *eloader, - GObject *object) -{ - EphyShlibLoader *loader = EPHY_SHLIB_LOADER (eloader); - GSList *l; - LoaderData *data; - - l = g_slist_find_custom (loader->priv->data, object, - (GCompareFunc) find_object); - g_return_if_fail (l != NULL); - data = l->data; - - g_object_unref (data->object); - data->object = NULL; -} - -static void -ephy_shlib_loader_iface_init (EphyLoaderIface *iface) -{ - iface->type = "shlib"; - iface->get_object = impl_get_object; - iface->release_object = impl_release_object; -} - -static void -ephy_shlib_loader_class_init (EphyShlibLoaderClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - parent_class = g_type_class_peek_parent (klass); - - object_class->finalize = ephy_shlib_loader_finalize; - - g_type_class_add_private (object_class, sizeof (EphyShlibLoaderPrivate)); -} diff --git a/lib/ephy-shlib-loader.h b/lib/ephy-shlib-loader.h deleted file mode 100644 index 50f4404e5..000000000 --- a/lib/ephy-shlib-loader.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright © 2003 Marco Pesenti Gritti - * Copyright © 2003, 2004 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_SHLIB_LOADER_H -#define EPHY_SHLIB_LOADER_H - -#include <glib-object.h> - -G_BEGIN_DECLS - -#define EPHY_TYPE_SHLIB_LOADER (ephy_shlib_loader_get_type ()) -#define EPHY_SHLIB_LOADER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EPHY_TYPE_SHLIB_LOADER, EphyShlibLoader)) -#define EPHY_SHLIB_LOADER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), EPHY_TYPE_SHLIB_LOADER, EphyShlibLoaderClass)) -#define EPHY_IS_SHLIB_LOADER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EPHY_TYPE_SHLIB_LOADER)) -#define EPHY_IS_SHLIB_LOADER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EPHY_TYPE_SHLIB_LOADER)) -#define EPHY_SHLIB_LOADER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EPHY_TYPE_SHLIB_LOADER, EphyShlibLoaderClass)) - -typedef struct _EphyShlibLoader EphyShlibLoader; -typedef struct _EphyShlibLoaderPrivate EphyShlibLoaderPrivate; -typedef struct _EphyShlibLoaderClass EphyShlibLoaderClass; - -struct _EphyShlibLoaderClass -{ - GObjectClass parent_class; -}; - -struct _EphyShlibLoader -{ - GObject parent_instance; - - /*< private >*/ - EphyShlibLoaderPrivate *priv; -}; - -GType ephy_shlib_loader_get_type (void); - -G_END_DECLS - -#endif |