Remove old update script
[platform/core/security/drm-service-core-tizen.git] / service / drm-tapps-initialize.cpp
1 /*
2  * Copyright (c) 2000-2015 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Flora License, Version 1.1 (the License);
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://floralicense.org/license/
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an AS IS BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #include <drm-tizen-mid.h>
18
19 #include "DTapps2SqliteDB.h"
20
21 static int __drm_tad_create_db(void)
22 {
23         BOOL db_ret = FALSE;
24         int IsBeginSuccessful = 0;
25
26         char Table_Name[16] = "dtapps2rights";
27         char *sql_query_table = NULL;
28         void *pDb = NULL;
29
30         db_ret = DTappsDBOpen(pDb, __func__);
31
32         if (db_ret != TRUE) {
33                 DRM_TAPPS_EXCEPTION("DTappsDBOpen FAILED");
34                 return -1;
35         }
36
37         db_ret = DTappsDBBeginImmedTrans(__func__);
38
39         if (db_ret != TRUE) {
40                 DRM_TAPPS_EXCEPTION("DTappsDBBeginImmedTrans FAILED");
41                 goto ErrorExit;
42         }
43
44         IsBeginSuccessful = 1;
45
46         sql_query_table = DTappsGetSQLCreateTable(Table_Name);
47
48         if (sql_query_table == NULL) {
49                 DRM_TAPPS_EXCEPTION("DTappsGetSQLCreateTable FAILED");
50                 goto ErrorExit;
51         }
52
53         DRM_TAPPS_FRQ_LOG("sql_query_table = %s", sql_query_table);
54
55         db_ret = DTappsExecuteSQL(pDb, sql_query_table);
56
57         if (db_ret != TRUE) {
58                 DRM_TAPPS_EXCEPTION("DTappsGetSQLCreateTable FAILED");
59                 goto ErrorExit;
60         }
61
62         db_ret = DTappsDBCommit(__func__);
63
64         if (db_ret != TRUE) {
65                 DRM_TAPPS_EXCEPTION("DTappsDBCommit FAILED");
66
67                 goto ErrorExit;
68         }
69
70         db_ret = DTappsDBClose(__func__);
71
72         if (db_ret != TRUE) {
73                 DRM_TAPPS_EXCEPTION("DTappsDBClose FAILED");
74                 goto ErrorExit;
75         }
76
77         DRM_TAPPS_FRQ_LOG("TAD DB created successfully");
78
79         return 0;
80
81 ErrorExit:
82
83         if (1 == IsBeginSuccessful)
84                 DTappsDBRollback(__func__);
85
86         db_ret = DTappsDBClose(__func__);
87
88         if (db_ret != TRUE)
89                 DRM_TAPPS_EXCEPTION("DTappsDBClose FAILED");
90
91         DRM_TAPPS_EXCEPTION("TAD DB creation FAILED");
92
93         return -1;
94 }
95
96 int main(int, char *[])
97 {
98         DRM_TAPPS_FRQ_LOG("=========Start Create TAD DB file ============\n\n");
99
100         if (0 != __drm_tad_create_db()) {
101                 DRM_TAPPS_EXCEPTION("=========Error Creating TAD DB file ============\n\n");
102                 return 1;
103         }
104
105         DRM_TAPPS_FRQ_LOG("=========Success Created TAD DB file  ============\n\n");
106
107         return 0;
108 }