diff options
author | HyungKyu Song <hk76.song@samsung.com> | 2013-02-16 00:55:29 +0900 |
---|---|---|
committer | HyungKyu Song <hk76.song@samsung.com> | 2013-02-16 00:55:29 +0900 |
commit | 4043c48868b1eafa7701ac19b4f93bc90ce79c99 (patch) | |
tree | 6f3bda67c8725cb999c8fe93c4c3846c83074be8 /src/agent/dm-engine/lawmo | |
parent | 2505051c83d63da1cac1e0ca958574cf98e164d9 (diff) | |
download | oma-dm-agent-4043c48868b1eafa7701ac19b4f93bc90ce79c99.tar.gz oma-dm-agent-4043c48868b1eafa7701ac19b4f93bc90ce79c99.tar.bz2 oma-dm-agent-4043c48868b1eafa7701ac19b4f93bc90ce79c99.zip |
Diffstat (limited to 'src/agent/dm-engine/lawmo')
-rw-r--r-- | src/agent/dm-engine/lawmo/lawmo_account.c | 101 | ||||
-rw-r--r-- | src/agent/dm-engine/lawmo/lawmo_engine.c | 352 |
2 files changed, 453 insertions, 0 deletions
diff --git a/src/agent/dm-engine/lawmo/lawmo_account.c b/src/agent/dm-engine/lawmo/lawmo_account.c new file mode 100644 index 0000000..e4d5469 --- /dev/null +++ b/src/agent/dm-engine/lawmo/lawmo_account.c @@ -0,0 +1,101 @@ +/* + * 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 "dm-engine/lawmo/lawmo_account.h" + +#ifndef OMADM_AGENT_LOG +#undef LOG_TAG +#define LOG_TAG "LAWMO_ENGINE" +#endif + +int register_lawmo_account(int item_id, void *user_data) +{ + _EXTERN_FUNC_ENTER; + + int ret = 1; + sync_agent_dm_mo_error_e err = 1; + int count = 0; + int value = 0; + +/*int db_ret = 0; + * db_ret = sync_agent_open_agent(); + _DEBUG_INFO("OPEN DACI : %d", db_ret);*/ + + set_alarm_config_int(LAWMO_ACCOUNT_FLAG_TYPE, LAWMO_ACCOUNT_FLAG, 0, LAWMO_ENGINE); + value = get_config_int(LAWMO_ACCOUNT_FLAG_TYPE, LAWMO_ACCOUNT_FLAG); + + _DEBUG_INFO("lawmo account flag : %d ", value); + + if (value != 1) { + do { + err = sync_agent_initialize_mo(7); + if (err == SYNC_AGENT_DM_MO_FAIL) { + _DEBUG_INFO("fail register lawmo account : %d ", err); + ret = 0; + } else { + _DEBUG_INFO("success register lawmo account : %d ", err); + break; + } + count++; + } while (err == SYNC_AGENT_DM_MO_FAIL && count < 3); + + if (err == SYNC_AGENT_DM_MO_FAIL) { + _DEBUG_INFO("add lawmo account registration alarm : %d ", ret); + ret = set_account_registration_alarm(LAWMO_ACCOUNT_ALARM, LAWMO_ACCOUNT_ALARM_TYPE); + _DEBUG_INFO("set account registration alarm lawmo account : %d ", ret); + ret = 0; + } else { + ret = set_config_int(LAWMO_ACCOUNT_FLAG_TYPE, LAWMO_ACCOUNT_FLAG, 1, LAWMO_ENGINE, 0); + _DEBUG_INFO("add lawmo account flag type setting result : %d ", ret); + delete_account_registration_alarm(LAWMO_ACCOUNT_ALARM, LAWMO_ACCOUNT_ALARM_TYPE); + _DEBUG_INFO("delete lawmo account delete alarm"); + } + } else { + //do nothing + } + +/* db_ret = sync_agent_close_agent(); + _DEBUG_INFO("CLOSE DACI : %d", db_ret);*/ + + _DEBUG_INFO("end : %d", ret); + _EXTERN_FUNC_EXIT; + return ret; +} + +int deregister_lawmo_account(int item_id, void *user_data) +{ + _EXTERN_FUNC_ENTER; + int ret = 1; + + ret = sync_agent_open_agent(); + _DEBUG_INFO("OPEN DACI : %d", ret); + + //set_alarm_config_int(LAWMO_ACCOUNT_FLAG_TYPE, LAWMO_ACCOUNT_FLAG, 0, LAWMO_ENGINE); + set_config_int(LAWMO_ACCOUNT_FLAG_TYPE, LAWMO_ACCOUNT_FLAG, 0, LAWMO_ENGINE, 0); + _DEBUG_INFO("lawmo account flag 0"); + + ret = sync_agent_close_agent(); + _DEBUG_INFO("CLOSE DACI : %d", ret); + + _EXTERN_FUNC_EXIT; + return ret; +} diff --git a/src/agent/dm-engine/lawmo/lawmo_engine.c b/src/agent/dm-engine/lawmo/lawmo_engine.c new file mode 100644 index 0000000..06a5476 --- /dev/null +++ b/src/agent/dm-engine/lawmo/lawmo_engine.c @@ -0,0 +1,352 @@ +/* + * 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> + +/*common*/ +#include "common/dm_common.h" +#include "common/util/util.h" +#include "dm-engine/lawmo/lawmo_engine.h" +#include "dm-engine/dm_common_engine.h" +#include "mo-handler/dm_mo_common.h" +#include "mo-handler/dm_mo_handler.h" + +#ifndef OMADM_AGENT_LOG +#undef LOG_TAG +#define LOG_TAG "LAWMO_ENGINE" +#endif + +static DM_ERROR _lawmo_fullylock(LAWMO_Result_code * lawmo_return); +static DM_ERROR _lawmo_partiallylock(LAWMO_Result_code * lawmo_return); +static DM_ERROR _lawmo_unlock(LAWMO_Result_code * lawmo_return); +static DM_ERROR _lawmo_factoryreset(LAWMO_Result_code * lawmo_return); +static DM_ERROR _lawmo_wipe(LAWMO_Result_code * lawmo_return); +static DM_ERROR _vendor_dependency_lawmo_operation(char *full_path, LAWMO_Result_code * lawmo_return, int check_operation); + +DM_ERROR lawmo_exec(char *full_path, char *correlator, LAWMO_Result_code * lawmo_return, int check_operation) +{ + + _DEBUG_INFO(" start\n"); + DM_ERROR ret = DM_OK; + + retvm_if((full_path) == NULL, COMMON_ERR_IS_NULL, "full_path is NULL!!"); + + char *result_mo_type = NULL; + /*LAWMO_State lawmo_state ; */ + + ret = get_mo_operationtype(full_path, &result_mo_type); + //ret = get_mo_root_path(full_path, &result_mo_type); + if (ret != DM_OK) + goto error; + + if (strcmp(result_mo_type, DM_LAWMO_OPERATIONS_FULLYLOCK_OP) == 0) { + if (check_operation == NON_CHECK_OPERATION) { //async + ret = _lawmo_fullylock(lawmo_return); + if (ret != DM_OK) + goto error; + if ((*lawmo_return) == OPERATION_SUCCEEDED) { + ret = set_current_lawmo_state(full_path, FULLY_LOCKED); + if (ret != DM_OK) + goto error; + } + } + } else if (strcmp(result_mo_type, DM_LAWMO_OPERATIONS_PARTIALLYLOCK_OP) == 0) { + if (check_operation == NON_CHECK_OPERATION) { //async + ret = _lawmo_partiallylock(lawmo_return); + if (ret != DM_OK) + goto error; + if ((*lawmo_return) == OPERATION_SUCCEEDED) { + ret = set_current_lawmo_state(full_path, PARTIALLY_LOCKED); + if (ret != DM_OK) + goto error; + } + } + } else if (strcmp(result_mo_type, DM_LAWMO_OPERATIONS_UNLOCK_OP) == 0) { + if (check_operation == NON_CHECK_OPERATION) { //async + ret = _lawmo_unlock(lawmo_return); + if (ret != DM_OK) + goto error; + if ((*lawmo_return) == OPERATION_SUCCEEDED) { + ret = set_current_lawmo_state(full_path, UNLOCKED); + if (ret != DM_OK) + goto error; + } + } + } else if (strcmp(result_mo_type, DM_LAWMO_OPERATIONS_FACTORYRESET_OP) == 0) { + if (check_operation == NON_CHECK_OPERATION) { //async + ret = _lawmo_factoryreset(lawmo_return); + if (ret != DM_OK) + goto error; + } + } else if (strcmp(result_mo_type, DM_LAWMO_OPERATIONS_WIPE_OP) == 0) { + if (check_operation == NON_CHECK_OPERATION) { //async + ret = _lawmo_wipe(lawmo_return); + if (ret != DM_OK) + goto error; + } + } else { + //1 : this is just available operation + ret = _vendor_dependency_lawmo_operation(full_path, lawmo_return, check_operation); + //*lawmo_return = 1200; + if (ret != DM_OK) + goto error; + + } + + str_free(&result_mo_type); + _DEBUG_INFO(" end\n"); + return ret; + error: + str_free(&result_mo_type); + _DEBUG_INFO(" end error : %d \n", ret); + return ret; +} + +/*this is oma dm spec function but this is not used slp phone.*/ +static DM_ERROR _lawmo_fullylock(LAWMO_Result_code * lawmo_return) +{ + _INNER_FUNC_ENTER; + + DM_ERROR ret = DM_OK; + +/* (*lawmo_return) = OPERATION_SUCCEEDED; + + sync_agent_dev_return_e error = 0; + //error = sync_agent_execute_dev_function(2, "full_lock", 0); + + if(error == 1 ) { + (*lawmo_return) = OPERATION_SUCCEEDED; + } else { + (*lawmo_return) = FULLY_LOCK_DEVICE_FAILED; + ret = FULLY_LOCK_DEVICE_FAILED; + goto error; + }*/ + /*this is oma dm spec function but this is not used slp phone. */ + /*not use this function so fail return */ + (*lawmo_return) = FULLY_LOCK_DEVICE_FAILED; + ret = FULLY_LOCK_DEVICE_FAILED; + + _INNER_FUNC_EXIT; + return ret; + +} + +/*this is oma dm spec function but this is not used slp phone.*/ +static DM_ERROR _lawmo_partiallylock(LAWMO_Result_code * lawmo_return) +{ + _INNER_FUNC_ENTER; + + DM_ERROR ret = DM_OK; + +/* (*lawmo_return) = OPERATION_SUCCEEDED; + + sync_agent_dev_return_e error =0; + //error = sync_agent_execute_dev_function(2, "partial_lock", 0); + + if(error == 1 ) { + (*lawmo_return) = OPERATION_SUCCEEDED; + } else { + (*lawmo_return) = PARTIALLY_LOCK_DEVICE_FAILED; + ret = PARTIALLY_LOCK_DEVICE_FAILED; + goto error; + }*/ + + /*not use this function so fail return */ + (*lawmo_return) = PARTIALLY_LOCK_DEVICE_FAILED; + ret = PARTIALLY_LOCK_DEVICE_FAILED; + + _INNER_FUNC_EXIT; + return ret; + +} + +/*this is oma dm spec function but this is not used slp phone.*/ +static DM_ERROR _lawmo_unlock(LAWMO_Result_code * lawmo_return) +{ + _INNER_FUNC_ENTER; + DM_ERROR ret = DM_OK; + +/* (*lawmo_return) = OPERATION_SUCCEEDED; + + sync_agent_dev_return_e error = 0; + //error = sync_agent_execute_dev_function(2, "unlock", 0); + + if(error == 1) { + (*lawmo_return) = OPERATION_SUCCEEDED; + } else { + (*lawmo_return) = UNLOCK_DEVICE_FAILED; + ret = UNLOCK_DEVICE_FAILED; + goto error; + }*/ + + /*not use this function so fail return */ + (*lawmo_return) = UNLOCK_DEVICE_FAILED; + ret = UNLOCK_DEVICE_FAILED; + + _INNER_FUNC_EXIT; + return ret; + +} + +/*this is oma dm spec function but this is not used slp phone.*/ +static DM_ERROR _lawmo_factoryreset(LAWMO_Result_code * lawmo_return) +{ + _INNER_FUNC_ENTER; + DM_ERROR ret = DM_OK; + +/* (*lawmo_return) = OPERATION_SUCCEEDED; + + sync_agent_dev_return_e error = 0; + //error = sync_agent_execute_dev_function(2, "factory_reset", 0); + + if(error == 1) { + (*lawmo_return) = OPERATION_SUCCEEDED; + } else { + (*lawmo_return) = WIPE_DEVICES_DATA_FAILED; + ret = WIPE_DEVICES_DATA_FAILED; + goto error; + }*/ + + /*not use this function so fail return */ + (*lawmo_return) = WIPE_DEVICES_DATA_FAILED; + ret = WIPE_DEVICES_DATA_FAILED; + + _INNER_FUNC_EXIT; + return ret; + +} + +/*this is oma dm spec function but this is not used slp phone.*/ +static DM_ERROR _lawmo_wipe(LAWMO_Result_code * lawmo_return) +{ + _INNER_FUNC_ENTER; + DM_ERROR ret = DM_OK; + + /*(*lawmo_return) = OPERATION_SUCCEEDED; + sync_agent_dev_return_e error = 0; + //error = sync_agent_execute_dev_function(2, "factory_reset", 0); + + if(error == 1) { + (*lawmo_return) = OPERATION_SUCCEEDED; + } else { + (*lawmo_return) = WIPE_DEVICES_DATA_FAILED; + ret = WIPE_DEVICES_DATA_FAILED; + goto error; + } */ + + /*not use this function so fail return */ + (*lawmo_return) = WIPE_DEVICES_DATA_FAILED; + ret = WIPE_DEVICES_DATA_FAILED; + + _INNER_FUNC_EXIT; + return ret; + +} + +static DM_ERROR _vendor_dependency_lawmo_operation(char *full_path, LAWMO_Result_code * lawmo_return, int check_operation) +{ + _INNER_FUNC_ENTER; + + DM_ERROR ret = DM_OK; + sync_agent_dm_mo_error_e ext_return; + ext_return = sync_agent_execute_mo_ext(full_path, (int *)lawmo_return, check_operation); + _DEBUG_TRACE("ext_return : %d", ext_return); + if (ext_return != SYNC_AGENT_DM_MO_SUCCESS) { + ret = DM_ERR_COMMAND_FAILED; + goto error; + } + + _INNER_FUNC_EXIT; + return ret; + error: + _DEBUG_TRACE(" end error : %d \n", ret); + _INNER_FUNC_EXIT; + return ret; +} + +DM_ERROR get_current_lawmo_state(char *full_path, char **lawmo_state_data) +{ + _INNER_FUNC_ENTER; + DM_ERROR ret = DM_OK; + + retvm_if((full_path) == NULL, COMMON_ERR_IS_NULL, "full_path is NULL!!"); + + char *lawmo_root = NULL; + char *lawmo_state_url = NULL; + //ret = get_mo_servicetype(full_path, &lawmo_root); + ret = get_mo_root_path(full_path, &lawmo_root); + if (ret != DM_OK) { + ret = COMMON_ERR_INTERNAL_NOT_DEFINED; + goto error; + } + lawmo_state_url = g_strdup_printf("%s%s", lawmo_root, DM_LAWMO_STATE_OP); + + ret = get_mo_data(lawmo_state_url, lawmo_state_data); + if (ret != DM_OK) { + ret = COMMON_ERR_GET_TYPE_NOT_FOUND; + goto error; + } + + str_free(&lawmo_state_url); + _INNER_FUNC_EXIT; + return ret; + error: + str_free(&lawmo_state_url); + _DEBUG_INFO(" end error : %d\n", ret); + _INNER_FUNC_EXIT; + return ret; +} + +DM_ERROR set_current_lawmo_state(char *full_path, LAWMO_State lawmo_state) +{ + _INNER_FUNC_ENTER; + + DM_ERROR ret = DM_OK; + + retvm_if((full_path) == NULL, COMMON_ERR_IS_NULL, "full_path is NULL!!"); + + char *lawmo_root = NULL; + char *lawmo_state_url = NULL; + char *lawmo_state_data = NULL; + + //ret = get_mo_servicetype(full_path, &lawmo_root); + ret = get_mo_root_path(full_path, &lawmo_root); + if (ret != DM_OK) { + goto error; + } + + lawmo_state_url = g_strdup_printf("%s%s", lawmo_root, DM_LAWMO_STATE_OP); + lawmo_state_data = g_strdup_printf("%d", lawmo_state); + + _DEBUG_INFO(" fumo_state : %d\n", lawmo_state); + ret = replace_mo_data(lawmo_state_url, lawmo_state_data); + if (ret != DM_OK) + goto error; + + str_free(&lawmo_state_url); + str_free(&lawmo_state_data); + _INNER_FUNC_EXIT; + return ret; + + error: + str_free(&lawmo_state_url); + str_free(&lawmo_state_data); + _DEBUG_INFO(" end error : %d\n", ret); + _INNER_FUNC_EXIT; + return ret; +} |