Minor patch in libmtp 92/98292/1 accepted/tizen_common accepted/tizen_ivi accepted/tizen_mobile accepted/tizen_tv accepted/tizen/common/20161118.090655 accepted/tizen/ivi/20161121.012103 accepted/tizen/mobile/20161121.012025 accepted/tizen/tv/20161121.012040 accepted/tizen/unified/20170309.040123 submit/tizen/20161118.061041 submit/tizen_unified/20170308.100414
authorJihoon Jung <jh8801.jung@samsung.com>
Tue, 15 Nov 2016 02:11:27 +0000 (11:11 +0900)
committerJihoon Jung <jh8801.jung@samsung.com>
Thu, 17 Nov 2016 02:56:09 +0000 (11:56 +0900)
- Modify Get partial object function
- Fix for overflow issue
- Add log

Change-Id: Id6a3915b708c5ade534b7938328e1d53cdc931fd

packaging/libmtp.spec
src/libmtp.c
src/libmtp.h
src/libmtp.h.in
src/libusb1-glue.c

index 118d1a5..cb25aec 100755 (executable)
@@ -3,7 +3,7 @@
 Name:       libmtp
 Summary:    Library for media transfer protocol (mtp)
 Version:    1.1.11
-Release:    1
+Release:    2
 Group:      Network & Connectivity/Other
 License:    LGPL-2.1
 Source0:    libmtp-%{version}.tar.gz
index 28249e1..cf34a72 100755 (executable)
@@ -3143,33 +3143,33 @@ void LIBMTP_Dump_Device_Info(LIBMTP_mtpdevice_t *device)
            tmpext->minor);
     tmpext = tmpext->next;
   }
-  printf("Supported operations:\n");
+  LIBMTP_INFO("Supported operations:");
   for (i=0;i<params->deviceinfo.OperationsSupported_len;i++) {
     char txt[256];
 
     (void) ptp_render_opcode(params, params->deviceinfo.OperationsSupported[i],
                             sizeof(txt), txt);
-    printf("   %04x: %s\n", params->deviceinfo.OperationsSupported[i], txt);
+    LIBMTP_INFO("   %04x: %s", params->deviceinfo.OperationsSupported[i], txt);
   }
-  printf("Events supported:\n");
+  LIBMTP_INFO("Events supported:\n");
   if (params->deviceinfo.EventsSupported_len == 0) {
-    printf("   None.\n");
+    LIBMTP_INFO("   None.\n");
   } else {
     for (i=0;i<params->deviceinfo.EventsSupported_len;i++) {
-      printf("   0x%04x\n", params->deviceinfo.EventsSupported[i]);
+      LIBMTP_INFO("   0x%04x\n", params->deviceinfo.EventsSupported[i]);
     }
   }
-  printf("Device Properties Supported:\n");
+  LIBMTP_INFO("Device Properties Supported:\n");
   for (i=0;i<params->deviceinfo.DevicePropertiesSupported_len;i++) {
     char const *propdesc = ptp_get_property_description(params,
                        params->deviceinfo.DevicePropertiesSupported[i]);
 
     if (propdesc != NULL) {
-      printf("   0x%04x: %s\n",
+      LIBMTP_INFO("   0x%04x: %s\n",
             params->deviceinfo.DevicePropertiesSupported[i], propdesc);
     } else {
       uint16_t prop = params->deviceinfo.DevicePropertiesSupported[i];
-      printf("   0x%04x: Unknown property\n", prop);
+      LIBMTP_INFO("   0x%04x: Unknown property\n", prop);
     }
   }
 
@@ -9066,32 +9066,34 @@ int LIBMTP_Get_Thumbnail_From_Exif_Data(LIBMTP_mtpdevice_t *device, uint32_t con
 #endif /* TIZEN_EXT */
 
 int LIBMTP_GetPartialObject(LIBMTP_mtpdevice_t *device, uint32_t const id,
-                            uint64_t offset, uint32_t maxbytes,
+                            uint32_t offset, uint32_t maxbytes,
                             unsigned char **data, unsigned int *size)
 {
   PTPParams *params = (PTPParams *) device->params;
   uint16_t ret;
+  PTPObject *ob;
 
-  if (!ptp_operation_issupported(params, PTP_OC_ANDROID_GetPartialObject64)) {
-    if  (!ptp_operation_issupported(params, PTP_OC_GetPartialObject)) {
-      add_error_to_errorstack(device, LIBMTP_ERROR_GENERAL,
-        "LIBMTP_GetPartialObject: PTP_OC_GetPartialObject not supported");
-      return -1;
-    }
+  if  (!ptp_operation_issupported(params, PTP_OC_GetPartialObject)) {
+       add_error_to_errorstack(device, LIBMTP_ERROR_GENERAL,
+       "LIBMTP_GetPartialObject: PTP_OC_GetPartialObject not supported");
+       return -1;
+  }
 
-    if (offset >> 32 != 0) {
-      add_error_to_errorstack(device, LIBMTP_ERROR_GENERAL,
-        "LIBMTP_GetPartialObject: PTP_OC_GetPartialObject only supports 32bit offsets");
-      return -1;
-    }
+  if (ptp_object_want(params, id, PTPOBJECT_OBJECTINFO_LOADED, &ob) != PTP_RC_OK) {
+    LIBMTP_INFO("ptp_object_want fail - id %d", id);
+    return -2;
+  }
 
-    ret = ptp_getpartialobject(params, id, (uint32_t)offset, maxbytes, data, size);
-  } else {
-    ret = ptp_android_getpartialobject64(params, id, offset, maxbytes, data, size);
+  if (offset >> 32 != 0) {
+    add_error_to_errorstack(device, LIBMTP_ERROR_GENERAL,
+      "LIBMTP_GetPartialObject: PTP_OC_GetPartialObject only supports 32bit offsets");
+    return -3;
   }
+
+  ret = ptp_getpartialobject(params, id, offset, maxbytes, data, size);
   if (ret == PTP_RC_OK)
       return 0;
-  return -1;
+  return ret;
 }
 
 
index 704c050..1a05aa1 100755 (executable)
@@ -1079,7 +1079,7 @@ int LIBMTP_Set_Album_Name(LIBMTP_mtpdevice_t *, LIBMTP_album_t *, const char *);
 int LIBMTP_Delete_Object(LIBMTP_mtpdevice_t *, uint32_t);
 int LIBMTP_Set_Object_Filename(LIBMTP_mtpdevice_t *, uint32_t , char *);
 int LIBMTP_GetPartialObject(LIBMTP_mtpdevice_t *, uint32_t const,
-                            uint64_t, uint32_t,
+                            uint32_t, uint32_t,
                             unsigned char **, unsigned int *);
 int LIBMTP_SendPartialObject(LIBMTP_mtpdevice_t *, uint32_t const,
                              uint64_t, unsigned char *, unsigned int);
index d10a624..024fce9 100755 (executable)
@@ -1079,7 +1079,7 @@ int LIBMTP_Set_Album_Name(LIBMTP_mtpdevice_t *, LIBMTP_album_t *, const char *);
 int LIBMTP_Delete_Object(LIBMTP_mtpdevice_t *, uint32_t);
 int LIBMTP_Set_Object_Filename(LIBMTP_mtpdevice_t *, uint32_t , char *);
 int LIBMTP_GetPartialObject(LIBMTP_mtpdevice_t *, uint32_t const,
-                            uint64_t, uint32_t,
+                            uint32_t, uint32_t,
                             unsigned char **, unsigned int *);
 int LIBMTP_SendPartialObject(LIBMTP_mtpdevice_t *, uint32_t const,
                              uint64_t, unsigned char *, unsigned int);
index ef13f03..c39603f 100755 (executable)
@@ -905,12 +905,24 @@ ptp_read_func (
 
     LIBMTP_USB_DEBUG("Reading in 0x%04lx bytes\n", toread);
 
-    ret = USB_BULK_READ(ptp_usb->handle,
+    if (ptp_usb->params != NULL &&
+               ptp_usb->params->deviceinfo.Model != NULL &&
+               !strcmp(ptp_usb->params->deviceinfo.Model, "SM-C200")) {
+                ret = USB_BULK_READ(ptp_usb->handle,
+                         ptp_usb->inep,
+                         bytes,
+                         CONTEXT_BLOCK_SIZE,
+                                                                 &xread,
+                         ptp_usb->timeout);
+    }
+    else {
+        ret = USB_BULK_READ(ptp_usb->handle,
                           ptp_usb->inep,
                           bytes,
                           toread,
                            &xread,
                           ptp_usb->timeout);
+       }
 
     LIBMTP_USB_DEBUG("Result of read: 0x%04x (%d bytes)\n", ret, xread);