4 * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Wonyoung Lee <wy1115.lee@samsung.com>, Sungchan Kim <sungchan81.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.
22 #ifndef __ACCOUNT_PRIVATE_TYPES_H__
23 #define __ACCOUNT_PRIVATE_TYPES_H__
39 #define LOG_TAG "ACCOUNT"
41 #define ACCOUNT_VERBOSE(fmt, arg...) \
42 LOGV(": " fmt "\n", ##arg);
43 #define ACCOUNT_DEBUG(fmt, arg...) \
44 LOGD(": " fmt "\n", ##arg);
45 #define ACCOUNT_INFO(fmt, arg...) \
46 LOGI(": " fmt "\n", ##arg);
47 #define ACCOUNT_WARNING(fmt, arg...) \
48 LOGW(": " fmt "\n", ##arg);
49 #define ACCOUNT_ERROR(fmt, arg...) \
50 LOGW(": " fmt "\n", ##arg);
51 #define ACCOUNT_FATAL(fmt, arg...) \
52 LOGF(": " fmt "\n", ##arg);
54 #define ACCOUNT_RETURN_VAL(eval, expr, ret_val, X)\
63 #define ACCOUNT_SNPRINTF(dest,size,format,arg...) \
65 snprintf(dest,size-1,format,##arg); \
67 /* If the same pointer is passed to free twice, known as a double free. To avoid this, set pointers to
68 NULL after passing them to free: free(NULL) is safe (it does nothing).
71 #define ACCOUNT_MEMSET(dest,value,size) \
73 memset(dest,value,size); \
76 #define ACCOUNT_CATCH_ERROR(eval, expr, error_val, X) \
80 error_code = (error_val);\
86 #define _ACCOUNT_FREE(ptr) \
93 #define _ACCOUNT_GFREE(ptr) \
99 #define ACCOUNT_DB_NAME "/opt/dbspace/.account.db"
100 #define ACCOUNT_TABLE "account"
101 #define CAPABILITY_TABLE "capability"
102 #define ACCOUNT_CUSTOM_TABLE "account_custom"
103 #define ACCOUNT_TYPE_TABLE "account_type"
104 #define LABEL_TABLE "label"
105 #define PROVIDER_FEATURE_TABLE "provider_feature"
106 #define ACCOUNT_SQLITE_SEQ "sqlite_sequence"
107 #define ACCOUNT_SQL_LEN_MAX 1024
108 #define ACCOUNT_TABLE_TOTAL_COUNT 6
110 typedef struct _account_s
120 char* domain_name; /*< domain name [Ex: google, facebook, twitter, samsung, ...] */
124 int user_data_int[USER_INT_CNT];
125 char* user_data_txt[USER_TXT_CNT];
126 GSList* capablity_list;
131 typedef struct _capability_s
139 }account_capability_s;
142 typedef struct _account_custom_s
150 typedef struct _account_type_s
154 char* service_provider_id;
156 char* small_icon_path;
157 bool multiple_account_support;
159 GList* account_type_list;
160 GSList* provider_feature_list;
164 typedef struct _label_s
171 typedef struct _provider_feature_s
177 typedef struct _account_subscribe_s
179 account_event_cb account_subscription_callback;
181 }account_subscribe_s;
184 * @brief Enumarations for account handle fields.
188 ACCOUNT_FIELD_NONE = -1,
190 ACCOUNT_FIELD_USER_NAME,
191 ACCOUNT_FIELD_EMAIL_ADDRESS,
192 ACCOUNT_FIELD_DISPLAY_NAME,
193 ACCOUNT_FIELD_ICON_PATH,
194 ACCOUNT_FIELD_SOURCE,
195 ACCOUNT_FIELD_PACKAGE_NAME,
196 ACCOUNT_FIELD_ACCESS_TOKEN,
197 ACCOUNT_FIELD_DOMAIN_NAME,
198 ACCOUNT_FIELD_AUTH_TYPE,
199 ACCOUNT_FIELD_SECRET,
200 ACCOUNT_FIELD_SYNC_SUPPORT,
201 ACCOUNT_FIELD_USER_TEXT_0,
202 ACCOUNT_FIELD_USER_TEXT_1,
203 ACCOUNT_FIELD_USER_TEXT_2,
204 ACCOUNT_FIELD_USER_TEXT_3,
205 ACCOUNT_FIELD_USER_TEXT_4,
206 ACCOUNT_FIELD_USER_INT_0,
207 ACCOUNT_FIELD_USER_INT_1,
208 ACCOUNT_FIELD_USER_INT_2,
209 ACCOUNT_FIELD_USER_INT_3,
210 ACCOUNT_FIELD_USER_INT_4,
211 ACCOUNT_DB_FIELD_END,
215 * @brief Enumarations for capability fields.
219 CAPABILITY_FIELD_NONE = -1,
221 CAPABILITY_FIELD_KEY,
222 CAPABILITY_FIELD_VALUE,
223 CAPABILITY_FIELD_PACKAGE_NAME,
224 CAPABILITY_FIELD_USER_NAME,
225 CAPABILITY_FIELD_ACCOUNT_ID,
226 CAPABILITY_FIELD_END,
231 ACCOUNT_CUSTOM_FIELD_NONE = -1,
232 ACCOUNT_CUSTOM_FIELD_ACCOUNT_ID,
233 ACCOUNT_CUSTOM_FIELD_APP_ID,
234 ACCOUNT_CUSTOM_FIELD_KEY,
235 ACCOUNT_CUSTOM_FIELD_VALUE,
236 ACCOUNT_CUSTOM_FIELD_END,
237 }ACCOUNT_CUSTOM_DB_IDX;
240 ACCOUNT_TYPE_FIELD_NONE = -1,
241 ACCOUNT_TYPE_FIELD_ID,
242 ACCOUNT_TYPE_FIELD_APP_ID,
243 ACCOUNT_TYPE_FIELD_SERVICE_PROVIDER_ID,
244 ACCOUNT_TYPE_FIELD_ICON_PATH,
245 ACCOUNT_TYPE_FIELD_SMALL_ICON_PATH,
246 ACCOUNT_TYPE_FIELD_MULTIPLE_ACCOUNT_SUPPORT,
247 ACCOUNT_TYPE_FIELD_END,
248 }ACCOUNT_TYPE_DB_IDX;
251 LABEL_FIELD_NONE = -1,
259 PROVIDER_FEATURE_FIELD_NONE = -1,
260 PROVIDER_FEATURE_FIELD_APP_ID,
261 PROVIDER_FEATURE_FIELD_KEY,
262 PROVIDER_FEATURE_FIELD_END,
263 }PROVIDER_FEATURE_DB_IDX;
265 typedef sqlite3_stmt* account_stmt;
267 #define ACCOUNT_SCHEMA "create table %s \n"\
269 "_id INTEGER PRIMARY KEY AUTOINCREMENT, "\
271 "email_address TEXT, "\
272 "display_name TEXT, "\
275 "package_name TEXT, "\
276 "access_token TEXT, "\
277 "domain_name TEXT, "\
278 "auth_type INTEGER, "\
280 "sync_support INTEGER, "\
281 "txt_custom0 TEXT, "\
282 "txt_custom1 TEXT, "\
283 "txt_custom2 TEXT, "\
284 "txt_custom3 TEXT, "\
285 "txt_custom4 TEXT, "\
286 "int_custom0 INTEGER, "\
287 "int_custom1 INTEGER, "\
288 "int_custom2 INTEGER, "\
289 "int_custom3 INTEGER, "\
290 "int_custom4 INTEGER "\
293 #define CAPABILITY_SCHEMA "create table %s \n"\
295 "_id INTEGER PRIMARY KEY AUTOINCREMENT, "\
298 "package_name TEXT, "\
300 "account_id INTEGER "\
303 #define ACCOUNT_CUSTOM_SCHEMA "create table %s \n"\
305 "AccountId INTEGER, "\
311 #define ACCOUNT_TYPE_SCHEMA "create table %s \n"\
313 "_id INTEGER PRIMARY KEY AUTOINCREMENT, "\
315 "ServiceProviderId TEXT, "\
317 "SmallIconPath TEXT, "\
318 "MultipleAccountSupport INTEGER "\
321 #define LABEL_SCHEMA "create table %s \n"\
328 #define PROVIDER_FEATURE_SCHEMA "create table %s \n"\
334 typedef struct GSList account_iterator_s;
340 #endif /* __SLP_ACCOUNT_PRIVATE_TYPES_H__*/