Fix build warning and add related gcc options
[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         {
34                 DRM_TAPPS_EXCEPTION("DTappsDBOpen FAILED");
35
36                 return -1;
37         }
38
39         db_ret = DTappsDBBeginImmedTrans(__func__);
40
41         if(db_ret != TRUE)
42         {
43                 DRM_TAPPS_EXCEPTION("DTappsDBBeginImmedTrans FAILED");
44
45                 goto ErrorExit;
46         }
47
48         IsBeginSuccessful = 1;
49
50         sql_query_table = DTappsGetSQLCreateTable(Table_Name);
51
52         if(sql_query_table == NULL)
53         {
54                 DRM_TAPPS_EXCEPTION("DTappsGetSQLCreateTable FAILED");
55
56                 goto ErrorExit;
57         }
58
59         DRM_TAPPS_FRQ_LOG("sql_query_table = %s", sql_query_table);
60
61         db_ret = DTappsExecuteSQL(pDb, sql_query_table);
62
63         if(db_ret != TRUE)
64         {
65                 DRM_TAPPS_EXCEPTION("DTappsGetSQLCreateTable FAILED");
66
67                 goto ErrorExit;
68         }
69
70         db_ret = DTappsDBCommit(__func__);
71
72         if(db_ret != TRUE)
73         {
74                 DRM_TAPPS_EXCEPTION("DTappsDBCommit FAILED");
75
76                 goto ErrorExit;
77         }
78
79         db_ret = DTappsDBClose(__func__);
80
81         if(db_ret != TRUE)
82         {
83                 DRM_TAPPS_EXCEPTION("DTappsDBClose FAILED");
84
85                 goto ErrorExit;
86         }
87
88         DRM_TAPPS_FRQ_LOG("TAD DB created successfully");
89
90         return 0;
91
92 ErrorExit:
93
94         if (1 == IsBeginSuccessful)
95         {
96                  DTappsDBRollback(__func__);
97         }
98
99         db_ret = DTappsDBClose(__func__);
100         if(db_ret != TRUE)
101         {
102                 DRM_TAPPS_EXCEPTION("DTappsDBClose FAILED");
103         }
104
105         DRM_TAPPS_EXCEPTION("TAD DB creation FAILED");
106
107         return -1;
108 }
109
110 int main(int, char *[])
111 {
112         DRM_TAPPS_FRQ_LOG("=============Start Create TAD DB file ================\n\n ");
113
114         if(0 != __drm_tad_create_db())
115         {
116                 DRM_TAPPS_EXCEPTION("=============Error Creating TAD DB file ================\n\n ");
117
118                 return 1;
119         }
120
121         DRM_TAPPS_FRQ_LOG("=============Success Created TAD DB file  ================\n\n ");
122
123         return 0;
124 }