Hello community, here is the log from the commit of package libmtp for openSUSE:Factory checked in at 2017-10-07 17:46:16 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/libmtp (Old) and /work/SRC/openSUSE:Factory/.libmtp.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "libmtp" Sat Oct 7 17:46:16 2017 rev:76 rq:530356 version:1.1.14 Changes: -------- --- /work/SRC/openSUSE:Factory/libmtp/libmtp.changes 2017-04-17 10:22:41.864918964 +0200 +++ /work/SRC/openSUSE:Factory/.libmtp.new/libmtp.changes 2017-10-07 17:46:18.470797574 +0200 @@ -1,0 +2,8 @@ +Mon Oct 2 08:06:48 UTC 2017 - [email protected] + +- updated to 1.1.14 release + - lots of new USB ids + - 64bit file bugfixes + - bugfixes + +------------------------------------------------------------------- Old: ---- libmtp-1.1.13.tar.gz libmtp-1.1.13.tar.gz.asc New: ---- libmtp-1.1.14.tar.gz libmtp-1.1.14.tar.gz.asc ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ libmtp.spec ++++++ --- /var/tmp/diff_new_pack.JyPuKk/_old 2017-10-07 17:46:19.178766453 +0200 +++ /var/tmp/diff_new_pack.JyPuKk/_new 2017-10-07 17:46:19.182766277 +0200 @@ -26,7 +26,7 @@ Summary: Commandline utilities for access to MTP Players License: LGPL-2.1+ Group: Productivity/Multimedia/Sound/Players -Version: 1.1.13 +Version: 1.1.14 Release: 0 %define sonum 9 Source0: http://downloads.sourceforge.net/project/%{name}/%{name}/%{version}/%{name}-%{version}.tar.gz ++++++ libmtp-1.1.13.tar.gz -> libmtp-1.1.14.tar.gz ++++++ ++++ 2705 lines of diff (skipped) ++++ retrying with extended exclude list diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/libmtp-1.1.13/compile new/libmtp-1.1.14/compile --- old/libmtp-1.1.13/compile 2017-03-05 17:56:22.000000000 +0100 +++ new/libmtp-1.1.14/compile 2017-08-14 12:53:24.000000000 +0200 @@ -1,9 +1,9 @@ #! /bin/sh # Wrapper for compilers which do not understand '-c -o'. -scriptversion=2012-10-14.11; # UTC +scriptversion=2016-01-11.22; # UTC -# Copyright (C) 1999-2014 Free Software Foundation, Inc. +# Copyright (C) 1999-2017 Free Software Foundation, Inc. # Written by Tom Tromey <[email protected]>. # # This program is free software; you can redistribute it and/or modify @@ -255,7 +255,8 @@ echo "compile $scriptversion" exit $? ;; - cl | *[/\\]cl | cl.exe | *[/\\]cl.exe ) + cl | *[/\\]cl | cl.exe | *[/\\]cl.exe | \ + icl | *[/\\]icl | icl.exe | *[/\\]icl.exe ) func_cl_wrapper "$@" # Doesn't return... ;; esac @@ -342,6 +343,6 @@ # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-time-zone: "UTC" +# time-stamp-time-zone: "UTC0" # time-stamp-end: "; # UTC" # End: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/libmtp-1.1.13/configure.ac new/libmtp-1.1.14/configure.ac --- old/libmtp-1.1.13/configure.ac 2017-04-02 21:12:47.000000000 +0200 +++ new/libmtp-1.1.14/configure.ac 2017-10-01 21:25:34.000000000 +0200 @@ -1,6 +1,6 @@ # Process this file with autoconf to produce a configure script. AC_PREREQ(2.52) -AC_INIT([libmtp], [1.1.13], [[email protected]]) +AC_INIT([libmtp], [1.1.14], [[email protected]]) AC_CONFIG_MACRO_DIR([m4]) AM_INIT_AUTOMAKE([foreign]) AC_CONFIG_SRCDIR([src/libmtp.c]) @@ -114,7 +114,7 @@ # Check for libusb-1.0 PKG_CHECK_MODULES(LIBUSB, libusb-1.0 >= 1.0.0,[ - LIBUSB_VER=`pkg-config --modversion libusb-1.0` + LIBUSB_VER=`$PKG_CONFIG --modversion libusb-1.0` LIBUSB_REQUIRES='libusb-1.0' AC_DEFINE(HAVE_LIBUSB1, [], [Have libusb 1.0]) found_libusb1_pkg=yes @@ -125,7 +125,7 @@ LIBUSB_VER=1.0 ],[ PKG_CHECK_MODULES(LIBUSB, libusb >= 0.1.8, [ - LIBUSB_VER=`pkg-config --modversion libusb` + LIBUSB_VER=`$PKG_CONFIG --modversion libusb` LIBUSB_REQUIRES='libusb' AC_DEFINE(HAVE_LIBUSB0, [], [Have libusb 0.x]) found_libusb0_pkg=yes diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/libmtp-1.1.13/libmtp.pc new/libmtp-1.1.14/libmtp.pc --- old/libmtp-1.1.13/libmtp.pc 2017-04-02 21:18:12.000000000 +0200 +++ new/libmtp-1.1.14/libmtp.pc 2017-10-01 21:25:58.000000000 +0200 @@ -7,7 +7,7 @@ Name: libmtp Description: libmtp is a library for accessing Media Transfer Protocol devices -Version: 1.1.13 +Version: 1.1.14 Requires.private: libusb-1.0 Conflicts: Libs: -L${libdir} -lmtp diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/libmtp-1.1.13/missing new/libmtp-1.1.14/missing --- old/libmtp-1.1.13/missing 2017-03-05 17:56:22.000000000 +0100 +++ new/libmtp-1.1.14/missing 2017-08-14 12:53:24.000000000 +0200 @@ -1,9 +1,9 @@ #! /bin/sh # Common wrapper for a few potentially missing GNU programs. -scriptversion=2013-10-28.13; # UTC +scriptversion=2016-01-11.22; # UTC -# Copyright (C) 1996-2014 Free Software Foundation, Inc. +# Copyright (C) 1996-2017 Free Software Foundation, Inc. # Originally written by Fran,cois Pinard <[email protected]>, 1996. # This program is free software; you can redistribute it and/or modify @@ -210,6 +210,6 @@ # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-time-zone: "UTC" +# time-stamp-time-zone: "UTC0" # time-stamp-end: "; # UTC" # End: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/libmtp-1.1.13/src/gphoto2-endian.h new/libmtp-1.1.14/src/gphoto2-endian.h --- old/libmtp-1.1.13/src/gphoto2-endian.h 2017-04-02 21:18:11.000000000 +0200 +++ new/libmtp-1.1.14/src/gphoto2-endian.h 2017-10-01 21:25:56.000000000 +0200 @@ -1,5 +1,5 @@ /* This file is generated automatically by configure */ -/* It is valid only for the system type x86_64-unknown-linux-gnu */ +/* It is valid only for the system type x86_64-pc-linux-gnu */ #ifndef __BYTEORDER_H #define __BYTEORDER_H diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/libmtp-1.1.13/src/libmtp.c new/libmtp-1.1.14/src/libmtp.c --- old/libmtp-1.1.13/src/libmtp.c 2017-03-20 07:16:09.000000000 +0100 +++ new/libmtp-1.1.14/src/libmtp.c 2017-06-10 16:35:54.000000000 +0200 @@ -45,6 +45,7 @@ #include "mtpz.h" +#include <stdarg.h> #include <stdlib.h> #include <limits.h> #include <unistd.h> @@ -2717,8 +2718,12 @@ prop++; } /* mark last entry also */ - params->objects[i].flags |= PTPOBJECT_OBJECTINFO_LOADED; - params->nrofobjects = i+1; + if (i >= 0) { + params->objects[i].flags |= PTPOBJECT_OBJECTINFO_LOADED; + params->nrofobjects = i+1; + } else { + params->nrofobjects = 0; + } free (props); /* The device might not give the list in linear ascending order */ ptp_objects_sort (params); @@ -9150,3 +9155,36 @@ ptp_remove_object_from_cache(params, object_id); add_object_to_cache(device, object_id); } + + +/** + * Issue custom (e.g. vendor specific) operation (without data phase) + * @param device a pointer to the device to send custom operation to. + * @param code operation code to send. + * @param n_param number of parameters passed. + * @param ... uint32_t operation specific parameters. + */ +int LIBMTP_Custom_Operation(LIBMTP_mtpdevice_t *device, uint16_t code, int n_param, ...) +{ + PTPParams *params = (PTPParams *) device->params; + PTPContainer ptp; + va_list args; + uint16_t ret; + int i; + + ptp.Code = code; + ptp.Nparam = n_param; + va_start(args, n_param); + for (i = 0; i < n_param; i++) + (&ptp.Param1)[i] = va_arg(args, uint32_t); + va_end(args); + + ret = ptp_transaction_new(params, &ptp, PTP_DP_NODATA, 0, NULL); + + if (ret != PTP_RC_OK) { + add_ptp_error_to_errorstack(device, ret, "LIBMTP_Custom_Operation(): failed to execute operation."); + return -1; + } + + return 0; +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/libmtp-1.1.13/src/libmtp.h new/libmtp-1.1.14/src/libmtp.h --- old/libmtp-1.1.13/src/libmtp.h 2017-04-02 21:18:12.000000000 +0200 +++ new/libmtp-1.1.14/src/libmtp.h 2017-10-01 21:25:57.000000000 +0200 @@ -29,8 +29,8 @@ #ifndef LIBMTP_H_INCLUSION_GUARD #define LIBMTP_H_INCLUSION_GUARD -#define LIBMTP_VERSION 1.1.13 -#define LIBMTP_VERSION_STRING "1.1.13" +#define LIBMTP_VERSION 1.1.14 +#define LIBMTP_VERSION_STRING "1.1.14" /* This handles MSVC pecularities */ #ifdef _MSC_VER @@ -1058,6 +1058,13 @@ int LIBMTP_Read_Event_Async(LIBMTP_mtpdevice_t *, LIBMTP_event_cb_fn, void *); int LIBMTP_Handle_Events_Timeout_Completed(struct timeval *, int *); +/** + * @} + * @defgroup custom Custom operations API. + * @{ + */ +int LIBMTP_Custom_Operation(LIBMTP_mtpdevice_t *, uint16_t, int, ...); + /** @} */ /* End of C++ exports */ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/libmtp-1.1.13/src/libmtp.h.in new/libmtp-1.1.14/src/libmtp.h.in --- old/libmtp-1.1.13/src/libmtp.h.in 2017-03-06 07:00:27.000000000 +0100 +++ new/libmtp-1.1.14/src/libmtp.h.in 2017-06-10 16:36:53.000000000 +0200 @@ -1058,6 +1058,13 @@ int LIBMTP_Read_Event_Async(LIBMTP_mtpdevice_t *, LIBMTP_event_cb_fn, void *); int LIBMTP_Handle_Events_Timeout_Completed(struct timeval *, int *); +/** + * @} + * @defgroup custom Custom operations API. + * @{ + */ +int LIBMTP_Custom_Operation(LIBMTP_mtpdevice_t *, uint16_t, int, ...); + /** @} */ /* End of C++ exports */ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/libmtp-1.1.13/src/libmtp.sym new/libmtp-1.1.14/src/libmtp.sym --- old/libmtp-1.1.13/src/libmtp.sym 2016-04-15 08:16:02.000000000 +0200 +++ new/libmtp-1.1.14/src/libmtp.sym 2017-06-10 16:07:29.000000000 +0200 @@ -110,3 +110,4 @@ LIBMTP_EndEditObject LIBMTP_TruncateObject LIBMTP_Check_Capability +LIBMTP_Custom_Operation diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/libmtp-1.1.13/src/libopenusb1-glue.c new/libmtp-1.1.14/src/libopenusb1-glue.c --- old/libmtp-1.1.13/src/libopenusb1-glue.c 2017-04-01 21:48:36.000000000 +0200 +++ new/libmtp-1.1.14/src/libopenusb1-glue.c 2017-10-01 21:48:58.000000000 +0200 @@ -1210,6 +1210,10 @@ PTPUSBBulkContainer usbdata; uint64_t bytes_left_to_transfer; PTPDataHandler memhandler; + unsigned long packet_size; + PTP_USB *ptp_usb = (PTP_USB *) params->data; + + packet_size = ptp_usb->inep_maxpacket; LIBMTP_USB_DEBUG("SEND DATA PHASE\n"); @@ -1252,7 +1256,9 @@ bytes_left_to_transfer = size - datawlen; ret = PTP_RC_OK; while (bytes_left_to_transfer > 0) { - ret = ptp_write_func(bytes_left_to_transfer, handler, params->data, &written); + unsigned long max_long_transfer = ULONG_MAX + 1 - packet_size; + ret = ptp_write_func (bytes_left_to_transfer > max_long_transfer ? max_long_transfer : bytes_left_to_transfer, + handler, params->data, &written); if (ret != PTP_RC_OK){ break; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/libmtp-1.1.13/src/libusb-glue.c new/libmtp-1.1.14/src/libusb-glue.c --- old/libmtp-1.1.13/src/libusb-glue.c 2017-04-01 21:48:36.000000000 +0200 +++ new/libmtp-1.1.14/src/libusb-glue.c 2017-10-01 21:49:13.000000000 +0200 @@ -1202,6 +1202,10 @@ PTPUSBBulkContainer usbdata; uint64_t bytes_left_to_transfer; PTPDataHandler memhandler; + unsigned long packet_size; + PTP_USB *ptp_usb = (PTP_USB *) params->data; + + packet_size = ptp_usb->inep_maxpacket; LIBMTP_USB_DEBUG("SEND DATA PHASE\n"); @@ -1242,7 +1246,9 @@ bytes_left_to_transfer = size-datawlen; ret = PTP_RC_OK; while(bytes_left_to_transfer > 0) { - ret = ptp_write_func (bytes_left_to_transfer, handler, params->data, &written); + unsigned long max_long_transfer = ULONG_MAX + 1 - packet_size; + ret = ptp_write_func (bytes_left_to_transfer > max_long_transfer ? max_long_transfer : bytes_left_to_transfer, + handler, params->data, &written); if (ret != PTP_RC_OK) break; if (written == 0) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/libmtp-1.1.13/src/libusb1-glue.c new/libmtp-1.1.14/src/libusb1-glue.c --- old/libmtp-1.1.13/src/libusb1-glue.c 2017-04-01 21:48:36.000000000 +0200 +++ new/libmtp-1.1.14/src/libusb1-glue.c 2017-10-01 21:49:09.000000000 +0200 @@ -52,6 +52,7 @@ * spend a bit of time collecting data. Higher values also * make connecting/disconnecting more reliable. */ +#define USB_START_TIMEOUT 5000 #define USB_TIMEOUT_DEFAULT 20000 #define USB_TIMEOUT_LONG 60000 static inline int get_timeout(PTP_USB* ptp_usb) @@ -109,6 +110,8 @@ PTPDataHandler*, void *data, unsigned long*); static short ptp_read_func (unsigned long, PTPDataHandler*, void *data, unsigned long*, int); +static short ptp_read_cancel_func (PTPParams* params, + uint32_t transactionid); static int usb_get_endpoint_status(PTP_USB* ptp_usb, int ep, uint16_t* status); @@ -837,6 +840,7 @@ PTP_USB *ptp_usb = (PTP_USB *)data; unsigned long toread = 0; int ret = 0; + uint16_t handler_ret = 0; int xread; unsigned long curread = 0; unsigned char *bytes; @@ -861,7 +865,6 @@ // This is the largest block we'll need to read in. bytes = malloc(CONTEXT_BLOCK_SIZE); while (curread < size) { - LIBMTP_USB_DEBUG("Remaining size to read: 0x%04lx bytes\n", size - curread); // check equal to condition here @@ -894,16 +897,20 @@ LIBMTP_USB_DEBUG("Reading in 0x%04lx bytes\n", toread); ret = USB_BULK_READ(ptp_usb->handle, - ptp_usb->inep, - bytes, - toread, - &xread, - ptp_usb->timeout); + ptp_usb->inep, + bytes, + toread, + &xread, + ptp_usb->timeout); LIBMTP_USB_DEBUG("Result of read: 0x%04x (%d bytes)\n", ret, xread); - if (ret != LIBUSB_SUCCESS) + if (ret == LIBUSB_ERROR_TIMEOUT) { + return PTP_ERROR_TIMEOUT; + } + else if (ret != LIBUSB_SUCCESS){ return PTP_ERROR_IO; + } LIBMTP_USB_DEBUG("<==USB IN\n"); if (xread == 0) @@ -915,45 +922,54 @@ if (expect_terminator_byte && xread == toread) { LIBMTP_USB_DEBUG("<==USB IN\nDiscarding extra byte\n"); - xread--; } - int putfunc_ret = handler->putfunc(NULL, handler->priv, xread, bytes); - if (putfunc_ret != PTP_RC_OK) - return putfunc_ret; + if (handler) { + handler_ret = handler->putfunc(NULL, handler->priv, xread, bytes); + if (handler_ret != PTP_RC_OK) { + LIBMTP_ERROR("LIBMTP error writing to fd or memory by handler." + "Not enough memory or temp/destination free space?"); + free (bytes); + return PTP_ERROR_CANCEL; + } + } - ptp_usb->current_transfer_complete += xread; + if (ptp_usb->callback_active) + ptp_usb->current_transfer_complete += xread; curread += xread; // Increase counters, call callback if (ptp_usb->callback_active) { if (ptp_usb->current_transfer_complete >= ptp_usb->current_transfer_total) { - // send last update and disable callback. - ptp_usb->current_transfer_complete = ptp_usb->current_transfer_total; - ptp_usb->callback_active = 0; + // send last update and disable callback. + ptp_usb->current_transfer_complete = ptp_usb->current_transfer_total; + ptp_usb->callback_active = 0; } if (ptp_usb->current_transfer_callback != NULL) { - int ret; - ret = ptp_usb->current_transfer_callback(ptp_usb->current_transfer_complete, - ptp_usb->current_transfer_total, - ptp_usb->current_transfer_callback_data); - if (ret != 0) { - return PTP_ERROR_CANCEL; - } + ret = ptp_usb->current_transfer_callback(ptp_usb->current_transfer_complete, + ptp_usb->current_transfer_total, + ptp_usb->current_transfer_callback_data); + if (ret != 0) { + LIBMTP_USB_DEBUG("ptp_read_func cancelled by user callback\n"); + free (bytes); + return PTP_ERROR_CANCEL; + } } } if (xread < toread) /* short reads are common */ break; } - if (readbytes) *readbytes = curread; + + if (readbytes) + *readbytes = curread; free (bytes); // there might be a zero packet waiting for us... if (readzero && - !FLAG_NO_ZERO_READS(ptp_usb) && - curread % ptp_usb->outep_maxpacket == 0) { + !FLAG_NO_ZERO_READS(ptp_usb) && + curread % ptp_usb->inep_maxpacket == 0) { unsigned char temp; int zeroresult = 0, xread; @@ -961,11 +977,11 @@ LIBMTP_USB_DEBUG("Zero Read\n"); zeroresult = USB_BULK_READ(ptp_usb->handle, - ptp_usb->inep, - &temp, - 0, + ptp_usb->inep, + &temp, + 0, &xread, - ptp_usb->timeout); + ptp_usb->timeout); if (zeroresult != LIBUSB_SUCCESS) LIBMTP_INFO("LIBMTP panic: unable to read in zero packet, response 0x%04x", zeroresult); } @@ -973,6 +989,69 @@ return PTP_RC_OK; } +/* + * When cancelling a read from device. + * The device can take time to really stop sending in data, so we have to + * read and discard it. + * Stop when we encounter a timeout (so no more data in after 300ms). + * Corner case: Lets imagine that the cancel will arrive just for the last bytes + * of a file, and so that the transfer would still complete. The current code + * will also discard the "reply status" frame. That makes sense because from + * the host point of view, the end of the file will not have be written. + * + */ +static short +ptp_read_cancel_func ( + PTPParams* params, + uint32_t transactionid +) { + PTP_USB *ptp_usb = (PTP_USB *) params->data; + uint16_t ret = 0; + PTPContainer MyEvent; + unsigned long xread = 0; + int old_callback_active = ptp_usb->callback_active; + int oldtimeout = 60000; + + + get_usb_device_timeout(ptp_usb, &oldtimeout); + + ptp_usb->callback_active = 0; + /* Set a timeout similar to the one of windows in such a case: 300ms */ + set_usb_device_timeout(ptp_usb, 300); + + params->cancelreq_func(params, transactionid); + + + ret = params->devstatreq_func(params); + while (ret == PTP_RC_DeviceBusy) { + usleep(200000); + ret = params->devstatreq_func(params); + } + + while (1) { + ret = ptp_read_func(ptp_usb->inep_maxpacket, + NULL, + params->data, + &xread, + 0); + + if (ret != PTP_RC_OK) + break; + } + + // Probably a "transfert cancelled" event will be raised. + // We have to clear it or a device like the "GoPro" will not reply anymore after + memset(&MyEvent,0,sizeof(MyEvent)); + ptp_usb_event_check(params, &MyEvent); + + /* Restore previous values */ + ptp_usb->callback_active = old_callback_active; + set_usb_device_timeout(ptp_usb, oldtimeout); + + + return PTP_ERROR_CANCEL; +} + static short ptp_write_func ( unsigned long size, @@ -1227,6 +1306,10 @@ PTPUSBBulkContainer usbdata; uint64_t bytes_left_to_transfer; PTPDataHandler memhandler; + unsigned long packet_size; + PTP_USB *ptp_usb = (PTP_USB *) params->data; + + packet_size = ptp_usb->outep_maxpacket; LIBMTP_USB_DEBUG("SEND DATA PHASE\n"); @@ -1267,7 +1350,9 @@ bytes_left_to_transfer = size-datawlen; ret = PTP_RC_OK; while(bytes_left_to_transfer > 0) { - ret = ptp_write_func (bytes_left_to_transfer, handler, params->data, &written); + unsigned long max_long_transfer = ULONG_MAX + 1 - packet_size; + ret = ptp_write_func (bytes_left_to_transfer > max_long_transfer ? max_long_transfer : bytes_left_to_transfer, + handler, params->data, &written); if (ret != PTP_RC_OK) break; if (written == 0) { @@ -1365,25 +1450,25 @@ handler->putfunc( params, handler->priv, rlen - PTP_USB_BULK_HDR_LEN, usbdata.payload.data ); - if (putfunc_ret != PTP_RC_OK) - return putfunc_ret; + if (putfunc_ret != PTP_RC_OK) + return ptp_read_cancel_func(params, ptp->Transaction_ID); /* stuff data directly to passed data handler */ while (1) { unsigned long readdata; - uint16_t xret; - xret = ptp_read_func( + ret = ptp_read_func( 0x20000000, handler, params->data, &readdata, - 0 - ); - if (xret != PTP_RC_OK) - return xret; - if (readdata < 0x20000000) - break; + 0); + if (ret == PTP_ERROR_CANCEL) + return ptp_read_cancel_func(params, ptp->Transaction_ID); + if (ret != PTP_RC_OK) + return ret; + if (readdata < 0x20000000) + break; } return PTP_RC_OK; } @@ -1436,7 +1521,7 @@ usbdata.payload.data ); if (putfunc_ret != PTP_RC_OK) - return putfunc_ret; + return ptp_read_cancel_func(params, ptp->Transaction_ID); if (FLAG_NO_ZERO_READS(ptp_usb) && len+PTP_USB_BULK_HDR_LEN == ptp_usb->inep_maxpacket) { @@ -1478,12 +1563,16 @@ } ret = ptp_read_func(len - (rlen - PTP_USB_BULK_HDR_LEN), - handler, - params->data, &rlen, 1); - - if (ret != PTP_RC_OK) { - break; + handler, + params->data, + &rlen, + 1); + if (ret == PTP_ERROR_CANCEL) { + ptp_read_cancel_func(params, ptp->Transaction_ID); + break; } + if (ret != PTP_RC_OK) + break; } while (0); return ret; } @@ -1768,6 +1857,34 @@ return PTP_RC_OK; } +/** + * PTP class level device status request + */ +uint16_t +ptp_usb_control_device_status_request (PTPParams *params) { + PTP_USB *ptp_usb = (PTP_USB *)(params->data); + int ret; + unsigned char buffer[4]; + // In theory, only 2x16 bytes are needed based on linux mtp implementation + // But the pima spec is not clear + + ret = libusb_control_transfer(ptp_usb->handle, + LIBUSB_ENDPOINT_IN | LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_INTERFACE, + 0x67, 0x0000, 0x0000, + buffer, + sizeof(buffer), + ptp_usb->timeout); + if (ret < sizeof(buffer)) + return PTP_ERROR_IO; + + ret = dtoh16a(&buffer[2]); + LIBMTP_USB_DEBUG("Device status request returned: 0x%04x \n", ret); + if (ret != PTP_RC_OK && ret != PTP_RC_DeviceBusy && ret != PTP_RC_TransactionCanceled) + return PTP_ERROR_IO; + + return ret; +} + static int init_ptp_usb(PTPParams* params, PTP_USB* ptp_usb, libusb_device* dev) { libusb_device_handle *device_handle; @@ -1780,6 +1897,7 @@ params->getresp_func=ptp_usb_getresp; params->getdata_func=ptp_usb_getdata; params->cancelreq_func=ptp_usb_control_cancel_request; + params->devstatreq_func=ptp_usb_control_device_status_request; params->data=ptp_usb; params->transaction_id=0; /* @@ -1810,6 +1928,13 @@ } } + usbresult = libusb_claim_interface(device_handle, ptp_usb->interface); + + if (usbresult != 0) { + fprintf(stderr, "error returned by libusb_claim_interface() = %d", usbresult); + return -1; + } + /* * Check if the config is set to something else than what we want * to use. Only set the configuration if we absolutely have to. @@ -1846,16 +1971,6 @@ } /* - * It seems like on kernel 2.6.31 if we already have it open on another - * pthread in our app, we'll get an error if we try to claim it again, - * but that error is harmless because our process already claimed the interface - */ - usbresult = libusb_claim_interface(device_handle, ptp_usb->interface); - - if (usbresult != 0) - fprintf(stderr, "ignoring libusb_claim_interface() = %d", usbresult); - - /* * If the altsetting is set to something different than we want, switch * it. * @@ -2169,6 +2284,8 @@ return LIBMTP_ERROR_CONNECTING; } + /* Special short timeout for the first trial of opensession. */ + set_usb_device_timeout(ptp_usb, USB_START_TIMEOUT); /* * This works in situations where previous bad applications * have not used LIBMTP_Release_Device on exit @@ -2186,6 +2303,7 @@ return LIBMTP_ERROR_CONNECTING; } + /* Normal timeout will have been restored by init_ptp_usb */ /* Device has been reset, try again */ if ((ret = ptp_opensession(params, 1)) == PTP_ERROR_IO) { LIBMTP_ERROR("LIBMTP PANIC: failed to open session on second attempt\n"); @@ -2212,6 +2330,9 @@ return LIBMTP_ERROR_CONNECTING; } + /* If everything is good, ensure to reset the timeout to the correct value */ + set_usb_device_timeout(ptp_usb, get_timeout(ptp_usb)); + /* OK configured properly */ *usbinfo = (void *) ptp_usb; libusb_free_device_list (devs, 0); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/libmtp-1.1.13/src/mtpz.c new/libmtp-1.1.14/src/mtpz.c --- old/libmtp-1.1.13/src/mtpz.c 2015-10-07 09:43:18.000000000 +0200 +++ new/libmtp-1.1.14/src/mtpz.c 2017-06-02 08:06:37.000000000 +0200 @@ -690,21 +690,22 @@ switch (key_len) { - case 16: - ks = 16 * (10 + 1); - break; + case 16: + ks = 16 * (10 + 1); + break; - case 24: - ks = 16 * (12 + 1); - break; + case 24: + ks = 16 * (12 + 1); + break; - case 32: - ks = 16 * (14 + 1); - break; + case 32: + ks = 16 * (14 + 1); + break; - default: - *out = NULL; - *out_len = 0; + default: + *out = NULL; + *out_len = 0; + return; } unsigned char *key = (unsigned char *)malloc(ks); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/libmtp-1.1.13/src/music-players.h new/libmtp-1.1.14/src/music-players.h --- old/libmtp-1.1.13/src/music-players.h 2017-04-02 20:16:54.000000000 +0200 +++ new/libmtp-1.1.14/src/music-players.h 2017-09-26 06:48:53.000000000 +0200 @@ -4,7 +4,7 @@ * * Copyright (C) 2005-2007 Richard A. Low <[email protected]> * Copyright (C) 2005-2013 Linus Walleij <[email protected]> - * Copyright (C) 2006-2007,2015 Marcus Meissner <[email protected]> + * Copyright (C) 2006-2007,2015-2017 Marcus Meissner <[email protected]> * Copyright (C) 2007 Ted Bullock * Copyright (C) 2012 Sony Mobile Communications AB * @@ -631,6 +631,9 @@ /* Mia */ { "Acer", 0x0502, "Liquid Zest Plus", 0x38bb, DEVICE_FLAGS_ANDROID_BUGS }, + /* Richard Waterbeek <[email protected]> on libmtp-discuss */ + { "Acer", 0x0502, "Liquid Liquid Z6E", 0x3938, + DEVICE_FLAGS_ANDROID_BUGS }, /* * SanDisk @@ -1018,7 +1021,10 @@ { "Archos (for Tesco)", 0x0e79, "Hudl (ID2)", 0x5009, DEVICE_FLAGS_ANDROID_BUGS }, /* https://sourceforge.net/p/libmtp/bugs/1404/ */ { "Archos", 0x0e79, "AC40DTI", 0x5217, DEVICE_FLAGS_ANDROID_BUGS }, - + /* https://sourceforge.net/p/libmtp/feature-requests/221/ */ + { "Archos", 0x0e79, "50 Helium Plus", 0x5229, DEVICE_FLAGS_ANDROID_BUGS }, + /* https://sourceforge.net/p/libmtp/bugs/1682/ */ + { "Archos", 0x0e79, "50 Helium Plus (2nd ID)", 0x522a, DEVICE_FLAGS_ANDROID_BUGS }, /* https://sourceforge.net/p/libmtp/bugs/1573/ */ { "Archos", 0x0e79, "101 xenon lite", 0x528c, DEVICE_FLAGS_ANDROID_BUGS }, { "Archos", 0x0e79, "101 xenon lite (ADB)", 0x528d, DEVICE_FLAGS_ANDROID_BUGS }, @@ -1035,9 +1041,12 @@ /* https://sourceforge.net/p/libmtp/bugs/1637/ */ { "Archos", 0x0e79, "101b Oxygen", 0x542f, DEVICE_FLAGS_ANDROID_BUGS }, + /* https://sourceforge.net/p/libmtp/support-requests/245/ */ + { "Archos", 0x0e79, "55B Platinum", 0x544a, DEVICE_FLAGS_ANDROID_BUGS }, /* https://sourceforge.net/p/libmtp/feature-requests/209/ */ { "Archos", 0x0e79, "55 diamond Selfie", 0x5465, DEVICE_FLAGS_ANDROID_BUGS }, + /* * Dunlop (OEM of EGOMAN ltd?) reported by Nanomad * This unit is falsely detected as USB mass storage in Linux @@ -1208,6 +1217,8 @@ { "Nokia", 0x0421, "C5-00", 0x0592, DEVICE_FLAG_NONE }, /* https://sourceforge.net/p/libmtp/bugs/1457/ */ { "Nokia", 0x0421, "C5-00 (ID2)", 0x0595, DEVICE_FLAG_NONE }, + /* https://sourceforge.net/p/libmtp/feature-requests/235/ */ + { "Nokia", 0x0421, "500", 0x05c0, DEVICE_FLAG_NONE }, { "Nokia", 0x0421, "808 PureView", 0x05d3, DEVICE_FLAG_NONE }, // Reported by Sampo Savola // Covers Lumia 920, 820 and probably any WP8 device. @@ -1224,6 +1235,8 @@ /* https://sourceforge.net/p/libmtp/bugs/1453/ */ { "Nokia", 0x0421, "X2 Dual Sim", 0x0708, DEVICE_FLAG_NONE }, + /* https://sourceforge.net/p/libmtp/bugs/1711/ */ + { "Nokia", 0x2e04, "6", 0xc025, DEVICE_FLAG_NONE }, /* * Qualcomm @@ -1357,6 +1370,12 @@ /* Also Thalia Toline. https://sourceforge.net/p/libmtp/bugs/1156/ */ {"iRiver", 0x1e68, "Tolino Tab 7", 0x1002, DEVICE_FLAGS_ANDROID_BUGS }, + /* https://sourceforge.net/p/libmtp/bugs/1694/ */ + {"iRiver", 0x1e68, "Tolino Tab 8", 0x1007, + DEVICE_FLAGS_ANDROID_BUGS }, + /* https://sourceforge.net/p/libmtp/bugs/1699/ */ + {"Trekstor", 0x1e68, "SurfTab breeze 7.0 quad 3G", 0x1045, + DEVICE_FLAGS_ANDROID_BUGS }, /* * Disney/Tevion/MyMusix @@ -1495,16 +1514,22 @@ /* https://sourceforge.net/p/libmtp/support-requests/190/ */ { "LG Electronics Inc.", 0x1004, "LG Optimus Zone 2", 0x6259, DEVICE_FLAGS_ANDROID_BUGS }, - { "LG Electronics Inc.", 0x1004, "VK810", 0x6265, - DEVICE_FLAGS_ANDROID_BUGS }, - { "LG Electronics Inc.", 0x1004, "G3", 0x627f, - DEVICE_FLAGS_ANDROID_BUGS }, /* https://sourceforge.net/p/libmtp/bugs/1463/ */ { "LG Electronics Inc.", 0x1004, "810 tablet", 0x6263, DEVICE_FLAGS_ANDROID_BUGS }, + { "LG Electronics Inc.", 0x1004, "VK810", 0x6265, + DEVICE_FLAGS_ANDROID_BUGS }, /* https://sourceforge.net/p/libmtp/support-requests/134/ */ { "LG Electronics Inc.", 0x1004, "G3 (VS985)", 0x626e, DEVICE_FLAGS_ANDROID_BUGS }, + { "LG Electronics Inc.", 0x1004, "G3", 0x627f, + DEVICE_FLAGS_ANDROID_BUGS }, + /* https://sourceforge.net/p/libmtp/bugs/1701/ */ + { "LG Electronics Inc.", 0x1004, "Transpyre", 0x628a, + DEVICE_FLAGS_ANDROID_BUGS }, + /* https://sourceforge.net/p/libmtp/feature-requests/222/ */ + { "LG Electronics Inc.", 0x1004, "LG G5 Phone", 0x62ce, + DEVICE_FLAGS_ANDROID_BUGS }, /* * This VID+PID is used by a lot of LG models: * E430 @@ -1614,6 +1639,9 @@ /* https://sourceforge.net/p/libmtp/bugs/1540/ */ { "Sony", 0x054c, "NWZ-E474", 0x06a9, DEVICE_FLAGS_SONY_NWZ_BUGS }, + /* https://sourceforge.net/p/libmtp/bugs/1688/ */ + { "Sony", 0x054c, "NWZ-E384", 0x0882, + DEVICE_FLAGS_SONY_NWZ_BUGS }, { "Sony", 0x054c, "DCR-SR75", 0x1294, DEVICE_FLAGS_SONY_NWZ_BUGS }, @@ -1816,6 +1844,8 @@ DEVICE_FLAG_NONE }, { "SONY", 0x0fce, "Xperia Z1 Compact D5503", 0x01a7, DEVICE_FLAG_NONE }, + { "SONY", 0x0fce, "Xperia T2 Ultra MTP", 0x01a9, + DEVICE_FLAG_NONE }, { "SONY", 0x0fce, "Xperia M2 MTP", 0x01aa, DEVICE_FLAG_NONE }, { "SONY", 0x0fce, "Xperia M2 Dual MTP", 0x01ab, @@ -1856,13 +1886,24 @@ DEVICE_FLAG_NONE }, { "SONY", 0x0fce, "XPeria Z5 Compact MTP", 0x01da, DEVICE_FLAG_NONE }, + /* https://sourceforge.net/p/libmtp/feature-requests/236/ */ + { "SONY", 0x0fce, "XPeria Z5 Premium Dual Sim MTP", 0x01db, + DEVICE_FLAG_NONE }, /* https://sourceforge.net/p/libmtp/bugs/1649/ */ { "SONY", 0x0fce, "XPeria XA MTP", 0x01de, DEVICE_FLAG_NONE }, + { "SONY", 0x0fce, "XPeria X MTP", 0x01e0, + DEVICE_FLAG_NONE }, { "SONY", 0x0fce, "XPeria XZ MTP", 0x01e7, DEVICE_FLAG_NONE }, { "SONY", 0x0fce, "XPeria X Compact MTP", 0x01e8, DEVICE_FLAG_NONE }, + /* https://sourceforge.net/p/libmtp/support-requests/247/ */ + { "SONY", 0x0fce, "XPeria XZ", 0x01ed, + DEVICE_FLAG_NONE }, + /* https://sourceforge.net/p/libmtp/support-requests/251/ */ + { "SONY", 0x0fce, "XPeria XZ Premium", 0x01f1, + DEVICE_FLAG_NONE }, /* @@ -1926,6 +1967,8 @@ DEVICE_FLAG_NONE }, { "SONY", 0x0fce, "Xperia Z1 Compact D5503 MTP+CDROM", 0x41a7, DEVICE_FLAG_NONE }, + { "SONY", 0x0fce, "Xperia T2 Ultra MTP+CDROM", 0x41a9, + DEVICE_FLAG_NONE }, { "SONY", 0x0fce, "Xperia M2 MTP+CDROM", 0x41aa, DEVICE_FLAG_NONE }, { "SONY", 0x0fce, "Xperia M2 Dual MTP+CDROM", 0x41ab, @@ -1966,12 +2009,20 @@ DEVICE_FLAG_NONE }, { "SONY", 0x0fce, "XPeria Z5 Compact MTP+CDROM", 0x41da, DEVICE_FLAG_NONE }, + { "SONY", 0x0fce, "XPeria Z5 Premium Dual Sim MTP+CDROM", 0x41db, + DEVICE_FLAG_NONE }, { "SONY", 0x0fce, "XPeria XA MTP+CDROM", 0x41de, DEVICE_FLAG_NONE }, + { "SONY", 0x0fce, "XPeria X MTP+CDROM", 0x41e0, + DEVICE_FLAG_NONE }, { "SONY", 0x0fce, "XPeria XZ MTP+CDROM", 0x41e7, DEVICE_FLAG_NONE }, { "SONY", 0x0fce, "XPeria X Compact MTP+CDROM", 0x41e8, DEVICE_FLAG_NONE }, + { "SONY", 0x0fce, "XPeria XZ CDROM", 0x41ed, + DEVICE_FLAG_NONE }, + { "SONY", 0x0fce, "XPeria XZ Premium MTP+CDROM", 0x41f1, + DEVICE_FLAG_NONE }, /* * MTP+ADB personalities of MTP devices (see above) @@ -2058,6 +2109,8 @@ DEVICE_FLAG_NONE }, { "SONY", 0x0fce, "Xperia Z1 Compact MTP+ADB", 0x51a7, DEVICE_FLAG_NONE }, + { "SONY", 0x0fce, "Xperia T2 Ultra MTP+ADB", 0x51a9, + DEVICE_FLAG_NONE }, { "SONY", 0x0fce, "Xperia M2 MTP+ADB", 0x51aa, DEVICE_FLAG_NONE }, { "SONY", 0x0fce, "Xperia M2 Dual MTP+ADB", 0x51ab, @@ -2098,12 +2151,20 @@ DEVICE_FLAG_NONE }, { "SONY", 0x0fce, "XPeria Z5 Compact MTP+ADB", 0x51da, DEVICE_FLAG_NONE }, + { "SONY", 0x0fce, "XPeria Z5 Premium Dual Sim MTP+ADB", 0x51db, + DEVICE_FLAG_NONE }, { "SONY", 0x0fce, "XPeria XA MTP+ADB", 0x51de, DEVICE_FLAG_NONE }, + { "SONY", 0x0fce, "XPeria X MTP+ADB", 0x51e0, + DEVICE_FLAG_NONE }, { "SONY", 0x0fce, "XPeria XZ MTP+ADB", 0x51e7, DEVICE_FLAG_NONE }, { "SONY", 0x0fce, "XPeria X Compact MTP+ADB", 0x51e8, DEVICE_FLAG_NONE }, + { "SONY", 0x0fce, "XPeria XZ ADB", 0x51ed, + DEVICE_FLAG_NONE }, + { "SONY", 0x0fce, "XPeria XZ Premium MTP+ADB", 0x51f1, + DEVICE_FLAG_NONE }, /* * MTP+UMS modes @@ -2149,6 +2210,9 @@ { "Motorola", 0x22b8, "V3m/V750 verizon", 0x2a65, DEVICE_FLAG_BROKEN_SET_OBJECT_PROPLIST | DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST_ALL }, + /* https://sourceforge.net/p/libmtp/support-requests/130/ */ + { "Motorola", 0x22b8, "X 2nd edition XT1097 (MTP)", 0x2e24, + DEVICE_FLAGS_ANDROID_BUGS }, { "Motorola", 0x22b8, "Atrix/Razr HD (MTP)", 0x2e32, DEVICE_FLAGS_ANDROID_BUGS }, { "Motorola", 0x22b8, "Atrix/Razr HD (MTP+ADB)", 0x2e33, @@ -2288,6 +2352,9 @@ DEVICE_FLAGS_ANDROID_BUGS }, { "Google Inc (for Sony)", 0x18d1, "S1", 0x05b3, DEVICE_FLAGS_ANDROID_BUGS }, + /* https://sourceforge.net/p/libmtp/feature-requests/218/ */ + { "Google Inc (for Fairphone)", 0x18d1, "Fairphone 2", 0x0a07, + DEVICE_FLAGS_ANDROID_BUGS }, // Reported by anonymous Sourceforge user { "Google Inc (for Barnes & Noble)", 0x18d1, "Nook Color", 0x2d02, DEVICE_FLAGS_ANDROID_BUGS }, @@ -2659,6 +2726,9 @@ // Reported by: anonymous sourceforge user { "Lenovo", 0x17ef, "Lifetab S9512", 0x74cc, DEVICE_FLAGS_ANDROID_BUGS }, + /* https://sourceforge.net/p/libmtp/feature-requests/217/ */ + { "Lenovo", 0x17ef, "Vibe K5", 0x74ee, + DEVICE_FLAGS_ANDROID_BUGS }, /* https://sourceforge.net/p/libmtp/support-requests/170/ */ { "Lenovo", 0x17ef, "S660", 0x74f8, DEVICE_FLAGS_ANDROID_BUGS }, @@ -2763,9 +2833,15 @@ /* https://sourceforge.net/p/libmtp/bugs/1465/ */ { "Lenovo", 0x17ef, "A1000 Smartphone ADB", 0x7929, DEVICE_FLAGS_ANDROID_BUGS }, + /* https://sourceforge.net/p/libmtp/feature-requests/224/ */ + { "Lenovo", 0x17ef, "Yoga 10 Tablet YT3-X50F", 0x7932, + DEVICE_FLAGS_ANDROID_BUGS }, /* https://sourceforge.net/p/libmtp/feature-requests/204/ */ { "Lenovo", 0x17ef, "TAB 2 A10-30", 0x7949, DEVICE_FLAGS_ANDROID_BUGS }, + /* https://sourceforge.net/p/libmtp/bugs/1719/ */ + { "Lenovo", 0x17ef, "YT3 X90F", 0x795c, + DEVICE_FLAGS_ANDROID_BUGS }, { "Lenovo", 0x17ef, "K5", 0x7993, DEVICE_FLAGS_ANDROID_BUGS }, { "Lenovo", 0x17ef, "Vibe K5 Note", 0x7999, @@ -2773,9 +2849,18 @@ /* https://sourceforge.net/p/libmtp/bugs/1664/ */ { "Lenovo", 0x17ef, "Vibe K4", 0x79b7, DEVICE_FLAGS_ANDROID_BUGS }, + /* https://sourceforge.net/p/libmtp/support-requests/242/ */ + { "Lenovo", 0x17ef, "Tab 3 10 Plus", 0x79de, + DEVICE_FLAGS_ANDROID_BUGS }, /* https://sourceforge.net/p/libmtp/bugs/1624/ */ { "Lenovo", 0x17ef, "B Smartphone", 0x7a18, DEVICE_FLAGS_ANDROID_BUGS }, + /* https://sourceforge.net/p/libmtp/bugs/1679/ */ + { "Lenovo", 0x17ef, "C2", 0x7a36, + DEVICE_FLAGS_ANDROID_BUGS }, + /* https://sourceforge.net/p/libmtp/support-requests/248/ */ + { "Lenovo", 0x17ef, "P2c72", 0x7a36, + DEVICE_FLAGS_ANDROID_BUGS }, /* * Huawei @@ -2809,6 +2894,9 @@ /* https://sourceforge.net/p/libmtp/bugs/1629/ */ { "Huawei", 0x12d1, "Y320-U10", 0x2406, DEVICE_FLAGS_ANDROID_BUGS }, + /* https://sourceforge.net/p/libmtp/bugs/1703/ */ + { "Huawei", 0x12d1, "Y625-U03", 0x255d, + DEVICE_FLAGS_ANDROID_BUGS }, /* https://sourceforge.net/p/libmtp/feature-requests/186/ */ { "Huawei", 0x12d1, "Y360-U61", 0x2567, DEVICE_FLAGS_ANDROID_BUGS }, @@ -2818,6 +2906,11 @@ /* https://sourceforge.net/p/libmtp/support-requests/227/ */ { "Huawei", 0x12d1, "Y560-L01", 0x259c, DEVICE_FLAGS_ANDROID_BUGS }, + /* https://sourceforge.net/p/libmtp/bugs/1695/ + * Seth Brown on libmtp-discuss + */ + { "Huawei", 0x12d1, "CUN-U29", 0x2608, + DEVICE_FLAGS_ANDROID_BUGS }, { "Huawei", 0x12d1, "Mediapad (mode 0)", 0x360f, DEVICE_FLAGS_ANDROID_BUGS }, // Reported by Bearsh <[email protected]> @@ -2846,6 +2939,9 @@ * Steven Eastland <[email protected]> * Kevin Cheng <[email protected]> */ + /* https://sourceforge.net/p/libmtp/feature-requests/173/ */ + { "HTC", 0x0bb4, "M9", 0x0401, + DEVICE_FLAGS_ANDROID_BUGS }, /* https://sourceforge.net/p/libmtp/support-requests/181/ */ { "HTC", 0x0bb4, "One M9 (1st ID)", 0x040b, DEVICE_FLAGS_ANDROID_BUGS }, @@ -2908,6 +3004,9 @@ { "HTC", 0x0bb4, "Android Device ID1 (Zopo, HD2, Bird...)", 0x0c02, DEVICE_FLAGS_ANDROID_BUGS }, #endif + /* https://sourceforge.net/p/libmtp/bugs/1677/ */ + { "DEXP", 0x0bb4, "Ixion XL145 Snatch", 0x0c08, + DEVICE_FLAGS_ANDROID_BUGS }, { "HTC", 0x0bb4, "EVO 4G LTE/One V (ID1)", 0x0c93, DEVICE_FLAGS_ANDROID_BUGS }, { "HTC", 0x0bb4, "EVO 4G LTE/One V (ID2)", 0x0ca8, @@ -3042,16 +3141,18 @@ /* https://sourceforge.net/p/libmtp/bugs/1582/ */ { "nVidia", 0x0955, "Jetson TX1", 0x7721, DEVICE_FLAGS_ANDROID_BUGS }, - { "nVidia", 0x0955, "Shield (ID1)", 0xb400, + { "nVidia", 0x0955, "Shield (MTP+ADB)", 0xb400, DEVICE_FLAGS_ANDROID_BUGS }, /* https://sourceforge.net/p/libmtp/bugs/1447/ */ - { "nVidia", 0x0955, "Shield (Tegra4)", 0xb401, + { "nVidia", 0x0955, "Shield (MTP)", 0xb401, DEVICE_FLAGS_ANDROID_BUGS }, /* https://sourceforge.net/p/libmtp/bugs/1087/ */ { "nVidia", 0x0955, "Tegra Note", 0xcf02, DEVICE_FLAGS_ANDROID_BUGS }, + { "nVidia", 0x0955, "Shield Tablet (MTP+ADB)", 0xcf05, + DEVICE_FLAGS_ANDROID_BUGS }, /* [email protected] */ - { "nVidia", 0x0955, "Shield (ID2)", 0xcf07, + { "nVidia", 0x0955, "Shield Tablet (MTP)", 0xcf07, DEVICE_FLAGS_ANDROID_BUGS }, /* @@ -3112,6 +3213,9 @@ /* https://sourceforge.net/p/libmtp/bugs/1491/ */ { "Amazon", 0x1949, "Kindle Fire 5", 0x0222, DEVICE_FLAGS_ANDROID_BUGS }, + /* https://sourceforge.net/p/libmtp/bugs/1718/ */ + { "Amazon", 0x1949, "Kindle Fire 8", 0x0261, + DEVICE_FLAGS_ANDROID_BUGS }, { "Amazon", 0x1949, "Fire Phone", 0x0800, DEVICE_FLAGS_ANDROID_BUGS }, @@ -3154,8 +3258,12 @@ * Hisense */ // Reported by Anonymous SourceForge users + { "HiSense", 0x109b, "Sero 7 Pro", 0x9105, DEVICE_FLAGS_ANDROID_BUGS }, { "Hisense", 0x109b, "E860 (ID1)", 0x9106, DEVICE_FLAGS_ANDROID_BUGS }, { "Hisense", 0x109b, "E860 (ID2)", 0x9109, DEVICE_FLAGS_ANDROID_BUGS }, + /* https://sourceforge.net/p/libmtp/bugs/1704/ */ + { "Crosscall", 0x109b, "Trekker M1 core", 0x9130, DEVICE_FLAGS_ANDROID_BUGS }, + /* * Intel @@ -3199,6 +3307,9 @@ /* https://sourceforge.net/p/libmtp/bugs/1164/ */ { "Redmi", 0x2717, "HM 1S (MTP)", 0x1268, DEVICE_FLAGS_ANDROID_BUGS }, + /* https://sourceforge.net/p/libmtp/bugs/1702/ */ + { "Xiaomi", 0x2717, "HM NOTE 1LTEW 4G Phone (MTP)", 0x1360, + DEVICE_FLAGS_ANDROID_BUGS }, /* https://sourceforge.net/p/libmtp/discussion/535190/ */ { "Xiaomi", 0x2717, "HM NOTE 1LTEW MIUI (MTP)", 0x1368, DEVICE_FLAGS_ANDROID_BUGS }, @@ -3290,12 +3401,8 @@ { "Kyocera", 0x0482, "KC-S701", 0x09cb, DEVICE_FLAGS_ANDROID_BUGS }, /* https://sourceforge.net/p/libmtp/feature-requests/192/ */ { "Kyocera", 0x0482, "C6740N", 0x0a73, DEVICE_FLAGS_ANDROID_BUGS }, - - /* - * HiSense - */ - { "HiSense", 0x109b, "Sero 7 Pro", 0x9105, - DEVICE_FLAGS_ANDROID_BUGS }, + /* https://sourceforge.net/p/libmtp/feature-requests/220/ */ + { "Kyocera", 0x0482, "Duraforce XD", 0x0a9a, DEVICE_FLAGS_ANDROID_BUGS }, /* * Hewlett-Packard @@ -3322,9 +3429,15 @@ /* https://sourceforge.net/p/libmtp/bugs/1467/ */ { "elephone", 0x0e8d, "p6000", 0x2008, DEVICE_FLAGS_ANDROID_BUGS }, + /* https://sourceforge.net/p/libmtp/feature-requests/234/ */ + { "DOODGE", 0x0e8d, "X6pro", 0x200a, + DEVICE_FLAGS_ANDROID_BUGS }, /* https://sourceforge.net/p/libmtp/feature-requests/79/ */ { "MediaTek Inc", 0x0e8d, "Elephone P8000", 0x201d, DEVICE_FLAGS_ANDROID_BUGS }, + /* https://sourceforge.net/p/libmtp/bugs/1717/ */ + { "MediaTek Inc", 0x0e8d, "Wiko Sunny", 0x4001, + DEVICE_FLAGS_ANDROID_BUGS }, /* * Jolla @@ -3398,6 +3511,8 @@ /* https://sourceforge.net/p/libmtp/bugs/1541/ */ { "bq", 0x2a47, "Aquarius M5.5", 0x901b, DEVICE_FLAGS_ANDROID_BUGS }, + /* https://sourceforge.net/p/libmtp/feature-requests/231/ */ + { "bq", 0x2a47, "U Plus", 0xf003, DEVICE_FLAGS_ANDROID_BUGS }, /* https://sourceforge.net/p/libmtp/bugs/1292/ */ { "Prestigio", 0x29e4, "5505 DUO ", 0x1103, DEVICE_FLAGS_ANDROID_BUGS }, @@ -3461,6 +3576,9 @@ /* https://sourceforge.net/p/libmtp/bugs/1212/ */ { "Fly", 0x2970, "Evo Tech 4", 0x2008, DEVICE_FLAGS_ANDROID_BUGS }, + /* https://sourceforge.net/p/libmtp/bugs/1720/ */ + { "Wileyfox", 0x2970, "Spark Plus", 0x2008, DEVICE_FLAGS_ANDROID_BUGS }, + /* https://sourceforge.net/p/libmtp/feature-requests/146/ */ { "Wileyfox", 0x2970, "Swift", 0x2281, DEVICE_FLAGS_ANDROID_BUGS }, /* https://sourceforge.net/p/libmtp/feature-requests/159/ */ @@ -3525,6 +3643,8 @@ /* https://sourceforge.net/p/libmtp/support-requests/214/ */ { "Fairphone" , 0x2ae5, "Fairphone 2 OS", 0x9039, DEVICE_FLAGS_ANDROID_BUGS }, + /* https://sourceforge.net/p/libmtp/bugs/1700/ */ + { "BLUE" , 0x271d, "Vivo XL", 0x4008, DEVICE_FLAGS_ANDROID_BUGS }, /* https://sourceforge.net/p/libmtp/bugs/1512/ */ { "Allview" , 0x271d, "Energy P5", 0x4016, DEVICE_FLAGS_ANDROID_BUGS }, /* https://sourceforge.net/p/libmtp/feature-requests/177/ */ @@ -3538,14 +3658,24 @@ /* https://sourceforge.net/p/libmtp/bugs/1596/ */ { "Zuk" , 0x2b4c, "Z1 (2nd ID)", 0x1005, DEVICE_FLAGS_ANDROID_BUGS }, + /* https://sourceforge.net/p/libmtp/support-requests/250/ */ + { "Zuk" , 0x2b4c, "Z2 Pro", 0x1013, DEVICE_FLAGS_ANDROID_BUGS }, + /* https://sourceforge.net/p/libmtp/bugs/1574/ */ { "Letv" , 0x2b0e, "X5001s", 0x1700, DEVICE_FLAGS_ANDROID_BUGS }, /* https://sourceforge.net/p/libmtp/support-requests/210/ */ { "Letv" , 0x2b0e, "1s", 0x1704, DEVICE_FLAGS_ANDROID_BUGS }, + /* https://sourceforge.net/p/libmtp/support-requests/241/ */ + { "Letv" , 0x2b0e, "Leeco Le 1s", 0x1768, DEVICE_FLAGS_ANDROID_BUGS }, + /* https://sourceforge.net/p/libmtp/support-requests/241/ */ + { "Letv" , 0x2b0e, "Leeco Le 2 Pro", 0x1778, DEVICE_FLAGS_ANDROID_BUGS }, /* https://sourceforge.net/p/libmtp/support-requests/220/ */ { "Letv" , 0x2b0e, "X800 (ID1)", 0x182c, DEVICE_FLAGS_ANDROID_BUGS }, { "Letv" , 0x2b0e, "X800 (ID2)", 0x1830, DEVICE_FLAGS_ANDROID_BUGS }, + /* https://sourceforge.net/p/libmtp/bugs/1716/ */ + { "Letv" , 0x2b0e, "Le Max2", 0x1840, DEVICE_FLAGS_ANDROID_BUGS }, + /* https://sourceforge.net/p/libmtp/bugs/1606/ */ { "TP-Link" , 0x2357, "Neffos C5 (MTP)", 0x0314, DEVICE_FLAGS_ANDROID_BUGS }, /* https://sourceforge.net/p/libmtp/feature-requests/197/ */ @@ -3554,6 +3684,8 @@ { "TP-Link" , 0x2357, "Neffos Y5L (MTP)", 0x0320, DEVICE_FLAGS_ANDROID_BUGS }, /* https://sourceforge.net/p/libmtp/feature-requests/195/ */ { "TP-Link" , 0x2357, "Neffos Y5 (MTP)", 0x0328, DEVICE_FLAGS_ANDROID_BUGS }, + /* https://sourceforge.net/p/libmtp/support-requests/240/ */ + { "TP-Link" , 0x2357, "Neffos X1 (MTP)", 0x033c, DEVICE_FLAGS_ANDROID_BUGS }, /* https://sourceforge.net/p/libmtp/bugs/1570/ */ { "Recon Instruments" , 0x2523, "Jet", 0xd209, DEVICE_FLAGS_ANDROID_BUGS }, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/libmtp-1.1.13/src/ptp-pack.c new/libmtp-1.1.14/src/ptp-pack.c --- old/libmtp-1.1.13/src/ptp-pack.c 2017-03-20 07:16:09.000000000 +0100 +++ new/libmtp-1.1.14/src/ptp-pack.c 2017-07-27 17:18:48.000000000 +0200 @@ -1,7 +1,7 @@ /* ptp-pack.c * * Copyright (C) 2001-2004 Mariusz Woloszyn <[email protected]> - * Copyright (C) 2003-2016 Marcus Meissner <[email protected]> + * Copyright (C) 2003-2017 Marcus Meissner <[email protected]> * Copyright (C) 2006-2008 Linus Walleij <[email protected]> * Copyright (C) 2007 Tero Saarni <[email protected]> * Copyright (C) 2009 Axel Waggershauser <[email protected]> @@ -1096,6 +1096,10 @@ unsigned int offset=0, ret; memset (opd, 0, sizeof(*opd)); + + if (opdlen < 5) + return 0; + opd->ObjectPropertyCode=dtoh16a(&data[PTP_opd_ObjectPropertyCode]); opd->DataType=dtoh16a(&data[PTP_opd_DataType]); opd->GetSet=dtoh8a(&data[PTP_opd_GetSet]); @@ -1338,24 +1342,32 @@ static inline int ptp_unpack_OPL (PTPParams *params, unsigned char* data, MTPProperties **pprops, unsigned int len) { - uint32_t prop_count = dtoh32a(data); + uint32_t prop_count; MTPProperties *props = NULL; unsigned int offset = 0, i; + if (len < sizeof(uint32_t)) { + ptp_debug (params ,"must have at least 4 bytes data, not %d", len); + return 0; + } + + prop_count = dtoh32a(data); *pprops = NULL; if (prop_count == 0) return 0; + if (prop_count >= INT_MAX/sizeof(MTPProperties)) { ptp_debug (params ,"prop_count %d is too large", prop_count); return 0; } ptp_debug (params ,"Unpacking MTP OPL, size %d (prop_count %d)", len, prop_count); + data += sizeof(uint32_t); len -= sizeof(uint32_t); props = malloc(prop_count * sizeof(MTPProperties)); if (!props) return 0; for (i = 0; i < prop_count; i++) { - if (len <= 0) { + if (len <= (sizeof(uint32_t) + sizeof(uint16_t) + sizeof(uint16_t))) { ptp_debug (params ,"short MTP Object Property List at property %d (of %d)", i, prop_count); ptp_debug (params ,"device probably needs DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST_ALL"); ptp_debug (params ,"or even DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST", i); @@ -1363,6 +1375,8 @@ *pprops = props; return i; } + + props[i].ObjectHandle = dtoh32a(data); data += sizeof(uint32_t); len -= sizeof(uint32_t); @@ -1528,10 +1542,12 @@ #define PTP_cefe_Time 48 static inline void -ptp_unpack_Canon_EOS_FE (PTPParams *params, unsigned char* data, PTPCANONFolderEntry *fe) +ptp_unpack_Canon_EOS_FE (PTPParams *params, unsigned char* data, unsigned int size, PTPCANONFolderEntry *fe) { int i; + if (size < PTP_cefe_Time + 4) return; + fe->ObjectHandle=dtoh32a(&data[PTP_cefe_ObjectHandle]); fe->ObjectFormatCode=dtoh16a(&data[PTP_cefe_ObjectFormatCode]); fe->Flags=dtoh8a(&data[PTP_cefe_Flags]); @@ -2165,6 +2181,7 @@ case PTP_DPC_CANON_EOS_EVFOutputDevice: case PTP_DPC_CANON_EOS_AutoPowerOff: case PTP_DPC_CANON_EOS_EVFRecordStatus: + case PTP_DPC_CANON_EOS_MultiAspect: /* actually a 32bit value, but lets try it for easyness */ dpd->DataType = PTP_DTC_UINT16; break; case PTP_DPC_CANON_EOS_PictureStyle: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/libmtp-1.1.13/src/ptp.c new/libmtp-1.1.14/src/ptp.c --- old/libmtp-1.1.13/src/ptp.c 2017-04-01 22:10:35.000000000 +0200 +++ new/libmtp-1.1.14/src/ptp.c 2017-07-27 17:19:37.000000000 +0200 @@ -170,6 +170,7 @@ ptp->SessionID=params->session_id; /* send request */ CHECK_PTP_RC(params->sendreq_func (params, ptp, flags)); + /* is there a dataphase? */ switch (flags&PTP_DP_DATA_MASK) { case PTP_DP_SENDDATA: @@ -182,10 +183,7 @@ break; case PTP_DP_GETDATA: { - uint16_t ret = params->getdata_func(params, ptp, handler); - if (ret == PTP_ERROR_CANCEL) - CHECK_PTP_RC(params->cancelreq_func(params, params->transaction_id-1)); - CHECK_PTP_RC(ret); + CHECK_PTP_RC(params->getdata_func(params, ptp, handler)); } break; case PTP_DP_NODATA: @@ -2476,15 +2474,34 @@ xdata = data+sizeof(uint32_t); for (i=0;i<*nrofentries;i++) { - if ((dtoh32a(xdata) + (xdata-data)) > size) { - ptp_debug (params, "reading canon FEs run over read data size?\n"); + unsigned int entrysize; + + if (4 + (xdata - data) > size) { + ptp_debug (params, "reading canon FEs run over read data size? (1)\n"); + free (*entries); + *entries = NULL; + *nrofentries = 0; + ret = PTP_RC_GeneralError; + goto exit; + } + entrysize = dtoh32a(xdata); + if ((entrysize + (xdata-data)) > size) { + ptp_debug (params, "reading canon FEs run over read data size? (2)\n"); + free (*entries); + *entries = NULL; + *nrofentries = 0; + ret = PTP_RC_GeneralError; + goto exit; + } + if (entrysize < 4 + 48 + 4) { + ptp_debug (params, "%d entry size %d does not match expected 56\n", i, entrysize); free (*entries); *entries = NULL; *nrofentries = 0; ret = PTP_RC_GeneralError; goto exit; } - ptp_unpack_Canon_EOS_FE (params, &xdata[4], &((*entries)[i])); + ptp_unpack_Canon_EOS_FE (params, &xdata[4], dtoh32a(xdata) - 4, &((*entries)[i])); xdata += dtoh32a(xdata); } exit: @@ -4235,6 +4252,7 @@ {PTP_RC_CANON_BATTERY_LOW, PTP_VENDOR_CANON, N_("Battery Low")}, {PTP_RC_CANON_NOT_READY, PTP_VENDOR_CANON, N_("Camera Not Ready")}, + {PTP_ERROR_NODEVICE, 0, N_("PTP No Device")}, {PTP_ERROR_TIMEOUT, 0, N_("PTP Timeout")}, {PTP_ERROR_CANCEL, 0, N_("PTP Cancel Request")}, {PTP_ERROR_BADPARAM, 0, N_("PTP Invalid Parameter")}, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/libmtp-1.1.13/src/ptp.h new/libmtp-1.1.14/src/ptp.h --- old/libmtp-1.1.13/src/ptp.h 2017-03-20 07:16:09.000000000 +0100 +++ new/libmtp-1.1.14/src/ptp.h 2017-07-27 17:20:04.000000000 +0200 @@ -1,7 +1,7 @@ /* ptp.h * * Copyright (C) 2001 Mariusz Woloszyn <[email protected]> - * Copyright (C) 2003-2014 Marcus Meissner <[email protected]> + * Copyright (C) 2003-2017 Marcus Meissner <[email protected]> * Copyright (C) 2006-2008 Linus Walleij <[email protected]> * * This library is free software; you can redistribute it and/or @@ -797,6 +797,7 @@ #define PTP_RC_MTP_WFC_Version_Not_Supported 0xA122 /* libptp2 extended ERROR codes */ +#define PTP_ERROR_NODEVICE 0x02F9 #define PTP_ERROR_TIMEOUT 0x02FA #define PTP_ERROR_CANCEL 0x02FB #define PTP_ERROR_BADPARAM 0x02FC @@ -2397,6 +2398,7 @@ typedef uint16_t (* PTPIOGetData) (PTPParams* params, PTPContainer* ptp, PTPDataHandler *putter); typedef uint16_t (* PTPIOCancelReq) (PTPParams* params, uint32_t transaction_id); +typedef uint16_t (* PTPIODevStatReq) (PTPParams* params); /* debug functions */ typedef void (* PTPErrorFunc) (void *data, const char *format, va_list args) @@ -2458,6 +2460,7 @@ PTPIOGetResp event_check_queue; PTPIOGetResp event_wait; PTPIOCancelReq cancelreq_func; + PTPIODevStatReq devstatreq_func; /* Custom error and debug function */ PTPErrorFunc error_func; @@ -2568,6 +2571,7 @@ uint16_t ptp_usb_control_device_reset_request (PTPParams *params); uint16_t ptp_usb_control_get_device_status (PTPParams *params, char *buffer, int *size); uint16_t ptp_usb_control_cancel_request (PTPParams *params, uint32_t transid); +uint16_t ptp_usb_control_device_status_request (PTPParams *params); int ptp_ptpip_connect (PTPParams* params, const char *port);
