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 #include <sync_agent.h>
22 #include "common/dm_common.h"
23 #include "common/util/util.h"
24 #include "framework/task/oma_dm_task_spec.h"
25 #include "framework/task/oma_dm_task_request.h"
26 #include "framework/san-parser/pm_sanparser.h"
27 #include "framework/ui-event-handler/ipc_agent.h"
28 #include "framework/platform-event-handler/dm_platform_event_handler.h"
29 #include "dm-engine/dm_common_engine.h"
30 #include "dm-engine/bootstrap/factory_bootstrap.h"
31 #include "dm-engine/fumo/fumo_engine.h"
32 #include "dm-engine/lawmo/lawmo_engine.h"
34 #ifndef OMADM_AGENT_LOG
36 #define LOG_TAG "TASK_SPEC"
39 static sync_agent_ec_task_error_e _start_dm_init_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array);
40 static sync_agent_ec_task_error_e _start_dm_reset_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array);
41 static sync_agent_ec_task_error_e _start_bootstrap_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array);
42 static sync_agent_ec_task_error_e _start_dm_fumo_common_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array);
43 static sync_agent_ec_task_error_e _start_dm_fumo_ui_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array);
44 static sync_agent_ec_task_error_e _start_dm_lawmo_common_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array);
45 static sync_agent_ec_task_error_e _start_genericAlert_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array);
46 static sync_agent_ec_task_error_e _start_fumo_serviceEngine_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array);
47 static sync_agent_ec_task_error_e _start_lawmo_serviceEngine_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array);
48 static sync_agent_ec_task_error_e _start_fumo_schedule_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array);
50 sync_agent_ec_task_spec_s *make_dm_init_task_spec()
54 sync_agent_ec_param_spec_s *pParam_spec1 = sync_agent_alloc_param_spec_int("dm_init_start", false, true, false, 0, 0, false, 0, false, 0, 0);
55 sync_agent_ec_param_spec_s *param_spec_array[1] = { pParam_spec1 };
57 sync_agent_ec_task_spec_s *pTask_spec = sync_agent_alloc_simple_task_spec("dm_init",
58 _start_dm_init_process, NULL, NULL,
61 sync_agent_unref_param_spec(pParam_spec1);
68 static sync_agent_ec_task_error_e _start_dm_init_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array)
75 _DEBUG_TRACE("status db : %d", ret);
76 ret = sync_agent_open_agent();
77 _DEBUG_TRACE("status db : %d", ret);
79 sync_agent_ec_task_error_e err = SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS;
80 ENGINE_STATUS value = DM_IDLE;
81 engine_status *status = NULL;
83 int is_exist = IsExist_Engine_id(IDLE_ENGINE);
87 ret = Get_Engine_Status(IDLE_ENGINE, &status);
89 _DEBUG_TRACE("status is null");
94 _DEBUG_TRACE("STATUS VALUE : %d ", status->engine_status);
95 value = status->engine_status;
97 if (value == DM_BEFORE_BOOTSTRAP) {
98 ret = bootstrap_task_request();
101 ret = auto_operate_service_engine();
104 sync_agent_set_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &value);
106 sync_agent_close_mo();
107 ret = sync_agent_close_agent();
108 _DEBUG_TRACE("close db agent : %d", ret);
111 Free_Memory_Engine_Status(&status, 1);
114 _DEBUG_TRACE("status is null");
122 sync_agent_set_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &value);
123 err = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
125 sync_agent_close_mo();
126 ret = sync_agent_close_agent();
127 _DEBUG_TRACE("close db agent : %d", ret);
131 Free_Memory_Engine_Status(&status, 1);
137 sync_agent_ec_task_spec_s *make_dm_reset_task_spec()
141 sync_agent_ec_param_spec_s *pParam_spec1 = sync_agent_alloc_param_spec_int("dm_reset_start", false, true, false, 0, 0, false, 0, false, 0, 0);
142 sync_agent_ec_param_spec_s *param_spec_array[1] = { pParam_spec1 };
144 sync_agent_ec_task_spec_s *pTask_spec = sync_agent_alloc_simple_task_spec("dm_reset",
145 _start_dm_reset_process, NULL, NULL,
146 1, param_spec_array);
148 sync_agent_unref_param_spec(pParam_spec1);
155 static sync_agent_ec_task_error_e _start_dm_reset_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array)
160 DM_ERROR ret = DM_OK;
162 ret = sync_agent_open_agent();
164 sync_agent_ec_task_error_e err = SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS;
170 sync_agent_set_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &ret);
172 ret = sync_agent_close_agent();
180 sync_agent_set_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &ret);
181 err = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
183 ret = sync_agent_close_agent();
190 sync_agent_ec_task_spec_s *make_bootstrap_task_spec()
194 sync_agent_ec_param_spec_s *pParam_spec1 = sync_agent_alloc_param_spec_int("bootstrap_start", true, false, false, 0, 0, false, 0, false, 0, 0);
195 sync_agent_ec_param_spec_s *pParam_spec2 = sync_agent_alloc_param_spec_int("bootstrap_result", false, true, false, 0, 0, false, 0, false, 0, 0);
197 sync_agent_ec_param_spec_s *param_spec_array[2] = { pParam_spec1, pParam_spec2 };
199 sync_agent_ec_task_spec_s *pTask_spec = sync_agent_alloc_simple_task_spec("dm_bootstrap_task",
200 _start_bootstrap_process, NULL, NULL,
201 2, param_spec_array);
203 sync_agent_unref_param_spec(pParam_spec1);
204 sync_agent_unref_param_spec(pParam_spec2);
210 static sync_agent_ec_task_error_e _start_bootstrap_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array)
214 DM_ERROR ret = DM_OK;
215 sync_agent_open_mo();
216 _DEBUG_TRACE(" Done Open Mo DB\n");
219 sync_agent_ec_task_error_e err = SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS;
222 * factory bootstrap 0
223 * server init bootstrap 1
224 * smart card bootstrap 2
227 int bootstrapType = 0;
228 sync_agent_get_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &bootstrapType);
233 _DEBUG_TRACE("reset dm db : %d", ret);
235 for (i = 0; i < max_try; ++i) {
236 switch (bootstrapType) {
238 ret = factory_bootstrap(NO_ENGINE_TYPE);
239 _DEBUG_TRACE("factory bootstrap : %d", ret);
242 _DEBUG_TRACE("reset dm db : %d", ret);
243 ret = DM_ERR_BOOTSTRAP;
251 ret = DM_ERR_BOOTSTRAP;
257 sync_agent_set_param_value(&(param_array[1]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, (void *)(&ret));
261 sync_agent_close_mo();
262 _DEBUG_TRACE(" Done Close Mo DB\n");
268 sync_agent_set_param_value(&(param_array[1]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, (void *)(&ret));
269 err = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
270 _DEBUG_TRACE("error");
273 sync_agent_close_mo();
274 _DEBUG_TRACE("Done Close Mo DB\n");
279 sync_agent_ec_task_spec_s *make_dm_fumo_common_process_task_spec()
283 sync_agent_ec_param_spec_s *pParam_spec1 = sync_agent_alloc_param_spec_structure("eventData", NULL, event_data_free, true, false, false, 0, false, 0, false, 0);
284 sync_agent_ec_param_spec_s *pParam_spec2 = sync_agent_alloc_param_spec_int("common_fumo_dm_result", false, true, false, 0, 0, false, 0, false, 0, 0);
286 sync_agent_ec_param_spec_s *param_spec_array[2] = { pParam_spec1, pParam_spec2 };
288 sync_agent_ec_task_spec_s *pTask_spec = sync_agent_alloc_simple_task_spec("common_fumo_dm",
289 _start_dm_fumo_common_process, NULL, NULL,
290 2, param_spec_array);
292 sync_agent_unref_param_spec(pParam_spec1);
293 sync_agent_unref_param_spec(pParam_spec2);
300 static sync_agent_ec_task_error_e _start_dm_fumo_common_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array)
304 _DEBUG_TRACE(" Done Open Mo DB\n");
306 DM_ERROR ret = DM_OK;
308 ret = sync_agent_open_agent();
309 sync_agent_open_mo();
310 sync_agent_ec_task_error_e err = SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS;
313 * telephony vconf status get
314 * if connecting call status
318 int roaming_state = -1;
321 Event_Contents *pEvent_data = NULL;
324 get_roaming_state(&roaming_state);
325 get_wifi_connected_state(&wifi_state);
326 get_call_sate(&call_state);
328 if (roaming_state == -1 || call_state == -1) {
329 _DEBUG_TRACE("NOT ROAMING OR CALL STATUS roaming state : %d , call state : %d", roaming_state, call_state);
330 ret = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
334 if (call_state == -1) {
335 _DEBUG_TRACE("CALL STATUS call state : %d", call_state);
336 ret = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
339 if ( (roaming_state == -1) && (wifi_state == -1) ) {
340 _DEBUG_TRACE("NOT ROAMING AND WiFi Status roaming state : %d , WiFi state : %d", roaming_state, wifi_state);
341 ret = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
345 task_id = sync_agent_get_self_request_id();
346 _DEBUG_TRACE("task id ============================================ %d", task_id);
348 sync_agent_get_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &pEvent_data);
349 if (pEvent_data == NULL) {
350 _DEBUG_TRACE("-------------------------------------NOT EVENT IDLE---------------------------------------");
354 if (pEvent_data->server_id == NULL) {
355 _DEBUG_TRACE("server id null");
356 ret = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
360 if (pEvent_data != NULL) {
361 _DEBUG_TRACE("mode = %d", pEvent_data->type);
362 _DEBUG_TRACE("server id = %s", pEvent_data->server_id);
363 _DEBUG_TRACE("session id= %s", pEvent_data->session_id);
364 _DEBUG_TRACE("noti type id= %d", pEvent_data->noti_type);
365 _DEBUG_TRACE("ui mode id= %s", pEvent_data->ui_mode);
368 if (pEvent_data->ui_mode != NULL) {
370 //add_config_db_using_ui( task_id, pEvent_data->ui_mode);
373 is_exist = IsExist_Engine_id(FUMO_SERVICE_ENGINE);
374 _DEBUG_INFO("IsExist_Engine_id(FUMO_SERVICE_ENGINE) [%d]", is_exist);
377 engine_status status;
378 memset(&status, 0x00, sizeof(engine_status));
379 status.engine_id = FUMO_SERVICE_ENGINE;
380 status.engine_status = DM_SERVICE_UNKNOWN;
381 //status.server_id = strdup(pEvent_data->server_id);
382 status.server_id = pEvent_data->server_id;
383 status.server_url = 0;
384 status.correlator = 0;
386 status.result_status = DM_OK;
387 //status.ui_mode = strdup(pEvent_data->ui_mode);
388 status.ui_mode = pEvent_data->ui_mode;
389 status.task_id = task_id;
390 status.ui_noti_type = get_default_noti_type(pEvent_data->ui_mode, pEvent_data->noti_type); //0;
392 status.download_click = RESUME_STATUS_DONWLOAD_BEFORE;
393 _DEBUG_TRACE("status noti ui type : %d", status.ui_noti_type);
394 DB_Begin_Transaction();
396 ret = Add_Engine_Status(&status);
397 _DEBUG_TRACE(" -------------------------------------add engine status : %d -------------------------------------\n", ret);
398 DB_End_Transaction(TRANSACTION_COMMIT_);
400 //str_free(&(status.server_id));
401 //str_free(&(status.ui_mode));
404 engine_status *status;
405 ret = Get_Engine_Status(FUMO_SERVICE_ENGINE, &status);
406 if (status != NULL) {
407 _DEBUG_TRACE(" -------------------------------------update engine status -------------------------------------\n");
408 status->ui_mode = strdup(pEvent_data->ui_mode);
409 status->task_id = task_id;
410 status->ui_noti_type = get_default_noti_type(pEvent_data->ui_mode, pEvent_data->noti_type); //0;
411 //status->download_click = RESUME_STATUS_DONWLOAD_BEFORE; // 959 error fix about "download done -> softwareupdate retry clicked". ???
413 DB_Begin_Transaction();
414 ret = Update_Engine_Status(status);
415 _DEBUG_TRACE(" update engine status : %d \n", ret);
416 _DEBUG_TRACE(" status->download_click [%d] ", status->download_click);
417 DB_End_Transaction(TRANSACTION_COMMIT_);
420 Free_Memory_Engine_Status(&status, 1);
425 int noti_ret = noti_start(pEvent_data->ui_mode);
426 _DEBUG_TRACE("noti start : %d", noti_ret);
429 _DEBUG_TRACE("ui mode null");
432 ENGINE_STATUS value = 0;
433 engine_status *status = NULL;
434 ret = Get_Engine_Status(IDLE_ENGINE, &status);
435 if (status != NULL) {
436 _DEBUG_TRACE("STATUS VALUE : %d ", status->engine_status);
437 value = status->engine_status;
439 if (value != DM_BEFORE_BOOTSTRAP) {
440 _DEBUG_INFO("status->ui_noti_type [%d] pEvent_data->noti_type [%d]", status->ui_noti_type, pEvent_data->noti_type);
441 if(pEvent_data->noti_type == NOTI_TYPE_POLLINTERACTION) {
443 ret = dm_common_start(pEvent_data);
447 //retry factorybootstrap
450 Free_Memory_Engine_Status(&status, 1);
452 ret = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
455 _DEBUG_TRACE("end ret :%d ", ret);
459 sync_agent_set_param_value(&(param_array[1]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, (void *)(&ret));
461 event_data_free((void *)pEvent_data);
462 ret = sync_agent_close_agent();
464 sync_agent_close_mo();
465 _DEBUG_TRACE("Done Close Mo DB\n");
470 _DEBUG_ERROR("error : %d", ret);
472 sync_agent_set_param_value(&(param_array[1]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, (void *)(&ret));
474 event_data_free((void *)pEvent_data);
475 ret = sync_agent_close_agent();
477 sync_agent_close_mo();
478 err = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
479 _DEBUG_ERROR("Done Close Mo DB\n");
484 sync_agent_ec_task_spec_s *make_dm_fumo_ui_process_task_spec()
488 sync_agent_ec_param_spec_s *pParam_spec1 = sync_agent_alloc_param_spec_structure("eventData", NULL, event_data_free, true, false, false, 0, false, 0, false, 0);
489 sync_agent_ec_param_spec_s *pParam_spec2 = sync_agent_alloc_param_spec_int("ui_fumo_dm_result", false, true, false, 0, 0, false, 0, false, 0, 0);
491 sync_agent_ec_param_spec_s *param_spec_array[2] = { pParam_spec1, pParam_spec2 };
493 sync_agent_ec_task_spec_s *pTask_spec = sync_agent_alloc_simple_task_spec("ui_fumo_dm",
494 _start_dm_fumo_ui_process, NULL, NULL,
495 2, param_spec_array);
497 sync_agent_unref_param_spec(pParam_spec1);
498 sync_agent_unref_param_spec(pParam_spec2);
505 static sync_agent_ec_task_error_e _start_dm_fumo_ui_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array)
509 DM_ERROR ret = DM_OK;
510 sync_agent_ec_task_error_e err = SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS;
513 * telephony vconf status get
514 * if connecting call status
522 task_id = sync_agent_get_self_request_id();
523 _DEBUG_TRACE("task id ============================================ %d", task_id);
525 Event_Contents *pEvent_data = NULL;
526 sync_agent_get_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &pEvent_data);
527 if (pEvent_data == NULL || (pEvent_data->session_id) == NULL || (pEvent_data->server_id) == NULL) {
528 _DEBUG_TRACE("-------------------------------------NOT EVENT IDLE---------------------------------------");
529 ret = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
533 _DEBUG_TRACE("-----------------------------------%s---------------------------------------", pEvent_data->session_id);
534 _DEBUG_TRACE("-----------------------------------%s---------------------------------------", pEvent_data->server_id);
535 _DEBUG_TRACE("noti type id= %d", pEvent_data->noti_type);
536 _DEBUG_TRACE("session id= %s", pEvent_data->session_id);
538 _DEBUG_TRACE("server id= %s", pEvent_data->server_id);
539 ENGINE_STATUS value = 0;
540 engine_status *status = NULL;
541 ret = Get_Engine_Status(IDLE_ENGINE, &status);
542 if (status != NULL) {
543 _DEBUG_TRACE("STATUS VALUE : %d ", status->engine_status);
544 value = status->engine_status;
546 if (value != DM_BEFORE_BOOTSTRAP) {
547 ret = launch_om_dm_fumo_noti_ui(pEvent_data->noti_type, pEvent_data->session_id, pEvent_data->server_id);
549 _DEBUG_TRACE("ui launch fail");
553 //retry factorybootstrap
556 Free_Memory_Engine_Status(&status, 1);
559 _DEBUG_TRACE("end ret :%d ", ret);
563 sync_agent_set_param_value(&(param_array[1]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, (void *)(&ret));
566 event_data_free((void *)pEvent_data);
567 _DEBUG_TRACE("Done Close Mo DB\n");
572 //err = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
573 _DEBUG_TRACE("error");
575 sync_agent_set_param_value(&(param_array[1]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, (void *)(&ret));
578 event_data_free((void *)pEvent_data);
579 _DEBUG_TRACE("Done Close Mo DB\n");
584 sync_agent_ec_task_spec_s *make_dm_lawmo_common_process_task_spec()
588 sync_agent_ec_param_spec_s *pParam_spec1 = sync_agent_alloc_param_spec_structure("eventData", NULL, event_data_free, true, false, false, 0, false, 0, false, 0);
589 sync_agent_ec_param_spec_s *pParam_spec2 = sync_agent_alloc_param_spec_int("common_lawmo_dm_result", false, true, false, 0, 0, false, 0, false, 0, 0);
591 sync_agent_ec_param_spec_s *param_spec_array[2] = { pParam_spec1, pParam_spec2 };
593 sync_agent_ec_task_spec_s *pTask_spec = sync_agent_alloc_simple_task_spec("common_lawmo_dm",
594 _start_dm_lawmo_common_process, NULL, NULL,
595 2, param_spec_array);
597 sync_agent_unref_param_spec(pParam_spec1);
598 sync_agent_unref_param_spec(pParam_spec2);
604 static sync_agent_ec_task_error_e _start_dm_lawmo_common_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array)
608 sync_agent_open_mo();
609 _DEBUG_TRACE(" Done Open Mo DB\n");
611 DM_ERROR ret = DM_OK;
613 ret = sync_agent_open_agent();
614 sync_agent_ec_task_error_e err = SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS;
617 task_id = sync_agent_get_self_request_id();*/
619 Event_Contents *pEvent_data = NULL;
620 sync_agent_get_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &pEvent_data);
621 if (pEvent_data == NULL) {
622 _DEBUG_TRACE("-------------------------------------NOT EVENT IDLE---------------------------------------");
626 if (pEvent_data != NULL) {
627 _DEBUG_TRACE("mode = %d", pEvent_data->type);
628 _DEBUG_TRACE("server id = %s", pEvent_data->server_id);
629 _DEBUG_TRACE("session id= %s", pEvent_data->session_id);
630 _DEBUG_TRACE("noti type id= %d", pEvent_data->noti_type);
631 _DEBUG_TRACE("ui mode id= %s", pEvent_data->ui_mode);
634 ENGINE_STATUS value = 0;
635 engine_status *status = NULL;
636 ret = Get_Engine_Status(IDLE_ENGINE, &status);
637 if (status != NULL) {
638 _DEBUG_TRACE("STATUS VALUE : %d ", status->engine_status);
639 value = status->engine_status;
641 if (value != DM_BEFORE_BOOTSTRAP) {
642 ret = dm_common_start(pEvent_data);
645 //retry factorybootstrap
648 Free_Memory_Engine_Status(&status, 1);
651 if(engine_type == SAMSUNG_FUMO_TYPE)
652 delete_config_db_using_ui( task_id);*/
654 _DEBUG_TRACE("end ret :%d ", ret);
658 sync_agent_set_param_value(&(param_array[1]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, (void *)(&ret));
660 event_data_free((void *)pEvent_data);
661 ret = sync_agent_close_agent();
663 sync_agent_close_mo();
664 _DEBUG_TRACE("Done Close Mo DB\n");
670 _DEBUG_TRACE("error");
672 sync_agent_set_param_value(&(param_array[1]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, (void *)(&ret));
673 event_data_free((void *)pEvent_data);
674 ret = sync_agent_close_agent();
676 sync_agent_close_mo();
677 _DEBUG_TRACE("Done Close Mo DB\n");
682 sync_agent_ec_task_spec_s *make_genericAlert_process_task_spec()
686 sync_agent_ec_param_spec_s *pParam_spec1 = sync_agent_alloc_param_spec_int("genericAlert_result", false, true, false, 0, 0, false, 0, false, 0, 0);
687 sync_agent_ec_param_spec_s *param_spec_array[1] = { pParam_spec1 };
689 sync_agent_ec_task_spec_s *pTask_spec = sync_agent_alloc_simple_task_spec("dm_genericAlert_task",
690 _start_genericAlert_process, NULL, NULL,
691 1, param_spec_array);
693 sync_agent_unref_param_spec(pParam_spec1);
700 static sync_agent_ec_task_error_e _start_genericAlert_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array)
704 sync_agent_open_mo();
705 _DEBUG_TRACE(" Done Open Mo DB\n");
707 DM_ERROR ret = DM_OK;
709 ret = sync_agent_open_agent();
710 sync_agent_ec_task_error_e err = SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS;
712 /*ENGINE_ID service_engine_id = GENERICALERT;
713 engine_status *service_status= NULL;
714 char* server_id = NULL;
717 if( IsExist_Engine_id(service_engine_id) == 1) {
718 ret = Get_Engine_Status(SERVICE_ENGINE, &service_status);
722 server_id = strdup(service_status->server_id);
723 result = service_status->engine_status;
724 ret = Free_Memory_Engine_Status(&service_status, 1);
726 ret = genericalert_operation(result, server_id);
732 sync_agent_set_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, (void *)(&ret));
735 ret = sync_agent_close_agent();
737 sync_agent_close_mo();
738 _DEBUG_TRACE("Done Close Mo DB\n");
743 err = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
744 _DEBUG_TRACE("error");
747 sync_agent_close_mo();
748 _DEBUG_TRACE( "Done Close Mo DB\n");
752 sync_agent_ec_task_spec_s *make_fumo_serviceEngine_process_task_spec()
756 sync_agent_ec_param_spec_s *pParam_spec1 = sync_agent_alloc_param_spec_int("fumo_service_engine_result", false, true, false, 0, 0, false, 0, false, 0, 0);
757 sync_agent_ec_param_spec_s *param_spec_array[1] = { pParam_spec1 };
759 sync_agent_ec_task_spec_s *pTask_spec = sync_agent_alloc_simple_task_spec("dm_fumo_service_engine_task",
760 _start_fumo_serviceEngine_process, NULL, NULL,
761 1, param_spec_array);
763 sync_agent_unref_param_spec(pParam_spec1);
770 static sync_agent_ec_task_error_e _start_fumo_serviceEngine_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array)
774 DM_ERROR ret = DM_OK;
775 DM_ERROR service_ret = DM_OK;
777 sync_agent_open_mo();
779 _DEBUG_TRACE("status db open : %d", ret);
780 ret = sync_agent_open_agent();
781 _DEBUG_TRACE("daci db open : %d", ret);
783 sync_agent_ec_task_error_e err = SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS;
785 int roaming_state = -1;
788 get_roaming_state(&roaming_state);
789 get_wifi_connected_state(&wifi_state);
790 get_call_sate(&call_state);
792 if (roaming_state == -1 || call_state == -1) {
793 _DEBUG_TRACE("NOT ROAMING OR CALL STATUS roaming state : %d , call state : %d", roaming_state, call_state);
794 ret = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
798 if (call_state == -1) {
799 _DEBUG_TRACE("CALL STATUS call state : %d", call_state);
800 ret = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
803 if ( (roaming_state == -1) && (wifi_state == -1) ) {
804 _DEBUG_TRACE("NOT ROAMING AND WiFi Status roaming state : %d , WiFi state : %d", roaming_state, wifi_state);
805 ret = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
811 task_id = sync_agent_get_self_request_id();
812 ret = Update_Engine_Status_Column(FUMO_SERVICE_ENGINE, VALUE_TASK_ID, &task_id);
813 _DEBUG_TRACE("update engine status : %d", ret);
814 _DEBUG_TRACE("------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------");
815 _DEBUG_TRACE("task id : %d", task_id);
816 _DEBUG_TRACE("------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------");
817 ret = service_engine_start(FUMO_SERVICE_ENGINE, &service_ret);
821 sync_agent_set_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, (void *)(&ret));
825 ret = sync_agent_close_agent();
827 sync_agent_close_mo();
828 _DEBUG_TRACE("Done Close Mo DB\n");
833 err = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
834 _DEBUG_TRACE("error");
836 sync_agent_set_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, (void *)(&ret));
838 ret = sync_agent_close_agent();
840 sync_agent_close_mo();
841 _DEBUG_TRACE("Done Close Mo DB\n");
846 sync_agent_ec_task_spec_s *make_lawmo_serviceEngine_process_task_spec()
850 sync_agent_ec_param_spec_s *pParam_spec1 = sync_agent_alloc_param_spec_int("lawmo_service_engine_result", false, true, false, 0, 0, false, 0, false, 0, 0);
851 sync_agent_ec_param_spec_s *param_spec_array[1] = { pParam_spec1 };
853 sync_agent_ec_task_spec_s *pTask_spec = sync_agent_alloc_simple_task_spec("dm_lawmo_service_engine_task",
854 _start_lawmo_serviceEngine_process, NULL, NULL,
855 1, param_spec_array);
857 sync_agent_unref_param_spec(pParam_spec1);
864 static sync_agent_ec_task_error_e _start_lawmo_serviceEngine_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array)
868 DM_ERROR ret = DM_OK;
869 DM_ERROR service_ret = DM_OK;
871 sync_agent_open_mo();
873 ret = sync_agent_open_agent();
875 sync_agent_ec_task_error_e err = SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS;
877 ret = service_engine_start(LAWMO_SERVICE_ENGINE, &service_ret);
881 sync_agent_set_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, (void *)(&ret));
885 ret = sync_agent_close_agent();
887 sync_agent_close_mo();
888 _DEBUG_TRACE("Done Close Mo DB\n");
893 err = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
895 sync_agent_set_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, (void *)(&ret));
896 _DEBUG_TRACE("error");
898 ret = sync_agent_close_agent();
900 sync_agent_close_mo();
901 _DEBUG_TRACE("Done Close Mo DB\n");
906 sync_agent_ec_task_spec_s *make_fumo_schedule_process_task_spec()
910 sync_agent_ec_param_spec_s *pParam_spec1 = sync_agent_alloc_param_spec_int("fumo_schdule_start", true, false, false, 0, 0, false, 0, false, 0, 0);
911 sync_agent_ec_param_spec_s *pParam_spec2 = sync_agent_alloc_param_spec_int("fumo_schdule_result", false, true, false, 0, 0, false, 0, false, 0, 0);
913 sync_agent_ec_param_spec_s *param_spec_array[2] = { pParam_spec1, pParam_spec2 };
915 sync_agent_ec_task_spec_s *pTask_spec = sync_agent_alloc_simple_task_spec("dm_fumo_schdule_task",
916 _start_fumo_schedule_process, NULL, NULL,
917 2, param_spec_array);
919 sync_agent_unref_param_spec(pParam_spec1);
920 sync_agent_unref_param_spec(pParam_spec2);
926 static sync_agent_ec_task_error_e _start_fumo_schedule_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array)
930 DM_ERROR ret = DM_OK;
932 da_err = sync_agent_open_agent();
933 _DEBUG_TRACE("db open result : %d", da_err);
935 sync_agent_ec_task_error_e err = SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS;
937 Reminder_Interval reminder_interval_type = 0;
938 sync_agent_get_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &reminder_interval_type);
940 delete_alarm_item(FUMO_INTERVAL, FUMO_INTERVAL_TYPE);
942 ret = add_alarm_item(reminder_interval_type, FUMO_INTERVAL, FUMO_INTERVAL_TYPE);
948 _DEBUG_TRACE("schedule fail");
952 sync_agent_set_param_value(&(param_array[1]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, (void *)(&ret));
954 da_err = sync_agent_close_agent();
955 _DEBUG_TRACE("db close result : %d", da_err);
960 err = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
961 _DEBUG_TRACE("error");
963 sync_agent_set_param_value(&(param_array[1]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, (void *)(&ret));
965 da_err = sync_agent_close_agent();
966 _DEBUG_TRACE("Done Close Mo DB\n");