diff options
Diffstat (limited to 'src/agent/dm-engine/bootstrap')
-rwxr-xr-x | src/agent/dm-engine/bootstrap/factory_bootstrap.c | 317 |
1 files changed, 317 insertions, 0 deletions
diff --git a/src/agent/dm-engine/bootstrap/factory_bootstrap.c b/src/agent/dm-engine/bootstrap/factory_bootstrap.c new file mode 100755 index 0000000..7633b6d --- /dev/null +++ b/src/agent/dm-engine/bootstrap/factory_bootstrap.c @@ -0,0 +1,317 @@ +/* + * 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 "mo-handler/dm_mo_handler.h" +#include "mo-handler/dm_mo_common.h" +#include "dm-engine/bootstrap/factory_bootstrap.h" + +#ifndef OMADM_AGENT_LOG +#undef LOG_TAG +#define LOG_TAG "OMA_DM_BOOTSTRAP" +#endif + +static DM_ERROR _completed_bootstrap(); +static DM_ERROR _start_ddf_mo(GSList * seg_list); + +static DM_ERROR _completed_bootstrap() +{ + _INNER_FUNC_ENTER; + + DM_ERROR ret = DM_OK; + ENGINE_STATUS status = DM_IDLE; + + ret = Update_Engine_Status_Column(IDLE_ENGINE, VALUE_ENGINE_STATUS, &status); + _DEBUG_TRACE("update engine status : %d", ret); + if (ret != DM_OK) + goto error; + + _INNER_FUNC_EXIT; + return ret; + error: + _DEBUG_TRACE(" end!! error : %d \n", ret); + _INNER_FUNC_EXIT; + return ret; +} + +static DM_ERROR _start_ddf_mo(GSList * seg_list) +{ + _INNER_FUNC_ENTER; + + DM_ERROR ret = DM_OK; + + GSList *ddf_iter = NULL; + sync_agent_dm_mo_error_e err_code; + ddf_spec *ddf_content; + + retvm_if((seg_list) == NULL, COMMON_ERR_IS_NULL, "seg_list is NULL!!"); + + for (ddf_iter = seg_list; ddf_iter != NULL; ddf_iter = g_slist_next(ddf_iter)) { + ddf_content = (ddf_spec *) (ddf_iter->data); + + _DEBUG_TRACE(" mo_type : %d schema : %s sevice_ddf : %d server_type : %d\n", ddf_content->mo_type, ddf_content->schema_file, ddf_content->service_ddf, ddf_content->server_type); + err_code = sync_agent_construct_mo_table(ddf_content->mo_type, ddf_content->schema_file, ddf_content->service_ddf, ddf_content->server_type); + + if (err_code == SYNC_AGENT_DM_MO_SUCCESS) { + _DEBUG_TRACE("Success to sync_agent_construct_mo_table()\n"); + } else { + _DEBUG_TRACE("Failed to sync_agent_construct_mo_table()\n"); + ret = DM_ERR_DDF_PROCCESS; + goto error; + } + } + + _INNER_FUNC_EXIT; + return ret; + error: + _DEBUG_TRACE(" end!! error : %d \n", ret); + _INNER_FUNC_EXIT; + return ret; +} + +DM_ERROR factory_bootstrap(SERVICE_SERVER_TYPE server_type) +{ + _INNER_FUNC_EXIT; + + DM_ERROR ret = DM_OK; + + /*dm acc */ + //pre_define_mo(); + + /*change css value for test */ + int file_ret = 0; + char *file_path = NULL; + unsigned long required_length = 0; + char *required_contents = NULL; + int is_exist = 0; + + switch (server_type) { + case SAMSUNG_FUMO_TYPE: + { + ret = is_exist_dmacc(SAMSUNG_FUMO_TYPE, &is_exist); + if (ret != DM_OK) { + _DEBUG_TRACE("is exist dmacc error : %d or not exist dm acc : %d", ret, is_exist); + goto error; + } + if (is_exist == 1) { + ret = remove_dm_acc(DM_DMACC_MSCTESTSERVER); + if (ret != DM_OK) { + _DEBUG_VERBOSE("remove dm acc error :%d", ret); + goto error; + } else { + _DEBUG_VERBOSE("remove fumo dm acc"); + } + } else { + _DEBUG_VERBOSE("samsung fumo dm acc"); + } + + file_path = DDF_MSCFUMO_DMACC_FILE; + } + break; + case SAMSUNG_FMM_TYPE: + { + ret = is_exist_dmacc(SAMSUNG_FMM_TYPE, &is_exist); + if (ret != DM_OK) { + _DEBUG_TRACE("is exist dmacc error : %d or not exist dm acc : %d", ret, is_exist); + goto error; + } + if (is_exist == 1) { + ret = remove_dm_acc(DM_DMACC_MSCSERVER); + if (ret != DM_OK) { + _DEBUG_VERBOSE("remove dm acc error :%d", ret); + goto error; + } else { + _DEBUG_VERBOSE("remove fumo dm acc"); + } + } else { + _DEBUG_VERBOSE("samsung fmm dm acc"); + } + + file_path = DDF_MSCLAWMO_DMACC_FILE; + } + break; + case GCF_TYPE: + { + ret = is_exist_dmacc(GCF_TYPE, &is_exist); + if (ret != DM_OK) { + _DEBUG_TRACE("is exist dmacc error : %d or not exist dm acc : %d", ret, is_exist); + goto error; + } + if (is_exist == 1) { + ret = remove_dm_acc(DM_DMACC_MSCSERVER); + if (ret != DM_OK) { + _DEBUG_VERBOSE("remove dm acc error :%d", ret); + goto error; + } else { + _DEBUG_VERBOSE("remove fumo dm acc"); + } + } else { + _DEBUG_VERBOSE("product dm acc"); + } + file_path = DDF_GCF_DMACC_FILE; + } + break; + default: + { + file_path = DDF_FILES; + _DEBUG_INFO("the first factory bootstrap"); + } + break; + } + + file_ret = sync_agent_read_whole_file(file_path, &required_contents, &required_length); + if (file_ret != 1) { + ret = DM_ERR_DDF_PROCCESS; + goto error; + } + _DEBUG_INFO(" file read is %d, required_length is %d \n", ret, required_length); + + GSList *seg_list = NULL; + char *check_segment = NULL; + ddf_spec ddf_contents[DDF_SPEC_COUNT] = { {0}, }; + int i = 0; + if (required_contents != NULL) { + check_segment = strtok(required_contents, "\n"); + _DEBUG_INFO(" check_segment : %s\n", check_segment); + } else { + ret = DM_ERR_DDF_PROCCESS; + goto error; + } + + if (check_segment != NULL) { + sscanf(check_segment, "%d %s %d %d", (int *)(&(ddf_contents[i].mo_type)), (ddf_contents[i].schema_file), &(ddf_contents[i].service_ddf), &(ddf_contents[i].server_type)); + seg_list = g_slist_append(seg_list, &(ddf_contents[i])); + + _DEBUG_INFO(" mo_type: %d\n", ddf_contents[i].mo_type); + _DEBUG_INFO(" schema_file : %s\n", ddf_contents[i].schema_file); + _DEBUG_INFO(" service_ddf : %d\n", ddf_contents[i].service_ddf); + _DEBUG_INFO(" server_type : %d\n", ddf_contents[i].server_type); + ++i; + + while (check_segment != NULL) { + check_segment = strtok(NULL, "\n"); + if (check_segment == NULL) + break; + _DEBUG_INFO(" check_segment : %s\n", check_segment); + + sscanf(check_segment, "%d %s %d %d", (int *)(&(ddf_contents[i].mo_type)), (ddf_contents[i].schema_file), &(ddf_contents[i].service_ddf), &(ddf_contents[i].server_type)); + seg_list = g_slist_append(seg_list, &(ddf_contents[i])); + + _DEBUG_INFO(" mo_type: %d\n", ddf_contents[i].mo_type); + _DEBUG_INFO(" schema_file : %s\n", ddf_contents[i].schema_file); + _DEBUG_INFO(" service_ddf : %d\n", ddf_contents[i].service_ddf); + _DEBUG_INFO(" server_type : %d\n", ddf_contents[i].server_type); + ++i; + } + + ret = _start_ddf_mo(seg_list); + if (ret != DM_OK) + goto error; + + file_ret = sync_agent_free_file(&required_contents); + required_contents = NULL; + if (file_ret != 1) { + ret = DM_ERR_DDF_PROCCESS; + goto error; + } + + ret = _completed_bootstrap(); + if (ret != DM_OK) { + goto error; + } + + } else { + ret = DM_ERR_DDF_PROCCESS; + goto error; + } + + _EXTERN_FUNC_EXIT; + + return ret; + error: + + file_ret = sync_agent_free_file(&required_contents); + if (file_ret != 1) { + ret = DM_ERR_DDF_PROCCESS; + } + + _DEBUG_INFO(" end!! error : %d \n", ret); + _EXTERN_FUNC_EXIT; + return ret; + +} + +/* +void ddf_parser() { + + sync_agent_dm_mo_type_e mo_type_devdetail = SYNC_AGENT_DM_MO_TYPE_DEVDETAIL; + sync_agent_dm_mo_type_e mo_type_devinfo = SYNC_AGENT_DM_MO_TYPE_DEVINFO; + sync_agent_dm_mo_type_e mo_type_fumo = SYNC_AGENT_DM_MO_TYPE_FUMO; + sync_agent_dm_mo_type_e mo_type_gcf = SYNC_AGENT_DM_MO_TYPE_DMACC; + sync_agent_dm_mo_type_e mo_type_mscserver = SYNC_AGENT_DM_MO_TYPE_DMACC; + sync_agent_dm_mo_type_e mo_type_msctestserver = SYNC_AGENT_DM_MO_TYPE_DMACC; + + const char *schema_file_devdetail = "/usr/share/oma-dm/ddf/slp/slp_DEVDETAIL_DDF.xml"; + const char *schema_file_devinfo = "/usr/share/oma-dm/ddf/slp/slp_DEVINF_DDF.xml"; + const char *schema_file_fumo = "/usr/share/oma-dm/ddf/slp/slp_FUMO_DDF.xml"; + const char *schema_file_gcf = "/usr/share/oma-dm/ddf/slp/slp_gcf_DMACC_DDF_1.2.xml"; + const char *schema_file_mscserver = "/usr/share/oma-dm/ddf/slp/slp_MSCserver_DMACC_DDF_1.2.xml"; + const char *schema_file_msctestserver = "/usr/share/oma-dm/ddf/slp/slp_MSCTestserver_DMACC_DDF_1.2.xml"; + + sync_agent_dm_mo_error_e err_code = sync_agent_construct_mo_table(mo_type_devdetail, schema_file_devdetail , "devdetail"); + if (err_code == SYNC_AGENT_DM_MO_SUCCESS) { + printf("Success to sync_agent_construct_mo_table()\n"); + } else { + printf("Failed to sync_agent_construct_mo_table()\n"); + } + + err_code = sync_agent_construct_mo_table(mo_type_devinfo, schema_file_devinfo , "devinf"); + if (err_code == SYNC_AGENT_DM_MO_SUCCESS) { + printf("Success to sync_agent_construct_mo_table()\n"); + } else { + printf("Failed to sync_agent_construct_mo_table()\n"); + } + + err_code = sync_agent_construct_mo_table(mo_type_fumo, schema_file_fumo , "fumo"); + if (err_code == SYNC_AGENT_DM_MO_SUCCESS) { + printf("Success to sync_agent_construct_mo_table()\n"); + } else { + printf("Failed to sync_agent_construct_mo_table()\n"); + } + err_code = sync_agent_construct_mo_table(mo_type_gcf, schema_file_gcf , "dmacc_gcf"); + if (err_code == SYNC_AGENT_DM_MO_SUCCESS) { + printf("Success to sync_agent_construct_mo_table()\n"); + } else { + printf("Failed to sync_agent_construct_mo_table()\n"); + } + err_code = sync_agent_construct_mo_table(mo_type_mscserver, schema_file_mscserver , "dmacc_MSCserver"); + if (err_code == SYNC_AGENT_DM_MO_SUCCESS) { + printf("Success to sync_agent_construct_mo_table()\n"); + } else { + printf("Failed to sync_agent_construct_mo_table()\n"); + } + err_code = sync_agent_construct_mo_table(mo_type_msctestserver, schema_file_msctestserver , "dmacc_MSCTestserver"); + if (err_code == SYNC_AGENT_DM_MO_SUCCESS) { + printf("Success to sync_agent_construct_mo_table()\n"); + } else { + printf("Failed to sync_agent_construct_mo_table()\n"); + } +*/ |