summaryrefslogtreecommitdiff
path: root/src/agent/dm-engine/lawmo/lawmo_engine.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/agent/dm-engine/lawmo/lawmo_engine.c')
-rw-r--r--src/agent/dm-engine/lawmo/lawmo_engine.c352
1 files changed, 352 insertions, 0 deletions
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;
+}