More verbose descriptor dump
diff --git a/ChangeLog b/ChangeLog
index d343ecd..c9305e1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2007-07-11  Linus Walleij <[email protected]>
+
+	* src/libmtp.c: put in Tero's name in the preamble.
+	* src/libusb-glue.c: make the dump function sump out the zuper zecret
+	  devize dezcriptorz in clear text hex.
+
 2007-07-10  Linus Walleij <[email protected]>
 
 	* examples/hotplug.c: force HAL OGG support on iriver devices. They all 
diff --git a/logs/mtp-detect-creative-zen-micro.txt b/logs/mtp-detect-creative-zen-micro.txt
index 57e8aae..0d05642 100644
--- a/logs/mtp-detect-creative-zen-micro.txt
+++ b/logs/mtp-detect-creative-zen-micro.txt
@@ -1,3 +1,5 @@
+libmtp version: 0.1.5
+
 Attempting to connect device(s)
 Detect: Successfully connected 1 devices
 USB low-level info:
@@ -11,6 +13,17 @@
    IN endpoint maxpacket: 512 bytes
    OUT endpoint maxpacket: 512 bytes
    Device flags: 0x00000000
+Microsoft device descriptor 0xee:
+	0000: 1203 4d00 5300 4600 5400 3100 3000 3000	..M.S.F.T.1.0.0.
+	0010: fe00                                   	..
+Microsoft device response to control message 1, CMD 0xfe:
+	0000: 2800 0000 0001 0400 0100 0000 0000 0000	(...............
+	0010: 0001 4d54 5000 0000 0000 0000 0000 0000	..MTP...........
+	0020: 0000 0000 0000 0000                    	........
+Microsoft device response to control message 2, CMD 0xfe:
+	0000: 2800 0000 0001 0400 0100 0000 0000 0000	(...............
+	0010: 0001 4d54 5000 0000 0000 0000 0000 0000	..MTP...........
+	0020: 0000 0000 0000 0000                    	........
 Device info:
    Manufacturer: Creative Technology Ltd
    Model: Creative Zen Micro
@@ -221,7 +234,7 @@
 MTP-specific device properties:
    Friendly name: Dokktor Lajban
    Synchronization partner: (NULL)
-   Battery level 206 of 255 (80%)
+   Battery level 252 of 255 (98%)
 libmtp supported (playable) filetypes:
    ISO MPEG-1 Audio Layer 3
    Microsoft Windows Media Audio
@@ -232,7 +245,7 @@
    Firmware file
 
 Secure Time:
-<DRMCLOCK type="status"><VALUE>#20050509 17:21:30Z#</VALUE><FLAG>DRM_CLK_NOT_SET</FLAG></DRMCLOCK>
+<DRMCLOCK type="status"><VALUE>#20050705 14:19:02Z#</VALUE><FLAG>DRM_CLK_NOT_SET</FLAG></DRMCLOCK>
 
 Device Certificate:
 <DEVCERT version="1.0"><CERTIFICATE type="DEVICE"><DATA><UNIQUEID private="1">AQUlUcYDj4K8Fxk2xgOPggAAAAA=</UNIQUEID><PUBLICKEY private="1">k912GjDbPJaNV6m2b+Ao7I6gERKu9q/HknX/Xk6Eof7RGsti0t8vKg==</PUBLICKEY><KEYDATA>UUBc4Bwahh3pLnmKCYNybLhvvDo=</KEYDATA></DATA><MSDRM_SIGNATURE_VALUE>C1S5c4HGU1qbAVsuYaL93PSPXS/c27En5jtyJb7CdQmS0lFgA08pBg==</MSDRM_SIGNATURE_VALUE><SYMSIGNATURE>YghjWMJr8V1Uo4n+quT/C7TNMWk=</SYMSIGNATURE></CERTIFICATE><FALLBACK><SECURITYVERSION>2.4.101.71</SECURITYVERSION><CERTIFICATE private="1">k912GjDbPJaNV6m2b+Ao7I6gERKu9q/HknX/Xk6Eof7RGsti0t8vKgIEZUfAbNZ0RU3logPBMUDW1Nwms7RvhZXdHSetXBT5t7zEnMSty5/eDVJV</CERTIFICATE></FALLBACK><CERTIFICATE type="GROUP"><DATA><NAME>Creative Zen Micro</NAME>

diff --git a/src/libmtp.c b/src/libmtp.c
index 63b8907..cbb6695 100644
--- a/src/libmtp.c
+++ b/src/libmtp.c
@@ -3,7 +3,8 @@
  *
  * Copyright (C) 2005-2007 Linus Walleij <[email protected]>
  * Copyright (C) 2005-2007 Richard A. Low <[email protected]>
- * Copyright (C) 2007 Ted Bullock
+ * Copyright (C) 2007 Ted Bullock <[email protected]>
+ * Copyright (C) 2007 Tero Saarni <[email protected]>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -1104,7 +1105,6 @@
       }
       prop = prop->next;
   }
-  printf("Fast directory retrieveal, found %d objects\n", cnt);
   lasthandle = 0xffffffff;
   params->objectinfo = malloc (sizeof (PTPObjectInfo) * cnt);
   memset (params->objectinfo, 0, sizeof(PTPObjectInfo) * cnt);
diff --git a/src/libusb-glue.c b/src/libusb-glue.c
index 226918e..cf9862c 100644
--- a/src/libusb-glue.c
+++ b/src/libusb-glue.c
@@ -465,11 +465,17 @@
 }
 
 /**
- * This checks if a device has an MTP descriptor.
+ * This checks if a device has an MTP descriptor. The descriptor was
+ * elaborated about in gPhoto bug 1482084, and some official documentation
+ * with no strings attached was published by Microsoft at
+ * http://www.microsoft.com/whdc/system/bus/USB/USBFAQ_intermed.mspx#E3HAC
+ *
  * @param dev a device struct from libusb.
+ * @param dumpfile set to non-NULL to make the descriptors dump out
+ *        to this file in human-readable hex so we can scruitinze them.
  * @return 1 if the device is MTP compliant, 0 if not.
  */
-static int device_has_descriptor(struct usb_device *dev)
+static int probe_device_descriptor(struct usb_device *dev, FILE *dumpfile)
 {
   usb_dev_handle *devh;
   unsigned char buf[1024], cmd;
@@ -489,6 +495,12 @@
   
   /* Read the special descriptor */
   ret = usb_get_descriptor(devh, 0x03, 0xee, buf, sizeof(buf));
+
+  // Dump it, if requested
+  if (dumpfile != NULL && ret > 0) {
+    fprintf(dumpfile, "Microsoft device descriptor 0xee:\n");
+    data_dump_ascii(dumpfile, buf, ret, 16);
+  }
   
   /* Check if descriptor length is at least 10 bytes */
   if (ret < 10) {
@@ -513,6 +525,12 @@
 			 (char *) buf,
 			 sizeof(buf),
 			 1000);
+
+  // Dump it, if requested
+  if (dumpfile != NULL && ret > 0) {
+    fprintf(dumpfile, "Microsoft device response to control message 1, CMD 0x%02x:\n", cmd);
+    data_dump_ascii(dumpfile, buf, ret, 16);
+  }
   
   /* If this is true, the device either isn't MTP or there was an error */
   if (ret <= 0x15) {
@@ -540,6 +558,12 @@
 			 (char *) buf,
 			 sizeof(buf),
 			 1000);
+
+  // Dump it, if requested
+  if (dumpfile != NULL && ret > 0) {
+    fprintf(dumpfile, "Microsoft device response to control message 2, CMD 0x%02x:\n", cmd);
+    data_dump_ascii(dumpfile, buf, ret, 16);
+  }
   
   /* If this is true, the device errored against control message 2 */
   if (ret == -1) {
@@ -593,7 +617,7 @@
   for (; bus != NULL; bus = bus->next) {
     struct usb_device *dev = bus->devices;
     for (; dev != NULL; dev = dev->next) {
-      if (device_has_descriptor(dev)) {
+      if (probe_device_descriptor(dev, NULL)) {
 	/* Append this usb device to the MTP USB Device List */
 	*mtp_device_list = append_to_mtpdevice_list(*mtp_device_list, dev);
       } else {
@@ -678,6 +702,7 @@
   printf("   OUT endpoint maxpacket: %d bytes\n", ptp_usb->outep_maxpacket);
   printf("   Device flags: 0x%08x\n", ptp_usb->device_flags);
   // TODO: add in string dumps for iManufacturer, iProduct, iSerialnumber...
+  (void) probe_device_descriptor(dev, stdout);
 }
 
 static void