INCLUDE(FindPkgConfig)
pkg_check_modules(pkgs REQUIRED glib-2.0 capi-content-media-content
- capi-media-metadata-extractor vconf dlog tapi capi-system-info libtzplatform-config)
+ capi-media-metadata-extractor vconf dlog tapi capi-system-info storage)
FOREACH(flag ${pkgs_CFLAGS})
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
#define _MTP_CONFIG_H_
#include <stdbool.h>
-#include <tzplatform_config.h>
/* Function Features */
#define MTP_USE_INFORMATION_REGISTRY /* for get and set some information value */
#define MTP_STORE_PATH_CHAR "/home/owner/content"
/* External Storage */
-#define MTP_EXTERNAL_PATH_CHAR tzplatform_mkpath(TZ_SYS_MEDIA, "/sdcard")
+#define MTP_EXTERNAL_PATH_CHAR "/opt/media/SDCardA1"
#define MTP_DEVICE_ICON "/usr/share/mtp/device_icon.ico"
/* File For WMP extesions */
void _util_get_usbmode_status(phone_status_t *val);
phone_status_t _util_get_local_usbmode_status(void);
void _util_set_local_usbmode_status(const phone_status_t val);
+void _util_get_external_path(char *ext_path);
#endif /* _MTP_UTIL_H_ */
Name: mtp-responder
Summary: Media Transfer Protocol daemon (responder)
-Version: 0.0.8
+Version: 0.0.9
Release: 1
Group: Network & Connectivity/Other
License: Apache-2.0
BuildRequires: pkgconfig(capi-content-media-content)
BuildRequires: pkgconfig(capi-media-metadata-extractor)
BuildRequires: pkgconfig(capi-system-info)
-Buildrequires: pkgconfig(libtzplatform-config)
+Buildrequires: pkgconfig(storage)
Requires(post): /usr/bin/vconftool
mtp_char *storage_path = NULL;
mtp_uint32 store_id = 0;
file_attr_t attrs = { 0, };
+ char ext_path[MTP_MAX_PATHNAME_SIZE + 1] = { 0 };
switch (store_type) {
case MTP_STORAGE_INTERNAL:
store_id = MTP_INTERNAL_STORE_ID;
break;
case MTP_STORAGE_EXTERNAL:
- storage_path = (mtp_char *)MTP_EXTERNAL_PATH_CHAR;
+ _util_get_external_path(ext_path);
+ storage_path = (mtp_char *)ext_path;
store_id = MTP_EXTERNAL_STORE_ID;
break;
default:
mtp_bool _entity_get_store_path_by_id(mtp_uint32 store_id, mtp_char *path)
{
+ char ext_path[MTP_MAX_PATHNAME_SIZE + 1] = { 0 };
+
switch(store_id) {
case MTP_INTERNAL_STORE_ID :
g_strlcpy(path, MTP_STORE_PATH_CHAR,
MTP_MAX_PATHNAME_SIZE + 1);
break;
case MTP_EXTERNAL_STORE_ID :
- g_strlcpy(path, MTP_EXTERNAL_PATH_CHAR,
+ _util_get_external_path(ext_path);
+ g_strlcpy(path, ext_path,
MTP_MAX_PATHNAME_SIZE + 1);
break;
default :
mtp_uint32 _entity_get_store_id_by_path(const mtp_char *path_name)
{
mtp_uint32 store_id = 0;
+ char ext_path[MTP_MAX_PATHNAME_SIZE + 1] = { 0 };
retv_if(NULL == path_name, FALSE);
+ _util_get_external_path(ext_path);
+
if (!strncmp(path_name, MTP_STORE_PATH_CHAR,
strlen(MTP_STORE_PATH_CHAR))) {
store_id = MTP_INTERNAL_STORE_ID;
- } else if (!strncmp(path_name, MTP_EXTERNAL_PATH_CHAR,
- strlen(MTP_EXTERNAL_PATH_CHAR))) {
+ } else if (!strncmp(path_name, ext_path,
+ strlen(ext_path))) {
store_id = MTP_EXTERNAL_STORE_ID;
}
DBG("object handle is not PTP_OBJECTHANDLE_ALL. [%ld]\n",
obj_handle);
obj = _entity_get_object_from_store(store, obj_handle);
- if (_entity_remove_object_mtp_store(store, obj, PTP_FORMATCODE_NOTUSED,
- &response, &atleas_one, read_only)) {
- slist_node_t *temp = NULL;
-
- temp = _util_delete_node(&(store->obj_list), obj);
- g_free(temp);
- _util_delete_file_from_db(obj->file_path);
- _entity_dealloc_mtp_obj(obj);
- } else {
- switch (response) {
- case PTP_RESPONSE_PARTIAL_DELETION:
- all_del = FALSE;
- break;
- case PTP_RESPONSE_OBJ_WRITEPROTECTED:
- case PTP_RESPONSE_ACCESSDENIED:
- all_del = FALSE;
- break;
- case PTP_RESPONSE_UNDEFINED:
- default:
- /* do nothing */
- break;
+
+ if (NULL != obj) {
+ if (_entity_remove_object_mtp_store(store, obj, PTP_FORMATCODE_NOTUSED,
+ &response, &atleas_one, read_only)) {
+ slist_node_t *temp = NULL;
+
+ temp = _util_delete_node(&(store->obj_list), obj);
+ g_free(temp);
+ _util_delete_file_from_db(obj->file_path);
+ _entity_dealloc_mtp_obj(obj);
+ } else {
+ switch (response) {
+ case PTP_RESPONSE_PARTIAL_DELETION:
+ all_del = FALSE;
+ break;
+ case PTP_RESPONSE_OBJ_WRITEPROTECTED:
+ case PTP_RESPONSE_ACCESSDENIED:
+ all_del = FALSE;
+ break;
+ case PTP_RESPONSE_UNDEFINED:
+ default:
+ /* do nothing */
+ break;
+ }
}
}
}
}
}
if (TRUE == _device_is_store_mounted(MTP_STORAGE_EXTERNAL)) {
+ char ext_path[MTP_MAX_PATHNAME_SIZE + 1] = { 0 };
+ _util_get_external_path(ext_path);
+
g_snprintf(command, FIND_CMD_LEN, FIND_CMD,
- MTP_EXTERNAL_PATH_CHAR, minutes,
+ ext_path, minutes,
MTP_FILES_MODIFIED_FILES);
DBG("find query is [%s]\n", command);
ret = system(command);
"%s/%s", MTP_STORE_PATH_CHAR,
MTP_FILE_NAME_WMPINFO_XML);
} else {
+ char ext_path[MTP_MAX_PATHNAME_SIZE + 1] = { 0 };
+ _util_get_external_path(ext_path);
+
g_snprintf(wmp_hidden_path,
MTP_MAX_PATHNAME_SIZE + 1,
"%s/%s/%s", MTP_USER_DIRECTORY,
MTP_FILE_NAME_WMPINFO_XML);
g_snprintf(wmp_info_path,
MTP_MAX_PATHNAME_SIZE + 1,
- "%s/%s", MTP_EXTERNAL_PATH_CHAR,
+ "%s/%s", ext_path,
MTP_FILE_NAME_WMPINFO_XML);
}
}
/* External Storage */
if (MTP_PHONE_MMC_INSERTED == _util_get_local_mmc_status()) {
- if (access(MTP_EXTERNAL_PATH_CHAR, F_OK) < 0) {
- if (FALSE == _util_dir_create(MTP_EXTERNAL_PATH_CHAR, &error)) {
+ char ext_path[MTP_MAX_PATHNAME_SIZE + 1] = { 0 };
+ _util_get_external_path(ext_path);
+ if (access(ext_path, F_OK) < 0) {
+ if (FALSE == _util_dir_create(ext_path, &error)) {
ERR("Cannot make directory!! [%s]\n",
- MTP_EXTERNAL_PATH_CHAR);
+ ext_path);
goto MTP_INIT_FAIL;
}
}
static void __clean_up_inoti(void *data)
{
+ char ext_path[MTP_MAX_PATHNAME_SIZE + 1] = { 0 };
+ _util_get_external_path(ext_path);
+
__remove_recursive_inoti_watch(MTP_STORE_PATH_CHAR);
- __remove_recursive_inoti_watch((mtp_char *)MTP_EXTERNAL_PATH_CHAR);
+ __remove_recursive_inoti_watch((mtp_char *)ext_path);
__destroy_inoti_open_files_list();
close(g_inoti_fd);
}
parent_obj = _entity_get_object_from_store_by_path(store, parent_path);
if (NULL == parent_obj) {
+ char ext_path[MTP_MAX_PATHNAME_SIZE + 1] = { 0 };
+ _util_get_external_path(ext_path);
+
if (!g_strcmp0(parent_path, MTP_STORE_PATH_CHAR) ||
- !g_strcmp0(parent_path, MTP_EXTERNAL_PATH_CHAR))
+ !g_strcmp0(parent_path, ext_path))
{
DBG("parent is the root folder");
h_parent = 0;
static mtp_uint32 internal_store_len = 0;
static mtp_uint32 external_store_len = 0;
+ char ext_path[MTP_MAX_PATHNAME_SIZE + 1] = { 0 };
+
retv_if(path == NULL, FALSE);
+ _util_get_external_path(ext_path);
+
if (!is_initialized) {
is_initialized = TRUE;
internal_store_len = strlen(MTP_STORE_PATH_CHAR);
- external_store_len = strlen(MTP_EXTERNAL_PATH_CHAR);
+ external_store_len = strlen(ext_path);
max_store_len = internal_store_len > external_store_len ?
internal_store_len : external_store_len;
if (!strncmp(path, MTP_STORE_PATH_CHAR, internal_store_len)) {
root_path_len = internal_store_len;
- } else if (!strncmp(path, MTP_EXTERNAL_PATH_CHAR, external_store_len)) {
+ } else if (!strncmp(path, ext_path, external_store_len)) {
root_path_len = external_store_len;
}
else {
#include "mtp_util.h"
#include "mtp_support.h"
#include "mtp_fs.h"
+#include <storage/storage.h>
static phone_state_t g_ph_status = { 0 };
g_ph_status.usb_mode_state = val;
return;
}
+
+static bool _util_device_supported_cb(int storage_id, storage_type_e type,
+ storage_state_e state, const char *path, void *user_data)
+{
+ char *ext_path = (char *)user_data;
+
+ if (type == STORAGE_TYPE_EXTERNAL && path != NULL) {
+ strncpy(ext_path, path, strlen(path));
+ DBG("external storage path : %s", ext_path);
+ }
+
+ return TRUE;
+}
+
+void _util_get_external_path(char *ext_path)
+{
+ int error = STORAGE_ERROR_NONE;
+ error = storage_foreach_device_supported(_util_device_supported_cb, ext_path);
+
+ if (error != STORAGE_ERROR_NONE) {
+ ERR("get external storage path Fail");
+ strncpy(ext_path, MTP_EXTERNAL_PATH_CHAR, strlen(MTP_EXTERNAL_PATH_CHAR));
+ }
+}