Tizen 2.0 Release
[framework/system/oma-dm-agent.git] / include / common / dm-status / oma_dm_status_db_common.h
1 /*
2  * oma-dm-agent
3  * Copyright (c) 2012 Samsung Electronics Co., Ltd.
4  *
5  * Licensed under the Apache License, Version 2.0 (the License);
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17
18 #ifndef OMA_DM_STATUS_DB_COMMON_H_
19 #define OMA_DM_STATUS_DB_COMMON_H_
20
21 /*lib*/
22 #include <stdio.h>
23 #include <stdlib.h>
24 #include <string.h>
25 #include <malloc.h>
26 #include <glib.h>
27 #include <time.h>
28 #include <sqlite3.h>
29 #include <pthread.h>
30
31 #define DB_HANDLER                                                              sqlite3
32
33 #define GET_THREAD_ID                                                   pthread_self()
34
35 #define RETRY_COUNT                                                     10
36
37 #define MAX_QUERY_LENGTH                                        1024
38
39 #define STRDUP(src)                                                             (src == NULL) ?  NULL : strdup(src);
40
41 #define ATOI(src)                                                                       (src == NULL) ? 0 : atoi(src);
42
43 #define MEMORY_FREE(src) \
44         if (src != NULL) {                                                                              \
45                 free(src);                                                                                              \
46                 src = NULL;                                                                                     \
47         }                                                                                                                               \
48
49 typedef sqlite3_stmt(*db_stmt);
50
51 /* define enum & structure */
52 typedef enum {
53         ENGINE_STATUS_TBL,
54
55         DB_TABLE_NAME_MAX
56 } DB_TABLE_NAME;
57
58 typedef enum {
59         TRANSACTION_COMMIT_ = 0,
60         TRANSACTION_ROLLBACK_
61 } DB_TRANSACTION;
62
63 typedef enum {
64         VALUE_ENGINE_ID,
65         VALUE_ENGINE_STATUS,
66         VALUE_SERVER_ID,
67         VALUE_SERVER_URL,
68         VALUE_CORRELATOR,
69         VALUE_MO_PATH,
70         VALUE_RESULT_STATUS,
71         VALUE_UI_MODE,
72         VALUE_TASK_ID,
73         VALUE_UI_NOTI_TYPE,
74         VALUE_DOWNLOAD_CLICK,
75         VALUE_UPDATE_TIME
76 } ENGINE_STATUS_VALUE;
77
78 typedef struct {
79         GHashTable *db_handlerTable;    /* db handler hash table */
80         pthread_mutex_t *db_handlerTable_mutex; /* mutex for db handler hash table */
81 } db_handler_mgr;
82
83 typedef struct {
84         int engine_id;
85         int engine_status;
86         char *server_id;
87         char *server_url;
88         char *correlator;
89         char *mo_path;
90         int result_status;
91         char *ui_mode;
92         int task_id;
93         int ui_noti_type;
94         int download_click;
95         time_t update_time;
96
97 } engine_status;
98
99 #endif                          /* OMA_DM_STATUS_DB_COMMON_H_ */