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_Event_Handler.c
21 * @brief This file is the source file of implementation of event callback function(from ui)
28 #include <sync_agent.h>
30 #include "framework/event/oma_ds_event_handler.h"
31 #include "framework/event/oma_ds_platform_event_handler.h"
32 #include "framework/task/oma_ds_engine_controller_task.h"
33 #include "common/common_define.h"
34 #include "common/common_vconf.h"
35 #include "common/common_util.h"
37 #ifndef OMADS_AGENT_LOG
39 #define LOG_TAG "OMA_DS_COMMON"
42 #define NOTI_KEY "OMADS"
44 static void _request_manual_sync_task_finish_callback(sync_agent_ec_task_error_e task_error, unsigned int out_param_cnt, sync_agent_ec_param_param_s ** out_param_spec_array, void *usr_data);
46 static void _request_manual_sync_task_finish_callback(sync_agent_ec_task_error_e task_error, unsigned int out_param_cnt, sync_agent_ec_param_param_s ** out_param_spec_array, void *usr_data)
50 unsigned int request_msg_id_to_cancel = 0;
51 get_manual_sync_request_id(&request_msg_id_to_cancel);
56 int event_callback_add_profile_sync(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
60 char *profile_dir_name = NULL;
61 char *profile_name = NULL;
64 char *password = NULL;
65 char *sync_mode = NULL;
66 char *sync_type = NULL;
67 char *interval = NULL;
72 GList *categorys = NULL;
75 sync_agent_get_event_data_param(request, &profile_dir_name);
76 sync_agent_get_event_data_param(request, &profile_name);
77 sync_agent_get_event_data_param(request, &addr);
78 sync_agent_get_event_data_param(request, &id);
79 sync_agent_get_event_data_param(request, &password);
80 sync_agent_get_event_data_param(request, &sync_mode);
81 sync_agent_get_event_data_param(request, &sync_type);
82 sync_agent_get_event_data_param(request, &interval);
83 sync_agent_get_event_data_param(request, &category_count);
86 _DEBUG_INFO("request param : %s", profile_dir_name);
87 _DEBUG_INFO("request param : %s", profile_name);
88 _DEBUG_INFO("request param : %s", addr);
89 _DEBUG_INFO("request param : %s", id);
90 _DEBUG_INFO("request param : %s", password);
91 _DEBUG_INFO("request param : %s", sync_mode);
92 _DEBUG_INFO("request param : %s", sync_type);
93 _DEBUG_INFO("request param : %s", interval);
94 _DEBUG_INFO("request param : %d", category_count);
98 for (; i < category_count; i++) {
99 sync_service_s *category = (sync_service_s *) calloc(1, sizeof(sync_service_s));
100 if (category == NULL) {
101 _DEBUG_ERROR("category is NULL !");
103 if (profile_dir_name != NULL)
104 free(profile_dir_name);
106 if (profile_name != NULL)
115 if (password != NULL)
118 if (sync_mode != NULL)
121 if (sync_type != NULL)
124 if (interval != NULL)
130 sync_agent_get_event_data_param(request, &(category->service_type));
131 sync_agent_get_event_data_param(request, &(category->enabled));
132 sync_agent_get_event_data_param(request, &(category->src_uri));
133 sync_agent_get_event_data_param(request, &(category->tgt_uri));
134 sync_agent_get_event_data_param(request, &(category->id));
135 sync_agent_get_event_data_param(request, &(category->password));
137 categorys = g_list_append(categorys, category);
140 _DEBUG_INFO("category[i]->content_type : %d", category->content_type);
141 _DEBUG_INFO("category[i]->enabled : %d", category->enabled);
142 _DEBUG_INFO("category[i]->srcURI : %s", category->src_uri);
143 _DEBUG_INFO("category[i]->tgtURI : %s", category->tgt_uri);
144 _DEBUG_INFO("category[i]->id : %s", category->id);
145 _DEBUG_INFO("category[i]->password : %s", category->password);
149 /* send to engine controller */
150 void *in_param_value_array[9] = { &profile_dir_name, &profile_name, &addr, &id, &password, &sync_mode, &sync_type, &interval, &categorys };
151 int in_param_index_array[9] = { 0, 1, 2, 3, 4, 5, 6, 7, 8 };
152 sync_agent_ec_value_type_e in_param_value_type_array[9] = { SYNC_AGENT_EC_VALUE_TYPE_STRUCT, SYNC_AGENT_EC_VALUE_TYPE_STRUCT, SYNC_AGENT_EC_VALUE_TYPE_STRUCT,
153 SYNC_AGENT_EC_VALUE_TYPE_STRUCT, SYNC_AGENT_EC_VALUE_TYPE_STRUCT, SYNC_AGENT_EC_VALUE_TYPE_STRUCT,
154 SYNC_AGENT_EC_VALUE_TYPE_STRUCT, SYNC_AGENT_EC_VALUE_TYPE_STRUCT, SYNC_AGENT_EC_VALUE_TYPE_STRUCT
156 unsigned int request_msg_id = 0;
158 unsigned int out_param_count;
159 sync_agent_ec_task_error_e task_error = SYNC_AGENT_EC_TASK_ERROR_NOT_YET_RUN;
160 sync_agent_ec_param_param_s **param_array = NULL;
162 sync_agent_request_sync_task(EC_MSG_TYPE_SYNC_TASK_ADD_PROFILE, 0, 9, in_param_index_array, in_param_value_type_array, in_param_value_array, (int *)&request_msg_id, &task_error, &out_param_count, ¶m_array);
164 sync_agent_get_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &result);
165 sync_agent_get_param_value(&(param_array[1]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &account_id);
167 sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &result);
168 sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &account_id);
170 for (iter = categorys; iter != NULL; iter = g_list_next(iter)) {
171 sync_service_s *category = (sync_service_s *) iter->data;
173 if (category != NULL)
174 free_sync_service(category);
181 int event_callback_edit_profile_sync(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
185 char *profile_dir_name = NULL;
186 char *profile_name = NULL;
189 char *password = NULL;
190 char *sync_mode = NULL;
191 char *sync_type = NULL;
192 char *interval = NULL;
196 GList *categorys = NULL;
199 sync_agent_get_event_data_param(request, &profile_dir_name);
200 if (profile_dir_name == NULL) {
201 _DEBUG_ERROR("profile_dir_name is not defined");
205 _DEBUG_INFO("request param : %s", profile_dir_name);
207 int account_id = get_account_id(profile_dir_name, false);
209 sync_agent_get_event_data_param(request, &profile_name);
210 sync_agent_get_event_data_param(request, &addr);
211 sync_agent_get_event_data_param(request, &id);
212 sync_agent_get_event_data_param(request, &password);
213 sync_agent_get_event_data_param(request, &sync_mode);
214 sync_agent_get_event_data_param(request, &sync_type);
215 sync_agent_get_event_data_param(request, &interval);
216 sync_agent_get_event_data_param(request, &category_count);
218 _DEBUG_INFO("request param : %s", profile_name);
219 _DEBUG_INFO("request param : %s", addr);
220 _DEBUG_INFO("request param : %s", id);
221 _DEBUG_INFO("request param : %s", password);
222 _DEBUG_INFO("request param : %s", sync_mode);
223 _DEBUG_INFO("request param : %s", sync_type);
224 _DEBUG_INFO("request param : %s", interval);
225 _DEBUG_INFO("request param : %d", category_count);
228 for (; i < category_count; i++) {
229 sync_service_s *category = (sync_service_s *) calloc(1, sizeof(sync_service_s));
230 if (category == NULL) {
231 _DEBUG_ERROR("category is NULL !");
233 if (profile_dir_name != NULL)
234 free(profile_dir_name);
236 if (profile_name != NULL)
245 if (password != NULL)
248 if (sync_mode != NULL)
251 if (sync_type != NULL)
254 if (interval != NULL)
260 sync_agent_get_event_data_param(request, &(category->service_type));
261 sync_agent_get_event_data_param(request, &(category->enabled));
262 sync_agent_get_event_data_param(request, &(category->src_uri));
263 sync_agent_get_event_data_param(request, &(category->tgt_uri));
264 sync_agent_get_event_data_param(request, &(category->id));
265 sync_agent_get_event_data_param(request, &(category->password));
267 categorys = g_list_append(categorys, category);
269 _DEBUG_INFO("category[i]->content_type : %d", category->service_type);
270 _DEBUG_INFO("category[i]->enabled : %d", category->enabled);
271 _DEBUG_INFO("category[i]->srcURI : %s", category->src_uri);
272 _DEBUG_INFO("category[i]->tgtURI : %s", category->tgt_uri);
273 _DEBUG_INFO("category[i]->id : %s", category->id);
274 _DEBUG_INFO("category[i]->password : %s", category->password);
277 /* send to engine controller */
278 void *in_param_value_array[9] = { &account_id, &profile_name, &addr, &id, &password, &sync_mode, &sync_type, &interval, &categorys };
279 int in_param_index_array[9] = { 0, 1, 2, 3, 4, 5, 6, 7, 8 };
280 sync_agent_ec_value_type_e in_param_value_type_array[9] = { SYNC_AGENT_EC_VALUE_TYPE_INT, SYNC_AGENT_EC_VALUE_TYPE_STRUCT, SYNC_AGENT_EC_VALUE_TYPE_STRUCT,
281 SYNC_AGENT_EC_VALUE_TYPE_STRUCT, SYNC_AGENT_EC_VALUE_TYPE_STRUCT, SYNC_AGENT_EC_VALUE_TYPE_STRUCT,
282 SYNC_AGENT_EC_VALUE_TYPE_STRUCT, SYNC_AGENT_EC_VALUE_TYPE_STRUCT, SYNC_AGENT_EC_VALUE_TYPE_STRUCT
284 unsigned int request_msg_id = 0;
286 unsigned int out_param_count;
287 sync_agent_ec_task_error_e task_error = SYNC_AGENT_EC_TASK_ERROR_NOT_YET_RUN;
288 sync_agent_ec_param_param_s **param_array = NULL;
290 sync_agent_request_sync_task(EC_MSG_TYPE_SYNC_TASK_EDIT_PROFILE, 0, 9, in_param_index_array, in_param_value_type_array, in_param_value_array, (int *)&request_msg_id, &task_error, &out_param_count, ¶m_array);
292 sync_agent_get_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &result);
296 sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &result);
298 for (iter = categorys; iter != NULL; iter = g_list_next(iter)) {
299 sync_service_s *category = (sync_service_s *) iter->data;
301 if (category != NULL)
302 free_sync_service(category);
305 if (profile_dir_name != NULL)
306 free(profile_dir_name);
312 int event_callback_delete_profile_sync(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
318 sync_agent_get_event_data_param(request, &count);
319 GList *profiles = NULL;
323 char *profile = NULL;
324 for (i = 0; i < count; i++) {
325 if (profile != NULL) {
330 sync_agent_get_event_data_param(request, &profile);
331 if (profile == NULL) {
332 _DEBUG_ERROR("profile is not defined");
336 _DEBUG_INFO("request param : %s", profile);
338 account_id = (int *)calloc(1, sizeof(int));
339 if (account_id == NULL) {
340 _DEBUG_ERROR("account_id is NULL");
345 *account_id = get_account_id(profile, false);
347 profiles = g_list_append(profiles, account_id);
350 /* send to engine controller */
351 void *in_param_value_array[1] = { &profiles };
352 int in_param_index_array[1] = { 0 };
353 sync_agent_ec_value_type_e in_param_value_type_array[1] = { SYNC_AGENT_EC_VALUE_TYPE_STRUCT };
354 unsigned int request_msg_id = 0;
356 unsigned int out_param_count;
357 sync_agent_ec_task_error_e task_error = SYNC_AGENT_EC_TASK_ERROR_NOT_YET_RUN;
358 sync_agent_ec_param_param_s **param_array = NULL;
360 sync_agent_request_sync_task(EC_MSG_TYPE_SYNC_TASK_DELETE_PROFILE, 0, 1, in_param_index_array, in_param_value_type_array, in_param_value_array, (int *)&request_msg_id, &task_error, &out_param_count, ¶m_array);
362 sync_agent_get_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &result);
366 sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &result);
375 int event_callback_request_sync_sync(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
378 char *profile = NULL;
381 sync_agent_get_event_data_param(request, &profile);
382 if (profile == NULL) {
383 _DEBUG_ERROR("profile is not defined");
387 _DEBUG_INFO("request param : %s", profile);
389 int account_id = get_account_id(profile, false);
390 char *sync_mode = strdup(DEFINE_SYNC_MODE_MANUAL);
392 void *in_param_value_array[3] = { &account_id, &sync_mode, NULL };
393 int in_param_index_array[3] = { 0, 1, 2 };
394 sync_agent_ec_value_type_e in_param_value_type_array[3] = { SYNC_AGENT_EC_VALUE_TYPE_INT, SYNC_AGENT_EC_VALUE_TYPE_STRUCT, SYNC_AGENT_EC_VALUE_TYPE_STRUCT };
395 unsigned int request_msg_id = 0;
396 sync_agent_request_async_task(EC_MSG_TYPE_SYNC_TASK_REQUEST, 0, 3, in_param_index_array, in_param_value_type_array, in_param_value_array, _request_manual_sync_task_finish_callback, NULL, (int *)&request_msg_id);
398 insert_request_msg_info(SYNC_MODE_MANUAL, request_msg_id);
402 sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &result);
411 int event_callback_cancel_sync_sync(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
414 char *profile = NULL;
418 sync_agent_get_event_data_param(request, &profile);
419 if (profile == NULL) {
420 _DEBUG_ERROR("profile is not defined");
425 _DEBUG_INFO("request param : %s", profile);
427 res = cancel_current_sync_task();
435 sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &result);
444 int event_callback_get_profile_data_sync(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
449 char *profile = NULL;
450 char *profile_name = NULL;
453 char *password = NULL;
454 char *sync_mode = NULL;
455 char *sync_type = NULL;
456 char *interval = NULL;
457 int last_session_status = 0;
458 int last_session_time = 0;
460 sync_agent_get_event_data_param(request, &profile);
461 if (profile == NULL) {
462 _DEBUG_ERROR("profile is not defined");
467 _DEBUG_INFO("request param : %s", profile);
469 int account_id = get_account_id(profile, false);
471 int in_param_index_array[1] = { 0 };
472 void *in_param_value_array[1] = { &account_id };
473 sync_agent_ec_value_type_e in_param_value_type_array[1] = { SYNC_AGENT_EC_VALUE_TYPE_INT };
475 unsigned int out_param_count;
476 sync_agent_ec_task_error_e task_error = SYNC_AGENT_EC_TASK_ERROR_NOT_YET_RUN;
477 sync_agent_ec_param_param_s **param_array = NULL;
479 unsigned int request_msg_id = 0;
480 sync_agent_request_sync_task(EC_MSG_TYPE_SYNC_TASK_GET_PROFILE_DATA, 0, 1, in_param_index_array, in_param_value_type_array, in_param_value_array, (int *)&request_msg_id, &task_error, &out_param_count, ¶m_array);
482 sync_agent_get_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &result);
483 sync_agent_get_param_value(&(param_array[1]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &profile_name);
484 sync_agent_get_param_value(&(param_array[2]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &addr);
485 sync_agent_get_param_value(&(param_array[3]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &id);
486 sync_agent_get_param_value(&(param_array[4]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &password);
487 sync_agent_get_param_value(&(param_array[5]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &sync_mode);
488 sync_agent_get_param_value(&(param_array[6]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &sync_type);
489 sync_agent_get_param_value(&(param_array[7]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &interval);
490 sync_agent_get_param_value(&(param_array[8]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &last_session_status);
491 sync_agent_get_param_value(&(param_array[9]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &last_session_time);
495 sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &result);
496 sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)profile_name);
497 sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)addr);
498 sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)id);
499 sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)password);
500 sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)sync_mode);
501 sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)sync_type);
502 sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)interval);
503 sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &last_session_status);
504 sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &last_session_time);
513 int event_callback_get_profile_sync_category_sync(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
516 char *profile = NULL;
517 int content_type = 0;
522 char *password = NULL;
525 sync_agent_get_event_data_param(request, &profile);
526 if (profile == NULL) {
527 _DEBUG_ERROR("profile is not defined");
532 sync_agent_get_event_data_param(request, &content_type);
534 _DEBUG_INFO("request param : %s", profile);
535 _DEBUG_INFO("request param : %d", content_type);
537 int account_id = get_account_id(profile, false);
538 _DEBUG_INFO(" account_id: %d", account_id);
540 int in_param_index_array[2] = { 0, 1 };
541 void *in_param_value_array[2] = { &account_id, &content_type };
542 sync_agent_ec_value_type_e in_param_value_type_array[2] = { SYNC_AGENT_EC_VALUE_TYPE_INT, SYNC_AGENT_EC_VALUE_TYPE_INT };
544 unsigned int out_param_count;
545 sync_agent_ec_task_error_e task_error = SYNC_AGENT_EC_TASK_ERROR_NOT_YET_RUN;
546 sync_agent_ec_param_param_s **param_array = NULL;
548 unsigned int request_msg_id = 0;
549 sync_agent_request_sync_task(EC_MSG_TYPE_SYNC_TASK_GET_PROFILE_SYNC_CATEGORY, 0, 2, in_param_index_array, in_param_value_type_array, in_param_value_array, (int *)&request_msg_id, &task_error, &out_param_count, ¶m_array);
551 sync_agent_get_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &result);
552 sync_agent_get_param_value(&(param_array[1]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &enabled);
553 sync_agent_get_param_value(&(param_array[2]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &srcURI);
554 sync_agent_get_param_value(&(param_array[3]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &tgtURI);
555 sync_agent_get_param_value(&(param_array[4]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &id);
556 sync_agent_get_param_value(&(param_array[5]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &password);
559 _DEBUG_INFO("result = %d", result);
560 _DEBUG_INFO("enabled = %d", enabled);
561 _DEBUG_INFO("srcURI = %s", srcURI);
562 _DEBUG_INFO("tgtURI = %s", tgtURI);
563 _DEBUG_INFO("id = %s", id);
564 _DEBUG_INFO("password = %s", password);
567 sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &result);
568 sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &enabled);
569 sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)srcURI);
570 sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)tgtURI);
571 sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)id);
572 sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)password);
583 int event_callback_get_profile_last_statistics_sync(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
587 char *profile = NULL;
588 int content_type = 0;
589 char *dbSynced = "NO";
590 int last_session_time = -1;
591 int server2Client_Total = 0;
592 int server2Client_NrOfAdd = 0;
593 int server2Client_NrOfDelete = 0;
594 int server2Client_NrOfReplace = 0;
595 int client2Server_Total = 0;
596 int client2Server_NrOfAdd = 0;
597 int client2Server_NrOrDelete = 0;
598 int client2Server_NrOfReplace = 0;
601 sync_agent_get_event_data_param(request, &profile);
602 if (profile == NULL) {
603 _DEBUG_ERROR("profile is not defined");
608 sync_agent_get_event_data_param(request, &content_type);
610 _DEBUG_INFO("request param : %s", profile);
611 _DEBUG_INFO("request param : %d", content_type);
613 int account_id = get_account_id(profile, false);
615 int in_param_index_array[2] = { 0, 1 };
616 void *in_param_value_array[2] = { &account_id, &content_type };
617 sync_agent_ec_value_type_e in_param_value_type_array[2] = { SYNC_AGENT_EC_VALUE_TYPE_INT, SYNC_AGENT_EC_VALUE_TYPE_INT };
619 unsigned int out_param_count;
620 sync_agent_ec_task_error_e task_error = SYNC_AGENT_EC_TASK_ERROR_NOT_YET_RUN;
621 sync_agent_ec_param_param_s **param_array = NULL;
623 unsigned int request_msg_id = 0;
624 sync_agent_request_sync_task(EC_MSG_TYPE_SYNC_TASK_GET_PROFILE_STATISTICS, 0, 2, in_param_index_array, in_param_value_type_array, in_param_value_array, (int *)&request_msg_id, &task_error, &out_param_count, ¶m_array);
626 sync_agent_get_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &result);
627 sync_agent_get_param_value(&(param_array[1]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &dbSynced);
628 sync_agent_get_param_value(&(param_array[2]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &last_session_time);
629 sync_agent_get_param_value(&(param_array[3]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &server2Client_Total);
630 sync_agent_get_param_value(&(param_array[4]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &server2Client_NrOfAdd);
631 sync_agent_get_param_value(&(param_array[5]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &server2Client_NrOfDelete);
632 sync_agent_get_param_value(&(param_array[6]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &server2Client_NrOfReplace);
633 sync_agent_get_param_value(&(param_array[7]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &client2Server_Total);
634 sync_agent_get_param_value(&(param_array[8]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &client2Server_NrOfAdd);
635 sync_agent_get_param_value(&(param_array[9]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &client2Server_NrOrDelete);
636 sync_agent_get_param_value(&(param_array[10]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &client2Server_NrOfReplace);
639 _DEBUG_INFO("result = %d", result);
640 _DEBUG_INFO("dbSynced = %s\n", dbSynced);
641 _DEBUG_INFO("last_session_time = %d\n", last_session_time);
642 _DEBUG_INFO("server2Client_Total = %d\n", server2Client_Total);
643 _DEBUG_INFO("server2Client_NrOfAdd = %d\n", server2Client_NrOfAdd);
644 _DEBUG_INFO("server2Client_NrOfDelete = %d\n", server2Client_NrOfDelete);
645 _DEBUG_INFO("server2Client_NrOfReplace = %d\n", server2Client_NrOfReplace);
646 _DEBUG_INFO("client2Server_Total = %d\n", client2Server_Total);
647 _DEBUG_INFO("client2Server_NrOfAdd = %d\n", client2Server_NrOfAdd);
648 _DEBUG_INFO("client2Server_NrOrDelete = %d\n", client2Server_NrOrDelete);
649 _DEBUG_INFO("client2Server_NrOfReplace = %d\n", client2Server_NrOfReplace);
654 sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &result);
655 sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)dbSynced);
656 sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &last_session_time);
657 sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &server2Client_Total);
658 sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &server2Client_NrOfAdd);
659 sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &server2Client_NrOfDelete);
660 sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &server2Client_NrOfReplace);
661 sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &client2Server_Total);
662 sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &client2Server_NrOfAdd);
663 sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &client2Server_NrOrDelete);
664 sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &client2Server_NrOfReplace);
673 int event_callback_add_profile_cp_sync(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
677 char *profile_name = NULL;
680 char *password = NULL;
685 sync_agent_get_event_data_param(request, &profile_name);
686 sync_agent_get_event_data_param(request, &addr);
687 sync_agent_get_event_data_param(request, &id);
688 sync_agent_get_event_data_param(request, &password);
689 sync_agent_get_event_data_param(request, &category_count);
692 _DEBUG_INFO("request param : %s", profile_name);
693 _DEBUG_INFO("request param : %s", addr);
694 _DEBUG_INFO("request param : %s", id);
695 _DEBUG_INFO("request param : %s", password);
696 _DEBUG_INFO("request param : %d", category_count);
699 GList *categorys = NULL;
701 for (; i < category_count; i++) {
702 resource_cp_s *category = (resource_cp_s *) calloc(1, sizeof(resource_cp_s));
703 if (category == NULL) {
704 _DEBUG_ERROR("category is NULL !");
706 if (profile_name != NULL)
715 if (password != NULL)
721 sync_agent_get_event_data_param(request, &(category->name));
722 sync_agent_get_event_data_param(request, &(category->accept));
723 sync_agent_get_event_data_param(request, &(category->id));
724 sync_agent_get_event_data_param(request, &(category->password));
725 sync_agent_get_event_data_param(request, &(category->auth_type));
726 sync_agent_get_event_data_param(request, &(category->auth_data));
728 categorys = g_list_append(categorys, category);
731 _DEBUG_INFO("category[%d]->name : %s", i, category->name);
732 _DEBUG_INFO("category[%d]->accept : %s", i, category->accept);
733 _DEBUG_INFO("category[%d]->id : %s", i, category->id);
734 _DEBUG_INFO("category[%d]->password : %s", i, category->password);
735 _DEBUG_INFO("category[%d]->authType : %s", i, category->auth_type);
736 _DEBUG_INFO("category[%d]->authData : %s\n", i, category->auth_data);
740 /* send to engine controller */
741 void *in_param_value_array[5] = { &profile_name, &addr, &id, &password, &categorys };
742 int in_param_index_array[5] = { 0, 1, 2, 3, 4 };
743 sync_agent_ec_value_type_e in_param_value_type_array[5] = { SYNC_AGENT_EC_VALUE_TYPE_STRUCT, SYNC_AGENT_EC_VALUE_TYPE_STRUCT,
744 SYNC_AGENT_EC_VALUE_TYPE_STRUCT, SYNC_AGENT_EC_VALUE_TYPE_STRUCT, SYNC_AGENT_EC_VALUE_TYPE_STRUCT
746 unsigned int request_msg_id = 0;
748 unsigned int out_param_count;
749 sync_agent_ec_task_error_e task_error = SYNC_AGENT_EC_TASK_ERROR_NOT_YET_RUN;
750 sync_agent_ec_param_param_s **param_array = NULL;
752 sync_agent_request_sync_task(EC_MSG_TYPE_SYNC_TASK_ADD_PROFILE_CP, 0, 5, in_param_index_array, in_param_value_type_array, in_param_value_array, (int *)&request_msg_id, &task_error, &out_param_count, ¶m_array);
754 sync_agent_get_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &result);
755 sync_agent_get_param_value(&(param_array[1]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &account_id);
757 sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &result);
758 sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &account_id);
764 int event_callback_request_calllog_sync_async(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
770 sync_agent_get_event_data_param(request, &data);
772 _DEBUG_ERROR("data is NULL");
776 _DEBUG_INFO("data = %s", data);
778 result = send_ip_push_sync_msg(data);
782 sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &result);
788 int event_callback_request_reset_all_data_sync(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
794 /* 1. cancel current sync session */
795 cancel_current_sync_task();
797 /* 2. reset all data */
798 unsigned int request_msg_id = 0;
799 sync_agent_ec_task_error_e task_error = SYNC_AGENT_EC_TASK_ERROR_NOT_YET_RUN;
801 unsigned int out_param_count;
802 sync_agent_ec_param_param_s **param_array = NULL;
804 sync_agent_request_sync_task(EC_MSG_TYPE_SYNC_TASK_RESET_ALL_DATA, 0, 0, NULL, NULL, NULL, (int *)&request_msg_id, &task_error, &out_param_count, ¶m_array);
806 sync_agent_get_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &result);
807 _DEBUG_INFO("result = %d", result);
809 sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &result);
815 int event_callback_request_get_all_profiles_data(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
820 GList *profiles_data = NULL;
821 GList *profile_iter = NULL;
822 GList *category_iter = NULL;
824 int profile_count = 0;
825 int category_count = 0;
826 sync_agent_ds_profile_info *profile_info = NULL;
827 sync_agent_ds_service_info *category_info = NULL;
829 unsigned int out_param_count;
830 sync_agent_ec_task_error_e task_error = SYNC_AGENT_EC_TASK_ERROR_NOT_YET_RUN;
831 sync_agent_ec_param_param_s **param_array = NULL;
833 unsigned int request_msg_id = 0;
834 sync_agent_request_sync_task(EC_MSG_TYPE_SYNC_TASK_GET_ALL_PROFILES_DATA, 0, 0, NULL, NULL, NULL, (int *)&request_msg_id, &task_error, &out_param_count, ¶m_array);
836 sync_agent_get_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &result);
837 sync_agent_get_param_value(&(param_array[1]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &profiles_data);
839 sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &result);
840 _DEBUG_INFO("result = %d", result);
842 if (profiles_data != NULL) {
843 profile_count = g_list_length(profiles_data);
844 sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &profile_count);
845 _DEBUG_INFO("profile_count = %d", profile_count);
847 for (profile_iter = profiles_data; profile_iter != NULL; profile_iter = g_list_next(profile_iter)) {
848 profile_info = (sync_agent_ds_profile_info *) profile_iter->data;
850 sync_agent_ds_server_info *server_info = &profile_info->server_info;
851 sync_agent_ds_sync_info *sync_info = &profile_info->sync_info;
853 sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)profile_info->profile_dir_name);
854 sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)profile_info->profile_name);
856 sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)server_info->addr);
857 sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)server_info->id);
858 sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)server_info->password);
860 sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)sync_info->sync_mode);
861 sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)sync_info->sync_type);
862 sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)sync_info->interval);
864 sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &profile_info->last_sync_status);
865 sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &profile_info->last_sync_time);
867 _DEBUG_INFO("profile_info->profile_dir_name = %s", profile_info->profile_dir_name);
868 _DEBUG_INFO("profile_info->profile_name = %s", profile_info->profile_name);
870 _DEBUG_INFO("server_info->addr = %s", server_info->addr);
871 _DEBUG_INFO("server_info->id = %s", server_info->id);
872 _DEBUG_INFO("server_info->password = %s", server_info->password);
874 _DEBUG_INFO("sync_info->sync_mode = %s", sync_info->sync_mode);
875 _DEBUG_INFO("sync_info->sync_type = %s", sync_info->sync_type);
876 _DEBUG_INFO("sync_info->interval = %s", sync_info->interval);
878 _DEBUG_INFO("profile_info->last_sync_status = %d", profile_info->last_sync_status);
879 _DEBUG_INFO("profile_info->last_sync_time = %d", profile_info->last_sync_time);
881 category_count = g_list_length(profile_info->service_list);
882 sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &category_count);
884 _DEBUG_INFO("category_count = %d", category_count);
886 for (category_iter = profile_info->service_list; category_iter != NULL; category_iter = g_list_next(category_iter)) {
887 category_info = (sync_agent_ds_service_info *) category_iter->data;
889 sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &category_info->service_type);
890 sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &category_info->enabled);
891 sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)category_info->src_uri);
892 sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)category_info->tgt_uri);
893 sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)category_info->id);
894 sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)category_info->password);
896 _DEBUG_INFO("category_info->service_type = %d", category_info->service_type);
897 _DEBUG_INFO("category_info->enabled = %d", category_info->enabled);
898 _DEBUG_INFO("category_info->src_uri = %s", category_info->src_uri);
899 _DEBUG_INFO("category_info->tgt_uri = %s", category_info->tgt_uri);
900 _DEBUG_INFO("category_info->id = %s", category_info->id);
901 _DEBUG_INFO("category_info->password = %s", category_info->password);