Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
DISCONTINUED:openSUSE:11.1
libgda
libgda-vfsmonitor.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File libgda-vfsmonitor.patch of Package libgda
http://bugzilla.gnome.org/show_bug.cgi?id=486021 ================================================================================ --- configure.in +++ configure.in @@ -82,6 +82,7 @@ gthread-2.0 >= req_ver_glib gmodule-2.0 >= req_ver_glib libxml-2.0 + gnome-vfs-2.0 ]) LIBGDA_CFLAGS="$LIBGDA_CFLAGS -DLIBGDA_ABI_NAME=$LIBGDA_ABI_NAME" AC_SUBST(LIBGDA_CFLAGS) @@ -116,29 +117,6 @@ AC_SUBST(SOPREFIX) dnl ****************************** -dnl Checking for FAM or gamin -dnl ****************************** -FAM_LIBS= -FAM_CFLAGS= -FAM_MISSING_WARNING="Libgda depends on FAM to provide notification when configuration files are changed, without FAM support any application using Libgda will have to be restarted when configuration files are changed to take into account those changes" -PKG_CHECK_MODULES(GAMIN, gamin >= 0.1.8, have_fam=yes, have_fam=no) -if test x"$have_fam" = "xyes" -then - FAM_CFLAGS="$GAMIN_CFLAGS" - FAM_LIBS="$GAMIN_LIBS" - AC_DEFINE(HAVE_FAM, [], [Define if we have FAM]) -else - AC_CHECK_LIB(fam, FAMOpen, - [AC_CHECK_HEADERS(fam.h, - [AC_DEFINE(HAVE_FAM, [], [Define if we have FAM]) - FAM_LIBS="-lfam"], - AC_MSG_WARN(*** FAM support will not be built (header files not found) $FAM_MISSING_WARNING ***))], - AC_MSG_WARN(*** FAM support will not be built (FAM library not found) $FAM_MISSING_WARNING ***)) -fi -AC_SUBST(FAM_LIBS) -AC_SUBST(FAM_CFLAGS) - -dnl ****************************** dnl Checks for libgcrypt dnl ****************************** LIBGCRYPT_CFLAGS="" --- libgda/Makefile.am +++ libgda/Makefile.am @@ -11,7 +11,6 @@ -I$(top_srcdir) \ -I$(top_builddir) \ $(LIBGDA_CFLAGS) \ - $(FAM_CFLAGS) \ $(BDB_CFLAGS) \ $(GNOMEVFS_CFLAGS) \ $(LIBGCRYPT_CFLAGS) @@ -229,7 +228,7 @@ handlers/libgda_handlers-3.0.la \ binreloc/libgda_binreloc-3.0.la \ $(top_builddir)/libsql/libgdasql-3.0.la \ - $(LIBGDA_LIBS) $(FAM_LIBS) \ + $(LIBGDA_LIBS) \ $(BDB_LIBS) $(GNOMEVFS_LIBS) $(LIBGCRYPT_LIBS) gdaincludedir=$(includedir)/libgda-$(GDA_ABI_MAJOR_VERSION).$(GDA_ABI_MINOR_VERSION)/libgda --- libgda/gda-config.c +++ libgda/gda-config.c @@ -36,13 +36,8 @@ #include <libxml/xmlmemory.h> #include <libxml/parser.h> #include <sys/stat.h> -#ifdef HAVE_FAM -#include <fam.h> -#include <glib/giochannel.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <unistd.h> -#endif +#include <libgnomevfs/gnome-vfs-ops.h> +#include <libgnomevfs/gnome-vfs-utils.h> #ifdef G_OS_WIN32 #include <io.h> #endif @@ -88,22 +83,16 @@ static gboolean dsn_list_only_in_mem = FALSE; /* - * FAM delcarations and static variables + * File monitoring declarations and static variables */ -#ifdef HAVE_FAM -static FAMConnection *fam_connection = NULL; -static gint fam_watch_id = 0; -static gboolean lock_fam = FALSE; -static FAMRequest *fam_conf_user = NULL; -static FAMRequest *fam_conf_global = NULL; -static time_t last_mtime = 0; -static time_t last_ctime = 0; -static off_t last_size = 0; - -static gboolean fam_callback (GIOChannel *source, GIOCondition condition, gpointer data); -static void fam_lock_notify (); -static void fam_unlock_notify (); -#endif +static GnomeVFSMonitorHandle *monitor_global, *monitor_user; +static gboolean monitor_lock; + +static void monitor_callback (GnomeVFSMonitorHandle *handle, + const gchar *monitor_uri, + const gchar *info_uri, + GnomeVFSMonitorEventType event_type, + gpointer user_data); /* * Private functions @@ -280,12 +269,12 @@ */ if (! config_client) { GDA_CONFIG_LOCK (); - guint len = 0; + gsize len = 0; gchar *full_file = NULL; gchar *user_config = NULL; + gchar *global_config = NULL; gboolean has_user_config = FALSE; gchar *memonly; - gchar *fname; config_client = g_new0 (GdaConfigClient, 1); xmlKeepBlanksDefault(0); @@ -307,7 +296,7 @@ } /* global config file name */ - fname = gda_gbr_get_file_path (GDA_ETC_DIR, LIBGDA_ABI_NAME, "config", NULL); + global_config = gda_gbr_get_file_path (GDA_ETC_DIR, LIBGDA_ABI_NAME, "config", NULL); has_user_config = g_get_home_dir () ? TRUE : FALSE; if (has_user_config) @@ -316,7 +305,7 @@ { /* compute system wide rights */ FILE *file; - file = fopen (fname, "a"); + file = fopen (global_config, "a"); if (file) { can_modify_global_conf = TRUE; #ifdef GDA_DEBUG_NO @@ -332,52 +321,36 @@ } } -#ifdef HAVE_FAM - if (!fam_connection) { - /* FAM init */ - GIOChannel *ioc; - int res; - -#ifdef GDA_DEBUG_NO - g_print ("Using FAM to monitor configuration files changes.\n"); -#endif - fam_connection = g_malloc0 (sizeof (FAMConnection)); - if (FAMOpen2 (fam_connection, "libgnomedb user") != 0) { - g_print ("FAMOpen failed, FAMErrno=%d\n", FAMErrno); - g_free (fam_connection); - fam_connection = NULL; - } - else { - ioc = g_io_channel_unix_new (FAMCONNECTION_GETFD(fam_connection)); - fam_watch_id = g_io_add_watch (ioc, - G_IO_IN | G_IO_HUP | G_IO_ERR, - fam_callback, NULL); - - fam_conf_global = g_new0 (FAMRequest, 1); - res = FAMMonitorFile (fam_connection, fname, fam_conf_global, - GINT_TO_POINTER (TRUE)); -#ifdef GDA_DEBUG_NO - g_print ("Monitoring changes on file %s: %s\n", fname, res ? "ERROR" : "Ok"); + if (!monitor_global) { + GnomeVFSResult res; + char *uri; + +#ifdef GDA_DEBUG + g_print ("Using GNOME-VFS to monitor configuration files changes.\n"); #endif - - if (has_user_config) { - fam_conf_user = g_new0 (FAMRequest, 1); - res = FAMMonitorFile (fam_connection, user_config, fam_conf_user, - GINT_TO_POINTER (FALSE)); -#ifdef GDA_DEBUG_NO - g_print ("Monitoring changes on file %s: %s\n", - user_config, res ? "ERROR" : "Ok"); + + uri = gnome_vfs_get_uri_from_local_path (global_config); + res = gnome_vfs_monitor_add (&monitor_global, uri, GNOME_VFS_MONITOR_FILE, monitor_callback, NULL); + g_free (uri); +#ifdef GDA_DEBUG + g_print ("Monitoring changes on file %s: %s\n", + fam_conf_global, res ? "ERROR" : "Ok"); #endif - } - } - } + if (has_user_config) { + uri = gnome_vfs_get_uri_from_local_path (user_config); + res = gnome_vfs_monitor_add (&monitor_user, uri, GNOME_VFS_MONITOR_FILE, monitor_callback, NULL); + g_free (uri); +#ifdef GDA_DEBUG + g_print ("Monitoring changes on file %s: %s\n", + user_config, res ? "ERROR" : "Ok"); #endif + } /* * load system wide config */ - if (g_file_get_contents (fname, &full_file, &len, NULL)){ + if (g_file_get_contents (global_config, &full_file, &len, NULL)){ GList *list; config_client->global = gda_config_parse_config_file (full_file, len); g_free (full_file); @@ -392,7 +365,7 @@ if (! has_user_config) { /* this can occur on win98, and maybe other win32 platforms */ - g_free (fname); + g_free (global_config); GDA_CONFIG_UNLOCK (); return config_client; } @@ -475,11 +448,12 @@ g_warning ("Config file is not readable."); } g_free (user_config); - g_free (fname); + g_free (global_config); #ifdef GDA_DEBUG_NO dump_config_client (); #endif GDA_CONFIG_UNLOCK (); + } } return config_client; @@ -487,88 +461,50 @@ static void gda_config_client_reset (); -#ifdef HAVE_FAM -static gboolean -fam_callback (GIOChannel *source, GIOCondition condition, gpointer data) +static void +monitor_callback (GnomeVFSMonitorHandle *handle, + const gchar *monitor_uri, + const gchar *info_uri, + GnomeVFSMonitorEventType event_type, + gpointer user_data) { - gboolean res = TRUE; + gboolean is_global; - GDA_CONFIG_LOCK (); - while (fam_connection && FAMPending (fam_connection)) { - FAMEvent ev; - gboolean is_global; - - if (FAMNextEvent (fam_connection, &ev) != 1) { - FAMClose (fam_connection); - g_free (fam_connection); - g_source_remove (fam_watch_id); - fam_watch_id = 0; - fam_connection = NULL; - GDA_CONFIG_UNLOCK (); - return FALSE; - } - - if (lock_fam) - continue; + if (monitor_lock) + return; - is_global = GPOINTER_TO_INT (ev.userdata); - switch (ev.code) { - case FAMChanged: { - struct stat stat; - if (lstat (ev.filename, &stat)) - break; - if ((stat.st_mtime != last_mtime) || - (stat.st_ctime != last_ctime) || - (stat.st_size != last_size)) { - last_mtime = stat.st_mtime; - last_ctime = stat.st_ctime; - last_size = stat.st_size; - } - else - break; - } - case FAMDeleted: - case FAMCreated: -#ifdef GDA_DEBUG_NO - g_print ("Reloading config files (%s config has changed)\n", is_global ? "global" : "user"); + is_global = GPOINTER_TO_INT (user_data); + switch (event_type) { + case GNOME_VFS_MONITOR_EVENT_CHANGED: + case GNOME_VFS_MONITOR_EVENT_DELETED: + case GNOME_VFS_MONITOR_EVENT_CREATED: +#ifdef GDA_DEBUG + g_print ("Reloading config files (%s config has changed)\n", is_global ? "global" : "user"); #endif - GDA_CONFIG_LOCK (); - gda_config_client_reset (); - g_free (config_client); - config_client = NULL; - /* config_client will be re-created next time a gda_config* call is made */ - do_notify (NULL); - GDA_CONFIG_UNLOCK (); - break; - case FAMAcknowledge: - case FAMStartExecuting: - case FAMStopExecuting: - case FAMExists: - case FAMEndExist: - case FAMMoved: - /* Not supported */ - break; - } + gda_config_client_reset (); + g_free (config_client); + config_client = NULL; + /* config_client will be re-created next time a gda_config* call is made */ + do_notify (NULL); + break; + default: + /* Not supported */ + break; } - - GDA_CONFIG_UNLOCK (); - return res; } static void -fam_lock_notify () +monitor_lock_notify () { - lock_fam = TRUE; + monitor_lock = TRUE; } static void -fam_unlock_notify () +monitor_unlock_notify () { - lock_fam = FALSE; + monitor_lock = FALSE; } -#endif - static GdaConfigSection * gda_config_search_section (GList *sections, const gchar *path) { @@ -785,14 +721,10 @@ } user_config = g_strdup_printf ("%s%s", g_get_home_dir (), LIBGDA_USER_CONFIG_FILE); -#ifdef HAVE_FAM - fam_lock_notify (); -#endif + monitor_lock_notify (); if (xmlSaveFormatFile (user_config, doc, TRUE) == -1) g_warning ("Error saving config data to '%s'", user_config); -#ifdef HAVE_FAM - fam_unlock_notify (); -#endif + monitor_unlock_notify (); g_free (user_config); xmlFreeDoc (doc); @@ -817,9 +749,7 @@ } } -#ifdef HAVE_FAM - fam_lock_notify (); -#endif + monitor_lock_notify (); /* global config file name */ gchar *fname; fname = gda_gbr_get_file_path (GDA_ETC_DIR, LIBGDA_ABI_NAME, "config", NULL); @@ -827,9 +757,7 @@ if (xmlSaveFormatFile (fname, doc, TRUE) == -1) g_warning ("Error saving config data to '%s'", user_config); g_free (fname); -#ifdef HAVE_FAM - fam_unlock_notify (); -#endif + monitor_unlock_notify (); xmlFreeDoc (doc); }
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor