#define LOG_TAG "CAPI_CONTENT_MEDIA_CONTENT"
-#define SAFE_STRLCPY(dst, src, n) ((g_strlcpy(dst, src, n) < n) ? TRUE : FALSE)
+#define SAFE_STRLCPY(dst, src, n) g_strlcpy(dst, src, n);
#define SAFE_STRLCAT(dst, src, n) g_strlcat(dst, src, n);
#define SAFE_FREE(src) {if (src) {free(src); src = NULL; } }
-#define SAFE_G_FREE(src) {if (src) {g_free(src); src = NULL; } }
#define STRING_VALID(str) ((str != NULL && strlen(str) > 0) ? TRUE : FALSE)
#define SQLITE3_FINALIZE(x) {if (x != NULL) sqlite3_finalize(x); }
#define SQLITE3_SAFE_FREE(x) {if (x != NULL) {sqlite3_free(x); x = NULL; } }
#define MAX_QUERY_SIZE 4096
#define MAX_PATH_LEN 4096
#define DEFAULT_QUERY_SIZE 1024
-#define COLLATE_STR_SIZE 32
#define MEDIA_CONTENT_UUID_SIZE 36
#define BATCH_REQUEST_MAX 300
-#define EMPTY_STR ""
-
typedef enum {
MEDIA_INFO_UUID = 0,
MEDIA_INFO_PATH,
MEDIA_INFO_SAMPLERATE,
MEDIA_INFO_CHANNEL,
MEDIA_INFO_TIMELINE,
- MEDIA_INFO_SYNC_STATUS,
MEDIA_INFO_STORAGE_UUID,
MEDIA_INFO_IS_360,
MEDIA_INFO_ITEM_MAX,
} media_info_item_e;
typedef enum {
- MEDIA_CONTENT_TYPE = 0,
- MEDIA_THUMBNAIL_TYPE,
- MEDIA_REGISTER_TYPE
-} media_info_error_type_e;
-
-typedef enum {
MEDIA_TAG_ADD,
MEDIA_TAG_REMOVE,
MEDIA_TAG_UPDATE_TAG_NAME,
int width;
int height;
char *date_taken;
- char *title;
char *exposure_time;
double fnumber;
int iso;
typedef struct {
char *media_id;
- char *title;
char *album;
char *artist;
char *album_artist;
typedef struct {
char *media_id;
- char *title;
char *album;
char *artist;
char *album_artist;
int is_drm;
int storage_type;
char *storage_uuid;
- int sync_status;
unsigned int request_id;
unsigned int face_request_id;
int is_360;
char *face_tag; /* face tag */
} media_face_s;
-typedef struct _attribute_map_s {
- GHashTable *attr_map;
-} attribute_s;
-
typedef struct {
media_info_s *handle;
void *user_data;
void *user_data;
} media_noti_cb_s;
-typedef struct attribute_s *attribute_h;
-
-
typedef struct _media_content_cb_data {
media_scan_completed_cb callback;
void *user_data;
/* 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"
-#define DB_TABLE_ALIAS_FOLDER "f"
/* DB field for media */
-#define DB_FIELD_MEDIA_ID "media_uuid"
-#define DB_FIELD_MEDIA_PATH "path"
-#define DB_FIELD_MEDIA_DISPLAY_NAME "file_name"
-#define DB_FIELD_MEDIA_TYPE "media_type"
-#define DB_FIELD_MEDIA_MIME_TYPE "mime_type"
-#define DB_FIELD_MEDIA_SIZE "size"
-#define DB_FIELD_MEDIA_ADDED_TIME "added_time"
-#define DB_FIELD_MEDIA_MODIFIED_TIME "modified_time"
-#define DB_FIELD_MEDIA_TIMELINE "timeline"
-#define DB_FIELD_MEDIA_THUMBNAIL_PATH "thumbnail_path"
-#define DB_FIELD_MEDIA_TITLE "title"
-#define DB_FIELD_MEDIA_ALBUM "album"
-#define DB_FIELD_MEDIA_ARTIST "artist"
-#define DB_FIELD_MEDIA_ALBUM_ARTIST "album_artist"
-#define DB_FIELD_MEDIA_GENRE "genre"
-#define DB_FIELD_MEDIA_COMPOSER "composer"
-#define DB_FIELD_MEDIA_YEAR "year"
-#define DB_FIELD_MEDIA_RECORDED_DATE "recorded_date"
-#define DB_FIELD_MEDIA_COPYRIGHT "copyright"
-#define DB_FIELD_MEDIA_TRACK_NUM "track_num"
-#define DB_FIELD_MEDIA_DESCRIPTION "description"
-#define DB_FIELD_MEDIA_BITRATE "bitrate"
-#define DB_FIELD_MEDIA_BITPERSAMPLE "bitpersample"
-#define DB_FIELD_MEDIA_SAMPLERATE "samplerate"
-#define DB_FIELD_MEDIA_CHANNEL "channel"
-#define DB_FIELD_MEDIA_DURATION "duration"
-#define DB_FIELD_MEDIA_LONGITUDE "longitude"
-#define DB_FIELD_MEDIA_LATITUDE "latitude"
-#define DB_FIELD_MEDIA_ALTITUDE "altitude"
-#define DB_FIELD_MEDIA_WIDTH "width"
-#define DB_FIELD_MEDIA_HEIGHT "height"
-#define DB_FIELD_MEDIA_DATETAKEN "datetaken"
-#define DB_FIELD_MEDIA_ORIENTATION "orientation"
-#define DB_FIELD_MEDIA_RATING "rating"
-#define DB_FIELD_MEDIA_FAVOURITE "favourite"
-#define DB_FIELD_MEDIA_IS_DRM "is_drm"
-#define DB_FIELD_MEDIA_STORAGE_TYPE "storage_type"
-
-#define DB_FIELD_MEDIA_FILE_NAME_PINYIN "file_name_pinyin"
-#define DB_FIELD_MEDIA_TITLE_PINYIN "title_pinyin"
-#define DB_FIELD_MEDIA_ALBUM_PINYIN "album_pinyin"
-#define DB_FIELD_MEDIA_ARTIST_PINYIN "artist_pinyin"
-#define DB_FIELD_MEDIA_ALBUM_ARTIST_PINYIN "album_artist_pinyin"
-#define DB_FIELD_MEDIA_GENRE_PINYIN "genre_pinyin"
-#define DB_FIELD_MEDIA_COMPOSER_PINYIN "composer_pinyin"
-#define DB_FIELD_MEDIA_COPYRIGHT_PINYIN "copyright_pinyin"
-#define DB_FIELD_MEDIA_DESCRIPTION_PINYIN "description_pinyin"
-#define DB_FIELD_MEDIA_360 "is_360"
-
-/* DB field for folder */
-#define DB_FIELD_FOLDER_ID "folder_uuid"
-#define DB_FIELD_FOLDER_PATH "folder_path"
-#define DB_FIELD_FOLDER_NAME "name"
-#define DB_FIELD_FOLDER_STORAGE_TYPE "storage_type"
-#define DB_FIELD_FOLDER_NAME_PINYIN "name_pinyin"
-
-/* DB field for Storage*/
-#define DB_FIELD_STORAGE_ID "storage_uuid"
-#define DB_FIELD_STORAGE_PATH "storage_path"
-
-/* DB Query Keyword */
-#define QUERY_KEYWORD_AND "AND"
-#define QUERY_KEYWORD_OR "OR"
-#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 "
+#define DB_FIELD_MEDIA_DISPLAY_NAME "media_display_name"
+#define DB_FIELD_MEDIA_TYPE "media_type"
+#define DB_FIELD_MEDIA_MIME_TYPE "media_mime_type"
+#define DB_FIELD_MEDIA_SIZE "media_size"
+#define DB_FIELD_MEDIA_ADDED_TIME "media_added_time"
+#define DB_FIELD_MEDIA_MODIFIED_TIME "media_modified_time"
+#define DB_FIELD_MEDIA_TITLE "media_title"
+#define DB_FIELD_MEDIA_ALBUM "media_album"
+#define DB_FIELD_MEDIA_ARTIST "media_artist"
+#define DB_FIELD_MEDIA_ALBUM_ARTIST "media_album_artist"
+#define DB_FIELD_MEDIA_GENRE "media_genre"
+#define DB_FIELD_MEDIA_COMPOSER "media_composer"
+#define DB_FIELD_MEDIA_YEAR "media_year"
+#define DB_FIELD_MEDIA_RECORDED_DATE "media_recorded_date"
+#define DB_FIELD_MEDIA_COPYRIGHT "media_copyright"
+#define DB_FIELD_MEDIA_TRACK_NUM "media_track_num"
+#define DB_FIELD_MEDIA_DESCRIPTION "media_description"
+#define DB_FIELD_MEDIA_RATING "media_rating"
+#define DB_FIELD_MEDIA_LONGITUDE "media_longitude"
+#define DB_FIELD_MEDIA_LATITUDE "media_latitude"
+#define DB_FIELD_MEDIA_ALTITUDE "media_altitude"
/* DB TABLE JOIN */
-#define FOLDER_MEDIA_JOIN DB_TABLE_FOLDER" NATURAL LEFT OUTER JOIN '%s' WHERE validity=1 "
-#define BOOKMARK_MEDIA_JOIN "("DB_TABLE_BOOKMARK" AS b INNER JOIN '%s' AS m ON (b.media_uuid = m.media_uuid)) WHERE validity=1"
-#define ALBUM_MEDIA_JOIN DB_TABLE_ALBUM" NATURAL JOIN '%s' WHERE validity=1 "
-#define FACE_MEDIA_JOIN "("DB_TABLE_FACE" AS fa INNER JOIN '%s' AS m ON (fa.media_uuid = m.media_uuid)) WHERE validity=1"
+#define FOLDER_MEDIA_JOIN DB_TABLE_FOLDER" NATURAL LEFT OUTER JOIN "DB_TABLE_MEDIA" WHERE validity IN (1, 2) "
+#define BOOKMARK_MEDIA_JOIN DB_TABLE_BOOKMARK" NATURAL JOIN "DB_TABLE_MEDIA" WHERE validity IN (1, 2) "
+#define ALBUM_MEDIA_JOIN DB_TABLE_ALBUM" NATURAL JOIN "DB_TABLE_MEDIA" WHERE validity IN (1, 2) "
+#define FACE_MEDIA_JOIN DB_TABLE_FACE" NATURAL JOIN "DB_TABLE_MEDIA" WHERE validity IN (1, 2) "
/* Get Group List */
#define SELECT_ALBUM_LIST "SELECT DISTINCT album_id, name, artist, album_art FROM "ALBUM_MEDIA_JOIN
-#define SELECT_MEDIA_GROUP_LIST "SELECT DISTINCT %s FROM '%s' WHERE validity=1 "
+#define SELECT_ALBUM_LIST_BY_STORAGE_ID SELECT_ALBUM_LIST"AND storage_uuid='%s' "
+#define SELECT_MEDIA_GROUP_LIST "SELECT DISTINCT %s FROM "DB_TABLE_MEDIA" WHERE validity IN (1, 2) "
+#define SELECT_MEDIA_GROUP_LIST_BY_STORAGE_ID SELECT_MEDIA_GROUP_LIST"AND storage_uuid='%s' "
-#define SELECT_FOLDER_LIST "SELECT DISTINCT folder_uuid, folder_path, name, storage_type, storage_uuid FROM "FOLDER_MEDIA_JOIN
+#define SELECT_FOLDER_LIST "SELECT DISTINCT folder_id, folder_path, folder_name, folder_storage_type, storage_uuid FROM "FOLDER_MEDIA_JOIN
#define SELECT_FOLDER_LIST_BY_STORAGE_ID SELECT_FOLDER_LIST"AND storage_uuid='%s' "
#define SELECT_TAG_LIST "SELECT DISTINCT tag_id, tag_name FROM "DB_VIEW_TAG" WHERE 1 "
#define SELECT_PLAYLIST_LIST "SELECT DISTINCT playlist_id, playlist_name, p_thumbnail_path FROM "DB_VIEW_PLAYLIST" WHERE 1 "
/* Get Group Count */
#define SELECT_ALBUM_COUNT "SELECT COUNT(DISTINCT album_id) FROM "ALBUM_MEDIA_JOIN
-#define SELECT_FOLDER_COUNT "SELECT COUNT(DISTINCT folder_uuid) FROM "FOLDER_MEDIA_JOIN
+#define SELECT_ALBUM_COUNT_BY_STORAGE_ID SELECT_ALBUM_COUNT"AND storage_uuid='%s' "
+#define SELECT_FOLDER_COUNT "SELECT COUNT(DISTINCT folder_id) FROM "FOLDER_MEDIA_JOIN
#define SELECT_FOLDER_COUNT_BY_STORAGE_ID SELECT_FOLDER_COUNT"AND storage_uuid='%s' "
#define SELECT_TAG_COUNT "SELECT COUNT(DISTINCT tag_id) FROM "DB_VIEW_TAG" WHERE 1 "
#define SELECT_PLAYLIST_COUNT "SELECT COUNT(DISTINCT playlist_id) FROM "DB_VIEW_PLAYLIST" WHERE 1 "
#define SELECT_BOOKMARK_COUNT "SELECT COUNT(*) FROM "BOOKMARK_MEDIA_JOIN
-#define SELECT_MEDIA_GROUP_COUNT "SELECT COUNT(*) FROM ("SELECT_MEDIA_GROUP_LIST
+#define SELECT_BOOKMARK_COUNT_BY_STORAGE_ID SELECT_BOOKMARK_COUNT"AND storage_uuid='%s' "
+#define SELECT_MEDIA_GROUP_COUNT "SELECT COUNT(DISTINCT %s) + COUNT(DISTINCT CASE WHEN %s IS NULL THEN 1 END) AS COUNT FROM "DB_TABLE_MEDIA" WHERE validity IN (1, 2) "
+#define SELECT_MEDIA_GROUP_COUNT_BY_STORAGE_ID SELECT_MEDIA_GROUP_COUNT"AND storage_uuid='%s' "
/*count(distinct x) count only non-null values, but select distinct X returns include null. so sync the result of count and list, don't use count(distinct x)*/
/* Get Media Count of Group */
-#define SELECT_MEDIA_COUNT_FROM_MEDIA "SELECT COUNT(*) FROM ("SELECT_MEDIA_ITEM /*to apply limit condition. "SELECT COUNT(*) FROM "DB_TABLE_MEDIA" WHERE validity=1" */
-#define SELECT_MEDIA_COUNT_FROM_MEDIA_SIMPLE "SELECT COUNT(*) FROM '%s' WHERE validity=1 "
-#define SELECT_MEDIA_COUNT_FROM_ALBUM "SELECT COUNT(*) FROM '%s' WHERE validity=1 AND album_id='%d'"
+#define SELECT_MEDIA_COUNT_FROM_MEDIA "SELECT COUNT(*) FROM (SELECT media_id FROM "DB_TABLE_MEDIA" WHERE validity IN (1, 2) "
+#define SELECT_MEDIA_COUNT_FROM_MEDIA_BY_STORAGE_ID SELECT_MEDIA_COUNT_FROM_MEDIA"AND storage_uuid='%s' "
+#define SELECT_MEDIA_COUNT_FROM_MEDIA_SIMPLE "SELECT COUNT(*) FROM "DB_TABLE_MEDIA" WHERE validity IN (1, 2) "
+#define SELECT_MEDIA_COUNT_FROM_MEDIA_SIMPLE_BY_STORAGE_ID SELECT_MEDIA_COUNT_FROM_MEDIA_SIMPLE"AND storage_uuid='%s' "
+#define SELECT_MEDIA_COUNT_FROM_ALBUM "SELECT COUNT(*) FROM "DB_TABLE_MEDIA" WHERE validity IN (1, 2) AND album_id='%d' "
+#define SELECT_MEDIA_COUNT_FROM_ALBUM_BY_STORAGE_ID SELECT_MEDIA_COUNT_FROM_ALBUM"AND storage_uuid='%s' "
#define SELECT_MEDIA_COUNT_FROM_GROUP "SELECT COUNT(*) FROM ("SELECT_MEDIA_FROM_GROUP /*to apply limit condition. */
+#define SELECT_MEDIA_COUNT_FROM_GROUP_BY_STORAGE_ID "SELECT COUNT(*) FROM ("SELECT_MEDIA_FROM_GROUP_BY_STORAGE_ID /*to apply limit condition. */
#define SELECT_MEDIA_COUNT_FROM_GROUP_NULL "SELECT COUNT(*) FROM ("SELECT_MEDIA_FROM_GROUP_NULL /* to apply limit condition. */
-#define SELECT_MEDIA_COUNT_FROM_FOLDER "SELECT COUNT(*) FROM '%s' WHERE validity=1 AND folder_uuid='%q'"
-#define SELECT_MEDIA_COUNT_FROM_STORAGE "SELECT COUNT(*) FROM '%s' WHERE validity=1 AND storage_uuid='%q'"
+#define SELECT_MEDIA_COUNT_FROM_GROUP_NULL_BY_STORAGE_ID "SELECT COUNT(*) FROM ("SELECT_MEDIA_FROM_GROUP_NULL_BY_STORAGE_ID /* to apply limit condition. */
+#define SELECT_MEDIA_COUNT_FROM_FOLDER "SELECT COUNT(*) FROM "DB_TABLE_MEDIA" WHERE validity IN (1, 2) AND folder_id='%q'"
+#define SELECT_MEDIA_COUNT_FROM_FOLDER_BY_STORAGE_ID SELECT_MEDIA_COUNT_FROM_FOLDER" AND storage_uuid='%s' "
+#define SELECT_MEDIA_COUNT_FROM_STORAGE "SELECT COUNT(*) FROM "DB_TABLE_MEDIA" WHERE validity IN (1, 2) AND storage_uuid='%q'"
#define SELECT_MEDIA_COUNT_FROM_TAG "SELECT COUNT(*) FROM "DB_VIEW_TAG" WHERE (tag_id=%d AND tag_media_count>0) "
#define SELECT_MEDIA_COUNT_FROM_PLAYLIST "SELECT COUNT(*) FROM "DB_VIEW_PLAYLIST" WHERE (playlist_id=%d and playlist_media_count>0) "
/* Get Group Info by Group ID*/
-#define SELECT_ALBUM_FROM_ALBUM "SELECT * FROM "DB_TABLE_ALBUM" WHERE album_id=%d"
-#define SELECT_FOLDER_FROM_FOLDER "SELECT folder_uuid, folder_path, name, storage_type, storage_uuid FROM "DB_TABLE_FOLDER" WHERE folder_uuid='%s'"
+#define SELECT_ALBUM_FROM_ALBUM "SELECT name, artist, album_art FROM "DB_TABLE_ALBUM" WHERE album_id=%d"
+#define SELECT_FOLDER_FROM_FOLDER "SELECT folder_path, folder_name, folder_storage_type, storage_uuid FROM "DB_TABLE_FOLDER" WHERE folder_id='%s'"
#define SELECT_PLAYLIST_FROM_PLAYLIST "SELECT playlist_name, thumbnail_path FROM "DB_TABLE_PLAYLIST" WHERE playlist_id=%d"
#define SELECT_TAG_FROM_TAG "SELECT tag_name FROM "DB_TABLE_TAG" WHERE tag_id=%d"
#define SELECT_TAG_BY_NAME "SELECT tag_id FROM "DB_TABLE_TAG" WHERE tag_name='%q'"
/* Tag info*/
#define INSERT_TAG_TO_TAG "INSERT INTO "DB_TABLE_TAG" (tag_name) VALUES (%Q)"
-#define REMOVE_TAG_ITEM_FROM_TAG_MAP "DELETE FROM "DB_TABLE_TAG_MAP" WHERE tag_id=%d AND media_uuid='%q';"
+#define REMOVE_TAG_ITEM_FROM_TAG_MAP "DELETE FROM "DB_TABLE_TAG_MAP" WHERE tag_id=%d AND media_id='%q';"
#define UPDATE_TAG_NAME_FROM_TAG "UPDATE "DB_TABLE_TAG" SET tag_name='%q' WHERE tag_id=%d;"
-#define SELECT_TAG_COUNT_BY_MEDIA_ID "SELECT COUNT(*) FROM "DB_VIEW_TAG" WHERE media_uuid = '%s'"
-#define SELECT_TAG_LIST_BY_MEDIA_ID "SELECT tag_id, tag_name FROM "DB_VIEW_TAG" WHERE media_uuid = '%s'"
+#define SELECT_TAG_COUNT_BY_MEDIA_ID "SELECT COUNT(*) FROM "DB_VIEW_TAG" WHERE media_id = '%s'"
+#define SELECT_TAG_LIST_BY_MEDIA_ID "SELECT tag_id, tag_name FROM "DB_VIEW_TAG" WHERE media_id = '%s' "
/* Get Media list of Group */
-#define MEDIA_INFO_ITEM "media_uuid, path, file_name, media_type, mime_type, size, added_time, modified_time, thumbnail_path, description, \
- rating, favourite, is_drm, storage_type, longitude, latitude, altitude, exposure_time, fnumber, iso, \
- model, width, height, datetaken, orientation, title, album, artist, album_artist, genre, \
- composer, year, recorded_date, copyright, track_num, bitrate, bitpersample, duration, samplerate, channel, \
- timeline, sync_status, storage_uuid, is_360"
+#define MEDIA_INFO_ITEM "media_id, media_path, media_display_name, media_type, media_mime_type, media_size, media_added_time, media_modified_time, media_thumbnail_path, media_description, \
+ media_rating, media_favourite, media_is_drm, media_storage_type, media_longitude, media_latitude, media_altitude, exposure_time, fnumber, iso, \
+ model, media_width, media_height, media_datetaken, media_orientation, media_title, media_album, media_artist, media_album_artist, media_genre, \
+ media_composer, media_year, media_recorded_date, media_copyright, media_track_num, media_bitrate, media_bitpersample, media_duration, media_samplerate, media_channel, \
+ media_timeline, storage_uuid, media_360"
/* Playlist Info */
#define INSERT_PLAYLIST_TO_PLAYLIST "INSERT INTO "DB_TABLE_PLAYLIST" (playlist_name) VALUES (%Q)"
#define SELECT_MAX_PLAY_ORDER_FROM_PLAYLIST_VIEW "SELECT MAX(playlist_member_order) FROM "DB_VIEW_PLAYLIST" WHERE playlist_id=%d"
#define REMOVE_PLAYLIST_ITEM_FROM_PLAYLIST_MAP "DELETE FROM "DB_TABLE_PLAYLIST_MAP" WHERE playlist_id=%d AND _id=%d;"
#define UPDATE_PLAYLIST_ORDER_FROM_PLAYLIST_MAP "UPDATE "DB_TABLE_PLAYLIST_MAP" SET playlist_member_order=%d WHERE playlist_id=%d AND _id=%d;"
-#define INSERT_PLAYLIST_ITEM_TO_PLAYLIST_MAP "INSERT INTO "DB_TABLE_PLAYLIST_MAP" (playlist_id, media_uuid, playlist_member_order) VALUES (%d, '%q', %d);"
+#define INSERT_PLAYLIST_ITEM_TO_PLAYLIST_MAP "INSERT INTO "DB_TABLE_PLAYLIST_MAP" (playlist_id, media_id, playlist_member_order) VALUES (%d, '%q', %d);"
/* Bookmark */
-#define INSERT_BOOKMARK_TO_BOOKMARK "INSERT INTO "DB_TABLE_BOOKMARK" (media_uuid, bookmark_marked_time, thumbnail_path, bookmark_name) VALUES ('%q', '%d', %Q, %Q)"
-#define SELECT_BOOKMARK_COUNT_BY_MEDIA_ID "SELECT COUNT(*) FROM "BOOKMARK_MEDIA_JOIN" AND b.media_uuid='%s'"
-#define SELECT_BOOKMARK_LIST "SELECT bookmark_id, b.media_uuid, bookmark_marked_time, b.thumbnail_path, bookmark_name FROM "BOOKMARK_MEDIA_JOIN
-#define SELECT_BOOKMARK_LIST_BY_MEDIA_ID "SELECT bookmark_id, b.media_uuid, bookmark_marked_time, b.thumbnail_path, bookmark_name FROM "BOOKMARK_MEDIA_JOIN" AND b.media_uuid='%s'"
-#define SELECT_BOOKMARK_ID_FROM_BOOKMARK "SELECT bookmark_id FROM "DB_TABLE_BOOKMARK" WHERE media_uuid='%s' AND bookmark_marked_time=%d"
+#define INSERT_BOOKMARK_TO_BOOKMARK "INSERT INTO "DB_TABLE_BOOKMARK" (media_id, bookmark_marked_time, bookmark_thumbnail_path, bookmark_name) VALUES ('%q', '%d', %Q, %Q)"
+#define SELECT_BOOKMARK_COUNT_BY_MEDIA_ID "SELECT COUNT(*) FROM "BOOKMARK_MEDIA_JOIN" AND media_id='%s'"
+#define SELECT_BOOKMARK_LIST "SELECT bookmark_id, media_id, bookmark_marked_time, bookmark_thumbnail_path, bookmark_name FROM "BOOKMARK_MEDIA_JOIN
+#define SELECT_BOOKMARK_LIST_BY_STORAGE_ID SELECT_BOOKMARK_LIST"AND storage_uuid='%s' "
+#define SELECT_BOOKMARK_LIST_BY_MEDIA_ID "SELECT bookmark_id, media_id, bookmark_marked_time, bookmark_thumbnail_path, bookmark_name FROM "BOOKMARK_MEDIA_JOIN" AND media_id='%s'"
+#define SELECT_BOOKMARK_ID_FROM_BOOKMARK "SELECT bookmark_id FROM "DB_TABLE_BOOKMARK" WHERE media_id='%s' AND bookmark_marked_time=%d"
#define UPDATE_BOOKMARK_FROM_BOOKMARK "UPDATE "DB_TABLE_BOOKMARK" SET bookmark_name=%Q WHERE bookmark_id=%d;"
/* Update Meta*/
-#define UPDATE_IMAGE_META_FROM_MEDIA "UPDATE '%s' SET orientation=%d WHERE media_uuid='%q'"
-
-#define SELECT_MEDIA_ITEM "SELECT "MEDIA_INFO_ITEM" FROM '%s' WHERE validity=1"
-#define SELECT_MEDIA_FROM_MEDIA "SELECT "MEDIA_INFO_ITEM" FROM '%s' WHERE validity=1 AND media_uuid='%s'"
-#define SELECT_MEDIA_BY_PATH "SELECT "MEDIA_INFO_ITEM" FROM '%s' WHERE validity=1 AND path='%q'"
-#define SELECT_MEDIA_FROM_ALBUM "SELECT "MEDIA_INFO_ITEM" FROM '%s' WHERE validity=1 AND album_id=%d"
-#define SELECT_MEDIA_FROM_GROUP "SELECT "MEDIA_INFO_ITEM" FROM '%s' WHERE validity=1 AND %s='%q'"
-#define SELECT_MEDIA_FROM_GROUP_NULL "SELECT "MEDIA_INFO_ITEM" FROM '%s' WHERE validity=1 AND %s IS NULL"
-#define SELECT_MEDIA_FROM_FOLDER "SELECT "MEDIA_INFO_ITEM" FROM '%s' WHERE validity=1 AND folder_uuid='%s'"
-#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_VIEW_MEDIA" WHERE media_uuid='%q'"
-#define SELECT_MEDIA_STORAGE_ID_BY_ID "SELECT storage_uuid FROM "DB_VIEW_MEDIA" WHERE media_uuid='%q'"
+#define UPDATE_IMAGE_META_FROM_MEDIA "UPDATE "DB_TABLE_MEDIA" SET media_orientation=%d WHERE media_id='%q'"
+
+#define SELECT_MEDIA_ITEM "SELECT "MEDIA_INFO_ITEM" FROM "DB_TABLE_MEDIA" WHERE validity IN (1, 2) "
+#define SELECT_MEDIA_ITEM_BY_STORAGE_ID SELECT_MEDIA_ITEM"AND storage_uuid='%s' "
+#define SELECT_MEDIA_FROM_MEDIA "SELECT "MEDIA_INFO_ITEM" FROM "DB_TABLE_MEDIA" WHERE validity IN (1, 2) AND media_id='%s'"
+#define SELECT_MEDIA_BY_PATH "SELECT "MEDIA_INFO_ITEM" FROM "DB_TABLE_MEDIA" WHERE validity=1 AND media_path='%q'"
+#define SELECT_MEDIA_FROM_ALBUM "SELECT "MEDIA_INFO_ITEM" FROM "DB_TABLE_MEDIA" WHERE validity IN (1, 2) AND album_id=%d"
+#define SELECT_MEDIA_FROM_ALBUM_BY_STORAGE_ID SELECT_MEDIA_FROM_ALBUM" AND storage_uuid='%s' "
+#define SELECT_MEDIA_FROM_GROUP "SELECT "MEDIA_INFO_ITEM" FROM "DB_TABLE_MEDIA" WHERE validity IN (1, 2) AND %s='%q'"
+#define SELECT_MEDIA_FROM_GROUP_BY_STORAGE_ID SELECT_MEDIA_FROM_GROUP" AND storage_uuid='%s' "
+#define SELECT_MEDIA_FROM_GROUP_NULL "SELECT "MEDIA_INFO_ITEM" FROM "DB_TABLE_MEDIA" WHERE validity IN (1, 2) AND %s IS NULL"
+#define SELECT_MEDIA_FROM_GROUP_NULL_BY_STORAGE_ID SELECT_MEDIA_FROM_GROUP_NULL" AND storage_uuid='%s' "
+#define SELECT_MEDIA_FROM_FOLDER "SELECT "MEDIA_INFO_ITEM" FROM "DB_TABLE_MEDIA" WHERE validity IN (1, 2) AND folder_id='%s'"
+#define SELECT_MEDIA_FROM_STORAGE "SELECT "MEDIA_INFO_ITEM" FROM "DB_TABLE_MEDIA" WHERE validity IN (1, 2) AND storage_uuid='%s'"
+#define SELECT_MEDIA_FROM_TAG "SELECT "MEDIA_INFO_ITEM" FROM "DB_TABLE_MEDIA" WHERE media_id IN (SELECT media_id FROM "DB_TABLE_TAG_MAP" WHERE tag_id=%d) AND validity IN (1, 2)"
+#define SELECT_MEDIA_FROM_PLAYLIST "SELECT "MEDIA_INFO_ITEM" FROM "DB_TABLE_MEDIA" WHERE media_id IN (SELECT media_id FROM "DB_TABLE_PLAYLIST_MAP" WHERE playlist_id=%d) AND validity IN (1, 2)"
+#define SELECT_MEDIA_FROM_TAG_BY_STORAGE_ID SELECT_MEDIA_FROM_TAG" AND storage_uuid='%s' "
+#define SELECT_MEDIA_FROM_PLAYLIST_BY_STORAGE_ID SELECT_MEDIA_FROM_PLAYLIST" AND storage_uuid='%s' "
+#define SELECT_MEDIA_PATH_BY_ID "SELECT media_path FROM "DB_TABLE_MEDIA" WHERE media_id='%q'"
+#define SELECT_MEDIA_STORAGE_ID_BY_ID "SELECT storage_uuid FROM "DB_TABLE_MEDIA" WHERE media_id='%q'"
/* Delete */
#define DELETE_PLAYLIST_FROM_PLAYLIST "DELETE FROM "DB_TABLE_PLAYLIST" WHERE playlist_id=%d"
/* Storage*/
#define SELECT_STORAGE_COUNT "SELECT COUNT(*) FROM "DB_TABLE_STORAGE" WHERE validity=1"
-#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'"
+#define SELECT_STORAGE_LIST "SELECT storage_id, storage_path, storage_type FROM "DB_TABLE_STORAGE" WHERE validity=1"
+#define SELECT_STORAGE_INFO_FROM_STORAGE "SELECT storage_path, storage_type FROM "DB_TABLE_STORAGE" WHERE validity=1 AND storage_id='%s'"
/* Face */
#define DELETE_FACE_FROM_FACE "DELETE FROM "DB_TABLE_FACE" WHERE media_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, media_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, media_face_tag=%Q WHERE media_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_IMAGE_COUNT_FROM_MEDIA_BY_ID "SELECT COUNT(*) FROM "DB_VIEW_MEDIA" WHERE media_uuid='%q' AND media_type=0 AND validity=1"
+#define INSERT_FACE_TO_FACE "INSERT INTO "DB_TABLE_FACE" (media_id, face_rect_x , face_rect_y, face_rect_w, face_rect_h, face_orientation, media_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, face_orientation=%d, media_face_tag=%Q WHERE media_face_id=%d"
+#define SELECT_MEDIA_COUNT_FROM_MEDIA_BY_ID "SELECT COUNT(*) FROM "DB_TABLE_MEDIA" WHERE media_id='%q' AND validity IN (1, 2)"
+#define SELECT_IMAGE_COUNT_FROM_MEDIA_BY_ID "SELECT COUNT(*) FROM "DB_TABLE_MEDIA" WHERE media_id='%q' AND media_type=0 AND validity IN (1, 2)"
#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 media_face_id, fa.media_uuid, face_rect_x, face_rect_y, face_rect_w, face_rect_h, fa.orientation, media_face_tag FROM "FACE_MEDIA_JOIN
-#define SELECT_FACE_LIST_BY_MEDIA_ID "SELECT media_face_id, fa.media_uuid, face_rect_x, face_rect_y, face_rect_w, face_rect_h, fa.orientation, media_face_tag FROM "FACE_MEDIA_JOIN" AND fa.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 media_face_id=%d)"
-#define SELECT_FACE_ID "SELECT media_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"
-
-int _content_query_prepare(sqlite3_stmt **stmt, char *select_query, char *condition_query, char *option_query);
-int _content_error_capi(int type, int cotent_error);
+#define SELECT_FACE_COUNT_BY_STORAGE_ID SELECT_FACE_COUNT"AND storage_uuid='%s' "
+#define SELECT_FACE_COUNT_BY_MEDIA_ID "SELECT COUNT(*) FROM "FACE_MEDIA_JOIN" AND media_id='%s'"
+#define SELECT_FACE_LIST "SELECT media_face_id, media_id, face_rect_x, face_rect_y, face_rect_w, face_rect_h, face_orientation, media_face_tag FROM "FACE_MEDIA_JOIN
+#define SELECT_FACE_LIST_BY_STORAGE_ID SELECT_FACE_LIST"AND storage_uuid='%s' "
+#define SELECT_FACE_LIST_BY_MEDIA_ID "SELECT media_face_id, media_id, face_rect_x, face_rect_y, face_rect_w, face_rect_h, face_orientation, media_face_tag FROM "FACE_MEDIA_JOIN" AND media_id='%s'"
+#define UPDATE_MEDIA_INFO_IN_FACE_SCAN_LIST "UPDATE "DB_TABLE_FACE_SCAN_LIST" SET modified_time = 0 WHERE media_id IN (SELECT media_id FROM "DB_TABLE_FACE" WHERE media_face_id=%d)"
+#define SELECT_FACE_ID "SELECT media_face_id FROM "DB_TABLE_FACE" WHERE media_id='%q' AND face_rect_x=%d AND face_rect_y=%d AND face_rect_w=%d AND face_rect_h=%d AND face_orientation=%d"
+
+int _content_query_prepare(const char *select_query, const char *condition_query, const char *option_query, sqlite3_stmt **stmt);
+int _content_get_result(char *query, sqlite3_stmt **stmt);
+int _content_error_capi(int internal_error);
int _content_query_sql(char *query_str);
sqlite3 * _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);
+int _media_info_get_media_info_from_db(const char *path, media_info_h media);
void _media_info_item_get_detail(sqlite3_stmt *stmt, media_info_h media);
int _media_db_get_group_count(filter_h filter, group_list_e group_type, int *group_count);
int _media_db_get_media_group_count(media_group_e group, filter_h filter, int *group_count);
int _media_db_get_media_group_item_count(const char *group_name, filter_h filter, media_group_e group, int *item_count);
int _media_db_get_media_group_item(const char *group_name, filter_h filter, media_group_e group, media_info_cb callback, void *user_data);
int _media_db_get_storage(filter_h filter, media_storage_cb callback, void *user_data);
-int _media_db_get_storage_id_by_media_id(const char *media_id, char *storage_id);
+int _media_db_get_storage_id_by_media_id(const char *media_id, char **storage_id);
-int _media_filter_attribute_create(attribute_h *attr);
-int _media_filter_attribute_add(attribute_h atrr, const char *user_attr, const char *platform_attr);
-int _media_filter_attribute_destory(attribute_h attr);
-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);
+int _media_filter_build_condition(bool is_full, const char *condition, media_content_collation_e collate_type, char **result);
+int _media_filter_build_option(filter_h filter, char **result);
#define FONT_COLOR_RESET "\033[0m"
#define media_content_gettid() syscall(__NR_gettid)
-#define media_content_retv_if(expr, val) do { \
+#define content_retv_if(expr, val) do { \
if (expr) { \
LOGE(FONT_COLOR_RED"[%ld]"FONT_COLOR_RESET, media_content_gettid()); \
return (val); \
} \
} while (0)
-#define media_content_retvm_if(expr, val, fmt, arg...) do { \
+#define content_retvm_if(expr, val, fmt, arg...) do { \
if (expr) { \
LOGE(FONT_COLOR_RED"[%ld]"fmt""FONT_COLOR_RESET, media_content_gettid(), ##arg); \
return (val); \
} \
} while (0)
-#define media_content_warn(fmt, arg...) do { \
+#define content_warn(fmt, arg...) do { \
LOGW(FONT_COLOR_GREEN"[%ld]"fmt""FONT_COLOR_RESET, media_content_gettid(), ##arg); \
} while (0)
-#define media_content_debug(fmt, arg...) do { \
+#define content_debug(fmt, arg...) do { \
LOGD(FONT_COLOR_RESET"[%ld]"fmt"", media_content_gettid(), ##arg); \
} while (0)
-#define media_content_info(fmt, arg...) do { \
+#define content_info(fmt, arg...) do { \
LOGI(FONT_COLOR_GREEN"[%ld]"fmt""FONT_COLOR_RESET, media_content_gettid(), ##arg); \
} while (0)
-#define media_content_error(fmt, arg...) do { \
+#define content_error(fmt, arg...) do { \
LOGE(FONT_COLOR_RED"[%ld]"fmt""FONT_COLOR_RESET, media_content_gettid(), ##arg); \
} while (0)
-#define media_content_debug_func() do { \
- LOGD(FONT_COLOR_RESET"[%ld]", media_content_gettid()); \
- } while (0)
-
-#define media_content_sec_debug(fmt, arg...) do { \
+#define content_sec_debug(fmt, arg...) do { \
SECURE_LOGD(FONT_COLOR_CYAN"[%ld]"fmt""FONT_COLOR_RESET, media_content_gettid(), ##arg); \
} while (0)
-#define media_content_sec_warn(fmt, arg...) do { \
- SECURE_LOGW(FONT_COLOR_RED"[%ld]"fmt""FONT_COLOR_RESET, media_content_gettid(), ##arg); \
- } while (0)
-
-#define media_content_sec_error(fmt, arg...) do { \
+#define content_sec_error(fmt, arg...) do { \
SECURE_LOGE(FONT_COLOR_RED"[%ld]"fmt""FONT_COLOR_RESET, media_content_gettid(), ##arg); \
} while (0)
#define ERR_BUF_LENGTH 256
-#define media_content_stderror(fmt) do { \
+#define content_stderror(fmt) do { \
char media_content_stderror_buf[ERR_BUF_LENGTH] = {0, }; \
strerror_r(errno, media_content_stderror_buf, ERR_BUF_LENGTH); \
LOGE(FONT_COLOR_RED fmt" : STANDARD ERROR [%s]"FONT_COLOR_RESET, media_content_stderror_buf); \