From a2146ea84487773534b27cdd73ae7fe0723a486f Mon Sep 17 00:00:00 2001 From: Alex Larsson Date: Wed, 11 Jul 2001 14:38:47 +0000 Subject: [PATCH] Add HAVE_LIBFAM 2001-07-11 Alex Larsson * acconfig.h: Add HAVE_LIBFAM * configure.in: Check for libfam, not only header. * libnautilus-private/Makefile.am: Link to libfam * libnautilus-private/nautilus-monitor.c: Use normal fam library calls. --- ChangeLog | 14 ++++ acconfig.h | 1 + configure.in | 15 ++-- libnautilus-private/Makefile.am | 1 + libnautilus-private/nautilus-monitor.c | 97 ++++---------------------- 5 files changed, 40 insertions(+), 88 deletions(-) diff --git a/ChangeLog b/ChangeLog index 658abe207..36ef98bcf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2001-07-11 Alex Larsson + + * acconfig.h: + Add HAVE_LIBFAM + + * configure.in: + Check for libfam, not only header. + + * libnautilus-private/Makefile.am: + Link to libfam + + * libnautilus-private/nautilus-monitor.c: + Use normal fam library calls. + 2001-07-11 Benedikt Roth * components/text/nautilus-text-view-ui.xml: diff --git a/acconfig.h b/acconfig.h index d2efc960c..daba7c739 100644 --- a/acconfig.h +++ b/acconfig.h @@ -12,6 +12,7 @@ #undef HAVE_STPCPY #undef HAVE_LIBBZ2 #undef HAVE_AMMONITE +#undef HAVE_LIBFAM #undef bzCompress #undef bzCompressInit #undef bzDecompress diff --git a/configure.in b/configure.in index e99e1b72b..0f7f77ec6 100644 --- a/configure.in +++ b/configure.in @@ -102,10 +102,17 @@ dnl = Method for changing environment dnl ==================================== AC_CHECK_FUNCS(setenv unsetenv putenv) -dnl ==================================== -dnl Check for FAM header -- we find the library at runtime -dnl ==================================== -AC_CHECK_HEADERS(fam.h) +dnl ============= +dnl Check for FAM +dnl ============= +FAM_LIBS= +AC_CHECK_LIB(fam, FAMOpen, + AC_CHECK_HEADERS(fam.h, + [AC_DEFINE(HAVE_LIBFAM) + FAM_LIBS="-lfam"], + AC_MSG_WARN(*** FAM support will not be built (header files not found) ***)), + AC_MSG_WARN(*** FAM support will not be built (FAM library not found) ***)) +AC_SUBST(FAM_LIBS) dnl ==================================== dnl = Use x86 optimized music routines? diff --git a/libnautilus-private/Makefile.am b/libnautilus-private/Makefile.am index d5fd9725b..a78977333 100644 --- a/libnautilus-private/Makefile.am +++ b/libnautilus-private/Makefile.am @@ -32,6 +32,7 @@ libnautilus_private_la_LDFLAGS = \ $(ESD_LIBS) \ $(LIBJPEG) \ $(MEDUSA_LIBS) \ + $(FAM_LIBS) \ $(CDDALIBADD) \ $(NULL) diff --git a/libnautilus-private/nautilus-monitor.c b/libnautilus-private/nautilus-monitor.c index b90b3ab66..cacd6c2eb 100644 --- a/libnautilus-private/nautilus-monitor.c +++ b/libnautilus-private/nautilus-monitor.c @@ -28,7 +28,7 @@ #include -#ifdef HAVE_FAM_H +#ifdef HAVE_LIBFAM #include "nautilus-file-changes-queue.h" #include @@ -38,57 +38,6 @@ #include #include -/* Turn off this to make FAM calls the normal way rather than using - * GModule. This can be useful to check that the parameters to all the - * functions are still correct, but it won't link without configure - * and makefile changes. - */ -#define USE_FAM_AS_MODULE - -#ifndef USE_FAM_AS_MODULE - -#define CALL_FAM(f) FAM##f - -#else /* USE_FAM_AS_MODULE */ - -typedef struct { - const char *name; - gpointer *function; -} ModuleSymbolPair; - -static int (* pointer_FAMCancelMonitor) (FAMConnection *fc, - const FAMRequest *fr); -static int (* pointer_FAMClose) (FAMConnection *fc); -static int (* pointer_FAMMonitorDirectory) (FAMConnection *fc, - const char *filename, - FAMRequest *fr, - void *user_data); -static int (* pointer_FAMMonitorFile) (FAMConnection *fc, - const char *filename, - FAMRequest *fr, - void *user_data); -static int (* pointer_FAMOpen2) (FAMConnection *connection, - const char *name); -static int (* pointer_FAMNextEvent) (FAMConnection *fc, - FAMEvent *fe); -static int (* pointer_FAMPending) (FAMConnection *fc); - -static const ModuleSymbolPair fam_symbols[] = { -#define IMPORT_FAM(f) { "FAM" #f, (gpointer *) &pointer_FAM##f }, - IMPORT_FAM (CancelMonitor) - IMPORT_FAM (Close) - IMPORT_FAM (MonitorDirectory) - IMPORT_FAM (MonitorFile) - IMPORT_FAM (NextEvent) - IMPORT_FAM (Open2) - IMPORT_FAM (Pending) -#undef IMPORT_FAM -}; - -#define CALL_FAM(f) (* pointer_FAM##f) - -#endif /* USE_FAM_AS_MODULE */ - struct NautilusMonitor { FAMRequest request; }; @@ -105,11 +54,6 @@ get_fam_connection (void) { static gboolean tried_connection; static FAMConnection connection; -#ifdef USE_FAM_AS_MODULE - char *path; - GModule *module; - guint i; -#endif /* Only try once. */ if (tried_connection) { @@ -118,22 +62,7 @@ get_fam_connection (void) } } else { tried_connection = TRUE; -#ifdef USE_FAM_AS_MODULE - path = g_module_build_path (NULL, "fam"); - module = g_module_open (path, 0); - g_free (path); - if (module == NULL) { - return NULL; - } - for (i = 0; i < EEL_N_ELEMENTS (fam_symbols); i++) { - if (!g_module_symbol (module, - fam_symbols[i].name, - fam_symbols[i].function)) { - return NULL; - } - } -#endif - if (CALL_FAM (Open2) (&connection, "Nautilus") != 0) { + if (FAMOpen2 (&connection, "Nautilus") != 0) { return NULL; } @@ -200,11 +129,11 @@ process_fam_notifications (gpointer callback_data, int fd, GdkInputCondition con /* Process all the pending events right now. */ - while (CALL_FAM (Pending) (connection)) { - if (CALL_FAM (NextEvent) (connection, &event) != 1) { + while (FAMPending (connection)) { + if (FAMNextEvent (connection, &event) != 1) { g_warning ("connection to FAM died"); gdk_input_remove (fd); - CALL_FAM (Close) (connection); + FAMClose (connection); got_connection = FALSE; return; } @@ -288,12 +217,12 @@ process_fam_notifications (gpointer callback_data, int fd, GdkInputCondition con nautilus_file_changes_consume_changes (TRUE); } -#endif /* HAVE_FAM_H */ +#endif /* HAVE_LIBFAM */ gboolean nautilus_monitor_active (void) { -#ifndef HAVE_FAM_H +#ifndef HAVE_LIBFAM return FALSE; #else return get_fam_connection () != NULL; @@ -303,7 +232,7 @@ nautilus_monitor_active (void) NautilusMonitor * nautilus_monitor_file (const char *uri) { -#ifndef HAVE_FAM_H +#ifndef HAVE_LIBFAM return NULL; #else FAMConnection *connection; @@ -321,7 +250,7 @@ nautilus_monitor_file (const char *uri) } monitor = g_new0 (NautilusMonitor, 1); - CALL_FAM (MonitorFile) (connection, path, &monitor->request, NULL); + FAMMonitorFile (connection, path, &monitor->request, NULL); g_free (path); @@ -334,7 +263,7 @@ nautilus_monitor_file (const char *uri) NautilusMonitor * nautilus_monitor_directory (const char *uri) { -#ifndef HAVE_FAM_H +#ifndef HAVE_LIBFAM return NULL; #else FAMConnection *connection; @@ -352,7 +281,7 @@ nautilus_monitor_directory (const char *uri) } monitor = g_new0 (NautilusMonitor, 1); - CALL_FAM (MonitorDirectory) (connection, path, &monitor->request, NULL); + FAMMonitorDirectory (connection, path, &monitor->request, NULL); g_assert (g_hash_table_lookup (get_request_hash_table (), GINT_TO_POINTER (FAMREQUEST_GETREQNUM (&monitor->request))) == NULL); @@ -368,7 +297,7 @@ nautilus_monitor_directory (const char *uri) void nautilus_monitor_cancel (NautilusMonitor *monitor) { -#ifndef HAVE_FAM_H +#ifndef HAVE_LIBFAM g_return_if_fail (monitor == NULL); #else FAMConnection *connection; @@ -389,7 +318,7 @@ nautilus_monitor_cancel (NautilusMonitor *monitor) connection = get_fam_connection (); g_return_if_fail (connection != NULL); - CALL_FAM (CancelMonitor) (connection, &monitor->request); + FAMCancelMonitor (connection, &monitor->request); g_free (monitor); #endif }