[Nautilus-list] Make fam a real dependency



I dislike the current fam not-really-a-runtime-requirement solution of
dlopening the library. One problem is that it opens libfam.so, a file that
would typically be in the fam-devel package on an RPM system. Another is
that you're never quite sure fam is actually being used. In a nautilus RPM
package i want to depend on fam anyway, so the run-time check doesn't help
me.

Here is a patch that links to libfam if it is found during configure. What
is the general feeling about applying this.

Index: acconfig.h
===================================================================
RCS file: /cvs/gnome/nautilus/acconfig.h,v
retrieving revision 1.25
diff -u -p -r1.25 acconfig.h
--- acconfig.h	2001/04/27 01:19:06	1.25
+++ acconfig.h	2001/07/09 14:55:19
@@ -12,6 +12,7 @@
 #undef HAVE_STPCPY
 #undef HAVE_LIBBZ2
 #undef HAVE_AMMONITE
+#undef HAVE_LIBFAM
 #undef bzCompress
 #undef bzCompressInit
 #undef bzDecompress
Index: configure.in
===================================================================
RCS file: /cvs/gnome/nautilus/configure.in,v
retrieving revision 1.356
diff -u -p -r1.356 configure.in
--- configure.in	2001/07/05 23:16:51	1.356
+++ configure.in	2001/07/09 14:55:19
@@ -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?
Index: libnautilus-private/Makefile.am
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/Makefile.am,v
retrieving revision 1.190
diff -u -p -r1.190 Makefile.am
--- libnautilus-private/Makefile.am	2001/05/04 10:17:51	1.190
+++ libnautilus-private/Makefile.am	2001/07/09 14:55:19
@@ -32,6 +32,7 @@ libnautilus_private_la_LDFLAGS =	\
 	$(ESD_LIBS)			\
 	$(LIBJPEG) 			\
 	$(MEDUSA_LIBS) 			\
+	$(FAM_LIBS) 			\
 	$(CDDALIBADD)			\
 	$(NULL)

Index: libnautilus-private/nautilus-monitor.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-monitor.c,v
retrieving revision 1.11
diff -u -p -r1.11 nautilus-monitor.c
--- libnautilus-private/nautilus-monitor.c	2001/04/28 01:51:32	1.11
+++ libnautilus-private/nautilus-monitor.c	2001/07/09 14:55:19
@@ -28,7 +28,7 @@

 #include <eel/eel-glib-extensions.h>

-#ifdef HAVE_FAM_H
+#ifdef HAVE_LIBFAM

 #include "nautilus-file-changes-queue.h"
 #include <fam.h>
@@ -38,57 +38,6 @@
 #include <libgnome/gnome-util.h>
 #include <libgnomevfs/gnome-vfs-utils.h>

-/* 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 call

         /* 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 call
 	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 *
 	}

 	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 *
 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
         connection = get_fam_connection ();
 	g_return_if_fail (connection != NULL);

-	CALL_FAM (CancelMonitor) (connection, &monitor->request);
+	FAMCancelMonitor (connection, &monitor->request);
 	g_free (monitor);
 #endif
 }





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]