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__
34 #include <tzplatform_config.h>
40 #define LOG_TAG "ACCOUNT"
42 #define ACCOUNT_VERBOSE(fmt, arg...) \
43 LOGV(": " fmt "\n", ##arg);
44 #define ACCOUNT_DEBUG(fmt, arg...) \
45 LOGD(": " fmt "\n", ##arg);
46 #define ACCOUNT_INFO(fmt, arg...) \
47 LOGI(": " fmt "\n", ##arg);
48 #define ACCOUNT_WARNING(fmt, arg...) \
49 LOGW(": " fmt "\n", ##arg);
50 #define ACCOUNT_ERROR(fmt, arg...) \
51 LOGW(": " fmt "\n", ##arg);
52 #define ACCOUNT_FATAL(fmt, arg...) \
53 LOGF(": " fmt "\n", ##arg);
55 #define ACCOUNT_RETURN_VAL(eval, expr, ret_val, X)\
64 #define ACCOUNT_SNPRINTF(dest,size,format,arg...) \
66 snprintf(dest,size-1,format,##arg); \
68 /* If the same pointer is passed to free twice, known as a double free. To avoid this, set pointers to
69 NULL after passing them to free: free(NULL) is safe (it does nothing).
72 #define ACCOUNT_MEMSET(dest,value,size) \
74 memset(dest,value,size); \
77 #define ACCOUNT_CATCH_ERROR(eval, expr, error_val, X) \
81 error_code = (error_val);\
87 #define _ACCOUNT_FREE(ptr) \
94 #define _ACCOUNT_GFREE(ptr) \
100 #define ACCOUNT_DB_NAME tzplatform_mkpath(TZ_SYS_DB, ".account.db")
101 #define ACCOUNT_TABLE "account"
102 #define CAPABILITY_TABLE "capability"
103 #define ACCOUNT_CUSTOM_TABLE "account_custom"
104 #define ACCOUNT_TYPE_TABLE "account_type"
105 #define LABEL_TABLE "label"
106 #define PROVIDER_FEATURE_TABLE "provider_feature"
107 #define ACCOUNT_SQLITE_SEQ "sqlite_sequence"
108 #define ACCOUNT_SQL_LEN_MAX 1024
109 #define ACCOUNT_TABLE_TOTAL_COUNT 6
111 typedef struct _account_s
121 char* domain_name; /*< domain name [Ex: google, facebook, twitter, samsung, ...] */
125 int user_data_int[USER_INT_CNT];
126 char* user_data_txt[USER_TXT_CNT];
127 GSList* capablity_list;
132 typedef struct _capability_s
140 }account_capability_s;
143 typedef struct _account_custom_s
151 typedef struct _account_type_s
155 char* service_provider_id;
157 char* small_icon_path;
158 bool multiple_account_support;
160 GList* account_type_list;
161 GSList* provider_feature_list;
165 typedef struct _label_s
172 typedef struct _provider_feature_s
178 typedef struct _account_subscribe_s
180 account_event_cb account_subscription_callback;
182 }account_subscribe_s;
185 * @brief Enumarations for account handle fields.
189 ACCOUNT_FIELD_NONE = -1,
191 ACCOUNT_FIELD_USER_NAME,
192 ACCOUNT_FIELD_EMAIL_ADDRESS,
193 ACCOUNT_FIELD_DISPLAY_NAME,
194 ACCOUNT_FIELD_ICON_PATH,
195 ACCOUNT_FIELD_SOURCE,
196 ACCOUNT_FIELD_PACKAGE_NAME,
197 ACCOUNT_FIELD_ACCESS_TOKEN,
198 ACCOUNT_FIELD_DOMAIN_NAME,
199 ACCOUNT_FIELD_AUTH_TYPE,
200 ACCOUNT_FIELD_SECRET,
201 ACCOUNT_FIELD_SYNC_SUPPORT,
202 ACCOUNT_FIELD_USER_TEXT_0,
203 ACCOUNT_FIELD_USER_TEXT_1,
204 ACCOUNT_FIELD_USER_TEXT_2,
205 ACCOUNT_FIELD_USER_TEXT_3,
206 ACCOUNT_FIELD_USER_TEXT_4,
207 ACCOUNT_FIELD_USER_INT_0,
208 ACCOUNT_FIELD_USER_INT_1,
209 ACCOUNT_FIELD_USER_INT_2,
210 ACCOUNT_FIELD_USER_INT_3,
211 ACCOUNT_FIELD_USER_INT_4,
212 ACCOUNT_DB_FIELD_END,
216 * @brief Enumarations for capability fields.
220 CAPABILITY_FIELD_NONE = -1,
222 CAPABILITY_FIELD_KEY,
223 CAPABILITY_FIELD_VALUE,
224 CAPABILITY_FIELD_PACKAGE_NAME,
225 CAPABILITY_FIELD_USER_NAME,
226 CAPABILITY_FIELD_ACCOUNT_ID,
227 CAPABILITY_FIELD_END,
232 ACCOUNT_CUSTOM_FIELD_NONE = -1,
233 ACCOUNT_CUSTOM_FIELD_ACCOUNT_ID,
234 ACCOUNT_CUSTOM_FIELD_APP_ID,
235 ACCOUNT_CUSTOM_FIELD_KEY,
236 ACCOUNT_CUSTOM_FIELD_VALUE,
237 ACCOUNT_CUSTOM_FIELD_END,
238 }ACCOUNT_CUSTOM_DB_IDX;
241 ACCOUNT_TYPE_FIELD_NONE = -1,
242 ACCOUNT_TYPE_FIELD_ID,
243 ACCOUNT_TYPE_FIELD_APP_ID,
244 ACCOUNT_TYPE_FIELD_SERVICE_PROVIDER_ID,
245 ACCOUNT_TYPE_FIELD_ICON_PATH,
246 ACCOUNT_TYPE_FIELD_SMALL_ICON_PATH,
247 ACCOUNT_TYPE_FIELD_MULTIPLE_ACCOUNT_SUPPORT,
248 ACCOUNT_TYPE_FIELD_END,
249 }ACCOUNT_TYPE_DB_IDX;
252 LABEL_FIELD_NONE = -1,
260 PROVIDER_FEATURE_FIELD_NONE = -1,
261 PROVIDER_FEATURE_FIELD_APP_ID,
262 PROVIDER_FEATURE_FIELD_KEY,
263 PROVIDER_FEATURE_FIELD_END,
264 }PROVIDER_FEATURE_DB_IDX;
266 typedef sqlite3_stmt* account_stmt;
268 #define ACCOUNT_SCHEMA "create table %s \n"\
270 "_id INTEGER PRIMARY KEY AUTOINCREMENT, "\
272 "email_address TEXT, "\
273 "display_name TEXT, "\
276 "package_name TEXT, "\
277 "access_token TEXT, "\
278 "domain_name TEXT, "\
279 "auth_type INTEGER, "\
281 "sync_support INTEGER, "\
282 "txt_custom0 TEXT, "\
283 "txt_custom1 TEXT, "\
284 "txt_custom2 TEXT, "\
285 "txt_custom3 TEXT, "\
286 "txt_custom4 TEXT, "\
287 "int_custom0 INTEGER, "\
288 "int_custom1 INTEGER, "\
289 "int_custom2 INTEGER, "\
290 "int_custom3 INTEGER, "\
291 "int_custom4 INTEGER "\
294 #define CAPABILITY_SCHEMA "create table %s \n"\
296 "_id INTEGER PRIMARY KEY AUTOINCREMENT, "\
299 "package_name TEXT, "\
301 "account_id INTEGER "\
304 #define ACCOUNT_CUSTOM_SCHEMA "create table %s \n"\
306 "AccountId INTEGER, "\
312 #define ACCOUNT_TYPE_SCHEMA "create table %s \n"\
314 "_id INTEGER PRIMARY KEY AUTOINCREMENT, "\
316 "ServiceProviderId TEXT, "\
318 "SmallIconPath TEXT, "\
319 "MultipleAccountSupport INTEGER "\
322 #define LABEL_SCHEMA "create table %s \n"\
329 #define PROVIDER_FEATURE_SCHEMA "create table %s \n"\
335 typedef struct GSList account_iterator_s;
341 #endif /* __SLP_ACCOUNT_PRIVATE_TYPES_H__*/