Re: gnome-pilot-2.0.14pre4 testing and fixes



--- Matt Davey <mcdavey mrao cam ac uk> wrote:
> On Mon, 2006-05-29 at 12:34 -0700, Nathan Owens wrote:
> > I also had to get a file from HAL's CVS repository: classdev.c. Without it, HAL 0.5.7 would
> > recognize the device, but fail to probe it (you can't probe a USB device using a serial probe
> > method). While I think gpilotd would still have worked (I found the HAL change before the
> > gpilotd changes), I think it's wise to use a CVS version of HAL if possible.

I've played around with some different versions of HAL, and the CVS classdev.c is definitely
necessary to get HAL working. It also requires a modified PDA .fdi file. I've attached the
modified .fdi file. The classdev.c file can be gotten from HAL CVS:
http://webcvs.freedesktop.org/hal/hal/hald/linux2/.

The classdev.c file made it possible for PDAs to be seen properly. The fdi file populated the
necessary data fields so that gnome-pilot can use them. The code I've implemented (see attached
patch) uses the capabilities to find the PDA. I've also added a "use_net" member to the PDA
structure so that the PDAs that don't support Network Sync work as before. I can then determine
the device to use (/dev/ttyUSB[01]) from the serial.device member. Since most devices use
/dev/ttyUSB1, I've made this the default for all unknown PDAs. For the few PDAs that requires
/dev/ttyUSB0 as their device, I'd made that specifically their default port. By default, unknown
PDAs support Network Sync as well, since only the very early PDAs don't support this feature.

The code I've attached is really just to play around with and get a feel for how HAL *should* work
with gnome-pilot. Of course, since the latest version of HAL doesn't support the PDA to where we'd
like it, I have to agree with the decision to continue using devices.xml. Maybe later we can make
this work if HAL 0.5.8 or higher is used.

Let me know what you think of the ideas in the code and the fdi file. I'd like to get a new fdi
file submitted to the HAL developers in time for their next release so that we can implement the
full functionality of HAL when 0.5.8 or higher is used.

With regards to libusb: would gnome-pilot have to implement that, or is that something pilot-link
will implement? I've taken a brief look at libusb, but that's about it.


> > With these changes to gpilotd, I have had no troubles whatsoever in synchronizing. The only
> > conduit I'm currently able to use is the backup one, as the other conduits have not been
> > converted to the new API. Matt, will you be converting these?
> 
> I haven't looked into it, to be honest.  I know jpr committed
> contributed patches for 0.12 conversion to gnome-pilot-conduits back in
> November last year so it shouldn't be in bad shape.  Fedora was shipping
> an 0.12 based gnome-pilot (don't mention the war...) so at least had
> compilation working.  I haven't tested how complete that all is, so any
> work here would be good.
>
> > Also, the Evolution conduits will need to be converted. I believe there's a patch for the
> > EAddress conduit floating around out there right now. I plan on doing those conduits myself,
> > since I use Evolution a lot and I haven't seen any talk about them on the evo-hackers list
> > lately.
> 
> Again, the fedora effort should have seen some work here, even if
> incomplete.

I've looked at them (thanks for the reference), and it looks like a good start. I'll probably be
working on the various conduits over the next week or two. Shouldn't be too hard given these
references.

In the future, I'd like to get rid of the old char buffers and start using the new pi_buffer API.
While they're essentially the same in use, using pi_buffer will cut out the conversions between
the char buffers and pi_buffer structures that currently has to be done. For 2.0.14, it's still
probably best to use the old char buffers since 0.12 isn't released yet (and they DO work). For
2.0.15, I'd like to see if the pi_buffers can replace the char buffers.


> > Let me know what you think of the patch. I'll let the list know if I find anything else.
> 
> The patch is great.  I'll commit it asap.

Thanks for committing it. pre5 has been working well for me (at least the backup-conduit has -
haven't had a chance to port the other conduits)

Thanks,
Nathan Owens

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
Index: capplet/pilot.c
===================================================================
RCS file: /cvs/gnome/gnome-pilot/capplet/pilot.c,v
retrieving revision 1.29
diff -u -r1.29 pilot.c
--- capplet/pilot.c	1 Feb 2006 22:03:55 -0000	1.29
+++ capplet/pilot.c	27 Jun 2006 01:34:02 -0000
@@ -88,8 +88,12 @@
 {
     g_list_foreach (state->pilots,(GFunc)gpilot_pilot_free, NULL);
     g_list_free (state->pilots);
+    state->pilots = NULL;
+    
     g_list_foreach (state->devices,(GFunc)gpilot_device_free, NULL);
     g_list_free (state->devices);
+    state->devices = NULL;
+    
     g_free (state);
 }
 
Index: gpilotd/gnome-pilot-structures.c
===================================================================
RCS file: /cvs/gnome/gnome-pilot/gpilotd/gnome-pilot-structures.c,v
retrieving revision 1.17
diff -u -r1.17 gnome-pilot-structures.c
--- gpilotd/gnome-pilot-structures.c	1 Jun 2006 09:43:39 -0000	1.17
+++ gpilotd/gnome-pilot-structures.c	27 Jun 2006 01:34:03 -0000
@@ -321,7 +321,11 @@
 		pi_close (device->fd);
 	}
 	g_free (device->name);
+	device->name = NULL;
+	
 	g_free (device->port);
+	device->port = NULL;
+	
 	gpilot_hdb_uucp_unlock (device);
 }
 
@@ -470,6 +474,7 @@
 	}
 
 	g_free(device->ip);
+	device->ip = NULL;
 }
 
 static void
@@ -704,12 +709,24 @@
 {
 	gchar *prefix;
 
+	if(pilot == NULL){
+		return; /* Can't do anything */
+	}
+
 	/* set up stuff  */
 	g_free (pilot->name);
+	pilot->name = NULL;
+	
 	g_free (pilot->passwd);
+	pilot->passwd = NULL;
+	
 	g_free (pilot->pilot_username);
+	pilot->pilot_username = NULL;
+	
 	g_list_foreach (pilot->trusted_users, (GFunc) g_free, NULL);
 	g_list_free (pilot->trusted_users);
+	pilot->trusted_users = NULL;
+	
 	prefix = g_strdup_printf ("/gnome-pilot.d/gpilotd/Pilot%d/", i);
 	gnome_config_push_prefix (prefix);
 
@@ -732,11 +749,21 @@
 gpilot_pilot_free (GPilotPilot *pilot)
 {
 	g_free (pilot->name);
+	pilot->name = NULL;
+	
 	g_free (pilot->passwd);
+	pilot->passwd = NULL;
+	
 	g_free (pilot->pilot_username);
+	pilot->pilot_username = NULL;
+	
 	g_free (pilot->sync_options.basedir);
+	pilot->sync_options.basedir = NULL;
+	
 	g_list_foreach (pilot->trusted_users, (GFunc) g_free, NULL);
 	g_list_free (pilot->trusted_users);
+	pilot->trusted_users = NULL;
+	
 	g_free (pilot);
 }
 
@@ -754,6 +781,7 @@
 gpilot_user_free (GPilotUser *user)
 {
 	g_free (user->username);
+	user->username = NULL;
 	g_free (user);
 }
  
Index: gpilotd/gpilotd.c
===================================================================
RCS file: /cvs/gnome/gnome-pilot/gpilotd/gpilotd.c,v
retrieving revision 1.156
diff -u -r1.156 gpilotd.c
--- gpilotd/gpilotd.c	2 Jun 2006 08:37:37 -0000	1.156
+++ gpilotd/gpilotd.c	27 Jun 2006 01:34:04 -0000
@@ -86,7 +86,7 @@
 static LibHalContext *gpilotd_hal_init (void);
 #endif
 static guint visor_timeout_id = -1;
-static guint hal_initialised = 0;
+static gboolean hal_initialised = FALSE;
 
 
 /* Set to true when the config should be reloaded */
@@ -955,9 +955,7 @@
 static void
 hal_device_added (LibHalContext *ctx, const char *udi)
 {
-	gboolean visor_net = FALSE;
-	char *bus, *match_str;
-	int vendor_id, product_id, i;
+	dbus_bool_t visor_net = FALSE;
 	GPilotDevice *device;
 	DBusError error;
 	GList *dev;
@@ -965,54 +963,70 @@
 	if (context->paused) 
 		return;
 
-	load_devices_xml ();
-
 	/* HAL match rule: we look for info.bus == 'usb_device'
 	 * and then try to match the usb_device.product_id and usb_device.vendor_id
 	 * against the list in devices.xml.
 	 */
-	if (!(bus = libhal_device_get_property_string (hal_ctx, udi, "info.bus", NULL)))
-		return;
-	if (strcmp (bus, "usb_device") != 0) {
-		libhal_free_string (bus);
-		return;
-	}
-
-	dbus_error_init (&error);
-	vendor_id = libhal_device_get_property_int (hal_ctx, udi,
-	    "usb_device.vendor_id", &error);
-	if(vendor_id == -1) {
-		g_warning ("Could not get usb vendor ID from hal: %s", error.message);
-		return;
-	}
-	product_id = libhal_device_get_property_int (hal_ctx, udi,
-	    "usb_device.product_id", NULL);
-	if(product_id == -1) {
-		g_warning ("Could not get usb product ID from hal: %s", error.message);
-		return;
+	
+	if(libhal_device_query_capability(hal_ctx, udi, "pda", NULL) == FALSE){
+		g_message("no capabilities found, HAL UDI: %s\n", udi);
+		return; /* Didn't find capability */
 	}
 	
-	/* 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;
+	g_message("capabilities found\nHAL UDI: %s", udi);
+
+	/* If we can't get pda.palm.use_net, then visor_net will be FALSE */
+	visor_net = libhal_device_get_property_bool(hal_ctx, udi,
+			"pda.palm.use_net", NULL);
+			
+	g_message("use Net? %s", (visor_net == TRUE) ? "TRUE" : "FALSE");
 
-	visor_net = g_array_index (product_net, gboolean, i);
 	dev = context->devices;
 	while (dev != NULL) {
 		device = dev->data;
 		if (device->type == PILOT_DEVICE_USB_VISOR) {
+			char *dev_location = NULL;
+			
 			if (!visor_net)
 				device->type = PILOT_DEVICE_SERIAL;
 			
+
+			dbus_error_init(&error);
+			dev_location = libhal_device_get_property_string(
+						hal_ctx, udi,
+						"serial.device",
+						&error);
+
+			if(dev_location == NULL || dbus_error_is_set(&error)){
+				g_warning ("Could not get HotSync device from HAL: %s", error.message);
+				dbus_error_free(&error);
+				if(dev_location != NULL){
+					libhal_free_string(dev_location);
+				}
+				return;
+			}
+
+			dbus_error_free(&error);
+			if(device->port != NULL){
+				/* 
+				 * initialized by gnome-pilot-structures.c.
+				 * If hal is initialized, we shouldn't use
+				 * the pre-initialized port for the device.
+				 */
+				g_free(device->port);
+				device->port = NULL;
+			}
+
+			device->port = dev_location;
+			
 			/* just try to sync.  Until I can talk to 
 			 * the kernel guys this is the best way to 
 			 * go. */
 			sync_device (device, context);
 
+			libhal_free_string(device->port);
+			device->port = dev_location = NULL;
+
 			if (!visor_net)
 				device->type = PILOT_DEVICE_USB_VISOR;
 			
@@ -1026,7 +1040,9 @@
 static void
 hal_device_removed (LibHalContext *ctx, const char *udi)
 {
-	
+	/* we should probably kill the sync here if one is going on (i.e. the
+	 * user removed the PDA before the HotSync was completed).
+	 * Don't know quite how yet, but it's something to think about. */
 }
 
 static gboolean
@@ -1363,7 +1379,12 @@
 	if (dev->type == PILOT_DEVICE_NETWORK) {
 		g_message (_("Watching %s (%s)"), dev->name, dev->ip);
 	} else {
-		g_message (_("Watching %s (%s)"), dev->name, dev->port);
+		if(hal_initialised){
+			g_message (_("Watching %s"), dev->name);
+		}
+		else {
+			g_message (_("Watching %s (%s)"), dev->name, dev->port);
+		}
 	}
 }
 
@@ -1525,7 +1546,7 @@
 
 #ifdef WITH_HAL
 	if ((hal_ctx = gpilotd_hal_init ()) != NULL)
-		hal_initialised = 1; /* if 0, fall back to polling sysfs */
+		hal_initialised = TRUE; /* if FALSE, fall back to polling sysfs */
 #endif
 	
 	/* Setup the correct gpilotd.pid file */
Index: gpilotd/manager.c
===================================================================
RCS file: /cvs/gnome/gnome-pilot/gpilotd/manager.c,v
retrieving revision 1.80
diff -u -r1.80 manager.c
--- gpilotd/manager.c	1 Jun 2006 09:43:39 -0000	1.80
+++ gpilotd/manager.c	27 Jun 2006 01:34:04 -0000
@@ -321,6 +321,9 @@
 		if (result < 0) {
 			/* is <0, there are no more databases, break
                            out so we can save the list */
+#ifdef PILOT_LINK_0_12
+			pi_buffer_free(pi_buf);
+#endif
 			g_free (dbinfo);
 			break;
 		}

Attachment: 10-usb-pda.fdi
Description: 1266591139-10-usb-pda.fdi



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