-
-
-int _media_content_replace_path_in_condition(const char *condition, char *replace_condition, bool replace)
-{
- int ret = MEDIA_CONTENT_ERROR_NONE;
-
-#ifdef _USE_TVPD_MODE
- snprintf(replace_condition, MAX_QUERY_SIZE, "%s", condition);
-#else
- char old_condition[MAX_QUERY_SIZE] = {0, };
- char new_condition[MAX_QUERY_SIZE] = {0, };
- char *find = NULL;
- unsigned int str_len = 0;
-
- char *find_str = NULL;
- char *to_replace_str = NULL;
-
- if (replace == TRUE) { //change User session path to System session path
- find_str = g_strdup(MEDIA_ROOT_PATH_INTERNAL_OLD);
- if (!STRING_VALID(find_str)) {
- media_content_error("strdup failed");
- ret = MEDIA_CONTENT_ERROR_INVALID_OPERATION;
- goto ERROR;
- }
-
- to_replace_str = g_strdup(MEDIA_ROOT_PATH_INTERNAL);
- if (!STRING_VALID(to_replace_str)) {
- media_content_error("Get TZ_USER_CONTENT failed");
- ret = MEDIA_CONTENT_ERROR_INVALID_OPERATION;
- goto ERROR;
- }
- } else {
- find_str = g_strdup(MEDIA_ROOT_PATH_INTERNAL);
- if (!STRING_VALID(find_str)) {
- media_content_error("Get TZ_USER_CONTENT failed");
- ret = MEDIA_CONTENT_ERROR_INVALID_OPERATION;
- goto ERROR;
- }
-
- to_replace_str = g_strdup(MEDIA_ROOT_PATH_INTERNAL_OLD);
- if (!STRING_VALID(to_replace_str)) {
- media_content_error("strdup failed");
- ret = MEDIA_CONTENT_ERROR_INVALID_OPERATION;
- goto ERROR;
- }
- }
-
- memset(old_condition, 0, sizeof(old_condition));
- memset(new_condition, 0, sizeof(new_condition));
-
- media_content_sec_debug("Old condition[%s]", condition);
-
- if (!SAFE_STRLCPY(new_condition, condition, sizeof(new_condition))) {
- media_content_error("MEDIA_CONTENT_ERROR_INVALID_OPERATION(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_OPERATION);
- ret = MEDIA_CONTENT_ERROR_INVALID_OPERATION;
- goto ERROR;
- }
-
- if (g_strcmp0(find_str, to_replace_str))
- find = strstr(new_condition, find_str);
-
- while (find != NULL) {
- str_len = find - new_condition;
-
- memset(old_condition, 0, sizeof(old_condition));
- if (!SAFE_STRLCPY(old_condition, new_condition, sizeof(old_condition))) {
- media_content_error("MEDIA_CONTENT_ERROR_INVALID_OPERATION(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_OPERATION);
- ret = MEDIA_CONTENT_ERROR_INVALID_OPERATION;
- goto ERROR;
- }
- memset(new_condition, 0, sizeof(new_condition));
-
- snprintf(new_condition, str_len + 1, "%s", old_condition);
-
- SAFE_STRLCAT(new_condition, to_replace_str, sizeof(new_condition));
- SAFE_STRLCAT(new_condition, old_condition + str_len + strlen(find_str), sizeof(new_condition));
-
- find = strstr(new_condition, find_str);
- }
-
- if (!SAFE_STRLCPY(replace_condition, new_condition, MAX_QUERY_SIZE)) {
- media_content_error("MEDIA_CONTENT_ERROR_INVALID_OPERATION(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_OPERATION);
- ret = MEDIA_CONTENT_ERROR_INVALID_OPERATION;
- goto ERROR;
- }
-
- media_content_sec_debug("repl cond[%s]", replace_condition);
-
- if (!STRING_VALID(replace_condition)) {
- media_content_error("replace failed");
- ret = MEDIA_CONTENT_ERROR_INVALID_OPERATION;
- goto ERROR;
- }
-
-ERROR:
- SAFE_FREE(find_str);
- SAFE_FREE(to_replace_str);
-#endif
-
- return ret;
-}
-
-int _media_content_replace_path(const char *path, char *replace_path)
-{
-#ifdef _USE_TVPD_MODE
- snprintf(replace_path, MAX_PATH_LEN, "%s", path);
-#else
- if (strncmp(path, MEDIA_ROOT_PATH_INTERNAL_OLD, strlen(MEDIA_ROOT_PATH_INTERNAL_OLD)) == 0) {
- media_content_sec_debug("Old path[%s]", path);
- snprintf(replace_path, MAX_PATH_LEN, "%s%s", MEDIA_ROOT_PATH_INTERNAL, path + strlen(MEDIA_ROOT_PATH_INTERNAL_OLD));
- } else {
- snprintf(replace_path, MAX_PATH_LEN, "%s", path);
- }
-#endif
-
- if (!STRING_VALID(replace_path)) {
- media_content_error("replace failed");
- return MEDIA_CONTENT_ERROR_INVALID_OPERATION;
- }
-
- return MEDIA_CONTENT_ERROR_NONE;
-}
-
-#ifdef _USE_SENIOR_MODE
-bool _media_content_is_support_senior_mode()
-{
- bool bSupportSeniorMode = false;
-
- if (system_info_get_value_bool(SYSTEM_INFO_KEY_GET_SENIOR_MODE_SUPPORTED, &bSupportSeniorMode) != SYSTEM_INFO_ERROR_NONE) {
- media_content_debug("Get senior mode support failed");
- return false;
- }
- /* media_content_debug("Senior mode Support : [%d]", bSupportSeniorMode); */
- return bSupportSeniorMode;
-}
-#endif
-