Various stuff, including Chris' patches to timeout defaults.
diff --git a/AUTHORS b/AUTHORS
index 0bebae8..62a0c71 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -31,3 +31,4 @@
 Jeff Mitchell <kde-dev@emailgoeshere.com>
 Johannes Huber <johub1180@gmx.at>
 Alistair Boyle <alistair.js.boyle@gmail.com>
+Chris Bagwell <chris@cnpbagwell.com>
diff --git a/ChangeLog b/ChangeLog
index 884b457..f5a91b9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2008-08-30  Chris Bagwell <chris@cnpbagwell.com>
+
+	* src/libusb-glue.c: make it possible to have per-command
+	  or otherwise altered timeout values for different PTP
+	  request/response sequences.
+	* src/libusb-glue.h: dito.
+	* src/libmtp.c: increase USB timeout to 30s when getting
+	  a complete track listing off the device.
+	* src/music-players.h: as a consequence, the Sirus Stiletto
+	  no longer needs any brokenness flag.
+
+2008-08-30  Linus Walleij <triad@df.lth.se>
+
+	* src/ptp.c: sync to upstream.
+
 2008-08-28  Linus Walleij <triad@df.lth.se>
 
 	* examples/sendtr.c: fix non-strdup():ed strings to be
diff --git a/examples/sendtr.c b/examples/sendtr.c
index b27ac4d..1cb2cf7 100644
--- a/examples/sendtr.c
+++ b/examples/sendtr.c
@@ -367,7 +367,6 @@
   uint16_t length = 0;
   uint16_t year = 0;
   uint16_t quiet = 0;
-  char *lang;
   while ( (opt = getopt(argc, argv, "qD:t:a:A:w:l:c:g:n:d:y:")) != -1 ) {
     switch (opt) {
     case 't':
diff --git a/src/libmtp.c b/src/libmtp.c
index 3fe06bf..2ea7261 100644
--- a/src/libmtp.c
+++ b/src/libmtp.c
@@ -1311,8 +1311,26 @@
   MTPProperties  *props = NULL;
   MTPProperties  *prop;
   uint16_t       ret;
+  int            oldtimeout;
+  PTP_USB *ptp_usb = (PTP_USB*) device->usbinfo;
+
+  /* The follow request causes the device to generate
+   * a list of very file on the device and return it
+   * in a single response.
+   *
+   * Some slow devices as well as devices with very
+   * large file systems can easily take longer then
+   * the standard timeout value before it is able
+   * to return a response.
+   *
+   * Temporarly set timeout to allow working with
+   * widest range of devices.
+   */
+  get_usb_device_timeout(ptp_usb, &oldtimeout);
+  set_usb_device_timeout(ptp_usb, 60000);
   
   ret = ptp_mtp_getobjectproplist(params, 0xffffffff, &props, &nrofprops);
+  set_usb_device_timeout(ptp_usb, oldtimeout);
 
   if (ret == PTP_RC_MTP_Specification_By_Group_Unsupported) {
     // What's the point in the device implementing this command if 
diff --git a/src/libusb-glue.c b/src/libusb-glue.c
index 6e866c4..92e72ef 100644
--- a/src/libusb-glue.c
+++ b/src/libusb-glue.c
@@ -6,6 +6,7 @@
  * Copyright (C) 2005-2008 Linus Walleij <triad@df.lth.se>
  * Copyright (C) 2006-2007 Marcus Meissner
  * Copyright (C) 2007 Ted Bullock
+ * Copyright (C) 2008 Chris Bagwell <chris@cnpbagwell.com>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -45,11 +46,14 @@
 /* To enable debug prints, switch on this */
 //#define ENABLE_USB_BULK_DEBUG
 
-/* this must not be too short - the original 4000 was not long
-   enough for big file transfers. I imagine the player spends a 
-   bit of time gearing up to receiving lots of data. This also makes
-   connecting/disconnecting more reliable */
-#define USB_TIMEOUT		10000
+/* Default USB timeout length.  This can be overridden as needed
+ * but should start with a reasonable value so most common 
+ * requests can be completed.  The original value of 4000 was
+ * not long enough for large file transfer.  Also, players can
+ * spend a bit of time collecting data.  Higher values also
+ * make connecting/disconnecting more reliable.
+ */
+#define USB_TIMEOUT_DEFAULT     10000
 
 /* USB control message data phase direction */
 #ifndef USB_DP_HTD
@@ -282,7 +286,7 @@
 			 4,
 			 (char *) buf,
 			 sizeof(buf),
-			 USB_TIMEOUT);
+                         USB_TIMEOUT_DEFAULT);
 
   // Dump it, if requested
   if (dumpfile != NULL && ret > 0) {
@@ -315,7 +319,7 @@
 			 5,
 			 (char *) buf,
 			 sizeof(buf),
-			 USB_TIMEOUT);
+                         USB_TIMEOUT_DEFAULT);
 
   // Dump it, if requested
   if (dumpfile != NULL && ret > 0) {
@@ -690,7 +694,7 @@
 #ifdef ENABLE_USB_BULK_DEBUG
     printf("Reading in 0x%04lx bytes\n", toread);
 #endif
-    result = USB_BULK_READ(ptp_usb->handle, ptp_usb->inep, (char*)bytes, toread, USB_TIMEOUT);
+    result = USB_BULK_READ(ptp_usb->handle, ptp_usb->inep, (char*)bytes, toread, ptp_usb->timeout);
 #ifdef ENABLE_USB_BULK_DEBUG
     printf("Result of read: 0x%04x\n", result);
 #endif
@@ -755,7 +759,7 @@
     printf("<==USB IN\n");
     printf("Zero Read\n");
 #endif
-    zeroresult = USB_BULK_READ(ptp_usb->handle, ptp_usb->inep, &temp, 0, USB_TIMEOUT);
+    zeroresult = USB_BULK_READ(ptp_usb->handle, ptp_usb->inep, &temp, 0, ptp_usb->timeout);
     if (zeroresult != 0)
       printf("LIBMTP panic: unable to read in zero packet, response 0x%04x", zeroresult);
   }
@@ -796,7 +800,7 @@
       }
     }
     handler->getfunc(NULL, handler->private,towrite,bytes,&towrite);
-    result = USB_BULK_WRITE(ptp_usb->handle,ptp_usb->outep,(char*)bytes,towrite,USB_TIMEOUT);
+    result = USB_BULK_WRITE(ptp_usb->handle,ptp_usb->outep,(char*)bytes,towrite,ptp_usb->timeout);
 #ifdef ENABLE_USB_BULK_DEBUG
     printf("USB OUT==>\n");
     data_dump_ascii (stdout,bytes,towrite,16);
@@ -841,7 +845,7 @@
       printf("USB OUT==>\n");
       printf("Zero Write\n");
 #endif
-      result=USB_BULK_WRITE(ptp_usb->handle,ptp_usb->outep,(char *)"x",0,USB_TIMEOUT);
+      result=USB_BULK_WRITE(ptp_usb->handle,ptp_usb->outep,(char *)"x",0,ptp_usb->timeout);
     }
   }
     
@@ -1213,7 +1217,7 @@
 		  // need to read in extra byte and discard it
 		  int result = 0;
 		  char byte = 0;
-		  result = USB_BULK_READ(ptp_usb->handle, ptp_usb->inep, &byte, 1, USB_TIMEOUT);
+                  result = USB_BULK_READ(ptp_usb->handle, ptp_usb->inep, &byte, 1, ptp_usb->timeout);
 		  
 		  if (result != 1)
 		    printf("Could not read in extra byte for PTP_USB_BULK_HS_MAX_PACKET_LEN_READ long file, return value 0x%04x\n", result);
@@ -1224,7 +1228,7 @@
 #ifdef ENABLE_USB_BULK_DEBUG
 		  printf("Reading in zero packet after header\n");
 #endif
-		  zeroresult = USB_BULK_READ(ptp_usb->handle, ptp_usb->inep, &zerobyte, 0, USB_TIMEOUT);
+                  zeroresult = USB_BULK_READ(ptp_usb->handle, ptp_usb->inep, &zerobyte, 0, ptp_usb->timeout);
 		  
 		  if (zeroresult != 0)
 		    printf("LIBMTP panic: unable to read in zero packet, response 0x%04x", zeroresult);
@@ -1333,15 +1337,15 @@
 	ret = PTP_RC_OK;
 	switch(wait) {
 	case PTP_EVENT_CHECK:
-		result=USB_BULK_READ(ptp_usb->handle, ptp_usb->intep,(char *)&usbevent,sizeof(usbevent),USB_TIMEOUT);
+                result=USB_BULK_READ(ptp_usb->handle, ptp_usb->intep,(char *)&usbevent,sizeof(usbevent),ptp_usb->timeout);
 		if (result==0)
-			result = USB_BULK_READ(ptp_usb->handle, ptp_usb->intep,(char *) &usbevent, sizeof(usbevent), USB_TIMEOUT);
+                        result = USB_BULK_READ(ptp_usb->handle, ptp_usb->intep,(char *) &usbevent, sizeof(usbevent), ptp_usb->timeout);
 		if (result < 0) ret = PTP_ERROR_IO;
 		break;
 	case PTP_EVENT_CHECK_FAST:
-		result=USB_BULK_READ(ptp_usb->handle, ptp_usb->intep,(char *)&usbevent,sizeof(usbevent),USB_TIMEOUT);
+                result=USB_BULK_READ(ptp_usb->handle, ptp_usb->intep,(char *)&usbevent,sizeof(usbevent),ptp_usb->timeout);
 		if (result==0)
-			result = USB_BULK_READ(ptp_usb->handle, ptp_usb->intep,(char *) &usbevent, sizeof(usbevent), USB_TIMEOUT);
+                        result = USB_BULK_READ(ptp_usb->handle, ptp_usb->intep,(char *) &usbevent, sizeof(usbevent), ptp_usb->timeout);
 		if (result < 0) ret = PTP_ERROR_IO;
 		break;
 	default:
@@ -1392,7 +1396,7 @@
 	htod32a(&buffer[2],transactionid);
 	ret = usb_control_msg(ptp_usb->handle, 
 			      USB_TYPE_CLASS | USB_RECIP_INTERFACE,
-			      0x64, 0x0000, 0x0000, (char *) buffer, sizeof(buffer), USB_TIMEOUT);
+                              0x64, 0x0000, 0x0000, (char *) buffer, sizeof(buffer), ptp_usb->timeout);
 	if (ret < sizeof(buffer))
 		return PTP_ERROR_IO;
 	return PTP_RC_OK;
@@ -1417,6 +1421,8 @@
    */
   params->byteorder = PTP_DL_LE;
   
+  ptp_usb->timeout = USB_TIMEOUT_DEFAULT;
+  
   if ((device_handle = usb_open(dev))){
     if (!device_handle) {
       perror("usb_open()");
@@ -1715,17 +1721,27 @@
   close_usb(ptp_usb);
 }
 
+void set_usb_device_timeout(PTP_USB *ptp_usb, int timeout)
+{
+    ptp_usb->timeout = timeout;
+}
+
+void get_usb_device_timeout(PTP_USB *ptp_usb, int *timeout)
+{
+    *timeout = ptp_usb->timeout;
+}
+
 static int usb_clear_stall_feature(PTP_USB* ptp_usb, int ep)
 {
   
   return (usb_control_msg(ptp_usb->handle,
 			  USB_RECIP_ENDPOINT, USB_REQ_CLEAR_FEATURE, USB_FEATURE_HALT,
-			  ep, NULL, 0, USB_TIMEOUT));
+                          ep, NULL, 0, ptp_usb->timeout));
 }
 
 static int usb_get_endpoint_status(PTP_USB* ptp_usb, int ep, uint16_t* status)
 {
   return (usb_control_msg(ptp_usb->handle,
 			  USB_DP_DTH|USB_RECIP_ENDPOINT, USB_REQ_GET_STATUS,
-			  USB_FEATURE_HALT, ep, (char *)status, 2, USB_TIMEOUT));
+                          USB_FEATURE_HALT, ep, (char *)status, 2, ptp_usb->timeout));
 }
diff --git a/src/libusb-glue.h b/src/libusb-glue.h
index 2fa6472..469a843 100644
--- a/src/libusb-glue.h
+++ b/src/libusb-glue.h
@@ -6,6 +6,7 @@
  * Copyright (C) 2005-2007 Linus Walleij <triad@df.lth.se>
  * Copyright (C) 2006-2007 Marcus Meissner
  * Copyright (C) 2007 Ted Bullock
+ * Copyright (C) 2008 Chris Bagwell <chris@cnpbagwell.com>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -48,6 +49,7 @@
   int outep;
   int outep_maxpacket;
   int intep;
+  int timeout;
   /** File transfer callbacks and counters */
   int callback_active;
   uint64_t current_transfer_total;
@@ -65,6 +67,8 @@
 LIBMTP_error_number_t configure_usb_device(LIBMTP_raw_device_t *device, 
 					   PTPParams *params,
 					   void **usbinfo);
+void set_usb_device_timeout(PTP_USB *ptp_usb, int timeout);
+void get_usb_device_timeout(PTP_USB *ptp_usb, int *timeout);
 
 /* Flag check macros */
 #define FLAG_BROKEN_MTPGETOBJPROPLIST_ALL(a) \
diff --git a/src/music-players.h b/src/music-players.h
index 2d6a420..2a2d355 100644
--- a/src/music-players.h
+++ b/src/music-players.h
@@ -429,9 +429,7 @@
    */
   { "Sirius", 0x18f6, "Stiletto", 0x0102, DEVICE_FLAG_NONE },
   // Reported by Chris Bagwell <chris@cnpbagwell.com>
-  // Apparently this comes with a firmware upgrade to the original
-  // Stiletto as well.
-  { "Sirius", 0x18f6, "Stiletto 2", 0x0110, DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST_ALL },
+  { "Sirius", 0x18f6, "Stiletto 2", 0x0110, DEVICE_FLAG_NONE },
 
   /*
    * Canon
diff --git a/src/ptp.c b/src/ptp.c
index dcae3f8..82e87ec 100644
--- a/src/ptp.c
+++ b/src/ptp.c
@@ -3235,8 +3235,7 @@
 		{PTP_DPC_CANON_EZoomSizeOfTele,	N_("EZoom Size of Tele")},
 		{PTP_DPC_CANON_PhotoEffect,	N_("Photo Effect")},
 		{PTP_DPC_CANON_AssistLight,	N_("Assist Light")},
-		{PTP_DPC_CANON_FlashQuantityCount,	N_("Flash Quanity Count")},
-		{PTP_DPC_CANON_FlashQuantityCount,	N_("Flash Quanity Count")},
+		{PTP_DPC_CANON_FlashQuantityCount,	N_("Flash Quantity Count")},
 		{PTP_DPC_CANON_RotationAngle,	N_("Rotation Angle")},
 		{PTP_DPC_CANON_RotationScene,	N_("Rotation Scene")},
 		{PTP_DPC_CANON_EventEmulateMode,N_("Event Emulate Mode")},