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 "mo-handler/dm_mo_handler.h"
24 #include "mo-handler/dm_mo_common.h"
25 #include "dm-engine/bootstrap/factory_bootstrap.h"
27 #ifndef OMADM_AGENT_LOG
29 #define LOG_TAG "OMA_DM_BOOTSTRAP"
32 static DM_ERROR _completed_bootstrap();
33 static DM_ERROR _start_ddf_mo(GSList * seg_list);
35 static DM_ERROR _completed_bootstrap()
40 ENGINE_STATUS status = DM_IDLE;
42 ret = Update_Engine_Status_Column(IDLE_ENGINE, VALUE_ENGINE_STATUS, &status);
43 _DEBUG_TRACE("update engine status : %d", ret);
50 _DEBUG_TRACE(" end!! error : %d \n", ret);
55 static DM_ERROR _start_ddf_mo(GSList * seg_list)
61 GSList *ddf_iter = NULL;
62 sync_agent_dm_mo_error_e err_code;
63 ddf_spec *ddf_content;
65 retvm_if((seg_list) == NULL, COMMON_ERR_IS_NULL, "seg_list is NULL!!");
67 for (ddf_iter = seg_list; ddf_iter != NULL; ddf_iter = g_slist_next(ddf_iter)) {
68 ddf_content = (ddf_spec *) (ddf_iter->data);
70 _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);
71 err_code = sync_agent_construct_mo_table(ddf_content->mo_type, ddf_content->schema_file, ddf_content->service_ddf, ddf_content->server_type);
73 if (err_code == SYNC_AGENT_DM_MO_SUCCESS) {
74 _DEBUG_TRACE("Success to sync_agent_construct_mo_table()\n");
76 _DEBUG_TRACE("Failed to sync_agent_construct_mo_table()\n");
77 ret = DM_ERR_DDF_PROCCESS;
85 _DEBUG_TRACE(" end!! error : %d \n", ret);
90 DM_ERROR factory_bootstrap(SERVICE_SERVER_TYPE server_type)
99 /*change css value for test */
101 char *file_path = NULL;
102 unsigned long required_length = 0;
103 char *required_contents = NULL;
106 _DEBUG_INFO("server_type : [%d]", server_type);
108 switch (server_type) {
109 case SAMSUNG_FUMO_TYPE:
111 ret = is_exist_dmacc(SAMSUNG_FUMO_TYPE, &is_exist);
113 _DEBUG_TRACE("is exist dmacc error : %d or not exist dm acc : %d", ret, is_exist);
117 ret = remove_dm_acc(DM_DMACC_MSCTESTSERVER);
119 _DEBUG_VERBOSE("remove dm acc error :%d", ret);
122 _DEBUG_VERBOSE("remove fumo dm acc");
125 _DEBUG_VERBOSE("samsung fumo dm acc");
128 file_path = DDF_MSCFUMO_DMACC_FILE;
131 case SAMSUNG_FMM_TYPE:
133 ret = is_exist_dmacc(SAMSUNG_FMM_TYPE, &is_exist);
135 _DEBUG_TRACE("is exist dmacc error : %d or not exist dm acc : %d", ret, is_exist);
139 ret = remove_dm_acc(DM_DMACC_MSCSERVER);
141 _DEBUG_VERBOSE("remove dm acc error :%d", ret);
144 _DEBUG_VERBOSE("remove fumo dm acc");
147 _DEBUG_VERBOSE("samsung fmm dm acc");
150 file_path = DDF_MSCLAWMO_DMACC_FILE;
155 ret = is_exist_dmacc(GCF_TYPE, &is_exist);
157 _DEBUG_TRACE("is exist dmacc error : %d or not exist dm acc : %d", ret, is_exist);
161 ret = remove_dm_acc(DM_DMACC_MSCSERVER);
163 _DEBUG_VERBOSE("remove dm acc error :%d", ret);
166 _DEBUG_VERBOSE("remove fumo dm acc");
169 _DEBUG_VERBOSE("product dm acc");
171 file_path = DDF_GCF_DMACC_FILE;
176 file_path = DDF_FILES;
177 _DEBUG_INFO("the first factory bootstrap");
182 file_ret = sync_agent_read_whole_file(file_path, &required_contents, &required_length);
184 ret = DM_ERR_DDF_PROCCESS;
187 _DEBUG_INFO(" file read is %d, required_length is %d \n", ret, required_length);
189 GSList *seg_list = NULL;
190 char *check_segment = NULL;
191 ddf_spec ddf_contents[DDF_SPEC_COUNT] = { {0}, };
193 if (required_contents != NULL) {
194 check_segment = strtok(required_contents, "\n");
195 _DEBUG_INFO(" check_segment : %s\n", check_segment);
197 ret = DM_ERR_DDF_PROCCESS;
201 if (check_segment != NULL) {
202 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));
203 seg_list = g_slist_append(seg_list, &(ddf_contents[i]));
205 _DEBUG_INFO(" mo_type: %d\n", ddf_contents[i].mo_type);
206 _DEBUG_INFO(" schema_file : %s\n", ddf_contents[i].schema_file);
207 _DEBUG_INFO(" service_ddf : %d\n", ddf_contents[i].service_ddf);
208 _DEBUG_INFO(" server_type : %d\n", ddf_contents[i].server_type);
211 while (check_segment != NULL) {
212 check_segment = strtok(NULL, "\n");
213 if (check_segment == NULL)
215 _DEBUG_INFO(" check_segment : %s\n", check_segment);
217 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));
218 seg_list = g_slist_append(seg_list, &(ddf_contents[i]));
220 _DEBUG_INFO(" mo_type: %d\n", ddf_contents[i].mo_type);
221 _DEBUG_INFO(" schema_file : %s\n", ddf_contents[i].schema_file);
222 _DEBUG_INFO(" service_ddf : %d\n", ddf_contents[i].service_ddf);
223 _DEBUG_INFO(" server_type : %d\n", ddf_contents[i].server_type);
227 ret = _start_ddf_mo(seg_list);
231 file_ret = sync_agent_free_file(&required_contents);
232 required_contents = NULL;
234 ret = DM_ERR_DDF_PROCCESS;
238 ret = _completed_bootstrap();
244 ret = DM_ERR_DDF_PROCCESS;
253 file_ret = sync_agent_free_file(&required_contents);
255 ret = DM_ERR_DDF_PROCCESS;
258 _DEBUG_INFO(" end!! error : %d \n", ret);
267 sync_agent_dm_mo_type_e mo_type_devdetail = SYNC_AGENT_DM_MO_TYPE_DEVDETAIL;
268 sync_agent_dm_mo_type_e mo_type_devinfo = SYNC_AGENT_DM_MO_TYPE_DEVINFO;
269 sync_agent_dm_mo_type_e mo_type_fumo = SYNC_AGENT_DM_MO_TYPE_FUMO;
270 sync_agent_dm_mo_type_e mo_type_gcf = SYNC_AGENT_DM_MO_TYPE_DMACC;
271 sync_agent_dm_mo_type_e mo_type_mscserver = SYNC_AGENT_DM_MO_TYPE_DMACC;
272 sync_agent_dm_mo_type_e mo_type_msctestserver = SYNC_AGENT_DM_MO_TYPE_DMACC;
274 const char *schema_file_devdetail = "/usr/share/oma-dm/ddf/slp/slp_DEVDETAIL_DDF.xml";
275 const char *schema_file_devinfo = "/usr/share/oma-dm/ddf/slp/slp_DEVINF_DDF.xml";
276 const char *schema_file_fumo = "/usr/share/oma-dm/ddf/slp/slp_FUMO_DDF.xml";
277 const char *schema_file_gcf = "/usr/share/oma-dm/ddf/slp/slp_gcf_DMACC_DDF_1.2.xml";
278 const char *schema_file_mscserver = "/usr/share/oma-dm/ddf/slp/slp_MSCserver_DMACC_DDF_1.2.xml";
279 const char *schema_file_msctestserver = "/usr/share/oma-dm/ddf/slp/slp_MSCTestserver_DMACC_DDF_1.2.xml";
281 sync_agent_dm_mo_error_e err_code = sync_agent_construct_mo_table(mo_type_devdetail, schema_file_devdetail , "devdetail");
282 if (err_code == SYNC_AGENT_DM_MO_SUCCESS) {
283 _DEBUG_INFO("Success to sync_agent_construct_mo_table()\n");
285 _DEBUG_INFO("Failed to sync_agent_construct_mo_table()\n");
288 err_code = sync_agent_construct_mo_table(mo_type_devinfo, schema_file_devinfo , "devinf");
289 if (err_code == SYNC_AGENT_DM_MO_SUCCESS) {
290 _DEBUG_INFO("Success to sync_agent_construct_mo_table()\n");
292 _DEBUG_INFO("Failed to sync_agent_construct_mo_table()\n");
295 err_code = sync_agent_construct_mo_table(mo_type_fumo, schema_file_fumo , "fumo");
296 if (err_code == SYNC_AGENT_DM_MO_SUCCESS) {
297 _DEBUG_INFO("Success to sync_agent_construct_mo_table()\n");
299 _DEBUG_INFO("Failed to sync_agent_construct_mo_table()\n");
301 err_code = sync_agent_construct_mo_table(mo_type_gcf, schema_file_gcf , "dmacc_gcf");
302 if (err_code == SYNC_AGENT_DM_MO_SUCCESS) {
303 _DEBUG_INFO("Success to sync_agent_construct_mo_table()\n");
305 _DEBUG_INFO("Failed to sync_agent_construct_mo_table()\n");
307 err_code = sync_agent_construct_mo_table(mo_type_mscserver, schema_file_mscserver , "dmacc_MSCserver");
308 if (err_code == SYNC_AGENT_DM_MO_SUCCESS) {
309 _DEBUG_INFO("Success to sync_agent_construct_mo_table()\n");
311 _DEBUG_INFO("Failed to sync_agent_construct_mo_table()\n");
313 err_code = sync_agent_construct_mo_table(mo_type_msctestserver, schema_file_msctestserver , "dmacc_MSCTestserver");
314 if (err_code == SYNC_AGENT_DM_MO_SUCCESS) {
315 _DEBUG_INFO("Success to sync_agent_construct_mo_table()\n");
317 _DEBUG_INFO("Failed to sync_agent_construct_mo_table()\n");