upload tizen1.0 source
[pkgs/o/oma-ds-service.git] / include / Common / Common_Define_Internal.h
1 /*
2  * oma-ds-service
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: JuHak Park <juhaki.park@samsung.com>,
7  *          JuneHyuk Lee <junhyuk7.lee@samsung.com>,
8  *          SunBong Ha <sunbong.ha@samsung.com>
9  *
10  * Licensed under the Apache License, Version 2.0 (the "License");
11  * you may not use this file except in compliance with the License.
12  * You may obtain a copy of the License at
13  *
14  * http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing, software
17  * distributed under the License is distributed on an "AS IS" BASIS,
18  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  * See the License for the specific language governing permissions and
20  * limitations under the License.
21  *
22  */
23
24
25
26
27
28 /*
29  * For any sort of issue you concern as to this software,
30  * you may use following point of contact.
31  * All resources contributed on this software
32  * are orinigally written by S-Core Inc., a member of Samsung Group.
33  *
34  * SeongWon Shim <seongwon.shim@samsung.com>
35  */
36
37 /**
38  *   @Common_Define_Internal.h
39  *   @version                                                                   0.1
40  *   @brief                                                                             This file is the header file of defined common structure for using between SE and SA
41  */
42
43 #ifndef COMMON_DEFINE_INTERNAL_H_
44 #define COMMON_DEFINE_INTERNAL_H_
45
46
47 #include <malloc.h>
48 #include <stdio.h>
49 #include <glib.h>
50 #include <string.h>
51
52 /*#define COMMUNICATION_TYPE ENCODING_XML*/
53 #define COMMUNICATION_TYPE ENCODING_WBXML_12
54
55 #define TRANSPORT_TYPE 1        /*http*/
56 /*#define TRANSPORT_TYPE "FW_MOBEX"*/   /*mobex -> does not support in OMA*/
57
58 #define NETWORK_TIMEOUT 30
59
60 #define PKG_NAME "oma-ds-service"
61 #define DEFINE_PLATFORM 1
62
63 #define OMA_DS_MSG_PATH "/tmp/Msg"
64 #define OMA_DS_CSC_CHECK_PATH "/opt/data/oma-ds/csc_check"
65
66 #define ELEMENT_TEXT_VCARD "text/x-vcard"
67 #define ELEMENT_TEXT_VCARD_30 "text/vcard"
68 #define ELEMENT_TEXT_VCAL "text/x-vcalendar"
69 #define ELEMENT_TEXT_ICAL "text/calendar"
70 #define ELEMENT_TEXT_PLAIN "text/plain"
71 #define ELEMENT_TEXT_MESSAGE "text/x-vMessage"
72
73 #define DEFINE_ALERT_SLOW_SYNC_STR "Full"
74 #define DEFINE_ALERT_TWO_WAY_STR "Update both"
75 #define DEFINE_ALERT_ONE_WAY_FROM_CLIENT_STR "Update to server"
76 #define DEFINE_ALERT_ONE_WAY_FROM_SERVER_STR "Update to phone"
77 #define DEFINE_ALERT_REFRESH_FROM_SERVER_STR "Refresh from server"
78 #define DEFINE_ALERT_REFRESH_FROM_CLIENT_STR "Refresh from phone"
79
80 #define DEFINE_ALERT_SLOW_SYNC_VALUE "201"
81 #define DEFINE_ALERT_TWO_WAY_VALUE "200"
82 #define DEFINE_ALERT_ONE_WAY_FROM_CLIENT_VALUE "202"
83 #define DEFINE_ALERT_ONE_WAY_FROM_SERVER_VALUE "204"
84 #define DEFINE_ALERT_REFRESH_FROM_SERVER_VALUE "205"
85 #define DEFINE_ALERT_REFRESH_FROM_CLIENT_VALUE "203"
86
87
88 #define DEFINE_CONFIG_KEY_PROFILE_SERVER_ID                                                     "Server_id"
89 #define DEFINE_CONFIG_KEY_PROFILE_SYNC_MODE                                             "Sync_mode"
90 #define DEFINE_CONFIG_KEY_PROFILE_SERVER_IP                                                     "Server_ip"
91 #define DEFINE_CONFIG_KEY_PROFILE_NEXT_NONCE                                            "Next_nonce"
92 #define DEFINE_CONFIG_KEY_PROFILE_DIR_NAME                                                      "Dir_name"
93 #define DEFINE_CONFIG_KEY_PROFILE_SYNCHRONISING                                 "Synchronising"
94 #define DEFINE_CONFIG_KEY_PROFILE_NAME                                                                  "Name"
95 #define DEFINE_CONFIG_KEY_PROFILE_SYNC_TYPE                                                     "Sync_type"
96 #define DEFINE_CONFIG_KEY_PROFILE_SYNC_INTERVAL                                 "Sync_interval"
97 #define DEFINE_CONFIG_KEY_PROFILE_CATEGORY_CONTACTS                     "Contacts"
98 #define DEFINE_CONFIG_KEY_PROFILE_CATEGORY_CALENDAR                     "Organizer"
99 #define DEFINE_CONFIG_KEY_PROFILE_CATEGORY_MEMO                         "Memo"
100 #define DEFINE_CONFIG_KEY_PROFILE_CATEGORY_CALLLOG                      "CallLog"
101 #define DEFINE_CONFIG_KEY_PROFILE_CATEGORY_SOURCE                               "source"
102 #define DEFINE_CONFIG_KEY_PROFILE_CATEGORY_TARGET                               "target"
103 #define DEFINE_CONFIG_KEY_PROFILE_CATEGORY_ID                                           "id"
104 #define DEFINE_CONFIG_KEY_PROFILE_CATEGORY_PASSWORD                     "password"
105 #define DEFINE_CONFIG_KEY_PROFILE_LAST_SESSION_STATUS           "Last_session_status"
106 #define DEFINE_CONFIG_KEY_PROFILE_LAST_SESSION_TIME                     "Last_session_time"
107 #define DEFINE_CONFIG_KEY_PROFILE_STATISTICS_DBSYNCED                   "dbSynced"
108 #define DEFINE_CONFIG_KEY_PROFILE_STATISTICS_LAST_TIME                  "last_session_time"
109 #define DEFINE_CONFIG_KEY_PROFILE_STATISTICS_TOTAL                              "numberOfChanges"
110 #define DEFINE_CONFIG_KEY_PROFILE_STATISTICS_NROFADD                    "add_count"
111 #define DEFINE_CONFIG_KEY_PROFILE_STATISTICS_NROFDELETE         "delete_count"
112 #define DEFINE_CONFIG_KEY_PROFILE_STATISTICS_NROFREPLACE        "replace_count"
113 #define DEFINE_CONFIG_KEY_PROFILE_STATISTICS_SERVER                             "server"
114 #define DEFINE_CONFIG_KEY_PROFILE_STATISTICS_CLIENT                             "client"
115 #define DEFINE_CONFIG_KEY_PROFILE_ALARM_ID                                                      "Alarm_id"
116
117 #define DEFINE_SYNC_MODE_MANUAL "Manual"
118 #define DEFINE_SYNC_MODE_PUSH "Push"
119 #define DEFINE_SYNC_MODE_PERIODIC "Periodic"
120
121 #define DEFINE_SOURCE_CONTACT_URI "Contacts"
122 #define DEFINE_SOURCE_CALENDAR_URI "Organizer"
123 #define DEFINE_SOURCE_MEMO_URI "Memo"
124 #define DEFINE_SOURCE_CALLLOG_URI "CallLog"
125
126 #define DEFINE_CALLLOG_SERVER_URL_HTTPS "https://www.xxxxx.com/sync"
127 #define DEFINE_CALLLOG_SERVER_URL_HTTP "http://www.xxxxx.com/sync"
128 #define DEFINE_CALLLOG_DEFAULT_NEXT_NONCE "pcwds"
129
130 typedef enum {
131         SYNC_SESSION_NOT_SYNCED_YET = -1,
132         SYNC_SESSION_FAILED = 0,
133         SYNC_SESSION_SUCCEEDED = 1,
134         SYNC_SESSION_STOPPED = 2,
135         SYNC_SESSION_SYNCHRONIZING = 3
136 } SyncSessionResult;
137
138 typedef enum  {
139         ALERT_UNKNOWN = 0,
140         ALERT_DISPLAY = 100,
141         ALERT_TWO_WAY = 200,
142         ALERT_SLOW_SYNC = 201,
143         ALERT_ONE_WAY_FROM_CLIENT = 202,
144         ALERT_REFRESH_FROM_CLIENT = 203,
145         ALERT_ONE_WAY_FROM_SERVER = 204,
146         ALERT_REFRESH_FROM_SERVER = 205,
147         ALERT_TWO_WAY_BY_SERVER = 206,
148         ALERT_ONE_WAY_FROM_CLIENT_BY_SERVER = 207,
149         ALERT_REFRESH_FROM_CLIENT_BY_SERVER = 208,
150         ALERT_ONE_WAY_FROM_SERVER_BY_SERVER = 209,
151         ALERT_REFRESH_FROM_SERVER_BY_SERVER = 210,
152         ALERT_RESULT = 221,
153         ALERT_NEXT_MESSAGE = 222,
154         ALERT_NO_END_OF_DATA = 223
155 } AlertType;
156
157 typedef enum {
158         CHANGE_UNKNOWN = 0,
159         CHANGE_ADD = 1,
160         CHANGE_REPLACE = 2,
161         CHANGE_DELETE = 3
162 } ChangeType;
163
164 typedef enum {
165         TYPE_CONTACT = 0,
166         TYPE_CALENDAR,
167         TYPE_MEMO,
168         TYPE_CALLLOG,
169
170         TYPE_CONTENT_COUNT
171 } CONTENT_TYPE;
172
173 typedef enum {
174         COMMON_INIT = 0,
175         COMMON_OK = 100,
176         COMMON_MISCONFIGURATION = 200,
177         COMMON_AUTHENTICATION_ERROR = 201,
178         COMMON_NOT_FOUND = 202,
179         COMMON_NO_MEMORY = 203,
180         COMMON_INTERNAL_ERROR = 204,
181         COMMON_SERVER_ERROR = 205,
182         COMMON_CONNECTION_ERROR = 206,
183         COMMON_AUTOCONFIG_NOT_SUPPORT_BY_SERVER = 207,
184         COMMON_BUSY_SIGNALING = 208,
185         COMMON_CANCEL = 300,
186 } Common_ErrorType;
187
188
189 typedef struct {
190         SyncSessionResult sessionResult;
191         unsigned int numberOfChange;
192         unsigned int received_count;
193         unsigned int add_count;
194         unsigned int replace_count;
195         unsigned int delete_count;
196 } SyncResult;
197
198
199 /**
200  * @brief Data Store information
201  * relevant information about Data Store\n
202  *
203  */
204 typedef struct {
205         int datastore_id;                                                                               /**< plugin_type : TYPE_CONTACT, TYPE_CALENDAR, TYPE_MEMO, TYPE_CALL_LOG */
206         int folder_type_id;                                                                     /**< folder type id 0 */
207         char *target;                                                                                   /**< target(server) URI */
208         char *source;                                                                           /**< source(client) URI */
209         char *id;                                                                                               /**< account id */
210         char *pw;                                                                                               /**< account pw */
211         AlertType clientSyncType;                                               /**< Sync Type(two-way, one-way ...) */
212         AlertType serverSyncType;                                               /**< Sync Type(two-way, one-way ...) */
213         char *lastAnchorClient;                                                 /**< Last Anchor of datastore for clientside */
214         char *nextAnchorClient;                                                 /**< Next Anchor of datastore for clientside */
215         char *lastAnchorServer;                                                 /**< Next Anchor of datastore for serverside */
216         char *nextAnchorServer;                                                 /**< Next Anchor of datastore for serverside */
217         SyncResult *clientSyncResult;
218         SyncResult *serverSyncResult;
219 } Datastore;
220
221
222 typedef struct {
223         char *target;                                                                                   /**< target(server) URI */
224         char *source;                                                                           /**< source(client) URI */
225         AlertType syncType;                                             /**< Sync Type(two-way, one-way ...) */
226         char *lastAnchor;                                                       /**< Last Anchor of datastore for clientside */
227         char *nextAnchor;                                                       /**< Next Anchor of datastore for clientside */
228         unsigned int maxObjSize;
229 } DatastoreInfo;
230
231 /**
232    @brief Third parameter of pre_sync function
233
234    Output data from pre_sync function\n
235    Data that need to be passed to Service Engine from Service Adapter result of pkg2
236
237  */
238 typedef struct {
239         GList *datastoreInfo;                   /**< containing DatastoreInfo structure*/
240         char *devID;
241 } PreSyncReturnObj;
242
243
244 /**
245    @brief a changed item(changelog)
246
247  */
248 typedef struct {
249         ChangeType changeType;                                  /**<  type of changes (add, replace, delete, copy, move ..) */
250         char *luid;                                                                                     /**< luid of item */
251         char *content_type;                                                     /**< content type of data */
252         unsigned int indexOfDatastore;
253         char *data;                                                                             /**< data  */
254 } ChangedItem;
255
256
257 /**
258    @brief item that are grouped by each Data Store
259
260  */
261 typedef struct {
262         char *source;                                                                   /**< source(client) URI */
263         char *target;                                                                           /**< target(server) URI */
264         int needSyncCommand;
265         unsigned int numberOfChanges;
266         int hasNumberOfChanges;
267
268         GList *changeItem;                      /**<  containing ChangedItem  all type */
269         GList *sentItem;                                /**<  containing ChangedItem  */
270 } ChangedDatastore;
271
272
273
274 /**
275    @brief result of applied command that from service engine or server
276
277  */
278 typedef struct {
279         ChangeType changeType;                  /**< change type (add, replace, delete...) */
280         char *luid;                                                                     /**< luid of item */
281         int status;                                                                     /**< status of applied item */
282 } AppliedStatus;
283
284 typedef struct {
285         char *source;                                           /**< source(client) URI */
286         char *target;                                                   /**< target(server) URI */
287         GList *items;                                                   /**< containing ApplliedStatus struct */
288 } SendingStatus;
289
290 /**
291    @brief second and third parameter of sync function
292
293  */
294 typedef struct {
295         GList *changedDatastore;                                        /**< containing ChangedDatastore structure when it's in SyncObj it will be command that client send to server */
296         GList *sendingStatus;                                           /**<  containing SendingStatus structure when it's in SyncObj status of add, replace, delete command from server */
297 } SyncObj;
298
299 typedef struct {
300         GList *changedDatastore;                                        /**< containing ChangedDatastore structure when it's in SyncReturnObj command(add, relpace, delete) from server */
301         GList *status;                                                                  /**<  containing AppliedStatus structure when it's in SyncReturnObj return to engine(status of add, replace, delete command that client sent to server)*/
302 } SyncReturnObj;
303
304 typedef struct {
305         int enabled;
306         char *srcURI;
307         char *tgtURI;
308         char *id;
309         char *password;
310 } sync_category;
311
312 typedef struct {
313         char *name;
314         char *accept;
315         char *id;
316         char *password;
317         char *authType;
318         char *authData;
319 } resource_cp;
320
321 extern Datastore *datastoreinfo_per_content_type[4];
322 extern AlertType syncType;
323
324 #endif /* COMMON_DEFINE_INTERNAL_H_ */