Include some patch from Marcus
diff --git a/ChangeLog b/ChangeLog
index 6930eaf..3847c30 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2009-05-09  Linus Walleij <triad@df.lth.se>
+
+	* src/libmtp.c: include <config.h> for iconv() compatibility.
+	* src/unicode.c: dito. NOTE: this file needs fixing to work
+	  without iconv!
+	* src/ptp.h: sync to upstream and get all the embedded support
+	  for FREE!
+	* src/ptp.c: dito.
+	* src/ptp-pack.c: dito.
+
 2009-05-06  Linus Walleij <triad@df.lth.se>
 
 	* src/ptp.h: sync to upstream.
diff --git a/src/libmtp.c b/src/libmtp.c
index 7ab0506..5343a25 100644
--- a/src/libmtp.c
+++ b/src/libmtp.c
@@ -37,6 +37,7 @@
 #define _LARGEFILE_SOURCE
 #define _LARGEFILE64_SOURCE
 
+#include <config.h>
 #include "libmtp.h"
 #include "unicode.h"
 #include "ptp.h"
diff --git a/src/ptp-pack.c b/src/ptp-pack.c
index a72c91e..14ab38d 100644
--- a/src/ptp-pack.c
+++ b/src/ptp-pack.c
@@ -1,6 +1,8 @@
 /* currently this file is included into ptp.c */
 
+#ifdef HAVE_ICONV
 #include <iconv.h>
+#endif
 
 extern void
 ptp_debug (PTPParams *params, const char *format, ...);
@@ -122,8 +124,11 @@
 	srclen = length * sizeof(string[0]);
 	dest = loclstr;
 	destlen = sizeof(loclstr)-1;
+	nconv = (size_t)-1;
+#ifdef HAVE_ICONV
 	nconv = iconv(params->cd_ucs2_to_locale, &src, &srclen, 
 			&dest, &destlen);
+#endif
 	if (nconv == (size_t) -1) { /* do it the hard way */
 		int i;
 		/* try the old way, in case iconv is broken */
@@ -157,17 +162,30 @@
 	int packedlen;
 	uint16_t ucs2str[PTP_MAXSTRLEN+1];
 	char *ucs2strp = (char *) ucs2str;
-	char *stringp = string;
-	size_t nconv;
 	size_t convlen = strlen(string);
-	size_t convmax = PTP_MAXSTRLEN * 2; /* Includes the terminator */
 
 	/* Cannot exceed 255 (PTP_MAXSTRLEN) since it is a single byte, duh ... */
 	memset(ucs2strp, 0, sizeof(ucs2str));  /* XXX: necessary? */
-	nconv = iconv(params->cd_locale_to_ucs2, &stringp, &convlen,
-		&ucs2strp, &convmax);
-	if (nconv == (size_t) -1)
-		ucs2str[0] = 0x0000U;
+#ifdef HAVE_ICONV
+	{ 
+		size_t nconv;
+		size_t convmax = PTP_MAXSTRLEN * 2; /* Includes the terminator */
+		char *stringp = string;
+
+		nconv = iconv(params->cd_locale_to_ucs2, &stringp, &convlen,
+			&ucs2strp, &convmax);
+		if (nconv == (size_t) -1)
+			ucs2str[0] = 0x0000U;
+	}
+#else
+	{
+		int i;
+		for (i=0;i<convlen;i++) {
+			ucs2str[i] = string[i];
+		}
+		ucs2str[convlen] = 0;
+	}
+#endif
 	/*
 	 * XXX: isn't packedlen just ( (uint16_t *)ucs2strp - ucs2str )?
 	 *      why do we need ucs2strlen()?
@@ -498,7 +516,7 @@
 }
 
 static time_t
-ptp_unpack_PTPTIME (PTPParams *params, const char *str) {
+ptp_unpack_PTPTIME (const char *str) {
 	char ptpdate[40];
 	char tmp[5];
 	int  ptpdatelen;
@@ -508,12 +526,12 @@
 		return 0;
 	ptpdatelen = strlen(str);
 	if (ptpdatelen >= sizeof (ptpdate)) {
-		ptp_debug (params ,"datelen is larger then size of buffer", ptpdatelen, (int)sizeof(ptpdate));
+		/*ptp_debug (params ,"datelen is larger then size of buffer", ptpdatelen, (int)sizeof(ptpdate));*/
 		return 0;
 	}
 	strcpy (ptpdate, str);
 	if (ptpdatelen<15) {
-		ptp_debug (params ,"datelen is less than 15 (%d)", ptpdatelen);
+		/*ptp_debug (params ,"datelen is less than 15 (%d)", ptpdatelen);*/
 		return 0;
 	}
 
@@ -536,7 +554,6 @@
 	strncpy (tmp, ptpdate + 13, 2);
 	tmp[2] = 0;
 	tm.tm_sec = atoi (tmp);
-	ptp_debug (params ,"mktime gets %d", mktime(&tm));
 	return mktime (&tm);
 }
 
@@ -569,14 +586,14 @@
 	/* subset of ISO 8601, without '.s' tenths of second and 
 	 * time zone
 	 */
-	oi->CaptureDate = ptp_unpack_PTPTIME(params,capture_date);
+	oi->CaptureDate = ptp_unpack_PTPTIME(capture_date);
 	free(capture_date);
 
 	/* now the modification date ... */
 	capture_date = ptp_unpack_string(params, data,
 		PTP_oi_filenamelen+filenamelen*2
 		+capturedatelen*2+2,&capturedatelen);
-	oi->ModificationDate = ptp_unpack_PTPTIME(params,capture_date);
+	oi->ModificationDate = ptp_unpack_PTPTIME(capture_date);
 	free(capture_date);
 }
 
diff --git a/src/ptp.h b/src/ptp.h
index a042616..7923499 100644
--- a/src/ptp.h
+++ b/src/ptp.h
@@ -25,7 +25,9 @@
 
 #include <stdarg.h>
 #include <time.h>
+#ifdef HAVE_ICONV
 #include <iconv.h>
+#endif
 #include "gphoto2-endian.h"
 
 #ifdef __cplusplus
@@ -1879,9 +1881,11 @@
 	uint32_t	eventpipeid;
 	char		*cameraname;
 
+#ifdef HAVE_ICONV
 	/* PTP: iconv converters */
 	iconv_t	cd_locale_to_ucs2;
 	iconv_t cd_ucs2_to_locale;
+#endif
 
 	/* IO: Sometimes the response packet get send in the dataphase
 	 * too. This only happens for a Samsung player now.
@@ -1994,7 +1998,7 @@
 uint16_t ptp_ek_9009 (PTPParams* params, uint32_t*, uint32_t*);
 uint16_t ptp_ek_900c (PTPParams* params, unsigned char **serial, unsigned int *size);
 uint16_t ptp_ek_getserial (PTPParams* params, unsigned char **serial, unsigned int *size);
-uint16_t ptp_ek_setserial (PTPParams* params, unsigned char *serial, uint32_t size);
+uint16_t ptp_ek_setserial (PTPParams* params, unsigned char *serial, unsigned int size);
 uint16_t ptp_ek_settext (PTPParams* params, PTPEKTextParams *text);
 uint16_t ptp_ek_sendfileobjectinfo (PTPParams* params, uint32_t* store,
 				uint32_t* parenthandle, uint32_t* handle,
diff --git a/src/unicode.c b/src/unicode.c
index c6ee239..2289039 100644
--- a/src/unicode.c
+++ b/src/unicode.c
@@ -10,7 +10,7 @@
  * <a href="http://en.wikipedia.org/wiki/UTF-16/UCS-2">UTF-16/UCS-2</a>
  * and <a href="http://en.wikipedia.org/wiki/UTF-8">UTF-8</a>.
  *
- * Copyright (C) 2005-2007 Linus Walleij <triad@df.lth.se>
+ * Copyright (C) 2005-2009 Linus Walleij <triad@df.lth.se>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -29,9 +29,14 @@
  *
  */
 
+#include <config.h>
 #include <stdlib.h>
 #include <string.h>
+#ifdef HAVE_ICONV
 #include <iconv.h>
+#else
+#error "libmtp unicode.c needs fixing to work without iconv()!"
+#endif
 #include "libmtp.h"
 #include "unicode.h"
 #include "util.h"