STORAGE_KEY_FLIGHT_MODE_BOOL is part of STORAGE_KEY_BOOL
[framework/telephony/libtcore.git] / include / storage.h
1 /*
2  * libtcore
3  *
4  * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Ja-young Gu <jygu@samsung.com>
7  *
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
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
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.
19  */
20
21 #ifndef __TCORE_STORAGE_H__
22 #define __TCORE_STORAGE_H__
23
24 __BEGIN_DECLS
25
26 #define STORAGE_KEY_INT         0x01000000
27 #define STORAGE_KEY_BOOL        0x02000000
28 #define STORAGE_KEY_STRING      0x03000000
29 #define STORAGE_KEY_DOUBLE      0x04000000
30
31 enum tcore_storage_key {
32         STORAGE_KEY_TELEPHONY_INT = STORAGE_KEY_INT,
33         STORAGE_KEY_TELEPHONY_PLMN,
34         STORAGE_KEY_TELEPHONY_LAC,
35         STORAGE_KEY_TELEPHONY_CELLID,
36         STORAGE_KEY_TELEPHONY_SVCTYPE,
37         STORAGE_KEY_TELEPHONY_SVC_CS,//5
38
39         STORAGE_KEY_TELEPHONY_SVC_PS,
40         STORAGE_KEY_TELEPHONY_SVC_ROAM,
41         STORAGE_KEY_TELEPHONY_ZONE_TYPE,
42         STORAGE_KEY_TELEPHONY_SIM_INIT,
43         STORAGE_KEY_TELEPHONY_SIM_CHV,//10
44
45         STORAGE_KEY_TELEPHONY_SIM_PB_INIT,
46         STORAGE_KEY_TELEPHONY_CALL_STATE,
47         STORAGE_KEY_TELEPHONY_CALL_FORWARD_STATE,
48         STORAGE_KEY_TELEPHONY_TAPI_STATE,
49         STORAGE_KEY_TELEPHONY_SPN_DISP_CONDITION,//15
50
51         STORAGE_KEY_TELEPHONY_SAT_STATE,
52         STORAGE_KEY_TELEPHONY_ZONE_ZUHAUSE,
53         STORAGE_KEY_TELEPHONY_RSSI,
54         STORAGE_KEY_TELEPHONY_LOW_BATTERY,
55         STORAGE_KEY_TELEPHONY_EVENT_SYSTEM_READY,//20
56
57         STORAGE_KEY_TELEPHONY_SIM_SLOT,
58         STORAGE_KEY_PM_STATE,
59         STORAGE_KEY_PACKET_SERVICE_STATE,
60         STORAGE_KEY_MESSAGE_NETWORK_MODE,
61         STORAGE_KEY_CELLULAR_STATE,//25
62
63         STORAGE_KEY_CELLULAR_PKT_TOTAL_RCV,
64         STORAGE_KEY_CELLULAR_PKT_TOTAL_SNT,
65         STORAGE_KEY_CELLULAR_PKT_LAST_RCV,
66         STORAGE_KEY_CELLULAR_PKT_LAST_SNT,
67
68         STORAGE_KEY_TELEPHONY_BOOL = STORAGE_KEY_BOOL,
69         STORAGE_KEY_3G_ENABLE,
70         STORAGE_KEY_TELEPHONY_READY,
71         STORAGE_KEY_SETAPPL_STATE_DATA_ROAMING_BOOL,
72         STORAGE_KEY_SETAPPL_STATE_AUTOMATIC_TIME_UPDATE_BOOL,
73         STORAGE_KEY_FLIGHT_MODE_BOOL,
74
75         STORAGE_KEY_TELEPHONY_STRING = STORAGE_KEY_STRING,
76         STORAGE_KEY_TELEPHONY_NWNAME,
77         STORAGE_KEY_TELEPHONY_SPN_NAME,
78         STORAGE_KEY_TELEPHONY_SAT_SETUP_IDLE_TEXT,
79         STORAGE_KEY_TELEPHONY_IMEI,
80         STORAGE_KEY_TELEPHONY_SUBSCRIBER_NUMBER,
81         STORAGE_KEY_TELEPHONY_SUBSCRIBER_NAME,
82         STORAGE_KEY_TELEPHONY_SWVERSION,
83         STORAGE_KEY_TELEPHONY_HWVERSION,
84         STORAGE_KEY_TELEPHONY_CALDATE,
85         STORAGE_KEY_TELEPHONY_IMEI_FACTORY_REBOOT,
86         STORAGE_KEY_TELEPHONY_SIM_FACTORY_MODE,
87         STORAGE_KEY_TELEPHONY_PRODUCTCODE,
88         STORAGE_KEY_TELEPHONY_FACTORY_KSTRINGB,
89         STORAGE_KEY_TELEPHONY_IMSI,
90         STORAGE_KEY_LANGUAGE_SET,
91         STORAGE_KEY_IDLE_SCREEN_LAUNCHED_BOOL,
92 };
93
94 enum storage_value {
95         STORAGE_VALUE_UNKNOWN = 0,
96         STORAGE_VALUE_OFF = 0,
97         STORAGE_VALUE_ON  = 1,
98         STORAGE_VALUE_STATE_0 = 0,
99         STORAGE_VALUE_STATE_1 = 1,
100         STORAGE_VALUE_STATE_2 = 2,
101         STORAGE_VALUE_STATE_3 = 3,
102         STORAGE_VALUE_STATE_4 = 4,
103         STORAGE_VALUE_STATE_5 = 5,
104         STORAGE_VALUE_STATE_6 = 6,
105         STORAGE_VALUE_STATE_7 = 7,
106         STORAGE_VALUE_STATE_8 = 8,
107         STORAGE_VALUE_STATE_9 = 9,
108 };
109
110 typedef void (*TcoreStorageKeyCallback) (enum tcore_storage_key key,
111     void *value, void *user_data);
112 typedef void (*TcoreStorageDispatchCallback) (Storage *strg,
113     enum tcore_storage_key key, void *value);
114
115 struct storage_operations {
116         void* (*create_handle)(Storage *strg, const char *path);
117         gboolean (*remove_handle)(Storage *strg, void *handle);
118
119         gboolean (*set_int)(Storage *strg, enum tcore_storage_key key, int value);
120         gboolean (*set_string)(Storage *strg, enum tcore_storage_key key, const char *value);
121         gboolean (*set_bool)(Storage *strg, enum tcore_storage_key key, gboolean value);
122         int (*get_int)(Storage *strg, enum tcore_storage_key key);
123         char* (*get_string)(Storage *strg, enum tcore_storage_key key);
124         gboolean (*get_bool)(Storage *strg, enum tcore_storage_key key);
125         gboolean (*set_key_callback)(Storage *strg, enum tcore_storage_key key,
126                         TcoreStorageDispatchCallback cb);
127         gboolean (*remove_key_callback)(Storage *strg, enum tcore_storage_key key);
128
129         gboolean (*update_query_database)(Storage *strg, void *handle,
130                         const char *query, GHashTable *in_param);
131         gboolean (*read_query_database)(Storage *strg, void *handle,
132                         const char *query, GHashTable *in_param,
133                         GHashTable *out_param, int out_param_cnt);
134         gboolean (*insert_query_database)(Storage *strg, void *handle,
135                         const char *query, GHashTable *in_param);
136         gboolean (*remove_query_database)(Storage *strg, void *handle,
137                         const char *query, GHashTable *in_param);
138 };
139
140 Storage*     tcore_storage_new(TcorePlugin *plugin, const char *name,
141                  struct storage_operations *ops);
142 void         tcore_storage_free(Storage *strg);
143 const char*  tcore_storage_ref_name(Storage *strg);
144
145 void*        tcore_storage_create_handle(Storage *strg, const char *path);
146 gboolean     tcore_storage_remove_handle(Storage *strg, void *handle);
147
148 //storage vconf
149 gboolean     tcore_storage_set_int(Storage *strg, enum tcore_storage_key key,
150                  int value);
151 int          tcore_storage_get_int(Storage *strg, enum tcore_storage_key key);
152
153 gboolean     tcore_storage_set_string(Storage *strg, enum tcore_storage_key key,
154                  const char *value);
155 char*        tcore_storage_get_string(Storage *strg, enum tcore_storage_key key);
156
157 gboolean     tcore_storage_set_bool(Storage *strg, enum tcore_storage_key key,
158                  gboolean value);
159 gboolean     tcore_storage_get_bool(Storage *strg, enum tcore_storage_key key);
160
161 gboolean     tcore_storage_set_key_callback(Storage *strg,
162                  enum tcore_storage_key key, TcoreStorageKeyCallback cb,
163                  void *user_data);
164 gboolean     tcore_storage_remove_key_callback(Storage *strg,
165                  enum tcore_storage_key key, TcoreStorageKeyCallback cb);
166
167 //storage database
168 gboolean     tcore_storage_update_query_database(Storage *strg, void *handle,
169                  const char *query, GHashTable *in_param);
170 gboolean     tcore_storage_read_query_database(Storage *strg, void *handle,
171                  const char *query, GHashTable *in_param, GHashTable *out_param,
172                  int out_param_cnt);
173 gboolean     tcore_storage_insert_query_database(Storage *strg, void *handle,
174                  const char *query, GHashTable *in_param);
175 gboolean     tcore_storage_remove_query_database(Storage *strg, void *handle,
176                  const char *query, GHashTable *in_param);
177
178 __END_DECLS
179
180 #endif