Tizen 2.0 Release
[framework/system/oma-dm-agent.git] / src / agent / mo-handler / dm_mo_common.c
1 /*
2  * oma-dm-agent
3  * Copyright (c) 2012 Samsung Electronics Co., Ltd.
4  *
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
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
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.
16  */
17
18 /*lib*/
19 #include <stdio.h>
20 #include <stdlib.h>
21 #include <string.h>
22
23 /*sync-agent*/
24 #include <sync_agent.h>
25
26 /*dm-agent*/
27 #include "common/dm_common.h"
28 #include "common/util/util.h"
29 #include "serviceadapter/sa_session.h"
30 #include "serviceadapter/protocolbinder/syncml_def.h"
31 #include "serviceadapter/sa_elements_internal.h"
32 #include "mo-handler/dm_mo_common.h"
33 #include "mo-handler/dm_mo_handler.h"
34 #include "dm-engine/bootstrap/factory_bootstrap.h"
35
36 #ifndef OMADM_AGENT_LOG
37 #undef LOG_TAG
38 #define LOG_TAG "MO_ENGINE"
39 #endif
40
41 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
42  /* mo test interface */
43  /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
44 /*
45
46 void dmacc_define_fumo() {
47         _DEBUG_INFO( " start!!\n");
48
49         sync_agent_dm_mo_type_e type =  SYNC_AGENT_DM_MO_TYPE_DMACC;
50
51         char *mo_full_path0 = FUMO_DM_ACC;
52         char *value0 = NULL;
53         sync_agent_dm_mo_node_type_e  mo_node_type0 = SYNC_AGENT_DM_MO_NODE_INTERIOR;
54
55         char *mo_full_path00 = FUMO_DM_ACC_FUMO;
56         char *value00 = NULL;
57         sync_agent_dm_mo_node_type_e  mo_node_type00 = SYNC_AGENT_DM_MO_NODE_INTERIOR;
58
59         char *mo_full_path1 = FUMO_DM_ACC_APPID;
60         char *value1 = "w7";
61         sync_agent_dm_mo_node_type_e  mo_node_type1 = SYNC_AGENT_DM_MO_NODE_LEAF;
62
63         char *mo_full_path2 = FUMO_DM_ACC_SERVERID;
64         char *value2 = "x6g1q14r75";
65         sync_agent_dm_mo_node_type_e  mo_node_type2 = SYNC_AGENT_DM_MO_NODE_LEAF;
66
67         char *mo_full_path3 = FUMO_DM_ACC_NAME;
68         char *value3 = "slp_msc_fumo";
69         sync_agent_dm_mo_node_type_e  mo_node_type3 = SYNC_AGENT_DM_MO_NODE_LEAF;
70
71         char *mo_full_path4 = FUMO_DM_ACC_PRECONREF;
72         char *value4 = NULL;
73         sync_agent_dm_mo_node_type_e  mo_node_type4 = SYNC_AGENT_DM_MO_NODE_LEAF;
74
75         char *mo_full_path5 = FUMO_DM_ACC_TOCONREF;
76         char *value5 = NULL;
77         sync_agent_dm_mo_node_type_e  mo_node_type5 = SYNC_AGENT_DM_MO_NODE_INTERIOR;
78
79         char *mo_full_path6 =FUMO_DM_ACC_TOCONREF_X;
80         char *value6 =  NULL;
81         sync_agent_dm_mo_node_type_e  mo_node_type6 = SYNC_AGENT_DM_MO_NODE_INTERIOR;
82
83         char *mo_full_path7 =FUMO_DM_ACC_TOCONREF_X_CONREF;
84         char *value7 = NULL;
85         sync_agent_dm_mo_node_type_e  mo_node_type7 = SYNC_AGENT_DM_MO_NODE_INTERIOR;
86
87         char *mo_full_path8 =FUMO_DM_ACC_APPADDR;
88         char *value8 = NULL;
89         sync_agent_dm_mo_node_type_e  mo_node_type8 = SYNC_AGENT_DM_MO_NODE_INTERIOR;
90
91         char *mo_full_path9 =FUMO_DM_ACC_APPADDR_X;
92         char *value9 = NULL;
93         sync_agent_dm_mo_node_type_e  mo_node_type9 = SYNC_AGENT_DM_MO_NODE_INTERIOR;
94
95         char *mo_full_path10 =FUMO_DM_ACC_APPADDR_X_ADDR;
96         char *value10 ="https://121.252.197.81:443/v1/device/magicsync/mdm";
97         sync_agent_dm_mo_node_type_e  mo_node_type10 = SYNC_AGENT_DM_MO_NODE_LEAF;
98
99         char *mo_full_path11 =FUMO_DM_ACC_APPADDR_X_ADDRTYPE;
100         char *value11 = "IPv4";
101         sync_agent_dm_mo_node_type_e  mo_node_type11 = SYNC_AGENT_DM_MO_NODE_LEAF;
102
103         char *mo_full_path12 =FUMO_DM_ACC_APPADDR_X_PORT;
104         char *value12 = NULL;
105         sync_agent_dm_mo_node_type_e  mo_node_type12 = SYNC_AGENT_DM_MO_NODE_INTERIOR;
106
107         char *mo_full_path13 =FUMO_DM_ACC_APPADDR_X_PORT_X;
108         char *value13 = NULL;
109         sync_agent_dm_mo_node_type_e  mo_node_type13 = SYNC_AGENT_DM_MO_NODE_INTERIOR;
110
111         char *mo_full_path14 =FUMO_DM_ACC_APPADDR_X_PORT_X_PORTNBR;
112         char *value14 ="443";
113         sync_agent_dm_mo_node_type_e  mo_node_type14 = SYNC_AGENT_DM_MO_NODE_LEAF;
114
115         char *mo_full_path15 =FUMO_DM_ACC_AAUTHPREF;
116         char *value15 = "DIGEST";
117         sync_agent_dm_mo_node_type_e  mo_node_type15 = SYNC_AGENT_DM_MO_NODE_LEAF;
118
119         char *mo_full_path16 =FUMO_DM_ACC_APPAUTH;
120         char *value16 =NULL;
121         sync_agent_dm_mo_node_type_e  mo_node_type16 = SYNC_AGENT_DM_MO_NODE_INTERIOR;
122
123         char *mo_full_path17 = FUMO_DM_ACC_APPAUTH_X1;
124         char *value17 =NULL;
125         sync_agent_dm_mo_node_type_e  mo_node_type17 = SYNC_AGENT_DM_MO_NODE_INTERIOR;
126
127         char *mo_full_path18 = FUMO_DM_ACC_APPAUTH_X1_AAUTHLEVEL;
128         char *value18 ="CLCRED";
129         sync_agent_dm_mo_node_type_e  mo_node_type18 = SYNC_AGENT_DM_MO_NODE_LEAF;
130
131         char *mo_full_path19 = FUMO_DM_ACC_APPAUTH_X1_AAUTHTYPE;
132         char *value19 ="DIGEST";
133         sync_agent_dm_mo_node_type_e  mo_node_type19 = SYNC_AGENT_DM_MO_NODE_LEAF;
134
135         char *mo_full_path20 = FUMO_DM_ACC_APPAUTH_X1_AAUTHNAME;
136         char *value20;
137
138         sync_agent_get_devinfo(2, "DevID", &value20 );//"IMEI:004401055493403";
139         MO_NODE_TYPE  mo_node_type20 = MO_NODE_LEAF;
140
141         char *mo_full_path21 = FUMO_DM_ACC_APPAUTH_X1_SECRET;
142         char *value21 = generate_Device_Password_temp( value20, value2);
143         sync_agent_dm_mo_node_type_e  mo_node_type21 = SYNC_AGENT_DM_MO_NODE_LEAF;
144
145         char *mo_full_path22 = FUMO_DM_ACC_APPAUTH_X1_AAUTHDATA;
146         char *value22 = NULL;
147         sync_agent_dm_mo_node_type_e  mo_node_type22 = SYNC_AGENT_DM_MO_NODE_INTERIOR;
148
149         char *mo_full_path23 = FUMO_DM_ACC_APPAUTH_X2;
150         char *value23 =NULL;
151         sync_agent_dm_mo_node_type_e  mo_node_type23 = SYNC_AGENT_DM_MO_NODE_INTERIOR;
152
153         char *mo_full_path24 = FUMO_DM_ACC_APPAUTH_X2_AAUTHLEVEL;
154         char *value24 ="SRVRED";
155         sync_agent_dm_mo_node_type_e  mo_node_type24 = SYNC_AGENT_DM_MO_NODE_LEAF;
156
157         char *mo_full_path25 = FUMO_DM_ACC_APPAUTH_X2_AAUTHTYPE;
158         char *value25 ="DIGEST";
159         sync_agent_dm_mo_node_type_e  mo_node_type25 = SYNC_AGENT_DM_MO_NODE_LEAF;
160
161         char *mo_full_path26 = FUMO_DM_ACC_APPAUTH_X2_AAUTHNAME;
162         char *value26 ="x6g1q14r75";
163         sync_agent_dm_mo_node_type_e  mo_node_type26 = SYNC_AGENT_DM_MO_NODE_LEAF;
164
165         char *mo_full_path27 = FUMO_DM_ACC_APPAUTH_X2_SECRET;
166         char *value27 ="T1NQIERNIFNIcnZIcg==";
167         sync_agent_dm_mo_node_type_e  mo_node_type27 = SYNC_AGENT_DM_MO_NODE_LEAF;
168
169         char *mo_full_path28 = FUMO_DM_ACC_APPAUTH_X2_AAUTHDATA;
170         char *value28 = NULL;
171         sync_agent_dm_mo_node_type_e  mo_node_type28 = SYNC_AGENT_DM_MO_NODE_INTERIOR;
172
173         char *mo_full_path29 = FUMO_DM_ACC_EXT;
174         char *value29 =NULL;
175         sync_agent_dm_mo_node_type_e  mo_node_type29 = SYNC_AGENT_DM_MO_NODE_INTERIOR;
176
177         sync_agent_dm_mo_framework_property_s *framework_property = NULL;
178         sync_agent_dm_mo_runtime_property_s *runtime_property = NULL;
179
180         _DEBUG_INFO( " add start!!\n");
181
182         add_mo(type, mo_full_path0, value0, mo_node_type0, framework_property,  runtime_property);
183         add_mo(type, mo_full_path00, value00, mo_node_type00, framework_property,  runtime_property);
184         add_mo(type, mo_full_path1, value1, mo_node_type1, framework_property,  runtime_property);
185         add_mo(type, mo_full_path2, value2, mo_node_type2, framework_property,  runtime_property);
186         add_mo(type, mo_full_path3, value3, mo_node_type3, framework_property,  runtime_property);
187         add_mo(type, mo_full_path4, value4, mo_node_type4, framework_property,  runtime_property);
188         add_mo(type, mo_full_path5, value5, mo_node_type5, framework_property,  runtime_property);
189         add_mo(type, mo_full_path6, value6, mo_node_type6, framework_property,  runtime_property);
190         add_mo(type, mo_full_path7, value7, mo_node_type7, framework_property,  runtime_property);
191         add_mo(type, mo_full_path8, value8, mo_node_type8, framework_property,  runtime_property);
192         add_mo(type, mo_full_path9, value9, mo_node_type9, framework_property,  runtime_property);
193         add_mo(type, mo_full_path10, value10, mo_node_type10, framework_property,  runtime_property);
194         add_mo(type, mo_full_path11, value11, mo_node_type11, framework_property,  runtime_property);
195         add_mo(type, mo_full_path12, value12, mo_node_type12, framework_property,  runtime_property);
196         add_mo(type, mo_full_path13, value13, mo_node_type13, framework_property,  runtime_property);
197         add_mo(type, mo_full_path14, value14, mo_node_type14, framework_property,  runtime_property);
198         add_mo(type, mo_full_path15, value15, mo_node_type15, framework_property,  runtime_property);
199         add_mo(type, mo_full_path16, value16, mo_node_type16, framework_property,  runtime_property);
200         add_mo(type, mo_full_path17, value17, mo_node_type17, framework_property,  runtime_property);
201         add_mo(type, mo_full_path18, value18, mo_node_type18, framework_property,  runtime_property);
202         add_mo(type, mo_full_path19, value19, mo_node_type19, framework_property,  runtime_property);
203         add_mo(type, mo_full_path20, value20, mo_node_type20, framework_property,  runtime_property);
204         add_mo(type, mo_full_path21, value21, mo_node_type21, framework_property,  runtime_property);
205         add_mo(type, mo_full_path22, value22, mo_node_type22, framework_property,  runtime_property);
206         add_mo(type, mo_full_path23, value23, mo_node_type23, framework_property,  runtime_property);
207         add_mo(type, mo_full_path24, value24, mo_node_type24, framework_property,  runtime_property);
208         add_mo(type, mo_full_path25, value25, mo_node_type25, framework_property,  runtime_property);
209         add_mo(type, mo_full_path26, value26, mo_node_type26, framework_property,  runtime_property);
210         add_mo(type, mo_full_path27, value27, mo_node_type27, framework_property,  runtime_property);
211         add_mo(type, mo_full_path28, value28, mo_node_type28, framework_property,  runtime_property);
212         add_mo(type, mo_full_path29, value29, mo_node_type29, framework_property,  runtime_property);
213
214         _DEBUG_INFO( " end!!\n");
215 }
216
217 void dmacc_define_lawmo() {
218         _DEBUG_INFO( " start!!\n");
219
220         sync_agent_dm_mo_type_e type =  SYNC_AGENT_DM_MO_TYPE_DMACC;
221
222         char *mo_full_path0 = LAWMO_DM_ACC;
223         char *value0 = NULL;
224         sync_agent_dm_mo_node_type_e  mo_node_type0 = SYNC_AGENT_DM_MO_NODE_INTERIOR;
225
226         char *mo_full_path00 = LAWMO_DM_ACC_LAWMO;
227         char *value00 = NULL;
228         sync_agent_dm_mo_node_type_e  mo_node_type00 = SYNC_AGENT_DM_MO_NODE_INTERIOR;
229
230         char *mo_full_path1 = LAWMO_DM_ACC_APPID;
231         char *value1 = "w7";
232         sync_agent_dm_mo_node_type_e  mo_node_type1 = SYNC_AGENT_DM_MO_NODE_LEAF;
233
234         char *mo_full_path2 = LAWMO_DM_ACC_SERVERID;
235         char *value2 = "5e8o9279r2";
236         sync_agent_dm_mo_node_type_e  mo_node_type2 = SYNC_AGENT_DM_MO_NODE_LEAF;
237
238         char *mo_full_path3 = LAWMO_DM_ACC_NAME;
239         char *value3 = "slp_msc_lawmo";
240         sync_agent_dm_mo_node_type_e  mo_node_type3 = SYNC_AGENT_DM_MO_NODE_LEAF;
241
242         char *mo_full_path4 = LAWMO_DM_ACC_PRECONREF;
243         char *value4 = NULL;
244         sync_agent_dm_mo_node_type_e  mo_node_type4 = SYNC_AGENT_DM_MO_NODE_LEAF;
245
246         char *mo_full_path5 = LAWMO_DM_ACC_TOCONREF;
247         char *value5 = NULL;
248         sync_agent_dm_mo_node_type_e  mo_node_type5 = SYNC_AGENT_DM_MO_NODE_INTERIOR;
249
250         char *mo_full_path6 =LAWMO_DM_ACC_TOCONREF_X;
251         char *value6 =  NULL;
252         sync_agent_dm_mo_node_type_e  mo_node_type6 = SYNC_AGENT_DM_MO_NODE_INTERIOR;
253
254         char *mo_full_path7 =LAWMO_DM_ACC_TOCONREF_X_CONREF;
255         char *value7 = NULL;
256         sync_agent_dm_mo_node_type_e  mo_node_type7 = SYNC_AGENT_DM_MO_NODE_INTERIOR;
257
258         char *mo_full_path8 =LAWMO_DM_ACC_APPADDR;
259         char *value8 = NULL;
260         sync_agent_dm_mo_node_type_e  mo_node_type8 = SYNC_AGENT_DM_MO_NODE_INTERIOR;
261
262         char *mo_full_path9 =LAWMO_DM_ACC_APPADDR_X;
263         char *value9 = NULL;
264         sync_agent_dm_mo_node_type_e  mo_node_type9 = SYNC_AGENT_DM_MO_NODE_INTERIOR;
265
266         char *mo_full_path10 =LAWMO_DM_ACC_APPADDR_X_ADDR;
267         char *value10 ="https://dm.samsungdive.com:443/v1/sdm/magicsync/dm";
268         sync_agent_dm_mo_node_type_e  mo_node_type10 = SYNC_AGENT_DM_MO_NODE_LEAF;
269
270         char *mo_full_path11 =LAWMO_DM_ACC_APPADDR_X_ADDRTYPE;
271         char *value11 = "IPv4";
272         sync_agent_dm_mo_node_type_e  mo_node_type11 = SYNC_AGENT_DM_MO_NODE_LEAF;
273
274         char *mo_full_path12 =LAWMO_DM_ACC_APPADDR_X_PORT;
275         char *value12 = NULL;
276         sync_agent_dm_mo_node_type_e  mo_node_type12 = SYNC_AGENT_DM_MO_NODE_INTERIOR;
277
278         char *mo_full_path13 =LAWMO_DM_ACC_APPADDR_X_PORT_X;
279         char *value13 = NULL;
280         sync_agent_dm_mo_node_type_e  mo_node_type13 = SYNC_AGENT_DM_MO_NODE_INTERIOR;
281
282         char *mo_full_path14 =LAWMO_DM_ACC_APPADDR_X_PORT_X_PORTNBR;
283         char *value14 ="443";
284         sync_agent_dm_mo_node_type_e  mo_node_type14 = SYNC_AGENT_DM_MO_NODE_LEAF;
285
286         char *mo_full_path15 =LAWMO_DM_ACC_AAUTHPREF;
287         char *value15 = "DIGEST";
288         sync_agent_dm_mo_node_type_e  mo_node_type15 = SYNC_AGENT_DM_MO_NODE_LEAF;
289
290         char *mo_full_path16 =LAWMO_DM_ACC_APPAUTH;
291         char *value16 =NULL;
292         sync_agent_dm_mo_node_type_e  mo_node_type16 = SYNC_AGENT_DM_MO_NODE_INTERIOR;
293
294         char *mo_full_path17 = LAWMO_DM_ACC_APPAUTH_X1;
295         char *value17 =NULL;
296         sync_agent_dm_mo_node_type_e  mo_node_type17 = SYNC_AGENT_DM_MO_NODE_INTERIOR;
297
298         char *mo_full_path18 = LAWMO_DM_ACC_APPAUTH_X1_AAUTHLEVEL;
299         char *value18 ="CLCRED";
300         sync_agent_dm_mo_node_type_e  mo_node_type18 = SYNC_AGENT_DM_MO_NODE_LEAF;
301
302         char *mo_full_path19 = LAWMO_DM_ACC_APPAUTH_X1_AAUTHTYPE;
303         char *value19 ="DIGEST";
304         sync_agent_dm_mo_node_type_e  mo_node_type19 = SYNC_AGENT_DM_MO_NODE_LEAF;
305
306         char *mo_full_path20 = LAWMO_DM_ACC_APPAUTH_X1_AAUTHNAME;
307         char *value20;
308
309         sync_agent_get_devinfo(2, "DevID", &value20 );//"IMEI:004401055493403";
310         sync_agent_dm_mo_node_type_e  mo_node_type20 = SYNC_AGENT_DM_MO_NODE_LEAF;
311
312         char *mo_full_path21 = LAWMO_DM_ACC_APPAUTH_X1_SECRET;
313         char *value21 = generate_Device_Password_temp( value20, value2);
314         sync_agent_dm_mo_node_type_e  mo_node_type21 = SYNC_AGENT_DM_MO_NODE_LEAF;
315
316         char *mo_full_path22 = LAWMO_DM_ACC_APPAUTH_X1_AAUTHDATA;
317         char *value22 = NULL;
318         sync_agent_dm_mo_node_type_e  mo_node_type22 = SYNC_AGENT_DM_MO_NODE_INTERIOR;
319
320         char *mo_full_path23 = LAWMO_DM_ACC_APPAUTH_X2;
321         char *value23 =NULL;
322         sync_agent_dm_mo_node_type_e  mo_node_type23 = SYNC_AGENT_DM_MO_NODE_INTERIOR;
323
324         char *mo_full_path24 = LAWMO_DM_ACC_APPAUTH_X2_AAUTHLEVEL;
325         char *value24 ="SRVRED";
326         sync_agent_dm_mo_node_type_e  mo_node_type24 = SYNC_AGENT_DM_MO_NODE_LEAF;
327
328         char *mo_full_path25 = LAWMO_DM_ACC_APPAUTH_X2_AAUTHTYPE;
329         char *value25 ="DIGEST";
330         sync_agent_dm_mo_node_type_e  mo_node_type25 = SYNC_AGENT_DM_MO_NODE_LEAF;
331
332         char *mo_full_path26 = LAWMO_DM_ACC_APPAUTH_X2_AAUTHNAME;
333         char *value26 ="5e8o9279r2";
334         sync_agent_dm_mo_node_type_e  mo_node_type26 = SYNC_AGENT_DM_MO_NODE_LEAF;
335
336         char *mo_full_path27 = LAWMO_DM_ACC_APPAUTH_X2_SECRET;
337         char *value27 ="T1NQIERNIFNlcnZlcg==";
338         sync_agent_dm_mo_node_type_e  mo_node_type27 = SYNC_AGENT_DM_MO_NODE_LEAF;
339
340         char *mo_full_path28 = LAWMO_DM_ACC_APPAUTH_X2_AAUTHDATA;
341         char *value28 = NULL;
342         sync_agent_dm_mo_node_type_e  mo_node_type28 = SYNC_AGENT_DM_MO_NODE_INTERIOR;
343
344         char *mo_full_path29 = LAWMO_DM_ACC_EXT;
345         char *value29 =NULL;
346         sync_agent_dm_mo_node_type_e  mo_node_type29 = SYNC_AGENT_DM_MO_NODE_INTERIOR;
347
348         sync_agent_dm_mo_framework_property_s *framework_property = NULL;
349         sync_agent_dm_mo_runtime_property_s *runtime_property = NULL;
350
351         _DEBUG_INFO( " add start!!\n");
352
353         add_mo(type, mo_full_path0, value0, mo_node_type0, framework_property,  runtime_property);
354         add_mo(type, mo_full_path00, value00, mo_node_type00, framework_property,  runtime_property);
355         add_mo(type, mo_full_path1, value1, mo_node_type1, framework_property,  runtime_property);
356         add_mo(type, mo_full_path2, value2, mo_node_type2, framework_property,  runtime_property);
357         add_mo(type, mo_full_path3, value3, mo_node_type3, framework_property,  runtime_property);
358         add_mo(type, mo_full_path4, value4, mo_node_type4, framework_property,  runtime_property);
359         add_mo(type, mo_full_path5, value5, mo_node_type5, framework_property,  runtime_property);
360         add_mo(type, mo_full_path6, value6, mo_node_type6, framework_property,  runtime_property);
361         add_mo(type, mo_full_path7, value7, mo_node_type7, framework_property,  runtime_property);
362         add_mo(type, mo_full_path8, value8, mo_node_type8, framework_property,  runtime_property);
363         add_mo(type, mo_full_path9, value9, mo_node_type9, framework_property,  runtime_property);
364         add_mo(type, mo_full_path10, value10, mo_node_type10, framework_property,  runtime_property);
365         add_mo(type, mo_full_path11, value11, mo_node_type11, framework_property,  runtime_property);
366         add_mo(type, mo_full_path12, value12, mo_node_type12, framework_property,  runtime_property);
367         add_mo(type, mo_full_path13, value13, mo_node_type13, framework_property,  runtime_property);
368         add_mo(type, mo_full_path14, value14, mo_node_type14, framework_property,  runtime_property);
369         add_mo(type, mo_full_path15, value15, mo_node_type15, framework_property,  runtime_property);
370         add_mo(type, mo_full_path16, value16, mo_node_type16, framework_property,  runtime_property);
371         add_mo(type, mo_full_path17, value17, mo_node_type17, framework_property,  runtime_property);
372         add_mo(type, mo_full_path18, value18, mo_node_type18, framework_property,  runtime_property);
373         add_mo(type, mo_full_path19, value19, mo_node_type19, framework_property,  runtime_property);
374         add_mo(type, mo_full_path20, value20, mo_node_type20, framework_property,  runtime_property);
375         add_mo(type, mo_full_path21, value21, mo_node_type21, framework_property,  runtime_property);
376         add_mo(type, mo_full_path22, value22, mo_node_type22, framework_property,  runtime_property);
377         add_mo(type, mo_full_path23, value23, mo_node_type23, framework_property,  runtime_property);
378         add_mo(type, mo_full_path24, value24, mo_node_type24, framework_property,  runtime_property);
379         add_mo(type, mo_full_path25, value25, mo_node_type25, framework_property,  runtime_property);
380         add_mo(type, mo_full_path26, value26, mo_node_type26, framework_property,  runtime_property);
381         add_mo(type, mo_full_path27, value27, mo_node_type27, framework_property,  runtime_property);
382         add_mo(type, mo_full_path28, value28, mo_node_type28, framework_property,  runtime_property);
383         add_mo(type, mo_full_path29, value29, mo_node_type29, framework_property,  runtime_property);
384
385         _DEBUG_INFO( " end!!\n");
386 }
387
388  void devinfo_define() {
389         _DEBUG_INFO( " start!!\n");
390
391         sync_agent_dm_mo_type_e type =  SYNC_AGENT_DM_MO_TYPE_DEVINFO;
392
393         char *mo_full_path0 = DM_DEVINFO;
394         char *value0 = NULL;
395         sync_agent_dm_mo_node_type_e  mo_node_type0 = SYNC_AGENT_DM_MO_NODE_INTERIOR;
396
397         char *mo_full_path1 = DM_DEVINFO_BEARER;
398         char *value1 = NULL;
399         sync_agent_dm_mo_node_type_e  mo_node_type1 = SYNC_AGENT_DM_MO_NODE_LEAF;
400
401         char *mo_full_path2 = DM_DEVINFO_DEVID;
402         char *value2;
403
404         sync_agent_get_devinfo(2, "DevID", &value2 );//"IMEI:004401055493403";
405         sync_agent_dm_mo_node_type_e  mo_node_type2 = SYNC_AGENT_DM_MO_NODE_LEAF;
406
407         char *mo_full_path3 = DM_DEVINFO_MAN;
408         char *value3 = "samsung-electronics";
409         sync_agent_dm_mo_node_type_e  mo_node_type3 = SYNC_AGENT_DM_MO_NODE_LEAF;
410
411         char *mo_full_path4 = DM_DEVINFO_MOD;
412         char *value4 = "GT-I9500";
413         sync_agent_dm_mo_node_type_e  mo_node_type4 = SYNC_AGENT_DM_MO_NODE_LEAF;
414
415         char *mo_full_path5 = DM_DEVINFO_DMV;
416         char *value5 = "1.2";
417         sync_agent_dm_mo_node_type_e  mo_node_type5 = SYNC_AGENT_DM_MO_NODE_LEAF;
418
419         char *mo_full_path6 =DM_DEVINFO_LANG;
420         char *value6 =  "en-us";
421         sync_agent_dm_mo_node_type_e  mo_node_type6 = SYNC_AGENT_DM_MO_NODE_LEAF;
422
423         char *mo_full_path7 =DM_DEVINFO_EXT;
424         char *value7 = NULL;
425         sync_agent_dm_mo_node_type_e  mo_node_type7 = SYNC_AGENT_DM_MO_NODE_INTERIOR;
426
427         sync_agent_dm_mo_framework_property_s *framework_property = NULL;
428         sync_agent_dm_mo_runtime_property_s *runtime_property = NULL;
429
430         _DEBUG_INFO( " add start!!\n");
431
432         add_mo(type, mo_full_path0, value0, mo_node_type0, framework_property,  runtime_property);
433         add_mo(type, mo_full_path1, value1, mo_node_type1, framework_property,  runtime_property);
434         add_mo(type, mo_full_path2, value2, mo_node_type2, framework_property,  runtime_property);
435         add_mo(type, mo_full_path3, value3, mo_node_type3, framework_property,  runtime_property);
436         add_mo(type, mo_full_path4, value4, mo_node_type4, framework_property,  runtime_property);
437         add_mo(type, mo_full_path5, value5, mo_node_type5, framework_property,  runtime_property);
438         add_mo(type, mo_full_path6, value6, mo_node_type6, framework_property,  runtime_property);
439         add_mo(type, mo_full_path7, value7, mo_node_type7, framework_property,  runtime_property);
440
441         _DEBUG_INFO( " end!!\n");
442 }
443  void devdetail_define() {
444         _DEBUG_INFO( " start!!\n");
445
446                 sync_agent_dm_mo_type_e type =  SYNC_AGENT_DM_MO_TYPE_DEVDETAIL;
447
448                 char *mo_full_path0 = DM_DEVDETAIL;
449                 char *value0 = NULL;
450                 sync_agent_dm_mo_node_type_e  mo_node_type0 = SYNC_AGENT_DM_MO_NODE_INTERIOR;
451
452                 char *mo_full_path1 = DM_DEVDETAIL_BEARER;
453                 char *value1 = NULL;
454                 sync_agent_dm_mo_node_type_e  mo_node_type1 = SYNC_AGENT_DM_MO_NODE_LEAF;
455
456                 char *mo_full_path2 = DM_DEVINFO_URI;
457                 char *value2 = NULL;
458                 sync_agent_dm_mo_node_type_e  mo_node_type2 = SYNC_AGENT_DM_MO_NODE_LEAF;
459
460                 char *mo_full_path3 = DM_DEVINFO_URI_MAXDEPTH;
461                 char *value3 = g_strdup_printf("%d",100);
462                 sync_agent_dm_mo_node_type_e  mo_node_type3 = SYNC_AGENT_DM_MO_NODE_LEAF;
463
464                 char *mo_full_path4 = DM_DEVINFO_URI_MAXTOTLEN;
465                 char *value4 = g_strdup_printf("%d",100);;
466                 sync_agent_dm_mo_node_type_e  mo_node_type4 = SYNC_AGENT_DM_MO_NODE_LEAF;
467
468                 char *mo_full_path5 = DM_DEVINFO_URI_MAXSEGLEN;
469                 char *value5 = g_strdup_printf("%d",100);;
470                 sync_agent_dm_mo_node_type_e  mo_node_type5 = SYNC_AGENT_DM_MO_NODE_LEAF;
471
472                 char *mo_full_path6 =DM_DEVINFO_DEVTYP;
473                 char *value6 =  "Smart";
474                 sync_agent_dm_mo_node_type_e  mo_node_type6 = SYNC_AGENT_DM_MO_NODE_LEAF;
475
476                 char *mo_full_path7 =DM_DEVINFO_OEM;
477                 char *value7 = "null";
478                 sync_agent_dm_mo_node_type_e  mo_node_type7 = SYNC_AGENT_DM_MO_NODE_LEAF;
479
480                 char *mo_full_path8 =DM_DEVINFO_FWV;
481                 char *value8 = "M.I9200XXKC1-P.I13-";
482                 sync_agent_dm_mo_node_type_e  mo_node_type8 = SYNC_AGENT_DM_MO_NODE_LEAF;
483
484                 char *mo_full_path9 =DM_DEVINFO_SWV;
485                 char *value9 = "M.I9200XXKC1-P.I13-";
486                 sync_agent_dm_mo_node_type_e  mo_node_type9 = SYNC_AGENT_DM_MO_NODE_LEAF;
487
488                 char *mo_full_path10 =DM_DEVINFO_HWV;
489                 char *value10 ="GT-I9500";
490                 sync_agent_dm_mo_node_type_e  mo_node_type10 = SYNC_AGENT_DM_MO_NODE_LEAF;
491
492                 char *mo_full_path11 =DM_DEVINFO_LRGOBJ;
493                 char *value11 = "IPv4";
494                 sync_agent_dm_mo_node_type_e  mo_node_type11 = SYNC_AGENT_DM_MO_NODE_LEAF;
495
496                 sync_agent_dm_mo_framework_property_s *framework_property = NULL;
497                 sync_agent_dm_mo_runtime_property_s *runtime_property = NULL;
498
499                 _DEBUG_INFO( " add start!!\n");
500
501                 add_mo(type, mo_full_path0, value0, mo_node_type0, framework_property,  runtime_property);
502                 add_mo(type, mo_full_path1, value1, mo_node_type1, framework_property,  runtime_property);
503                 add_mo(type, mo_full_path2, value2, mo_node_type2, framework_property,  runtime_property);
504                 add_mo(type, mo_full_path3, value3, mo_node_type3, framework_property,  runtime_property);
505                 add_mo(type, mo_full_path4, value4, mo_node_type4, framework_property,  runtime_property);
506                 add_mo(type, mo_full_path5, value5, mo_node_type5, framework_property,  runtime_property);
507                 add_mo(type, mo_full_path6, value6, mo_node_type6, framework_property,  runtime_property);
508                 add_mo(type, mo_full_path7, value7, mo_node_type7, framework_property,  runtime_property);
509                 add_mo(type, mo_full_path8, value8, mo_node_type8, framework_property,  runtime_property);
510                 add_mo(type, mo_full_path9, value9, mo_node_type9, framework_property,  runtime_property);
511                 add_mo(type, mo_full_path10, value10, mo_node_type10, framework_property,  runtime_property);
512                 add_mo(type, mo_full_path11, value11, mo_node_type11, framework_property,  runtime_property);
513
514                 _DEBUG_INFO( " ed!!\n");
515
516 }
517
518  void fumo_define() {
519         _DEBUG_INFO( " start!!\n");
520
521         sync_agent_dm_mo_type_e type =  SYNC_AGENT_DM_MO_TYPE_FUMO;
522
523         char *mo_full_path0 = DM_FUMO;
524         char *value0 = NULL;
525         sync_agent_dm_mo_node_type_e  mo_node_type0 = SYNC_AGENT_DM_MO_NODE_INTERIOR;
526
527         char *mo_full_path1 = DM_FUMO_PKGNAME;
528         char *value1 = "0830_0831_FW_delta.tar";
529         sync_agent_dm_mo_node_type_e  mo_node_type1 = SYNC_AGENT_DM_MO_NODE_LEAF;
530
531         char *mo_full_path2 = DM_FUMO_VERSION;
532         char *value2 = "M.I9200XXKC1-P.I13-";
533         sync_agent_dm_mo_node_type_e  mo_node_type2 = SYNC_AGENT_DM_MO_NODE_LEAF;
534
535         char *mo_full_path3 = DM_FUMO_DOWNLOAD;
536         char *value3 = NULL;
537         sync_agent_dm_mo_node_type_e  mo_node_type3 = SYNC_AGENT_DM_MO_NODE_INTERIOR;
538
539         char *mo_full_path4 = DM_FUMO_DWONLOAD_PKGURL;
540         char *value4 = NULL;
541         sync_agent_dm_mo_node_type_e  mo_node_type4 = SYNC_AGENT_DM_MO_NODE_LEAF;
542
543         char *mo_full_path5 = DM_FUMO_UPDATE;
544         char *value5 = NULL;
545         sync_agent_dm_mo_node_type_e  mo_node_type5 = SYNC_AGENT_DM_MO_NODE_INTERIOR;
546
547         char *mo_full_path6 =DM_FUMO_UPDATE_PKG_DATA;
548         char *value6 =  NULL;
549         sync_agent_dm_mo_node_type_e  mo_node_type6 = SYNC_AGENT_DM_MO_NODE_LEAF;
550
551         char *mo_full_path7 =DM_FUMO_DOWNLOADAND_UPDATE;
552         char *value7 = NULL;
553         sync_agent_dm_mo_node_type_e  mo_node_type7 = SYNC_AGENT_DM_MO_NODE_INTERIOR;
554
555         char *mo_full_path8 =DM_FUMO_DOWNLOADAND_UPDATE_PKGURL;
556         char *value8 = NULL;
557         sync_agent_dm_mo_node_type_e  mo_node_type8 = SYNC_AGENT_DM_MO_NODE_LEAF;
558
559         char *mo_full_path9 =DM_FUMO_STATE;
560         char *value9 = "10";
561         sync_agent_dm_mo_node_type_e  mo_node_type9 = SYNC_AGENT_DM_MO_NODE_LEAF;
562
563         char *mo_full_path10 =DM_FUMO_EXT;
564         char *value10 = NULL;
565         sync_agent_dm_mo_node_type_e  mo_node_type10 = SYNC_AGENT_DM_MO_NODE_INTERIOR;
566
567         sync_agent_dm_mo_framework_property_s *framework_property = NULL;
568         sync_agent_dm_mo_runtime_property_s *runtime_property = NULL;
569
570         _DEBUG_INFO( " add start!!\n");
571
572         add_mo(type, mo_full_path0, value0, mo_node_type0, framework_property,  runtime_property);
573         add_mo(type, mo_full_path1, value1, mo_node_type1, framework_property,  runtime_property);
574         add_mo(type, mo_full_path2, value2, mo_node_type2, framework_property,  runtime_property);
575         add_mo(type, mo_full_path3, value3, mo_node_type3, framework_property,  runtime_property);
576         add_mo(type, mo_full_path4, value4, mo_node_type4, framework_property,  runtime_property);
577         add_mo(type, mo_full_path5, value5, mo_node_type5, framework_property,  runtime_property);
578         add_mo(type, mo_full_path6, value6, mo_node_type6, framework_property,  runtime_property);
579         add_mo(type, mo_full_path7, value7, mo_node_type7, framework_property,  runtime_property);
580         add_mo(type, mo_full_path8, value8, mo_node_type8, framework_property,  runtime_property);
581         add_mo(type, mo_full_path9, value9, mo_node_type9, framework_property,  runtime_property);
582         add_mo(type, mo_full_path10, value10, mo_node_type10, framework_property,  runtime_property);
583
584         _DEBUG_INFO( " end!!\n");
585 }
586  void lawmo_define() {
587
588         _DEBUG_INFO( " start!!\n");
589
590         sync_agent_dm_mo_type_e type =  SYNC_AGENT_DM_MO_TYPE_LAWMO;
591
592         char *mo_full_path0 = DM_LAWMO;
593         char *value0 = NULL;
594         sync_agent_dm_mo_node_type_e  mo_node_type0 = SYNC_AGENT_DM_MO_NODE_INTERIOR;
595
596         char *mo_full_path1 = DM_LAWMO_STATE;
597         char *value1 = "30";
598         sync_agent_dm_mo_node_type_e  mo_node_type1 = SYNC_AGENT_DM_MO_NODE_LEAF;
599
600         char *mo_full_path2 = DM_LAWMO_AVAILABLEWIPELIST;
601         char *value2 = NULL;
602         sync_agent_dm_mo_node_type_e  mo_node_type2 = SYNC_AGENT_DM_MO_NODE_INTERIOR;
603
604         char *mo_full_path3 = DM_LAWMO_AVAILABLEWIPELIST_x1;
605         char *value3 = NULL;
606         sync_agent_dm_mo_node_type_e  mo_node_type3 = SYNC_AGENT_DM_MO_NODE_INTERIOR;
607
608         char *mo_full_path4 = DM_LAWMO_AVAILABLEWIPELIST_x1_LISTITEMNAME;
609         char *value4 = NULL;
610         sync_agent_dm_mo_node_type_e  mo_node_type4 = SYNC_AGENT_DM_MO_NODE_LEAF;
611
612         char *mo_full_path5 = DM_LAWMO_AVAILABLEWIPELIST_x1_TOBEWIPED;
613         char *value5 =  NULL;
614         sync_agent_dm_mo_node_type_e  mo_node_type5 = SYNC_AGENT_DM_MO_NODE_LEAF;
615
616         char *mo_full_path6 =DM_LAWMO_LAWMOCONFIG;
617         char *value6 =  NULL;
618         sync_agent_dm_mo_node_type_e  mo_node_type6 = SYNC_AGENT_DM_MO_NODE_INTERIOR;
619
620         char *mo_full_path7 =DM_LAWMO_LAWMOCONFIG_NOFITYUSER;
621         char *value7 = NULL;
622         sync_agent_dm_mo_node_type_e  mo_node_type7 = SYNC_AGENT_DM_MO_NODE_LEAF;
623
624         char *mo_full_path8 =DM_LAWMO_OPERATIONS;
625         char *value8 = NULL;
626         sync_agent_dm_mo_node_type_e  mo_node_type8 = SYNC_AGENT_DM_MO_NODE_INTERIOR;
627
628         char *mo_full_path9 =DM_LAWMO_OPERATIONS_FULLYLOCK;
629         char *value9 = NULL;
630         sync_agent_dm_mo_node_type_e  mo_node_type9 = SYNC_AGENT_DM_MO_NODE_LEAF;
631
632         char *mo_full_path10 =DM_LAWMO_OPERATIONS_PARTIALLYLOCK;
633         char *value10 = NULL;
634         sync_agent_dm_mo_node_type_e  mo_node_type10 = SYNC_AGENT_DM_MO_NODE_LEAF;
635
636         char *mo_full_path11 =DM_LAWMO_OPERATIONS_UNLOCK;
637         char *value11 = NULL;
638         sync_agent_dm_mo_node_type_e  mo_node_type11 = SYNC_AGENT_DM_MO_NODE_LEAF;
639
640         char *mo_full_path12 =DM_LAWMO_OPERATIONS_FACTORYRESET;
641         char *value12 = NULL;
642         sync_agent_dm_mo_node_type_e  mo_node_type12 = SYNC_AGENT_DM_MO_NODE_LEAF;
643
644         char *mo_full_path13 =DM_LAWMO_OPERATIONS_WIPE;
645         char *value13 = NULL;
646         sync_agent_dm_mo_node_type_e  mo_node_type13 = SYNC_AGENT_DM_MO_NODE_LEAF;
647
648         char *mo_full_path14 =DM_LAWMO_EXT;
649         char *value14 = NULL;
650         sync_agent_dm_mo_node_type_e  mo_node_type14 = SYNC_AGENT_DM_MO_NODE_INTERIOR;
651
652         sync_agent_dm_mo_framework_property_s *framework_property = NULL;
653         sync_agent_dm_mo_runtime_property_s *runtime_property = NULL;
654
655         _DEBUG_INFO( " add start!!\n");
656
657         add_mo(type, mo_full_path0, value0, mo_node_type0, framework_property,  runtime_property);
658         add_mo(type, mo_full_path1, value1, mo_node_type1, framework_property,  runtime_property);
659         add_mo(type, mo_full_path2, value2, mo_node_type2, framework_property,  runtime_property);
660         add_mo(type, mo_full_path3, value3, mo_node_type3, framework_property,  runtime_property);
661         add_mo(type, mo_full_path4, value4, mo_node_type4, framework_property,  runtime_property);
662         add_mo(type, mo_full_path5, value5, mo_node_type5, framework_property,  runtime_property);
663         add_mo(type, mo_full_path6, value6, mo_node_type6, framework_property,  runtime_property);
664         add_mo(type, mo_full_path7, value7, mo_node_type7, framework_property,  runtime_property);
665         add_mo(type, mo_full_path8, value8, mo_node_type8, framework_property,  runtime_property);
666         add_mo(type, mo_full_path9, value9, mo_node_type9, framework_property,  runtime_property);
667         add_mo(type, mo_full_path10, value10, mo_node_type10, framework_property,  runtime_property);
668         add_mo(type, mo_full_path11, value11, mo_node_type11, framework_property,  runtime_property);
669         add_mo(type, mo_full_path12, value12, mo_node_type12, framework_property,  runtime_property);
670         add_mo(type, mo_full_path13, value13, mo_node_type13, framework_property,  runtime_property);
671         add_mo(type, mo_full_path14, value14, mo_node_type14, framework_property,  runtime_property);
672
673         _DEBUG_INFO( " end!!\n");
674 }
675
676 */
677
678  /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
679  /* mo common inteface */
680  /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
681
682 void free_dm_acc(dm_acc * dmaccount)
683 {
684         _EXTERN_FUNC_ENTER;
685
686         if (dmaccount == NULL)
687                 return;
688
689         if (dmaccount->server_url != NULL) {
690                 free(dmaccount->server_url);
691                 dmaccount->server_url = NULL;
692         }
693         if (dmaccount->server_id != NULL) {
694                 free(dmaccount->server_id);
695                 dmaccount->server_id = NULL;
696         }
697         if (dmaccount->server_pw != NULL) {
698                 free(dmaccount->server_pw);
699                 dmaccount->server_pw = NULL;
700         }
701         if (dmaccount->server_auth_type != NULL) {
702                 free(dmaccount->server_auth_type);
703                 dmaccount->server_auth_type = NULL;
704         }
705         if (dmaccount->user_id != NULL) {
706                 free(dmaccount->user_id);
707                 dmaccount->user_id = NULL;
708         }
709         if (dmaccount->user_pw != NULL) {
710                 free(dmaccount->user_pw);
711                 dmaccount->user_pw = NULL;
712         }
713         if (dmaccount->user_auth_type != NULL) {
714                 free(dmaccount->user_auth_type);
715                 dmaccount->user_auth_type = NULL;
716         }
717         if (dmaccount->user_nextNonce != NULL) {
718                 free(dmaccount->user_nextNonce);
719                 dmaccount->user_nextNonce = NULL;
720         }
721         if (dmaccount->server_nextNonce != NULL) {
722                 free(dmaccount->server_nextNonce);
723                 dmaccount->server_nextNonce = NULL;
724         }
725
726         free(dmaccount);
727         dmaccount = NULL;
728
729         _EXTERN_FUNC_EXIT;
730 }
731
732 DM_ERROR get_client_dmacc(char *pServer_id, char **client_id, char **client_pwd, char **sourceUrl, char **targetUrl, int *isBase64, char **nextNonce, char **authType)
733 {
734
735         _EXTERN_FUNC_ENTER;
736
737         DM_ERROR ret = DM_OK;
738         sync_agent_dev_return_e err;
739         sync_agent_dm_mo_error_e err_code = SYNC_AGENT_DM_MO_SUCCESS;
740         sync_agent_dm_acc_info_s *acc_info = NULL;
741         sync_agent_dm_mo_acc_item_info_s sync_agent_mo_acc_info_item;
742
743         sync_agent_mo_acc_info_item.acc_type = DEVICE_MANAGE_ACC_TYPE_CLIENT;
744         sync_agent_mo_acc_info_item.serverid = pServer_id;
745
746         err_code = sync_agent_get_mo_acc_item(&sync_agent_mo_acc_info_item, &acc_info);
747         //acc_info = sync_agent_get_acc_info(pServer_id, DEVICE_MANAGE_ACC_TYPE_CLIENT);
748         if (err_code != SYNC_AGENT_DM_MO_SUCCESS || acc_info == NULL) {
749                 _DEBUG_INFO(" acc null!!\n");
750                 ret = COMMON_ERR_IS_NULL;
751                 goto error;
752         }
753
754         _DEBUG_INFO(" id = %s\n", acc_info->auth_name);
755         _DEBUG_INFO(" pwd = %s\n", acc_info->auth_secret);
756 /*      _DEBUG_INFO( " Session_id = %s\n", pSession_id);*/
757         _DEBUG_INFO(" serverUrl = %s\n", acc_info->addr);
758         _DEBUG_INFO(" nextNonce = %s\n", acc_info->auth_data);
759
760         if ((acc_info->auth_name) == NULL || (acc_info->auth_secret) == NULL || (acc_info->addr) == NULL) {
761                 ret = COMMON_ERR_IS_NULL;
762                 goto error;
763         }
764
765         (*client_id) = strdup(acc_info->auth_name);
766         (*client_pwd) = strdup(acc_info->auth_secret);
767         (*targetUrl) = strdup(acc_info->addr);
768         if (acc_info->auth_data != NULL) {
769                 str_free(nextNonce);
770                 (*nextNonce) = strdup(acc_info->auth_data);
771         }
772         //(*sourceUrl) = strdup("IMEI:004401055493403");
773         if (acc_info->auth_type != NULL)
774                 (*authType) = strdup(acc_info->auth_type);
775
776         err = sync_agent_get_devinfo(2, "DevID", sourceUrl);
777         _DEBUG_INFO(" sourceUrl = %s\n", (*sourceUrl));
778
779         *isBase64 = 1;
780
781         sync_agent_free_mo_acc_item(&acc_info);
782         _EXTERN_FUNC_EXIT;
783         return ret;
784  error:
785         ret = COMMON_ERR_MO_NOT_FOUND_IN_DB;
786         sync_agent_free_mo_acc_item(&acc_info);
787         _DEBUG_INFO(" end!! error : %d\n", ret);
788         _EXTERN_FUNC_EXIT;
789         return ret;
790 }
791
792 DM_ERROR get_server_dmacc(char *pServer_id, char **server_id, char **server_pwd, char **sourceUrl, char **targetUrl, int *isBase64, char **nextNonce, char **authType)
793 {
794         _EXTERN_FUNC_ENTER;
795
796         retvm_if((pServer_id) == NULL, COMMON_ERR_IS_NULL, "pServer_id is NULL!!");
797
798         DM_ERROR ret = DM_OK;
799         sync_agent_dev_return_e err;
800
801         sync_agent_dm_mo_error_e err_code = SYNC_AGENT_DM_MO_SUCCESS;
802         sync_agent_dm_acc_info_s *acc_info = NULL;
803         sync_agent_dm_mo_acc_item_info_s sync_agent_mo_acc_info_item;
804
805         sync_agent_mo_acc_info_item.acc_type = DEVICE_MANAGE_ACC_TYPE_SERVER;
806         sync_agent_mo_acc_info_item.serverid = pServer_id;
807
808         err_code = sync_agent_get_mo_acc_item(&sync_agent_mo_acc_info_item, &acc_info);
809         //acc_info = sync_agent_get_acc_info(pServer_id, DEVICE_MANAGE_ACC_TYPE_CLIENT);
810         if (err_code != SYNC_AGENT_DM_MO_SUCCESS || acc_info == NULL) {
811                 _DEBUG_INFO(" acc null!!\n");
812                 ret = COMMON_ERR_IS_NULL;
813                 goto error;
814         }
815
816         _DEBUG_INFO(" id = %s\n", acc_info->auth_name);
817         _DEBUG_INFO(" pwd = %s\n", acc_info->auth_secret);
818 /*      _DEBUG_INFO( " Session_id = %s\n", pSession_id);*/
819         _DEBUG_INFO(" serverUrl = %s\n", acc_info->addr);
820         _DEBUG_INFO(" nextNonce = %s\n", acc_info->auth_data);
821
822         if ((acc_info->auth_name) == NULL || (acc_info->auth_secret) == NULL || (acc_info->addr) == NULL) {
823                 ret = COMMON_ERR_IS_NULL;
824                 goto error;
825         }
826
827         (*server_id) = strdup(acc_info->auth_name);
828         (*server_pwd) = strdup(acc_info->auth_secret);
829         (*targetUrl) = strdup(acc_info->addr);
830         if (acc_info->auth_data != NULL)
831                 (*nextNonce) = strdup(acc_info->auth_data);
832         //(*sourceUrl) = strdup("IMEI:004401055493403");
833         if (acc_info->auth_type != NULL)
834                 (*authType) = strdup(acc_info->auth_type);
835
836         err = sync_agent_get_devinfo(2, "DevID", sourceUrl);
837         _DEBUG_INFO(" sourceUrl = %s\n", (*sourceUrl));
838
839         *isBase64 = 1;
840         // temp test code
841
842         sync_agent_free_mo_acc_item(&acc_info);
843
844         _EXTERN_FUNC_EXIT;
845         return ret;
846
847  error:
848         sync_agent_free_mo_acc_item(&acc_info);
849         ret = COMMON_ERR_MO_NOT_FOUND_IN_DB;
850         _EXTERN_FUNC_EXIT;
851         return ret;
852 }
853
854 int update_dmacc(char *pServer_id, dm_acc * dmaccount)
855 {
856         _EXTERN_FUNC_ENTER;
857         int ret = 1;
858
859         retvm_if((pServer_id) == NULL, COMMON_ERR_IS_NULL, "pServer_id is NULL!!");
860
861         sync_agent_dm_mo_error_e err_code = SYNC_AGENT_DM_MO_SUCCESS;
862         sync_agent_dm_acc_info_s *acc_info_c = NULL;
863         sync_agent_dm_acc_info_s *acc_info_s = NULL;
864         sync_agent_dm_mo_acc_item_info_s sync_agent_mo_acc_info_item;
865
866         sync_agent_open_mo();
867         err_code = sync_agent_begin_transaction_mo();
868         _DEBUG_INFO("transanction begin : %d", err_code);
869
870         sync_agent_mo_acc_info_item.acc_type = DEVICE_MANAGE_ACC_TYPE_CLIENT;
871         sync_agent_mo_acc_info_item.serverid = pServer_id;
872
873         err_code = sync_agent_get_mo_acc_item(&sync_agent_mo_acc_info_item, &acc_info_c);
874         //acc_info = sync_agent_get_acc_info(pServer_id, DEVICE_MANAGE_ACC_TYPE_CLIENT);
875         if (err_code != SYNC_AGENT_DM_MO_SUCCESS || acc_info_c == NULL) {
876                 _DEBUG_INFO(" acc null!!\n");
877                 ret = COMMON_ERR_IS_NULL;
878                 goto error;
879         }
880
881         _DEBUG_INFO("user id = %s\n", dmaccount->user_id);
882         _DEBUG_INFO("user pwd = %s\n", dmaccount->user_pw);
883         _DEBUG_INFO("user auth type = %s\n", dmaccount->user_auth_type);
884         _DEBUG_INFO("user nextNonce = %s\n", dmaccount->user_nextNonce);
885
886         //if ((acc_info_c->auth_name) == NULL || (acc_info_c->auth_secret) == NULL || (acc_info_c->addr) == NULL) {
887         if ( (acc_info_c->addr) == NULL) {
888                 ret = 0;
889                 goto error;
890         }
891         if (dmaccount->user_id != NULL) {
892                 if(acc_info_c->auth_name != NULL) {
893                         str_free(&(acc_info_c->auth_name));
894                 }
895                 acc_info_c->auth_name = strdup(dmaccount->user_id);
896         }
897         if (dmaccount->user_pw != NULL) {
898                 if(acc_info_c->auth_secret != NULL) {
899                         str_free(&(acc_info_c->auth_secret));
900                 }
901                 acc_info_c->auth_secret = strdup(dmaccount->user_pw);
902         }
903         if (dmaccount->user_auth_type != NULL) {
904                 str_free(&(acc_info_c->auth_type));
905                 acc_info_c->auth_type = strdup(dmaccount->user_auth_type);
906         } else {
907                 if (acc_info_c->auth_type != NULL) {
908                         //do nothing
909                 } else {
910                         acc_info_c->auth_type = strdup("DIGEST");
911                 }
912         }
913
914         if (dmaccount->user_nextNonce != NULL) {
915                 str_free(&(acc_info_c->auth_data));
916                 acc_info_c->auth_data = strdup(dmaccount->user_nextNonce);
917         }
918         //acc_info_c->auth_level = dmaccount->base64;
919         err_code = sync_agent_update_mo_acc_item(&sync_agent_mo_acc_info_item, acc_info_c);
920         //err_code = sync_agent_set_acc_info(pServer_id, DEVICE_MANAGE_ACC_TYPE_CLIENT, acc_info_c);
921         _DEBUG_INFO("sync agent update result : %d", err_code);
922         if (err_code != SYNC_AGENT_DM_MO_SUCCESS) {
923                 ret = COMMON_ERR_IS_NULL;
924                 goto error;
925         }
926         _DEBUG_INFO("set client account result : %d", err_code);
927
928 /*************************************************************************************/
929
930         sync_agent_mo_acc_info_item.acc_type = DEVICE_MANAGE_ACC_TYPE_SERVER;
931         sync_agent_mo_acc_info_item.serverid = pServer_id;
932
933         err_code = sync_agent_get_mo_acc_item(&sync_agent_mo_acc_info_item, &acc_info_s);
934         //acc_info = sync_agent_get_acc_info(pServer_id, DEVICE_MANAGE_ACC_TYPE_CLIENT);
935         if (err_code != SYNC_AGENT_DM_MO_SUCCESS || acc_info_s == NULL) {
936                 _DEBUG_INFO(" acc null!!\n");
937                 ret = COMMON_ERR_IS_NULL;
938                 goto error;
939         }
940
941         _DEBUG_INFO("server id = %s\n", dmaccount->server_url);
942         _DEBUG_INFO("server id = %s\n", dmaccount->server_id);
943         _DEBUG_INFO("sever pwd = %s\n", dmaccount->server_pw);
944         _DEBUG_INFO("server auth type = %s\n", dmaccount->server_auth_type);
945         _DEBUG_INFO("server nextNonce = %s\n", dmaccount->server_nextNonce);
946
947         //if ((acc_info_s->auth_name) == NULL || (acc_info_s->auth_secret) == NULL || (acc_info_s->addr) == NULL) {
948         if ((acc_info_s->auth_name) == NULL || (acc_info_s->addr) == NULL) {
949                 ret = 0;
950                 goto error;
951         }
952
953         if (dmaccount->server_url != NULL) {
954                 str_free(&(acc_info_s->addr));
955                 acc_info_s->addr = strdup(dmaccount->server_url);
956         }
957         if (dmaccount->server_id != NULL) {
958                 str_free(&(acc_info_s->auth_name));
959                 acc_info_s->auth_name = strdup(dmaccount->server_id);
960         }
961         if (dmaccount->server_pw != NULL) {
962                 if(acc_info_s->auth_secret != NULL) {
963                         str_free(&(acc_info_s->auth_secret));
964                 }
965                 acc_info_s->auth_secret = strdup(dmaccount->server_pw);
966         }
967         if (dmaccount->server_auth_type != NULL) {
968                 str_free(&(acc_info_s->auth_type));
969                 acc_info_s->auth_type = strdup(dmaccount->server_auth_type);
970         }
971         if (dmaccount->server_nextNonce != NULL) {
972                 str_free(&(acc_info_s->auth_data));
973                 acc_info_s->auth_data = strdup(dmaccount->server_nextNonce);
974         }
975         //acc_info_s->auth_level = dmaccount->base64;
976         err_code = sync_agent_update_mo_acc_item(&sync_agent_mo_acc_info_item, acc_info_s);
977         //err_code = sync_agent_set_acc_info(pServer_id, DEVICE_MANAGE_ACC_TYPE_SERVER, acc_info_s);
978         _DEBUG_INFO("set server account result : %d", err_code);
979         if (err_code != SYNC_AGENT_DM_MO_SUCCESS) {
980                 ret = COMMON_ERR_IS_NULL;
981                 goto error;
982         }
983
984  /*************************************************************************************/
985
986         err_code = sync_agent_end_transaction_mo(SYNC_AGENT_DM_MO_TRANSACTION_COMMIT);
987         _DEBUG_INFO("transanction commit : %d", err_code);
988         sync_agent_close_mo();
989
990         err_code = sync_agent_free_mo_acc_item(&acc_info_c);
991         _DEBUG_INFO("free mo acc  result : %d", err_code);
992
993         err_code = sync_agent_free_mo_acc_item(&acc_info_s);
994         _DEBUG_INFO("free mo acc  result : %d", err_code);
995
996         _EXTERN_FUNC_EXIT;
997         return ret;
998
999  error:
1000         err_code = sync_agent_end_transaction_mo(SYNC_AGENT_DM_MO_TRANSACTION_ROLLBACK);
1001         _DEBUG_INFO("transanction rollback : %d", err_code);
1002         sync_agent_close_mo();
1003
1004         err_code = sync_agent_free_mo_acc_item(&acc_info_c);
1005         _DEBUG_INFO("free mo acc  result : %d", err_code);
1006
1007         err_code = sync_agent_free_mo_acc_item(&acc_info_s);
1008         _DEBUG_INFO("free mo acc  result : %d", err_code);
1009
1010         _DEBUG_INFO(" end!! error : %d\n", ret);
1011         _EXTERN_FUNC_EXIT;
1012         return ret;
1013 }
1014
1015 DM_ERROR get_dmacc_authType(char *pServer_id, AuthType * pAuthType)
1016 {
1017         _EXTERN_FUNC_ENTER;
1018         DM_ERROR ret = DM_OK;
1019
1020         retvm_if((pServer_id) == NULL, COMMON_ERR_IS_NULL, "pServer_id is NULL!!");
1021
1022         sync_agent_dm_mo_error_e err_code = SYNC_AGENT_DM_MO_SUCCESS;
1023         sync_agent_dm_acc_info_s *acc_info = NULL;
1024         sync_agent_dm_mo_acc_item_info_s sync_agent_mo_acc_info_item;
1025
1026         sync_agent_mo_acc_info_item.acc_type = DEVICE_MANAGE_ACC_TYPE_CLIENT;
1027         sync_agent_mo_acc_info_item.serverid = pServer_id;
1028
1029         err_code = sync_agent_get_mo_acc_item(&sync_agent_mo_acc_info_item, &acc_info);
1030         //acc_info = sync_agent_get_acc_info(pServer_id, DEVICE_MANAGE_ACC_TYPE_CLIENT);
1031         if (err_code != SYNC_AGENT_DM_MO_SUCCESS || acc_info == NULL) {
1032                 _DEBUG_INFO(" acc null!!\n");
1033                 ret = COMMON_ERR_IS_NULL;
1034                 goto error;
1035         }
1036
1037         *pAuthType = __get_Session_AuthType_enum(acc_info->auth_type);
1038
1039         _DEBUG_INFO(" end!! auth type : %d\n", *pAuthType);
1040
1041         sync_agent_free_mo_acc_item(&acc_info);
1042
1043         _EXTERN_FUNC_EXIT;
1044         return ret;
1045  error:
1046
1047         ret = COMMON_ERR_MO_NOT_FOUND_IN_DB;
1048         _EXTERN_FUNC_EXIT;
1049         return ret;
1050 }
1051
1052 DM_ERROR get_format(sync_agent_dm_mo_format_e format_enum, char **format)
1053 {
1054         _EXTERN_FUNC_ENTER;
1055         DM_ERROR ret = DM_OK;
1056
1057         switch (format_enum) {
1058         case SYNC_AGENT_DM_MO_FORMAT_NO_SET:
1059                 (*format) = strdup(ELEMENT_NULL);
1060                 break;
1061         case SYNC_AGENT_DM_MO_FORMAT_B64:
1062                 (*format) = strdup(ELEMENT_B64);
1063                 break;
1064         case SYNC_AGENT_DM_MO_FORMAT_BIN:
1065                 (*format) = strdup(ELEMENT_BIN);
1066                 break;
1067         case SYNC_AGENT_DM_MO_FORMAT_BOOL:
1068                 (*format) = strdup(ELEMENT_BOOL);
1069                 break;
1070         case SYNC_AGENT_DM_MO_FORMAT_CHR:
1071                 (*format) = strdup(ELEMENT_CHR);
1072                 break;
1073         case SYNC_AGENT_DM_MO_FORMAT_INT:
1074                 (*format) = strdup(ELEMENT_INT);
1075                 break;
1076         case SYNC_AGENT_DM_MO_FORMAT_NODE:
1077                 (*format) = strdup(ELEMENT_NODE);
1078                 break;
1079         case SYNC_AGENT_DM_MO_FORMAT_NULL:
1080                 (*format) = strdup(ELEMENT_NULL);
1081                 break;
1082         case SYNC_AGENT_DM_MO_FORMAT_XML:
1083                 (*format) = strdup(ELEMENT_XML);
1084                 break;
1085         case SYNC_AGENT_DM_MO_FORMAT_DATE:
1086                 (*format) = strdup(ELEMENT_DATE);
1087                 break;
1088         case SYNC_AGENT_DM_MO_FORMAT_TIME:
1089                 (*format) = strdup(ELEMENT_TIME);
1090                 break;
1091         case SYNC_AGENT_DM_MO_FORMAT_FLOAT:
1092                 (*format) = strdup(ELEMENT_FLOAT);
1093                 break;
1094         default:
1095                 break;
1096         }
1097
1098         _EXTERN_FUNC_EXIT;
1099         return ret;
1100 }
1101
1102 DM_ERROR get_format_enum(char *format, sync_agent_dm_mo_format_e * format_enum)
1103 {
1104         _EXTERN_FUNC_ENTER;
1105         DM_ERROR ret = DM_OK;
1106
1107         retvm_if((format) == NULL, COMMON_ERR_IS_NULL, "format is NULL!!");
1108
1109         if (!strcmp(format, ELEMENT_NULL)) {
1110                 (*format_enum) = SYNC_AGENT_DM_MO_FORMAT_NO_SET;
1111         } else if (!strcmp(format, ELEMENT_B64)) {
1112                 (*format_enum) = SYNC_AGENT_DM_MO_FORMAT_B64;
1113         } else if (!strcmp(format, ELEMENT_BIN)) {
1114                 (*format_enum) = SYNC_AGENT_DM_MO_FORMAT_BIN;
1115         } else if (!strcmp(format, ELEMENT_BOOL)) {
1116                 (*format_enum) = SYNC_AGENT_DM_MO_FORMAT_BOOL;
1117         } else if (!strcmp(format, ELEMENT_CHR)) {
1118                 (*format_enum) = SYNC_AGENT_DM_MO_FORMAT_CHR;
1119         } else if (!strcmp(format, ELEMENT_INT)) {
1120                 (*format_enum) = SYNC_AGENT_DM_MO_FORMAT_INT;
1121         } else if (!strcmp(format, ELEMENT_NODE)) {
1122                 (*format_enum) = SYNC_AGENT_DM_MO_FORMAT_NODE;
1123         } else if (!strcmp(format, ELEMENT_NULL)) {
1124                 (*format_enum) = SYNC_AGENT_DM_MO_FORMAT_NULL;
1125         } else if (!strcmp(format, ELEMENT_XML)) {
1126                 (*format_enum) = SYNC_AGENT_DM_MO_FORMAT_XML;
1127         } else if (!strcmp(format, ELEMENT_DATE)) {
1128                 (*format_enum) = SYNC_AGENT_DM_MO_FORMAT_DATE;
1129         } else if (!strcmp(format, ELEMENT_TIME)) {
1130                 (*format_enum) = SYNC_AGENT_DM_MO_FORMAT_TIME;
1131         } else if (!strcmp(format, ELEMENT_FLOAT)) {
1132                 (*format_enum) = SYNC_AGENT_DM_MO_FORMAT_FLOAT;
1133         } else {
1134                 (*format_enum) = SYNC_AGENT_DM_MO_FORMAT_NULL;
1135         }
1136
1137         _EXTERN_FUNC_EXIT;
1138         return ret;
1139 }
1140
1141 /*
1142
1143 DM_ERROR get_contenttype(sync_agent_dm_mo_df_type_e contenttype_enum, char** contenttype)
1144 {
1145         _DEBUG_INFO( " start!!\n");
1146         DM_ERROR ret;
1147
1148         switch(contenttype_enum){
1149         case SYNC_AGENT_DM_MO_DF_TYPE_NO_SET:
1150                 //(*contenttype) = strdup( (*mo_node)->runtime_property->type_value );
1151                 break;
1152         case SYNC_AGENT_DM_MO_DF_TYPE_MIME:
1153                 //(*contenttype) = strdup( (*mo_node)->runtime_property->type_value );
1154                 break;
1155         case SYNC_AGENT_DM_MO_DF_TYPE_DDFNAME:
1156                 //(*contenttype) = strdup( (*mo_node)->runtime_property->type_value );
1157                 break;
1158         default:
1159                 break;
1160         }
1161
1162         _DEBUG_INFO( " end!!\n");
1163 }
1164 */
1165
1166 void reset_dmacc_mscserver()
1167 {
1168         _EXTERN_FUNC_ENTER;
1169
1170         sync_agent_open_mo();
1171         sync_agent_dm_mo_error_e err_code = SYNC_AGENT_DM_MO_SUCCESS;
1172
1173         int is_exist = 0;
1174
1175         err_code = sync_agent_is_exist_mo(DM_DMACC_MSCSERVER, &is_exist);
1176         if (err_code != SYNC_AGENT_DM_MO_SUCCESS) {
1177                 _DEBUG_INFO("exist mo error : %d", err_code);
1178                 _EXTERN_FUNC_EXIT;
1179                 return;
1180         }
1181
1182         if (is_exist != 1) {
1183                 _DEBUG_INFO("dm acc not exist");
1184                 _EXTERN_FUNC_EXIT;
1185                 return;
1186         }
1187
1188         err_code = sync_agent_uptodate_mo_table(SYNC_AGENT_DM_MO_TYPE_DMACC, 5, DM_DMACC_MSCSERVER);
1189         _DEBUG_INFO(" end!!: err_code : %d", err_code);
1190         sync_agent_close_mo();
1191
1192         _EXTERN_FUNC_EXIT;
1193
1194 }
1195
1196 void reset_dmacc_msctestserver()
1197 {
1198         _EXTERN_FUNC_ENTER;
1199
1200         sync_agent_open_mo();
1201         sync_agent_dm_mo_error_e err_code = SYNC_AGENT_DM_MO_SUCCESS;
1202         int is_exist = 0;
1203
1204         err_code = sync_agent_is_exist_mo(DM_DMACC_MSCTESTSERVER, &is_exist);
1205         if (err_code != SYNC_AGENT_DM_MO_SUCCESS) {
1206                 _DEBUG_INFO("exist mo error : %d", err_code);
1207                 _EXTERN_FUNC_EXIT;
1208                 return;
1209         }
1210
1211         if (is_exist != 1) {
1212                 _DEBUG_INFO("dm acc not exist");
1213                 _EXTERN_FUNC_EXIT;
1214                 return;
1215         }
1216
1217         err_code = sync_agent_uptodate_mo_table(SYNC_AGENT_DM_MO_TYPE_DMACC, 6, DM_DMACC_MSCTESTSERVER);
1218         _DEBUG_INFO(" end!!: err_code : %d", err_code);
1219         sync_agent_close_mo();
1220
1221         _EXTERN_FUNC_EXIT;
1222 }
1223
1224 void reset_dmacc_gcf()
1225 {
1226         _EXTERN_FUNC_ENTER;
1227
1228         sync_agent_open_mo();
1229         sync_agent_dm_mo_error_e err_code = SYNC_AGENT_DM_MO_SUCCESS;
1230
1231         int is_exist = 0;
1232
1233         err_code = sync_agent_is_exist_mo(DM_DMACC_GCF, &is_exist);
1234         if (err_code != SYNC_AGENT_DM_MO_SUCCESS) {
1235                 _DEBUG_INFO("exist mo error : %d", err_code);
1236                 _EXTERN_FUNC_EXIT;
1237                 return;
1238         }
1239
1240         if (is_exist != 1) {
1241                 _DEBUG_INFO("dm acc not exist");
1242                 _EXTERN_FUNC_EXIT;
1243                 return;
1244         }
1245
1246         err_code = sync_agent_uptodate_mo_table(SYNC_AGENT_DM_MO_TYPE_DMACC, 4, DM_DMACC_GCF);
1247         _DEBUG_INFO(" end!!: err_code : %d", err_code);
1248         sync_agent_close_mo();
1249
1250         _EXTERN_FUNC_EXIT;
1251 }
1252
1253 void reset_devinfo()
1254 {
1255         _EXTERN_FUNC_ENTER;
1256
1257         sync_agent_dm_mo_error_e err_code = sync_agent_uptodate_mo_table(SYNC_AGENT_DM_MO_TYPE_DEVINFO, 2, DM_DEVINFO);
1258         _DEBUG_INFO(" end!!: err_code : %d", err_code);
1259
1260         _EXTERN_FUNC_EXIT;
1261 }
1262
1263 void reset_devdetail()
1264 {
1265         _EXTERN_FUNC_ENTER;
1266
1267         sync_agent_dm_mo_error_e err_code = sync_agent_uptodate_mo_table(SYNC_AGENT_DM_MO_TYPE_DEVDETAIL, 1, DM_DEVDETAIL);
1268         _DEBUG_INFO(" end!! : err_code : %d", err_code);
1269
1270         _EXTERN_FUNC_EXIT;
1271 }
1272
1273 DM_ERROR get_mo_root_path(const char *mo_full_path, char **root_path)
1274 {
1275         _EXTERN_FUNC_ENTER;
1276
1277         DM_ERROR ret = DM_OK;
1278         char *temp_root = NULL;
1279         sync_agent_dm_mo_error_e err_code = SYNC_AGENT_DM_MO_SUCCESS;
1280
1281         retvm_if((mo_full_path) == NULL, COMMON_ERR_IS_NULL, "mo_full_path is NULL!!");
1282
1283         err_code = sync_agent_get_root_path(mo_full_path, &temp_root);
1284         _DEBUG_INFO("get root path : %d", err_code);
1285         if (err_code != SYNC_AGENT_DM_MO_SUCCESS) {
1286                 _EXTERN_FUNC_EXIT;
1287                 return COMMON_ERR_IS_NULL;
1288         }
1289
1290         _DEBUG_INFO("get root path : %s", temp_root);
1291
1292         if (temp_root != NULL) {
1293                 (*root_path) = strdup(temp_root);
1294                 _DEBUG_INFO(" root : %s\n", (*root_path));
1295         }
1296         _DEBUG_INFO(" root : %s\n", temp_root);
1297         /*root_size = strlen(temp_root) - 2 ;
1298            memcpy( (*root_path), temp_root + 2, root_size); */
1299
1300         if ((*root_path) == NULL) {
1301                 ret = COMMON_ERR_INTERNAL_NOT_DEFINED;
1302                 goto error;
1303         }
1304
1305         _EXTERN_FUNC_EXIT;
1306         return ret;
1307
1308  error:
1309         _DEBUG_INFO(" end!! error : %d\n", ret);
1310         _EXTERN_FUNC_EXIT;
1311         return ret;
1312
1313 }
1314
1315 SERVICE_SERVER_TYPE get_engine_type_by_serverid(const char *server_id)
1316 {
1317         _EXTERN_FUNC_ENTER;
1318
1319         retvm_if((server_id) == NULL, COMMON_ERR_IS_NULL, "server_id is NULL!!");
1320
1321         sync_agent_open_mo();
1322         SERVICE_SERVER_TYPE engine_type = NO_ENGINE_TYPE;
1323         SERVICE_SERVER_TYPE service_engine_type = NO_ENGINE_TYPE;
1324
1325         sync_agent_dm_mo_error_e err_code = SYNC_AGENT_DM_MO_SUCCESS;
1326         err_code = sync_agent_get_server_type(server_id, (int *)(&service_engine_type));
1327         _DEBUG_INFO("get server type result : %d", err_code);
1328         _DEBUG_INFO("service engine type : %d", service_engine_type);
1329         if (service_engine_type != NO_ENGINE_TYPE) {
1330                 //todo change & operation
1331                 if ((service_engine_type & SAMSUNG_FUMO_TYPE) == SAMSUNG_FUMO_TYPE) {
1332                         engine_type = SAMSUNG_FUMO_TYPE;
1333                         _DEBUG_INFO("FUMO SERVICE");
1334                 } else if ((service_engine_type & SAMSUNG_FMM_TYPE) == SAMSUNG_FMM_TYPE) {
1335                         engine_type = SAMSUNG_FMM_TYPE;
1336                         _DEBUG_INFO("LAWMO SERVICE");
1337                 } else if ((service_engine_type & GCF_TYPE) == GCF_TYPE) {
1338                         engine_type = GCF_TYPE;
1339                         _DEBUG_INFO("GCF_TYPE");
1340                 }
1341
1342                 _EXTERN_FUNC_EXIT;
1343                 return engine_type;
1344         } else {
1345                 //error;
1346         }
1347
1348         sync_agent_close_mo();
1349
1350         _EXTERN_FUNC_EXIT;
1351         return NO_ENGINE_TYPE;
1352 }
1353
1354 SERVICE_SERVER_TYPE get_service_type(const char *mo_full_path)
1355 {
1356         //sync_agent_open_mo();
1357         _EXTERN_FUNC_ENTER;
1358
1359         retvm_if((mo_full_path) == NULL, COMMON_ERR_IS_NULL, "mo_full_path is NULL!!");
1360
1361         sync_agent_dm_mo_error_e err_code = SYNC_AGENT_DM_MO_SUCCESS;
1362         sync_agent_dm_mo_type_e engine_type;
1363         err_code = sync_agent_get_mo_type(mo_full_path, &engine_type);
1364         _DEBUG_INFO("get mo type result : %d", err_code);
1365
1366         //sync_agent_close_mo();
1367         _EXTERN_FUNC_EXIT;
1368         return engine_type;
1369 }
1370
1371 DM_ERROR get_Serverid(SERVICE_SERVER_TYPE mo_type, char **server_id)
1372 {
1373         _EXTERN_FUNC_ENTER;
1374
1375         sync_agent_open_mo();
1376         char *temp_server_id = 0;
1377         sync_agent_dm_mo_error_e err_code = SYNC_AGENT_DM_MO_SUCCESS;
1378         err_code = sync_agent_get_serverid(mo_type, &temp_server_id);
1379         _DEBUG_INFO("get server id : %d", err_code);
1380         if (err_code != SYNC_AGENT_DM_MO_SUCCESS) {
1381                 _EXTERN_FUNC_EXIT;
1382                 return COMMON_ERR_IS_NULL;
1383         }
1384
1385         _DEBUG_INFO("get server id : %s", temp_server_id);
1386
1387         if (temp_server_id != NULL) {
1388                 (*server_id) = strdup(temp_server_id);
1389                 str_free(&temp_server_id);
1390         } else {
1391                 _EXTERN_FUNC_EXIT;
1392                 return COMMON_ERR_IS_NULL;
1393         }
1394
1395         //sync_agent_close_mo();
1396         _EXTERN_FUNC_EXIT;
1397         return DM_OK;
1398 }
1399
1400 DM_ERROR get_server_type(char *server_id, int *server_type)
1401 {
1402         _EXTERN_FUNC_ENTER;
1403         retvm_if((server_id) == NULL, COMMON_ERR_IS_NULL, "server id is NULL!!");
1404
1405         DM_ERROR ret = DM_OK;
1406         sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
1407         sync_agent_dm_server_info_s *server_info = NULL;
1408         sync_agent_dm_server_info_s *cursor_ptr = NULL;
1409
1410         err = sync_agent_get_serverinfo(&server_info);
1411         if (err != SYNC_AGENT_DM_MO_SUCCESS) {
1412                 _DEBUG_INFO("get server info : %d", err);
1413                 return COMMON_ERR_IS_NULL;
1414         }
1415
1416         *server_type = SYNC_AGENT_DM_MO_TYPE_NO_TYPE;
1417         cursor_ptr = server_info;
1418
1419         _DEBUG_INFO("server_id : %s", server_id);
1420
1421         while (cursor_ptr != NULL) {
1422                 _DEBUG_INFO("server_id list : %s", cursor_ptr->server_id);
1423                 _DEBUG_INFO("server_type list: %d", cursor_ptr->server_type);
1424
1425                 cursor_ptr = cursor_ptr->next;
1426         }
1427
1428         cursor_ptr = server_info;
1429         while (cursor_ptr != NULL) {
1430                 _DEBUG_INFO("server_id : %s", cursor_ptr->server_id);
1431                 _DEBUG_INFO("server_type : %d", cursor_ptr->server_type);
1432
1433                 if (cursor_ptr->server_id != NULL) {
1434                         if (!strncmp(server_id, cursor_ptr->server_id, strlen(server_id))) {
1435                                 _DEBUG_INFO("server_id : %s", server_id);
1436                                 _DEBUG_INFO("same server type : %d", cursor_ptr->server_type);
1437                                 *server_type = cursor_ptr->server_type;
1438
1439                                 sync_agent_free_serverinfo(server_info);
1440                                 _EXTERN_FUNC_EXIT;
1441                                 return ret;
1442                         } else {
1443                                 _DEBUG_INFO("not same server id");
1444                         }
1445                 }
1446
1447                 cursor_ptr = cursor_ptr->next;
1448         }
1449
1450         sync_agent_free_serverinfo(server_info);
1451
1452         _EXTERN_FUNC_EXIT;
1453         return ret;
1454 }
1455
1456 DM_ERROR add_dm_acc(SERVICE_SERVER_TYPE server_type)
1457 {
1458         _EXTERN_FUNC_ENTER;
1459
1460         DM_ERROR ret = DM_OK;
1461
1462         ret = factory_bootstrap(server_type);
1463         if (ret != DM_OK) {
1464                 _DEBUG_INFO("factory bootstrap fail : %d", ret);
1465         }
1466
1467         _EXTERN_FUNC_EXIT;
1468         return ret;
1469 }
1470
1471 DM_ERROR remove_dm_acc(char *mo_path)
1472 {
1473         _EXTERN_FUNC_ENTER;
1474         DM_ERROR ret = DM_OK;
1475         sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_FAIL;
1476
1477         err = sync_agent_delete_mo_tree_item(mo_path);
1478         _DEBUG_INFO("delete dmacc mo %d", err);
1479         if (err != SYNC_AGENT_DM_MO_SUCCESS) {
1480                 _DEBUG_INFO("delete dmacc mo fail");
1481                 ret = DM_ERR_BOOTSTRAP;
1482         }
1483
1484         _EXTERN_FUNC_EXIT;
1485
1486         return ret;
1487 }
1488
1489 DM_ERROR is_exist_dmacc(SERVICE_SERVER_TYPE dmacc_type, int *is_exist)
1490 {
1491         _EXTERN_FUNC_ENTER;
1492         DM_ERROR ret = DM_OK;
1493         sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_FAIL;
1494         char *mo_path = NULL;
1495
1496         switch (dmacc_type) {
1497         case SAMSUNG_FUMO_TYPE:
1498                 mo_path = DM_DMACC_MSCTESTSERVER;
1499
1500                 break;
1501         case SAMSUNG_FMM_TYPE:
1502                 mo_path = DM_DMACC_MSCSERVER;
1503
1504                 break;
1505         case GCF_TYPE:
1506                 mo_path = DM_DMACC_GCF;
1507
1508                 break;
1509         default:
1510                 break;
1511
1512         }
1513
1514         err = sync_agent_is_exist_mo(mo_path, is_exist);
1515         if (err != SYNC_AGENT_DM_MO_SUCCESS) {
1516                 _DEBUG_INFO("exist dmacc mo fail %d", err);
1517                 ret = COMMON_ERR_NOT_FOUND;
1518         }
1519         _EXTERN_FUNC_EXIT;
1520
1521         return ret;
1522 }