add new plugin API for counting invalid items before items are deleted
authorYong Yeon Kim <yy9875.kim@samsung.com>
Fri, 5 Apr 2013 02:27:02 +0000 (11:27 +0900)
committerYong Yeon Kim <yy9875.kim@samsung.com>
Fri, 5 Apr 2013 02:27:02 +0000 (11:27 +0900)
include/media-svc.h
packaging/libmedia-service.spec
plugin/media-content-plugin.c
src/common/media-svc-media.c
src/common/media-svc.c
src/include/common/media-svc-media.h

index 61002c7..8cc969e 100755 (executable)
@@ -235,6 +235,8 @@ int media_svc_get_media_type(const char *path, const char *mime_type, media_svc_
 
 int media_svc_send_dir_update_noti(MediaSvcHandle *handle, const char *dir_path);
 
+int media_svc_count_invalid_items_in_folder(MediaSvcHandle *handle, const char *folder_path, int *count);
+
 /** @} */
 
 /**
index 10611c9..3338580 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       libmedia-service
 Summary:    Media information service library for multimedia applications.
-Version: 0.2.32
+Version: 0.2.33
 Release:    1
 Group:      System/Libraries
 License:    Apache License, Version 2.0
index 366c10e..2436b94 100755 (executable)
@@ -702,3 +702,31 @@ int send_dir_update_noti(void * handle, const char *dir_path, char **err_msg)
 
        return MEDIA_SVC_PLUGIN_ERROR_NONE;
 }
+
+int count_delete_items_in_folder(void * handle, const char *folder_path, int *count, char ** err_msg)
+{
+       int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
+
+       if(handle == NULL) {
+               __set_error_message(ERR_HANDLE, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       if(count == NULL) {
+               __set_error_message(ERR_HANDLE, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       if (!STRING_VALID(folder_path)) {
+               __set_error_message(ERR_FOLDER_PATH, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       ret = media_svc_count_invalid_items_in_folder(handle, folder_path, count);
+       if(ret < 0) {
+               __set_error_message(ret, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       return MEDIA_SVC_PLUGIN_ERROR_NONE;
+}
index 321ebec..cf5aafe 100755 (executable)
@@ -777,3 +777,24 @@ int _media_svc_get_noti_info(sqlite3 *handle, const char *path, int update_item,
 
        return MEDIA_INFO_ERROR_NONE;
 }
+
+int _media_svc_count_invalid_folder_items(sqlite3 *handle, const char *folder_path, int *count)
+{
+       int ret = MEDIA_INFO_ERROR_NONE;
+       sqlite3_stmt *sql_stmt = NULL;
+       char *sql = sqlite3_mprintf("SELECT count(*) FROM %s WHERE validity=0 AND path LIKE '%q/%%'",
+                                       MEDIA_SVC_DB_TABLE_MEDIA, folder_path);
+
+       ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
+
+       if (ret != MEDIA_INFO_ERROR_NONE) {
+               media_svc_error("error when __media_svc_count_invalid_folder_records_with_thumbnail. err = [%d]", ret);
+               return ret;
+       }
+
+       *count = sqlite3_column_int(sql_stmt, 0);
+
+       SQLITE3_FINALIZE(sql_stmt);
+
+       return MEDIA_INFO_ERROR_NONE;
+}
\ No newline at end of file
index a95ccd7..eee1936 100755 (executable)
@@ -1161,3 +1161,16 @@ int media_svc_send_dir_update_noti(MediaSvcHandle *handle, const char *dir_path)
 
        return ret;
 }
+
+int media_svc_count_invalid_items_in_folder(MediaSvcHandle *handle, const char *folder_path, int *count)
+{
+       sqlite3 * db_handle = (sqlite3 *)handle;
+
+       media_svc_debug_func();
+
+       media_svc_retvm_if(db_handle == NULL, MEDIA_INFO_ERROR_INVALID_PARAMETER, "Handle is NULL");
+       media_svc_retvm_if(folder_path == NULL, MEDIA_INFO_ERROR_INVALID_PARAMETER, "folder_path is NULL");
+       media_svc_retvm_if(count == NULL, MEDIA_INFO_ERROR_INVALID_PARAMETER, "count is NULL");
+
+       return _media_svc_count_invalid_folder_items(db_handle, folder_path, count);
+}
\ No newline at end of file
index 3508edb..a59ddbc 100755 (executable)
@@ -47,5 +47,6 @@ int _media_svc_list_query_do(sqlite3 *handle, media_svc_query_type_e query_type)
 int _media_svc_get_media_id_by_path(sqlite3 *handle, const char *path, char *media_uuid, int max_length);
 int _media_svc_update_thumbnail_path(sqlite3 *handle, const char *path, const char *thumb_path);
 int _media_svc_get_noti_info(sqlite3 *handle, const char *path, int update_item, media_svc_noti_item **item);
+int _media_svc_count_invalid_folder_items(sqlite3 *handle, const char *folder_path, int *count);
 
 #endif /*_MEDIA_SVC_MEDIA_H_*/