3 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 * @OMA_DS_Engine_Controller_Task.c
21 * @brief This file is the source file of implementation of make and register task to Engine Controller
26 #include <sync_agent.h>
28 #include "framework/task/oma_ds_engine_controller_task.h"
29 #include "service-engine/se_account.h"
30 #include "service-engine/se_sync.h"
31 #include "service-engine/se_storage.h"
33 #ifndef OMADS_AGENT_LOG
35 #define LOG_TAG "OMA_DS_COMMON"
38 static GList *sync_request_id_list = NULL;
40 static void _free_sync_categorie_list(void *list);
41 static void _free_delete_profile_list(void *list);
42 static void _free_resource_cp_list(void *list);
44 static void _request_msg_info_free(request_msg_info_t * info);
45 static void *_string_copy_struct(void *string);
46 static request_msg_info_t *_create_request_msg_info(int sync_type, unsigned int request_id);
48 static void __free_resource_cp(resource_cp_s * resource);
50 static void _free_sync_categorie_list(void *list)
53 retm_if(list == NULL, "list is NULL");
55 GList *categories = (GList *) list;
57 for (iter = categories; iter != NULL; iter = g_list_next(iter))
58 free_sync_service(iter->data);
60 g_list_free(categories);
64 static void _free_delete_profile_list(void *list)
67 retm_if(list == NULL, "list is NULL");
69 GList *profiles = (GList *) list;
71 for (iter = profiles; iter != NULL; iter = g_list_next(iter))
74 g_list_free(profiles);
78 static void _free_resource_cp_list(void *list)
81 retm_if(list == NULL, "list is NULL");
83 GList *profiles = (GList *) list;
85 for (iter = profiles; iter != NULL; iter = g_list_next(iter))
86 __free_resource_cp(iter->data);
88 g_list_free(profiles);
92 static void __free_resource_cp(resource_cp_s * resource)
95 retm_if(resource == NULL, "resource is NULL");
97 if (resource->name != NULL)
100 if (resource->accept != NULL)
101 free(resource->accept);
103 if (resource->id != NULL)
106 if (resource->password != NULL)
107 free(resource->password);
109 if (resource->auth_type != NULL)
110 free(resource->auth_type);
112 if (resource->auth_data != NULL)
113 free(resource->auth_data);
119 static request_msg_info_t *_create_request_msg_info(int sync_type, unsigned int request_id)
122 request_msg_info_t *pInfo = (request_msg_info_t *) calloc(1, sizeof(request_msg_info_t));
123 retvm_if(pInfo == NULL, NULL, "pInfo is NULL");
125 pInfo->sync_type = sync_type;
126 pInfo->request_id = request_id;
132 static void _request_msg_info_free(request_msg_info_t * info)
142 static void *_string_copy_struct(void *string)
147 data = strdup((const char *)string);
153 sync_agent_ec_task_spec_s *make_synchronize_task()
157 sync_agent_ec_param_spec_s *pParam_spec1 = sync_agent_alloc_param_spec_int("accountId", true, false, false, 0, 0, false, 0, false, 0, 0);
158 sync_agent_ec_param_spec_s *pParam_spec2 = sync_agent_alloc_param_spec_structure("syncMode", _string_copy_struct, free,
159 true, false, false, NULL, false, NULL, false, NULL);
160 sync_agent_ec_param_spec_s *pParam_spec3 = sync_agent_alloc_param_spec_structure("sanPackage", NULL, sanPackageParserFree,
161 true, false, false, NULL, false, NULL, false, NULL);
162 sync_agent_ec_param_spec_s *param_spec_array[3] = { pParam_spec1, pParam_spec2, pParam_spec3 };
164 sync_agent_ec_task_spec_s *pTask_spec = sync_agent_alloc_simple_task_spec("synchronize",
165 synchronize_task_process, NULL, NULL,
166 3, param_spec_array);
168 sync_agent_unref_param_spec(pParam_spec1);
169 sync_agent_unref_param_spec(pParam_spec2);
170 sync_agent_unref_param_spec(pParam_spec3);
176 sync_agent_ec_task_spec_s *make_add_profile_task()
180 sync_agent_ec_param_spec_s *pParam_spec1 = sync_agent_alloc_param_spec_structure("profileName", _string_copy_struct, free,
181 true, false, false, NULL, false, NULL, false, NULL);
182 sync_agent_ec_param_spec_s *pParam_spec2 = sync_agent_alloc_param_spec_structure("addr", _string_copy_struct, free,
183 true, false, false, NULL, false, NULL, false, NULL);
184 sync_agent_ec_param_spec_s *pParam_spec3 = sync_agent_alloc_param_spec_structure("id", _string_copy_struct, free,
185 true, false, false, NULL, false, NULL, false, NULL);
186 sync_agent_ec_param_spec_s *pParam_spec4 = sync_agent_alloc_param_spec_structure("password", _string_copy_struct, free,
187 true, false, false, NULL, false, NULL, false, NULL);
188 sync_agent_ec_param_spec_s *pParam_spec5 = sync_agent_alloc_param_spec_int("syncMode", true, false, false, 0, 0, false, 0, false, 0, 0);
189 sync_agent_ec_param_spec_s *pParam_spec6 = sync_agent_alloc_param_spec_int("syncType", true, false, false, 0, 0, false, 0, false, 0, 0);
190 sync_agent_ec_param_spec_s *pParam_spec7 = sync_agent_alloc_param_spec_int("interval", true, false, false, 0, 0, false, 0, false, 0, 0);
191 sync_agent_ec_param_spec_s *pParam_spec8 = sync_agent_alloc_param_spec_structure("categories", NULL, _free_sync_categorie_list,
192 true, false, false, NULL, false, NULL, false, NULL);
194 sync_agent_ec_param_spec_s *pParam_spec9 = sync_agent_alloc_param_spec_int("result", false, true, false, 0, 0, false, 0, false, 0, 0);
195 sync_agent_ec_param_spec_s *pParam_spec10 = sync_agent_alloc_param_spec_int("accountId", false, true, false, 0, 0, false, 0, false, 0, 0);
197 sync_agent_ec_param_spec_s *param_spec_array[10] = { pParam_spec1, pParam_spec2, pParam_spec3, pParam_spec4, pParam_spec5,
198 pParam_spec6, pParam_spec7, pParam_spec8, pParam_spec9, pParam_spec10
201 sync_agent_ec_task_spec_s *pTask_spec = sync_agent_alloc_simple_task_spec("add_profile",
202 add_profile_task_process, NULL, NULL,
203 10, param_spec_array);
205 sync_agent_unref_param_spec(pParam_spec1);
206 sync_agent_unref_param_spec(pParam_spec2);
207 sync_agent_unref_param_spec(pParam_spec3);
208 sync_agent_unref_param_spec(pParam_spec4);
209 sync_agent_unref_param_spec(pParam_spec5);
210 sync_agent_unref_param_spec(pParam_spec6);
211 sync_agent_unref_param_spec(pParam_spec7);
212 sync_agent_unref_param_spec(pParam_spec8);
213 sync_agent_unref_param_spec(pParam_spec9);
214 sync_agent_unref_param_spec(pParam_spec10);
220 sync_agent_ec_task_spec_s *make_edit_profile_task()
224 sync_agent_ec_param_spec_s *pParam_spec1 = sync_agent_alloc_param_spec_int("accountId", true, false, false, 0, 0, false, 0, false, 0, 0);
225 sync_agent_ec_param_spec_s *pParam_spec2 = sync_agent_alloc_param_spec_structure("profileName", _string_copy_struct, free,
226 true, false, false, NULL, false, NULL, false, NULL);
227 sync_agent_ec_param_spec_s *pParam_spec3 = sync_agent_alloc_param_spec_structure("addr", _string_copy_struct, free,
228 true, false, false, NULL, false, NULL, false, NULL);
229 sync_agent_ec_param_spec_s *pParam_spec4 = sync_agent_alloc_param_spec_structure("id", _string_copy_struct, free,
230 true, false, false, NULL, false, NULL, false, NULL);
231 sync_agent_ec_param_spec_s *pParam_spec5 = sync_agent_alloc_param_spec_structure("password", _string_copy_struct, free,
232 true, false, false, NULL, false, NULL, false, NULL);
233 sync_agent_ec_param_spec_s *pParam_spec6 = sync_agent_alloc_param_spec_int("syncMode", true, false, false, 0, 0, false, 0, false, 0, 0);
234 sync_agent_ec_param_spec_s *pParam_spec7 = sync_agent_alloc_param_spec_int("syncType", true, false, false, 0, 0, false, 0, false, 0, 0);
235 sync_agent_ec_param_spec_s *pParam_spec8 = sync_agent_alloc_param_spec_int("interval", true, false, false, 0, 0, false, 0, false, 0, 0);
236 sync_agent_ec_param_spec_s *pParam_spec9 = sync_agent_alloc_param_spec_structure("categories", NULL, _free_sync_categorie_list,
237 true, false, false, NULL, false, NULL, false, NULL);
239 sync_agent_ec_param_spec_s *pParam_spec10 = sync_agent_alloc_param_spec_int("result", false, true, false, 0, 0, false, 0, false, 0, 0);
241 sync_agent_ec_param_spec_s *param_spec_array[10] = { pParam_spec1, pParam_spec2, pParam_spec3, pParam_spec4, pParam_spec5,
242 pParam_spec6, pParam_spec7, pParam_spec8, pParam_spec9, pParam_spec10
245 sync_agent_ec_task_spec_s *pTask_spec = sync_agent_alloc_simple_task_spec("edit_profile",
246 edit_profile_task_process, NULL, NULL,
247 10, param_spec_array);
249 sync_agent_unref_param_spec(pParam_spec1);
250 sync_agent_unref_param_spec(pParam_spec2);
251 sync_agent_unref_param_spec(pParam_spec3);
252 sync_agent_unref_param_spec(pParam_spec4);
253 sync_agent_unref_param_spec(pParam_spec5);
254 sync_agent_unref_param_spec(pParam_spec6);
255 sync_agent_unref_param_spec(pParam_spec7);
256 sync_agent_unref_param_spec(pParam_spec8);
257 sync_agent_unref_param_spec(pParam_spec9);
258 sync_agent_unref_param_spec(pParam_spec10);
264 sync_agent_ec_task_spec_s *make_delete_profile_task()
268 sync_agent_ec_param_spec_s *pParam_spec1 = sync_agent_alloc_param_spec_structure("profiles", NULL, _free_delete_profile_list,
269 true, false, false, NULL, false, NULL, false, NULL);
271 sync_agent_ec_param_spec_s *pParam_spec2 = sync_agent_alloc_param_spec_int("result", false, true, false, 0, 0, false, 0, false, 0, 0);
273 sync_agent_ec_param_spec_s *param_spec_array[2] = { pParam_spec1, pParam_spec2 };
275 sync_agent_ec_task_spec_s *pTask_spec = sync_agent_alloc_simple_task_spec("delete_profile",
276 delete_profile_task_process, NULL, NULL,
277 2, param_spec_array);
279 sync_agent_unref_param_spec(pParam_spec1);
280 sync_agent_unref_param_spec(pParam_spec2);
286 sync_agent_ec_task_spec_s *make_get_profile_data_task()
290 sync_agent_ec_param_spec_s *pParam_spec1 = sync_agent_alloc_param_spec_int("accountId", true, false, false, 0, 0, false, 0, false, 0, 0);
292 sync_agent_ec_param_spec_s *pParam_spec2 = sync_agent_alloc_param_spec_int("result", false, true, false, 0, 0, false, 0, false, 0, 0);
293 sync_agent_ec_param_spec_s *pParam_spec3 = sync_agent_alloc_param_spec_structure("profileName", _string_copy_struct, free,
294 false, true, false, NULL, false, NULL, false, NULL);
295 sync_agent_ec_param_spec_s *pParam_spec4 = sync_agent_alloc_param_spec_structure("addr", _string_copy_struct, free,
296 false, true, false, NULL, false, NULL, false, NULL);
297 sync_agent_ec_param_spec_s *pParam_spec5 = sync_agent_alloc_param_spec_structure("id", _string_copy_struct, free,
298 false, true, false, NULL, false, NULL, false, NULL);
299 sync_agent_ec_param_spec_s *pParam_spec6 = sync_agent_alloc_param_spec_structure("password", _string_copy_struct, free,
300 false, true, false, NULL, false, NULL, false, NULL);
301 sync_agent_ec_param_spec_s *pParam_spec7 = sync_agent_alloc_param_spec_int("syncMode", false, true, false, 0, 0, false, 0, false, 0, 0);
302 sync_agent_ec_param_spec_s *pParam_spec8 = sync_agent_alloc_param_spec_int("syncType", false, true, false, 0, 0, false, 0, false, 0, 0);
303 sync_agent_ec_param_spec_s *pParam_spec9 = sync_agent_alloc_param_spec_int("interval", false, true, false, 0, 0, false, 0, false, 0, 0);
304 sync_agent_ec_param_spec_s *pParam_spec10 = sync_agent_alloc_param_spec_int("lastSessionStatus", false, true, false, 0, 0, false, 0, false, 0, 0);
305 sync_agent_ec_param_spec_s *pParam_spec11 = sync_agent_alloc_param_spec_int("lastSessionTime", false, true, false, 0, 0, false, 0, false, 0, 0);
307 sync_agent_ec_param_spec_s *param_spec_array[11] = { pParam_spec1, pParam_spec2, pParam_spec3,
308 pParam_spec4, pParam_spec5, pParam_spec6, pParam_spec7, pParam_spec8,
309 pParam_spec9, pParam_spec10, pParam_spec11
312 sync_agent_ec_task_spec_s *pTask_spec = sync_agent_alloc_simple_task_spec("get_profile_data",
313 get_profile_data_task_process, NULL, NULL,
314 11, param_spec_array);
316 sync_agent_unref_param_spec(pParam_spec1);
317 sync_agent_unref_param_spec(pParam_spec2);
318 sync_agent_unref_param_spec(pParam_spec3);
319 sync_agent_unref_param_spec(pParam_spec4);
320 sync_agent_unref_param_spec(pParam_spec5);
321 sync_agent_unref_param_spec(pParam_spec6);
322 sync_agent_unref_param_spec(pParam_spec7);
323 sync_agent_unref_param_spec(pParam_spec8);
324 sync_agent_unref_param_spec(pParam_spec9);
325 sync_agent_unref_param_spec(pParam_spec10);
326 sync_agent_unref_param_spec(pParam_spec11);
332 sync_agent_ec_task_spec_s *make_get_profile_sync_category_task()
336 sync_agent_ec_param_spec_s *pParam_spec1 = sync_agent_alloc_param_spec_int("accountId", true, false, false, 0, 0, false, 0, false, 0, 0);
337 sync_agent_ec_param_spec_s *pParam_spec2 = sync_agent_alloc_param_spec_int("contentType", true, false, false, 0, 0, false, 0, false, 0, 0);
339 sync_agent_ec_param_spec_s *pParam_spec3 = sync_agent_alloc_param_spec_int("result", false, true, false, 0, 0, false, 0, false, 0, 0);
340 sync_agent_ec_param_spec_s *pParam_spec4 = sync_agent_alloc_param_spec_int("enabled", false, true, false, 0, 0, false, 0, false, 0, 0);
341 sync_agent_ec_param_spec_s *pParam_spec5 = sync_agent_alloc_param_spec_int("srcURI", false, true, false, 0, 0, false, 0, false, 0, 0);
342 sync_agent_ec_param_spec_s *pParam_spec6 = sync_agent_alloc_param_spec_structure("tgtURI", _string_copy_struct, free,
343 false, true, false, NULL, false, NULL, false, NULL);
344 sync_agent_ec_param_spec_s *pParam_spec7 = sync_agent_alloc_param_spec_structure("id", _string_copy_struct, free,
345 false, true, false, NULL, false, NULL, false, NULL);
346 sync_agent_ec_param_spec_s *pParam_spec8 = sync_agent_alloc_param_spec_structure("password", _string_copy_struct, free,
347 false, true, false, NULL, false, NULL, false, NULL);
349 sync_agent_ec_param_spec_s *param_spec_array[8] = { pParam_spec1, pParam_spec2, pParam_spec3, pParam_spec4,
350 pParam_spec5, pParam_spec6, pParam_spec7, pParam_spec8
353 sync_agent_ec_task_spec_s *pTask_spec = sync_agent_alloc_simple_task_spec("get_profile_sync_category",
354 get_profile_sync_category_task_process, NULL, NULL,
355 8, param_spec_array);
357 sync_agent_unref_param_spec(pParam_spec1);
358 sync_agent_unref_param_spec(pParam_spec2);
359 sync_agent_unref_param_spec(pParam_spec3);
360 sync_agent_unref_param_spec(pParam_spec4);
361 sync_agent_unref_param_spec(pParam_spec5);
362 sync_agent_unref_param_spec(pParam_spec6);
363 sync_agent_unref_param_spec(pParam_spec7);
364 sync_agent_unref_param_spec(pParam_spec8);
370 sync_agent_ec_task_spec_s *make_get_profile_statistics_task()
374 sync_agent_ec_param_spec_s *pParam_spec1 = sync_agent_alloc_param_spec_int("accountId", true, false, false, 0, 0, false, 0, false, 0, 0);
375 sync_agent_ec_param_spec_s *pParam_spec2 = sync_agent_alloc_param_spec_int("contentType", true, false, false, 0, 0, false, 0, false, 0, 0);
377 sync_agent_ec_param_spec_s *pParam_spec3 = sync_agent_alloc_param_spec_int("result", false, true, false, 0, 0, false, 0, false, 0, 0);
378 sync_agent_ec_param_spec_s *pParam_spec4 = sync_agent_alloc_param_spec_structure("dbSynced", _string_copy_struct, free,
379 false, true, false, NULL, false, NULL, false, NULL);
380 sync_agent_ec_param_spec_s *pParam_spec5 = sync_agent_alloc_param_spec_int("lastSessionTime", false, true, false, 0, 0, false, 0, false, 0, 0);
381 sync_agent_ec_param_spec_s *pParam_spec6 = sync_agent_alloc_param_spec_int("server2Client_Total", false, true, false, 0, 0, false, 0, false, 0, 0);
382 sync_agent_ec_param_spec_s *pParam_spec7 = sync_agent_alloc_param_spec_int("server2Client_NrOfAdd", false, true, false, 0, 0, false, 0, false, 0, 0);
383 sync_agent_ec_param_spec_s *pParam_spec8 = sync_agent_alloc_param_spec_int("server2Client_NrOfDelete", false, true, false, 0, 0, false, 0, false, 0, 0);
384 sync_agent_ec_param_spec_s *pParam_spec9 = sync_agent_alloc_param_spec_int("server2Client_NrOfReplace", false, true, false, 0, 0, false, 0, false, 0, 0);
385 sync_agent_ec_param_spec_s *pParam_spec10 = sync_agent_alloc_param_spec_int("client2Server_Total", false, true, false, 0, 0, false, 0, false, 0, 0);
386 sync_agent_ec_param_spec_s *pParam_spec11 = sync_agent_alloc_param_spec_int("client2Server_NrOfAdd", false, true, false, 0, 0, false, 0, false, 0, 0);
387 sync_agent_ec_param_spec_s *pParam_spec12 = sync_agent_alloc_param_spec_int("client2Server_NrOfDelete", false, true, false, 0, 0, false, 0, false, 0, 0);
388 sync_agent_ec_param_spec_s *pParam_spec13 = sync_agent_alloc_param_spec_int("client2Server_NrOfReplace", false, true, false, 0, 0, false, 0, false, 0, 0);
390 sync_agent_ec_param_spec_s *param_spec_array[13] = { pParam_spec1, pParam_spec2, pParam_spec3,
391 pParam_spec4, pParam_spec5, pParam_spec6, pParam_spec7, pParam_spec8,
392 pParam_spec9, pParam_spec10, pParam_spec11, pParam_spec12, pParam_spec13
395 sync_agent_ec_task_spec_s *pTask_spec = sync_agent_alloc_simple_task_spec("get_profile_statistics",
396 get_profile_statistics_task_process, NULL, NULL,
397 13, param_spec_array);
399 sync_agent_unref_param_spec(pParam_spec1);
400 sync_agent_unref_param_spec(pParam_spec2);
401 sync_agent_unref_param_spec(pParam_spec3);
402 sync_agent_unref_param_spec(pParam_spec4);
403 sync_agent_unref_param_spec(pParam_spec5);
404 sync_agent_unref_param_spec(pParam_spec6);
405 sync_agent_unref_param_spec(pParam_spec7);
406 sync_agent_unref_param_spec(pParam_spec8);
407 sync_agent_unref_param_spec(pParam_spec9);
408 sync_agent_unref_param_spec(pParam_spec10);
409 sync_agent_unref_param_spec(pParam_spec11);
410 sync_agent_unref_param_spec(pParam_spec12);
411 sync_agent_unref_param_spec(pParam_spec13);
417 sync_agent_ec_task_spec_s *make_reset_synchronizing_profiles_task()
421 sync_agent_ec_task_spec_s *pTask_spec = sync_agent_alloc_simple_task_spec("reset_synchronizing_profiles",
422 reset_synchronizing_profiles_task_process, NULL, NULL,
429 sync_agent_ec_task_spec_s *make_add_profile_cp_task()
433 sync_agent_ec_param_spec_s *pParam_spec1 = sync_agent_alloc_param_spec_structure("profileName", _string_copy_struct, free,
434 true, false, false, NULL, false, NULL, false, NULL);
435 sync_agent_ec_param_spec_s *pParam_spec2 = sync_agent_alloc_param_spec_structure("addr", _string_copy_struct, free,
436 true, false, false, NULL, false, NULL, false, NULL);
437 sync_agent_ec_param_spec_s *pParam_spec3 = sync_agent_alloc_param_spec_structure("id", _string_copy_struct, free,
438 true, false, false, NULL, false, NULL, false, NULL);
439 sync_agent_ec_param_spec_s *pParam_spec4 = sync_agent_alloc_param_spec_structure("password", _string_copy_struct, free,
440 true, false, false, NULL, false, NULL, false, NULL);
441 sync_agent_ec_param_spec_s *pParam_spec5 = sync_agent_alloc_param_spec_structure("categories", NULL, _free_resource_cp_list,
442 true, false, false, NULL, false, NULL, false, NULL);
444 sync_agent_ec_param_spec_s *pParam_spec6 = sync_agent_alloc_param_spec_int("result", false, true, false, 0, 0, false, 0, false, 0, 0);
445 sync_agent_ec_param_spec_s *pParam_spec7 = sync_agent_alloc_param_spec_int("accountId", false, true, false, 0, 0, false, 0, false, 0, 0);
447 sync_agent_ec_param_spec_s *param_spec_array[7] = { pParam_spec1, pParam_spec2, pParam_spec3, pParam_spec4, pParam_spec5,
448 pParam_spec6, pParam_spec7
451 sync_agent_ec_task_spec_s *pTask_spec = sync_agent_alloc_simple_task_spec("add_profile_cp",
452 add_profile_cp_task_process, NULL, NULL,
453 7, param_spec_array);
455 sync_agent_unref_param_spec(pParam_spec1);
456 sync_agent_unref_param_spec(pParam_spec2);
457 sync_agent_unref_param_spec(pParam_spec3);
458 sync_agent_unref_param_spec(pParam_spec4);
459 sync_agent_unref_param_spec(pParam_spec5);
460 sync_agent_unref_param_spec(pParam_spec6);
461 sync_agent_unref_param_spec(pParam_spec7);
467 sync_agent_ec_task_spec_s *make_refresh_from_service_task()
471 sync_agent_ec_param_spec_s *pParam_spec1 = sync_agent_alloc_param_spec_int("accountId", true, false, false, 0, 0, false, 0, false, 0, 0);
473 sync_agent_ec_param_spec_s *param_spec_array[1] = { pParam_spec1 };
475 sync_agent_ec_task_spec_s *pTask_spec = sync_agent_alloc_simple_task_spec("refresh_from_service",
476 refresh_from_service_task_process, NULL, NULL,
477 1, param_spec_array);
479 sync_agent_unref_param_spec(pParam_spec1);
485 sync_agent_ec_task_spec_s *make_cancel_request_task()
489 sync_agent_ec_task_spec_s *pTask_spec = sync_agent_alloc_simple_task_spec("cancel_sync_request",
490 cancel_sync_request_task_process, NULL, NULL,
497 sync_agent_ec_task_spec_s *make_reset_all_data_task()
501 sync_agent_ec_param_spec_s *pParam_spec1 = sync_agent_alloc_param_spec_int("result", false, true, false, 0, 0, false, 0, false, 0, 0);
502 sync_agent_ec_param_spec_s *param_spec_array[1] = { pParam_spec1 };
504 sync_agent_ec_task_spec_s *pTask_spec = sync_agent_alloc_simple_task_spec("reset_all_data",
505 reset_all_data_task_process, NULL, NULL,
506 1, param_spec_array);
508 sync_agent_unref_param_spec(pParam_spec1);
514 sync_agent_ec_task_spec_s *make_get_all_profiles_data_task()
518 sync_agent_ec_param_spec_s *pParam_spec1 = sync_agent_alloc_param_spec_int("result", false, true, false, 0, 0, false, 0, false, 0, 0);
519 sync_agent_ec_param_spec_s *pParam_spec2 = sync_agent_alloc_param_spec_structure("profilesData", NULL, NULL,
520 false, true, false, NULL, false, NULL, false, NULL);
522 sync_agent_ec_param_spec_s *param_spec_array[2] = { pParam_spec1, pParam_spec2 };
524 sync_agent_ec_task_spec_s *pTask_spec = sync_agent_alloc_simple_task_spec("get_all_profiles_data",
525 get_all_profiles_data_task_process, NULL, NULL,
526 2, param_spec_array);
532 sync_agent_ec_task_error_e synchronize_task_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array)
536 sync_agent_ec_task_error_e err = SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS;
539 sync_agent_get_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &accountId);
540 retvm_if(accountId < 0, SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED, "account id = %d", accountId);
542 char *syncMode = NULL;
543 sync_agent_get_param_value(&(param_array[1]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &syncMode);
545 san_package_s *pSanPackage = NULL;
546 sync_agent_get_param_value(&(param_array[2]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &pSanPackage);
548 _DEBUG_INFO("accountId = %d", accountId);
549 _DEBUG_INFO("syncMode = %s", syncMode);
551 bool result = synchronize(accountId, syncMode, pSanPackage);
553 err = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
559 sync_agent_ec_task_error_e add_profile_task_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array)
563 sync_agent_ec_task_error_e err = SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS;
565 char *profileName = NULL;
568 char *password = NULL;
572 GList *categories = NULL;
578 sync_agent_get_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &profileName);
579 sync_agent_get_param_value(&(param_array[1]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &addr);
580 sync_agent_get_param_value(&(param_array[2]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &id);
581 sync_agent_get_param_value(&(param_array[3]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &password);
582 sync_agent_get_param_value(&(param_array[4]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &syncMode);
583 sync_agent_get_param_value(&(param_array[5]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &syncType);
584 sync_agent_get_param_value(&(param_array[6]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &interval);
585 sync_agent_get_param_value(&(param_array[7]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &categories);
587 res = add_profile(profileName, addr, id, password, syncMode, syncType, interval, categories, &accountId);
589 err = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
594 sync_agent_set_param_value(&(param_array[8]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &result);
595 sync_agent_set_param_value(&(param_array[9]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &accountId);
597 /*step 2 : start refresh_from_service for added account */
598 void *in_param_value_array[1] = { &accountId };
599 int in_param_index_array[1] = { 0 };
600 sync_agent_ec_value_type_e in_param_value_type_array[1] = { SYNC_AGENT_EC_VALUE_TYPE_INT };
601 unsigned int request_msg_id = 0;
602 sync_agent_request_async_task(EC_MSG_TYPE_SYNC_TASK_REFRESH_FROM_SERVICE, 0, 1, in_param_index_array, in_param_value_type_array, in_param_value_array, NULL, NULL, (int *)&request_msg_id);
608 sync_agent_ec_task_error_e edit_profile_task_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array)
612 sync_agent_ec_task_error_e err = SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS;
615 char *profileName = NULL;
618 char *password = NULL;
622 GList *categories = NULL;
627 sync_agent_get_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &accountId);
628 sync_agent_get_param_value(&(param_array[1]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &profileName);
629 sync_agent_get_param_value(&(param_array[2]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &addr);
630 sync_agent_get_param_value(&(param_array[3]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &id);
631 sync_agent_get_param_value(&(param_array[4]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &password);
632 sync_agent_get_param_value(&(param_array[5]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &syncMode);
633 sync_agent_get_param_value(&(param_array[6]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &syncType);
634 sync_agent_get_param_value(&(param_array[7]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &interval);
635 sync_agent_get_param_value(&(param_array[8]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &categories);
637 res = edit_profile(accountId, profileName, addr, id, password, syncMode, syncType, interval, categories);
639 err = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
644 sync_agent_set_param_value(&(param_array[9]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &result);
650 sync_agent_ec_task_error_e delete_profile_task_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array)
656 sync_agent_ec_task_error_e err = SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS;
658 GList *profiles = NULL;
659 sync_agent_get_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &profiles);
661 res = delete_profiles(profiles);
663 err = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
668 sync_agent_set_param_value(&(param_array[1]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &result);
675 sync_agent_ec_task_error_e get_profile_data_task_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array)
679 sync_agent_ec_task_error_e err = SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS;
682 char *profileName = NULL;
685 char *password = NULL;
689 int lastSessionStatus;
694 sync_agent_get_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &accountId);
695 retvm_if(accountId < 0, SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED, "account id = %d", accountId);
697 res = get_profile_data(accountId, &profileName, &addr, &id, &password, &sync_mode, &syncType, &interval, &lastSessionStatus, &lastSessionTime);
699 err = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
704 sync_agent_set_param_value(&(param_array[1]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &result);
705 sync_agent_set_param_value(&(param_array[2]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &profileName);
706 sync_agent_set_param_value(&(param_array[3]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &addr);
707 sync_agent_set_param_value(&(param_array[4]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &id);
708 sync_agent_set_param_value(&(param_array[5]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &password);
709 sync_agent_set_param_value(&(param_array[6]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &sync_mode);
710 sync_agent_set_param_value(&(param_array[7]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &syncType);
711 sync_agent_set_param_value(&(param_array[8]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &interval);
712 sync_agent_set_param_value(&(param_array[9]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &lastSessionStatus);
713 sync_agent_set_param_value(&(param_array[10]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &lastSessionTime);
720 sync_agent_ec_task_error_e get_profile_sync_category_task_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array)
724 sync_agent_ec_task_error_e err = SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS;
733 char *password = NULL;
737 sync_agent_get_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &accountId);
738 retvm_if(accountId < 0, SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED, "account id = %d", accountId);
740 sync_agent_get_param_value(&(param_array[1]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &contentType);
742 res = get_profile_sync_category(accountId, contentType, &enabled, &srcURI, &tgtURI, &id, &password);
744 err = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
749 sync_agent_set_param_value(&(param_array[2]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &result);
750 sync_agent_set_param_value(&(param_array[3]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &enabled);
751 sync_agent_set_param_value(&(param_array[4]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &srcURI);
752 sync_agent_set_param_value(&(param_array[5]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &tgtURI);
753 sync_agent_set_param_value(&(param_array[6]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &id);
754 sync_agent_set_param_value(&(param_array[7]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &password);
760 sync_agent_ec_task_error_e get_profile_statistics_task_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array)
764 sync_agent_ec_task_error_e err = SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS;
769 char *dbSynced = NULL;
770 int lastSessionTime = -1;
771 int server2Client_Total = 0;
772 int server2Client_NrOfAdd = 0;
773 int server2Client_NrOfDelete = 0;
774 int server2Client_NrOfReplace = 0;
775 int client2Server_Total = 0;
776 int client2Server_NrOfAdd = 0;
777 int client2Server_NrOfDelete = 0;
778 int client2Server_NrOfReplace = 0;
783 sync_agent_get_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &accountId);
784 retvm_if(accountId < 0, SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED, "account id = %d", accountId);
786 sync_agent_get_param_value(&(param_array[1]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &contentType);
788 res = get_profile_statistics(accountId, contentType, &dbSynced, &lastSessionTime,
789 &server2Client_Total, &server2Client_NrOfAdd, &server2Client_NrOfDelete, &server2Client_NrOfReplace, &client2Server_Total, &client2Server_NrOfAdd, &client2Server_NrOfDelete, &client2Server_NrOfReplace);
792 err = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
797 sync_agent_set_param_value(&(param_array[2]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &result);
798 sync_agent_set_param_value(&(param_array[3]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &dbSynced);
799 sync_agent_set_param_value(&(param_array[4]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &lastSessionTime);
800 sync_agent_set_param_value(&(param_array[5]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &server2Client_Total);
801 sync_agent_set_param_value(&(param_array[6]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &server2Client_NrOfAdd);
802 sync_agent_set_param_value(&(param_array[7]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &server2Client_NrOfDelete);
803 sync_agent_set_param_value(&(param_array[8]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &server2Client_NrOfReplace);
804 sync_agent_set_param_value(&(param_array[9]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &client2Server_Total);
805 sync_agent_set_param_value(&(param_array[10]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &client2Server_NrOfAdd);
806 sync_agent_set_param_value(&(param_array[11]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &client2Server_NrOfDelete);
807 sync_agent_set_param_value(&(param_array[12]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &client2Server_NrOfReplace);
813 sync_agent_ec_task_error_e reset_synchronizing_profiles_task_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array)
817 sync_agent_ec_task_error_e err = SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS;
819 reset_synchronizing_profiles();
825 sync_agent_ec_task_error_e add_profile_cp_task_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array)
829 sync_agent_ec_task_error_e err = SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS;
831 char *profileName = NULL;
834 char *password = NULL;
835 GList *categories = NULL;
841 sync_agent_get_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &profileName);
842 sync_agent_get_param_value(&(param_array[1]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &addr);
843 sync_agent_get_param_value(&(param_array[2]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &id);
844 sync_agent_get_param_value(&(param_array[3]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &password);
845 sync_agent_get_param_value(&(param_array[4]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &categories);
847 res = add_profile_cp(profileName, addr, id, password, categories, &accountId);
849 err = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
854 sync_agent_set_param_value(&(param_array[5]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &result);
855 sync_agent_set_param_value(&(param_array[6]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &accountId);
861 sync_agent_ec_task_error_e refresh_from_service_task_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array)
865 sync_agent_ec_task_error_e err = SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS;
870 sync_agent_get_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &accountId);
872 res = refresh_from_service_all(accountId);
874 err = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
880 sync_agent_ec_task_error_e cancel_sync_request_task_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array)
884 sync_agent_ec_task_error_e err = SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS;
886 cancel_sync_request();
892 sync_agent_ec_task_error_e reset_all_data_task_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array)
896 sync_agent_ec_task_error_e err = SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS;
899 /* delete all profiles */
900 result = delete_all_profiles();
902 /* delete all agent default table */
903 result = delete_all_agent_default_table();
905 sync_agent_set_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &result);
911 sync_agent_ec_task_error_e get_all_profiles_data_task_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array)
915 sync_agent_ec_task_error_e err = SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS;
919 GList *profiles_data = NULL;
921 res = get_all_profiles_data(&profiles_data);
924 err = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
929 sync_agent_set_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &result);
930 sync_agent_set_param_value(&(param_array[1]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &profiles_data);
937 void insert_request_msg_info(int sync_type, unsigned int request_id)
941 sync_request_id_list = g_list_prepend(sync_request_id_list, _create_request_msg_info(sync_type, request_id));
946 void delete_request_msg_info(unsigned int request_id)
951 request_msg_info_t *pMsg_info = NULL;
953 for (iter = sync_request_id_list; iter != NULL; iter = g_list_next(iter)) {
954 pMsg_info = iter->data;
956 if (pMsg_info->request_id == request_id) {
957 sync_request_id_list = g_list_remove_link(sync_request_id_list, iter);
963 _request_msg_info_free(iter->data);
969 bool get_synchronizing_request_id(unsigned int *pRequest_id)
973 bool success = false;
974 request_msg_info_t *pMsg_info = NULL;
977 for (iter = sync_request_id_list; iter != NULL; iter = g_list_next(iter)) {
978 pMsg_info = iter->data;
980 if (pMsg_info->sync_type == SYNC_MODE_MANUAL || pMsg_info->sync_type == SYNC_MODE_PERIODIC || pMsg_info->sync_type == SYNC_MODE_SAN) {
982 *pRequest_id = pMsg_info->request_id;
984 _request_msg_info_free(pMsg_info);
985 sync_request_id_list = g_list_delete_link(sync_request_id_list, iter);
995 bool get_manual_sync_request_id(unsigned int *pRequest_id)
999 bool success = false;
1000 request_msg_info_t *pMsg_info = NULL;
1003 for (iter = sync_request_id_list; iter != NULL; iter = g_list_next(iter)) {
1004 pMsg_info = iter->data;
1006 if (pMsg_info->sync_type == SYNC_MODE_MANUAL) {
1008 *pRequest_id = pMsg_info->request_id;
1010 _request_msg_info_free(pMsg_info);
1011 sync_request_id_list = g_list_delete_link(sync_request_id_list, iter);
1020 bool get_periodic_sync_request_id(unsigned int *pRequest_id)
1024 bool success = false;
1025 request_msg_info_t *pMsg_info = NULL;
1028 for (iter = sync_request_id_list; iter != NULL; iter = g_list_next(iter)) {
1029 pMsg_info = iter->data;
1031 if (pMsg_info->sync_type == SYNC_MODE_PERIODIC) {
1033 *pRequest_id = pMsg_info->request_id;
1035 _request_msg_info_free(pMsg_info);
1036 sync_request_id_list = g_list_delete_link(sync_request_id_list, iter);
1046 bool get_san_sync_request_id(unsigned int *pRequest_id)
1050 bool success = false;
1051 request_msg_info_t *pMsg_info = NULL;
1054 for (iter = sync_request_id_list; iter != NULL; iter = g_list_next(iter)) {
1055 pMsg_info = iter->data;
1057 if (pMsg_info->sync_type == SYNC_MODE_SAN) {
1059 *pRequest_id = pMsg_info->request_id;
1061 _request_msg_info_free(pMsg_info);
1062 sync_request_id_list = g_list_delete_link(sync_request_id_list, iter);
1072 bool get_auto_configure_request_id(unsigned int *pRequest_id)
1076 bool success = false;
1077 request_msg_info_t *pMsg_info = NULL;
1080 for (iter = sync_request_id_list; iter != NULL; iter = g_list_next(iter)) {
1081 pMsg_info = iter->data;
1083 if (pMsg_info->sync_type == SYNC_MODE_AUTOCONFIG) {
1085 *pRequest_id = pMsg_info->request_id;
1087 _request_msg_info_free(pMsg_info);
1088 sync_request_id_list = g_list_delete_link(sync_request_id_list, iter);
1098 bool cancel_current_sync_task()
1102 unsigned int request_msg_id_to_cancel = 0;
1103 unsigned int request_msg_id = 0;
1104 bool has_autoconfig = get_auto_configure_request_id(&request_msg_id_to_cancel);
1105 if (has_autoconfig) {
1106 _DEBUG_INFO("has_autoconfig [%d] ", request_msg_id_to_cancel);
1107 sync_agent_cancel_task(request_msg_id_to_cancel);
1109 bool has_sync = get_synchronizing_request_id(&request_msg_id_to_cancel);
1111 _DEBUG_INFO("has_manual_sync [%d] ", request_msg_id_to_cancel);
1112 sync_agent_cancel_task(request_msg_id_to_cancel);
1114 /*request network session cancel */
1115 sync_agent_request_async_task(EC_MSG_TYPE_SYNC_TASK_CANCEL_SYNC_REQUEST, 0, 0, NULL, NULL, NULL, NULL, NULL, (int *)&request_msg_id);