* Transport related configuration
*/
/* Internal Storage */
-#define MTP_STORE_PATH_CHAR "/home/owner/content"
+#define MTP_STORE_PATH_CHAR "/opt/home/owner/content"
/* External Storage */
#define MTP_EXTERNAL_PATH_CHAR "/opt/media/SDCardA1"
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);
-
+void _util_get_external_path(char *external_path);
+void _util_get_internal_path(char *internal_path);
#endif /* _MTP_UTIL_H_ */
mtp_char *storage_path = NULL;
mtp_uint32 store_id = 0;
file_attr_t attrs = { 0, };
- char ext_path[MTP_MAX_PATHNAME_SIZE + 1] = { 0 };
+ char sto_path[MTP_MAX_PATHNAME_SIZE + 1] = { 0 };
switch (store_type) {
case MTP_STORAGE_INTERNAL:
- storage_path = MTP_STORE_PATH_CHAR;
+ _util_get_internal_path(sto_path);
+ storage_path = (mtp_char *)sto_path;
store_id = MTP_INTERNAL_STORE_ID;
break;
case MTP_STORAGE_EXTERNAL:
- _util_get_external_path(ext_path);
- storage_path = (mtp_char *)ext_path;
+ _util_get_external_path(sto_path);
+ storage_path = (mtp_char *)sto_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 };
+ char sto_path[MTP_MAX_PATHNAME_SIZE + 1] = { 0 };
switch(store_id) {
case MTP_INTERNAL_STORE_ID :
- g_strlcpy(path, MTP_STORE_PATH_CHAR,
+ _util_get_internal_path(sto_path);
+ g_strlcpy(path, sto_path,
MTP_MAX_PATHNAME_SIZE + 1);
break;
case MTP_EXTERNAL_STORE_ID :
- _util_get_external_path(ext_path);
- g_strlcpy(path, ext_path,
+ _util_get_external_path(sto_path);
+ g_strlcpy(path, sto_path,
MTP_MAX_PATHNAME_SIZE + 1);
break;
default :
{
mtp_uint32 store_id = 0;
char ext_path[MTP_MAX_PATHNAME_SIZE + 1] = { 0 };
+ char inter_path[MTP_MAX_PATHNAME_SIZE + 1] = { 0 };
retv_if(NULL == path_name, FALSE);
_util_get_external_path(ext_path);
+ _util_get_internal_path(inter_path);
- if (!strncmp(path_name, MTP_STORE_PATH_CHAR,
- strlen(MTP_STORE_PATH_CHAR))) {
+ if (!strncmp(path_name, inter_path,
+ strlen(inter_path))) {
store_id = MTP_INTERNAL_STORE_ID;
} else if (!strncmp(path_name, ext_path,
strlen(ext_path))) {
mtp_char command[FIND_CMD_LEN] = { 0 };
if (TRUE == _device_is_store_mounted(MTP_STORAGE_INTERNAL)) {
+ char inter_path[MTP_MAX_PATHNAME_SIZE + 1] = { 0 };
+ _util_get_internal_path(inter_path);
+
g_snprintf(command, FIND_CMD_LEN, FIND_CMD,
- MTP_STORE_PATH_CHAR, minutes,
+ inter_path, minutes,
MTP_FILES_MODIFIED_FILES);
DBG("find query is [%s]\n", command);
ret = system(command);
mtp_char wmp_hidden_path[MTP_MAX_PATHNAME_SIZE + 1] = { 0 };
if (obj_info->store_id == MTP_INTERNAL_STORE_ID) {
+ char inter_path[MTP_MAX_PATHNAME_SIZE + 1] = { 0 };
+ _util_get_internal_path(inter_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_STORE_PATH_CHAR,
+ "%s/%s", inter_path,
MTP_FILE_NAME_WMPINFO_XML);
} else {
char ext_path[MTP_MAX_PATHNAME_SIZE + 1] = { 0 };
mtp_bool ret = 0;
int vconf_ret = 0;
mtp_int32 error = 0;
+ char inter_path[MTP_MAX_PATHNAME_SIZE + 1] = { 0 };
DBG("Initialization start!");
}
/* Internal Storage */
- if (access(MTP_STORE_PATH_CHAR, F_OK) < 0) {
- if (FALSE == _util_dir_create(MTP_STORE_PATH_CHAR, &error)) {
+ _util_get_internal_path(inter_path);
+ if (access(inter_path, F_OK) < 0) {
+ if (FALSE == _util_dir_create((const mtp_char *)inter_path, &error)) {
ERR("Cannot make directory!! [%s]\n",
- MTP_STORE_PATH_CHAR);
+ inter_path);
goto MTP_INIT_FAIL;
}
}
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)) {
+ if (FALSE == _util_dir_create((const mtp_char *)ext_path, &error)) {
ERR("Cannot make directory!! [%s]\n",
ext_path);
goto MTP_INIT_FAIL;
#ifndef MTP_SUPPORT_HIDE_WMPINFO_XML
/* Update WMPInfo.xml for preventing frequent saving */
ret = _util_create_path(wmpinfopath, sizeof(wmpinfopath),
- MTP_STORE_PATH_CHAR, MTP_FILE_NAME_WMPINFO_XML);
+ (const mtp_char *)inter_path, MTP_FILE_NAME_WMPINFO_XML);
if (FALSE == ret) {
ERR("szWMPInfoPath is too long");
goto MTP_INIT_FAIL;
static void __clean_up_inoti(void *data)
{
char ext_path[MTP_MAX_PATHNAME_SIZE + 1] = { 0 };
+ char inter_path[MTP_MAX_PATHNAME_SIZE + 1] = { 0 };
_util_get_external_path(ext_path);
+ _util_get_internal_path(inter_path);
- __remove_recursive_inoti_watch(MTP_STORE_PATH_CHAR);
+ __remove_recursive_inoti_watch((mtp_char *)inter_path);
__remove_recursive_inoti_watch((mtp_char *)ext_path);
__destroy_inoti_open_files_list();
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 };
+ char inter_path[MTP_MAX_PATHNAME_SIZE + 1] = { 0 };
_util_get_external_path(ext_path);
+ _util_get_internal_path(inter_path);
- if (!g_strcmp0(parent_path, MTP_STORE_PATH_CHAR) ||
+ if (!g_strcmp0(parent_path, inter_path) ||
!g_strcmp0(parent_path, ext_path))
{
DBG("parent is the root folder");
static mtp_uint32 external_store_len = 0;
char ext_path[MTP_MAX_PATHNAME_SIZE + 1] = { 0 };
+ char inter_path[MTP_MAX_PATHNAME_SIZE + 1] = { 0 };
retv_if(path == NULL, FALSE);
_util_get_external_path(ext_path);
+ _util_get_internal_path(inter_path);
if (!is_initialized) {
is_initialized = TRUE;
- internal_store_len = strlen(MTP_STORE_PATH_CHAR);
+ internal_store_len = strlen(inter_path);
external_store_len = strlen(ext_path);
max_store_len = internal_store_len > external_store_len ?
DBG("max store len : [%u]\n", max_store_len);
}
- if (!strncmp(path, MTP_STORE_PATH_CHAR, internal_store_len)) {
+ if (!strncmp(path, inter_path, internal_store_len)) {
root_path_len = internal_store_len;
} else if (!strncmp(path, ext_path, external_store_len)) {
root_path_len = external_store_len;
return;
}
-static bool _util_device_supported_cb(int storage_id, storage_type_e type,
+static bool _util_device_external_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;
+ char *storage_path = (char *)user_data;
+
+ DBG("storage id: %d, path: %s", storage_id, path);
if (type == STORAGE_TYPE_EXTERNAL && path != NULL) {
- strncpy(ext_path, path, strlen(path));
- DBG("external storage path : %s", ext_path);
+ strncpy(storage_path, path, strlen(path));
+ DBG("external storage path : %s", storage_path);
}
return TRUE;
}
-void _util_get_external_path(char *ext_path)
+void _util_get_external_path(char *external_path)
{
int error = STORAGE_ERROR_NONE;
- error = storage_foreach_device_supported(_util_device_supported_cb, ext_path);
+ error = storage_foreach_device_supported(_util_device_external_supported_cb, external_path);
if (error != STORAGE_ERROR_NONE) {
ERR("get external storage path Fail");
- strncpy(ext_path, MTP_EXTERNAL_PATH_CHAR, strlen(MTP_EXTERNAL_PATH_CHAR));
+ strncpy(external_path, MTP_EXTERNAL_PATH_CHAR, strlen(MTP_EXTERNAL_PATH_CHAR));
+ }
+}
+
+static bool _util_device_internal_supported_cb(int storage_id, storage_type_e type,
+ storage_state_e state, const char *path, void *user_data)
+{
+ char *storage_path = (char *)user_data;
+
+ DBG("storage id: %d, path: %s", storage_id, path);
+
+ if (type == STORAGE_TYPE_INTERNAL && path != NULL) {
+ strncpy(storage_path, path, strlen(path));
+ DBG("internal storage path : %s", storage_path);
+
+ if (storage_get_root_directory(storage_id, &storage_path) != STORAGE_ERROR_NONE) {
+ ERR("get internal storage path Fail");
+ return FALSE;
+ } else {
+ DBG("get internal storage path : %s", storage_path);
+ }
+ }
+
+ return TRUE;
+}
+
+void _util_get_internal_path(char *internal_path)
+{
+ int error = STORAGE_ERROR_NONE;
+ error = storage_foreach_device_supported(_util_device_internal_supported_cb, internal_path);
+
+ if (error != STORAGE_ERROR_NONE) {
+ ERR("get internal storage path Fail");
+ strncpy(internal_path, MTP_STORE_PATH_CHAR, strlen(MTP_STORE_PATH_CHAR));
}
}