Tizen Native API
7.0
|
The MTP Manager API provides functions for establish connection to access MTP responder device, and to Get/Delete files.
Required Header
#include <mtp.h>
Overview
The MTP manager api provides following functions :
- Create / destroy connection to access MTP responder device
- Get Device list
- Get Storage list
- Get Object handles
- Get thumbnail
- Get Object
- Delete Object
Related Features
This API is related with the following features:
It is recommended to design feature related codes in your application for reliability.
You can check if a device supports the related features for this API by using System Information, thereby controlling the procedure of your application.
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.
More details on featuring your application can be found from Feature Element.
Functions | |
int | mtp_initialize (void) |
Initializes for using MTP. | |
int | mtp_get_devices (mtp_device_h **mtp_devices, int *device_count) |
Gets the mtp devices. | |
int | mtp_get_storages (mtp_device_h mtp_device, mtp_storage_h **mtp_storages, int *storage_count) |
Gets mtp storages from the given device. | |
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_count) |
Gets object handles from the given device and storage. | |
int | mtp_get_object (mtp_device_h mtp_device, mtp_object_h object_handle, char *dest_path) |
Gets object for a given path from object handle. | |
int | mtp_get_thumbnail (mtp_device_h mtp_device, mtp_object_h object_handle, char *dest_path) |
Gets thumbnail from the given object handle. | |
int | mtp_add_mtp_event_cb (mtp_event_cb event_cb, void *user_data) |
Adds a callback function for receiving MTP event. | |
int | mtp_remove_mtp_event_cb (mtp_event_cb event_cb) |
Removes the callback function. | |
int | mtp_deinitialize (void) |
Deinitializes MTP operation. | |
Typedefs | |
typedef int | mtp_device_h |
The handle to the mtp device. | |
typedef int | mtp_storage_h |
The handle to the mtp storage. | |
typedef int | mtp_object_h |
The handle to the mtp object. | |
typedef void(* | mtp_event_cb )(mtp_event_e event, int event_parameter, void *user_data) |
Called when mtp event is occured. |
Typedef Documentation
typedef int mtp_device_h |
The handle to the mtp device.
- Since :
- 3.0
typedef void(* mtp_event_cb)(mtp_event_e event, int event_parameter, void *user_data) |
Called when mtp event is occured.
- Since :
- 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.
- 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.
- Parameters:
-
[in] event The event [in] event_parameter The event parameter [in] user_data The user data passed from the callback registration function
typedef int mtp_object_h |
The handle to the mtp object.
- Since :
- 3.0
typedef int mtp_storage_h |
The handle to the mtp storage.
- Since :
- 3.0
Enumeration Type Documentation
enum mtp_error_e |
Error codes reported by the MTP API.
- Since :
- 3.0
- Enumerator:
enum mtp_event_e |
Enumerations for MTP event type.
- Since :
- 3.0
- Enumerator:
enum mtp_filetype_e |
Enumerations for MTP file type.
- Since :
- 3.0
- Enumerator:
enum mtp_storage_type_e |
Enumerations for MTP Storage type.
- Since :
- 3.0
Function Documentation
int mtp_add_mtp_event_cb | ( | mtp_event_cb | event_cb, |
void * | user_data | ||
) |
Adds a callback function for receiving MTP event.
- Since :
- 3.0
- Remarks:
- You can register multiple callback.
If you don't want to receive the event, then using the mtp_remove_mtp_event_cb() function to unregister a callback. -
If device state is changed, MTP_EVENT_DEVICE_ADDED or MTP_EVENT_DEVICE_REMOVED event is occur.
If storage state is changed, MTP_EVENT_STORAGE_ADDED or MTP_EVENT_STORAGE_REMOVED event is occur.
If object state is changed, MTP_EVENT_OBJECT_ADDED or MTP_EVENT_OBJECT_REMOVED event is occur.
If mtp service is turned off, MTP_EVENT_TURNED_OFF event is occur.
- Parameters:
-
[in] event_cb The callback [in] user_data The user data
- Returns:
- 0 on success, otherwise a negative error value.
- Return values:
-
MTP_ERROR_NONE Successful MTP_ERROR_NOT_SUPPORTED MTP is not supported MTP_ERROR_INVALID_PARAMETER Invalid parameter MTP_ERROR_NOT_INITIALIZED MTP is not initialized
- See also:
- mtp_remove_mtp_event_cb()
int mtp_deinitialize | ( | void | ) |
Deinitializes MTP operation.
- Since :
- 3.0
- Remarks:
- http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.
http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage.
- Returns:
- 0 on success, otherwise a negative error value.
- Return values:
-
MTP_ERROR_NONE Successful MTP_ERROR_NOT_SUPPORTED MTP is not supported MTP_ERROR_PERMISSION_DENIED Permission Denied
- See also:
- mtp_initialize()
int mtp_get_devices | ( | mtp_device_h ** | mtp_devices, |
int * | device_count | ||
) |
Gets the mtp devices.
- Since :
- 3.0
- Remarks:
- The mtp_devices should be released using free().
- Parameters:
-
[out] mtp_devices The MTP device list [out] device_count Length of device list
- Returns:
- 0 on success, otherwise a negative error value.
- Return values:
-
MTP_ERROR_NONE Successful MTP_ERROR_NOT_SUPPORTED MTP is not supported MTP_ERROR_INVALID_PARAMETER Invalid parameter MTP_ERROR_NOT_INITIALIZED MTP is not initialized MTP_ERROR_NOT_ACTIVATED MTP is not activated MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized MTP_ERROR_COMM_ERROR MTP communication error
- See also:
- mtp_initialize()
int mtp_get_object | ( | mtp_device_h | mtp_device, |
mtp_object_h | object_handle, | ||
char * | dest_path | ||
) |
Gets object for a given path from object handle.
- Since :
- 3.0
- Remarks:
- The dest_path is host storage path.
-
http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.
http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage.
- Parameters:
-
[in] mtp_device The MTP device [in] object_handle The object handle [in] dest_path The dest path
- Returns:
- 0 on success, otherwise a negative error value.
- Return values:
-
MTP_ERROR_NONE Successful MTP_ERROR_NOT_SUPPORTED MTP is not supported MTP_ERROR_PERMISSION_DENIED Permission denied MTP_ERROR_INVALID_PARAMETER Invalid parameter MTP_ERROR_NOT_INITIALIZED MTP is not initialized MTP_ERROR_NOT_ACTIVATED MTP is not activated MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized MTP_ERROR_COMM_ERROR MTP communication error MTP_ERROR_IO_ERROR I/O error
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_count | ||
) |
Gets object handles from the given device and storage.
- Since :
- 3.0
- Remarks:
- The object_handles should be freed using free().
- If the parent is 0, it means "root folder" of mtp storage.
- Parameters:
-
[in] mtp_device The MTP device [in] mtp_storage The MTP storage [in] file_type The file type what you want [in] parent The parent object handle [out] object_handles The object handle list [out] object_count Length of object handle list
- Returns:
- 0 on success, otherwise a negative error value.
- Return values:
-
MTP_ERROR_NONE Successful MTP_ERROR_NOT_SUPPORTED MTP is not supported MTP_ERROR_INVALID_PARAMETER Invalid parameter MTP_ERROR_NOT_INITIALIZED MTP is not initialized MTP_ERROR_NOT_ACTIVATED MTP is not activated MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized MTP_ERROR_COMM_ERROR MTP communication error
- See also:
- mtp_get_devices()
- mtp_get_storages()
int mtp_get_storages | ( | mtp_device_h | mtp_device, |
mtp_storage_h ** | mtp_storages, | ||
int * | storage_count | ||
) |
Gets mtp storages from the given device.
- Since :
- 3.0
- Remarks:
- The mtp_storages should be freed using free().
- Parameters:
-
[in] mtp_device The MTP device [out] mtp_storages Current mtp storage list [out] storage_count Length of storage list
- Returns:
- 0 on success, otherwise a negative error value.
- Return values:
-
MTP_ERROR_NONE Successful MTP_ERROR_NOT_SUPPORTED MTP is not supported MTP_ERROR_INVALID_PARAMETER Invalid parameter MTP_ERROR_NOT_INITIALIZED MTP is not initialized MTP_ERROR_NOT_ACTIVATED MTP is not activated MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized MTP_ERROR_COMM_ERROR MTP communication error
- See also:
- mtp_get_devices()
int mtp_get_thumbnail | ( | mtp_device_h | mtp_device, |
mtp_object_h | object_handle, | ||
char * | dest_path | ||
) |
Gets thumbnail from the given object handle.
- Since :
- 3.0
- Remarks:
- The dest_path is host storage path.
-
http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.
http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage.
- Parameters:
-
[in] mtp_device The MTP device [in] object_handle The object handle [in] dest_path The dest path
- Returns:
- 0 on success, otherwise a negative error value.
- Return values:
-
MTP_ERROR_NONE Successful MTP_ERROR_NOT_SUPPORTED MTP is not supported MTP_ERROR_PERMISSION_DENIED Permission denied MTP_ERROR_INVALID_PARAMETER Invalid parameter MTP_ERROR_NOT_INITIALIZED MTP is not initialized MTP_ERROR_NOT_ACTIVATED MTP is not activated MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized MTP_ERROR_COMM_ERROR MTP communication error MTP_ERROR_IO_ERROR I/O error
int mtp_initialize | ( | void | ) |
Initializes for using MTP.
- Since :
- 3.0
- Remarks:
- This function must be called before proceeding any other mtp functions.
-
http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.
http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage.
- Returns:
- 0 on success, otherwise a negative error value.
- Return values:
-
MTP_ERROR_NONE Successful MTP_ERROR_NOT_SUPPORTED MTP is not supported MTP_ERROR_PERMISSION_DENIED Permission Denied MTP_ERROR_NOT_COMM_INITIALIZED MTP communication is not initialized
- See also:
- mtp_deinitialize()
int mtp_remove_mtp_event_cb | ( | mtp_event_cb | event_cb | ) |
Removes the callback function.
- Since :
- 3.0
- Parameters:
-
[in] event_cb The callback
- Returns:
- 0 on success, otherwise a negative error value.
- Return values:
-
MTP_ERROR_NONE Successful MTP_ERROR_NOT_SUPPORTED MTP is not supported MTP_ERROR_INVALID_PARAMETER Invalid parameter MTP_ERROR_NOT_INITIALIZED MTP is not initialized
- See also:
- mtp_add_mtp_event_cb()