From 61af2a21e477ed5fa99d49bb4601cbf12a3d2f22 Mon Sep 17 00:00:00 2001 From: Jihoon Jung Date: Wed, 23 Dec 2015 15:29:54 +0900 Subject: [PATCH] Apply ACR comment in native mtp api Signed-off-by: Ji-hoon Jung Change-Id: I4001f01051ef2b9c450be787fd4e3b97f7fc95f6 --- doc/mtp_doc.h | 168 +++++++ include/mtp.h | 966 ++++++++++++++++++++++++++++------------ include/mtp_db.h | 2 +- include/mtp_gdbus.h | 1 + include/mtp_gdbus_manager.h | 20 +- include/mtp_gdbus_objectinfo.h | 4 +- include/mtp_gdbus_storageinfo.h | 20 +- include/mtp_internal.h | 4 +- include/mtp_private.h | 65 +++ packaging/capi-network-mtp.spec | 2 +- src/mtp.c | 389 +++++++++------- src/mtp_db.c | 6 +- src/mtp_gdbus_deviceinfo.c | 32 +- src/mtp_gdbus_manager.c | 95 ++-- src/mtp_gdbus_objectinfo.c | 16 +- src/mtp_gdbus_storageinfo.c | 60 +-- src/mtp_gdbuslib.xml | 59 +-- test/mtp_unit_test.c | 430 ++++++++---------- 18 files changed, 1491 insertions(+), 848 deletions(-) create mode 100755 doc/mtp_doc.h create mode 100755 include/mtp_private.h diff --git a/doc/mtp_doc.h b/doc/mtp_doc.h new file mode 100755 index 0000000..a041d94 --- /dev/null +++ b/doc/mtp_doc.h @@ -0,0 +1,168 @@ +/* + * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __TIZEN_NETWORK_MTP_DOC_H__ +#define __TIZEN_NETWORK_MTP_DOC_H__ + +/** + * @defgroup CAPI_NETWORK_MTP_MODULE MTP + * @brief The MTP API provides functions for support PTP(Picture Transfer Protocol) subset of MTP(Media Transfer Protocol). + * @ingroup CAPI_NETWORK_FRAMEWORK + * + * @section CAPI_NETWORK_MTP_MODULE_HEADER Required Header + * \#include + * @section CAPI_NETWORK_MTP_MODULE_OVERVIEW Overview + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
API Description
@ref CAPI_NETWORK_MTP_MANAGER_MODULE Provide functions to establish connection to access MTP responder device, and to Get/Delete files
@ref CAPI_NETWORK_MTP_DEVICEINFO_MODULE Provide functions to gets the device information of MTP responder device
@ref CAPI_NETWORK_MTP_STORAGEINFO_MODULE Provide functions to gets the storage information of MTP responder storage
@ref CAPI_NETWORK_MTP_OBJECTINFO_MODULE Provide functions to gets the object information of certain file in MTP responder
+ **/ + +/** + * @defgroup CAPI_NETWORK_MTP_MANAGER_MODULE MTP Manager + * @brief The MTP Manager API provides functions for establish connection to access MTP responder device, and to Get/Delete files. + * @ingroup CAPI_NETWORK_MTP_MODULE + * + * @section CAPI_NETWORK_MTP_MANAGER_MODULE_HEADER Required Header + * \#include + * @section CAPI_NETWORK_MTP_MANAGER_MODULE_OVERVIEW Overview + * The MTP manager api provides following functions :\n + * - Create / destroy connection to access MTP responder device\n + * - Get Device list\n + * - Get Storage list\n + * - Get Object handles\n + * - Get thumbnail\n + * - Get Object\n + * - Delete Object\n + * + * @section CAPI_NETWORK_MTP_MANAGER_MODULE_FEATURE Related Features + * This API is related with the following features:\n + * - http://tizen.org/feature/network.mtp\n + * + * It is recommended to design feature related codes in your application for reliability.\n + * + * You can check if a device supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, thereby controlling the procedure of your application.\n + * + * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n + * + * More details on featuring your application can be found from Feature List. + * + */ + +/* + * @defgroup CAPI_NETWORK_MTP_DEVICEINFO_MODULE MTP Device Information + * @brief The MTP Device Information API provides functions for gets the device information of MTP responder device. + * @ingroup CAPI_NETWORK_MTP_MODULE + * + * @section CAPI_NETWORK_MTP_DEVICEINFO_MODULE_HEADER Required Header + * \#include + * @section CAPI_NETWORK_MTP_DEVICEINFO_MODULE_OVERVIEW Overview + * The MTP Device Information api provides following functions :\n + * - Get device manufacturer name\n + * - Get device model name\n + * - Get device serial number\n + * - Get device version\n + * + * @section CAPI_NETWORK_MTP_DEVICEINFO_MODULE_FEATURE Related Features + * This API is related with the following features:\n + * - http://tizen.org/feature/network.mtp\n + * + * It is recommended to design feature related codes in your application for reliability.\n + * + * You can check if a device supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, thereby controlling the procedure of your application.\n + * + * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n + * + * More details on featuring your application can be found from Feature List. + * + */ + + +/* + * @defgroup CAPI_NETWORK_MTP_STORAGEINFO_MODULE MTP Storage Information + * @brief The MTP Storage Information API provides functions for gets the storage information of MTP responder storage. + * @ingroup CAPI_NETWORK_MTP_MODULE + * + * @section CAPI_NETWORK_MTP_STORAGEINFO_MODULE_HEADER Required Header + * \#include + * @section CAPI_NETWORK_MTP_STORAGEINFO_MODULE_OVERVIEW Overview + * The MTP Storage Information api provides following functions :\n + * - Get storage free space\n + * - Get storage description\n + * - Get storage type\n + * - and, more storage information\n + * + * @section CAPI_NETWORK_MTP_STORAGEINFO_MODULE_FEATURE Related Features + * This API is related with the following features:\n + * - http://tizen.org/feature/network.mtp\n + * + * It is recommended to design feature related codes in your application for reliability.\n + * + * You can check if a device supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, thereby controlling the procedure of your application.\n + * + * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n + * + * More details on featuring your application can be found from Feature List. + * + */ + +/* + * @defgroup CAPI_NETWORK_MTP_OBJECTINFO_MODULE MTP Object Information + * @brief The MTP Manager API provides functions for gets the object information of certain file in MTP responder. + * @ingroup CAPI_NETWORK_MTP_MODULE + * + * @section CAPI_NETWORK_MTP_OBJECTINFO_MODULE_HEADER Required Header + * \#include + * @section CAPI_NETWORK_MTP_OBJECTINFO_MODULE_OVERVIEW Overview + * The MTP Object Information api provides following functions :\n + * - Get object format\n + * - Get object name\n + * - Get object size\n + * - and, more object information\n + * + * @section CAPI_NETWORK_MTP_OBJECTINFO_MODULE_FEATURE Related Features + * This API is related with the following features:\n + * - http://tizen.org/feature/network.mtp\n + * + * It is recommended to design feature related codes in your application for reliability.\n + * + * You can check if a device supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, thereby controlling the procedure of your application.\n + * + * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n + * + * More details on featuring your application can be found from Feature List. + * + */ + +#endif diff --git a/include/mtp.h b/include/mtp.h index 1f6f3ac..79a3b4c 100755 --- a/include/mtp.h +++ b/include/mtp.h @@ -23,60 +23,66 @@ extern "C" { #endif -#ifndef MTP_API -#define MTP_API -#endif - /** * @file mtp.h * @brief This file contains the MTP API */ -#define MTP_ERROR_CLASS TIZEN_ERROR_NETWORK_CLASS /* Need define mtp error class */ +#ifndef TIZEN_ERROR_MTP +#define TIZEN_ERROR_MTP -0x03000000 +#endif /** - * @brief Structure for mtp device + * @addtogroup CAPI_NETWORK_MTP_MANAGER_MODULE + * @{ + */ + +/** + * @brief The handle to the mtp raw device * @since_tizen 3.0 - * @ingroup CAPI_NETWORK_MTP_MANAGER_MODULE */ -typedef struct _mtp_device { - int bus_location; - char *model_name; -} mtp_device; +typedef struct mtp_raw_device *mtp_raw_device_h; /** - * @brief Structure for mtp device list + * @brief The handle to the mtp device * @since_tizen 3.0 - * @ingroup CAPI_NETWORK_MTP_MANAGER_MODULE */ -typedef struct _mtp_device_list { - mtp_device *devices; - int device_num; -} mtp_device_list; +typedef int mtp_device_h; + +/** + * @brief The handle to the mtp storage + * @since_tizen 3.0 + */ +typedef int mtp_storage_h; + +/** + * @brief The handle to the mtp object + * @since_tizen 3.0 + */ +typedef int mtp_object_h; /** * @brief Error codes reported by the MTP API. * @since_tizen 3.0 - * @ingroup CAPI_NETWORK_MTP_MANAGER_MODULE */ typedef enum { MTP_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */ - MTP_ERROR_GENERAL = MTP_ERROR_CLASS | 0x01, /**< A general error occurred */ MTP_ERROR_IO_ERROR = TIZEN_ERROR_IO_ERROR, /**< I/O error */ MTP_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */ - MTP_ERROR_NO_DEVICE = MTP_ERROR_CLASS | 0x02, /**< MTP have not any device */ - MTP_ERROR_ALLOC_FAIL = MTP_ERROR_CLASS | 0x03, /**< Memory Allocation failed */ - MTP_ERROR_PLUGIN = MTP_ERROR_CLASS | 0x04, /**< Plugin failed */ - MTP_ERROR_DB = MTP_ERROR_CLASS | 0x05, /**< Plugin failed */ + MTP_ERROR_NO_DEVICE = TIZEN_ERROR_MTP | 0x01, /**< MTP have not any device */ + MTP_ERROR_ALLOC_FAIL = TIZEN_ERROR_MTP | 0x02, /**< Memory Allocation failed */ + MTP_ERROR_PLUGIN_FAIL = TIZEN_ERROR_MTP | 0x03, /**< Plugin failed */ MTP_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */ - MTP_ERROR_NOT_INITIALIZED = MTP_ERROR_CLASS | 0x06, /**< MTP is not supported */ - MTP_ERROR_NOT_ACTIVATED = MTP_ERROR_CLASS | 0x07, /**< MTP is not activated */ + MTP_ERROR_COMM_ERROR = TIZEN_ERROR_MTP | 0x04, /**< MTP communication error */ + MTP_ERROR_CONTROLLER = TIZEN_ERROR_MTP | 0x05, /**< MTP controller error */ + MTP_ERROR_NOT_INITIALIZED = TIZEN_ERROR_MTP | 0x06, /**< MTP is not initialized */ + MTP_ERROR_NOT_ACTIVATED = TIZEN_ERROR_MTP | 0x07, /**< MTP is not activated */ MTP_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< MTP is not supported */ + MTP_ERROR_NOT_COMM_INITIALIZED = TIZEN_ERROR_MTP | 0x08 /**< MTP communication is not initialized */ } mtp_error_e; /** * @brief Enumerations for MTP file type * @since_tizen 3.0 - * @ingroup CAPI_NETWORK_MTP_MANAGER_MODULE */ typedef enum { MTP_FILETYPE_FOLDER, /**< FOLDER file type */ @@ -125,14 +131,13 @@ typedef enum { MTP_FILETYPE_PLAYLIST, /**< PLAYLIST file type */ MTP_FILETYPE_UNKNOWN, /**< Unknown file type */ - MTP_FILETYPE_ALL, /**< helper enum value for certain function */ - MTP_FILETYPE_ALL_IMAGE /**< helper enum value for certain function */ + MTP_FILETYPE_ALL, /**< Helper enum value for certain function */ + MTP_FILETYPE_ALL_IMAGE /**< Helper enum value for certain function */ } mtp_filetype_e; /** * @brief Enumerations for MTP event type * @since_tizen 3.0 - * @ingroup CAPI_NETWORK_MTP_MANAGER_MODULE */ typedef enum { MTP_EVENT_UNKNOWN, /**< Unknown event type */ @@ -142,604 +147,977 @@ typedef enum { MTP_EVENT_OBJECT_REMOVED, /**< Object is removed */ MTP_EVENT_DEVICE_ADDED, /**< Device is added */ MTP_EVENT_DEVICE_REMOVED, /**< Device is removed */ - MTP_EVENT_DAEMON_TERMINATED /**< Daemon is terminated */ + MTP_EVENT_TURNED_OFF /**< MTP is turned off */ } mtp_event_e; /** * @brief Called after mtp_set_mtp_event_cb() has completed. * @since_tizen 3.0 - * @ingroup CAPI_NETWORK_MTP_MANAGER_MODULE + * @remarks Depending on the type of event, the meaning of event parameter is different. + * - If event is device event, then event_parameter type is mtp_device_h. + * - If event is storage event, then event_parameter type is mtp_storage_h. + * - If event is object event, then event_parameter type is mtp_object_h. + * - If event is MTP_EVENT_TURNED_OFF, then event_parameter is 0. * * @param [in] event The event - * @param [in] arg The argument + * @param [in] event_parameter The event parameter * @param [in] user_data The user data passed from the callback registration function * * @see mtp_set_mtp_event_cb() * @see mtp_unset_mtp_event_cb() */ -typedef void (* mtp_event_cb)(mtp_event_e event, int arg, void *user_data); +typedef void (* mtp_event_cb)(mtp_event_e event, int event_parameter, void *user_data); /** * @brief Initializes for using MTP. * @since_tizen 3.0 - * @ingroup CAPI_NETWORK_MTP_MANAGER_MODULE - * @remarks This function must be called before proceeding any other mtp functions\n + * @remarks This function must be called before proceeding any other mtp functions. * * @return 0 on success, otherwise a negative error value. * @retval #MTP_ERROR_NONE Successful + * @retval #MTP_ERROR_NOT_SUPPORTED MTP is not supported + * @retval #MTP_ERROR_PERMISSION_DENIED Permission Denied + * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized * * @see mtp_deinitialize() */ -MTP_API int mtp_initialize(void); +int mtp_initialize(void); /** - * @brief Get device list. + * @brief Gets device list. * @since_tizen 3.0 - * @ingroup CAPI_NETWORK_MTP_MANAGER_MODULE + * @remarks The @a raw_devices should be freed using mtp_destroy_raw_devices(). + * + * @param [out] raw_devices All current connected device list + * @param [out] device_count The count of device * * @return 0 on success, otherwise a negative error value. * @retval #MTP_ERROR_NONE Successful + * @retval #MTP_ERROR_NOT_SUPPORTED MTP is not supported + * @retval #MTP_ERROR_NOT_INITIALIZED MTP is not initialized + * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated + * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized * - * @param [out] dev_list All current device list + * @see mtp_destroy_raw_devices() */ -MTP_API int mtp_get_device_list(mtp_device_list **dev_list); +int mtp_get_raw_devices(mtp_raw_device_h **raw_devices, int *device_count); /** - * @brief Get device handler from bus location + * @brief Gets bus location from raw device. * @since_tizen 3.0 - * @ingroup CAPI_NETWORK_MTP_MANAGER_MODULE + * @remarks The @a raw_device can get using mtp_get_raw_devices(). + * + * @param [in] raw_device The raw device + * @param [out] bus_location The bus location * * @return 0 on success, otherwise a negative error value. * @retval #MTP_ERROR_NONE Successful + * @retval #MTP_ERROR_NOT_SUPPORTED MTP is not supported + * @retval #MTP_ERROR_NOT_INITIALIZED MTP is not initialized + * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter * - * @param [in] bus_location The bus location - * @param [out] device_handle The device handle - * - * @see mtp_initialize() + * @see mtp_get_raw_devices() */ -MTP_API int mtp_get_device_handle(int bus_location, int* device_handle); +int mtp_get_bus_location(mtp_raw_device_h raw_device, int *bus_location); /** - * @brief Get storage ids from device + * @brief Gets device number from raw device. * @since_tizen 3.0 - * @ingroup CAPI_NETWORK_MTP_MANAGER_MODULE + * @remarks The @a raw_device can get using mtp_get_raw_devices(). + * + * @param [in] raw_device The raw device + * @param [out] device_number The device number * * @return 0 on success, otherwise a negative error value. * @retval #MTP_ERROR_NONE Successful + * @retval #MTP_ERROR_NOT_SUPPORTED MTP is not supported + * @retval #MTP_ERROR_NOT_INITIALIZED MTP is not initialized + * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter * - * @param [in] device_handle The device handle - * @param [out] storage_id Current storage id list - * @param [out] storage_num Length of storage id list - * - * @see mtp_get_device_handle() + * @see mtp_get_raw_devices() */ -MTP_API int mtp_get_storage_ids(int device_handle, int **storage_id, int* storage_num); +int mtp_get_device_number(mtp_raw_device_h raw_device, int *device_number); /** - * @brief Get object handles from device + * @brief Gets device name from raw device. * @since_tizen 3.0 - * @ingroup CAPI_NETWORK_MTP_MANAGER_MODULE + * @remarks The @a raw_device can get using mtp_get_raw_devices(). + * @remarks The @a model_name should be freed using free(). + * + * @param [in] raw_device The raw device + * @param [out] model_name The model name * * @return 0 on success, otherwise a negative error value. * @retval #MTP_ERROR_NONE Successful + * @retval #MTP_ERROR_NOT_SUPPORTED MTP is not supported + * @retval #MTP_ERROR_NOT_INITIALIZED MTP is not initialized + * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter * - * @param [in] device_handle The device handle - * @param [in] storage_id The storage id - * @param [in] format The file type what you want - * @param [in] parent_object_handle The parent object handle - * @param [out] object_handles The object handle list - * @param [out] object_num Length of object handle list - * - * @see mtp_get_device_handle() - * @see mtp_get_storage_ids() + * @see mtp_get_raw_devices() */ -MTP_API int mtp_get_object_handles(int device_handle, int storage_id, int format, - int parent_object_handle, int **object_handles, int* object_num); +int mtp_get_device_name(mtp_raw_device_h raw_device, char **model_name); /** - * @brief Delete object from device + * @brief Destroys the raw devices handler. * @since_tizen 3.0 - * @ingroup CAPI_NETWORK_MTP_MANAGER_MODULE + * + * @param [in] raw_devices The raw devices handler * * @return 0 on success, otherwise a negative error value. * @retval #MTP_ERROR_NONE Successful + * @retval #MTP_ERROR_NOT_SUPPORTED MTP is not supported + * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter * - * @param [in] device_handle The device handle - * @param [in] object_handle The object handle - * - * @see mtp_get_device_handle() - * @see mtp_get_object_handles() + * @see mtp_get_raw_devices() */ -MTP_API int mtp_delete_object(int device_handle, int object_handle); +int mtp_destroy_raw_devices(mtp_raw_device_h *raw_devices); /** - * @brief Get object from object handle + * @brief Gets device handler from bus location. * @since_tizen 3.0 - * @ingroup CAPI_NETWORK_MTP_MANAGER_MODULE + * @remarks For using this api, you should get bus location and device number from raw device. + * + * @param [in] bus_location The bus location + * @param [in] device_number The device number + * @param [out] mtp_device The MTP device * * @return 0 on success, otherwise a negative error value. * @retval #MTP_ERROR_NONE Successful + * @retval #MTP_ERROR_NOT_SUPPORTED MTP is not supported + * @retval #MTP_ERROR_NOT_INITIALIZED MTP is not initialized + * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated + * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized + * @retval #MTP_ERROR_COMM MTP communication error + * + * @pre mtp_get_bus_location(), mtp_get_device_number() + * @see mtp_initialize() + */ +int mtp_get_device(int bus_location, int device_number, mtp_device_h *mtp_device); + +/** + * @brief Gets mtp storages from device. + * @since_tizen 3.0 + * @remarks The @a mtp_storages should be freed using free(). * - * @param [in] device_handle The device handle - * @param [in] object_handle The object handle - * @param [in] dest_path The dest path + * @param [in] mtp_device The MTP device + * @param [out] mtp_storages Current mtp storage list + * @param [out] storage_num Length of storage list * - * @see mtp_get_device_handle() - * @see mtp_get_object_handles() + * @return 0 on success, otherwise a negative error value. + * @retval #MTP_ERROR_NONE Successful + * @retval #MTP_ERROR_NOT_SUPPORTED MTP is not supported + * @retval #MTP_ERROR_NOT_INITIALIZED MTP is not initialized + * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated + * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized + * @retval #MTP_ERROR_COMM MTP communication error + * + * @see mtp_get_device() */ -MTP_API int mtp_get_object(int device_handle, int object_handle, char *dest_path); +int mtp_get_storages(mtp_device_h mtp_device, mtp_storage_h **mtp_storages, int* storage_num); /** - * @brief Get thumbnail from object handle + * @brief Gets object handles from device. * @since_tizen 3.0 - * @ingroup CAPI_NETWORK_MTP_MANAGER_MODULE + * @remarks The @a object_handles should be freed using free(). + * @remarks If the @a parent is 0, it means "root folder" of mtp storage. + * + * @param [in] mtp_device The MTP device + * @param [in] mtp_storage The MTP storage + * @param [in] file_type The file type what you want + * @param [in] parent The parent object handle + * @param [out] object_handles The object handle list + * @param [out] object_num Length of object handle list * * @return 0 on success, otherwise a negative error value. * @retval #MTP_ERROR_NONE Successful + * @retval #MTP_ERROR_NOT_SUPPORTED MTP is not supported + * @retval #MTP_ERROR_NOT_INITIALIZED MTP is not initialized + * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated + * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized + * @retval #MTP_ERROR_COMM MTP communication error + * + * @see mtp_get_device() + * @see mtp_get_storages() + */ +int mtp_get_object_handles(mtp_device_h mtp_device, mtp_storage_h mtp_storage, mtp_filetype_e file_type, + mtp_object_h parent, mtp_object_h **object_handles, int* object_num); + +/** + * @brief Gets object for a given path from object handle. + * @since_tizen 3.0 + * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n + * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. \n * - * @param [in] device_handle The device handle + * @param [in] mtp_device The MTP device * @param [in] object_handle The object handle * @param [in] dest_path The dest path * - * @see mtp_get_device_handle() + * @return 0 on success, otherwise a negative error value. + * @retval #MTP_ERROR_NONE Successful + * @retval #MTP_ERROR_NOT_SUPPORTED MTP is not supported + * @retval #MTP_ERROR_NOT_INITIALIZED MTP is not initialized + * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated + * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized + * @retval #MTP_ERROR_COMM MTP communication error + * @retval #MTP_ERROR_IO_ERROR I/O error + * + * @see mtp_get_device() * @see mtp_get_object_handles() */ -MTP_API int mtp_get_thumbnail(int device_handle, int object_handle, char *dest_path); +int mtp_get_object(mtp_device_h mtp_device, mtp_object_h object_handle, char *dest_path); /** - * @brief Registers a callback function for receiving MTP event. + * @brief Gets thumbnail from object handle. * @since_tizen 3.0 - * @ingroup CAPI_NETWORK_MTP_MANAGER_MODULE + * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n + * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. * - * @detail If device state is changed, DEVICE_ADD or DEVICE_REMOVE event is occur. \n - * If storage state is changed, STORAGE_ADD or STORAGE_REMOVE event is occur. \n - * If object state is changed, OBJECT_ADD or OBJECT_REMOVE event is occur. + * @param [in] mtp_device The MTP device + * @param [in] object_handle The object handle + * @param [in] dest_path The dest path * * @return 0 on success, otherwise a negative error value. * @retval #MTP_ERROR_NONE Successful + * @retval #MTP_ERROR_NOT_SUPPORTED MTP is not supported + * @retval #MTP_ERROR_NOT_INITIALIZED MTP is not initialized + * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated + * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized + * @retval #MTP_ERROR_COMM MTP communication error + * @retval #MTP_ERROR_IO_ERROR I/O error + * + * @see mtp_get_device() + * @see mtp_get_object_handles() + */ +int mtp_get_thumbnail(mtp_device_h mtp_device, mtp_object_h object_handle, char *dest_path); + +/** + * @brief Registers a callback function for receiving MTP event. + * @since_tizen 3.0 + * + * @remarks If device state is changed, DEVICE_ADD or DEVICE_REMOVE event is occur. \n + * If storage state is changed, STORAGE_ADD or STORAGE_REMOVE event is occur. \n + * If object state is changed, OBJECT_ADD or OBJECT_REMOVE event is occur. * - * @param [in] callback The callback + * @param [in] event_cb The callback * @param [in] user_data The user data * + * @return 0 on success, otherwise a negative error value. + * @retval #MTP_ERROR_NONE Successful + * @retval #MTP_ERROR_NOT_SUPPORTED MTP is not supported + * @retval #MTP_ERROR_NOT_INITIALIZED MTP is not initialized + * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter + * @see mtp_unset_mtp_event_cb() */ -MTP_API int mtp_set_mtp_event_cb(mtp_event_cb callback, void *user_data); +int mtp_set_mtp_event_cb(mtp_event_cb event_cb, void *user_data); /** * @brief Unregisters the callback function. * @since_tizen 3.0 - * @ingroup CAPI_NETWORK_MTP_MANAGER_MODULE * * @return 0 on success, otherwise a negative error value. * @retval #MTP_ERROR_NONE Successful + * @retval #MTP_ERROR_NOT_SUPPORTED MTP is not supported + * @retval #MTP_ERROR_NOT_INITIALIZED MTP is not initialized * * @see mtp_set_mtp_event_cb() */ -MTP_API int mtp_unset_mtp_event_cb(void); +int mtp_unset_mtp_event_cb(void); /** * @brief Deinitializes MTP operation. * @since_tizen 3.0 - * @ingroup CAPI_NETWORK_MTP_MANAGER_MODULE * * @return 0 on success, otherwise a negative error value. * @retval #MTP_ERROR_NONE Successful + * @retval #MTP_ERROR_NOT_SUPPORTED MTP is not supported + * @retval #MTP_ERROR_PERMISSION_DENIED Permission Denied * * @see mtp_initialize() */ -MTP_API int mtp_deinitialize(void); +int mtp_deinitialize(void); /** - * @brief Get the manufacturer name of the device information. +* @} +*/ + +/** + * @addtogroup CAPI_NETWORK_MTP_DEVICEINFO_MODULE + * @{ + */ + +/** + * @brief Gets the manufacturer name of the device information. * @since_tizen 3.0 - * @ingroup CAPI_NETWORK_MTP_DEVICEINFO_MODULE + * @remarks The @a manufacturer_name should be freed using free(). + * + * @param [in] mtp_device The MTP device + * @param [out] manufacturer_name The manufacturer name of Device information * * @return 0 on success, otherwise a negative error value. * @retval #MTP_ERROR_NONE Successful - * - * @param [in] device_handle The device handle - * @param [out] manufacturername The manufacturername of Device information - * - * @see mtp_get_device_handle() + * @retval #MTP_ERROR_NOT_SUPPORTED MTP is not supported + * @retval #MTP_ERROR_NOT_INITIALIZED MTP is not initialized + * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated + * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized + * @retval #MTP_ERROR_COMM MTP communication error + * @retval #MTP_ERROR_CONTROLLER MTP controller error + * @retval #MTP_ERROR_ALLOC_FAIL Memory Allocation failed + * @retval #MTP_ERROR_NO_DEVICE MTP have not any device + * + * @see mtp_get_device() */ -MTP_API int mtp_deviceinfo_get_manufacturername(int device_handle, char **manufacturername); +int mtp_deviceinfo_get_manufacturer_name(mtp_device_h mtp_device, char **manufacturer_name); /** - * @brief Get the model name of the device information. + * @brief Gets the model name of the device information. * @since_tizen 3.0 - * @ingroup CAPI_NETWORK_MTP_DEVICEINFO_MODULE + * @remarks The @a model_name should be freed using free(). + * + * @param [in] mtp_device The MTP device + * @param [out] model_name The model name of Device information * * @return 0 on success, otherwise a negative error value. * @retval #MTP_ERROR_NONE Successful - * - * @param [in] device_handle The device handle - * @param [out] modelname The modelname of Device information - * - * @see mtp_get_device_handle() + * @retval #MTP_ERROR_NOT_SUPPORTED MTP is not supported + * @retval #MTP_ERROR_NOT_INITIALIZED MTP is not initialized + * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated + * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized + * @retval #MTP_ERROR_COMM MTP communication error + * @retval #MTP_ERROR_CONTROLLER MTP controller error + * @retval #MTP_ERROR_ALLOC_FAIL Memory Allocation failed + * @retval #MTP_ERROR_NO_DEVICE MTP have not any device + * + * @see mtp_get_device() */ -MTP_API int mtp_deviceinfo_get_modelname(int device_handle, char **modelname); +int mtp_deviceinfo_get_model_name(mtp_device_h mtp_device, char **model_name); /** - * @brief Get the serial number of the device information. + * @brief Gets the serial number of the device information. * @since_tizen 3.0 - * @ingroup CAPI_NETWORK_MTP_DEVICEINFO_MODULE + * @remarks The @a serial_number should be freed using free(). + * + * @param [in] mtp_device The MTP device + * @param [out] serial_number The serial number of Device information * * @return 0 on success, otherwise a negative error value. * @retval #MTP_ERROR_NONE Successful - * - * @param [in] device_handle The device handle - * @param [out] serialnumber The serialnumber of Device information - * - * @see mtp_get_device_handle() + * @retval #MTP_ERROR_NOT_SUPPORTED MTP is not supported + * @retval #MTP_ERROR_NOT_INITIALIZED MTP is not initialized + * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated + * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized + * @retval #MTP_ERROR_COMM MTP communication error + * @retval #MTP_ERROR_CONTROLLER MTP controller error + * @retval #MTP_ERROR_ALLOC_FAIL Memory Allocation failed + * @retval #MTP_ERROR_NO_DEVICE MTP have not any device + * + * @see mtp_get_device() */ -MTP_API int mtp_deviceinfo_get_serialnumber(int device_handle, char **serialnumber); +int mtp_deviceinfo_get_serial_number(mtp_device_h mtp_device, char **serial_number); /** - * @brief Get the device version of the device information. + * @brief Gets the device version of the device information. * @since_tizen 3.0 - * @ingroup CAPI_NETWORK_MTP_DEVICEINFO_MODULE + * @remarks The @a device_version should be freed using free(). + * + * @param [in] mtp_device The MTP device + * @param [out] device_version The device version of Device information * * @return 0 on success, otherwise a negative error value. * @retval #MTP_ERROR_NONE Successful - * - * @param [in] device_handle The device handle - * @param [out] serialnumber The deviceversion of Device information - * - * @see mtp_get_device_handle() + * @retval #MTP_ERROR_NOT_SUPPORTED MTP is not supported + * @retval #MTP_ERROR_NOT_INITIALIZED MTP is not initialized + * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated + * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized + * @retval #MTP_ERROR_COMM MTP communication error + * @retval #MTP_ERROR_CONTROLLER MTP controller error + * @retval #MTP_ERROR_ALLOC_FAIL Memory Allocation failed + * @retval #MTP_ERROR_NO_DEVICE MTP have not any device + * + * @see mtp_get_device() */ -MTP_API int mtp_deviceinfo_get_deviceversion(int device_handle, char **deviceversion); +int mtp_deviceinfo_get_device_version(mtp_device_h mtp_device, char **device_version); + +/** +* @} +*/ /** - * @brief Get the description of the storage information. + * @addtogroup CAPI_NETWORK_MTP_STORAGEINFO_MODULE + * @{ + */ + +/** + * @brief Gets the description of the storage information. * @since_tizen 3.0 - * @ingroup CAPI_NETWORK_MTP_STORAGEINFO_MODULE - * - * @return 0 on success, otherwise a negative error value. - * @retval #MTP_ERROR_NONE Successful + * @remarks The @a description should be freed using free(). * - * @param [in] device_handle The device handle - * @param [in] storage_id The storage id + * @param [in] mtp_device The MTP device + * @param [in] mtp_storage The MTP storage * @param [out] description The description of Storage information * - * @see mtp_get_storage_ids() + * @return 0 on success, otherwise a negative error value. + * @retval #MTP_ERROR_NONE Successful + * @retval #MTP_ERROR_NOT_SUPPORTED MTP is not supported + * @retval #MTP_ERROR_NOT_INITIALIZED MTP is not initialized + * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated + * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized + * @retval #MTP_ERROR_COMM MTP communication error + * @retval #MTP_ERROR_CONTROLLER MTP controller error + * @retval #MTP_ERROR_ALLOC_FAIL Memory Allocation failed + * @retval #MTP_ERROR_NO_DEVICE MTP have not any device + * + * @see mtp_get_storages() */ -MTP_API int mtp_storageinfo_get_description(int device_handle, int storage_id, char **description); +int mtp_storageinfo_get_description(mtp_device_h mtp_device, mtp_storage_h mtp_storage, char **description); /** - * @brief Get the freespace of the storage information. + * @brief Gets the freespace of the storage information. * @since_tizen 3.0 - * @ingroup CAPI_NETWORK_MTP_STORAGEINFO_MODULE + * + * @param [in] mtp_device The MTP device + * @param [in] mtp_storage The MTP storage + * @param [out] free_space The free space of Storage information * * @return 0 on success, otherwise a negative error value. * @retval #MTP_ERROR_NONE Successful - * - * @param [in] device_handle The device handle - * @param [in] storage_id The storage id - * @param [out] freespace The freespace of Storage information - * - * @see mtp_get_storage_ids() + * @retval #MTP_ERROR_NOT_SUPPORTED MTP is not supported + * @retval #MTP_ERROR_NOT_INITIALIZED MTP is not initialized + * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated + * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized + * @retval #MTP_ERROR_COMM MTP communication error + * @retval #MTP_ERROR_CONTROLLER MTP controller error + * @retval #MTP_ERROR_ALLOC_FAIL Memory Allocation failed + * @retval #MTP_ERROR_NO_DEVICE MTP have not any device + * + * @see mtp_get_storages() */ -MTP_API int mtp_storageinfo_get_freespace(int device_handle, int storage_id, unsigned long long *freespace); +int mtp_storageinfo_get_free_space(mtp_device_h mtp_device, mtp_storage_h mtp_storage, unsigned long long *free_space); /** - * @brief Get the max capacity of the storage information. + * @brief Gets the max capacity of the storage information. * @since_tizen 3.0 - * @ingroup CAPI_NETWORK_MTP_STORAGEINFO_MODULE + * + * @param [in] mtp_device The MTP device + * @param [in] mtp_storage The MTP storage + * @param [out] max_capacity The max capacity of Storage information * * @return 0 on success, otherwise a negative error value. * @retval #MTP_ERROR_NONE Successful - * - * @param [in] device_handle The device handle - * @param [in] storage_id The storage id - * @param [out] maxcapacity The maxcapacity of Storage information - * - * @see mtp_get_storage_ids() + * @retval #MTP_ERROR_NOT_SUPPORTED MTP is not supported + * @retval #MTP_ERROR_NOT_INITIALIZED MTP is not initialized + * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated + * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized + * @retval #MTP_ERROR_COMM MTP communication error + * @retval #MTP_ERROR_CONTROLLER MTP controller error + * @retval #MTP_ERROR_ALLOC_FAIL Memory Allocation failed + * @retval #MTP_ERROR_NO_DEVICE MTP have not any device + * + * @see mtp_get_storages() */ -MTP_API int mtp_storageinfo_get_maxcapacity(int device_handle, int storage_id, unsigned long long *maxcapacity); +int mtp_storageinfo_get_max_capacity(mtp_device_h mtp_device, mtp_storage_h mtp_storage, unsigned long long *max_capacity); /** - * @brief Get the storage type of the storage information. + * @brief Gets the storage type of the storage information. * @since_tizen 3.0 - * @ingroup CAPI_NETWORK_MTP_STORAGEINFO_MODULE + * + * @param [in] mtp_device The MTP device + * @param [in] mtp_storage The MTP storage + * @param [out] storage_type The storage type of Storage information * * @return 0 on success, otherwise a negative error value. * @retval #MTP_ERROR_NONE Successful - * - * @param [in] device_handle The device handle - * @param [in] storage_id The storage id - * @param [out] storagetype The storagetype of Storage information - * - * @see mtp_get_storage_ids() + * @retval #MTP_ERROR_NOT_SUPPORTED MTP is not supported + * @retval #MTP_ERROR_NOT_INITIALIZED MTP is not initialized + * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated + * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized + * @retval #MTP_ERROR_COMM MTP communication error + * @retval #MTP_ERROR_CONTROLLER MTP controller error + * @retval #MTP_ERROR_ALLOC_FAIL Memory Allocation failed + * @retval #MTP_ERROR_NO_DEVICE MTP have not any device + * + * @see mtp_get_storages() */ -MTP_API int mtp_storageinfo_get_storagetype(int device_handle, int storage_id, int *storagetype); +int mtp_storageinfo_get_storage_type(mtp_device_h mtp_device, mtp_storage_h mtp_storage, int *storage_type); /** - * @brief Get the volumeidentifier of the storage information. + * @brief Gets the volumeidentifier of the storage information. * @since_tizen 3.0 - * @ingroup CAPI_NETWORK_MTP_STORAGEINFO_MODULE + * @remarks The @a volume_identifier should be freed using free(). + * + * @param [in] mtp_device The MTP device + * @param [in] mtp_storage The MTP storage + * @param [out] volume_identifier The volume identifier of Storage information * * @return 0 on success, otherwise a negative error value. * @retval #MTP_ERROR_NONE Successful - * - * @param [in] device_handle The device handle - * @param [in] storage_id The storage id - * @param [out] volumeidentifier The volumeidentifier of Storage information + * @retval #MTP_ERROR_NOT_SUPPORTED MTP is not supported + * @retval #MTP_ERROR_NOT_INITIALIZED MTP is not initialized + * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated + * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized + * @retval #MTP_ERROR_COMM MTP communication error + * @retval #MTP_ERROR_CONTROLLER MTP controller error + * @retval #MTP_ERROR_ALLOC_FAIL Memory Allocation failed + * @retval #MTP_ERROR_NO_DEVICE MTP have not any device * * @see mtp_get_object_handles() */ -MTP_API int mtp_storageinfo_get_volumeidentifier(int device_handle, int storage_id, char **volumeidentifier); +int mtp_storageinfo_get_volume_identifier(mtp_device_h mtp_device, mtp_storage_h mtp_storage, char **volume_identifier); + +/** +* @} +*/ /** - * @brief Get the filename of the object information. + * @addtogroup CAPI_NETWORK_MTP_OBJECTINFO_MODULE + * @{ + */ + +/** + * @brief Gets the filename of the object information. * @since_tizen 3.0 - * @ingroup CAPI_NETWORK_MTP_OBJECTINFO_MODULE + * @remarks The @a file_name should be freed using free(). + * + * @param [in] mtp_device The MTP device + * @param [in] object_handle The object handle + * @param [out] file_name The file name of Object information * * @return 0 on success, otherwise a negative error value. * @retval #MTP_ERROR_NONE Successful - * - * @param [in] device_handle The device handle - * @param [in] object_handle The object handle - * @param [out] filename The filename of Object information + * @retval #MTP_ERROR_NOT_SUPPORTED MTP is not supported + * @retval #MTP_ERROR_NOT_INITIALIZED MTP is not initialized + * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated + * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized + * @retval #MTP_ERROR_COMM MTP communication error + * @retval #MTP_ERROR_CONTROLLER MTP controller error + * @retval #MTP_ERROR_ALLOC_FAIL Memory Allocation failed + * @retval #MTP_ERROR_NO_DEVICE MTP have not any device + * @retval #MTP_ERROR_PLUGIN Plugin failed * * @see mtp_get_object_handles() */ -MTP_API int mtp_objectinfo_get_filename(int device_handle, int object_handle, char **filename); +int mtp_objectinfo_get_file_name(mtp_device_h mtp_device, mtp_object_h object_handle, char **file_name); /** - * @brief Get the keywords of the object information. + * @brief Gets the keywords of the object information. * @since_tizen 3.0 - * @ingroup CAPI_NETWORK_MTP_OBJECTINFO_MODULE - * - * @return 0 on success, otherwise a negative error value. - * @retval #MTP_ERROR_NONE Successful + * @remarks The @a keywords should be freed using free(). * - * @param [in] device_handle The device handle + * @param [in] mtp_device The MTP device * @param [in] object_handle The object handle * @param [out] keywords The keywords of Object information * + * @return 0 on success, otherwise a negative error value. + * @retval #MTP_ERROR_NONE Successful + * @retval #MTP_ERROR_NOT_SUPPORTED MTP is not supported + * @retval #MTP_ERROR_NOT_INITIALIZED MTP is not initialized + * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated + * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized + * @retval #MTP_ERROR_COMM MTP communication error + * @retval #MTP_ERROR_CONTROLLER MTP controller error + * @retval #MTP_ERROR_ALLOC_FAIL Memory Allocation failed + * @retval #MTP_ERROR_NO_DEVICE MTP have not any device + * @retval #MTP_ERROR_PLUGIN Plugin failed + * * @see mtp_get_object_handles() */ -MTP_API int mtp_objectinfo_get_keywords(int device_handle, int object_handle, char **keywords); +int mtp_objectinfo_get_keywords(mtp_device_h mtp_device, mtp_object_h object_handle, char **keywords); /** - * @brief Get the association desc of the object information. + * @brief Gets the association desc of the object information. * @since_tizen 3.0 - * @ingroup CAPI_NETWORK_MTP_OBJECTINFO_MODULE - * - * @return 0 on success, otherwise a negative error value. - * @retval #MTP_ERROR_NONE Successful * - * @param [in] device_handle The device handle + * @param [in] mtp_device The MTP device * @param [in] object_handle The object handle * @param [out] asso_desc The association description of Object information * + * @return 0 on success, otherwise a negative error value. + * @retval #MTP_ERROR_NONE Successful + * @retval #MTP_ERROR_NOT_SUPPORTED MTP is not supported + * @retval #MTP_ERROR_NOT_INITIALIZED MTP is not initialized + * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated + * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized + * @retval #MTP_ERROR_COMM MTP communication error + * @retval #MTP_ERROR_CONTROLLER MTP controller error + * @retval #MTP_ERROR_ALLOC_FAIL Memory Allocation failed + * @retval #MTP_ERROR_NO_DEVICE MTP have not any device + * @retval #MTP_ERROR_PLUGIN Plugin failed + * * @see mtp_get_object_handles() */ -MTP_API int mtp_objectinfo_get_association_desc(int device_handle, int object_handle, int *asso_desc); +int mtp_objectinfo_get_association_desc(mtp_device_h mtp_device, mtp_object_h object_handle, int *asso_desc); /** - * @brief Get the association type of the object information. + * @brief Gets the association type of the object information. * @since_tizen 3.0 - * @ingroup CAPI_NETWORK_MTP_OBJECTINFO_MODULE - * - * @return 0 on success, otherwise a negative error value. - * @retval #MTP_ERROR_NONE Successful * - * @param [in] device_handle The device handle + * @param [in] mtp_device The MTP device * @param [in] object_handle The object handle * @param [out] asso_type The association type of Object information * + * @return 0 on success, otherwise a negative error value. + * @retval #MTP_ERROR_NONE Successful + * @retval #MTP_ERROR_NOT_SUPPORTED MTP is not supported + * @retval #MTP_ERROR_NOT_INITIALIZED MTP is not initialized + * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated + * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized + * @retval #MTP_ERROR_COMM MTP communication error + * @retval #MTP_ERROR_CONTROLLER MTP controller error + * @retval #MTP_ERROR_ALLOC_FAIL Memory Allocation failed + * @retval #MTP_ERROR_NO_DEVICE MTP have not any device + * @retval #MTP_ERROR_PLUGIN Plugin failed + * * @see mtp_get_object_handles() */ -MTP_API int mtp_objectinfo_get_association_type(int device_handle, int object_handle, int *asso_type); +int mtp_objectinfo_get_association_type(mtp_device_h mtp_device, mtp_object_h object_handle, int *asso_type); /** - * @brief Get the size of the object information. + * @brief Gets the size of the object information. * @since_tizen 3.0 - * @ingroup CAPI_NETWORK_MTP_OBJECTINFO_MODULE * - * @return 0 on success, otherwise a negative error value. - * @retval #MTP_ERROR_NONE Successful - * - * @param [in] device_handle The device handle + * @param [in] mtp_device The MTP device * @param [in] object_handle The object handle * @param [out] size The size of Object information * + * @return 0 on success, otherwise a negative error value. + * @retval #MTP_ERROR_NONE Successful + * @retval #MTP_ERROR_NOT_SUPPORTED MTP is not supported + * @retval #MTP_ERROR_NOT_INITIALIZED MTP is not initialized + * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated + * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized + * @retval #MTP_ERROR_COMM MTP communication error + * @retval #MTP_ERROR_CONTROLLER MTP controller error + * @retval #MTP_ERROR_ALLOC_FAIL Memory Allocation failed + * @retval #MTP_ERROR_NO_DEVICE MTP have not any device + * @retval #MTP_ERROR_PLUGIN Plugin failed + * * @see mtp_get_object_handles() */ -MTP_API int mtp_objectinfo_get_size(int device_handle, int object_handle, int *size); +int mtp_objectinfo_get_size(mtp_device_h mtp_device, mtp_object_h object_handle, int *size); /** - * @brief Get the parent object handle of the object information. + * @brief Gets the parent object handle of the object information. * @since_tizen 3.0 - * @ingroup CAPI_NETWORK_MTP_OBJECTINFO_MODULE - * - * @return 0 on success, otherwise a negative error value. - * @retval #MTP_ERROR_NONE Successful * - * @param [in] device_handle The device handle + * @param [in] mtp_device The MTP device * @param [in] object_handle The object handle * @param [out] parent_object_handle The parent of Object information * + * @return 0 on success, otherwise a negative error value. + * @retval #MTP_ERROR_NONE Successful + * @retval #MTP_ERROR_NOT_SUPPORTED MTP is not supported + * @retval #MTP_ERROR_NOT_INITIALIZED MTP is not initialized + * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated + * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized + * @retval #MTP_ERROR_COMM MTP communication error + * @retval #MTP_ERROR_CONTROLLER MTP controller error + * @retval #MTP_ERROR_ALLOC_FAIL Memory Allocation failed + * @retval #MTP_ERROR_NO_DEVICE MTP have not any device + * @retval #MTP_ERROR_PLUGIN Plugin failed + * * @see mtp_get_object_handles() */ -MTP_API int mtp_objectinfo_get_parent_object_handle(int device_handle, int object_handle, int *parent_object_handle); +int mtp_objectinfo_get_parent_object_handle(mtp_device_h mtp_device, mtp_object_h object_handle, mtp_object_h *parent_object_handle); /** - * @brief Get the storage id of the object information. + * @brief Gets the mtp storage of the object information. * @since_tizen 3.0 - * @ingroup CAPI_NETWORK_MTP_OBJECTINFO_MODULE + * + * @param [in] mtp_device The MTP device + * @param [in] object_handle The object handle + * @param [out] mtp_storage The MTP storage of Object information * * @return 0 on success, otherwise a negative error value. * @retval #MTP_ERROR_NONE Successful - * - * @param [in] device_handle The device handle - * @param [in] object_handle The object handle - * @param [out] storage_id The storage id of Object information + * @retval #MTP_ERROR_NOT_SUPPORTED MTP is not supported + * @retval #MTP_ERROR_NOT_INITIALIZED MTP is not initialized + * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated + * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized + * @retval #MTP_ERROR_COMM MTP communication error + * @retval #MTP_ERROR_CONTROLLER MTP controller error + * @retval #MTP_ERROR_ALLOC_FAIL Memory Allocation failed + * @retval #MTP_ERROR_NO_DEVICE MTP have not any device + * @retval #MTP_ERROR_PLUGIN Plugin failed * * @see mtp_get_object_handles() */ -MTP_API int mtp_objectinfo_get_storage_id(int device_handle, int object_handle, int *storage_id); +int mtp_objectinfo_get_storage(mtp_device_h mtp_device, mtp_object_h object_handle, mtp_storage_h* mtp_storage); /** - * @brief Get the data created time of the object information. + * @brief Gets the data created time of the object information. * @since_tizen 3.0 - * @ingroup CAPI_NETWORK_MTP_OBJECTINFO_MODULE * - * @return 0 on success, otherwise a negative error value. - * @retval #MTP_ERROR_NONE Successful - * - * @param [in] device_handle The device handle + * @param [in] mtp_device The MTP device * @param [in] object_handle The object handle * @param [out] data_created The data created time of Object information * + * @return 0 on success, otherwise a negative error value. + * @retval #MTP_ERROR_NONE Successful + * @retval #MTP_ERROR_NOT_SUPPORTED MTP is not supported + * @retval #MTP_ERROR_NOT_INITIALIZED MTP is not initialized + * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated + * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized + * @retval #MTP_ERROR_COMM MTP communication error + * @retval #MTP_ERROR_CONTROLLER MTP controller error + * @retval #MTP_ERROR_ALLOC_FAIL Memory Allocation failed + * @retval #MTP_ERROR_NO_DEVICE MTP have not any device + * @retval #MTP_ERROR_PLUGIN Plugin failed + * * @see mtp_get_object_handles() */ -MTP_API int mtp_objectinfo_get_data_created(int device_handle, int object_handle, int *data_created); +int mtp_objectinfo_get_data_created(mtp_device_h mtp_device, mtp_object_h object_handle, int *data_created); /** - * @brief Get the data modified time of the object information. + * @brief Gets the data modified time of the object information. * @since_tizen 3.0 - * @ingroup CAPI_NETWORK_MTP_OBJECTINFO_MODULE * - * @return 0 on success, otherwise a negative error value. - * @retval #MTP_ERROR_NONE Successful - * - * @param [in] device_handle The device handle + * @param [in] mtp_device The MTP device * @param [in] object_handle The object handle * @param [out] data_modified The data modified time of Object information * + * @return 0 on success, otherwise a negative error value. + * @retval #MTP_ERROR_NONE Successful + * @retval #MTP_ERROR_NOT_SUPPORTED MTP is not supported + * @retval #MTP_ERROR_NOT_INITIALIZED MTP is not initialized + * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated + * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized + * @retval #MTP_ERROR_COMM MTP communication error + * @retval #MTP_ERROR_CONTROLLER MTP controller error + * @retval #MTP_ERROR_ALLOC_FAIL Memory Allocation failed + * @retval #MTP_ERROR_NO_DEVICE MTP have not any device + * @retval #MTP_ERROR_PLUGIN Plugin failed + * * @see mtp_get_object_handles() */ -MTP_API int mtp_objectinfo_get_data_modified(int device_handle, int object_handle, int *data_modified); +int mtp_objectinfo_get_data_modified(mtp_device_h mtp_device, mtp_object_h object_handle, int *data_modified); /** - * @brief Get the format of the object information. + * @brief Gets the file type of the object information. * @since_tizen 3.0 - * @ingroup CAPI_NETWORK_MTP_OBJECTINFO_MODULE + * + * @param [in] mtp_device The MTP device + * @param [in] object_handle The object handle + * @param [out] file_type The file type of Object information * * @return 0 on success, otherwise a negative error value. * @retval #MTP_ERROR_NONE Successful - * - * @param [in] device_handle The device handle - * @param [in] object_handle The object handle - * @param [out] format The image format of Object information + * @retval #MTP_ERROR_NOT_SUPPORTED MTP is not supported + * @retval #MTP_ERROR_NOT_INITIALIZED MTP is not initialized + * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated + * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized + * @retval #MTP_ERROR_COMM MTP communication error + * @retval #MTP_ERROR_CONTROLLER MTP controller error + * @retval #MTP_ERROR_ALLOC_FAIL Memory Allocation failed + * @retval #MTP_ERROR_NO_DEVICE MTP have not any device + * @retval #MTP_ERROR_PLUGIN Plugin failed * * @see mtp_get_object_handles() */ -MTP_API int mtp_objectinfo_get_format(int device_handle, int object_handle, int *format); +int mtp_objectinfo_get_file_type(mtp_device_h mtp_device, mtp_object_h object_handle, mtp_filetype_e *file_type); /** - * @brief Get the image pix depth of the object information. + * @brief Gets the image bit depth of the object information. * @since_tizen 3.0 - * @ingroup CAPI_NETWORK_MTP_OBJECTINFO_MODULE + * + * @param [in] mtp_device The MTP device + * @param [in] object_handle The object handle + * @param [out] depth The image bit depth of Object information * * @return 0 on success, otherwise a negative error value. * @retval #MTP_ERROR_NONE Successful - * - * @param [in] device_handle The device handle - * @param [in] object_handle The object handle - * @param [out] depth The image pixel depth of Object information + * @retval #MTP_ERROR_NOT_SUPPORTED MTP is not supported + * @retval #MTP_ERROR_NOT_INITIALIZED MTP is not initialized + * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated + * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized + * @retval #MTP_ERROR_COMM MTP communication error + * @retval #MTP_ERROR_CONTROLLER MTP controller error + * @retval #MTP_ERROR_ALLOC_FAIL Memory Allocation failed + * @retval #MTP_ERROR_NO_DEVICE MTP have not any device + * @retval #MTP_ERROR_PLUGIN Plugin failed * * @see mtp_get_object_handles() */ -MTP_API int mtp_objectinfo_get_image_pix_depth(int device_handle, int object_handle, int *depth); +int mtp_objectinfo_get_image_bit_depth(mtp_device_h mtp_device, mtp_object_h object_handle, int *depth); /** - * @brief Get the image pix width of the object information. + * @brief Gets the image pix width of the object information. * @since_tizen 3.0 - * @ingroup CAPI_NETWORK_MTP_OBJECTINFO_MODULE - * - * @return 0 on success, otherwise a negative error value. - * @retval #MTP_ERROR_NONE Successful * - * @param [in] device_handle The device handle + * @param [in] mtp_device The MTP device * @param [in] object_handle The object handle * @param [out] width The image pixel width of Object information * + * @return 0 on success, otherwise a negative error value. + * @retval #MTP_ERROR_NONE Successful + * @retval #MTP_ERROR_NOT_SUPPORTED MTP is not supported + * @retval #MTP_ERROR_NOT_INITIALIZED MTP is not initialized + * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated + * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized + * @retval #MTP_ERROR_COMM MTP communication error + * @retval #MTP_ERROR_CONTROLLER MTP controller error + * @retval #MTP_ERROR_ALLOC_FAIL Memory Allocation failed + * @retval #MTP_ERROR_NO_DEVICE MTP have not any device + * @retval #MTP_ERROR_PLUGIN Plugin failed + * * @see mtp_get_object_handles() */ -MTP_API int mtp_objectinfo_get_image_pix_width(int device_handle, int object_handle, int *width); +int mtp_objectinfo_get_image_pix_width(mtp_device_h mtp_device, mtp_object_h object_handle, int *width); /** - * @brief Get the image pix height of the object information. + * @brief Gets the image pix height of the object information. * @since_tizen 3.0 - * @ingroup CAPI_NETWORK_MTP_OBJECTINFO_MODULE - * - * @return 0 on success, otherwise a negative error value. - * @retval #MTP_ERROR_NONE Successful * - * @param [in] device_handle The device handle + * @param [in] mtp_device The MTP device * @param [in] object_handle The object handle * @param [out] height The image pixel height of Object information * + * @return 0 on success, otherwise a negative error value. + * @retval #MTP_ERROR_NONE Successful + * @retval #MTP_ERROR_NOT_SUPPORTED MTP is not supported + * @retval #MTP_ERROR_NOT_INITIALIZED MTP is not initialized + * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated + * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized + * @retval #MTP_ERROR_COMM MTP communication error + * @retval #MTP_ERROR_CONTROLLER MTP controller error + * @retval #MTP_ERROR_ALLOC_FAIL Memory Allocation failed + * @retval #MTP_ERROR_NO_DEVICE MTP have not any device + * @retval #MTP_ERROR_PLUGIN Plugin failed + * * @see mtp_get_object_handles() */ -MTP_API int mtp_objectinfo_get_image_pix_height(int device_handle, int object_handle, int *height); +int mtp_objectinfo_get_image_pix_height(mtp_device_h mtp_device, mtp_object_h object_handle, int *height); /** - * @brief Get the thumbnail size of the object information. + * @brief Gets the thumbnail size of the object information. * @since_tizen 3.0 - * @ingroup CAPI_NETWORK_MTP_OBJECTINFO_MODULE - * - * @return 0 on success, otherwise a negative error value. - * @retval #MTP_ERROR_NONE Successful * - * @param [in] device_handle The device handle + * @param [in] mtp_device The MTP device * @param [in] object_handle The object handle * @param [out] size The thumbnail size of Object information * + * @return 0 on success, otherwise a negative error value. + * @retval #MTP_ERROR_NONE Successful + * @retval #MTP_ERROR_NOT_SUPPORTED MTP is not supported + * @retval #MTP_ERROR_NOT_INITIALIZED MTP is not initialized + * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated + * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized + * @retval #MTP_ERROR_COMM MTP communication error + * @retval #MTP_ERROR_CONTROLLER MTP controller error + * @retval #MTP_ERROR_ALLOC_FAIL Memory Allocation failed + * @retval #MTP_ERROR_NO_DEVICE MTP have not any device + * @retval #MTP_ERROR_PLUGIN Plugin failed + * * @see mtp_get_object_handles() */ -MTP_API int mtp_objectinfo_get_thumbnail_size(int device_handle, int object_handle, int *size); +int mtp_objectinfo_get_thumbnail_size(mtp_device_h mtp_device, mtp_object_h object_handle, int *size); /** - * @brief Get the thumbnail format of the object information. + * @brief Gets the thumbnail file_type of the object information. * @since_tizen 3.0 - * @ingroup CAPI_NETWORK_MTP_OBJECTINFO_MODULE + * + * @param [in] mtp_device The MTP device + * @param [in] object_handle The object handle + * @param [out] file_type The file type of Object information * * @return 0 on success, otherwise a negative error value. * @retval #MTP_ERROR_NONE Successful - * - * @param [in] device_handle The device handle - * @param [in] object_handle The object handle - * @param [out] format The thumbnail format of Object information + * @retval #MTP_ERROR_NOT_SUPPORTED MTP is not supported + * @retval #MTP_ERROR_NOT_INITIALIZED MTP is not initialized + * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated + * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized + * @retval #MTP_ERROR_COMM MTP communication error + * @retval #MTP_ERROR_CONTROLLER MTP controller error + * @retval #MTP_ERROR_ALLOC_FAIL Memory Allocation failed + * @retval #MTP_ERROR_NO_DEVICE MTP have not any device + * @retval #MTP_ERROR_PLUGIN Plugin failed * * @see mtp_get_object_handles() */ -MTP_API int mtp_objectinfo_get_thumbnail_format(int device_handle, int object_handle, int *format); +int mtp_objectinfo_get_thumbnail_file_type(mtp_device_h mtp_device, mtp_object_h object_handle, mtp_filetype_e *file_type); /** - * @brief Get the thumbnail pix height of the object information. + * @brief Gets the thumbnail pix height of the object information. * @since_tizen 3.0 - * @ingroup CAPI_NETWORK_MTP_OBJECTINFO_MODULE * - * @return 0 on success, otherwise a negative error value. - * @retval #MTP_ERROR_NONE Successful - * - * @param [in] device_handle The device handle + * @param [in] mtp_device The MTP device * @param [in] object_handle The object handle * @param [out] height The thumbnail pixel height of Object information * + * @return 0 on success, otherwise a negative error value. + * @retval #MTP_ERROR_NONE Successful + * @retval #MTP_ERROR_NOT_SUPPORTED MTP is not supported + * @retval #MTP_ERROR_NOT_INITIALIZED MTP is not initialized + * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated + * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized + * @retval #MTP_ERROR_COMM MTP communication error + * @retval #MTP_ERROR_CONTROLLER MTP controller error + * @retval #MTP_ERROR_ALLOC_FAIL Memory Allocation failed + * @retval #MTP_ERROR_NO_DEVICE MTP have not any device + * @retval #MTP_ERROR_PLUGIN Plugin failed + * * @see mtp_get_object_handles() */ -MTP_API int mtp_objectinfo_get_thumbnail_pix_height(int device_handle, int object_handle, int *height); +int mtp_objectinfo_get_thumbnail_pix_height(mtp_device_h mtp_device, mtp_object_h object_handle, int *height); /** - * @brief Get the thumbnail pix width of the object information. + * @brief Gets the thumbnail pix width of the object information. * @since_tizen 3.0 - * @ingroup CAPI_NETWORK_MTP_OBJECTINFO_MODULE - * - * @return 0 on success, otherwise a negative error value. - * @retval #MTP_ERROR_NONE Successful * - * @param [in] device_handle The device handle + * @param [in] mtp_device The MTP device * @param [in] object_handle The object handle * @param [out] width The thumbnail pixel width of Object information * + * @return 0 on success, otherwise a negative error value. + * @retval #MTP_ERROR_NONE Successful + * @retval #MTP_ERROR_NOT_SUPPORTED MTP is not supported + * @retval #MTP_ERROR_NOT_INITIALIZED MTP is not initialized + * @retval #MTP_ERROR_NOT_ACTIVATED MTP is not activated + * @retval #MTP_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized + * @retval #MTP_ERROR_COMM MTP communication error + * @retval #MTP_ERROR_CONTROLLER MTP controller error + * @retval #MTP_ERROR_ALLOC_FAIL Memory Allocation failed + * @retval #MTP_ERROR_NO_DEVICE MTP have not any device + * @retval #MTP_ERROR_PLUGIN Plugin failed + * * @see mtp_get_object_handles() */ -MTP_API int mtp_objectinfo_get_thumbnail_pix_width(int device_handle, int object_handle, int *width); +int mtp_objectinfo_get_thumbnail_pix_width(mtp_device_h mtp_device, mtp_object_h object_handle, int *width); + +/** +* @} +*/ #ifdef __cplusplus } diff --git a/include/mtp_db.h b/include/mtp_db.h index a546820..2364d0a 100755 --- a/include/mtp_db.h +++ b/include/mtp_db.h @@ -30,7 +30,7 @@ #define MTP_DB_TABLE "mtp_object_info" mtp_error_e mtp_db_init(void); -mtp_error_e mtp_db_get_object_info(int device_handle, int object_handle, mtp_object_info** object_info); +mtp_error_e mtp_db_get_object_info(int mtp_device, int object_handle, mtp_object_info** object_info); mtp_error_e mtp_db_deinit(void); #endif diff --git a/include/mtp_gdbus.h b/include/mtp_gdbus.h index a740ff1..2811fb1 100755 --- a/include/mtp_gdbus.h +++ b/include/mtp_gdbus.h @@ -21,6 +21,7 @@ #include #include "mtp.h" +#include "mtp_private.h" #include "mtp_gdbuslib.h" #define MTP_DBUS_SERVICE "org.tizen.mtp" diff --git a/include/mtp_gdbus_manager.h b/include/mtp_gdbus_manager.h index 9c9699c..ea2eaf4 100755 --- a/include/mtp_gdbus_manager.h +++ b/include/mtp_gdbus_manager.h @@ -20,17 +20,17 @@ #include "mtp_gdbus.h" mtp_error_e mtp_gdbus_manager_initialize(void); -mtp_error_e mtp_gdbus_manager_get_device_list(mtp_device_list **dev_list); -mtp_error_e mtp_gdbus_manager_get_device_handle(int bus_location, - int *device_handle); -mtp_error_e mtp_gdbus_manager_get_storage_ids(int device_handle, - int **storage_ids, int *storage_num); -mtp_error_e mtp_gdbus_manager_get_object_handles(int device_handle, - int storage_id, int format, int parent_object_handle, int **object_handles, int *object_num); -mtp_error_e mtp_gdbus_manager_delete_object(int device_handle, int object_handle); -mtp_error_e mtp_gdbus_manager_get_object(int device_handle, +mtp_error_e mtp_gdbus_manager_get_raw_devices(mtp_raw_device ***raw_devices, int *device_count); +mtp_error_e mtp_gdbus_manager_get_device(int bus_location, int device_number, + int *mtp_device); +mtp_error_e mtp_gdbus_manager_get_storages(int mtp_device, + int **mtp_storages, int *storage_num); +mtp_error_e mtp_gdbus_manager_get_object_handles(int mtp_device, + int mtp_storage, int format, int parent_object_handle, int **object_handles, int *object_num); +mtp_error_e mtp_gdbus_manager_delete_object(int mtp_device, int object_handle); +mtp_error_e mtp_gdbus_manager_get_object(int mtp_device, int object_handle, char *dest_path); -mtp_error_e mtp_gdbus_manager_get_thumbnail(int device_handle, +mtp_error_e mtp_gdbus_manager_get_thumbnail(int mtp_device, int object_handle, char *dest_path); mtp_error_e mtp_gdbus_manager_set_event_cb(mtp_event_cb callback, void *user_data); mtp_error_e mtp_gdbus_manager_unset_event_cb(); diff --git a/include/mtp_gdbus_objectinfo.h b/include/mtp_gdbus_objectinfo.h index 3c5930f..421704d 100755 --- a/include/mtp_gdbus_objectinfo.h +++ b/include/mtp_gdbus_objectinfo.h @@ -22,9 +22,9 @@ void mtp_gdbus_objectinfo_proxy_init(void); void mtp_gdbus_objectinfo_proxy_deinit(void); -int mtp_gdbus_objectinfo_get_property(int device_handle, +int mtp_gdbus_objectinfo_get_property(int mtp_device, int object_handle, int property, int *property_value); -int mtp_gdbus_objectinfo_get_property_string(int device_handle, +int mtp_gdbus_objectinfo_get_property_string(int mtp_device, int object_handle, int property, char **property_value); #endif diff --git a/include/mtp_gdbus_storageinfo.h b/include/mtp_gdbus_storageinfo.h index c4e90a3..f335e1f 100755 --- a/include/mtp_gdbus_storageinfo.h +++ b/include/mtp_gdbus_storageinfo.h @@ -22,15 +22,15 @@ void mtp_gdbus_storageinfo_proxy_init(void); void mtp_gdbus_storageinfo_proxy_deinit(void); -mtp_error_e mtp_gdbus_storageinfo_get_description(int device_handle, - int storage_id, char **description); -mtp_error_e mtp_gdbus_storageinfo_get_freespace(int device_handle, - int storage_id, guint64 *freespace); -mtp_error_e mtp_gdbus_storageinfo_get_maxcapacity(int device_handle, - int storage_id, guint64 *maxcapacity); -mtp_error_e mtp_gdbus_storageinfo_get_storagetype(int device_handle, - int storage_id, int *storagetype); -mtp_error_e mtp_gdbus_storageinfo_get_volumeidentifier(int device_handle, - int storage_id, char **volumeidentifier); +mtp_error_e mtp_gdbus_storageinfo_get_description(int mtp_device, + int mtp_storage, char **description); +mtp_error_e mtp_gdbus_storageinfo_get_freespace(int mtp_device, + int mtp_storage, guint64 *freespace); +mtp_error_e mtp_gdbus_storageinfo_get_maxcapacity(int mtp_device, + int mtp_storage, guint64 *maxcapacity); +mtp_error_e mtp_gdbus_storageinfo_get_storagetype(int mtp_device, + int mtp_storage, int *storagetype); +mtp_error_e mtp_gdbus_storageinfo_get_volumeidentifier(int mtp_device, + int mtp_storage, char **volumeidentifier); #endif diff --git a/include/mtp_internal.h b/include/mtp_internal.h index 0702f5a..71a0d1d 100755 --- a/include/mtp_internal.h +++ b/include/mtp_internal.h @@ -49,7 +49,9 @@ typedef struct _mtp_object_info { }mtp_object_info; /* internal api */ -MTP_API int mtp_objectinfo_get_object_info(int device_handle, int object_handle, mtp_object_info **object_info); +int mtp_objectinfo_get_object_info(int mtp_device, int object_handle, mtp_object_info **object_info); + +int mtp_delete_object(mtp_device_h mtp_device, mtp_object_h object_handle); #ifdef __cplusplus } diff --git a/include/mtp_private.h b/include/mtp_private.h new file mode 100755 index 0000000..cb4075a --- /dev/null +++ b/include/mtp_private.h @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __MTP_PRIVATE_H__ +#define __MTP_PRIVATE_H__ + +typedef struct _mtp_raw_device { + int bus_location; + int device_number; + char *model_name; + int dev_count; +} mtp_raw_device; + +#define CHECK_SUPPORTED() \ +do { \ + { \ + if (__is_mtp_supported() == false) { \ + return MTP_ERROR_NOT_SUPPORTED; \ + } \ + } \ +} while (0); + +#define CHECK_ACTIVATED() \ +do { \ + { \ + if (__is_mtp_activated() == false) { \ + return MTP_ERROR_NOT_ACTIVATED; \ + } \ + } \ +} while (0); + +typedef enum { + MTP_PROPERTY_ASSOCIATION_DESC = 1, + MTP_PROPERTY_ASSOCIATION_TYPE, + MTP_PROPERTY_SIZE, + MTP_PROPERTY_DATA_CREATED, + MTP_PROPERTY_DATA_MODIFIED, + MTP_PROPERTY_FORMAT, + MTP_PROPERTY_IMAGE_BIT_DEPTH, + MTP_PROPERTY_IMAGE_FIX_WIDTH, + MTP_PROPERTY_IMAGE_FIX_HEIGHT, + MTP_PROPERTY_PARENT_OBJECT_HANDLE, + MTP_PROPERTY_STORAGE, + MTP_PROPERTY_THUMBNAIL_SIZE, + MTP_PROPERTY_THUMBNAIL_FORMAT, + MTP_PROPERTY_THUMBNAIL_WIDTH, + MTP_PROPERTY_THUMBNAIL_HEIGHT, + MTP_PROPERTY_FILENAME, + MTP_PROPERTY_KEYWORDS +} mtp_property_e; + +#endif diff --git a/packaging/capi-network-mtp.spec b/packaging/capi-network-mtp.spec index e03c530..d3271c5 100755 --- a/packaging/capi-network-mtp.spec +++ b/packaging/capi-network-mtp.spec @@ -1,6 +1,6 @@ Name: capi-network-mtp Summary: A MTP library in Native API -Version: 1.2.4 +Version: 1.3.0 Release: 1 Group: Network & Connectivity/Other License: Apache-2.0 diff --git a/src/mtp.c b/src/mtp.c index 3ce3e87..03357dc 100755 --- a/src/mtp.c +++ b/src/mtp.c @@ -26,15 +26,13 @@ #include "mtp_internal.h" #include "mtp_db.h" #include "mtp_debug.h" +#include "mtp_private.h" #include "mtp_gdbus_manager.h" #include "mtp_gdbus_deviceinfo.h" #include "mtp_gdbus_storageinfo.h" #include "mtp_gdbus_objectinfo.h" -int ref_count = 0; -bool __is_initialized = false; - #define MTP_LOCK \ do { \ pthread_mutex_lock(&mutex); \ @@ -59,43 +57,8 @@ do { \ MTP_UNLOCK; \ } while (0); -#define CHECK_SUPPORTED() \ -do { \ - { \ - if (__is_mtp_supported() == false) { \ - return MTP_ERROR_NOT_SUPPORTED; \ - } \ - } \ -} while (0); - -#define CHECK_ACTIVATED() \ -do { \ - { \ - if (__is_mtp_activated() == false) { \ - return MTP_ERROR_NOT_ACTIVATED; \ - } \ - } \ -} while (0); - -typedef enum { - MTP_PROPERTY_ASSOCIATION_DESC = 1, - MTP_PROPERTY_ASSOCIATION_TYPE, - MTP_PROPERTY_SIZE, - MTP_PROPERTY_DATA_CREATED, - MTP_PROPERTY_DATA_MODIFIED, - MTP_PROPERTY_FORMAT, - MTP_PROPERTY_IMAGE_FIX_DEPTH, - MTP_PROPERTY_IMAGE_FIX_WIDTH, - MTP_PROPERTY_IMAGE_FIX_HEIGHT, - MTP_PROPERTY_PARENT_OBJECT_HANDLE, - MTP_PROPERTY_STORAGE_ID, - MTP_PROPERTY_THUMBNAIL_SIZE, - MTP_PROPERTY_THUMBNAIL_FORMAT, - MTP_PROPERTY_THUMBNAIL_WIDTH, - MTP_PROPERTY_THUMBNAIL_HEIGHT, - MTP_PROPERTY_FILENAME, - MTP_PROPERTY_KEYWORDS -} mtp_property_e; +int ref_count = 0; +bool __is_initialized = false; static bool __is_mtp_supported() { @@ -136,7 +99,7 @@ int mtp_initialize(void) return ret; } -int mtp_get_device_list(mtp_device_list **dev_list) +int mtp_get_raw_devices(mtp_raw_device_h **raw_devices, int *device_count) { int ret = MTP_ERROR_NONE; @@ -147,17 +110,117 @@ int mtp_get_device_list(mtp_device_list **dev_list) CHECK_SUPPORTED(); CHECK_INIT(); CHECK_ACTIVATED(); + cond_expr_ret(device_count == NULL, MTP_ERROR_INVALID_PARAMETER); /* precondition check end */ + *device_count = 0; + + ret = mtp_gdbus_manager_get_raw_devices((mtp_raw_device ***)raw_devices, device_count); + + _END(); + + return ret; +} + +int mtp_get_bus_location(mtp_raw_device_h raw_device, int *bus_location) +{ + int ret = MTP_ERROR_NONE; + + _BEGIN(); + + /* precondition check start */ + + CHECK_SUPPORTED(); + CHECK_INIT(); + cond_expr_ret(raw_device == NULL, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(bus_location == NULL, MTP_ERROR_INVALID_PARAMETER); + + /* precondition check end */ + + *bus_location = ((mtp_raw_device *)raw_device)->bus_location; + + _END(); + + return ret; +} + +int mtp_get_device_number(mtp_raw_device_h raw_device, int *device_number) +{ + int ret = MTP_ERROR_NONE; + + _BEGIN(); + + /* precondition check start */ + + CHECK_SUPPORTED(); + CHECK_INIT(); + cond_expr_ret(raw_device == NULL, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(device_number == NULL, MTP_ERROR_INVALID_PARAMETER); + + /* precondition check end */ + + *device_number = ((mtp_raw_device *)raw_device)->device_number; + + _END(); + + return ret; +} + +int mtp_get_device_name(mtp_raw_device_h raw_device, char **model_name) +{ + int ret = MTP_ERROR_NONE; + + /* precondition check start */ + + CHECK_SUPPORTED(); + CHECK_INIT(); + cond_expr_ret(raw_device == NULL, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(model_name == NULL, MTP_ERROR_INVALID_PARAMETER); + + /* precondition check end */ + + *model_name = g_strdup(((mtp_raw_device *)raw_device)->model_name); + + return ret; +} + +int mtp_destroy_raw_devices(mtp_raw_device_h *raw_devices) +{ + int i; + int ret = MTP_ERROR_NONE; + int dev_count; + mtp_raw_device *first_device = (mtp_raw_device *)raw_devices[0]; + + _BEGIN(); + + /* precondition check start */ + + CHECK_SUPPORTED(); + cond_expr_ret(raw_devices == NULL, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(first_device == NULL, MTP_ERROR_INVALID_PARAMETER); + + /* precondition check end */ + dev_count = first_device->dev_count; + if (dev_count <= 0 || dev_count > 6) + return MTP_ERROR_INVALID_PARAMETER; + + for (i = 0; i < dev_count; i++) { + mtp_raw_device *r_device = (mtp_raw_device *)raw_devices[i]; + + if (r_device != NULL && r_device->model_name != NULL) { + free(r_device->model_name); + free(r_device); + } + } - ret = mtp_gdbus_manager_get_device_list(dev_list); + free(raw_devices); _END(); return ret; } -int mtp_get_device_handle(int bus_location, int *device_handle) +int mtp_get_device(int bus_location, int device_number, int *mtp_device) { int ret = MTP_ERROR_NONE; @@ -172,16 +235,16 @@ int mtp_get_device_handle(int bus_location, int *device_handle) /* precondition check end */ - ret = mtp_gdbus_manager_get_device_handle(bus_location, device_handle); + ret = mtp_gdbus_manager_get_device(bus_location, device_number, mtp_device); - TC_PRT("mtp_handle %d", *device_handle); + TC_PRT("mtp_device %d", *mtp_device); _END(); return ret; } -int mtp_get_storage_ids(int device_handle, int **storage_ids, int *storage_num) +int mtp_get_storages(int mtp_device, int **mtp_storages, int* storage_num) { int ret = MTP_ERROR_NONE; @@ -192,11 +255,11 @@ int mtp_get_storage_ids(int device_handle, int **storage_ids, int *storage_num) CHECK_SUPPORTED(); CHECK_INIT(); CHECK_ACTIVATED(); - cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER); /* precondition check end */ - ret = mtp_gdbus_manager_get_storage_ids(device_handle, storage_ids, storage_num); + ret = mtp_gdbus_manager_get_storages(mtp_device, mtp_storages, storage_num); TC_PRT("storage number %d", *storage_num); @@ -205,8 +268,8 @@ int mtp_get_storage_ids(int device_handle, int **storage_ids, int *storage_num) return ret; } -int mtp_get_object_handles(int device_handle, int storage_id, int format, - int parent_object_handle, int **object_handles, int *object_num) +int mtp_get_object_handles(int mtp_device, int mtp_storage, mtp_filetype_e file_type, + int parent, int **object_handles, int* object_num) { int ret = MTP_ERROR_NONE; @@ -217,20 +280,20 @@ int mtp_get_object_handles(int device_handle, int storage_id, int format, CHECK_SUPPORTED(); CHECK_INIT(); CHECK_ACTIVATED(); - cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); - cond_expr_ret(storage_id == 0, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(mtp_storage == 0, MTP_ERROR_INVALID_PARAMETER); /* precondition check end */ - ret = mtp_gdbus_manager_get_object_handles(device_handle, - storage_id, format, parent_object_handle, object_handles, object_num); + ret = mtp_gdbus_manager_get_object_handles(mtp_device, + mtp_storage, file_type, parent, object_handles, object_num); _END(); return ret; } -int mtp_delete_object(int device_handle, int object_handle) +int mtp_delete_object(int mtp_device, int object_handle) { int ret = MTP_ERROR_NONE; @@ -241,19 +304,19 @@ int mtp_delete_object(int device_handle, int object_handle) CHECK_SUPPORTED(); CHECK_INIT(); CHECK_ACTIVATED(); - cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER); cond_expr_ret(object_handle == 0, MTP_ERROR_INVALID_PARAMETER); /* precondition check end */ - ret = mtp_gdbus_manager_delete_object(device_handle, object_handle); + ret = mtp_gdbus_manager_delete_object(mtp_device, object_handle); _END(); return ret; } -int mtp_get_object(int device_handle, int object_handle, char *dest_path) +int mtp_get_object(int mtp_device, int object_handle, char *dest_path) { int ret = MTP_ERROR_NONE; @@ -264,19 +327,19 @@ int mtp_get_object(int device_handle, int object_handle, char *dest_path) CHECK_SUPPORTED(); CHECK_INIT(); CHECK_ACTIVATED(); - cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER); cond_expr_ret(dest_path == NULL, MTP_ERROR_INVALID_PARAMETER); /* precondition check end */ - ret = mtp_gdbus_manager_get_object(device_handle, object_handle, dest_path); + ret = mtp_gdbus_manager_get_object(mtp_device, object_handle, dest_path); _END(); return ret; } -int mtp_get_thumbnail(int device_handle, int object_handle, char *dest_path) +int mtp_get_thumbnail(int mtp_device, int object_handle, char *dest_path) { int ret = MTP_ERROR_NONE; @@ -287,12 +350,12 @@ int mtp_get_thumbnail(int device_handle, int object_handle, char *dest_path) CHECK_SUPPORTED(); CHECK_INIT(); CHECK_ACTIVATED(); - cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER); cond_expr_ret(dest_path == NULL, MTP_ERROR_INVALID_PARAMETER); /* precondition check end */ - ret = mtp_gdbus_manager_get_thumbnail(device_handle, object_handle, dest_path); + ret = mtp_gdbus_manager_get_thumbnail(mtp_device, object_handle, dest_path); _END(); @@ -371,7 +434,7 @@ int mtp_deinitialize(void) } /* Device Info */ -int mtp_deviceinfo_get_manufacturername(int device_handle, char **manufacturername) +int mtp_deviceinfo_get_manufacturer_name(int mtp_device, char **manufacturer_name) { int ret = MTP_ERROR_NONE; @@ -382,20 +445,20 @@ int mtp_deviceinfo_get_manufacturername(int device_handle, char **manufacturerna CHECK_SUPPORTED(); CHECK_INIT(); CHECK_ACTIVATED(); - cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER); /* precondition check end */ - ret = mtp_gdbus_deviceinfo_get_manufacturername(device_handle, manufacturername); + ret = mtp_gdbus_deviceinfo_get_manufacturername(mtp_device, manufacturer_name); - TC_PRT("manufacturername %s", *manufacturername); + TC_PRT("manufacturername %s", *manufacturer_name); _END(); return ret; } -int mtp_deviceinfo_get_modelname(int device_handle, char **modelname) +int mtp_deviceinfo_get_model_name(int mtp_device, char **model_name) { int ret = MTP_ERROR_NONE; @@ -406,20 +469,20 @@ int mtp_deviceinfo_get_modelname(int device_handle, char **modelname) CHECK_SUPPORTED(); CHECK_INIT(); CHECK_ACTIVATED(); - cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER); /* precondition check end */ - ret = mtp_gdbus_deviceinfo_get_modelname(device_handle, modelname); + ret = mtp_gdbus_deviceinfo_get_modelname(mtp_device, model_name); - TC_PRT("modelname %s", *modelname); + TC_PRT("modelname %s", *model_name); _END(); return ret; } -int mtp_deviceinfo_get_serialnumber(int device_handle, char **serialnumber) +int mtp_deviceinfo_get_serial_number(int mtp_device, char **serial_number) { int ret = MTP_ERROR_NONE; @@ -430,20 +493,20 @@ int mtp_deviceinfo_get_serialnumber(int device_handle, char **serialnumber) CHECK_SUPPORTED(); CHECK_INIT(); CHECK_ACTIVATED(); - cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER); /* precondition check end */ - ret = mtp_gdbus_deviceinfo_get_serialnumber(device_handle, serialnumber); + ret = mtp_gdbus_deviceinfo_get_serialnumber(mtp_device, serial_number); - TC_PRT("serialnumber %s", *serialnumber); + TC_PRT("serialnumber %s", *serial_number); _END(); return ret; } -int mtp_deviceinfo_get_deviceversion(int device_handle, char **deviceversion) +int mtp_deviceinfo_get_device_version(int mtp_device, char **device_version) { int ret = MTP_ERROR_NONE; @@ -454,13 +517,13 @@ int mtp_deviceinfo_get_deviceversion(int device_handle, char **deviceversion) CHECK_SUPPORTED(); CHECK_INIT(); CHECK_ACTIVATED(); - cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER); /* precondition check end */ - ret = mtp_gdbus_deviceinfo_get_deviceversion(device_handle, deviceversion); + ret = mtp_gdbus_deviceinfo_get_deviceversion(mtp_device, device_version); - TC_PRT("deviceversion %s", *deviceversion); + TC_PRT("deviceversion %s", *device_version); _END(); @@ -468,7 +531,7 @@ int mtp_deviceinfo_get_deviceversion(int device_handle, char **deviceversion) } /* Storage Info */ -int mtp_storageinfo_get_description(int device_handle, int storage_id, char **description) +int mtp_storageinfo_get_description(int mtp_device, int mtp_storage, char **description) { int ret = MTP_ERROR_NONE; @@ -479,12 +542,12 @@ int mtp_storageinfo_get_description(int device_handle, int storage_id, char **de CHECK_SUPPORTED(); CHECK_INIT(); CHECK_ACTIVATED(); - cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); - cond_expr_ret(storage_id == 0, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(mtp_storage == 0, MTP_ERROR_INVALID_PARAMETER); /* precondition check end */ - ret = mtp_gdbus_storageinfo_get_description(device_handle, storage_id, description); + ret = mtp_gdbus_storageinfo_get_description(mtp_device, mtp_storage, description); TC_PRT("description %s", *description); @@ -493,7 +556,7 @@ int mtp_storageinfo_get_description(int device_handle, int storage_id, char **de return ret; } -int mtp_storageinfo_get_freespace(int device_handle, int storage_id, unsigned long long *freespace) +int mtp_storageinfo_get_free_space(int mtp_device, int mtp_storage, unsigned long long *free_space) { int ret = MTP_ERROR_NONE; @@ -504,21 +567,21 @@ int mtp_storageinfo_get_freespace(int device_handle, int storage_id, unsigned lo CHECK_SUPPORTED(); CHECK_INIT(); CHECK_ACTIVATED(); - cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); - cond_expr_ret(storage_id == 0, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(mtp_storage == 0, MTP_ERROR_INVALID_PARAMETER); /* precondition check end */ - ret = mtp_gdbus_storageinfo_get_freespace(device_handle, storage_id, (guint64 *)freespace); + ret = mtp_gdbus_storageinfo_get_freespace(mtp_device, mtp_storage, (guint64 *)free_space); - TC_PRT("freespace %llu", *freespace); + TC_PRT("freespace %llu", *free_space); _END(); return ret; } -int mtp_storageinfo_get_maxcapacity(int device_handle, int storage_id, unsigned long long *maxcapacity) +int mtp_storageinfo_get_max_capacity(int mtp_device, int mtp_storage, unsigned long long *max_capacity) { int ret = MTP_ERROR_NONE; @@ -529,21 +592,21 @@ int mtp_storageinfo_get_maxcapacity(int device_handle, int storage_id, unsigned CHECK_SUPPORTED(); CHECK_INIT(); CHECK_ACTIVATED(); - cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); - cond_expr_ret(storage_id == 0, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(mtp_storage == 0, MTP_ERROR_INVALID_PARAMETER); /* precondition check end */ - ret = mtp_gdbus_storageinfo_get_maxcapacity(device_handle, storage_id, (guint64 *)maxcapacity); + ret = mtp_gdbus_storageinfo_get_maxcapacity(mtp_device, mtp_storage, (guint64 *)max_capacity); - TC_PRT("maxcapacity %llu", *maxcapacity); + TC_PRT("maxcapacity %llu", *max_capacity); _END(); return ret; } -int mtp_storageinfo_get_storagetype(int device_handle, int storage_id, int *storagetype) +int mtp_storageinfo_get_storage_type(int mtp_device, int mtp_storage, int *storage_type) { int ret = MTP_ERROR_NONE; @@ -554,21 +617,21 @@ int mtp_storageinfo_get_storagetype(int device_handle, int storage_id, int *stor CHECK_SUPPORTED(); CHECK_INIT(); CHECK_ACTIVATED(); - cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); - cond_expr_ret(storage_id == 0, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(mtp_storage == 0, MTP_ERROR_INVALID_PARAMETER); /* precondition check end */ - ret = mtp_gdbus_storageinfo_get_storagetype(device_handle, storage_id, storagetype); + ret = mtp_gdbus_storageinfo_get_storagetype(mtp_device, mtp_storage, storage_type); - TC_PRT("storagetype %d", *storagetype); + TC_PRT("storagetype %d", *storage_type); _END(); return ret; } -int mtp_storageinfo_get_volumeidentifier(int device_handle, int storage_id, char **volumeidentifier) +int mtp_storageinfo_get_volume_identifier(int mtp_device, int mtp_storage, char **volume_identifier) { int ret = MTP_ERROR_NONE; @@ -579,14 +642,14 @@ int mtp_storageinfo_get_volumeidentifier(int device_handle, int storage_id, char CHECK_SUPPORTED(); CHECK_INIT(); CHECK_ACTIVATED(); - cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); - cond_expr_ret(storage_id == 0, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(mtp_storage == 0, MTP_ERROR_INVALID_PARAMETER); /* precondition check end */ - ret = mtp_gdbus_storageinfo_get_volumeidentifier(device_handle, storage_id, volumeidentifier); + ret = mtp_gdbus_storageinfo_get_volumeidentifier(mtp_device, mtp_storage, volume_identifier); - TC_PRT("volumeidentifier %s", *volumeidentifier); + TC_PRT("volumeidentifier %s", *volume_identifier); _END(); @@ -594,7 +657,7 @@ int mtp_storageinfo_get_volumeidentifier(int device_handle, int storage_id, char } /* Object Info */ -int mtp_objectinfo_get_parent_object_handle(int device_handle, int object_handle, +int mtp_objectinfo_get_parent_object_handle(int mtp_device, int object_handle, int *parent_object_handle) { int ret = MTP_ERROR_NONE; @@ -606,11 +669,11 @@ int mtp_objectinfo_get_parent_object_handle(int device_handle, int object_handle CHECK_SUPPORTED(); CHECK_INIT(); CHECK_ACTIVATED(); - cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER); /* precondition check end */ - ret = mtp_gdbus_objectinfo_get_property(device_handle, + ret = mtp_gdbus_objectinfo_get_property(mtp_device, object_handle, MTP_PROPERTY_PARENT_OBJECT_HANDLE, parent_object_handle); TC_PRT("parent object id %d", *parent_object_handle); @@ -620,8 +683,8 @@ int mtp_objectinfo_get_parent_object_handle(int device_handle, int object_handle return ret; } -int mtp_objectinfo_get_storage_id(int device_handle, int object_handle, - int *storage_id) +int mtp_objectinfo_get_storage(int mtp_device, int object_handle, + int *mtp_storage) { int ret = MTP_ERROR_NONE; @@ -632,19 +695,19 @@ int mtp_objectinfo_get_storage_id(int device_handle, int object_handle, CHECK_SUPPORTED(); CHECK_INIT(); CHECK_ACTIVATED(); - cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER); /* precondition check end */ - ret = mtp_gdbus_objectinfo_get_property(device_handle, - object_handle, MTP_PROPERTY_STORAGE_ID, storage_id); + ret = mtp_gdbus_objectinfo_get_property(mtp_device, + object_handle, MTP_PROPERTY_STORAGE, mtp_storage); _END(); return ret; } -int mtp_objectinfo_get_association_desc(int device_handle, +int mtp_objectinfo_get_association_desc(int mtp_device, int object_handle, int *asso_desc) { int ret = MTP_ERROR_NONE; @@ -656,11 +719,11 @@ int mtp_objectinfo_get_association_desc(int device_handle, CHECK_SUPPORTED(); CHECK_INIT(); CHECK_ACTIVATED(); - cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER); /* precondition check end */ - ret = mtp_gdbus_objectinfo_get_property(device_handle, + ret = mtp_gdbus_objectinfo_get_property(mtp_device, object_handle, MTP_PROPERTY_ASSOCIATION_DESC, asso_desc); _END(); @@ -668,7 +731,7 @@ int mtp_objectinfo_get_association_desc(int device_handle, return ret; } -int mtp_objectinfo_get_association_type(int device_handle, +int mtp_objectinfo_get_association_type(int mtp_device, int object_handle, int *asso_type) { int ret = MTP_ERROR_NONE; @@ -680,11 +743,11 @@ int mtp_objectinfo_get_association_type(int device_handle, CHECK_SUPPORTED(); CHECK_INIT(); CHECK_ACTIVATED(); - cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER); /* precondition check end */ - ret = mtp_gdbus_objectinfo_get_property(device_handle, + ret = mtp_gdbus_objectinfo_get_property(mtp_device, object_handle, MTP_PROPERTY_ASSOCIATION_TYPE, asso_type); _END(); @@ -692,7 +755,7 @@ int mtp_objectinfo_get_association_type(int device_handle, return ret; } -int mtp_objectinfo_get_size(int device_handle, int object_handle, int *size) +int mtp_objectinfo_get_size(int mtp_device, int object_handle, int *size) { int ret = MTP_ERROR_NONE; @@ -703,11 +766,11 @@ int mtp_objectinfo_get_size(int device_handle, int object_handle, int *size) CHECK_SUPPORTED(); CHECK_INIT(); CHECK_ACTIVATED(); - cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER); /* precondition check end */ - ret = mtp_gdbus_objectinfo_get_property(device_handle, + ret = mtp_gdbus_objectinfo_get_property(mtp_device, object_handle, MTP_PROPERTY_SIZE, size); _END(); @@ -715,7 +778,7 @@ int mtp_objectinfo_get_size(int device_handle, int object_handle, int *size) return ret; } -int mtp_objectinfo_get_data_created(int device_handle, +int mtp_objectinfo_get_data_created(int mtp_device, int object_handle, int *data_created) { int ret = MTP_ERROR_NONE; @@ -727,11 +790,11 @@ int mtp_objectinfo_get_data_created(int device_handle, CHECK_SUPPORTED(); CHECK_INIT(); CHECK_ACTIVATED(); - cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER); /* precondition check end */ - ret = mtp_gdbus_objectinfo_get_property(device_handle, + ret = mtp_gdbus_objectinfo_get_property(mtp_device, object_handle, MTP_PROPERTY_DATA_CREATED, data_created); _END(); @@ -739,7 +802,7 @@ int mtp_objectinfo_get_data_created(int device_handle, return ret; } -int mtp_objectinfo_get_data_modified(int device_handle, +int mtp_objectinfo_get_data_modified(int mtp_device, int object_handle, int *data_modified) { int ret = MTP_ERROR_NONE; @@ -751,11 +814,11 @@ int mtp_objectinfo_get_data_modified(int device_handle, CHECK_SUPPORTED(); CHECK_INIT(); CHECK_ACTIVATED(); - cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER); /* precondition check end */ - ret = mtp_gdbus_objectinfo_get_property(device_handle, + ret = mtp_gdbus_objectinfo_get_property(mtp_device, object_handle, MTP_PROPERTY_DATA_MODIFIED, data_modified); _END(); @@ -763,7 +826,7 @@ int mtp_objectinfo_get_data_modified(int device_handle, return ret; } -int mtp_objectinfo_get_format(int device_handle, int object_handle, int *format) +int mtp_objectinfo_get_file_type(int mtp_device, int object_handle, mtp_filetype_e *file_type) { int ret = MTP_ERROR_NONE; @@ -774,19 +837,19 @@ int mtp_objectinfo_get_format(int device_handle, int object_handle, int *format) CHECK_SUPPORTED(); CHECK_INIT(); CHECK_ACTIVATED(); - cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER); /* precondition check end */ - ret = mtp_gdbus_objectinfo_get_property(device_handle, - object_handle, MTP_PROPERTY_FORMAT, format); + ret = mtp_gdbus_objectinfo_get_property(mtp_device, + object_handle, MTP_PROPERTY_FORMAT, (int*)file_type); _END(); return ret; } -int mtp_objectinfo_get_image_pix_depth(int device_handle, +int mtp_objectinfo_get_image_bit_depth(int mtp_device, int object_handle, int *depth) { int ret = MTP_ERROR_NONE; @@ -798,19 +861,19 @@ int mtp_objectinfo_get_image_pix_depth(int device_handle, CHECK_SUPPORTED(); CHECK_INIT(); CHECK_ACTIVATED(); - cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER); /* precondition check end */ - ret = mtp_gdbus_objectinfo_get_property(device_handle, - object_handle, MTP_PROPERTY_IMAGE_FIX_DEPTH, depth); + ret = mtp_gdbus_objectinfo_get_property(mtp_device, + object_handle, MTP_PROPERTY_IMAGE_BIT_DEPTH, depth); _END(); return ret; } -int mtp_objectinfo_get_image_pix_width(int device_handle, +int mtp_objectinfo_get_image_pix_width(int mtp_device, int object_handle, int *width) { int ret = MTP_ERROR_NONE; @@ -822,11 +885,11 @@ int mtp_objectinfo_get_image_pix_width(int device_handle, CHECK_SUPPORTED(); CHECK_INIT(); CHECK_ACTIVATED(); - cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER); /* precondition check end */ - ret = mtp_gdbus_objectinfo_get_property(device_handle, + ret = mtp_gdbus_objectinfo_get_property(mtp_device, object_handle, MTP_PROPERTY_IMAGE_FIX_WIDTH, width); _END(); @@ -834,7 +897,7 @@ int mtp_objectinfo_get_image_pix_width(int device_handle, return ret; } -int mtp_objectinfo_get_image_pix_height(int device_handle, +int mtp_objectinfo_get_image_pix_height(int mtp_device, int object_handle, int *height) { int ret = MTP_ERROR_NONE; @@ -846,11 +909,11 @@ int mtp_objectinfo_get_image_pix_height(int device_handle, CHECK_SUPPORTED(); CHECK_INIT(); CHECK_ACTIVATED(); - cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER); /* precondition check end */ - ret = mtp_gdbus_objectinfo_get_property(device_handle, + ret = mtp_gdbus_objectinfo_get_property(mtp_device, object_handle, MTP_PROPERTY_IMAGE_FIX_HEIGHT, height); _END(); @@ -858,7 +921,7 @@ int mtp_objectinfo_get_image_pix_height(int device_handle, return ret; } -int mtp_objectinfo_get_thumbnail_size(int device_handle, +int mtp_objectinfo_get_thumbnail_size(int mtp_device, int object_handle, int *size) { int ret = MTP_ERROR_NONE; @@ -870,11 +933,11 @@ int mtp_objectinfo_get_thumbnail_size(int device_handle, CHECK_SUPPORTED(); CHECK_INIT(); CHECK_ACTIVATED(); - cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER); /* precondition check end */ - ret = mtp_gdbus_objectinfo_get_property(device_handle, + ret = mtp_gdbus_objectinfo_get_property(mtp_device, object_handle, MTP_PROPERTY_THUMBNAIL_SIZE, size); _END(); @@ -882,8 +945,8 @@ int mtp_objectinfo_get_thumbnail_size(int device_handle, return ret; } -int mtp_objectinfo_get_thumbnail_format(int device_handle, - int object_handle, int *format) +int mtp_objectinfo_get_thumbnail_file_type(int mtp_device, + int object_handle, mtp_filetype_e *file_type) { int ret = MTP_ERROR_NONE; @@ -894,19 +957,19 @@ int mtp_objectinfo_get_thumbnail_format(int device_handle, CHECK_SUPPORTED(); CHECK_INIT(); CHECK_ACTIVATED(); - cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER); /* precondition check end */ - ret = mtp_gdbus_objectinfo_get_property(device_handle, - object_handle, MTP_PROPERTY_THUMBNAIL_FORMAT, format); + ret = mtp_gdbus_objectinfo_get_property(mtp_device, + object_handle, MTP_PROPERTY_THUMBNAIL_FORMAT, (int*)file_type); _END(); return ret; } -int mtp_objectinfo_get_thumbnail_pix_height(int device_handle, +int mtp_objectinfo_get_thumbnail_pix_height(int mtp_device, int object_handle, int *height) { int ret = MTP_ERROR_NONE; @@ -918,11 +981,11 @@ int mtp_objectinfo_get_thumbnail_pix_height(int device_handle, CHECK_SUPPORTED(); CHECK_INIT(); CHECK_ACTIVATED(); - cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER); /* precondition check end */ - ret = mtp_gdbus_objectinfo_get_property(device_handle, + ret = mtp_gdbus_objectinfo_get_property(mtp_device, object_handle, MTP_PROPERTY_THUMBNAIL_HEIGHT, height); _END(); @@ -930,7 +993,7 @@ int mtp_objectinfo_get_thumbnail_pix_height(int device_handle, return ret; } -int mtp_objectinfo_get_thumbnail_pix_width(int device_handle, +int mtp_objectinfo_get_thumbnail_pix_width(int mtp_device, int object_handle, int *width) { int ret = MTP_ERROR_NONE; @@ -942,11 +1005,11 @@ int mtp_objectinfo_get_thumbnail_pix_width(int device_handle, CHECK_SUPPORTED(); CHECK_INIT(); CHECK_ACTIVATED(); - cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER); /* precondition check end */ - ret = mtp_gdbus_objectinfo_get_property(device_handle, + ret = mtp_gdbus_objectinfo_get_property(mtp_device, object_handle, MTP_PROPERTY_THUMBNAIL_WIDTH, width); _END(); @@ -954,7 +1017,7 @@ int mtp_objectinfo_get_thumbnail_pix_width(int device_handle, return ret; } -int mtp_objectinfo_get_filename(int device_handle, +int mtp_objectinfo_get_file_name(int mtp_device, int object_handle, char **filename) { int ret = MTP_ERROR_NONE; @@ -966,11 +1029,11 @@ int mtp_objectinfo_get_filename(int device_handle, CHECK_SUPPORTED(); CHECK_INIT(); CHECK_ACTIVATED(); - cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER); /* precondition check end */ - ret = mtp_gdbus_objectinfo_get_property_string(device_handle, + ret = mtp_gdbus_objectinfo_get_property_string(mtp_device, object_handle, MTP_PROPERTY_FILENAME, filename); _END(); @@ -978,7 +1041,7 @@ int mtp_objectinfo_get_filename(int device_handle, return ret; } -int mtp_objectinfo_get_keywords(int device_handle, +int mtp_objectinfo_get_keywords(int mtp_device, int object_handle, char **keywords) { int ret = MTP_ERROR_NONE; @@ -990,11 +1053,11 @@ int mtp_objectinfo_get_keywords(int device_handle, CHECK_SUPPORTED(); CHECK_INIT(); CHECK_ACTIVATED(); - cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER); /* precondition check end */ - ret = mtp_gdbus_objectinfo_get_property_string(device_handle, + ret = mtp_gdbus_objectinfo_get_property_string(mtp_device, object_handle, MTP_PROPERTY_KEYWORDS, keywords); _END(); @@ -1002,7 +1065,7 @@ int mtp_objectinfo_get_keywords(int device_handle, return ret; } -int mtp_objectinfo_get_object_info(int device_handle, +int mtp_objectinfo_get_object_info(int mtp_device, int object_handle, mtp_object_info **object_info) { int ret = MTP_ERROR_NONE; @@ -1014,11 +1077,11 @@ int mtp_objectinfo_get_object_info(int device_handle, CHECK_SUPPORTED(); CHECK_INIT(); CHECK_ACTIVATED(); - cond_expr_ret(device_handle == 0, MTP_ERROR_INVALID_PARAMETER); + cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER); /* precondition check end */ - ret = mtp_db_get_object_info(device_handle, object_handle, object_info); + ret = mtp_db_get_object_info(mtp_device, object_handle, object_info); _END(); diff --git a/src/mtp_db.c b/src/mtp_db.c index fe4b685..ddd1e2e 100755 --- a/src/mtp_db.c +++ b/src/mtp_db.c @@ -49,7 +49,7 @@ mtp_error_e mtp_db_init() return ret; } -mtp_error_e mtp_db_get_object_info(int device_handle, int object_handle, mtp_object_info** object_info) +mtp_error_e mtp_db_get_object_info(int mtp_device, int object_handle, mtp_object_info** object_info) { int ret = MTP_ERROR_NONE; int sql_ret; @@ -65,8 +65,8 @@ mtp_error_e mtp_db_get_object_info(int device_handle, int object_handle, mtp_obj *object_info = (mtp_object_info *)malloc(sizeof(mtp_object_info)); - sql = sqlite3_mprintf("SELECT * FROM %s WHERE device_handle=%d and object_handle=%d;", - MTP_DB_TABLE, device_handle, object_handle); + sql = sqlite3_mprintf("SELECT * FROM %s WHERE mtp_device=%d and object_handle=%d;", + MTP_DB_TABLE, mtp_device, object_handle); if (sql != NULL && (*object_info) != NULL) { sql_ret = sqlite3_prepare_v2(db, sql, strlen(sql), &stmt, NULL); diff --git a/src/mtp_gdbus_deviceinfo.c b/src/mtp_gdbus_deviceinfo.c index eff5d5b..f6e0da4 100755 --- a/src/mtp_gdbus_deviceinfo.c +++ b/src/mtp_gdbus_deviceinfo.c @@ -34,88 +34,88 @@ void mtp_gdbus_deviceinfo_proxy_deinit(void) deviceinfo_proxy = NULL; } -mtp_error_e mtp_gdbus_deviceinfo_get_manufacturername(int device_handle, char **manufacturername) +mtp_error_e mtp_gdbus_deviceinfo_get_manufacturername(int mtp_device, char **manufacturername) { mtp_error_e result = MTP_ERROR_NONE; GError *error = NULL; if (deviceinfo_proxy == NULL) - return MTP_ERROR_GENERAL; + return MTP_ERROR_NOT_COMM_INITIALIZED; if (mtp_gdbuslib_deviceinfo_call_get_manufacturername_sync( deviceinfo_proxy, - device_handle, + mtp_device, manufacturername, &result, NULL, &error) == FALSE) { - result = MTP_ERROR_IO_ERROR; + result = MTP_ERROR_COMM_ERROR; g_error_free(error); } return result; } -mtp_error_e mtp_gdbus_deviceinfo_get_modelname(int device_handle, char **modelname) +mtp_error_e mtp_gdbus_deviceinfo_get_modelname(int mtp_device, char **modelname) { mtp_error_e result = MTP_ERROR_NONE; GError *error = NULL; if (deviceinfo_proxy == NULL) - return MTP_ERROR_GENERAL; + return MTP_ERROR_NOT_COMM_INITIALIZED; if (mtp_gdbuslib_deviceinfo_call_get_modelname_sync( deviceinfo_proxy, - device_handle, + mtp_device, modelname, &result, NULL, &error) == FALSE) { - result = MTP_ERROR_IO_ERROR; + result = MTP_ERROR_COMM_ERROR; g_error_free(error); } return result; } -mtp_error_e mtp_gdbus_deviceinfo_get_serialnumber(int device_handle, char **serialnumber) +mtp_error_e mtp_gdbus_deviceinfo_get_serialnumber(int mtp_device, char **serialnumber) { mtp_error_e result = MTP_ERROR_NONE; GError *error = NULL; if (deviceinfo_proxy == NULL) - return MTP_ERROR_GENERAL; + return MTP_ERROR_NOT_COMM_INITIALIZED; if (mtp_gdbuslib_deviceinfo_call_get_serialnumber_sync( deviceinfo_proxy, - device_handle, + mtp_device, serialnumber, &result, NULL, &error) == FALSE) { - result = MTP_ERROR_IO_ERROR; + result = MTP_ERROR_COMM_ERROR; g_error_free(error); } return result; } -mtp_error_e mtp_gdbus_deviceinfo_get_deviceversion(int device_handle, char **deviceversion) +mtp_error_e mtp_gdbus_deviceinfo_get_deviceversion(int mtp_device, char **deviceversion) { mtp_error_e result = MTP_ERROR_NONE; GError *error = NULL; if (deviceinfo_proxy == NULL) - return MTP_ERROR_GENERAL; + return MTP_ERROR_NOT_COMM_INITIALIZED; if (mtp_gdbuslib_deviceinfo_call_get_deviceversion_sync( deviceinfo_proxy, - device_handle, + mtp_device, deviceversion, &result, NULL, &error) == FALSE) { - result = MTP_ERROR_IO_ERROR; + result = MTP_ERROR_COMM_ERROR; g_error_free(error); } diff --git a/src/mtp_gdbus_manager.c b/src/mtp_gdbus_manager.c index ca4b603..63be494 100755 --- a/src/mtp_gdbus_manager.c +++ b/src/mtp_gdbus_manager.c @@ -14,6 +14,12 @@ * limitations under the License. */ +#include +#include +#include +#include +#include + #include "mtp_gdbus_manager.h" #include "mtp_gdbus_objectinfo.h" #include "mtp_gdbus_deviceinfo.h" @@ -76,12 +82,12 @@ mtp_error_e mtp_gdbus_manager_initialize(void) mtp_gdbus_objectinfo_proxy_init(); if (manager_proxy == NULL) - result = MTP_ERROR_GENERAL; + result = MTP_ERROR_NOT_COMM_INITIALIZED; return result; } -mtp_error_e mtp_gdbus_manager_get_device_list(mtp_device_list **dev_list) +mtp_error_e mtp_gdbus_manager_get_raw_devices(mtp_raw_device ***raw_devices, int *device_count) { int dev_count; GVariant *va = NULL; @@ -89,41 +95,45 @@ mtp_error_e mtp_gdbus_manager_get_device_list(mtp_device_list **dev_list) GError *error = NULL; if (manager_proxy == NULL) - return MTP_ERROR_GENERAL; + return MTP_ERROR_NOT_COMM_INITIALIZED; - if (mtp_gdbuslib_manager_call_get_device_list_sync( + if (mtp_gdbuslib_manager_call_get_raw_devices_sync( manager_proxy, &dev_count, &va, &result, NULL, &error) == FALSE) { - result = MTP_ERROR_IO_ERROR; + result = MTP_ERROR_COMM_ERROR; g_error_free(error); return result; } + *device_count = dev_count; + if (dev_count != 0 && (g_variant_n_children(va) == dev_count)) { GVariantIter *iter = NULL, *iter_row = NULL; GVariant *key_value; const gchar *key; guint i = 0; - *dev_list = g_new(mtp_device_list, 1); - (*dev_list)->device_num = dev_count; - (*dev_list)->devices = g_new(mtp_device, dev_count); + *raw_devices = (mtp_raw_device **)malloc(sizeof(mtp_raw_device*) * 1); + **raw_devices = (mtp_raw_device *)malloc(sizeof(mtp_raw_device) * *device_count); g_variant_get(va, "aa{sv}", &iter); while (g_variant_iter_next(iter, "a{sv}", &iter_row)) { while (g_variant_iter_loop(iter_row, "{sv}", &key, &key_value)) { if (g_strcmp0(key, "model_name") == 0) { - ((*dev_list)->devices)[i].model_name = + (**raw_devices)[i].model_name = g_strdup(g_variant_get_string(key_value, NULL)); } else if (g_strcmp0(key, "bus_location") == 0) { - ((*dev_list)->devices)[i].bus_location = g_variant_get_int32(key_value); + (**raw_devices)[i].bus_location = g_variant_get_int32(key_value); + } else if (g_strcmp0(key, "device_number") == 0) { + (**raw_devices)[i].device_number = g_variant_get_int32(key_value); } } + (**raw_devices)[i].dev_count = dev_count; i++; g_variant_iter_free(iter_row); } @@ -137,22 +147,23 @@ mtp_error_e mtp_gdbus_manager_get_device_list(mtp_device_list **dev_list) return result; } -mtp_error_e mtp_gdbus_manager_get_device_handle(int bus_location, int *device_handle) +mtp_error_e mtp_gdbus_manager_get_device(int bus_location, int device_number, int *mtp_device) { mtp_error_e result = MTP_ERROR_NONE; GError *error = NULL; if (manager_proxy == NULL) - return MTP_ERROR_GENERAL; + return MTP_ERROR_NOT_COMM_INITIALIZED; - if (mtp_gdbuslib_manager_call_get_device_handle_sync( + if (mtp_gdbuslib_manager_call_get_device_sync( manager_proxy, bus_location, - device_handle, + device_number, + mtp_device, &result, NULL, &error) == FALSE) { - result = MTP_ERROR_IO_ERROR; + result = MTP_ERROR_COMM_ERROR; g_error_free(error); } @@ -160,25 +171,25 @@ mtp_error_e mtp_gdbus_manager_get_device_handle(int bus_location, int *device_ha return result; } -mtp_error_e mtp_gdbus_manager_get_storage_ids(int device_handle, - int **storage_ids, int *storage_num) +mtp_error_e mtp_gdbus_manager_get_storages(int mtp_device, + int **mtp_storages, int *storage_num) { GVariant *va = NULL; mtp_error_e result = MTP_ERROR_NONE; GError *error = NULL; if (manager_proxy == NULL) - return MTP_ERROR_GENERAL; + return MTP_ERROR_NOT_COMM_INITIALIZED; - if (mtp_gdbuslib_manager_call_get_storage_ids_sync( + if (mtp_gdbuslib_manager_call_get_storages_sync( manager_proxy, - device_handle, + mtp_device, storage_num, &va, &result, NULL, &error) == FALSE) { - result = MTP_ERROR_IO_ERROR; + result = MTP_ERROR_COMM_ERROR; g_error_free(error); return result; @@ -190,13 +201,13 @@ mtp_error_e mtp_gdbus_manager_get_storage_ids(int device_handle, const gchar *key; guint i = 0; - *storage_ids = g_new(int, *storage_num); + *mtp_storages = g_new(int, *storage_num); g_variant_get(va, "aa{sv}", &iter); while (g_variant_iter_next(iter, "a{sv}", &iter_row)) { while (g_variant_iter_loop(iter_row, "{sv}", &key, &key_value)) { - if (g_strcmp0(key, "storage_id") == 0) - (*storage_ids)[i] = g_variant_get_int32(key_value); + if (g_strcmp0(key, "mtp_storage") == 0) + (*mtp_storages)[i] = g_variant_get_int32(key_value); } i++; g_variant_iter_free(iter_row); @@ -209,20 +220,20 @@ mtp_error_e mtp_gdbus_manager_get_storage_ids(int device_handle, return result; } -mtp_error_e mtp_gdbus_manager_get_object_handles(int device_handle, - int storage_id, int format, int parent_object_handle, int **object_handles, int *object_num) +mtp_error_e mtp_gdbus_manager_get_object_handles(int mtp_device, + int mtp_storage, int format, int parent_object_handle, int **object_handles, int *object_num) { GVariant *va = NULL; mtp_error_e result = MTP_ERROR_NONE; GError *error = NULL; if (manager_proxy == NULL) - return MTP_ERROR_GENERAL; + return MTP_ERROR_NOT_COMM_INITIALIZED; if (mtp_gdbuslib_manager_call_get_object_handles_sync( manager_proxy, - device_handle, - storage_id, + mtp_device, + mtp_storage, format, parent_object_handle, object_num, @@ -230,7 +241,7 @@ mtp_error_e mtp_gdbus_manager_get_object_handles(int device_handle, &result, NULL, &error) == FALSE) { - result = MTP_ERROR_IO_ERROR; + result = MTP_ERROR_COMM_ERROR; g_error_free(error); return result; @@ -261,23 +272,23 @@ mtp_error_e mtp_gdbus_manager_get_object_handles(int device_handle, return result; } -mtp_error_e mtp_gdbus_manager_delete_object(int device_handle, +mtp_error_e mtp_gdbus_manager_delete_object(int mtp_device, int object_handle) { mtp_error_e result = MTP_ERROR_NONE; GError *error = NULL; if (manager_proxy == NULL) - return MTP_ERROR_GENERAL; + return MTP_ERROR_NOT_COMM_INITIALIZED; if (mtp_gdbuslib_manager_call_delete_object_sync( manager_proxy, - device_handle, + mtp_device, object_handle, &result, NULL, &error) == FALSE) { - result = MTP_ERROR_IO_ERROR; + result = MTP_ERROR_COMM_ERROR; g_error_free(error); } @@ -285,24 +296,24 @@ mtp_error_e mtp_gdbus_manager_delete_object(int device_handle, return result; } -mtp_error_e mtp_gdbus_manager_get_object(int device_handle, +mtp_error_e mtp_gdbus_manager_get_object(int mtp_device, int object_handle, char *dest_path) { mtp_error_e result = MTP_ERROR_NONE; GError *error = NULL; if (manager_proxy == NULL) - return MTP_ERROR_GENERAL; + return MTP_ERROR_NOT_COMM_INITIALIZED; if (mtp_gdbuslib_manager_call_get_object_sync( manager_proxy, - device_handle, + mtp_device, object_handle, dest_path, &result, NULL, &error) == FALSE) { - result = MTP_ERROR_IO_ERROR; + result = MTP_ERROR_COMM_ERROR; g_error_free(error); } @@ -310,24 +321,24 @@ mtp_error_e mtp_gdbus_manager_get_object(int device_handle, return result; } -mtp_error_e mtp_gdbus_manager_get_thumbnail(int device_handle, +mtp_error_e mtp_gdbus_manager_get_thumbnail(int mtp_device, int object_handle, char *dest_path) { mtp_error_e result = MTP_ERROR_NONE; GError *error = NULL; if (manager_proxy == NULL) - return MTP_ERROR_GENERAL; + return MTP_ERROR_NOT_COMM_INITIALIZED; if (mtp_gdbuslib_manager_call_get_thumbnail_sync( manager_proxy, - device_handle, + mtp_device, object_handle, dest_path, &result, NULL, &error) == FALSE) { - result = MTP_ERROR_IO_ERROR; + result = MTP_ERROR_COMM_ERROR; g_error_free(error); } diff --git a/src/mtp_gdbus_objectinfo.c b/src/mtp_gdbus_objectinfo.c index 38077fb..c5382ff 100755 --- a/src/mtp_gdbus_objectinfo.c +++ b/src/mtp_gdbus_objectinfo.c @@ -34,50 +34,50 @@ void mtp_gdbus_objectinfo_proxy_deinit(void) objectinfo_proxy = NULL; } -int mtp_gdbus_objectinfo_get_property(int device_handle, +int mtp_gdbus_objectinfo_get_property(int mtp_device, int object_handle, int property, int *property_value) { mtp_error_e result = MTP_ERROR_NONE; GError *error = NULL; if (objectinfo_proxy == NULL) - return MTP_ERROR_GENERAL; + return MTP_ERROR_NOT_COMM_INITIALIZED; if (mtp_gdbuslib_objectinfo_call_get_property_sync( objectinfo_proxy, - device_handle, + mtp_device, object_handle, property, property_value, &result, NULL, &error) == FALSE) { - result = MTP_ERROR_IO_ERROR; + result = MTP_ERROR_COMM_ERROR; g_error_free(error); } return result; } -int mtp_gdbus_objectinfo_get_property_string(int device_handle, +int mtp_gdbus_objectinfo_get_property_string(int mtp_device, int object_handle, int property, char **property_value) { mtp_error_e result = MTP_ERROR_NONE; GError *error = NULL; if (objectinfo_proxy == NULL) - return MTP_ERROR_GENERAL; + return MTP_ERROR_NOT_COMM_INITIALIZED; if (mtp_gdbuslib_objectinfo_call_get_property_string_sync( objectinfo_proxy, - device_handle, + mtp_device, object_handle, property, property_value, &result, NULL, &error) == FALSE) { - result = MTP_ERROR_IO_ERROR; + result = MTP_ERROR_COMM_ERROR; g_error_free(error); } diff --git a/src/mtp_gdbus_storageinfo.c b/src/mtp_gdbus_storageinfo.c index b8ab9f6..db5f020 100755 --- a/src/mtp_gdbus_storageinfo.c +++ b/src/mtp_gdbus_storageinfo.c @@ -34,120 +34,120 @@ void mtp_gdbus_storageinfo_proxy_deinit(void) storageinfo_proxy = NULL; } -mtp_error_e mtp_gdbus_storageinfo_get_description(int device_handle, - int storage_id, char **description) +mtp_error_e mtp_gdbus_storageinfo_get_description(int mtp_device, + int mtp_storage, char **description) { mtp_error_e result = MTP_ERROR_NONE; GError *error = NULL; if (storageinfo_proxy == NULL) - return MTP_ERROR_GENERAL; + return MTP_ERROR_NOT_COMM_INITIALIZED; if (mtp_gdbuslib_storageinfo_call_get_description_sync( storageinfo_proxy, - device_handle, - storage_id, + mtp_device, + mtp_storage, description, &result, NULL, &error) == FALSE) { - result = MTP_ERROR_IO_ERROR; + result = MTP_ERROR_COMM_ERROR; g_error_free(error); } return result; } -mtp_error_e mtp_gdbus_storageinfo_get_freespace(int device_handle, - int storage_id, guint64 *freespace) +mtp_error_e mtp_gdbus_storageinfo_get_freespace(int mtp_device, + int mtp_storage, guint64 *freespace) { mtp_error_e result = MTP_ERROR_NONE; GError *error = NULL; if (storageinfo_proxy == NULL) - return MTP_ERROR_GENERAL; + return MTP_ERROR_NOT_COMM_INITIALIZED; if (mtp_gdbuslib_storageinfo_call_get_free_space_sync( storageinfo_proxy, - device_handle, - storage_id, + mtp_device, + mtp_storage, freespace, &result, NULL, &error) == FALSE) { - result = MTP_ERROR_IO_ERROR; + result = MTP_ERROR_COMM_ERROR; g_error_free(error); } return result; } -mtp_error_e mtp_gdbus_storageinfo_get_maxcapacity(int device_handle, - int storage_id, guint64 *maxcapacity) +mtp_error_e mtp_gdbus_storageinfo_get_maxcapacity(int mtp_device, + int mtp_storage, guint64 *maxcapacity) { mtp_error_e result = MTP_ERROR_NONE; GError *error = NULL; if (storageinfo_proxy == NULL) - return MTP_ERROR_GENERAL; + return MTP_ERROR_NOT_COMM_INITIALIZED; if (mtp_gdbuslib_storageinfo_call_get_max_capacity_sync( storageinfo_proxy, - device_handle, - storage_id, + mtp_device, + mtp_storage, maxcapacity, &result, NULL, &error) == FALSE) { - result = MTP_ERROR_IO_ERROR; + result = MTP_ERROR_COMM_ERROR; g_error_free(error); } return result; } -mtp_error_e mtp_gdbus_storageinfo_get_storagetype(int device_handle, - int storage_id, int *storagetype) +mtp_error_e mtp_gdbus_storageinfo_get_storagetype(int mtp_device, + int mtp_storage, int *storagetype) { mtp_error_e result = MTP_ERROR_NONE; GError *error = NULL; if (storageinfo_proxy == NULL) - return MTP_ERROR_GENERAL; + return MTP_ERROR_NOT_COMM_INITIALIZED; if (mtp_gdbuslib_storageinfo_call_get_storage_type_sync( storageinfo_proxy, - device_handle, - storage_id, + mtp_device, + mtp_storage, storagetype, &result, NULL, &error) == FALSE) { - result = MTP_ERROR_IO_ERROR; + result = MTP_ERROR_COMM_ERROR; g_error_free(error); } return result; } -mtp_error_e mtp_gdbus_storageinfo_get_volumeidentifier(int device_handle, - int storage_id, char **volumeidentifier) +mtp_error_e mtp_gdbus_storageinfo_get_volumeidentifier(int mtp_device, + int mtp_storage, char **volumeidentifier) { mtp_error_e result = MTP_ERROR_NONE; GError *error = NULL; if (storageinfo_proxy == NULL) - return MTP_ERROR_GENERAL; + return MTP_ERROR_NOT_COMM_INITIALIZED; if (mtp_gdbuslib_storageinfo_call_get_volume_identifier_sync( storageinfo_proxy, - device_handle, - storage_id, + mtp_device, + mtp_storage, volumeidentifier, &result, NULL, &error) == FALSE) { - result = MTP_ERROR_IO_ERROR; + result = MTP_ERROR_COMM_ERROR; g_error_free(error); } diff --git a/src/mtp_gdbuslib.xml b/src/mtp_gdbuslib.xml index 45afda8..aaca563 100755 --- a/src/mtp_gdbuslib.xml +++ b/src/mtp_gdbuslib.xml @@ -4,28 +4,29 @@ - - - + + + - + - + + - - + + - + - - + + @@ -34,21 +35,21 @@ - + - + - + @@ -60,75 +61,75 @@ - + - + - + - + - - + + - - + + - - + + - - + + - - + + - + - + diff --git a/test/mtp_unit_test.c b/test/mtp_unit_test.c index 6488e98..266a0d2 100755 --- a/test/mtp_unit_test.c +++ b/test/mtp_unit_test.c @@ -18,14 +18,10 @@ #define BEGIN() TC_PRT("BEGIN >>>>"); #define END() TC_PRT("END <<<<"); -static int handle; -static mtp_device_list* dev_list; - -static int strg_handle = 0; -static int* strg_list; - -static int obj_handle = 0; -static int* obj_list; +static mtp_device_h mtp_device; +static mtp_storage_h mtp_storage = 0; +static mtp_object_h mtp_object = 0; +static mtp_object_h* mtp_objects; int obj_count; GMainLoop *main_loop = NULL; @@ -144,20 +140,28 @@ int manager_test_initialize(void) return ret; } -int manager_test_get_device_list(void) +int manager_test_get_raw_devices(void) { int ret = 0; int i; + mtp_raw_device_h *raw_devices = NULL; + int device_count; + BEGIN(); - ret = mtp_get_device_list(&dev_list); + ret = mtp_get_raw_devices(&raw_devices, &device_count); + TC_PRT("ret[%d]: device_num[%d]", ret, device_count); if (ret == MTP_ERROR_NONE) { - TC_PRT("ret[%d]: device_num[%d]", ret, dev_list->device_num); - - for (i = 0; i < dev_list->device_num; i++) { - TC_PRT("device bus_location[%d] model_name[%s]", - dev_list->devices[i].bus_location, dev_list->devices[i].model_name); + for (i = 0; i < device_count; i++) { + int bus_location; + int device_number; + char *device_name = NULL; + mtp_get_bus_location(raw_devices[i], &bus_location); + mtp_get_device_number(raw_devices[i], &device_number); + mtp_get_device_name(raw_devices[i], &device_name); + TC_PRT("device bus_location[%d], dev_no [%d], model_name[%s]", + bus_location, device_number, device_name); } } else { TC_PRT("get device list failed, ret[%d]", ret); @@ -167,64 +171,94 @@ int manager_test_get_device_list(void) return ret; } -int manager_test_get_device_handle(void) +int manager_test_get_device(void) { int ret = 0; - int input_int = 0; int bus_location = 0; + int device_number = 0; + int device_count; + mtp_raw_device_h *raw_devices = NULL; + BEGIN(); - if (dev_list->device_num == 0) { + ret = mtp_get_raw_devices(&raw_devices, &device_count); + + if (ret != MTP_ERROR_NONE) { + TC_PRT("mtp_get_raw_devices is failed!!!"); + return -1; + } + + if (device_count == 0) { TC_PRT("device is not exist!!!"); END(); return -1; } - input_int = dev_list->devices[0].bus_location; + TC_PRT("Select first device"); - if (dev_list->device_num > 1) { - if (!test_get_user_int("==> Input Bus_location No :", &input_int)) - TC_PRT("select first bus[%d]", input_int); - } + mtp_get_bus_location(raw_devices[0], &bus_location); + mtp_get_device_number(raw_devices[0], &device_number); - bus_location = input_int; + TC_PRT("bus location : %d, device_number : %d", bus_location, device_number); - ret = mtp_get_device_handle(bus_location, &handle); - TC_PRT("ret[%d]: 1st device handle[%d]", ret, handle); + ret = mtp_get_device(bus_location, device_number, &mtp_device); + TC_PRT("ret[%d]: 1st mtp device [%d]", ret, mtp_device); END(); return ret; } -int manager_test_get_storage_ids(void) +int manager_test_get_storages(void) { - int ret = 0; int i; - int count = 0; - int input_int = 0; - BEGIN(); + int ret = 0; + int bus_location = 0; + int device_number = 0; + int device_count; + int storage_count; + mtp_raw_device_h *raw_devices = NULL; + mtp_storage_h *mtp_storages = NULL; - ret = mtp_get_storage_ids(handle, &strg_list, &count); - TC_PRT("ret[%d]: storage_num[%d]", ret, count); + ret = mtp_get_raw_devices(&raw_devices, &device_count); - if (count == 0) { - TC_PRT("storage is not exist!!!"); + if (ret != MTP_ERROR_NONE) { + TC_PRT("mtp_get_raw_devices is failed!!!"); + return -1; + } + + if (device_count == 0) { + TC_PRT("device is not exist!!!"); END(); return -1; } - for (i = 0; i < count; i++) - TC_PRT("storage handle[%d]", strg_list[i]); + TC_PRT("Select first device"); + + mtp_get_bus_location(raw_devices[0], &bus_location); + mtp_get_device_number(raw_devices[0], &device_number); - input_int = strg_list[0]; + TC_PRT("bus location : %d, device_number : %d", bus_location, device_number); - if (count > 1) { - if (!test_get_user_int("==> Input Storage Handle :", &input_int)) - TC_PRT("select first storage[%d]", strg_list[0]); + ret = mtp_get_device(bus_location, device_number, &mtp_device); + TC_PRT("ret[%d]: 1st mtp device [%d]", ret, mtp_device); + + ret = mtp_get_storages(mtp_device, &mtp_storages, &storage_count); + TC_PRT("ret[%d]: storage_count[%d]", ret, storage_count); + + if (storage_count == 0) { + TC_PRT("storage is not exist!!!"); + END(); + return -1; } - strg_handle = input_int; - TC_PRT("selected storage handle[%d]", strg_handle); + ret = mtp_destroy_raw_devices(raw_devices); + TC_PRT("ret[%d]: mtp_destroy_raw_devices", ret); + + + for (i = 0; i < storage_count; i++) + TC_PRT("mtp storage %d [%d]", i, mtp_storages[i]); + + mtp_storage = mtp_storages[0]; END(); return ret; @@ -239,35 +273,35 @@ int manager_test_get_object_handles(void) int folder_count = 0; int *file_list; int file_count = 0; - int format = MTP_FILETYPE_FOLDER; + mtp_filetype_e filetype = MTP_FILETYPE_FOLDER; char *filename = NULL; int folder_max = 0; int file_max = 0; int list_max = 0; BEGIN(); - ret = mtp_get_object_handles(handle, strg_handle, MTP_FILETYPE_FOLDER, obj_handle, &folder_list, &folder_count); + ret = mtp_get_object_handles(mtp_device, mtp_storage, MTP_FILETYPE_FOLDER, mtp_object, &folder_list, &folder_count); TC_PRT("ret[%d]: total folder_count[%d]", ret, folder_count); folder_max = (folder_count < TEST_LIST_MAX) ? folder_count : TEST_LIST_MAX; for (i = 0; i < folder_max; i++) { - ret = mtp_objectinfo_get_filename(handle, folder_list[i], &filename); - ret = mtp_objectinfo_get_format(handle, folder_list[i], &format); - TC_PRT("ret[%d]: object id[%d] - filename[%s], format[%s]", - ret, folder_list[i], filename, test_filetype_to_string(format)); + ret = mtp_objectinfo_get_file_name(mtp_device, folder_list[i], &filename); + ret = mtp_objectinfo_get_file_type(mtp_device, folder_list[i], &filetype); + TC_PRT("ret[%d]: object id[%d] - filename[%s], filetype[%s]", + ret, folder_list[i], filename, test_filetype_to_string(filetype)); } - ret = mtp_get_object_handles(handle, strg_handle, MTP_FILETYPE_JPEG, obj_handle, &file_list, &file_count); + ret = mtp_get_object_handles(mtp_device, mtp_storage, MTP_FILETYPE_JPEG, mtp_object, &file_list, &file_count); TC_PRT("ret[%d]: total file_count[%d]", ret, file_count); file_max = (file_count < TEST_LIST_MAX) ? file_count : TEST_LIST_MAX; for (i = 0; i < file_max; i++) { - ret = mtp_objectinfo_get_filename(handle, file_list[i], &filename); - ret = mtp_objectinfo_get_format(handle, file_list[i], &format); - TC_PRT("ret[%d]: object id[%d] - filename[%s], format[%s]", - ret, file_list[i], filename, test_filetype_to_string(format)); + ret = mtp_objectinfo_get_file_name(mtp_device, file_list[i], &filename); + ret = mtp_objectinfo_get_file_type(mtp_device, file_list[i], &filetype); + TC_PRT("ret[%d]: object id[%d] - filename[%s], filetype[%s]", + ret, file_list[i], filename, test_filetype_to_string(filetype)); } if (!test_get_user_int("==> Select Object Type(FOLDER:0, JPEG:14)" @@ -275,27 +309,27 @@ int manager_test_get_object_handles(void) TC_PRT("select default : folder[%d]", input_int); } - ret = mtp_get_object_handles(handle, strg_handle, input_int, obj_handle, &obj_list, &obj_count); + ret = mtp_get_object_handles(mtp_device, mtp_storage, input_int, mtp_object, &mtp_objects, &obj_count); TC_PRT("ret[%d]: total object_num[%d]", ret, obj_count); list_max = (obj_count < TEST_LIST_MAX) ? obj_count : TEST_LIST_MAX; for (i = 0; i < list_max; i++) { - ret = mtp_objectinfo_get_filename(handle, obj_list[i], &filename); - ret = mtp_objectinfo_get_format(handle, obj_list[i], &format); - TC_PRT("ret[%d]: object id[%d] - filename[%s], format[%s]", - ret, obj_list[i], filename, test_filetype_to_string(format)); + ret = mtp_objectinfo_get_file_name(mtp_device, mtp_objects[i], &filename); + ret = mtp_objectinfo_get_file_type(mtp_device, mtp_objects[i], &filetype); + TC_PRT("ret[%d]: object id[%d] - filename[%s], filetype[%s]", + ret, mtp_objects[i], filename, test_filetype_to_string(filetype)); } if (input_int == MTP_FILETYPE_FOLDER) { - if (!test_get_user_int("==> Input Object ID :", &obj_handle)) { - TC_PRT("invalid input !!![%d]", obj_handle); - obj_handle = 0; + if (!test_get_user_int("==> Input Object ID :", &mtp_object)) { + TC_PRT("invalid input !!![%d]", mtp_object); + mtp_object = 0; END(); return -1; } - TC_PRT("selected object id[%d]", obj_handle); + TC_PRT("selected object id[%d]", mtp_object); TC_PRT("===== Object List - Folder ====="); } else { TC_PRT("===== Object List - JPEG ====="); @@ -310,7 +344,7 @@ int manager_test_delete_object(void) int ret = 0; int i; int input_int = 0; - int format = MTP_FILETYPE_JPEG; + mtp_filetype_e filetype = MTP_FILETYPE_JPEG; char *filename = NULL; int list_max = 0; BEGIN(); @@ -320,10 +354,10 @@ int manager_test_delete_object(void) list_max = (obj_count < TEST_LIST_MAX) ? obj_count : TEST_LIST_MAX; for (i = 0; i < list_max; i++) { - ret = mtp_objectinfo_get_filename(handle, obj_list[i], &filename); - ret = mtp_objectinfo_get_format(handle, obj_list[i], &format); - TC_PRT("ret[%d]: object id[%d] - filename[%s], format[%s]", - ret, obj_list[i], filename, test_filetype_to_string(format)); + ret = mtp_objectinfo_get_file_name(mtp_device, mtp_objects[i], &filename); + ret = mtp_objectinfo_get_file_type(mtp_device, mtp_objects[i], &filetype); + TC_PRT("ret[%d]: object id[%d] - filename[%s], filetype[%s]", + ret, mtp_objects[i], filename, test_filetype_to_string(filetype)); } if (!test_get_user_int("==> Input Object ID :", &input_int)) { @@ -332,7 +366,7 @@ int manager_test_delete_object(void) return -1; } - ret = mtp_delete_object(handle, input_int); + ret = mtp_delete_object(mtp_device, input_int); TC_PRT("ret[%d]: input id[%d]", ret, input_int); END(); @@ -344,7 +378,7 @@ int manager_test_get_object(void) int ret = 0; int i; int input_int = 0; - int format = MTP_FILETYPE_JPEG; + mtp_filetype_e filetype = MTP_FILETYPE_JPEG; char *filename = NULL; char filepath[100] = {0,}; int list_max = 0; @@ -355,10 +389,10 @@ int manager_test_get_object(void) list_max = (obj_count < TEST_LIST_MAX) ? obj_count : TEST_LIST_MAX; for (i = 0; i < list_max; i++) { - ret = mtp_objectinfo_get_filename(handle, obj_list[i], &filename); - ret = mtp_objectinfo_get_format(handle, obj_list[i], &format); - TC_PRT("ret[%d]: object id[%d] - filename[%s], format[%s]", - ret, obj_list[i], filename, test_filetype_to_string(format)); + ret = mtp_objectinfo_get_file_name(mtp_device, mtp_objects[i], &filename); + ret = mtp_objectinfo_get_file_type(mtp_device, mtp_objects[i], &filetype); + TC_PRT("ret[%d]: object id[%d] - filename[%s], filetype[%s]", + ret, mtp_objects[i], filename, test_filetype_to_string(filetype)); } if (!test_get_user_int("==> Input Object ID :", &input_int)) { @@ -369,7 +403,7 @@ int manager_test_get_object(void) snprintf(filepath, 100, "/opt/usr/media/Downloads/JpegObject_%d.jpg", input_int); - ret = mtp_get_object(handle, input_int, filepath); + ret = mtp_get_object(mtp_device, input_int, filepath); TC_PRT("ret[%d]: input id[%d]", ret, input_int); END(); @@ -384,7 +418,7 @@ int manager_test_get_thumbnail(void) int input_int = 0; char input_str[50] = {0, }; char filepath[100] = {0,}; - int format = MTP_FILETYPE_JPEG; + mtp_filetype_e filetype = MTP_FILETYPE_JPEG; char *filename = NULL; int list_max = 0; BEGIN(); @@ -394,10 +428,10 @@ int manager_test_get_thumbnail(void) list_max = (obj_count < TEST_LIST_MAX) ? obj_count : TEST_LIST_MAX; for (i = 0; i < list_max; i++) { - ret = mtp_objectinfo_get_filename(handle, obj_list[i], &filename); - ret = mtp_objectinfo_get_format(handle, obj_list[i], &format); - TC_PRT("ret[%d]: object id[%d] - filename[%s], format[%s]", - ret, obj_list[i], filename, test_filetype_to_string(format)); + ret = mtp_objectinfo_get_file_name(mtp_device, mtp_objects[i], &filename); + ret = mtp_objectinfo_get_file_type(mtp_device, mtp_objects[i], &filetype); + TC_PRT("ret[%d]: object id[%d] - filename[%s], filetype[%s]", + ret, mtp_objects[i], filename, test_filetype_to_string(filetype)); } if (!test_get_user_int("==> Input JPEG ID :", &input_int)) { @@ -418,7 +452,7 @@ int manager_test_get_thumbnail(void) snprintf(filepath, 100, "/opt/usr/media/Downloads/%s_%d.jpg", input_str, input_int); - ret = mtp_get_thumbnail(handle, input_int, filepath); + ret = mtp_get_thumbnail(mtp_device, input_int, filepath); TC_PRT("ret[%d]: input jpeg id[%d], input file path[%s]", ret, input_int, filepath); END(); @@ -443,7 +477,7 @@ int deviceinfo_test_get_manufacturername(void) char *name = NULL; BEGIN(); - ret = mtp_deviceinfo_get_manufacturername(handle, &name); + ret = mtp_deviceinfo_get_manufacturer_name(mtp_device, &name); TC_PRT("ret[%d]: manufacturername[%s]", ret, name); END(); @@ -456,7 +490,7 @@ int deviceinfo_test_get_modelname(void) char *name = NULL; BEGIN(); - ret = mtp_deviceinfo_get_modelname(handle, &name); + ret = mtp_deviceinfo_get_model_name(mtp_device, &name); TC_PRT("ret[%d]: modelname[%s]", ret, name); END(); @@ -469,7 +503,7 @@ int deviceinfo_test_get_serialnumber(void) char *name = NULL; BEGIN(); - ret = mtp_deviceinfo_get_serialnumber(handle, &name); + ret = mtp_deviceinfo_get_serial_number(mtp_device, &name); TC_PRT("ret[%d]: serialnumber[%s]", ret, name); END(); @@ -482,7 +516,7 @@ int deviceinfo_test_get_deviceversion(void) char *name = NULL; BEGIN(); - ret = mtp_deviceinfo_get_deviceversion(handle, &name); + ret = mtp_deviceinfo_get_device_version(mtp_device, &name); TC_PRT("ret[%d]: deviceversion[%s]", ret, name); END(); @@ -496,7 +530,7 @@ int storageinfo_test_get_description(void) char *name = NULL; BEGIN(); - ret = mtp_storageinfo_get_description(handle, strg_handle, &name); + ret = mtp_storageinfo_get_description(mtp_device, mtp_storage, &name); TC_PRT("ret[%d]: description[%s]", ret, name); END(); @@ -509,7 +543,7 @@ int storageinfo_test_get_freespace(void) unsigned long long value = 0; BEGIN(); - ret = mtp_storageinfo_get_freespace(handle, strg_handle, &value); + ret = mtp_storageinfo_get_free_space(mtp_device, mtp_storage, &value); TC_PRT("ret[%d]: freespace[%llu]", ret, value); END(); @@ -522,7 +556,7 @@ int storageinfo_test_get_maxcapacity(void) unsigned long long value = 0; BEGIN(); - ret = mtp_storageinfo_get_maxcapacity(handle, strg_handle, &value); + ret = mtp_storageinfo_get_max_capacity(mtp_device, mtp_storage, &value); TC_PRT("ret[%d]: maxcapacity[%llu]", ret, value); END(); @@ -535,7 +569,7 @@ int storageinfo_test_get_storagetype(void) int value = 0; BEGIN(); - ret = mtp_storageinfo_get_storagetype(handle, strg_handle, &value); + ret = mtp_storageinfo_get_storage_type(mtp_device, mtp_storage, &value); TC_PRT("ret[%d]: storagetype[%d]", ret, value); END(); @@ -548,7 +582,7 @@ int storageinfo_test_get_volumeidentifier(void) char *name = NULL; BEGIN(); - ret = mtp_storageinfo_get_volumeidentifier(handle, strg_handle, &name); + ret = mtp_storageinfo_get_volume_identifier(mtp_device, mtp_storage, &name); TC_PRT("ret[%d]: volumeidentifier[%s]", ret, name); END(); @@ -566,8 +600,8 @@ int objectinfo_test_get_association_desc(void) list_max = (obj_count < TEST_LIST_MAX) ? obj_count : TEST_LIST_MAX; for (i = 0; i < list_max; i++) { - ret = mtp_objectinfo_get_association_desc(handle, obj_list[i], &value); - TC_PRT("ret[%d]: object id[%d] association_desc[%d]", ret, obj_list[i], value); + ret = mtp_objectinfo_get_association_desc(mtp_device, mtp_objects[i], &value); + TC_PRT("ret[%d]: object id[%d] association_desc[%d]", ret, mtp_objects[i], value); } END(); @@ -585,8 +619,8 @@ int objectinfo_test_get_association_type(void) list_max = (obj_count < TEST_LIST_MAX) ? obj_count : TEST_LIST_MAX; for (i = 0; i < list_max; i++) { - ret = mtp_objectinfo_get_association_type(handle, obj_list[i], &value); - TC_PRT("ret[%d]: object id[%d] association_type[%d]", ret, obj_list[i], value); + ret = mtp_objectinfo_get_association_type(mtp_device, mtp_objects[i], &value); + TC_PRT("ret[%d]: object id[%d] association_type[%d]", ret, mtp_objects[i], value); } END(); @@ -604,8 +638,8 @@ int objectinfo_test_get_size(void) list_max = (obj_count < TEST_LIST_MAX) ? obj_count : TEST_LIST_MAX; for (i = 0; i < list_max; i++) { - ret = mtp_objectinfo_get_size(handle, obj_list[i], &value); - TC_PRT("ret[%d]: object id[%d] size[%d]", ret, obj_list[i], value); + ret = mtp_objectinfo_get_size(mtp_device, mtp_objects[i], &value); + TC_PRT("ret[%d]: object id[%d] size[%d]", ret, mtp_objects[i], value); } END(); @@ -623,8 +657,8 @@ int objectinfo_test_get_parent_object_handle(void) list_max = (obj_count < TEST_LIST_MAX) ? obj_count : TEST_LIST_MAX; for (i = 0; i < list_max; i++) { - ret = mtp_objectinfo_get_parent_object_handle(handle, obj_list[i], &value); - TC_PRT("ret[%d]: object id[%d] parent_object_handle[%d]", ret, obj_list[i], value); + ret = mtp_objectinfo_get_parent_object_handle(mtp_device, mtp_objects[i], &value); + TC_PRT("ret[%d]: object id[%d] parent_object_handle[%d]", ret, mtp_objects[i], value); } END(); @@ -642,8 +676,8 @@ int objectinfo_test_get_storage_id(void) list_max = (obj_count < TEST_LIST_MAX) ? obj_count : TEST_LIST_MAX; for (i = 0; i < list_max; i++) { - ret = mtp_objectinfo_get_storage_id(handle, obj_list[i], &value); - TC_PRT("ret[%d]: object id[%d] storage_id[%d]", ret, obj_list[i], value); + ret = mtp_objectinfo_get_storage(mtp_device, mtp_objects[i], &value); + TC_PRT("ret[%d]: object id[%d] mtp_storage[%d]", ret, mtp_objects[i], value); } END(); @@ -661,8 +695,8 @@ int objectinfo_test_get_data_created(void) list_max = (obj_count < TEST_LIST_MAX) ? obj_count : TEST_LIST_MAX; for (i = 0; i < list_max; i++) { - ret = mtp_objectinfo_get_data_created(handle, obj_list[i], &value); - TC_PRT("ret[%d]: object id[%d] data_created[%d]", ret, obj_list[i], value); + ret = mtp_objectinfo_get_data_created(mtp_device, mtp_objects[i], &value); + TC_PRT("ret[%d]: object id[%d] mtp_device[%d]", ret, mtp_objects[i], value); } END(); @@ -680,34 +714,34 @@ int objectinfo_test_get_data_modified(void) list_max = (obj_count < TEST_LIST_MAX) ? obj_count : TEST_LIST_MAX; for (i = 0; i < list_max; i++) { - ret = mtp_objectinfo_get_data_modified(handle, obj_list[i], &value); - TC_PRT("ret[%d]: object id[%d] data_modified[%d]", ret, obj_list[i], value); + ret = mtp_objectinfo_get_data_modified(mtp_device, mtp_objects[i], &value); + TC_PRT("ret[%d]: object id[%d] data_modified[%d]", ret, mtp_objects[i], value); } END(); return ret; } -int objectinfo_test_get_format(void) +int objectinfo_test_get_file_type(void) { int i; int ret = 0; - int value = 0; + mtp_filetype_e value = 0; int list_max = 0; BEGIN(); list_max = (obj_count < TEST_LIST_MAX) ? obj_count : TEST_LIST_MAX; for (i = 0; i < list_max; i++) { - ret = mtp_objectinfo_get_format(handle, obj_list[i], &value); - TC_PRT("ret[%d]: object id[%d] format[%d]", ret, obj_list[i], value); + ret = mtp_objectinfo_get_file_type(mtp_device, mtp_objects[i], &value); + TC_PRT("ret[%d]: object id[%d] file type[%d]", ret, mtp_objects[i], value); } END(); return ret; } -int objectinfo_test_get_image_pix_depth(void) +int objectinfo_test_get_image_bit_depth(void) { int i; int ret = 0; @@ -718,8 +752,8 @@ int objectinfo_test_get_image_pix_depth(void) list_max = (obj_count < TEST_LIST_MAX) ? obj_count : TEST_LIST_MAX; for (i = 0; i < list_max; i++) { - ret = mtp_objectinfo_get_image_pix_depth(handle, obj_list[i], &value); - TC_PRT("ret[%d]: object id[%d] image_pix_depth[%d]", ret, obj_list[i], value); + ret = mtp_objectinfo_get_image_bit_depth(mtp_device, mtp_objects[i], &value); + TC_PRT("ret[%d]: object id[%d] image_bit_depth[%d]", ret, mtp_objects[i], value); } END(); @@ -737,8 +771,8 @@ int objectinfo_test_get_image_pix_width(void) list_max = (obj_count < TEST_LIST_MAX) ? obj_count : TEST_LIST_MAX; for (i = 0; i < list_max; i++) { - ret = mtp_objectinfo_get_image_pix_width(handle, obj_list[i], &value); - TC_PRT("ret[%d]: object id[%d] image_pix_width[%d]", ret, obj_list[i], value); + ret = mtp_objectinfo_get_image_pix_width(mtp_device, mtp_objects[i], &value); + TC_PRT("ret[%d]: object id[%d] image_pix_width[%d]", ret, mtp_objects[i], value); } END(); @@ -756,8 +790,8 @@ int objectinfo_test_get_image_pix_height(void) list_max = (obj_count < TEST_LIST_MAX) ? obj_count : TEST_LIST_MAX; for (i = 0; i < list_max; i++) { - ret = mtp_objectinfo_get_image_pix_height(handle, obj_list[i], &value); - TC_PRT("ret[%d]: object id[%d] image_pix_height[%d]", ret, obj_list[i], value); + ret = mtp_objectinfo_get_image_pix_height(mtp_device, mtp_objects[i], &value); + TC_PRT("ret[%d]: object id[%d] image_pix_height[%d]", ret, mtp_objects[i], value); } END(); @@ -775,27 +809,27 @@ int objectinfo_test_get_thumbnail_size(void) list_max = (obj_count < TEST_LIST_MAX) ? obj_count : TEST_LIST_MAX; for (i = 0; i < list_max; i++) { - ret = mtp_objectinfo_get_thumbnail_size(handle, obj_list[i], &value); - TC_PRT("ret[%d]: object id[%d] thumbnail_size[%d]", ret, obj_list[i], value); + ret = mtp_objectinfo_get_thumbnail_size(mtp_device, mtp_objects[i], &value); + TC_PRT("ret[%d]: object id[%d] thumbnail_size[%d]", ret, mtp_objects[i], value); } END(); return ret; } -int objectinfo_test_get_thumbnail_format(void) +int objectinfo_test_get_thumbnail_file_type(void) { int i; int ret = 0; - int value = 0; + mtp_filetype_e value = 0; int list_max = 0; BEGIN(); list_max = (obj_count < TEST_LIST_MAX) ? obj_count : TEST_LIST_MAX; for (i = 0; i < list_max; i++) { - ret = mtp_objectinfo_get_thumbnail_format(handle, obj_list[i], &value); - TC_PRT("ret[%d]: object id[%d] thumbnail_format[%d]", ret, obj_list[i], value); + ret = mtp_objectinfo_get_thumbnail_file_type(mtp_device, mtp_objects[i], &value); + TC_PRT("ret[%d]: object id[%d] thumbnail_format[%d]", ret, mtp_objects[i], value); } END(); @@ -813,8 +847,8 @@ int objectinfo_test_get_thumbnail_pix_height(void) list_max = (obj_count < TEST_LIST_MAX) ? obj_count : TEST_LIST_MAX; for (i = 0; i < list_max; i++) { - ret = mtp_objectinfo_get_thumbnail_pix_height(handle, obj_list[i], &value); - TC_PRT("ret[%d]: object id[%d] thumbnail_pix_height[%d]", ret, obj_list[i], value); + ret = mtp_objectinfo_get_thumbnail_pix_height(mtp_device, mtp_objects[i], &value); + TC_PRT("ret[%d]: object id[%d] thumbnail_pix_height[%d]", ret, mtp_objects[i], value); } END(); @@ -832,8 +866,8 @@ int objectinfo_test_get_thumbnail_pix_width(void) list_max = (obj_count < TEST_LIST_MAX) ? obj_count : TEST_LIST_MAX; for (i = 0; i < list_max; i++) { - ret = mtp_objectinfo_get_thumbnail_pix_width(handle, obj_list[i], &value); - TC_PRT("ret[%d]: object id[%d] thumbnail_pix_width[%d]", ret, obj_list[i], value); + ret = mtp_objectinfo_get_thumbnail_pix_width(mtp_device, mtp_objects[i], &value); + TC_PRT("ret[%d]: object id[%d] thumbnail_pix_width[%d]", ret, mtp_objects[i], value); } END(); @@ -851,8 +885,8 @@ int objectinfo_test_get_filename(void) list_max = (obj_count < TEST_LIST_MAX) ? obj_count : TEST_LIST_MAX; for (i = 0; i < list_max; i++) { - ret = mtp_objectinfo_get_filename(handle, obj_list[i], &value); - TC_PRT("ret[%d]: object id[%d] filename[%s]", ret, obj_list[i], value); + ret = mtp_objectinfo_get_file_name(mtp_device, mtp_objects[i], &value); + TC_PRT("ret[%d]: object id[%d] filename[%s]", ret, mtp_objects[i], value); } END(); @@ -870,8 +904,8 @@ int objectinfo_test_get_keywords(void) list_max = (obj_count < TEST_LIST_MAX) ? obj_count : TEST_LIST_MAX; for (i = 0; i < list_max; i++) { - ret = mtp_objectinfo_get_keywords(handle, obj_list[i], &value); - TC_PRT("ret[%d]: object id[%d] keywords[%s]", ret, obj_list[i], value); + ret = mtp_objectinfo_get_keywords(mtp_device, mtp_objects[i], &value); + TC_PRT("ret[%d]: object id[%d] keywords[%s]", ret, mtp_objects[i], value); } END(); @@ -882,7 +916,7 @@ int application_test_get_image_from_DCIM(void) { int ret = 0; int i; - int format = MTP_FILETYPE_FOLDER; + mtp_filetype_e filetype = MTP_FILETYPE_FOLDER; int *object_list; int object_count = 0; int *object_list2; @@ -895,7 +929,7 @@ int application_test_get_image_from_DCIM(void) BEGIN(); while (true) { - TC_PRT("storage_handle : %d", strg_handle); + TC_PRT("storage_handle : %d", mtp_storage); if (!test_get_user_int("==> 1. Select Object type (FOLDER:0, JPEG:14, BMP:17)" " - (Enter for skip) :", &input_object_id2)) { @@ -903,18 +937,18 @@ int application_test_get_image_from_DCIM(void) break; } - ret = mtp_get_object_handles(handle, (strg_handle > 0 ? strg_handle : 0), input_object_id2, selected_id, &object_list, &object_count); + ret = mtp_get_object_handles(mtp_device, (mtp_storage > 0 ? mtp_storage : 0), input_object_id2, selected_id, &object_list, &object_count); TC_PRT("Total object_num [%d]", object_count); for (i = 0; i < object_count; i++) { TC_PRT("object handle %d", object_list[i]); - ret = mtp_objectinfo_get_filename(handle, object_list[i], &filename); - ret = mtp_objectinfo_get_format(handle, object_list[i], &format); + ret = mtp_objectinfo_get_file_name(mtp_device, object_list[i], &filename); + ret = mtp_objectinfo_get_file_type(mtp_device, object_list[i], &filetype); TC_PRT("ret : %d", ret); - TC_PRT("Folder object id %d - filename[%s], format[%s]\n", object_list[i], filename, test_filetype_to_string(format)); + TC_PRT("Folder object id %d - filename[%s], filetype[%s]\n", object_list[i], filename, test_filetype_to_string(filetype)); } if (!test_get_user_int("==> 1. Input Folder Object ID (Enter for exit):", &input_object_id)) { @@ -925,27 +959,27 @@ int application_test_get_image_from_DCIM(void) selected_id = input_object_id; - ret = mtp_objectinfo_get_filename(handle, selected_id, &filename); - ret = mtp_objectinfo_get_format(handle, selected_id, &format); + ret = mtp_objectinfo_get_file_name(mtp_device, selected_id, &filename); + ret = mtp_objectinfo_get_file_type(mtp_device, selected_id, &filetype); TC_PRT("ret : %d", ret); - TC_PRT("selected id[%d] - filename[%s], format[%s]\n", selected_id, filename, test_filetype_to_string(format)); + TC_PRT("selected id[%d] - filename[%s], filetype[%s]\n", selected_id, filename, test_filetype_to_string(filetype)); g_free(filename); } - ret = mtp_get_object_handles(handle, (strg_handle > 0 ? strg_handle : 0), MTP_FILETYPE_JPEG, selected_id, &object_list2, &object_count2); + ret = mtp_get_object_handles(mtp_device, (mtp_storage > 0 ? mtp_storage : 0), MTP_FILETYPE_JPEG, selected_id, &object_list2, &object_count2); TC_PRT("Total object_num [%d]", object_count2); for (i = 0; i < object_count2; i++) { TC_PRT("object handle %d", object_list2[i]); - ret = mtp_objectinfo_get_filename(handle, object_list2[i], &filename); - ret = mtp_objectinfo_get_format(handle, object_list2[i], &format); + ret = mtp_objectinfo_get_file_name(mtp_device, object_list2[i], &filename); + ret = mtp_objectinfo_get_file_type(mtp_device, object_list2[i], &filetype); TC_PRT("ret : %d", ret); - TC_PRT("JPEG id[%d] - filename[%s], format[%s]\n", object_list2[i], filename, test_filetype_to_string(format)); + TC_PRT("JPEG id[%d] - filename[%s], filetype[%s]\n", object_list2[i], filename, test_filetype_to_string(filetype)); } while (true) { @@ -954,18 +988,18 @@ int application_test_get_image_from_DCIM(void) break; } - ret = mtp_objectinfo_get_filename(handle, input_object_id2, &filename); - ret = mtp_objectinfo_get_format(handle, input_object_id2, &format); + ret = mtp_objectinfo_get_file_name(mtp_device, input_object_id2, &filename); + ret = mtp_objectinfo_get_file_type(mtp_device, input_object_id2, &filetype); TC_PRT("ret : %d", ret); - TC_PRT("selected id[%d] - filename[%s], format[%s]\n", input_object_id2, filename, test_filetype_to_string(format)); + TC_PRT("selected id[%d] - filename[%s], filetype[%s]\n", input_object_id2, filename, test_filetype_to_string(filetype)); g_free(filename); - if (format == MTP_FILETYPE_JPEG) { + if (filetype == MTP_FILETYPE_JPEG) { snprintf(filepath, 100, "/home/JpegObject_%d.jpg", input_object_id2); - ret = mtp_get_object(handle, input_object_id2, filepath); + ret = mtp_get_object(mtp_device, input_object_id2, filepath); TC_PRT("mtp_get_object ret : %d", ret); } } @@ -983,7 +1017,7 @@ int application_test_get_object_handle_using_all(void) BEGIN(); - ret = mtp_get_object_handles(handle, strg_handle, MTP_FILETYPE_ALL, 0, &file_list, &file_count); + ret = mtp_get_object_handles(mtp_device, mtp_storage, MTP_FILETYPE_ALL, 0, &file_list, &file_count); TC_PRT("ret[%d]: total folder_count[%d]", ret, file_count); for (i = 0; i < file_count; i++) @@ -1001,7 +1035,7 @@ int application_test_get_object_handle_using_all_image(void) int ret = 0; BEGIN(); - ret = mtp_get_object_handles(handle, strg_handle, MTP_FILETYPE_ALL_IMAGE, 0, &file_list, &file_count); + ret = mtp_get_object_handles(mtp_device, mtp_storage, MTP_FILETYPE_ALL_IMAGE, 0, &file_list, &file_count); TC_PRT("ret[%d]: total folder_count[%d]", ret, file_count); for (i = 0; i < file_count; i++) @@ -1017,7 +1051,7 @@ void __test_mtp_event_cb(mtp_event_e state, int arg, void *user_data) TC_PRT("state [%d] : %d", state, arg); - if (state == MTP_EVENT_DAEMON_TERMINATED) { + if (state == MTP_EVENT_TURNED_OFF) { ret = mtp_deinitialize(); TC_PRT("ret[%d] : Terminated daemon", ret); } @@ -1036,91 +1070,12 @@ int application_test_event_callback(void) return ret; } -int application_test_scenario(void) -{ - int i; - int ret; - int device_handle = 0; - int *storage_list; - int storage_count = 0; - int *image_list; - int image_count = 0; - mtp_device_list* dev_list; - struct timeval start1, start2, start3, start4; - struct timeval end1, end2, end3, end4; - - BEGIN(); - - /* init phase */ - gettimeofday(&start1, NULL); - TC_PRT("init phase start, %ld.%ld", start1.tv_sec, start1.tv_usec); - - ret = mtp_initialize(); - - ret = mtp_get_device_list(&dev_list); - - if (dev_list->device_num == 0) { - TC_PRT("device is not exist!!!"); - END(); - return -1; - } - - ret = mtp_get_device_handle(dev_list->devices[0].bus_location, &device_handle); - ret = mtp_get_storage_ids(device_handle, &storage_list, &storage_count); - - gettimeofday(&end1, NULL); - TC_PRT("init phase end time, %ld.%ld", end1.tv_sec, end1.tv_usec); - - /* scan phase */ - gettimeofday(&start2, NULL); - TC_PRT("scan phase start, %ld.%ld", start2.tv_sec, start2.tv_usec); - - ret = mtp_get_object_handles(device_handle, storage_list[0], MTP_FILETYPE_ALL_IMAGE, - 0, &image_list, &image_count); - - gettimeofday(&end2, NULL); - TC_PRT("scan phase end time, %ld.%ld", end2.tv_sec, end2.tv_usec); - - /* get objectinfo phase */ - gettimeofday(&start3, NULL); - TC_PRT("get objectinfo phase start, %ld.%ld", start3.tv_sec, start3.tv_usec); - - for (i = 0; i < image_count; i++) { - mtp_object_info *object_info; - mtp_objectinfo_get_object_info(device_handle, image_list[i], &object_info); - TC_PRT("filename : %s", object_info->Filename); - g_free(object_info); - } - - gettimeofday(&end3, NULL); - TC_PRT("get objectinfo phase end, %ld.%ld", end3.tv_sec, end3.tv_usec); - - /* get thumbnail phase */ - gettimeofday(&start4, NULL); - TC_PRT("get thumbnail phase start, %ld.%ld", start4.tv_sec, start4.tv_usec); - - for (i = 0; i < image_count; i++) { - char path[256] = {0,}; - - snprintf(path, 256, "/tmp/thumbnail%d.jpg", i); - mtp_get_thumbnail(device_handle, image_list[i], path); - } - gettimeofday(&end4, NULL); - TC_PRT("get thumbnail phase end, %ld.%ld", end4.tv_sec, end4.tv_usec); - - ret = mtp_deinitialize(); - - END(); - - return ret; -} - tc_table_t tc_table[] = { /* manager api */ {"mtp_initialize", 1, manager_test_initialize}, - {"mtp_get_device_list", 2, manager_test_get_device_list}, - {"mtp_get_device_handle", 3, manager_test_get_device_handle}, - {"mtp_get_storage_ids", 4, manager_test_get_storage_ids}, + {"mtp_get_raw_devices", 2, manager_test_get_raw_devices}, + {"mtp_get_device", 3, manager_test_get_device}, + {"mtp_get_storages", 4, manager_test_get_storages}, {"mtp_get_object_handles", 5, manager_test_get_object_handles}, {"mtp_delete_object", 6, manager_test_delete_object}, {"mtp_get_object", 7, manager_test_get_object}, @@ -1146,12 +1101,12 @@ tc_table_t tc_table[] = { {"mtp_objectinfo_get_size", 21, objectinfo_test_get_size}, {"mtp_objectinfo_get_data_created", 22, objectinfo_test_get_data_created}, {"mtp_objectinfo_get_data_modified", 23, objectinfo_test_get_data_modified}, - {"mtp_objectinfo_get_format", 24, objectinfo_test_get_format}, - {"mtp_objectinfo_get_image_pix_depth", 25, objectinfo_test_get_image_pix_depth}, + {"mtp_objectinfo_get_file_type", 24, objectinfo_test_get_file_type}, + {"mtp_objectinfo_get_image_pix_depth", 25, objectinfo_test_get_image_bit_depth}, {"mtp_objectinfo_get_image_pix_width", 26, objectinfo_test_get_image_pix_width}, {"mtp_objectinfo_get_image_pix_height", 27, objectinfo_test_get_image_pix_height}, {"mtp_objectinfo_get_thumbnail_size", 28, objectinfo_test_get_thumbnail_size}, - {"mtp_objectinfo_get_thumbnail_format", 29, objectinfo_test_get_thumbnail_format}, + {"mtp_objectinfo_get_thumbnail_format", 29, objectinfo_test_get_thumbnail_file_type}, {"mtp_objectinfo_get_thumbnail_pix_height", 30, objectinfo_test_get_thumbnail_pix_height}, {"mtp_objectinfo_get_thumbnail_pix_width", 31, objectinfo_test_get_thumbnail_pix_width}, {"mtp_objectinfo_get_filename", 32, objectinfo_test_get_filename}, @@ -1159,10 +1114,9 @@ tc_table_t tc_table[] = { /* application test */ {"get Jpeg image from /DCIM folder", 34, application_test_get_image_from_DCIM}, - {"get object handle using ALL format", 35, application_test_get_object_handle_using_all}, - {"get object handle using ALL Image format", 36, application_test_get_object_handle_using_all_image}, + {"get object handle using ALL file type", 35, application_test_get_object_handle_using_all}, + {"get object handle using ALL Image file type", 36, application_test_get_object_handle_using_all_image}, {"test callback function", 37, application_test_event_callback}, - {"application_test_scenario", 38, application_test_scenario}, {"get object and get thumbnail test", TEST_CASE_MAX, NULL}, /*-----------*/ -- 2.7.4