Tizen 2.0 Release
[pkgs/o/oma-ds-service.git] / include / common / common_define_internal.h
1 /*
2  * oma-ds-agent
3  * Copyright (c) 2012 Samsung Electronics Co., Ltd.
4  *
5  * Licensed under the Apache License, Version 2.0 (the License);
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17
18 /**
19  *   @Common_Define_Internal.h
20  *   @version                                                                   0.1
21  *   @brief                                                                             This file is the header file of defined common structure for using between SE and SA
22  */
23
24 #ifndef COMMON_DEFINE_INTERNAL_H_
25 #define COMMON_DEFINE_INTERNAL_H_
26
27 #include <malloc.h>
28 #include <stdio.h>
29 #include <glib.h>
30 #include <string.h>
31
32 /* #define COMMUNICATION_TYPE SYNC_AGENT_PB_ENCODING_XML */
33 #define COMMUNICATION_TYPE SYNC_AGENT_PB_ENCODING_WBXML_12
34
35 #define TRANSPORT_TYPE 1        /*http */
36                                                                              /*#define TRANSPORT_TYPE "FW_MOBEX" *//*mobex -> does not support in OMA */
37
38 #define NETWORK_TIMEOUT 60
39
40 #define MAXIMUM_ACCOUNT_COUNT 5
41
42 #define PKG_NAME "oma-ds-agent"
43 #define DEFINE_PLATFORM 1
44 #define LOW_BATTERY_LEVEL 10
45
46 #define OMA_DS_MSG_PATH "/opt/usr/data/oma-ds/debug_msg"
47 #define OMA_DS_CSC_CHECK_PATH "/opt/usr/data/oma-ds/csc_check"
48
49 #define ELEMENT_TEXT_VCARD "text/x-vcard"
50 #define ELEMENT_TEXT_VCARD_30 "text/vcard"
51 #define ELEMENT_TEXT_VCAL "text/x-vcalendar"
52 #define ELEMENT_TEXT_ICAL "text/calendar"
53 #define ELEMENT_TEXT_PLAIN "text/plain"
54 #define ELEMENT_TEXT_XCALLLOG "text/x-calllog"
55 #define ELEMENT_TEXT_MESSAGE "text/x-vMessage"
56
57 #define DEFINE_ALERT_UNKNOWN_STR "Unknown"
58 #define DEFINE_ALERT_SLOW_SYNC_STR "Full"
59 #define DEFINE_ALERT_TWO_WAY_STR "Update both"
60 #define DEFINE_ALERT_ONE_WAY_FROM_CLIENT_STR "Update to server"
61 #define DEFINE_ALERT_ONE_WAY_FROM_SERVER_STR "Update to phone"
62 #define DEFINE_ALERT_REFRESH_FROM_SERVER_STR "Refresh from server"
63 #define DEFINE_ALERT_REFRESH_FROM_CLIENT_STR "Refresh from phone"
64
65 #define DEFINE_ALERT_SLOW_SYNC_VALUE "201"
66 #define DEFINE_ALERT_TWO_WAY_VALUE "200"
67 #define DEFINE_ALERT_ONE_WAY_FROM_CLIENT_VALUE "202"
68 #define DEFINE_ALERT_ONE_WAY_FROM_SERVER_VALUE "204"
69 #define DEFINE_ALERT_REFRESH_FROM_SERVER_VALUE "205"
70 #define DEFINE_ALERT_REFRESH_FROM_CLIENT_VALUE "203"
71
72 #define DEFINE_CONFIG_KEY_PROFILE_SERVER_ID                                                     "Server_id"
73 #define DEFINE_CONFIG_KEY_PROFILE_SYNC_MODE                                             "Sync_mode"
74 #define DEFINE_CONFIG_KEY_PROFILE_SERVER_IP                                                     "Server_ip"
75 #define DEFINE_CONFIG_KEY_PROFILE_NEXT_NONCE                                            "Next_nonce"
76 #define DEFINE_CONFIG_KEY_PROFILE_DIR_NAME                                                      "Dir_name"
77 #define DEFINE_CONFIG_KEY_PROFILE_SYNCHRONISING                                 "Synchronising"
78 #define DEFINE_CONFIG_KEY_PROFILE_RESUME                                                                "Resume"
79 #define DEFINE_CONFIG_KEY_PROFILE_NAME                                                                  "Name"
80 #define DEFINE_CONFIG_KEY_PROFILE_CLIENT_SYNC_TYPE                                                      "Client_Sync_type"
81 #define DEFINE_CONFIG_KEY_PROFILE_SERVER_SYNC_TYPE                                                      "Server_Sync_type"
82 #define DEFINE_CONFIG_KEY_PROFILE_SYNC_INTERVAL                                 "Sync_interval"
83 #define DEFINE_CONFIG_KEY_PROFILE_CATEGORY_CONTACTS                     "Contacts"
84 #define DEFINE_CONFIG_KEY_PROFILE_CATEGORY_CALENDAR                     "Organizer"
85 #define DEFINE_CONFIG_KEY_PROFILE_CATEGORY_MEMO                         "Memo"
86 #define DEFINE_CONFIG_KEY_PROFILE_CATEGORY_CALLLOG                      "CallLog"
87 #define DEFINE_CONFIG_KEY_PROFILE_CATEGORY_SOURCE                               "source"
88 #define DEFINE_CONFIG_KEY_PROFILE_CATEGORY_TARGET                               "target"
89 #define DEFINE_CONFIG_KEY_PROFILE_CATEGORY_ID                                           "id"
90 #define DEFINE_CONFIG_KEY_PROFILE_CATEGORY_PASSWORD                     "password"
91 #define DEFINE_CONFIG_KEY_PROFILE_LAST_SESSION_STATUS           "Last_session_status"
92 #define DEFINE_CONFIG_KEY_PROFILE_LAST_SESSION_TIME                     "Last_session_time"
93 #define DEFINE_CONFIG_KEY_PROFILE_STATISTICS_DBSYNCED                   "dbSynced"
94 #define DEFINE_CONFIG_KEY_PROFILE_STATISTICS_LAST_TIME                  "last_session_time"
95 #define DEFINE_CONFIG_KEY_PROFILE_STATISTICS_TOTAL                              "numberOfChanges"
96 #define DEFINE_CONFIG_KEY_PROFILE_STATISTICS_NROFADD                    "add_count"
97 #define DEFINE_CONFIG_KEY_PROFILE_STATISTICS_NROFDELETE         "delete_count"
98 #define DEFINE_CONFIG_KEY_PROFILE_STATISTICS_NROFREPLACE        "replace_count"
99 #define DEFINE_CONFIG_KEY_PROFILE_STATISTICS_SERVER                             "server"
100 #define DEFINE_CONFIG_KEY_PROFILE_STATISTICS_CLIENT                             "client"
101 #define DEFINE_CONFIG_KEY_PROFILE_ALARM_ID                                                      "Alarm_id"
102
103 #define DEFINE_SYNC_MODE_MANUAL "Manual"
104 #define DEFINE_SYNC_MODE_PUSH "Push"
105 #define DEFINE_SYNC_MODE_PERIODIC "Periodic"
106
107 #define DEFINE_SOURCE_CONTACT_URI "Contacts"
108 #define DEFINE_SOURCE_CALENDAR_URI "Organizer"
109 #define DEFINE_SOURCE_MEMO_URI "Memo"
110 #define DEFINE_SOURCE_CALLLOG_URI "CallLog"
111
112 #define DEFINE_DIVE_SERVER_URL_HTTPS "https://syn.samsungdive.com/sync"
113 #define DEFINE_DIVE_SERVER_URL_HTTP "http://syn.samsungdive.com/sync"
114 #define DEFINE_DIVE_SERVER_ID "syn.samsungdive.com"
115 #define DEFINE_DIVE_DEFAULT_NEXT_NONCE "pcwds"
116
117 typedef enum {
118         SYNC_SESSION_NOT_SYNCED_YET = -1,
119         SYNC_SESSION_FAILED = 0,
120         SYNC_SESSION_SUCCEEDED = 1,
121         SYNC_SESSION_STOPPED = 2,
122         SYNC_SESSION_SYNCHRONIZING = 3
123 } sync_session_result_e;
124
125 typedef enum {
126         ALERT_UNKNOWN = 0,
127         ALERT_DISPLAY = 100,
128         ALERT_TWO_WAY = 200,
129         ALERT_SLOW_SYNC = 201,
130         ALERT_ONE_WAY_FROM_CLIENT = 202,
131         ALERT_REFRESH_FROM_CLIENT = 203,
132         ALERT_ONE_WAY_FROM_SERVER = 204,
133         ALERT_REFRESH_FROM_SERVER = 205,
134         ALERT_TWO_WAY_BY_SERVER = 206,
135         ALERT_ONE_WAY_FROM_CLIENT_BY_SERVER = 207,
136         ALERT_REFRESH_FROM_CLIENT_BY_SERVER = 208,
137         ALERT_ONE_WAY_FROM_SERVER_BY_SERVER = 209,
138         ALERT_REFRESH_FROM_SERVER_BY_SERVER = 210,
139         ALERT_RESULT = 221,
140         ALERT_NEXT_MESSAGE = 222,
141         ALERT_NO_END_OF_DATA = 223,
142         ALERT_SUSPEND = 224,
143         ALERT_RESUME = 225,
144 } alert_type_e;
145
146 typedef enum {
147         CHANGE_UNKNOWN = 0,
148         CHANGE_ADD = 1,
149         CHANGE_REPLACE = 2,
150         CHANGE_DELETE = 3
151 } change_type_e;
152
153 typedef enum {
154         TYPE_CONTACT = 0,
155         TYPE_CALENDAR,
156         TYPE_MEMO,
157         TYPE_CALLLOG,
158
159         TYPE_SERVICE_COUNT
160 } service_type_e;
161
162 typedef enum {
163         COMMON_INIT = 0,
164         COMMON_OK = 100,
165         COMMON_MISCONFIGURATION = 200,
166         COMMON_AUTHENTICATION_ERROR = 201,
167         COMMON_NOT_FOUND = 202,
168         COMMON_NO_MEMORY = 203,
169         COMMON_INTERNAL_ERROR = 204,
170         COMMON_SERVER_ERROR = 205,
171         COMMON_CONNECTION_ERROR = 206,
172         COMMON_AUTOCONFIG_NOT_SUPPORT_BY_SERVER = 207,
173         COMMON_BUSY_SIGNALING = 208,
174         COMMON_SUSPEND_FAIL = 209,
175         COMMON_CANCEL = 300,
176 } common_error_type_e;
177
178 typedef struct {
179         sync_session_result_e session_result;
180         unsigned int number_of_change;
181         unsigned int received_count;
182         unsigned int add_count;
183         unsigned int replace_count;
184         unsigned int delete_count;
185 } sync_result_s;
186
187 /**
188  * @brief Data Store information
189  * relevant information about Data Store\n
190  *
191  */
192 typedef struct {
193         int datastore_id;                                                                               /**< plugin_type : TYPE_CONTACT, TYPE_CALENDAR, TYPE_MEMO, TYPE_CALL_LOG */
194         int folder_type_id;                                                                     /**< folder type id 0 */
195         char *target;                                                                                   /**< target(server) URI */
196         char *source;                                                                           /**< source(client) URI */
197         char *id;                                                                                               /**< account id */
198         char *pw;                                                                                               /**< account pw */
199         alert_type_e client_sync_type;                                          /**< Sync Type(two-way, one-way ...) */
200         alert_type_e server_sync_type;                                          /**< Sync Type(two-way, one-way ...) */
201         char *last_anchor_client;                                                       /**< Last Anchor of datastore for client side */
202         char *next_anchor_client;                                                       /**< Next Anchor of datastore for client side */
203         char *last_anchor_server;                                                       /**< Next Anchor of datastore for server side */
204         char *next_anchor_server;                                                       /**< Next Anchor of datastore for server side */
205         sync_result_s *client_sync_result;
206         sync_result_s *server_sync_result;
207 } datastore_s;
208
209 typedef struct {
210         char *target;                                                                                   /**< target(server) URI */
211         char *source;                                                                           /**< source(client) URI */
212         alert_type_e sync_type;                                         /**< Sync Type(two-way, one-way ...) */
213         char *last_anchor;                                                      /**< Last Anchor of datastore for client side */
214         char *next_anchor;                                                      /**< Next Anchor of datastore for client side */
215         unsigned int max_obj_size;
216 } datastore_info_s;
217
218 /**
219    @brief Third parameter of pre_sync function
220
221    Output data from pre_sync function\n
222    Data that need to be passed to Service Engine from Service Adapter result of pkg2
223
224  */
225 typedef struct {
226         GList *datastore_info;                  /**< containing datastore_info structure*/
227         char *dev_id;
228 } pre_sync_return_obj_s;
229
230 /**
231    @brief a changed item(changelog)
232
233  */
234 typedef struct {
235         change_type_e change_type;                                      /**<  type of changes (add, replace, delete, copy, move ..) */
236         char *luid;                                                                                     /**< luid of item */
237         char *content_type;                                                     /**< content type of data */
238         unsigned int index_of_datastore;
239         char *data;                                                                             /**< data  */
240 } changed_item_s;
241
242 /**
243    @brief item that are grouped by each Data Store
244
245  */
246 typedef struct {
247         char *source;                                                                   /**< source(client) URI */
248         char *target;                                                                           /**< target(server) URI */
249         int need_sync_command;
250         unsigned int number_of_changes;
251         int has_number_of_changes;
252
253         GList *change_item;                     /**<  containing changed_item  all type */
254         GList *sent_item;                               /**<  containing changed_item  */
255 } changed_datastore_s;
256
257 /**
258    @brief result of applied command that from service engine or server
259
260  */
261 typedef struct {
262         change_type_e change_type;                      /**< change type (add, replace, delete...) */
263         char *luid;                                                                     /**< luid of item */
264         int status;                                                                     /**< status of applied item */
265 } applied_status_s;
266
267 typedef struct {
268         char *source;                                           /**< source(client) URI */
269         char *target;                                                   /**< target(server) URI */
270         GList *items;                                                   /**< containing appllied_status struct */
271 } sending_status_s;
272
273 /**
274    @brief second and third parameter of sync function
275
276  */
277 typedef struct {
278         GList *changed_datastore;                                       /**< containing changed_datastore structure when it's in SyncObj it will be command that client send to server */
279         GList *sending_status;                                          /**<  containing sending_status structure when it's in SyncObj status of add, replace, delete command from server */
280 } sync_obj_s;
281
282 typedef struct {
283         GList *changed_datastore;                                       /**< containing changed_datastore structure when it's in SyncReturnObj command(add, relpace, delete) from server */
284         GList *status;                                                                  /**<  containing applied_status structure when it's in SyncReturnObj return to engine(status of add, replace, delete command that client sent to server)*/
285 } sync_return_obj_s;
286
287 typedef struct {
288         service_type_e service_type;
289         int enabled;
290         char *src_uri;
291         char *tgt_uri;
292         char *id;
293         char *password;
294 } sync_service_s;
295
296 typedef struct {
297         char *name;
298         char *accept;
299         char *id;
300         char *password;
301         char *auth_type;
302         char *auth_data;
303 } resource_cp_s;
304
305 extern datastore_s *datastoreinfo_per_content_type[4];
306
307 #endif                          /* COMMON_DEFINE_INTERNAL_H_ */