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.
23 #ifndef _MEDIA_SVC_DB_UTILS_H_
24 #define _MEDIA_SVC_DB_UTILS_H_
29 #define SQLITE3_FINALIZE(x) if (x != NULL) {sqlite3_finalize(x);}
30 #define SQLITE3_SAFE_FREE(x) {if(x != NULL) {sqlite3_free(x);x = NULL;}}
32 int _media_svc_make_table_query(const char *table_name, media_svc_table_slist_e list, uid_t uid);
33 int _media_svc_upgrade_table_query(sqlite3 *db_handle, const char *table_name, media_svc_table_slist_e list, uid_t uid);
34 int _media_svc_init_table_query(const char *event_table_name);
35 void _media_svc_destroy_table_query();
36 int _media_svc_create_media_table_with_id(const char *table_id, uid_t uid);
37 int _media_svc_drop_media_table(const char *storage_id, uid_t uid);
38 int _media_svc_update_media_view(sqlite3 *db_handle, uid_t uid);
39 int _media_svc_sql_query(const char *sql_str, uid_t uid);
40 int _media_svc_get_user_version(sqlite3 *db_handle, int *user_version);
41 int _media_svc_sql_prepare_to_step(sqlite3 *handle, const char *sql_str, sqlite3_stmt **stmt);
42 int _media_svc_sql_prepare_to_step_simple(sqlite3 *handle, const char *sql_str, sqlite3_stmt **stmt);
43 int _media_svc_sql_begin_trans(uid_t uid);
44 int _media_svc_sql_end_trans(uid_t uid);
45 int _media_svc_sql_rollback_trans(uid_t uid);
46 int _media_svc_sql_query_list(GList **query_list, uid_t uid);
47 void _media_svc_sql_query_add(GList **query_list, char **query);
48 void _media_svc_sql_query_release(GList **query_list);
49 int _media_svc_check_db_upgrade(sqlite3 *db_handle, int user_version, uid_t uid);
50 int _media_db_check_corrupt(sqlite3 *db_handle);
51 char *_media_svc_get_path(uid_t uid);
54 #endif /*_MEDIA_SVC_DB_UTILS_H_*/