--- /dev/null
+Jihoon Jung <jh8801.jung@samsung.com>
--- /dev/null
+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 <jh8801.jung@samsung.com>")
+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)
+
--- /dev/null
+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.
+
+
+
--- /dev/null
+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.
--- /dev/null
+<manifest>
+ <request>
+ <domain name="_" />
+ </request>
+</manifest>
+
--- /dev/null
+
+# 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}
+
--- /dev/null
+/*
+ * 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 <tizen.h>
+
+#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
--- /dev/null
+/*
+ * 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 <glib.h>
+#include <gio/gio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sqlite3.h>
+
+#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
+
--- /dev/null
+/*
+ * 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 <stdio.h>
+
+#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
--- /dev/null
+/*
+ * 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 <glib.h>
+#include <gio/gio.h>
+
+#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
--- /dev/null
+/*
+ * 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
--- /dev/null
+/*
+ * 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
--- /dev/null
+/*
+ * 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
--- /dev/null
+/*
+ * 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
--- /dev/null
+/*
+ * 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 <mtp.h>
+
+#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
--- /dev/null
+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
--- /dev/null
+/*
+* 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 <stdio.h>
+#include <unistd.h>
+#include <glib.h>
+#include <gio/gio.h>
+#include <stdlib.h>
+
+#include <dlog.h>
+
+#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;
+}
+
--- /dev/null
+/*
+ * 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;
+}
--- /dev/null
+/*
+ * 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;
+}
+
--- /dev/null
+/*
+ * 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;
+}
--- /dev/null
+/*
+ * 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;
+}
+
--- /dev/null
+/*
+ * 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;
+}
--- /dev/null
+<!--
+ org.tizen.mtp
+-->
+
+<node>
+ <interface name="org.tizen.mtp.manager">
+ <method name="GetDeviceList">
+ <arg type="i" name="device_num" direction="out" />
+ <arg type="aa{sv}" name="device_list" direction="out" />
+ <arg type="i" name="result" direction="out" />
+ </method>
+
+ <method name="GetDeviceHandle">
+ <arg type="i" name="bus_location" direction="in" />
+ <arg type="i" name="device_handle" direction="out" />
+ <arg type="i" name="result" direction="out" />
+ </method>
+
+ <method name="GetStorageIds">
+ <arg type="i" name="device_handle" direction="in" />
+ <arg type="i" name="storage_num" direction="out" />
+ <arg type="aa{sv}" name="storage_ids" direction="out" />
+ <arg type="i" name="result" direction="out" />
+ </method>
+
+ <method name="GetObjectHandles">
+ <arg type="i" name="device_handle" direction="in" />
+ <arg type="i" name="storage_id" direction="in" />
+ <arg type="i" name="format" direction="in" />
+ <arg type="i" name="parent_object_handle" direction="in" />
+ <arg type="i" name="object_num" direction="out" />
+ <arg type="aa{sv}" name="object_handles" direction="out" />
+ <arg type="i" name="result" direction="out" />
+ </method>
+
+ <method name="GetObject">
+ <arg type="i" name="device_handle" direction="in" />
+ <arg type="i" name="object_handle" direction="in" />
+ <arg type="s" name="dest_path" direction="in" />
+ <arg type="i" name="result" direction="out" />
+ </method>
+
+ <method name="GetThumbnail">
+ <arg type="i" name="device_handle" direction="in" />
+ <arg type="i" name="object_handle" direction="in" />
+ <arg type="s" name="dest_path" direction="in" />
+ <arg type="i" name="result" direction="out" />
+ </method>
+
+ <method name="DeleteObject">
+ <arg type="i" name="device_handle" direction="in" />
+ <arg type="i" name="object_handle" direction="in" />
+ <arg type="i" name="result" direction="out" />
+ </method>
+
+ <signal name="MtpEvent">
+ <arg type="i" name="event" />
+ <arg type="i" name="arg1" />
+ </signal>
+ </interface>
+ <interface name="org.tizen.mtp.deviceinfo">
+ <method name="GetManufacturername">
+ <arg type="i" name="device_handle" direction="in" />
+ <arg type="s" name="manufacturer_name" direction="out" />
+ <arg type="i" name="result" direction="out" />
+ </method>
+
+ <method name="GetModelname">
+ <arg type="i" name="device_handle" direction="in" />
+ <arg type="s" name="model_name" direction="out" />
+ <arg type="i" name="result" direction="out" />
+ </method>
+
+ <method name="GetSerialnumber">
+ <arg type="i" name="device_handle" direction="in" />
+ <arg type="s" name="serial_number" direction="out" />
+ <arg type="i" name="result" direction="out" />
+ </method>
+
+ <method name="GetDeviceversion">
+ <arg type="i" name="device_handle" direction="in" />
+ <arg type="s" name="device_version" direction="out" />
+ <arg type="i" name="result" direction="out" />
+ </method>
+ </interface>
+ <interface name="org.tizen.mtp.storageinfo">
+ <method name="GetDescription">
+ <arg type="i" name="device_handle" direction="in" />
+ <arg type="i" name="storage_id" direction="in" />
+ <arg type="s" name="description" direction="out" />
+ <arg type="i" name="result" direction="out" />
+ </method>
+
+ <method name="GetFreeSpace">
+ <arg type="i" name="device_handle" direction="in" />
+ <arg type="i" name="storage_id" direction="in" />
+ <arg type="t" name="free_space" direction="out" />
+ <arg type="i" name="result" direction="out" />
+ </method>
+
+ <method name="GetMaxCapacity">
+ <arg type="i" name="device_handle" direction="in" />
+ <arg type="i" name="storage_id" direction="in" />
+ <arg type="t" name="max_capacity" direction="out" />
+ <arg type="i" name="result" direction="out" />
+ </method>
+
+ <method name="GetStorageType">
+ <arg type="i" name="device_handle" direction="in" />
+ <arg type="i" name="storage_id" direction="in" />
+ <arg type="i" name="storage_type" direction="out" />
+ <arg type="i" name="result" direction="out" />
+ </method>
+
+ <method name="GetVolumeIdentifier">
+ <arg type="i" name="device_handle" direction="in" />
+ <arg type="i" name="storage_id" direction="in" />
+ <arg type="s" name="volume_identifier" direction="out" />
+ <arg type="i" name="result" direction="out" />
+ </method>
+ </interface>
+ <interface name="org.tizen.mtp.objectinfo">
+ <method name="GetProperty">
+ <arg type="i" name="device_handle" direction="in" />
+ <arg type="i" name="object_handle" direction="in" />
+ <arg type="i" name="property" direction="in" />
+ <arg type="i" name="property_value" direction="out" />
+ <arg type="i" name="result" direction="out" />
+ </method>
+ <method name="GetPropertyString">
+ <arg type="i" name="device_handle" direction="in" />
+ <arg type="i" name="object_handle" direction="in" />
+ <arg type="i" name="property" direction="in" />
+ <arg type="s" name="property_value" direction="out" />
+ <arg type="i" name="result" direction="out" />
+ </method>
+ </interface>
+</node>
--- /dev/null
+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()
--- /dev/null
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <glib.h>
+#include <sys/time.h>
+
+#include <mtp.h>
+#include <mtp_internal.h>
+
+#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;
+}