return content_g_uid;
}
-int _content_query_prepare(char *select_query, char *condition_query, char *option_query, sqlite3_stmt **stmt)
+int _content_query_prepare(const char *select_query, const char *condition_query, const char *option_query, sqlite3_stmt **stmt)
{
int ret = MEDIA_CONTENT_ERROR_NONE;
char *query = NULL;
media_content_retvm_if(!STRING_VALID(select_query), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid select_query");
- if (!STRING_VALID(condition_query))
- condition_query = (char *)" ";
-
- if (!STRING_VALID(option_query))
- option_query = (char *)" ";
+ if (STRING_VALID(condition_query)) {
+ if (STRING_VALID(option_query))
+ query = sqlite3_mprintf("%s AND %s %s", select_query, condition_query, option_query);
+ else
+ query = sqlite3_mprintf("%s AND %s", select_query, condition_query);
+ } else {
+ if (STRING_VALID(option_query))
+ query = sqlite3_mprintf("%s %s", select_query, option_query);
+ else
+ query = sqlite3_mprintf("%s", select_query);
+ }
- query = sqlite3_mprintf("%s %s %s", select_query, condition_query, option_query);
ret = _content_get_result(query, stmt);
SQLITE3_SAFE_FREE(query);
}
#endif
-int _content_error_capi(int content_error)
+int _content_error_capi(int internal_error)
{
- if (content_error != MEDIA_CONTENT_ERROR_NONE)
- media_content_error("MS Error[%d]", content_error);
-
- /*Error None*/
- if (content_error == MS_MEDIA_ERR_NONE)
+ if (internal_error == MS_MEDIA_ERR_NONE)
return MEDIA_CONTENT_ERROR_NONE;
- /* Internal operation error*/
- else if ((content_error == MS_MEDIA_ERR_INVALID_PARAMETER) ||
- (content_error == MS_MEDIA_ERR_INVALID_PATH) ||
- (content_error == MS_MEDIA_ERR_THUMB_DUPLICATED_REQUEST))
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+ media_content_error("MS Error[%d]", internal_error);
- else if (content_error == MS_MEDIA_ERR_OUT_OF_MEMORY)
+ switch (internal_error) {
+ case MS_MEDIA_ERR_INVALID_PARAMETER:
+ return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+ case MS_MEDIA_ERR_OUT_OF_MEMORY:
return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
-
- /* DB operation error*/
- else if (content_error == MS_MEDIA_ERR_DB_BUSY_FAIL)
+ case MS_MEDIA_ERR_DB_BUSY_FAIL:
return MEDIA_CONTENT_ERROR_DB_BUSY;
-
- else if ((content_error <= MS_MEDIA_ERR_DB_CONNECT_FAIL) && (content_error >= MS_MEDIA_ERR_DB_INTERNAL))
+ case MS_MEDIA_ERR_DB_CONSTRAINT_FAIL:
+ case MS_MEDIA_ERR_DB_NO_RECORD:
+ case MS_MEDIA_ERR_DB_CORRUPT:
+ case MS_MEDIA_ERR_DB_FULL_FAIL:
+ case MS_MEDIA_ERR_DB_RESET:
+ case MS_MEDIA_ERR_DB_INTERNAL:
return MEDIA_CONTENT_ERROR_DB_FAILED;
-
- /* IPC operation error*/
- else if ((content_error <= MS_MEDIA_ERR_SOCKET_CONN) && (content_error >= MS_MEDIA_ERR_SOCKET_INTERNAL))
+ case MS_MEDIA_ERR_IPC:
return MEDIA_CONTENT_ERROR_NETWORK;
-
- /* MEDIA SERVER error*/
- else if (content_error == MS_MEDIA_ERR_PERMISSION_DENIED)
+ case MS_MEDIA_ERR_PERMISSION_DENIED:
return MEDIA_CONTENT_ERROR_PERMISSION_DENIED;
-
- /* Thumbnail error*/
- else if ((content_error == MS_MEDIA_ERR_THUMB_TOO_BIG) || (content_error == MS_MEDIA_ERR_THUMB_UNSUPPORTED))
- return MEDIA_CONTENT_ERROR_UNSUPPORTED_CONTENT;
-
- /*ETC*/
- return MEDIA_CONTENT_ERROR_INVALID_OPERATION;
+ case MS_MEDIA_ERR_THUMB_TOO_BIG:
+ case MS_MEDIA_ERR_THUMB_UNSUPPORTED:
+ return MEDIA_CONTENT_ERROR_UNSUPPORTED_CONTENT;
+ default:
+ return MEDIA_CONTENT_ERROR_INVALID_OPERATION;
+ }
}
int _content_query_sql(char *query_str)
int media_content_disconnect(void)
{
- int ret = MEDIA_CONTENT_ERROR_NONE;
-
g_mutex_lock(&db_mutex);
media_content_debug("ref count : %d", ref_count);
- if (ref_count > 0) {
- if (db_handle != NULL) {
- ref_count--;
- } else {
- media_content_error("Wrong DB Handle status");
- ret = MEDIA_CONTENT_ERROR_DB_FAILED;
+
+ if (db_handle && ref_count > 0) {
+ if (--ref_count == 0) {
+ media_db_disconnect(db_handle);
+ db_handle = NULL;
}
} else {
- media_content_error("DB_FAILED(0x%08x) database is not connected", MEDIA_CONTENT_ERROR_DB_FAILED);
+ media_content_error("Database is not connected");
g_mutex_unlock(&db_mutex);
return MEDIA_CONTENT_ERROR_DB_FAILED;
}
- if (ref_count == 0) {
- if (db_handle != NULL) {
- ret = media_db_disconnect(db_handle);
- ret = _content_error_capi(ret);
- if (ret == MEDIA_CONTENT_ERROR_NONE) {
- db_handle = NULL;
- } else {
- media_content_error("database disconnect fail");
- ref_count++;
- }
- } else {
- media_content_error("Wrong DB Handle status");
- ret = MEDIA_CONTENT_ERROR_DB_FAILED;
- }
-
- g_mutex_unlock(&db_mutex);
-
- media_content_info("ref count changed to: %d", ref_count);
-
- return ret;
- }
-
g_mutex_unlock(&db_mutex);
media_content_info("ref count changed to: %d", ref_count);
- return ret;
+ return MEDIA_CONTENT_ERROR_NONE;
}
int media_content_scan_file(const char *path)
/* This means this path has to be inserted or refreshed */
folder_path = g_path_get_dirname(repl_path);
ret = _media_util_check_ignore_dir(folder_path, &ignore_dir);
- SAFE_FREE(folder_path);
+ g_free(folder_path);
media_content_retvm_if(ignore_dir == TRUE, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid folder path");
/* check feature */
err = _content_error_capi(result->result);
#ifdef _USE_TVPD_MODE
if (result->request_type != MEDIA_REQUEST_SCAN_COMPLETE &&
- result->request_type != MEDIA_REQUEST_SCAN_PARTIAL) {
+ result->request_type != MEDIA_REQUEST_SCAN_PARTIAL &&
+ result->request_type != MEDIA_RECURSIVE_START) {
if (cb_data && cb_data->callback) {
media_content_debug("begin:User callback is being called now, result=%d", err);
cb_data->callback(err, cb_data->user_data);
complete_phase = MEDIA_CONTENT_SCAN_COMPLETE;
else if (result->request_type == MEDIA_REQUEST_EXTRACT_COMPLETE)
complete_phase = MEDIA_CONTENT_EXTRACT_COMPLETE;
+ else if (result->request_type == MEDIA_RECURSIVE_START)
+ complete_phase = MEDIA_CONTENT_RECURSIVE_START;
if (cb_data && cb_data->callback)
cb_data->callback(err, complete_phase, cb_data->user_data);
media_content_debug("run error");
if ((result->request_type != MEDIA_REQUEST_SCAN_COMPLETE) &&
- (result->request_type != MEDIA_REQUEST_SCAN_PARTIAL))
+ (result->request_type != MEDIA_REQUEST_SCAN_PARTIAL) &&
+ (result->request_type != MEDIA_RECURSIVE_START))
SAFE_FREE(cb_data);
return;
noti_info->user_data = user_data;
ret = media_db_update_subscribe_internal((MediaNotiHandle*)noti_handle, _media_content_db_update_noti_cb, (void *)noti_info);
+ if (ret != MS_MEDIA_ERR_NONE)
+ SAFE_FREE(noti_info);
return _content_error_capi(ret);
}
+#ifdef TIZEN_FEATURE_COMPATIBILITY
+int media_content_set_db_updated_cb(media_content_db_update_cb callback, void *user_data)
+{
+ media_content_warn("DEPRECATION WARNING: media_content_set_db_updated_cb() is removed from 5.0.");
+
+ return MEDIA_CONTENT_ERROR_NONE;
+}
+#endif
+
void __media_content_clear_user_data(void *user_data)
{
media_noti_cb_s *noti_info = user_data;