upload tizen1.0 source
[profile/ivi/libaccounts-svc.git] / include / account-private.h
1 /*
2  * libaccounts-svc
3  *
4  * Copyright (c) 2010 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Tarun Kumar <tarun.kr@samsung.com>, Sukumar Moharana <msukumar@samsung.com>, Wonyoung Lee <wy1115.lee@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
22 #ifndef __ACCOUNT_PRIVATE_TYPES_H__
23 #define __ACCOUNT_PRIVATE_TYPES_H__
24
25
26 /*#include <glib.h>*/
27 #ifdef __cplusplus
28 extern "C"
29 {
30 #endif
31
32 #include <glib.h>
33
34 #define _ACCOUNT_FREE(ptr)      \
35                 if (ptr != NULL) {      \
36                         free(ptr);      \
37                         ptr = NULL; \
38                 }       \
39
40
41 #define _ACCOUNT_GFREE(ptr)     \
42                                 if (ptr != NULL) {      \
43                                         g_free(ptr);    \
44                                         ptr = NULL; \
45                                 }       \
46
47 #define ACCOUNT_DB_NAME "/opt/dbspace/.account.db"
48 #define ACCOUNT_TABLE "account"
49 #define CAPABILITY_TABLE "capability"
50 #define ACCOUNT_SQLITE_SEQ "sqlite_sequence"
51 #define ACCOUNT_SQL_LEN_MAX     1024
52 #define ACCOUNT_TABLE_TOTAL_COUNT       2
53
54 typedef struct _account_s
55 {
56         int                     id;
57         char*           user_name;
58         char*           email_address;
59         char*           display_name;
60         char*           icon_path;
61         char*           source;
62         char*           package_name;
63         char*           access_token;
64         char*           domain_name;            /*< domain name [Ex: google, facebook, twitter, samsung, ...] */
65         /*int                   service_type;*/ /* ACCOUNT_CATEGORY*/
66         int                     auth_type;
67         int             secret;
68         int                     user_data_int[USER_INT_CNT];
69         char*           user_data_txt[USER_TXT_CNT];
70         GSList*         capablity_list;
71         GList*          account_list;
72 }account_s;
73
74 typedef struct _capability_s
75 {
76         int id;
77         int type;
78         int value;
79         char* package_name;
80         char* user_name;
81         int account_id;
82 }account_capability_s;
83
84 /**
85  * @brief   Enumarations for account handle fields.
86  */
87
88 typedef enum {
89         ACCOUNT_FIELD_NONE = -1,
90         ACCOUNT_FIELD_ID,
91         ACCOUNT_FIELD_USER_NAME,
92         ACCOUNT_FIELD_EMAIL_ADDRESS,
93         ACCOUNT_FIELD_DISPLAY_NAME,
94         ACCOUNT_FIELD_ICON_PATH,
95         ACCOUNT_FIELD_SOURCE,
96         ACCOUNT_FIELD_PACKAGE_NAME,
97         ACCOUNT_FIELD_ACCESS_TOKEN,
98         ACCOUNT_FIELD_DOMAIN_NAME,
99         ACCOUNT_FIELD_AUTH_TYPE,
100         ACCOUNT_FIELD_SECRET,
101         ACCOUNT_FIELD_USER_TEXT_0,
102         ACCOUNT_FIELD_USER_TEXT_1,
103         ACCOUNT_FIELD_USER_TEXT_2,
104         ACCOUNT_FIELD_USER_TEXT_3,
105         ACCOUNT_FIELD_USER_TEXT_4,
106         ACCOUNT_FIELD_USER_INT_0,
107         ACCOUNT_FIELD_USER_INT_1,
108         ACCOUNT_FIELD_USER_INT_2,
109         ACCOUNT_FIELD_USER_INT_3,
110         ACCOUNT_FIELD_USER_INT_4,
111         ACCOUNT_DB_FIELD_END,
112 } ACCOUNT_DB_IDX;
113
114 /**
115  * @brief       Enumarations for capability fields.
116  */
117
118 typedef enum {
119         CAPABILITY_FIELD_NONE = -1,
120         CAPABILITY_FIELD_ID,
121         CAPABILITY_FIELD_KEY,
122         CAPABILITY_FIELD_VALUE,
123         CAPABILITY_FIELD_PACKAGE_NAME,
124         CAPABILITY_FIELD_USER_NAME,
125         CAPABILITY_FIELD_ACCOUNT_ID,
126         CAPABILITY_FIELD_END,
127 }CAPABILITY_DB_IDX;
128
129
130 typedef sqlite3_stmt* account_stmt;
131
132 #define ACCOUNT_SCHEMA  "create table %s \n"\
133         "(\n"\
134 "_id INTEGER PRIMARY KEY AUTOINCREMENT, "\
135 "user_name TEXT, "\
136 "email_address TEXT, "\
137 "display_name TEXT, "\
138 "icon_path TEXT, "\
139 "source TEXT, "\
140 "package_name TEXT, "\
141 "access_token TEXT, "\
142 "domain_name TEXT, "\
143 "auth_type INTEGER, "\
144 "secret INTEGER, "\
145 "txt_custom0 TEXT, "\
146 "txt_custom1 TEXT, "\
147 "txt_custom2 TEXT, "\
148 "txt_custom3 TEXT, "\
149 "txt_custom4 TEXT, "\
150 "int_custom0 INTEGER, "\
151 "int_custom1 INTEGER, "\
152 "int_custom2 INTEGER, "\
153 "int_custom3 INTEGER, "\
154 "int_custom4 INTEGER "\
155 ");"
156
157 #define CAPABILITY_SCHEMA  "create table %s \n"\
158         "(\n"\
159 "_id INTEGER PRIMARY KEY AUTOINCREMENT, "\
160 "key INTEGER, "\
161 "value INTEGER, "\
162 "package_name TEXT, "\
163 "user_name TEXT, "\
164 "account_id INTEGER "\
165 ");"
166
167 typedef struct GSList           account_iterator_s;
168
169 #ifdef __cplusplus
170 }
171 #endif
172
173 #endif /* __SLP_ACCOUNT_PRIVATE_TYPES_H__*/