diff options
author | Hyihong Chae <hh.chae@samsung.com> | 2015-11-16 22:01:01 +0900 |
---|---|---|
committer | Hyihong Chae <hh.chae@samsung.com> | 2015-11-16 22:01:01 +0900 |
commit | 5bee8a93b31a90c52fdaeb5db145448f7b390bb3 (patch) | |
tree | 83d73653216cad16fbdd741d7ba591f49b53de4c | |
parent | 9adc282feeef5d17c9840401bf0f9ab9408c10ee (diff) | |
download | libmtp-5bee8a93b31a90c52fdaeb5db145448f7b390bb3.tar.gz libmtp-5bee8a93b31a90c52fdaeb5db145448f7b390bb3.tar.bz2 libmtp-5bee8a93b31a90c52fdaeb5db145448f7b390bb3.zip |
Sync with Tizen 2.4submit/tizen/20151116.132242accepted/tizen/wearable/20151117.005750accepted/tizen/tv/20151117.005721accepted/tizen/mobile/20151117.005714
Change-Id: Id44a46bc610c43610b696c516276a7454a8c943e
Signed-off-by: HyiHong Chae <hh.chae@samsung.com>
-rwxr-xr-x | configure.ac | 4 | ||||
-rwxr-xr-x | packaging/libmtp.spec | 7 | ||||
-rwxr-xr-x | src/Makefile.am | 4 | ||||
-rwxr-xr-x | src/libmtp.c | 49 | ||||
-rwxr-xr-x | src/libmtp.h | 4 | ||||
-rwxr-xr-x | src/libmtp.h.in | 4 | ||||
-rwxr-xr-x | src/libusb1-glue.c | 83 | ||||
-rwxr-xr-x | src/ptp.c | 4 | ||||
-rwxr-xr-x | src/util.h | 11 |
9 files changed, 120 insertions, 50 deletions
diff --git a/configure.ac b/configure.ac index 528b015..da4e46b 100755 --- a/configure.ac +++ b/configure.ac @@ -164,6 +164,10 @@ else AC_MSG_NOTICE([MTPZ functionality disable]); fi +#TIZEN_EXT +PKG_CHECK_MODULES(DLOG, dlog) +AC_SUBST(DLOG_CFLAGS) +AC_SUBST(DLOG_LIBS) AC_SUBST(LIBUSB_CFLAGS) AC_SUBST(LIBUSB_LIBS) diff --git a/packaging/libmtp.spec b/packaging/libmtp.spec index 30f5368..0c404a7 100755 --- a/packaging/libmtp.spec +++ b/packaging/libmtp.spec @@ -3,19 +3,20 @@ Name: libmtp Summary: Library for media transfer protocol (mtp) Version: 1.1.9 -Release: 5 +Release: 8 Group: Network & Connectivity/Other License: LGPL-2.1 Source0: libmtp-%{version}.tar.gz # This package would be built only TV -%if "%{?tizen_profile_name}" != "tv" -ExcludeArch: %{arm} %ix86 x86_64 +%if "%{?profile}" != "tv" +ExcludeArch: %arm aarch64 %ix86 x86_64 %endif Requires(post): /sbin/ldconfig Requires(postun): /sbin/ldconfig BuildRequires: pkgconfig(libusb-1.0) +BuildRequires: pkgconfig(dlog) BuildRequires: libtool-ltdl-devel BuildRequires: gettext-devel diff --git a/src/Makefile.am b/src/Makefile.am index d00e372..6aede70 100755 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,6 +1,6 @@ lib_LTLIBRARIES = libmtp.la -libmtp_la_CFLAGS = @LIBUSB_CFLAGS@ +libmtp_la_CFLAGS = @LIBUSB_CFLAGS@ $(DLOG_CFLAGS) libmtp_la_SOURCES = libmtp.c unicode.c unicode.h util.c util.h playlist-spl.c \ gphoto2-endian.h _stdint.h ptp.c ptp.h libusb-glue.h \ music-players.h device-flags.h playlist-spl.h mtpz.h \ @@ -74,7 +74,7 @@ endif endif libmtp_la_LDFLAGS=@LDFLAGS@ -no-undefined -export-symbols $(srcdir)/libmtp.sym -version-info $(SOVERSION) $(W32_LDFLAGS) -libmtp_la_LIBADD=$(W32_LIBS) $(LTLIBICONV) @LIBUSB_LIBS@ +libmtp_la_LIBADD=$(W32_LIBS) $(LTLIBICONV) @LIBUSB_LIBS@ $(DLOG_LIBS) libmtp_la_DEPENDENCIES=$(srcdir)/libmtp.sym DISTCLEANFILES = _stdint.h gphoto2-endian.h diff --git a/src/libmtp.c b/src/libmtp.c index c16ddb5..c47feff 100755 --- a/src/libmtp.c +++ b/src/libmtp.c @@ -1683,7 +1683,7 @@ LIBMTP_mtpdevice_t *LIBMTP_Get_First_Device(void) return NULL; } -#if 1//defined TIZEN_EXT +#ifdef TIZEN_EXT if (devices == NULL) { return NULL; } @@ -2180,6 +2180,7 @@ int LIBMTP_Read_Event(LIBMTP_mtpdevice_t *device, LIBMTP_event_t *event, uint32_ if (ret != PTP_RC_OK) { /* Device is closing down or other fatal stuff, exit thread */ + LIBMTP_INFO("ptp_usb_event_wait ret %u\n", ret); return -1; } @@ -2327,7 +2328,7 @@ LIBMTP_error_number_t LIBMTP_Get_Connected_Devices(LIBMTP_mtpdevice_t **device_l } /* Assign linked list of devices */ -#if 1//defined TIZEN_EXT +#ifdef TIZEN_EXT if (devices == NULL) { *device_list = NULL; return LIBMTP_ERROR_NO_DEVICE_ATTACHED; @@ -9115,7 +9116,7 @@ static void update_metadata_cache(LIBMTP_mtpdevice_t *device, uint32_t object_id add_object_to_cache(device, object_id); } -#if 1//defined TIZEN_EXT +#ifdef TIZEN_EXT int _is_exist_handler(int **object_list, int size, int current_handler) { int i; @@ -9157,8 +9158,14 @@ int LIBMTP_Get_Object_Handles(LIBMTP_mtpdevice_t *device, uint32_t storage, ret = ptp_getobjecthandles(params, storageid, PTP_GOH_ALL_FORMATS, parentid, ¤tHandles); - if (ret != PTP_RC_OK) - return ret; + if (ret != PTP_RC_OK) { + LIBMTP_INFO("LIBMTP_Get_Object_Handles ret %u\n", ret); + return ret; + } + +#ifdef TIZEN_EXT + LIBMTP_INFO("LIBMTP_Get_Object_Handles currentHandles.n %u\n", currentHandles.n); +#endif /* TIZEN_EXT */ if (currentHandles.n == 0) { add_error_to_errorstack(device, LIBMTP_ERROR_GENERAL, @@ -9189,6 +9196,7 @@ int LIBMTP_Get_Object_Handles(LIBMTP_mtpdevice_t *device, uint32_t storage, MTPObjectInfo *LIBMTP_Get_Object_Info(LIBMTP_mtpdevice_t *device, uint32_t object_id) { PTPParams *params = (PTPParams *)device->params; + PTPObject *ob; MTPObjectInfo *object_info; uint16_t ret; @@ -9200,7 +9208,7 @@ MTPObjectInfo *LIBMTP_Get_Object_Info(LIBMTP_mtpdevice_t *device, uint32_t objec object_info = (MTPObjectInfo *)malloc(sizeof(MTPObjectInfo)); - ret = ptp_getobjectinfo(params, object_id, (PTPObjectInfo *)object_info); + ret = ptp_object_want(params, object_id, PTPOBJECT_OBJECTINFO_LOADED, &ob); if (ret != PTP_RC_OK) { if (object_info != NULL) @@ -9208,6 +9216,35 @@ MTPObjectInfo *LIBMTP_Get_Object_Info(LIBMTP_mtpdevice_t *device, uint32_t objec return NULL; } + object_info->StorageID = ob->oi.StorageID; + object_info->ObjectFormat = ob->oi.ObjectFormat; + object_info->ProtectionStatus = ob->oi.ProtectionStatus; + object_info->ObjectCompressedSize = ob->oi.ObjectCompressedSize; + object_info->ThumbFormat = ob->oi.ThumbFormat; + object_info->ThumbCompressedSize = ob->oi.ThumbCompressedSize; + object_info->ThumbPixWidth = ob->oi.ThumbPixWidth; + object_info->ThumbPixHeight = ob->oi.ThumbPixHeight; + object_info->ImagePixWidth = ob->oi.ImagePixWidth; + object_info->ImagePixHeight = ob->oi.ImagePixHeight; + object_info->ImageBitDepth = ob->oi.ImageBitDepth; + + object_info->ParentObject = ob->oi.ParentObject; + object_info->AssociationType = ob->oi.AssociationType; + object_info->AssociationDesc = ob->oi.AssociationDesc; + object_info->SequenceNumber = ob->oi.SequenceNumber; + object_info->CaptureDate = ob->oi.CaptureDate; + object_info->ModificationDate = ob->oi.ModificationDate; + + if (ob->oi.Filename != NULL) + object_info->Filename = strdup(ob->oi.Filename); + else + object_info->Filename = NULL; + + if (ob->oi.Keywords != NULL) + object_info->Keywords = strdup(ob->oi.Keywords); + else + object_info->Keywords = NULL; + object_info->ObjectFormat = map_ptp_type_to_libmtp_type(object_info->ObjectFormat); object_info->ThumbFormat = map_ptp_type_to_libmtp_type(object_info->ThumbFormat); diff --git a/src/libmtp.h b/src/libmtp.h index 1328818..47ea6a6 100755 --- a/src/libmtp.h +++ b/src/libmtp.h @@ -792,7 +792,7 @@ struct LIBMTP_devicestorage_struct { LIBMTP_devicestorage_t *prev; /**< Previous storage */ }; -#if 1//defined TIZEN_EXT +#ifdef TIZEN_EXT struct _MTPObjectInfo { uint32_t StorageID; uint16_t ObjectFormat; @@ -893,7 +893,7 @@ void LIBMTP_Dump_Errorstack(LIBMTP_mtpdevice_t*); int LIBMTP_Get_Storage(LIBMTP_mtpdevice_t *, int const); int LIBMTP_Format_Storage(LIBMTP_mtpdevice_t *, LIBMTP_devicestorage_t *); -#if 1//defined TIZEN_EXT +#ifdef TIZEN_EXT int LIBMTP_Get_Object_Handles(LIBMTP_mtpdevice_t *device, uint32_t storage, uint32_t format, uint32_t parent, uint32_t **object_list, uint32_t *object_num); MTPObjectInfo *LIBMTP_Get_Object_Info(LIBMTP_mtpdevice_t *device, uint32_t object_id); diff --git a/src/libmtp.h.in b/src/libmtp.h.in index 697dfe4..68d8443 100755 --- a/src/libmtp.h.in +++ b/src/libmtp.h.in @@ -792,7 +792,7 @@ struct LIBMTP_devicestorage_struct { LIBMTP_devicestorage_t *prev; /**< Previous storage */ }; -#if 1//defined TIZEN_EXT +#ifdef TIZEN_EXT struct _MTPObjectInfo { uint32_t StorageID; uint16_t ObjectFormat; @@ -893,7 +893,7 @@ void LIBMTP_Dump_Errorstack(LIBMTP_mtpdevice_t*); int LIBMTP_Get_Storage(LIBMTP_mtpdevice_t *, int const); int LIBMTP_Format_Storage(LIBMTP_mtpdevice_t *, LIBMTP_devicestorage_t *); -#if 1//defined TIZEN_EXT +#ifdef TIZEN_EXT int LIBMTP_Get_Object_Handles(LIBMTP_mtpdevice_t *device, uint32_t storage, uint32_t format, uint32_t parent, uint32_t **object_list, uint32_t *object_num); MTPObjectInfo *LIBMTP_Get_Object_Info(LIBMTP_mtpdevice_t *device, uint32_t object_id); diff --git a/src/libusb1-glue.c b/src/libusb1-glue.c index 2c69494..e187420 100755 --- a/src/libusb1-glue.c +++ b/src/libusb1-glue.c @@ -670,7 +670,7 @@ LIBMTP_error_number_t LIBMTP_Detect_Raw_Devices(LIBMTP_raw_device_t ** devices, // Out of memory *devices = NULL; *numdevs = 0; -#if 1//defined TIZEN_EXT +#ifdef TIZEN_EXT free_mtpdevice_list(devlist); #endif /* TIZEN_EXT */ return LIBMTP_ERROR_MEMORY_ALLOCATION; @@ -1606,37 +1606,56 @@ ptp_usb_event (PTPParams* params, PTPContainer* event, int wait) ptp_usb = (PTP_USB *)(params->data); ret = PTP_RC_OK; + +#ifdef TIZEN_EXT + LIBMTP_INFO("ptp_usb_event() wait[%d]", wait); +#endif /* TIZEN_EXT */ + switch(wait) { case PTP_EVENT_CHECK: - result = USB_BULK_READ(ptp_usb->handle, - ptp_usb->intep, - (unsigned char *) &usbevent, - sizeof(usbevent), - &xread, - 0); + result = USB_BULK_READ(ptp_usb->handle, + ptp_usb->intep, + (unsigned char *) &usbevent, + sizeof(usbevent), + &xread, + 0); +#ifdef TIZEN_EXT + LIBMTP_INFO("first PTP_EVENT_CHECK USB_BULK_READ() result[%d]", result); +#endif /* TIZEN_EXT */ + if (xread == 0) - result = USB_BULK_READ(ptp_usb->handle, - ptp_usb->intep, - (unsigned char *) &usbevent, - sizeof(usbevent), - &xread, - 0); + result = USB_BULK_READ(ptp_usb->handle, + ptp_usb->intep, + (unsigned char *) &usbevent, + sizeof(usbevent), + &xread, + 0); +#ifdef TIZEN_EXT + LIBMTP_INFO("second PTP_EVENT_CHECK USB_BULK_READ() result[%d]", result); +#endif /* TIZEN_EXT */ if (result < 0) ret = PTP_ERROR_IO; break; case PTP_EVENT_CHECK_FAST: - result = USB_BULK_READ(ptp_usb->handle, - ptp_usb->intep, - (unsigned char *) &usbevent, - sizeof(usbevent), - &xread, - ptp_usb->timeout); + result = USB_BULK_READ(ptp_usb->handle, + ptp_usb->intep, + (unsigned char *) &usbevent, + sizeof(usbevent), + &xread, + ptp_usb->timeout); +#ifdef TIZEN_EXT + LIBMTP_INFO("first PTP_EVENT_CHECK_FAST USB_BULK_READ() result[%d]", result); +#endif /* TIZEN_EXT */ + if (xread == 0) - result = USB_BULK_READ(ptp_usb->handle, - ptp_usb->intep, - (unsigned char *) &usbevent, - sizeof(usbevent), - &xread, - ptp_usb->timeout); + result = USB_BULK_READ(ptp_usb->handle, + ptp_usb->intep, + (unsigned char *) &usbevent, + sizeof(usbevent), + &xread, + ptp_usb->timeout); +#ifdef TIZEN_EXT + LIBMTP_INFO("second PTP_EVENT_CHECK_FAST USB_BULK_READ() result[%d]", result); +#endif /* TIZEN_EXT */ if (result < 0) ret = PTP_ERROR_IO; break; default: @@ -1720,7 +1739,7 @@ static int init_ptp_usb(PTPParams* params, PTP_USB* ptp_usb, libusb_device* dev) ret = libusb_open(dev, &device_handle); if (ret != LIBUSB_SUCCESS) { - perror("libusb_open() failed!"); + LIBMTP_ERROR("libusb_open() failed! ret[%d]", ret); return -1; } ptp_usb->handle = device_handle; @@ -1734,7 +1753,7 @@ static int init_ptp_usb(PTPParams* params, PTP_USB* ptp_usb, libusb_device* dev) libusb_kernel_driver_active(device_handle, ptp_usb->interface) ) { if (LIBUSB_SUCCESS != libusb_detach_kernel_driver(device_handle, ptp_usb->interface)) { - perror("libusb_detach_kernel_driver() failed, continuing anyway..."); + LIBMTP_ERROR("libusb_detach_kernel_driver() failed, continuing anyway..."); } } @@ -1748,27 +1767,27 @@ static int init_ptp_usb(PTPParams* params, PTP_USB* ptp_usb, libusb_device* dev) */ ret = libusb_get_active_config_descriptor(dev, &config); if (ret != LIBUSB_SUCCESS) { - perror("libusb_get_active_config_descriptor(1) failed"); + LIBMTP_ERROR("libusb_get_active_config_descriptor(1) failed"); fprintf(stderr, "no active configuration, trying to set configuration\n"); if (libusb_set_configuration(device_handle, ptp_usb->config) != LIBUSB_SUCCESS) { - perror("libusb_set_configuration() failed, continuing anyway..."); + LIBMTP_ERROR("libusb_set_configuration() failed, continuing anyway..."); } ret = libusb_get_active_config_descriptor(dev, &config); if (ret != LIBUSB_SUCCESS) { - perror("libusb_get_active_config_descriptor(2) failed"); + LIBMTP_ERROR("libusb_get_active_config_descriptor(2) failed"); return -1; } } if (config->bConfigurationValue != ptp_usb->config) { fprintf(stderr, "desired configuration different from current, trying to set configuration\n"); if (libusb_set_configuration(device_handle, ptp_usb->config)) { - perror("libusb_set_configuration() failed, continuing anyway..."); + LIBMTP_ERROR("libusb_set_configuration() failed, continuing anyway..."); } /* Re-fetch the config descriptor if we changed */ libusb_free_config_descriptor(config); ret = libusb_get_active_config_descriptor(dev, &config); if (ret != LIBUSB_SUCCESS) { - perror("libusb_get_active_config_descriptor(2) failed"); + LIBMTP_ERROR("libusb_get_active_config_descriptor(2) failed"); return -1; } } @@ -1240,8 +1240,8 @@ ptp_getobjecthandles (PTPParams* params, uint32_t storage, if (ret == PTP_RC_OK) { ptp_unpack_OH(params, oh, objecthandles, len); } else { - if ( (storage == 0xffffffff) && -#if 1//defined TIZEN_EXT + if ((storage == 0xffffffff) && +#ifdef TIZEN_EXT (associationOH == 0xffffffff) #else /* TIZEN_EXT */ (objectformatcode == 0) && @@ -23,6 +23,9 @@ #ifndef __MTP__UTIL__H #define __MTP__UTIL__H #include "config.h" // To get HAVE_STRNDUP +#ifdef TIZEN_EXT +#include <dlog.h> +#endif /* TIZEN_EXT */ void data_dump(FILE *f, void *buf, uint32_t nbytes); void data_dump_ascii (FILE *f, void *buf, uint32_t n, uint32_t dump_boundry); @@ -30,6 +33,12 @@ void data_dump_ascii (FILE *f, void *buf, uint32_t n, uint32_t dump_boundry); char *strndup (const char *s, size_t n); #endif +#ifdef TIZEN_EXT +#define DLOG_TAG "LIBMTP" + +#define LIBMTP_INFO(format, arg...) LOG(LOG_ERROR, DLOG_TAG, format, ##arg) +#define LIBMTP_ERROR(format, arg...) LOG(LOG_ERROR, DLOG_TAG, format, ##arg) +#else /* TIZEN_EXT */ /** * Info macro */ @@ -51,6 +60,6 @@ char *strndup (const char *s, size_t n); else \ fprintf(stderr, format, ##args); \ } while (0) - +#endif /* TIZEN_EXT */ #endif //__MTP__UTIL__H |