[gnome-pilot] Removed libhal, and fixed up a couple of recent 'make dist' problems.



commit eddb7137a4f0d1c34fa71251b89697f156e76c16
Author: Matt Davey <mcdavey mrao cam ac uk>
Date:   Mon Jan 3 14:51:03 2011 +0000

    Removed libhal, and fixed up a couple of recent 'make dist' problems.
    
    2011-01-03  Matt Davey <mcdavey mrao cam ac uk>
           * gpilotd/Makefile.am: add gpmarshal.[ch] to BUILT_SRCS, so
    		they get built from a clean checkout, and whenever
    		gpmarshal.list changes. #634873 Thanks Matt McCutchen
    		Also, add support for gudev. #593936
           * gpilotd/gpilot-daemon.c: add support for gudev to replace
    		libhal.  Keep libhal around for backwards compatibility,
    		but default to gudev. #593936
           * gpilotd/configure.ac: default to not using libhal.  Add support
    		for using gudev. #593936
    		Also, put the GNOME_DOC_INIT instruction before config.status
    		and all the makefiles are created! #638557
           * help/C/gnome-pilot.xml: fix markup so it passes xmlint test
    		in 'make dist' #638557
           * .gitignore: add a few extra files, introduced during
    		gnome-doc-utils change recently.

 .gitignore              |    6 ++
 ChangeLog               |   19 +++++-
 configure.ac            |   43 ++++++++-----
 gpilotd/Makefile.am     |   16 +++--
 gpilotd/gpilot-daemon.c |  168 ++++++++++++++++++++++++++++++++++-------------
 help/C/gnome-pilot.xml  |   10 ++-
 6 files changed, 192 insertions(+), 70 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index 71771f9..07f3792 100644
--- a/.gitignore
+++ b/.gitignore
@@ -30,6 +30,7 @@ install-sh
 intltool-extract.in
 intltool-merge.in
 intltool-update.in
+macros/gnome-doc-utils.m4
 macros/intltool.m4
 macros/libtool.m4
 macros/ltoptions.m4
@@ -82,8 +83,13 @@ gpilotd/gpilotd
 gpilotd/gpilotd-session-wrapper
 gpilotd/gpmarshal.c
 gpilotd/gpmarshal.h
+gnome-doc-utils.make
 help/C/gnome-pilot-C.omf.out
 help/C/omf_timestamp
+help/de/de.mo
+help/de/gnome-pilot.xml
+help/es/es.mo
+help/es/gnome-pilot.xml
 libgpilotdCM/gnome-pilot-conduit-config-private.h
 libgpilotdCM/gnome-pilot-conduit-config.c
 libgpilotdCM/gnome-pilot-conduit-config.h
diff --git a/ChangeLog b/ChangeLog
index 288db33..2f8f892 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2011-01-02  Matt Davey <mcdavey mrao cam ac uk>
+       * gpilotd/Makefile.am: add gpmarshal.[ch] to BUILT_SRCS, so
+		they get built from a clean checkout, and whenever
+		gpmarshal.list changes. #634873 Thanks Matt McCutchen
+		Also, add support for gudev. #593936
+       * gpilotd/gpilot-daemon.c: add support for gudev to replace
+		libhal.  Keep libhal around for backwards compatibility,
+		but default to gudev. #593936
+       * gpilotd/configure.ac: default to not using libhal.  Add support
+		for using gudev. #593936
+		Also, put the GNOME_DOC_INIT instruction before config.status
+		and all the makefiles are created! #638557
+       * help/C/gnome-pilot.xml: fix markup so it passes xmlint test
+		in 'make dist' #638557
+       * .gitignore: add a few extra files, introduced during
+		gnome-doc-utils change recently.
+
 2010-09-26  Matt Davey <mcdavey mrao cam ac uk>
        * configure.ac: Change version to 2.32.1
 
@@ -8,7 +25,7 @@
 
 
 2010-08-07 Matt Davey <mcdavey mrao cam ac uk>
-       * #594214:  Remove remaining deprecated symbols: 
+       * #594214:  Remove remaining deprecated symbols:
 	GTK_SIGNAL_FUNC, GTK_SIGNAL_OFFSET,
 	GtkSignalFunc, gtk_signal_connect, gtk_signal_disconnect,
 	gtk_signal_disconnect_by_data,
diff --git a/configure.ac b/configure.ac
index 191e389..8dff6eb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -100,34 +100,43 @@ if test x"$do_network" = x"yes"; then
 fi
 
 dnl ******************************
-dnl Whether to use HAL/DBUS
+dnl Whether to use HAL or GUDEV
 dnl ******************************
-dnl Default: use it if it is available
+dnl Default: use gudev it if it is available
+GUDEV_REQUIRED="gudev-1.0"
 DBUS_REQUIRED="dbus-glib-1 >= 0.31"
 HAL_REQUIRED="hal >= 0.5.4"
 
 AC_ARG_WITH([hal],
-	[AS_HELP_STRING([--enable-hal],
-	[Enable HAL/DBUS support.])],
-	[enable_hal="$enableval"],[enable_hal="yes"])
+	[AS_HELP_STRING([--with-hal],
+	[Force use of LIBHAL.])],
+	[with_hal="$withval"],[with_hal="no"])
 
-if test x"$enable_hal" = x"yes"; then
-	PKG_CHECK_MODULES(HAL,
+with_gudev="no"
+
+dnl if --with-hal is specified, then error if we don't find it
+PKG_CHECK_MODULES(HAL,
 	[$DBUS_REQUIRED $HAL_REQUIRED],
-	[found_hal="yes"],[found_hal="no"]) 
+	[found_hal="yes"],[found_hal="no"])
+PKG_CHECK_MODULES(GUDEV, $GUDEV_REQUIRED,
+	[found_gudev="yes"],[found_gudev="no"]) 
+
+if test x"$with_hal" = x"yes"; then
 	if test x"$found_hal" = x"yes"; then
-		AC_DEFINE(WITH_HAL,,"Using HAL/DBUS")
-		with_hal="yes"
+		AC_DEFINE(WITH_HAL,,"Using LIBHAL")
 	else
-		AC_MSG_ERROR([HAL/DBUS Library requirements ($DBUS_REQUIRED, $HAL_REQUIRED)
+		AC_MSG_ERROR([LIBHAL Library requirements ($DBUS_REQUIRED, $HAL_REQUIRED)
 not met; consider using --disable-hal option, or adjusting the PKG_CONFIG_PATH
 environment variable if your libraries are in a nonstandard prefix so pkg-config
 can find them.])
 	fi
-dnl if --with-hal wasn't specified, carry on without HAL if it's not found.
 else
-	AC_MSG_WARN([HAL/DBUS Library requirements ($DBUS_REQUIRED, $HAL_REQUIRED)
-not met; disabling HAL support.])
+dnl if --with-hal wasn't specified, carry on without HAL if it's not found.
+	with_hal="no"
+	if test x"$found_gudev" = x"yes"; then
+		with_gudev="yes"
+		AC_DEFINE(WITH_GUDEV,,"Using GUDEV")
+	fi
 fi
 
 dnl *********************************
@@ -244,6 +253,8 @@ if test $ac_cv_func_crypt = no; then
     AC_CHECK_LIB(crypt, crypt,[ LIBS="$LIBS -lcrypt" ],[ AC_MSG_ERROR("Unable to find crypt")])])
 fi
 
+GNOME_DOC_INIT
+
 dnl Create files.
 AC_CONFIG_FILES([
 Makefile 
@@ -266,10 +277,10 @@ AC_MSG_NOTICE([
 Configuration :
 	network sync : $do_network
 	usb          : $do_usb
-	HAL/DBUS     : $with_hal
+	LIBHAL       : $with_hal
+	GUDEV        : $with_gudev
 	EDS conduits : $enable_eds
 	gob          : $GOB
 	pilot-link   : $PILOT_LINK_VERSION
 ])
 #AC_CONFIG_MACRO_DIR([m4])
-GNOME_DOC_INIT
diff --git a/gpilotd/Makefile.am b/gpilotd/Makefile.am
index a2bb3a8..ede664a 100644
--- a/gpilotd/Makefile.am
+++ b/gpilotd/Makefile.am
@@ -11,6 +11,7 @@ AM_CPPFLAGS = 							\
 	-DGNOMELOCALEDIR=\""$(datadir)/locale"\" 		\
 	-DCONDUITDIR=\"$(datadir)\"				\
 	$(HAL_CFLAGS)						\
+	$(GUDEV_CFLAGS)						\
 	$(GNOME_PILOT_CFLAGS)	
 
 gpmarshal.h: gpmarshal.list
@@ -38,6 +39,12 @@ gpilotdcmlibsdir=$(libdir)
 gpilotdcmlibs_LTLIBRARIES =		\
 	libgpilotdcm.la
 
+## MARSHAL STUFF
+
+GPMARSHAL_BUILT_SRCS =				\
+	gpmarshal.c				\
+	gpmarshal.h
+
 ## GOB STUFF 
 
 GOB_LIBGPILOTDCM_BUILT_SRCS = 					\
@@ -104,7 +111,7 @@ DBUS_SRCLIST = 		\
 	gpilot-daemon-glue.h \
 	$(NULL)
 
-BUILT_SOURCES = $(DBUS_SRCLIST) $(GOB_BUILT_SRCS)
+BUILT_SOURCES = $(DBUS_SRCLIST) $(GOB_BUILT_SRCS) $(GPMARSHAL_BUILT_SRCS)
 
 gpilot-daemon-glue.h: gpilot-daemon.xml
 	dbus-binding-tool --prefix=gpilot_daemon --mode=glib-server $< > gpilot-daemon-glue.h
@@ -134,8 +141,7 @@ libgpilotdcm_la_LDFLAGS = \
 
 libgpilotd_la_SOURCES = 		\
 	$(GOB_LIBGPILOTD_BUILT_SRCS)	\
-	gpmarshal.c 			\
-	gpmarshal.h			\
+	$(GPMARSHAL_BUILT_SRCS)	\
 	$(NULL)
 
 libgpilotdincludedir = $(includedir)/gpilotd
@@ -152,8 +158,7 @@ libgpilotd_la_LDFLAGS = \
 ## LIBGPILOTDCONDUIT
 libgpilotdconduit_la_SOURCES = 			\
 	$(GOB_GPILOTD_CONDUIT_SRCS)		\
-	gpmarshal.c				\
-	gpmarshal.h				\
+        $(GPMARSHAL_BUILT_SRCS) \
 	gnome-pilot-conduit-standard-abs.c 	\
 	gnome-pilot-conduit-standard-abs.h 	\
 	gnome-pilot-conduit-sync-abs.h 		\
@@ -211,6 +216,7 @@ gpilotd_LDADD = libgpilotdconduit.la libgpilotd.la	\
 		./libgpilotd.la				\
 		$(GNOME_PILOT_LIBS) 			\
 		$(HAL_LIBS) 				\
+		$(GUDEV_LIBS) 				\
 		$(NULL)
 
 gpilotd_session_wrapper_SOURCES = 		\
diff --git a/gpilotd/gpilot-daemon.c b/gpilotd/gpilot-daemon.c
index 8e371c6..82b9389 100644
--- a/gpilotd/gpilot-daemon.c
+++ b/gpilotd/gpilot-daemon.c
@@ -98,10 +98,17 @@ static LibHalContext *hal_ctx = NULL;
 
 static gboolean gpilotd_dbus_init (void);
 static LibHalContext *gpilotd_hal_init (void);
-#endif
+#else
+# ifdef WITH_GUDEV
+/* move these into GpilotDaemonPrivate... */
+#include <gudev/gudev.h>
+static gboolean gpilotd_gudev_init (void);
+GUdevClient *gudev_client = NULL;
+# endif /* WITH_GUDEV */
+#endif /* WITH_HAL */
 
 static guint visor_timeout_id = -1;
-static guint hal_initialised = 0;
+static guint udev_initialised = 0;
 static GPtrArray *vendor_product_ids = NULL;
 static GArray *product_net = NULL;
 
@@ -163,15 +170,14 @@ match_pilot_userID (const GPilotPilot   *p,
         return -1;
 }
 
-#ifdef WITH_HAL
-static void
-hal_device_added (LibHalContext *ctx, const char *udi)
-{
+/* function to handle a usb device/vendor ID connection.
+ * used by sysfs, hal, gdbus paths
+ */
+static void usb_device_added (int vendor_id, int product_id) {
 	gboolean visor_net = FALSE;
-	char *bus, *platform, *match_str;
-	int vendor_id, product_id, i;
+	char *match_str;
+	int i;
 	GPilotDevice *device;
-	DBusError error;
 	GList *dev;
         GpilotDaemonPrivate *priv;
 
@@ -182,6 +188,58 @@ hal_device_added (LibHalContext *ctx, const char *udi)
 
 	load_devices_xml ();
 
+	/* now look for a vendor/product match */
+	match_str = g_strdup_printf ("Vendor=%04x ProdID=%04x",
+	    vendor_id, product_id);
+	i = known_usb_device(match_str);
+	g_warning("found match: index=%d looking for: %s\n", i, match_str);
+	g_free(match_str);
+	if(i == -1)
+		return;
+
+	visor_net = g_array_index (product_net, gboolean, i);
+	dev = priv->gpilotd_context->devices;
+	while (dev != NULL) {
+		device = dev->data;
+		if (device->type == PILOT_DEVICE_USB_VISOR) {
+			if (!visor_net)
+				device->type = PILOT_DEVICE_SERIAL;
+			/* problems have been reported with devices
+ 			 * not being ready for sync immediately,
+ 			 * so we wait for 0.4 seconds.  See
+ 			 * bugzilla.gnome #362565
+ 			 */
+			usleep(400000);
+			/* just try to sync.  Until I can talk to 
+			 * the kernel guys this is the best way to 
+			 * go. */
+			sync_device (device, priv->gpilotd_context);
+
+			if (!visor_net)
+				device->type = PILOT_DEVICE_USB_VISOR;
+			
+			break;
+		}
+		
+		dev = dev->next;
+	}
+}
+
+
+#ifdef WITH_HAL
+static void
+hal_device_added (LibHalContext *ctx, const char *udi)
+{
+	char *bus, *platform;
+	int vendor_id, product_id;
+	DBusError error;
+        GpilotDaemonPrivate *priv;
+
+        priv = GPILOT_DAEMON (daemon_object)->priv;
+
+	if (priv->gpilotd_context->paused) 
+		return;
+
 	/* HAL match rule: we look for pda.platform == 'palm'
 	 * (or the legacy info.bus == 'usb_device')
 	 * and then try to match the usb_device.product_id and usb_device.vendor_id
@@ -216,41 +274,8 @@ hal_device_added (LibHalContext *ctx, const char *udi)
 		g_warning ("Could not get usb product ID from hal: %s", error.message);
 		return;
 	}
-	
-	/* now look for a vendor/product match */
-	match_str = g_strdup_printf ("Vendor=%04x ProdID=%04x",
-	    vendor_id, product_id);
-	i = known_usb_device(match_str);
-	g_free(match_str);
-	if(i == -1)
-		return;
-
-	visor_net = g_array_index (product_net, gboolean, i);
-	dev = priv->gpilotd_context->devices;
-	while (dev != NULL) {
-		device = dev->data;
-		if (device->type == PILOT_DEVICE_USB_VISOR) {
-			if (!visor_net)
-				device->type = PILOT_DEVICE_SERIAL;
-			/* problems have been reported with devices
- 			 * not being ready for sync immediately,
- 			 * so we wait for 0.4 seconds.  See
- 			 * bugzilla.gnome #362565
- 			 */
-			usleep(400000);
-			/* just try to sync.  Until I can talk to 
-			 * the kernel guys this is the best way to 
-			 * go. */
-			sync_device (device, priv->gpilotd_context);
 
-			if (!visor_net)
-				device->type = PILOT_DEVICE_USB_VISOR;
-			
-			break;
-		}
-		
-		dev = dev->next;
-	}
+	usb_device_added(vendor_id, product_id);
 }
 
 static void
@@ -377,6 +402,53 @@ gpilotd_hal_init (void)
 	
 	return ctx;
 }
+#else
+# ifdef WITH_GUDEV
+static void gpilotd_gudev_handler  (GUdevClient *client, gchar *action, GUdevDevice *device,
+    gpointer user_data)
+{
+	int vendor_id = -1, product_id = -1;
+        GpilotDaemonPrivate *priv;
+	const gchar *s = NULL;
+
+	g_warning ("got usb device: %s", g_udev_device_get_sysfs_path(device));
+
+        priv = GPILOT_DAEMON (daemon_object)->priv;
+
+	if (priv->gpilotd_context->paused) 
+		return;
+	if (g_strncasecmp (action, "add", 3) == 0) {
+		s = g_udev_device_get_property (device, "ID_VENDOR_ID");
+		if (s != NULL)
+			vendor_id = g_ascii_strtoll (s, NULL, 16);
+		s = g_udev_device_get_property (device, "ID_MODEL_ID");
+		if (s != NULL)
+			product_id = g_ascii_strtoll (s, NULL, 16);
+		usb_device_added(vendor_id, product_id);
+	}
+}
+
+static gboolean
+gpilotd_gudev_init (void)
+{
+	GError *error = NULL;
+	const gchar * const udev_subsystems[2] = { "usb/usb_device", NULL};
+
+	/* Just use g_udev_client / g_udev_device
+	   http://www.kernel.org/pub/linux/utils/kernel/hotplug/gudev/GUdevClient.html
+	*/
+
+	if (gudev_client != NULL)
+		return TRUE;
+
+	gudev_client = g_udev_client_new (udev_subsystems);
+
+        g_signal_connect (G_OBJECT (gudev_client),"uevent", G_CALLBACK (gpilotd_gudev_handler), NULL);
+	
+	return TRUE;
+}
+
+#endif /* WITH_GUDEV */
 #endif /* WITH_HAL */
 
 static int
@@ -1555,7 +1627,7 @@ monitor_channel (GPilotDevice *dev, GPilotContext *context)
 		g_assert_not_reached ();
 #endif /* WITH_NETWORK */
 	} if (dev->type == PILOT_DEVICE_USB_VISOR) {
-		if(hal_initialised) {
+		if(udev_initialised) {
 			/* handled by hal callbacks */
 			dev->device_exists = FALSE;
 		} else {
@@ -3027,8 +3099,14 @@ gpilot_daemon_init (GpilotDaemon *daemon)
 {
 #ifdef WITH_HAL
 	if ((hal_ctx = gpilotd_hal_init ()) != NULL)
-		hal_initialised = 1; /* if 0, fall back to polling sysfs */
+		udev_initialised = 1; /* if 0, fall back to polling sysfs */
+#else
+# ifdef WITH_GUDEV
+	gpilotd_gudev_init();
+	udev_initialised = 1;
+# endif
 #endif
+
 	
         daemon->priv = GPILOT_DAEMON_GET_PRIVATE (daemon);
 
diff --git a/help/C/gnome-pilot.xml b/help/C/gnome-pilot.xml
index e59acc9..cc9ac24 100644
--- a/help/C/gnome-pilot.xml
+++ b/help/C/gnome-pilot.xml
@@ -1,7 +1,7 @@
 <?xml version='1.0' ?>
 
-<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" 
- "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd"; [
+<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN" 
+ "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd"; [
 
 <!ENTITY appversion "2.0">
 <!ENTITY docversion "2.0.1">
@@ -12,7 +12,11 @@
 <article id="index">
   <articleinfo>
     <title>GNOME PalmOS Synchronization Tools</title>
-    <abstract role="description">A user's guide to the gnome-pilot tools for use with PalmOS handheld devices.</abstract>
+    <abstract role="description">
+	<para>
+	A user's guide to the gnome-pilot tools for use with PalmOS handheld devices.
+	</para>
+    </abstract>
     
     <authorgroup>
       <author><firstname>Aaron</firstname><surname>Weber</surname></author>



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