summaryrefslogtreecommitdiff
path: root/src/agent/framework/task/oma_dm_task_spec.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/agent/framework/task/oma_dm_task_spec.c')
-rw-r--r--src/agent/framework/task/oma_dm_task_spec.c934
1 files changed, 934 insertions, 0 deletions
diff --git a/src/agent/framework/task/oma_dm_task_spec.c b/src/agent/framework/task/oma_dm_task_spec.c
new file mode 100644
index 0000000..7bbb4f6
--- /dev/null
+++ b/src/agent/framework/task/oma_dm_task_spec.c
@@ -0,0 +1,934 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*sync-agent*/
+#include <sync_agent.h>
+
+/*dm-agent*/
+#include "common/dm_common.h"
+#include "common/util/util.h"
+#include "framework/task/oma_dm_task_spec.h"
+#include "framework/task/oma_dm_task_request.h"
+#include "framework/san-parser/pm_sanparser.h"
+#include "framework/ui-event-handler/ipc_agent.h"
+#include "framework/platform-event-handler/dm_platform_event_handler.h"
+#include "dm-engine/dm_common_engine.h"
+#include "dm-engine/bootstrap/factory_bootstrap.h"
+#include "dm-engine/fumo/fumo_engine.h"
+#include "dm-engine/lawmo/lawmo_engine.h"
+
+#ifndef OMADM_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "TASK_SPEC"
+#endif
+
+static sync_agent_ec_task_error_e _start_dm_init_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array);
+static sync_agent_ec_task_error_e _start_dm_reset_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array);
+static sync_agent_ec_task_error_e _start_bootstrap_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array);
+static sync_agent_ec_task_error_e _start_dm_fumo_common_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array);
+static sync_agent_ec_task_error_e _start_dm_fumo_ui_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array);
+static sync_agent_ec_task_error_e _start_dm_lawmo_common_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array);
+static sync_agent_ec_task_error_e _start_genericAlert_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array);
+static sync_agent_ec_task_error_e _start_fumo_serviceEngine_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array);
+static sync_agent_ec_task_error_e _start_lawmo_serviceEngine_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array);
+static sync_agent_ec_task_error_e _start_fumo_schedule_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array);
+
+sync_agent_ec_task_spec_s *make_dm_init_task_spec()
+{
+ _EXTERN_FUNC_ENTER;
+
+ 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);
+ sync_agent_ec_param_spec_s *param_spec_array[1] = { pParam_spec1 };
+
+ sync_agent_ec_task_spec_s *pTask_spec = sync_agent_alloc_simple_task_spec("dm_init",
+ _start_dm_init_process, NULL, NULL,
+ 1, param_spec_array);
+
+ sync_agent_unref_param_spec(pParam_spec1);
+
+ _EXTERN_FUNC_EXIT;
+ return pTask_spec;
+
+}
+
+static sync_agent_ec_task_error_e _start_dm_init_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array)
+{
+ _INNER_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+ sync_agent_open_mo();
+ ret = DB_Open();
+ _DEBUG_TRACE("status db : %d", ret);
+ ret = sync_agent_open_agent();
+ _DEBUG_TRACE("status db : %d", ret);
+
+ sync_agent_ec_task_error_e err = SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS;
+ ENGINE_STATUS value = DM_IDLE;
+ engine_status *status = NULL;
+
+ int is_exist = IsExist_Engine_id(IDLE_ENGINE);
+ if (is_exist == 0)
+ goto error;
+
+ ret = Get_Engine_Status(IDLE_ENGINE, &status);
+ if (ret != DM_OK) {
+ _DEBUG_TRACE("status is null");
+ goto error;
+ }
+ if (status != NULL) {
+
+ _DEBUG_TRACE("STATUS VALUE : %d ", status->engine_status);
+ value = status->engine_status;
+
+ if (value == DM_BEFORE_BOOTSTRAP) {
+ ret = bootstrap_task_request();
+ } else {
+ init_Dm_Engine();
+ ret = auto_operate_service_engine();
+ }
+
+ sync_agent_set_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &value);
+
+ sync_agent_close_mo();
+ ret = sync_agent_close_agent();
+ _DEBUG_TRACE("close db agent : %d", ret);
+ DB_Close();
+
+ Free_Memory_Engine_Status(&status, 1);
+
+ } else {
+ _DEBUG_TRACE("status is null");
+ }
+
+ _INNER_FUNC_EXIT;
+ return err;
+
+ error:
+
+ sync_agent_set_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &value);
+ err = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
+
+ sync_agent_close_mo();
+ ret = sync_agent_close_agent();
+ _DEBUG_TRACE("close db agent : %d", ret);
+ DB_Close();
+
+ if (status != NULL)
+ Free_Memory_Engine_Status(&status, 1);
+
+ _INNER_FUNC_EXIT;
+ return err;
+}
+
+sync_agent_ec_task_spec_s *make_dm_reset_task_spec()
+{
+ _EXTERN_FUNC_ENTER;
+
+ 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);
+ sync_agent_ec_param_spec_s *param_spec_array[1] = { pParam_spec1 };
+
+ sync_agent_ec_task_spec_s *pTask_spec = sync_agent_alloc_simple_task_spec("dm_reset",
+ _start_dm_reset_process, NULL, NULL,
+ 1, param_spec_array);
+
+ sync_agent_unref_param_spec(pParam_spec1);
+
+ _EXTERN_FUNC_EXIT;
+ return pTask_spec;
+
+}
+
+static sync_agent_ec_task_error_e _start_dm_reset_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array)
+{
+
+ _INNER_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+ ret = DB_Open();
+ ret = sync_agent_open_agent();
+
+ sync_agent_ec_task_error_e err = SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS;
+
+ //ret = reset_dm();
+ if (ret != DM_OK)
+ goto error;
+
+ sync_agent_set_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &ret);
+
+ ret = sync_agent_close_agent();
+ DB_Close();
+
+ _INNER_FUNC_EXIT;
+ return err;
+
+ error:
+
+ sync_agent_set_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &ret);
+ err = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
+
+ ret = sync_agent_close_agent();
+ DB_Close();
+ _INNER_FUNC_EXIT;
+ return err;
+
+}
+
+sync_agent_ec_task_spec_s *make_bootstrap_task_spec()
+{
+ _EXTERN_FUNC_ENTER;
+
+ 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);
+ 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);
+
+ sync_agent_ec_param_spec_s *param_spec_array[2] = { pParam_spec1, pParam_spec2 };
+
+ sync_agent_ec_task_spec_s *pTask_spec = sync_agent_alloc_simple_task_spec("dm_bootstrap_task",
+ _start_bootstrap_process, NULL, NULL,
+ 2, param_spec_array);
+
+ sync_agent_unref_param_spec(pParam_spec1);
+ sync_agent_unref_param_spec(pParam_spec2);
+
+ _EXTERN_FUNC_EXIT;
+ return pTask_spec;
+}
+
+static sync_agent_ec_task_error_e _start_bootstrap_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array)
+{
+ _INNER_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+ sync_agent_open_mo();
+ _DEBUG_TRACE(" Done Open Mo DB\n");
+ ret = DB_Open();
+
+ sync_agent_ec_task_error_e err = SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS;
+
+ /*
+ * factory bootstrap 0
+ * server init bootstrap 1
+ * smart card bootstrap 2
+ */
+
+ int bootstrapType = 0;
+ sync_agent_get_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &bootstrapType);
+ int i = 0;
+ int max_try = 3;
+
+ ret = reset_dm();
+ _DEBUG_TRACE("reset dm db : %d", ret);
+
+ for (i = 0; i < max_try; ++i) {
+ switch (bootstrapType) {
+ case 0:
+ ret = factory_bootstrap(NO_ENGINE_TYPE);
+ _DEBUG_TRACE("factory bootstrap : %d", ret);
+ if (ret != DM_OK) {
+ ret = reset_dm();
+ _DEBUG_TRACE("reset dm db : %d", ret);
+ ret = DM_ERR_BOOTSTRAP;
+ continue;
+ } else {
+ i = max_try;
+ break;
+ }
+ break;
+ default:
+ ret = DM_ERR_BOOTSTRAP;
+ goto error;
+ break;
+ }
+ }
+
+ sync_agent_set_param_value(&(param_array[1]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, (void *)(&ret));
+ _DEBUG_TRACE("end");
+
+ DB_Close();
+ sync_agent_close_mo();
+ _DEBUG_TRACE(" Done Close Mo DB\n");
+ _INNER_FUNC_EXIT;
+ return err;
+
+ error:
+
+ sync_agent_set_param_value(&(param_array[1]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, (void *)(&ret));
+ err = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
+ _DEBUG_TRACE("error");
+
+ DB_Close();
+ sync_agent_close_mo();
+ _DEBUG_TRACE("Done Close Mo DB\n");
+ _INNER_FUNC_EXIT;
+ return err;
+}
+
+sync_agent_ec_task_spec_s *make_dm_fumo_common_process_task_spec()
+{
+ _EXTERN_FUNC_ENTER;
+
+ 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);
+ 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);
+
+ sync_agent_ec_param_spec_s *param_spec_array[2] = { pParam_spec1, pParam_spec2 };
+
+ sync_agent_ec_task_spec_s *pTask_spec = sync_agent_alloc_simple_task_spec("common_fumo_dm",
+ _start_dm_fumo_common_process, NULL, NULL,
+ 2, param_spec_array);
+
+ sync_agent_unref_param_spec(pParam_spec1);
+ sync_agent_unref_param_spec(pParam_spec2);
+
+ _EXTERN_FUNC_EXIT;
+ return pTask_spec;
+
+}
+
+static sync_agent_ec_task_error_e _start_dm_fumo_common_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array)
+{
+ _INNER_FUNC_ENTER;
+
+ _DEBUG_TRACE(" Done Open Mo DB\n");
+
+ DM_ERROR ret = DM_OK;
+ ret = DB_Open();
+ ret = sync_agent_open_agent();
+ sync_agent_open_mo();
+ sync_agent_ec_task_error_e err = SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS;
+
+ /* todo
+ * telephony vconf status get
+ * if connecting call status
+ * add quick panel
+ * goto error;
+ */
+ int roaming_state = -1;
+ int call_state = -1;
+ Event_Contents *pEvent_data = NULL;
+ int task_id;
+
+ get_roaming_state(&roaming_state);
+ get_call_sate(&call_state);
+ if (roaming_state == -1 || call_state == -1) {
+ _DEBUG_TRACE("NOT ROAMING OR CALL STATUS roaming state : %d , call state : %d", roaming_state, call_state);
+ ret = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
+ goto error;
+ }
+
+ task_id = sync_agent_get_self_request_id();
+ _DEBUG_TRACE("task id ============================================ %d", task_id);
+
+ sync_agent_get_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &pEvent_data);
+ if (pEvent_data == NULL) {
+ _DEBUG_TRACE("-------------------------------------NOT EVENT IDLE---------------------------------------");
+ goto error;
+ }
+
+ if (pEvent_data->server_id == NULL) {
+ _DEBUG_TRACE("server id null");
+ ret = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
+ goto error;
+ }
+
+ if (pEvent_data != NULL) {
+ _DEBUG_TRACE("mode = %d", pEvent_data->type);
+ _DEBUG_TRACE("server id = %s", pEvent_data->server_id);
+ _DEBUG_TRACE("session id= %s", pEvent_data->session_id);
+ _DEBUG_TRACE("noti type id= %d", pEvent_data->noti_type);
+ _DEBUG_TRACE("ui mode id= %s", pEvent_data->ui_mode);
+ }
+
+ if (pEvent_data->ui_mode != NULL) {
+ //for using fumo ui
+ //add_config_db_using_ui( task_id, pEvent_data->ui_mode);
+
+ int is_exist;
+ is_exist = IsExist_Engine_id(FUMO_SERVICE_ENGINE);
+
+ if (is_exist == 0) {
+ engine_status status;
+ memset(&status, 0x00, sizeof(engine_status));
+ status.engine_id = FUMO_SERVICE_ENGINE;
+ status.engine_status = DM_SERVICE_UNKNOWN;
+ //status.server_id = strdup(pEvent_data->server_id);
+ status.server_id = pEvent_data->server_id;
+ status.server_url = 0;
+ status.correlator = 0;
+ status.mo_path = 0;
+ status.result_status = DM_OK;
+ //status.ui_mode = strdup(pEvent_data->ui_mode);
+ status.ui_mode = pEvent_data->ui_mode;
+ status.task_id = task_id;
+ status.ui_noti_type = get_default_noti_type(pEvent_data->ui_mode, pEvent_data->noti_type); //0;
+
+ status.download_click = RESUME_STATUS_DONWLOAD_BEFORE;
+ _DEBUG_TRACE("status noti ui type : %d", status.ui_noti_type);
+ DB_Begin_Transaction();
+
+ ret = Add_Engine_Status(&status);
+ _DEBUG_TRACE(" -------------------------------------add engine status : %d -------------------------------------\n", ret);
+ DB_End_Transaction(TRANSACTION_COMMIT_);
+
+ //str_free(&(status.server_id));
+ //str_free(&(status.ui_mode));
+
+ } else {
+ engine_status *status;
+ ret = Get_Engine_Status(FUMO_SERVICE_ENGINE, &status);
+ if (status != NULL) {
+ _DEBUG_TRACE(" -------------------------------------update engine status -------------------------------------\n");
+ status->ui_mode = strdup(pEvent_data->ui_mode);
+ status->task_id = task_id;
+ status->ui_noti_type = get_default_noti_type(pEvent_data->ui_mode, pEvent_data->noti_type); //0;
+ status->download_click = RESUME_STATUS_DONWLOAD_BEFORE;
+
+ DB_Begin_Transaction();
+ ret = Update_Engine_Status(status);
+ _DEBUG_TRACE(" update engine status : %d \n", ret);
+ DB_End_Transaction(TRANSACTION_COMMIT_);
+
+ if (status != NULL)
+ Free_Memory_Engine_Status(&status, 1);
+
+ }
+ }
+
+ int noti_ret = noti_start(pEvent_data->ui_mode);
+ _DEBUG_TRACE("noti start : %d", noti_ret);
+
+ } else {
+ _DEBUG_TRACE("ui mode null");
+ }
+
+ ENGINE_STATUS value = 0;
+ engine_status *status = NULL;
+ ret = Get_Engine_Status(IDLE_ENGINE, &status);
+ if (status != NULL) {
+ _DEBUG_TRACE("STATUS VALUE : %d ", status->engine_status);
+ value = status->engine_status;
+
+ if (value != DM_BEFORE_BOOTSTRAP) {
+ ret = dm_common_start(pEvent_data);
+ } else {
+ //do popup ui
+ //retry factorybootstrap
+ }
+
+ Free_Memory_Engine_Status(&status, 1);
+ } else {
+ ret = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
+ }
+
+ _DEBUG_TRACE("end ret :%d ", ret);
+ if (ret != DM_OK)
+ goto error;
+
+ sync_agent_set_param_value(&(param_array[1]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, (void *)(&ret));
+
+ event_data_free((void *)pEvent_data);
+ ret = sync_agent_close_agent();
+ DB_Close();
+ sync_agent_close_mo();
+ _DEBUG_TRACE("Done Close Mo DB\n");
+ _INNER_FUNC_EXIT;
+ return err;
+
+ error:
+ _DEBUG_ERROR("error : %d", ret);
+
+ sync_agent_set_param_value(&(param_array[1]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, (void *)(&ret));
+
+ event_data_free((void *)pEvent_data);
+ ret = sync_agent_close_agent();
+ DB_Close();
+ sync_agent_close_mo();
+ err = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
+ _DEBUG_ERROR("Done Close Mo DB\n");
+ _INNER_FUNC_EXIT;
+ return err;
+}
+
+sync_agent_ec_task_spec_s *make_dm_fumo_ui_process_task_spec()
+{
+ _EXTERN_FUNC_ENTER;
+
+ 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);
+ 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);
+
+ sync_agent_ec_param_spec_s *param_spec_array[2] = { pParam_spec1, pParam_spec2 };
+
+ sync_agent_ec_task_spec_s *pTask_spec = sync_agent_alloc_simple_task_spec("ui_fumo_dm",
+ _start_dm_fumo_ui_process, NULL, NULL,
+ 2, param_spec_array);
+
+ sync_agent_unref_param_spec(pParam_spec1);
+ sync_agent_unref_param_spec(pParam_spec2);
+
+ _EXTERN_FUNC_EXIT;
+ return pTask_spec;
+
+}
+
+static sync_agent_ec_task_error_e _start_dm_fumo_ui_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array)
+{
+ _INNER_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+ sync_agent_ec_task_error_e err = SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS;
+ ret = DB_Open();
+ /* todo
+ * telephony vconf status get
+ * if connecting call status
+ *
+ * add quick panel
+ *
+ * goto error;
+ */
+
+ int task_id;
+ task_id = sync_agent_get_self_request_id();
+ _DEBUG_TRACE("task id ============================================ %d", task_id);
+
+ Event_Contents *pEvent_data = NULL;
+ sync_agent_get_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &pEvent_data);
+ if (pEvent_data == NULL || (pEvent_data->session_id) == NULL || (pEvent_data->server_id) == NULL) {
+ _DEBUG_TRACE("-------------------------------------NOT EVENT IDLE---------------------------------------");
+ ret = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
+ goto error;
+ }
+
+ _DEBUG_TRACE("-----------------------------------%s---------------------------------------", pEvent_data->session_id);
+ _DEBUG_TRACE("-----------------------------------%s---------------------------------------", pEvent_data->server_id);
+ _DEBUG_TRACE("noti type id= %d", pEvent_data->noti_type);
+ _DEBUG_TRACE("session id= %s", pEvent_data->session_id);
+
+ _DEBUG_TRACE("server id= %s", pEvent_data->server_id);
+ ENGINE_STATUS value = 0;
+ engine_status *status = NULL;
+ ret = Get_Engine_Status(IDLE_ENGINE, &status);
+ if (status != NULL) {
+ _DEBUG_TRACE("STATUS VALUE : %d ", status->engine_status);
+ value = status->engine_status;
+
+ if (value != DM_BEFORE_BOOTSTRAP) {
+ ret = launch_om_dm_fumo_noti_ui(pEvent_data->noti_type, pEvent_data->session_id, pEvent_data->server_id);
+ if (ret == 0) {
+ _DEBUG_TRACE("ui launch fail");
+ }
+ } else {
+ //do popup ui
+ //retry factorybootstrap
+ }
+
+ Free_Memory_Engine_Status(&status, 1);
+ }
+
+ _DEBUG_TRACE("end ret :%d ", ret);
+ if (ret != 1)
+ goto error;
+
+ sync_agent_set_param_value(&(param_array[1]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, (void *)(&ret));
+
+ DB_Close();
+ event_data_free((void *)pEvent_data);
+ _DEBUG_TRACE("Done Close Mo DB\n");
+ _INNER_FUNC_EXIT;
+ return err;
+
+ error:
+ //err = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
+ _DEBUG_TRACE("error");
+
+ sync_agent_set_param_value(&(param_array[1]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, (void *)(&ret));
+
+ DB_Close();
+ event_data_free((void *)pEvent_data);
+ _DEBUG_TRACE("Done Close Mo DB\n");
+ _INNER_FUNC_EXIT;
+ return err;
+}
+
+sync_agent_ec_task_spec_s *make_dm_lawmo_common_process_task_spec()
+{
+ _EXTERN_FUNC_ENTER;
+
+ 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);
+ 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);
+
+ sync_agent_ec_param_spec_s *param_spec_array[2] = { pParam_spec1, pParam_spec2 };
+
+ sync_agent_ec_task_spec_s *pTask_spec = sync_agent_alloc_simple_task_spec("common_lawmo_dm",
+ _start_dm_lawmo_common_process, NULL, NULL,
+ 2, param_spec_array);
+
+ sync_agent_unref_param_spec(pParam_spec1);
+ sync_agent_unref_param_spec(pParam_spec2);
+
+ _EXTERN_FUNC_EXIT;
+ return pTask_spec;
+}
+
+static sync_agent_ec_task_error_e _start_dm_lawmo_common_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array)
+{
+ _INNER_FUNC_ENTER;
+
+ sync_agent_open_mo();
+ _DEBUG_TRACE(" Done Open Mo DB\n");
+
+ DM_ERROR ret = DM_OK;
+ ret = DB_Open();
+ ret = sync_agent_open_agent();
+ sync_agent_ec_task_error_e err = SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS;
+
+/* int task_id;
+ task_id = sync_agent_get_self_request_id();*/
+
+ Event_Contents *pEvent_data = NULL;
+ sync_agent_get_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &pEvent_data);
+ if (pEvent_data == NULL) {
+ _DEBUG_TRACE("-------------------------------------NOT EVENT IDLE---------------------------------------");
+ goto error;
+ }
+
+ if (pEvent_data != NULL) {
+ _DEBUG_TRACE("mode = %d", pEvent_data->type);
+ _DEBUG_TRACE("server id = %s", pEvent_data->server_id);
+ _DEBUG_TRACE("session id= %s", pEvent_data->session_id);
+ _DEBUG_TRACE("noti type id= %d", pEvent_data->noti_type);
+ _DEBUG_TRACE("ui mode id= %s", pEvent_data->ui_mode);
+ }
+
+ ENGINE_STATUS value = 0;
+ engine_status *status = NULL;
+ ret = Get_Engine_Status(IDLE_ENGINE, &status);
+ if (status != NULL) {
+ _DEBUG_TRACE("STATUS VALUE : %d ", status->engine_status);
+ value = status->engine_status;
+
+ if (value != DM_BEFORE_BOOTSTRAP) {
+ ret = dm_common_start(pEvent_data);
+ } else {
+ //do popup ui
+ //retry factorybootstrap
+ }
+
+ Free_Memory_Engine_Status(&status, 1);
+ }
+/* //for using ui
+ if(engine_type == SAMSUNG_FUMO_TYPE)
+ delete_config_db_using_ui( task_id);*/
+
+ _DEBUG_TRACE("end ret :%d ", ret);
+ if (ret != DM_OK)
+ goto error;
+
+ sync_agent_set_param_value(&(param_array[1]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, (void *)(&ret));
+
+ event_data_free((void *)pEvent_data);
+ ret = sync_agent_close_agent();
+ DB_Close();
+ sync_agent_close_mo();
+ _DEBUG_TRACE("Done Close Mo DB\n");
+ _INNER_FUNC_EXIT;
+ return err;
+
+ error:
+
+ _DEBUG_TRACE("error");
+
+ sync_agent_set_param_value(&(param_array[1]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, (void *)(&ret));
+ event_data_free((void *)pEvent_data);
+ ret = sync_agent_close_agent();
+ DB_Close();
+ sync_agent_close_mo();
+ _DEBUG_TRACE("Done Close Mo DB\n");
+ _INNER_FUNC_EXIT;
+ return err;
+}
+
+sync_agent_ec_task_spec_s *make_genericAlert_process_task_spec()
+{
+ _EXTERN_FUNC_ENTER;
+
+ 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);
+ sync_agent_ec_param_spec_s *param_spec_array[1] = { pParam_spec1 };
+
+ sync_agent_ec_task_spec_s *pTask_spec = sync_agent_alloc_simple_task_spec("dm_genericAlert_task",
+ _start_genericAlert_process, NULL, NULL,
+ 1, param_spec_array);
+
+ sync_agent_unref_param_spec(pParam_spec1);
+
+ _EXTERN_FUNC_EXIT;
+ return pTask_spec;
+
+}
+
+static sync_agent_ec_task_error_e _start_genericAlert_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array)
+{
+ _INNER_FUNC_ENTER;
+
+ sync_agent_open_mo();
+ _DEBUG_TRACE(" Done Open Mo DB\n");
+
+ DM_ERROR ret = DM_OK;
+ ret = DB_Open();
+ ret = sync_agent_open_agent();
+ sync_agent_ec_task_error_e err = SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS;
+
+ /*ENGINE_ID service_engine_id = GENERICALERT;
+ engine_status *service_status= NULL;
+ char* server_id = NULL;
+ int result = DM_OK;
+
+ if( IsExist_Engine_id(service_engine_id) == 1) {
+ ret = Get_Engine_Status(SERVICE_ENGINE, &service_status);
+ if(ret != DM_OK)
+ goto error;
+
+ server_id = strdup(service_status->server_id);
+ result = service_status->engine_status;
+ ret = Free_Memory_Engine_Status(&service_status, 1);
+
+ ret = genericalert_operation(result, server_id);
+
+ } else {
+ //do nothting
+ } */
+
+ sync_agent_set_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, (void *)(&ret));
+ _DEBUG_TRACE("end");
+
+ ret = sync_agent_close_agent();
+ DB_Close();
+ sync_agent_close_mo();
+ _DEBUG_TRACE("Done Close Mo DB\n");
+ _INNER_FUNC_EXIT;
+ return err;
+
+/*error:
+ err = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
+ _DEBUG_TRACE("error");
+
+ DB_Close();
+ sync_agent_close_mo();
+ _DEBUG_TRACE( "Done Close Mo DB\n");
+ return err;*/
+}
+
+sync_agent_ec_task_spec_s *make_fumo_serviceEngine_process_task_spec()
+{
+ _EXTERN_FUNC_ENTER;
+
+ 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);
+ sync_agent_ec_param_spec_s *param_spec_array[1] = { pParam_spec1 };
+
+ sync_agent_ec_task_spec_s *pTask_spec = sync_agent_alloc_simple_task_spec("dm_fumo_service_engine_task",
+ _start_fumo_serviceEngine_process, NULL, NULL,
+ 1, param_spec_array);
+
+ sync_agent_unref_param_spec(pParam_spec1);
+
+ _EXTERN_FUNC_EXIT;
+ return pTask_spec;
+
+}
+
+static sync_agent_ec_task_error_e _start_fumo_serviceEngine_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array)
+{
+ _INNER_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+ DM_ERROR service_ret = DM_OK;
+
+ sync_agent_open_mo();
+ ret = DB_Open();
+ _DEBUG_TRACE("status db open : %d", ret);
+ ret = sync_agent_open_agent();
+ _DEBUG_TRACE("daci db open : %d", ret);
+
+ sync_agent_ec_task_error_e err = SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS;
+
+ int roaming_state = -1;
+ int call_state = -1;
+ get_roaming_state(&roaming_state);
+ get_call_sate(&call_state);
+ if (roaming_state == -1 || call_state == -1) {
+ _DEBUG_TRACE("NOT ROAMING OR CALL STATUS roaming state : %d , call state : %d", roaming_state, call_state);
+ ret = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
+ goto error;
+ }
+
+ int task_id;
+ task_id = sync_agent_get_self_request_id();
+ ret = Update_Engine_Status_Column(FUMO_SERVICE_ENGINE, VALUE_TASK_ID, &task_id);
+ _DEBUG_TRACE("update engine status : %d", ret);
+ _DEBUG_TRACE("------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------");
+ _DEBUG_TRACE("task id : %d", task_id);
+ _DEBUG_TRACE("------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------");
+ ret = service_engine_start(FUMO_SERVICE_ENGINE, &service_ret);
+ if (ret != DM_OK)
+ goto error;
+
+ sync_agent_set_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, (void *)(&ret));
+
+ _DEBUG_TRACE("end");
+
+ ret = sync_agent_close_agent();
+ DB_Close();
+ sync_agent_close_mo();
+ _DEBUG_TRACE("Done Close Mo DB\n");
+ _INNER_FUNC_EXIT;
+ return err;
+
+ error:
+ err = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
+ _DEBUG_TRACE("error");
+
+ sync_agent_set_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, (void *)(&ret));
+
+ ret = sync_agent_close_agent();
+ DB_Close();
+ sync_agent_close_mo();
+ _DEBUG_TRACE("Done Close Mo DB\n");
+ _INNER_FUNC_EXIT;
+ return err;
+}
+
+sync_agent_ec_task_spec_s *make_lawmo_serviceEngine_process_task_spec()
+{
+ _EXTERN_FUNC_ENTER;
+
+ 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);
+ sync_agent_ec_param_spec_s *param_spec_array[1] = { pParam_spec1 };
+
+ sync_agent_ec_task_spec_s *pTask_spec = sync_agent_alloc_simple_task_spec("dm_lawmo_service_engine_task",
+ _start_lawmo_serviceEngine_process, NULL, NULL,
+ 1, param_spec_array);
+
+ sync_agent_unref_param_spec(pParam_spec1);
+
+ _EXTERN_FUNC_EXIT;
+ return pTask_spec;
+
+}
+
+static sync_agent_ec_task_error_e _start_lawmo_serviceEngine_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array)
+{
+ _INNER_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+ DM_ERROR service_ret = DM_OK;
+
+ sync_agent_open_mo();
+ ret = DB_Open();
+ ret = sync_agent_open_agent();
+
+ sync_agent_ec_task_error_e err = SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS;
+
+ ret = service_engine_start(LAWMO_SERVICE_ENGINE, &service_ret);
+ if (ret != DM_OK)
+ goto error;
+
+ sync_agent_set_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, (void *)(&ret));
+
+ _DEBUG_TRACE("end");
+
+ ret = sync_agent_close_agent();
+ DB_Close();
+ sync_agent_close_mo();
+ _DEBUG_TRACE("Done Close Mo DB\n");
+ _INNER_FUNC_EXIT;
+ return err;
+
+ error:
+ err = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
+
+ sync_agent_set_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, (void *)(&ret));
+ _DEBUG_TRACE("error");
+
+ ret = sync_agent_close_agent();
+ DB_Close();
+ sync_agent_close_mo();
+ _DEBUG_TRACE("Done Close Mo DB\n");
+ _INNER_FUNC_EXIT;
+ return err;
+}
+
+sync_agent_ec_task_spec_s *make_fumo_schedule_process_task_spec()
+{
+ _EXTERN_FUNC_ENTER;
+
+ 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);
+ 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);
+
+ sync_agent_ec_param_spec_s *param_spec_array[2] = { pParam_spec1, pParam_spec2 };
+
+ sync_agent_ec_task_spec_s *pTask_spec = sync_agent_alloc_simple_task_spec("dm_fumo_schdule_task",
+ _start_fumo_schedule_process, NULL, NULL,
+ 2, param_spec_array);
+
+ sync_agent_unref_param_spec(pParam_spec1);
+ sync_agent_unref_param_spec(pParam_spec2);
+
+ _EXTERN_FUNC_EXIT;
+ return pTask_spec;
+}
+
+static sync_agent_ec_task_error_e _start_fumo_schedule_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array)
+{
+ _INNER_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+ int da_err = 0;
+ da_err = sync_agent_open_agent();
+ _DEBUG_TRACE("db open result : %d", da_err);
+
+ sync_agent_ec_task_error_e err = SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS;
+
+ Reminder_Interval reminder_interval_type = 0;
+ sync_agent_get_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &reminder_interval_type);
+
+ delete_alarm_item(FUMO_INTERVAL, FUMO_INTERVAL_TYPE);
+
+ ret = add_alarm_item(reminder_interval_type, FUMO_INTERVAL, FUMO_INTERVAL_TYPE);
+ if (ret != DM_OK)
+ goto error;
+
+ _DEBUG_TRACE("end");
+ if (ret != DM_OK) {
+ _DEBUG_TRACE("schedule fail");
+ goto error;
+ }
+
+ sync_agent_set_param_value(&(param_array[1]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, (void *)(&ret));
+
+ da_err = sync_agent_close_agent();
+ _DEBUG_TRACE("db close result : %d", da_err);
+ _INNER_FUNC_EXIT;
+ return err;
+
+ error:
+ err = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
+ _DEBUG_TRACE("error");
+
+ sync_agent_set_param_value(&(param_array[1]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, (void *)(&ret));
+
+ da_err = sync_agent_close_agent();
+ _DEBUG_TRACE("Done Close Mo DB\n");
+ _INNER_FUNC_EXIT;
+ return err;
+}