[ACR-1226] deprecate function to remove item from db
[platform/core/api/media-content.git] / include_product / media_info_private.h
index 8a2c6d0..fa9a853 100755 (executable)
@@ -15,8 +15,8 @@
 */
 
 
-#ifndef __TIZEN_MEDIA_INFO_PRIVATE_H__
-#define __TIZEN_MEDIA_INFO_PRIVATE_H__
+#ifndef __TIZEN_CONTENT_MEDIA_INFO_PRIVATE_H__
+#define __TIZEN_CONTENT_MEDIA_INFO_PRIVATE_H__
 
 
 #include <unistd.h>
@@ -32,7 +32,7 @@
 #include <media-util.h>
 #include <errno.h>
 #include <tzplatform_config.h>
-#ifdef _USE_TV_PROFILE
+#ifdef _USE_TVPD_MODE
 #include <media_content_type_product.h>
 #endif
 
@@ -245,7 +245,6 @@ typedef struct {
        char *date_taken;
        char *title;
        char *burst_id;
-       char *weather;
        char *exposure_time;
        double fnumber;
        int iso;
@@ -274,10 +273,7 @@ typedef struct {
        int duration;
        int width;
        int height;
-       int played_count;
        int rotation;
-       time_t played_time;
-       int played_position;
 } video_meta_s;
 
 typedef struct {
@@ -297,9 +293,6 @@ typedef struct {
        int samplerate;
        int channel;
        int duration;
-       int played_count;
-       time_t played_time;
-       int played_position;
 } audio_meta_s;
 
 typedef struct {
@@ -367,13 +360,12 @@ typedef struct {
 
 typedef struct {
        char *storage_id;
-       char *storage_name;
        char *storage_path;
        int storage_type;
 } media_storage_s;
 
 typedef struct {
-       char *face_id;                          /* face uuid */
+       int face_id;                            /* face id */
        char *media_id;                 /* media uuid */
        unsigned int face_rect_x;       /* x position of face */
        unsigned int face_rect_y;       /* y position of face */
@@ -459,7 +451,6 @@ typedef struct {
 } media_thumbnail_cb_s;
 
 typedef struct {
-       media_info_s *handle;
        void *user_data;
        media_face_detection_completed_cb face_completed_cb;
 } media_face_cb_s;
@@ -498,7 +489,6 @@ typedef struct _media_content_scan_cb_data_v2 {
 #define DB_TABLE_PLAYLIST_MAP  "playlist_map"
 #define DB_TABLE_BOOKMARK              "bookmark"
 #define DB_TABLE_STORAGE               "storage"
-#define DB_TABLE_MEDIA_VIEW    "media_view"
 #define DB_TABLE_FACE                  "face"
 #define DB_TABLE_FACE_SCAN_LIST        "face_scan_list"
 #define DB_TABLE_PVR                           "pvr"
@@ -507,6 +497,7 @@ typedef struct _media_content_scan_cb_data_v2 {
 /* DB View */
 #define DB_VIEW_PLAYLIST       "playlist_view"
 #define DB_VIEW_TAG                    "tag_view"
+#define DB_VIEW_MEDIA          "media_view"
 
 /* DB Table Alias */
 #define DB_TABLE_ALIAS_MEDIA                   "m"
@@ -633,7 +624,7 @@ typedef struct _media_content_scan_cb_data_v2 {
 #define DB_FIELD_STORAGE_PATH          "storage_path"
 
 /* DB field for Face */
-#define DB_FIELD_FACE_ID                               "face_uuid"
+#define DB_FIELD_FACE_ID                               "face_id"
 #define DB_FIELD_FACE_TAG                      "face_tag"
 
 /* DB field for PVR*/
@@ -691,22 +682,20 @@ typedef struct _media_content_scan_cb_data_v2 {
 /* DB Query Keyword */
 #define QUERY_KEYWORD_AND "AND"
 #define QUERY_KEYWORD_OR "OR"
-#define QUERY_KEYWORD_ORDER_BY "ORDER BY"
+#define QUERY_KEYWORD_ORDER_BY "ORDER BY "
 #define QUERY_KEYWORD_LIMIT "limit"
 #define QUERY_KEYWORD_DESC "DESC"
 #define QUERY_KEYWORD_SPACE " "
 #define QUERY_KEYWORD_OPEN_BRACKET "("
 #define QUERY_KEYWORD_BRACKET ")"
+#define QUERY_KEYWORD_COLLATE "COLLATE "
 
 /* DB TABLE JOIN */
 /*#define FOLDER_MEDIA_JOIN                                    "("DB_TABLE_FOLDER" AS f LEFT OUTER JOIN '%s' AS m ON f.folder_uuid=m.folder_uuid AND m.validity=1) WHERE f.storage_uuid IN (SELECT storage_uuid FROM "DB_TABLE_STORAGE" WHERE validity=1) " */
 #define FOLDER_MEDIA_JOIN                                      "("DB_TABLE_FOLDER" AS f LEFT OUTER JOIN '%s' AS m ON f.folder_uuid=m.folder_uuid AND m.validity=1) WHERE f.validity=1 "
-#define BOOKMARK_MEDIA_JOIN                            "("DB_TABLE_BOOKMARK" AS b INNER JOIN '%s' AS m \
-                                                                                       ON (b.media_uuid = m.media_uuid)) WHERE m.validity=1"
-#define ALBUM_MEDIA_JOIN                                       "("DB_TABLE_ALBUM" AS a INNER JOIN '%s' AS m \
-                                                                                       ON (a.album_id = m.album_id)) WHERE m.validity=1"
-#define FACE_MEDIA_JOIN                                                "("DB_TABLE_FACE" AS fa INNER JOIN '%s' AS m \
-                                                                                               ON (fa.media_uuid = m.media_uuid)) WHERE m.validity=1"
+#define BOOKMARK_MEDIA_JOIN                            "("DB_TABLE_BOOKMARK" AS b INNER JOIN '%s' AS m ON (b.media_uuid = m.media_uuid)) WHERE m.validity=1"
+#define ALBUM_MEDIA_JOIN                                       "("DB_TABLE_ALBUM" AS a INNER JOIN '%s' AS m ON (a.album_id = m.album_id)) WHERE m.validity=1"
+#define FACE_MEDIA_JOIN                                                "("DB_TABLE_FACE" AS fa INNER JOIN '%s' AS m ON (fa.media_uuid = m.media_uuid)) WHERE m.validity=1"
 
 /* Get Group info */
 #define SELECT_MEDIA_GROUP_AND_COUNT           "SELECT %s, COUNT(*) FROM '%s' WHERE validity=1 "
@@ -791,8 +780,7 @@ typedef struct _media_content_scan_cb_data_v2 {
 #define UPDATE_BOOKMARK_FROM_BOOKMARK          "UPDATE "DB_TABLE_BOOKMARK" SET name=%Q WHERE bookmark_id=%d;"
 
 /* Update Meta*/
-#define UPDATE_AV_META_FROM_MEDIA      "UPDATE '%s' SET played_count=%d, last_played_time=%d, last_played_position=%d WHERE media_uuid='%q'"
-#define UPDATE_IMAGE_META_FROM_MEDIA   "UPDATE '%s' SET orientation=%d, weather=%Q WHERE media_uuid='%q'"
+#define UPDATE_IMAGE_META_FROM_MEDIA   "UPDATE '%s' SET orientation=%d WHERE media_uuid='%q'"
 
 #define UPDATE_VIDEO_MM_DATA_FROM_MEDIA                "UPDATE '%s' SET bitrate=%d, duration=%d, width=%d, height=%d WHERE media_uuid='%q'"
 #define UPDATE_AUDIO_MM_DATA_FROM_MEDIA                "UPDATE '%s' SET duration=%d, bitrate=%d, bitpersample=%d, samplerate=%d, channel=%d WHERE media_uuid='%q'"
@@ -811,30 +799,36 @@ typedef struct _media_content_scan_cb_data_v2 {
 #define SELECT_MEDIA_FROM_STORAGE              "SELECT "MEDIA_INFO_ITEM" FROM '%s' WHERE validity=1 AND storage_uuid='%s'"
 #define SELECT_MEDIA_FROM_TAG                          "SELECT "MEDIA_INFO_ITEM" FROM '%s' WHERE media_uuid IN (SELECT media_uuid FROM "DB_TABLE_TAG_MAP" WHERE tag_id=%d) AND validity=1"
 #define SELECT_MEDIA_FROM_PLAYLIST             "SELECT "MEDIA_INFO_ITEM" FROM '%s' WHERE media_uuid IN (SELECT media_uuid FROM "DB_TABLE_PLAYLIST_MAP" WHERE playlist_id=%d) AND validity=1"
-#define SELECT_MEDIA_PATH_BY_ID                        "SELECT path FROM "DB_TABLE_MEDIA_VIEW" WHERE media_uuid='%q'"
-#define SELECT_MEDIA_STORAGE_ID_BY_ID          "SELECT storage_uuid FROM "DB_TABLE_MEDIA_VIEW" WHERE media_uuid='%q'"
+#define SELECT_MEDIA_PATH_BY_ID                        "SELECT path FROM "DB_VIEW_MEDIA" WHERE media_uuid='%q'"
+#define SELECT_MEDIA_STORAGE_ID_BY_ID          "SELECT storage_uuid FROM "DB_VIEW_MEDIA" WHERE media_uuid='%q'"
 
 /* Delete */
-#define DELETE_MEDIA_FROM_MEDIA_BATCH  "DELETE FROM  '%s' WHERE (%s"
+#define DELETE_MEDIA_FROM_MEDIA_BATCH  "DELETE FROM  '%s' WHERE %s AND storage_type = %d"
 #define DELETE_PLAYLIST_FROM_PLAYLIST          "DELETE FROM "DB_TABLE_PLAYLIST" WHERE playlist_id=%d"
 #define DELETE_TAG_FROM_TAG                            "DELETE FROM "DB_TABLE_TAG" WHERE tag_id=%d"
 #define DELETE_BOOKMARK_FROM_BOOKMARK  "DELETE FROM "DB_TABLE_BOOKMARK" WHERE bookmark_id=%d"
 
+/*For batch remove*/
+#define SELECT_STORAGE_BY_FILTER       "SELECT DISTINCT storage_uuid, storage_type FROM "DB_VIEW_MEDIA" WHERE %s"
+#define SELECT_THUMBNAIL_BY_FILTER     "SELECT DISTINCT thumbnail_path FROM '%s' WHERE %s AND storage_type = %d"
+
 /* Storage*/
 #define SELECT_STORAGE_COUNT                           "SELECT COUNT(*) FROM "DB_TABLE_STORAGE" WHERE validity=1"
-#define SELECT_STORAGE_LIST                                    "SELECT * FROM "DB_TABLE_STORAGE" WHERE validity=1"
-#define SELECT_STORAGE_INFO_FROM_STORAGE       "SELECT * FROM "DB_TABLE_STORAGE" WHERE validity=1 AND storage_uuid='%s'"
+#define SELECT_STORAGE_LIST                                    "SELECT storage_uuid, storage_path, storage_type FROM "DB_TABLE_STORAGE" WHERE validity=1"
+#define SELECT_STORAGE_INFO_FROM_STORAGE       "SELECT storage_uuid, storage_path, storage_type FROM "DB_TABLE_STORAGE" WHERE validity=1 AND storage_uuid='%s'"
 
 /* Face */
-#define DELETE_FACE_FROM_FACE                  "DELETE FROM "DB_TABLE_FACE" WHERE face_uuid='%q'"
-#define INSERT_FACE_TO_FACE                            "INSERT INTO "DB_TABLE_FACE" (face_uuid, media_uuid, face_rect_x , face_rect_y, face_rect_w, face_rect_h, orientation, face_tag) VALUES ('%q', '%q', %d, %d, %d, %d, %d, %Q);"
-#define UPDATE_FACE_TO_FACE                    "UPDATE "DB_TABLE_FACE" SET face_rect_x=%d, face_rect_y=%d, face_rect_w=%d, face_rect_h=%d, orientation=%d, face_tag=%Q WHERE face_uuid='%q'"
-#define SELECT_MEDIA_COUNT_FROM_MEDIA_BY_ID            "SELECT COUNT(*) FROM "DB_TABLE_MEDIA_VIEW" WHERE media_uuid='%q' AND validity=1"
+#define DELETE_FACE_FROM_FACE                  "DELETE FROM "DB_TABLE_FACE" WHERE face_id=%d"
+#define INSERT_FACE_TO_FACE                            "INSERT INTO "DB_TABLE_FACE" (media_uuid, face_rect_x , face_rect_y, face_rect_w, face_rect_h, orientation, face_tag) VALUES ('%q', %d, %d, %d, %d, %d, %Q);"
+#define UPDATE_FACE_TO_FACE                    "UPDATE "DB_TABLE_FACE" SET face_rect_x=%d, face_rect_y=%d, face_rect_w=%d, face_rect_h=%d, orientation=%d, face_tag=%Q WHERE face_id=%d"
+#define SELECT_MEDIA_COUNT_FROM_MEDIA_BY_ID            "SELECT COUNT(*) FROM "DB_VIEW_MEDIA" WHERE media_uuid='%q' AND validity=1"
 #define SELECT_FACE_COUNT                                      "SELECT COUNT(*) FROM "FACE_MEDIA_JOIN
 #define SELECT_FACE_COUNT_BY_MEDIA_ID          "SELECT COUNT(*) FROM "FACE_MEDIA_JOIN" AND fa.media_uuid='%s'"
-#define SELECT_FACE_LIST                                               "SELECT fa.face_uuid, fa.media_uuid, fa.face_rect_x, fa.face_rect_y, fa.face_rect_w, fa.face_rect_h, fa.orientation, fa.face_tag FROM "FACE_MEDIA_JOIN
-#define SELECT_FACE_LIST_BY_MEDIA_ID           "SELECT fa.face_uuid, fa.media_uuid, fa.face_rect_x, fa.face_rect_y, fa.face_rect_w, fa.face_rect_h, fa.orientation, fa.face_tag FROM "FACE_MEDIA_JOIN" AND fa.media_uuid='%s'"
-#define SELECT_FACE_PATH_FROM_MEDIA            "SELECT path FROM "DB_TABLE_MEDIA_VIEW" media_uuid='%s'"
+#define SELECT_FACE_LIST                                               "SELECT fa.face_id, fa.media_uuid, fa.face_rect_x, fa.face_rect_y, fa.face_rect_w, fa.face_rect_h, fa.orientation, fa.face_tag FROM "FACE_MEDIA_JOIN
+#define SELECT_FACE_LIST_BY_MEDIA_ID           "SELECT fa.face_id, fa.media_uuid, fa.face_rect_x, fa.face_rect_y, fa.face_rect_w, fa.face_rect_h, fa.orientation, fa.face_tag FROM "FACE_MEDIA_JOIN" AND fa.media_uuid='%s'"
+#define SELECT_FACE_PATH_FROM_MEDIA            "SELECT path FROM "DB_VIEW_MEDIA" media_uuid='%s'"
+#define UPDATE_MEDIA_INFO_IN_FACE_SCAN_LIST    "UPDATE "DB_TABLE_FACE_SCAN_LIST" SET modified_time = 0 WHERE media_uuid IN (SELECT media_uuid FROM "DB_TABLE_FACE" WHERE face_id=%d)"
+#define SELECT_FACE_ID                 "SELECT face_id FROM "DB_TABLE_FACE" WHERE media_uuid='%q' AND face_rect_x=%d AND face_rect_y=%d AND face_rect_w=%d AND face_rect_h=%d AND orientation=%d"
 
 #define DEFAULT_MEDIA_STORAGE_ID                       "media"
 
@@ -889,6 +883,7 @@ int _content_query_prepare(sqlite3_stmt **stmt, char *select_query, char *condit
 int _content_error_capi(int type, int cotent_error);
 int _content_query_sql(char *query_str);
 MediaSvcHandle* _content_get_db_handle(void);
+uid_t _content_get_uid(void);
 attribute_h _content_get_attirbute_handle(void);
 attribute_h _content_get_alias_attirbute_handle(void);
 int _media_info_get_media_info_from_db(const char *path, const char *storage_id, media_info_h media);
@@ -924,97 +919,11 @@ int _media_db_get_pvr_group_item(const char *group_name, filter_h filter, media_
 int _media_db_get_uhd(filter_h filter, media_uhd_cb callback, void *user_data);
 void _media_uhd_item_get_detail(sqlite3_stmt* stmt, media_uhd_h uhd);
 
-/**
- * @internal
- * @brief Creates a media filter attribute handle.
- * @details This function creates a media filter attribute handle. The handle can be
- * used to convert to attributes of database from attributes of user.
- * @remarks The @a handle must be released with media_filter_attribute_destory() by you.
- * @param[out] filter A handle to media filter attribute
- * @return 0 on success, otherwise a negative error value.
- * @retval #MEDIA_CONTENT_ERROR_NONE Successful
- * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
- * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
- * @see media_filter_attribute_destory()
- *
- */
 int _media_filter_attribute_create(attribute_h *attr);
-
-/**
- * @internal
- * @brief Add the attributes to the handle.
- * @details This function add the attribute to handle.
- * @param[in] filter The handle to media filter attribute
- * @param[in] user_attr The user attribute
- * @param[in] platform_attr The platform attribute
- * @return 0 on success, otherwise a negative error value.
- * @retval #MEDIA_CONTENT_ERROR_NONE Successful
- * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
- * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
- * @see media_filter_attribute_remove()
- *
- */
 int _media_filter_attribute_add(attribute_h atrr, const char *user_attr, const char *platform_attr);
-
-/**
- * @internal
- * @brief Destroys a media filter attribute handle.
- * @details The function frees all resources related to the media filter attribute handle. The filter attribute
- * handle no longer can be used to perform any operation. A new handle
- * has to be created before the next usage.
- *
- * @param[in] filter The handle to media filter attribute
- * @return 0 on success, otherwise a negative error value.
- * @retval #MEDIA_CONTENT_ERROR_NONE Successful
- * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
- * @see media_filter_create()
- *
- */
 int _media_filter_attribute_destory(attribute_h attr);
-
-/**
- * @internal
- * @brief Replace to platform attributes from user attributes.
- * @details This function replace to platform attributes from user attributes to generate the WHERE clause
- * @param[in] filter The handle to media filter attribute
- * @param[in] user_attr The user attribute
- * @param[in] platform_attr The platform attribute
- * @return 0 on success, otherwise a negative error value.
- * @retval #MEDIA_CONTENT_ERROR_NONE Successful
- * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
- * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
- * @see media_filter_attribute_create()
- * @see media_filter_attribute_destory()
- *
- */
-int _media_filter_attribute_generate(attribute_h attr, char *condition, media_content_collation_e collate_type, char **generated_condition);
-
-int _media_filter_attribute_generate_with_full_query(attribute_h attr, filter_h filter, char **generated_condition);
-
-
-/**
- * @internal
- * @brief Replace to platform attributes from user attributes.
- * @details This function replace to platform attributes from user attributes to generate the WHERE clause
- * @param[in] filter The handle to media filter attribute
- * @param[in] attr The attribute
- * @param[in] generated_option The handle to generated option
- * @return 0 on success, otherwise a negative error value.
- * @retval #MEDIA_CONTENT_ERROR_NONE Successful
- * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #MEDIA_CONTENT_ERROR_DB_FAILED Filed DB
- * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
- * @see media_filter_attribute_create()
- * @see media_filter_attribute_destory()
- *
- */
-
+int _media_filter_attribute_generate(attribute_h attr, filter_h filter, char **generated_condition);
 int _media_filter_attribute_option_generate(attribute_h attr, filter_h filter, char **generated_option);
-
 int _media_filter_attribute_option_generate_with_full_query(attribute_h attr, filter_h filter, char **generated_option);
 
 GMutex* _content_get_db_mutex(void);
@@ -1087,4 +996,4 @@ GMutex* _content_get_db_mutex(void);
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
-#endif /*__TIZEN_MEDIA_INFO_PRIVATE_H__*/
+#endif /*__TIZEN_CONTENT_MEDIA_INFO_PRIVATE_H__*/