RSA initial upload from private git
[framework/pim/libaccounts-svc.git] / include / account-private.h
1 /*
2  *  account
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Wonyoung Lee <wy1115.lee@samsung.com>, Tarun Kumar <tarun.kr@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                     sync_support;
69         int                     user_data_int[USER_INT_CNT];
70         char*           user_data_txt[USER_TXT_CNT];
71         GSList*         capablity_list;
72         GList*          account_list;
73 }account_s;
74
75 typedef struct _capability_s
76 {
77         int id;
78         int type;
79         int value;
80         char* package_name;
81         char* user_name;
82         int account_id;
83 }account_capability_s;
84
85 /**
86  * @brief   Enumarations for account handle fields.
87  */
88
89 typedef enum {
90         ACCOUNT_FIELD_NONE = -1,
91         ACCOUNT_FIELD_ID,
92         ACCOUNT_FIELD_USER_NAME,
93         ACCOUNT_FIELD_EMAIL_ADDRESS,
94         ACCOUNT_FIELD_DISPLAY_NAME,
95         ACCOUNT_FIELD_ICON_PATH,
96         ACCOUNT_FIELD_SOURCE,
97         ACCOUNT_FIELD_PACKAGE_NAME,
98         ACCOUNT_FIELD_ACCESS_TOKEN,
99         ACCOUNT_FIELD_DOMAIN_NAME,
100         ACCOUNT_FIELD_AUTH_TYPE,
101         ACCOUNT_FIELD_SECRET,
102         ACCOUNT_FIELD_SYNC_SUPPORT,
103         ACCOUNT_FIELD_USER_TEXT_0,
104         ACCOUNT_FIELD_USER_TEXT_1,
105         ACCOUNT_FIELD_USER_TEXT_2,
106         ACCOUNT_FIELD_USER_TEXT_3,
107         ACCOUNT_FIELD_USER_TEXT_4,
108         ACCOUNT_FIELD_USER_INT_0,
109         ACCOUNT_FIELD_USER_INT_1,
110         ACCOUNT_FIELD_USER_INT_2,
111         ACCOUNT_FIELD_USER_INT_3,
112         ACCOUNT_FIELD_USER_INT_4,
113         ACCOUNT_DB_FIELD_END,
114 } ACCOUNT_DB_IDX;
115
116 /**
117  * @brief       Enumarations for capability fields.
118  */
119
120 typedef enum {
121         CAPABILITY_FIELD_NONE = -1,
122         CAPABILITY_FIELD_ID,
123         CAPABILITY_FIELD_KEY,
124         CAPABILITY_FIELD_VALUE,
125         CAPABILITY_FIELD_PACKAGE_NAME,
126         CAPABILITY_FIELD_USER_NAME,
127         CAPABILITY_FIELD_ACCOUNT_ID,
128         CAPABILITY_FIELD_END,
129 }CAPABILITY_DB_IDX;
130
131 typedef sqlite3_stmt* account_stmt;
132
133 #define ACCOUNT_SCHEMA  "create table %s \n"\
134         "(\n"\
135 "_id INTEGER PRIMARY KEY AUTOINCREMENT, "\
136 "user_name TEXT, "\
137 "email_address TEXT, "\
138 "display_name TEXT, "\
139 "icon_path TEXT, "\
140 "source TEXT, "\
141 "package_name TEXT, "\
142 "access_token TEXT, "\
143 "domain_name TEXT, "\
144 "auth_type INTEGER, "\
145 "secret INTEGER, "\
146 "sync_support INTEGER, "\
147 "txt_custom0 TEXT, "\
148 "txt_custom1 TEXT, "\
149 "txt_custom2 TEXT, "\
150 "txt_custom3 TEXT, "\
151 "txt_custom4 TEXT, "\
152 "int_custom0 INTEGER, "\
153 "int_custom1 INTEGER, "\
154 "int_custom2 INTEGER, "\
155 "int_custom3 INTEGER, "\
156 "int_custom4 INTEGER "\
157 ");"
158
159 #define CAPABILITY_SCHEMA  "create table %s \n"\
160         "(\n"\
161 "_id INTEGER PRIMARY KEY AUTOINCREMENT, "\
162 "key INTEGER, "\
163 "value INTEGER, "\
164 "package_name TEXT, "\
165 "user_name TEXT, "\
166 "account_id INTEGER "\
167 ");"
168
169 typedef struct GSList           account_iterator_s;
170
171 #ifdef __cplusplus
172 }
173 #endif
174
175 #endif /* __SLP_ACCOUNT_PRIVATE_TYPES_H__*/