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 switch (server_type) {
107 case SAMSUNG_FUMO_TYPE:
109 ret = is_exist_dmacc(SAMSUNG_FUMO_TYPE, &is_exist);
111 _DEBUG_TRACE("is exist dmacc error : %d or not exist dm acc : %d", ret, is_exist);
115 ret = remove_dm_acc(DM_DMACC_MSCTESTSERVER);
117 _DEBUG_VERBOSE("remove dm acc error :%d", ret);
120 _DEBUG_VERBOSE("remove fumo dm acc");
123 _DEBUG_VERBOSE("samsung fumo dm acc");
126 file_path = DDF_MSCFUMO_DMACC_FILE;
129 case SAMSUNG_FMM_TYPE:
131 ret = is_exist_dmacc(SAMSUNG_FMM_TYPE, &is_exist);
133 _DEBUG_TRACE("is exist dmacc error : %d or not exist dm acc : %d", ret, is_exist);
137 ret = remove_dm_acc(DM_DMACC_MSCSERVER);
139 _DEBUG_VERBOSE("remove dm acc error :%d", ret);
142 _DEBUG_VERBOSE("remove fumo dm acc");
145 _DEBUG_VERBOSE("samsung fmm dm acc");
148 file_path = DDF_MSCLAWMO_DMACC_FILE;
153 ret = is_exist_dmacc(GCF_TYPE, &is_exist);
155 _DEBUG_TRACE("is exist dmacc error : %d or not exist dm acc : %d", ret, is_exist);
159 ret = remove_dm_acc(DM_DMACC_MSCSERVER);
161 _DEBUG_VERBOSE("remove dm acc error :%d", ret);
164 _DEBUG_VERBOSE("remove fumo dm acc");
167 _DEBUG_VERBOSE("product dm acc");
169 file_path = DDF_GCF_DMACC_FILE;
174 file_path = DDF_FILES;
175 _DEBUG_INFO("the first factory bootstrap");
180 file_ret = sync_agent_read_whole_file(file_path, &required_contents, &required_length);
182 ret = DM_ERR_DDF_PROCCESS;
185 _DEBUG_INFO(" file read is %d, required_length is %d \n", ret, required_length);
187 GSList *seg_list = NULL;
188 char *check_segment = NULL;
189 ddf_spec ddf_contents[DDF_SPEC_COUNT] = { {0}, };
191 if (required_contents != NULL) {
192 check_segment = strtok(required_contents, "\n");
193 _DEBUG_INFO(" check_segment : %s\n", check_segment);
195 ret = DM_ERR_DDF_PROCCESS;
199 if (check_segment != NULL) {
200 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));
201 seg_list = g_slist_append(seg_list, &(ddf_contents[i]));
203 _DEBUG_INFO(" mo_type: %d\n", ddf_contents[i].mo_type);
204 _DEBUG_INFO(" schema_file : %s\n", ddf_contents[i].schema_file);
205 _DEBUG_INFO(" service_ddf : %d\n", ddf_contents[i].service_ddf);
206 _DEBUG_INFO(" server_type : %d\n", ddf_contents[i].server_type);
209 while (check_segment != NULL) {
210 check_segment = strtok(NULL, "\n");
211 if (check_segment == NULL)
213 _DEBUG_INFO(" check_segment : %s\n", check_segment);
215 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));
216 seg_list = g_slist_append(seg_list, &(ddf_contents[i]));
218 _DEBUG_INFO(" mo_type: %d\n", ddf_contents[i].mo_type);
219 _DEBUG_INFO(" schema_file : %s\n", ddf_contents[i].schema_file);
220 _DEBUG_INFO(" service_ddf : %d\n", ddf_contents[i].service_ddf);
221 _DEBUG_INFO(" server_type : %d\n", ddf_contents[i].server_type);
225 ret = _start_ddf_mo(seg_list);
229 file_ret = sync_agent_free_file(&required_contents);
230 required_contents = NULL;
232 ret = DM_ERR_DDF_PROCCESS;
236 ret = _completed_bootstrap();
242 ret = DM_ERR_DDF_PROCCESS;
251 file_ret = sync_agent_free_file(&required_contents);
253 ret = DM_ERR_DDF_PROCCESS;
256 _DEBUG_INFO(" end!! error : %d \n", ret);
265 sync_agent_dm_mo_type_e mo_type_devdetail = SYNC_AGENT_DM_MO_TYPE_DEVDETAIL;
266 sync_agent_dm_mo_type_e mo_type_devinfo = SYNC_AGENT_DM_MO_TYPE_DEVINFO;
267 sync_agent_dm_mo_type_e mo_type_fumo = SYNC_AGENT_DM_MO_TYPE_FUMO;
268 sync_agent_dm_mo_type_e mo_type_gcf = SYNC_AGENT_DM_MO_TYPE_DMACC;
269 sync_agent_dm_mo_type_e mo_type_mscserver = SYNC_AGENT_DM_MO_TYPE_DMACC;
270 sync_agent_dm_mo_type_e mo_type_msctestserver = SYNC_AGENT_DM_MO_TYPE_DMACC;
272 const char *schema_file_devdetail = "/usr/share/oma-dm/ddf/slp/slp_DEVDETAIL_DDF.xml";
273 const char *schema_file_devinfo = "/usr/share/oma-dm/ddf/slp/slp_DEVINF_DDF.xml";
274 const char *schema_file_fumo = "/usr/share/oma-dm/ddf/slp/slp_FUMO_DDF.xml";
275 const char *schema_file_gcf = "/usr/share/oma-dm/ddf/slp/slp_gcf_DMACC_DDF_1.2.xml";
276 const char *schema_file_mscserver = "/usr/share/oma-dm/ddf/slp/slp_MSCserver_DMACC_DDF_1.2.xml";
277 const char *schema_file_msctestserver = "/usr/share/oma-dm/ddf/slp/slp_MSCTestserver_DMACC_DDF_1.2.xml";
279 sync_agent_dm_mo_error_e err_code = sync_agent_construct_mo_table(mo_type_devdetail, schema_file_devdetail , "devdetail");
280 if (err_code == SYNC_AGENT_DM_MO_SUCCESS) {
281 printf("Success to sync_agent_construct_mo_table()\n");
283 printf("Failed to sync_agent_construct_mo_table()\n");
286 err_code = sync_agent_construct_mo_table(mo_type_devinfo, schema_file_devinfo , "devinf");
287 if (err_code == SYNC_AGENT_DM_MO_SUCCESS) {
288 printf("Success to sync_agent_construct_mo_table()\n");
290 printf("Failed to sync_agent_construct_mo_table()\n");
293 err_code = sync_agent_construct_mo_table(mo_type_fumo, schema_file_fumo , "fumo");
294 if (err_code == SYNC_AGENT_DM_MO_SUCCESS) {
295 printf("Success to sync_agent_construct_mo_table()\n");
297 printf("Failed to sync_agent_construct_mo_table()\n");
299 err_code = sync_agent_construct_mo_table(mo_type_gcf, schema_file_gcf , "dmacc_gcf");
300 if (err_code == SYNC_AGENT_DM_MO_SUCCESS) {
301 printf("Success to sync_agent_construct_mo_table()\n");
303 printf("Failed to sync_agent_construct_mo_table()\n");
305 err_code = sync_agent_construct_mo_table(mo_type_mscserver, schema_file_mscserver , "dmacc_MSCserver");
306 if (err_code == SYNC_AGENT_DM_MO_SUCCESS) {
307 printf("Success to sync_agent_construct_mo_table()\n");
309 printf("Failed to sync_agent_construct_mo_table()\n");
311 err_code = sync_agent_construct_mo_table(mo_type_msctestserver, schema_file_msctestserver , "dmacc_MSCTestserver");
312 if (err_code == SYNC_AGENT_DM_MO_SUCCESS) {
313 printf("Success to sync_agent_construct_mo_table()\n");
315 printf("Failed to sync_agent_construct_mo_table()\n");