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("profile_dir_name", _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("profile_name", _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("addr", _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("id", _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_structure("password", _string_copy_struct, free,
302 false, true, false, NULL, false, NULL, false, NULL);
303 sync_agent_ec_param_spec_s *pParam_spec8 = sync_agent_alloc_param_spec_int("syncMode", false, true, false, 0, 0, false, 0, false, 0, 0);
304 sync_agent_ec_param_spec_s *pParam_spec9 = sync_agent_alloc_param_spec_int("syncType", false, true, false, 0, 0, false, 0, false, 0, 0);
305 sync_agent_ec_param_spec_s *pParam_spec10 = sync_agent_alloc_param_spec_int("interval", false, true, false, 0, 0, false, 0, false, 0, 0);
306 sync_agent_ec_param_spec_s *pParam_spec11 = sync_agent_alloc_param_spec_int("lastSessionStatus", false, true, false, 0, 0, false, 0, false, 0, 0);
307 sync_agent_ec_param_spec_s *pParam_spec12 = sync_agent_alloc_param_spec_int("lastSessionTime", false, true, false, 0, 0, false, 0, false, 0, 0);
309 sync_agent_ec_param_spec_s *param_spec_array[12] = { pParam_spec1, pParam_spec2, pParam_spec3,
310 pParam_spec4, pParam_spec5, pParam_spec6, pParam_spec7, pParam_spec8,
311 pParam_spec9, pParam_spec10, pParam_spec11, pParam_spec12
314 sync_agent_ec_task_spec_s *pTask_spec = sync_agent_alloc_simple_task_spec("get_profile_data",
315 get_profile_data_task_process, NULL, NULL,
316 12, param_spec_array);
318 sync_agent_unref_param_spec(pParam_spec1);
319 sync_agent_unref_param_spec(pParam_spec2);
320 sync_agent_unref_param_spec(pParam_spec3);
321 sync_agent_unref_param_spec(pParam_spec4);
322 sync_agent_unref_param_spec(pParam_spec5);
323 sync_agent_unref_param_spec(pParam_spec6);
324 sync_agent_unref_param_spec(pParam_spec7);
325 sync_agent_unref_param_spec(pParam_spec8);
326 sync_agent_unref_param_spec(pParam_spec9);
327 sync_agent_unref_param_spec(pParam_spec10);
328 sync_agent_unref_param_spec(pParam_spec11);
329 sync_agent_unref_param_spec(pParam_spec12);
335 sync_agent_ec_task_spec_s *make_get_profile_sync_category_task()
339 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);
340 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);
342 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);
343 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);
344 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);
345 sync_agent_ec_param_spec_s *pParam_spec6 = sync_agent_alloc_param_spec_structure("tgtURI", _string_copy_struct, free,
346 false, true, false, NULL, false, NULL, false, NULL);
347 sync_agent_ec_param_spec_s *pParam_spec7 = sync_agent_alloc_param_spec_structure("id", _string_copy_struct, free,
348 false, true, false, NULL, false, NULL, false, NULL);
349 sync_agent_ec_param_spec_s *pParam_spec8 = sync_agent_alloc_param_spec_structure("password", _string_copy_struct, free,
350 false, true, false, NULL, false, NULL, false, NULL);
352 sync_agent_ec_param_spec_s *param_spec_array[8] = { pParam_spec1, pParam_spec2, pParam_spec3, pParam_spec4,
353 pParam_spec5, pParam_spec6, pParam_spec7, pParam_spec8
356 sync_agent_ec_task_spec_s *pTask_spec = sync_agent_alloc_simple_task_spec("get_profile_sync_category",
357 get_profile_sync_category_task_process, NULL, NULL,
358 8, param_spec_array);
360 sync_agent_unref_param_spec(pParam_spec1);
361 sync_agent_unref_param_spec(pParam_spec2);
362 sync_agent_unref_param_spec(pParam_spec3);
363 sync_agent_unref_param_spec(pParam_spec4);
364 sync_agent_unref_param_spec(pParam_spec5);
365 sync_agent_unref_param_spec(pParam_spec6);
366 sync_agent_unref_param_spec(pParam_spec7);
367 sync_agent_unref_param_spec(pParam_spec8);
373 sync_agent_ec_task_spec_s *make_get_profile_statistics_task()
377 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);
378 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);
380 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);
381 sync_agent_ec_param_spec_s *pParam_spec4 = sync_agent_alloc_param_spec_structure("dbSynced", _string_copy_struct, free,
382 false, true, false, NULL, false, NULL, false, NULL);
383 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);
384 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);
385 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);
386 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);
387 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);
388 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);
389 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);
390 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);
391 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);
393 sync_agent_ec_param_spec_s *param_spec_array[13] = { pParam_spec1, pParam_spec2, pParam_spec3,
394 pParam_spec4, pParam_spec5, pParam_spec6, pParam_spec7, pParam_spec8,
395 pParam_spec9, pParam_spec10, pParam_spec11, pParam_spec12, pParam_spec13
398 sync_agent_ec_task_spec_s *pTask_spec = sync_agent_alloc_simple_task_spec("get_profile_statistics",
399 get_profile_statistics_task_process, NULL, NULL,
400 13, param_spec_array);
402 sync_agent_unref_param_spec(pParam_spec1);
403 sync_agent_unref_param_spec(pParam_spec2);
404 sync_agent_unref_param_spec(pParam_spec3);
405 sync_agent_unref_param_spec(pParam_spec4);
406 sync_agent_unref_param_spec(pParam_spec5);
407 sync_agent_unref_param_spec(pParam_spec6);
408 sync_agent_unref_param_spec(pParam_spec7);
409 sync_agent_unref_param_spec(pParam_spec8);
410 sync_agent_unref_param_spec(pParam_spec9);
411 sync_agent_unref_param_spec(pParam_spec10);
412 sync_agent_unref_param_spec(pParam_spec11);
413 sync_agent_unref_param_spec(pParam_spec12);
414 sync_agent_unref_param_spec(pParam_spec13);
420 sync_agent_ec_task_spec_s *make_reset_synchronizing_profiles_task()
424 sync_agent_ec_task_spec_s *pTask_spec = sync_agent_alloc_simple_task_spec("reset_synchronizing_profiles",
425 reset_synchronizing_profiles_task_process, NULL, NULL,
432 sync_agent_ec_task_spec_s *make_add_profile_cp_task()
436 sync_agent_ec_param_spec_s *pParam_spec1 = sync_agent_alloc_param_spec_structure("profileName", _string_copy_struct, free,
437 true, false, false, NULL, false, NULL, false, NULL);
438 sync_agent_ec_param_spec_s *pParam_spec2 = sync_agent_alloc_param_spec_structure("addr", _string_copy_struct, free,
439 true, false, false, NULL, false, NULL, false, NULL);
440 sync_agent_ec_param_spec_s *pParam_spec3 = sync_agent_alloc_param_spec_structure("id", _string_copy_struct, free,
441 true, false, false, NULL, false, NULL, false, NULL);
442 sync_agent_ec_param_spec_s *pParam_spec4 = sync_agent_alloc_param_spec_structure("password", _string_copy_struct, free,
443 true, false, false, NULL, false, NULL, false, NULL);
444 sync_agent_ec_param_spec_s *pParam_spec5 = sync_agent_alloc_param_spec_structure("categories", NULL, _free_resource_cp_list,
445 true, false, false, NULL, false, NULL, false, NULL);
447 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);
448 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);
450 sync_agent_ec_param_spec_s *param_spec_array[7] = { pParam_spec1, pParam_spec2, pParam_spec3, pParam_spec4, pParam_spec5,
451 pParam_spec6, pParam_spec7
454 sync_agent_ec_task_spec_s *pTask_spec = sync_agent_alloc_simple_task_spec("add_profile_cp",
455 add_profile_cp_task_process, NULL, NULL,
456 7, param_spec_array);
458 sync_agent_unref_param_spec(pParam_spec1);
459 sync_agent_unref_param_spec(pParam_spec2);
460 sync_agent_unref_param_spec(pParam_spec3);
461 sync_agent_unref_param_spec(pParam_spec4);
462 sync_agent_unref_param_spec(pParam_spec5);
463 sync_agent_unref_param_spec(pParam_spec6);
464 sync_agent_unref_param_spec(pParam_spec7);
470 sync_agent_ec_task_spec_s *make_refresh_from_service_task()
474 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);
476 sync_agent_ec_param_spec_s *param_spec_array[1] = { pParam_spec1 };
478 sync_agent_ec_task_spec_s *pTask_spec = sync_agent_alloc_simple_task_spec("refresh_from_service",
479 refresh_from_service_task_process, NULL, NULL,
480 1, param_spec_array);
482 sync_agent_unref_param_spec(pParam_spec1);
488 sync_agent_ec_task_spec_s *make_cancel_request_task()
492 sync_agent_ec_task_spec_s *pTask_spec = sync_agent_alloc_simple_task_spec("cancel_sync_request",
493 cancel_sync_request_task_process, NULL, NULL,
500 sync_agent_ec_task_spec_s *make_reset_all_data_task()
504 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);
505 sync_agent_ec_param_spec_s *param_spec_array[1] = { pParam_spec1 };
507 sync_agent_ec_task_spec_s *pTask_spec = sync_agent_alloc_simple_task_spec("reset_all_data",
508 reset_all_data_task_process, NULL, NULL,
509 1, param_spec_array);
511 sync_agent_unref_param_spec(pParam_spec1);
517 sync_agent_ec_task_spec_s *make_get_all_profiles_data_task()
521 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);
522 sync_agent_ec_param_spec_s *pParam_spec2 = sync_agent_alloc_param_spec_structure("profilesData", NULL, NULL,
523 false, true, false, NULL, false, NULL, false, NULL);
525 sync_agent_ec_param_spec_s *param_spec_array[2] = { pParam_spec1, pParam_spec2 };
527 sync_agent_ec_task_spec_s *pTask_spec = sync_agent_alloc_simple_task_spec("get_all_profiles_data",
528 get_all_profiles_data_task_process, NULL, NULL,
529 2, param_spec_array);
535 sync_agent_ec_task_error_e synchronize_task_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array)
539 sync_agent_ec_task_error_e err = SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS;
542 sync_agent_get_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &accountId);
543 retvm_if(accountId < 0, SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED, "account id = %d", accountId);
545 char *syncMode = NULL;
546 sync_agent_get_param_value(&(param_array[1]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &syncMode);
548 san_package_s *pSanPackage = NULL;
549 sync_agent_get_param_value(&(param_array[2]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &pSanPackage);
551 _DEBUG_INFO("accountId = %d", accountId);
552 _DEBUG_INFO("syncMode = %s", syncMode);
554 bool result = synchronize(accountId, syncMode, pSanPackage);
556 err = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
562 sync_agent_ec_task_error_e add_profile_task_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array)
566 sync_agent_ec_task_error_e err = SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS;
568 char *profileName = NULL;
571 char *password = NULL;
575 GList *categories = NULL;
581 sync_agent_get_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &profileName);
582 sync_agent_get_param_value(&(param_array[1]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &addr);
583 sync_agent_get_param_value(&(param_array[2]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &id);
584 sync_agent_get_param_value(&(param_array[3]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &password);
585 sync_agent_get_param_value(&(param_array[4]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &syncMode);
586 sync_agent_get_param_value(&(param_array[5]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &syncType);
587 sync_agent_get_param_value(&(param_array[6]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &interval);
588 sync_agent_get_param_value(&(param_array[7]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &categories);
590 res = add_profile(profileName, addr, id, password, syncMode, syncType, interval, categories, &accountId);
592 err = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
597 sync_agent_set_param_value(&(param_array[8]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &result);
598 sync_agent_set_param_value(&(param_array[9]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &accountId);
600 /*step 2 : start refresh_from_service for added account */
601 void *in_param_value_array[1] = { &accountId };
602 int in_param_index_array[1] = { 0 };
603 sync_agent_ec_value_type_e in_param_value_type_array[1] = { SYNC_AGENT_EC_VALUE_TYPE_INT };
604 unsigned int request_msg_id = 0;
605 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);
611 sync_agent_ec_task_error_e edit_profile_task_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array)
615 sync_agent_ec_task_error_e err = SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS;
618 char *profileName = NULL;
621 char *password = NULL;
625 GList *categories = NULL;
630 sync_agent_get_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &accountId);
631 sync_agent_get_param_value(&(param_array[1]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &profileName);
632 sync_agent_get_param_value(&(param_array[2]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &addr);
633 sync_agent_get_param_value(&(param_array[3]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &id);
634 sync_agent_get_param_value(&(param_array[4]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &password);
635 sync_agent_get_param_value(&(param_array[5]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &syncMode);
636 sync_agent_get_param_value(&(param_array[6]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &syncType);
637 sync_agent_get_param_value(&(param_array[7]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &interval);
638 sync_agent_get_param_value(&(param_array[8]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &categories);
640 res = edit_profile(accountId, profileName, addr, id, password, syncMode, syncType, interval, categories);
642 err = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
647 sync_agent_set_param_value(&(param_array[9]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &result);
653 sync_agent_ec_task_error_e delete_profile_task_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array)
659 sync_agent_ec_task_error_e err = SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS;
661 GList *profiles = NULL;
662 sync_agent_get_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &profiles);
664 res = delete_profiles(profiles);
666 err = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
671 sync_agent_set_param_value(&(param_array[1]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &result);
678 sync_agent_ec_task_error_e get_profile_data_task_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array)
682 sync_agent_ec_task_error_e err = SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS;
685 char *profile_dir_name = NULL;
686 char *profileName = NULL;
689 char *password = NULL;
693 int lastSessionStatus;
698 sync_agent_get_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &accountId);
699 retvm_if(accountId < 1, SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED, "account id = %d", accountId);
701 res = get_profile_data(accountId, &profile_dir_name, &profileName, &addr, &id, &password, &sync_mode, &syncType, &interval, &lastSessionStatus, &lastSessionTime);
703 err = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
708 sync_agent_set_param_value(&(param_array[1]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &result);
709 sync_agent_set_param_value(&(param_array[2]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &profile_dir_name);
710 sync_agent_set_param_value(&(param_array[3]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &profileName);
711 sync_agent_set_param_value(&(param_array[4]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &addr);
712 sync_agent_set_param_value(&(param_array[5]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &id);
713 sync_agent_set_param_value(&(param_array[6]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &password);
714 sync_agent_set_param_value(&(param_array[7]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &sync_mode);
715 sync_agent_set_param_value(&(param_array[8]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &syncType);
716 sync_agent_set_param_value(&(param_array[9]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &interval);
717 sync_agent_set_param_value(&(param_array[10]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &lastSessionStatus);
718 sync_agent_set_param_value(&(param_array[11]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &lastSessionTime);
725 sync_agent_ec_task_error_e get_profile_sync_category_task_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array)
729 sync_agent_ec_task_error_e err = SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS;
738 char *password = NULL;
742 sync_agent_get_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &accountId);
743 retvm_if(accountId < 0, SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED, "account id = %d", accountId);
745 sync_agent_get_param_value(&(param_array[1]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &contentType);
747 res = get_profile_sync_category(accountId, contentType, &enabled, &srcURI, &tgtURI, &id, &password);
749 err = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
754 sync_agent_set_param_value(&(param_array[2]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &result);
755 sync_agent_set_param_value(&(param_array[3]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &enabled);
756 sync_agent_set_param_value(&(param_array[4]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &srcURI);
757 sync_agent_set_param_value(&(param_array[5]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &tgtURI);
758 sync_agent_set_param_value(&(param_array[6]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &id);
759 sync_agent_set_param_value(&(param_array[7]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &password);
765 sync_agent_ec_task_error_e get_profile_statistics_task_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array)
769 sync_agent_ec_task_error_e err = SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS;
774 char *dbSynced = NULL;
775 int lastSessionTime = -1;
776 int server2Client_Total = 0;
777 int server2Client_NrOfAdd = 0;
778 int server2Client_NrOfDelete = 0;
779 int server2Client_NrOfReplace = 0;
780 int client2Server_Total = 0;
781 int client2Server_NrOfAdd = 0;
782 int client2Server_NrOfDelete = 0;
783 int client2Server_NrOfReplace = 0;
788 sync_agent_get_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &accountId);
789 retvm_if(accountId < 0, SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED, "account id = %d", accountId);
791 sync_agent_get_param_value(&(param_array[1]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &contentType);
793 res = get_profile_statistics(accountId, contentType, &dbSynced, &lastSessionTime,
794 &server2Client_Total, &server2Client_NrOfAdd, &server2Client_NrOfDelete, &server2Client_NrOfReplace, &client2Server_Total, &client2Server_NrOfAdd, &client2Server_NrOfDelete, &client2Server_NrOfReplace);
797 err = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
802 sync_agent_set_param_value(&(param_array[2]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &result);
803 sync_agent_set_param_value(&(param_array[3]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &dbSynced);
804 sync_agent_set_param_value(&(param_array[4]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &lastSessionTime);
805 sync_agent_set_param_value(&(param_array[5]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &server2Client_Total);
806 sync_agent_set_param_value(&(param_array[6]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &server2Client_NrOfAdd);
807 sync_agent_set_param_value(&(param_array[7]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &server2Client_NrOfDelete);
808 sync_agent_set_param_value(&(param_array[8]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &server2Client_NrOfReplace);
809 sync_agent_set_param_value(&(param_array[9]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &client2Server_Total);
810 sync_agent_set_param_value(&(param_array[10]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &client2Server_NrOfAdd);
811 sync_agent_set_param_value(&(param_array[11]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &client2Server_NrOfDelete);
812 sync_agent_set_param_value(&(param_array[12]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &client2Server_NrOfReplace);
818 sync_agent_ec_task_error_e reset_synchronizing_profiles_task_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array)
822 sync_agent_ec_task_error_e err = SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS;
824 reset_synchronizing_profiles();
830 sync_agent_ec_task_error_e add_profile_cp_task_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array)
834 sync_agent_ec_task_error_e err = SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS;
836 char *profileName = NULL;
839 char *password = NULL;
840 GList *categories = NULL;
846 sync_agent_get_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &profileName);
847 sync_agent_get_param_value(&(param_array[1]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &addr);
848 sync_agent_get_param_value(&(param_array[2]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &id);
849 sync_agent_get_param_value(&(param_array[3]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &password);
850 sync_agent_get_param_value(&(param_array[4]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &categories);
852 res = add_profile_cp(profileName, addr, id, password, categories, &accountId);
854 err = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
859 sync_agent_set_param_value(&(param_array[5]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &result);
860 sync_agent_set_param_value(&(param_array[6]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &accountId);
866 sync_agent_ec_task_error_e refresh_from_service_task_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array)
870 sync_agent_ec_task_error_e err = SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS;
875 sync_agent_get_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &accountId);
877 res = refresh_from_service_all(accountId);
879 err = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
885 sync_agent_ec_task_error_e cancel_sync_request_task_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array)
889 sync_agent_ec_task_error_e err = SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS;
891 cancel_sync_request();
897 sync_agent_ec_task_error_e reset_all_data_task_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array)
901 sync_agent_ec_task_error_e err = SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS;
904 /* delete all profiles */
905 result = delete_all_profiles();
907 /* delete all agent default table */
908 result = delete_all_agent_default_table();
910 sync_agent_set_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &result);
916 sync_agent_ec_task_error_e get_all_profiles_data_task_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array)
920 sync_agent_ec_task_error_e err = SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS;
924 GList *profiles_data = NULL;
926 res = get_all_profiles_data(&profiles_data);
929 err = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
934 sync_agent_set_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &result);
935 sync_agent_set_param_value(&(param_array[1]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &profiles_data);
942 void insert_request_msg_info(int sync_type, unsigned int request_id)
946 sync_request_id_list = g_list_prepend(sync_request_id_list, _create_request_msg_info(sync_type, request_id));
951 void delete_request_msg_info(unsigned int request_id)
956 request_msg_info_t *pMsg_info = NULL;
958 for (iter = sync_request_id_list; iter != NULL; iter = g_list_next(iter)) {
959 pMsg_info = iter->data;
961 if (pMsg_info->request_id == request_id) {
962 sync_request_id_list = g_list_remove_link(sync_request_id_list, iter);
968 _request_msg_info_free(iter->data);
974 bool get_synchronizing_request_id(unsigned int *pRequest_id)
978 bool success = false;
979 request_msg_info_t *pMsg_info = NULL;
982 for (iter = sync_request_id_list; iter != NULL; iter = g_list_next(iter)) {
983 pMsg_info = iter->data;
985 if (pMsg_info->sync_type == SYNC_MODE_MANUAL || pMsg_info->sync_type == SYNC_MODE_PERIODIC || pMsg_info->sync_type == SYNC_MODE_SAN) {
987 *pRequest_id = pMsg_info->request_id;
989 _request_msg_info_free(pMsg_info);
990 sync_request_id_list = g_list_delete_link(sync_request_id_list, iter);
1000 bool get_manual_sync_request_id(unsigned int *pRequest_id)
1004 bool success = false;
1005 request_msg_info_t *pMsg_info = NULL;
1008 for (iter = sync_request_id_list; iter != NULL; iter = g_list_next(iter)) {
1009 pMsg_info = iter->data;
1011 if (pMsg_info->sync_type == SYNC_MODE_MANUAL) {
1013 *pRequest_id = pMsg_info->request_id;
1015 _request_msg_info_free(pMsg_info);
1016 sync_request_id_list = g_list_delete_link(sync_request_id_list, iter);
1025 bool get_periodic_sync_request_id(unsigned int *pRequest_id)
1029 bool success = false;
1030 request_msg_info_t *pMsg_info = NULL;
1033 for (iter = sync_request_id_list; iter != NULL; iter = g_list_next(iter)) {
1034 pMsg_info = iter->data;
1036 if (pMsg_info->sync_type == SYNC_MODE_PERIODIC) {
1038 *pRequest_id = pMsg_info->request_id;
1040 _request_msg_info_free(pMsg_info);
1041 sync_request_id_list = g_list_delete_link(sync_request_id_list, iter);
1051 bool get_san_sync_request_id(unsigned int *pRequest_id)
1055 bool success = false;
1056 request_msg_info_t *pMsg_info = NULL;
1059 for (iter = sync_request_id_list; iter != NULL; iter = g_list_next(iter)) {
1060 pMsg_info = iter->data;
1062 if (pMsg_info->sync_type == SYNC_MODE_SAN) {
1064 *pRequest_id = pMsg_info->request_id;
1066 _request_msg_info_free(pMsg_info);
1067 sync_request_id_list = g_list_delete_link(sync_request_id_list, iter);
1077 bool get_auto_configure_request_id(unsigned int *pRequest_id)
1081 bool success = false;
1082 request_msg_info_t *pMsg_info = NULL;
1085 for (iter = sync_request_id_list; iter != NULL; iter = g_list_next(iter)) {
1086 pMsg_info = iter->data;
1088 if (pMsg_info->sync_type == SYNC_MODE_AUTOCONFIG) {
1090 *pRequest_id = pMsg_info->request_id;
1092 _request_msg_info_free(pMsg_info);
1093 sync_request_id_list = g_list_delete_link(sync_request_id_list, iter);
1103 bool cancel_current_sync_task()
1107 unsigned int request_msg_id_to_cancel = 0;
1108 unsigned int request_msg_id = 0;
1109 bool has_autoconfig = get_auto_configure_request_id(&request_msg_id_to_cancel);
1110 if (has_autoconfig) {
1111 _DEBUG_INFO("has_autoconfig [%d] ", request_msg_id_to_cancel);
1112 sync_agent_cancel_task(request_msg_id_to_cancel);
1114 bool has_sync = get_synchronizing_request_id(&request_msg_id_to_cancel);
1116 _DEBUG_INFO("has_manual_sync [%d] ", request_msg_id_to_cancel);
1117 sync_agent_cancel_task(request_msg_id_to_cancel);
1119 /*request network session cancel */
1120 sync_agent_request_async_task(EC_MSG_TYPE_SYNC_TASK_CANCEL_SYNC_REQUEST, 0, 0, NULL, NULL, NULL, NULL, NULL, (int *)&request_msg_id);