#ifndef _MEDIA_SVC_ENV_H_
#define _MEDIA_SVC_ENV_H_
-#include <time.h>
-#include <media-util.h>
-#include <tzplatform_config.h>
+#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
+ * Notice : New table user version -1 : alter table issue
+ */
+#define USER_V1 1
+#define USER_V2 2
+#define USER_V3 3 /** Tizen 2.3*/
+#define USER_V4 4 /** Tizen 2.4*/
+#define USER_V5 5 /** Tizen 3.0*/
+#define USER_V6 6 /** Tizen 4.0*/
+#define USER_V7 7 /** Tizen 5.0*/
+#define USER_V8 8 /** Tizen 5.5*/
+#define USER_V9 9 /** Tizen 6.0*/
+
+/**
* DB information
*/
-#define MEDIA_SVC_DB_NAME MEDIA_DB_NAME /**< media db name*/
+#define LATEST_DB_VERSION USER_V9
+
/**
* DB table information
*/
-#define MEDIA_SVC_DB_TABLE_MEDIA "media" /**< media table*/
-#define MEDIA_SVC_DB_TABLE_FOLDER "folder" /**< media_folder table*/
-#define MEDIA_SVC_DB_TABLE_PLAYLIST "playlist" /**< playlist table*/
-#define MEDIA_SVC_DB_TABLE_PLAYLIST_MAP "playlist_map" /**< playlist_map table*/
-#define MEDIA_SVC_DB_TABLE_ALBUM "album" /**< album table*/
-#define MEDIA_SVC_DB_TABLE_TAG "tag" /**< tag table*/
-#define MEDIA_SVC_DB_TABLE_TAG_MAP "tag_map" /**< tag_map table*/
-#define MEDIA_SVC_DB_TABLE_BOOKMARK "bookmark" /**< bookmark table*/
-#define MEDIA_SVC_DB_TABLE_CUSTOM "custom" /**< custom table*/
-
-
-#define MEDIA_SVC_METADATA_LEN_MAX 128 /**< Length of metadata*/
-#define MEDIA_SVC_METADATA_DESCRIPTION_MAX 512 /**< Length of description*/
-#define MEDIA_SVC_PATHNAME_SIZE 4096 /**< Length of Path name. */
-#define MEDIA_SVC_UUID_SIZE 36 /**< Length of UUID*/
-
-#define MEDIA_SVC_TAG_UNKNOWN "Unknown"
-#define MEDIA_SVC_MEDIA_PATH tzplatform_mkpath(TZ_USER_DATA, "file-manager-service") /**< Media path*/
-#define MEDIA_SVC_THUMB_PATH_PREFIX tzplatform_mkpath(TZ_USER_DATA, "file-manager-service/.thumb") /**< Thumbnail path prefix*/
-#define MEDIA_SVC_THUMB_INTERNAL_PATH tzplatform_mkpath(TZ_USER_DATA, "file-manager-service/.thumb/phone") /**< Phone thumbnail path*/
-#define MEDIA_SVC_THUMB_EXTERNAL_PATH tzplatform_mkpath(TZ_USER_DATA, "file-manager-service/.thumb/mmc") /**< MMC thumbnail path*/
-#define MEDIA_SVC_THUMB_DEFAULT_PATH tzplatform_mkpath(TZ_USER_DATA, "file-manager-service/.thumb/thumb_default.png") /** default thumbnail */
-
-#define MEDIA_SVC_DEFAULT_GPS_VALUE -200 /**< Default GPS Value*/
-#define THUMB_EXT "jpg"
-
-#define MEDIA_SVC_PATH_PHONE MEDIA_ROOT_PATH_INTERNAL
-#define MEDIA_SVC_PATH_MMC MEDIA_ROOT_PATH_SDCARD
-
-enum Exif_Orientation {
- NOT_AVAILABLE=0,
- NORMAL =1,
- HFLIP =2,
- ROT_180 =3,
- VFLIP =4,
- TRANSPOSE =5,
- ROT_90 =6,
- TRANSVERSE =7,
- ROT_270 =8
-};
-
-#if 0
/**
- * Media meta data information
+ * Table Name
*/
-typedef struct {
- char title[MEDIA_SVC_METADATA_LEN_MAX]; /**< track title*/
- char album[MEDIA_SVC_METADATA_LEN_MAX]; /**< album name*/
- char artist[MEDIA_SVC_METADATA_LEN_MAX]; /**< artist name*/
- char genre[MEDIA_SVC_METADATA_LEN_MAX]; /**< genre of track*/
- char author[MEDIA_SVC_METADATA_LEN_MAX]; /**< author name*/
- char year[MEDIA_SVC_METADATA_LEN_MAX]; /**< author name*/
- char recorded_date[MEDIA_SVC_METADATA_LEN_MAX]; /**< recorded date*/
- char copyright[MEDIA_SVC_METADATA_LEN_MAX]; /**< copyright*/
- char track_num[MEDIA_SVC_METADATA_LEN_MAX]; /**< track number*/
- char description[MEDIA_SVC_METADATA_DESCRIPTION_MAX]; /**< description*/
- int bitrate; /**< bitrate*/
- int samplerate; /**< samplerate*/
- int channel; /**< channel*/
- int duration; /**< duration*/
- float longitude; /**< longitude*/
- float latitude; /**< latitude*/
- float altitude; /**< altitude*/
- int width; /**< width*/
- int height; /**< height*/
- char datetaken[MEDIA_SVC_METADATA_LEN_MAX]; /**< datetaken*/
- char timetaken[MEDIA_SVC_METADATA_LEN_MAX]; /**< timetaken*/
- int orientation; /**< orientation*/
- int rating; /**< user defined rating */
-} media_svc_content_meta_s;
+#define DB_TABLE_MEDIA "media" /**< media table*/
+#define DB_TABLE_FOLDER "folder" /**< media_folder table*/
+#define DB_TABLE_PLAYLIST "playlist" /**< playlist table*/
+#define DB_TABLE_PLAYLIST_MAP "playlist_map" /**< playlist_map table*/
+#define DB_TABLE_ALBUM "album" /**< album table*/
+#define DB_TABLE_TAG "tag" /**< tag table*/
+#define DB_TABLE_TAG_MAP "tag_map" /**< tag_map table*/
+#define DB_TABLE_BOOKMARK "bookmark" /**< bookmark table*/
+#define DB_TABLE_STORAGE "storage" /**< storage table*/
+#define DB_TABLE_TMP_TABLE "tmp" /**< tmp table for backup*/
+#define DB_TABLE_FACE "face" /**< face table*/
+#define DB_TABLE_FACE_SCAN_LIST "face_scan_list" /**< face_scan_list table*/
+/**
+ * View Name
+ */
+#define DB_VIEW_MEDIA "media_view" /**< media_view(For upgrade func) */
+#define DB_VIEW_PLAYLIST "playlist_view" /**< playlist_view*/
+#define DB_VIEW_TAG "tag_view" /**< tag_view*/
/**
- * Media data information
+ * Trigger Name
*/
-typedef struct {
- char media_uuid[MEDIA_SVC_UUID_SIZE+1]; /**< Unique ID of item */
- char path[MEDIA_SVC_PATHNAME_SIZE]; /**< Full path and file name of media file */
- char file_name[MEDIA_SVC_PATHNAME_SIZE]; /**< Full path and file name of media file */
- int media_type; /**< Type of media file : internal/external */
- char mime_type[MEDIA_SVC_PATHNAME_SIZE]; /**< Full path and file name of media file */
- int size;
- int added_time; /**< added time */
- int modified_time; /**< modified time */
- char folder_uuid[MEDIA_SVC_UUID_SIZE+1]; /**< Unique ID of folder */
- int album_id; /**< Unique ID of album */
- char thumbnail_path[MEDIA_SVC_PATHNAME_SIZE]; /**< Thumbnail image file path */
- int played_count; /**< played count */
- int last_played_time; /**< last played time */
- int last_played_position;
- int favourate; /**< favourate. o or 1 */
- int hiding; /**< hiding. o or 1 */
- int is_drm; /**< is_drm. o or 1 */
- int storage_type; /**< Storage of media file : internal/external */
- media_svc_content_meta_s media_meta; /**< meta data structure for audio files */
-} media_svc_content_info_s;
-#else
+#define DB_TRIGGER_PLAYLIST_MAP "playlist_map_cleanup" /**< media to map*/
+#define DB_TRIGGER_PLAYLIST_MAP1 "playlist_map_cleanup_1" /**< playlist to map*/
+#define DB_TRIGGER_ALBUM "album_cleanup"
+#define DB_TRIGGER_TAG_MAP "tag_map_cleanup" /**< media to map*/
+#define DB_TRIGGER_TAG_MAP1 "tag_map_cleanup_1" /**< tag to map*/
+#define DB_TRIGGER_BOOKMARK "bookmark_cleanup"
+#define DB_TRIGGER_FACE_SCAN_LIST "face_scan_list_cleanup"
+#define DB_TRIGGER_FACE "face_cleanup"
+
/**
- * Media meta data information
+ * Column Name for view
*/
-typedef struct {
- char * title; /**< track title*/
- char * album; /**< album name*/
- char * artist; /**< artist name*/
- char * genre; /**< genre of track*/
- char * composer; /**< composer name*/
- char * year; /**< year*/
- char * recorded_date; /**< recorded date*/
- char * copyright; /**< copyright*/
- char * track_num; /**< track number*/
- char * description; /**< description*/
- int bitrate; /**< bitrate*/
- int samplerate; /**< samplerate*/
- int channel; /**< channel*/
- int duration; /**< duration*/
- float longitude; /**< longitude*/
- float latitude; /**< latitude*/
- float altitude; /**< altitude*/
- int width; /**< width*/
- int height; /**< height*/
- char * datetaken; /**< datetaken*/
- int orientation; /**< orientation*/
- int rating; /**< user defined rating */
-} media_svc_content_meta_s;
+#define DB_COLUMN_THUMBNAIL "thumbnail_path"
+#define DB_COLUMN_MAP_ID "_id"
/**
- * Media data information
+ * option
*/
-typedef struct {
- char * media_uuid; /**< Unique ID of item */
- char * path; /**< Full path of media file */
- char * file_name; /**< File name of media file. Display name */
- int media_type; /**< Type of media file : internal/external */
- char * mime_type; /**< Full path and file name of media file */
- unsigned long long size; /**< size */
- time_t added_time; /**< added time, time_t */
- time_t modified_time; /**< modified time, time_t */
- char * folder_uuid; /**< Unique ID of folder */
- int album_id; /**< Unique ID of album */
- char * thumbnail_path; /**< Thumbnail image file path */
- int played_count; /**< played count */
- int last_played_time; /**< last played time */
- int last_played_position; /**< last played position */
- int favourate; /**< favourate. o or 1 */
- int is_drm; /**< is_drm. o or 1 */
- int storage_type; /**< Storage of media file : internal/external */
- media_svc_content_meta_s media_meta; /**< meta data structure for audio files */
-} media_svc_content_info_s;
-#endif
+#define DB_TYPE_TEXT "TEXT"
+#define DB_TYPE_INT "INTEGER"
+#define DB_TYPE_DOUBLE "DOUBLE"
-typedef enum{
- MEDIA_SVC_QUERY_INSERT_ITEM,
- MEDIA_SVC_QUERY_SET_ITEM_VALIDITY,
- MEDIA_SVC_QUERY_MOVE_ITEM,
+/**
+ * Query form
+ */
+#define DB_QUERY_TABLE_WITH_UNIQUE "CREATE TABLE IF NOT EXISTS '%s' (%s, unique(%s));"
+#define DB_QUERY_TABLE "CREATE TABLE IF NOT EXISTS '%s' (%s);"
+#define DB_QUERY_INDEX "CREATE INDEX IF NOT EXISTS %s on '%s' (%s);"
+#define DB_QUERY_TRIGGER "CREATE TRIGGER IF NOT EXISTS '%s' DELETE ON '%s' BEGIN DELETE FROM %s WHERE %s=old.%s;END;"
+#define DB_QUERY_TRIGGER_WITH_COUNT "CREATE TRIGGER IF NOT EXISTS '%s' DELETE ON '%s' BEGIN DELETE FROM %s WHERE (SELECT count(*) FROM '%s' WHERE %s=old.%s)=1 AND %s=old.%s;END;"
+#define DB_QUERY_VIEW_PLAYLIST "CREATE VIEW IF NOT EXISTS %s AS SELECT %s FROM playlist \
+ LEFT OUTER JOIN playlist_map ON playlist.playlist_id = playlist_map.playlist_id \
+ LEFT OUTER JOIN media ON (playlist_map.media_id = media.media_id AND media.validity=1) \
+ LEFT OUTER JOIN (SELECT count(playlist_id) as playlist_media_count, playlist_id FROM playlist_map group by playlist_id) as cnt_tbl ON (cnt_tbl.playlist_id=playlist_map.playlist_id AND media.validity=1);"
+#define DB_QUERY_VIEW_TAG "CREATE VIEW IF NOT EXISTS %s AS SELECT %s FROM tag \
+ LEFT OUTER JOIN tag_map ON tag.tag_id=tag_map.tag_id \
+ LEFT OUTER JOIN media ON (tag_map.media_id = media.media_id AND media.validity=1) \
+ LEFT OUTER JOIN (SELECT count(tag_id) as tag_media_count, tag_id FROM tag_map group by tag_id) as cnt_tbl ON (cnt_tbl.tag_id=tag_map.tag_id AND media.validity=1);"
+#define DB_QUERY_ALTER_TABLE "ALTER TABLE %s ADD COLUMN %s;"
+
+
+#define MEDIA_SVC_METADATA_LEN_MAX 512 /**< Length of metadata*/
+#define MEDIA_SVC_PATHNAME_SIZE 4096 /**< Length of Path name. */
+#define MEDIA_SVC_UUID_SIZE 36 /**< Length of UUID*/
+#define MEDIA_SVC_QUERY_LEN_MAX 4096*2 /**< Max Query length*/
+#define MEDIA_SVC_QUERY_LEN_NORMAL 4096 /**< Normal Query length*/
+
+
+#define MEDIA_SVC_TAG_UNKNOWN ""
+
+typedef enum {
+ MEDIA_SVC_QUERY_SCANNER,
+ MEDIA_SVC_QUERY_UPDATE_COMMON,
} media_svc_query_type_e;
+typedef enum {
+ DB_LIST_MEDIA = 0,
+ DB_LIST_FOLDER,
+ DB_LIST_PLAYLIST_MAP,
+ DB_LIST_PLAYLIST,
+ DB_LIST_ALBUM,
+ DB_LIST_TAG_MAP,
+ DB_LIST_TAG,
+ DB_LIST_BOOKMARK,
+ DB_LIST_STORAGE,
+ DB_LIST_FACE_SCAN_LIST,
+ DB_LIST_FACE,
+ DB_LIST_MAX,
+} media_svc_table_slist_e;
+
#ifdef __cplusplus
}
#endif