From 5daeaaa22f47680ac5804d8d8a8a55b116e5b008 Mon Sep 17 00:00:00 2001 From: Hyihong Chae Date: Mon, 26 Oct 2015 14:48:39 +0900 Subject: [PATCH 02/11] Code Sync up from tizen_2.4 Change-Id: Icbef7a255d37531e0549daac644ea8ca8cbca668 Signed-off-by: HyiHong Chae --- AUTHORS | 1 + CMakeLists.txt | 90 +++ LICENSE.APLv2 | 206 +++++++ NOTICE | 3 + capi-network-mtp.manifest | 6 + capi-network-mtp.pc.in | 15 + include/mtp.h | 747 +++++++++++++++++++++++ include/mtp_db.h | 37 ++ include/mtp_debug.h | 93 +++ include/mtp_gdbus.h | 32 + include/mtp_gdbus_deviceinfo.h | 30 + include/mtp_gdbus_manager.h | 39 ++ include/mtp_gdbus_objectinfo.h | 30 + include/mtp_gdbus_storageinfo.h | 36 ++ include/mtp_internal.h | 58 ++ packaging/capi-network-mtp.spec | 68 +++ src/mtp.c | 1027 ++++++++++++++++++++++++++++++++ src/mtp_db.c | 143 +++++ src/mtp_gdbus_deviceinfo.c | 124 ++++ src/mtp_gdbus_manager.c | 348 +++++++++++ src/mtp_gdbus_objectinfo.c | 86 +++ src/mtp_gdbus_storageinfo.c | 155 +++++ src/mtp_gdbuslib.xml | 138 +++++ test/CMakeLists.txt | 18 + test/mtp_unit_test.c | 1254 +++++++++++++++++++++++++++++++++++++++ 25 files changed, 4784 insertions(+) create mode 100755 AUTHORS create mode 100755 CMakeLists.txt create mode 100755 LICENSE.APLv2 create mode 100755 NOTICE create mode 100755 capi-network-mtp.manifest create mode 100755 capi-network-mtp.pc.in create mode 100755 include/mtp.h create mode 100755 include/mtp_db.h create mode 100755 include/mtp_debug.h create mode 100755 include/mtp_gdbus.h create mode 100755 include/mtp_gdbus_deviceinfo.h create mode 100755 include/mtp_gdbus_manager.h create mode 100755 include/mtp_gdbus_objectinfo.h create mode 100755 include/mtp_gdbus_storageinfo.h create mode 100755 include/mtp_internal.h create mode 100755 packaging/capi-network-mtp.spec create mode 100755 src/mtp.c create mode 100755 src/mtp_db.c create mode 100755 src/mtp_gdbus_deviceinfo.c create mode 100755 src/mtp_gdbus_manager.c create mode 100755 src/mtp_gdbus_objectinfo.c create mode 100755 src/mtp_gdbus_storageinfo.c create mode 100755 src/mtp_gdbuslib.xml create mode 100755 test/CMakeLists.txt create mode 100755 test/mtp_unit_test.c diff --git a/AUTHORS b/AUTHORS new file mode 100755 index 0000000..d8dcd77 --- /dev/null +++ b/AUTHORS @@ -0,0 +1 @@ +Jihoon Jung diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100755 index 0000000..eba39c8 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,90 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) + +# project +SET(project_prefix "capi") +SET(prefix "/usr") +SET(libdir ${LIB_INSTALL_DIR}) +SET(version "0.0.1") +SET(maintainer "Jihoon Jung ") +SET(description "A MTP library in Tizen Native API") +SET(service "network") +SET(submodule "mtp") + +# for package file +SET(dependents "dlog glib-2.0 gio-2.0 capi-base-common gio-unix-2.0 sqlite3") +SET(pc_dependents "capi-base-common") + +SET(fw_name "${project_prefix}-${service}-${submodule}") + +FIND_PROGRAM(GDBUS_CODEGEN NAMES gdbus-codegen) +EXEC_PROGRAM(${GDBUS_CODEGEN} ARGS + " \\ + --generate-c-code ${CMAKE_CURRENT_SOURCE_DIR}/src/mtp_gdbuslib \\ + --c-namespace mtp_gdbuslib \\ + --interface-prefix org.tizen.mtp. \\ + ${CMAKE_CURRENT_SOURCE_DIR}/src/mtp_gdbuslib.xml \\ + ") + +PROJECT(${fw_name}) + +SET(CMAKE_INSTALL_PREFIX ${prefix}) +SET(PREFIX ${CMAKE_INSTALL_PREFIX}) +SET(VERSION ${version}) + +SET(INC_DIR include) +INCLUDE_DIRECTORIES(${INC_DIR}) +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src) + +INCLUDE(FindPkgConfig) +pkg_check_modules(${fw_name} REQUIRED ${dependents}) +FOREACH(flag ${${fw_name}_CFLAGS}) + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") +ENDFOREACH(flag) + +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -Werror") +SET(CMAKE_C_FLAGS_DEBUG "-O0 -g") + +ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"") +ADD_DEFINITIONS("-DTIZEN_DEBUG") + +SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=%{_libdir}") + +SET(SOURCES src/mtp.c + src/mtp_gdbuslib.c + src/mtp_gdbus_deviceinfo.c + src/mtp_gdbus_manager.c + src/mtp_gdbus_storageinfo.c + src/mtp_gdbus_objectinfo.c + src/mtp_db.c) + +ADD_LIBRARY(${fw_name} SHARED ${SOURCES}) + +TARGET_LINK_LIBRARIES(${fw_name} ${${fw_name}_LDFLAGS}) + +SET_TARGET_PROPERTIES(${fw_name} + PROPERTIES + VERSION ${FULLVER} + SOVERSION ${MAJORVER} + CLEAN_DIRECT_OUTPUT 1 +) + +INSTALL(TARGETS ${fw_name} DESTINATION ${libdir}) +INSTALL( + DIRECTORY ${INC_DIR}/ DESTINATION include + FILES_MATCHING + PATTERN "${INC_DIR}/*.h" + ) + +SET(PC_NAME ${fw_name}) +SET(PC_REQUIRED ${pc_dependents}) +SET(PC_LDFLAGS -l${fw_name}) + +CONFIGURE_FILE( + ${fw_name}.pc.in + ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc + @ONLY +) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc DESTINATION ${libdir}/pkgconfig) + +ADD_SUBDIRECTORY(test) + diff --git a/LICENSE.APLv2 b/LICENSE.APLv2 new file mode 100755 index 0000000..2e43946 --- /dev/null +++ b/LICENSE.APLv2 @@ -0,0 +1,206 @@ +Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved. + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + + diff --git a/NOTICE b/NOTICE new file mode 100755 index 0000000..0e0f016 --- /dev/null +++ b/NOTICE @@ -0,0 +1,3 @@ +Copyright (c) Samsung Electronics Co., Ltd. All rights reserved. +Except as noted, this software is licensed under Apache License, Version 2. +Please, see the LICENSE.APLv2 file for Apache License terms and conditions. diff --git a/capi-network-mtp.manifest b/capi-network-mtp.manifest new file mode 100755 index 0000000..ca37499 --- /dev/null +++ b/capi-network-mtp.manifest @@ -0,0 +1,6 @@ + + + + + + diff --git a/capi-network-mtp.pc.in b/capi-network-mtp.pc.in new file mode 100755 index 0000000..c45e5b2 --- /dev/null +++ b/capi-network-mtp.pc.in @@ -0,0 +1,15 @@ + +# Package Information for pkg-config + +prefix=@PREFIX@ +exec_prefix=/usr +libdir=@libdir@ +includedir=/usr/include/ + +Name: @PC_NAME@ +Description: @PACKAGE_DESCRIPTION@ +Version: @VERSION@ +Requires: @PC_REQUIRED@ +Libs: -L${libdir} @PC_LDFLAGS@ +Cflags: -I${includedir} + diff --git a/include/mtp.h b/include/mtp.h new file mode 100755 index 0000000..1297417 --- /dev/null +++ b/include/mtp.h @@ -0,0 +1,747 @@ +/* + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __MTP_H__ +#define __MTP_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef MTP_API +#define MTP_API +#endif + +/** + * @file mtp.h + * @brief This file contains the MTP API + */ +#define MTP_ERROR_CLASS TIZEN_ERROR_NETWORK_CLASS /* Need define mtp error class */ + +/** + * @brief Structure for mtp device + * @since_tizen 3.0 + * @ingroup CAPI_NETWORK_MTP_MANAGER_MODULE + */ +typedef struct _mtp_device { + int bus_location; + char *model_name; +} mtp_device; + +/** + * @brief Structure for mtp device list + * @since_tizen 3.0 + * @ingroup CAPI_NETWORK_MTP_MANAGER_MODULE + */ +typedef struct _mtp_device_list { + mtp_device *devices; + int device_num; +} mtp_device_list; + +/** + * @brief Error codes reported by the MTP API. + * @since_tizen 3.0 + * @ingroup CAPI_NETWORK_MTP_MANAGER_MODULE + */ +typedef enum { + MTP_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */ + MTP_ERROR_GENERAL = MTP_ERROR_CLASS | 0x01, /**< A general error occurred */ + MTP_ERROR_IO_ERROR = TIZEN_ERROR_IO_ERROR, /**< I/O error */ + MTP_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */ + MTP_ERROR_NO_DEVICE = MTP_ERROR_CLASS | 0x02, /**< MTP have not any device */ + MTP_ERROR_ALLOC_FAIL = MTP_ERROR_CLASS | 0x03, /**< Memory Allocation failed */ + MTP_ERROR_PLUGIN = MTP_ERROR_CLASS | 0x04, /**< Plugin failed */ + MTP_ERROR_DB = MTP_ERROR_CLASS | 0x05, /**< Plugin failed */ + MTP_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */ + MTP_ERROR_NOT_INITIALIZED = MTP_ERROR_CLASS | 0x06, /**< MTP is not supported */ + MTP_ERROR_NOT_ACTIVATED = MTP_ERROR_CLASS | 0x07, /**< MTP is not activated */ + MTP_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< MTP is not supported */ +} mtp_error_e; + +/** + * @brief Enumerations for MTP file type + * @since_tizen 3.0 + * @ingroup CAPI_NETWORK_MTP_MANAGER_MODULE + */ +typedef enum { + MTP_FILETYPE_FOLDER, /**< FOLDER file type */ + MTP_FILETYPE_WAV, /**< WAV file type */ + MTP_FILETYPE_MP3, /**< MP3 file type */ + MTP_FILETYPE_WMA, /**< WMA file type */ + MTP_FILETYPE_OGG, /**< OGG file type */ + MTP_FILETYPE_AUDIBLE, /**< AUDIBLE file type */ + MTP_FILETYPE_MP4, /**< MP4 file type */ + MTP_FILETYPE_UNDEF_AUDIO, /**< UNDEF_AUDIO file type */ + MTP_FILETYPE_WMV, /**< WMV file type */ + MTP_FILETYPE_AVI, /**< AVI file type */ + MTP_FILETYPE_MPEG, /**< MPEG file type */ + MTP_FILETYPE_ASF, /**< ASF file type */ + MTP_FILETYPE_QT, /**< QT file type */ + MTP_FILETYPE_UNDEF_VIDEO, /**< UNDEF_VIDEO file type */ + MTP_FILETYPE_JPEG, /**< JPEG file type */ + MTP_FILETYPE_JFIF, /**< JFIF file type */ + MTP_FILETYPE_TIFF, /**< TIFF file type */ + MTP_FILETYPE_BMP, /**< BMP file type */ + MTP_FILETYPE_GIF, /**< GIF file type */ + MTP_FILETYPE_PICT, /**< PICT file type */ + MTP_FILETYPE_PNG, /**< PNG file type */ + MTP_FILETYPE_VCALENDAR1, /**< VCALENDAR1 file type */ + MTP_FILETYPE_VCALENDAR2, /**< VCALENDAR2 file type */ + MTP_FILETYPE_VCARD2, /**< VCARD2 file type */ + MTP_FILETYPE_VCARD3, /**< VCARD3 file type */ + MTP_FILETYPE_WINDOWSIMAGEFORMAT, /**< WINDOWSIMAGEFORMAT file type */ + MTP_FILETYPE_WINEXEC, /**< WINEXEC file type */ + MTP_FILETYPE_TEXT, /**< TEXT file type */ + MTP_FILETYPE_HTML, /**< HTML file type */ + MTP_FILETYPE_FIRMWARE, /**< FIRMWARE file type */ + MTP_FILETYPE_AAC, /**< AAC file type */ + MTP_FILETYPE_MEDIACARD, /**< MEDIACARD file type */ + MTP_FILETYPE_FLAC, /**< FLAC file type */ + MTP_FILETYPE_MP2, /**< MP2 file type */ + MTP_FILETYPE_M4A, /**< M4A file type */ + MTP_FILETYPE_DOC, /**< DOC file type */ + MTP_FILETYPE_XML, /**< XML file type */ + MTP_FILETYPE_XLS, /**< XLS file type */ + MTP_FILETYPE_PPT, /**< PPT file type */ + MTP_FILETYPE_MHT, /**< MHT file type */ + MTP_FILETYPE_JP2, /**< JP2 file type */ + MTP_FILETYPE_JPX, /**< JPX file type */ + MTP_FILETYPE_ALBUM, /**< ALBUM file type */ + MTP_FILETYPE_PLAYLIST, /**< PLAYLIST file type */ + MTP_FILETYPE_UNKNOWN, /**< Unknown file type */ + + MTP_FILETYPE_ALL, /**< helper enum value for certain function */ + MTP_FILETYPE_ALL_IMAGE /**< helper enum value for certain function */ +} mtp_filetype_e; + +/** + * @brief Enumerations for MTP event type + * @since_tizen 3.0 + * @ingroup CAPI_NETWORK_MTP_MANAGER_MODULE + */ +typedef enum { + MTP_EVENT_UNKNOWN, /**< Unknown event type */ + MTP_EVENT_STORAGE_ADDED, /**< Storage is added */ + MTP_EVENT_STORAGE_REMOVED, /**< Storage is removed */ + MTP_EVENT_OBJECT_ADDED, /**< Object is added */ + MTP_EVENT_OBJECT_REMOVED, /**< Object is removed */ + MTP_EVENT_DEVICE_ADDED, /**< Device is added */ + MTP_EVENT_DEVICE_REMOVED /**< Device is removed */ +} mtp_event_e; + +/** + * @brief Called after mtp_set_mtp_event_cb() has completed. + * @since_tizen 3.0 + * @ingroup CAPI_NETWORK_MTP_MANAGER_MODULE + * + * @param [in] event The event + * @param [in] arg The argument + * @param [in] user_data The user data passed from the callback registration function + * + * @see mtp_set_mtp_event_cb() + * @see mtp_unset_mtp_event_cb() + */ +typedef void (* mtp_event_cb)(mtp_event_e event, int arg, void *user_data); + +/** + * @brief Initializes for using MTP. + * @since_tizen 3.0 + * @ingroup CAPI_NETWORK_MTP_MANAGER_MODULE + * @remarks This function must be called before proceeding any other mtp functions\n + * + * @return 0 on success, otherwise a negative error value. + * @retval #MTP_ERROR_NONE Successful + * + * @see mtp_deinitialize() + */ +MTP_API int mtp_initialize(void); + +/** + * @brief Get device list. + * @since_tizen 3.0 + * @ingroup CAPI_NETWORK_MTP_MANAGER_MODULE + * + * @return 0 on success, otherwise a negative error value. + * @retval #MTP_ERROR_NONE Successful + * + * @param [out] dev_list All current device list + */ +MTP_API int mtp_get_device_list(mtp_device_list **dev_list); + +/** + * @brief Get device handler from bus location + * @since_tizen 3.0 + * @ingroup CAPI_NETWORK_MTP_MANAGER_MODULE + * + * @return 0 on success, otherwise a negative error value. + * @retval #MTP_ERROR_NONE Successful + * + * @param [in] bus_location The bus location + * @param [out] device_handle The device handle + * + * @see mtp_initialize() + */ +MTP_API int mtp_get_device_handle(int bus_location, int* device_handle); + +/** + * @brief Get storage ids from device + * @since_tizen 3.0 + * @ingroup CAPI_NETWORK_MTP_MANAGER_MODULE + * + * @return 0 on success, otherwise a negative error value. + * @retval #MTP_ERROR_NONE Successful + * + * @param [in] device_handle The device handle + * @param [out] storage_id Current storage id list + * @param [out] storage_num Length of storage id list + * + * @see mtp_get_device_handle() + */ +MTP_API int mtp_get_storage_ids(int device_handle, int **storage_id, int* storage_num); + +/** + * @brief Get object handles from device + * @since_tizen 3.0 + * @ingroup CAPI_NETWORK_MTP_MANAGER_MODULE + * + * @return 0 on success, otherwise a negative error value. + * @retval #MTP_ERROR_NONE Successful + * + * @param [in] device_handle The device handle + * @param [in] storage_id The storage id + * @param [in] format The file type what you want + * @param [in] parent_object_handle The parent object handle + * @param [out] object_handles The object handle list + * @param [out] object_num Length of object handle list + * + * @see mtp_get_device_handle() + * @see mtp_get_storage_ids() + */ +MTP_API int mtp_get_object_handles(int device_handle, int storage_id, int format, + int parent_object_handle, int **object_handles, int* object_num); + +/** + * @brief Delete object from device + * @since_tizen 3.0 + * @ingroup CAPI_NETWORK_MTP_MANAGER_MODULE + * + * @return 0 on success, otherwise a negative error value. + * @retval #MTP_ERROR_NONE Successful + * + * @param [in] device_handle The device handle + * @param [in] object_handle The object handle + * + * @see mtp_get_device_handle() + * @see mtp_get_object_handles() + */ +MTP_API int mtp_delete_object(int device_handle, int object_handle); + +/** + * @brief Get object from object handle + * @since_tizen 3.0 + * @ingroup CAPI_NETWORK_MTP_MANAGER_MODULE + * + * @return 0 on success, otherwise a negative error value. + * @retval #MTP_ERROR_NONE Successful + * + * @param [in] device_handle The device handle + * @param [in] object_handle The object handle + * @param [in] dest_path The dest path + * + * @see mtp_get_device_handle() + * @see mtp_get_object_handles() + */ +MTP_API int mtp_get_object(int device_handle, int object_handle, char *dest_path); + +/** + * @brief Get thumbnail from object handle + * @since_tizen 3.0 + * @ingroup CAPI_NETWORK_MTP_MANAGER_MODULE + * + * @return 0 on success, otherwise a negative error value. + * @retval #MTP_ERROR_NONE Successful + * + * @param [in] device_handle The device handle + * @param [in] object_handle The object handle + * @param [in] dest_path The dest path + * + * @see mtp_get_device_handle() + * @see mtp_get_object_handles() + */ +MTP_API int mtp_get_thumbnail(int device_handle, int object_handle, char *dest_path); + +/** + * @brief Registers a callback function for receiving MTP event. + * @since_tizen 3.0 + * @ingroup CAPI_NETWORK_MTP_MANAGER_MODULE + * + * @detail If device state is changed, DEVICE_ADD or DEVICE_REMOVE event is occur. \n + * If storage state is changed, STORAGE_ADD or STORAGE_REMOVE event is occur. \n + * If object state is changed, OBJECT_ADD or OBJECT_REMOVE event is occur. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MTP_ERROR_NONE Successful + * + * @param [in] callback The callback + * @param [in] user_data The user data + * + * @see mtp_unset_mtp_event_cb() + */ +MTP_API int mtp_set_mtp_event_cb(mtp_event_cb callback, void *user_data); + +/** + * @brief Unregisters the callback function. + * @since_tizen 3.0 + * @ingroup CAPI_NETWORK_MTP_MANAGER_MODULE + * + * @return 0 on success, otherwise a negative error value. + * @retval #MTP_ERROR_NONE Successful + * + * @see mtp_set_mtp_event_cb() + */ +MTP_API int mtp_unset_mtp_event_cb(void); + +/** + * @brief Deinitializes MTP operation. + * @since_tizen 3.0 + * @ingroup CAPI_NETWORK_MTP_MANAGER_MODULE + * + * @return 0 on success, otherwise a negative error value. + * @retval #MTP_ERROR_NONE Successful + * + * @see mtp_initialize() + */ +MTP_API int mtp_deinitialize(void); + +/** + * @brief Get the manufacturer name of the device information. + * @since_tizen 3.0 + * @ingroup CAPI_NETWORK_MTP_DEVICEINFO_MODULE + * + * @return 0 on success, otherwise a negative error value. + * @retval #MTP_ERROR_NONE Successful + * + * @param [in] device_handle The device handle + * @param [out] manufacturername The manufacturername of Device information + * + * @see mtp_get_device_handle() + */ +MTP_API int mtp_deviceinfo_get_manufacturername(int device_handle, char **manufacturername); + +/** + * @brief Get the model name of the device information. + * @since_tizen 3.0 + * @ingroup CAPI_NETWORK_MTP_DEVICEINFO_MODULE + * + * @return 0 on success, otherwise a negative error value. + * @retval #MTP_ERROR_NONE Successful + * + * @param [in] device_handle The device handle + * @param [out] modelname The modelname of Device information + * + * @see mtp_get_device_handle() + */ +MTP_API int mtp_deviceinfo_get_modelname(int device_handle, char **modelname); + +/** + * @brief Get the serial number of the device information. + * @since_tizen 3.0 + * @ingroup CAPI_NETWORK_MTP_DEVICEINFO_MODULE + * + * @return 0 on success, otherwise a negative error value. + * @retval #MTP_ERROR_NONE Successful + * + * @param [in] device_handle The device handle + * @param [out] serialnumber The serialnumber of Device information + * + * @see mtp_get_device_handle() + */ +MTP_API int mtp_deviceinfo_get_serialnumber(int device_handle, char **serialnumber); + +/** + * @brief Get the device version of the device information. + * @since_tizen 3.0 + * @ingroup CAPI_NETWORK_MTP_DEVICEINFO_MODULE + * + * @return 0 on success, otherwise a negative error value. + * @retval #MTP_ERROR_NONE Successful + * + * @param [in] device_handle The device handle + * @param [out] serialnumber The deviceversion of Device information + * + * @see mtp_get_device_handle() + */ +MTP_API int mtp_deviceinfo_get_deviceversion(int device_handle, char **deviceversion); + +/** + * @brief Get the description of the storage information. + * @since_tizen 3.0 + * @ingroup CAPI_NETWORK_MTP_STORAGEINFO_MODULE + * + * @return 0 on success, otherwise a negative error value. + * @retval #MTP_ERROR_NONE Successful + * + * @param [in] device_handle The device handle + * @param [in] storage_id The storage id + * @param [out] description The description of Storage information + * + * @see mtp_get_storage_ids() + */ +MTP_API int mtp_storageinfo_get_description(int device_handle, int storage_id, char **description); + +/** + * @brief Get the freespace of the storage information. + * @since_tizen 3.0 + * @ingroup CAPI_NETWORK_MTP_STORAGEINFO_MODULE + * + * @return 0 on success, otherwise a negative error value. + * @retval #MTP_ERROR_NONE Successful + * + * @param [in] device_handle The device handle + * @param [in] storage_id The storage id + * @param [out] freespace The freespace of Storage information + * + * @see mtp_get_storage_ids() + */ +MTP_API int mtp_storageinfo_get_freespace(int device_handle, int storage_id, guint64 *freespace); + +/** + * @brief Get the max capacity of the storage information. + * @since_tizen 3.0 + * @ingroup CAPI_NETWORK_MTP_STORAGEINFO_MODULE + * + * @return 0 on success, otherwise a negative error value. + * @retval #MTP_ERROR_NONE Successful + * + * @param [in] device_handle The device handle + * @param [in] storage_id The storage id + * @param [out] maxcapacity The maxcapacity of Storage information + * + * @see mtp_get_storage_ids() + */ +MTP_API int mtp_storageinfo_get_maxcapacity(int device_handle, int storage_id, guint64 *maxcapacity); + +/** + * @brief Get the storage type of the storage information. + * @since_tizen 3.0 + * @ingroup CAPI_NETWORK_MTP_STORAGEINFO_MODULE + * + * @return 0 on success, otherwise a negative error value. + * @retval #MTP_ERROR_NONE Successful + * + * @param [in] device_handle The device handle + * @param [in] storage_id The storage id + * @param [out] storagetype The storagetype of Storage information + * + * @see mtp_get_storage_ids() + */ +MTP_API int mtp_storageinfo_get_storagetype(int device_handle, int storage_id, int *storagetype); + +/** + * @brief Get the volumeidentifier of the storage information. + * @since_tizen 3.0 + * @ingroup CAPI_NETWORK_MTP_STORAGEINFO_MODULE + * + * @return 0 on success, otherwise a negative error value. + * @retval #MTP_ERROR_NONE Successful + * + * @param [in] device_handle The device handle + * @param [in] storage_id The storage id + * @param [out] volumeidentifier The volumeidentifier of Storage information + * + * @see mtp_get_object_handles() + */ +MTP_API int mtp_storageinfo_get_volumeidentifier(int device_handle, int storage_id, char **volumeidentifier); + +/** + * @brief Get the filename of the object information. + * @since_tizen 3.0 + * @ingroup CAPI_NETWORK_MTP_OBJECTINFO_MODULE + * + * @return 0 on success, otherwise a negative error value. + * @retval #MTP_ERROR_NONE Successful + * + * @param [in] device_handle The device handle + * @param [in] object_handle The object handle + * @param [out] filename The filename of Object information + * + * @see mtp_get_object_handles() + */ +MTP_API int mtp_objectinfo_get_filename(int device_handle, int object_handle, char **filename); + +/** + * @brief Get the keywords of the object information. + * @since_tizen 3.0 + * @ingroup CAPI_NETWORK_MTP_OBJECTINFO_MODULE + * + * @return 0 on success, otherwise a negative error value. + * @retval #MTP_ERROR_NONE Successful + * + * @param [in] device_handle The device handle + * @param [in] object_handle The object handle + * @param [out] keywords The keywords of Object information + * + * @see mtp_get_object_handles() + */ +MTP_API int mtp_objectinfo_get_keywords(int device_handle, int object_handle, char **keywords); + +/** + * @brief Get the association desc of the object information. + * @since_tizen 3.0 + * @ingroup CAPI_NETWORK_MTP_OBJECTINFO_MODULE + * + * @return 0 on success, otherwise a negative error value. + * @retval #MTP_ERROR_NONE Successful + * + * @param [in] device_handle The device handle + * @param [in] object_handle The object handle + * @param [out] asso_desc The association description of Object information + * + * @see mtp_get_object_handles() + */ +MTP_API int mtp_objectinfo_get_association_desc(int device_handle, int object_handle, int *asso_desc); + +/** + * @brief Get the association type of the object information. + * @since_tizen 3.0 + * @ingroup CAPI_NETWORK_MTP_OBJECTINFO_MODULE + * + * @return 0 on success, otherwise a negative error value. + * @retval #MTP_ERROR_NONE Successful + * + * @param [in] device_handle The device handle + * @param [in] object_handle The object handle + * @param [out] asso_type The association type of Object information + * + * @see mtp_get_object_handles() + */ +MTP_API int mtp_objectinfo_get_association_type(int device_handle, int object_handle, int *asso_type); + +/** + * @brief Get the size of the object information. + * @since_tizen 3.0 + * @ingroup CAPI_NETWORK_MTP_OBJECTINFO_MODULE + * + * @return 0 on success, otherwise a negative error value. + * @retval #MTP_ERROR_NONE Successful + * + * @param [in] device_handle The device handle + * @param [in] object_handle The object handle + * @param [out] size The size of Object information + * + * @see mtp_get_object_handles() + */ +MTP_API int mtp_objectinfo_get_size(int device_handle, int object_handle, int *size); + +/** + * @brief Get the parent object handle of the object information. + * @since_tizen 3.0 + * @ingroup CAPI_NETWORK_MTP_OBJECTINFO_MODULE + * + * @return 0 on success, otherwise a negative error value. + * @retval #MTP_ERROR_NONE Successful + * + * @param [in] device_handle The device handle + * @param [in] object_handle The object handle + * @param [out] parent_object_handle The parent of Object information + * + * @see mtp_get_object_handles() + */ +MTP_API int mtp_objectinfo_get_parent_object_handle(int device_handle, int object_handle, int *parent_object_handle); + +/** + * @brief Get the storage id of the object information. + * @since_tizen 3.0 + * @ingroup CAPI_NETWORK_MTP_OBJECTINFO_MODULE + * + * @return 0 on success, otherwise a negative error value. + * @retval #MTP_ERROR_NONE Successful + * + * @param [in] device_handle The device handle + * @param [in] object_handle The object handle + * @param [out] storage_id The storage id of Object information + * + * @see mtp_get_object_handles() + */ +MTP_API int mtp_objectinfo_get_storage_id(int device_handle, int object_handle, int *storage_id); + +/** + * @brief Get the data created time of the object information. + * @since_tizen 3.0 + * @ingroup CAPI_NETWORK_MTP_OBJECTINFO_MODULE + * + * @return 0 on success, otherwise a negative error value. + * @retval #MTP_ERROR_NONE Successful + * + * @param [in] device_handle The device handle + * @param [in] object_handle The object handle + * @param [out] data_created The data created time of Object information + * + * @see mtp_get_object_handles() + */ +MTP_API int mtp_objectinfo_get_data_created(int device_handle, int object_handle, int *data_created); + +/** + * @brief Get the data modified time of the object information. + * @since_tizen 3.0 + * @ingroup CAPI_NETWORK_MTP_OBJECTINFO_MODULE + * + * @return 0 on success, otherwise a negative error value. + * @retval #MTP_ERROR_NONE Successful + * + * @param [in] device_handle The device handle + * @param [in] object_handle The object handle + * @param [out] data_modified The data modified time of Object information + * + * @see mtp_get_object_handles() + */ +MTP_API int mtp_objectinfo_get_data_modified(int device_handle, int object_handle, int *data_modified); + +/** + * @brief Get the format of the object information. + * @since_tizen 3.0 + * @ingroup CAPI_NETWORK_MTP_OBJECTINFO_MODULE + * + * @return 0 on success, otherwise a negative error value. + * @retval #MTP_ERROR_NONE Successful + * + * @param [in] device_handle The device handle + * @param [in] object_handle The object handle + * @param [out] format The image format of Object information + * + * @see mtp_get_object_handles() + */ +MTP_API int mtp_objectinfo_get_format(int device_handle, int object_handle, int *format); + +/** + * @brief Get the image pix depth of the object information. + * @since_tizen 3.0 + * @ingroup CAPI_NETWORK_MTP_OBJECTINFO_MODULE + * + * @return 0 on success, otherwise a negative error value. + * @retval #MTP_ERROR_NONE Successful + * + * @param [in] device_handle The device handle + * @param [in] object_handle The object handle + * @param [out] depth The image pixel depth of Object information + * + * @see mtp_get_object_handles() + */ +MTP_API int mtp_objectinfo_get_image_pix_depth(int device_handle, int object_handle, int *depth); + +/** + * @brief Get the image pix width of the object information. + * @since_tizen 3.0 + * @ingroup CAPI_NETWORK_MTP_OBJECTINFO_MODULE + * + * @return 0 on success, otherwise a negative error value. + * @retval #MTP_ERROR_NONE Successful + * + * @param [in] device_handle The device handle + * @param [in] object_handle The object handle + * @param [out] width The image pixel width of Object information + * + * @see mtp_get_object_handles() + */ +MTP_API int mtp_objectinfo_get_image_pix_width(int device_handle, int object_handle, int *width); + +/** + * @brief Get the image pix height of the object information. + * @since_tizen 3.0 + * @ingroup CAPI_NETWORK_MTP_OBJECTINFO_MODULE + * + * @return 0 on success, otherwise a negative error value. + * @retval #MTP_ERROR_NONE Successful + * + * @param [in] device_handle The device handle + * @param [in] object_handle The object handle + * @param [out] height The image pixel height of Object information + * + * @see mtp_get_object_handles() + */ +MTP_API int mtp_objectinfo_get_image_pix_height(int device_handle, int object_handle, int *height); + +/** + * @brief Get the thumbnail size of the object information. + * @since_tizen 3.0 + * @ingroup CAPI_NETWORK_MTP_OBJECTINFO_MODULE + * + * @return 0 on success, otherwise a negative error value. + * @retval #MTP_ERROR_NONE Successful + * + * @param [in] device_handle The device handle + * @param [in] object_handle The object handle + * @param [out] size The thumbnail size of Object information + * + * @see mtp_get_object_handles() + */ +MTP_API int mtp_objectinfo_get_thumbnail_size(int device_handle, int object_handle, int *size); + +/** + * @brief Get the thumbnail format of the object information. + * @since_tizen 3.0 + * @ingroup CAPI_NETWORK_MTP_OBJECTINFO_MODULE + * + * @return 0 on success, otherwise a negative error value. + * @retval #MTP_ERROR_NONE Successful + * + * @param [in] device_handle The device handle + * @param [in] object_handle The object handle + * @param [out] format The thumbnail format of Object information + * + * @see mtp_get_object_handles() + */ +MTP_API int mtp_objectinfo_get_thumbnail_format(int device_handle, int object_handle, int *format); + +/** + * @brief Get the thumbnail pix height of the object information. + * @since_tizen 3.0 + * @ingroup CAPI_NETWORK_MTP_OBJECTINFO_MODULE + * + * @return 0 on success, otherwise a negative error value. + * @retval #MTP_ERROR_NONE Successful + * + * @param [in] device_handle The device handle + * @param [in] object_handle The object handle + * @param [out] height The thumbnail pixel height of Object information + * + * @see mtp_get_object_handles() + */ +MTP_API int mtp_objectinfo_get_thumbnail_pix_height(int device_handle, int object_handle, int *height); + +/** + * @brief Get the thumbnail pix width of the object information. + * @since_tizen 3.0 + * @ingroup CAPI_NETWORK_MTP_OBJECTINFO_MODULE + * + * @return 0 on success, otherwise a negative error value. + * @retval #MTP_ERROR_NONE Successful + * + * @param [in] device_handle The device handle + * @param [in] object_handle The object handle + * @param [out] width The thumbnail pixel width of Object information + * + * @see mtp_get_object_handles() + */ +MTP_API int mtp_objectinfo_get_thumbnail_pix_width(int device_handle, int object_handle, int *width); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/mtp_db.h b/include/mtp_db.h new file mode 100755 index 0000000..a546820 --- /dev/null +++ b/include/mtp_db.h @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __MTP_DB_H__ +#define __MTP_DB_H__ + +#include +#include +#include +#include +#include + +#include "mtp.h" +#include "mtp_internal.h" + +#define MTP_DB_FILE "/tmp/.mtp.db" +#define MTP_DB_TABLE "mtp_object_info" + +mtp_error_e mtp_db_init(void); +mtp_error_e mtp_db_get_object_info(int device_handle, int object_handle, mtp_object_info** object_info); +mtp_error_e mtp_db_deinit(void); + +#endif + diff --git a/include/mtp_debug.h b/include/mtp_debug.h new file mode 100755 index 0000000..a95ce04 --- /dev/null +++ b/include/mtp_debug.h @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __MTP_DEBUG_H__ +#define __MTP_DEBUG_H__ + +#include + +#define COLOR_BLACK "\033[0;30m" +#define COLOR_RED "\033[0;31m" +#define COLOR_GREEN "\033[0;32m" +#define COLOR_BROWN "\033[0;33m" +#define COLOR_BLUE "\033[0;34m" +#define COLOR_PURPLE "\033[0;35m" +#define COLOR_CYAN "\033[0;36m" +#define COLOR_GRAY "\033[0;37m" +#define COLOR_END "\033[0;m" + +#define _ERR(fmt, ...) \ + do \ + { \ + LOGE(COLOR_RED fmt COLOR_END, ##__VA_ARGS__); \ + } \ + while (0) + +#define _INFO(fmt, ...) \ + do \ + { \ + LOGI(COLOR_GREEN fmt COLOR_END, ##__VA_ARGS__); \ + } \ + while (0) + +#define _WARN(fmt, ...) \ + do \ + { \ + LOGI(COLOR_BROWN fmt COLOR_END, ##__VA_ARGS__); \ + } \ + while (0) + +#define _DBG(fmt, ...) \ + do \ + { \ + LOGD(fmt, ##__VA_ARGS__); \ + } \ + while (0) + +#define _BEGIN() \ + do \ + { \ + LOGD(COLOR_BLUE "BEGIN >>>>" COLOR_END); \ + } \ + while (0) + +#define _END() \ + do \ + { \ + LOGD(COLOR_BLUE "END <<<<" COLOR_END); \ + } \ + while (0) + +#define cond_expr_ret(expr, val) \ + do {\ + if (expr) { \ + _ERR("[precond fail] expr : %s, ret : %d\n", #expr, val); \ + return (val); \ + } \ + } while(0) + +#define cond_ret(val) \ + do {\ + if(val) { \ + _ERR("[precond fail] ret : %d\n", val); \ + return (val); \ + } \ + } while(0) + +#define PRT(format, args...) printf("%s:%d() "format, __FUNCTION__, __LINE__, ##args) +#define TC_PRT(format, args...) PRT(format"\n", ##args) + +#endif diff --git a/include/mtp_gdbus.h b/include/mtp_gdbus.h new file mode 100755 index 0000000..a740ff1 --- /dev/null +++ b/include/mtp_gdbus.h @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __MTP_GDBUS_H__ +#define __MTP_GDBUS_H__ + +#include +#include + +#include "mtp.h" +#include "mtp_gdbuslib.h" + +#define MTP_DBUS_SERVICE "org.tizen.mtp" +#define MTP_DBUS_MANAGER_PATH "/org/tizen/mtp/manager" +#define MTP_DBUS_DEVICEINFO_PATH "/org/tizen/mtp/deviceinfo" +#define MTP_DBUS_STORAGEINFO_PATH "/org/tizen/mtp/storageinfo" +#define MTP_DBUS_OBJECTINFO_PATH "/org/tizen/mtp/objectinfo" + +#endif diff --git a/include/mtp_gdbus_deviceinfo.h b/include/mtp_gdbus_deviceinfo.h new file mode 100755 index 0000000..69f2c92 --- /dev/null +++ b/include/mtp_gdbus_deviceinfo.h @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __MTP_GDBUS_DEVICEINFO_H__ +#define __MTP_GDBUS_DEVICEINFO_H__ + +#include "mtp_gdbus.h" + +void mtp_gdbus_deviceinfo_proxy_init(void); +void mtp_gdbus_deviceinfo_proxy_deinit(void); + +mtp_error_e mtp_gdbus_deviceinfo_get_manufacturername(int mtp_handle, char **manufacturername); +mtp_error_e mtp_gdbus_deviceinfo_get_modelname(int mtp_handle, char **modelname); +mtp_error_e mtp_gdbus_deviceinfo_get_serialnumber(int mtp_handle, char **serialnumber); +mtp_error_e mtp_gdbus_deviceinfo_get_deviceversion(int mtp_handle, char **deviceversion); + +#endif diff --git a/include/mtp_gdbus_manager.h b/include/mtp_gdbus_manager.h new file mode 100755 index 0000000..9c9699c --- /dev/null +++ b/include/mtp_gdbus_manager.h @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __MTP_GDBUS_MANAGER_H__ +#define __MTP_GDBUS_MANAGER_H__ + +#include "mtp_gdbus.h" + +mtp_error_e mtp_gdbus_manager_initialize(void); +mtp_error_e mtp_gdbus_manager_get_device_list(mtp_device_list **dev_list); +mtp_error_e mtp_gdbus_manager_get_device_handle(int bus_location, + int *device_handle); +mtp_error_e mtp_gdbus_manager_get_storage_ids(int device_handle, + int **storage_ids, int *storage_num); +mtp_error_e mtp_gdbus_manager_get_object_handles(int device_handle, + int storage_id, int format, int parent_object_handle, int **object_handles, int *object_num); +mtp_error_e mtp_gdbus_manager_delete_object(int device_handle, int object_handle); +mtp_error_e mtp_gdbus_manager_get_object(int device_handle, + int object_handle, char *dest_path); +mtp_error_e mtp_gdbus_manager_get_thumbnail(int device_handle, + int object_handle, char *dest_path); +mtp_error_e mtp_gdbus_manager_set_event_cb(mtp_event_cb callback, void *user_data); +mtp_error_e mtp_gdbus_manager_unset_event_cb(); +mtp_error_e mtp_gdbus_manager_deinitialize(void); + +#endif diff --git a/include/mtp_gdbus_objectinfo.h b/include/mtp_gdbus_objectinfo.h new file mode 100755 index 0000000..3c5930f --- /dev/null +++ b/include/mtp_gdbus_objectinfo.h @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __MTP_GDBUS_OBJECTINFO_H__ +#define __MTP_GDBUS_OBJECTINFO_H__ + +#include "mtp_gdbus.h" + +void mtp_gdbus_objectinfo_proxy_init(void); +void mtp_gdbus_objectinfo_proxy_deinit(void); + +int mtp_gdbus_objectinfo_get_property(int device_handle, + int object_handle, int property, int *property_value); +int mtp_gdbus_objectinfo_get_property_string(int device_handle, + int object_handle, int property, char **property_value); + +#endif diff --git a/include/mtp_gdbus_storageinfo.h b/include/mtp_gdbus_storageinfo.h new file mode 100755 index 0000000..c4e90a3 --- /dev/null +++ b/include/mtp_gdbus_storageinfo.h @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __MTP_GDBUS_STORAGEINFO_H__ +#define __MTP_GDBUS_STORAGEINFO_H__ + +#include "mtp_gdbus.h" + +void mtp_gdbus_storageinfo_proxy_init(void); +void mtp_gdbus_storageinfo_proxy_deinit(void); + +mtp_error_e mtp_gdbus_storageinfo_get_description(int device_handle, + int storage_id, char **description); +mtp_error_e mtp_gdbus_storageinfo_get_freespace(int device_handle, + int storage_id, guint64 *freespace); +mtp_error_e mtp_gdbus_storageinfo_get_maxcapacity(int device_handle, + int storage_id, guint64 *maxcapacity); +mtp_error_e mtp_gdbus_storageinfo_get_storagetype(int device_handle, + int storage_id, int *storagetype); +mtp_error_e mtp_gdbus_storageinfo_get_volumeidentifier(int device_handle, + int storage_id, char **volumeidentifier); + +#endif diff --git a/include/mtp_internal.h b/include/mtp_internal.h new file mode 100755 index 0000000..0702f5a --- /dev/null +++ b/include/mtp_internal.h @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __MTP_INTERNAL_H__ +#define __MTP_INTERNAL_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define MTP_ERROR_DB -980 + +/* internal struct */ +typedef struct _mtp_object_info { + int StorageID; + int ObjectFormat; + int ProtectionStatus; + int ObjectCompressedSize; + int ThumbFormat; + int ThumbCompressedSize; + int ThumbPixWidth; + int ThumbPixHeight; + int ImagePixWidth; + int ImagePixHeight; + int ImageBitDepth; + int ParentObject; + int AssociationType; + int AssociationDesc; + int SequenceNumber; + char *Filename; + int CaptureDate; + int ModificationDate; + char *Keywords; +}mtp_object_info; + +/* internal api */ +MTP_API int mtp_objectinfo_get_object_info(int device_handle, int object_handle, mtp_object_info **object_info); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/packaging/capi-network-mtp.spec b/packaging/capi-network-mtp.spec new file mode 100755 index 0000000..139898b --- /dev/null +++ b/packaging/capi-network-mtp.spec @@ -0,0 +1,68 @@ +Name: capi-network-mtp +Summary: A MTP library in Native API +Version: 1.2.1 +Release: 1 +Group: Network & Connectivity/Other +License: Apache-2.0 +Source0: %{name}-%{version}.tar.gz + +# This package would be built only TV +%if "%{?tizen_profile_name}" != "tv" +ExcludeArch: %{arm} %ix86 x86_64 +%endif + +BuildRequires: cmake +BuildRequires: pkgconfig(dlog) +BuildRequires: pkgconfig(glib-2.0) +BuildRequires: pkgconfig(gobject-2.0) +BuildRequires: pkgconfig(capi-base-common) +BuildRequires: pkgconfig(sqlite3) +BuildRequires: python +Buildrequires: python-xml + +Requires(post): /sbin/ldconfig +Requires(postun): /sbin/ldconfig + +%description + +%package devel +Summary: A MTP library in Native API (Development) +Group: Network & Connectivity/Other +Requires: %{name} = %{version}-%{release} + +%description devel + +%prep +%setup -q + +%build +MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'` + +cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} \ + -DLIB_INSTALL_DIR=%{_libdir} \ + -DFULLVER=%{version} \ + -DMAJORVER=${MAJORVER} + +make %{?jobs:-j%jobs} + +%install +rm -rf %{buildroot} +mkdir -p %{buildroot}/usr/share/license/mtp/ +cp -af %{_builddir}/%{name}-%{version}/LICENSE.APLv2 %{buildroot}/usr/share/license/mtp/ + +%make_install + +%post -p /sbin/ldconfig + +%postun -p /sbin/ldconfig + + +%files +%manifest capi-network-mtp.manifest +%{_libdir}/libcapi-network-mtp.so* +/usr/share/license/mtp/LICENSE.APLv2 + +%files devel +%{_includedir}/*.h +%{_libdir}/pkgconfig/*.pc +%{_libdir}/libcapi-network-mtp.so diff --git a/src/mtp.c b/src/mtp.c new file mode 100755 index 0000000..d1096a1 --- /dev/null +++ b/src/mtp.c @@ -0,0 +1,1027 @@ +/* +* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include +#include +#include +#include +#include + +#include + +#include "mtp.h" +#include "mtp_internal.h" +#include "mtp_db.h" +#include "mtp_debug.h" + +#include "mtp_gdbus_manager.h" +#include "mtp_gdbus_deviceinfo.h" +#include "mtp_gdbus_storageinfo.h" +#include "mtp_gdbus_objectinfo.h" + +int ref_count = 0; +bool __is_initialized = false; + +#define MTP_LOCK \ +do { \ + pthread_mutex_lock(&mutex); \ +} while (0); + +#define MTP_UNLOCK \ +do { \ + pthread_mutex_unlock(&mutex); \ +} while (0); + +static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; + +#define CHECK_INIT() \ +do { \ + MTP_LOCK; \ + { \ + if (__is_initialized == false) { \ + MTP_UNLOCK; \ + return MTP_ERROR_NOT_INITIALIZED; \ + } \ + } \ + MTP_UNLOCK; \ +} while (0); + +#define CHECK_SUPPORTED() \ +do { \ + { \ + if (__is_mtp_supported() == false) { \ + return MTP_ERROR_NOT_SUPPORTED; \ + } \ + } \ +} while (0); + +#define CHECK_ACTIVATED() \ +do { \ + { \ + if (__is_mtp_activated() == false) { \ + return MTP_ERROR_NOT_ACTIVATED; \ + } \ + } \ +} while (0); + +typedef enum { + MTP_PROPERTY_ASSOCIATION_DESC = 1, + MTP_PROPERTY_ASSOCIATION_TYPE, + MTP_PROPERTY_SIZE, + MTP_PROPERTY_DATA_CREATED, + MTP_PROPERTY_DATA_MODIFIED, + MTP_PROPERTY_FORMAT, + MTP_PROPERTY_IMAGE_FIX_DEPTH, + MTP_PROPERTY_IMAGE_FIX_WIDTH, + MTP_PROPERTY_IMAGE_FIX_HEIGHT, + MTP_PROPERTY_PARENT_OBJECT_HANDLE, + MTP_PROPERTY_STORAGE_ID, + MTP_PROPERTY_THUMBNAIL_SIZE, + MTP_PROPERTY_THUMBNAIL_FORMAT, + MTP_PROPERTY_THUMBNAIL_WIDTH, + MTP_PROPERTY_THUMBNAIL_HEIGHT, + MTP_PROPERTY_FILENAME, + MTP_PROPERTY_KEYWORDS +} mtp_property_e; + +static bool __is_mtp_supported() +{ + return true; +} + +static bool __is_mtp_activated() +{ + return true; +} + +/* Device Manager */ +int mtp_initialize(void) +{ + int ret = MTP_ERROR_NONE; + + _BEGIN(); + + /* precondition check start */ + + CHECK_SUPPORTED(); + + /* precondition check end */ + + MTP_LOCK; + + if (__is_initialized == false) { + ret = mtp_gdbus_manager_initialize(); + mtp_db_init(); + __is_initialized = true; + } + ref_count++; + + MTP_UNLOCK; + + _END(); + + return ret; +} + +int mtp_get_device_list(mtp_device_list **dev_list) +{ + int ret = MTP_ERROR_NONE; + + _BEGIN(); + + /* precondition check start */ + + CHECK_SUPPORTED(); + CHECK_INIT(); + CHECK_ACTIVATED(); + + /* precondition check end */ + + ret = mtp_gdbus_manager_get_device_list(dev_list); + + _END(); + + return ret; +} + +int mtp_get_device_handle(int bus_location, int *device_handle) +{ + int ret = MTP_ERROR_NONE; + + _BEGIN(); + + /* precondition check start */ + + CHECK_SUPPORTED(); + CHECK_INIT(); + CHECK_ACTIVATED(); + cond_expr_ret(bus_location == 0, MTP_ERROR_INVALID_PARAMETER); + + /* precondition check end */ + + ret = mtp_gdbus_manager_get_device_handle(bus_location, device_handle); + + TC_PRT("mtp_handle %d", *device_handle); + + _END(); + + return ret; +} + +int mtp_get_storage_ids(int device_handle, int **storage_ids, int *storage_num) +{ + int ret = MTP_ERROR_NONE; + + _BEGIN(); + + /* precondition check start */ + + CHECK_SUPPORTED(); + CHECK_INIT(); + CHECK_ACTIVATED(); + cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); + + /* precondition check end */ + + ret = mtp_gdbus_manager_get_storage_ids(device_handle, storage_ids, storage_num); + + TC_PRT("storage number %d", *storage_num); + + _END(); + + return ret; +} + +int mtp_get_object_handles(int device_handle, int storage_id, int format, + int parent_object_handle, int **object_handles, int *object_num) +{ + int ret = MTP_ERROR_NONE; + + _BEGIN(); + + /* precondition check start */ + + CHECK_SUPPORTED(); + CHECK_INIT(); + CHECK_ACTIVATED(); + cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(storage_id == 0, MTP_ERROR_INVALID_PARAMETER); + + /* precondition check end */ + + ret = mtp_gdbus_manager_get_object_handles(device_handle, + storage_id, format, parent_object_handle, object_handles, object_num); + + _END(); + + return ret; +} + +int mtp_delete_object(int device_handle, int object_handle) +{ + int ret = MTP_ERROR_NONE; + + _BEGIN(); + + /* precondition check start */ + + CHECK_SUPPORTED(); + CHECK_INIT(); + CHECK_ACTIVATED(); + cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(object_handle == 0, MTP_ERROR_INVALID_PARAMETER); + + /* precondition check end */ + + ret = mtp_gdbus_manager_delete_object(device_handle, object_handle); + + _END(); + + return ret; +} + +int mtp_get_object(int device_handle, int object_handle, char *dest_path) +{ + int ret = MTP_ERROR_NONE; + + _BEGIN(); + + /* precondition check start */ + + CHECK_SUPPORTED(); + CHECK_INIT(); + CHECK_ACTIVATED(); + cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(dest_path == NULL, MTP_ERROR_INVALID_PARAMETER); + + /* precondition check end */ + + ret = mtp_gdbus_manager_get_object(device_handle, object_handle, dest_path); + + _END(); + + return ret; +} + +int mtp_get_thumbnail(int device_handle, int object_handle, char *dest_path) +{ + int ret = MTP_ERROR_NONE; + + _BEGIN(); + + /* precondition check start */ + + CHECK_SUPPORTED(); + CHECK_INIT(); + CHECK_ACTIVATED(); + cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(dest_path == NULL, MTP_ERROR_INVALID_PARAMETER); + + /* precondition check end */ + + ret = mtp_gdbus_manager_get_thumbnail(device_handle, object_handle, dest_path); + + _END(); + + return ret; +} + +int mtp_set_mtp_event_cb(mtp_event_cb callback, void *user_data) +{ + int ret = MTP_ERROR_NONE; + + _BEGIN(); + + /* precondition check start */ + + CHECK_SUPPORTED(); + CHECK_INIT(); + cond_expr_ret(callback == NULL, MTP_ERROR_INVALID_PARAMETER); + + /* precondition check end */ + + ret = mtp_gdbus_manager_set_event_cb(callback, user_data); + + _END(); + + return ret; +} + +int mtp_unset_mtp_event_cb(void) +{ + int ret = MTP_ERROR_NONE; + + _BEGIN(); + + /* precondition check start */ + + CHECK_SUPPORTED(); + CHECK_INIT(); + + /* precondition check end */ + + ret = mtp_gdbus_manager_unset_event_cb(); + + _END(); + + return ret; +} + +int mtp_deinitialize(void) +{ + int ret = MTP_ERROR_NONE; + + _BEGIN(); + + /* precondition check start */ + + CHECK_SUPPORTED(); + + /* precondition check end */ + + MTP_LOCK; + + if (ref_count > 0) + ref_count--; + + if (__is_initialized == true && ref_count == 0) { + mtp_db_deinit(); + ret = mtp_gdbus_manager_deinitialize(); + __is_initialized = false; + } + + MTP_UNLOCK; + + _END(); + + return ret; +} + +/* Device Info */ +int mtp_deviceinfo_get_manufacturername(int device_handle, char **manufacturername) +{ + int ret = MTP_ERROR_NONE; + + _BEGIN(); + + /* precondition check start */ + + CHECK_SUPPORTED(); + CHECK_INIT(); + CHECK_ACTIVATED(); + cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); + + /* precondition check end */ + + ret = mtp_gdbus_deviceinfo_get_manufacturername(device_handle, manufacturername); + + TC_PRT("manufacturername %s", *manufacturername); + + _END(); + + return ret; +} + +int mtp_deviceinfo_get_modelname(int device_handle, char **modelname) +{ + int ret = MTP_ERROR_NONE; + + _BEGIN(); + + /* precondition check start */ + + CHECK_SUPPORTED(); + CHECK_INIT(); + CHECK_ACTIVATED(); + cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); + + /* precondition check end */ + + ret = mtp_gdbus_deviceinfo_get_modelname(device_handle, modelname); + + TC_PRT("modelname %s", *modelname); + + _END(); + + return ret; +} + +int mtp_deviceinfo_get_serialnumber(int device_handle, char **serialnumber) +{ + int ret = MTP_ERROR_NONE; + + _BEGIN(); + + /* precondition check start */ + + CHECK_SUPPORTED(); + CHECK_INIT(); + CHECK_ACTIVATED(); + cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); + + /* precondition check end */ + + ret = mtp_gdbus_deviceinfo_get_serialnumber(device_handle, serialnumber); + + TC_PRT("serialnumber %s", *serialnumber); + + _END(); + + return ret; +} + +int mtp_deviceinfo_get_deviceversion(int device_handle, char **deviceversion) +{ + int ret = MTP_ERROR_NONE; + + _BEGIN(); + + /* precondition check start */ + + CHECK_SUPPORTED(); + CHECK_INIT(); + CHECK_ACTIVATED(); + cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); + + /* precondition check end */ + + ret = mtp_gdbus_deviceinfo_get_deviceversion(device_handle, deviceversion); + + TC_PRT("deviceversion %s", *deviceversion); + + _END(); + + return ret; +} + +/* Storage Info */ +int mtp_storageinfo_get_description(int device_handle, int storage_id, char **description) +{ + int ret = MTP_ERROR_NONE; + + _BEGIN(); + + /* precondition check start */ + + CHECK_SUPPORTED(); + CHECK_INIT(); + CHECK_ACTIVATED(); + cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(storage_id == 0, MTP_ERROR_INVALID_PARAMETER); + + /* precondition check end */ + + ret = mtp_gdbus_storageinfo_get_description(device_handle, storage_id, description); + + TC_PRT("description %s", *description); + + _END(); + + return ret; +} + +int mtp_storageinfo_get_freespace(int device_handle, int storage_id, guint64 *freespace) +{ + int ret = MTP_ERROR_NONE; + + _BEGIN(); + + /* precondition check start */ + + CHECK_SUPPORTED(); + CHECK_INIT(); + CHECK_ACTIVATED(); + cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(storage_id == 0, MTP_ERROR_INVALID_PARAMETER); + + /* precondition check end */ + + ret = mtp_gdbus_storageinfo_get_freespace(device_handle, storage_id, freespace); + + TC_PRT("freespace %d", (int)*freespace); + + _END(); + + return ret; +} + +int mtp_storageinfo_get_maxcapacity(int device_handle, int storage_id, guint64 *maxcapacity) +{ + int ret = MTP_ERROR_NONE; + + _BEGIN(); + + /* precondition check start */ + + CHECK_SUPPORTED(); + CHECK_INIT(); + CHECK_ACTIVATED(); + cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(storage_id == 0, MTP_ERROR_INVALID_PARAMETER); + + /* precondition check end */ + + ret = mtp_gdbus_storageinfo_get_maxcapacity(device_handle, storage_id, maxcapacity); + + TC_PRT("maxcapacity %d", (int)*maxcapacity); + + _END(); + + return ret; +} + +int mtp_storageinfo_get_storagetype(int device_handle, int storage_id, int *storagetype) +{ + int ret = MTP_ERROR_NONE; + + _BEGIN(); + + /* precondition check start */ + + CHECK_SUPPORTED(); + CHECK_INIT(); + CHECK_ACTIVATED(); + cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(storage_id == 0, MTP_ERROR_INVALID_PARAMETER); + + /* precondition check end */ + + ret = mtp_gdbus_storageinfo_get_storagetype(device_handle, storage_id, storagetype); + + TC_PRT("storagetype %d", *storagetype); + + _END(); + + return ret; +} + +int mtp_storageinfo_get_volumeidentifier(int device_handle, int storage_id, char **volumeidentifier) +{ + int ret = MTP_ERROR_NONE; + + _BEGIN(); + + /* precondition check start */ + + CHECK_SUPPORTED(); + CHECK_INIT(); + CHECK_ACTIVATED(); + cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(storage_id == 0, MTP_ERROR_INVALID_PARAMETER); + + /* precondition check end */ + + ret = mtp_gdbus_storageinfo_get_volumeidentifier(device_handle, storage_id, volumeidentifier); + + TC_PRT("volumeidentifier %s", *volumeidentifier); + + _END(); + + return ret; +} + +/* Object Info */ +int mtp_objectinfo_get_parent_object_handle(int device_handle, int object_handle, + int *parent_object_handle) +{ + int ret = MTP_ERROR_NONE; + + _BEGIN(); + + /* precondition check start */ + + CHECK_SUPPORTED(); + CHECK_INIT(); + CHECK_ACTIVATED(); + cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); + + /* precondition check end */ + + ret = mtp_gdbus_objectinfo_get_property(device_handle, + object_handle, MTP_PROPERTY_PARENT_OBJECT_HANDLE, parent_object_handle); + + TC_PRT("parent object id %d", *parent_object_handle); + + _END(); + + return ret; +} + +int mtp_objectinfo_get_storage_id(int device_handle, int object_handle, + int *storage_id) +{ + int ret = MTP_ERROR_NONE; + + _BEGIN(); + + /* precondition check start */ + + CHECK_SUPPORTED(); + CHECK_INIT(); + CHECK_ACTIVATED(); + cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); + + /* precondition check end */ + + ret = mtp_gdbus_objectinfo_get_property(device_handle, + object_handle, MTP_PROPERTY_STORAGE_ID, storage_id); + + _END(); + + return ret; +} + +int mtp_objectinfo_get_association_desc(int device_handle, + int object_handle, int *asso_desc) +{ + int ret = MTP_ERROR_NONE; + + _BEGIN(); + + /* precondition check start */ + + CHECK_SUPPORTED(); + CHECK_INIT(); + CHECK_ACTIVATED(); + cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); + + /* precondition check end */ + + ret = mtp_gdbus_objectinfo_get_property(device_handle, + object_handle, MTP_PROPERTY_ASSOCIATION_DESC, asso_desc); + + _END(); + + return ret; +} + +int mtp_objectinfo_get_association_type(int device_handle, + int object_handle, int *asso_type) +{ + int ret = MTP_ERROR_NONE; + + _BEGIN(); + + /* precondition check start */ + + CHECK_SUPPORTED(); + CHECK_INIT(); + CHECK_ACTIVATED(); + cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); + + /* precondition check end */ + + ret = mtp_gdbus_objectinfo_get_property(device_handle, + object_handle, MTP_PROPERTY_ASSOCIATION_TYPE, asso_type); + + _END(); + + return ret; +} + +int mtp_objectinfo_get_size(int device_handle, int object_handle, int *size) +{ + int ret = MTP_ERROR_NONE; + + _BEGIN(); + + /* precondition check start */ + + CHECK_SUPPORTED(); + CHECK_INIT(); + CHECK_ACTIVATED(); + cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); + + /* precondition check end */ + + ret = mtp_gdbus_objectinfo_get_property(device_handle, + object_handle, MTP_PROPERTY_SIZE, size); + + _END(); + + return ret; +} + +int mtp_objectinfo_get_data_created(int device_handle, + int object_handle, int *data_created) +{ + int ret = MTP_ERROR_NONE; + + _BEGIN(); + + /* precondition check start */ + + CHECK_SUPPORTED(); + CHECK_INIT(); + CHECK_ACTIVATED(); + cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); + + /* precondition check end */ + + ret = mtp_gdbus_objectinfo_get_property(device_handle, + object_handle, MTP_PROPERTY_DATA_CREATED, data_created); + + _END(); + + return ret; +} + +int mtp_objectinfo_get_data_modified(int device_handle, + int object_handle, int *data_modified) +{ + int ret = MTP_ERROR_NONE; + + _BEGIN(); + + /* precondition check start */ + + CHECK_SUPPORTED(); + CHECK_INIT(); + CHECK_ACTIVATED(); + cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); + + /* precondition check end */ + + ret = mtp_gdbus_objectinfo_get_property(device_handle, + object_handle, MTP_PROPERTY_DATA_MODIFIED, data_modified); + + _END(); + + return ret; +} + +int mtp_objectinfo_get_format(int device_handle, int object_handle, int *format) +{ + int ret = MTP_ERROR_NONE; + + _BEGIN(); + + /* precondition check start */ + + CHECK_SUPPORTED(); + CHECK_INIT(); + CHECK_ACTIVATED(); + cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); + + /* precondition check end */ + + ret = mtp_gdbus_objectinfo_get_property(device_handle, + object_handle, MTP_PROPERTY_FORMAT, format); + + _END(); + + return ret; +} + +int mtp_objectinfo_get_image_pix_depth(int device_handle, + int object_handle, int *depth) +{ + int ret = MTP_ERROR_NONE; + + _BEGIN(); + + /* precondition check start */ + + CHECK_SUPPORTED(); + CHECK_INIT(); + CHECK_ACTIVATED(); + cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); + + /* precondition check end */ + + ret = mtp_gdbus_objectinfo_get_property(device_handle, + object_handle, MTP_PROPERTY_IMAGE_FIX_DEPTH, depth); + + _END(); + + return ret; +} + +int mtp_objectinfo_get_image_pix_width(int device_handle, + int object_handle, int *width) +{ + int ret = MTP_ERROR_NONE; + + _BEGIN(); + + /* precondition check start */ + + CHECK_SUPPORTED(); + CHECK_INIT(); + CHECK_ACTIVATED(); + cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); + + /* precondition check end */ + + ret = mtp_gdbus_objectinfo_get_property(device_handle, + object_handle, MTP_PROPERTY_IMAGE_FIX_WIDTH, width); + + _END(); + + return ret; +} + +int mtp_objectinfo_get_image_pix_height(int device_handle, + int object_handle, int *height) +{ + int ret = MTP_ERROR_NONE; + + _BEGIN(); + + /* precondition check start */ + + CHECK_SUPPORTED(); + CHECK_INIT(); + CHECK_ACTIVATED(); + cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); + + /* precondition check end */ + + ret = mtp_gdbus_objectinfo_get_property(device_handle, + object_handle, MTP_PROPERTY_IMAGE_FIX_HEIGHT, height); + + _END(); + + return ret; +} + +int mtp_objectinfo_get_thumbnail_size(int device_handle, + int object_handle, int *size) +{ + int ret = MTP_ERROR_NONE; + + _BEGIN(); + + /* precondition check start */ + + CHECK_SUPPORTED(); + CHECK_INIT(); + CHECK_ACTIVATED(); + cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); + + /* precondition check end */ + + ret = mtp_gdbus_objectinfo_get_property(device_handle, + object_handle, MTP_PROPERTY_THUMBNAIL_SIZE, size); + + _END(); + + return ret; +} + +int mtp_objectinfo_get_thumbnail_format(int device_handle, + int object_handle, int *format) +{ + int ret = MTP_ERROR_NONE; + + _BEGIN(); + + /* precondition check start */ + + CHECK_SUPPORTED(); + CHECK_INIT(); + CHECK_ACTIVATED(); + cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); + + /* precondition check end */ + + ret = mtp_gdbus_objectinfo_get_property(device_handle, + object_handle, MTP_PROPERTY_THUMBNAIL_FORMAT, format); + + _END(); + + return ret; +} + +int mtp_objectinfo_get_thumbnail_pix_height(int device_handle, + int object_handle, int *height) +{ + int ret = MTP_ERROR_NONE; + + _BEGIN(); + + /* precondition check start */ + + CHECK_SUPPORTED(); + CHECK_INIT(); + CHECK_ACTIVATED(); + cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); + + /* precondition check end */ + + ret = mtp_gdbus_objectinfo_get_property(device_handle, + object_handle, MTP_PROPERTY_THUMBNAIL_HEIGHT, height); + + _END(); + + return ret; +} + +int mtp_objectinfo_get_thumbnail_pix_width(int device_handle, + int object_handle, int *width) +{ + int ret = MTP_ERROR_NONE; + + _BEGIN(); + + /* precondition check start */ + + CHECK_SUPPORTED(); + CHECK_INIT(); + CHECK_ACTIVATED(); + cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); + + /* precondition check end */ + + ret = mtp_gdbus_objectinfo_get_property(device_handle, + object_handle, MTP_PROPERTY_THUMBNAIL_WIDTH, width); + + _END(); + + return ret; +} + +int mtp_objectinfo_get_filename(int device_handle, + int object_handle, char **filename) +{ + int ret = MTP_ERROR_NONE; + + _BEGIN(); + + /* precondition check start */ + + CHECK_SUPPORTED(); + CHECK_INIT(); + CHECK_ACTIVATED(); + cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); + + /* precondition check end */ + + ret = mtp_gdbus_objectinfo_get_property_string(device_handle, + object_handle, MTP_PROPERTY_FILENAME, filename); + + _END(); + + return ret; +} + +int mtp_objectinfo_get_keywords(int device_handle, + int object_handle, char **keywords) +{ + int ret = MTP_ERROR_NONE; + + _BEGIN(); + + /* precondition check start */ + + CHECK_SUPPORTED(); + CHECK_INIT(); + CHECK_ACTIVATED(); + cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); + + /* precondition check end */ + + ret = mtp_gdbus_objectinfo_get_property_string(device_handle, + object_handle, MTP_PROPERTY_KEYWORDS, keywords); + + _END(); + + return ret; +} + +int mtp_objectinfo_get_object_info(int device_handle, + int object_handle, mtp_object_info **object_info) +{ + int ret = MTP_ERROR_NONE; + + _BEGIN(); + + /* precondition check start */ + + CHECK_SUPPORTED(); + CHECK_INIT(); + CHECK_ACTIVATED(); + cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); + + /* precondition check end */ + + ret = mtp_db_get_object_info(device_handle, object_handle, object_info); + + _END(); + + return ret; +} + diff --git a/src/mtp_db.c b/src/mtp_db.c new file mode 100755 index 0000000..84e518d --- /dev/null +++ b/src/mtp_db.c @@ -0,0 +1,143 @@ +/* + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "mtp_db.h" + +#define MTP_DB_LOCK \ + do { \ + pthread_mutex_lock(&mutex); \ + } while (0); + +#define MTP_DB_UNLOCK \ + do { \ + pthread_mutex_unlock(&mutex); \ + } while (0); + +static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; +static sqlite3 *db; +int ref_count; + +mtp_error_e mtp_db_init() +{ + int ret = MTP_ERROR_NONE; + int sql_ret; + + MTP_DB_LOCK; + + if (ref_count > 0) { + ref_count++; + } else if (db == NULL) { + sql_ret = sqlite3_open_v2(MTP_DB_FILE, &db, + SQLITE_OPEN_NOMUTEX | SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL); + + if (sql_ret == SQLITE_OK) + ref_count++; + else + ret = MTP_ERROR_DB; + } + + MTP_DB_UNLOCK; + + return ret; +} + +mtp_error_e mtp_db_get_object_info(int device_handle, int object_handle, mtp_object_info** object_info) +{ + int ret = MTP_ERROR_NONE; + int sql_ret; + char *sql = NULL; + sqlite3_stmt *stmt = NULL; + + MTP_DB_LOCK; + + if (db == NULL) { + MTP_DB_UNLOCK; + return MTP_ERROR_DB; + } + + *object_info = (mtp_object_info *)malloc(sizeof(mtp_object_info)); + + sql = sqlite3_mprintf("SELECT * FROM %s WHERE device_handle=%d and object_handle=%d;", + MTP_DB_TABLE, device_handle, object_handle); + + if (sql != NULL && (*object_info) != NULL) { + sql_ret = sqlite3_prepare_v2(db, sql, strlen(sql), &stmt, NULL); + if (stmt != NULL) { + sql_ret = sqlite3_step(stmt); + if (sql_ret == SQLITE_ROW) { + (*object_info)->StorageID = sqlite3_column_int(stmt, 2); + (*object_info)->ObjectFormat = sqlite3_column_int(stmt, 4); + (*object_info)->ProtectionStatus = sqlite3_column_int(stmt, 5); + (*object_info)->ObjectCompressedSize = sqlite3_column_int(stmt, 6); + (*object_info)->ThumbFormat = sqlite3_column_int(stmt, 7); + (*object_info)->ThumbCompressedSize = sqlite3_column_int(stmt, 8); + (*object_info)->ThumbPixWidth = sqlite3_column_int(stmt, 9); + (*object_info)->ThumbPixHeight = sqlite3_column_int(stmt, 10); + (*object_info)->ImagePixWidth = sqlite3_column_int(stmt, 11); + (*object_info)->ImagePixHeight = sqlite3_column_int(stmt, 12); + (*object_info)->ImageBitDepth = sqlite3_column_int(stmt, 13); + (*object_info)->ParentObject = sqlite3_column_int(stmt, 14); + (*object_info)->AssociationType = sqlite3_column_int(stmt, 15); + (*object_info)->AssociationDesc = sqlite3_column_int(stmt, 16); + (*object_info)->SequenceNumber = sqlite3_column_int(stmt, 17); + (*object_info)->Filename = g_strdup((const char*)sqlite3_column_text(stmt, 18)); + (*object_info)->CaptureDate = sqlite3_column_int(stmt, 19); + (*object_info)->ModificationDate = sqlite3_column_int(stmt, 20); + (*object_info)->Keywords = NULL; + } else { + ret = MTP_ERROR_DB; + } + } else { + ret = MTP_ERROR_DB; + } + } else { + ret = MTP_ERROR_DB; + } + + if (stmt != NULL) + sqlite3_finalize(stmt); + + if (sql != NULL) + sqlite3_free(sql); + + MTP_DB_UNLOCK; + + return ret; +} + +mtp_error_e mtp_db_deinit() +{ + int ret = MTP_ERROR_NONE; + int sql_ret; + + MTP_DB_LOCK; + + if (ref_count > 0) + ref_count--; + + if (db != NULL && ref_count == 0) { + sql_ret = sqlite3_close(db); + + if (sql_ret != SQLITE_OK) + ret = MTP_ERROR_DB; + + db = NULL; + } + + MTP_DB_UNLOCK; + + return ret; +} diff --git a/src/mtp_gdbus_deviceinfo.c b/src/mtp_gdbus_deviceinfo.c new file mode 100755 index 0000000..eff5d5b --- /dev/null +++ b/src/mtp_gdbus_deviceinfo.c @@ -0,0 +1,124 @@ +/* + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "mtp_gdbus_deviceinfo.h" + +mtpgdbuslibDeviceinfo *deviceinfo_proxy = NULL; + +void mtp_gdbus_deviceinfo_proxy_init(void) +{ + deviceinfo_proxy = mtp_gdbuslib_deviceinfo_proxy_new_for_bus_sync( + G_BUS_TYPE_SYSTEM, + G_DBUS_PROXY_FLAGS_NONE, + MTP_DBUS_SERVICE, + MTP_DBUS_DEVICEINFO_PATH, + NULL, + NULL); +} + +void mtp_gdbus_deviceinfo_proxy_deinit(void) +{ + deviceinfo_proxy = NULL; +} + +mtp_error_e mtp_gdbus_deviceinfo_get_manufacturername(int device_handle, char **manufacturername) +{ + mtp_error_e result = MTP_ERROR_NONE; + GError *error = NULL; + + if (deviceinfo_proxy == NULL) + return MTP_ERROR_GENERAL; + + if (mtp_gdbuslib_deviceinfo_call_get_manufacturername_sync( + deviceinfo_proxy, + device_handle, + manufacturername, + &result, + NULL, + &error) == FALSE) { + result = MTP_ERROR_IO_ERROR; + g_error_free(error); + } + + return result; +} + +mtp_error_e mtp_gdbus_deviceinfo_get_modelname(int device_handle, char **modelname) +{ + mtp_error_e result = MTP_ERROR_NONE; + GError *error = NULL; + + if (deviceinfo_proxy == NULL) + return MTP_ERROR_GENERAL; + + if (mtp_gdbuslib_deviceinfo_call_get_modelname_sync( + deviceinfo_proxy, + device_handle, + modelname, + &result, + NULL, + &error) == FALSE) { + result = MTP_ERROR_IO_ERROR; + g_error_free(error); + } + + return result; +} + +mtp_error_e mtp_gdbus_deviceinfo_get_serialnumber(int device_handle, char **serialnumber) +{ + mtp_error_e result = MTP_ERROR_NONE; + GError *error = NULL; + + if (deviceinfo_proxy == NULL) + return MTP_ERROR_GENERAL; + + if (mtp_gdbuslib_deviceinfo_call_get_serialnumber_sync( + deviceinfo_proxy, + device_handle, + serialnumber, + &result, + NULL, + &error) == FALSE) { + result = MTP_ERROR_IO_ERROR; + g_error_free(error); + } + + return result; +} + +mtp_error_e mtp_gdbus_deviceinfo_get_deviceversion(int device_handle, char **deviceversion) +{ + mtp_error_e result = MTP_ERROR_NONE; + GError *error = NULL; + + if (deviceinfo_proxy == NULL) + return MTP_ERROR_GENERAL; + + if (mtp_gdbuslib_deviceinfo_call_get_deviceversion_sync( + deviceinfo_proxy, + device_handle, + deviceversion, + &result, + NULL, + &error) == FALSE) { + result = MTP_ERROR_IO_ERROR; + g_error_free(error); + } + + return result; +} + diff --git a/src/mtp_gdbus_manager.c b/src/mtp_gdbus_manager.c new file mode 100755 index 0000000..ca4b603 --- /dev/null +++ b/src/mtp_gdbus_manager.c @@ -0,0 +1,348 @@ +/* + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "mtp_gdbus_manager.h" +#include "mtp_gdbus_objectinfo.h" +#include "mtp_gdbus_deviceinfo.h" +#include "mtp_gdbus_storageinfo.h" + +mtpgdbuslibManager *manager_proxy = NULL; +mtp_event_cb event_callback; +void *event_user_data; + +static void __mtp_event_cb(mtpgdbuslibManager *object, + gint event, gint arg1, gpointer user_data) +{ + if (event_callback) + event_callback(event, arg1, event_user_data); +} + +static void __manager_proxy_init(void) +{ + GError *error = NULL; + + manager_proxy = mtp_gdbuslib_manager_proxy_new_for_bus_sync( + G_BUS_TYPE_SYSTEM, + G_DBUS_PROXY_FLAGS_NONE, + MTP_DBUS_SERVICE, + MTP_DBUS_MANAGER_PATH, + NULL, + &error); + + g_signal_connect(manager_proxy, "mtp-event", G_CALLBACK(__mtp_event_cb), NULL); +} + +static void __manager_proxy_deinit(void) +{ + manager_proxy = NULL; +} + +mtp_error_e mtp_gdbus_manager_set_event_cb(mtp_event_cb callback, void *user_data) +{ + event_callback = callback; + event_user_data = user_data; + + return MTP_ERROR_NONE; +} + +mtp_error_e mtp_gdbus_manager_unset_event_cb(void) +{ + event_callback = NULL; + event_user_data = NULL; + + return MTP_ERROR_NONE; +} + +mtp_error_e mtp_gdbus_manager_initialize(void) +{ + mtp_error_e result = MTP_ERROR_NONE; + + __manager_proxy_init(); + mtp_gdbus_deviceinfo_proxy_init(); + mtp_gdbus_storageinfo_proxy_init(); + mtp_gdbus_objectinfo_proxy_init(); + + if (manager_proxy == NULL) + result = MTP_ERROR_GENERAL; + + return result; +} + +mtp_error_e mtp_gdbus_manager_get_device_list(mtp_device_list **dev_list) +{ + int dev_count; + GVariant *va = NULL; + mtp_error_e result = MTP_ERROR_NONE; + GError *error = NULL; + + if (manager_proxy == NULL) + return MTP_ERROR_GENERAL; + + if (mtp_gdbuslib_manager_call_get_device_list_sync( + manager_proxy, + &dev_count, + &va, + &result, + NULL, + &error) == FALSE) { + result = MTP_ERROR_IO_ERROR; + + g_error_free(error); + return result; + } + + if (dev_count != 0 && (g_variant_n_children(va) == dev_count)) { + GVariantIter *iter = NULL, *iter_row = NULL; + GVariant *key_value; + const gchar *key; + guint i = 0; + + *dev_list = g_new(mtp_device_list, 1); + (*dev_list)->device_num = dev_count; + (*dev_list)->devices = g_new(mtp_device, dev_count); + + g_variant_get(va, "aa{sv}", &iter); + while (g_variant_iter_next(iter, "a{sv}", &iter_row)) { + while (g_variant_iter_loop(iter_row, "{sv}", &key, &key_value)) { + if (g_strcmp0(key, "model_name") == 0) { + ((*dev_list)->devices)[i].model_name = + g_strdup(g_variant_get_string(key_value, NULL)); + } else if (g_strcmp0(key, "bus_location") == 0) { + ((*dev_list)->devices)[i].bus_location = g_variant_get_int32(key_value); + } + } + i++; + g_variant_iter_free(iter_row); + } + g_variant_iter_free(iter); + } else { + result = MTP_ERROR_NO_DEVICE; + } + + g_variant_unref(va); + + return result; +} + +mtp_error_e mtp_gdbus_manager_get_device_handle(int bus_location, int *device_handle) +{ + mtp_error_e result = MTP_ERROR_NONE; + GError *error = NULL; + + if (manager_proxy == NULL) + return MTP_ERROR_GENERAL; + + if (mtp_gdbuslib_manager_call_get_device_handle_sync( + manager_proxy, + bus_location, + device_handle, + &result, + NULL, + &error) == FALSE) { + result = MTP_ERROR_IO_ERROR; + + g_error_free(error); + } + + return result; +} + +mtp_error_e mtp_gdbus_manager_get_storage_ids(int device_handle, + int **storage_ids, int *storage_num) +{ + GVariant *va = NULL; + mtp_error_e result = MTP_ERROR_NONE; + GError *error = NULL; + + if (manager_proxy == NULL) + return MTP_ERROR_GENERAL; + + if (mtp_gdbuslib_manager_call_get_storage_ids_sync( + manager_proxy, + device_handle, + storage_num, + &va, + &result, + NULL, + &error) == FALSE) { + result = MTP_ERROR_IO_ERROR; + + g_error_free(error); + return result; + } + + if (*storage_num != 0 && (g_variant_n_children(va) == *storage_num)) { + GVariantIter *iter = NULL, *iter_row = NULL; + GVariant *key_value; + const gchar *key; + guint i = 0; + + *storage_ids = g_new(int, *storage_num); + + g_variant_get(va, "aa{sv}", &iter); + while (g_variant_iter_next(iter, "a{sv}", &iter_row)) { + while (g_variant_iter_loop(iter_row, "{sv}", &key, &key_value)) { + if (g_strcmp0(key, "storage_id") == 0) + (*storage_ids)[i] = g_variant_get_int32(key_value); + } + i++; + g_variant_iter_free(iter_row); + } + g_variant_iter_free(iter); + } + + g_variant_unref(va); + + return result; +} + +mtp_error_e mtp_gdbus_manager_get_object_handles(int device_handle, + int storage_id, int format, int parent_object_handle, int **object_handles, int *object_num) +{ + GVariant *va = NULL; + mtp_error_e result = MTP_ERROR_NONE; + GError *error = NULL; + + if (manager_proxy == NULL) + return MTP_ERROR_GENERAL; + + if (mtp_gdbuslib_manager_call_get_object_handles_sync( + manager_proxy, + device_handle, + storage_id, + format, + parent_object_handle, + object_num, + &va, + &result, + NULL, + &error) == FALSE) { + result = MTP_ERROR_IO_ERROR; + + g_error_free(error); + return result; + } + + if (*object_num != 0 && (g_variant_n_children(va) == *object_num)) { + GVariantIter *iter = NULL, *iter_row = NULL; + GVariant *key_value; + const gchar *key; + guint i = 0; + + *object_handles = g_new(int, *object_num); + + g_variant_get(va, "aa{sv}", &iter); + while (g_variant_iter_next(iter, "a{sv}", &iter_row)) { + while (g_variant_iter_loop(iter_row, "{sv}", &key, &key_value)) { + if (g_strcmp0(key, "object_handle") == 0) + (*object_handles)[i] = g_variant_get_int32(key_value); + } + i++; + g_variant_iter_free(iter_row); + } + g_variant_iter_free(iter); + } + + g_variant_unref(va); + + return result; +} + +mtp_error_e mtp_gdbus_manager_delete_object(int device_handle, + int object_handle) +{ + mtp_error_e result = MTP_ERROR_NONE; + GError *error = NULL; + + if (manager_proxy == NULL) + return MTP_ERROR_GENERAL; + + if (mtp_gdbuslib_manager_call_delete_object_sync( + manager_proxy, + device_handle, + object_handle, + &result, + NULL, + &error) == FALSE) { + result = MTP_ERROR_IO_ERROR; + + g_error_free(error); + } + + return result; +} + +mtp_error_e mtp_gdbus_manager_get_object(int device_handle, + int object_handle, char *dest_path) +{ + mtp_error_e result = MTP_ERROR_NONE; + GError *error = NULL; + + if (manager_proxy == NULL) + return MTP_ERROR_GENERAL; + + if (mtp_gdbuslib_manager_call_get_object_sync( + manager_proxy, + device_handle, + object_handle, + dest_path, + &result, + NULL, + &error) == FALSE) { + result = MTP_ERROR_IO_ERROR; + + g_error_free(error); + } + + return result; +} + +mtp_error_e mtp_gdbus_manager_get_thumbnail(int device_handle, + int object_handle, char *dest_path) +{ + mtp_error_e result = MTP_ERROR_NONE; + GError *error = NULL; + + if (manager_proxy == NULL) + return MTP_ERROR_GENERAL; + + if (mtp_gdbuslib_manager_call_get_thumbnail_sync( + manager_proxy, + device_handle, + object_handle, + dest_path, + &result, + NULL, + &error) == FALSE) { + result = MTP_ERROR_IO_ERROR; + + g_error_free(error); + } + + return result; +} + +mtp_error_e mtp_gdbus_manager_deinitialize(void) +{ + mtp_error_e result = MTP_ERROR_NONE; + + __manager_proxy_deinit(); + mtp_gdbus_deviceinfo_proxy_deinit(); + mtp_gdbus_storageinfo_proxy_deinit(); + mtp_gdbus_objectinfo_proxy_deinit(); + + return result; +} diff --git a/src/mtp_gdbus_objectinfo.c b/src/mtp_gdbus_objectinfo.c new file mode 100755 index 0000000..38077fb --- /dev/null +++ b/src/mtp_gdbus_objectinfo.c @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "mtp_gdbus_objectinfo.h" + +mtpgdbuslibObjectinfo *objectinfo_proxy = NULL; + +void mtp_gdbus_objectinfo_proxy_init(void) +{ + objectinfo_proxy = mtp_gdbuslib_objectinfo_proxy_new_for_bus_sync( + G_BUS_TYPE_SYSTEM, + G_DBUS_PROXY_FLAGS_NONE, + MTP_DBUS_SERVICE, + MTP_DBUS_OBJECTINFO_PATH, + NULL, + NULL); +} + +void mtp_gdbus_objectinfo_proxy_deinit(void) +{ + objectinfo_proxy = NULL; +} + +int mtp_gdbus_objectinfo_get_property(int device_handle, + int object_handle, int property, int *property_value) +{ + mtp_error_e result = MTP_ERROR_NONE; + GError *error = NULL; + + if (objectinfo_proxy == NULL) + return MTP_ERROR_GENERAL; + + if (mtp_gdbuslib_objectinfo_call_get_property_sync( + objectinfo_proxy, + device_handle, + object_handle, + property, + property_value, + &result, + NULL, + &error) == FALSE) { + result = MTP_ERROR_IO_ERROR; + g_error_free(error); + } + + return result; +} + +int mtp_gdbus_objectinfo_get_property_string(int device_handle, + int object_handle, int property, char **property_value) +{ + mtp_error_e result = MTP_ERROR_NONE; + GError *error = NULL; + + if (objectinfo_proxy == NULL) + return MTP_ERROR_GENERAL; + + if (mtp_gdbuslib_objectinfo_call_get_property_string_sync( + objectinfo_proxy, + device_handle, + object_handle, + property, + property_value, + &result, + NULL, + &error) == FALSE) { + result = MTP_ERROR_IO_ERROR; + g_error_free(error); + } + + return result; +} + diff --git a/src/mtp_gdbus_storageinfo.c b/src/mtp_gdbus_storageinfo.c new file mode 100755 index 0000000..b8ab9f6 --- /dev/null +++ b/src/mtp_gdbus_storageinfo.c @@ -0,0 +1,155 @@ +/* + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "mtp_gdbus_storageinfo.h" + +mtpgdbuslibStorageinfo *storageinfo_proxy = NULL; + +void mtp_gdbus_storageinfo_proxy_init(void) +{ + storageinfo_proxy = mtp_gdbuslib_storageinfo_proxy_new_for_bus_sync( + G_BUS_TYPE_SYSTEM, + G_DBUS_PROXY_FLAGS_NONE, + MTP_DBUS_SERVICE, + MTP_DBUS_STORAGEINFO_PATH, + NULL, + NULL); +} + +void mtp_gdbus_storageinfo_proxy_deinit(void) +{ + storageinfo_proxy = NULL; +} + +mtp_error_e mtp_gdbus_storageinfo_get_description(int device_handle, + int storage_id, char **description) +{ + mtp_error_e result = MTP_ERROR_NONE; + GError *error = NULL; + + if (storageinfo_proxy == NULL) + return MTP_ERROR_GENERAL; + + if (mtp_gdbuslib_storageinfo_call_get_description_sync( + storageinfo_proxy, + device_handle, + storage_id, + description, + &result, + NULL, + &error) == FALSE) { + result = MTP_ERROR_IO_ERROR; + g_error_free(error); + } + + return result; +} + +mtp_error_e mtp_gdbus_storageinfo_get_freespace(int device_handle, + int storage_id, guint64 *freespace) +{ + mtp_error_e result = MTP_ERROR_NONE; + GError *error = NULL; + + if (storageinfo_proxy == NULL) + return MTP_ERROR_GENERAL; + + if (mtp_gdbuslib_storageinfo_call_get_free_space_sync( + storageinfo_proxy, + device_handle, + storage_id, + freespace, + &result, + NULL, + &error) == FALSE) { + result = MTP_ERROR_IO_ERROR; + g_error_free(error); + } + + return result; +} + +mtp_error_e mtp_gdbus_storageinfo_get_maxcapacity(int device_handle, + int storage_id, guint64 *maxcapacity) +{ + mtp_error_e result = MTP_ERROR_NONE; + GError *error = NULL; + + if (storageinfo_proxy == NULL) + return MTP_ERROR_GENERAL; + + if (mtp_gdbuslib_storageinfo_call_get_max_capacity_sync( + storageinfo_proxy, + device_handle, + storage_id, + maxcapacity, + &result, + NULL, + &error) == FALSE) { + result = MTP_ERROR_IO_ERROR; + g_error_free(error); + } + + return result; +} + +mtp_error_e mtp_gdbus_storageinfo_get_storagetype(int device_handle, + int storage_id, int *storagetype) +{ + mtp_error_e result = MTP_ERROR_NONE; + GError *error = NULL; + + if (storageinfo_proxy == NULL) + return MTP_ERROR_GENERAL; + + if (mtp_gdbuslib_storageinfo_call_get_storage_type_sync( + storageinfo_proxy, + device_handle, + storage_id, + storagetype, + &result, + NULL, + &error) == FALSE) { + result = MTP_ERROR_IO_ERROR; + g_error_free(error); + } + + return result; +} + +mtp_error_e mtp_gdbus_storageinfo_get_volumeidentifier(int device_handle, + int storage_id, char **volumeidentifier) +{ + mtp_error_e result = MTP_ERROR_NONE; + GError *error = NULL; + + if (storageinfo_proxy == NULL) + return MTP_ERROR_GENERAL; + + if (mtp_gdbuslib_storageinfo_call_get_volume_identifier_sync( + storageinfo_proxy, + device_handle, + storage_id, + volumeidentifier, + &result, + NULL, + &error) == FALSE) { + result = MTP_ERROR_IO_ERROR; + g_error_free(error); + } + + return result; +} diff --git a/src/mtp_gdbuslib.xml b/src/mtp_gdbuslib.xml new file mode 100755 index 0000000..45afda8 --- /dev/null +++ b/src/mtp_gdbuslib.xml @@ -0,0 +1,138 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100755 index 0000000..474d37d --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,18 @@ +SET(fw_test "${fw_name}-test") + +INCLUDE(FindPkgConfig) +pkg_check_modules(${fw_test} REQUIRED dlog glib-2.0) +FOREACH(flag ${${fw_test}_CFLAGS}) + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") + MESSAGE(${flag}) +ENDFOREACH() + +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -Wall") + +aux_source_directory(. sources) +FOREACH(src ${sources}) + GET_FILENAME_COMPONENT(src_name ${src} NAME_WE) + MESSAGE("${src_name}") + ADD_EXECUTABLE(${src_name} ${src}) + TARGET_LINK_LIBRARIES(${src_name} ${fw_name} ${${fw_test}_LDFLAGS}) +ENDFOREACH() diff --git a/test/mtp_unit_test.c b/test/mtp_unit_test.c new file mode 100755 index 0000000..5aa8377 --- /dev/null +++ b/test/mtp_unit_test.c @@ -0,0 +1,1254 @@ +#include +#include +#include +#include +#include +#include + +#include +#include + +#define BUFFER_LEN 100 +#define TEST_CASE_MAX 39 +#define TEST_LIST_MAX 20 + +#define PRT(format, args...) printf("%s:%d() "format, __FUNCTION__, __LINE__, ##args) +#define TC_PRT(format, args...) PRT(format"\n", ##args) + +#define BEGIN() TC_PRT("BEGIN >>>>"); +#define END() TC_PRT("END <<<<"); + +static int handle; +static mtp_device_list* dev_list; + +static int strg_handle = 0; +static int* strg_list; + +static int obj_handle = 0; +static int* obj_list; +int obj_count; + +GMainLoop *main_loop = NULL; + +typedef struct { + const char *tc_name; + int tc_code; + int (*tc_func)(void); +} tc_table_t; + + +static bool test_get_user_int(const char *msg, int *num) +{ + if (msg == NULL || num == NULL) + return false; + + int rv; + char buf[32] = { 0, }; + printf("%s\n", msg); + rv = read(0, buf, 32); + + if (rv < 0 || *buf == 0 || *buf == '\n' || *buf == '\r') + return false; + + *num = atoi(buf); + return true; +} + +static bool test_get_user_string(const char *msg, char *buf, int buf_size) +{ + if (msg == NULL || buf == NULL || buf_size < 2) + return false; + + int rv; + printf("%s\n", msg); + memset(buf, 0, buf_size); + rv = read(0, buf, buf_size - 1); + + if (rv < 0 || buf[0] == '\0' || buf[0] == '\n' || buf[0] == '\r') { + buf[0] = '\0'; + return false; + } + + if (rv >= 0) + buf[rv] = '\0'; + + return true; +} + +static char *test_filetype_to_string(int type) +{ + switch (type) { + case MTP_FILETYPE_FOLDER: return "MTP_FILETYPE_FOLDER"; + case MTP_FILETYPE_WAV: return "MTP_FILETYPE_WAV"; + case MTP_FILETYPE_MP3: return "MTP_FILETYPE_MP3"; + case MTP_FILETYPE_WMA: return "MTP_FILETYPE_WMA"; + case MTP_FILETYPE_OGG: return "MTP_FILETYPE_OGG"; + case MTP_FILETYPE_AUDIBLE: return "MTP_FILETYPE_AUDIBLE"; + case MTP_FILETYPE_MP4: return "MTP_FILETYPE_MP4"; + case MTP_FILETYPE_UNDEF_AUDIO: return "MTP_FILETYPE_UNDEF_AUDIO"; + case MTP_FILETYPE_WMV: return "MTP_FILETYPE_WMV"; + case MTP_FILETYPE_AVI: return "MTP_FILETYPE_AVI"; + case MTP_FILETYPE_MPEG: return "MTP_FILETYPE_MPEG"; + case MTP_FILETYPE_ASF: return "MTP_FILETYPE_ASF"; + case MTP_FILETYPE_QT: return "MTP_FILETYPE_QT"; + case MTP_FILETYPE_UNDEF_VIDEO: return "MTP_FILETYPE_UNDEF_VIDEO"; + case MTP_FILETYPE_JPEG: return "MTP_FILETYPE_JPEG"; + case MTP_FILETYPE_JFIF: return "MTP_FILETYPE_JFIF"; + case MTP_FILETYPE_TIFF: return "MTP_FILETYPE_TIFF"; + case MTP_FILETYPE_BMP: return "MTP_FILETYPE_BMP"; + case MTP_FILETYPE_GIF: return "MTP_FILETYPE_GIF"; + case MTP_FILETYPE_PICT: return "MTP_FILETYPE_PICT"; + case MTP_FILETYPE_PNG: return "MTP_FILETYPE_PNG"; + case MTP_FILETYPE_VCALENDAR1: return "MTP_FILETYPE_VCALENDAR1"; + case MTP_FILETYPE_VCALENDAR2: return "MTP_FILETYPE_VCALENDAR2"; + case MTP_FILETYPE_VCARD2: return "MTP_FILETYPE_VCARD2"; + case MTP_FILETYPE_VCARD3: return "MTP_FILETYPE_VCARD3"; + case MTP_FILETYPE_WINDOWSIMAGEFORMAT: return "MTP_FILETYPE_WINDOWSIMAGEFORMAT"; + case MTP_FILETYPE_WINEXEC: return "MTP_FILETYPE_WINEXEC"; + case MTP_FILETYPE_TEXT: return "MTP_FILETYPE_TEXT"; + case MTP_FILETYPE_HTML: return "MTP_FILETYPE_HTML"; + case MTP_FILETYPE_FIRMWARE: return "MTP_FILETYPE_FIRMWARE"; + case MTP_FILETYPE_AAC: return "MTP_FILETYPE_AAC"; + case MTP_FILETYPE_MEDIACARD: return "MTP_FILETYPE_MEDIACARD"; + case MTP_FILETYPE_FLAC: return "MTP_FILETYPE_FLAC"; + case MTP_FILETYPE_MP2: return "MTP_FILETYPE_MP2"; + case MTP_FILETYPE_M4A: return "MTP_FILETYPE_M4A"; + case MTP_FILETYPE_DOC: return "MTP_FILETYPE_DOC"; + case MTP_FILETYPE_XML: return "MTP_FILETYPE_XML"; + case MTP_FILETYPE_XLS: return "MTP_FILETYPE_XLS"; + case MTP_FILETYPE_PPT: return "MTP_FILETYPE_PPT"; + case MTP_FILETYPE_MHT: return "MTP_FILETYPE_MHT"; + case MTP_FILETYPE_JP2: return "MTP_FILETYPE_JP2"; + case MTP_FILETYPE_JPX: return "MTP_FILETYPE_JPX"; + case MTP_FILETYPE_ALBUM: return "MTP_FILETYPE_ALBUM"; + case MTP_FILETYPE_PLAYLIST: return "MTP_FILETYPE_PLAYLIST"; + case MTP_FILETYPE_UNKNOWN: return "MTP_FILETYPE_UNKNOWN"; + default: return "Not Supported type!!!"; + } +} + +int manager_test_initialize(void) +{ + int ret = 0; + + BEGIN(); + + ret = mtp_initialize(); + + if (ret == MTP_ERROR_NONE) + TC_PRT("Initialize successful"); + else + TC_PRT("Initialize failed, ret [%d]", ret); + + END(); + return ret; +} + +int manager_test_get_device_list(void) +{ + int ret = 0; + int i; + BEGIN(); + + ret = mtp_get_device_list(&dev_list); + + if (ret == MTP_ERROR_NONE) { + TC_PRT("ret[%d]: device_num[%d]", ret, dev_list->device_num); + + for (i = 0; i < dev_list->device_num; i++) { + TC_PRT("device bus_location[%d] model_name[%s]", + dev_list->devices[i].bus_location, dev_list->devices[i].model_name); + } + } else { + TC_PRT("get device list failed, ret[%d]", ret); + } + + END(); + return ret; +} + +int manager_test_get_device_handle(void) +{ + int ret = 0; + int input_int = 0; + int bus_location = 0; + BEGIN(); + + if (dev_list->device_num == 0) { + TC_PRT("device is not exist!!!"); + END(); + return -1; + } + + input_int = dev_list->devices[0].bus_location; + + if (dev_list->device_num > 1) { + if (!test_get_user_int("==> Input Bus_location No :", &input_int)) + TC_PRT("select first bus[%d]", input_int); + } + + bus_location = input_int; + + ret = mtp_get_device_handle(bus_location, &handle); + TC_PRT("ret[%d]: 1st device handle[%d]", ret, handle); + + END(); + return ret; +} + +int manager_test_get_storage_ids(void) +{ + int ret = 0; + int i; + int count = 0; + int input_int = 0; + BEGIN(); + + ret = mtp_get_storage_ids(handle, &strg_list, &count); + TC_PRT("ret[%d]: storage_num[%d]", ret, count); + + if (count == 0) { + TC_PRT("storage is not exist!!!"); + END(); + return -1; + } + + for (i = 0; i < count; i++) + TC_PRT("storage handle[%d]", strg_list[i]); + + input_int = strg_list[0]; + + if (count > 1) { + if (!test_get_user_int("==> Input Storage Handle :", &input_int)) + TC_PRT("select first storage[%d]", strg_list[0]); + } + + strg_handle = input_int; + TC_PRT("selected storage handle[%d]", strg_handle); + + END(); + return ret; +} + +int manager_test_get_object_handles(void) +{ + int ret = 0; + int i; + int input_int = 0; + int *folder_list; + int folder_count = 0; + int *file_list; + int file_count = 0; + int format = MTP_FILETYPE_FOLDER; + char *filename = NULL; + int folder_max = 0; + int file_max = 0; + int list_max = 0; + BEGIN(); + + ret = mtp_get_object_handles(handle, strg_handle, MTP_FILETYPE_FOLDER, obj_handle, &folder_list, &folder_count); + TC_PRT("ret[%d]: total folder_count[%d]", ret, folder_count); + + folder_max = (folder_count < TEST_LIST_MAX) ? folder_count : TEST_LIST_MAX; + + for (i = 0; i < folder_max; i++) { + ret = mtp_objectinfo_get_filename(handle, folder_list[i], &filename); + ret = mtp_objectinfo_get_format(handle, folder_list[i], &format); + TC_PRT("ret[%d]: object id[%d] - filename[%s], format[%s]", + ret, folder_list[i], filename, test_filetype_to_string(format)); + } + + ret = mtp_get_object_handles(handle, strg_handle, MTP_FILETYPE_JPEG, obj_handle, &file_list, &file_count); + TC_PRT("ret[%d]: total file_count[%d]", ret, file_count); + + file_max = (file_count < TEST_LIST_MAX) ? file_count : TEST_LIST_MAX; + + for (i = 0; i < file_max; i++) { + ret = mtp_objectinfo_get_filename(handle, file_list[i], &filename); + ret = mtp_objectinfo_get_format(handle, file_list[i], &format); + TC_PRT("ret[%d]: object id[%d] - filename[%s], format[%s]", + ret, file_list[i], filename, test_filetype_to_string(format)); + } + + if (!test_get_user_int("==> Select Object Type(FOLDER:0, JPEG:14)" + " - (Enter for skip) :", &input_int)) { + TC_PRT("select default : folder[%d]", input_int); + } + + ret = mtp_get_object_handles(handle, strg_handle, input_int, obj_handle, &obj_list, &obj_count); + + TC_PRT("ret[%d]: total object_num[%d]", ret, 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_filename(handle, obj_list[i], &filename); + ret = mtp_objectinfo_get_format(handle, obj_list[i], &format); + TC_PRT("ret[%d]: object id[%d] - filename[%s], format[%s]", + ret, obj_list[i], filename, test_filetype_to_string(format)); + } + + if (input_int == MTP_FILETYPE_FOLDER) { + if (!test_get_user_int("==> Input Object ID :", &obj_handle)) { + TC_PRT("invalid input !!![%d]", obj_handle); + obj_handle = 0; + END(); + return -1; + } + TC_PRT("selected object id[%d]", obj_handle); + TC_PRT("===== Object List - Folder ====="); + } else { + TC_PRT("===== Object List - JPEG ====="); + } + + END(); + return ret; +} + +int manager_test_delete_object(void) +{ + int ret = 0; + int i; + int input_int = 0; + int format = MTP_FILETYPE_JPEG; + char *filename = NULL; + int list_max = 0; + 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_filename(handle, obj_list[i], &filename); + ret = mtp_objectinfo_get_format(handle, obj_list[i], &format); + TC_PRT("ret[%d]: object id[%d] - filename[%s], format[%s]", + ret, obj_list[i], filename, test_filetype_to_string(format)); + } + + if (!test_get_user_int("==> Input Object ID :", &input_int)) { + TC_PRT("Invalid Input !!![%d]", input_int); + END(); + return -1; + } + + ret = mtp_delete_object(handle, input_int); + TC_PRT("ret[%d]: input id[%d]", ret, input_int); + + END(); + return ret; +} + +int manager_test_get_object(void) +{ + int ret = 0; + int i; + int input_int = 0; + int format = MTP_FILETYPE_JPEG; + char *filename = NULL; + char filepath[100] = {0,}; + int list_max = 0; + 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_filename(handle, obj_list[i], &filename); + ret = mtp_objectinfo_get_format(handle, obj_list[i], &format); + TC_PRT("ret[%d]: object id[%d] - filename[%s], format[%s]", + ret, obj_list[i], filename, test_filetype_to_string(format)); + } + + if (!test_get_user_int("==> Input Object ID :", &input_int)) { + TC_PRT("Invalid Input !!![%d]", input_int); + END(); + return -1; + } + + snprintf(filepath, 100, "/opt/usr/media/Downloads/JpegObject_%d.jpg", input_int); + + ret = mtp_get_object(handle, input_int, filepath); + TC_PRT("ret[%d]: input id[%d]", ret, input_int); + + END(); + return ret; +} + + +int manager_test_get_thumbnail(void) +{ + int i; + int ret = 0; + int input_int = 0; + char input_str[50] = {0, }; + char filepath[100] = {0,}; + int format = MTP_FILETYPE_JPEG; + char *filename = NULL; + int list_max = 0; + 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_filename(handle, obj_list[i], &filename); + ret = mtp_objectinfo_get_format(handle, obj_list[i], &format); + TC_PRT("ret[%d]: object id[%d] - filename[%s], format[%s]", + ret, obj_list[i], filename, test_filetype_to_string(format)); + } + + if (!test_get_user_int("==> Input JPEG ID :", &input_int)) { + TC_PRT("Invalid Input !!![%d]", input_int); + END(); + return -1; + } + + /* String Input Test */ + if (test_get_user_string("Input Dest File Name(ex - thumbnail or thum)" + " - (Enter for skip) :", input_str, 50)) { + g_strstrip(input_str); + } else { + TC_PRT("Invalid Input !!![%s]", input_str); + END(); + return -1; + } + + snprintf(filepath, 100, "/opt/usr/media/Downloads/%s_%d.jpg", input_str, input_int); + + ret = mtp_get_thumbnail(handle, input_int, filepath); + TC_PRT("ret[%d]: input jpeg id[%d], input file path[%s]", ret, input_int, filepath); + + END(); + return ret; +} + +int manager_test_deinitialize(void) +{ + int ret = 0; + BEGIN(); + + ret = mtp_deinitialize(); + TC_PRT("ret[%d] : deinitialize", ret); + + END(); + return ret; +} + +int deviceinfo_test_get_manufacturername(void) +{ + int ret = 0; + char *name = NULL; + BEGIN(); + + ret = mtp_deviceinfo_get_manufacturername(handle, &name); + TC_PRT("ret[%d]: manufacturername[%s]", ret, name); + + END(); + return ret; +} + +int deviceinfo_test_get_modelname(void) +{ + int ret = 0; + char *name = NULL; + BEGIN(); + + ret = mtp_deviceinfo_get_modelname(handle, &name); + TC_PRT("ret[%d]: modelname[%s]", ret, name); + + END(); + return ret; +} + +int deviceinfo_test_get_serialnumber(void) +{ + int ret = 0; + char *name = NULL; + BEGIN(); + + ret = mtp_deviceinfo_get_serialnumber(handle, &name); + TC_PRT("ret[%d]: serialnumber[%s]", ret, name); + + END(); + return ret; +} + +int deviceinfo_test_get_deviceversion(void) +{ + int ret = 0; + char *name = NULL; + BEGIN(); + + ret = mtp_deviceinfo_get_deviceversion(handle, &name); + TC_PRT("ret[%d]: deviceversion[%s]", ret, name); + + END(); + return ret; +} + + +int storageinfo_test_get_description(void) +{ + int ret = 0; + char *name = NULL; + BEGIN(); + + ret = mtp_storageinfo_get_description(handle, strg_handle, &name); + TC_PRT("ret[%d]: description[%s]", ret, name); + + END(); + return ret; +} + +int storageinfo_test_get_freespace(void) +{ + int ret = 0; + guint64 value = 0; + BEGIN(); + + ret = mtp_storageinfo_get_freespace(handle, strg_handle, &value); + TC_PRT("ret[%d]: freespace[%d]", ret, (int)value); + + END(); + return ret; +} + +int storageinfo_test_get_maxcapacity(void) +{ + int ret = 0; + guint64 value = 0; + BEGIN(); + + ret = mtp_storageinfo_get_maxcapacity(handle, strg_handle, &value); + TC_PRT("ret[%d]: maxcapacity[%d]", ret, (int)value); + + END(); + return ret; +} + +int storageinfo_test_get_storagetype(void) +{ + int ret = 0; + int value = 0; + BEGIN(); + + ret = mtp_storageinfo_get_storagetype(handle, strg_handle, &value); + TC_PRT("ret[%d]: storagetype[%d]", ret, value); + + END(); + return ret; +} + +int storageinfo_test_get_volumeidentifier(void) +{ + int ret = 0; + char *name = NULL; + BEGIN(); + + ret = mtp_storageinfo_get_volumeidentifier(handle, strg_handle, &name); + TC_PRT("ret[%d]: volumeidentifier[%s]", ret, name); + + END(); + return ret; +} + +int objectinfo_test_get_association_desc(void) +{ + int i; + int ret = 0; + int value = 0; + int list_max = 0; + BEGIN(); + + list_max = (obj_count < TEST_LIST_MAX) ? obj_count : TEST_LIST_MAX; + + for (i = 0; i < list_max; i++) { + ret = mtp_objectinfo_get_association_desc(handle, obj_list[i], &value); + TC_PRT("ret[%d]: object id[%d] association_desc[%d]", ret, obj_list[i], value); + } + + END(); + return ret; +} + +int objectinfo_test_get_association_type(void) +{ + int i; + int ret = 0; + int value = 0; + int list_max = 0; + BEGIN(); + + list_max = (obj_count < TEST_LIST_MAX) ? obj_count : TEST_LIST_MAX; + + for (i = 0; i < list_max; i++) { + ret = mtp_objectinfo_get_association_type(handle, obj_list[i], &value); + TC_PRT("ret[%d]: object id[%d] association_type[%d]", ret, obj_list[i], value); + } + + END(); + return ret; +} + +int objectinfo_test_get_size(void) +{ + int i; + int ret = 0; + int value = 0; + int list_max = 0; + BEGIN(); + + list_max = (obj_count < TEST_LIST_MAX) ? obj_count : TEST_LIST_MAX; + + for (i = 0; i < list_max; i++) { + ret = mtp_objectinfo_get_size(handle, obj_list[i], &value); + TC_PRT("ret[%d]: object id[%d] size[%d]", ret, obj_list[i], value); + } + + END(); + return ret; +} + +int objectinfo_test_get_parent_object_handle(void) +{ + int i; + int ret = 0; + int value = 0; + int list_max = 0; + BEGIN(); + + list_max = (obj_count < TEST_LIST_MAX) ? obj_count : TEST_LIST_MAX; + + for (i = 0; i < list_max; i++) { + ret = mtp_objectinfo_get_parent_object_handle(handle, obj_list[i], &value); + TC_PRT("ret[%d]: object id[%d] parent_object_handle[%d]", ret, obj_list[i], value); + } + + END(); + return ret; +} + +int objectinfo_test_get_storage_id(void) +{ + int i; + int ret = 0; + int value = 0; + int list_max = 0; + BEGIN(); + + list_max = (obj_count < TEST_LIST_MAX) ? obj_count : TEST_LIST_MAX; + + for (i = 0; i < list_max; i++) { + ret = mtp_objectinfo_get_storage_id(handle, obj_list[i], &value); + TC_PRT("ret[%d]: object id[%d] storage_id[%d]", ret, obj_list[i], value); + } + + END(); + return ret; +} + +int objectinfo_test_get_data_created(void) +{ + int i; + int ret = 0; + int value = 0; + int list_max = 0; + BEGIN(); + + list_max = (obj_count < TEST_LIST_MAX) ? obj_count : TEST_LIST_MAX; + + for (i = 0; i < list_max; i++) { + ret = mtp_objectinfo_get_data_created(handle, obj_list[i], &value); + TC_PRT("ret[%d]: object id[%d] data_created[%d]", ret, obj_list[i], value); + } + + END(); + return ret; +} + +int objectinfo_test_get_data_modified(void) +{ + int i; + int ret = 0; + int value = 0; + int list_max = 0; + BEGIN(); + + list_max = (obj_count < TEST_LIST_MAX) ? obj_count : TEST_LIST_MAX; + + for (i = 0; i < list_max; i++) { + ret = mtp_objectinfo_get_data_modified(handle, obj_list[i], &value); + TC_PRT("ret[%d]: object id[%d] data_modified[%d]", ret, obj_list[i], value); + } + + END(); + return ret; +} + +int objectinfo_test_get_format(void) +{ + int i; + int ret = 0; + int value = 0; + int list_max = 0; + BEGIN(); + + list_max = (obj_count < TEST_LIST_MAX) ? obj_count : TEST_LIST_MAX; + + for (i = 0; i < list_max; i++) { + ret = mtp_objectinfo_get_format(handle, obj_list[i], &value); + TC_PRT("ret[%d]: object id[%d] format[%d]", ret, obj_list[i], value); + } + + END(); + return ret; +} + +int objectinfo_test_get_image_pix_depth(void) +{ + int i; + int ret = 0; + int value = 0; + int list_max = 0; + BEGIN(); + + list_max = (obj_count < TEST_LIST_MAX) ? obj_count : TEST_LIST_MAX; + + for (i = 0; i < list_max; i++) { + ret = mtp_objectinfo_get_image_pix_depth(handle, obj_list[i], &value); + TC_PRT("ret[%d]: object id[%d] image_pix_depth[%d]", ret, obj_list[i], value); + } + + END(); + return ret; +} + +int objectinfo_test_get_image_pix_width(void) +{ + int i; + int ret = 0; + int value = 0; + int list_max = 0; + BEGIN(); + + list_max = (obj_count < TEST_LIST_MAX) ? obj_count : TEST_LIST_MAX; + + for (i = 0; i < list_max; i++) { + ret = mtp_objectinfo_get_image_pix_width(handle, obj_list[i], &value); + TC_PRT("ret[%d]: object id[%d] image_pix_width[%d]", ret, obj_list[i], value); + } + + END(); + return ret; +} + +int objectinfo_test_get_image_pix_height(void) +{ + int i; + int ret = 0; + int value = 0; + int list_max = 0; + BEGIN(); + + list_max = (obj_count < TEST_LIST_MAX) ? obj_count : TEST_LIST_MAX; + + for (i = 0; i < list_max; i++) { + ret = mtp_objectinfo_get_image_pix_height(handle, obj_list[i], &value); + TC_PRT("ret[%d]: object id[%d] image_pix_height[%d]", ret, obj_list[i], value); + } + + END(); + return ret; +} + +int objectinfo_test_get_thumbnail_size(void) +{ + int i; + int ret = 0; + int value = 0; + int list_max = 0; + BEGIN(); + + list_max = (obj_count < TEST_LIST_MAX) ? obj_count : TEST_LIST_MAX; + + for (i = 0; i < list_max; i++) { + ret = mtp_objectinfo_get_thumbnail_size(handle, obj_list[i], &value); + TC_PRT("ret[%d]: object id[%d] thumbnail_size[%d]", ret, obj_list[i], value); + } + + END(); + return ret; +} + +int objectinfo_test_get_thumbnail_format(void) +{ + int i; + int ret = 0; + int value = 0; + int list_max = 0; + BEGIN(); + + list_max = (obj_count < TEST_LIST_MAX) ? obj_count : TEST_LIST_MAX; + + for (i = 0; i < list_max; i++) { + ret = mtp_objectinfo_get_thumbnail_format(handle, obj_list[i], &value); + TC_PRT("ret[%d]: object id[%d] thumbnail_format[%d]", ret, obj_list[i], value); + } + + END(); + return ret; +} + +int objectinfo_test_get_thumbnail_pix_height(void) +{ + int i; + int ret = 0; + int value = 0; + int list_max = 0; + BEGIN(); + + list_max = (obj_count < TEST_LIST_MAX) ? obj_count : TEST_LIST_MAX; + + for (i = 0; i < list_max; i++) { + ret = mtp_objectinfo_get_thumbnail_pix_height(handle, obj_list[i], &value); + TC_PRT("ret[%d]: object id[%d] thumbnail_pix_height[%d]", ret, obj_list[i], value); + } + + END(); + return ret; +} + +int objectinfo_test_get_thumbnail_pix_width(void) +{ + int i; + int ret = 0; + int value = 0; + int list_max = 0; + BEGIN(); + + list_max = (obj_count < TEST_LIST_MAX) ? obj_count : TEST_LIST_MAX; + + for (i = 0; i < list_max; i++) { + ret = mtp_objectinfo_get_thumbnail_pix_width(handle, obj_list[i], &value); + TC_PRT("ret[%d]: object id[%d] thumbnail_pix_width[%d]", ret, obj_list[i], value); + } + + END(); + return ret; +} + +int objectinfo_test_get_filename(void) +{ + int i; + int ret = 0; + char *value = NULL; + int list_max = 0; + BEGIN(); + + list_max = (obj_count < TEST_LIST_MAX) ? obj_count : TEST_LIST_MAX; + + for (i = 0; i < list_max; i++) { + ret = mtp_objectinfo_get_filename(handle, obj_list[i], &value); + TC_PRT("ret[%d]: object id[%d] filename[%s]", ret, obj_list[i], value); + } + + END(); + return ret; +} + +int objectinfo_test_get_keywords(void) +{ + int i; + int ret = 0; + char *value = NULL; + int list_max = 0; + BEGIN(); + + list_max = (obj_count < TEST_LIST_MAX) ? obj_count : TEST_LIST_MAX; + + for (i = 0; i < list_max; i++) { + ret = mtp_objectinfo_get_keywords(handle, obj_list[i], &value); + TC_PRT("ret[%d]: object id[%d] keywords[%s]", ret, obj_list[i], value); + } + + END(); + return ret; +} + +int application_test_get_image_from_DCIM(void) +{ + int ret = 0; + int i; + int format = MTP_FILETYPE_FOLDER; + int *object_list; + int object_count = 0; + int *object_list2; + int object_count2 = 0; + char filepath[100] = {0,}; + char *filename = NULL; + int selected_id = 0; + int input_object_id = 0; + int input_object_id2 = 0; + BEGIN(); + + while (true) { + TC_PRT("storage_handle : %d", strg_handle); + + if (!test_get_user_int("==> 1. Select Object type (FOLDER:0, JPEG:14, BMP:17)" + " - (Enter for skip) :", &input_object_id2)) { + TC_PRT("Invalid Input !!! [%d]", input_object_id2); + break; + } + + ret = mtp_get_object_handles(handle, (strg_handle > 0 ? strg_handle : 0), input_object_id2, selected_id, &object_list, &object_count); + + TC_PRT("Total object_num [%d]", object_count); + + for (i = 0; i < object_count; i++) { + TC_PRT("object handle %d", object_list[i]); + + ret = mtp_objectinfo_get_filename(handle, object_list[i], &filename); + ret = mtp_objectinfo_get_format(handle, object_list[i], &format); + + TC_PRT("ret : %d", ret); + TC_PRT("Folder object id %d - filename[%s], format[%s]\n", object_list[i], filename, test_filetype_to_string(format)); + } + + if (!test_get_user_int("==> 1. Input Folder Object ID (Enter for exit):", &input_object_id)) { + TC_PRT("input_object_id : %d", input_object_id); + g_free(object_list); + break; + } + + selected_id = input_object_id; + + ret = mtp_objectinfo_get_filename(handle, selected_id, &filename); + ret = mtp_objectinfo_get_format(handle, selected_id, &format); + + TC_PRT("ret : %d", ret); + TC_PRT("selected id[%d] - filename[%s], format[%s]\n", selected_id, filename, test_filetype_to_string(format)); + + g_free(filename); + } + + ret = mtp_get_object_handles(handle, (strg_handle > 0 ? strg_handle : 0), MTP_FILETYPE_JPEG, selected_id, &object_list2, &object_count2); + + TC_PRT("Total object_num [%d]", object_count2); + + for (i = 0; i < object_count2; i++) { + TC_PRT("object handle %d", object_list2[i]); + + ret = mtp_objectinfo_get_filename(handle, object_list2[i], &filename); + ret = mtp_objectinfo_get_format(handle, object_list2[i], &format); + + TC_PRT("ret : %d", ret); + TC_PRT("JPEG id[%d] - filename[%s], format[%s]\n", object_list2[i], filename, test_filetype_to_string(format)); + } + + while (true) { + if (!test_get_user_int("==> 2. Input JPEG Object ID (Enter for exit):", &input_object_id2)) { + TC_PRT("input_object_id2 : %d", input_object_id2); + break; + } + + ret = mtp_objectinfo_get_filename(handle, input_object_id2, &filename); + ret = mtp_objectinfo_get_format(handle, input_object_id2, &format); + + TC_PRT("ret : %d", ret); + TC_PRT("selected id[%d] - filename[%s], format[%s]\n", input_object_id2, filename, test_filetype_to_string(format)); + + g_free(filename); + + if (format == MTP_FILETYPE_JPEG) { + snprintf(filepath, 100, "/home/JpegObject_%d.jpg", input_object_id2); + + ret = mtp_get_object(handle, input_object_id2, filepath); + TC_PRT("mtp_get_object ret : %d", ret); + } + } + + END(); + return ret; +} + +int application_test_get_object_handle_using_all(void) +{ + int i; + int ret = 0; + int *file_list; + int file_count; + + BEGIN(); + + ret = mtp_get_object_handles(handle, strg_handle, MTP_FILETYPE_ALL, 0, &file_list, &file_count); + + TC_PRT("ret[%d]: total folder_count[%d]", ret, file_count); + for (i = 0; i < file_count; i++) + TC_PRT("object handle [%d] : %d", file_count, file_list[i]); + + END(); + return ret; +} + +int application_test_get_object_handle_using_all_image(void) +{ + int i; + int *file_list; + int file_count; + int ret = 0; + BEGIN(); + + ret = mtp_get_object_handles(handle, strg_handle, MTP_FILETYPE_ALL_IMAGE, 0, &file_list, &file_count); + + TC_PRT("ret[%d]: total folder_count[%d]", ret, file_count); + for (i = 0; i < file_count; i++) + TC_PRT("object handle [%d] : %d", file_count, file_list[i]); + + END(); + return ret; +} + +void __test_mtp_event_cb(mtp_event_e state, int arg, void *user_data) +{ + TC_PRT("state [%d] : %d", state, arg); +} + +int application_test_event_callback(void) +{ + int ret; + + BEGIN(); + + ret = mtp_set_mtp_event_cb(__test_mtp_event_cb, NULL); + + END(); + + return ret; +} + +int application_test_scenario(void) +{ + int i; + int ret; + int device_handle = 0; + int *storage_list; + int storage_count = 0; + int *image_list; + int image_count = 0; + mtp_device_list* dev_list; + struct timeval start1, start2, start3, start4; + struct timeval end1, end2, end3, end4; + + BEGIN(); + + /* init phase */ + gettimeofday(&start1, NULL); + TC_PRT("init phase start, %ld.%ld", start1.tv_sec, start1.tv_usec); + + ret = mtp_initialize(); + + ret = mtp_get_device_list(&dev_list); + + if (dev_list->device_num == 0) { + TC_PRT("device is not exist!!!"); + END(); + return -1; + } + + ret = mtp_get_device_handle(dev_list->devices[0].bus_location, &device_handle); + ret = mtp_get_storage_ids(device_handle, &storage_list, &storage_count); + + gettimeofday(&end1, NULL); + TC_PRT("init phase end time, %ld.%ld", end1.tv_sec, end1.tv_usec); + + /* scan phase */ + gettimeofday(&start2, NULL); + TC_PRT("scan phase start, %ld.%ld", start2.tv_sec, start2.tv_usec); + + ret = mtp_get_object_handles(device_handle, storage_list[0], MTP_FILETYPE_ALL_IMAGE, + 0, &image_list, &image_count); + + gettimeofday(&end2, NULL); + TC_PRT("scan phase end time, %ld.%ld", end2.tv_sec, end2.tv_usec); + + /* get objectinfo phase */ + gettimeofday(&start3, NULL); + TC_PRT("get objectinfo phase start, %ld.%ld", start3.tv_sec, start3.tv_usec); + + for (i = 0; i < image_count; i++) { + mtp_object_info *object_info; + mtp_objectinfo_get_object_info(device_handle, image_list[i], &object_info); + TC_PRT("filename : %s", object_info->Filename); + g_free(object_info); + } + + gettimeofday(&end3, NULL); + TC_PRT("get objectinfo phase end, %ld.%ld", end3.tv_sec, end3.tv_usec); + + /* get thumbnail phase */ + gettimeofday(&start4, NULL); + TC_PRT("get thumbnail phase start, %ld.%ld", start4.tv_sec, start4.tv_usec); + + for (i = 0; i < image_count; i++) { + char path[256] = {0,}; + + snprintf(path, 256, "/tmp/thumbnail%d.jpg", i); + mtp_get_thumbnail(device_handle, image_list[i], path); + } + gettimeofday(&end4, NULL); + TC_PRT("get thumbnail phase end, %ld.%ld", end4.tv_sec, end4.tv_usec); + + ret = mtp_deinitialize(); + + END(); + + return ret; +} + +tc_table_t tc_table[] = { + /* manager api */ + {"mtp_initialize", 1, manager_test_initialize}, + {"mtp_get_device_list", 2, manager_test_get_device_list}, + {"mtp_get_device_handle", 3, manager_test_get_device_handle}, + {"mtp_get_storage_ids", 4, manager_test_get_storage_ids}, + {"mtp_get_object_handles", 5, manager_test_get_object_handles}, + {"mtp_delete_object", 6, manager_test_delete_object}, + {"mtp_get_object", 7, manager_test_get_object}, + {"mtp_get_thumbnail", 8, manager_test_get_thumbnail}, + {"mtp_deinitialize", 9, manager_test_deinitialize}, + + /* device api */ + {"mtp_deviceinfo_manufacturer_name", 10, deviceinfo_test_get_manufacturername}, + {"mtp_deviceinfo_model_name", 11, deviceinfo_test_get_modelname}, + {"mtp_deviceinfo_serial_number", 12, deviceinfo_test_get_serialnumber}, + {"mtp_deviceinfo_device_version", 13, deviceinfo_test_get_deviceversion}, + + /* storage api */ + {"mtp_storageinfo_get_description", 14, storageinfo_test_get_description}, + {"mtp_storageinfo_get_freespace", 15, storageinfo_test_get_freespace}, + {"mtp_storageinfo_get_maxcapacity", 16, storageinfo_test_get_maxcapacity}, + {"mtp_storageinfo_get_storagetype", 17, storageinfo_test_get_storagetype}, + {"mtp_storageinfo_get_volumeidentifier", 18, storageinfo_test_get_volumeidentifier}, + + /* object api */ + {"mtp_objectinfo_get_association_desc", 19, objectinfo_test_get_association_desc}, + {"mtp_objectinfo_get_association_type", 20, objectinfo_test_get_association_type}, + {"mtp_objectinfo_get_size", 21, objectinfo_test_get_size}, + {"mtp_objectinfo_get_data_created", 22, objectinfo_test_get_data_created}, + {"mtp_objectinfo_get_data_modified", 23, objectinfo_test_get_data_modified}, + {"mtp_objectinfo_get_format", 24, objectinfo_test_get_format}, + {"mtp_objectinfo_get_image_pix_depth", 25, objectinfo_test_get_image_pix_depth}, + {"mtp_objectinfo_get_image_pix_width", 26, objectinfo_test_get_image_pix_width}, + {"mtp_objectinfo_get_image_pix_height", 27, objectinfo_test_get_image_pix_height}, + {"mtp_objectinfo_get_thumbnail_size", 28, objectinfo_test_get_thumbnail_size}, + {"mtp_objectinfo_get_thumbnail_format", 29, objectinfo_test_get_thumbnail_format}, + {"mtp_objectinfo_get_thumbnail_pix_height", 30, objectinfo_test_get_thumbnail_pix_height}, + {"mtp_objectinfo_get_thumbnail_pix_width", 31, objectinfo_test_get_thumbnail_pix_width}, + {"mtp_objectinfo_get_filename", 32, objectinfo_test_get_filename}, + {"mtp_objectinfo_get_keywords", 33, objectinfo_test_get_keywords}, + + /* application test */ + {"get Jpeg image from /DCIM folder", 34, application_test_get_image_from_DCIM}, + {"get object handle using ALL format", 35, application_test_get_object_handle_using_all}, + {"get object handle using ALL Image format", 36, application_test_get_object_handle_using_all_image}, + {"test callback function", 37, application_test_event_callback}, + {"application_test_scenario", 38, application_test_scenario}, + {"get object and get thumbnail test", TEST_CASE_MAX, NULL}, + + /*-----------*/ + {"Finish", 0x0000, NULL}, + {NULL, 0x00ff, NULL}, +}; + +static void tc_usage_print(void) +{ + int i = 0; + + while (tc_table[i].tc_name) { + if (tc_table[i].tc_code != 0x00ff) + printf("Key [%2d] : usage %s\n", tc_table[i].tc_code, tc_table[i].tc_name); + else + printf("Key [%2d] : usage %s\n\n", 0x00ff, tc_table[i].tc_name); + + i++; + } +} + +static int test_input_callback(void *data) +{ + long test_id = (long)data; + int ret = MTP_ERROR_NONE; + + if ((test_id >= 1) && (test_id <= TEST_CASE_MAX)) { + TC_PRT("test_input_callback test_id : %ld", test_id); + + if (tc_table[test_id-1].tc_func != NULL) { + ret = tc_table[test_id-1].tc_func(); + + if (ret != MTP_ERROR_NONE) + TC_PRT(">>>>> Test Error Returned !!! : %d", ret); + } + } + + return 0; +} + +static int test_mtp_terminate(void) +{ + int ret = 0; + + TC_PRT("Finished"); + + manager_test_deinitialize(); + g_main_loop_quit(main_loop); + + return ret; +} + +static gboolean key_event_cb(GIOChannel *chan, GIOCondition cond, gpointer data) +{ + char buf[BUFFER_LEN] = {0,}; + long test_id; + int rv = 0; + + memset(buf, 0, sizeof(buf)); + printf("Event received from stdin\n"); + + rv = read(0, buf, 100); + + if (rv < 0 || buf[0] == '0') { + test_mtp_terminate(); + exit(1); + } + + if (*buf == '\n' || *buf == '\r') + tc_usage_print(); + + test_id = atoi(buf); + + test_input_callback((void *)test_id); + + return TRUE; +} + + +int main(int argc, char ** argv) +{ + GIOChannel *key_io; + + main_loop = g_main_loop_new(NULL, FALSE); + key_io = g_io_channel_unix_new(0); + + printf("Test Thread created...\n"); + + g_io_add_watch(key_io, (G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL), key_event_cb, NULL); + g_main_loop_run(main_loop); + + g_io_channel_unref(key_io); + g_main_loop_unref(main_loop); + + return 0; +} -- 2.7.4 From 006f59071815c5e67647ea899c441599f996a603 Mon Sep 17 00:00:00 2001 From: Hyihong Chae Date: Mon, 16 Nov 2015 22:08:40 +0900 Subject: [PATCH 03/11] Sync with Tizen 2.4 Change-Id: I33a88302b9ed5cb86ff7c91808fc57889b98375d Signed-off-by: HyiHong Chae --- include/mtp.h | 3 ++- packaging/capi-network-mtp.spec | 6 +++--- test/mtp_unit_test.c | 7 +++++++ 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/include/mtp.h b/include/mtp.h index 1297417..bae4233 100755 --- a/include/mtp.h +++ b/include/mtp.h @@ -141,7 +141,8 @@ typedef enum { MTP_EVENT_OBJECT_ADDED, /**< Object is added */ MTP_EVENT_OBJECT_REMOVED, /**< Object is removed */ MTP_EVENT_DEVICE_ADDED, /**< Device is added */ - MTP_EVENT_DEVICE_REMOVED /**< Device is removed */ + MTP_EVENT_DEVICE_REMOVED, /**< Device is removed */ + MTP_EVENT_DAEMON_TERMINATED /**< Daemon is terminated */ } mtp_event_e; /** diff --git a/packaging/capi-network-mtp.spec b/packaging/capi-network-mtp.spec index 139898b..3355fe0 100755 --- a/packaging/capi-network-mtp.spec +++ b/packaging/capi-network-mtp.spec @@ -1,14 +1,14 @@ Name: capi-network-mtp Summary: A MTP library in Native API -Version: 1.2.1 +Version: 1.2.2 Release: 1 Group: Network & Connectivity/Other License: Apache-2.0 Source0: %{name}-%{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 BuildRequires: cmake diff --git a/test/mtp_unit_test.c b/test/mtp_unit_test.c index 5aa8377..8667883 100755 --- a/test/mtp_unit_test.c +++ b/test/mtp_unit_test.c @@ -1013,7 +1013,14 @@ int application_test_get_object_handle_using_all_image(void) void __test_mtp_event_cb(mtp_event_e state, int arg, void *user_data) { + int ret = 0; + TC_PRT("state [%d] : %d", state, arg); + + if (state == MTP_EVENT_DAEMON_TERMINATED) { + ret = mtp_deinitialize(); + TC_PRT("ret[%d] : Terminated daemon", ret); + } } int application_test_event_callback(void) -- 2.7.4 From c4fa94c7d0425efe3b43e69443d78b434316da9d Mon Sep 17 00:00:00 2001 From: Hyihong Chae Date: Wed, 18 Nov 2015 13:45:35 +0900 Subject: [PATCH 04/11] modify to support mobile profile. Change-Id: I4b41e5bbad65e83b84619a2315f11cb53dd5e7c8 Signed-off-by: HyiHong Chae --- packaging/capi-network-mtp.spec | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/packaging/capi-network-mtp.spec b/packaging/capi-network-mtp.spec index 3355fe0..87cb0b2 100755 --- a/packaging/capi-network-mtp.spec +++ b/packaging/capi-network-mtp.spec @@ -6,10 +6,7 @@ Group: Network & Connectivity/Other License: Apache-2.0 Source0: %{name}-%{version}.tar.gz -# This package would be built only TV -%if "%{?profile}" != "tv" -ExcludeArch: %arm aarch64 %ix86 x86_64 -%endif +ExcludeArch: %ix86 x86_64 BuildRequires: cmake BuildRequires: pkgconfig(dlog) -- 2.7.4 From c7c381b986f431a645ed940435b204e4677e7b61 Mon Sep 17 00:00:00 2001 From: Hyihong Chae Date: Fri, 20 Nov 2015 18:11:23 +0900 Subject: [PATCH 05/11] change parameter type of some APIs Change-Id: Ifbe370712512bac25712d1b650eea981821fe786 Signed-off-by: HyiHong Chae --- include/mtp.h | 4 ++-- packaging/capi-network-mtp.spec | 2 +- src/mtp.c | 12 ++++++------ test/mtp_unit_test.c | 10 +++++----- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/include/mtp.h b/include/mtp.h index bae4233..1f6f3ac 100755 --- a/include/mtp.h +++ b/include/mtp.h @@ -419,7 +419,7 @@ MTP_API int mtp_storageinfo_get_description(int device_handle, int storage_id, c * * @see mtp_get_storage_ids() */ -MTP_API int mtp_storageinfo_get_freespace(int device_handle, int storage_id, guint64 *freespace); +MTP_API int mtp_storageinfo_get_freespace(int device_handle, int storage_id, unsigned long long *freespace); /** * @brief Get the max capacity of the storage information. @@ -435,7 +435,7 @@ MTP_API int mtp_storageinfo_get_freespace(int device_handle, int storage_id, gui * * @see mtp_get_storage_ids() */ -MTP_API int mtp_storageinfo_get_maxcapacity(int device_handle, int storage_id, guint64 *maxcapacity); +MTP_API int mtp_storageinfo_get_maxcapacity(int device_handle, int storage_id, unsigned long long *maxcapacity); /** * @brief Get the storage type of the storage information. diff --git a/packaging/capi-network-mtp.spec b/packaging/capi-network-mtp.spec index 87cb0b2..8b94159 100755 --- a/packaging/capi-network-mtp.spec +++ b/packaging/capi-network-mtp.spec @@ -1,6 +1,6 @@ Name: capi-network-mtp Summary: A MTP library in Native API -Version: 1.2.2 +Version: 1.2.3 Release: 1 Group: Network & Connectivity/Other License: Apache-2.0 diff --git a/src/mtp.c b/src/mtp.c index d1096a1..3ce3e87 100755 --- a/src/mtp.c +++ b/src/mtp.c @@ -493,7 +493,7 @@ int mtp_storageinfo_get_description(int device_handle, int storage_id, char **de return ret; } -int mtp_storageinfo_get_freespace(int device_handle, int storage_id, guint64 *freespace) +int mtp_storageinfo_get_freespace(int device_handle, int storage_id, unsigned long long *freespace) { int ret = MTP_ERROR_NONE; @@ -509,16 +509,16 @@ int mtp_storageinfo_get_freespace(int device_handle, int storage_id, guint64 *fr /* precondition check end */ - ret = mtp_gdbus_storageinfo_get_freespace(device_handle, storage_id, freespace); + ret = mtp_gdbus_storageinfo_get_freespace(device_handle, storage_id, (guint64 *)freespace); - TC_PRT("freespace %d", (int)*freespace); + TC_PRT("freespace %llu", *freespace); _END(); return ret; } -int mtp_storageinfo_get_maxcapacity(int device_handle, int storage_id, guint64 *maxcapacity) +int mtp_storageinfo_get_maxcapacity(int device_handle, int storage_id, unsigned long long *maxcapacity) { int ret = MTP_ERROR_NONE; @@ -534,9 +534,9 @@ int mtp_storageinfo_get_maxcapacity(int device_handle, int storage_id, guint64 * /* precondition check end */ - ret = mtp_gdbus_storageinfo_get_maxcapacity(device_handle, storage_id, maxcapacity); + ret = mtp_gdbus_storageinfo_get_maxcapacity(device_handle, storage_id, (guint64 *)maxcapacity); - TC_PRT("maxcapacity %d", (int)*maxcapacity); + TC_PRT("maxcapacity %llu", *maxcapacity); _END(); diff --git a/test/mtp_unit_test.c b/test/mtp_unit_test.c index 8667883..6488e98 100755 --- a/test/mtp_unit_test.c +++ b/test/mtp_unit_test.c @@ -506,11 +506,11 @@ int storageinfo_test_get_description(void) int storageinfo_test_get_freespace(void) { int ret = 0; - guint64 value = 0; + unsigned long long value = 0; BEGIN(); ret = mtp_storageinfo_get_freespace(handle, strg_handle, &value); - TC_PRT("ret[%d]: freespace[%d]", ret, (int)value); + TC_PRT("ret[%d]: freespace[%llu]", ret, value); END(); return ret; @@ -519,11 +519,11 @@ int storageinfo_test_get_freespace(void) int storageinfo_test_get_maxcapacity(void) { int ret = 0; - guint64 value = 0; + unsigned long long value = 0; BEGIN(); ret = mtp_storageinfo_get_maxcapacity(handle, strg_handle, &value); - TC_PRT("ret[%d]: maxcapacity[%d]", ret, (int)value); + TC_PRT("ret[%d]: maxcapacity[%llu]", ret, value); END(); return ret; @@ -1118,7 +1118,7 @@ int application_test_scenario(void) tc_table_t tc_table[] = { /* manager api */ {"mtp_initialize", 1, manager_test_initialize}, - {"mtp_get_device_list", 2, manager_test_get_device_list}, + {"mtp_get_device_list", 2, manager_test_get_device_list}, {"mtp_get_device_handle", 3, manager_test_get_device_handle}, {"mtp_get_storage_ids", 4, manager_test_get_storage_ids}, {"mtp_get_object_handles", 5, manager_test_get_object_handles}, -- 2.7.4 From 5497abd9b020703e30c7e7462497028769d9ab16 Mon Sep 17 00:00:00 2001 From: Hyihong Chae Date: Fri, 18 Dec 2015 18:25:33 +0900 Subject: [PATCH 06/11] remove the unnecessary ref_count value. Change-Id: I7b4d72659979b727dfe148cd1925156e68068113 Signed-off-by: HyiHong Chae --- packaging/capi-network-mtp.spec | 2 +- src/mtp_db.c | 16 ++++------------ 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/packaging/capi-network-mtp.spec b/packaging/capi-network-mtp.spec index 8b94159..e03c530 100755 --- a/packaging/capi-network-mtp.spec +++ b/packaging/capi-network-mtp.spec @@ -1,6 +1,6 @@ Name: capi-network-mtp Summary: A MTP library in Native API -Version: 1.2.3 +Version: 1.2.4 Release: 1 Group: Network & Connectivity/Other License: Apache-2.0 diff --git a/src/mtp_db.c b/src/mtp_db.c index 84e518d..fe4b685 100755 --- a/src/mtp_db.c +++ b/src/mtp_db.c @@ -28,7 +28,6 @@ static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; static sqlite3 *db; -int ref_count; mtp_error_e mtp_db_init() { @@ -37,15 +36,11 @@ mtp_error_e mtp_db_init() MTP_DB_LOCK; - if (ref_count > 0) { - ref_count++; - } else if (db == NULL) { + if (db == NULL) { sql_ret = sqlite3_open_v2(MTP_DB_FILE, &db, - SQLITE_OPEN_NOMUTEX | SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL); + SQLITE_OPEN_FULLMUTEX | SQLITE_OPEN_READWRITE, NULL); - if (sql_ret == SQLITE_OK) - ref_count++; - else + if (sql_ret != SQLITE_OK) ret = MTP_ERROR_DB; } @@ -125,10 +120,7 @@ mtp_error_e mtp_db_deinit() MTP_DB_LOCK; - if (ref_count > 0) - ref_count--; - - if (db != NULL && ref_count == 0) { + if (db != NULL) { sql_ret = sqlite3_close(db); if (sql_ret != SQLITE_OK) -- 2.7.4 From 61af2a21e477ed5fa99d49bb4601cbf12a3d2f22 Mon Sep 17 00:00:00 2001 From: Jihoon Jung Date: Wed, 23 Dec 2015 15:29:54 +0900 Subject: [PATCH 07/11] Apply ACR comment in native mtp api Signed-off-by: Ji-hoon Jung Change-Id: I4001f01051ef2b9c450be787fd4e3b97f7fc95f6 --- doc/mtp_doc.h | 168 +++++++ include/mtp.h | 966 ++++++++++++++++++++++++++++------------ include/mtp_db.h | 2 +- include/mtp_gdbus.h | 1 + include/mtp_gdbus_manager.h | 20 +- include/mtp_gdbus_objectinfo.h | 4 +- include/mtp_gdbus_storageinfo.h | 20 +- include/mtp_internal.h | 4 +- include/mtp_private.h | 65 +++ packaging/capi-network-mtp.spec | 2 +- src/mtp.c | 389 +++++++++------- src/mtp_db.c | 6 +- src/mtp_gdbus_deviceinfo.c | 32 +- src/mtp_gdbus_manager.c | 95 ++-- src/mtp_gdbus_objectinfo.c | 16 +- src/mtp_gdbus_storageinfo.c | 60 +-- src/mtp_gdbuslib.xml | 59 +-- test/mtp_unit_test.c | 430 ++++++++---------- 18 files changed, 1491 insertions(+), 848 deletions(-) create mode 100755 doc/mtp_doc.h create mode 100755 include/mtp_private.h diff --git a/doc/mtp_doc.h b/doc/mtp_doc.h new file mode 100755 index 0000000..a041d94 --- /dev/null +++ b/doc/mtp_doc.h @@ -0,0 +1,168 @@ +/* + * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __TIZEN_NETWORK_MTP_DOC_H__ +#define __TIZEN_NETWORK_MTP_DOC_H__ + +/** + * @defgroup CAPI_NETWORK_MTP_MODULE MTP + * @brief The MTP API provides functions for support PTP(Picture Transfer Protocol) subset of MTP(Media Transfer Protocol). + * @ingroup CAPI_NETWORK_FRAMEWORK + * + * @section CAPI_NETWORK_MTP_MODULE_HEADER Required Header + * \#include + * @section CAPI_NETWORK_MTP_MODULE_OVERVIEW Overview + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
API Description
@ref CAPI_NETWORK_MTP_MANAGER_MODULE Provide functions to establish connection to access MTP responder device, and to Get/Delete files
@ref CAPI_NETWORK_MTP_DEVICEINFO_MODULE Provide functions to gets the device information of MTP responder device
@ref CAPI_NETWORK_MTP_STORAGEINFO_MODULE Provide functions to gets the storage information of MTP responder storage
@ref CAPI_NETWORK_MTP_OBJECTINFO_MODULE Provide functions to gets the object information of certain file in MTP responder
+ **/ + +/** + * @defgroup CAPI_NETWORK_MTP_MANAGER_MODULE MTP Manager + * @brief The MTP Manager API provides functions for establish connection to access MTP responder device, and to Get/Delete files. + * @ingroup CAPI_NETWORK_MTP_MODULE + * + * @section CAPI_NETWORK_MTP_MANAGER_MODULE_HEADER Required Header + * \#include + * @section CAPI_NETWORK_MTP_MANAGER_MODULE_OVERVIEW Overview + * The MTP manager api provides following functions :\n + * - Create / destroy connection to access MTP responder device\n + * - Get Device list\n + * - Get Storage list\n + * - Get Object handles\n + * - Get thumbnail\n + * - Get Object\n + * - Delete Object\n + * + * @section CAPI_NETWORK_MTP_MANAGER_MODULE_FEATURE Related Features + * This API is related with the following features:\n + * - http://tizen.org/feature/network.mtp\n + * + * It is recommended to design feature related codes in your application for reliability.\n + * + * You can check if a device supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, thereby controlling the procedure of your application.\n + * + * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n + * + * More details on featuring your application can be found from Feature List. + * + */ + +/* + * @defgroup CAPI_NETWORK_MTP_DEVICEINFO_MODULE MTP Device Information + * @brief The MTP Device Information API provides functions for gets the device information of MTP responder device. + * @ingroup CAPI_NETWORK_MTP_MODULE + * + * @section CAPI_NETWORK_MTP_DEVICEINFO_MODULE_HEADER Required Header + * \#include + * @section CAPI_NETWORK_MTP_DEVICEINFO_MODULE_OVERVIEW Overview + * The MTP Device Information api provides following functions :\n + * - Get device manufacturer name\n + * - Get device model name\n + * - Get device serial number\n + * - Get device version\n + * + * @section CAPI_NETWORK_MTP_DEVICEINFO_MODULE_FEATURE Related Features + * This API is related with the following features:\n + * - http://tizen.org/feature/network.mtp\n + * + * It is recommended to design feature related codes in your application for reliability.\n + * + * You can check if a device supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, thereby controlling the procedure of your application.\n + * + * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n + * + * More details on featuring your application can be found from Feature List. + * + */ + + +/* + * @defgroup CAPI_NETWORK_MTP_STORAGEINFO_MODULE MTP Storage Information + * @brief The MTP Storage Information API provides functions for gets the storage information of MTP responder storage. + * @ingroup CAPI_NETWORK_MTP_MODULE + * + * @section CAPI_NETWORK_MTP_STORAGEINFO_MODULE_HEADER Required Header + * \#include + * @section CAPI_NETWORK_MTP_STORAGEINFO_MODULE_OVERVIEW Overview + * The MTP Storage Information api provides following functions :\n + * - Get storage free space\n + * - Get storage description\n + * - Get storage type\n + * - and, more storage information\n + * + * @section CAPI_NETWORK_MTP_STORAGEINFO_MODULE_FEATURE Related Features + * This API is related with the following features:\n + * - http://tizen.org/feature/network.mtp\n + * + * It is recommended to design feature related codes in your application for reliability.\n + * + * You can check if a device supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, thereby controlling the procedure of your application.\n + * + * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n + * + * More details on featuring your application can be found from Feature List. + * + */ + +/* + * @defgroup CAPI_NETWORK_MTP_OBJECTINFO_MODULE MTP Object Information + * @brief The MTP Manager API provides functions for gets the object information of certain file in MTP responder. + * @ingroup CAPI_NETWORK_MTP_MODULE + * + * @section CAPI_NETWORK_MTP_OBJECTINFO_MODULE_HEADER Required Header + * \#include + * @section CAPI_NETWORK_MTP_OBJECTINFO_MODULE_OVERVIEW Overview + * The MTP Object Information api provides following functions :\n + * - Get object format\n + * - Get object name\n + * - Get object size\n + * - and, more object information\n + * + * @section CAPI_NETWORK_MTP_OBJECTINFO_MODULE_FEATURE Related Features + * This API is related with the following features:\n + * - http://tizen.org/feature/network.mtp\n + * + * It is recommended to design feature related codes in your application for reliability.\n + * + * You can check if a device supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, thereby controlling the procedure of your application.\n + * + * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n + * + * More details on featuring your application can be found from Feature List. + * + */ + +#endif diff --git a/include/mtp.h b/include/mtp.h index 1f6f3ac..79a3b4c 100755 --- a/include/mtp.h +++ b/include/mtp.h @@ -23,60 +23,66 @@ extern "C" { #endif -#ifndef MTP_API -#define MTP_API -#endif - /** * @file mtp.h * @brief This file contains the MTP API */ -#define MTP_ERROR_CLASS TIZEN_ERROR_NETWORK_CLASS /* Need define mtp error class */ +#ifndef TIZEN_ERROR_MTP +#define TIZEN_ERROR_MTP -0x03000000 +#endif /** - * @brief Structure for mtp device + * @addtogroup CAPI_NETWORK_MTP_MANAGER_MODULE + * @{ + */ + +/** + * @brief The handle to the mtp raw device * @since_tizen 3.0 - * @ingroup CAPI_NETWORK_MTP_MANAGER_MODULE */ -typedef struct _mtp_device { - int bus_location; - char *model_name; -} mtp_device; +typedef struct mtp_raw_device *mtp_raw_device_h; /** - * @brief Structure for mtp device list + * @brief The handle to the mtp device * @since_tizen 3.0 - * @ingroup CAPI_NETWORK_MTP_MANAGER_MODULE */ -typedef struct _mtp_device_list { - mtp_device *devices; - int device_num; -} mtp_device_list; +typedef int mtp_device_h; + +/** + * @brief The handle to the mtp storage + * @since_tizen 3.0 + */ +typedef int mtp_storage_h; + +/** + * @brief The handle to the mtp object + * @since_tizen 3.0 + */ +typedef int mtp_object_h; /** * @brief Error codes reported by the MTP API. * @since_tizen 3.0 - * @ingroup CAPI_NETWORK_MTP_MANAGER_MODULE */ typedef enum { MTP_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */ - MTP_ERROR_GENERAL = MTP_ERROR_CLASS | 0x01, /**< A general error occurred */ MTP_ERROR_IO_ERROR = TIZEN_ERROR_IO_ERROR, /**< I/O error */ MTP_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */ - MTP_ERROR_NO_DEVICE = MTP_ERROR_CLASS | 0x02, /**< MTP have not any device */ - MTP_ERROR_ALLOC_FAIL = MTP_ERROR_CLASS | 0x03, /**< Memory Allocation failed */ - MTP_ERROR_PLUGIN = MTP_ERROR_CLASS | 0x04, /**< Plugin failed */ - MTP_ERROR_DB = MTP_ERROR_CLASS | 0x05, /**< Plugin failed */ + MTP_ERROR_NO_DEVICE = TIZEN_ERROR_MTP | 0x01, /**< MTP have not any device */ + MTP_ERROR_ALLOC_FAIL = TIZEN_ERROR_MTP | 0x02, /**< Memory Allocation failed */ + MTP_ERROR_PLUGIN_FAIL = TIZEN_ERROR_MTP | 0x03, /**< Plugin failed */ MTP_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */ - MTP_ERROR_NOT_INITIALIZED = MTP_ERROR_CLASS | 0x06, /**< MTP is not supported */ - MTP_ERROR_NOT_ACTIVATED = MTP_ERROR_CLASS | 0x07, /**< MTP is not activated */ + MTP_ERROR_COMM_ERROR = TIZEN_ERROR_MTP | 0x04, /**< MTP communication error */ + MTP_ERROR_CONTROLLER = TIZEN_ERROR_MTP | 0x05, /**< MTP controller error */ + MTP_ERROR_NOT_INITIALIZED = TIZEN_ERROR_MTP | 0x06, /**< MTP is not initialized */ + MTP_ERROR_NOT_ACTIVATED = TIZEN_ERROR_MTP | 0x07, /**< MTP is not activated */ MTP_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< MTP is not supported */ + MTP_ERROR_NOT_COMM_INITIALIZED = TIZEN_ERROR_MTP | 0x08 /**< MTP communication is not initialized */ } mtp_error_e; /** * @brief Enumerations for MTP file type * @since_tizen 3.0 - * @ingroup CAPI_NETWORK_MTP_MANAGER_MODULE */ typedef enum { MTP_FILETYPE_FOLDER, /**< FOLDER file type */ @@ -125,14 +131,13 @@ typedef enum { MTP_FILETYPE_PLAYLIST, /**< PLAYLIST file type */ MTP_FILETYPE_UNKNOWN, /**< Unknown file type */ - MTP_FILETYPE_ALL, /**< helper enum value for certain function */ - MTP_FILETYPE_ALL_IMAGE /**< helper enum value for certain function */ + MTP_FILETYPE_ALL, /**< Helper enum value for certain function */ + MTP_FILETYPE_ALL_IMAGE /**< Helper enum value for certain function */ } mtp_filetype_e; /** * @brief Enumerations for MTP event type * @since_tizen 3.0 - * @ingroup CAPI_NETWORK_MTP_MANAGER_MODULE */ typedef enum { MTP_EVENT_UNKNOWN, /**< Unknown event type */ @@ -142,604 +147,977 @@ typedef enum { MTP_EVENT_OBJECT_REMOVED, /**< Object is removed */ MTP_EVENT_DEVICE_ADDED, /**< Device is added */ MTP_EVENT_DEVICE_REMOVED, /**< Device is removed */ - MTP_EVENT_DAEMON_TERMINATED /**< Daemon is terminated */ + MTP_EVENT_TURNED_OFF /**< MTP is turned off */ } mtp_event_e; /** * @brief Called after mtp_set_mtp_event_cb() has completed. * @since_tizen 3.0 - * @ingroup CAPI_NETWORK_MTP_MANAGER_MODULE + * @remarks Depending on the type of event, the meaning of event parameter is different. + * - If event is device event, then event_parameter type is mtp_device_h. + * - If event is storage event, then event_parameter type is mtp_storage_h. + * - If event is object event, then event_parameter type is mtp_object_h. + * - If event is MTP_EVENT_TURNED_OFF, then event_parameter is 0. * * @param [in] event The event - * @param [in] arg The argument + * @param [in] event_parameter The event parameter * @param [in] user_data The user data passed from the callback registration function * * @see mtp_set_mtp_event_cb() * @see mtp_unset_mtp_event_cb() */ -typedef void (* mtp_event_cb)(mtp_event_e event, int arg, void *user_data); +typedef void (* mtp_event_cb)(mtp_event_e event, int event_parameter, void *user_data); /** * @brief Initializes for using MTP. * @since_tizen 3.0 - * @ingroup CAPI_NETWORK_MTP_MANAGER_MODULE - * @remarks This function must be called before proceeding any other mtp functions\n + * @remarks This function must be called before proceeding any other mtp functions. * * @return 0 on success, otherwise a negative error value. * @retval #MTP_ERROR_NONE Successful + * @retval #MTP_ERROR_NOT_SUPPORTED MTP is not supported + * @retval #MTP_ERROR_PERMISSION_DENIED Permission Denied + * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized * * @see mtp_deinitialize() */ -MTP_API int mtp_initialize(void); +int mtp_initialize(void); /** - * @brief Get device list. + * @brief Gets device list. * @since_tizen 3.0 - * @ingroup CAPI_NETWORK_MTP_MANAGER_MODULE + * @remarks The @a raw_devices should be freed using mtp_destroy_raw_devices(). + * + * @param [out] raw_devices All current connected device list + * @param [out] device_count The count of device * * @return 0 on success, otherwise a negative error value. * @retval #MTP_ERROR_NONE Successful + * @retval #MTP_ERROR_NOT_SUPPORTED MTP is not supported + * @retval #MTP_ERROR_NOT_INITIALIZED MTP is not initialized + * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated + * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized * - * @param [out] dev_list All current device list + * @see mtp_destroy_raw_devices() */ -MTP_API int mtp_get_device_list(mtp_device_list **dev_list); +int mtp_get_raw_devices(mtp_raw_device_h **raw_devices, int *device_count); /** - * @brief Get device handler from bus location + * @brief Gets bus location from raw device. * @since_tizen 3.0 - * @ingroup CAPI_NETWORK_MTP_MANAGER_MODULE + * @remarks The @a raw_device can get using mtp_get_raw_devices(). + * + * @param [in] raw_device The raw device + * @param [out] bus_location The bus location * * @return 0 on success, otherwise a negative error value. * @retval #MTP_ERROR_NONE Successful + * @retval #MTP_ERROR_NOT_SUPPORTED MTP is not supported + * @retval #MTP_ERROR_NOT_INITIALIZED MTP is not initialized + * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter * - * @param [in] bus_location The bus location - * @param [out] device_handle The device handle - * - * @see mtp_initialize() + * @see mtp_get_raw_devices() */ -MTP_API int mtp_get_device_handle(int bus_location, int* device_handle); +int mtp_get_bus_location(mtp_raw_device_h raw_device, int *bus_location); /** - * @brief Get storage ids from device + * @brief Gets device number from raw device. * @since_tizen 3.0 - * @ingroup CAPI_NETWORK_MTP_MANAGER_MODULE + * @remarks The @a raw_device can get using mtp_get_raw_devices(). + * + * @param [in] raw_device The raw device + * @param [out] device_number The device number * * @return 0 on success, otherwise a negative error value. * @retval #MTP_ERROR_NONE Successful + * @retval #MTP_ERROR_NOT_SUPPORTED MTP is not supported + * @retval #MTP_ERROR_NOT_INITIALIZED MTP is not initialized + * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter * - * @param [in] device_handle The device handle - * @param [out] storage_id Current storage id list - * @param [out] storage_num Length of storage id list - * - * @see mtp_get_device_handle() + * @see mtp_get_raw_devices() */ -MTP_API int mtp_get_storage_ids(int device_handle, int **storage_id, int* storage_num); +int mtp_get_device_number(mtp_raw_device_h raw_device, int *device_number); /** - * @brief Get object handles from device + * @brief Gets device name from raw device. * @since_tizen 3.0 - * @ingroup CAPI_NETWORK_MTP_MANAGER_MODULE + * @remarks The @a raw_device can get using mtp_get_raw_devices(). + * @remarks The @a model_name should be freed using free(). + * + * @param [in] raw_device The raw device + * @param [out] model_name The model name * * @return 0 on success, otherwise a negative error value. * @retval #MTP_ERROR_NONE Successful + * @retval #MTP_ERROR_NOT_SUPPORTED MTP is not supported + * @retval #MTP_ERROR_NOT_INITIALIZED MTP is not initialized + * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter * - * @param [in] device_handle The device handle - * @param [in] storage_id The storage id - * @param [in] format The file type what you want - * @param [in] parent_object_handle The parent object handle - * @param [out] object_handles The object handle list - * @param [out] object_num Length of object handle list - * - * @see mtp_get_device_handle() - * @see mtp_get_storage_ids() + * @see mtp_get_raw_devices() */ -MTP_API int mtp_get_object_handles(int device_handle, int storage_id, int format, - int parent_object_handle, int **object_handles, int* object_num); +int mtp_get_device_name(mtp_raw_device_h raw_device, char **model_name); /** - * @brief Delete object from device + * @brief Destroys the raw devices handler. * @since_tizen 3.0 - * @ingroup CAPI_NETWORK_MTP_MANAGER_MODULE + * + * @param [in] raw_devices The raw devices handler * * @return 0 on success, otherwise a negative error value. * @retval #MTP_ERROR_NONE Successful + * @retval #MTP_ERROR_NOT_SUPPORTED MTP is not supported + * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter * - * @param [in] device_handle The device handle - * @param [in] object_handle The object handle - * - * @see mtp_get_device_handle() - * @see mtp_get_object_handles() + * @see mtp_get_raw_devices() */ -MTP_API int mtp_delete_object(int device_handle, int object_handle); +int mtp_destroy_raw_devices(mtp_raw_device_h *raw_devices); /** - * @brief Get object from object handle + * @brief Gets device handler from bus location. * @since_tizen 3.0 - * @ingroup CAPI_NETWORK_MTP_MANAGER_MODULE + * @remarks For using this api, you should get bus location and device number from raw device. + * + * @param [in] bus_location The bus location + * @param [in] device_number The device number + * @param [out] mtp_device The MTP device * * @return 0 on success, otherwise a negative error value. * @retval #MTP_ERROR_NONE Successful + * @retval #MTP_ERROR_NOT_SUPPORTED MTP is not supported + * @retval #MTP_ERROR_NOT_INITIALIZED MTP is not initialized + * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated + * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized + * @retval #MTP_ERROR_COMM MTP communication error + * + * @pre mtp_get_bus_location(), mtp_get_device_number() + * @see mtp_initialize() + */ +int mtp_get_device(int bus_location, int device_number, mtp_device_h *mtp_device); + +/** + * @brief Gets mtp storages from device. + * @since_tizen 3.0 + * @remarks The @a mtp_storages should be freed using free(). * - * @param [in] device_handle The device handle - * @param [in] object_handle The object handle - * @param [in] dest_path The dest path + * @param [in] mtp_device The MTP device + * @param [out] mtp_storages Current mtp storage list + * @param [out] storage_num Length of storage list * - * @see mtp_get_device_handle() - * @see mtp_get_object_handles() + * @return 0 on success, otherwise a negative error value. + * @retval #MTP_ERROR_NONE Successful + * @retval #MTP_ERROR_NOT_SUPPORTED MTP is not supported + * @retval #MTP_ERROR_NOT_INITIALIZED MTP is not initialized + * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated + * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized + * @retval #MTP_ERROR_COMM MTP communication error + * + * @see mtp_get_device() */ -MTP_API int mtp_get_object(int device_handle, int object_handle, char *dest_path); +int mtp_get_storages(mtp_device_h mtp_device, mtp_storage_h **mtp_storages, int* storage_num); /** - * @brief Get thumbnail from object handle + * @brief Gets object handles from device. * @since_tizen 3.0 - * @ingroup CAPI_NETWORK_MTP_MANAGER_MODULE + * @remarks The @a object_handles should be freed using free(). + * @remarks If the @a parent is 0, it means "root folder" of mtp storage. + * + * @param [in] mtp_device The MTP device + * @param [in] mtp_storage The MTP storage + * @param [in] file_type The file type what you want + * @param [in] parent The parent object handle + * @param [out] object_handles The object handle list + * @param [out] object_num Length of object handle list * * @return 0 on success, otherwise a negative error value. * @retval #MTP_ERROR_NONE Successful + * @retval #MTP_ERROR_NOT_SUPPORTED MTP is not supported + * @retval #MTP_ERROR_NOT_INITIALIZED MTP is not initialized + * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated + * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized + * @retval #MTP_ERROR_COMM MTP communication error + * + * @see mtp_get_device() + * @see mtp_get_storages() + */ +int mtp_get_object_handles(mtp_device_h mtp_device, mtp_storage_h mtp_storage, mtp_filetype_e file_type, + mtp_object_h parent, mtp_object_h **object_handles, int* object_num); + +/** + * @brief Gets object for a given path from object handle. + * @since_tizen 3.0 + * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n + * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. \n * - * @param [in] device_handle The device handle + * @param [in] mtp_device The MTP device * @param [in] object_handle The object handle * @param [in] dest_path The dest path * - * @see mtp_get_device_handle() + * @return 0 on success, otherwise a negative error value. + * @retval #MTP_ERROR_NONE Successful + * @retval #MTP_ERROR_NOT_SUPPORTED MTP is not supported + * @retval #MTP_ERROR_NOT_INITIALIZED MTP is not initialized + * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated + * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized + * @retval #MTP_ERROR_COMM MTP communication error + * @retval #MTP_ERROR_IO_ERROR I/O error + * + * @see mtp_get_device() * @see mtp_get_object_handles() */ -MTP_API int mtp_get_thumbnail(int device_handle, int object_handle, char *dest_path); +int mtp_get_object(mtp_device_h mtp_device, mtp_object_h object_handle, char *dest_path); /** - * @brief Registers a callback function for receiving MTP event. + * @brief Gets thumbnail from object handle. * @since_tizen 3.0 - * @ingroup CAPI_NETWORK_MTP_MANAGER_MODULE + * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n + * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. * - * @detail If device state is changed, DEVICE_ADD or DEVICE_REMOVE event is occur. \n - * If storage state is changed, STORAGE_ADD or STORAGE_REMOVE event is occur. \n - * If object state is changed, OBJECT_ADD or OBJECT_REMOVE event is occur. + * @param [in] mtp_device The MTP device + * @param [in] object_handle The object handle + * @param [in] dest_path The dest path * * @return 0 on success, otherwise a negative error value. * @retval #MTP_ERROR_NONE Successful + * @retval #MTP_ERROR_NOT_SUPPORTED MTP is not supported + * @retval #MTP_ERROR_NOT_INITIALIZED MTP is not initialized + * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated + * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized + * @retval #MTP_ERROR_COMM MTP communication error + * @retval #MTP_ERROR_IO_ERROR I/O error + * + * @see mtp_get_device() + * @see mtp_get_object_handles() + */ +int mtp_get_thumbnail(mtp_device_h mtp_device, mtp_object_h object_handle, char *dest_path); + +/** + * @brief Registers a callback function for receiving MTP event. + * @since_tizen 3.0 + * + * @remarks If device state is changed, DEVICE_ADD or DEVICE_REMOVE event is occur. \n + * If storage state is changed, STORAGE_ADD or STORAGE_REMOVE event is occur. \n + * If object state is changed, OBJECT_ADD or OBJECT_REMOVE event is occur. * - * @param [in] callback The callback + * @param [in] event_cb The callback * @param [in] user_data The user data * + * @return 0 on success, otherwise a negative error value. + * @retval #MTP_ERROR_NONE Successful + * @retval #MTP_ERROR_NOT_SUPPORTED MTP is not supported + * @retval #MTP_ERROR_NOT_INITIALIZED MTP is not initialized + * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter + * @see mtp_unset_mtp_event_cb() */ -MTP_API int mtp_set_mtp_event_cb(mtp_event_cb callback, void *user_data); +int mtp_set_mtp_event_cb(mtp_event_cb event_cb, void *user_data); /** * @brief Unregisters the callback function. * @since_tizen 3.0 - * @ingroup CAPI_NETWORK_MTP_MANAGER_MODULE * * @return 0 on success, otherwise a negative error value. * @retval #MTP_ERROR_NONE Successful + * @retval #MTP_ERROR_NOT_SUPPORTED MTP is not supported + * @retval #MTP_ERROR_NOT_INITIALIZED MTP is not initialized * * @see mtp_set_mtp_event_cb() */ -MTP_API int mtp_unset_mtp_event_cb(void); +int mtp_unset_mtp_event_cb(void); /** * @brief Deinitializes MTP operation. * @since_tizen 3.0 - * @ingroup CAPI_NETWORK_MTP_MANAGER_MODULE * * @return 0 on success, otherwise a negative error value. * @retval #MTP_ERROR_NONE Successful + * @retval #MTP_ERROR_NOT_SUPPORTED MTP is not supported + * @retval #MTP_ERROR_PERMISSION_DENIED Permission Denied * * @see mtp_initialize() */ -MTP_API int mtp_deinitialize(void); +int mtp_deinitialize(void); /** - * @brief Get the manufacturer name of the device information. +* @} +*/ + +/** + * @addtogroup CAPI_NETWORK_MTP_DEVICEINFO_MODULE + * @{ + */ + +/** + * @brief Gets the manufacturer name of the device information. * @since_tizen 3.0 - * @ingroup CAPI_NETWORK_MTP_DEVICEINFO_MODULE + * @remarks The @a manufacturer_name should be freed using free(). + * + * @param [in] mtp_device The MTP device + * @param [out] manufacturer_name The manufacturer name of Device information * * @return 0 on success, otherwise a negative error value. * @retval #MTP_ERROR_NONE Successful - * - * @param [in] device_handle The device handle - * @param [out] manufacturername The manufacturername of Device information - * - * @see mtp_get_device_handle() + * @retval #MTP_ERROR_NOT_SUPPORTED MTP is not supported + * @retval #MTP_ERROR_NOT_INITIALIZED MTP is not initialized + * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated + * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized + * @retval #MTP_ERROR_COMM MTP communication error + * @retval #MTP_ERROR_CONTROLLER MTP controller error + * @retval #MTP_ERROR_ALLOC_FAIL Memory Allocation failed + * @retval #MTP_ERROR_NO_DEVICE MTP have not any device + * + * @see mtp_get_device() */ -MTP_API int mtp_deviceinfo_get_manufacturername(int device_handle, char **manufacturername); +int mtp_deviceinfo_get_manufacturer_name(mtp_device_h mtp_device, char **manufacturer_name); /** - * @brief Get the model name of the device information. + * @brief Gets the model name of the device information. * @since_tizen 3.0 - * @ingroup CAPI_NETWORK_MTP_DEVICEINFO_MODULE + * @remarks The @a model_name should be freed using free(). + * + * @param [in] mtp_device The MTP device + * @param [out] model_name The model name of Device information * * @return 0 on success, otherwise a negative error value. * @retval #MTP_ERROR_NONE Successful - * - * @param [in] device_handle The device handle - * @param [out] modelname The modelname of Device information - * - * @see mtp_get_device_handle() + * @retval #MTP_ERROR_NOT_SUPPORTED MTP is not supported + * @retval #MTP_ERROR_NOT_INITIALIZED MTP is not initialized + * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated + * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized + * @retval #MTP_ERROR_COMM MTP communication error + * @retval #MTP_ERROR_CONTROLLER MTP controller error + * @retval #MTP_ERROR_ALLOC_FAIL Memory Allocation failed + * @retval #MTP_ERROR_NO_DEVICE MTP have not any device + * + * @see mtp_get_device() */ -MTP_API int mtp_deviceinfo_get_modelname(int device_handle, char **modelname); +int mtp_deviceinfo_get_model_name(mtp_device_h mtp_device, char **model_name); /** - * @brief Get the serial number of the device information. + * @brief Gets the serial number of the device information. * @since_tizen 3.0 - * @ingroup CAPI_NETWORK_MTP_DEVICEINFO_MODULE + * @remarks The @a serial_number should be freed using free(). + * + * @param [in] mtp_device The MTP device + * @param [out] serial_number The serial number of Device information * * @return 0 on success, otherwise a negative error value. * @retval #MTP_ERROR_NONE Successful - * - * @param [in] device_handle The device handle - * @param [out] serialnumber The serialnumber of Device information - * - * @see mtp_get_device_handle() + * @retval #MTP_ERROR_NOT_SUPPORTED MTP is not supported + * @retval #MTP_ERROR_NOT_INITIALIZED MTP is not initialized + * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated + * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized + * @retval #MTP_ERROR_COMM MTP communication error + * @retval #MTP_ERROR_CONTROLLER MTP controller error + * @retval #MTP_ERROR_ALLOC_FAIL Memory Allocation failed + * @retval #MTP_ERROR_NO_DEVICE MTP have not any device + * + * @see mtp_get_device() */ -MTP_API int mtp_deviceinfo_get_serialnumber(int device_handle, char **serialnumber); +int mtp_deviceinfo_get_serial_number(mtp_device_h mtp_device, char **serial_number); /** - * @brief Get the device version of the device information. + * @brief Gets the device version of the device information. * @since_tizen 3.0 - * @ingroup CAPI_NETWORK_MTP_DEVICEINFO_MODULE + * @remarks The @a device_version should be freed using free(). + * + * @param [in] mtp_device The MTP device + * @param [out] device_version The device version of Device information * * @return 0 on success, otherwise a negative error value. * @retval #MTP_ERROR_NONE Successful - * - * @param [in] device_handle The device handle - * @param [out] serialnumber The deviceversion of Device information - * - * @see mtp_get_device_handle() + * @retval #MTP_ERROR_NOT_SUPPORTED MTP is not supported + * @retval #MTP_ERROR_NOT_INITIALIZED MTP is not initialized + * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated + * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized + * @retval #MTP_ERROR_COMM MTP communication error + * @retval #MTP_ERROR_CONTROLLER MTP controller error + * @retval #MTP_ERROR_ALLOC_FAIL Memory Allocation failed + * @retval #MTP_ERROR_NO_DEVICE MTP have not any device + * + * @see mtp_get_device() */ -MTP_API int mtp_deviceinfo_get_deviceversion(int device_handle, char **deviceversion); +int mtp_deviceinfo_get_device_version(mtp_device_h mtp_device, char **device_version); + +/** +* @} +*/ /** - * @brief Get the description of the storage information. + * @addtogroup CAPI_NETWORK_MTP_STORAGEINFO_MODULE + * @{ + */ + +/** + * @brief Gets the description of the storage information. * @since_tizen 3.0 - * @ingroup CAPI_NETWORK_MTP_STORAGEINFO_MODULE - * - * @return 0 on success, otherwise a negative error value. - * @retval #MTP_ERROR_NONE Successful + * @remarks The @a description should be freed using free(). * - * @param [in] device_handle The device handle - * @param [in] storage_id The storage id + * @param [in] mtp_device The MTP device + * @param [in] mtp_storage The MTP storage * @param [out] description The description of Storage information * - * @see mtp_get_storage_ids() + * @return 0 on success, otherwise a negative error value. + * @retval #MTP_ERROR_NONE Successful + * @retval #MTP_ERROR_NOT_SUPPORTED MTP is not supported + * @retval #MTP_ERROR_NOT_INITIALIZED MTP is not initialized + * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated + * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized + * @retval #MTP_ERROR_COMM MTP communication error + * @retval #MTP_ERROR_CONTROLLER MTP controller error + * @retval #MTP_ERROR_ALLOC_FAIL Memory Allocation failed + * @retval #MTP_ERROR_NO_DEVICE MTP have not any device + * + * @see mtp_get_storages() */ -MTP_API int mtp_storageinfo_get_description(int device_handle, int storage_id, char **description); +int mtp_storageinfo_get_description(mtp_device_h mtp_device, mtp_storage_h mtp_storage, char **description); /** - * @brief Get the freespace of the storage information. + * @brief Gets the freespace of the storage information. * @since_tizen 3.0 - * @ingroup CAPI_NETWORK_MTP_STORAGEINFO_MODULE + * + * @param [in] mtp_device The MTP device + * @param [in] mtp_storage The MTP storage + * @param [out] free_space The free space of Storage information * * @return 0 on success, otherwise a negative error value. * @retval #MTP_ERROR_NONE Successful - * - * @param [in] device_handle The device handle - * @param [in] storage_id The storage id - * @param [out] freespace The freespace of Storage information - * - * @see mtp_get_storage_ids() + * @retval #MTP_ERROR_NOT_SUPPORTED MTP is not supported + * @retval #MTP_ERROR_NOT_INITIALIZED MTP is not initialized + * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated + * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized + * @retval #MTP_ERROR_COMM MTP communication error + * @retval #MTP_ERROR_CONTROLLER MTP controller error + * @retval #MTP_ERROR_ALLOC_FAIL Memory Allocation failed + * @retval #MTP_ERROR_NO_DEVICE MTP have not any device + * + * @see mtp_get_storages() */ -MTP_API int mtp_storageinfo_get_freespace(int device_handle, int storage_id, unsigned long long *freespace); +int mtp_storageinfo_get_free_space(mtp_device_h mtp_device, mtp_storage_h mtp_storage, unsigned long long *free_space); /** - * @brief Get the max capacity of the storage information. + * @brief Gets the max capacity of the storage information. * @since_tizen 3.0 - * @ingroup CAPI_NETWORK_MTP_STORAGEINFO_MODULE + * + * @param [in] mtp_device The MTP device + * @param [in] mtp_storage The MTP storage + * @param [out] max_capacity The max capacity of Storage information * * @return 0 on success, otherwise a negative error value. * @retval #MTP_ERROR_NONE Successful - * - * @param [in] device_handle The device handle - * @param [in] storage_id The storage id - * @param [out] maxcapacity The maxcapacity of Storage information - * - * @see mtp_get_storage_ids() + * @retval #MTP_ERROR_NOT_SUPPORTED MTP is not supported + * @retval #MTP_ERROR_NOT_INITIALIZED MTP is not initialized + * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated + * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized + * @retval #MTP_ERROR_COMM MTP communication error + * @retval #MTP_ERROR_CONTROLLER MTP controller error + * @retval #MTP_ERROR_ALLOC_FAIL Memory Allocation failed + * @retval #MTP_ERROR_NO_DEVICE MTP have not any device + * + * @see mtp_get_storages() */ -MTP_API int mtp_storageinfo_get_maxcapacity(int device_handle, int storage_id, unsigned long long *maxcapacity); +int mtp_storageinfo_get_max_capacity(mtp_device_h mtp_device, mtp_storage_h mtp_storage, unsigned long long *max_capacity); /** - * @brief Get the storage type of the storage information. + * @brief Gets the storage type of the storage information. * @since_tizen 3.0 - * @ingroup CAPI_NETWORK_MTP_STORAGEINFO_MODULE + * + * @param [in] mtp_device The MTP device + * @param [in] mtp_storage The MTP storage + * @param [out] storage_type The storage type of Storage information * * @return 0 on success, otherwise a negative error value. * @retval #MTP_ERROR_NONE Successful - * - * @param [in] device_handle The device handle - * @param [in] storage_id The storage id - * @param [out] storagetype The storagetype of Storage information - * - * @see mtp_get_storage_ids() + * @retval #MTP_ERROR_NOT_SUPPORTED MTP is not supported + * @retval #MTP_ERROR_NOT_INITIALIZED MTP is not initialized + * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated + * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized + * @retval #MTP_ERROR_COMM MTP communication error + * @retval #MTP_ERROR_CONTROLLER MTP controller error + * @retval #MTP_ERROR_ALLOC_FAIL Memory Allocation failed + * @retval #MTP_ERROR_NO_DEVICE MTP have not any device + * + * @see mtp_get_storages() */ -MTP_API int mtp_storageinfo_get_storagetype(int device_handle, int storage_id, int *storagetype); +int mtp_storageinfo_get_storage_type(mtp_device_h mtp_device, mtp_storage_h mtp_storage, int *storage_type); /** - * @brief Get the volumeidentifier of the storage information. + * @brief Gets the volumeidentifier of the storage information. * @since_tizen 3.0 - * @ingroup CAPI_NETWORK_MTP_STORAGEINFO_MODULE + * @remarks The @a volume_identifier should be freed using free(). + * + * @param [in] mtp_device The MTP device + * @param [in] mtp_storage The MTP storage + * @param [out] volume_identifier The volume identifier of Storage information * * @return 0 on success, otherwise a negative error value. * @retval #MTP_ERROR_NONE Successful - * - * @param [in] device_handle The device handle - * @param [in] storage_id The storage id - * @param [out] volumeidentifier The volumeidentifier of Storage information + * @retval #MTP_ERROR_NOT_SUPPORTED MTP is not supported + * @retval #MTP_ERROR_NOT_INITIALIZED MTP is not initialized + * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated + * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized + * @retval #MTP_ERROR_COMM MTP communication error + * @retval #MTP_ERROR_CONTROLLER MTP controller error + * @retval #MTP_ERROR_ALLOC_FAIL Memory Allocation failed + * @retval #MTP_ERROR_NO_DEVICE MTP have not any device * * @see mtp_get_object_handles() */ -MTP_API int mtp_storageinfo_get_volumeidentifier(int device_handle, int storage_id, char **volumeidentifier); +int mtp_storageinfo_get_volume_identifier(mtp_device_h mtp_device, mtp_storage_h mtp_storage, char **volume_identifier); + +/** +* @} +*/ /** - * @brief Get the filename of the object information. + * @addtogroup CAPI_NETWORK_MTP_OBJECTINFO_MODULE + * @{ + */ + +/** + * @brief Gets the filename of the object information. * @since_tizen 3.0 - * @ingroup CAPI_NETWORK_MTP_OBJECTINFO_MODULE + * @remarks The @a file_name should be freed using free(). + * + * @param [in] mtp_device The MTP device + * @param [in] object_handle The object handle + * @param [out] file_name The file name of Object information * * @return 0 on success, otherwise a negative error value. * @retval #MTP_ERROR_NONE Successful - * - * @param [in] device_handle The device handle - * @param [in] object_handle The object handle - * @param [out] filename The filename of Object information + * @retval #MTP_ERROR_NOT_SUPPORTED MTP is not supported + * @retval #MTP_ERROR_NOT_INITIALIZED MTP is not initialized + * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated + * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized + * @retval #MTP_ERROR_COMM MTP communication error + * @retval #MTP_ERROR_CONTROLLER MTP controller error + * @retval #MTP_ERROR_ALLOC_FAIL Memory Allocation failed + * @retval #MTP_ERROR_NO_DEVICE MTP have not any device + * @retval #MTP_ERROR_PLUGIN Plugin failed * * @see mtp_get_object_handles() */ -MTP_API int mtp_objectinfo_get_filename(int device_handle, int object_handle, char **filename); +int mtp_objectinfo_get_file_name(mtp_device_h mtp_device, mtp_object_h object_handle, char **file_name); /** - * @brief Get the keywords of the object information. + * @brief Gets the keywords of the object information. * @since_tizen 3.0 - * @ingroup CAPI_NETWORK_MTP_OBJECTINFO_MODULE - * - * @return 0 on success, otherwise a negative error value. - * @retval #MTP_ERROR_NONE Successful + * @remarks The @a keywords should be freed using free(). * - * @param [in] device_handle The device handle + * @param [in] mtp_device The MTP device * @param [in] object_handle The object handle * @param [out] keywords The keywords of Object information * + * @return 0 on success, otherwise a negative error value. + * @retval #MTP_ERROR_NONE Successful + * @retval #MTP_ERROR_NOT_SUPPORTED MTP is not supported + * @retval #MTP_ERROR_NOT_INITIALIZED MTP is not initialized + * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated + * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized + * @retval #MTP_ERROR_COMM MTP communication error + * @retval #MTP_ERROR_CONTROLLER MTP controller error + * @retval #MTP_ERROR_ALLOC_FAIL Memory Allocation failed + * @retval #MTP_ERROR_NO_DEVICE MTP have not any device + * @retval #MTP_ERROR_PLUGIN Plugin failed + * * @see mtp_get_object_handles() */ -MTP_API int mtp_objectinfo_get_keywords(int device_handle, int object_handle, char **keywords); +int mtp_objectinfo_get_keywords(mtp_device_h mtp_device, mtp_object_h object_handle, char **keywords); /** - * @brief Get the association desc of the object information. + * @brief Gets the association desc of the object information. * @since_tizen 3.0 - * @ingroup CAPI_NETWORK_MTP_OBJECTINFO_MODULE - * - * @return 0 on success, otherwise a negative error value. - * @retval #MTP_ERROR_NONE Successful * - * @param [in] device_handle The device handle + * @param [in] mtp_device The MTP device * @param [in] object_handle The object handle * @param [out] asso_desc The association description of Object information * + * @return 0 on success, otherwise a negative error value. + * @retval #MTP_ERROR_NONE Successful + * @retval #MTP_ERROR_NOT_SUPPORTED MTP is not supported + * @retval #MTP_ERROR_NOT_INITIALIZED MTP is not initialized + * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated + * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized + * @retval #MTP_ERROR_COMM MTP communication error + * @retval #MTP_ERROR_CONTROLLER MTP controller error + * @retval #MTP_ERROR_ALLOC_FAIL Memory Allocation failed + * @retval #MTP_ERROR_NO_DEVICE MTP have not any device + * @retval #MTP_ERROR_PLUGIN Plugin failed + * * @see mtp_get_object_handles() */ -MTP_API int mtp_objectinfo_get_association_desc(int device_handle, int object_handle, int *asso_desc); +int mtp_objectinfo_get_association_desc(mtp_device_h mtp_device, mtp_object_h object_handle, int *asso_desc); /** - * @brief Get the association type of the object information. + * @brief Gets the association type of the object information. * @since_tizen 3.0 - * @ingroup CAPI_NETWORK_MTP_OBJECTINFO_MODULE - * - * @return 0 on success, otherwise a negative error value. - * @retval #MTP_ERROR_NONE Successful * - * @param [in] device_handle The device handle + * @param [in] mtp_device The MTP device * @param [in] object_handle The object handle * @param [out] asso_type The association type of Object information * + * @return 0 on success, otherwise a negative error value. + * @retval #MTP_ERROR_NONE Successful + * @retval #MTP_ERROR_NOT_SUPPORTED MTP is not supported + * @retval #MTP_ERROR_NOT_INITIALIZED MTP is not initialized + * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated + * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized + * @retval #MTP_ERROR_COMM MTP communication error + * @retval #MTP_ERROR_CONTROLLER MTP controller error + * @retval #MTP_ERROR_ALLOC_FAIL Memory Allocation failed + * @retval #MTP_ERROR_NO_DEVICE MTP have not any device + * @retval #MTP_ERROR_PLUGIN Plugin failed + * * @see mtp_get_object_handles() */ -MTP_API int mtp_objectinfo_get_association_type(int device_handle, int object_handle, int *asso_type); +int mtp_objectinfo_get_association_type(mtp_device_h mtp_device, mtp_object_h object_handle, int *asso_type); /** - * @brief Get the size of the object information. + * @brief Gets the size of the object information. * @since_tizen 3.0 - * @ingroup CAPI_NETWORK_MTP_OBJECTINFO_MODULE * - * @return 0 on success, otherwise a negative error value. - * @retval #MTP_ERROR_NONE Successful - * - * @param [in] device_handle The device handle + * @param [in] mtp_device The MTP device * @param [in] object_handle The object handle * @param [out] size The size of Object information * + * @return 0 on success, otherwise a negative error value. + * @retval #MTP_ERROR_NONE Successful + * @retval #MTP_ERROR_NOT_SUPPORTED MTP is not supported + * @retval #MTP_ERROR_NOT_INITIALIZED MTP is not initialized + * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated + * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized + * @retval #MTP_ERROR_COMM MTP communication error + * @retval #MTP_ERROR_CONTROLLER MTP controller error + * @retval #MTP_ERROR_ALLOC_FAIL Memory Allocation failed + * @retval #MTP_ERROR_NO_DEVICE MTP have not any device + * @retval #MTP_ERROR_PLUGIN Plugin failed + * * @see mtp_get_object_handles() */ -MTP_API int mtp_objectinfo_get_size(int device_handle, int object_handle, int *size); +int mtp_objectinfo_get_size(mtp_device_h mtp_device, mtp_object_h object_handle, int *size); /** - * @brief Get the parent object handle of the object information. + * @brief Gets the parent object handle of the object information. * @since_tizen 3.0 - * @ingroup CAPI_NETWORK_MTP_OBJECTINFO_MODULE - * - * @return 0 on success, otherwise a negative error value. - * @retval #MTP_ERROR_NONE Successful * - * @param [in] device_handle The device handle + * @param [in] mtp_device The MTP device * @param [in] object_handle The object handle * @param [out] parent_object_handle The parent of Object information * + * @return 0 on success, otherwise a negative error value. + * @retval #MTP_ERROR_NONE Successful + * @retval #MTP_ERROR_NOT_SUPPORTED MTP is not supported + * @retval #MTP_ERROR_NOT_INITIALIZED MTP is not initialized + * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated + * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized + * @retval #MTP_ERROR_COMM MTP communication error + * @retval #MTP_ERROR_CONTROLLER MTP controller error + * @retval #MTP_ERROR_ALLOC_FAIL Memory Allocation failed + * @retval #MTP_ERROR_NO_DEVICE MTP have not any device + * @retval #MTP_ERROR_PLUGIN Plugin failed + * * @see mtp_get_object_handles() */ -MTP_API int mtp_objectinfo_get_parent_object_handle(int device_handle, int object_handle, int *parent_object_handle); +int mtp_objectinfo_get_parent_object_handle(mtp_device_h mtp_device, mtp_object_h object_handle, mtp_object_h *parent_object_handle); /** - * @brief Get the storage id of the object information. + * @brief Gets the mtp storage of the object information. * @since_tizen 3.0 - * @ingroup CAPI_NETWORK_MTP_OBJECTINFO_MODULE + * + * @param [in] mtp_device The MTP device + * @param [in] object_handle The object handle + * @param [out] mtp_storage The MTP storage of Object information * * @return 0 on success, otherwise a negative error value. * @retval #MTP_ERROR_NONE Successful - * - * @param [in] device_handle The device handle - * @param [in] object_handle The object handle - * @param [out] storage_id The storage id of Object information + * @retval #MTP_ERROR_NOT_SUPPORTED MTP is not supported + * @retval #MTP_ERROR_NOT_INITIALIZED MTP is not initialized + * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated + * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized + * @retval #MTP_ERROR_COMM MTP communication error + * @retval #MTP_ERROR_CONTROLLER MTP controller error + * @retval #MTP_ERROR_ALLOC_FAIL Memory Allocation failed + * @retval #MTP_ERROR_NO_DEVICE MTP have not any device + * @retval #MTP_ERROR_PLUGIN Plugin failed * * @see mtp_get_object_handles() */ -MTP_API int mtp_objectinfo_get_storage_id(int device_handle, int object_handle, int *storage_id); +int mtp_objectinfo_get_storage(mtp_device_h mtp_device, mtp_object_h object_handle, mtp_storage_h* mtp_storage); /** - * @brief Get the data created time of the object information. + * @brief Gets the data created time of the object information. * @since_tizen 3.0 - * @ingroup CAPI_NETWORK_MTP_OBJECTINFO_MODULE * - * @return 0 on success, otherwise a negative error value. - * @retval #MTP_ERROR_NONE Successful - * - * @param [in] device_handle The device handle + * @param [in] mtp_device The MTP device * @param [in] object_handle The object handle * @param [out] data_created The data created time of Object information * + * @return 0 on success, otherwise a negative error value. + * @retval #MTP_ERROR_NONE Successful + * @retval #MTP_ERROR_NOT_SUPPORTED MTP is not supported + * @retval #MTP_ERROR_NOT_INITIALIZED MTP is not initialized + * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated + * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized + * @retval #MTP_ERROR_COMM MTP communication error + * @retval #MTP_ERROR_CONTROLLER MTP controller error + * @retval #MTP_ERROR_ALLOC_FAIL Memory Allocation failed + * @retval #MTP_ERROR_NO_DEVICE MTP have not any device + * @retval #MTP_ERROR_PLUGIN Plugin failed + * * @see mtp_get_object_handles() */ -MTP_API int mtp_objectinfo_get_data_created(int device_handle, int object_handle, int *data_created); +int mtp_objectinfo_get_data_created(mtp_device_h mtp_device, mtp_object_h object_handle, int *data_created); /** - * @brief Get the data modified time of the object information. + * @brief Gets the data modified time of the object information. * @since_tizen 3.0 - * @ingroup CAPI_NETWORK_MTP_OBJECTINFO_MODULE * - * @return 0 on success, otherwise a negative error value. - * @retval #MTP_ERROR_NONE Successful - * - * @param [in] device_handle The device handle + * @param [in] mtp_device The MTP device * @param [in] object_handle The object handle * @param [out] data_modified The data modified time of Object information * + * @return 0 on success, otherwise a negative error value. + * @retval #MTP_ERROR_NONE Successful + * @retval #MTP_ERROR_NOT_SUPPORTED MTP is not supported + * @retval #MTP_ERROR_NOT_INITIALIZED MTP is not initialized + * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated + * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized + * @retval #MTP_ERROR_COMM MTP communication error + * @retval #MTP_ERROR_CONTROLLER MTP controller error + * @retval #MTP_ERROR_ALLOC_FAIL Memory Allocation failed + * @retval #MTP_ERROR_NO_DEVICE MTP have not any device + * @retval #MTP_ERROR_PLUGIN Plugin failed + * * @see mtp_get_object_handles() */ -MTP_API int mtp_objectinfo_get_data_modified(int device_handle, int object_handle, int *data_modified); +int mtp_objectinfo_get_data_modified(mtp_device_h mtp_device, mtp_object_h object_handle, int *data_modified); /** - * @brief Get the format of the object information. + * @brief Gets the file type of the object information. * @since_tizen 3.0 - * @ingroup CAPI_NETWORK_MTP_OBJECTINFO_MODULE + * + * @param [in] mtp_device The MTP device + * @param [in] object_handle The object handle + * @param [out] file_type The file type of Object information * * @return 0 on success, otherwise a negative error value. * @retval #MTP_ERROR_NONE Successful - * - * @param [in] device_handle The device handle - * @param [in] object_handle The object handle - * @param [out] format The image format of Object information + * @retval #MTP_ERROR_NOT_SUPPORTED MTP is not supported + * @retval #MTP_ERROR_NOT_INITIALIZED MTP is not initialized + * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated + * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized + * @retval #MTP_ERROR_COMM MTP communication error + * @retval #MTP_ERROR_CONTROLLER MTP controller error + * @retval #MTP_ERROR_ALLOC_FAIL Memory Allocation failed + * @retval #MTP_ERROR_NO_DEVICE MTP have not any device + * @retval #MTP_ERROR_PLUGIN Plugin failed * * @see mtp_get_object_handles() */ -MTP_API int mtp_objectinfo_get_format(int device_handle, int object_handle, int *format); +int mtp_objectinfo_get_file_type(mtp_device_h mtp_device, mtp_object_h object_handle, mtp_filetype_e *file_type); /** - * @brief Get the image pix depth of the object information. + * @brief Gets the image bit depth of the object information. * @since_tizen 3.0 - * @ingroup CAPI_NETWORK_MTP_OBJECTINFO_MODULE + * + * @param [in] mtp_device The MTP device + * @param [in] object_handle The object handle + * @param [out] depth The image bit depth of Object information * * @return 0 on success, otherwise a negative error value. * @retval #MTP_ERROR_NONE Successful - * - * @param [in] device_handle The device handle - * @param [in] object_handle The object handle - * @param [out] depth The image pixel depth of Object information + * @retval #MTP_ERROR_NOT_SUPPORTED MTP is not supported + * @retval #MTP_ERROR_NOT_INITIALIZED MTP is not initialized + * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated + * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized + * @retval #MTP_ERROR_COMM MTP communication error + * @retval #MTP_ERROR_CONTROLLER MTP controller error + * @retval #MTP_ERROR_ALLOC_FAIL Memory Allocation failed + * @retval #MTP_ERROR_NO_DEVICE MTP have not any device + * @retval #MTP_ERROR_PLUGIN Plugin failed * * @see mtp_get_object_handles() */ -MTP_API int mtp_objectinfo_get_image_pix_depth(int device_handle, int object_handle, int *depth); +int mtp_objectinfo_get_image_bit_depth(mtp_device_h mtp_device, mtp_object_h object_handle, int *depth); /** - * @brief Get the image pix width of the object information. + * @brief Gets the image pix width of the object information. * @since_tizen 3.0 - * @ingroup CAPI_NETWORK_MTP_OBJECTINFO_MODULE - * - * @return 0 on success, otherwise a negative error value. - * @retval #MTP_ERROR_NONE Successful * - * @param [in] device_handle The device handle + * @param [in] mtp_device The MTP device * @param [in] object_handle The object handle * @param [out] width The image pixel width of Object information * + * @return 0 on success, otherwise a negative error value. + * @retval #MTP_ERROR_NONE Successful + * @retval #MTP_ERROR_NOT_SUPPORTED MTP is not supported + * @retval #MTP_ERROR_NOT_INITIALIZED MTP is not initialized + * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated + * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized + * @retval #MTP_ERROR_COMM MTP communication error + * @retval #MTP_ERROR_CONTROLLER MTP controller error + * @retval #MTP_ERROR_ALLOC_FAIL Memory Allocation failed + * @retval #MTP_ERROR_NO_DEVICE MTP have not any device + * @retval #MTP_ERROR_PLUGIN Plugin failed + * * @see mtp_get_object_handles() */ -MTP_API int mtp_objectinfo_get_image_pix_width(int device_handle, int object_handle, int *width); +int mtp_objectinfo_get_image_pix_width(mtp_device_h mtp_device, mtp_object_h object_handle, int *width); /** - * @brief Get the image pix height of the object information. + * @brief Gets the image pix height of the object information. * @since_tizen 3.0 - * @ingroup CAPI_NETWORK_MTP_OBJECTINFO_MODULE - * - * @return 0 on success, otherwise a negative error value. - * @retval #MTP_ERROR_NONE Successful * - * @param [in] device_handle The device handle + * @param [in] mtp_device The MTP device * @param [in] object_handle The object handle * @param [out] height The image pixel height of Object information * + * @return 0 on success, otherwise a negative error value. + * @retval #MTP_ERROR_NONE Successful + * @retval #MTP_ERROR_NOT_SUPPORTED MTP is not supported + * @retval #MTP_ERROR_NOT_INITIALIZED MTP is not initialized + * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated + * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized + * @retval #MTP_ERROR_COMM MTP communication error + * @retval #MTP_ERROR_CONTROLLER MTP controller error + * @retval #MTP_ERROR_ALLOC_FAIL Memory Allocation failed + * @retval #MTP_ERROR_NO_DEVICE MTP have not any device + * @retval #MTP_ERROR_PLUGIN Plugin failed + * * @see mtp_get_object_handles() */ -MTP_API int mtp_objectinfo_get_image_pix_height(int device_handle, int object_handle, int *height); +int mtp_objectinfo_get_image_pix_height(mtp_device_h mtp_device, mtp_object_h object_handle, int *height); /** - * @brief Get the thumbnail size of the object information. + * @brief Gets the thumbnail size of the object information. * @since_tizen 3.0 - * @ingroup CAPI_NETWORK_MTP_OBJECTINFO_MODULE - * - * @return 0 on success, otherwise a negative error value. - * @retval #MTP_ERROR_NONE Successful * - * @param [in] device_handle The device handle + * @param [in] mtp_device The MTP device * @param [in] object_handle The object handle * @param [out] size The thumbnail size of Object information * + * @return 0 on success, otherwise a negative error value. + * @retval #MTP_ERROR_NONE Successful + * @retval #MTP_ERROR_NOT_SUPPORTED MTP is not supported + * @retval #MTP_ERROR_NOT_INITIALIZED MTP is not initialized + * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated + * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized + * @retval #MTP_ERROR_COMM MTP communication error + * @retval #MTP_ERROR_CONTROLLER MTP controller error + * @retval #MTP_ERROR_ALLOC_FAIL Memory Allocation failed + * @retval #MTP_ERROR_NO_DEVICE MTP have not any device + * @retval #MTP_ERROR_PLUGIN Plugin failed + * * @see mtp_get_object_handles() */ -MTP_API int mtp_objectinfo_get_thumbnail_size(int device_handle, int object_handle, int *size); +int mtp_objectinfo_get_thumbnail_size(mtp_device_h mtp_device, mtp_object_h object_handle, int *size); /** - * @brief Get the thumbnail format of the object information. + * @brief Gets the thumbnail file_type of the object information. * @since_tizen 3.0 - * @ingroup CAPI_NETWORK_MTP_OBJECTINFO_MODULE + * + * @param [in] mtp_device The MTP device + * @param [in] object_handle The object handle + * @param [out] file_type The file type of Object information * * @return 0 on success, otherwise a negative error value. * @retval #MTP_ERROR_NONE Successful - * - * @param [in] device_handle The device handle - * @param [in] object_handle The object handle - * @param [out] format The thumbnail format of Object information + * @retval #MTP_ERROR_NOT_SUPPORTED MTP is not supported + * @retval #MTP_ERROR_NOT_INITIALIZED MTP is not initialized + * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated + * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized + * @retval #MTP_ERROR_COMM MTP communication error + * @retval #MTP_ERROR_CONTROLLER MTP controller error + * @retval #MTP_ERROR_ALLOC_FAIL Memory Allocation failed + * @retval #MTP_ERROR_NO_DEVICE MTP have not any device + * @retval #MTP_ERROR_PLUGIN Plugin failed * * @see mtp_get_object_handles() */ -MTP_API int mtp_objectinfo_get_thumbnail_format(int device_handle, int object_handle, int *format); +int mtp_objectinfo_get_thumbnail_file_type(mtp_device_h mtp_device, mtp_object_h object_handle, mtp_filetype_e *file_type); /** - * @brief Get the thumbnail pix height of the object information. + * @brief Gets the thumbnail pix height of the object information. * @since_tizen 3.0 - * @ingroup CAPI_NETWORK_MTP_OBJECTINFO_MODULE * - * @return 0 on success, otherwise a negative error value. - * @retval #MTP_ERROR_NONE Successful - * - * @param [in] device_handle The device handle + * @param [in] mtp_device The MTP device * @param [in] object_handle The object handle * @param [out] height The thumbnail pixel height of Object information * + * @return 0 on success, otherwise a negative error value. + * @retval #MTP_ERROR_NONE Successful + * @retval #MTP_ERROR_NOT_SUPPORTED MTP is not supported + * @retval #MTP_ERROR_NOT_INITIALIZED MTP is not initialized + * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated + * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized + * @retval #MTP_ERROR_COMM MTP communication error + * @retval #MTP_ERROR_CONTROLLER MTP controller error + * @retval #MTP_ERROR_ALLOC_FAIL Memory Allocation failed + * @retval #MTP_ERROR_NO_DEVICE MTP have not any device + * @retval #MTP_ERROR_PLUGIN Plugin failed + * * @see mtp_get_object_handles() */ -MTP_API int mtp_objectinfo_get_thumbnail_pix_height(int device_handle, int object_handle, int *height); +int mtp_objectinfo_get_thumbnail_pix_height(mtp_device_h mtp_device, mtp_object_h object_handle, int *height); /** - * @brief Get the thumbnail pix width of the object information. + * @brief Gets the thumbnail pix width of the object information. * @since_tizen 3.0 - * @ingroup CAPI_NETWORK_MTP_OBJECTINFO_MODULE - * - * @return 0 on success, otherwise a negative error value. - * @retval #MTP_ERROR_NONE Successful * - * @param [in] device_handle The device handle + * @param [in] mtp_device The MTP device * @param [in] object_handle The object handle * @param [out] width The thumbnail pixel width of Object information * + * @return 0 on success, otherwise a negative error value. + * @retval #MTP_ERROR_NONE Successful + * @retval #MTP_ERROR_NOT_SUPPORTED MTP is not supported + * @retval #MTP_ERROR_NOT_INITIALIZED MTP is not initialized + * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated + * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized + * @retval #MTP_ERROR_COMM MTP communication error + * @retval #MTP_ERROR_CONTROLLER MTP controller error + * @retval #MTP_ERROR_ALLOC_FAIL Memory Allocation failed + * @retval #MTP_ERROR_NO_DEVICE MTP have not any device + * @retval #MTP_ERROR_PLUGIN Plugin failed + * * @see mtp_get_object_handles() */ -MTP_API int mtp_objectinfo_get_thumbnail_pix_width(int device_handle, int object_handle, int *width); +int mtp_objectinfo_get_thumbnail_pix_width(mtp_device_h mtp_device, mtp_object_h object_handle, int *width); + +/** +* @} +*/ #ifdef __cplusplus } diff --git a/include/mtp_db.h b/include/mtp_db.h index a546820..2364d0a 100755 --- a/include/mtp_db.h +++ b/include/mtp_db.h @@ -30,7 +30,7 @@ #define MTP_DB_TABLE "mtp_object_info" mtp_error_e mtp_db_init(void); -mtp_error_e mtp_db_get_object_info(int device_handle, int object_handle, mtp_object_info** object_info); +mtp_error_e mtp_db_get_object_info(int mtp_device, int object_handle, mtp_object_info** object_info); mtp_error_e mtp_db_deinit(void); #endif diff --git a/include/mtp_gdbus.h b/include/mtp_gdbus.h index a740ff1..2811fb1 100755 --- a/include/mtp_gdbus.h +++ b/include/mtp_gdbus.h @@ -21,6 +21,7 @@ #include #include "mtp.h" +#include "mtp_private.h" #include "mtp_gdbuslib.h" #define MTP_DBUS_SERVICE "org.tizen.mtp" diff --git a/include/mtp_gdbus_manager.h b/include/mtp_gdbus_manager.h index 9c9699c..ea2eaf4 100755 --- a/include/mtp_gdbus_manager.h +++ b/include/mtp_gdbus_manager.h @@ -20,17 +20,17 @@ #include "mtp_gdbus.h" mtp_error_e mtp_gdbus_manager_initialize(void); -mtp_error_e mtp_gdbus_manager_get_device_list(mtp_device_list **dev_list); -mtp_error_e mtp_gdbus_manager_get_device_handle(int bus_location, - int *device_handle); -mtp_error_e mtp_gdbus_manager_get_storage_ids(int device_handle, - int **storage_ids, int *storage_num); -mtp_error_e mtp_gdbus_manager_get_object_handles(int device_handle, - int storage_id, int format, int parent_object_handle, int **object_handles, int *object_num); -mtp_error_e mtp_gdbus_manager_delete_object(int device_handle, int object_handle); -mtp_error_e mtp_gdbus_manager_get_object(int device_handle, +mtp_error_e mtp_gdbus_manager_get_raw_devices(mtp_raw_device ***raw_devices, int *device_count); +mtp_error_e mtp_gdbus_manager_get_device(int bus_location, int device_number, + int *mtp_device); +mtp_error_e mtp_gdbus_manager_get_storages(int mtp_device, + int **mtp_storages, int *storage_num); +mtp_error_e mtp_gdbus_manager_get_object_handles(int mtp_device, + int mtp_storage, int format, int parent_object_handle, int **object_handles, int *object_num); +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_thumbnail(int device_handle, +mtp_error_e mtp_gdbus_manager_get_thumbnail(int mtp_device, int object_handle, char *dest_path); mtp_error_e mtp_gdbus_manager_set_event_cb(mtp_event_cb callback, void *user_data); mtp_error_e mtp_gdbus_manager_unset_event_cb(); diff --git a/include/mtp_gdbus_objectinfo.h b/include/mtp_gdbus_objectinfo.h index 3c5930f..421704d 100755 --- a/include/mtp_gdbus_objectinfo.h +++ b/include/mtp_gdbus_objectinfo.h @@ -22,9 +22,9 @@ void mtp_gdbus_objectinfo_proxy_init(void); void mtp_gdbus_objectinfo_proxy_deinit(void); -int mtp_gdbus_objectinfo_get_property(int device_handle, +int mtp_gdbus_objectinfo_get_property(int mtp_device, int object_handle, int property, int *property_value); -int mtp_gdbus_objectinfo_get_property_string(int device_handle, +int mtp_gdbus_objectinfo_get_property_string(int mtp_device, int object_handle, int property, char **property_value); #endif diff --git a/include/mtp_gdbus_storageinfo.h b/include/mtp_gdbus_storageinfo.h index c4e90a3..f335e1f 100755 --- a/include/mtp_gdbus_storageinfo.h +++ b/include/mtp_gdbus_storageinfo.h @@ -22,15 +22,15 @@ void mtp_gdbus_storageinfo_proxy_init(void); void mtp_gdbus_storageinfo_proxy_deinit(void); -mtp_error_e mtp_gdbus_storageinfo_get_description(int device_handle, - int storage_id, char **description); -mtp_error_e mtp_gdbus_storageinfo_get_freespace(int device_handle, - int storage_id, guint64 *freespace); -mtp_error_e mtp_gdbus_storageinfo_get_maxcapacity(int device_handle, - int storage_id, guint64 *maxcapacity); -mtp_error_e mtp_gdbus_storageinfo_get_storagetype(int device_handle, - int storage_id, int *storagetype); -mtp_error_e mtp_gdbus_storageinfo_get_volumeidentifier(int device_handle, - int storage_id, char **volumeidentifier); +mtp_error_e mtp_gdbus_storageinfo_get_description(int mtp_device, + int mtp_storage, char **description); +mtp_error_e mtp_gdbus_storageinfo_get_freespace(int mtp_device, + int mtp_storage, guint64 *freespace); +mtp_error_e mtp_gdbus_storageinfo_get_maxcapacity(int mtp_device, + int mtp_storage, guint64 *maxcapacity); +mtp_error_e mtp_gdbus_storageinfo_get_storagetype(int mtp_device, + int mtp_storage, int *storagetype); +mtp_error_e mtp_gdbus_storageinfo_get_volumeidentifier(int mtp_device, + int mtp_storage, char **volumeidentifier); #endif diff --git a/include/mtp_internal.h b/include/mtp_internal.h index 0702f5a..71a0d1d 100755 --- a/include/mtp_internal.h +++ b/include/mtp_internal.h @@ -49,7 +49,9 @@ typedef struct _mtp_object_info { }mtp_object_info; /* internal api */ -MTP_API int mtp_objectinfo_get_object_info(int device_handle, int object_handle, mtp_object_info **object_info); +int mtp_objectinfo_get_object_info(int mtp_device, int object_handle, mtp_object_info **object_info); + +int mtp_delete_object(mtp_device_h mtp_device, mtp_object_h object_handle); #ifdef __cplusplus } diff --git a/include/mtp_private.h b/include/mtp_private.h new file mode 100755 index 0000000..cb4075a --- /dev/null +++ b/include/mtp_private.h @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __MTP_PRIVATE_H__ +#define __MTP_PRIVATE_H__ + +typedef struct _mtp_raw_device { + int bus_location; + int device_number; + char *model_name; + int dev_count; +} mtp_raw_device; + +#define CHECK_SUPPORTED() \ +do { \ + { \ + if (__is_mtp_supported() == false) { \ + return MTP_ERROR_NOT_SUPPORTED; \ + } \ + } \ +} while (0); + +#define CHECK_ACTIVATED() \ +do { \ + { \ + if (__is_mtp_activated() == false) { \ + return MTP_ERROR_NOT_ACTIVATED; \ + } \ + } \ +} while (0); + +typedef enum { + MTP_PROPERTY_ASSOCIATION_DESC = 1, + MTP_PROPERTY_ASSOCIATION_TYPE, + MTP_PROPERTY_SIZE, + MTP_PROPERTY_DATA_CREATED, + MTP_PROPERTY_DATA_MODIFIED, + MTP_PROPERTY_FORMAT, + MTP_PROPERTY_IMAGE_BIT_DEPTH, + MTP_PROPERTY_IMAGE_FIX_WIDTH, + MTP_PROPERTY_IMAGE_FIX_HEIGHT, + MTP_PROPERTY_PARENT_OBJECT_HANDLE, + MTP_PROPERTY_STORAGE, + MTP_PROPERTY_THUMBNAIL_SIZE, + MTP_PROPERTY_THUMBNAIL_FORMAT, + MTP_PROPERTY_THUMBNAIL_WIDTH, + MTP_PROPERTY_THUMBNAIL_HEIGHT, + MTP_PROPERTY_FILENAME, + MTP_PROPERTY_KEYWORDS +} mtp_property_e; + +#endif diff --git a/packaging/capi-network-mtp.spec b/packaging/capi-network-mtp.spec index e03c530..d3271c5 100755 --- a/packaging/capi-network-mtp.spec +++ b/packaging/capi-network-mtp.spec @@ -1,6 +1,6 @@ Name: capi-network-mtp Summary: A MTP library in Native API -Version: 1.2.4 +Version: 1.3.0 Release: 1 Group: Network & Connectivity/Other License: Apache-2.0 diff --git a/src/mtp.c b/src/mtp.c index 3ce3e87..03357dc 100755 --- a/src/mtp.c +++ b/src/mtp.c @@ -26,15 +26,13 @@ #include "mtp_internal.h" #include "mtp_db.h" #include "mtp_debug.h" +#include "mtp_private.h" #include "mtp_gdbus_manager.h" #include "mtp_gdbus_deviceinfo.h" #include "mtp_gdbus_storageinfo.h" #include "mtp_gdbus_objectinfo.h" -int ref_count = 0; -bool __is_initialized = false; - #define MTP_LOCK \ do { \ pthread_mutex_lock(&mutex); \ @@ -59,43 +57,8 @@ do { \ MTP_UNLOCK; \ } while (0); -#define CHECK_SUPPORTED() \ -do { \ - { \ - if (__is_mtp_supported() == false) { \ - return MTP_ERROR_NOT_SUPPORTED; \ - } \ - } \ -} while (0); - -#define CHECK_ACTIVATED() \ -do { \ - { \ - if (__is_mtp_activated() == false) { \ - return MTP_ERROR_NOT_ACTIVATED; \ - } \ - } \ -} while (0); - -typedef enum { - MTP_PROPERTY_ASSOCIATION_DESC = 1, - MTP_PROPERTY_ASSOCIATION_TYPE, - MTP_PROPERTY_SIZE, - MTP_PROPERTY_DATA_CREATED, - MTP_PROPERTY_DATA_MODIFIED, - MTP_PROPERTY_FORMAT, - MTP_PROPERTY_IMAGE_FIX_DEPTH, - MTP_PROPERTY_IMAGE_FIX_WIDTH, - MTP_PROPERTY_IMAGE_FIX_HEIGHT, - MTP_PROPERTY_PARENT_OBJECT_HANDLE, - MTP_PROPERTY_STORAGE_ID, - MTP_PROPERTY_THUMBNAIL_SIZE, - MTP_PROPERTY_THUMBNAIL_FORMAT, - MTP_PROPERTY_THUMBNAIL_WIDTH, - MTP_PROPERTY_THUMBNAIL_HEIGHT, - MTP_PROPERTY_FILENAME, - MTP_PROPERTY_KEYWORDS -} mtp_property_e; +int ref_count = 0; +bool __is_initialized = false; static bool __is_mtp_supported() { @@ -136,7 +99,7 @@ int mtp_initialize(void) return ret; } -int mtp_get_device_list(mtp_device_list **dev_list) +int mtp_get_raw_devices(mtp_raw_device_h **raw_devices, int *device_count) { int ret = MTP_ERROR_NONE; @@ -147,17 +110,117 @@ int mtp_get_device_list(mtp_device_list **dev_list) CHECK_SUPPORTED(); CHECK_INIT(); CHECK_ACTIVATED(); + cond_expr_ret(device_count == NULL, MTP_ERROR_INVALID_PARAMETER); /* precondition check end */ + *device_count = 0; + + ret = mtp_gdbus_manager_get_raw_devices((mtp_raw_device ***)raw_devices, device_count); + + _END(); + + return ret; +} + +int mtp_get_bus_location(mtp_raw_device_h raw_device, int *bus_location) +{ + int ret = MTP_ERROR_NONE; + + _BEGIN(); + + /* precondition check start */ + + CHECK_SUPPORTED(); + CHECK_INIT(); + cond_expr_ret(raw_device == NULL, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(bus_location == NULL, MTP_ERROR_INVALID_PARAMETER); + + /* precondition check end */ + + *bus_location = ((mtp_raw_device *)raw_device)->bus_location; + + _END(); + + return ret; +} + +int mtp_get_device_number(mtp_raw_device_h raw_device, int *device_number) +{ + int ret = MTP_ERROR_NONE; + + _BEGIN(); + + /* precondition check start */ + + CHECK_SUPPORTED(); + CHECK_INIT(); + cond_expr_ret(raw_device == NULL, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(device_number == NULL, MTP_ERROR_INVALID_PARAMETER); + + /* precondition check end */ + + *device_number = ((mtp_raw_device *)raw_device)->device_number; + + _END(); + + return ret; +} + +int mtp_get_device_name(mtp_raw_device_h raw_device, char **model_name) +{ + int ret = MTP_ERROR_NONE; + + /* precondition check start */ + + CHECK_SUPPORTED(); + CHECK_INIT(); + cond_expr_ret(raw_device == NULL, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(model_name == NULL, MTP_ERROR_INVALID_PARAMETER); + + /* precondition check end */ + + *model_name = g_strdup(((mtp_raw_device *)raw_device)->model_name); + + return ret; +} + +int mtp_destroy_raw_devices(mtp_raw_device_h *raw_devices) +{ + int i; + int ret = MTP_ERROR_NONE; + int dev_count; + mtp_raw_device *first_device = (mtp_raw_device *)raw_devices[0]; + + _BEGIN(); + + /* precondition check start */ + + CHECK_SUPPORTED(); + cond_expr_ret(raw_devices == NULL, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(first_device == NULL, MTP_ERROR_INVALID_PARAMETER); + + /* precondition check end */ + dev_count = first_device->dev_count; + if (dev_count <= 0 || dev_count > 6) + return MTP_ERROR_INVALID_PARAMETER; + + for (i = 0; i < dev_count; i++) { + mtp_raw_device *r_device = (mtp_raw_device *)raw_devices[i]; + + if (r_device != NULL && r_device->model_name != NULL) { + free(r_device->model_name); + free(r_device); + } + } - ret = mtp_gdbus_manager_get_device_list(dev_list); + free(raw_devices); _END(); return ret; } -int mtp_get_device_handle(int bus_location, int *device_handle) +int mtp_get_device(int bus_location, int device_number, int *mtp_device) { int ret = MTP_ERROR_NONE; @@ -172,16 +235,16 @@ int mtp_get_device_handle(int bus_location, int *device_handle) /* precondition check end */ - ret = mtp_gdbus_manager_get_device_handle(bus_location, device_handle); + ret = mtp_gdbus_manager_get_device(bus_location, device_number, mtp_device); - TC_PRT("mtp_handle %d", *device_handle); + TC_PRT("mtp_device %d", *mtp_device); _END(); return ret; } -int mtp_get_storage_ids(int device_handle, int **storage_ids, int *storage_num) +int mtp_get_storages(int mtp_device, int **mtp_storages, int* storage_num) { int ret = MTP_ERROR_NONE; @@ -192,11 +255,11 @@ int mtp_get_storage_ids(int device_handle, int **storage_ids, int *storage_num) CHECK_SUPPORTED(); CHECK_INIT(); CHECK_ACTIVATED(); - cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER); /* precondition check end */ - ret = mtp_gdbus_manager_get_storage_ids(device_handle, storage_ids, storage_num); + ret = mtp_gdbus_manager_get_storages(mtp_device, mtp_storages, storage_num); TC_PRT("storage number %d", *storage_num); @@ -205,8 +268,8 @@ int mtp_get_storage_ids(int device_handle, int **storage_ids, int *storage_num) return ret; } -int mtp_get_object_handles(int device_handle, int storage_id, int format, - int parent_object_handle, int **object_handles, int *object_num) +int mtp_get_object_handles(int mtp_device, int mtp_storage, mtp_filetype_e file_type, + int parent, int **object_handles, int* object_num) { int ret = MTP_ERROR_NONE; @@ -217,20 +280,20 @@ int mtp_get_object_handles(int device_handle, int storage_id, int format, CHECK_SUPPORTED(); CHECK_INIT(); CHECK_ACTIVATED(); - cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); - cond_expr_ret(storage_id == 0, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(mtp_storage == 0, MTP_ERROR_INVALID_PARAMETER); /* precondition check end */ - ret = mtp_gdbus_manager_get_object_handles(device_handle, - storage_id, format, parent_object_handle, object_handles, object_num); + ret = mtp_gdbus_manager_get_object_handles(mtp_device, + mtp_storage, file_type, parent, object_handles, object_num); _END(); return ret; } -int mtp_delete_object(int device_handle, int object_handle) +int mtp_delete_object(int mtp_device, int object_handle) { int ret = MTP_ERROR_NONE; @@ -241,19 +304,19 @@ int mtp_delete_object(int device_handle, int object_handle) CHECK_SUPPORTED(); CHECK_INIT(); CHECK_ACTIVATED(); - cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER); cond_expr_ret(object_handle == 0, MTP_ERROR_INVALID_PARAMETER); /* precondition check end */ - ret = mtp_gdbus_manager_delete_object(device_handle, object_handle); + ret = mtp_gdbus_manager_delete_object(mtp_device, object_handle); _END(); return ret; } -int mtp_get_object(int device_handle, int object_handle, char *dest_path) +int mtp_get_object(int mtp_device, int object_handle, char *dest_path) { int ret = MTP_ERROR_NONE; @@ -264,19 +327,19 @@ int mtp_get_object(int device_handle, int object_handle, char *dest_path) CHECK_SUPPORTED(); CHECK_INIT(); CHECK_ACTIVATED(); - cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER); cond_expr_ret(dest_path == NULL, MTP_ERROR_INVALID_PARAMETER); /* precondition check end */ - ret = mtp_gdbus_manager_get_object(device_handle, object_handle, dest_path); + ret = mtp_gdbus_manager_get_object(mtp_device, object_handle, dest_path); _END(); return ret; } -int mtp_get_thumbnail(int device_handle, int object_handle, char *dest_path) +int mtp_get_thumbnail(int mtp_device, int object_handle, char *dest_path) { int ret = MTP_ERROR_NONE; @@ -287,12 +350,12 @@ int mtp_get_thumbnail(int device_handle, int object_handle, char *dest_path) CHECK_SUPPORTED(); CHECK_INIT(); CHECK_ACTIVATED(); - cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER); cond_expr_ret(dest_path == NULL, MTP_ERROR_INVALID_PARAMETER); /* precondition check end */ - ret = mtp_gdbus_manager_get_thumbnail(device_handle, object_handle, dest_path); + ret = mtp_gdbus_manager_get_thumbnail(mtp_device, object_handle, dest_path); _END(); @@ -371,7 +434,7 @@ int mtp_deinitialize(void) } /* Device Info */ -int mtp_deviceinfo_get_manufacturername(int device_handle, char **manufacturername) +int mtp_deviceinfo_get_manufacturer_name(int mtp_device, char **manufacturer_name) { int ret = MTP_ERROR_NONE; @@ -382,20 +445,20 @@ int mtp_deviceinfo_get_manufacturername(int device_handle, char **manufacturerna CHECK_SUPPORTED(); CHECK_INIT(); CHECK_ACTIVATED(); - cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER); /* precondition check end */ - ret = mtp_gdbus_deviceinfo_get_manufacturername(device_handle, manufacturername); + ret = mtp_gdbus_deviceinfo_get_manufacturername(mtp_device, manufacturer_name); - TC_PRT("manufacturername %s", *manufacturername); + TC_PRT("manufacturername %s", *manufacturer_name); _END(); return ret; } -int mtp_deviceinfo_get_modelname(int device_handle, char **modelname) +int mtp_deviceinfo_get_model_name(int mtp_device, char **model_name) { int ret = MTP_ERROR_NONE; @@ -406,20 +469,20 @@ int mtp_deviceinfo_get_modelname(int device_handle, char **modelname) CHECK_SUPPORTED(); CHECK_INIT(); CHECK_ACTIVATED(); - cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER); /* precondition check end */ - ret = mtp_gdbus_deviceinfo_get_modelname(device_handle, modelname); + ret = mtp_gdbus_deviceinfo_get_modelname(mtp_device, model_name); - TC_PRT("modelname %s", *modelname); + TC_PRT("modelname %s", *model_name); _END(); return ret; } -int mtp_deviceinfo_get_serialnumber(int device_handle, char **serialnumber) +int mtp_deviceinfo_get_serial_number(int mtp_device, char **serial_number) { int ret = MTP_ERROR_NONE; @@ -430,20 +493,20 @@ int mtp_deviceinfo_get_serialnumber(int device_handle, char **serialnumber) CHECK_SUPPORTED(); CHECK_INIT(); CHECK_ACTIVATED(); - cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER); /* precondition check end */ - ret = mtp_gdbus_deviceinfo_get_serialnumber(device_handle, serialnumber); + ret = mtp_gdbus_deviceinfo_get_serialnumber(mtp_device, serial_number); - TC_PRT("serialnumber %s", *serialnumber); + TC_PRT("serialnumber %s", *serial_number); _END(); return ret; } -int mtp_deviceinfo_get_deviceversion(int device_handle, char **deviceversion) +int mtp_deviceinfo_get_device_version(int mtp_device, char **device_version) { int ret = MTP_ERROR_NONE; @@ -454,13 +517,13 @@ int mtp_deviceinfo_get_deviceversion(int device_handle, char **deviceversion) CHECK_SUPPORTED(); CHECK_INIT(); CHECK_ACTIVATED(); - cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER); /* precondition check end */ - ret = mtp_gdbus_deviceinfo_get_deviceversion(device_handle, deviceversion); + ret = mtp_gdbus_deviceinfo_get_deviceversion(mtp_device, device_version); - TC_PRT("deviceversion %s", *deviceversion); + TC_PRT("deviceversion %s", *device_version); _END(); @@ -468,7 +531,7 @@ int mtp_deviceinfo_get_deviceversion(int device_handle, char **deviceversion) } /* Storage Info */ -int mtp_storageinfo_get_description(int device_handle, int storage_id, char **description) +int mtp_storageinfo_get_description(int mtp_device, int mtp_storage, char **description) { int ret = MTP_ERROR_NONE; @@ -479,12 +542,12 @@ int mtp_storageinfo_get_description(int device_handle, int storage_id, char **de CHECK_SUPPORTED(); CHECK_INIT(); CHECK_ACTIVATED(); - cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); - cond_expr_ret(storage_id == 0, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(mtp_storage == 0, MTP_ERROR_INVALID_PARAMETER); /* precondition check end */ - ret = mtp_gdbus_storageinfo_get_description(device_handle, storage_id, description); + ret = mtp_gdbus_storageinfo_get_description(mtp_device, mtp_storage, description); TC_PRT("description %s", *description); @@ -493,7 +556,7 @@ int mtp_storageinfo_get_description(int device_handle, int storage_id, char **de return ret; } -int mtp_storageinfo_get_freespace(int device_handle, int storage_id, unsigned long long *freespace) +int mtp_storageinfo_get_free_space(int mtp_device, int mtp_storage, unsigned long long *free_space) { int ret = MTP_ERROR_NONE; @@ -504,21 +567,21 @@ int mtp_storageinfo_get_freespace(int device_handle, int storage_id, unsigned lo CHECK_SUPPORTED(); CHECK_INIT(); CHECK_ACTIVATED(); - cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); - cond_expr_ret(storage_id == 0, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(mtp_storage == 0, MTP_ERROR_INVALID_PARAMETER); /* precondition check end */ - ret = mtp_gdbus_storageinfo_get_freespace(device_handle, storage_id, (guint64 *)freespace); + ret = mtp_gdbus_storageinfo_get_freespace(mtp_device, mtp_storage, (guint64 *)free_space); - TC_PRT("freespace %llu", *freespace); + TC_PRT("freespace %llu", *free_space); _END(); return ret; } -int mtp_storageinfo_get_maxcapacity(int device_handle, int storage_id, unsigned long long *maxcapacity) +int mtp_storageinfo_get_max_capacity(int mtp_device, int mtp_storage, unsigned long long *max_capacity) { int ret = MTP_ERROR_NONE; @@ -529,21 +592,21 @@ int mtp_storageinfo_get_maxcapacity(int device_handle, int storage_id, unsigned CHECK_SUPPORTED(); CHECK_INIT(); CHECK_ACTIVATED(); - cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); - cond_expr_ret(storage_id == 0, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(mtp_storage == 0, MTP_ERROR_INVALID_PARAMETER); /* precondition check end */ - ret = mtp_gdbus_storageinfo_get_maxcapacity(device_handle, storage_id, (guint64 *)maxcapacity); + ret = mtp_gdbus_storageinfo_get_maxcapacity(mtp_device, mtp_storage, (guint64 *)max_capacity); - TC_PRT("maxcapacity %llu", *maxcapacity); + TC_PRT("maxcapacity %llu", *max_capacity); _END(); return ret; } -int mtp_storageinfo_get_storagetype(int device_handle, int storage_id, int *storagetype) +int mtp_storageinfo_get_storage_type(int mtp_device, int mtp_storage, int *storage_type) { int ret = MTP_ERROR_NONE; @@ -554,21 +617,21 @@ int mtp_storageinfo_get_storagetype(int device_handle, int storage_id, int *stor CHECK_SUPPORTED(); CHECK_INIT(); CHECK_ACTIVATED(); - cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); - cond_expr_ret(storage_id == 0, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(mtp_storage == 0, MTP_ERROR_INVALID_PARAMETER); /* precondition check end */ - ret = mtp_gdbus_storageinfo_get_storagetype(device_handle, storage_id, storagetype); + ret = mtp_gdbus_storageinfo_get_storagetype(mtp_device, mtp_storage, storage_type); - TC_PRT("storagetype %d", *storagetype); + TC_PRT("storagetype %d", *storage_type); _END(); return ret; } -int mtp_storageinfo_get_volumeidentifier(int device_handle, int storage_id, char **volumeidentifier) +int mtp_storageinfo_get_volume_identifier(int mtp_device, int mtp_storage, char **volume_identifier) { int ret = MTP_ERROR_NONE; @@ -579,14 +642,14 @@ int mtp_storageinfo_get_volumeidentifier(int device_handle, int storage_id, char CHECK_SUPPORTED(); CHECK_INIT(); CHECK_ACTIVATED(); - cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); - cond_expr_ret(storage_id == 0, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(mtp_storage == 0, MTP_ERROR_INVALID_PARAMETER); /* precondition check end */ - ret = mtp_gdbus_storageinfo_get_volumeidentifier(device_handle, storage_id, volumeidentifier); + ret = mtp_gdbus_storageinfo_get_volumeidentifier(mtp_device, mtp_storage, volume_identifier); - TC_PRT("volumeidentifier %s", *volumeidentifier); + TC_PRT("volumeidentifier %s", *volume_identifier); _END(); @@ -594,7 +657,7 @@ int mtp_storageinfo_get_volumeidentifier(int device_handle, int storage_id, char } /* Object Info */ -int mtp_objectinfo_get_parent_object_handle(int device_handle, int object_handle, +int mtp_objectinfo_get_parent_object_handle(int mtp_device, int object_handle, int *parent_object_handle) { int ret = MTP_ERROR_NONE; @@ -606,11 +669,11 @@ int mtp_objectinfo_get_parent_object_handle(int device_handle, int object_handle CHECK_SUPPORTED(); CHECK_INIT(); CHECK_ACTIVATED(); - cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER); /* precondition check end */ - ret = mtp_gdbus_objectinfo_get_property(device_handle, + ret = mtp_gdbus_objectinfo_get_property(mtp_device, object_handle, MTP_PROPERTY_PARENT_OBJECT_HANDLE, parent_object_handle); TC_PRT("parent object id %d", *parent_object_handle); @@ -620,8 +683,8 @@ int mtp_objectinfo_get_parent_object_handle(int device_handle, int object_handle return ret; } -int mtp_objectinfo_get_storage_id(int device_handle, int object_handle, - int *storage_id) +int mtp_objectinfo_get_storage(int mtp_device, int object_handle, + int *mtp_storage) { int ret = MTP_ERROR_NONE; @@ -632,19 +695,19 @@ int mtp_objectinfo_get_storage_id(int device_handle, int object_handle, CHECK_SUPPORTED(); CHECK_INIT(); CHECK_ACTIVATED(); - cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER); /* precondition check end */ - ret = mtp_gdbus_objectinfo_get_property(device_handle, - object_handle, MTP_PROPERTY_STORAGE_ID, storage_id); + ret = mtp_gdbus_objectinfo_get_property(mtp_device, + object_handle, MTP_PROPERTY_STORAGE, mtp_storage); _END(); return ret; } -int mtp_objectinfo_get_association_desc(int device_handle, +int mtp_objectinfo_get_association_desc(int mtp_device, int object_handle, int *asso_desc) { int ret = MTP_ERROR_NONE; @@ -656,11 +719,11 @@ int mtp_objectinfo_get_association_desc(int device_handle, CHECK_SUPPORTED(); CHECK_INIT(); CHECK_ACTIVATED(); - cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER); /* precondition check end */ - ret = mtp_gdbus_objectinfo_get_property(device_handle, + ret = mtp_gdbus_objectinfo_get_property(mtp_device, object_handle, MTP_PROPERTY_ASSOCIATION_DESC, asso_desc); _END(); @@ -668,7 +731,7 @@ int mtp_objectinfo_get_association_desc(int device_handle, return ret; } -int mtp_objectinfo_get_association_type(int device_handle, +int mtp_objectinfo_get_association_type(int mtp_device, int object_handle, int *asso_type) { int ret = MTP_ERROR_NONE; @@ -680,11 +743,11 @@ int mtp_objectinfo_get_association_type(int device_handle, CHECK_SUPPORTED(); CHECK_INIT(); CHECK_ACTIVATED(); - cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER); /* precondition check end */ - ret = mtp_gdbus_objectinfo_get_property(device_handle, + ret = mtp_gdbus_objectinfo_get_property(mtp_device, object_handle, MTP_PROPERTY_ASSOCIATION_TYPE, asso_type); _END(); @@ -692,7 +755,7 @@ int mtp_objectinfo_get_association_type(int device_handle, return ret; } -int mtp_objectinfo_get_size(int device_handle, int object_handle, int *size) +int mtp_objectinfo_get_size(int mtp_device, int object_handle, int *size) { int ret = MTP_ERROR_NONE; @@ -703,11 +766,11 @@ int mtp_objectinfo_get_size(int device_handle, int object_handle, int *size) CHECK_SUPPORTED(); CHECK_INIT(); CHECK_ACTIVATED(); - cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER); /* precondition check end */ - ret = mtp_gdbus_objectinfo_get_property(device_handle, + ret = mtp_gdbus_objectinfo_get_property(mtp_device, object_handle, MTP_PROPERTY_SIZE, size); _END(); @@ -715,7 +778,7 @@ int mtp_objectinfo_get_size(int device_handle, int object_handle, int *size) return ret; } -int mtp_objectinfo_get_data_created(int device_handle, +int mtp_objectinfo_get_data_created(int mtp_device, int object_handle, int *data_created) { int ret = MTP_ERROR_NONE; @@ -727,11 +790,11 @@ int mtp_objectinfo_get_data_created(int device_handle, CHECK_SUPPORTED(); CHECK_INIT(); CHECK_ACTIVATED(); - cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER); /* precondition check end */ - ret = mtp_gdbus_objectinfo_get_property(device_handle, + ret = mtp_gdbus_objectinfo_get_property(mtp_device, object_handle, MTP_PROPERTY_DATA_CREATED, data_created); _END(); @@ -739,7 +802,7 @@ int mtp_objectinfo_get_data_created(int device_handle, return ret; } -int mtp_objectinfo_get_data_modified(int device_handle, +int mtp_objectinfo_get_data_modified(int mtp_device, int object_handle, int *data_modified) { int ret = MTP_ERROR_NONE; @@ -751,11 +814,11 @@ int mtp_objectinfo_get_data_modified(int device_handle, CHECK_SUPPORTED(); CHECK_INIT(); CHECK_ACTIVATED(); - cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER); /* precondition check end */ - ret = mtp_gdbus_objectinfo_get_property(device_handle, + ret = mtp_gdbus_objectinfo_get_property(mtp_device, object_handle, MTP_PROPERTY_DATA_MODIFIED, data_modified); _END(); @@ -763,7 +826,7 @@ int mtp_objectinfo_get_data_modified(int device_handle, return ret; } -int mtp_objectinfo_get_format(int device_handle, int object_handle, int *format) +int mtp_objectinfo_get_file_type(int mtp_device, int object_handle, mtp_filetype_e *file_type) { int ret = MTP_ERROR_NONE; @@ -774,19 +837,19 @@ int mtp_objectinfo_get_format(int device_handle, int object_handle, int *format) CHECK_SUPPORTED(); CHECK_INIT(); CHECK_ACTIVATED(); - cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER); /* precondition check end */ - ret = mtp_gdbus_objectinfo_get_property(device_handle, - object_handle, MTP_PROPERTY_FORMAT, format); + ret = mtp_gdbus_objectinfo_get_property(mtp_device, + object_handle, MTP_PROPERTY_FORMAT, (int*)file_type); _END(); return ret; } -int mtp_objectinfo_get_image_pix_depth(int device_handle, +int mtp_objectinfo_get_image_bit_depth(int mtp_device, int object_handle, int *depth) { int ret = MTP_ERROR_NONE; @@ -798,19 +861,19 @@ int mtp_objectinfo_get_image_pix_depth(int device_handle, CHECK_SUPPORTED(); CHECK_INIT(); CHECK_ACTIVATED(); - cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER); /* precondition check end */ - ret = mtp_gdbus_objectinfo_get_property(device_handle, - object_handle, MTP_PROPERTY_IMAGE_FIX_DEPTH, depth); + ret = mtp_gdbus_objectinfo_get_property(mtp_device, + object_handle, MTP_PROPERTY_IMAGE_BIT_DEPTH, depth); _END(); return ret; } -int mtp_objectinfo_get_image_pix_width(int device_handle, +int mtp_objectinfo_get_image_pix_width(int mtp_device, int object_handle, int *width) { int ret = MTP_ERROR_NONE; @@ -822,11 +885,11 @@ int mtp_objectinfo_get_image_pix_width(int device_handle, CHECK_SUPPORTED(); CHECK_INIT(); CHECK_ACTIVATED(); - cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER); /* precondition check end */ - ret = mtp_gdbus_objectinfo_get_property(device_handle, + ret = mtp_gdbus_objectinfo_get_property(mtp_device, object_handle, MTP_PROPERTY_IMAGE_FIX_WIDTH, width); _END(); @@ -834,7 +897,7 @@ int mtp_objectinfo_get_image_pix_width(int device_handle, return ret; } -int mtp_objectinfo_get_image_pix_height(int device_handle, +int mtp_objectinfo_get_image_pix_height(int mtp_device, int object_handle, int *height) { int ret = MTP_ERROR_NONE; @@ -846,11 +909,11 @@ int mtp_objectinfo_get_image_pix_height(int device_handle, CHECK_SUPPORTED(); CHECK_INIT(); CHECK_ACTIVATED(); - cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER); /* precondition check end */ - ret = mtp_gdbus_objectinfo_get_property(device_handle, + ret = mtp_gdbus_objectinfo_get_property(mtp_device, object_handle, MTP_PROPERTY_IMAGE_FIX_HEIGHT, height); _END(); @@ -858,7 +921,7 @@ int mtp_objectinfo_get_image_pix_height(int device_handle, return ret; } -int mtp_objectinfo_get_thumbnail_size(int device_handle, +int mtp_objectinfo_get_thumbnail_size(int mtp_device, int object_handle, int *size) { int ret = MTP_ERROR_NONE; @@ -870,11 +933,11 @@ int mtp_objectinfo_get_thumbnail_size(int device_handle, CHECK_SUPPORTED(); CHECK_INIT(); CHECK_ACTIVATED(); - cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER); /* precondition check end */ - ret = mtp_gdbus_objectinfo_get_property(device_handle, + ret = mtp_gdbus_objectinfo_get_property(mtp_device, object_handle, MTP_PROPERTY_THUMBNAIL_SIZE, size); _END(); @@ -882,8 +945,8 @@ int mtp_objectinfo_get_thumbnail_size(int device_handle, return ret; } -int mtp_objectinfo_get_thumbnail_format(int device_handle, - int object_handle, int *format) +int mtp_objectinfo_get_thumbnail_file_type(int mtp_device, + int object_handle, mtp_filetype_e *file_type) { int ret = MTP_ERROR_NONE; @@ -894,19 +957,19 @@ int mtp_objectinfo_get_thumbnail_format(int device_handle, CHECK_SUPPORTED(); CHECK_INIT(); CHECK_ACTIVATED(); - cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER); /* precondition check end */ - ret = mtp_gdbus_objectinfo_get_property(device_handle, - object_handle, MTP_PROPERTY_THUMBNAIL_FORMAT, format); + ret = mtp_gdbus_objectinfo_get_property(mtp_device, + object_handle, MTP_PROPERTY_THUMBNAIL_FORMAT, (int*)file_type); _END(); return ret; } -int mtp_objectinfo_get_thumbnail_pix_height(int device_handle, +int mtp_objectinfo_get_thumbnail_pix_height(int mtp_device, int object_handle, int *height) { int ret = MTP_ERROR_NONE; @@ -918,11 +981,11 @@ int mtp_objectinfo_get_thumbnail_pix_height(int device_handle, CHECK_SUPPORTED(); CHECK_INIT(); CHECK_ACTIVATED(); - cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER); /* precondition check end */ - ret = mtp_gdbus_objectinfo_get_property(device_handle, + ret = mtp_gdbus_objectinfo_get_property(mtp_device, object_handle, MTP_PROPERTY_THUMBNAIL_HEIGHT, height); _END(); @@ -930,7 +993,7 @@ int mtp_objectinfo_get_thumbnail_pix_height(int device_handle, return ret; } -int mtp_objectinfo_get_thumbnail_pix_width(int device_handle, +int mtp_objectinfo_get_thumbnail_pix_width(int mtp_device, int object_handle, int *width) { int ret = MTP_ERROR_NONE; @@ -942,11 +1005,11 @@ int mtp_objectinfo_get_thumbnail_pix_width(int device_handle, CHECK_SUPPORTED(); CHECK_INIT(); CHECK_ACTIVATED(); - cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER); /* precondition check end */ - ret = mtp_gdbus_objectinfo_get_property(device_handle, + ret = mtp_gdbus_objectinfo_get_property(mtp_device, object_handle, MTP_PROPERTY_THUMBNAIL_WIDTH, width); _END(); @@ -954,7 +1017,7 @@ int mtp_objectinfo_get_thumbnail_pix_width(int device_handle, return ret; } -int mtp_objectinfo_get_filename(int device_handle, +int mtp_objectinfo_get_file_name(int mtp_device, int object_handle, char **filename) { int ret = MTP_ERROR_NONE; @@ -966,11 +1029,11 @@ int mtp_objectinfo_get_filename(int device_handle, CHECK_SUPPORTED(); CHECK_INIT(); CHECK_ACTIVATED(); - cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER); /* precondition check end */ - ret = mtp_gdbus_objectinfo_get_property_string(device_handle, + ret = mtp_gdbus_objectinfo_get_property_string(mtp_device, object_handle, MTP_PROPERTY_FILENAME, filename); _END(); @@ -978,7 +1041,7 @@ int mtp_objectinfo_get_filename(int device_handle, return ret; } -int mtp_objectinfo_get_keywords(int device_handle, +int mtp_objectinfo_get_keywords(int mtp_device, int object_handle, char **keywords) { int ret = MTP_ERROR_NONE; @@ -990,11 +1053,11 @@ int mtp_objectinfo_get_keywords(int device_handle, CHECK_SUPPORTED(); CHECK_INIT(); CHECK_ACTIVATED(); - cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER); /* precondition check end */ - ret = mtp_gdbus_objectinfo_get_property_string(device_handle, + ret = mtp_gdbus_objectinfo_get_property_string(mtp_device, object_handle, MTP_PROPERTY_KEYWORDS, keywords); _END(); @@ -1002,7 +1065,7 @@ int mtp_objectinfo_get_keywords(int device_handle, return ret; } -int mtp_objectinfo_get_object_info(int device_handle, +int mtp_objectinfo_get_object_info(int mtp_device, int object_handle, mtp_object_info **object_info) { int ret = MTP_ERROR_NONE; @@ -1014,11 +1077,11 @@ int mtp_objectinfo_get_object_info(int device_handle, CHECK_SUPPORTED(); CHECK_INIT(); CHECK_ACTIVATED(); - cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER); /* precondition check end */ - ret = mtp_db_get_object_info(device_handle, object_handle, object_info); + ret = mtp_db_get_object_info(mtp_device, object_handle, object_info); _END(); diff --git a/src/mtp_db.c b/src/mtp_db.c index fe4b685..ddd1e2e 100755 --- a/src/mtp_db.c +++ b/src/mtp_db.c @@ -49,7 +49,7 @@ mtp_error_e mtp_db_init() return ret; } -mtp_error_e mtp_db_get_object_info(int device_handle, int object_handle, mtp_object_info** object_info) +mtp_error_e mtp_db_get_object_info(int mtp_device, int object_handle, mtp_object_info** object_info) { int ret = MTP_ERROR_NONE; int sql_ret; @@ -65,8 +65,8 @@ mtp_error_e mtp_db_get_object_info(int device_handle, int object_handle, mtp_obj *object_info = (mtp_object_info *)malloc(sizeof(mtp_object_info)); - sql = sqlite3_mprintf("SELECT * FROM %s WHERE device_handle=%d and object_handle=%d;", - MTP_DB_TABLE, device_handle, object_handle); + sql = sqlite3_mprintf("SELECT * FROM %s WHERE mtp_device=%d and object_handle=%d;", + MTP_DB_TABLE, mtp_device, object_handle); if (sql != NULL && (*object_info) != NULL) { sql_ret = sqlite3_prepare_v2(db, sql, strlen(sql), &stmt, NULL); diff --git a/src/mtp_gdbus_deviceinfo.c b/src/mtp_gdbus_deviceinfo.c index eff5d5b..f6e0da4 100755 --- a/src/mtp_gdbus_deviceinfo.c +++ b/src/mtp_gdbus_deviceinfo.c @@ -34,88 +34,88 @@ void mtp_gdbus_deviceinfo_proxy_deinit(void) deviceinfo_proxy = NULL; } -mtp_error_e mtp_gdbus_deviceinfo_get_manufacturername(int device_handle, char **manufacturername) +mtp_error_e mtp_gdbus_deviceinfo_get_manufacturername(int mtp_device, char **manufacturername) { mtp_error_e result = MTP_ERROR_NONE; GError *error = NULL; if (deviceinfo_proxy == NULL) - return MTP_ERROR_GENERAL; + return MTP_ERROR_NOT_COMM_INITIALIZED; if (mtp_gdbuslib_deviceinfo_call_get_manufacturername_sync( deviceinfo_proxy, - device_handle, + mtp_device, manufacturername, &result, NULL, &error) == FALSE) { - result = MTP_ERROR_IO_ERROR; + result = MTP_ERROR_COMM_ERROR; g_error_free(error); } return result; } -mtp_error_e mtp_gdbus_deviceinfo_get_modelname(int device_handle, char **modelname) +mtp_error_e mtp_gdbus_deviceinfo_get_modelname(int mtp_device, char **modelname) { mtp_error_e result = MTP_ERROR_NONE; GError *error = NULL; if (deviceinfo_proxy == NULL) - return MTP_ERROR_GENERAL; + return MTP_ERROR_NOT_COMM_INITIALIZED; if (mtp_gdbuslib_deviceinfo_call_get_modelname_sync( deviceinfo_proxy, - device_handle, + mtp_device, modelname, &result, NULL, &error) == FALSE) { - result = MTP_ERROR_IO_ERROR; + result = MTP_ERROR_COMM_ERROR; g_error_free(error); } return result; } -mtp_error_e mtp_gdbus_deviceinfo_get_serialnumber(int device_handle, char **serialnumber) +mtp_error_e mtp_gdbus_deviceinfo_get_serialnumber(int mtp_device, char **serialnumber) { mtp_error_e result = MTP_ERROR_NONE; GError *error = NULL; if (deviceinfo_proxy == NULL) - return MTP_ERROR_GENERAL; + return MTP_ERROR_NOT_COMM_INITIALIZED; if (mtp_gdbuslib_deviceinfo_call_get_serialnumber_sync( deviceinfo_proxy, - device_handle, + mtp_device, serialnumber, &result, NULL, &error) == FALSE) { - result = MTP_ERROR_IO_ERROR; + result = MTP_ERROR_COMM_ERROR; g_error_free(error); } return result; } -mtp_error_e mtp_gdbus_deviceinfo_get_deviceversion(int device_handle, char **deviceversion) +mtp_error_e mtp_gdbus_deviceinfo_get_deviceversion(int mtp_device, char **deviceversion) { mtp_error_e result = MTP_ERROR_NONE; GError *error = NULL; if (deviceinfo_proxy == NULL) - return MTP_ERROR_GENERAL; + return MTP_ERROR_NOT_COMM_INITIALIZED; if (mtp_gdbuslib_deviceinfo_call_get_deviceversion_sync( deviceinfo_proxy, - device_handle, + mtp_device, deviceversion, &result, NULL, &error) == FALSE) { - result = MTP_ERROR_IO_ERROR; + result = MTP_ERROR_COMM_ERROR; g_error_free(error); } diff --git a/src/mtp_gdbus_manager.c b/src/mtp_gdbus_manager.c index ca4b603..63be494 100755 --- a/src/mtp_gdbus_manager.c +++ b/src/mtp_gdbus_manager.c @@ -14,6 +14,12 @@ * limitations under the License. */ +#include +#include +#include +#include +#include + #include "mtp_gdbus_manager.h" #include "mtp_gdbus_objectinfo.h" #include "mtp_gdbus_deviceinfo.h" @@ -76,12 +82,12 @@ mtp_error_e mtp_gdbus_manager_initialize(void) mtp_gdbus_objectinfo_proxy_init(); if (manager_proxy == NULL) - result = MTP_ERROR_GENERAL; + result = MTP_ERROR_NOT_COMM_INITIALIZED; return result; } -mtp_error_e mtp_gdbus_manager_get_device_list(mtp_device_list **dev_list) +mtp_error_e mtp_gdbus_manager_get_raw_devices(mtp_raw_device ***raw_devices, int *device_count) { int dev_count; GVariant *va = NULL; @@ -89,41 +95,45 @@ mtp_error_e mtp_gdbus_manager_get_device_list(mtp_device_list **dev_list) GError *error = NULL; if (manager_proxy == NULL) - return MTP_ERROR_GENERAL; + return MTP_ERROR_NOT_COMM_INITIALIZED; - if (mtp_gdbuslib_manager_call_get_device_list_sync( + if (mtp_gdbuslib_manager_call_get_raw_devices_sync( manager_proxy, &dev_count, &va, &result, NULL, &error) == FALSE) { - result = MTP_ERROR_IO_ERROR; + result = MTP_ERROR_COMM_ERROR; g_error_free(error); return result; } + *device_count = dev_count; + if (dev_count != 0 && (g_variant_n_children(va) == dev_count)) { GVariantIter *iter = NULL, *iter_row = NULL; GVariant *key_value; const gchar *key; guint i = 0; - *dev_list = g_new(mtp_device_list, 1); - (*dev_list)->device_num = dev_count; - (*dev_list)->devices = g_new(mtp_device, dev_count); + *raw_devices = (mtp_raw_device **)malloc(sizeof(mtp_raw_device*) * 1); + **raw_devices = (mtp_raw_device *)malloc(sizeof(mtp_raw_device) * *device_count); g_variant_get(va, "aa{sv}", &iter); while (g_variant_iter_next(iter, "a{sv}", &iter_row)) { while (g_variant_iter_loop(iter_row, "{sv}", &key, &key_value)) { if (g_strcmp0(key, "model_name") == 0) { - ((*dev_list)->devices)[i].model_name = + (**raw_devices)[i].model_name = g_strdup(g_variant_get_string(key_value, NULL)); } else if (g_strcmp0(key, "bus_location") == 0) { - ((*dev_list)->devices)[i].bus_location = g_variant_get_int32(key_value); + (**raw_devices)[i].bus_location = g_variant_get_int32(key_value); + } else if (g_strcmp0(key, "device_number") == 0) { + (**raw_devices)[i].device_number = g_variant_get_int32(key_value); } } + (**raw_devices)[i].dev_count = dev_count; i++; g_variant_iter_free(iter_row); } @@ -137,22 +147,23 @@ mtp_error_e mtp_gdbus_manager_get_device_list(mtp_device_list **dev_list) return result; } -mtp_error_e mtp_gdbus_manager_get_device_handle(int bus_location, int *device_handle) +mtp_error_e mtp_gdbus_manager_get_device(int bus_location, int device_number, int *mtp_device) { mtp_error_e result = MTP_ERROR_NONE; GError *error = NULL; if (manager_proxy == NULL) - return MTP_ERROR_GENERAL; + return MTP_ERROR_NOT_COMM_INITIALIZED; - if (mtp_gdbuslib_manager_call_get_device_handle_sync( + if (mtp_gdbuslib_manager_call_get_device_sync( manager_proxy, bus_location, - device_handle, + device_number, + mtp_device, &result, NULL, &error) == FALSE) { - result = MTP_ERROR_IO_ERROR; + result = MTP_ERROR_COMM_ERROR; g_error_free(error); } @@ -160,25 +171,25 @@ mtp_error_e mtp_gdbus_manager_get_device_handle(int bus_location, int *device_ha return result; } -mtp_error_e mtp_gdbus_manager_get_storage_ids(int device_handle, - int **storage_ids, int *storage_num) +mtp_error_e mtp_gdbus_manager_get_storages(int mtp_device, + int **mtp_storages, int *storage_num) { GVariant *va = NULL; mtp_error_e result = MTP_ERROR_NONE; GError *error = NULL; if (manager_proxy == NULL) - return MTP_ERROR_GENERAL; + return MTP_ERROR_NOT_COMM_INITIALIZED; - if (mtp_gdbuslib_manager_call_get_storage_ids_sync( + if (mtp_gdbuslib_manager_call_get_storages_sync( manager_proxy, - device_handle, + mtp_device, storage_num, &va, &result, NULL, &error) == FALSE) { - result = MTP_ERROR_IO_ERROR; + result = MTP_ERROR_COMM_ERROR; g_error_free(error); return result; @@ -190,13 +201,13 @@ mtp_error_e mtp_gdbus_manager_get_storage_ids(int device_handle, const gchar *key; guint i = 0; - *storage_ids = g_new(int, *storage_num); + *mtp_storages = g_new(int, *storage_num); g_variant_get(va, "aa{sv}", &iter); while (g_variant_iter_next(iter, "a{sv}", &iter_row)) { while (g_variant_iter_loop(iter_row, "{sv}", &key, &key_value)) { - if (g_strcmp0(key, "storage_id") == 0) - (*storage_ids)[i] = g_variant_get_int32(key_value); + if (g_strcmp0(key, "mtp_storage") == 0) + (*mtp_storages)[i] = g_variant_get_int32(key_value); } i++; g_variant_iter_free(iter_row); @@ -209,20 +220,20 @@ mtp_error_e mtp_gdbus_manager_get_storage_ids(int device_handle, return result; } -mtp_error_e mtp_gdbus_manager_get_object_handles(int device_handle, - int storage_id, int format, int parent_object_handle, int **object_handles, int *object_num) +mtp_error_e mtp_gdbus_manager_get_object_handles(int mtp_device, + int mtp_storage, int format, int parent_object_handle, int **object_handles, int *object_num) { GVariant *va = NULL; mtp_error_e result = MTP_ERROR_NONE; GError *error = NULL; if (manager_proxy == NULL) - return MTP_ERROR_GENERAL; + return MTP_ERROR_NOT_COMM_INITIALIZED; if (mtp_gdbuslib_manager_call_get_object_handles_sync( manager_proxy, - device_handle, - storage_id, + mtp_device, + mtp_storage, format, parent_object_handle, object_num, @@ -230,7 +241,7 @@ mtp_error_e mtp_gdbus_manager_get_object_handles(int device_handle, &result, NULL, &error) == FALSE) { - result = MTP_ERROR_IO_ERROR; + result = MTP_ERROR_COMM_ERROR; g_error_free(error); return result; @@ -261,23 +272,23 @@ mtp_error_e mtp_gdbus_manager_get_object_handles(int device_handle, return result; } -mtp_error_e mtp_gdbus_manager_delete_object(int device_handle, +mtp_error_e mtp_gdbus_manager_delete_object(int mtp_device, int object_handle) { mtp_error_e result = MTP_ERROR_NONE; GError *error = NULL; if (manager_proxy == NULL) - return MTP_ERROR_GENERAL; + return MTP_ERROR_NOT_COMM_INITIALIZED; if (mtp_gdbuslib_manager_call_delete_object_sync( manager_proxy, - device_handle, + mtp_device, object_handle, &result, NULL, &error) == FALSE) { - result = MTP_ERROR_IO_ERROR; + result = MTP_ERROR_COMM_ERROR; g_error_free(error); } @@ -285,24 +296,24 @@ mtp_error_e mtp_gdbus_manager_delete_object(int device_handle, return result; } -mtp_error_e mtp_gdbus_manager_get_object(int device_handle, +mtp_error_e mtp_gdbus_manager_get_object(int mtp_device, int object_handle, char *dest_path) { mtp_error_e result = MTP_ERROR_NONE; GError *error = NULL; if (manager_proxy == NULL) - return MTP_ERROR_GENERAL; + return MTP_ERROR_NOT_COMM_INITIALIZED; if (mtp_gdbuslib_manager_call_get_object_sync( manager_proxy, - device_handle, + mtp_device, object_handle, dest_path, &result, NULL, &error) == FALSE) { - result = MTP_ERROR_IO_ERROR; + result = MTP_ERROR_COMM_ERROR; g_error_free(error); } @@ -310,24 +321,24 @@ mtp_error_e mtp_gdbus_manager_get_object(int device_handle, return result; } -mtp_error_e mtp_gdbus_manager_get_thumbnail(int device_handle, +mtp_error_e mtp_gdbus_manager_get_thumbnail(int mtp_device, int object_handle, char *dest_path) { mtp_error_e result = MTP_ERROR_NONE; GError *error = NULL; if (manager_proxy == NULL) - return MTP_ERROR_GENERAL; + return MTP_ERROR_NOT_COMM_INITIALIZED; if (mtp_gdbuslib_manager_call_get_thumbnail_sync( manager_proxy, - device_handle, + mtp_device, object_handle, dest_path, &result, NULL, &error) == FALSE) { - result = MTP_ERROR_IO_ERROR; + result = MTP_ERROR_COMM_ERROR; g_error_free(error); } diff --git a/src/mtp_gdbus_objectinfo.c b/src/mtp_gdbus_objectinfo.c index 38077fb..c5382ff 100755 --- a/src/mtp_gdbus_objectinfo.c +++ b/src/mtp_gdbus_objectinfo.c @@ -34,50 +34,50 @@ void mtp_gdbus_objectinfo_proxy_deinit(void) objectinfo_proxy = NULL; } -int mtp_gdbus_objectinfo_get_property(int device_handle, +int mtp_gdbus_objectinfo_get_property(int mtp_device, int object_handle, int property, int *property_value) { mtp_error_e result = MTP_ERROR_NONE; GError *error = NULL; if (objectinfo_proxy == NULL) - return MTP_ERROR_GENERAL; + return MTP_ERROR_NOT_COMM_INITIALIZED; if (mtp_gdbuslib_objectinfo_call_get_property_sync( objectinfo_proxy, - device_handle, + mtp_device, object_handle, property, property_value, &result, NULL, &error) == FALSE) { - result = MTP_ERROR_IO_ERROR; + result = MTP_ERROR_COMM_ERROR; g_error_free(error); } return result; } -int mtp_gdbus_objectinfo_get_property_string(int device_handle, +int mtp_gdbus_objectinfo_get_property_string(int mtp_device, int object_handle, int property, char **property_value) { mtp_error_e result = MTP_ERROR_NONE; GError *error = NULL; if (objectinfo_proxy == NULL) - return MTP_ERROR_GENERAL; + return MTP_ERROR_NOT_COMM_INITIALIZED; if (mtp_gdbuslib_objectinfo_call_get_property_string_sync( objectinfo_proxy, - device_handle, + mtp_device, object_handle, property, property_value, &result, NULL, &error) == FALSE) { - result = MTP_ERROR_IO_ERROR; + result = MTP_ERROR_COMM_ERROR; g_error_free(error); } diff --git a/src/mtp_gdbus_storageinfo.c b/src/mtp_gdbus_storageinfo.c index b8ab9f6..db5f020 100755 --- a/src/mtp_gdbus_storageinfo.c +++ b/src/mtp_gdbus_storageinfo.c @@ -34,120 +34,120 @@ void mtp_gdbus_storageinfo_proxy_deinit(void) storageinfo_proxy = NULL; } -mtp_error_e mtp_gdbus_storageinfo_get_description(int device_handle, - int storage_id, char **description) +mtp_error_e mtp_gdbus_storageinfo_get_description(int mtp_device, + int mtp_storage, char **description) { mtp_error_e result = MTP_ERROR_NONE; GError *error = NULL; if (storageinfo_proxy == NULL) - return MTP_ERROR_GENERAL; + return MTP_ERROR_NOT_COMM_INITIALIZED; if (mtp_gdbuslib_storageinfo_call_get_description_sync( storageinfo_proxy, - device_handle, - storage_id, + mtp_device, + mtp_storage, description, &result, NULL, &error) == FALSE) { - result = MTP_ERROR_IO_ERROR; + result = MTP_ERROR_COMM_ERROR; g_error_free(error); } return result; } -mtp_error_e mtp_gdbus_storageinfo_get_freespace(int device_handle, - int storage_id, guint64 *freespace) +mtp_error_e mtp_gdbus_storageinfo_get_freespace(int mtp_device, + int mtp_storage, guint64 *freespace) { mtp_error_e result = MTP_ERROR_NONE; GError *error = NULL; if (storageinfo_proxy == NULL) - return MTP_ERROR_GENERAL; + return MTP_ERROR_NOT_COMM_INITIALIZED; if (mtp_gdbuslib_storageinfo_call_get_free_space_sync( storageinfo_proxy, - device_handle, - storage_id, + mtp_device, + mtp_storage, freespace, &result, NULL, &error) == FALSE) { - result = MTP_ERROR_IO_ERROR; + result = MTP_ERROR_COMM_ERROR; g_error_free(error); } return result; } -mtp_error_e mtp_gdbus_storageinfo_get_maxcapacity(int device_handle, - int storage_id, guint64 *maxcapacity) +mtp_error_e mtp_gdbus_storageinfo_get_maxcapacity(int mtp_device, + int mtp_storage, guint64 *maxcapacity) { mtp_error_e result = MTP_ERROR_NONE; GError *error = NULL; if (storageinfo_proxy == NULL) - return MTP_ERROR_GENERAL; + return MTP_ERROR_NOT_COMM_INITIALIZED; if (mtp_gdbuslib_storageinfo_call_get_max_capacity_sync( storageinfo_proxy, - device_handle, - storage_id, + mtp_device, + mtp_storage, maxcapacity, &result, NULL, &error) == FALSE) { - result = MTP_ERROR_IO_ERROR; + result = MTP_ERROR_COMM_ERROR; g_error_free(error); } return result; } -mtp_error_e mtp_gdbus_storageinfo_get_storagetype(int device_handle, - int storage_id, int *storagetype) +mtp_error_e mtp_gdbus_storageinfo_get_storagetype(int mtp_device, + int mtp_storage, int *storagetype) { mtp_error_e result = MTP_ERROR_NONE; GError *error = NULL; if (storageinfo_proxy == NULL) - return MTP_ERROR_GENERAL; + return MTP_ERROR_NOT_COMM_INITIALIZED; if (mtp_gdbuslib_storageinfo_call_get_storage_type_sync( storageinfo_proxy, - device_handle, - storage_id, + mtp_device, + mtp_storage, storagetype, &result, NULL, &error) == FALSE) { - result = MTP_ERROR_IO_ERROR; + result = MTP_ERROR_COMM_ERROR; g_error_free(error); } return result; } -mtp_error_e mtp_gdbus_storageinfo_get_volumeidentifier(int device_handle, - int storage_id, char **volumeidentifier) +mtp_error_e mtp_gdbus_storageinfo_get_volumeidentifier(int mtp_device, + int mtp_storage, char **volumeidentifier) { mtp_error_e result = MTP_ERROR_NONE; GError *error = NULL; if (storageinfo_proxy == NULL) - return MTP_ERROR_GENERAL; + return MTP_ERROR_NOT_COMM_INITIALIZED; if (mtp_gdbuslib_storageinfo_call_get_volume_identifier_sync( storageinfo_proxy, - device_handle, - storage_id, + mtp_device, + mtp_storage, volumeidentifier, &result, NULL, &error) == FALSE) { - result = MTP_ERROR_IO_ERROR; + result = MTP_ERROR_COMM_ERROR; g_error_free(error); } diff --git a/src/mtp_gdbuslib.xml b/src/mtp_gdbuslib.xml index 45afda8..aaca563 100755 --- a/src/mtp_gdbuslib.xml +++ b/src/mtp_gdbuslib.xml @@ -4,28 +4,29 @@ - - - + + + - + - + + - - + + - + - - + + @@ -34,21 +35,21 @@ - + - + - + @@ -60,75 +61,75 @@ - + - + - + - + - - + + - - + + - - + + - - + + - - + + - + - + diff --git a/test/mtp_unit_test.c b/test/mtp_unit_test.c index 6488e98..266a0d2 100755 --- a/test/mtp_unit_test.c +++ b/test/mtp_unit_test.c @@ -18,14 +18,10 @@ #define BEGIN() TC_PRT("BEGIN >>>>"); #define END() TC_PRT("END <<<<"); -static int handle; -static mtp_device_list* dev_list; - -static int strg_handle = 0; -static int* strg_list; - -static int obj_handle = 0; -static int* obj_list; +static mtp_device_h mtp_device; +static mtp_storage_h mtp_storage = 0; +static mtp_object_h mtp_object = 0; +static mtp_object_h* mtp_objects; int obj_count; GMainLoop *main_loop = NULL; @@ -144,20 +140,28 @@ int manager_test_initialize(void) return ret; } -int manager_test_get_device_list(void) +int manager_test_get_raw_devices(void) { int ret = 0; int i; + mtp_raw_device_h *raw_devices = NULL; + int device_count; + BEGIN(); - ret = mtp_get_device_list(&dev_list); + ret = mtp_get_raw_devices(&raw_devices, &device_count); + TC_PRT("ret[%d]: device_num[%d]", ret, device_count); if (ret == MTP_ERROR_NONE) { - TC_PRT("ret[%d]: device_num[%d]", ret, dev_list->device_num); - - for (i = 0; i < dev_list->device_num; i++) { - TC_PRT("device bus_location[%d] model_name[%s]", - dev_list->devices[i].bus_location, dev_list->devices[i].model_name); + for (i = 0; i < device_count; i++) { + int bus_location; + int device_number; + char *device_name = NULL; + mtp_get_bus_location(raw_devices[i], &bus_location); + mtp_get_device_number(raw_devices[i], &device_number); + mtp_get_device_name(raw_devices[i], &device_name); + TC_PRT("device bus_location[%d], dev_no [%d], model_name[%s]", + bus_location, device_number, device_name); } } else { TC_PRT("get device list failed, ret[%d]", ret); @@ -167,64 +171,94 @@ int manager_test_get_device_list(void) return ret; } -int manager_test_get_device_handle(void) +int manager_test_get_device(void) { int ret = 0; - int input_int = 0; int bus_location = 0; + int device_number = 0; + int device_count; + mtp_raw_device_h *raw_devices = NULL; + BEGIN(); - if (dev_list->device_num == 0) { + ret = mtp_get_raw_devices(&raw_devices, &device_count); + + if (ret != MTP_ERROR_NONE) { + TC_PRT("mtp_get_raw_devices is failed!!!"); + return -1; + } + + if (device_count == 0) { TC_PRT("device is not exist!!!"); END(); return -1; } - input_int = dev_list->devices[0].bus_location; + TC_PRT("Select first device"); - if (dev_list->device_num > 1) { - if (!test_get_user_int("==> Input Bus_location No :", &input_int)) - TC_PRT("select first bus[%d]", input_int); - } + mtp_get_bus_location(raw_devices[0], &bus_location); + mtp_get_device_number(raw_devices[0], &device_number); - bus_location = input_int; + TC_PRT("bus location : %d, device_number : %d", bus_location, device_number); - ret = mtp_get_device_handle(bus_location, &handle); - TC_PRT("ret[%d]: 1st device handle[%d]", ret, handle); + ret = mtp_get_device(bus_location, device_number, &mtp_device); + TC_PRT("ret[%d]: 1st mtp device [%d]", ret, mtp_device); END(); return ret; } -int manager_test_get_storage_ids(void) +int manager_test_get_storages(void) { - int ret = 0; int i; - int count = 0; - int input_int = 0; - BEGIN(); + int ret = 0; + int bus_location = 0; + int device_number = 0; + int device_count; + int storage_count; + mtp_raw_device_h *raw_devices = NULL; + mtp_storage_h *mtp_storages = NULL; - ret = mtp_get_storage_ids(handle, &strg_list, &count); - TC_PRT("ret[%d]: storage_num[%d]", ret, count); + ret = mtp_get_raw_devices(&raw_devices, &device_count); - if (count == 0) { - TC_PRT("storage is not exist!!!"); + if (ret != MTP_ERROR_NONE) { + TC_PRT("mtp_get_raw_devices is failed!!!"); + return -1; + } + + if (device_count == 0) { + TC_PRT("device is not exist!!!"); END(); return -1; } - for (i = 0; i < count; i++) - TC_PRT("storage handle[%d]", strg_list[i]); + TC_PRT("Select first device"); + + mtp_get_bus_location(raw_devices[0], &bus_location); + mtp_get_device_number(raw_devices[0], &device_number); - input_int = strg_list[0]; + TC_PRT("bus location : %d, device_number : %d", bus_location, device_number); - if (count > 1) { - if (!test_get_user_int("==> Input Storage Handle :", &input_int)) - TC_PRT("select first storage[%d]", strg_list[0]); + ret = mtp_get_device(bus_location, device_number, &mtp_device); + TC_PRT("ret[%d]: 1st mtp device [%d]", ret, mtp_device); + + ret = mtp_get_storages(mtp_device, &mtp_storages, &storage_count); + TC_PRT("ret[%d]: storage_count[%d]", ret, storage_count); + + if (storage_count == 0) { + TC_PRT("storage is not exist!!!"); + END(); + return -1; } - strg_handle = input_int; - TC_PRT("selected storage handle[%d]", strg_handle); + ret = mtp_destroy_raw_devices(raw_devices); + TC_PRT("ret[%d]: mtp_destroy_raw_devices", ret); + + + for (i = 0; i < storage_count; i++) + TC_PRT("mtp storage %d [%d]", i, mtp_storages[i]); + + mtp_storage = mtp_storages[0]; END(); return ret; @@ -239,35 +273,35 @@ int manager_test_get_object_handles(void) int folder_count = 0; int *file_list; int file_count = 0; - int format = MTP_FILETYPE_FOLDER; + mtp_filetype_e filetype = MTP_FILETYPE_FOLDER; char *filename = NULL; int folder_max = 0; int file_max = 0; int list_max = 0; BEGIN(); - ret = mtp_get_object_handles(handle, strg_handle, MTP_FILETYPE_FOLDER, obj_handle, &folder_list, &folder_count); + ret = mtp_get_object_handles(mtp_device, mtp_storage, MTP_FILETYPE_FOLDER, mtp_object, &folder_list, &folder_count); TC_PRT("ret[%d]: total folder_count[%d]", ret, folder_count); folder_max = (folder_count < TEST_LIST_MAX) ? folder_count : TEST_LIST_MAX; for (i = 0; i < folder_max; i++) { - ret = mtp_objectinfo_get_filename(handle, folder_list[i], &filename); - ret = mtp_objectinfo_get_format(handle, folder_list[i], &format); - TC_PRT("ret[%d]: object id[%d] - filename[%s], format[%s]", - ret, folder_list[i], filename, test_filetype_to_string(format)); + ret = mtp_objectinfo_get_file_name(mtp_device, folder_list[i], &filename); + ret = mtp_objectinfo_get_file_type(mtp_device, folder_list[i], &filetype); + TC_PRT("ret[%d]: object id[%d] - filename[%s], filetype[%s]", + ret, folder_list[i], filename, test_filetype_to_string(filetype)); } - ret = mtp_get_object_handles(handle, strg_handle, MTP_FILETYPE_JPEG, obj_handle, &file_list, &file_count); + ret = mtp_get_object_handles(mtp_device, mtp_storage, MTP_FILETYPE_JPEG, mtp_object, &file_list, &file_count); TC_PRT("ret[%d]: total file_count[%d]", ret, file_count); file_max = (file_count < TEST_LIST_MAX) ? file_count : TEST_LIST_MAX; for (i = 0; i < file_max; i++) { - ret = mtp_objectinfo_get_filename(handle, file_list[i], &filename); - ret = mtp_objectinfo_get_format(handle, file_list[i], &format); - TC_PRT("ret[%d]: object id[%d] - filename[%s], format[%s]", - ret, file_list[i], filename, test_filetype_to_string(format)); + ret = mtp_objectinfo_get_file_name(mtp_device, file_list[i], &filename); + ret = mtp_objectinfo_get_file_type(mtp_device, file_list[i], &filetype); + TC_PRT("ret[%d]: object id[%d] - filename[%s], filetype[%s]", + ret, file_list[i], filename, test_filetype_to_string(filetype)); } if (!test_get_user_int("==> Select Object Type(FOLDER:0, JPEG:14)" @@ -275,27 +309,27 @@ int manager_test_get_object_handles(void) TC_PRT("select default : folder[%d]", input_int); } - ret = mtp_get_object_handles(handle, strg_handle, input_int, obj_handle, &obj_list, &obj_count); + ret = mtp_get_object_handles(mtp_device, mtp_storage, input_int, mtp_object, &mtp_objects, &obj_count); TC_PRT("ret[%d]: total object_num[%d]", ret, 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_filename(handle, obj_list[i], &filename); - ret = mtp_objectinfo_get_format(handle, obj_list[i], &format); - TC_PRT("ret[%d]: object id[%d] - filename[%s], format[%s]", - ret, obj_list[i], filename, test_filetype_to_string(format)); + 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 (input_int == MTP_FILETYPE_FOLDER) { - if (!test_get_user_int("==> Input Object ID :", &obj_handle)) { - TC_PRT("invalid input !!![%d]", obj_handle); - obj_handle = 0; + if (!test_get_user_int("==> Input Object ID :", &mtp_object)) { + TC_PRT("invalid input !!![%d]", mtp_object); + mtp_object = 0; END(); return -1; } - TC_PRT("selected object id[%d]", obj_handle); + TC_PRT("selected object id[%d]", mtp_object); TC_PRT("===== Object List - Folder ====="); } else { TC_PRT("===== Object List - JPEG ====="); @@ -310,7 +344,7 @@ int manager_test_delete_object(void) int ret = 0; int i; int input_int = 0; - int format = MTP_FILETYPE_JPEG; + mtp_filetype_e filetype = MTP_FILETYPE_JPEG; char *filename = NULL; int list_max = 0; BEGIN(); @@ -320,10 +354,10 @@ int manager_test_delete_object(void) list_max = (obj_count < TEST_LIST_MAX) ? obj_count : TEST_LIST_MAX; for (i = 0; i < list_max; i++) { - ret = mtp_objectinfo_get_filename(handle, obj_list[i], &filename); - ret = mtp_objectinfo_get_format(handle, obj_list[i], &format); - TC_PRT("ret[%d]: object id[%d] - filename[%s], format[%s]", - ret, obj_list[i], filename, test_filetype_to_string(format)); + 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)) { @@ -332,7 +366,7 @@ int manager_test_delete_object(void) return -1; } - ret = mtp_delete_object(handle, input_int); + ret = mtp_delete_object(mtp_device, input_int); TC_PRT("ret[%d]: input id[%d]", ret, input_int); END(); @@ -344,7 +378,7 @@ int manager_test_get_object(void) int ret = 0; int i; int input_int = 0; - int format = MTP_FILETYPE_JPEG; + mtp_filetype_e filetype = MTP_FILETYPE_JPEG; char *filename = NULL; char filepath[100] = {0,}; int list_max = 0; @@ -355,10 +389,10 @@ int manager_test_get_object(void) list_max = (obj_count < TEST_LIST_MAX) ? obj_count : TEST_LIST_MAX; for (i = 0; i < list_max; i++) { - ret = mtp_objectinfo_get_filename(handle, obj_list[i], &filename); - ret = mtp_objectinfo_get_format(handle, obj_list[i], &format); - TC_PRT("ret[%d]: object id[%d] - filename[%s], format[%s]", - ret, obj_list[i], filename, test_filetype_to_string(format)); + 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)) { @@ -369,7 +403,7 @@ int manager_test_get_object(void) snprintf(filepath, 100, "/opt/usr/media/Downloads/JpegObject_%d.jpg", input_int); - ret = mtp_get_object(handle, input_int, filepath); + ret = mtp_get_object(mtp_device, input_int, filepath); TC_PRT("ret[%d]: input id[%d]", ret, input_int); END(); @@ -384,7 +418,7 @@ int manager_test_get_thumbnail(void) int input_int = 0; char input_str[50] = {0, }; char filepath[100] = {0,}; - int format = MTP_FILETYPE_JPEG; + mtp_filetype_e filetype = MTP_FILETYPE_JPEG; char *filename = NULL; int list_max = 0; BEGIN(); @@ -394,10 +428,10 @@ int manager_test_get_thumbnail(void) list_max = (obj_count < TEST_LIST_MAX) ? obj_count : TEST_LIST_MAX; for (i = 0; i < list_max; i++) { - ret = mtp_objectinfo_get_filename(handle, obj_list[i], &filename); - ret = mtp_objectinfo_get_format(handle, obj_list[i], &format); - TC_PRT("ret[%d]: object id[%d] - filename[%s], format[%s]", - ret, obj_list[i], filename, test_filetype_to_string(format)); + 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 JPEG ID :", &input_int)) { @@ -418,7 +452,7 @@ int manager_test_get_thumbnail(void) snprintf(filepath, 100, "/opt/usr/media/Downloads/%s_%d.jpg", input_str, input_int); - ret = mtp_get_thumbnail(handle, input_int, filepath); + ret = mtp_get_thumbnail(mtp_device, input_int, filepath); TC_PRT("ret[%d]: input jpeg id[%d], input file path[%s]", ret, input_int, filepath); END(); @@ -443,7 +477,7 @@ int deviceinfo_test_get_manufacturername(void) char *name = NULL; BEGIN(); - ret = mtp_deviceinfo_get_manufacturername(handle, &name); + ret = mtp_deviceinfo_get_manufacturer_name(mtp_device, &name); TC_PRT("ret[%d]: manufacturername[%s]", ret, name); END(); @@ -456,7 +490,7 @@ int deviceinfo_test_get_modelname(void) char *name = NULL; BEGIN(); - ret = mtp_deviceinfo_get_modelname(handle, &name); + ret = mtp_deviceinfo_get_model_name(mtp_device, &name); TC_PRT("ret[%d]: modelname[%s]", ret, name); END(); @@ -469,7 +503,7 @@ int deviceinfo_test_get_serialnumber(void) char *name = NULL; BEGIN(); - ret = mtp_deviceinfo_get_serialnumber(handle, &name); + ret = mtp_deviceinfo_get_serial_number(mtp_device, &name); TC_PRT("ret[%d]: serialnumber[%s]", ret, name); END(); @@ -482,7 +516,7 @@ int deviceinfo_test_get_deviceversion(void) char *name = NULL; BEGIN(); - ret = mtp_deviceinfo_get_deviceversion(handle, &name); + ret = mtp_deviceinfo_get_device_version(mtp_device, &name); TC_PRT("ret[%d]: deviceversion[%s]", ret, name); END(); @@ -496,7 +530,7 @@ int storageinfo_test_get_description(void) char *name = NULL; BEGIN(); - ret = mtp_storageinfo_get_description(handle, strg_handle, &name); + ret = mtp_storageinfo_get_description(mtp_device, mtp_storage, &name); TC_PRT("ret[%d]: description[%s]", ret, name); END(); @@ -509,7 +543,7 @@ int storageinfo_test_get_freespace(void) unsigned long long value = 0; BEGIN(); - ret = mtp_storageinfo_get_freespace(handle, strg_handle, &value); + ret = mtp_storageinfo_get_free_space(mtp_device, mtp_storage, &value); TC_PRT("ret[%d]: freespace[%llu]", ret, value); END(); @@ -522,7 +556,7 @@ int storageinfo_test_get_maxcapacity(void) unsigned long long value = 0; BEGIN(); - ret = mtp_storageinfo_get_maxcapacity(handle, strg_handle, &value); + ret = mtp_storageinfo_get_max_capacity(mtp_device, mtp_storage, &value); TC_PRT("ret[%d]: maxcapacity[%llu]", ret, value); END(); @@ -535,7 +569,7 @@ int storageinfo_test_get_storagetype(void) int value = 0; BEGIN(); - ret = mtp_storageinfo_get_storagetype(handle, strg_handle, &value); + ret = mtp_storageinfo_get_storage_type(mtp_device, mtp_storage, &value); TC_PRT("ret[%d]: storagetype[%d]", ret, value); END(); @@ -548,7 +582,7 @@ int storageinfo_test_get_volumeidentifier(void) char *name = NULL; BEGIN(); - ret = mtp_storageinfo_get_volumeidentifier(handle, strg_handle, &name); + ret = mtp_storageinfo_get_volume_identifier(mtp_device, mtp_storage, &name); TC_PRT("ret[%d]: volumeidentifier[%s]", ret, name); END(); @@ -566,8 +600,8 @@ int objectinfo_test_get_association_desc(void) list_max = (obj_count < TEST_LIST_MAX) ? obj_count : TEST_LIST_MAX; for (i = 0; i < list_max; i++) { - ret = mtp_objectinfo_get_association_desc(handle, obj_list[i], &value); - TC_PRT("ret[%d]: object id[%d] association_desc[%d]", ret, obj_list[i], value); + ret = mtp_objectinfo_get_association_desc(mtp_device, mtp_objects[i], &value); + TC_PRT("ret[%d]: object id[%d] association_desc[%d]", ret, mtp_objects[i], value); } END(); @@ -585,8 +619,8 @@ int objectinfo_test_get_association_type(void) list_max = (obj_count < TEST_LIST_MAX) ? obj_count : TEST_LIST_MAX; for (i = 0; i < list_max; i++) { - ret = mtp_objectinfo_get_association_type(handle, obj_list[i], &value); - TC_PRT("ret[%d]: object id[%d] association_type[%d]", ret, obj_list[i], value); + ret = mtp_objectinfo_get_association_type(mtp_device, mtp_objects[i], &value); + TC_PRT("ret[%d]: object id[%d] association_type[%d]", ret, mtp_objects[i], value); } END(); @@ -604,8 +638,8 @@ int objectinfo_test_get_size(void) list_max = (obj_count < TEST_LIST_MAX) ? obj_count : TEST_LIST_MAX; for (i = 0; i < list_max; i++) { - ret = mtp_objectinfo_get_size(handle, obj_list[i], &value); - TC_PRT("ret[%d]: object id[%d] size[%d]", ret, obj_list[i], value); + ret = mtp_objectinfo_get_size(mtp_device, mtp_objects[i], &value); + TC_PRT("ret[%d]: object id[%d] size[%d]", ret, mtp_objects[i], value); } END(); @@ -623,8 +657,8 @@ int objectinfo_test_get_parent_object_handle(void) list_max = (obj_count < TEST_LIST_MAX) ? obj_count : TEST_LIST_MAX; for (i = 0; i < list_max; i++) { - ret = mtp_objectinfo_get_parent_object_handle(handle, obj_list[i], &value); - TC_PRT("ret[%d]: object id[%d] parent_object_handle[%d]", ret, obj_list[i], value); + ret = mtp_objectinfo_get_parent_object_handle(mtp_device, mtp_objects[i], &value); + TC_PRT("ret[%d]: object id[%d] parent_object_handle[%d]", ret, mtp_objects[i], value); } END(); @@ -642,8 +676,8 @@ int objectinfo_test_get_storage_id(void) list_max = (obj_count < TEST_LIST_MAX) ? obj_count : TEST_LIST_MAX; for (i = 0; i < list_max; i++) { - ret = mtp_objectinfo_get_storage_id(handle, obj_list[i], &value); - TC_PRT("ret[%d]: object id[%d] storage_id[%d]", ret, obj_list[i], value); + ret = mtp_objectinfo_get_storage(mtp_device, mtp_objects[i], &value); + TC_PRT("ret[%d]: object id[%d] mtp_storage[%d]", ret, mtp_objects[i], value); } END(); @@ -661,8 +695,8 @@ int objectinfo_test_get_data_created(void) list_max = (obj_count < TEST_LIST_MAX) ? obj_count : TEST_LIST_MAX; for (i = 0; i < list_max; i++) { - ret = mtp_objectinfo_get_data_created(handle, obj_list[i], &value); - TC_PRT("ret[%d]: object id[%d] data_created[%d]", ret, obj_list[i], value); + ret = mtp_objectinfo_get_data_created(mtp_device, mtp_objects[i], &value); + TC_PRT("ret[%d]: object id[%d] mtp_device[%d]", ret, mtp_objects[i], value); } END(); @@ -680,34 +714,34 @@ int objectinfo_test_get_data_modified(void) list_max = (obj_count < TEST_LIST_MAX) ? obj_count : TEST_LIST_MAX; for (i = 0; i < list_max; i++) { - ret = mtp_objectinfo_get_data_modified(handle, obj_list[i], &value); - TC_PRT("ret[%d]: object id[%d] data_modified[%d]", ret, obj_list[i], value); + ret = mtp_objectinfo_get_data_modified(mtp_device, mtp_objects[i], &value); + TC_PRT("ret[%d]: object id[%d] data_modified[%d]", ret, mtp_objects[i], value); } END(); return ret; } -int objectinfo_test_get_format(void) +int objectinfo_test_get_file_type(void) { int i; int ret = 0; - int value = 0; + mtp_filetype_e value = 0; int list_max = 0; BEGIN(); list_max = (obj_count < TEST_LIST_MAX) ? obj_count : TEST_LIST_MAX; for (i = 0; i < list_max; i++) { - ret = mtp_objectinfo_get_format(handle, obj_list[i], &value); - TC_PRT("ret[%d]: object id[%d] format[%d]", ret, obj_list[i], value); + ret = mtp_objectinfo_get_file_type(mtp_device, mtp_objects[i], &value); + TC_PRT("ret[%d]: object id[%d] file type[%d]", ret, mtp_objects[i], value); } END(); return ret; } -int objectinfo_test_get_image_pix_depth(void) +int objectinfo_test_get_image_bit_depth(void) { int i; int ret = 0; @@ -718,8 +752,8 @@ int objectinfo_test_get_image_pix_depth(void) list_max = (obj_count < TEST_LIST_MAX) ? obj_count : TEST_LIST_MAX; for (i = 0; i < list_max; i++) { - ret = mtp_objectinfo_get_image_pix_depth(handle, obj_list[i], &value); - TC_PRT("ret[%d]: object id[%d] image_pix_depth[%d]", ret, obj_list[i], value); + ret = mtp_objectinfo_get_image_bit_depth(mtp_device, mtp_objects[i], &value); + TC_PRT("ret[%d]: object id[%d] image_bit_depth[%d]", ret, mtp_objects[i], value); } END(); @@ -737,8 +771,8 @@ int objectinfo_test_get_image_pix_width(void) list_max = (obj_count < TEST_LIST_MAX) ? obj_count : TEST_LIST_MAX; for (i = 0; i < list_max; i++) { - ret = mtp_objectinfo_get_image_pix_width(handle, obj_list[i], &value); - TC_PRT("ret[%d]: object id[%d] image_pix_width[%d]", ret, obj_list[i], value); + ret = mtp_objectinfo_get_image_pix_width(mtp_device, mtp_objects[i], &value); + TC_PRT("ret[%d]: object id[%d] image_pix_width[%d]", ret, mtp_objects[i], value); } END(); @@ -756,8 +790,8 @@ int objectinfo_test_get_image_pix_height(void) list_max = (obj_count < TEST_LIST_MAX) ? obj_count : TEST_LIST_MAX; for (i = 0; i < list_max; i++) { - ret = mtp_objectinfo_get_image_pix_height(handle, obj_list[i], &value); - TC_PRT("ret[%d]: object id[%d] image_pix_height[%d]", ret, obj_list[i], value); + ret = mtp_objectinfo_get_image_pix_height(mtp_device, mtp_objects[i], &value); + TC_PRT("ret[%d]: object id[%d] image_pix_height[%d]", ret, mtp_objects[i], value); } END(); @@ -775,27 +809,27 @@ int objectinfo_test_get_thumbnail_size(void) list_max = (obj_count < TEST_LIST_MAX) ? obj_count : TEST_LIST_MAX; for (i = 0; i < list_max; i++) { - ret = mtp_objectinfo_get_thumbnail_size(handle, obj_list[i], &value); - TC_PRT("ret[%d]: object id[%d] thumbnail_size[%d]", ret, obj_list[i], value); + ret = mtp_objectinfo_get_thumbnail_size(mtp_device, mtp_objects[i], &value); + TC_PRT("ret[%d]: object id[%d] thumbnail_size[%d]", ret, mtp_objects[i], value); } END(); return ret; } -int objectinfo_test_get_thumbnail_format(void) +int objectinfo_test_get_thumbnail_file_type(void) { int i; int ret = 0; - int value = 0; + mtp_filetype_e value = 0; int list_max = 0; BEGIN(); list_max = (obj_count < TEST_LIST_MAX) ? obj_count : TEST_LIST_MAX; for (i = 0; i < list_max; i++) { - ret = mtp_objectinfo_get_thumbnail_format(handle, obj_list[i], &value); - TC_PRT("ret[%d]: object id[%d] thumbnail_format[%d]", ret, obj_list[i], value); + ret = mtp_objectinfo_get_thumbnail_file_type(mtp_device, mtp_objects[i], &value); + TC_PRT("ret[%d]: object id[%d] thumbnail_format[%d]", ret, mtp_objects[i], value); } END(); @@ -813,8 +847,8 @@ int objectinfo_test_get_thumbnail_pix_height(void) list_max = (obj_count < TEST_LIST_MAX) ? obj_count : TEST_LIST_MAX; for (i = 0; i < list_max; i++) { - ret = mtp_objectinfo_get_thumbnail_pix_height(handle, obj_list[i], &value); - TC_PRT("ret[%d]: object id[%d] thumbnail_pix_height[%d]", ret, obj_list[i], value); + ret = mtp_objectinfo_get_thumbnail_pix_height(mtp_device, mtp_objects[i], &value); + TC_PRT("ret[%d]: object id[%d] thumbnail_pix_height[%d]", ret, mtp_objects[i], value); } END(); @@ -832,8 +866,8 @@ int objectinfo_test_get_thumbnail_pix_width(void) list_max = (obj_count < TEST_LIST_MAX) ? obj_count : TEST_LIST_MAX; for (i = 0; i < list_max; i++) { - ret = mtp_objectinfo_get_thumbnail_pix_width(handle, obj_list[i], &value); - TC_PRT("ret[%d]: object id[%d] thumbnail_pix_width[%d]", ret, obj_list[i], value); + ret = mtp_objectinfo_get_thumbnail_pix_width(mtp_device, mtp_objects[i], &value); + TC_PRT("ret[%d]: object id[%d] thumbnail_pix_width[%d]", ret, mtp_objects[i], value); } END(); @@ -851,8 +885,8 @@ int objectinfo_test_get_filename(void) list_max = (obj_count < TEST_LIST_MAX) ? obj_count : TEST_LIST_MAX; for (i = 0; i < list_max; i++) { - ret = mtp_objectinfo_get_filename(handle, obj_list[i], &value); - TC_PRT("ret[%d]: object id[%d] filename[%s]", ret, obj_list[i], value); + ret = mtp_objectinfo_get_file_name(mtp_device, mtp_objects[i], &value); + TC_PRT("ret[%d]: object id[%d] filename[%s]", ret, mtp_objects[i], value); } END(); @@ -870,8 +904,8 @@ int objectinfo_test_get_keywords(void) list_max = (obj_count < TEST_LIST_MAX) ? obj_count : TEST_LIST_MAX; for (i = 0; i < list_max; i++) { - ret = mtp_objectinfo_get_keywords(handle, obj_list[i], &value); - TC_PRT("ret[%d]: object id[%d] keywords[%s]", ret, obj_list[i], value); + ret = mtp_objectinfo_get_keywords(mtp_device, mtp_objects[i], &value); + TC_PRT("ret[%d]: object id[%d] keywords[%s]", ret, mtp_objects[i], value); } END(); @@ -882,7 +916,7 @@ int application_test_get_image_from_DCIM(void) { int ret = 0; int i; - int format = MTP_FILETYPE_FOLDER; + mtp_filetype_e filetype = MTP_FILETYPE_FOLDER; int *object_list; int object_count = 0; int *object_list2; @@ -895,7 +929,7 @@ int application_test_get_image_from_DCIM(void) BEGIN(); while (true) { - TC_PRT("storage_handle : %d", strg_handle); + TC_PRT("storage_handle : %d", mtp_storage); if (!test_get_user_int("==> 1. Select Object type (FOLDER:0, JPEG:14, BMP:17)" " - (Enter for skip) :", &input_object_id2)) { @@ -903,18 +937,18 @@ int application_test_get_image_from_DCIM(void) break; } - ret = mtp_get_object_handles(handle, (strg_handle > 0 ? strg_handle : 0), input_object_id2, selected_id, &object_list, &object_count); + ret = mtp_get_object_handles(mtp_device, (mtp_storage > 0 ? mtp_storage : 0), input_object_id2, selected_id, &object_list, &object_count); TC_PRT("Total object_num [%d]", object_count); for (i = 0; i < object_count; i++) { TC_PRT("object handle %d", object_list[i]); - ret = mtp_objectinfo_get_filename(handle, object_list[i], &filename); - ret = mtp_objectinfo_get_format(handle, object_list[i], &format); + ret = mtp_objectinfo_get_file_name(mtp_device, object_list[i], &filename); + ret = mtp_objectinfo_get_file_type(mtp_device, object_list[i], &filetype); TC_PRT("ret : %d", ret); - TC_PRT("Folder object id %d - filename[%s], format[%s]\n", object_list[i], filename, test_filetype_to_string(format)); + TC_PRT("Folder object id %d - filename[%s], filetype[%s]\n", object_list[i], filename, test_filetype_to_string(filetype)); } if (!test_get_user_int("==> 1. Input Folder Object ID (Enter for exit):", &input_object_id)) { @@ -925,27 +959,27 @@ int application_test_get_image_from_DCIM(void) selected_id = input_object_id; - ret = mtp_objectinfo_get_filename(handle, selected_id, &filename); - ret = mtp_objectinfo_get_format(handle, selected_id, &format); + ret = mtp_objectinfo_get_file_name(mtp_device, selected_id, &filename); + ret = mtp_objectinfo_get_file_type(mtp_device, selected_id, &filetype); TC_PRT("ret : %d", ret); - TC_PRT("selected id[%d] - filename[%s], format[%s]\n", selected_id, filename, test_filetype_to_string(format)); + TC_PRT("selected id[%d] - filename[%s], filetype[%s]\n", selected_id, filename, test_filetype_to_string(filetype)); g_free(filename); } - ret = mtp_get_object_handles(handle, (strg_handle > 0 ? strg_handle : 0), MTP_FILETYPE_JPEG, selected_id, &object_list2, &object_count2); + ret = mtp_get_object_handles(mtp_device, (mtp_storage > 0 ? mtp_storage : 0), MTP_FILETYPE_JPEG, selected_id, &object_list2, &object_count2); TC_PRT("Total object_num [%d]", object_count2); for (i = 0; i < object_count2; i++) { TC_PRT("object handle %d", object_list2[i]); - ret = mtp_objectinfo_get_filename(handle, object_list2[i], &filename); - ret = mtp_objectinfo_get_format(handle, object_list2[i], &format); + ret = mtp_objectinfo_get_file_name(mtp_device, object_list2[i], &filename); + ret = mtp_objectinfo_get_file_type(mtp_device, object_list2[i], &filetype); TC_PRT("ret : %d", ret); - TC_PRT("JPEG id[%d] - filename[%s], format[%s]\n", object_list2[i], filename, test_filetype_to_string(format)); + TC_PRT("JPEG id[%d] - filename[%s], filetype[%s]\n", object_list2[i], filename, test_filetype_to_string(filetype)); } while (true) { @@ -954,18 +988,18 @@ int application_test_get_image_from_DCIM(void) break; } - ret = mtp_objectinfo_get_filename(handle, input_object_id2, &filename); - ret = mtp_objectinfo_get_format(handle, input_object_id2, &format); + ret = mtp_objectinfo_get_file_name(mtp_device, input_object_id2, &filename); + ret = mtp_objectinfo_get_file_type(mtp_device, input_object_id2, &filetype); TC_PRT("ret : %d", ret); - TC_PRT("selected id[%d] - filename[%s], format[%s]\n", input_object_id2, filename, test_filetype_to_string(format)); + TC_PRT("selected id[%d] - filename[%s], filetype[%s]\n", input_object_id2, filename, test_filetype_to_string(filetype)); g_free(filename); - if (format == MTP_FILETYPE_JPEG) { + if (filetype == MTP_FILETYPE_JPEG) { snprintf(filepath, 100, "/home/JpegObject_%d.jpg", input_object_id2); - ret = mtp_get_object(handle, input_object_id2, filepath); + ret = mtp_get_object(mtp_device, input_object_id2, filepath); TC_PRT("mtp_get_object ret : %d", ret); } } @@ -983,7 +1017,7 @@ int application_test_get_object_handle_using_all(void) BEGIN(); - ret = mtp_get_object_handles(handle, strg_handle, MTP_FILETYPE_ALL, 0, &file_list, &file_count); + ret = mtp_get_object_handles(mtp_device, mtp_storage, MTP_FILETYPE_ALL, 0, &file_list, &file_count); TC_PRT("ret[%d]: total folder_count[%d]", ret, file_count); for (i = 0; i < file_count; i++) @@ -1001,7 +1035,7 @@ int application_test_get_object_handle_using_all_image(void) int ret = 0; BEGIN(); - ret = mtp_get_object_handles(handle, strg_handle, MTP_FILETYPE_ALL_IMAGE, 0, &file_list, &file_count); + ret = mtp_get_object_handles(mtp_device, mtp_storage, MTP_FILETYPE_ALL_IMAGE, 0, &file_list, &file_count); TC_PRT("ret[%d]: total folder_count[%d]", ret, file_count); for (i = 0; i < file_count; i++) @@ -1017,7 +1051,7 @@ void __test_mtp_event_cb(mtp_event_e state, int arg, void *user_data) TC_PRT("state [%d] : %d", state, arg); - if (state == MTP_EVENT_DAEMON_TERMINATED) { + if (state == MTP_EVENT_TURNED_OFF) { ret = mtp_deinitialize(); TC_PRT("ret[%d] : Terminated daemon", ret); } @@ -1036,91 +1070,12 @@ int application_test_event_callback(void) return ret; } -int application_test_scenario(void) -{ - int i; - int ret; - int device_handle = 0; - int *storage_list; - int storage_count = 0; - int *image_list; - int image_count = 0; - mtp_device_list* dev_list; - struct timeval start1, start2, start3, start4; - struct timeval end1, end2, end3, end4; - - BEGIN(); - - /* init phase */ - gettimeofday(&start1, NULL); - TC_PRT("init phase start, %ld.%ld", start1.tv_sec, start1.tv_usec); - - ret = mtp_initialize(); - - ret = mtp_get_device_list(&dev_list); - - if (dev_list->device_num == 0) { - TC_PRT("device is not exist!!!"); - END(); - return -1; - } - - ret = mtp_get_device_handle(dev_list->devices[0].bus_location, &device_handle); - ret = mtp_get_storage_ids(device_handle, &storage_list, &storage_count); - - gettimeofday(&end1, NULL); - TC_PRT("init phase end time, %ld.%ld", end1.tv_sec, end1.tv_usec); - - /* scan phase */ - gettimeofday(&start2, NULL); - TC_PRT("scan phase start, %ld.%ld", start2.tv_sec, start2.tv_usec); - - ret = mtp_get_object_handles(device_handle, storage_list[0], MTP_FILETYPE_ALL_IMAGE, - 0, &image_list, &image_count); - - gettimeofday(&end2, NULL); - TC_PRT("scan phase end time, %ld.%ld", end2.tv_sec, end2.tv_usec); - - /* get objectinfo phase */ - gettimeofday(&start3, NULL); - TC_PRT("get objectinfo phase start, %ld.%ld", start3.tv_sec, start3.tv_usec); - - for (i = 0; i < image_count; i++) { - mtp_object_info *object_info; - mtp_objectinfo_get_object_info(device_handle, image_list[i], &object_info); - TC_PRT("filename : %s", object_info->Filename); - g_free(object_info); - } - - gettimeofday(&end3, NULL); - TC_PRT("get objectinfo phase end, %ld.%ld", end3.tv_sec, end3.tv_usec); - - /* get thumbnail phase */ - gettimeofday(&start4, NULL); - TC_PRT("get thumbnail phase start, %ld.%ld", start4.tv_sec, start4.tv_usec); - - for (i = 0; i < image_count; i++) { - char path[256] = {0,}; - - snprintf(path, 256, "/tmp/thumbnail%d.jpg", i); - mtp_get_thumbnail(device_handle, image_list[i], path); - } - gettimeofday(&end4, NULL); - TC_PRT("get thumbnail phase end, %ld.%ld", end4.tv_sec, end4.tv_usec); - - ret = mtp_deinitialize(); - - END(); - - return ret; -} - tc_table_t tc_table[] = { /* manager api */ {"mtp_initialize", 1, manager_test_initialize}, - {"mtp_get_device_list", 2, manager_test_get_device_list}, - {"mtp_get_device_handle", 3, manager_test_get_device_handle}, - {"mtp_get_storage_ids", 4, manager_test_get_storage_ids}, + {"mtp_get_raw_devices", 2, manager_test_get_raw_devices}, + {"mtp_get_device", 3, manager_test_get_device}, + {"mtp_get_storages", 4, manager_test_get_storages}, {"mtp_get_object_handles", 5, manager_test_get_object_handles}, {"mtp_delete_object", 6, manager_test_delete_object}, {"mtp_get_object", 7, manager_test_get_object}, @@ -1146,12 +1101,12 @@ tc_table_t tc_table[] = { {"mtp_objectinfo_get_size", 21, objectinfo_test_get_size}, {"mtp_objectinfo_get_data_created", 22, objectinfo_test_get_data_created}, {"mtp_objectinfo_get_data_modified", 23, objectinfo_test_get_data_modified}, - {"mtp_objectinfo_get_format", 24, objectinfo_test_get_format}, - {"mtp_objectinfo_get_image_pix_depth", 25, objectinfo_test_get_image_pix_depth}, + {"mtp_objectinfo_get_file_type", 24, objectinfo_test_get_file_type}, + {"mtp_objectinfo_get_image_pix_depth", 25, objectinfo_test_get_image_bit_depth}, {"mtp_objectinfo_get_image_pix_width", 26, objectinfo_test_get_image_pix_width}, {"mtp_objectinfo_get_image_pix_height", 27, objectinfo_test_get_image_pix_height}, {"mtp_objectinfo_get_thumbnail_size", 28, objectinfo_test_get_thumbnail_size}, - {"mtp_objectinfo_get_thumbnail_format", 29, objectinfo_test_get_thumbnail_format}, + {"mtp_objectinfo_get_thumbnail_format", 29, objectinfo_test_get_thumbnail_file_type}, {"mtp_objectinfo_get_thumbnail_pix_height", 30, objectinfo_test_get_thumbnail_pix_height}, {"mtp_objectinfo_get_thumbnail_pix_width", 31, objectinfo_test_get_thumbnail_pix_width}, {"mtp_objectinfo_get_filename", 32, objectinfo_test_get_filename}, @@ -1159,10 +1114,9 @@ tc_table_t tc_table[] = { /* application test */ {"get Jpeg image from /DCIM folder", 34, application_test_get_image_from_DCIM}, - {"get object handle using ALL format", 35, application_test_get_object_handle_using_all}, - {"get object handle using ALL Image format", 36, application_test_get_object_handle_using_all_image}, + {"get object handle using ALL file type", 35, application_test_get_object_handle_using_all}, + {"get object handle using ALL Image file type", 36, application_test_get_object_handle_using_all_image}, {"test callback function", 37, application_test_event_callback}, - {"application_test_scenario", 38, application_test_scenario}, {"get object and get thumbnail test", TEST_CASE_MAX, NULL}, /*-----------*/ -- 2.7.4 From 135c004f336e37f904086e4a3f22503d187ffd2c Mon Sep 17 00:00:00 2001 From: Hyihong Chae Date: Tue, 5 Jan 2016 15:28:36 +0900 Subject: [PATCH 08/11] fix naming error of property Change-Id: Iea288dbd68803d17076f62bacf2e5eb636dec0e2 Signed-off-by: HyiHong Chae --- include/mtp_private.h | 4 ++-- packaging/capi-network-mtp.spec | 2 +- src/mtp.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/mtp_private.h b/include/mtp_private.h index cb4075a..e849a0a 100755 --- a/include/mtp_private.h +++ b/include/mtp_private.h @@ -50,8 +50,8 @@ typedef enum { MTP_PROPERTY_DATA_MODIFIED, MTP_PROPERTY_FORMAT, MTP_PROPERTY_IMAGE_BIT_DEPTH, - MTP_PROPERTY_IMAGE_FIX_WIDTH, - MTP_PROPERTY_IMAGE_FIX_HEIGHT, + MTP_PROPERTY_IMAGE_PIX_WIDTH, + MTP_PROPERTY_IMAGE_PIX_HEIGHT, MTP_PROPERTY_PARENT_OBJECT_HANDLE, MTP_PROPERTY_STORAGE, MTP_PROPERTY_THUMBNAIL_SIZE, diff --git a/packaging/capi-network-mtp.spec b/packaging/capi-network-mtp.spec index d3271c5..81d4ff9 100755 --- a/packaging/capi-network-mtp.spec +++ b/packaging/capi-network-mtp.spec @@ -1,6 +1,6 @@ Name: capi-network-mtp Summary: A MTP library in Native API -Version: 1.3.0 +Version: 1.3.1 Release: 1 Group: Network & Connectivity/Other License: Apache-2.0 diff --git a/src/mtp.c b/src/mtp.c index 03357dc..50f03f3 100755 --- a/src/mtp.c +++ b/src/mtp.c @@ -890,7 +890,7 @@ int mtp_objectinfo_get_image_pix_width(int mtp_device, /* precondition check end */ ret = mtp_gdbus_objectinfo_get_property(mtp_device, - object_handle, MTP_PROPERTY_IMAGE_FIX_WIDTH, width); + object_handle, MTP_PROPERTY_IMAGE_PIX_WIDTH, width); _END(); @@ -914,7 +914,7 @@ int mtp_objectinfo_get_image_pix_height(int mtp_device, /* precondition check end */ ret = mtp_gdbus_objectinfo_get_property(mtp_device, - object_handle, MTP_PROPERTY_IMAGE_FIX_HEIGHT, height); + object_handle, MTP_PROPERTY_IMAGE_PIX_HEIGHT, height); _END(); -- 2.7.4 From 8ba583250fcc25beb263ab99475406d1ae753b77 Mon Sep 17 00:00:00 2001 From: Hyihong Chae Date: Wed, 6 Jan 2016 10:50:51 +0900 Subject: [PATCH 09/11] apply ACR comments Change-Id: I7eabf6f2c0ccd7f8892a9ed670d12d3f5a44cbf3 Signed-off-by: HyiHong Chae --- include/mtp.h | 110 ++++++++++++++++++++-------------------- packaging/capi-network-mtp.spec | 2 +- 2 files changed, 56 insertions(+), 56 deletions(-) diff --git a/include/mtp.h b/include/mtp.h index 79a3b4c..05b8fbf 100755 --- a/include/mtp.h +++ b/include/mtp.h @@ -289,7 +289,7 @@ int mtp_destroy_raw_devices(mtp_raw_device_h *raw_devices); * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized - * @retval #MTP_ERROR_COMM MTP communication error + * @retval #MTP_ERROR_COMM_ERROR MTP communication error * * @pre mtp_get_bus_location(), mtp_get_device_number() * @see mtp_initialize() @@ -312,7 +312,7 @@ int mtp_get_device(int bus_location, int device_number, mtp_device_h *mtp_device * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized - * @retval #MTP_ERROR_COMM MTP communication error + * @retval #MTP_ERROR_COMM_ERROR MTP communication error * * @see mtp_get_device() */ @@ -338,7 +338,7 @@ int mtp_get_storages(mtp_device_h mtp_device, mtp_storage_h **mtp_storages, int* * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized - * @retval #MTP_ERROR_COMM MTP communication error + * @retval #MTP_ERROR_COMM_ERROR MTP communication error * * @see mtp_get_device() * @see mtp_get_storages() @@ -363,7 +363,7 @@ int mtp_get_object_handles(mtp_device_h mtp_device, mtp_storage_h mtp_storage, m * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized - * @retval #MTP_ERROR_COMM MTP communication error + * @retval #MTP_ERROR_COMM_ERROR MTP communication error * @retval #MTP_ERROR_IO_ERROR I/O error * * @see mtp_get_device() @@ -388,7 +388,7 @@ int mtp_get_object(mtp_device_h mtp_device, mtp_object_h object_handle, char *de * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized - * @retval #MTP_ERROR_COMM MTP communication error + * @retval #MTP_ERROR_COMM_ERROR MTP communication error * @retval #MTP_ERROR_IO_ERROR I/O error * * @see mtp_get_device() @@ -467,7 +467,7 @@ int mtp_deinitialize(void); * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized - * @retval #MTP_ERROR_COMM MTP communication error + * @retval #MTP_ERROR_COMM_ERROR MTP communication error * @retval #MTP_ERROR_CONTROLLER MTP controller error * @retval #MTP_ERROR_ALLOC_FAIL Memory Allocation failed * @retval #MTP_ERROR_NO_DEVICE MTP have not any device @@ -491,7 +491,7 @@ int mtp_deviceinfo_get_manufacturer_name(mtp_device_h mtp_device, char **manufac * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized - * @retval #MTP_ERROR_COMM MTP communication error + * @retval #MTP_ERROR_COMM_ERROR MTP communication error * @retval #MTP_ERROR_CONTROLLER MTP controller error * @retval #MTP_ERROR_ALLOC_FAIL Memory Allocation failed * @retval #MTP_ERROR_NO_DEVICE MTP have not any device @@ -515,7 +515,7 @@ int mtp_deviceinfo_get_model_name(mtp_device_h mtp_device, char **model_name); * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized - * @retval #MTP_ERROR_COMM MTP communication error + * @retval #MTP_ERROR_COMM_ERROR MTP communication error * @retval #MTP_ERROR_CONTROLLER MTP controller error * @retval #MTP_ERROR_ALLOC_FAIL Memory Allocation failed * @retval #MTP_ERROR_NO_DEVICE MTP have not any device @@ -539,7 +539,7 @@ int mtp_deviceinfo_get_serial_number(mtp_device_h mtp_device, char **serial_numb * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized - * @retval #MTP_ERROR_COMM MTP communication error + * @retval #MTP_ERROR_COMM_ERROR MTP communication error * @retval #MTP_ERROR_CONTROLLER MTP controller error * @retval #MTP_ERROR_ALLOC_FAIL Memory Allocation failed * @retval #MTP_ERROR_NO_DEVICE MTP have not any device @@ -573,7 +573,7 @@ int mtp_deviceinfo_get_device_version(mtp_device_h mtp_device, char **device_ver * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized - * @retval #MTP_ERROR_COMM MTP communication error + * @retval #MTP_ERROR_COMM_ERROR MTP communication error * @retval #MTP_ERROR_CONTROLLER MTP controller error * @retval #MTP_ERROR_ALLOC_FAIL Memory Allocation failed * @retval #MTP_ERROR_NO_DEVICE MTP have not any device @@ -583,7 +583,7 @@ int mtp_deviceinfo_get_device_version(mtp_device_h mtp_device, char **device_ver int mtp_storageinfo_get_description(mtp_device_h mtp_device, mtp_storage_h mtp_storage, char **description); /** - * @brief Gets the freespace of the storage information. + * @brief Gets the free space of the storage information. * @since_tizen 3.0 * * @param [in] mtp_device The MTP device @@ -597,7 +597,7 @@ int mtp_storageinfo_get_description(mtp_device_h mtp_device, mtp_storage_h mtp_s * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized - * @retval #MTP_ERROR_COMM MTP communication error + * @retval #MTP_ERROR_COMM_ERROR MTP communication error * @retval #MTP_ERROR_CONTROLLER MTP controller error * @retval #MTP_ERROR_ALLOC_FAIL Memory Allocation failed * @retval #MTP_ERROR_NO_DEVICE MTP have not any device @@ -621,7 +621,7 @@ int mtp_storageinfo_get_free_space(mtp_device_h mtp_device, mtp_storage_h mtp_st * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized - * @retval #MTP_ERROR_COMM MTP communication error + * @retval #MTP_ERROR_COMM_ERROR MTP communication error * @retval #MTP_ERROR_CONTROLLER MTP controller error * @retval #MTP_ERROR_ALLOC_FAIL Memory Allocation failed * @retval #MTP_ERROR_NO_DEVICE MTP have not any device @@ -645,7 +645,7 @@ int mtp_storageinfo_get_max_capacity(mtp_device_h mtp_device, mtp_storage_h mtp_ * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized - * @retval #MTP_ERROR_COMM MTP communication error + * @retval #MTP_ERROR_COMM_ERROR MTP communication error * @retval #MTP_ERROR_CONTROLLER MTP controller error * @retval #MTP_ERROR_ALLOC_FAIL Memory Allocation failed * @retval #MTP_ERROR_NO_DEVICE MTP have not any device @@ -655,7 +655,7 @@ int mtp_storageinfo_get_max_capacity(mtp_device_h mtp_device, mtp_storage_h mtp_ int mtp_storageinfo_get_storage_type(mtp_device_h mtp_device, mtp_storage_h mtp_storage, int *storage_type); /** - * @brief Gets the volumeidentifier of the storage information. + * @brief Gets the volume identifier of the storage information. * @since_tizen 3.0 * @remarks The @a volume_identifier should be freed using free(). * @@ -670,7 +670,7 @@ int mtp_storageinfo_get_storage_type(mtp_device_h mtp_device, mtp_storage_h mtp_ * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized - * @retval #MTP_ERROR_COMM MTP communication error + * @retval #MTP_ERROR_COMM_ERROR MTP communication error * @retval #MTP_ERROR_CONTROLLER MTP controller error * @retval #MTP_ERROR_ALLOC_FAIL Memory Allocation failed * @retval #MTP_ERROR_NO_DEVICE MTP have not any device @@ -704,11 +704,11 @@ int mtp_storageinfo_get_volume_identifier(mtp_device_h mtp_device, mtp_storage_h * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized - * @retval #MTP_ERROR_COMM MTP communication error + * @retval #MTP_ERROR_COMM_ERROR MTP communication error * @retval #MTP_ERROR_CONTROLLER MTP controller error * @retval #MTP_ERROR_ALLOC_FAIL Memory Allocation failed * @retval #MTP_ERROR_NO_DEVICE MTP have not any device - * @retval #MTP_ERROR_PLUGIN Plugin failed + * @retval #MTP_ERROR_PLUGIN_FAIL Plugin failed * * @see mtp_get_object_handles() */ @@ -730,11 +730,11 @@ int mtp_objectinfo_get_file_name(mtp_device_h mtp_device, mtp_object_h object_ha * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized - * @retval #MTP_ERROR_COMM MTP communication error + * @retval #MTP_ERROR_COMM_ERROR MTP communication error * @retval #MTP_ERROR_CONTROLLER MTP controller error * @retval #MTP_ERROR_ALLOC_FAIL Memory Allocation failed * @retval #MTP_ERROR_NO_DEVICE MTP have not any device - * @retval #MTP_ERROR_PLUGIN Plugin failed + * @retval #MTP_ERROR_PLUGIN_FAIL Plugin failed * * @see mtp_get_object_handles() */ @@ -755,11 +755,11 @@ int mtp_objectinfo_get_keywords(mtp_device_h mtp_device, mtp_object_h object_han * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized - * @retval #MTP_ERROR_COMM MTP communication error + * @retval #MTP_ERROR_COMM_ERROR MTP communication error * @retval #MTP_ERROR_CONTROLLER MTP controller error * @retval #MTP_ERROR_ALLOC_FAIL Memory Allocation failed * @retval #MTP_ERROR_NO_DEVICE MTP have not any device - * @retval #MTP_ERROR_PLUGIN Plugin failed + * @retval #MTP_ERROR_PLUGIN_FAIL Plugin failed * * @see mtp_get_object_handles() */ @@ -780,11 +780,11 @@ int mtp_objectinfo_get_association_desc(mtp_device_h mtp_device, mtp_object_h ob * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized - * @retval #MTP_ERROR_COMM MTP communication error + * @retval #MTP_ERROR_COMM_ERROR MTP communication error * @retval #MTP_ERROR_CONTROLLER MTP controller error * @retval #MTP_ERROR_ALLOC_FAIL Memory Allocation failed * @retval #MTP_ERROR_NO_DEVICE MTP have not any device - * @retval #MTP_ERROR_PLUGIN Plugin failed + * @retval #MTP_ERROR_PLUGIN_FAIL Plugin failed * * @see mtp_get_object_handles() */ @@ -805,11 +805,11 @@ int mtp_objectinfo_get_association_type(mtp_device_h mtp_device, mtp_object_h ob * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized - * @retval #MTP_ERROR_COMM MTP communication error + * @retval #MTP_ERROR_COMM_ERROR MTP communication error * @retval #MTP_ERROR_CONTROLLER MTP controller error * @retval #MTP_ERROR_ALLOC_FAIL Memory Allocation failed * @retval #MTP_ERROR_NO_DEVICE MTP have not any device - * @retval #MTP_ERROR_PLUGIN Plugin failed + * @retval #MTP_ERROR_PLUGIN_FAIL Plugin failed * * @see mtp_get_object_handles() */ @@ -830,11 +830,11 @@ int mtp_objectinfo_get_size(mtp_device_h mtp_device, mtp_object_h object_handle, * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized - * @retval #MTP_ERROR_COMM MTP communication error + * @retval #MTP_ERROR_COMM_ERROR MTP communication error * @retval #MTP_ERROR_CONTROLLER MTP controller error * @retval #MTP_ERROR_ALLOC_FAIL Memory Allocation failed * @retval #MTP_ERROR_NO_DEVICE MTP have not any device - * @retval #MTP_ERROR_PLUGIN Plugin failed + * @retval #MTP_ERROR_PLUGIN_FAIL Plugin failed * * @see mtp_get_object_handles() */ @@ -855,11 +855,11 @@ int mtp_objectinfo_get_parent_object_handle(mtp_device_h mtp_device, mtp_object_ * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized - * @retval #MTP_ERROR_COMM MTP communication error + * @retval #MTP_ERROR_COMM_ERROR MTP communication error * @retval #MTP_ERROR_CONTROLLER MTP controller error * @retval #MTP_ERROR_ALLOC_FAIL Memory Allocation failed * @retval #MTP_ERROR_NO_DEVICE MTP have not any device - * @retval #MTP_ERROR_PLUGIN Plugin failed + * @retval #MTP_ERROR_PLUGIN_FAIL Plugin failed * * @see mtp_get_object_handles() */ @@ -880,11 +880,11 @@ int mtp_objectinfo_get_storage(mtp_device_h mtp_device, mtp_object_h object_hand * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized - * @retval #MTP_ERROR_COMM MTP communication error + * @retval #MTP_ERROR_COMM_ERROR MTP communication error * @retval #MTP_ERROR_CONTROLLER MTP controller error * @retval #MTP_ERROR_ALLOC_FAIL Memory Allocation failed * @retval #MTP_ERROR_NO_DEVICE MTP have not any device - * @retval #MTP_ERROR_PLUGIN Plugin failed + * @retval #MTP_ERROR_PLUGIN_FAIL Plugin failed * * @see mtp_get_object_handles() */ @@ -905,11 +905,11 @@ int mtp_objectinfo_get_data_created(mtp_device_h mtp_device, mtp_object_h object * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized - * @retval #MTP_ERROR_COMM MTP communication error + * @retval #MTP_ERROR_COMM_ERROR MTP communication error * @retval #MTP_ERROR_CONTROLLER MTP controller error * @retval #MTP_ERROR_ALLOC_FAIL Memory Allocation failed * @retval #MTP_ERROR_NO_DEVICE MTP have not any device - * @retval #MTP_ERROR_PLUGIN Plugin failed + * @retval #MTP_ERROR_PLUGIN_FAIL Plugin failed * * @see mtp_get_object_handles() */ @@ -930,11 +930,11 @@ int mtp_objectinfo_get_data_modified(mtp_device_h mtp_device, mtp_object_h objec * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized - * @retval #MTP_ERROR_COMM MTP communication error + * @retval #MTP_ERROR_COMM_ERROR MTP communication error * @retval #MTP_ERROR_CONTROLLER MTP controller error * @retval #MTP_ERROR_ALLOC_FAIL Memory Allocation failed * @retval #MTP_ERROR_NO_DEVICE MTP have not any device - * @retval #MTP_ERROR_PLUGIN Plugin failed + * @retval #MTP_ERROR_PLUGIN_FAIL Plugin failed * * @see mtp_get_object_handles() */ @@ -955,18 +955,18 @@ int mtp_objectinfo_get_file_type(mtp_device_h mtp_device, mtp_object_h object_ha * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized - * @retval #MTP_ERROR_COMM MTP communication error + * @retval #MTP_ERROR_COMM_ERROR MTP communication error * @retval #MTP_ERROR_CONTROLLER MTP controller error * @retval #MTP_ERROR_ALLOC_FAIL Memory Allocation failed * @retval #MTP_ERROR_NO_DEVICE MTP have not any device - * @retval #MTP_ERROR_PLUGIN Plugin failed + * @retval #MTP_ERROR_PLUGIN_FAIL Plugin failed * * @see mtp_get_object_handles() */ int mtp_objectinfo_get_image_bit_depth(mtp_device_h mtp_device, mtp_object_h object_handle, int *depth); /** - * @brief Gets the image pix width of the object information. + * @brief Gets the image pixel width of the object information. * @since_tizen 3.0 * * @param [in] mtp_device The MTP device @@ -980,18 +980,18 @@ int mtp_objectinfo_get_image_bit_depth(mtp_device_h mtp_device, mtp_object_h obj * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized - * @retval #MTP_ERROR_COMM MTP communication error + * @retval #MTP_ERROR_COMM_ERROR MTP communication error * @retval #MTP_ERROR_CONTROLLER MTP controller error * @retval #MTP_ERROR_ALLOC_FAIL Memory Allocation failed * @retval #MTP_ERROR_NO_DEVICE MTP have not any device - * @retval #MTP_ERROR_PLUGIN Plugin failed + * @retval #MTP_ERROR_PLUGIN_FAIL Plugin failed * * @see mtp_get_object_handles() */ int mtp_objectinfo_get_image_pix_width(mtp_device_h mtp_device, mtp_object_h object_handle, int *width); /** - * @brief Gets the image pix height of the object information. + * @brief Gets the image pixel height of the object information. * @since_tizen 3.0 * * @param [in] mtp_device The MTP device @@ -1005,11 +1005,11 @@ int mtp_objectinfo_get_image_pix_width(mtp_device_h mtp_device, mtp_object_h obj * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized - * @retval #MTP_ERROR_COMM MTP communication error + * @retval #MTP_ERROR_COMM_ERROR MTP communication error * @retval #MTP_ERROR_CONTROLLER MTP controller error * @retval #MTP_ERROR_ALLOC_FAIL Memory Allocation failed * @retval #MTP_ERROR_NO_DEVICE MTP have not any device - * @retval #MTP_ERROR_PLUGIN Plugin failed + * @retval #MTP_ERROR_PLUGIN_FAIL Plugin failed * * @see mtp_get_object_handles() */ @@ -1030,18 +1030,18 @@ int mtp_objectinfo_get_image_pix_height(mtp_device_h mtp_device, mtp_object_h ob * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized - * @retval #MTP_ERROR_COMM MTP communication error + * @retval #MTP_ERROR_COMM_ERROR MTP communication error * @retval #MTP_ERROR_CONTROLLER MTP controller error * @retval #MTP_ERROR_ALLOC_FAIL Memory Allocation failed * @retval #MTP_ERROR_NO_DEVICE MTP have not any device - * @retval #MTP_ERROR_PLUGIN Plugin failed + * @retval #MTP_ERROR_PLUGIN_FAIL Plugin failed * * @see mtp_get_object_handles() */ int mtp_objectinfo_get_thumbnail_size(mtp_device_h mtp_device, mtp_object_h object_handle, int *size); /** - * @brief Gets the thumbnail file_type of the object information. + * @brief Gets the thumbnail file type of the object information. * @since_tizen 3.0 * * @param [in] mtp_device The MTP device @@ -1055,18 +1055,18 @@ int mtp_objectinfo_get_thumbnail_size(mtp_device_h mtp_device, mtp_object_h obje * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized - * @retval #MTP_ERROR_COMM MTP communication error + * @retval #MTP_ERROR_COMM_ERROR MTP communication error * @retval #MTP_ERROR_CONTROLLER MTP controller error * @retval #MTP_ERROR_ALLOC_FAIL Memory Allocation failed * @retval #MTP_ERROR_NO_DEVICE MTP have not any device - * @retval #MTP_ERROR_PLUGIN Plugin failed + * @retval #MTP_ERROR_PLUGIN_FAIL Plugin failed * * @see mtp_get_object_handles() */ int mtp_objectinfo_get_thumbnail_file_type(mtp_device_h mtp_device, mtp_object_h object_handle, mtp_filetype_e *file_type); /** - * @brief Gets the thumbnail pix height of the object information. + * @brief Gets the thumbnail pixel height of the object information. * @since_tizen 3.0 * * @param [in] mtp_device The MTP device @@ -1080,18 +1080,18 @@ int mtp_objectinfo_get_thumbnail_file_type(mtp_device_h mtp_device, mtp_object_h * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized - * @retval #MTP_ERROR_COMM MTP communication error + * @retval #MTP_ERROR_COMM_ERROR MTP communication error * @retval #MTP_ERROR_CONTROLLER MTP controller error * @retval #MTP_ERROR_ALLOC_FAIL Memory Allocation failed * @retval #MTP_ERROR_NO_DEVICE MTP have not any device - * @retval #MTP_ERROR_PLUGIN Plugin failed + * @retval #MTP_ERROR_PLUGIN_FAIL Plugin failed * * @see mtp_get_object_handles() */ int mtp_objectinfo_get_thumbnail_pix_height(mtp_device_h mtp_device, mtp_object_h object_handle, int *height); /** - * @brief Gets the thumbnail pix width of the object information. + * @brief Gets the thumbnail pixel width of the object information. * @since_tizen 3.0 * * @param [in] mtp_device The MTP device @@ -1105,11 +1105,11 @@ int mtp_objectinfo_get_thumbnail_pix_height(mtp_device_h mtp_device, mtp_object_ * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized - * @retval #MTP_ERROR_COMM MTP communication error + * @retval #MTP_ERROR_COMM_ERROR MTP communication error * @retval #MTP_ERROR_CONTROLLER MTP controller error * @retval #MTP_ERROR_ALLOC_FAIL Memory Allocation failed * @retval #MTP_ERROR_NO_DEVICE MTP have not any device - * @retval #MTP_ERROR_PLUGIN Plugin failed + * @retval #MTP_ERROR_PLUGIN_FAIL Plugin failed * * @see mtp_get_object_handles() */ diff --git a/packaging/capi-network-mtp.spec b/packaging/capi-network-mtp.spec index 81d4ff9..98f917c 100755 --- a/packaging/capi-network-mtp.spec +++ b/packaging/capi-network-mtp.spec @@ -1,6 +1,6 @@ Name: capi-network-mtp Summary: A MTP library in Native API -Version: 1.3.1 +Version: 1.3.2 Release: 1 Group: Network & Connectivity/Other License: Apache-2.0 -- 2.7.4 From d416b10dde47e2c422ac66e78041eb354f9e0b03 Mon Sep 17 00:00:00 2001 From: Jihoon Jung Date: Mon, 11 Jan 2016 18:39:59 +0900 Subject: [PATCH 10/11] apply ACR comments Signed-off-by: Ji-hoon Jung Change-Id: Icdb528587e2d67a5f2314b6fbb82511000062cfe --- include/mtp.h | 19 ++++++++++++++++++- src/mtp.c | 4 ++-- test/mtp_unit_test.c | 2 +- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/include/mtp.h b/include/mtp.h index 05b8fbf..0ea1b30 100755 --- a/include/mtp.h +++ b/include/mtp.h @@ -81,6 +81,19 @@ typedef enum { } mtp_error_e; /** + * @brief Enumerations for MTP Storage type + * @since_tizen 3.0 + */ + +typedef enum { + MTP_STORAGE_TYPE_UNDEFINED, /**< Storage type is undefined */ + MTP_STORAGE_TYPE_FIXED_ROM, /**< Storage type is fixed ROM */ + MTP_STORAGE_TYPE_REMOVABLE_ROM, /**< Storage type is removable ROM */ + MTP_STORAGE_TYPE_FIXED_RAM, /**< Storage type is fixed RAM */ + MTP_STORAGE_TYPE_REMOVABLE_RAM /**< Storage type is Removable RAM */ +} mtp_storage_type_e; + +/** * @brief Enumerations for MTP file type * @since_tizen 3.0 */ @@ -652,7 +665,7 @@ int mtp_storageinfo_get_max_capacity(mtp_device_h mtp_device, mtp_storage_h mtp_ * * @see mtp_get_storages() */ -int mtp_storageinfo_get_storage_type(mtp_device_h mtp_device, mtp_storage_h mtp_storage, int *storage_type); +int mtp_storageinfo_get_storage_type(mtp_device_h mtp_device, mtp_storage_h mtp_storage, mtp_storage_type_e *storage_type); /** * @brief Gets the volume identifier of the storage information. @@ -868,6 +881,8 @@ int mtp_objectinfo_get_storage(mtp_device_h mtp_device, mtp_object_h object_hand /** * @brief Gets the data created time of the object information. * @since_tizen 3.0 + * @remarks When interpreted as an absolute time value, \n + * @a data_created represents the number of seconds elapsed since the Epoch, 1970-01-01 00:00:00 +0000 (UTC). * * @param [in] mtp_device The MTP device * @param [in] object_handle The object handle @@ -893,6 +908,8 @@ int mtp_objectinfo_get_data_created(mtp_device_h mtp_device, mtp_object_h object /** * @brief Gets the data modified time of the object information. * @since_tizen 3.0 + * @remarks When interpreted as an absolute time value, \n + * @a data_modified represents the number of seconds elapsed since the Epoch, 1970-01-01 00:00:00 +0000 (UTC). * * @param [in] mtp_device The MTP device * @param [in] object_handle The object handle diff --git a/src/mtp.c b/src/mtp.c index 50f03f3..b250cba 100755 --- a/src/mtp.c +++ b/src/mtp.c @@ -606,7 +606,7 @@ int mtp_storageinfo_get_max_capacity(int mtp_device, int mtp_storage, unsigned l return ret; } -int mtp_storageinfo_get_storage_type(int mtp_device, int mtp_storage, int *storage_type) +int mtp_storageinfo_get_storage_type(int mtp_device, int mtp_storage, mtp_storage_type_e *storage_type) { int ret = MTP_ERROR_NONE; @@ -622,7 +622,7 @@ int mtp_storageinfo_get_storage_type(int mtp_device, int mtp_storage, int *stora /* precondition check end */ - ret = mtp_gdbus_storageinfo_get_storagetype(mtp_device, mtp_storage, storage_type); + ret = mtp_gdbus_storageinfo_get_storagetype(mtp_device, mtp_storage, (int *)storage_type); TC_PRT("storagetype %d", *storage_type); diff --git a/test/mtp_unit_test.c b/test/mtp_unit_test.c index 266a0d2..f33ee83 100755 --- a/test/mtp_unit_test.c +++ b/test/mtp_unit_test.c @@ -566,7 +566,7 @@ int storageinfo_test_get_maxcapacity(void) int storageinfo_test_get_storagetype(void) { int ret = 0; - int value = 0; + mtp_storage_type_e value = 0; BEGIN(); ret = mtp_storageinfo_get_storage_type(mtp_device, mtp_storage, &value); -- 2.7.4 From c41f3a2a09053fd71e6781d8c7f6e1a545aede41 Mon Sep 17 00:00:00 2001 From: Hyihong Chae Date: Thu, 14 Jan 2016 21:48:34 +0900 Subject: [PATCH 11/11] apply security comments. Change-Id: Ib3358ec53d270de0750aca2c27a344cfd7ba56ee Signed-off-by: HyiHong Chae --- include/mtp.h | 76 +++++++++++++++++++++++++++++++++++++++++ packaging/capi-network-mtp.spec | 2 +- 2 files changed, 77 insertions(+), 1 deletion(-) diff --git a/include/mtp.h b/include/mtp.h index 0ea1b30..93af315 100755 --- a/include/mtp.h +++ b/include/mtp.h @@ -185,6 +185,8 @@ typedef void (* mtp_event_cb)(mtp_event_e event, int event_parameter, void *user * @brief Initializes for using MTP. * @since_tizen 3.0 * @remarks This function must be called before proceeding any other mtp functions. + * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n + * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. \n * * @return 0 on success, otherwise a negative error value. * @retval #MTP_ERROR_NONE Successful @@ -200,6 +202,8 @@ int mtp_initialize(void); * @brief Gets device list. * @since_tizen 3.0 * @remarks The @a raw_devices should be freed using mtp_destroy_raw_devices(). + * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n + * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. \n * * @param [out] raw_devices All current connected device list * @param [out] device_count The count of device @@ -220,6 +224,8 @@ int mtp_get_raw_devices(mtp_raw_device_h **raw_devices, int *device_count); * @brief Gets bus location from raw device. * @since_tizen 3.0 * @remarks The @a raw_device can get using mtp_get_raw_devices(). + * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n + * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. \n * * @param [in] raw_device The raw device * @param [out] bus_location The bus location @@ -238,6 +244,8 @@ int mtp_get_bus_location(mtp_raw_device_h raw_device, int *bus_location); * @brief Gets device number from raw device. * @since_tizen 3.0 * @remarks The @a raw_device can get using mtp_get_raw_devices(). + * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n + * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. \n * * @param [in] raw_device The raw device * @param [out] device_number The device number @@ -257,6 +265,8 @@ int mtp_get_device_number(mtp_raw_device_h raw_device, int *device_number); * @since_tizen 3.0 * @remarks The @a raw_device can get using mtp_get_raw_devices(). * @remarks The @a model_name should be freed using free(). + * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n + * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. \n * * @param [in] raw_device The raw device * @param [out] model_name The model name @@ -274,6 +284,8 @@ int mtp_get_device_name(mtp_raw_device_h raw_device, char **model_name); /** * @brief Destroys the raw devices handler. * @since_tizen 3.0 + * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n + * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. \n * * @param [in] raw_devices The raw devices handler * @@ -290,6 +302,8 @@ int mtp_destroy_raw_devices(mtp_raw_device_h *raw_devices); * @brief Gets device handler from bus location. * @since_tizen 3.0 * @remarks For using this api, you should get bus location and device number from raw device. + * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n + * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. \n * * @param [in] bus_location The bus location * @param [in] device_number The device number @@ -313,6 +327,8 @@ int mtp_get_device(int bus_location, int device_number, mtp_device_h *mtp_device * @brief Gets mtp storages from device. * @since_tizen 3.0 * @remarks The @a mtp_storages should be freed using free(). + * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n + * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. \n * * @param [in] mtp_device The MTP device * @param [out] mtp_storages Current mtp storage list @@ -336,6 +352,8 @@ int mtp_get_storages(mtp_device_h mtp_device, mtp_storage_h **mtp_storages, int* * @since_tizen 3.0 * @remarks The @a object_handles should be freed using free(). * @remarks If the @a parent is 0, it means "root folder" of mtp storage. + * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n + * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. \n * * @param [in] mtp_device The MTP device * @param [in] mtp_storage The MTP storage @@ -416,6 +434,8 @@ int mtp_get_thumbnail(mtp_device_h mtp_device, mtp_object_h object_handle, char * @remarks If device state is changed, DEVICE_ADD or DEVICE_REMOVE event is occur. \n * If storage state is changed, STORAGE_ADD or STORAGE_REMOVE event is occur. \n * If object state is changed, OBJECT_ADD or OBJECT_REMOVE event is occur. + * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n + * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. \n * * @param [in] event_cb The callback * @param [in] user_data The user data @@ -433,6 +453,8 @@ int mtp_set_mtp_event_cb(mtp_event_cb event_cb, void *user_data); /** * @brief Unregisters the callback function. * @since_tizen 3.0 + * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n + * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. \n * * @return 0 on success, otherwise a negative error value. * @retval #MTP_ERROR_NONE Successful @@ -446,6 +468,8 @@ int mtp_unset_mtp_event_cb(void); /** * @brief Deinitializes MTP operation. * @since_tizen 3.0 + * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n + * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. \n * * @return 0 on success, otherwise a negative error value. * @retval #MTP_ERROR_NONE Successful @@ -469,6 +493,8 @@ int mtp_deinitialize(void); * @brief Gets the manufacturer name of the device information. * @since_tizen 3.0 * @remarks The @a manufacturer_name should be freed using free(). + * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n + * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. \n * * @param [in] mtp_device The MTP device * @param [out] manufacturer_name The manufacturer name of Device information @@ -493,6 +519,8 @@ int mtp_deviceinfo_get_manufacturer_name(mtp_device_h mtp_device, char **manufac * @brief Gets the model name of the device information. * @since_tizen 3.0 * @remarks The @a model_name should be freed using free(). + * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n + * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. \n * * @param [in] mtp_device The MTP device * @param [out] model_name The model name of Device information @@ -517,6 +545,8 @@ int mtp_deviceinfo_get_model_name(mtp_device_h mtp_device, char **model_name); * @brief Gets the serial number of the device information. * @since_tizen 3.0 * @remarks The @a serial_number should be freed using free(). + * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n + * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. \n * * @param [in] mtp_device The MTP device * @param [out] serial_number The serial number of Device information @@ -541,6 +571,8 @@ int mtp_deviceinfo_get_serial_number(mtp_device_h mtp_device, char **serial_numb * @brief Gets the device version of the device information. * @since_tizen 3.0 * @remarks The @a device_version should be freed using free(). + * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n + * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. \n * * @param [in] mtp_device The MTP device * @param [out] device_version The device version of Device information @@ -574,6 +606,8 @@ int mtp_deviceinfo_get_device_version(mtp_device_h mtp_device, char **device_ver * @brief Gets the description of the storage information. * @since_tizen 3.0 * @remarks The @a description should be freed using free(). + * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n + * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. \n * * @param [in] mtp_device The MTP device * @param [in] mtp_storage The MTP storage @@ -598,6 +632,8 @@ int mtp_storageinfo_get_description(mtp_device_h mtp_device, mtp_storage_h mtp_s /** * @brief Gets the free space of the storage information. * @since_tizen 3.0 + * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n + * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. \n * * @param [in] mtp_device The MTP device * @param [in] mtp_storage The MTP storage @@ -622,6 +658,8 @@ int mtp_storageinfo_get_free_space(mtp_device_h mtp_device, mtp_storage_h mtp_st /** * @brief Gets the max capacity of the storage information. * @since_tizen 3.0 + * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n + * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. \n * * @param [in] mtp_device The MTP device * @param [in] mtp_storage The MTP storage @@ -646,6 +684,8 @@ int mtp_storageinfo_get_max_capacity(mtp_device_h mtp_device, mtp_storage_h mtp_ /** * @brief Gets the storage type of the storage information. * @since_tizen 3.0 + * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n + * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. \n * * @param [in] mtp_device The MTP device * @param [in] mtp_storage The MTP storage @@ -671,6 +711,8 @@ int mtp_storageinfo_get_storage_type(mtp_device_h mtp_device, mtp_storage_h mtp_ * @brief Gets the volume identifier of the storage information. * @since_tizen 3.0 * @remarks The @a volume_identifier should be freed using free(). + * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n + * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. \n * * @param [in] mtp_device The MTP device * @param [in] mtp_storage The MTP storage @@ -705,6 +747,8 @@ int mtp_storageinfo_get_volume_identifier(mtp_device_h mtp_device, mtp_storage_h * @brief Gets the filename of the object information. * @since_tizen 3.0 * @remarks The @a file_name should be freed using free(). + * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n + * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. \n * * @param [in] mtp_device The MTP device * @param [in] object_handle The object handle @@ -731,6 +775,8 @@ int mtp_objectinfo_get_file_name(mtp_device_h mtp_device, mtp_object_h object_ha * @brief Gets the keywords of the object information. * @since_tizen 3.0 * @remarks The @a keywords should be freed using free(). + * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n + * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. \n * * @param [in] mtp_device The MTP device * @param [in] object_handle The object handle @@ -756,6 +802,8 @@ int mtp_objectinfo_get_keywords(mtp_device_h mtp_device, mtp_object_h object_han /** * @brief Gets the association desc of the object information. * @since_tizen 3.0 + * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n + * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. \n * * @param [in] mtp_device The MTP device * @param [in] object_handle The object handle @@ -781,6 +829,8 @@ int mtp_objectinfo_get_association_desc(mtp_device_h mtp_device, mtp_object_h ob /** * @brief Gets the association type of the object information. * @since_tizen 3.0 + * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n + * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. \n * * @param [in] mtp_device The MTP device * @param [in] object_handle The object handle @@ -806,6 +856,8 @@ int mtp_objectinfo_get_association_type(mtp_device_h mtp_device, mtp_object_h ob /** * @brief Gets the size of the object information. * @since_tizen 3.0 + * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n + * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. \n * * @param [in] mtp_device The MTP device * @param [in] object_handle The object handle @@ -831,6 +883,8 @@ int mtp_objectinfo_get_size(mtp_device_h mtp_device, mtp_object_h object_handle, /** * @brief Gets the parent object handle of the object information. * @since_tizen 3.0 + * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n + * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. \n * * @param [in] mtp_device The MTP device * @param [in] object_handle The object handle @@ -856,6 +910,8 @@ int mtp_objectinfo_get_parent_object_handle(mtp_device_h mtp_device, mtp_object_ /** * @brief Gets the mtp storage of the object information. * @since_tizen 3.0 + * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n + * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. \n * * @param [in] mtp_device The MTP device * @param [in] object_handle The object handle @@ -883,6 +939,8 @@ int mtp_objectinfo_get_storage(mtp_device_h mtp_device, mtp_object_h object_hand * @since_tizen 3.0 * @remarks When interpreted as an absolute time value, \n * @a data_created represents the number of seconds elapsed since the Epoch, 1970-01-01 00:00:00 +0000 (UTC). + * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n + * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. \n * * @param [in] mtp_device The MTP device * @param [in] object_handle The object handle @@ -910,6 +968,8 @@ int mtp_objectinfo_get_data_created(mtp_device_h mtp_device, mtp_object_h object * @since_tizen 3.0 * @remarks When interpreted as an absolute time value, \n * @a data_modified represents the number of seconds elapsed since the Epoch, 1970-01-01 00:00:00 +0000 (UTC). + * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n + * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. \n * * @param [in] mtp_device The MTP device * @param [in] object_handle The object handle @@ -935,6 +995,8 @@ int mtp_objectinfo_get_data_modified(mtp_device_h mtp_device, mtp_object_h objec /** * @brief Gets the file type of the object information. * @since_tizen 3.0 + * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n + * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. \n * * @param [in] mtp_device The MTP device * @param [in] object_handle The object handle @@ -960,6 +1022,8 @@ int mtp_objectinfo_get_file_type(mtp_device_h mtp_device, mtp_object_h object_ha /** * @brief Gets the image bit depth of the object information. * @since_tizen 3.0 + * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n + * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. \n * * @param [in] mtp_device The MTP device * @param [in] object_handle The object handle @@ -985,6 +1049,8 @@ int mtp_objectinfo_get_image_bit_depth(mtp_device_h mtp_device, mtp_object_h obj /** * @brief Gets the image pixel width of the object information. * @since_tizen 3.0 + * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n + * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. \n * * @param [in] mtp_device The MTP device * @param [in] object_handle The object handle @@ -1010,6 +1076,8 @@ int mtp_objectinfo_get_image_pix_width(mtp_device_h mtp_device, mtp_object_h obj /** * @brief Gets the image pixel height of the object information. * @since_tizen 3.0 + * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n + * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. \n * * @param [in] mtp_device The MTP device * @param [in] object_handle The object handle @@ -1035,6 +1103,8 @@ int mtp_objectinfo_get_image_pix_height(mtp_device_h mtp_device, mtp_object_h ob /** * @brief Gets the thumbnail size of the object information. * @since_tizen 3.0 + * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n + * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. \n * * @param [in] mtp_device The MTP device * @param [in] object_handle The object handle @@ -1060,6 +1130,8 @@ int mtp_objectinfo_get_thumbnail_size(mtp_device_h mtp_device, mtp_object_h obje /** * @brief Gets the thumbnail file type of the object information. * @since_tizen 3.0 + * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n + * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. \n * * @param [in] mtp_device The MTP device * @param [in] object_handle The object handle @@ -1085,6 +1157,8 @@ int mtp_objectinfo_get_thumbnail_file_type(mtp_device_h mtp_device, mtp_object_h /** * @brief Gets the thumbnail pixel height of the object information. * @since_tizen 3.0 + * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n + * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. \n * * @param [in] mtp_device The MTP device * @param [in] object_handle The object handle @@ -1110,6 +1184,8 @@ int mtp_objectinfo_get_thumbnail_pix_height(mtp_device_h mtp_device, mtp_object_ /** * @brief Gets the thumbnail pixel width of the object information. * @since_tizen 3.0 + * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n + * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. \n * * @param [in] mtp_device The MTP device * @param [in] object_handle The object handle diff --git a/packaging/capi-network-mtp.spec b/packaging/capi-network-mtp.spec index 98f917c..17e447f 100755 --- a/packaging/capi-network-mtp.spec +++ b/packaging/capi-network-mtp.spec @@ -1,6 +1,6 @@ Name: capi-network-mtp Summary: A MTP library in Native API -Version: 1.3.2 +Version: 1.3.3 Release: 1 Group: Network & Connectivity/Other License: Apache-2.0 -- 2.7.4