4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
24 #ifndef _MEDIA_SVC_ENV_H_
25 #define _MEDIA_SVC_ENV_H_
34 * Notice : New table user version -1 : alter table issue
38 #define USER_V3 3 /** Tizen 2.3*/
39 #define USER_V4 4 /** Tizen 2.4*/
40 #define USER_V5 5 /** Tizen 3.0*/
41 #define USER_V6 6 /** Tizen 4.0*/
42 #define USER_V7 7 /** Tizen 5.0*/
43 #define USER_V8 8 /** Tizen 5.5*/
44 #define USER_V9 9 /** Tizen 6.0*/
50 #define LATEST_DB_VERSION USER_V9
54 * DB table information
60 #define DB_TABLE_MEDIA "media" /**< media table*/
61 #define DB_TABLE_FOLDER "folder" /**< media_folder table*/
62 #define DB_TABLE_PLAYLIST "playlist" /**< playlist table*/
63 #define DB_TABLE_PLAYLIST_MAP "playlist_map" /**< playlist_map table*/
64 #define DB_TABLE_ALBUM "album" /**< album table*/
65 #define DB_TABLE_TAG "tag" /**< tag table*/
66 #define DB_TABLE_TAG_MAP "tag_map" /**< tag_map table*/
67 #define DB_TABLE_BOOKMARK "bookmark" /**< bookmark table*/
68 #define DB_TABLE_STORAGE "storage" /**< storage table*/
69 #define DB_TABLE_TMP_TABLE "tmp" /**< tmp table for backup*/
70 #define DB_TABLE_FACE "face" /**< face table*/
71 #define DB_TABLE_FACE_SCAN_LIST "face_scan_list" /**< face_scan_list table*/
76 #define DB_VIEW_MEDIA "media_view" /**< media_view(For upgrade func) */
77 #define DB_VIEW_PLAYLIST "playlist_view" /**< playlist_view*/
78 #define DB_VIEW_TAG "tag_view" /**< tag_view*/
83 #define DB_TRIGGER_PLAYLIST_MAP "playlist_map_cleanup" /**< media to map*/
84 #define DB_TRIGGER_PLAYLIST_MAP1 "playlist_map_cleanup_1" /**< playlist to map*/
85 #define DB_TRIGGER_ALBUM "album_cleanup"
86 #define DB_TRIGGER_TAG_MAP "tag_map_cleanup" /**< media to map*/
87 #define DB_TRIGGER_TAG_MAP1 "tag_map_cleanup_1" /**< tag to map*/
88 #define DB_TRIGGER_BOOKMARK "bookmark_cleanup"
89 #define DB_TRIGGER_FACE_SCAN_LIST "face_scan_list_cleanup"
90 #define DB_TRIGGER_FACE "face_cleanup"
93 * Column Name for view
95 #define DB_COLUMN_THUMBNAIL "thumbnail_path"
96 #define DB_COLUMN_MAP_ID "_id"
102 #define DB_TYPE_TEXT "TEXT"
103 #define DB_TYPE_INT "INTEGER"
104 #define DB_TYPE_DOUBLE "DOUBLE"
109 #define DB_QUERY_TABLE_WITH_UNIQUE "CREATE TABLE IF NOT EXISTS '%s' (%s, unique(%s));"
110 #define DB_QUERY_TABLE "CREATE TABLE IF NOT EXISTS '%s' (%s);"
111 #define DB_QUERY_INDEX "CREATE INDEX IF NOT EXISTS %s on '%s' (%s);"
112 #define DB_QUERY_TRIGGER "CREATE TRIGGER IF NOT EXISTS '%s' DELETE ON '%s' BEGIN DELETE FROM %s WHERE %s=old.%s;END;"
113 #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;"
114 #define DB_QUERY_VIEW_PLAYLIST "CREATE VIEW IF NOT EXISTS %s AS SELECT %s FROM playlist \
115 LEFT OUTER JOIN playlist_map ON playlist.playlist_id = playlist_map.playlist_id \
116 LEFT OUTER JOIN media ON (playlist_map.media_id = media.media_id AND media.validity=1) \
117 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);"
118 #define DB_QUERY_VIEW_TAG "CREATE VIEW IF NOT EXISTS %s AS SELECT %s FROM tag \
119 LEFT OUTER JOIN tag_map ON tag.tag_id=tag_map.tag_id \
120 LEFT OUTER JOIN media ON (tag_map.media_id = media.media_id AND media.validity=1) \
121 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);"
122 #define DB_QUERY_ALTER_TABLE "ALTER TABLE %s ADD COLUMN %s;"
125 #define MEDIA_SVC_METADATA_LEN_MAX 512 /**< Length of metadata*/
126 #define MEDIA_SVC_PATHNAME_SIZE 4096 /**< Length of Path name. */
127 #define MEDIA_SVC_UUID_SIZE 36 /**< Length of UUID*/
128 #define MEDIA_SVC_QUERY_LEN_MAX 4096*2 /**< Max Query length*/
129 #define MEDIA_SVC_QUERY_LEN_NORMAL 4096 /**< Normal Query length*/
132 #define MEDIA_SVC_TAG_UNKNOWN ""
135 MEDIA_SVC_QUERY_SCANNER,
136 MEDIA_SVC_QUERY_UPDATE_COMMON,
137 } media_svc_query_type_e;
142 DB_LIST_PLAYLIST_MAP,
149 DB_LIST_FACE_SCAN_LIST,
152 } media_svc_table_slist_e;
158 #endif /*_MEDIA_SVC_ENV_H_*/