Commit f413c5c0 authored by Pierre Wieser's avatar Pierre Wieser

Define NagpGConfProvider as an IO provider

parent 29b1a6c7
2009-11-19 Pierre Wieser <pwieser@trychlos.org>
Create GConf IO Provider as a plugin.
* nautilus-actions/runtime/na-gconf-provider-keys.h:
* nautilus-actions/runtime/na-gconf-provider.c:
* nautilus-actions/runtime/na-gconf-provider.h:
Moved to io-provider-gconf/, and thus removed from runtime/.
* configure.ac:
* nautilus-actions/Makefile.am:
Maage io-provider-gconf/ new directory.
* m4/na-log-domains.m4:
Define new NA_LOGDOMAIN_IO_PROVIDER_GCONF log domain.
* nautilus-actions/api/na-api.c:
* nautilus-actions/api/na-api.h (na_api_module_init):
Now returns a boolean.
* nautilus-actions/plugin/nautilus-module.c:
Set module name.
* nautilus-actions/runtime/na-gconf-utils.c:
* nautilus-actions/runtime/na-gconf-utils.h
(na_gconf_utils_get_subdirs, na_gconf_utils_free_subdirs,
na_gconf_utils_have_entry:): Move functions to NagpIOProvider class.
* nautilus-actions/runtime/na-module.c:
Fix dynamic loading of the modules.
* nautilus-actions/runtime/na-gconf-utils.c:
* nautilus-actions/runtime/na-gconf-utils.h
(na_gconf_utils_have_subdir): Removed function.
* nautilus-actions/nact/nact-xml-reader.c:
* nautilus-actions/runtime/Makefile.am:
* nautilus-actions/runtime/na-pivot.c:
* nautilus-actions/runtime/na-xml-writer.c:
Updated accordingly.
2009-11-18 Pierre Wieser <pwieser@trychlos.org>
Move runtime/na-gconf-monitor.{c,h} to api/.
......
......@@ -80,3 +80,5 @@
- export: add a overwrite page: what to do if file already exists ?
- na_object_id_get_topmost_parent: should it return a NAObjectItem ?
- nautilus-actions-new: write to GConf
......@@ -49,6 +49,7 @@ AC_CONFIG_FILES([
icons/scalable/Makefile
nautilus-actions/Makefile
nautilus-actions/api/Makefile
nautilus-actions/io-provider-gconf/Makefile
nautilus-actions/nact/Makefile
nautilus-actions/plugin/Makefile
nautilus-actions/private/Makefile
......
......@@ -8,6 +8,9 @@ AC_DEFUN([NA_LOG_DOMAINS],[
AC_SUBST([NA_LOGDOMAIN_API],[NA-api])
AC_DEFINE_UNQUOTED([NA_LOGDOMAIN_API],["NA-api"],[Log domain of API library])
AC_SUBST([NA_LOGDOMAIN_IO_PROVIDER_GCONF],[NA-io-provider-gconf])
AC_DEFINE_UNQUOTED([NA_LOGDOMAIN_IO_PROVIDER_GCONF],["NA-io-provider-gconf"],[Log domain of GConf IO Provider])
AC_SUBST([NA_LOGDOMAIN_NACT],[NA-nact])
AC_DEFINE_UNQUOTED([NA_LOGDOMAIN_NACT],["NA-nact"],[Log domain of NACT user interface])
......
......@@ -29,6 +29,7 @@
SUBDIRS = \
api \
private \
io-provider-gconf \
runtime \
nact \
plugin \
......
......@@ -54,8 +54,9 @@ G_BEGIN_DECLS
*
* The dynamically loaded library may benefit of being triggered by
* initializing itself, registering its internal GTypes, etc.
* It should at least register module GTypes it provides.
*/
void na_api_module_init ( GTypeModule *module );
gboolean na_api_module_init ( GTypeModule *module );
/**
* na_api_module_list_types:
......
# Nautilus Actions
# A Nautilus extension which offers configurable context menu actions.
#
# Copyright (C) 2005 The GNOME Foundation
# Copyright (C) 2006, 2007, 2008 Frederic Ruaudel and others (see AUTHORS)
# Copyright (C) 2009 Pierre Wieser and others (see AUTHORS)
#
# 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 of
# the License, 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 Library; see the file COPYING. If not,
# write to the Free Software Foundation, Inc., 59 Temple Place,
# Suite 330, Boston, MA 02111-1307, USA.
#
# Authors:
# Frederic Ruaudel <grumz@grumz.net>
# Rodrigo Moya <rodrigo@gnome-db.org>
# Pierre Wieser <pwieser@trychlos.org>
# ... and many others (see AUTHORS)
pluginsdir = $(pkglibdir)
plugins_LTLIBRARIES=libna-io-provider-gconf.la
AM_CPPFLAGS += \
-I $(top_srcdir) \
$(NAUTILUS_ACTIONS_CFLAGS) \
-DG_LOG_DOMAIN=\"${NA_LOGDOMAIN_IO_PROVIDER_GCONF}\" \
$(NULL)
libna_io_provider_gconf_la_SOURCES = \
nagp-gconf-provider.c \
nagp-gconf-provider.h \
nagp-keys.h \
nagp-module.c \
$(NULL)
libna_io_provider_gconf_la_LIBADD = \
-L$(top_builddir)/nautilus-actions/api -lna-api \
-L$(top_builddir)/nautilus-actions/private -lna-private \
-L$(top_builddir)/nautilus-actions/runtime -lna-runtime \
$(NULL)
VERSION_INFO = 1:0:0
libna_io_provider_gconf_la_LDFLAGS = \
-module \
-no-undefined \
-version-number $(VERSION_INFO) \
$(NULL)
......@@ -28,54 +28,53 @@
* ... and many others (see AUTHORS)
*/
#ifndef __NA_RUNTIME_GCONF_PROVIDER_H__
#define __NA_RUNTIME_GCONF_PROVIDER_H__
#ifndef __NAGP_GCONF_PROVIDER_H__
#define __NAGP_GCONF_PROVIDER_H__
/**
* SECTION: na_gconf_provider
* @short_description: #NAGConfProvider class definition.
* @include: runtime/na-gconf-provider.h
* SECTION: nagp_gconf_provider
* @short_description: #NagpGConfProvider class definition.
* @include: na-gconf-provider.h
*
* This class manages the GConf I/O storage subsystem, or, in other words,
* the GConf subsystem as an NAIIOProvider. As this, it should only be
* used through the NAIIOProvider interface.
*
* #NAGConfProvider uses #NAGConfMonitor to watch at the configuration
* tree. When something is modified, it sends the appropriate signal to
* the #NAPivot object it was created against.
* #NagpGConfProvider uses #NAGConfMonitor to watch at the configuration
* tree. Modifications are notified to the NAIIOProvider interface.
*/
#include "na-pivot.h"
#include <glib.h>
#include <glib-object.h>
G_BEGIN_DECLS
#define NA_GCONF_PROVIDER_TYPE ( na_gconf_provider_get_type())
#define NA_GCONF_PROVIDER( object ) ( G_TYPE_CHECK_INSTANCE_CAST( object, NA_GCONF_PROVIDER_TYPE, NAGConfProvider ))
#define NA_GCONF_PROVIDER_CLASS( klass ) ( G_TYPE_CHECK_CLASS_CAST( klass, NA_GCONF_PROVIDER_TYPE, NAGConfProviderClass ))
#define NA_IS_GCONF_PROVIDER( object ) ( G_TYPE_CHECK_INSTANCE_TYPE( object, NA_GCONF_PROVIDER_TYPE ))
#define NA_IS_GCONF_PROVIDER_CLASS( klass ) ( G_TYPE_CHECK_CLASS_TYPE(( klass ), NA_GCONF_PROVIDER_TYPE ))
#define NA_GCONF_PROVIDER_GET_CLASS( object ) ( G_TYPE_INSTANCE_GET_CLASS(( object ), NA_GCONF_PROVIDER_TYPE, NAGConfProviderClass ))
#define NAGP_GCONF_PROVIDER_TYPE ( nagp_gconf_provider_get_type())
#define NAGP_GCONF_PROVIDER( object ) ( G_TYPE_CHECK_INSTANCE_CAST( object, NAGP_GCONF_PROVIDER_TYPE, NagpGConfProvider ))
#define NAGP_GCONF_PROVIDER_CLASS( klass ) ( G_TYPE_CHECK_CLASS_CAST( klass, NAGP_GCONF_PROVIDER_TYPE, NagpGConfProviderClass ))
#define NAGP_IS_GCONF_PROVIDER( object ) ( G_TYPE_CHECK_INSTANCE_TYPE( object, NAGP_GCONF_PROVIDER_TYPE ))
#define NAGP_IS_GCONF_PROVIDER_CLASS( klass ) ( G_TYPE_CHECK_CLASS_TYPE(( klass ), NAGP_GCONF_PROVIDER_TYPE ))
#define NAGP_GCONF_PROVIDER_GET_CLASS( object ) ( G_TYPE_INSTANCE_GET_CLASS(( object ), NAGP_GCONF_PROVIDER_TYPE, NagpGConfProviderClass ))
typedef struct NAGConfProviderPrivate NAGConfProviderPrivate;
typedef struct NagpGConfProviderPrivate NagpGConfProviderPrivate;
typedef struct {
GObject parent;
NAGConfProviderPrivate *private;
GObject parent;
NagpGConfProviderPrivate *private;
}
NAGConfProvider;
NagpGConfProvider;
typedef struct NAGConfProviderClassPrivate NAGConfProviderClassPrivate;
typedef struct NagpGConfProviderClassPrivate NagpGConfProviderClassPrivate;
typedef struct {
GObjectClass parent;
NAGConfProviderClassPrivate *private;
GObjectClass parent;
NagpGConfProviderClassPrivate *private;
}
NAGConfProviderClass;
NagpGConfProviderClass;
GType na_gconf_provider_get_type( void );
NAGConfProvider *na_gconf_provider_new( NAPivot *notified );
GType nagp_gconf_provider_get_type ( void );
void nagp_gconf_provider_register_type( GTypeModule *module );
G_END_DECLS
#endif /* __NA_RUNTIME_GCONF_PROVIDER_PROVIDER_H__ */
#endif /* __NAGP_GCONF_PROVIDER_H__ */
......@@ -28,10 +28,10 @@
* ... and many others (see AUTHORS)
*/
#ifndef __NA_RUNTIME_GCONF_PROVIDER_KEYS_H__
#define __NA_RUNTIME_GCONF_PROVIDER_KEYS_H__
#ifndef __NAGP_GCONF_PROVIDER_KEYS_H__
#define __NAGP_GCONF_PROVIDER_KEYS_H__
#include <api/na-gconf-keys.h>
#include <nautilus-actions/api/na-gconf-keys.h>
/* GConf general information
*/
......@@ -51,28 +51,28 @@
#define OBJECT_ITEM_TOOLBAR_SAME_LABEL_ENTRY "toolbar-same-label"
#define OBJECT_ITEM_TOOLBAR_LABEL_ENTRY "toolbar-label"
#define OBJECT_ITEM_TYPE_MENU "Menu"
#define OBJECT_ITEM_TYPE_ACTION "Action"
#define OBJECT_ITEM_TYPE_MENU "Menu"
#define OBJECT_ITEM_TYPE_ACTION "Action"
/* GConf key names (specific to menu)
*/
/* GConf key names (specific to action)
*/
#define ACTION_VERSION_ENTRY "version"
#define ACTION_VERSION_ENTRY "version"
/* GConf key names (specific to profile)
*/
#define ACTION_PROFILE_LABEL_ENTRY "desc-name"
#define ACTION_PATH_ENTRY "path"
#define ACTION_PARAMETERS_ENTRY "parameters"
#define ACTION_BASENAMES_ENTRY "basenames"
#define ACTION_MATCHCASE_ENTRY "matchcase"
#define ACTION_MIMETYPES_ENTRY "mimetypes"
#define ACTION_ISFILE_ENTRY "isfile"
#define ACTION_ISDIR_ENTRY "isdir"
#define ACTION_MULTIPLE_ENTRY "accept-multiple-files"
#define ACTION_SCHEMES_ENTRY "schemes"
#define ACTION_FOLDERS_ENTRY "folders"
#define ACTION_PROFILE_LABEL_ENTRY "desc-name"
#define ACTION_PATH_ENTRY "path"
#define ACTION_PARAMETERS_ENTRY "parameters"
#define ACTION_BASENAMES_ENTRY "basenames"
#define ACTION_MATCHCASE_ENTRY "matchcase"
#define ACTION_MIMETYPES_ENTRY "mimetypes"
#define ACTION_ISFILE_ENTRY "isfile"
#define ACTION_ISDIR_ENTRY "isdir"
#define ACTION_MULTIPLE_ENTRY "accept-multiple-files"
#define ACTION_SCHEMES_ENTRY "schemes"
#define ACTION_FOLDERS_ENTRY "folders"
#endif /* __NA_RUNTIME_GCONF_PROVIDER_KEYS_H__ */
#endif /* __NAGP_GCONF_PROVIDER_KEYS_H__ */
/*
* Nautilus Actions
* A Nautilus extension which offers configurable context menu actions.
*
* Copyright (C) 2005 The GNOME Foundation
* Copyright (C) 2006, 2007, 2008 Frederic Ruaudel and others (see AUTHORS)
* Copyright (C) 2009 Pierre Wieser and others (see AUTHORS)
*
* 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 of
* the License, 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 Library; see the file COPYING. If not,
* write to the Free Software Foundation, Inc., 59 Temple Place,
* Suite 330, Boston, MA 02111-1307, USA.
*
* Authors:
* Frederic Ruaudel <grumz@grumz.net>
* Rodrigo Moya <rodrigo@gnome-db.org>
* Pierre Wieser <pwieser@trychlos.org>
* ... and many others (see AUTHORS)
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <syslog.h>
#include <nautilus-actions/api/na-api.h>
#include "nagp-gconf-provider.h"
static guint st_log_handler_api = 0;
static guint st_log_handler_plugin = 0;
static void setup_log_handler( const gchar *log_domain, guint *handler_id );
static void remove_log_handler( guint *handler_id );
static void nagp_log_handler( const gchar *log_domain, GLogLevelFlags log_level, const gchar *message, gpointer user_data );
/*
* A Nautilus-Actions extension must implement four functions :
*
* - na_api_module_init
* - na_api_module_list_types
* - na_api_module_get_name
* - na_api_module_shutdown
*
* The first two functions are called at Nautilus-Actions startup.
*
* The prototypes for these functions are defined in nautilus-actions/na-api.h
*/
gboolean
na_api_module_init( GTypeModule *module )
{
static const gchar *thisfn = "nagp_module_na_api_module_initialize";
static const gchar *name = "NagpGConfIOProvider";
syslog( LOG_USER | LOG_INFO, "%s initializing...", name );
openlog( G_LOG_DOMAIN, LOG_PID, LOG_USER );
setup_log_handler( NA_LOGDOMAIN_API, &st_log_handler_api );
setup_log_handler( NA_LOGDOMAIN_IO_PROVIDER_GCONF, &st_log_handler_plugin );
g_debug( "%s: module=%p", thisfn, ( void * ) module );
g_type_module_set_name( module, name );
nagp_gconf_provider_register_type( module );
return( TRUE );
}
gint
na_api_module_list_types( const GType **types )
{
static const gchar *thisfn = "nagp_module_na_api_module_list_types";
#define count 1
static GType type_list[count];
g_debug( "%s: types=%p", thisfn, ( void * ) types );
type_list[0] = NAGP_GCONF_PROVIDER_TYPE;
*types = type_list;
return( count );
}
const gchar *
na_api_module_get_name( GType type )
{
static const gchar *thisfn = "nagp_module_na_api_module_get_name";
g_debug( "%s: type=%ld", thisfn, ( gulong ) type );
if( type == NAGP_GCONF_PROVIDER_TYPE ){
return( "Nautilus Actions GConf Provider" );
}
return( NULL );
}
void
na_api_module_shutdown( void )
{
static const gchar *thisfn = "nagp_module_na_api_module_shutdown";
g_debug( "%s", thisfn );
/* remove the log handler
* almost useless as the process is nonetheless terminating at this time
* but this is the art of coding...
*/
remove_log_handler( &st_log_handler_api );
remove_log_handler( &st_log_handler_plugin );
}
static void
setup_log_handler( const gchar *log_domain, guint *handler_id )
{
*handler_id = g_log_set_handler( log_domain, G_LOG_LEVEL_DEBUG, nagp_log_handler, NULL );
}
static void
remove_log_handler( guint *handler_id )
{
if( *handler_id ){
g_log_remove_handler( G_LOG_DOMAIN, *handler_id );
*handler_id = 0;
}
}
/*
* a log handler that we install when in development mode in order to be
* able to log plugin runtime
* TODO: the debug flag should be dynamic, so that an advanced user could
* setup a given key and obtain a full log to send to Bugzilla..
* For now, is always install when compiled in maintainer mode, never else
*/
static void
nagp_log_handler( const gchar *log_domain,
GLogLevelFlags log_level,
const gchar *message,
gpointer user_data )
{
#ifdef NA_MAINTAINER_MODE
syslog( LOG_USER | LOG_DEBUG, "%s", message );
#else
/* do nothing */
#endif
}
......@@ -40,7 +40,8 @@
#include <api/na-object-api.h>
#include <runtime/na-gconf-provider-keys.h>
#include <io-provider-gconf/nagp-keys.h>
#include <runtime/na-gconf-utils.h>
#include <runtime/na-iprefs.h>
#include <runtime/na-utils.h>
......
......@@ -77,7 +77,7 @@ typedef struct
}
NautilusActionsClass;
GType nautilus_actions_get_type( void );
GType nautilus_actions_get_type ( void );
void nautilus_actions_register_type( GTypeModule *module );
G_END_DECLS
......
......@@ -69,6 +69,8 @@ nautilus_module_initialize( GTypeModule *module )
g_debug( "%s: module=%p", thisfn, ( void * ) module );
g_type_module_set_name( module, PACKAGE_STRING );
nautilus_actions_register_type( module );
}
......
......@@ -38,9 +38,6 @@ AM_CPPFLAGS += \
$(NULL)
libna_runtime_la_SOURCES = \
na-gconf-provider.c \
na-gconf-provider.h \
na-gconf-provider-keys.h \
na-gconf-utils.c \
na-gconf-utils.h \
na-iabout.c \
......
......@@ -40,69 +40,6 @@
static GConfValue *read_value( GConfClient *gconf, const gchar *path, gboolean use_schema, GConfValueType type );
static gboolean sync_gconf( GConfClient *gconf, gchar **message );
/**
* na_gconf_utils_get_subdirs:
* @gconf: a #GConfClient instance.
* @path: a full path to be readen.
*
* Loads the subdirs of the given path.
*
* Returns: a GSList of full path subdirectories.
*
* The returned list should be na_gconf_utils_free_subdirs() by the
* caller.
*/
GSList *
na_gconf_utils_get_subdirs( GConfClient *gconf, const gchar *path )
{
static const gchar *thisfn = "na_gconf_utils_get_subdirs";
GError *error = NULL;
GSList *list_subdirs;
list_subdirs = gconf_client_all_dirs( gconf, path, &error );
if( error ){
g_warning( "%s: path=%s, error=%s", thisfn, path, error->message );
g_error_free( error );
return(( GSList * ) NULL );
}
return( list_subdirs );
}
/**
* na_gconf_utils_free_subdirs:
* @subdirs: a list of subdirs as returned by na_gconf_utils_get_subdirs().
*
* Release the list of subdirs.
*/
void
na_gconf_utils_free_subdirs( GSList *subdirs )
{
na_utils_free_string_list( subdirs );
}
/**
* na_gconf_utils_have_subdir:
* @gconf: a #GConfClient instance.
* @path: a full path to be readen.
*
* Returns: %TRUE if the specified path has at least one subdirectory,
* %FALSE else.
*/
gboolean
na_gconf_utils_have_subdir( GConfClient *gconf, const gchar *path )
{
GSList *listpath;
gboolean have_subdir;
listpath = na_gconf_utils_get_subdirs( gconf, path );
have_subdir = ( listpath && g_slist_length( listpath ));
na_gconf_utils_free_subdirs( listpath );
return( have_subdir );
}
/**
* na_gconf_utils_get_entries:
* @gconf: a #GConfClient instance.
......@@ -147,47 +84,6 @@ na_gconf_utils_free_entries( GSList *list )
g_slist_free( list );
}
/**
* na_gconf_utils_have_entry:
* @gconf: a #GConfClient instance.
* @path: the full path of a key.
* @entry: the entry to be tested.
*
* Returns: %TRUE if the given @entry exists for the given @path,
* %FALSE else.
*/
gboolean
na_gconf_utils_have_entry( GConfClient *gconf, const gchar *path, const gchar *entry )
{
static const gchar *thisfn = "na_gconf_utils_have_entry";
gboolean have_entry = FALSE;
GError *error = NULL;
gchar *key;
GConfValue *value;
key = g_strdup_printf( "%s/%s", path, entry );
value = gconf_client_get_without_default( gconf, key, &error );
if( error ){
g_warning( "%s: key=%s, error=%s", thisfn, key, error->message );
g_error_free( error );
if( value ){
gconf_value_free( value );
value = NULL;
}
}
if( value ){
have_entry = TRUE;
gconf_value_free( value );
}
g_free( key );
return( have_entry );
}
/**
* na_gconf_utils_get_bool_from_entries:
* @entries: a list of #GConfEntry as returned by na_gconf_utils_get_entries().
......
......@@ -40,13 +40,8 @@
#include <gconf/gconf.h>
#include <gconf/gconf-client.h>
GSList *na_gconf_utils_get_subdirs( GConfClient *gconf, const gchar *path );
void na_gconf_utils_free_subdirs( GSList *subdirs );
gboolean na_gconf_utils_have_subdir( GConfClient *gconf, const gchar *path );
GSList *na_gconf_utils_get_entries( GConfClient *gconf, const gchar *path );
void na_gconf_utils_free_entries( GSList *entries );
gboolean na_gconf_utils_have_entry( GConfClient *gconf, const gchar *path, const gchar *entry );
gboolean na_gconf_utils_get_bool_from_entries( GSList *entries, const gchar *entry, gboolean *value );
gboolean na_gconf_utils_get_string_from_entries( GSList *entries, const gchar *entry, gchar **value );
gboolean na_gconf_utils_get_string_list_from_entries( GSList *entries, const gchar *entry, GSList **value );
......
......@@ -46,7 +46,7 @@ struct NAModuleClassPrivate {
*/
struct NAModulePrivate {
gboolean dispose_has_run;
gchar *path;
gchar *path; /* full pathname of the plugin */
GModule *library;
GList *objects;
......@@ -66,15 +66,15 @@ static void instance_init( GTypeInstance *instance, gpointer klass );
static void instance_dispose( GObject *object );
static void instance_finalize( GObject *object );
static NAModule *module_new( const gchar *filename );
static gboolean module_load( GTypeModule *gmodule );
static gboolean module_load_check( NAModule *module, const gchar *symbol, gpointer *pfn );
static void module_unload( GTypeModule *gmodule );
static void add_module_objects( NAModule *module );
static gboolean is_a_na_plugin( NAModule *module );
static gboolean plugin_check( NAModule *module, const gchar *symbol, gpointer *pfn );
static void register_module_types( NAModule *module );
static void add_module_type( NAModule *module, GType type );
static NAModule *module_new( const gchar *filename );
static void module_object_weak_notify( NAModule *module, GObject *object );
static void set_name( NAModule *module );
static void object_weak_notify( NAModule *module, GObject *object );
static void module_unload( GTypeModule *gmodule );
GType
na_module_get_type( void )
......@@ -164,6 +164,8 @@ instance_dispose( GObject *object )
self->private->dispose_has_run = TRUE;
g_type_module_unuse( G_TYPE_MODULE( self ));
/* chain up to the parent class */
if( G_OBJECT_CLASS( st_parent_class )->dispose ){
G_OBJECT_CLASS( st_parent_class )->dispose( object );
......@@ -191,79 +193,10 @@ instance_finalize( GObject *object )
}
}
/*
* triggered by GTypeModule base class when first loading the library
* which is itself triggered by module_new:g_type_module_use()
*/
static gboolean
module_load( GTypeModule *gmodule )
{
static const gchar *thisfn = "na_module_module_load";
NAModule *module;
gboolean loaded;
g_debug( "%s: gmodule=%p", thisfn, ( void * ) gmodule );
g_return_val_if_fail( G_IS_TYPE_MODULE( gmodule ), FALSE );
module = NA_MODULE( gmodule );
module->private->library = g_module_open( module->private->path, G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL );
if( !module->private->library ){
g_warning( "%s: g_module_open: path=%s, error=%s", thisfn, module->private->path, g_module_error());
return( FALSE );
}
loaded =
module_load_check( module, "na_api_module_init", ( gpointer * ) &module->private->initialize) &&
module_load_check( module, "na_api_module_list_types", ( gpointer * ) &module->private->list_types ) &&
module_load_check( module, "na_api_module_get_name", ( gpointer * ) &module->private->get_name ) &&
module_load_check( module, "na_api_module_shutdown", ( gpointer * ) &module->private->shutdown ) &&
module->private->initialize( gmodule );
return( loaded );
}
static gboolean
module_load_check( NAModule *module, const gchar *symbol, gpointer *pfn )
{
static const gchar *thisfn = "na_module_module_load_check";
gboolean ok;
ok = g_module_symbol( module->private->library, symbol, pfn );
if( !ok ){
g_debug("%s: %s: symbol not found in %s", thisfn, symbol, module->private->path );
g_module_close( module->private->library );
}
return( ok );
}
static void
module_unload( GTypeModule *gmodule )
{
static const gchar *thisfn = "na_module_module_unload";
NAModule *module;
g_debug( "%s: gmodule=%p", thisfn, ( void * ) gmodule );
g_return_if_fail( G_IS_TYPE_MODULE( gmodule ));
module = NA_MODULE( gmodule );
module->private->shutdown();