* \#include <mtp.h>
* @section CAPI_NETWORK_MTP_OBJECTINFO_MODULE_OVERVIEW Overview
* The MTP Object Information api provides following functions :\n
- * - Get object format\n
+ * - Get object file type\n
* - Get object name\n
* - Get object size\n
* - and, more object information\n
*/
/**
- * @brief The handle to the mtp raw device
- * @since_tizen 3.0
- */
-typedef struct mtp_raw_device *mtp_raw_device_h;
-
-/**
* @brief The handle to the mtp device
* @since_tizen 3.0
*/
MTP_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
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 = TIZEN_ERROR_MTP | 0x01, /**< MTP have not any device */
MTP_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
- MTP_ERROR_PLUGIN_FAIL = TIZEN_ERROR_MTP | 0x02, /**< Plugin failed */
MTP_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */
- MTP_ERROR_COMM_ERROR = TIZEN_ERROR_MTP | 0x03, /**< MTP communication error */
- MTP_ERROR_CONTROLLER = TIZEN_ERROR_MTP | 0x04, /**< MTP controller error */
- MTP_ERROR_NOT_INITIALIZED = TIZEN_ERROR_MTP | 0x05, /**< MTP is not initialized */
- MTP_ERROR_NOT_ACTIVATED = TIZEN_ERROR_MTP | 0x06, /**< MTP is not activated */
- MTP_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< MTP is not supported */
- MTP_ERROR_NOT_COMM_INITIALIZED = TIZEN_ERROR_MTP | 0x07, /**< MTP communication is not initialized */
+ MTP_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< Not supported */
+ MTP_ERROR_COMM_ERROR = TIZEN_ERROR_MTP | 0x01, /**< MTP communication error */
+ MTP_ERROR_CONTROLLER = TIZEN_ERROR_MTP | 0x02, /**< MTP controller error */
+ MTP_ERROR_NO_DEVICE = TIZEN_ERROR_MTP | 0x03, /**< MTP have not any device */
+ MTP_ERROR_NOT_INITIALIZED = TIZEN_ERROR_MTP | 0x04, /**< MTP is not initialized */
+ MTP_ERROR_NOT_ACTIVATED = TIZEN_ERROR_MTP | 0x05, /**< MTP is not activated */
+ MTP_ERROR_NOT_COMM_INITIALIZED = TIZEN_ERROR_MTP | 0x06, /**< MTP communication is not initialized */
+ MTP_ERROR_PLUGIN_FAIL = TIZEN_ERROR_MTP | 0x07, /**< MTP Plugin failed */
} mtp_error_e;
/**
* @brief Enumerations for MTP Storage type
* @since_tizen 3.0
*/
-
typedef enum {
MTP_STORAGE_TYPE_UNDEFINED, /**< Storage type is undefined */
MTP_STORAGE_TYPE_FIXED_ROM, /**< Storage type is fixed ROM */
} mtp_event_e;
/**
- * @brief Called after mtp_set_mtp_event_cb() has completed.
+ * @brief Called when mtp event is occured.
* @since_tizen 3.0
* @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.
int mtp_initialize(void);
/**
- * @brief Gets device list.
- * @since_tizen 3.0
- * @remarks The @a raw_devices should be freed using mtp_destroy_raw_devices().
- * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n
- * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. \n
- *
- * @param [out] raw_devices All current connected device list
- * @param [out] device_count The count of device
- *
- * @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
- *
- * @see mtp_destroy_raw_devices()
- */
-int mtp_get_raw_devices(mtp_raw_device_h **raw_devices, int *device_count);
-
-/**
- * @brief Gets bus location from raw device.
- * @since_tizen 3.0
- * @remarks The @a raw_device can get using mtp_get_raw_devices().
- * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n
- * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. \n
- *
- * @param [in] raw_device The raw device
- * @param [out] bus_location The bus location
- *
- * @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_get_raw_devices()
- */
-int mtp_get_bus_location(mtp_raw_device_h raw_device, int *bus_location);
-
-/**
- * @brief Gets device number from raw device.
- * @since_tizen 3.0
- * @remarks The @a raw_device can get using mtp_get_raw_devices().
- * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n
- * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. \n
- *
- * @param [in] raw_device The raw device
- * @param [out] device_number The device number
- *
- * @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_get_raw_devices()
- */
-int mtp_get_device_number(mtp_raw_device_h raw_device, int *device_number);
-
-/**
- * @brief Gets device name from raw device.
- * @since_tizen 3.0
- * @remarks The @a raw_device can get using mtp_get_raw_devices().
- * @remarks The @a model_name should be freed using free().
- * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n
- * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. \n
- *
- * @param [in] raw_device The raw device
- * @param [out] model_name The model name
- *
- * @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_get_raw_devices()
- */
-int mtp_get_device_name(mtp_raw_device_h raw_device, char **model_name);
-
-/**
- * @brief Destroys the raw devices handler.
- * @since_tizen 3.0
- * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n
- * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. \n
- *
- * @param [in] raw_devices The raw devices handler
- *
- * @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
- *
- * @see mtp_get_raw_devices()
- */
-int mtp_destroy_raw_devices(mtp_raw_device_h *raw_devices);
-
-/**
- * @brief Gets device handler from bus location.
+ * @brief Gets the mtp devices.
* @since_tizen 3.0
- * @remarks For using this api, you should get bus location and device number from raw device.
- * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n
- * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. \n
- *
- * @param [in] bus_location The bus location
- * @param [in] device_number The device number
- * @param [out] mtp_device The MTP device
+ * @param [out] mtp_devices The MTP device list
+ * @param [out] device_count Length of device list
*
* @return 0 on success, otherwise a negative error value.
* @retval #MTP_ERROR_NONE Successful
* @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized
* @retval #MTP_ERROR_COMM_ERROR 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);
+int mtp_get_devices(mtp_device_h **mtp_devices, int *device_count);
/**
- * @brief Gets mtp storages from device.
+ * @brief Gets mtp storages from the given device.
* @since_tizen 3.0
* @remarks The @a mtp_storages should be freed using free().
- * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n
- * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. \n
*
* @param [in] mtp_device The MTP device
* @param [out] mtp_storages Current mtp storage list
- * @param [out] storage_num Length of storage list
+ * @param [out] storage_count Length of storage list
*
* @return 0 on success, otherwise a negative error value.
* @retval #MTP_ERROR_NONE Successful
* @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized
* @retval #MTP_ERROR_COMM_ERROR MTP communication error
*
- * @see mtp_get_device()
+ * @see mtp_get_devices()
*/
-int mtp_get_storages(mtp_device_h mtp_device, mtp_storage_h **mtp_storages, int* storage_num);
+int mtp_get_storages(mtp_device_h mtp_device, mtp_storage_h **mtp_storages, int* storage_count);
/**
* @brief Gets object handles from the given device and storage.
* @since_tizen 3.0
* @remarks The @a object_handles should be freed using free().
* @remarks If the @a parent is 0, it means "root folder" of mtp storage.
- * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n
- * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. \n
*
* @param [in] mtp_device The MTP device
* @param [in] mtp_storage The MTP storage
* @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
+ * @param [out] object_count Length of object handle list
*
* @return 0 on success, otherwise a negative error value.
* @retval #MTP_ERROR_NONE Successful
* @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized
* @retval #MTP_ERROR_COMM_ERROR MTP communication error
*
- * @see mtp_get_device()
+ * @see mtp_get_devices()
* @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);
+ mtp_object_h parent, mtp_object_h **object_handles, int* object_count);
/**
* @brief Gets object for a given path from object handle.
* @since_tizen 3.0
+ * @remarks The @a dest_path is host storage path.
* @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
*
* @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized
* @retval #MTP_ERROR_COMM_ERROR MTP communication error
* @retval #MTP_ERROR_IO_ERROR I/O error
+ * @retval #MTP_ERROR_PERMISSION_DENIED Permission denied
*
- * @see mtp_get_device()
+ * @see mtp_get_devices()
* @see mtp_get_object_handles()
*/
int mtp_get_object(mtp_device_h mtp_device, mtp_object_h object_handle, char *dest_path);
/**
- * @brief Gets thumbnail from object handle.
+ * @brief Gets thumbnail from the given object handle.
* @since_tizen 3.0
+ * @remarks The @a dest_path is host storage path.
* @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.
*
* @retval #MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized
* @retval #MTP_ERROR_COMM_ERROR MTP communication error
* @retval #MTP_ERROR_IO_ERROR I/O error
+ * @retval #MTP_ERROR_PERMISSION_DENIED Permission denied
*
- * @see mtp_get_device()
+ * @see mtp_get_devices()
* @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.
+ * @brief Adds a callback function for receiving MTP event.
* @since_tizen 3.0
- *
+ * @remarks You can register multiple callback. \n
+ * If you don't want to receive the event, then using the mtp_remove_mtp_event_cb() function to unregister a callback.
* @remarks If device state is changed, #MTP_EVENT_DEVICE_ADDED or #MTP_EVENT_DEVICE_REMOVED event is occur. \n
* If storage state is changed, #MTP_EVENT_STORAGE_ADDED or #MTP_EVENT_STORAGE_REMOVED event is occur. \n
* If object state is changed, #MTP_EVENT_OBJECT_ADDED or #MTP_EVENT_OBJECT_REMOVED event is occur. \n
* If mtp service is turned off, #MTP_EVENT_TURNED_OFF event is occur. \n
- * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n
- * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. \n
*
* @param [in] event_cb The callback
* @param [in] user_data The user data
* @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()
+ *
+ * @see mtp_remove_mtp_event_cb()
*/
-int mtp_set_mtp_event_cb(mtp_event_cb event_cb, void *user_data);
+int mtp_add_mtp_event_cb(mtp_event_cb event_cb, void *user_data);
/**
- * @brief Unregisters the callback function.
+ * @brief Removes the callback function.
* @since_tizen 3.0
- * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n
- * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. \n
+ *
+ * @param [in] event_cb The callback
*
* @return 0 on success, otherwise a negative error value.
* @retval #MTP_ERROR_NONE Successful
*
* @see mtp_set_mtp_event_cb()
*/
-int mtp_unset_mtp_event_cb(void);
+int mtp_remove_mtp_event_cb(mtp_event_cb event_cb);
/**
* @brief Deinitializes MTP operation.
* @brief Gets the manufacturer name of the device information.
* @since_tizen 3.0
* @remarks The @a manufacturer_name should be freed using free().
- * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n
- * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. \n
*
* @param [in] mtp_device The MTP device
* @param [out] manufacturer_name The manufacturer name of Device information
* @retval #MTP_ERROR_OUT_OF_MEMORY Memory Allocation failed
* @retval #MTP_ERROR_NO_DEVICE MTP have not any device
*
- * @see mtp_get_device()
+ * @see mtp_get_devices()
*/
int mtp_deviceinfo_get_manufacturer_name(mtp_device_h mtp_device, char **manufacturer_name);
* @brief Gets the model name of the device information.
* @since_tizen 3.0
* @remarks The @a model_name should be freed using free().
- * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n
- * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. \n
*
* @param [in] mtp_device The MTP device
* @param [out] model_name The model name of Device information
* @retval #MTP_ERROR_OUT_OF_MEMORY Out of memory
* @retval #MTP_ERROR_NO_DEVICE MTP have not any device
*
- * @see mtp_get_device()
+ * @see mtp_get_devices()
*/
int mtp_deviceinfo_get_model_name(mtp_device_h mtp_device, char **model_name);
* @brief Gets the serial number of the device information.
* @since_tizen 3.0
* @remarks The @a serial_number should be freed using free().
- * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n
- * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. \n
*
* @param [in] mtp_device The MTP device
* @param [out] serial_number The serial number of Device information
* @retval #MTP_ERROR_OUT_OF_MEMORY Out of memory
* @retval #MTP_ERROR_NO_DEVICE MTP have not any device
*
- * @see mtp_get_device()
+ * @see mtp_get_devices()
*/
int mtp_deviceinfo_get_serial_number(mtp_device_h mtp_device, char **serial_number);
* @brief Gets the device version of the device information.
* @since_tizen 3.0
* @remarks The @a device_version should be freed using free().
- * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n
- * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. \n
*
* @param [in] mtp_device The MTP device
* @param [out] device_version The device version of Device information
* @retval #MTP_ERROR_OUT_OF_MEMORY Out of memory
* @retval #MTP_ERROR_NO_DEVICE MTP have not any device
*
- * @see mtp_get_device()
+ * @see mtp_get_devices()
*/
int mtp_deviceinfo_get_device_version(mtp_device_h mtp_device, char **device_version);
* @brief Gets the description of the storage information.
* @since_tizen 3.0
* @remarks The @a description should be freed using free().
- * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n
- * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. \n
*
* @param [in] mtp_device The MTP device
* @param [in] mtp_storage The MTP storage
/**
* @brief Gets the free space of the storage information.
* @since_tizen 3.0
- * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n
- * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. \n
*
* @param [in] mtp_device The MTP device
* @param [in] mtp_storage The MTP storage
/**
* @brief Gets the max capacity of the storage information.
* @since_tizen 3.0
- * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n
- * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. \n
*
* @param [in] mtp_device The MTP device
* @param [in] mtp_storage The MTP storage
/**
* @brief Gets the storage type of the storage information.
* @since_tizen 3.0
- * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n
- * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. \n
*
* @param [in] mtp_device The MTP device
* @param [in] mtp_storage The MTP storage
* @brief Gets the volume identifier of the storage information.
* @since_tizen 3.0
* @remarks The @a volume_identifier should be freed using free().
- * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n
- * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. \n
*
* @param [in] mtp_device The MTP device
* @param [in] mtp_storage The MTP storage
* @brief Gets the filename of the object information.
* @since_tizen 3.0
* @remarks The @a file_name should be freed using free().
- * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n
- * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. \n
*
* @param [in] mtp_device The MTP device
* @param [in] object_handle The object handle
* @since_tizen 3.0
* @remarks The @a keywords should be freed using free().
* @remarks The keywords are separated by comma.
- * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n
- * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. \n
*
* @param [in] mtp_device The MTP device
* @param [in] object_handle The object handle
/**
* @brief Gets the association desc of the object information.
* @since_tizen 3.0
- * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n
- * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. \n
*
* @param [in] mtp_device The MTP device
* @param [in] object_handle The object handle
/**
* @brief Gets the association type of the object information.
* @since_tizen 3.0
- * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n
- * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. \n
*
* @param [in] mtp_device The MTP device
* @param [in] object_handle The object handle
/**
* @brief Gets the size of the object information.
* @since_tizen 3.0
- * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n
- * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. \n
*
* @param [in] mtp_device The MTP device
* @param [in] object_handle The object handle
/**
* @brief Gets the parent object handle of the object information.
* @since_tizen 3.0
- * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n
- * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. \n
*
* @param [in] mtp_device The MTP device
* @param [in] object_handle The object handle
/**
* @brief Gets the mtp storage of the object information.
* @since_tizen 3.0
- * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n
- * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. \n
*
* @param [in] mtp_device The MTP device
* @param [in] object_handle The object handle
* @since_tizen 3.0
* @remarks When interpreted as an absolute time value, \n
* @a data_created represents the number of seconds elapsed since the Epoch, 1970-01-01 00:00:00 +0000 (UTC).
- * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n
- * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. \n
*
* @param [in] mtp_device The MTP device
* @param [in] object_handle The object handle
* @since_tizen 3.0
* @remarks When interpreted as an absolute time value, \n
* @a data_modified represents the number of seconds elapsed since the Epoch, 1970-01-01 00:00:00 +0000 (UTC).
- * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n
- * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. \n
*
* @param [in] mtp_device The MTP device
* @param [in] object_handle The object handle
/**
* @brief Gets the file type of the object information.
* @since_tizen 3.0
- * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n
- * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. \n
*
* @param [in] mtp_device The MTP device
* @param [in] object_handle The object handle
/**
* @brief Gets the image bit depth of the object information.
* @since_tizen 3.0
- * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n
- * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. \n
*
* @param [in] mtp_device The MTP device
* @param [in] object_handle The object handle
/**
* @brief Gets the image pixel width of the object information.
* @since_tizen 3.0
- * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n
- * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. \n
*
* @param [in] mtp_device The MTP device
* @param [in] object_handle The object handle
/**
* @brief Gets the image pixel height of the object information.
* @since_tizen 3.0
- * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n
- * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. \n
*
* @param [in] mtp_device The MTP device
* @param [in] object_handle The object handle
/**
* @brief Gets the thumbnail size of the object information.
* @since_tizen 3.0
- * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n
- * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. \n
*
* @param [in] mtp_device The MTP device
* @param [in] object_handle The object handle
/**
* @brief Gets the thumbnail file type of the object information.
* @since_tizen 3.0
- * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n
- * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. \n
*
* @param [in] mtp_device The MTP device
* @param [in] object_handle The object handle
/**
* @brief Gets the thumbnail pixel height of the object information.
* @since_tizen 3.0
- * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n
- * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. \n
*
* @param [in] mtp_device The MTP device
* @param [in] object_handle The object handle
/**
* @brief Gets the thumbnail pixel width of the object information.
* @since_tizen 3.0
- * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n
- * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. \n
*
* @param [in] mtp_device The MTP device
* @param [in] object_handle The object handle
void mtp_gdbus_deviceinfo_proxy_init(void);
void mtp_gdbus_deviceinfo_proxy_deinit(void);
-mtp_error_e mtp_gdbus_deviceinfo_get_manufacturername(int mtp_handle, char **manufacturername);
-mtp_error_e mtp_gdbus_deviceinfo_get_modelname(int mtp_handle, char **modelname);
-mtp_error_e mtp_gdbus_deviceinfo_get_serialnumber(int mtp_handle, char **serialnumber);
-mtp_error_e mtp_gdbus_deviceinfo_get_deviceversion(int mtp_handle, char **deviceversion);
+mtp_error_e mtp_gdbus_deviceinfo_get_manufacturer_name(int mtp_device, char **manufacturername);
+mtp_error_e mtp_gdbus_deviceinfo_get_model_name(int mtp_device, char **modelname);
+mtp_error_e mtp_gdbus_deviceinfo_get_serial_number(int mtp_device, char **serialnumber);
+mtp_error_e mtp_gdbus_deviceinfo_get_device_version(int mtp_device, char **deviceversion);
+mtp_error_e mtp_gdbus_deviceinfo_get_bus_location(int mtp_device, int *bus_location);
+mtp_error_e mtp_gdbus_deviceinfo_get_device_number(int mtp_device, int *device_number);
#endif
#include "mtp_gdbus.h"
mtp_error_e mtp_gdbus_manager_initialize(void);
-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_devices(int **mtp_devices, int *device_num);
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 object_handle, char *dest_path);
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();
+mtp_error_e mtp_gdbus_manager_add_event_cb(mtp_event_cb callback, void *user_data);
+mtp_error_e mtp_gdbus_manager_remove_event_cb(mtp_event_cb callback);
+mtp_error_e mtp_gdbus_manager_remove_all_event_cb(void);
mtp_error_e mtp_gdbus_manager_deinitialize(void);
#endif
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);
+mtp_error_e mtp_gdbus_storageinfo_get_free_space(int mtp_device,
+ int mtp_storage, guint64 *free_space);
+mtp_error_e mtp_gdbus_storageinfo_get_max_capacity(int mtp_device,
+ int mtp_storage, guint64 *max_capacity);
+mtp_error_e mtp_gdbus_storageinfo_get_storage_type(int mtp_device,
+ int mtp_storage, int *storage_type);
+mtp_error_e mtp_gdbus_storageinfo_get_volume_identifier(int mtp_device,
+ int mtp_storage, char **volume_identifier);
#endif
/* internal api */
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);
+int mtp_deviceinfo_get_bus_location(mtp_device_h mtp_device, int *bus_locaton);
+int mtp_deviceinfo_get_device_number(mtp_device_h mtp_device, int *device_number);
#ifdef __cplusplus
}
#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 { \
{ \
MTP_PROPERTY_SIZE,
MTP_PROPERTY_DATE_CREATED,
MTP_PROPERTY_DATE_MODIFIED,
- MTP_PROPERTY_FORMAT,
+ MTP_PROPERTY_FILE_TYPE,
MTP_PROPERTY_IMAGE_BIT_DEPTH,
MTP_PROPERTY_IMAGE_PIX_WIDTH,
MTP_PROPERTY_IMAGE_PIX_HEIGHT,
MTP_PROPERTY_PARENT_OBJECT_HANDLE,
MTP_PROPERTY_STORAGE,
MTP_PROPERTY_THUMBNAIL_SIZE,
- MTP_PROPERTY_THUMBNAIL_FORMAT,
+ MTP_PROPERTY_THUMBNAIL_FILE_TYPE,
MTP_PROPERTY_THUMBNAIL_WIDTH,
MTP_PROPERTY_THUMBNAIL_HEIGHT,
MTP_PROPERTY_FILENAME,
return true;
}
-/* Device Manager */
+/* Manager */
int mtp_initialize(void)
{
int ret = MTP_ERROR_NONE;
return ret;
}
-int mtp_get_raw_devices(mtp_raw_device_h **raw_devices, int *device_count)
+int mtp_get_devices(int **mtp_devices, int *device_count)
{
int ret = MTP_ERROR_NONE;
CHECK_SUPPORTED();
CHECK_INIT();
CHECK_ACTIVATED();
+ cond_expr_ret(mtp_devices == NULL, MTP_ERROR_INVALID_PARAMETER);
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);
+ ret = mtp_gdbus_manager_get_devices(mtp_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;
+ TC_PRT("device count %d", *device_count);
_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);
- }
- }
-
- free(raw_devices);
-
- _END();
-
- return ret;
-}
-
-int mtp_get_device(int bus_location, int device_number, int *mtp_device)
-{
- int ret = MTP_ERROR_NONE;
-
- _BEGIN();
-
- /* precondition check start */
-
- CHECK_SUPPORTED();
- CHECK_INIT();
- CHECK_ACTIVATED();
- cond_expr_ret(bus_location == 0, MTP_ERROR_INVALID_PARAMETER);
-
- /* precondition check end */
-
- ret = mtp_gdbus_manager_get_device(bus_location, device_number, mtp_device);
-
- TC_PRT("mtp_device %d", *mtp_device);
-
- _END();
-
- return ret;
-}
-
-int mtp_get_storages(int mtp_device, int **mtp_storages, int* storage_num)
+int mtp_get_storages(int mtp_device, int **mtp_storages, int* storage_count)
{
int ret = MTP_ERROR_NONE;
CHECK_INIT();
CHECK_ACTIVATED();
cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER);
+ cond_expr_ret(mtp_storages == NULL, MTP_ERROR_INVALID_PARAMETER);
+ cond_expr_ret(storage_count == NULL, MTP_ERROR_INVALID_PARAMETER);
/* precondition check end */
- ret = mtp_gdbus_manager_get_storages(mtp_device, mtp_storages, storage_num);
+ ret = mtp_gdbus_manager_get_storages(mtp_device, mtp_storages, storage_count);
- TC_PRT("storage number %d", *storage_num);
+ TC_PRT("storage count %d", *storage_count);
_END();
}
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 parent, int **object_handles, int* object_count)
{
int ret = MTP_ERROR_NONE;
CHECK_ACTIVATED();
cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER);
cond_expr_ret(mtp_storage == 0, MTP_ERROR_INVALID_PARAMETER);
+ cond_expr_ret(object_handles == NULL, MTP_ERROR_INVALID_PARAMETER);
+ cond_expr_ret(object_count == NULL, MTP_ERROR_INVALID_PARAMETER);
/* precondition check end */
ret = mtp_gdbus_manager_get_object_handles(mtp_device,
- mtp_storage, file_type, parent, object_handles, object_num);
+ mtp_storage, file_type, parent, object_handles, object_count);
_END();
return ret;
}
-int mtp_set_mtp_event_cb(mtp_event_cb callback, void *user_data)
+int mtp_add_mtp_event_cb(mtp_event_cb callback, void *user_data)
{
int ret = MTP_ERROR_NONE;
/* precondition check end */
- ret = mtp_gdbus_manager_set_event_cb(callback, user_data);
+ ret = mtp_gdbus_manager_add_event_cb(callback, user_data);
_END();
return ret;
}
-int mtp_unset_mtp_event_cb(void)
+int mtp_remove_mtp_event_cb(mtp_event_cb callback)
{
int ret = MTP_ERROR_NONE;
/* precondition check end */
- ret = mtp_gdbus_manager_unset_event_cb();
+ ret = mtp_gdbus_manager_remove_event_cb(callback);
_END();
/* precondition check end */
- ret = mtp_gdbus_deviceinfo_get_manufacturername(mtp_device, manufacturer_name);
+ ret = mtp_gdbus_deviceinfo_get_manufacturer_name(mtp_device, manufacturer_name);
TC_PRT("manufacturername %s", *manufacturer_name);
/* precondition check end */
- ret = mtp_gdbus_deviceinfo_get_modelname(mtp_device, model_name);
+ ret = mtp_gdbus_deviceinfo_get_model_name(mtp_device, model_name);
TC_PRT("modelname %s", *model_name);
/* precondition check end */
- ret = mtp_gdbus_deviceinfo_get_serialnumber(mtp_device, serial_number);
+ ret = mtp_gdbus_deviceinfo_get_serial_number(mtp_device, serial_number);
- TC_PRT("serialnumber %s", *serial_number);
+ TC_PRT("serial number %s", *serial_number);
_END();
/* precondition check end */
- ret = mtp_gdbus_deviceinfo_get_deviceversion(mtp_device, device_version);
+ ret = mtp_gdbus_deviceinfo_get_device_version(mtp_device, device_version);
+
+ TC_PRT("device version %s", *device_version);
+
+ _END();
+
+ return ret;
+}
+
+int mtp_deviceinfo_get_bus_location(int mtp_device, int *bus_location)
+{
+ int ret = MTP_ERROR_NONE;
+
+ _BEGIN();
+
+ /* precondition check start */
+
+ CHECK_SUPPORTED();
+ CHECK_INIT();
+ CHECK_ACTIVATED();
+ cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER);
+ cond_expr_ret(bus_location == NULL, MTP_ERROR_INVALID_PARAMETER);
+
+ /* precondition check end */
+
+ ret = mtp_gdbus_deviceinfo_get_bus_location(mtp_device, bus_location);
+
+ TC_PRT("bus location %d", *bus_location);
+
+ _END();
+
+ return ret;
+}
+
+int mtp_deviceinfo_get_device_number(int mtp_device, int *device_number)
+{
+ int ret = MTP_ERROR_NONE;
+
+ _BEGIN();
+
+ /* precondition check start */
+
+ CHECK_SUPPORTED();
+ CHECK_INIT();
+ CHECK_ACTIVATED();
+ cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER);
+ cond_expr_ret(device_number == NULL, MTP_ERROR_INVALID_PARAMETER);
+
+ /* precondition check end */
+
+ ret = mtp_gdbus_deviceinfo_get_device_number(mtp_device, device_number);
- TC_PRT("deviceversion %s", *device_version);
+ TC_PRT("device number %d", *device_number);
_END();
/* precondition check end */
- ret = mtp_gdbus_storageinfo_get_freespace(mtp_device, mtp_storage, (guint64 *)free_space);
+ ret = mtp_gdbus_storageinfo_get_free_space(mtp_device, mtp_storage, (guint64 *)free_space);
TC_PRT("freespace %llu", *free_space);
/* precondition check end */
- ret = mtp_gdbus_storageinfo_get_maxcapacity(mtp_device, mtp_storage, (guint64 *)max_capacity);
+ ret = mtp_gdbus_storageinfo_get_max_capacity(mtp_device, mtp_storage, (guint64 *)max_capacity);
TC_PRT("maxcapacity %llu", *max_capacity);
/* precondition check end */
- ret = mtp_gdbus_storageinfo_get_storagetype(mtp_device, mtp_storage, (int *)storage_type);
+ ret = mtp_gdbus_storageinfo_get_storage_type(mtp_device, mtp_storage, (int *)storage_type);
TC_PRT("storagetype %d", *storage_type);
/* precondition check end */
- ret = mtp_gdbus_storageinfo_get_volumeidentifier(mtp_device, mtp_storage, volume_identifier);
+ ret = mtp_gdbus_storageinfo_get_volume_identifier(mtp_device, mtp_storage, volume_identifier);
TC_PRT("volumeidentifier %s", *volume_identifier);
/* precondition check end */
ret = mtp_gdbus_objectinfo_get_property(mtp_device,
- object_handle, MTP_PROPERTY_FORMAT, (int*)file_type);
+ object_handle, MTP_PROPERTY_FILE_TYPE, (int*)file_type);
_END();
/* precondition check end */
ret = mtp_gdbus_objectinfo_get_property(mtp_device,
- object_handle, MTP_PROPERTY_THUMBNAIL_FORMAT, (int*)file_type);
+ object_handle, MTP_PROPERTY_THUMBNAIL_FILE_TYPE, (int*)file_type);
_END();
deviceinfo_proxy = NULL;
}
-mtp_error_e mtp_gdbus_deviceinfo_get_manufacturername(int mtp_device, char **manufacturername)
+mtp_error_e mtp_gdbus_deviceinfo_get_manufacturer_name(int mtp_device, char **manufacturer_name)
{
mtp_error_e result = MTP_ERROR_NONE;
GError *error = NULL;
if (deviceinfo_proxy == NULL)
return MTP_ERROR_NOT_COMM_INITIALIZED;
- if (mtp_gdbuslib_deviceinfo_call_get_manufacturername_sync(
+ if (mtp_gdbuslib_deviceinfo_call_get_manufacturer_name_sync(
deviceinfo_proxy,
mtp_device,
- manufacturername,
+ manufacturer_name,
&result,
NULL,
&error) == FALSE) {
return result;
}
-mtp_error_e mtp_gdbus_deviceinfo_get_modelname(int mtp_device, char **modelname)
+mtp_error_e mtp_gdbus_deviceinfo_get_model_name(int mtp_device, char **model_name)
{
mtp_error_e result = MTP_ERROR_NONE;
GError *error = NULL;
if (deviceinfo_proxy == NULL)
return MTP_ERROR_NOT_COMM_INITIALIZED;
- if (mtp_gdbuslib_deviceinfo_call_get_modelname_sync(
+ if (mtp_gdbuslib_deviceinfo_call_get_model_name_sync(
deviceinfo_proxy,
mtp_device,
- modelname,
+ model_name,
&result,
NULL,
&error) == FALSE) {
return result;
}
-mtp_error_e mtp_gdbus_deviceinfo_get_serialnumber(int mtp_device, char **serialnumber)
+mtp_error_e mtp_gdbus_deviceinfo_get_serial_number(int mtp_device, char **serial_number)
{
mtp_error_e result = MTP_ERROR_NONE;
GError *error = NULL;
if (deviceinfo_proxy == NULL)
return MTP_ERROR_NOT_COMM_INITIALIZED;
- if (mtp_gdbuslib_deviceinfo_call_get_serialnumber_sync(
+ if (mtp_gdbuslib_deviceinfo_call_get_serial_number_sync(
deviceinfo_proxy,
mtp_device,
- serialnumber,
+ serial_number,
&result,
NULL,
&error) == FALSE) {
return result;
}
-mtp_error_e mtp_gdbus_deviceinfo_get_deviceversion(int mtp_device, char **deviceversion)
+mtp_error_e mtp_gdbus_deviceinfo_get_device_version(int mtp_device, char **device_version)
{
mtp_error_e result = MTP_ERROR_NONE;
GError *error = NULL;
if (deviceinfo_proxy == NULL)
return MTP_ERROR_NOT_COMM_INITIALIZED;
- if (mtp_gdbuslib_deviceinfo_call_get_deviceversion_sync(
+ if (mtp_gdbuslib_deviceinfo_call_get_device_version_sync(
deviceinfo_proxy,
mtp_device,
- deviceversion,
+ device_version,
+ &result,
+ NULL,
+ &error) == FALSE) {
+ result = MTP_ERROR_COMM_ERROR;
+ g_error_free(error);
+ }
+
+ return result;
+}
+
+mtp_error_e mtp_gdbus_deviceinfo_get_bus_location(int mtp_device, int *bus_location)
+{
+ mtp_error_e result = MTP_ERROR_NONE;
+ GError *error = NULL;
+
+ if (deviceinfo_proxy == NULL)
+ return MTP_ERROR_NOT_COMM_INITIALIZED;
+
+ if (mtp_gdbuslib_deviceinfo_call_get_bus_location_sync(
+ deviceinfo_proxy,
+ mtp_device,
+ bus_location,
+ &result,
+ NULL,
+ &error) == FALSE) {
+ result = MTP_ERROR_COMM_ERROR;
+ g_error_free(error);
+ }
+
+ return result;
+}
+
+mtp_error_e mtp_gdbus_deviceinfo_get_device_number(int mtp_device, int *device_number)
+{
+ mtp_error_e result = MTP_ERROR_NONE;
+ GError *error = NULL;
+
+ if (deviceinfo_proxy == NULL)
+ return MTP_ERROR_NOT_COMM_INITIALIZED;
+
+ if (mtp_gdbuslib_deviceinfo_call_get_device_number_sync(
+ deviceinfo_proxy,
+ mtp_device,
+ device_number,
&result,
NULL,
&error) == FALSE) {
#include "mtp_gdbus_deviceinfo.h"
#include "mtp_gdbus_storageinfo.h"
+typedef struct _event_cb_s {
+ mtp_event_cb cb;
+ void *user_data;
+} event_cb_s;
+
mtpgdbuslibManager *manager_proxy = NULL;
-mtp_event_cb event_callback;
-void *event_user_data;
+static __thread GSList *event_cb_list = NULL;
static void __mtp_event_cb(mtpgdbuslibManager *object,
gint event, gint arg1, gpointer user_data)
{
- if (event_callback)
- event_callback(event, arg1, event_user_data);
+ GSList *l;
+ event_cb_s *event_s;
+
+ for (l = event_cb_list; l != NULL; l = l->next)
+ {
+ event_s = (event_cb_s *)l->data;
+ event_s->cb(event, arg1, event_s->user_data);
+ }
}
static void __manager_proxy_init(void)
manager_proxy = NULL;
}
-mtp_error_e mtp_gdbus_manager_set_event_cb(mtp_event_cb callback, void *user_data)
+mtp_error_e mtp_gdbus_manager_add_event_cb(mtp_event_cb callback, void *user_data)
{
- event_callback = callback;
- event_user_data = user_data;
+ event_cb_s *event_s;
+
+ event_s = g_try_new0(event_cb_s, 1);
+ if (event_s == NULL)
+ return MTP_ERROR_OUT_OF_MEMORY;
+
+ event_s->cb = callback;
+ event_s->user_data = user_data;
+
+ event_cb_list = g_slist_prepend(event_cb_list, event_s);
return MTP_ERROR_NONE;
}
-mtp_error_e mtp_gdbus_manager_unset_event_cb(void)
+mtp_error_e mtp_gdbus_manager_remove_event_cb(mtp_event_cb callback)
{
- event_callback = NULL;
- event_user_data = NULL;
+ GSList *l;
+ event_cb_s *event_s;
+
+ for (l = event_cb_list; l != NULL; l = l->next)
+ {
+ event_s = (event_cb_s *)l->data;
+ if (callback == event_s->cb)
+ event_cb_list = g_slist_delete_link (event_cb_list, l);
+ }
return MTP_ERROR_NONE;
}
return result;
}
-mtp_error_e mtp_gdbus_manager_get_raw_devices(mtp_raw_device ***raw_devices, int *device_count)
+mtp_error_e mtp_gdbus_manager_get_devices(int **mtp_devices, int *device_num)
{
- int dev_count;
GVariant *va = NULL;
mtp_error_e result = MTP_ERROR_NONE;
GError *error = NULL;
if (manager_proxy == NULL)
- return MTP_ERROR_NOT_COMM_INITIALIZED;
+ return MTP_ERROR_NOT_COMM_INITIALIZED;
- if (mtp_gdbuslib_manager_call_get_raw_devices_sync(
+ if (mtp_gdbuslib_manager_call_get_devices_sync(
manager_proxy,
- &dev_count,
+ device_num,
&va,
&result,
NULL,
return result;
}
- *device_count = dev_count;
-
- if (dev_count != 0 && (g_variant_n_children(va) == dev_count)) {
+ if (*device_num != 0 && (g_variant_n_children(va) == *device_num)) {
GVariantIter *iter = NULL, *iter_row = NULL;
GVariant *key_value;
const gchar *key;
guint i = 0;
- *raw_devices = (mtp_raw_device **)malloc(sizeof(mtp_raw_device*) * 1);
- **raw_devices = (mtp_raw_device *)malloc(sizeof(mtp_raw_device) * *device_count);
+ *mtp_devices = g_new(int, *device_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, "model_name") == 0) {
- (**raw_devices)[i].model_name =
- g_strdup(g_variant_get_string(key_value, NULL));
- } else if (g_strcmp0(key, "bus_location") == 0) {
- (**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);
- }
+ if (g_strcmp0(key, "mtp_device") == 0)
+ (*mtp_devices)[i] = g_variant_get_int32(key_value);
}
- (**raw_devices)[i].dev_count = dev_count;
i++;
g_variant_iter_free(iter_row);
}
g_variant_iter_free(iter);
- } else {
- result = MTP_ERROR_NO_DEVICE;
}
g_variant_unref(va);
return result;
}
-mtp_error_e mtp_gdbus_manager_get_device(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_NOT_COMM_INITIALIZED;
-
- if (mtp_gdbuslib_manager_call_get_device_sync(
- manager_proxy,
- bus_location,
- device_number,
- mtp_device,
- &result,
- NULL,
- &error) == FALSE) {
- result = MTP_ERROR_COMM_ERROR;
-
- g_error_free(error);
- }
-
- return result;
-}
-
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)
+ int mtp_storage, int file_type, int parent_object_handle, int **object_handles, int *object_num)
{
GVariant *va = NULL;
mtp_error_e result = MTP_ERROR_NONE;
manager_proxy,
mtp_device,
mtp_storage,
- format,
+ file_type,
parent_object_handle,
object_num,
&va,
return result;
}
-mtp_error_e mtp_gdbus_storageinfo_get_freespace(int mtp_device,
- int mtp_storage, guint64 *freespace)
+mtp_error_e mtp_gdbus_storageinfo_get_free_space(int mtp_device,
+ int mtp_storage, guint64 *free_space)
{
mtp_error_e result = MTP_ERROR_NONE;
GError *error = NULL;
storageinfo_proxy,
mtp_device,
mtp_storage,
- freespace,
+ free_space,
&result,
NULL,
&error) == FALSE) {
return result;
}
-mtp_error_e mtp_gdbus_storageinfo_get_maxcapacity(int mtp_device,
- int mtp_storage, guint64 *maxcapacity)
+mtp_error_e mtp_gdbus_storageinfo_get_max_capacity(int mtp_device,
+ int mtp_storage, guint64 *max_capacity)
{
mtp_error_e result = MTP_ERROR_NONE;
GError *error = NULL;
storageinfo_proxy,
mtp_device,
mtp_storage,
- maxcapacity,
+ max_capacity,
&result,
NULL,
&error) == FALSE) {
return result;
}
-mtp_error_e mtp_gdbus_storageinfo_get_storagetype(int mtp_device,
- int mtp_storage, int *storagetype)
+mtp_error_e mtp_gdbus_storageinfo_get_storage_type(int mtp_device,
+ int mtp_storage, int *storage_type)
{
mtp_error_e result = MTP_ERROR_NONE;
GError *error = NULL;
storageinfo_proxy,
mtp_device,
mtp_storage,
- storagetype,
+ storage_type,
&result,
NULL,
&error) == FALSE) {
return result;
}
-mtp_error_e mtp_gdbus_storageinfo_get_volumeidentifier(int mtp_device,
- int mtp_storage, char **volumeidentifier)
+mtp_error_e mtp_gdbus_storageinfo_get_volume_identifier(int mtp_device,
+ int mtp_storage, char **volume_identifier)
{
mtp_error_e result = MTP_ERROR_NONE;
GError *error = NULL;
storageinfo_proxy,
mtp_device,
mtp_storage,
- volumeidentifier,
+ volume_identifier,
&result,
NULL,
&error) == FALSE) {
<node>
<interface name="org.tizen.mtp.manager">
- <method name="GetRawDevices">
+ <method name="GetDevices">
<arg type="i" name="device_count" direction="out" />
- <arg type="aa{sv}" name="raw_devices" direction="out" />
- <arg type="i" name="result" direction="out" />
- </method>
-
- <method name="GetDevice">
- <arg type="i" name="bus_location" direction="in" />
- <arg type="i" name="device_number" direction="in" />
- <arg type="i" name="mtp_device" direction="out" />
+ <arg type="aa{sv}" name="mtp_devices" direction="out" />
<arg type="i" name="result" direction="out" />
</method>
<method name="GetStorages">
<arg type="i" name="mtp_device" direction="in" />
- <arg type="i" name="storage_num" direction="out" />
+ <arg type="i" name="storage_count" direction="out" />
<arg type="aa{sv}" name="mtp_storages" direction="out" />
<arg type="i" name="result" direction="out" />
</method>
<method name="GetObjectHandles">
<arg type="i" name="mtp_device" direction="in" />
<arg type="i" name="mtp_storage" direction="in" />
- <arg type="i" name="format" direction="in" />
+ <arg type="i" name="file_type" direction="in" />
<arg type="i" name="parent_object_handle" direction="in" />
- <arg type="i" name="object_num" direction="out" />
+ <arg type="i" name="object_count" direction="out" />
<arg type="aa{sv}" name="object_handles" direction="out" />
<arg type="i" name="result" direction="out" />
</method>
</signal>
</interface>
<interface name="org.tizen.mtp.deviceinfo">
- <method name="GetManufacturername">
+ <method name="GetManufacturerName">
<arg type="i" name="mtp_device" direction="in" />
<arg type="s" name="manufacturer_name" direction="out" />
<arg type="i" name="result" direction="out" />
</method>
- <method name="GetModelname">
+ <method name="GetModelName">
<arg type="i" name="mtp_device" direction="in" />
<arg type="s" name="model_name" direction="out" />
<arg type="i" name="result" direction="out" />
</method>
- <method name="GetSerialnumber">
+ <method name="GetSerialNumber">
<arg type="i" name="mtp_device" direction="in" />
<arg type="s" name="serial_number" direction="out" />
<arg type="i" name="result" direction="out" />
</method>
- <method name="GetDeviceversion">
+ <method name="GetDeviceVersion">
<arg type="i" name="mtp_device" direction="in" />
<arg type="s" name="device_version" direction="out" />
<arg type="i" name="result" direction="out" />
</method>
+
+ <method name="GetBusLocation">
+ <arg type="i" name="mtp_device" direction="in" />
+ <arg type="i" name="bus_location" direction="out" />
+ <arg type="i" name="result" direction="out" />
+ </method>
+
+ <method name="GetDeviceNumber">
+ <arg type="i" name="mtp_device" direction="in" />
+ <arg type="i" name="device_number" direction="out" />
+ <arg type="i" name="result" direction="out" />
+ </method>
</interface>
<interface name="org.tizen.mtp.storageinfo">
<method name="GetDescription">
#include <mtp_internal.h>
#define BUFFER_LEN 100
-#define TEST_CASE_MAX 39
+#define TEST_CASE_MAX 40
#define TEST_LIST_MAX 20
#define PRT(format, args...) printf("%s:%d() "format, __FUNCTION__, __LINE__, ##args)
return ret;
}
-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_raw_devices(&raw_devices, &device_count);
- TC_PRT("ret[%d]: device_num[%d]", ret, device_count);
-
- if (ret == MTP_ERROR_NONE) {
- 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);
- }
-
- END();
- return ret;
-}
-
-int manager_test_get_device(void)
-{
- int ret = 0;
- int bus_location = 0;
- int device_number = 0;
- int device_count;
- mtp_raw_device_h *raw_devices = NULL;
-
- BEGIN();
-
- 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;
- }
-
- TC_PRT("Select first device");
-
- mtp_get_bus_location(raw_devices[0], &bus_location);
- mtp_get_device_number(raw_devices[0], &device_number);
-
- TC_PRT("bus location : %d, device_number : %d", bus_location, device_number);
-
- 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_storages(void)
{
int i;
int device_number = 0;
int device_count;
int storage_count;
- mtp_raw_device_h *raw_devices = NULL;
+ mtp_device_h *mtp_devices = NULL;
mtp_storage_h *mtp_storages = NULL;
- ret = mtp_get_raw_devices(&raw_devices, &device_count);
+ ret = mtp_get_devices(&mtp_devices, &device_count);
if (ret != MTP_ERROR_NONE) {
TC_PRT("mtp_get_raw_devices is failed!!!");
TC_PRT("Select first device");
- mtp_get_bus_location(raw_devices[0], &bus_location);
- mtp_get_device_number(raw_devices[0], &device_number);
+ mtp_deviceinfo_get_bus_location(mtp_devices[0], &bus_location);
+ mtp_deviceinfo_get_device_number(mtp_devices[0], &device_number);
TC_PRT("bus location : %d, device_number : %d", bus_location, device_number);
- ret = mtp_get_device(bus_location, device_number, &mtp_device);
- TC_PRT("ret[%d]: 1st mtp device [%d]", ret, mtp_device);
+ TC_PRT("ret[%d]: 1st mtp device [%d]", ret, mtp_devices[0]);
- ret = mtp_get_storages(mtp_device, &mtp_storages, &storage_count);
+ ret = mtp_get_storages(mtp_devices[0], &mtp_storages, &storage_count);
TC_PRT("ret[%d]: storage_count[%d]", ret, storage_count);
if (storage_count == 0) {
return -1;
}
- 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]);
for (i = 0; i < list_max; i++) {
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);
+ TC_PRT("ret[%d]: object id[%d] thumbnail_file_type[%d]", ret, mtp_objects[i], value);
}
END();
return ret;
}
-void __test_mtp_event_cb(mtp_event_e state, int arg, void *user_data)
+void __test_mtp_event_cb1(mtp_event_e state, int arg, void *user_data)
+{
+ int ret = 0;
+
+ TC_PRT("test mtp event cb 1 is called");
+ TC_PRT("state [%d] : %d", state, arg);
+
+ if (state == MTP_EVENT_TURNED_OFF) {
+ ret = mtp_deinitialize();
+ TC_PRT("ret[%d] : Terminated daemon", ret);
+ }
+}
+
+void __test_mtp_event_cb2(mtp_event_e state, int arg, void *user_data)
{
int ret = 0;
+ TC_PRT("test mtp event cb 2 is called");
TC_PRT("state [%d] : %d", state, arg);
if (state == MTP_EVENT_TURNED_OFF) {
}
}
-int application_test_event_callback(void)
+int application_test_add_event_callback(void)
+{
+ int ret;
+
+ BEGIN();
+
+ ret = mtp_add_mtp_event_cb(__test_mtp_event_cb1, NULL);
+ ret = mtp_add_mtp_event_cb(__test_mtp_event_cb2, NULL);
+
+ END();
+
+ return ret;
+}
+
+int application_test_remove_event_callback(void)
{
int ret;
BEGIN();
- ret = mtp_set_mtp_event_cb(__test_mtp_event_cb, NULL);
+ ret = mtp_remove_mtp_event_cb(__test_mtp_event_cb1);
END();
tc_table_t tc_table[] = {
/* manager api */
{"mtp_initialize", 1, manager_test_initialize},
- {"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_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_file_type},
+ {"mtp_objectinfo_get_thumbnail_file_type", 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},
{"get Jpeg image from /DCIM folder", 34, application_test_get_image_from_DCIM},
{"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},
+ {"test add callback function", 37, application_test_add_event_callback},
+ {"test remove callback function", 38, application_test_remove_event_callback},
{"get object and get thumbnail test", TEST_CASE_MAX, NULL},
/*-----------*/