Add mtp_get_partial_object API in internal api 48/98648/1 accepted/tizen_common accepted/tizen_ivi accepted/tizen_mobile accepted/tizen_tv accepted/tizen/common/20161118.090704 accepted/tizen/ivi/20161121.012106 accepted/tizen/mobile/20161121.012029 accepted/tizen/tv/20161121.012043 accepted/tizen/unified/20170309.032053 submit/tizen/20161118.061041 submit/tizen_unified/20170308.100405
authorJihoon Jung <jh8801.jung@samsung.com>
Tue, 15 Nov 2016 02:13:22 +0000 (11:13 +0900)
committerJihoon Jung <jh8801.jung@samsung.com>
Fri, 18 Nov 2016 05:54:03 +0000 (14:54 +0900)
Change-Id: I788a4a0c6b262ff312e18644f5213c2066b70182

include/mtp_gdbus_manager.h
include/mtp_internal.h
src/mtp.c
src/mtp_gdbus_manager.c
src/mtp_gdbuslib.xml
test/mtp_unit_test.c

index 70e4cbf..6af61aa 100755 (executable)
@@ -28,6 +28,8 @@ mtp_error_e mtp_gdbus_manager_get_object_handles(int mtp_device,
 mtp_error_e mtp_gdbus_manager_delete_object(int mtp_device, int object_handle);
 mtp_error_e mtp_gdbus_manager_get_object(int mtp_device,
        int object_handle, char *dest_path);
+mtp_error_e mtp_gdbus_manager_get_partial_object(int mtp_device,
+       int object_handle, char *dest_path, int offset, int max_bytes, int *actual_written);
 mtp_error_e mtp_gdbus_manager_get_thumbnail(int mtp_device,
        int object_handle, char *dest_path);
 mtp_error_e mtp_gdbus_manager_add_event_cb(mtp_event_cb callback, void *user_data);
index 822dc21..7a16e69 100755 (executable)
@@ -53,6 +53,7 @@ int mtp_objectinfo_get_object_info(int mtp_device, int object_handle, mtp_object
 int mtp_delete_object(mtp_device_h mtp_device, mtp_object_h object_handle);
 int mtp_deviceinfo_get_bus_location(mtp_device_h mtp_device, int *bus_locaton);
 int mtp_deviceinfo_get_device_number(mtp_device_h mtp_device, int *device_number);
+int mtp_get_partial_object(int mtp_device, int object_handle, char *dest_path, int offset, int max_bytes, int *actual_written);
 
 #ifdef __cplusplus
 }
index 8f84169..0c3eae3 100755 (executable)
--- a/src/mtp.c
+++ b/src/mtp.c
@@ -243,6 +243,34 @@ int mtp_get_object(int mtp_device, int object_handle, char *dest_path)
        /* LCOV_EXCL_STOP */
 }
 
+int mtp_get_partial_object(int mtp_device, int object_handle, char *dest_path, int offset, int max_bytes, int *actual_written)
+{
+       int ret = MTP_ERROR_NONE;
+
+       _BEGIN();
+
+       /* precondition check start */
+
+       CHECK_SUPPORTED();
+       CHECK_INIT();
+       CHECK_ACTIVATED();
+       cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER);
+       cond_expr_ret(offset < 0, MTP_ERROR_INVALID_PARAMETER);
+       cond_expr_ret(max_bytes < 0, MTP_ERROR_INVALID_PARAMETER);
+
+       /* LCOV_EXCL_START */
+       cond_expr_ret(dest_path == NULL, MTP_ERROR_INVALID_PARAMETER);
+
+       /* precondition check end */
+
+       ret = mtp_gdbus_manager_get_partial_object(mtp_device, object_handle, dest_path, offset, max_bytes, actual_written);
+
+       _END();
+
+       return ret;
+       /* LCOV_EXCL_STOP */
+}
+
 int mtp_get_thumbnail(int mtp_device, int object_handle, char *dest_path)
 {
        int ret = MTP_ERROR_NONE;
index f3869b8..ff2e427 100755 (executable)
@@ -320,6 +320,34 @@ mtp_error_e mtp_gdbus_manager_get_object(int mtp_device,
        return result;
 }
 
+mtp_error_e mtp_gdbus_manager_get_partial_object(int mtp_device,
+       int object_handle, char *dest_path, int offset, int max_bytes, int *actual_written)
+{
+       mtp_error_e result = MTP_ERROR_NONE;
+       GError *error = NULL;
+
+       if (manager_proxy == NULL)
+                       return MTP_ERROR_NOT_COMM_INITIALIZED;
+
+       if (mtp_gdbuslib_manager_call_get_partial_object_sync(
+                       manager_proxy,
+                       mtp_device,
+                       object_handle,
+                       dest_path,
+                       offset,
+                       max_bytes,
+                       actual_written,
+                       &result,
+                       NULL,
+                       &error) == FALSE) {
+               result = MTP_ERROR_COMM_ERROR;
+
+               g_error_free(error);
+       }
+
+       return result;
+}
+
 mtp_error_e mtp_gdbus_manager_get_thumbnail(int mtp_device,
        int object_handle, char *dest_path)
 {
index 03998e3..f497f7e 100755 (executable)
                        <arg type="i" name="result" direction="out" />
                </method>
 
+               <method name="GetPartialObject">
+                       <arg type="i" name="mtp_device" direction="in" />
+                       <arg type="i" name="object_handle" direction="in" />
+                       <arg type="s" name="dest_path" direction="in" />
+                       <arg type="i" name="offset" direction="in" />
+                       <arg type="i" name="max_bytes" direction="in" />
+                       <arg type="i" name="actual_written" direction="out" />
+                       <arg type="i" name="result" direction="out" />
+               </method>
+
                <method name="GetThumbnail">
                        <arg type="i" name="mtp_device" direction="in" />
                        <arg type="i" name="object_handle" direction="in" />
index 03bbbe2..e3c9d51 100755 (executable)
@@ -10,7 +10,7 @@
 #include <mtp_internal.h>
 
 #define BUFFER_LEN 100
-#define TEST_CASE_MAX 38
+#define TEST_CASE_MAX 39
 #define TEST_LIST_MAX 20
 
 #define PRT(format, args...) printf("%s:%d() "format, __FUNCTION__, __LINE__, ##args)
@@ -363,6 +363,46 @@ int manager_test_get_object(void)
        return ret;
 }
 
+int manager_test_get_partial_object(void)
+{
+       int ret = 0;
+       int i;
+       int input_int = 0;
+       mtp_filetype_e filetype = MTP_FILETYPE_JPEG;
+       char *filename = NULL;
+       char filepath[100] = {0,};
+       int list_max = 0;
+       int actual_written;
+
+       BEGIN();
+
+       TC_PRT("total object_num[%d]", obj_count);
+
+       list_max = (obj_count < TEST_LIST_MAX) ? obj_count : TEST_LIST_MAX;
+
+       for (i = 0; i < list_max; i++) {
+               ret = mtp_objectinfo_get_file_name(mtp_device, mtp_objects[i], &filename);
+               ret = mtp_objectinfo_get_file_type(mtp_device, mtp_objects[i], &filetype);
+               TC_PRT("ret[%d]: object id[%d] - filename[%s], filetype[%s]",
+                       ret, mtp_objects[i], filename, test_filetype_to_string(filetype));
+       }
+
+       if (!test_get_user_int("==> Input Object ID :", &input_int)) {
+               TC_PRT("Invalid Input !!![%d]", input_int);
+               END();
+               return -1;
+       }
+
+       snprintf(filepath, 100, "/tmp/JpegObject_%d.jpg", input_int);
+       TC_PRT("filepath[%s]", filepath);
+
+       ret = mtp_get_partial_object(mtp_device, input_int, filepath, 0, 250000, &actual_written);
+       TC_PRT("ret[%d]: input id[%d], actual written bytes[%d]", ret, input_int, actual_written);
+
+       END();
+       return ret;
+}
+
 
 int manager_test_get_thumbnail(void)
 {
@@ -1121,6 +1161,7 @@ tc_table_t tc_table[] = {
        {"get object handle using ALL Image file type", 35,     application_test_get_object_handle_using_all_image},
        {"test add callback function",                                  36,     application_test_add_event_callback},
        {"test remove callback function",                               37,     application_test_remove_event_callback},
+       {"mtp_get_partial_object",                                                      38,     manager_test_get_partial_object},
        {"get object and get thumbnail test",                   TEST_CASE_MAX,  NULL},
 
        /*-----------*/