upload tizen1.0 source
[pkgs/o/oma-ds-service.git] / src / ServiceAdapter / ProtocolBinder / oma_ds_protocol_binder.c
1 /*
2  * oma-ds-service
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: JuHak Park <juhaki.park@samsung.com>,
7  *          JuneHyuk Lee <junhyuk7.lee@samsung.com>,
8  *          SunBong Ha <sunbong.ha@samsung.com>
9  *
10  * Licensed under the Apache License, Version 2.0 (the "License");
11  * you may not use this file except in compliance with the License.
12  * You may obtain a copy of the License at
13  *
14  * http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing, software
17  * distributed under the License is distributed on an "AS IS" BASIS,
18  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  * See the License for the specific language governing permissions and
20  * limitations under the License.
21  *
22  */
23
24
25
26
27 /*
28  * For any sort of issue you concern as to this software,
29  * you may use following point of contact.
30  * All resources contributed on this software
31  * are orinigally written by S-Core Inc., a member of Samsung Group.
32  *
33  * SeongWon Shim <seongwon.shim@samsung.com>
34  */
35
36 /**
37  *   @oma_ds_protocol_binder.c
38  *   @version                                                                   0.1
39  *   @brief                                                                             This file is the source file of implementation of callback function for Protocol Binder
40  */
41
42 #include <glib.h>
43 #include <assert.h>     /* TODO : replace this line to fw_assert.h */
44
45 #include "agent-framework/Utility/fw_log.h"
46 #include "agent-framework/NetworkAssistant/protocol_binder/protocol_binder_util.h"
47 #include "ServiceAdapter/ProtocolBinder/oma_ds_protocol_binder.h"
48 #include "ServiceAdapter/SA_Elements_Internal.h"
49 #include "ServiceAdapter/SA_Command_Internal.h"
50 #include "ServiceAdapter/SA_DevInf_Internal.h"
51 #include "ServiceAdapter/SA_Command.h"
52 #include "ServiceAdapter/SA_Elements.h"
53 #include "ServiceAdapter/SA_DevInf.h"
54 #include "ServiceAdapter/SA_Define.h"
55
56 #define LOG_TAG "OMA_DS_BINDER"
57
58 static PROTOCOL_BINDER_ERROR __append_location_to_wbxml_node(Location *pLocation,
59                 protocol_binder *pBinder,       WBXMLTreeNode *parent_node);
60
61 static PROTOCOL_BINDER_ERROR __append_anchor_to_wbxml_node(Anchor *pAnchor,
62                 protocol_binder *pBinder, WBXMLTreeNode *parent_node);
63
64 static PROTOCOL_BINDER_ERROR __append_devinf_contenttype_to_wbxml_node(DevInfContentType *pDevInfContentType,
65                 protocol_binder *pBinder, WBXMLTreeNode *parent_node, char *node);
66
67 static PROTOCOL_BINDER_ERROR __append_cred_to_wbxml_node(Cred *pCred,   protocol_binder *pBinder, WBXMLTreeNode *parent_node) ;
68
69 static PROTOCOL_BINDER_ERROR __oma_ds_binder_devinf_converter_function(protocol_binder *pBinder,
70                                                                                 Content_Ptr pContent, WBXMLTreeNode **ppWbxml_dom_node);
71 static PROTOCOL_BINDER_ERROR __oma_ds_binder_syncml_start_converter_function(protocol_binder *pBinder,
72                                                                                 Content_Ptr pContent, WBXMLTreeNode **ppWbxml_dom_node);
73 static PROTOCOL_BINDER_ERROR __oma_ds_binder_header_converter_function(protocol_binder *pBinder,
74                                                                                 Content_Ptr pContent, WBXMLTreeNode **ppWbxml_dom_node);
75 static PROTOCOL_BINDER_ERROR __oma_ds_binder_final_converter_function(protocol_binder *pBinder,
76                                                                                 Content_Ptr pContent, WBXMLTreeNode **ppWbxml_dom_node);
77 static PROTOCOL_BINDER_ERROR __oma_ds_binder_body_start_converter_function(protocol_binder *pBinder,
78                                                                                 Content_Ptr pContent, WBXMLTreeNode **ppWbxml_dom_node);
79 static PROTOCOL_BINDER_ERROR __oma_ds_binder_status_converter_function(protocol_binder *pBinder,
80                                                                                 Content_Ptr pContent, WBXMLTreeNode **ppWbxml_dom_node);
81 static PROTOCOL_BINDER_ERROR __oma_ds_binder_alert_command_converter_function(protocol_binder *pBinder,
82                                                                                 Content_Ptr pContent, WBXMLTreeNode **ppWbxml_dom_node);
83 static PROTOCOL_BINDER_ERROR __oma_ds_binder_results_command_converter_function(protocol_binder *pBinder,
84                                                                                 Content_Ptr pContent, WBXMLTreeNode **ppWbxml_dom_node);
85 static PROTOCOL_BINDER_ERROR __oma_ds_binder_put_command_converter_function(protocol_binder *pBinder,
86                                                                                 Content_Ptr pContent, WBXMLTreeNode **ppWbxml_dom_node);
87 static PROTOCOL_BINDER_ERROR __oma_ds_binder_get_command_converter_function(protocol_binder *pBinder,
88                                                                                 Content_Ptr pContent, WBXMLTreeNode **ppWbxml_dom_node);
89 static PROTOCOL_BINDER_ERROR __oma_ds_binder_sync_start_command_converter_function(protocol_binder *pBinder,
90                                                                                 Content_Ptr pContent, WBXMLTreeNode **ppWbxml_dom_node);
91 static PROTOCOL_BINDER_ERROR __oma_ds_binder_sync_end_command_converter_function(protocol_binder *pBinder,
92                                                                                 Content_Ptr pContent, WBXMLTreeNode **ppWbxml_dom_node);
93 static PROTOCOL_BINDER_ERROR __oma_ds_binder_add_command_converter_function(protocol_binder *pBinder,
94                                                                                 Content_Ptr pContent, WBXMLTreeNode **ppWbxml_dom_node);
95 static PROTOCOL_BINDER_ERROR __oma_ds_binder_replace_command_converter_function(protocol_binder *pBinder,
96                                                                                 Content_Ptr pContent, WBXMLTreeNode **ppWbxml_dom_node);
97 static PROTOCOL_BINDER_ERROR __oma_ds_binder_delete_command_converter_function(protocol_binder *pBinder,
98                                                                                 Content_Ptr pContent, WBXMLTreeNode **ppWbxml_dom_node);
99 static PROTOCOL_BINDER_ERROR __oma_ds_binder_map_command_converter_function(protocol_binder *pBinder,
100                                                                                 Content_Ptr pContent, WBXMLTreeNode **ppWbxml_dom_node);
101
102 static ProtocolVersion __get_oma_ds_protocol_version(char *verdtd);
103 static DevInfVersion __get_oma_ds_devInf_version(char *verdtd);
104 static DevInfDevTyp __get_oma_ds_devInf_device_type(char *devType);
105 static DevInfContentType *__get_devinf_contenttype(WBXMLTreeNode *node);
106 static Location *_get_location(WBXMLTreeNode *node);
107 static Anchor *_get_anchor(WBXMLTreeNode *node);
108 static Cred *__get_cred(WBXMLTreeNode *node);
109 static Chal *_get_chal(WBXMLTreeNode *node);
110
111 static PROTOCOL_BINDER_ERROR __oma_ds_binder_devinf_reverse_converter_function(Reverse_protocol_binder *pReverse_binder,
112                                                                                                 WBXMLTreeNode *wbxml_dom_node, Content_Ptr *pContent);
113 static PROTOCOL_BINDER_ERROR __oma_ds_binder_header_reverse_converter_function(Reverse_protocol_binder *pReverse_binder,
114                                                                                                 WBXMLTreeNode *wbxml_dom_node, Content_Ptr *pContent);
115 static PROTOCOL_BINDER_ERROR __oma_ds_binder_results_command_reverse_converter_function(Reverse_protocol_binder *pReverse_binder,
116                                                                                                 WBXMLTreeNode *wbxml_dom_node, Content_Ptr *pContent);
117 static PROTOCOL_BINDER_ERROR __oma_ds_binder_put_command_reverse_converter_function(Reverse_protocol_binder *pReverse_binder,
118                                                                                                 WBXMLTreeNode *wbxml_dom_node, Content_Ptr *pContent);
119 static PROTOCOL_BINDER_ERROR __oma_ds_binder_get_command_reverse_converter_function(Reverse_protocol_binder *pReverse_binder,
120                                                                                                 WBXMLTreeNode *wbxml_dom_node, Content_Ptr *pContent);
121 static PROTOCOL_BINDER_ERROR __oma_ds_binder_alert_command_reverse_converter_function(Reverse_protocol_binder *pReverse_binder,
122                                                                                                 WBXMLTreeNode *wbxml_dom_node, Content_Ptr *pContent);
123 static PROTOCOL_BINDER_ERROR __oma_ds_binder_sync_end_command_reverse_converter_function(Reverse_protocol_binder *pReverse_binder,
124                                                                                                 WBXMLTreeNode *wbxml_dom_node, Content_Ptr *pContent);
125 static PROTOCOL_BINDER_ERROR __oma_ds_binder_sync_start_command_reverse_converter_function(Reverse_protocol_binder *pReverse_binder,
126                                                                                                 WBXMLTreeNode *wbxml_dom_node, Content_Ptr *pContent);
127 static PROTOCOL_BINDER_ERROR __oma_ds_binder_add_command_reverse_converter_function(Reverse_protocol_binder *pReverse_binder,
128                                                                                                 WBXMLTreeNode *wbxml_dom_node, Content_Ptr *pContent);
129 static PROTOCOL_BINDER_ERROR __oma_ds_binder_replace_command_reverse_converter_function(Reverse_protocol_binder *pReverse_binder,
130                                                                                                 WBXMLTreeNode *wbxml_dom_node, Content_Ptr *pContent);
131 static PROTOCOL_BINDER_ERROR __oma_ds_binder_delete_command_reverse_converter_function(Reverse_protocol_binder *pReverse_binder,
132                                                                                                 WBXMLTreeNode *wbxml_dom_node, Content_Ptr *pContent);
133 static PROTOCOL_BINDER_ERROR __oma_ds_binder_final_reverse_converter_function(Reverse_protocol_binder *pReverse_binder,
134                                                                                                 WBXMLTreeNode *wbxml_dom_node, Content_Ptr *pContent);
135 static PROTOCOL_BINDER_ERROR __oma_ds_binder_status_reverse_converter_function(Reverse_protocol_binder *pReverse_binder,
136                                                                                                 WBXMLTreeNode *wbxml_dom_node, Content_Ptr *pContent);
137
138
139 /*
140         PE_ADD,
141     PE_DELETE,
142     PE_REPLACE,
143     PE_ALERT,
144     PE_GET,
145     PE_MAP,
146     PE_PUT,
147     PE_RESULTS,
148     PE_STATUS,
149     PE_SYNC_START,
150     PE_SYNC_END,
151     PE_HEADER,
152     PE_FINAL
153
154     PE_COPY,
155     PE_EXEC,
156     PE_SEARCH,
157     PE_SEQUENCE_START,
158     PE_SEQUENCE_END,
159     PE_ATOMIC_START,
160     PE_ATOMIC_END,
161     PE_PUT_GET,
162     PE_CMD_GROUP,
163     PE_GENERIC,
164  */
165 const Binder_function_info oma_ds_binder_function_info[] = {
166                 { PE_SYNCML_START,              "SyncML",                       __oma_ds_binder_syncml_start_converter_function,                                NULL,                                                                                                                                                                                   false},
167                 { PE_SYNCML_END,                "/SyncML",              NULL,                                                                                                                                                           NULL,                                                                                                                                                                                   false},
168                 { PE_HEADER,                            "SyncHdr",                      __oma_ds_binder_header_converter_function,                                              __oma_ds_binder_header_reverse_converter_function,                                              true},
169                 { PE_BODY_START,                        "SyncBody",             __oma_ds_binder_body_start_converter_function,                                  NULL,                                                                                                                                                                                   false},
170                 { PE_BODY_END,                  "/SyncBody",            NULL,                                                                                                                                                           NULL,                                                                                                                                                                                   false},
171                 { PE_FINAL,                                     "Final",                                __oma_ds_binder_final_converter_function,                                                       __oma_ds_binder_final_reverse_converter_function,                                                       true},
172                 { PE_ALERT,                                     "Alert",                                __oma_ds_binder_alert_command_converter_function,                       __oma_ds_binder_alert_command_reverse_converter_function,                       true},
173                 { PE_STATUS,                                    "Status",                       __oma_ds_binder_status_converter_function,                                              __oma_ds_binder_status_reverse_converter_function,                                              true},
174                 { PE_RESULTS_START,     "Results",                      __oma_ds_binder_results_command_converter_function,             __oma_ds_binder_results_command_reverse_converter_function,             false},
175                 { PE_RESULTS_END,               "/Results",             NULL,                                                                                                                                                           NULL,                                                                                                                                                                                   false},
176                 { PE_PUT_START,                 "Put",                          __oma_ds_binder_put_command_converter_function,                 __oma_ds_binder_put_command_reverse_converter_function,                 false},
177                 { PE_PUT_END,                           "/Put",                         NULL,                                                                                                                                                           NULL,                                                                                                                                                                                   false},
178                 { PE_GET,                                               "Get",                          __oma_ds_binder_get_command_converter_function,                 __oma_ds_binder_get_command_reverse_converter_function,                 true},
179                 { PE_SYNC_START,                        "Sync",                         __oma_ds_binder_sync_start_command_converter_function,  __oma_ds_binder_sync_start_command_reverse_converter_function,  false},
180                 { PE_SYNC_END,                  "/Sync",                        __oma_ds_binder_sync_end_command_converter_function,    __oma_ds_binder_sync_end_command_reverse_converter_function,    false},
181                 { PE_ADD,                                               "Add",                          __oma_ds_binder_add_command_converter_function,                 __oma_ds_binder_add_command_reverse_converter_function,                 true},
182                 { PE_REPLACE,                           "Replace",                      __oma_ds_binder_replace_command_converter_function,             __oma_ds_binder_replace_command_reverse_converter_function,             true},
183                 { PE_DELETE,                                    "Delete",                       __oma_ds_binder_delete_command_converter_function,              __oma_ds_binder_delete_command_reverse_converter_function,              true},
184                 { PE_MAP,                                               "Map",                          __oma_ds_binder_map_command_converter_function,                 NULL,                                                                                                                                                                                   true},
185                 { PE_DEVINF,                                    "DevInf",                       __oma_ds_binder_devinf_converter_function,                                              __oma_ds_binder_devinf_reverse_converter_function,                                              true}
186 };
187
188
189
190 static PROTOCOL_BINDER_ERROR __append_location_to_wbxml_node(Location *pLocation,
191                                                                                                                         protocol_binder *pBinder,
192                                                                                                                         WBXMLTreeNode *parent_node)
193 {
194         FW_LOGV("start");
195         PROTOCOL_BINDER_ERROR err = PROTOCOL_BINDER_OK;
196
197         if (pLocation->locURI != NULL) {
198                 WBXMLTreeNode *LocURI = add_child_wbxml_node_using_xml_name_with_text(pBinder,
199                                                                 parent_node, ELEMENT_LOCURI, pLocation->locURI, strlen(pLocation->locURI));
200                 if (LocURI == NULL) {
201                         err = PROTOCOL_BINDER_OUT_OF_MEMORY;
202                         goto error;
203                 }
204         } else {
205                 /* error case */
206         }
207
208         if (pLocation->locName != NULL) {
209                 WBXMLTreeNode *locName = add_child_wbxml_node_using_xml_name_with_text(pBinder,
210                                                         parent_node, ELEMENT_LOCNAME, pLocation->locName, strlen(pLocation->locName));
211                 if (locName == NULL) {
212                         err = PROTOCOL_BINDER_OUT_OF_MEMORY;
213                         goto error;
214                 }
215         }
216
217         FW_LOGV("end");
218         return err;
219
220 error:
221         FW_LOGE("error : %d", err);
222         return err;
223 }
224
225 static PROTOCOL_BINDER_ERROR __append_anchor_to_wbxml_node(Anchor *pAnchor,
226                                                                                                                         protocol_binder *pBinder,
227                                                                                                                         WBXMLTreeNode *parent_node)
228 {
229         FW_LOGV("start");
230         PROTOCOL_BINDER_ERROR err = PROTOCOL_BINDER_OK;
231
232         WBXMLTreeNode *meta_node = add_child_wbxml_node_using_xml_name(pBinder, parent_node, ELEMENT_META);
233         if (meta_node == NULL) {
234                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
235                 goto error;
236         }
237
238         WBXMLTreeNode *anchor_node = add_child_wbxml_node_using_xml_name(pBinder, meta_node, ELEMENT_ANCHOR);
239         if (anchor_node == NULL) {
240                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
241                 goto error;
242         }
243
244         if (pAnchor->lastAnchor) {
245                 WBXMLTreeNode *last_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
246                                 anchor_node, ELEMENT_LAST, pAnchor->lastAnchor, strlen(pAnchor->lastAnchor));
247                 if (last_node == NULL) {
248                         err = PROTOCOL_BINDER_OUT_OF_MEMORY;
249                         goto error;
250                 }
251         }
252
253         if (pAnchor->nextAnchor) {
254                 WBXMLTreeNode *next_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
255                                 anchor_node, ELEMENT_NEXT, pAnchor->nextAnchor, strlen(pAnchor->nextAnchor));
256                 if (next_node == NULL) {
257                         err = PROTOCOL_BINDER_OUT_OF_MEMORY;
258                         goto error;
259                 }
260         }
261
262         FW_LOGV("end");
263         return err;
264
265 error:
266         FW_LOGE("error : %d", err);
267         return err;
268 }
269
270 static PROTOCOL_BINDER_ERROR __append_devinf_contenttype_to_wbxml_node(DevInfContentType *pDevInfContentType,
271                                                                                                                         protocol_binder *pBinder,
272                                                                                                                         WBXMLTreeNode *parent_node,
273                                                                                                                         char *node)
274 {
275         FW_LOGV("start");
276         PROTOCOL_BINDER_ERROR err = PROTOCOL_BINDER_OK;
277         WBXMLTreeNode *xnode = add_child_wbxml_node_using_xml_name(pBinder, parent_node, node);
278         if (xnode == NULL) {
279                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
280                 goto error;
281         }
282
283         WBXMLTreeNode *cttype_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
284                         xnode, "CTType", pDevInfContentType->cttype, strlen(pDevInfContentType->cttype));
285         if (cttype_node == NULL) {
286                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
287                 goto error;
288         }
289
290         WBXMLTreeNode *verct_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
291                         xnode, "VerCT", pDevInfContentType->verct, strlen(pDevInfContentType->verct));
292         if (verct_node == NULL) {
293                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
294                 goto error;
295         }
296
297         FW_LOGV("end");
298         return err;
299
300 error:
301         FW_LOGE("error : %d", err);
302         return err;
303 }
304
305 static PROTOCOL_BINDER_ERROR __append_cred_to_wbxml_node(Cred *pCred,
306                                                                                                                         protocol_binder *pBinder,
307                                                                                                                         WBXMLTreeNode *parent_node)
308 {
309         FW_LOGV("start");
310         PROTOCOL_BINDER_ERROR err = PROTOCOL_BINDER_OK;
311
312         /* check validity */
313         WBXMLTreeNode *cred_node = add_child_wbxml_node_using_xml_name(pBinder, parent_node, ELEMENT_CRED);
314         if (cred_node == NULL) {
315                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
316                 goto error;
317         }
318
319         WBXMLTreeNode *meta_node = add_child_wbxml_node_using_xml_name(pBinder, cred_node, ELEMENT_META);
320         if (meta_node == NULL) {
321                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
322                 goto error;
323         }
324
325
326         WBXMLTreeNode *type_node = NULL;
327
328         switch (pCred->type) {
329         case AUTH_TYPE_BASIC:
330
331                 if (pCred->format == FORMAT_TYPE_BASE64) {
332                         WBXMLTreeNode *format_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
333                                         meta_node, ELEMENT_FORMAT,  ELEMENT_FORMAT_BASE64, strlen(ELEMENT_FORMAT_BASE64));
334                         if (format_node == NULL) {
335                                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
336                                 goto error;
337                         }
338                 }
339
340                 type_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
341                                 meta_node, ELEMENT_TYPE, ELEMENT_AUTH_BASIC, strlen(ELEMENT_AUTH_BASIC));
342                 if (type_node == NULL) {
343                         err = PROTOCOL_BINDER_OUT_OF_MEMORY;
344                         goto error;
345                 }
346
347                 if (pCred->data) {
348                         WBXMLTreeNode *data_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
349                                         cred_node, ELEMENT_DATA,  pCred->data, strlen(pCred->data));
350                         if (data_node == NULL) {
351                                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
352                                 goto error;
353                         }
354                 }
355                 break;
356         case AUTH_TYPE_MD5:
357
358                 if (pCred->format == FORMAT_TYPE_BASE64) {
359                         WBXMLTreeNode *format_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
360                                         meta_node, ELEMENT_FORMAT, ELEMENT_FORMAT_BASE64, strlen(ELEMENT_FORMAT_BASE64));
361                         if (format_node == NULL) {
362                                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
363                                 goto error;
364                         }
365                 }
366
367                 type_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
368                                 meta_node, ELEMENT_TYPE, ELEMENT_AUTH_MD5, strlen(ELEMENT_AUTH_MD5));
369                 if (type_node == NULL) {
370                         err = PROTOCOL_BINDER_OUT_OF_MEMORY;
371                         goto error;
372                 }
373
374                 if (pCred->data) {
375                         WBXMLTreeNode *data_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
376                                         cred_node, ELEMENT_DATA,  pCred->data, strlen(pCred->data));
377                         if (data_node == NULL) {
378                                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
379                                 goto error;
380                         }
381                 }
382                 break;
383         default:
384                 break;
385         }
386
387         FW_LOGV("end");
388         return err;
389
390 error:
391         FW_LOGE("error : %d", err);
392         return err;
393 }
394
395
396 static PROTOCOL_BINDER_ERROR __oma_ds_binder_devinf_converter_function(protocol_binder *pBinder,
397                                                                                                                 Content_Ptr pContent, WBXMLTreeNode **ppWbxml_dom_node)
398 {
399         FW_LOGV("start");
400         PROTOCOL_BINDER_ERROR err = PROTOCOL_BINDER_OK;
401
402         Item *pItem = (Item *)pContent;
403         DevInf *pDevInf = pItem->private.devInf;
404
405         if (pItem) {
406                 WBXMLTreeNode *item_node = create_wbxml_node_using_xml_name(pBinder, ELEMENT_ITEM);
407                 if (item_node == NULL) {
408                         err = PROTOCOL_BINDER_OUT_OF_MEMORY;
409                         goto error;
410                 }
411
412                 WBXMLTreeNode *source_node = add_child_wbxml_node_using_xml_name(pBinder, item_node, ELEMENT_SOURCE);
413                 if (source_node == NULL) {
414                         err = PROTOCOL_BINDER_OUT_OF_MEMORY;
415                         goto error;
416                 }
417
418                 err = __append_location_to_wbxml_node(pItem->source, pBinder, source_node);
419                 if (err != PROTOCOL_BINDER_OK)
420                         goto error;
421
422                 WBXMLTreeNode *data_node = add_child_wbxml_node_using_xml_name(pBinder, item_node, ELEMENT_DATA);
423                 if (data_node == NULL) {
424                         err = PROTOCOL_BINDER_OUT_OF_MEMORY;
425                         goto error;
426                 }
427
428                 /* devinf language setting */
429                 switch_protocol(pBinder, PROTOCOL_SYNCML_DEVINF12);
430                 WBXMLTree *devinf_tree = create_wbxml_tree(pBinder);
431                 if (devinf_tree == NULL) {
432                         err = PROTOCOL_BINDER_OUT_OF_MEMORY;
433                         goto error;
434                 }
435
436                 add_wbxml_tree_to_wbxml_node(data_node, devinf_tree);
437
438                 /* create root node of devinf tree*/
439                 WBXMLTreeNode *devinf_node = create_wbxml_node_using_xml_name(pBinder, ELEMENT_DEVINF);
440                 if (devinf_node == NULL) {
441                         err = PROTOCOL_BINDER_OUT_OF_MEMORY;
442                         goto error;
443                 }
444
445                 set_wbxml_tree_root(devinf_tree, devinf_node);
446
447                 WBXMLTreeNode *verDTD_node = NULL;
448                 switch (pDevInf->version) {
449                 case DEVINF_VERSION_UNKNOWN:
450                         verDTD_node = add_child_wbxml_node_using_xml_name(pBinder, devinf_node, ELEMENT_VERDTD);
451                         break;
452                 case DEVINF_VERSION_10:
453                         verDTD_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
454                                         devinf_node, ELEMENT_VERDTD, ELEMENT_VERDRD_10, strlen(ELEMENT_VERDRD_10));
455                         break;
456                 case DEVINF_VERSION_11:
457                         verDTD_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
458                                         devinf_node, ELEMENT_VERDTD, ELEMENT_VERDRD_11, strlen(ELEMENT_VERDRD_11));
459                         break;
460                 case DEVINF_VERSION_12:
461                         verDTD_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
462                                         devinf_node, ELEMENT_VERDTD, ELEMENT_VERDRD_12, strlen(ELEMENT_VERDRD_12));
463                         break;
464                 }
465
466                 if (verDTD_node == NULL) {
467                         err = PROTOCOL_BINDER_OUT_OF_MEMORY;
468                         goto error;
469                 }
470
471                 WBXMLTreeNode *man_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
472                                 devinf_node, ELEMENT_MAN, pDevInf->manufacturer, strlen(pDevInf->manufacturer));
473                 if (man_node == NULL) {
474                         err = PROTOCOL_BINDER_OUT_OF_MEMORY;
475                         goto error;
476                 }
477
478                 WBXMLTreeNode *mod_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
479                                 devinf_node, ELEMENT_MOD, pDevInf->model, strlen(pDevInf->model));
480                 if (mod_node == NULL) {
481                         err = PROTOCOL_BINDER_OUT_OF_MEMORY;
482                         goto error;
483                 }
484
485
486                 if (pDevInf->oem) {
487                         WBXMLTreeNode *oem_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
488                                         devinf_node, ELEMENT_OEM, pDevInf->oem, strlen(pDevInf->oem));
489                         if (oem_node == NULL) {
490                                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
491                                 goto error;
492                         }
493                 }
494
495                 WBXMLTreeNode *FwV_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
496                                 devinf_node, ELEMENT_FWV, pDevInf->firmwareVersion, strlen(pDevInf->firmwareVersion));
497                 if (FwV_node == NULL) {
498                         err = PROTOCOL_BINDER_OUT_OF_MEMORY;
499                         goto error;
500                 }
501
502                 WBXMLTreeNode *SwV_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
503                                 devinf_node, ELEMENT_SWV, pDevInf->softwareVersion, strlen(pDevInf->softwareVersion));
504                 if (SwV_node == NULL) {
505                         err = PROTOCOL_BINDER_OUT_OF_MEMORY;
506                         goto error;
507                 }
508
509                 WBXMLTreeNode *HwV_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
510                                 devinf_node, ELEMENT_HWV, pDevInf->hardwareVersion, strlen(pDevInf->hardwareVersion));
511                 if (HwV_node == NULL) {
512                         err = PROTOCOL_BINDER_OUT_OF_MEMORY;
513                         goto error;
514                 }
515
516                 WBXMLTreeNode *devID_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
517                                 devinf_node, ELEMENT_DEVID, pDevInf->devid, strlen(pDevInf->devid));
518                 if (devID_node == NULL) {
519                         err = PROTOCOL_BINDER_OUT_OF_MEMORY;
520                         goto error;
521                 }
522
523                 WBXMLTreeNode *devTyp_node = NULL;
524                 switch (pDevInf->devtyp) {
525                 case DEVINF_DEVTYPE_UNKNOWN:
526                         devTyp_node = add_child_wbxml_node_using_xml_name(pBinder, devinf_node, ELEMENT_DEVTYP);
527                         break;
528                 case DEVINF_DEVTYPE_PAGER:
529                         devTyp_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
530                                         devinf_node, ELEMENT_DEVTYP, ELEMENT_PAGER, strlen(ELEMENT_PAGER));
531                         break;
532                 case DEVINF_DEVTYPE_HANDHELD:
533                         devTyp_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
534                                         devinf_node, ELEMENT_DEVTYP, ELEMENT_HANDHELD, strlen(ELEMENT_HANDHELD));
535                         break;
536                 case DEVINF_DEVTYPE_PDA:
537                         devTyp_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
538                                         devinf_node, ELEMENT_DEVTYP, ELEMENT_PDA, strlen(ELEMENT_PDA));
539                         break;
540                 case DEVINF_DEVTYPE_PHONE:
541                         devTyp_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
542                                         devinf_node, ELEMENT_DEVTYP, ELEMENT_PHONE, strlen(ELEMENT_PHONE));
543                         break;
544                 case DEVINF_DEVTYPE_SMARTPHONE:
545                         devTyp_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
546                                         devinf_node, ELEMENT_DEVTYP, ELEMENT_SMARTPHONE, strlen(ELEMENT_SMARTPHONE));
547                         break;
548                 case DEVINF_DEVTYPE_SERVER:
549                         devTyp_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
550                                         devinf_node, ELEMENT_DEVTYP, ELEMENT_SERVER, strlen(ELEMENT_SERVER));
551                         break;
552                 case DEVINF_DEVTYPE_WORKSTATION:
553                         devTyp_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
554                                         devinf_node, ELEMENT_DEVTYP, ELEMENT_WORKSTATION, strlen(ELEMENT_WORKSTATION));
555                         break;
556                 }
557
558                 if (devTyp_node == NULL) {
559                         err = PROTOCOL_BINDER_OUT_OF_MEMORY;
560                         goto error;
561                 }
562
563                 if (pDevInf->supportsUTC) {
564                         WBXMLTreeNode *supportUTC_node = add_child_wbxml_node_using_xml_name(pBinder,
565                                         devinf_node, ELEMENT_UTC);
566                         if (supportUTC_node == NULL) {
567                                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
568                                 goto error;
569                         }
570                 }
571
572                 if (pDevInf->supportsLargeObjs) {
573                         WBXMLTreeNode *supportLargeObjs_node = add_child_wbxml_node_using_xml_name(pBinder,
574                                         devinf_node, ELEMENT_SUPPORTLARGEOBJS);
575                         if (supportLargeObjs_node == NULL) {
576                                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
577                                 goto error;
578                         }
579                 }
580
581                 if (pDevInf->supportsNumberOfChanges) {
582                         WBXMLTreeNode *supportNumberOfChanges_node = add_child_wbxml_node_using_xml_name(pBinder,
583                                         devinf_node, ELEMENT_SUPPORTNUMBEROFCHANGES);
584                         if (supportNumberOfChanges_node == NULL) {
585                                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
586                                 goto error;
587                         }
588                 }
589
590                 GList *datastoreIter = NULL;
591                 DevInfDataStore *devInfDataStore = NULL;
592                 for (datastoreIter = pDevInf->datastores; datastoreIter != NULL; datastoreIter = g_list_next(datastoreIter)) {
593                         devInfDataStore = datastoreIter->data;
594
595                         WBXMLTreeNode *datastore_node = add_child_wbxml_node_using_xml_name(pBinder,
596                                         devinf_node, ELEMENT_DATASTORE);
597                         if (datastore_node == NULL) {
598                                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
599                                 goto error;
600                         }
601
602                         WBXMLTreeNode *sourceRef_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
603                                         datastore_node, ELEMENT_SOURCEREF, devInfDataStore->sourceref, strlen(devInfDataStore->sourceref));
604                         if (sourceRef_node == NULL) {
605                                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
606                                 goto error;
607                         }
608
609                         if (devInfDataStore->displayname) {
610                                 WBXMLTreeNode *displayname_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
611                                                 datastore_node, ELEMENT_DISPLAYNAME, devInfDataStore->displayname, strlen(devInfDataStore->displayname));
612                                 if (displayname_node == NULL) {
613                                         err = PROTOCOL_BINDER_OUT_OF_MEMORY;
614                                         goto error;
615                                 }
616                         }
617
618                         if (devInfDataStore->maxGUIDSize) {
619                                 char *str_maxguidsize = g_strdup_printf("%u", devInfDataStore->maxGUIDSize);
620                                 if (str_maxguidsize == NULL) {
621                                         err = PROTOCOL_BINDER_OUT_OF_MEMORY;
622                                         goto error;
623                                 }
624
625                                 WBXMLTreeNode *maxguidsize_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
626                                                 datastore_node, ELEMENT_MAXGUIDSIZE, str_maxguidsize, strlen(str_maxguidsize));
627
628                                 if (str_maxguidsize != NULL)
629                                         free(str_maxguidsize);
630
631                                 if (maxguidsize_node == NULL) {
632                                         err = PROTOCOL_BINDER_OUT_OF_MEMORY;
633                                         goto error;
634                                 }
635                         }
636
637                         __append_devinf_contenttype_to_wbxml_node(devInfDataStore->rxPref, pBinder,
638                                         datastore_node, ELEMENT_RX_PREF);
639                         if (err != PROTOCOL_BINDER_OK)
640                                 goto error;
641
642
643                         GList *rxIter = NULL;
644                         DevInfContentType *devInfContentType = NULL;
645                         for (rxIter = devInfDataStore->rx; rxIter != NULL; rxIter = g_list_next(rxIter)) {
646                                 devInfContentType = rxIter->data;
647                                 __append_devinf_contenttype_to_wbxml_node(devInfContentType, pBinder,
648                                                 datastore_node, ELEMENT_RX);
649                                 if (err != PROTOCOL_BINDER_OK)
650                                         goto error;
651                         }
652
653                         __append_devinf_contenttype_to_wbxml_node(devInfDataStore->txPref, pBinder,
654                                         datastore_node, ELEMENT_TX_PREF);
655                         if (err != PROTOCOL_BINDER_OK)
656                                 goto error;
657
658
659                         GList *txIter = NULL;
660                         for (txIter = devInfDataStore->tx; txIter != NULL; txIter = g_list_next(txIter)) {
661                                 devInfContentType = txIter->data;
662                                 __append_devinf_contenttype_to_wbxml_node(devInfContentType, pBinder,
663                                                 datastore_node, ELEMENT_TX);
664                                 if (err != PROTOCOL_BINDER_OK)
665                                         goto error;
666
667                         }
668
669                         GList *ctcapIter = NULL;
670                         DevInfCTCap *devInfCTCap = NULL;
671                         for (ctcapIter = devInfDataStore->ctcaps; ctcapIter != NULL;  ctcapIter = g_list_next(ctcapIter)) {
672                                 devInfCTCap = ctcapIter->data;
673
674                                 WBXMLTreeNode *ctcap_node = add_child_wbxml_node_using_xml_name(pBinder,
675                                                 datastore_node, ELEMENT_CTCAP);
676                                 if (ctcap_node == NULL) {
677                                         err = PROTOCOL_BINDER_OUT_OF_MEMORY;
678                                         goto error;
679                                 }
680
681                                 WBXMLTreeNode *cttype_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
682                                                 ctcap_node, ELEMENT_CTTYPE, devInfCTCap->ct->cttype, strlen(devInfCTCap->ct->cttype));
683                                 if (cttype_node == NULL) {
684                                         err = PROTOCOL_BINDER_OUT_OF_MEMORY;
685                                         goto error;
686                                 }
687
688                                 WBXMLTreeNode *verct_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
689                                                 ctcap_node, ELEMENT_VERCT, devInfCTCap->ct->verct, strlen(devInfCTCap->ct->verct));
690                                 if (verct_node == NULL) {
691                                         err = PROTOCOL_BINDER_OUT_OF_MEMORY;
692                                         goto error;
693                                 }
694
695                                 /*TODO FieldLevel*/
696
697                                 GList *propertyIter = NULL;
698                                 DevInfProperty *devInfProperty = NULL;
699                                 for (propertyIter = devInfCTCap->properties; propertyIter != NULL; propertyIter = g_list_next(propertyIter)) {
700                                         devInfProperty = propertyIter->data;
701
702                                         WBXMLTreeNode *property_node = add_child_wbxml_node_using_xml_name(pBinder,
703                                                         ctcap_node, ELEMENT_PROPERTY);
704                                         if (property_node == NULL) {
705                                                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
706                                                 goto error;
707                                         }
708
709                                         WBXMLTreeNode *propname_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
710                                                         property_node, ELEMENT_PROPNAME, devInfProperty->propName, strlen(devInfProperty->propName));
711                                         if (propname_node == NULL) {
712                                                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
713                                                 goto error;
714                                         }
715
716                                         if (devInfProperty->dataType) {
717                                                 WBXMLTreeNode *datatype_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
718                                                                 property_node, ELEMENT_DATATYPE, devInfProperty->dataType, strlen(devInfProperty->dataType));
719                                                 if (datatype_node == NULL) {
720                                                         err = PROTOCOL_BINDER_OUT_OF_MEMORY;
721                                                         goto error;
722                                                 }
723                                         }
724
725                                         if (devInfProperty->maxOccur) {
726                                                 char *str_maxoccur = g_strdup_printf("%u", devInfProperty->maxOccur);
727                                                 if (str_maxoccur == NULL) {
728                                                         err = PROTOCOL_BINDER_OUT_OF_MEMORY;
729                                                         goto error;
730                                                 }
731
732                                                 WBXMLTreeNode *maxoccur_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
733                                                                 property_node, ELEMENT_MAXOCCUR, str_maxoccur, strlen(str_maxoccur));
734
735                                                 if (str_maxoccur != NULL)
736                                                         free(str_maxoccur);
737
738                                                 if (maxoccur_node == NULL) {
739                                                         err = PROTOCOL_BINDER_OUT_OF_MEMORY;
740                                                         goto error;
741                                                 }
742                                         }
743
744                                         if (devInfProperty->maxSize) {
745                                                 char *str_maxsize = g_strdup_printf("%u", devInfProperty->maxSize);
746                                                 if (str_maxsize == NULL) {
747                                                         err = PROTOCOL_BINDER_OUT_OF_MEMORY;
748                                                         goto error;
749                                                 }
750
751                                                 WBXMLTreeNode *maxsize_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
752                                                                 property_node, ELEMENT_MAXSIZE, str_maxsize, strlen(str_maxsize));
753
754                                                 if (str_maxsize != NULL)
755                                                         free(str_maxsize);
756
757                                                 if (maxsize_node == NULL) {
758                                                         err = PROTOCOL_BINDER_OUT_OF_MEMORY;
759                                                         goto error;
760                                                 }
761                                         }
762
763                                         if (devInfProperty->noTruncate) {
764                                                 WBXMLTreeNode *notruncate_node = add_child_wbxml_node_using_xml_name(pBinder,
765                                                                 property_node, ELEMENT_NOTRUNCATE);
766                                                 if (notruncate_node == NULL) {
767                                                         err = PROTOCOL_BINDER_OUT_OF_MEMORY;
768                                                         goto error;
769                                                 }
770                                         }
771
772                                         GList *valenum = NULL;
773                                         char *val = NULL;
774                                         for (valenum = devInfProperty->valEnums; valenum != NULL; valenum = g_list_next(valenum)) {
775                                                 val = valenum->data;
776                                                 WBXMLTreeNode *valenum_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
777                                                                 property_node, ELEMENT_VALENUM, val, strlen(val));
778                                                 if (valenum_node == NULL) {
779                                                         err = PROTOCOL_BINDER_OUT_OF_MEMORY;
780                                                         goto error;
781                                                 }
782                                         }
783
784                                         if (devInfProperty->displayName) {
785                                                 WBXMLTreeNode *displayname_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
786                                                                 property_node, ELEMENT_DISPLAYNAME, devInfProperty->displayName, strlen(devInfProperty->displayName));
787                                                 if (displayname_node == NULL) {
788                                                         err = PROTOCOL_BINDER_OUT_OF_MEMORY;
789                                                         goto error;
790                                                 }
791                                         }
792
793                                         GList *propparamIter = NULL;
794                                         DevInfPropParam *devInfPropParam = NULL;
795                                         for (propparamIter = devInfProperty->propParams; propparamIter != NULL; propparamIter = g_list_next(propparamIter)) {
796                                                 devInfPropParam = propparamIter->data;
797
798                                                 WBXMLTreeNode *propparam_node = add_child_wbxml_node_using_xml_name(pBinder,
799                                                                 property_node, ELEMENT_PROPPARAM);
800                                                 if (propparam_node == NULL) {
801                                                         err = PROTOCOL_BINDER_OUT_OF_MEMORY;
802                                                         goto error;
803                                                 }
804
805                                                 WBXMLTreeNode *paramname_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
806                                                                 propparam_node, ELEMENT_PARAMNAME, devInfPropParam->paramName, strlen(devInfPropParam->paramName));
807                                                 if (paramname_node == NULL) {
808                                                         err = PROTOCOL_BINDER_OUT_OF_MEMORY;
809                                                         goto error;
810                                                 }
811
812                                                 if (devInfPropParam->dataType) {
813                                                         WBXMLTreeNode *datatype_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
814                                                                         propparam_node, ELEMENT_DATATYPE, devInfPropParam->dataType, strlen(devInfPropParam->dataType));
815                                                         if (datatype_node == NULL) {
816                                                                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
817                                                                 goto error;
818                                                         }
819                                                 }
820
821                                                 valenum = NULL;
822                                                 val = NULL;
823                                                 for (valenum = devInfPropParam->valEnums; valenum != NULL; valenum = g_list_next(valenum)) {
824                                                         val = valenum->data;
825                                                         WBXMLTreeNode *valenum_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
826                                                                         propparam_node, ELEMENT_VALENUM, val, strlen(val));
827                                                         if (valenum_node == NULL) {
828                                                                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
829                                                                 goto error;
830                                                         }
831                                                 }
832
833                                                 if (devInfPropParam->displayName) {
834                                                         WBXMLTreeNode *displayname_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
835                                                                         propparam_node, ELEMENT_DISPLAYNAME, devInfPropParam->displayName, strlen(devInfPropParam->displayName));
836                                                         if (displayname_node == NULL) {
837                                                                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
838                                                                 goto error;
839                                                         }
840                                                 }
841                                         }
842                                 }
843                         }
844                         /*TODO DSMem*/
845
846                         if (devInfDataStore->supportsHierarchicalSync) {
847                                 WBXMLTreeNode *supportshierarchicalsync_node = add_child_wbxml_node_using_xml_name(pBinder,
848                                                 datastore_node, ELEMENT_SUPPORTHIERARCHICALSYNC);
849                                 if (supportshierarchicalsync_node == NULL) {
850                                         err = PROTOCOL_BINDER_OUT_OF_MEMORY;
851                                         goto error;
852                                 }
853                         }
854
855                         WBXMLTreeNode *synccap_node = add_child_wbxml_node_using_xml_name(pBinder,
856                                         datastore_node, ELEMENT_SYNCCAP);
857                         if (synccap_node == NULL) {
858                                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
859                                 goto error;
860                         }
861
862                         if (get_devinf_datastore_synccap(devInfDataStore, DEVINF_SYNCTYPE_TWO_WAY)) {
863                                 WBXMLTreeNode *synctype_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
864                                                 synccap_node, ELEMENT_SYNCTYPE, ELEMENT_SYNCTYPE_1, strlen(ELEMENT_SYNCTYPE_1));
865                                 if (synctype_node == NULL) {
866                                         err = PROTOCOL_BINDER_OUT_OF_MEMORY;
867                                         goto error;
868                                 }
869                         }
870                         if (get_devinf_datastore_synccap(devInfDataStore, DEVINF_SYNCTYPE_SLOW_SYNC)) {
871                                 WBXMLTreeNode *synctype_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
872                                                 synccap_node, ELEMENT_SYNCTYPE, ELEMENT_SYNCTYPE_2, strlen(ELEMENT_SYNCTYPE_2));
873                                 if (synctype_node == NULL) {
874                                         err = PROTOCOL_BINDER_OUT_OF_MEMORY;
875                                         goto error;
876                                 }
877                         }
878                         if (get_devinf_datastore_synccap(devInfDataStore, DEVINF_SYNCTYPE_ONE_WAY_FROM_CLIENT)) {
879                                 WBXMLTreeNode *synctype_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
880                                                 synccap_node, ELEMENT_SYNCTYPE, ELEMENT_SYNCTYPE_3, strlen(ELEMENT_SYNCTYPE_3));
881                                 if (synctype_node == NULL) {
882                                         err = PROTOCOL_BINDER_OUT_OF_MEMORY;
883                                         goto error;
884                                 }
885                         }
886                         if (get_devinf_datastore_synccap(devInfDataStore, DEVINF_SYNCTYPE_REFRESH_FROM_CLIENT)) {
887                                 WBXMLTreeNode *synctype_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
888                                                 synccap_node, ELEMENT_SYNCTYPE, ELEMENT_SYNCTYPE_4, strlen(ELEMENT_SYNCTYPE_4));
889                                 if (synctype_node == NULL) {
890                                         err = PROTOCOL_BINDER_OUT_OF_MEMORY;
891                                         goto error;
892                                 }
893                         }
894                         if (get_devinf_datastore_synccap(devInfDataStore, DEVINF_SYNCTYPE_ONE_WAY_FROM_SERVER)) {
895                                 WBXMLTreeNode *synctype_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
896                                                 synccap_node, ELEMENT_SYNCTYPE, ELEMENT_SYNCTYPE_5, strlen(ELEMENT_SYNCTYPE_5));
897                                 if (synctype_node == NULL) {
898                                         err = PROTOCOL_BINDER_OUT_OF_MEMORY;
899                                         goto error;
900                                 }
901                         }
902                         if (get_devinf_datastore_synccap(devInfDataStore, DEVINF_SYNCTYPE_REFRESH_FROM_SERVER)) {
903                                 WBXMLTreeNode *synctype_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
904                                                 synccap_node, ELEMENT_SYNCTYPE, ELEMENT_SYNCTYPE_6, strlen(ELEMENT_SYNCTYPE_6));
905                                 if (synctype_node == NULL) {
906                                         err = PROTOCOL_BINDER_OUT_OF_MEMORY;
907                                         goto error;
908                                 }
909                         }
910                         if (get_devinf_datastore_synccap(devInfDataStore, DEVINF_SYNCTYPE_SERVER_ALERTED_SYNC)) {
911                                 WBXMLTreeNode *synctype_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
912                                                 synccap_node, ELEMENT_SYNCTYPE, ELEMENT_SYNCTYPE_7, strlen(ELEMENT_SYNCTYPE_7));
913                                 if (synctype_node == NULL) {
914                                         err = PROTOCOL_BINDER_OUT_OF_MEMORY;
915                                         goto error;
916                                 }
917                         }
918                         /*TODO filter-rx, filterCap*/
919                 }
920                 undo_switch_protocol(pBinder);
921                 *ppWbxml_dom_node =  item_node;
922         }
923
924         FW_LOGV("end");
925         return err;
926
927 error:
928         FW_LOGE("error : %d", err);
929         return err;
930 }
931
932
933 static PROTOCOL_BINDER_ERROR __oma_ds_binder_syncml_start_converter_function(protocol_binder *pBinder,
934                                                                                                                                         Content_Ptr pContent, WBXMLTreeNode **ppWbxml_dom_node)
935 {
936         FW_LOGV("start");
937         PROTOCOL_BINDER_ERROR err = PROTOCOL_BINDER_OK;
938         WBXMLTreeNode *syncml_node = create_wbxml_node_using_xml_name(pBinder, ELEMENT_SYNCML);
939         if (syncml_node == NULL) {
940                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
941                 goto error;
942         }
943
944         *ppWbxml_dom_node = syncml_node;
945
946         FW_LOGV("end");
947         return err;
948
949 error:
950         FW_LOGE("error :%d", err);
951         return err;
952 }
953
954
955 static PROTOCOL_BINDER_ERROR __oma_ds_binder_header_converter_function(protocol_binder *pBinder,
956                                                                                                                                         Content_Ptr pContent, WBXMLTreeNode **ppWbxml_dom_node)
957 {
958         FW_LOGV("start");
959         PROTOCOL_BINDER_ERROR err = PROTOCOL_BINDER_OK;
960         SyncHdr *pSyncHdr = (SyncHdr *)pContent;
961
962         /* add SyncHdr, VerDTD, VerProto node */
963         WBXMLTreeNode *synchdr_node = create_wbxml_node_using_xml_name(pBinder, ELEMENT_SYNCHDR);
964         if (synchdr_node == NULL) {
965                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
966                 goto error;
967         }
968
969
970         char *verDTD = ELEMENT_VERDTD;
971         char *verProto = ELEMENT_VERPROTO;
972
973         char *verDTD_data = NULL;
974         char *verProto_data = NULL;
975         if (pSyncHdr->version == VERSION_10) {
976                 verDTD_data = ELEMENT_VERDRD_10;
977                 verProto_data = ELEMENT_VERPROTO_10;
978         } else if (pSyncHdr->version == VERSION_11) {
979                 verDTD_data = ELEMENT_VERDRD_11;
980                 verProto_data = ELEMENT_VERPROTO_11;
981         } else if (pSyncHdr->version == VERSION_12) {
982                 verDTD_data = ELEMENT_VERDRD_12;
983                 verProto_data = ELEMENT_VERPROTO_12;
984         }
985
986         if (verDTD_data == NULL || verProto_data  == NULL) {
987                 err = PROTOCOL_BINDER_NOT_DEFINED;
988                 goto error;
989         }
990
991         WBXMLTreeNode *verdtd_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
992                         synchdr_node, verDTD, verDTD_data, strlen(verDTD_data));
993         if (verdtd_node == NULL) {
994                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
995                 goto error;
996         }
997
998         WBXMLTreeNode *verProto_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
999                         synchdr_node, verProto, verProto_data, strlen(verProto_data));
1000         if (verProto_node == NULL) {
1001                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
1002                 goto error;
1003         }
1004
1005         /* session ID */
1006         WBXMLTreeNode *sessionID_node = NULL;
1007         if (pSyncHdr->sessionID != NULL)
1008                 sessionID_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
1009                                 synchdr_node, ELEMENT_SESSIONID, pSyncHdr->sessionID, strlen(pSyncHdr->sessionID));
1010         else
1011                 sessionID_node = add_child_wbxml_node_using_xml_name(pBinder,
1012                                 synchdr_node, ELEMENT_SESSIONID);
1013
1014         if (sessionID_node == NULL) {
1015                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
1016                 goto error;
1017         }
1018
1019         /* msgID */
1020         char *msgID_data = g_strdup_printf("%u", pSyncHdr->messageID);
1021         if (msgID_data == NULL) {
1022                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
1023                 goto error;
1024         }
1025
1026         WBXMLTreeNode *msgID_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
1027                         synchdr_node, ELEMENT_MSGID, msgID_data, strlen(msgID_data));
1028
1029         if (msgID_data != NULL)
1030                 free(msgID_data);
1031
1032         if (msgID_node == NULL) {
1033                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
1034                 goto error;
1035         }
1036
1037         WBXMLTreeNode *target_node = add_child_wbxml_node_using_xml_name(pBinder,
1038                         synchdr_node, ELEMENT_TARGET);
1039         if (target_node == NULL) {
1040                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
1041                 goto error;
1042         }
1043
1044         err = __append_location_to_wbxml_node(pSyncHdr->target, pBinder, target_node);
1045         if (err != PROTOCOL_BINDER_OK)
1046                 goto error;
1047
1048
1049         WBXMLTreeNode *source_node = add_child_wbxml_node_using_xml_name(pBinder,
1050                         synchdr_node, ELEMENT_SOURCE);
1051         if (source_node == NULL) {
1052                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
1053                 goto error;
1054         }
1055
1056         err = __append_location_to_wbxml_node(pSyncHdr->source, pBinder, source_node);
1057         if (err != PROTOCOL_BINDER_OK)
1058                 goto error;
1059
1060
1061         if (pSyncHdr->responseURI) {
1062                 WBXMLTreeNode *respuri_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
1063                                 synchdr_node, ELEMENT_RESPURI, pSyncHdr->responseURI, strlen(pSyncHdr->responseURI));
1064                 if (respuri_node == NULL) {
1065                         err = PROTOCOL_BINDER_OUT_OF_MEMORY;
1066                         goto error;
1067                 }
1068         }
1069
1070
1071         if (pSyncHdr->noResponse) {
1072                 WBXMLTreeNode *noResponse_node = add_child_wbxml_node_using_xml_name(pBinder,
1073                                 synchdr_node, ELEMENT_NORESP);
1074                 if (noResponse_node == NULL) {
1075                         err = PROTOCOL_BINDER_OUT_OF_MEMORY;
1076                         goto error;
1077                 }
1078         }
1079
1080
1081         if (pSyncHdr->cred) {
1082                 err = __append_cred_to_wbxml_node(pSyncHdr->cred, pBinder, synchdr_node);
1083                 if (err != PROTOCOL_BINDER_OK)
1084                         goto error;
1085         }
1086
1087
1088         char *meta = ELEMENT_META;
1089         if (pSyncHdr->maxmsgsize != 0 || pSyncHdr->maxobjsize != 0) {
1090                 WBXMLTreeNode *meta_node = add_child_wbxml_node_using_xml_name(pBinder,
1091                                 synchdr_node, meta);
1092                 if (meta_node == NULL) {
1093                         err = PROTOCOL_BINDER_OUT_OF_MEMORY;
1094                         goto error;
1095                 }
1096
1097                 unsigned int maxmsgsize = pSyncHdr->maxmsgsize;
1098                 unsigned int maxobjsize = pSyncHdr->maxobjsize;
1099
1100
1101                 if (maxmsgsize != 0) {
1102                         char *str_maxmsgsize = g_strdup_printf("%u", maxmsgsize);
1103                         if (str_maxmsgsize == NULL) {
1104                                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
1105                                 goto error;
1106                         }
1107
1108                         WBXMLTreeNode *maxmsgsize_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
1109                                         meta_node, ELEMENT_MAXMSGSIZE, str_maxmsgsize, strlen(str_maxmsgsize));
1110                         if (str_maxmsgsize != NULL)
1111                                 free(str_maxmsgsize);
1112
1113                         if (maxmsgsize_node == NULL) {
1114                                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
1115                                 goto error;
1116                         }
1117                 }
1118
1119                 if (maxobjsize != 0) {
1120                         char *str_maxobjsize = g_strdup_printf("%u", maxobjsize);
1121                         if (str_maxobjsize == NULL) {
1122                                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
1123                                 goto error;
1124                         }
1125
1126                         WBXMLTreeNode *maxobjsize_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
1127                                         meta_node, ELEMENT_MAXOBJSIZE, str_maxobjsize, strlen(str_maxobjsize));
1128                         if (str_maxobjsize != NULL)
1129                                 free(str_maxobjsize);
1130
1131                         if (maxobjsize_node == NULL) {
1132                                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
1133                                 goto error;
1134                         }
1135                 }
1136         }
1137
1138         *ppWbxml_dom_node = synchdr_node;
1139
1140         FW_LOGV("end");
1141         return err;
1142
1143 error:
1144         FW_LOGE("error :%d", err);
1145         return err;
1146 }
1147
1148 static PROTOCOL_BINDER_ERROR __oma_ds_binder_final_converter_function(protocol_binder *pBinder,
1149                                                                                                                                                                                                                                 Content_Ptr pContent,
1150                                                                                                                                                                                                                                 WBXMLTreeNode **ppWbxml_dom_node)
1151 {
1152         FW_LOGV("start");
1153         PROTOCOL_BINDER_ERROR err = PROTOCOL_BINDER_OK;
1154
1155         WBXMLTreeNode *final_node = create_wbxml_node_using_xml_name(pBinder, "Final");
1156         if (final_node == NULL) {
1157                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
1158                 goto error;
1159         }
1160
1161         *ppWbxml_dom_node = final_node;
1162
1163         FW_LOGV("end");
1164         return err;
1165
1166 error:
1167         FW_LOGE("error :%d", err);
1168         return err;
1169
1170 }
1171
1172
1173 static PROTOCOL_BINDER_ERROR __oma_ds_binder_body_start_converter_function(protocol_binder *pBinder,
1174                                                                                                                                         Content_Ptr pContent, WBXMLTreeNode **ppWbxml_dom_node)
1175 {
1176         FW_LOGV("start");
1177         PROTOCOL_BINDER_ERROR err = PROTOCOL_BINDER_OK;
1178
1179         WBXMLTreeNode *syncbody_node = create_wbxml_node_using_xml_name(pBinder, ELEMENT_SYNCBODY);
1180         if (syncbody_node == NULL) {
1181                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
1182                 goto error;
1183         }
1184
1185         *ppWbxml_dom_node = syncbody_node;
1186
1187         FW_LOGV("end");
1188         return err;
1189
1190 error:
1191         FW_LOGE("error :%d", err);
1192         return err;
1193 }
1194
1195 static PROTOCOL_BINDER_ERROR __oma_ds_binder_status_converter_function(protocol_binder *pBinder,
1196                                                                                                                                         Content_Ptr pContent, WBXMLTreeNode **ppWbxml_dom_node)
1197 {
1198         FW_LOGV("start");
1199         PROTOCOL_BINDER_ERROR err = PROTOCOL_BINDER_OK;
1200
1201         Status *pStatus = (Status *)pContent;
1202         assert(pStatus != NULL);
1203
1204         CommandType type = pStatus->type;
1205
1206         char *str_cmdID = NULL;
1207         char *str_msgRef = NULL;
1208         char *str_cmdRef = NULL;
1209
1210         WBXMLTreeNode *status_node = create_wbxml_node_using_xml_name(pBinder, ELEMENT_STATUS);
1211         if (status_node == NULL) {
1212                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
1213                 goto error;
1214         }
1215
1216         unsigned int cmdID = pStatus->cmdID;
1217         str_cmdID = g_strdup_printf("%u", cmdID);
1218         if (str_cmdID == NULL) {
1219                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
1220                 goto error;
1221         }
1222
1223         WBXMLTreeNode *cmdid_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
1224                         status_node, ELEMENT_CMDID, str_cmdID, strlen(str_cmdID));
1225         if (cmdid_node == NULL) {
1226                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
1227                 goto error;
1228         }
1229
1230         unsigned int msgRef = pStatus->msgRef;
1231         str_msgRef = g_strdup_printf("%u", msgRef);
1232         if (str_msgRef == NULL) {
1233                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
1234                 goto error;
1235         }
1236
1237         WBXMLTreeNode *msgref_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
1238                         status_node, ELEMENT_MSGREF, str_msgRef, strlen(str_msgRef));
1239         if (msgref_node == NULL) {
1240                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
1241                 goto error;
1242         }
1243
1244         unsigned int cmdRef = pStatus->cmdRef;
1245         str_cmdRef = g_strdup_printf("%u", cmdRef);
1246         if (str_cmdRef == NULL) {
1247                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
1248                 goto error;
1249         }
1250
1251         WBXMLTreeNode *cmdref_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
1252                         status_node, ELEMENT_CMDREF, str_cmdRef, strlen(str_cmdRef));
1253         if (cmdref_node == NULL) {
1254                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
1255                 goto error;
1256         }
1257
1258         char *str_command = NULL;
1259         switch (type) {
1260         case COMMAND_TYPE_ALERT:
1261                 {
1262                         str_command = ELEMENT_ALERT;
1263                 }
1264                 break;
1265         case COMMAND_TYPE_SYNC_START:
1266                 {
1267                         str_command = ELEMENT_SYNC;
1268                 }
1269                 break;
1270         case COMMAND_TYPE_PUT:
1271                 {
1272                         str_command = ELEMENT_PUT;
1273                 }
1274                 break;
1275         case COMMAND_TYPE_HEADER:
1276                 {
1277                         str_command = ELEMENT_SYNCHDR;
1278                 }
1279                 break;
1280         case COMMAND_TYPE_ADD:
1281                 {
1282                         str_command = ELEMENT_ADD;
1283                 }
1284                 break;
1285         case COMMAND_TYPE_REPLACE:
1286                 {
1287                         str_command = ELEMENT_REPLACE;
1288                 }
1289                 break;
1290         case COMMAND_TYPE_DELETE:
1291                 {
1292                         str_command = ELEMENT_DELETE;
1293                 }
1294                 break;
1295         case COMMAND_TYPE_MAP:
1296                 {
1297                         str_command = ELEMENT_MAP;
1298                 }
1299                 break;
1300         case COMMAND_TYPE_GET:
1301                 {
1302                         str_command = ELEMENT_GET;
1303                 }
1304                 break;
1305         case COMMAND_TYPE_RESULTS:
1306                 {
1307                         str_command = ELEMENT_RESULTS;
1308                 }
1309                 break;
1310         default:
1311                 break;
1312         }
1313
1314         if (str_command == NULL) {
1315                 err = PROTOCOL_BINDER_NOT_DEFINED;
1316                 goto error;
1317         }
1318
1319         WBXMLTreeNode *command_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
1320                         status_node, ELEMENT_CMD, str_command, strlen(str_command));
1321         if (command_node == NULL) {
1322                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
1323                 goto error;
1324         }
1325
1326         if (pStatus->targetRef) {
1327                 WBXMLTreeNode *targetref_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
1328                                 status_node, ELEMENT_TARGETREF, pStatus->targetRef->locURI, strlen(pStatus->targetRef->locURI));
1329                 if (targetref_node == NULL) {
1330                         err = PROTOCOL_BINDER_OUT_OF_MEMORY;
1331                         goto error;
1332                 }
1333         }
1334
1335         if (pStatus->sourceRef) {
1336                 WBXMLTreeNode *sourceref_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
1337                                 status_node, ELEMENT_SOURCEREF, pStatus->sourceRef->locURI, strlen(pStatus->sourceRef->locURI));
1338                 if (sourceref_node == NULL) {
1339                         err = PROTOCOL_BINDER_OUT_OF_MEMORY;
1340                         goto error;
1341                 }
1342         }
1343
1344         if (pStatus->cred) {
1345                 err = __append_cred_to_wbxml_node(pStatus->cred, pBinder, status_node);
1346                 if (err != PROTOCOL_BINDER_OK)
1347                         goto error;
1348         }
1349
1350         if (pStatus->chal) {
1351                         /*TODO chal*/
1352         }
1353
1354         WBXMLTreeNode *data_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
1355                         status_node, ELEMENT_DATA, pStatus->data, strlen(pStatus->data));
1356         if (data_node == NULL) {
1357                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
1358                 goto error;
1359         }
1360
1361         if (type == COMMAND_TYPE_ALERT) {
1362                 if (pStatus->item) {
1363                         WBXMLTreeNode *item_node = add_child_wbxml_node_using_xml_name(pBinder,
1364                                         status_node, ELEMENT_ITEM);
1365                         if (item_node == NULL) {
1366                                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
1367                                 goto error;
1368                         }
1369
1370                         WBXMLTreeNode *item_data_node = add_child_wbxml_node_using_xml_name(pBinder,
1371                                         item_node, ELEMENT_DATA);
1372                         if (item_data_node == NULL) {
1373                                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
1374                                 goto error;
1375                         }
1376
1377                         WBXMLTreeNode *item_data_Anchor_node = add_child_wbxml_node_using_xml_name(pBinder,
1378                                         item_data_node, ELEMENT_ANCHOR);
1379                         if (item_data_Anchor_node == NULL) {
1380                                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
1381                                 goto error;
1382                         }
1383
1384                         if (pStatus->item->anchor) {
1385                                 WBXMLTreeNode *item_data_Anchor_Next_node =
1386                                                 add_child_wbxml_node_using_xml_name_with_text(pBinder,
1387                                                                 item_data_Anchor_node, ELEMENT_NEXT, pStatus->item->anchor->nextAnchor,
1388                                                                 strlen(pStatus->item->anchor->nextAnchor));
1389
1390                                 if (item_data_Anchor_Next_node == NULL) {
1391                                         err = PROTOCOL_BINDER_OUT_OF_MEMORY;
1392                                         goto error;
1393                                 }
1394                         }
1395                 }
1396         }
1397
1398         if (str_cmdID != NULL)
1399                 free(str_cmdID);
1400
1401         if (str_cmdRef != NULL)
1402                 free(str_cmdRef);
1403
1404         if (str_msgRef != NULL)
1405                 free(str_msgRef);
1406
1407         *ppWbxml_dom_node = status_node;
1408
1409         FW_LOGV("end");
1410         return err;
1411
1412 error:
1413
1414         if (str_cmdID != NULL)
1415                 free(str_cmdID);
1416
1417         if (str_cmdRef != NULL)
1418                 free(str_cmdRef);
1419
1420         if (str_msgRef != NULL)
1421                 free(str_msgRef);
1422
1423         FW_LOGE("error :%d", err);
1424         return err;
1425
1426 }
1427
1428 static PROTOCOL_BINDER_ERROR __oma_ds_binder_alert_command_converter_function(protocol_binder *pBinder,
1429                                                                                                                                                                 Content_Ptr pContent, WBXMLTreeNode **ppWbxml_dom_node)
1430 {
1431         FW_LOGV("start");
1432         PROTOCOL_BINDER_ERROR err = PROTOCOL_BINDER_OK;
1433
1434         Command *pCommand = (Command *)pContent;
1435
1436         CommandAlertPrivate *pAlert = (CommandAlertPrivate *)(&(pCommand->private));
1437
1438         char *str_cmdID = NULL;
1439         char *str_alert_type  = NULL;
1440
1441         if (!pAlert) {
1442                 err = PROTOCOL_BINDER_NOT_DEFINED;
1443                 goto error;
1444         }
1445
1446         if (pAlert->type == ALERT_UNKNOWN) {
1447                 /* error case */
1448                 err = PROTOCOL_BINDER_INVALID_INPUT_PARAMETER;
1449                 goto error;
1450         }
1451
1452         WBXMLTreeNode *alert_node = create_wbxml_node_using_xml_name(pBinder, ELEMENT_ALERT);
1453         if (alert_node == NULL) {
1454                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
1455                 goto error;
1456         }
1457
1458         str_cmdID = g_strdup_printf("%u", pCommand->cmdID);
1459         if (str_cmdID == NULL) {
1460                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
1461                 goto error;
1462         }
1463
1464         WBXMLTreeNode *cmdid_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
1465                         alert_node, ELEMENT_CMDID, str_cmdID, strlen(str_cmdID));
1466         if (cmdid_node == NULL) {
1467                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
1468                 goto error;
1469         }
1470
1471         if (pCommand->noResp) {
1472                 WBXMLTreeNode *noResp_node = add_child_wbxml_node_using_xml_name(pBinder,
1473                                 alert_node, ELEMENT_NORESP);
1474                 if (noResp_node == NULL) {
1475                         err = PROTOCOL_BINDER_OUT_OF_MEMORY;
1476                         goto error;
1477                 }
1478         }
1479
1480         if (pCommand->cred) {
1481                 err = __append_cred_to_wbxml_node(pCommand->cred, pBinder, alert_node);
1482                 if (err != PROTOCOL_BINDER_OK)
1483                         goto error;
1484         }
1485
1486         str_alert_type = g_strdup_printf("%u",  pAlert->type);
1487         if (str_alert_type == NULL) {
1488                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
1489                 goto error;
1490         }
1491
1492         WBXMLTreeNode *data_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
1493                         alert_node, ELEMENT_DATA, str_alert_type, strlen(str_alert_type));
1494         if (data_node == NULL) {
1495                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
1496                 goto error;
1497         }
1498
1499         /* item */
1500         if (pCommand->source != NULL && pCommand->target != NULL) {
1501                 WBXMLTreeNode *item_node = add_child_wbxml_node_using_xml_name(pBinder,
1502                                 alert_node, ELEMENT_ITEM);
1503                 if (item_node == NULL) {
1504                         err = PROTOCOL_BINDER_OUT_OF_MEMORY;
1505                         goto error;
1506                 }
1507
1508                 WBXMLTreeNode *target_node = add_child_wbxml_node_using_xml_name(pBinder,
1509                                 item_node, ELEMENT_TARGET);
1510                 if (target_node == NULL) {
1511                         err = PROTOCOL_BINDER_OUT_OF_MEMORY;
1512                         goto error;
1513                 }
1514
1515                 err = __append_location_to_wbxml_node(pCommand->target, pBinder, target_node);
1516                 if (err != PROTOCOL_BINDER_OK)
1517                         goto error;
1518
1519
1520                 WBXMLTreeNode *source_node = add_child_wbxml_node_using_xml_name(pBinder,
1521                                 item_node, ELEMENT_SOURCE);
1522                 if (source_node == NULL) {
1523                         err = PROTOCOL_BINDER_OUT_OF_MEMORY;
1524                         goto error;
1525                 }
1526
1527                 err = __append_location_to_wbxml_node(pCommand->source, pBinder, source_node);
1528                 if (err != PROTOCOL_BINDER_OK)
1529                         goto error;
1530
1531
1532                 if (pAlert->anchor != NULL) {
1533                         err = __append_anchor_to_wbxml_node(pAlert->anchor, pBinder, item_node);
1534                         if (err != PROTOCOL_BINDER_OK)
1535                                 goto error;
1536                 }
1537         }
1538
1539         if (str_cmdID != NULL)
1540                 free(str_cmdID);
1541
1542         if (str_alert_type != NULL)
1543                 free(str_alert_type);
1544
1545         *ppWbxml_dom_node = alert_node;
1546
1547         FW_LOGV("end");
1548         return err;
1549
1550 error:
1551
1552         if (str_cmdID != NULL)
1553                 free(str_cmdID);
1554
1555         if (str_alert_type != NULL)
1556                 free(str_alert_type);
1557
1558         FW_LOGE("error :%d", err);
1559         return err;
1560 }
1561
1562 static PROTOCOL_BINDER_ERROR __oma_ds_binder_results_command_converter_function(protocol_binder *pBinder,
1563                                                                                                                                                                 Content_Ptr pContent, WBXMLTreeNode **ppWbxml_dom_node)
1564 {
1565         FW_LOGV("start");
1566         PROTOCOL_BINDER_ERROR err = PROTOCOL_BINDER_OK;
1567
1568         Command *pCommand = (Command *)pContent;
1569         CommandResultsPrivate *pResults = (CommandResultsPrivate *)(&(pCommand->private));
1570
1571         char *str_cmdID = NULL;
1572         char *str_cmdRef  = NULL;
1573         char *str_msgRef = NULL;
1574
1575         if (!pResults) {
1576                 err = PROTOCOL_BINDER_NOT_DEFINED;
1577                 goto error;
1578         }
1579
1580         if (pResults->item == NULL) {
1581                 err = PROTOCOL_BINDER_NOT_DEFINED;
1582                 goto error;
1583         }
1584
1585         char *content_type = (pResults->item)->contenttype;
1586         if (!content_type) {
1587                 /* error case */
1588                 err = PROTOCOL_BINDER_NOT_DEFINED;
1589                 goto error;
1590         }
1591
1592
1593         WBXMLTreeNode *results_node = create_wbxml_node_using_xml_name(pBinder, ELEMENT_RESULTS);
1594         if (results_node == NULL) {
1595                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
1596                 goto error;
1597         }
1598
1599         str_cmdID = g_strdup_printf("%u", pCommand->cmdID);
1600         if (str_cmdID != NULL) {
1601                 WBXMLTreeNode *cmdid_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
1602                                 results_node, ELEMENT_CMDID, str_cmdID, strlen(str_cmdID));
1603                 if (cmdid_node == NULL) {
1604                         err = PROTOCOL_BINDER_OUT_OF_MEMORY;
1605                         goto error;
1606                 }
1607         }
1608
1609
1610         if (pResults->msgRef) {
1611                 str_msgRef = g_strdup_printf("%u", pResults->msgRef);
1612                 if (str_msgRef == NULL) {
1613                         err = PROTOCOL_BINDER_OUT_OF_MEMORY;
1614                         goto error;
1615                 }
1616
1617                 WBXMLTreeNode *msgref_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
1618                                 results_node, ELEMENT_MSGREF, str_msgRef, strlen(str_msgRef));
1619                 if (msgref_node == NULL) {
1620                         err = PROTOCOL_BINDER_OUT_OF_MEMORY;
1621                         goto error;
1622                 }
1623         }
1624
1625         str_cmdRef = g_strdup_printf("%u", pResults->cmdRef);
1626         if (str_cmdRef == NULL) {
1627                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
1628                 goto error;
1629         }
1630
1631         WBXMLTreeNode *msgref_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
1632                         results_node, ELEMENT_CMDREF, str_cmdRef, strlen(str_cmdRef));
1633         if (msgref_node == NULL) {
1634                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
1635                 goto error;
1636         }
1637
1638         if (content_type) {
1639                 WBXMLTreeNode *meta_node = add_child_wbxml_node_using_xml_name(pBinder,
1640                                 results_node, ELEMENT_META);
1641                 if (meta_node == NULL) {
1642                         err = PROTOCOL_BINDER_OUT_OF_MEMORY;
1643                         goto error;
1644                 }
1645
1646                 WBXMLTreeNode *type_node  = add_child_wbxml_node_using_xml_name_with_text(pBinder,
1647                                 meta_node, ELEMENT_TYPE, content_type, strlen(content_type));
1648                 if (type_node == NULL) {
1649                         err = PROTOCOL_BINDER_OUT_OF_MEMORY;
1650                         goto error;
1651                 }
1652         }
1653
1654         if (pResults->targetRef) {
1655                 WBXMLTreeNode *targetref_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
1656                                 results_node, ELEMENT_TARGETREF, pResults->targetRef->locURI, strlen(pResults->targetRef->locURI));
1657                 if (targetref_node == NULL) {
1658                         err = PROTOCOL_BINDER_OUT_OF_MEMORY;
1659                         goto error;
1660                 }
1661         }
1662
1663         if (str_cmdID != NULL)
1664                 free(str_cmdID);
1665
1666         if (str_cmdRef != NULL)
1667                 free(str_cmdRef);
1668
1669         if (str_msgRef != NULL)
1670                 free(str_msgRef);
1671
1672         *ppWbxml_dom_node = results_node;
1673
1674         FW_LOGV("end");
1675         return err;
1676
1677 error:
1678
1679         if (str_cmdID != NULL)
1680                 free(str_cmdID);
1681
1682         if (str_cmdRef != NULL)
1683                 free(str_cmdRef);
1684
1685         if (str_msgRef != NULL)
1686                 free(str_msgRef);
1687
1688         FW_LOGE("error :%d", err);
1689         return err;
1690 }
1691
1692
1693 static PROTOCOL_BINDER_ERROR __oma_ds_binder_put_command_converter_function(protocol_binder *pBinder,
1694                                                                                                                                         Content_Ptr pContent, WBXMLTreeNode **ppWbxml_dom_node)
1695 {
1696         FW_LOGV("start");
1697         PROTOCOL_BINDER_ERROR err = PROTOCOL_BINDER_OK;
1698
1699         Command *pCommand = (Command *)pContent;
1700         CommandAccessPrivate *pAccess = (CommandAccessPrivate *)(&(pCommand->private));
1701         char *str_cmdID = NULL;
1702
1703         if (!pAccess) {
1704                 err = PROTOCOL_BINDER_NOT_DEFINED;
1705                 goto error;
1706         }
1707
1708         char *content_type = (pAccess->item)->contenttype;
1709         if (!content_type) {
1710                 /* error case */
1711                 err = PROTOCOL_BINDER_NOT_DEFINED;
1712                 goto error;
1713         }
1714
1715         WBXMLTreeNode *put_node = create_wbxml_node_using_xml_name(pBinder, ELEMENT_PUT);
1716         if (put_node == NULL) {
1717                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
1718                 goto error;
1719         }
1720
1721         str_cmdID = g_strdup_printf("%u", pCommand->cmdID);
1722         if (str_cmdID == NULL) {
1723                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
1724                 goto error;
1725         }
1726
1727         WBXMLTreeNode *cmdid_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
1728                         put_node, ELEMENT_CMDID, str_cmdID, strlen(str_cmdID));
1729         if (cmdid_node == NULL) {
1730                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
1731                 goto error;
1732         }
1733
1734         if (pCommand->noResp) {
1735                 WBXMLTreeNode *noResp_node = add_child_wbxml_node_using_xml_name(pBinder,
1736                                 put_node, ELEMENT_NORESP);
1737                 if (noResp_node == NULL) {
1738                         err = PROTOCOL_BINDER_OUT_OF_MEMORY;
1739                         goto error;
1740                 }
1741         }
1742
1743         if (pCommand->cred) {
1744                 err = __append_cred_to_wbxml_node(pCommand->cred, pBinder, put_node);
1745                 if (err != PROTOCOL_BINDER_OK)
1746                         goto error;
1747         }
1748
1749         if (content_type) {
1750                 WBXMLTreeNode *meta_node = add_child_wbxml_node_using_xml_name(pBinder,
1751                                 put_node, ELEMENT_META);
1752                 if (meta_node == NULL) {
1753                         err = PROTOCOL_BINDER_OUT_OF_MEMORY;
1754                         goto error;
1755                 }
1756
1757                 WBXMLTreeNode *type_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
1758                                 meta_node, ELEMENT_TYPE, content_type, strlen(content_type));
1759                 if (type_node == NULL) {
1760                         err = PROTOCOL_BINDER_OUT_OF_MEMORY;
1761                         goto error;
1762                 }
1763         }
1764
1765         if (str_cmdID != NULL)
1766                 free(str_cmdID);
1767
1768         *ppWbxml_dom_node = put_node;
1769
1770         FW_LOGV("end");
1771         return err;
1772
1773 error:
1774
1775         if (str_cmdID != NULL)
1776                 free(str_cmdID);
1777
1778         FW_LOGE("error :%d", err);
1779         return err;
1780 }
1781
1782 static PROTOCOL_BINDER_ERROR __oma_ds_binder_get_command_converter_function(protocol_binder *pBinder,
1783                                                                                                                                                                                 Content_Ptr pContent, WBXMLTreeNode **ppWbxml_dom_node)
1784 {
1785         FW_LOGV("start");
1786         PROTOCOL_BINDER_ERROR err = PROTOCOL_BINDER_OK;
1787
1788         Command *pCommand = (Command *)pContent;
1789         CommandAccessPrivate *pAccess = (CommandAccessPrivate *)(&(pCommand->private));
1790         char *str_cmdID = NULL;
1791
1792         if (!pAccess) {
1793                 err = PROTOCOL_BINDER_NOT_DEFINED;
1794                 goto error;
1795         }
1796
1797         if (!pAccess->item) {
1798                 err = PROTOCOL_BINDER_NOT_DEFINED;
1799                 goto error;
1800         }
1801
1802         char *content_type = (pAccess->item)->contenttype;
1803
1804         if (!content_type) {
1805                 /* error case */
1806                 err = PROTOCOL_BINDER_NOT_DEFINED;
1807                 goto error;
1808         }
1809
1810         WBXMLTreeNode *get_node = create_wbxml_node_using_xml_name(pBinder, ELEMENT_GET);
1811
1812         str_cmdID = g_strdup_printf("%u", pCommand->cmdID);
1813         if (str_cmdID == NULL) {
1814                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
1815                 goto error;
1816         }
1817
1818         WBXMLTreeNode *cmdid_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
1819                         get_node, ELEMENT_CMDID, str_cmdID, strlen(str_cmdID));
1820         if (cmdid_node == NULL) {
1821                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
1822                 goto error;
1823         }
1824
1825         if (pCommand->noResp) {
1826                 WBXMLTreeNode *noResp_node = add_child_wbxml_node_using_xml_name(pBinder,
1827                                 get_node, ELEMENT_NORESP);
1828                 if (noResp_node == NULL) {
1829                         err = PROTOCOL_BINDER_OUT_OF_MEMORY;
1830                         goto error;
1831                 }
1832         }
1833
1834         if (pCommand->cred) {
1835                 err = __append_cred_to_wbxml_node(pCommand->cred, pBinder, get_node);
1836                 if (err != PROTOCOL_BINDER_OK)
1837                         goto error;
1838         }
1839
1840         if (content_type) {
1841                 WBXMLTreeNode *meta_node = add_child_wbxml_node_using_xml_name(pBinder,
1842                                 get_node, ELEMENT_META);
1843                 if (meta_node == NULL) {
1844                         err = PROTOCOL_BINDER_OUT_OF_MEMORY;
1845                         goto error;
1846                 }
1847
1848                 WBXMLTreeNode *type_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
1849                                 meta_node, ELEMENT_TYPE, content_type, strlen(content_type));
1850                 if (type_node == NULL) {
1851                         err = PROTOCOL_BINDER_OUT_OF_MEMORY;
1852                         goto error;
1853                 }
1854         }
1855
1856         if (pAccess->item) {
1857                 WBXMLTreeNode *item_node = add_child_wbxml_node_using_xml_name(pBinder,
1858                                 get_node, ELEMENT_ITEM);
1859                 if (item_node == NULL) {
1860                         err = PROTOCOL_BINDER_OUT_OF_MEMORY;
1861                         goto error;
1862                 }
1863
1864                 WBXMLTreeNode *target_node = add_child_wbxml_node_using_xml_name(pBinder,
1865                                 item_node, ELEMENT_TARGET);
1866                 if (target_node == NULL) {
1867                         err = PROTOCOL_BINDER_OUT_OF_MEMORY;
1868                         goto error;
1869                 }
1870
1871                 err = __append_location_to_wbxml_node(pAccess->item->target, pBinder, target_node);
1872                 if (err != PROTOCOL_BINDER_OK)
1873                         goto error;
1874         }
1875
1876         *ppWbxml_dom_node = get_node;
1877
1878         if (str_cmdID)
1879                 free(str_cmdID);
1880
1881         FW_LOGV("end");
1882         return err;
1883
1884 error:
1885         if (str_cmdID)
1886                 free(str_cmdID);
1887
1888         FW_LOGE("error :%d", err);
1889         return err;
1890 }
1891
1892 static PROTOCOL_BINDER_ERROR __oma_ds_binder_sync_start_command_converter_function(protocol_binder *pBinder,
1893                                                                                                                                                                                         Content_Ptr pContent, WBXMLTreeNode **ppWbxml_dom_node)
1894 {
1895         FW_LOGV("start");
1896         PROTOCOL_BINDER_ERROR err = PROTOCOL_BINDER_OK;
1897
1898         Command *pCommand = (Command *)pContent;
1899
1900         char *str_cmdID = NULL;
1901         char *numChanged_str  = NULL;
1902
1903         WBXMLTreeNode *sync_node = create_wbxml_node_using_xml_name(pBinder, ELEMENT_SYNC);
1904         if (sync_node == NULL) {
1905                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
1906                 goto error;
1907         }
1908
1909         str_cmdID = g_strdup_printf("%u", pCommand->cmdID);
1910         if (str_cmdID == NULL) {
1911                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
1912                 goto error;
1913         }
1914
1915         WBXMLTreeNode *cmdid_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
1916                         sync_node, ELEMENT_CMDID, str_cmdID, strlen(str_cmdID));
1917         if (cmdid_node == NULL) {
1918                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
1919                 goto error;
1920         }
1921
1922         if (pCommand->noResp) {
1923                 WBXMLTreeNode *noResp_node = add_child_wbxml_node_using_xml_name(pBinder,
1924                                 sync_node, ELEMENT_NORESP);
1925                 if (noResp_node == NULL) {
1926                         err = PROTOCOL_BINDER_OUT_OF_MEMORY;
1927                         goto error;
1928                 }
1929         }
1930
1931         if (pCommand->cred) {
1932                 err = __append_cred_to_wbxml_node(pCommand->cred, pBinder, sync_node);
1933                 if (err != PROTOCOL_BINDER_OK)
1934                         goto error;
1935         }
1936
1937         if (pCommand->source != NULL && pCommand->target != NULL) {
1938                 WBXMLTreeNode *target_node = add_child_wbxml_node_using_xml_name(pBinder,
1939                                 sync_node, ELEMENT_TARGET);
1940                 if (target_node == NULL) {
1941                         err = PROTOCOL_BINDER_OUT_OF_MEMORY;
1942                         goto error;
1943                 }
1944
1945                 err = __append_location_to_wbxml_node(pCommand->target, pBinder, target_node);
1946                 if (err != PROTOCOL_BINDER_OK)
1947                         goto error;
1948
1949
1950                 WBXMLTreeNode *source_node = add_child_wbxml_node_using_xml_name(pBinder,
1951                                 sync_node, ELEMENT_SOURCE);
1952                 if (source_node == NULL) {
1953                         err = PROTOCOL_BINDER_OUT_OF_MEMORY;
1954                         goto error;
1955                 }
1956
1957                 err = __append_location_to_wbxml_node(pCommand->source, pBinder, source_node);
1958                 if (err != PROTOCOL_BINDER_OK)
1959                         goto error;
1960
1961         }
1962
1963         if (pCommand->private.sync.hasNumChanged) {
1964                 numChanged_str = g_strdup_printf("%u", pCommand->private.sync.numChanged);
1965                 if (numChanged_str == NULL) {
1966                         err = PROTOCOL_BINDER_OUT_OF_MEMORY;
1967                         goto error;
1968                 }
1969
1970                 WBXMLTreeNode *numberOfChanges_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
1971                                 sync_node, ELEMENT_NUMBEROFCHANGES, numChanged_str, strlen(numChanged_str));
1972                 if (numberOfChanges_node == NULL) {
1973                         err = PROTOCOL_BINDER_OUT_OF_MEMORY;
1974                         goto error;
1975                 }
1976         }
1977
1978         if (str_cmdID != NULL)
1979                 free(str_cmdID);
1980
1981         if (numChanged_str != NULL)
1982                 free(numChanged_str);
1983
1984         *ppWbxml_dom_node = sync_node;
1985
1986         FW_LOGV("end");
1987         return err;
1988
1989 error:
1990
1991         if (str_cmdID != NULL)
1992                 free(str_cmdID);
1993
1994         if (numChanged_str != NULL)
1995                 free(numChanged_str);
1996
1997         FW_LOGE("error :%d", err);
1998         return err;
1999 }
2000
2001
2002 static PROTOCOL_BINDER_ERROR __oma_ds_binder_sync_end_command_converter_function(protocol_binder *pBinder,
2003                                                                                                                                                                                 Content_Ptr pContent, WBXMLTreeNode **ppWbxml_dom_node)
2004 {
2005         FW_LOGV("start");
2006
2007         PROTOCOL_BINDER_ERROR err = PROTOCOL_BINDER_OK;
2008
2009         FW_LOGV("end");
2010
2011         return err;
2012 }
2013
2014 static PROTOCOL_BINDER_ERROR __oma_ds_binder_add_command_converter_function(protocol_binder *pBinder,
2015                                                                                                                                                                                 Content_Ptr pContent, WBXMLTreeNode **ppWbxml_dom_node)
2016 {
2017         FW_LOGV("start");
2018         PROTOCOL_BINDER_ERROR err = PROTOCOL_BINDER_OK;
2019
2020         char *str_cmdID = NULL;
2021         char *str_size = NULL;
2022
2023         Command *pCommand = (Command *)pContent;
2024
2025         CommandChangePrivate *pChange = (CommandChangePrivate *)(&(pCommand->private));
2026
2027         if (!pChange) {
2028                 err = PROTOCOL_BINDER_NOT_DEFINED;
2029                 goto error;
2030         }
2031
2032         WBXMLTreeNode  *add_node = create_wbxml_node_using_xml_name(pBinder, ELEMENT_ADD);
2033         if (add_node == NULL) {
2034                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
2035                 goto error;
2036         }
2037
2038         str_cmdID = g_strdup_printf("%u", pCommand->cmdID);
2039         if (str_cmdID == NULL) {
2040                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
2041                 goto error;
2042         }
2043
2044         WBXMLTreeNode *cmdid_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
2045                         add_node, ELEMENT_CMDID, str_cmdID, strlen(str_cmdID));
2046         if (cmdid_node == NULL) {
2047                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
2048                 goto error;
2049         }
2050
2051         if (pCommand->noResp) {
2052                 WBXMLTreeNode *noResp_node = add_child_wbxml_node_using_xml_name(pBinder,
2053                                 add_node, ELEMENT_NORESP);
2054                 if (noResp_node == NULL) {
2055                         err = PROTOCOL_BINDER_OUT_OF_MEMORY;
2056                         goto error;
2057                 }
2058         }
2059
2060         if (pCommand->cred) {
2061                 err = __append_cred_to_wbxml_node(pCommand->cred, pBinder, add_node);
2062                 if (err != PROTOCOL_BINDER_OK)
2063                         goto error;
2064         }
2065
2066         GList *Iter = NULL;
2067         Item *item = NULL;
2068         for (Iter = pChange->items; Iter != NULL; Iter = g_list_next(Iter)) {
2069                 item =  (Iter->data);
2070
2071                 WBXMLTreeNode *item_node = add_child_wbxml_node_using_xml_name(pBinder,
2072                                 add_node, ELEMENT_ITEM);
2073                 if (item_node == NULL) {
2074                         err = PROTOCOL_BINDER_OUT_OF_MEMORY;
2075                         goto error;
2076                 }
2077
2078                 if (item->source != NULL) {
2079                         WBXMLTreeNode *source_node = add_child_wbxml_node_using_xml_name(pBinder,
2080                                         item_node, ELEMENT_SOURCE);
2081                         if (source_node == NULL) {
2082                                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
2083                                 goto error;
2084                         }
2085
2086                         err = __append_location_to_wbxml_node(item->source, pBinder, source_node);
2087                         if (err != PROTOCOL_BINDER_OK)
2088                                 goto error;
2089
2090                 }
2091
2092                 if (item->target != NULL) {
2093                         WBXMLTreeNode *target_node = add_child_wbxml_node_using_xml_name(pBinder,
2094                                         item_node, ELEMENT_TARGET);
2095                         if (target_node == NULL) {
2096                                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
2097                                 goto error;
2098                         }
2099
2100                         err = __append_location_to_wbxml_node(item->target, pBinder, target_node);
2101                         if (err != PROTOCOL_BINDER_OK)
2102                                 goto error;
2103                 }
2104
2105                 if (item->contenttype) {
2106                         WBXMLTreeNode *meta_node = add_child_wbxml_node_using_xml_name(pBinder,
2107                                         item_node, ELEMENT_META);
2108                         if (meta_node == NULL) {
2109                                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
2110                                 goto error;
2111                         }
2112
2113                         WBXMLTreeNode *type_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
2114                                         meta_node, ELEMENT_TYPE, item->contenttype, strlen(item->contenttype));
2115                         if (type_node == NULL) {
2116                                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
2117                                 goto error;
2118                         }
2119
2120                         if (item->moreData) {
2121                                 if (item->size) {
2122                                         str_size = g_strdup_printf("%u", item->size);
2123                                         if (str_size == NULL) {
2124                                                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
2125                                                 goto error;
2126                                         }
2127
2128                                         WBXMLTreeNode *size_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
2129                                                         meta_node, ELEMENT_SIZE, str_size, strlen(str_size));
2130                                         if (size_node == NULL) {
2131                                                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
2132                                                 goto error;
2133                                         }
2134                                 }
2135                         }
2136                 }
2137
2138                 if (item->dataType == ITEM_DATA) {
2139                         if (item->private.data) {
2140                                 WBXMLTreeNode *data_node = add_child_wbxml_node_using_xml_name_with_cdata(pBinder,
2141                                                 item_node, ELEMENT_DATA, item->private.data, strlen(item->private.data));
2142                                 if (data_node == NULL) {
2143                                         err = PROTOCOL_BINDER_OUT_OF_MEMORY;
2144                                         goto error;
2145                                 }
2146                         }
2147                 }
2148
2149                 if (item->moreData) {
2150                         WBXMLTreeNode *moredata_node = add_child_wbxml_node_using_xml_name(pBinder,
2151                                         item_node, ELEMENT_MOREDATA);
2152                         if (moredata_node == NULL) {
2153                                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
2154                                 goto error;
2155                         }
2156                 }
2157         }
2158
2159         if (str_cmdID != NULL)
2160                 free(str_cmdID);
2161
2162         if (str_size != NULL)
2163                 free(str_size);
2164
2165         *ppWbxml_dom_node = add_node;
2166
2167         FW_LOGV("end");
2168         return err;
2169
2170 error:
2171
2172         if (str_cmdID != NULL)
2173                 free(str_cmdID);
2174
2175         if (str_size != NULL)
2176                 free(str_size);
2177
2178         FW_LOGE("error :%d", err);
2179         return err;
2180 }
2181
2182 static PROTOCOL_BINDER_ERROR __oma_ds_binder_replace_command_converter_function(protocol_binder *pBinder,
2183                                                                                                                                                                 Content_Ptr pContent, WBXMLTreeNode **ppWbxml_dom_node)
2184 {
2185         FW_LOGV("start");
2186         PROTOCOL_BINDER_ERROR err = PROTOCOL_BINDER_OK;
2187
2188         char *str_cmdID = NULL;
2189         char *str_size = NULL;
2190
2191         Command *pCommand = (Command *)pContent;
2192
2193         CommandChangePrivate *pChange = (CommandChangePrivate *)(&(pCommand->private));
2194
2195         if (!pChange) {
2196                 err = PROTOCOL_BINDER_NOT_DEFINED;
2197                 goto error;
2198         }
2199
2200         WBXMLTreeNode *replace_node = create_wbxml_node_using_xml_name(pBinder, ELEMENT_REPLACE);
2201         if (replace_node == NULL) {
2202                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
2203                 goto error;
2204         }
2205
2206         str_cmdID = g_strdup_printf("%u", pCommand->cmdID);
2207         if (str_cmdID == NULL) {
2208                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
2209                 goto error;
2210         }
2211
2212         WBXMLTreeNode *cmdid_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
2213                         replace_node, ELEMENT_CMDID, str_cmdID, strlen(str_cmdID));
2214         if (cmdid_node == NULL) {
2215                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
2216                 goto error;
2217         }
2218
2219         if (pCommand->noResp) {
2220                 WBXMLTreeNode *noResp_node = add_child_wbxml_node_using_xml_name(pBinder,
2221                                 replace_node, ELEMENT_NORESP);
2222                 if (noResp_node == NULL) {
2223                         err = PROTOCOL_BINDER_OUT_OF_MEMORY;
2224                         goto error;
2225                 }
2226         }
2227
2228         if (pCommand->cred) {
2229                 err = __append_cred_to_wbxml_node(pCommand->cred, pBinder, replace_node);
2230                 if (err != PROTOCOL_BINDER_OK)
2231                         goto error;
2232         }
2233
2234         GList *Iter = NULL;
2235         Item *item = NULL;
2236         for (Iter = pChange->items; Iter != NULL; Iter = g_list_next(Iter)) {
2237                 item =  (Iter->data);
2238
2239                 WBXMLTreeNode *item_node = add_child_wbxml_node_using_xml_name(pBinder,
2240                                 replace_node, ELEMENT_ITEM);
2241                 if (item_node == NULL) {
2242                         err = PROTOCOL_BINDER_OUT_OF_MEMORY;
2243                         goto error;
2244                 }
2245
2246                 if (item->source != NULL) {
2247                         WBXMLTreeNode *source_node = add_child_wbxml_node_using_xml_name(pBinder,
2248                                         item_node, ELEMENT_SOURCE);
2249                         if (source_node == NULL) {
2250                                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
2251                                 goto error;
2252                         }
2253                         err = __append_location_to_wbxml_node(item->source, pBinder, source_node);
2254                         if (err != PROTOCOL_BINDER_OK)
2255                                 goto error;
2256
2257                 }
2258
2259                 if (item->target != NULL) {
2260                         WBXMLTreeNode *target_node = add_child_wbxml_node_using_xml_name(pBinder,
2261                                         item_node, ELEMENT_TARGET);
2262                         if (target_node == NULL) {
2263                                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
2264                                 goto error;
2265                         }
2266                         err = __append_location_to_wbxml_node(item->target, pBinder, target_node);
2267                         if (err != PROTOCOL_BINDER_OK)
2268                                 goto error;
2269
2270                 }
2271
2272                 if (item->contenttype) {
2273                         WBXMLTreeNode *meta_node = add_child_wbxml_node_using_xml_name(pBinder,
2274                                         item_node, ELEMENT_META);
2275                         if (meta_node == NULL) {
2276                                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
2277                                 goto error;
2278                         }
2279
2280                         WBXMLTreeNode *type_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
2281                                         meta_node, ELEMENT_TYPE, item->contenttype, strlen(item->contenttype));
2282                         if (type_node == NULL) {
2283                                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
2284                                 goto error;
2285                         }
2286
2287                         if (item->moreData) {
2288                                 if (item->size) {
2289                                         str_size = g_strdup_printf("%u", item->size);
2290                                         if (str_size == NULL) {
2291                                                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
2292                                                 goto error;
2293                                         }
2294
2295                                         WBXMLTreeNode *size_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
2296                                                         meta_node, ELEMENT_SIZE, str_size, strlen(str_size));
2297                                         if (size_node == NULL) {
2298                                                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
2299                                                 goto error;
2300                                         }
2301                                 }
2302                         }
2303                 }
2304
2305                 if (item->dataType == ITEM_DATA) {
2306                         if (item->private.data) {
2307                                 WBXMLTreeNode *data_node = add_child_wbxml_node_using_xml_name_with_cdata(pBinder,
2308                                                 item_node, ELEMENT_DATA, item->private.data, strlen(item->private.data));
2309                                 if (data_node == NULL) {
2310                                         err = PROTOCOL_BINDER_OUT_OF_MEMORY;
2311                                         goto error;
2312                                 }
2313                         }
2314                 }
2315
2316                 if (item->moreData) {
2317                         WBXMLTreeNode *moredata_node = add_child_wbxml_node_using_xml_name(pBinder,
2318                                         item_node, ELEMENT_MOREDATA);
2319                         if (moredata_node == NULL) {
2320                                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
2321                                 goto error;
2322                         }
2323                 }
2324
2325         }
2326
2327         if (str_cmdID != NULL)
2328                 free(str_cmdID);
2329
2330         if (str_size != NULL)
2331                 free(str_size);
2332
2333         *ppWbxml_dom_node = replace_node;
2334
2335         FW_LOGV("end");
2336         return err;
2337
2338 error:
2339
2340         if (str_cmdID != NULL)
2341                 free(str_cmdID);
2342
2343         if (str_size != NULL)
2344                 free(str_size);
2345
2346         FW_LOGE("error :%d", err);
2347         return err;
2348 }
2349
2350 static PROTOCOL_BINDER_ERROR __oma_ds_binder_delete_command_converter_function(protocol_binder *pBinder,
2351                                                                                                                                                                         Content_Ptr pContent, WBXMLTreeNode **ppWbxml_dom_node)
2352 {
2353         FW_LOGV("start");
2354         PROTOCOL_BINDER_ERROR err = PROTOCOL_BINDER_OK;
2355
2356         char *str_cmdID = NULL;
2357         char *str_size = NULL;
2358
2359         Command *pCommand = (Command *)pContent;
2360
2361         CommandChangePrivate *pChange = (CommandChangePrivate *)(&(pCommand->private));
2362
2363         if (!pChange) {
2364                 err = PROTOCOL_BINDER_NOT_DEFINED;
2365                 goto error;
2366         }
2367
2368         WBXMLTreeNode *delete_node = create_wbxml_node_using_xml_name(pBinder, ELEMENT_DELETE);
2369         if (delete_node == NULL) {
2370                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
2371                 goto error;
2372         }
2373
2374         str_cmdID = g_strdup_printf("%u", pCommand->cmdID);
2375         if (str_cmdID == NULL) {
2376                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
2377                 goto error;
2378         }
2379
2380         WBXMLTreeNode *cmdid_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
2381                         delete_node, ELEMENT_CMDID, str_cmdID, strlen(str_cmdID));
2382         if (cmdid_node == NULL) {
2383                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
2384                 goto error;
2385         }
2386
2387         if (pCommand->noResp) {
2388                 WBXMLTreeNode *noResp_node = add_child_wbxml_node_using_xml_name(pBinder,
2389                                 delete_node, ELEMENT_NORESP);
2390                 if (noResp_node == NULL) {
2391                         err = PROTOCOL_BINDER_OUT_OF_MEMORY;
2392                         goto error;
2393                 }
2394         }
2395
2396         /*TODO Archive*/
2397         /*TODO sftDel*/
2398
2399         if (pCommand->cred) {
2400                 err = __append_cred_to_wbxml_node(pCommand->cred, pBinder, delete_node);
2401                 if (err != PROTOCOL_BINDER_OK)
2402                         goto error;
2403         }
2404
2405         GList *Iter = NULL;
2406         Item *item = NULL;
2407         for (Iter = pCommand->private.change.items; Iter != NULL; Iter = g_list_next(Iter)) {
2408                 item =  (Iter->data);
2409
2410                 WBXMLTreeNode *item_node = add_child_wbxml_node_using_xml_name(pBinder,
2411                                 delete_node, ELEMENT_ITEM);
2412                 if (item_node == NULL) {
2413                         err = PROTOCOL_BINDER_OUT_OF_MEMORY;
2414                         goto error;
2415                 }
2416
2417                 if (item->source != NULL) {
2418                         WBXMLTreeNode *source_node = add_child_wbxml_node_using_xml_name(pBinder,
2419                                         item_node, ELEMENT_SOURCE);
2420                         if (source_node == NULL) {
2421                                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
2422                                 goto error;
2423                         }
2424
2425                         err = __append_location_to_wbxml_node(item->source, pBinder, source_node);
2426                         if (err != PROTOCOL_BINDER_OK)
2427                                 goto error;
2428
2429                 }
2430
2431                 if (item->target != NULL) {
2432                         WBXMLTreeNode *target_node = add_child_wbxml_node_using_xml_name(pBinder,
2433                                         item_node, ELEMENT_TARGET);
2434                         if (target_node == NULL) {
2435                                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
2436                                 goto error;
2437                         }
2438
2439                         err = __append_location_to_wbxml_node(item->target, pBinder, target_node);
2440                         if (err != PROTOCOL_BINDER_OK)
2441                                 goto error;
2442
2443                 }
2444
2445                 if (item->contenttype) {
2446                         WBXMLTreeNode *meta_node = add_child_wbxml_node_using_xml_name(pBinder,
2447                                         item_node, ELEMENT_META);
2448                         if (meta_node == NULL) {
2449                                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
2450                                 goto error;
2451                         }
2452
2453                         WBXMLTreeNode *type_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
2454                                         meta_node, ELEMENT_TYPE, item->contenttype, strlen(item->contenttype));
2455                         if (type_node == NULL) {
2456                                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
2457                                 goto error;
2458                         }
2459
2460                         if (item->size) {
2461                                 str_size = g_strdup_printf("%u", item->size);
2462                                 if (str_size == NULL) {
2463                                         err = PROTOCOL_BINDER_OUT_OF_MEMORY;
2464                                         goto error;
2465                                 }
2466
2467                                 WBXMLTreeNode *size_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
2468                                                 meta_node, ELEMENT_SIZE, str_size, strlen(str_size));
2469                                 if (size_node == NULL) {
2470                                         err = PROTOCOL_BINDER_OUT_OF_MEMORY;
2471                                         goto error;
2472                                 }
2473                         }
2474                 }
2475         }
2476
2477         if (str_cmdID != NULL)
2478                 free(str_cmdID);
2479
2480         if (str_size != NULL)
2481                 free(str_size);
2482
2483         *ppWbxml_dom_node = delete_node;
2484
2485         FW_LOGV("end");
2486         return err;
2487
2488 error:
2489
2490         if (str_cmdID != NULL)
2491                 free(str_cmdID);
2492
2493         if (str_size != NULL)
2494                 free(str_size);
2495
2496         FW_LOGE("error :%d", err);
2497         return err;
2498 }
2499
2500 static PROTOCOL_BINDER_ERROR __oma_ds_binder_map_command_converter_function(protocol_binder *pBinder,
2501                                                                                                                                                         Content_Ptr pContent, WBXMLTreeNode **ppWbxml_dom_node)
2502 {
2503         FW_LOGV("start");
2504         PROTOCOL_BINDER_ERROR err = PROTOCOL_BINDER_OK;
2505         char *str_cmdID = NULL;
2506
2507         Command *pCommand = (Command *)pContent;
2508
2509         WBXMLTreeNode *map_node = create_wbxml_node_using_xml_name(pBinder, ELEMENT_MAP);
2510
2511         str_cmdID = g_strdup_printf("%u", pCommand->cmdID);
2512         if (str_cmdID == NULL) {
2513                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
2514                 goto error;
2515         }
2516
2517         WBXMLTreeNode *cmdid_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
2518                         map_node, ELEMENT_CMDID, str_cmdID, strlen(str_cmdID));
2519         if (cmdid_node == NULL) {
2520                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
2521                 goto error;
2522         }
2523
2524         if (pCommand->source != NULL && pCommand->target != NULL) {
2525                 WBXMLTreeNode *target_node = add_child_wbxml_node_using_xml_name(pBinder,
2526                                 map_node, ELEMENT_TARGET);
2527                 if (target_node == NULL) {
2528                         err = PROTOCOL_BINDER_OUT_OF_MEMORY;
2529                         goto error;
2530                 }
2531
2532                 err = __append_location_to_wbxml_node(pCommand->target, pBinder, target_node);
2533                 if (err != PROTOCOL_BINDER_OK)
2534                         goto error;
2535
2536
2537                 WBXMLTreeNode *source_node = add_child_wbxml_node_using_xml_name(pBinder,
2538                                 map_node, ELEMENT_SOURCE);
2539                 if (source_node == NULL) {
2540                         err = PROTOCOL_BINDER_OUT_OF_MEMORY;
2541                         goto error;
2542                 }
2543
2544                 err = __append_location_to_wbxml_node(pCommand->source, pBinder, source_node);
2545                 if (err != PROTOCOL_BINDER_OK)
2546                         goto error;
2547
2548         }
2549
2550         if (pCommand->cred) {
2551                 err = __append_cred_to_wbxml_node(pCommand->cred, pBinder, map_node);
2552                 if (err != PROTOCOL_BINDER_OK)
2553                         goto error;
2554         }
2555
2556         GList *iter = NULL;
2557         Item *item = NULL;
2558         for (iter = pCommand->private.map.items; iter != NULL; iter = g_list_next(iter)) {
2559                 item = iter->data;
2560                 WBXMLTreeNode *mapItem_node = add_child_wbxml_node_using_xml_name(pBinder,
2561                                 map_node, ELEMENT_MAPITEM);
2562                 if (mapItem_node == NULL) {
2563                         err = PROTOCOL_BINDER_OUT_OF_MEMORY;
2564                         goto error;
2565                 }
2566
2567                 if (item->source != NULL && item->target != NULL) {
2568                         WBXMLTreeNode *item_target_node = add_child_wbxml_node_using_xml_name(pBinder,
2569                                         mapItem_node, ELEMENT_TARGET);
2570                         if (item_target_node == NULL) {
2571                                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
2572                                 goto error;
2573                         }
2574
2575                         err = __append_location_to_wbxml_node(item->target, pBinder, item_target_node);
2576                         if (err != PROTOCOL_BINDER_OK)
2577                                 goto error;
2578
2579
2580                         WBXMLTreeNode *item_source_node = add_child_wbxml_node_using_xml_name(pBinder,
2581                                         mapItem_node, ELEMENT_SOURCE);
2582                         if (item_source_node == NULL) {
2583                                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
2584                                 goto error;
2585                         }
2586
2587                         err = __append_location_to_wbxml_node(item->source, pBinder, item_source_node);
2588                         if (err != PROTOCOL_BINDER_OK)
2589                                 goto error;
2590
2591                 }
2592         }
2593
2594         if (str_cmdID != NULL)
2595                 free(str_cmdID);
2596
2597         *ppWbxml_dom_node = map_node;
2598
2599         FW_LOGV("end");
2600         return err;
2601
2602 error:
2603
2604         if (str_cmdID != NULL)
2605                 free(str_cmdID);
2606
2607         FW_LOGE("error :%d", err);
2608         return err;
2609 }
2610
2611 static ProtocolVersion __get_oma_ds_protocol_version(char *verdtd)
2612 {
2613         ProtocolVersion protocol_version = VERSION_UNKNOWN;
2614         if (strcmp(verdtd, ELEMENT_VERDRD_12) == 0) {
2615                 protocol_version = VERSION_12;
2616         } else if (strcmp(verdtd, ELEMENT_VERDRD_11) == 0) {
2617                 protocol_version = VERSION_11;
2618         } else if (strcmp(verdtd, ELEMENT_VERDRD_10) == 0) {
2619                 protocol_version = VERSION_10;
2620         }
2621
2622         return protocol_version;
2623 }
2624
2625 static DevInfVersion __get_oma_ds_devInf_version(char *verdtd)
2626 {
2627         DevInfVersion devInf_version = DEVINF_VERSION_UNKNOWN;
2628         if (strcmp(verdtd, ELEMENT_VERDRD_12) == 0) {
2629                 devInf_version = DEVINF_VERSION_12;
2630         } else if (strcmp(verdtd, ELEMENT_VERDRD_11) == 0) {
2631                 devInf_version = DEVINF_VERSION_11;
2632         } else if (strcmp(verdtd, ELEMENT_VERDRD_10) == 0) {
2633                 devInf_version = DEVINF_VERSION_10;
2634         }
2635
2636         return devInf_version;
2637 }
2638
2639 static DevInfDevTyp __get_oma_ds_devInf_device_type(char *devType)
2640 {
2641         DevInfDevTyp device_type = DEVINF_DEVTYPE_UNKNOWN;
2642         if (strcmp(devType, ELEMENT_PAGER) == 0) {
2643                 device_type = DEVINF_DEVTYPE_PAGER;
2644         } else if (strcmp(devType, ELEMENT_HANDHELD) == 0) {
2645                 device_type = DEVINF_DEVTYPE_HANDHELD;
2646         } else if (strcmp(devType, ELEMENT_PDA) == 0) {
2647                 device_type = DEVINF_DEVTYPE_PDA;
2648         } else if (strcmp(devType, ELEMENT_PHONE) == 0) {
2649                 device_type = DEVINF_DEVTYPE_PHONE;
2650         } else if (strcmp(devType, ELEMENT_SMARTPHONE) == 0) {
2651                 device_type = DEVINF_DEVTYPE_SMARTPHONE;
2652         } else if (strcmp(devType, ELEMENT_SERVER) == 0) {
2653                 device_type = DEVINF_DEVTYPE_SERVER;
2654         } else if (strcmp(devType, ELEMENT_WORKSTATION) == 0) {
2655                 device_type = DEVINF_DEVTYPE_WORKSTATION;
2656         }
2657
2658         return device_type;
2659 }
2660
2661 static DevInfContentType *__get_devinf_contenttype(WBXMLTreeNode *node)
2662 {
2663         FW_LOGV("start");
2664
2665         PROTOCOL_BINDER_ERROR err = PROTOCOL_BINDER_OK;
2666         DevInfContentType *pDevInfContentType = (DevInfContentType *)calloc(1, sizeof(DevInfContentType));
2667         if (pDevInfContentType == NULL) {
2668                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
2669                 FW_LOGE("pDevInfContentType is null");
2670                 goto return_part;
2671         }
2672
2673         /* get first child */
2674         WBXMLTreeNode *child = node->children;
2675         for (; child != NULL && child->type != WBXML_TREE_ELEMENT_NODE; child = child->next) {}
2676
2677         const char *first_child_name = NULL;
2678         first_child_name = (const char *)wbxml_tag_get_xml_name(child->name);
2679         if (strcmp(first_child_name, ELEMENT_CTTYPE) == 0) {
2680                 char *ctType = NULL;
2681                 err = get_text_pointer_from_wbxml_node(child, &ctType);
2682                 if (err != PROTOCOL_BINDER_OK) {
2683                         goto return_part;
2684                 }
2685                 if (ctType != NULL)
2686                         pDevInfContentType->cttype = strdup(ctType);
2687         } else {
2688                 /* error */
2689                 goto return_part;
2690         }
2691
2692         /* get second child  */
2693         child = child->next;
2694         for (; child != NULL && child->type != WBXML_TREE_ELEMENT_NODE; child = child->next) {}
2695
2696         if (child != NULL) {
2697                 const char *second_child_name = NULL;
2698                 second_child_name = (const char *)wbxml_tag_get_xml_name(child->name);
2699                 if (strcmp(second_child_name, ELEMENT_VERCT) == 0) {
2700                         char *verCT = NULL;
2701                         err = get_text_pointer_from_wbxml_node(child, &verCT);
2702                         if (err != PROTOCOL_BINDER_OK) {
2703                                 goto return_part;
2704                         }
2705                         if (verCT != NULL)
2706                                 pDevInfContentType->verct = strdup(verCT);
2707                 } else {
2708                         /* error */
2709                         goto return_part;
2710                 }
2711         }
2712
2713         FW_LOGV("end");
2714         return pDevInfContentType;
2715
2716 return_part:
2717         FW_LOGE("error : %d", err);
2718         return NULL;
2719
2720 }
2721
2722 static Location *_get_location(WBXMLTreeNode *node)
2723 {
2724         FW_LOGV("start");
2725
2726         PROTOCOL_BINDER_ERROR err = PROTOCOL_BINDER_OK;
2727         Location *pLocation = NULL;
2728
2729         WBXMLTreeNode *child = NULL;
2730
2731         char *locURI = NULL;
2732         char *locName = NULL;
2733
2734         /* get first child : required LocURI */
2735         child = node->children;
2736         for (; child != NULL && child->type != WBXML_TREE_ELEMENT_NODE; child = child->next) {}
2737
2738         const char *first_child_name = NULL;
2739         first_child_name = (const char *)wbxml_tag_get_xml_name(child->name);
2740         FW_LOGV("child_name = %s", first_child_name);
2741         if (strcmp(first_child_name, ELEMENT_LOCURI) == 0) {
2742                 err = get_text_pointer_from_wbxml_node(child, &locURI);
2743                 if (err != PROTOCOL_BINDER_OK) {
2744                         goto return_part;
2745                 }
2746         } else {
2747                 /* error */
2748                 goto return_part;
2749         }
2750
2751         /* get second child : optional LocName */
2752         child = child->next;
2753         for (; child != NULL && child->type != WBXML_TREE_ELEMENT_NODE; child = child->next) {}
2754
2755         if (child != NULL) {
2756                 const char *second_child_name = NULL;
2757                 second_child_name = (const char *)wbxml_tag_get_xml_name(child->name);
2758                 FW_LOGV("child_name = %s", second_child_name);
2759                 if (strcmp(second_child_name, ELEMENT_LOCNAME) == 0) {
2760                         err = get_text_pointer_from_wbxml_node(child, &locName);
2761                         if (err != PROTOCOL_BINDER_OK) {
2762                                 goto return_part;
2763                         }
2764                 } else {
2765                         /* error */
2766                         goto return_part;
2767                 }
2768         }
2769
2770         create_location(locURI, locName, &pLocation);
2771
2772         FW_LOGV("end");
2773         return pLocation;
2774
2775 return_part:
2776         FW_LOGE("error : %d", err);
2777         free_location(pLocation);
2778         return NULL;
2779 }
2780
2781 static Anchor *_get_anchor(WBXMLTreeNode *node)
2782 {
2783         FW_LOGV("start");
2784
2785         PROTOCOL_BINDER_ERROR err = PROTOCOL_BINDER_OK;
2786         Anchor *pAnchor = NULL;
2787
2788         WBXMLTreeNode *child = NULL;
2789
2790         char *lastAnchor = NULL;
2791         char *nextAnchor = NULL;
2792         /* get first child : optional lastAnchor */
2793         child = node->children;
2794         for (; child != NULL && child->type != WBXML_TREE_ELEMENT_NODE; child = child->next) {}
2795
2796         const char *first_child_name = NULL;
2797
2798         first_child_name = (const char *)wbxml_tag_get_xml_name(child->name);
2799         FW_LOGV("child_name = %s", first_child_name);
2800         if (strcmp(first_child_name, ELEMENT_LAST) == 0) {
2801                 err = get_text_pointer_from_wbxml_node(child, &lastAnchor);
2802                 if (err != PROTOCOL_BINDER_OK) {
2803                         goto return_part;
2804                 }
2805                 child = child->next;
2806                 for (; child != NULL && child->type != WBXML_TREE_ELEMENT_NODE; child = child->next) {}
2807         } else if (strcmp(first_child_name, ELEMENT_NEXT) == 0) {
2808                 err = get_text_pointer_from_wbxml_node(child, &nextAnchor);
2809                 if (err != PROTOCOL_BINDER_OK) {
2810                         goto return_part;
2811                 }
2812                 child = NULL;
2813         }
2814
2815         /* get second child : required nextAnchor */
2816         if (child != NULL) {
2817                 const char *second_child_name = NULL;
2818                 second_child_name = (const char *)wbxml_tag_get_xml_name(child->name);
2819                 FW_LOGV("child_name = %s", second_child_name);
2820                 if (strcmp(second_child_name, ELEMENT_NEXT) == 0) {
2821                         err = get_text_pointer_from_wbxml_node(child, &nextAnchor);
2822                         if (err != PROTOCOL_BINDER_OK) {
2823                                 goto return_part;
2824                         }
2825                 } else {
2826                         /* error */
2827                         goto return_part;
2828                 }
2829         }
2830
2831         create_anchor(lastAnchor, nextAnchor, &pAnchor);
2832
2833         FW_LOGV("end");
2834         return pAnchor;
2835
2836 return_part:
2837         FW_LOGE("error : %d", err);
2838         free_anchor(pAnchor);
2839         return NULL;
2840 }
2841
2842 static Cred *__get_cred(WBXMLTreeNode *node)
2843 {
2844         FW_LOGV("start");
2845         PROTOCOL_BINDER_ERROR err = PROTOCOL_BINDER_OK;
2846         Cred *cred = NULL;
2847
2848         char *data = NULL;
2849         char *type = NULL;
2850         char *format = NULL;
2851
2852         WBXMLTreeNode *child = NULL;
2853
2854         for (child = node->children; child != NULL; child = child->next) {
2855                 if (child->type != WBXML_TREE_ELEMENT_NODE) continue;
2856
2857                 const char *child_xml_name = NULL;
2858                 child_xml_name = (const char *)wbxml_tag_get_xml_name(child->name);
2859
2860                 if (strcmp(child_xml_name, ELEMENT_META) == 0) {
2861                         WBXMLTreeNode *grand_child = child->children;
2862
2863                         const char *grand_child_xml_name = NULL;
2864                         grand_child_xml_name = (const char *)wbxml_tag_get_xml_name(grand_child->name);
2865
2866                         if (strcmp(grand_child_xml_name, ELEMENT_TYPE) == 0) {
2867                                 err = get_text_pointer_from_wbxml_node(grand_child, &type);
2868                                 if (err != PROTOCOL_BINDER_OK) {
2869                                         goto return_part;
2870                                 }
2871                                 FW_LOGV("Type = [%s]" , type);
2872                         } else if (strcmp(grand_child_xml_name, ELEMENT_FORMAT) == 0) {
2873                                 err = get_text_pointer_from_wbxml_node(grand_child, &format);
2874                                 if (err != PROTOCOL_BINDER_OK) {
2875                                         goto return_part;
2876                                 }
2877                                 FW_LOGV("Type = [%s]" , format);
2878                         }
2879                 } else if (strcmp(child_xml_name, ELEMENT_DATA) == 0) {
2880                         err = get_text_pointer_from_wbxml_node(child, &data);
2881                         if (err != PROTOCOL_BINDER_OK) {
2882                                 goto return_part;
2883                         }
2884                         FW_LOGV("Data = [%s]" , data);
2885                 }
2886
2887         }
2888
2889         cred = create_cred_with_data(convert_auth_type(type), data);
2890
2891         FormatType formatType = FORMAT_TYPE_UNKNOWN;
2892         if (strcmp(format, ELEMENT_B64) == 0)
2893                 formatType = FORMAT_TYPE_BASE64;
2894
2895         set_cred_format_type(cred, formatType);
2896
2897         FW_LOGV("end");
2898         return cred;
2899
2900 return_part:
2901         FW_LOGE("error");
2902         free_cred(cred);
2903         return NULL;
2904 }
2905
2906 static Chal *_get_chal(WBXMLTreeNode *node)
2907 {
2908         FW_LOGV("start");
2909         PROTOCOL_BINDER_ERROR err = PROTOCOL_BINDER_OK;
2910
2911         Chal *pChal = (Chal *)calloc(1, sizeof(Chal));
2912         if (pChal == NULL) {
2913                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
2914                 FW_LOGE("pChal is null");
2915                 goto return_part;
2916         }
2917
2918         WBXMLTreeNode *chal_child = node->children;
2919
2920         WBXMLTreeNode *meta_child = NULL;
2921
2922         for (meta_child = chal_child->children; meta_child != NULL; meta_child = meta_child->next) {
2923                 if (meta_child->type != WBXML_TREE_ELEMENT_NODE) continue;
2924
2925                 const char *meta_child_xml_name = NULL;
2926                 meta_child_xml_name = (const char *)wbxml_tag_get_xml_name(meta_child->name);
2927
2928                 if (strcmp(meta_child_xml_name, ELEMENT_TYPE) == 0) {
2929                         char *type = NULL;
2930                         err = get_text_pointer_from_wbxml_node(meta_child, &type);
2931                         if (err != PROTOCOL_BINDER_OK) {
2932                                 goto return_part;
2933                         }
2934                         FW_LOGV("Type = [%s]" , type);
2935
2936                         pChal->type = convert_auth_type(type);
2937                 } else if (strcmp(meta_child_xml_name, ELEMENT_FORMAT) == 0) {
2938                         char *format = NULL;
2939                         err = get_text_pointer_from_wbxml_node(meta_child, &format);
2940                         if (err != PROTOCOL_BINDER_OK) {
2941                                 goto return_part;
2942                         }
2943                         FW_LOGV("Format = [%s]" , format);
2944
2945                         pChal->format = convert_format_type(format);
2946                 } else if (strcmp(meta_child_xml_name, ELEMENT_NEXTNONCE) == 0) {
2947                         char *nextnonce = NULL;
2948                         unsigned int nonce_len = 0;
2949                         err = get_binary_pointer_from_wbxml_node(meta_child, &nextnonce, &nonce_len);
2950                         if (err != PROTOCOL_BINDER_OK) {
2951                                 goto return_part;
2952                         }
2953                         FW_LOGV("NextNonce = [%s]" , nextnonce);
2954                         if (pChal->format == FORMAT_TYPE_BASE64) {
2955                                 if (nextnonce != NULL)
2956                                         pChal->nonce_b64 = strdup(nextnonce);
2957                         } else{
2958                                 pChal->nonce_plain = (char *) malloc(nonce_len+1);
2959                                 if (pChal->nonce_plain == NULL) {
2960                                         err = PROTOCOL_BINDER_OUT_OF_MEMORY;
2961                                         goto return_part;
2962                                 }
2963                                 memcpy(pChal->nonce_plain, nextnonce, nonce_len);
2964                                 pChal->nonce_plain[nonce_len] = '\0';
2965                         }
2966
2967                         pChal->nonce_length = nonce_len;
2968                 }
2969         }
2970
2971         FW_LOGV("end");
2972         return pChal;
2973
2974 return_part:
2975         FW_LOGE("error");
2976         free_chal(pChal);
2977         return NULL;
2978 }
2979
2980 static PROTOCOL_BINDER_ERROR __oma_ds_binder_devinf_reverse_converter_function(Reverse_protocol_binder *pReverse_binder,
2981                                                                                                                                                         WBXMLTreeNode *wbxml_dom_node,
2982                                                                                                                                                         Content_Ptr *pContent)
2983 {
2984         FW_LOGV("start");
2985         PROTOCOL_BINDER_ERROR err = PROTOCOL_BINDER_OK;
2986
2987         /* get data from dom tree */
2988         DevInf *pDevInf = (DevInf *)calloc(1, sizeof(DevInf));
2989         if (pDevInf == NULL) {
2990                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
2991                 FW_LOGE("pDevInf is null");
2992                 goto return_part;
2993         }
2994
2995         WBXMLTreeNode *child = NULL;
2996
2997         for (child = wbxml_dom_node->children; child != NULL; child = child->next) {
2998                 if (child->type != WBXML_TREE_ELEMENT_NODE) continue;
2999
3000                 const char *child_xml_name = NULL;
3001                 child_xml_name = (const char *)wbxml_tag_get_xml_name(child->name);
3002
3003                 if (strcmp(child_xml_name, ELEMENT_VERDTD) == 0) {
3004                         char *verdtd = NULL;
3005                         err = get_text_pointer_from_wbxml_node(child, &verdtd);
3006                         if (err != PROTOCOL_BINDER_OK) {
3007                                 goto return_part;
3008                         }
3009                         FW_LOGV("VerDTD = [%s]" , verdtd);
3010
3011                         pDevInf->version = __get_oma_ds_devInf_version(verdtd);
3012                 } else if (strcmp(child_xml_name, ELEMENT_MAN) == 0) {
3013                         char *man = NULL;
3014                         err = get_text_pointer_from_wbxml_node(child, &man);
3015                         if (err != PROTOCOL_BINDER_OK) {
3016                                 goto return_part;
3017                         }
3018                         FW_LOGV("Man = [%s]" , man);
3019                         if (man != NULL)
3020                                 pDevInf->manufacturer = strdup(man);
3021                 } else if (strcmp(child_xml_name, ELEMENT_MOD) == 0) {
3022                         char *mod = NULL;
3023                         err = get_text_pointer_from_wbxml_node(child, &mod);
3024                         if (err != PROTOCOL_BINDER_OK) {
3025                                 goto return_part;
3026                         }
3027                         FW_LOGV("Mod = [%s]" , mod);
3028                         if (mod != NULL)
3029                                 pDevInf->model = strdup(mod);
3030                 } else if (strcmp(child_xml_name, ELEMENT_OEM) == 0) {
3031                         char *oem = NULL;
3032                         err = get_text_pointer_from_wbxml_node(child, &oem);
3033                         if (err != PROTOCOL_BINDER_OK) {
3034                                 goto return_part;
3035                         }
3036                         FW_LOGV("OEM = [%s]" , oem);
3037                         if (oem != NULL)
3038                                 pDevInf->oem = strdup(oem);
3039                 } else if (strcmp(child_xml_name, ELEMENT_FWV) == 0) {
3040                         char *fwv = NULL;
3041                         err = get_text_pointer_from_wbxml_node(child, &fwv);
3042                         if (err != PROTOCOL_BINDER_OK) {
3043                                 goto return_part;
3044                         }
3045                         FW_LOGV("FwV = [%s]" , fwv);
3046                         if (fwv != NULL)
3047                                 pDevInf->firmwareVersion = strdup(fwv);
3048                 } else if (strcmp(child_xml_name, ELEMENT_SWV) == 0) {
3049                         char *swv = NULL;
3050                         err = get_text_pointer_from_wbxml_node(child, &swv);
3051                         if (err != PROTOCOL_BINDER_OK) {
3052                                 goto return_part;
3053                         }
3054                         FW_LOGV("SwV = [%s]" , swv);
3055                         if (swv != NULL)
3056                                 pDevInf->softwareVersion = strdup(swv);
3057                 } else if (strcmp(child_xml_name, ELEMENT_HWV) == 0) {
3058                         char *hwv = NULL;
3059                         err = get_text_pointer_from_wbxml_node(child, &hwv);
3060                         if (err != PROTOCOL_BINDER_OK) {
3061                                 goto return_part;
3062                         }
3063                         FW_LOGV("HwV = [%s]" , hwv);
3064                         if (hwv != NULL)
3065                                 pDevInf->hardwareVersion = strdup(hwv);
3066                 } else if (strcmp(child_xml_name, ELEMENT_DEVID) == 0) {
3067                         char *devID = NULL;
3068                         err = get_text_pointer_from_wbxml_node(child, &devID);
3069                         if (err != PROTOCOL_BINDER_OK) {
3070                                 goto return_part;
3071                         }
3072                         FW_LOGV("DevID = [%s]" , devID);
3073                         if (devID != NULL)
3074                                 pDevInf->devid = strdup(devID);
3075                 } else if (strcmp(child_xml_name, ELEMENT_DEVTYP) == 0) {
3076                         char *devtyp = NULL;
3077                         err = get_text_pointer_from_wbxml_node(child, &devtyp);
3078                         if (err != PROTOCOL_BINDER_OK) {
3079                                 goto return_part;
3080                         }
3081                         FW_LOGV("DevTyp = [%s]" , devtyp);
3082
3083                         pDevInf->devtyp = __get_oma_ds_devInf_device_type(devtyp);
3084                 } else if (strcmp(child_xml_name, ELEMENT_UTC) == 0) {
3085                         FW_LOGV("UTC");
3086                         pDevInf->supportsUTC = 1;
3087                 } else if (strcmp(child_xml_name, ELEMENT_SUPPORTLARGEOBJS) == 0) {
3088                         FW_LOGV("SupportLargeObjs");
3089                         pDevInf->supportsLargeObjs = 1;
3090                 } else if (strcmp(child_xml_name, ELEMENT_SUPPORTNUMBEROFCHANGES) == 0) {
3091                         FW_LOGV("SupportNumberOfChanges");
3092                         pDevInf->supportsNumberOfChanges = 1;
3093                 } else if (strcmp(child_xml_name, ELEMENT_DATASTORE) == 0) {
3094
3095                         DevInfDataStore *pDevInfDataStore = (DevInfDataStore *)calloc(1, sizeof(DevInfDataStore));
3096
3097                         WBXMLTreeNode *datastore_child = NULL;
3098
3099                         for (datastore_child = child->children; datastore_child != NULL; datastore_child = datastore_child->next) {
3100                                 if (datastore_child->type != WBXML_TREE_ELEMENT_NODE) continue;
3101
3102                                 const char *datastore_child_xml_name = NULL;
3103                                 datastore_child_xml_name = (const char *)wbxml_tag_get_xml_name(datastore_child->name);
3104
3105                                 if (strcmp(datastore_child_xml_name, ELEMENT_SOURCEREF) == 0) {
3106                                         char *sourceref = NULL;
3107                                         err = get_text_pointer_from_wbxml_node(datastore_child, &sourceref);
3108                                         if (err != PROTOCOL_BINDER_OK) {
3109                                                 goto return_part;
3110                                         }
3111                                         FW_LOGV("SourceRef = [%s]" , sourceref);
3112                                         if (sourceref != NULL)
3113                                                 pDevInfDataStore->sourceref = strdup(sourceref);
3114                                 } else if (strcmp(datastore_child_xml_name, ELEMENT_DISPLAYNAME) == 0) {
3115                                         char *displayname = NULL;
3116                                         err = get_text_pointer_from_wbxml_node(datastore_child, &displayname);
3117                                         if (err != PROTOCOL_BINDER_OK) {
3118                                                 goto return_part;
3119                                         }
3120                                         FW_LOGV("DisplayName = [%s]" , displayname);
3121                                         if (displayname != NULL)
3122                                                 pDevInfDataStore->displayname = strdup(displayname);
3123                                 } else if (strcmp(datastore_child_xml_name, ELEMENT_MAXGUIDSIZE) == 0) {
3124                                         char *maxguidsize = NULL;
3125                                         err = get_text_pointer_from_wbxml_node(datastore_child, &maxguidsize);
3126                                         if (err != PROTOCOL_BINDER_OK) {
3127                                                 goto return_part;
3128                                         }
3129                                         FW_LOGV("MaxGUIDSize = [%s]" , maxguidsize);
3130                                         if (maxguidsize != NULL)
3131                                                 pDevInfDataStore->maxGUIDSize = atoi(maxguidsize);
3132                                 } else if (strcmp(datastore_child_xml_name, ELEMENT_RX_PREF) == 0) {
3133                                         DevInfContentType *pDevInfContentType = __get_devinf_contenttype(datastore_child);
3134                                         if (pDevInfContentType == NULL) {
3135                                                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
3136                                                 goto return_part;
3137                                         }
3138                                         pDevInfDataStore->rxPref = pDevInfContentType;
3139                                 } else if (strcmp(datastore_child_xml_name, ELEMENT_RX) == 0) {
3140                                         DevInfContentType *pDevInfContentType = __get_devinf_contenttype(datastore_child);
3141                                         if (pDevInfContentType == NULL) {
3142                                                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
3143                                                 goto return_part;
3144                                         }
3145                                         pDevInfDataStore->rx = g_list_append(pDevInfDataStore->rx, pDevInfContentType);
3146                                 } else if (strcmp(datastore_child_xml_name, ELEMENT_TX_PREF) == 0) {
3147                                         DevInfContentType *pDevInfContentType = __get_devinf_contenttype(datastore_child);
3148                                         if (pDevInfContentType == NULL) {
3149                                                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
3150                                                 goto return_part;
3151                                         }
3152                                         pDevInfDataStore->txPref = pDevInfContentType;
3153                                 } else if (strcmp(datastore_child_xml_name, ELEMENT_TX) == 0) {
3154                                         DevInfContentType *pDevInfContentType = __get_devinf_contenttype(datastore_child);
3155                                         if (pDevInfContentType == NULL) {
3156                                                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
3157                                                 goto return_part;
3158                                         }
3159                                         pDevInfDataStore->tx = g_list_append(pDevInfDataStore->tx, pDevInfContentType);
3160                                 } else if (strcmp(datastore_child_xml_name, ELEMENT_CTCAP) == 0) {
3161
3162                                         DevInfCTCap *pDevInfCtCap = (DevInfCTCap *)calloc(1, sizeof(DevInfCTCap));
3163
3164                                         DevInfContentType *pDevInfContentType = NULL;
3165                                         WBXMLTreeNode *ctcap_child = NULL;
3166
3167                                         for (ctcap_child = datastore_child->children; ctcap_child != NULL; ctcap_child = ctcap_child->next) {
3168                                                 if (ctcap_child->type != WBXML_TREE_ELEMENT_NODE) continue;
3169
3170                                                 const char *ctcap_child_xml_name = NULL;
3171                                                 ctcap_child_xml_name = (const char *)wbxml_tag_get_xml_name(ctcap_child->name);
3172
3173                                                 if (strcmp(ctcap_child_xml_name, ELEMENT_CTTYPE) == 0) {
3174                                                         if (pDevInfContentType == NULL)
3175                                                                 pDevInfContentType = (DevInfContentType *)calloc(1, sizeof(DevInfContentType));
3176
3177                                                         char *cttype = NULL;
3178                                                         err = get_text_pointer_from_wbxml_node(ctcap_child, &cttype);
3179                                                         if (err != PROTOCOL_BINDER_OK) {
3180                                                                 goto return_part;
3181                                                         }
3182                                                         FW_LOGV("CTType = [%s]" , cttype);
3183                                                         if (cttype != NULL)
3184                                                                 pDevInfContentType->cttype = strdup(cttype);
3185                                                 } else if (strcmp(ctcap_child_xml_name, ELEMENT_VERCT) == 0) {
3186                                                         if (pDevInfContentType == NULL)
3187                                                                 pDevInfContentType = (DevInfContentType *)calloc(1, sizeof(DevInfContentType));
3188
3189                                                         char *verct = NULL;
3190                                                         err = get_text_pointer_from_wbxml_node(ctcap_child, &verct);
3191                                                         if (err != PROTOCOL_BINDER_OK) {
3192                                                                 goto return_part;
3193                                                         }
3194                                                         FW_LOGV("VerCT = [%s]" , verct);
3195                                                         if (verct != NULL)
3196                                                                 pDevInfContentType->verct = strdup(verct);
3197                                                 } else if (strcmp(ctcap_child_xml_name, ELEMENT_FIELDLEVEL) == 0) {
3198                                                         /*TODO fieldlevel*/
3199
3200                                                 } else if (strcmp(ctcap_child_xml_name, ELEMENT_PROPERTY) == 0) {
3201
3202                                                         DevInfProperty *pDevInfProperty = (DevInfProperty *)calloc(1, sizeof(DevInfProperty));
3203
3204                                                         WBXMLTreeNode *property_child = NULL;
3205                                                         for (property_child = ctcap_child->children; property_child != NULL; property_child = property_child->next) {
3206                                                                 if (property_child->type != WBXML_TREE_ELEMENT_NODE) continue;
3207
3208                                                                 const char *property_child_xml_name = NULL;
3209                                                                 property_child_xml_name = (const char *)wbxml_tag_get_xml_name(property_child->name);
3210
3211                                                                 if (strcmp(property_child_xml_name, ELEMENT_PROPNAME) == 0) {
3212                                                                         char *propname = NULL;
3213                                                                         err = get_text_pointer_from_wbxml_node(property_child, &propname);
3214                                                                         if (err != PROTOCOL_BINDER_OK) {
3215                                                                                 goto return_part;
3216                                                                         }
3217                                                                         FW_LOGV("PropName = [%s]" , propname);
3218                                                                         if (propname != NULL)
3219                                                                                 pDevInfProperty->propName = strdup(propname);
3220                                                                 } else if (strcmp(property_child_xml_name, ELEMENT_DATATYPE) == 0) {
3221                                                                         char *datatype = NULL;
3222                                                                         err = get_text_pointer_from_wbxml_node(property_child, &datatype);
3223                                                                         if (err != PROTOCOL_BINDER_OK) {
3224                                                                                 goto return_part;
3225                                                                         }
3226                                                                         FW_LOGV("DataType = [%s]" , datatype);
3227                                                                         if (datatype != NULL)
3228                                                                                 pDevInfProperty->dataType = strdup(datatype);
3229                                                                 } else if (strcmp(property_child_xml_name, ELEMENT_MAXOCCUR) == 0) {
3230                                                                         char *maxoccur = NULL;
3231                                                                         err = get_text_pointer_from_wbxml_node(property_child, &maxoccur);
3232                                                                         if (err != PROTOCOL_BINDER_OK) {
3233                                                                                 goto return_part;
3234                                                                         }
3235                                                                         FW_LOGV("MaxOccur = [%s]" , maxoccur);
3236                                                                         if (maxoccur != NULL)
3237                                                                                 pDevInfProperty->maxOccur = atoi(maxoccur);
3238                                                                 } else if (strcmp(property_child_xml_name, ELEMENT_MAXSIZE) == 0) {
3239                                                                         char *maxsize = NULL;
3240                                                                         err = get_text_pointer_from_wbxml_node(property_child, &maxsize);
3241                                                                         if (err != PROTOCOL_BINDER_OK) {
3242                                                                                 goto return_part;
3243                                                                         }
3244                                                                         FW_LOGV("MaxSize = [%s]" , maxsize);
3245                                                                         if (maxsize != NULL)
3246                                                                                 pDevInfProperty->maxSize = atoi(maxsize);
3247                                                                 } else if (strcmp(property_child_xml_name, ELEMENT_NOTRUNCATE) == 0) {
3248                                                                         FW_LOGV("NoTruncate");
3249                                                                         pDevInfProperty->noTruncate = 1;
3250                                                                 } else if (strcmp(property_child_xml_name, ELEMENT_VALENUM) == 0) {
3251                                                                         char *valenum = NULL;
3252                                                                         err = get_text_pointer_from_wbxml_node(property_child, &valenum);
3253                                                                         if (err != PROTOCOL_BINDER_OK) {
3254                                                                                 goto return_part;
3255                                                                         }
3256                                                                         FW_LOGV("ValEnum = [%s]" , valenum);
3257                                                                         pDevInfProperty->valEnums = g_list_append(pDevInfProperty->valEnums, strdup(valenum));
3258                                                                 } else if (strcmp(property_child_xml_name, ELEMENT_DISPLAYNAME) == 0) {
3259                                                                         char *displayname = NULL;
3260                                                                         err = get_text_pointer_from_wbxml_node(property_child, &displayname);
3261                                                                         if (err != PROTOCOL_BINDER_OK) {
3262                                                                                 goto return_part;
3263                                                                         }
3264                                                                         FW_LOGV("DisplayName = [%s]" , displayname);
3265                                                                         if (displayname != NULL)
3266                                                                                 pDevInfProperty->displayName = strdup(displayname);
3267                                                                 } else if (strcmp(property_child_xml_name, ELEMENT_PROPPARAM) == 0) {
3268
3269                                                                         DevInfPropParam *pDevInfPropParam = (DevInfPropParam *)calloc(1, sizeof(DevInfPropParam));
3270
3271                                                                         WBXMLTreeNode *propparam_child = NULL;
3272
3273                                                                         for (propparam_child = property_child->children; propparam_child != NULL; propparam_child = propparam_child->next) {
3274                                                                                 if (propparam_child->type != WBXML_TREE_ELEMENT_NODE) continue;
3275
3276                                                                                 const char *propparam_child_xml_name = NULL;
3277                                                                                 propparam_child_xml_name = (const char *)wbxml_tag_get_xml_name(propparam_child->name);
3278
3279                                                                                 if (strcmp(propparam_child_xml_name, ELEMENT_PARAMNAME) == 0) {
3280                                                                                         char *paramname = NULL;
3281                                                                                         err = get_text_pointer_from_wbxml_node(propparam_child, &paramname);
3282                                                                                         if (err != PROTOCOL_BINDER_OK) {
3283                                                                                                 goto return_part;
3284                                                                                         }
3285                                                                                         FW_LOGV("ParamName = [%s]" , paramname);
3286                                                                                         if (paramname != NULL)
3287                                                                                                 pDevInfPropParam->paramName = strdup(paramname);
3288                                                                                 } else if (strcmp(propparam_child_xml_name, ELEMENT_DATATYPE) == 0) {
3289                                                                                         char *datatype = NULL;
3290                                                                                         err = get_text_pointer_from_wbxml_node(propparam_child, &datatype);
3291                                                                                         if (err != PROTOCOL_BINDER_OK) {
3292                                                                                                 goto return_part;
3293                                                                                         }
3294                                                                                         FW_LOGV("DataType = [%s]" , datatype);
3295                                                                                         if (datatype != NULL)
3296                                                                                                 pDevInfPropParam->dataType = strdup(datatype);
3297                                                                                 } else if (strcmp(propparam_child_xml_name, ELEMENT_VALENUM) == 0) {
3298                                                                                         char *valenum = NULL;
3299                                                                                         err = get_text_pointer_from_wbxml_node(propparam_child, &valenum);
3300                                                                                         if (err != PROTOCOL_BINDER_OK) {
3301                                                                                                 goto return_part;
3302                                                                                         }
3303                                                                                         FW_LOGV("ValEnum = [%s]" , valenum);
3304                                                                                         if (valenum != NULL)
3305                                                                                                 pDevInfPropParam->valEnums = g_list_append(pDevInfPropParam->valEnums, strdup(valenum));
3306                                                                                 } else if (strcmp(propparam_child_xml_name, ELEMENT_DISPLAYNAME) == 0) {
3307                                                                                         char *displayname = NULL;
3308                                                                                         err = get_text_pointer_from_wbxml_node(propparam_child, &displayname);
3309                                                                                         if (err != PROTOCOL_BINDER_OK) {
3310                                                                                                 goto return_part;
3311                                                                                         }
3312                                                                                         FW_LOGV("DisplayName = [%s]" , displayname);
3313                                                                                         if (displayname != NULL)
3314                                                                                                 pDevInfPropParam->displayName = strdup(displayname);
3315                                                                                 }
3316                                                                         }
3317
3318                                                                         pDevInfProperty->propParams = g_list_append(pDevInfProperty->propParams, pDevInfPropParam);
3319                                                                 }
3320                                                         }
3321
3322                                                         pDevInfCtCap->properties = g_list_append(pDevInfCtCap->properties, pDevInfProperty);
3323                                                 }
3324                                         }
3325                                         pDevInfCtCap->ct = pDevInfContentType;
3326                                         pDevInfDataStore->ctcaps = g_list_append(pDevInfDataStore->ctcaps, pDevInfCtCap);
3327                                 } else if (strcmp(datastore_child_xml_name, ELEMENT_DSMEM) == 0) {
3328
3329                                         /*TODO DSMem*/
3330                                 } else if (strcmp(datastore_child_xml_name, ELEMENT_SUPPORTHIERARCHICALSYNC) == 0) {
3331                                         FW_LOGV("SupportHierarchicalSync");
3332                                         pDevInfDataStore->supportsHierarchicalSync = 1;
3333                                 } else if (strcmp(datastore_child_xml_name, ELEMENT_SYNCCAP) == 0) {
3334
3335                                         WBXMLTreeNode *synccap_child = NULL;
3336
3337                                         for (synccap_child = datastore_child->children; synccap_child != NULL; synccap_child = synccap_child->next) {
3338                                                 if (synccap_child->type != WBXML_TREE_ELEMENT_NODE) continue;
3339
3340                                                 const char *synccap_child_xml_name = NULL;
3341                                                 synccap_child_xml_name = (const char *)wbxml_tag_get_xml_name(synccap_child->name);
3342
3343                                                 if (strcmp(synccap_child_xml_name, ELEMENT_SYNCTYPE) == 0) {
3344                                                         char *synctype_str = NULL;
3345                                                         unsigned int synctype = 0;
3346                                                         err = get_text_pointer_from_wbxml_node(synccap_child, &synctype_str);
3347                                                         if (err != PROTOCOL_BINDER_OK) {
3348                                                                 goto return_part;
3349                                                         }
3350                                                         FW_LOGV("SyncType = [%s]" , synctype_str);
3351                                                         if (synctype_str != NULL) {
3352                                                                 synctype = atoi(synctype_str);
3353                                                                 synctype = 1 << (synctype - 1);
3354                                                         }
3355                                                         /*DevInfSyncCap synccap = convert_devinf_synccap(synctype);*/
3356                                                         set_devInf_datastore_synccap(pDevInfDataStore, synctype, 1);
3357                                                 }
3358                                         }
3359                                 } else if (strcmp(datastore_child_xml_name, ELEMENT_FILTER_RX) == 0) {
3360                                                 /*TODO filter-rx*/
3361                                 } else if (strcmp(datastore_child_xml_name, ELEMENT_FILTERCAP) == 0) {
3362                                                 /*TODO filtercap*/
3363                                 }
3364                         }
3365                         pDevInf->datastores = g_list_append(pDevInf->datastores, pDevInfDataStore);
3366                 }
3367         }
3368
3369
3370 return_part:
3371         if (err == PROTOCOL_BINDER_OK) {
3372                 FW_LOGV("end");
3373                 *pContent = pDevInf;
3374         } else{
3375                 FW_LOGE("error");
3376                 free_devinf(pDevInf);
3377         }
3378
3379         return err;
3380 }
3381 static PROTOCOL_BINDER_ERROR __oma_ds_binder_header_reverse_converter_function(Reverse_protocol_binder *pReverse_binder,
3382                                                                                                                                                         WBXMLTreeNode *wbxml_dom_node,
3383                                                                                                                                                         Content_Ptr *pContent)
3384 {
3385         FW_LOGV("start");
3386         PROTOCOL_BINDER_ERROR err = PROTOCOL_BINDER_OK;
3387
3388         /* get data from dom tree */
3389         SyncHdr *pSyncHdr = (SyncHdr *)calloc(1, sizeof(SyncHdr));
3390         if (pSyncHdr == NULL) {
3391                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
3392                 FW_LOGE("pSyncHdr is null");
3393                 goto return_part;
3394         }
3395
3396         WBXMLTreeNode *child = NULL;
3397
3398         for (child = wbxml_dom_node->children; child != NULL; child = child->next) {
3399                 if (child->type != WBXML_TREE_ELEMENT_NODE) continue;
3400
3401                 const char *child_xml_name = NULL;
3402                 child_xml_name = (const char *)wbxml_tag_get_xml_name(child->name);
3403
3404                 if (strcmp(child_xml_name, ELEMENT_VERDTD) == 0) {
3405                         char *verdtd = NULL;
3406                         err = get_text_pointer_from_wbxml_node(child, &verdtd);
3407                         if (err != PROTOCOL_BINDER_OK) {
3408                                 goto return_part;
3409                         }
3410                         FW_LOGV("VerDTD = [%s]" , verdtd);
3411
3412                         pSyncHdr->version = __get_oma_ds_protocol_version(verdtd);
3413                 } else if (strcmp(child_xml_name, ELEMENT_SESSIONID) == 0) {
3414                         char *sessionID = NULL;
3415                         err = get_text_pointer_from_wbxml_node(child, &sessionID);
3416                         if (err != PROTOCOL_BINDER_OK) {
3417                                 goto return_part;
3418                         }
3419                         FW_LOGV("SessionID = [%s]" , sessionID);
3420
3421                         if (sessionID)
3422                                 pSyncHdr->sessionID = strdup(sessionID);
3423                         else
3424                                 pSyncHdr->sessionID = NULL;
3425                 } else if (strcmp(child_xml_name, ELEMENT_MSGID) == 0) {
3426                         char *msgID = NULL;
3427                         err = get_text_pointer_from_wbxml_node(child, &msgID);
3428                         if (err != PROTOCOL_BINDER_OK) {
3429                                 goto return_part;
3430                         }
3431                         FW_LOGV("MsgID = [%s]" , msgID);
3432                         if (msgID != NULL)
3433                                 pSyncHdr->messageID = atoi(msgID);
3434                 } else if (strcmp(child_xml_name, ELEMENT_TARGET) == 0) {
3435                         Location *pTargetLocation = _get_location(child);
3436                         if (pTargetLocation == NULL) {
3437                                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
3438                                 goto return_part;
3439                         }
3440                         pSyncHdr->target = pTargetLocation;
3441                 } else if (strcmp(child_xml_name, ELEMENT_SOURCE) == 0) {
3442                         Location *pSourceLocation = _get_location(child);
3443                         if (pSourceLocation == NULL) {
3444                                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
3445                                 goto return_part;
3446                         }
3447                         pSyncHdr->source = pSourceLocation;
3448                 } else if (strcmp(child_xml_name, ELEMENT_RESPURI) == 0) {
3449                         char *resp_uri = NULL;
3450                         err = get_text_pointer_from_wbxml_node(child, &resp_uri);
3451                         if (err != PROTOCOL_BINDER_OK) {
3452                                 goto return_part;
3453                         }
3454                         FW_LOGV("resp_uri = [%s]" , resp_uri);
3455                         if (resp_uri != NULL)
3456                                 pSyncHdr->responseURI = strdup(resp_uri);
3457                 } else if (strcmp(child_xml_name, ELEMENT_NORESP) == 0) {
3458                         FW_LOGV("noResp\n");
3459                         pSyncHdr->noResponse = 1;
3460                 } else if (strcmp(child_xml_name, ELEMENT_CRED) == 0) {
3461                         FW_LOGV("Cred\n");
3462                         Cred *pCred = NULL;
3463                         pCred = __get_cred(child);
3464                         if (pCred == NULL) {
3465                                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
3466                                 goto return_part;
3467                         }
3468                         pSyncHdr->cred = pCred;
3469                 } else if (strcmp(child_xml_name, ELEMENT_META) == 0) {
3470
3471                 }
3472         }
3473
3474 return_part:
3475         if (err == PROTOCOL_BINDER_OK) {
3476                 FW_LOGV("end");
3477                 *pContent = pSyncHdr;
3478         } else{
3479                 FW_LOGE("error");
3480                 free_synchdr(pSyncHdr);
3481         }
3482
3483         return err;
3484 }
3485
3486 static PROTOCOL_BINDER_ERROR __oma_ds_binder_results_command_reverse_converter_function(Reverse_protocol_binder *pReverse_binder,
3487                                                                                                                                                         WBXMLTreeNode *wbxml_dom_node,
3488                                                                                                                                                         Content_Ptr *pContent)
3489 {
3490         FW_LOGV("start");
3491         PROTOCOL_BINDER_ERROR err = PROTOCOL_BINDER_OK;
3492
3493         SyncHdr *pSyncHdr = (SyncHdr *)reverse_protocol_binder_get_user_data(pReverse_binder);
3494
3495         /* get data from dom tree */
3496         Command *pResults = (Command *)calloc(1, sizeof(Command));
3497         if (pResults == NULL) {
3498                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
3499                 FW_LOGE("pResults is null");
3500                 goto return_part;
3501         }
3502
3503         pResults->type = COMMAND_TYPE_RESULTS;
3504         pResults->msgID = pSyncHdr->messageID;
3505         pResults->refCount = 1;
3506
3507         WBXMLTreeNode *child = NULL;
3508
3509         for (child = wbxml_dom_node->children; child != NULL; child = child->next) {
3510                 if (child->type != WBXML_TREE_ELEMENT_NODE) continue;
3511
3512                 const char *child_xml_name = NULL;
3513                 child_xml_name = (const char *)wbxml_tag_get_xml_name(child->name);
3514
3515                 if (strcmp(child_xml_name, ELEMENT_CMDID) == 0) {
3516                         char *cmd_id = NULL;
3517                         err = get_text_pointer_from_wbxml_node(child, &cmd_id);
3518                         if (err != PROTOCOL_BINDER_OK) {
3519                                 goto return_part;
3520                         }
3521                         FW_LOGV("CmdID = [%s]" , cmd_id);
3522                         if (cmd_id != NULL)
3523                                 pResults->cmdID = atoi(cmd_id);
3524                 } else if (strcmp(child_xml_name, ELEMENT_MSGREF) == 0) {
3525                         char *msg_ref = NULL;
3526                         err = get_text_pointer_from_wbxml_node(child, &msg_ref);
3527                         if (err != PROTOCOL_BINDER_OK) {
3528                                 goto return_part;
3529                         }
3530                         FW_LOGV("MsgRef = [%s]" , msg_ref);
3531                         if (msg_ref != NULL)
3532                                 pResults->private.results.msgRef = atoi(msg_ref);
3533                 } else if (strcmp(child_xml_name, ELEMENT_CMDREF) == 0) {
3534                         char *cmd_ref = NULL;
3535                         err = get_text_pointer_from_wbxml_node(child, &cmd_ref);
3536                         if (err != PROTOCOL_BINDER_OK) {
3537                                 goto return_part;
3538                         }
3539                         FW_LOGV("MsgRef = [%s]" , cmd_ref);
3540                         if (cmd_ref != NULL)
3541                                 pResults->private.results.cmdRef = atoi(cmd_ref);
3542                 } else if (strcmp(child_xml_name, ELEMENT_META) == 0) {
3543
3544                         WBXMLTreeNode *grandchild = NULL;
3545
3546
3547                         for (grandchild = child->children; grandchild != NULL; grandchild = grandchild->next) {
3548                                 if (grandchild->type != WBXML_TREE_ELEMENT_NODE) continue;
3549
3550                                 const char *grandchild_xml_name = NULL;
3551                                 grandchild_xml_name = (const char *)wbxml_tag_get_xml_name(grandchild->name);
3552
3553                                 if (strcmp(grandchild_xml_name, ELEMENT_TYPE) == 0) {
3554                                         char *contentType = NULL;
3555                                         err = get_text_pointer_from_wbxml_node(grandchild, &contentType);
3556                                         if (err != PROTOCOL_BINDER_OK) {
3557                                                 goto return_part;
3558                                         }
3559                                         FW_LOGV("Content Type = [%s]" , contentType);
3560                                         if (contentType != NULL)
3561                                                 pResults->private.results.type = strdup(contentType);
3562                                 }
3563                         }
3564                 } else if (strcmp(child_xml_name, ELEMENT_TARGETREF) == 0) {
3565                 /*TODO targetRef*/
3566                 } else if (strcmp(child_xml_name, ELEMENT_SOURCEREF) == 0) {
3567                 /*TODO sourceRef*/
3568                 } else if (strcmp(child_xml_name, ELEMENT_ITEM) == 0) {
3569                         /*create item in results command */
3570                         Item *item = create_item();
3571                         if (item == NULL) {
3572                                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
3573                                 goto return_part;
3574                         }
3575                         pResults->private.results.item = item;
3576
3577                         WBXMLTreeNode *grandchild = NULL;
3578
3579                         for (grandchild = child->children; grandchild != NULL; grandchild = grandchild->next) {
3580                                 if (grandchild->type != WBXML_TREE_ELEMENT_NODE) continue;
3581
3582                                 const char *grandchild_xml_name = NULL;
3583                                 grandchild_xml_name = (const char *)wbxml_tag_get_xml_name(grandchild->name);
3584
3585                                 if (strcmp(grandchild_xml_name, ELEMENT_SOURCE) == 0) {
3586                                         Location *pSourceLocation = _get_location(grandchild);
3587                                         if (pSourceLocation == NULL) {
3588                                                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
3589                                                 goto return_part;
3590                                         }
3591                                         pResults->private.results.item->source = pSourceLocation;
3592                                 } else if (strcmp(grandchild_xml_name, ELEMENT_TARGET) == 0) {
3593                                         Location *pTargetLocation = _get_location(grandchild);
3594                                         if (pTargetLocation == NULL) {
3595                                                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
3596                                                 goto return_part;
3597                                         }
3598                                         pResults->private.results.item->target = pTargetLocation;
3599                                 } else if (strcmp(grandchild_xml_name, ELEMENT_DATA) == 0) {
3600                                         /* TODO data*/
3601                                 }
3602                         }
3603                 }
3604         }
3605 return_part:
3606         if (err == PROTOCOL_BINDER_OK) {
3607                 FW_LOGV("end");
3608                 *pContent = pResults;
3609         } else{
3610                 FW_LOGE("error");
3611                 free_command(pResults);
3612         }
3613         return err;
3614 }
3615
3616 static PROTOCOL_BINDER_ERROR __oma_ds_binder_put_command_reverse_converter_function(Reverse_protocol_binder *pReverse_binder,
3617                                                                                                                                                         WBXMLTreeNode *wbxml_dom_node,
3618                                                                                                                                                         Content_Ptr *pContent)
3619 {
3620         FW_LOGV("start");
3621         PROTOCOL_BINDER_ERROR err = PROTOCOL_BINDER_OK;
3622
3623         SyncHdr *pSyncHdr = (SyncHdr *)reverse_protocol_binder_get_user_data(pReverse_binder);
3624
3625         /* get data from dom tree */
3626         Command *pPut = (Command *)calloc(1, sizeof(Command));
3627         if (pPut == NULL) {
3628                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
3629                 FW_LOGE("pPut is null");
3630                 goto return_part;
3631         }
3632
3633         pPut->type = COMMAND_TYPE_PUT;
3634         pPut->msgID = pSyncHdr->messageID;
3635         pPut->refCount = 1;
3636
3637         WBXMLTreeNode *child = NULL;
3638
3639         for (child = wbxml_dom_node->children; child != NULL; child = child->next) {
3640                 if (child->type != WBXML_TREE_ELEMENT_NODE) continue;
3641
3642                 const char *child_xml_name = NULL;
3643                 child_xml_name = (const char *)wbxml_tag_get_xml_name(child->name);
3644
3645                 if (strcmp(child_xml_name, ELEMENT_CMDID) == 0) {
3646                         char *cmd_id = NULL;
3647                         err = get_text_pointer_from_wbxml_node(child, &cmd_id);
3648                         if (err != PROTOCOL_BINDER_OK) {
3649                                 goto return_part;
3650                         }
3651                         FW_LOGV("CmdID = [%s]" , cmd_id);
3652                         if (cmd_id != NULL)
3653                                 pPut->cmdID = atoi(cmd_id);
3654                 } else if (strcmp(child_xml_name, ELEMENT_NORESP) == 0) {
3655                         FW_LOGV("NoResp");
3656                         pPut->noResp = 1;
3657                 } else if (strcmp(child_xml_name, ELEMENT_CRED) == 0) {
3658                         FW_LOGV("Cred\n");
3659                         Cred *pCred = NULL;
3660                         pCred = __get_cred(child);
3661                         if (pCred == NULL) {
3662                                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
3663                                 goto return_part;
3664                         }
3665                         pPut->cred = pCred;
3666                 } else if (strcmp(child_xml_name, ELEMENT_META) == 0) {
3667                         WBXMLTreeNode *grandchild = NULL;
3668
3669
3670                         for (grandchild = child->children; grandchild != NULL; grandchild = grandchild->next) {
3671                                 if (grandchild->type != WBXML_TREE_ELEMENT_NODE) continue;
3672
3673                                 const char *grandchild_xml_name = NULL;
3674                                 grandchild_xml_name = (const char *)wbxml_tag_get_xml_name(grandchild->name);
3675
3676                                 if (strcmp(grandchild_xml_name, ELEMENT_TYPE) == 0) {
3677                                         char *contentType = NULL;
3678                                         err = get_text_pointer_from_wbxml_node(grandchild, &contentType);
3679                                         if (err != PROTOCOL_BINDER_OK) {
3680                                                 goto return_part;
3681                                         }
3682                                         FW_LOGV("Content Type = [%s]" , contentType);
3683                                         if (contentType != NULL)
3684                                                 pPut->private.access.type = strdup(contentType);
3685                                 }
3686                         }
3687                 } else if (strcmp(child_xml_name, ELEMENT_ITEM) == 0) {
3688                         /*create item in put command */
3689                         Item *item = create_item();
3690                         if (item == NULL) {
3691                                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
3692                                 goto return_part;
3693                         }
3694                         pPut->private.access.item = item;
3695
3696                         WBXMLTreeNode *grandchild = NULL;
3697
3698                         for (grandchild = child->children; grandchild != NULL; grandchild = grandchild->next) {
3699                                 if (grandchild->type != WBXML_TREE_ELEMENT_NODE) continue;
3700
3701                                 const char *grandchild_xml_name = NULL;
3702                                 grandchild_xml_name = (const char *)wbxml_tag_get_xml_name(grandchild->name);
3703
3704                                 if (strcmp(grandchild_xml_name, ELEMENT_SOURCE) == 0) {
3705                                         Location *pSourceLocation = _get_location(grandchild);
3706                                         if (pSourceLocation == NULL) {
3707                                                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
3708                                                 goto return_part;
3709                                         }
3710                                         pPut->private.access.item->source = pSourceLocation;
3711                                 } else if (strcmp(grandchild_xml_name, ELEMENT_TARGET) == 0) {
3712                                         Location *pTargetLocation = _get_location(grandchild);
3713                                         if (pTargetLocation == NULL) {
3714                                                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
3715                                                 goto return_part;
3716                                         }
3717                                         pPut->private.access.item->target = pTargetLocation;
3718                                 } else if (strcmp(grandchild_xml_name, ELEMENT_DATA) == 0) {
3719                                         /* TODO data*/
3720                                 }
3721                         }
3722                 }
3723         }
3724
3725 return_part:
3726         if (err == PROTOCOL_BINDER_OK) {
3727                 FW_LOGV("end");
3728                 *pContent = pPut;
3729         } else{
3730                 FW_LOGE("error");
3731                 free_command(pPut);
3732         }
3733         return err;
3734 }
3735
3736 static PROTOCOL_BINDER_ERROR __oma_ds_binder_get_command_reverse_converter_function(Reverse_protocol_binder *pReverse_binder,
3737                                                                                                                                                         WBXMLTreeNode *wbxml_dom_node,
3738                                                                                                                                                         Content_Ptr *pContent)
3739 {
3740         FW_LOGV("start");
3741         PROTOCOL_BINDER_ERROR err = PROTOCOL_BINDER_OK;
3742
3743         SyncHdr *pSyncHdr = (SyncHdr *)reverse_protocol_binder_get_user_data(pReverse_binder);
3744
3745         /* get data from dom tree */
3746         Command *pGet = (Command *)calloc(1, sizeof(Command));
3747         if (pGet == NULL) {
3748                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
3749                 FW_LOGE("pGet is null");
3750                 goto return_part;
3751         }
3752
3753         pGet->type = COMMAND_TYPE_GET;
3754         pGet->msgID = pSyncHdr->messageID;
3755         pGet->refCount = 1;
3756
3757         WBXMLTreeNode *child = NULL;
3758
3759         for (child = wbxml_dom_node->children; child != NULL; child = child->next) {
3760                 if (child->type != WBXML_TREE_ELEMENT_NODE) continue;
3761
3762                 const char *child_xml_name = NULL;
3763                 child_xml_name = (const char *)wbxml_tag_get_xml_name(child->name);
3764
3765                 if (strcmp(child_xml_name, ELEMENT_CMDID) == 0) {
3766                         char *cmd_id = NULL;
3767                         err = get_text_pointer_from_wbxml_node(child, &cmd_id);
3768                         if (err != PROTOCOL_BINDER_OK) {
3769                                 goto return_part;
3770                         }
3771                         FW_LOGV("CmdID = [%s]" , cmd_id);
3772                         if (cmd_id != NULL)
3773                                 pGet->cmdID = atoi(cmd_id);
3774                 } else if (strcmp(child_xml_name, ELEMENT_NORESP) == 0) {
3775                         FW_LOGV("NoResp");
3776                         pGet->noResp = 1;
3777                 } else if (strcmp(child_xml_name, ELEMENT_CRED) == 0) {
3778                         FW_LOGV("Cred\n");
3779                         Cred *pCred = NULL;
3780                         pCred = __get_cred(child);
3781                         if (pCred == NULL) {
3782                                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
3783                                 goto return_part;
3784                         }
3785                         pGet->cred = pCred;
3786                 } else if (strcmp(child_xml_name, ELEMENT_META) == 0) {
3787
3788                         WBXMLTreeNode *grandchild = NULL;
3789
3790                         for (grandchild = child->children; grandchild != NULL; grandchild = grandchild->next) {
3791                                 if (grandchild->type != WBXML_TREE_ELEMENT_NODE) continue;
3792
3793                                 const char *grandchild_xml_name = NULL;
3794                                 grandchild_xml_name = (const char *)wbxml_tag_get_xml_name(grandchild->name);
3795
3796                                 if (strcmp(grandchild_xml_name, ELEMENT_TYPE) == 0) {
3797                                         char *contentType = NULL;
3798                                         err = get_text_pointer_from_wbxml_node(grandchild, &contentType);
3799                                         if (err != PROTOCOL_BINDER_OK) {
3800                                                 goto return_part;
3801                                         }
3802                                         FW_LOGV("Content Type = [%s]" , contentType);
3803                                         if (contentType != NULL)
3804                                                 pGet->private.access.type = strdup(contentType);
3805                                 }
3806                         }
3807                 } else if (strcmp(child_xml_name, ELEMENT_ITEM) == 0) {
3808                         /*create item in put command */
3809                         Item *item = create_item();
3810                         if (item == NULL) {
3811                                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
3812                                 goto return_part;
3813                         }
3814                         pGet->private.access.item = item;
3815
3816                         WBXMLTreeNode *grandchild = NULL;
3817                         for (grandchild = child->children; grandchild != NULL; grandchild = grandchild->next) {
3818                                 if (grandchild->type != WBXML_TREE_ELEMENT_NODE) continue;
3819
3820                                 const char *grandchild_xml_name = NULL;
3821                                 grandchild_xml_name = (const char *)wbxml_tag_get_xml_name(grandchild->name);
3822
3823                                 if (strcmp(grandchild_xml_name, ELEMENT_SOURCE) == 0) {
3824                                         Location *pSourceLocation = _get_location(grandchild);
3825                                         if (pSourceLocation == NULL) {
3826                                                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
3827                                                 goto return_part;
3828                                         }
3829                                         pGet->private.access.item->source = pSourceLocation;
3830                                 } else if (strcmp(grandchild_xml_name, ELEMENT_TARGET) == 0) {
3831                                         Location *pTargetLocation = _get_location(grandchild);
3832                                         if (pTargetLocation == NULL) {
3833                                                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
3834                                                 goto return_part;
3835                                         }
3836                                         pGet->private.access.item->target = pTargetLocation;
3837                                 } else if (strcmp(grandchild_xml_name, ELEMENT_DATA) == 0) {
3838                                         /* TODO data*/
3839                                 }
3840                         }
3841                 }
3842         }
3843
3844 return_part:
3845         if (err == PROTOCOL_BINDER_OK) {
3846                 FW_LOGV("end");
3847                 *pContent = pGet;
3848         } else{
3849                 FW_LOGE("error");
3850                 free_command(pGet);
3851         }
3852         return err;
3853 }
3854
3855
3856 static PROTOCOL_BINDER_ERROR __oma_ds_binder_alert_command_reverse_converter_function(Reverse_protocol_binder *pReverse_binder,
3857                                                                                                                                                         WBXMLTreeNode *wbxml_dom_node,
3858                                                                                                                                                         Content_Ptr *pContent)
3859 {
3860         FW_LOGV("start");
3861         PROTOCOL_BINDER_ERROR err = PROTOCOL_BINDER_OK;
3862
3863         SyncHdr *pSyncHdr = (SyncHdr *)reverse_protocol_binder_get_user_data(pReverse_binder);
3864
3865         /* get data from dom tree */
3866         Command *pAlert = (Command *)calloc(1, sizeof(Command));
3867         if (pAlert == NULL) {
3868                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
3869                 FW_LOGE("pAlert is null");
3870                 goto return_part;
3871         }
3872
3873         pAlert->type = COMMAND_TYPE_ALERT;
3874         pAlert->msgID = pSyncHdr->messageID;
3875         pAlert->refCount = 1;
3876
3877         WBXMLTreeNode *child = NULL;
3878
3879         for (child = wbxml_dom_node->children; child != NULL; child = child->next) {
3880                 if (child->type != WBXML_TREE_ELEMENT_NODE) continue;
3881
3882                 const char *child_xml_name = NULL;
3883                 child_xml_name = (const char *)wbxml_tag_get_xml_name(child->name);
3884
3885                 if (strcmp(child_xml_name, ELEMENT_CMDID) == 0) {
3886                         char *cmd_id = NULL;
3887                         err = get_text_pointer_from_wbxml_node(child, &cmd_id);
3888                         if (err != PROTOCOL_BINDER_OK) {
3889                                 goto return_part;
3890                         }
3891                         FW_LOGV("CmdID = [%s]" , cmd_id);
3892                         if (cmd_id != NULL)
3893                                 pAlert->cmdID = atoi(cmd_id);
3894                 } else if (strcmp(child_xml_name, ELEMENT_NORESP) == 0) {
3895                         FW_LOGV("NoResp");
3896                         pAlert->noResp = 1;
3897                 } else if (strcmp(child_xml_name, ELEMENT_CRED) == 0) {
3898                         FW_LOGV("Cred\n");
3899                         Cred *pCred = NULL;
3900                         pCred = __get_cred(child);
3901                         if (pCred == NULL) {
3902                                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
3903                                 goto return_part;
3904                         }
3905                         pAlert->cred = pCred;
3906                 } else if (strcmp(child_xml_name, ELEMENT_DATA) == 0) {
3907                         char *data = NULL;
3908                         err = get_text_pointer_from_wbxml_node(child, &data);
3909                         if (err != PROTOCOL_BINDER_OK) {
3910                                 goto return_part;
3911                         }
3912                         FW_LOGV("Data = [%s]" , data);
3913                         if (data != NULL)
3914                                 pAlert->private.alert.type = atoi(data);
3915                 } else if (strcmp(child_xml_name, ELEMENT_ITEM) == 0) {
3916                         WBXMLTreeNode *grandchild = NULL;
3917
3918                         for (grandchild = child->children; grandchild != NULL; grandchild = grandchild->next) {
3919                                 if (grandchild->type != WBXML_TREE_ELEMENT_NODE) continue;
3920
3921                                 const char *grandchild_xml_name = NULL;
3922                                 grandchild_xml_name = (const char *)wbxml_tag_get_xml_name(grandchild->name);
3923
3924                                 if (strcmp(grandchild_xml_name, ELEMENT_SOURCE) == 0) {
3925                                         Location *pSourceLocation = _get_location(grandchild);
3926                                         if (pSourceLocation == NULL) {
3927                                                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
3928                                                 goto return_part;
3929                                         }
3930                                         pAlert->source = pSourceLocation;
3931                                 } else if (strcmp(grandchild_xml_name, ELEMENT_TARGET) == 0) {
3932                                         Location *pTargetLocation = _get_location(grandchild);
3933                                         if (pTargetLocation == NULL) {
3934                                                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
3935                                                 goto return_part;
3936                                         }
3937                                         pAlert->target = pTargetLocation;
3938                                 } else if (strcmp(grandchild_xml_name, ELEMENT_META) == 0) {
3939
3940                                         WBXMLTreeNode *grandgrandchild = NULL;
3941                                         for (grandgrandchild = grandchild->children; grandgrandchild != NULL; grandgrandchild = grandgrandchild->next) {
3942                                                 if (grandgrandchild->type != WBXML_TREE_ELEMENT_NODE) continue;
3943
3944                                                 const char *grandgrandchild_xml_name = NULL;
3945                                                 grandgrandchild_xml_name = (const char *)wbxml_tag_get_xml_name(grandgrandchild->name);
3946
3947                                                 if (strcmp(grandgrandchild_xml_name, ELEMENT_ANCHOR) == 0) {
3948                                                         Anchor *pAnchor = _get_anchor(grandgrandchild);
3949                                                         if (pAnchor == NULL) {
3950                                                                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
3951                                                                 goto return_part;
3952                                                         }
3953                                                         pAlert->private.alert.anchor = pAnchor;
3954                                                 } else if (strcmp(grandgrandchild_xml_name, ELEMENT_MAXOBJSIZE) == 0) {
3955                                                         char *maxObjSize = NULL;
3956                                                         err = get_text_pointer_from_wbxml_node(grandgrandchild, &maxObjSize);
3957                                                         if (err != PROTOCOL_BINDER_OK) {
3958                                                                 goto return_part;
3959                                                         }
3960                                                         FW_LOGV("MaxObjSize = [%s]" , maxObjSize);
3961                                                         if (maxObjSize != NULL)
3962                                                                 pAlert->private.alert.maxObjSize = atoi(maxObjSize);
3963                                                 }
3964                                         }
3965                                 }
3966                         }
3967                 }
3968         }
3969
3970 return_part:
3971         if (err == PROTOCOL_BINDER_OK) {
3972                 FW_LOGV("end");
3973                 *pContent = pAlert;
3974         } else{
3975                 FW_LOGE("error");
3976                 free_command(pAlert);
3977         }
3978         return err;
3979 }
3980
3981 static PROTOCOL_BINDER_ERROR __oma_ds_binder_sync_end_command_reverse_converter_function(Reverse_protocol_binder *pReverse_binder,
3982                                                                                                                                                         WBXMLTreeNode *wbxml_dom_node,
3983                                                                                                                                                         Content_Ptr *pContent)
3984 {
3985         FW_LOGV("start");
3986         PROTOCOL_BINDER_ERROR err = PROTOCOL_BINDER_OK;
3987
3988         SyncHdr *pSyncHdr = (SyncHdr *)reverse_protocol_binder_get_user_data(pReverse_binder);
3989
3990         /* get data from dom tree */
3991         Command *pSyncEnd = (Command *)calloc(1, sizeof(Command));
3992         if (pSyncEnd == NULL) {
3993                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
3994                 FW_LOGE("pSyncEnd is null");
3995                 goto return_part;
3996         }
3997
3998         pSyncEnd->type = COMMAND_TYPE_SYNC_END;;
3999         pSyncEnd->msgID = pSyncHdr->messageID;
4000         pSyncEnd->refCount = 1;
4001
4002 return_part:
4003         if (err == PROTOCOL_BINDER_OK) {
4004                 FW_LOGV("end");
4005                 *pContent = pSyncEnd;
4006         } else{
4007                 FW_LOGE("error");
4008                 free_command(pSyncEnd);
4009         }
4010         return err;
4011 }
4012
4013
4014
4015 static PROTOCOL_BINDER_ERROR __oma_ds_binder_sync_start_command_reverse_converter_function(Reverse_protocol_binder *pReverse_binder,
4016                                                                                                                                                         WBXMLTreeNode *wbxml_dom_node,
4017                                                                                                                                                         Content_Ptr *pContent)
4018 {
4019         FW_LOGV("start");
4020         PROTOCOL_BINDER_ERROR err = PROTOCOL_BINDER_OK;
4021
4022         SyncHdr *pSyncHdr = (SyncHdr *)reverse_protocol_binder_get_user_data(pReverse_binder);
4023
4024         /* get data from dom tree */
4025         Command *pSync = (Command *)calloc(1, sizeof(Command));
4026         if (pSync == NULL) {
4027                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
4028                 FW_LOGE("pSync is null");
4029                 goto return_part;
4030         }
4031
4032         pSync->type = COMMAND_TYPE_SYNC_START;;
4033         pSync->msgID = pSyncHdr->messageID;
4034         pSync->refCount = 1;
4035
4036         WBXMLTreeNode *child = NULL;
4037
4038         for (child = wbxml_dom_node->children; child != NULL; child = child->next) {
4039                 if (child->type != WBXML_TREE_ELEMENT_NODE) continue;
4040
4041                 const char *child_xml_name = NULL;
4042                 child_xml_name = (const char *)wbxml_tag_get_xml_name(child->name);
4043
4044                 if (strcmp(child_xml_name, ELEMENT_CMDID) == 0) {
4045                         char *cmd_id = NULL;
4046                         err = get_text_pointer_from_wbxml_node(child, &cmd_id);
4047                         if (err != PROTOCOL_BINDER_OK) {
4048                                 goto return_part;
4049                         }
4050                         FW_LOGV("CmdID = [%s]" , cmd_id);
4051                         if (cmd_id != NULL)
4052                                 pSync->cmdID = atoi(cmd_id);
4053                 } else if (strcmp(child_xml_name, ELEMENT_NORESP) == 0) {
4054                         FW_LOGV("NoResp");
4055                         pSync->noResp = 1;
4056                 } else if (strcmp(child_xml_name, ELEMENT_CRED) == 0) {
4057                         FW_LOGV("Cred\n");
4058                         Cred *pCred = NULL;
4059                         pCred = __get_cred(child);
4060                         if (pCred == NULL) {
4061                                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
4062                                 goto return_part;
4063                         }
4064                         pSync->cred = pCred;
4065                 } else if (strcmp(child_xml_name, ELEMENT_TARGET) == 0) {
4066                         Location *pTargetLocation = _get_location(child);
4067                         if (pTargetLocation == NULL) {
4068                                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
4069                                 goto return_part;
4070                         }
4071                         pSync->target = pTargetLocation;
4072                 } else if (strcmp(child_xml_name, ELEMENT_SOURCE) == 0) {
4073                         Location *pSourceLocation = _get_location(child);
4074                         if (pSourceLocation == NULL) {
4075                                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
4076                                 goto return_part;
4077                         }
4078                         pSync->source = pSourceLocation;
4079                 } else if (strcmp(child_xml_name, ELEMENT_META) == 0) {
4080                         /*TODO meta*/
4081                 } else if (strcmp(child_xml_name, ELEMENT_NUMBEROFCHANGES) == 0) {
4082                         char *numOfChanges = NULL;
4083                         err = get_text_pointer_from_wbxml_node(child, &numOfChanges);
4084                         if (err != PROTOCOL_BINDER_OK) {
4085                                 goto return_part;
4086                         }
4087                         FW_LOGV("NumberOfChanges = [%s]" , numOfChanges);
4088
4089                         pSync->private.sync.hasNumChanged = 1;
4090                         if (numOfChanges != NULL)
4091                                 pSync->private.sync.numChanged = atoi(numOfChanges);
4092                 }
4093         }
4094
4095 return_part:
4096         if (err == PROTOCOL_BINDER_OK) {
4097                 FW_LOGV("end");
4098                 *pContent = pSync;
4099         } else{
4100                 FW_LOGE("error");
4101                 free_command(pSync);
4102         }
4103         return err;
4104 }
4105
4106 static PROTOCOL_BINDER_ERROR __oma_ds_binder_add_command_reverse_converter_function(Reverse_protocol_binder *pReverse_binder,
4107                                                                                                                                                         WBXMLTreeNode *wbxml_dom_node,
4108                                                                                                                                                         Content_Ptr *pContent)
4109 {
4110         FW_LOGV("start");
4111         PROTOCOL_BINDER_ERROR err = PROTOCOL_BINDER_OK;
4112
4113         SyncHdr *pSyncHdr = (SyncHdr *)reverse_protocol_binder_get_user_data(pReverse_binder);
4114
4115         /* get data from dom tree */
4116         Command *pAdd = (Command *)calloc(1, sizeof(Command));
4117         if (pAdd == NULL) {
4118                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
4119                 FW_LOGE("pAdd is null");
4120                 goto return_part;
4121         }
4122
4123         pAdd->type = COMMAND_TYPE_ADD;;
4124         pAdd->msgID = pSyncHdr->messageID;
4125         pAdd->private.change.type = CHANGE_ADD;
4126         pAdd->refCount = 1;
4127
4128         Item *item = NULL;
4129
4130         WBXMLTreeNode *child = NULL;
4131
4132         for (child = wbxml_dom_node->children; child != NULL; child = child->next) {
4133                 if (child->type != WBXML_TREE_ELEMENT_NODE) continue;
4134
4135                 const char *child_xml_name = NULL;
4136                 child_xml_name = (const char *)wbxml_tag_get_xml_name(child->name);
4137
4138                 if (strcmp(child_xml_name, ELEMENT_CMDID) == 0) {
4139                         char *cmd_id = NULL;
4140                         err = get_text_pointer_from_wbxml_node(child, &cmd_id);
4141                         if (err != PROTOCOL_BINDER_OK) {
4142                                 goto return_part;
4143                         }
4144                         FW_LOGV("CmdID = [%s]" , cmd_id);
4145                         if (cmd_id != NULL)
4146                                 pAdd->cmdID = atoi(cmd_id);
4147                 } else if (strcmp(child_xml_name, ELEMENT_NORESP) == 0) {
4148                         FW_LOGV("NoResp");
4149                         pAdd->noResp = 1;
4150                 } else if (strcmp(child_xml_name, ELEMENT_CRED) == 0) {
4151                         FW_LOGV("Cred\n");
4152                         Cred *pCred = NULL;
4153                         pCred = __get_cred(child);
4154                         if (pCred == NULL) {
4155                                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
4156                                 goto return_part;
4157                         }
4158                         pAdd->cred = pCred;
4159                 } else if (strcmp(child_xml_name, ELEMENT_META) == 0) {
4160                         WBXMLTreeNode *grandchild = NULL;
4161
4162
4163                         item = create_item();
4164                         if (item == NULL) {
4165                                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
4166                                 goto return_part;
4167                         }
4168
4169                         for (grandchild = child->children; grandchild != NULL; grandchild = grandchild->next) {
4170                                 if (grandchild->type != WBXML_TREE_ELEMENT_NODE) continue;
4171
4172                                 const char *grandchild_xml_name = NULL;
4173                                 grandchild_xml_name = (const char *)wbxml_tag_get_xml_name(grandchild->name);
4174
4175                                 if (strcmp(grandchild_xml_name, ELEMENT_TYPE) == 0) {
4176                                         char *contentType = NULL;
4177                                         err = get_text_pointer_from_wbxml_node(grandchild, &contentType);
4178                                         if (err != PROTOCOL_BINDER_OK) {
4179                                                 goto return_part;
4180                                         }
4181                                         FW_LOGV("Content Type = [%s]" , contentType);
4182                                         if (contentType != NULL)
4183                                                 item->contenttype = strdup(contentType);
4184                                 } else if (strcmp(grandchild_xml_name, ELEMENT_SIZE) == 0) {
4185                                         char *size = NULL;
4186                                         err = get_text_pointer_from_wbxml_node(grandchild, &size);
4187                                         if (err != PROTOCOL_BINDER_OK) {
4188                                                 goto return_part;
4189                                         }
4190                                         FW_LOGV("Size = [%s]" , size);
4191                                         if (size != NULL)
4192                                                 item->size = atoi(size);
4193                                 }
4194                         }
4195                 } else if (strcmp(child_xml_name, ELEMENT_ITEM) == 0) {
4196
4197                         if (!item) {
4198                                 item =  create_item();
4199                                 if (item == NULL) {
4200                                         err = PROTOCOL_BINDER_OUT_OF_MEMORY;
4201                                         goto return_part;
4202                                 }
4203                         }
4204
4205                         WBXMLTreeNode *grandchild = NULL;
4206                         for (grandchild = child->children; grandchild != NULL; grandchild = grandchild->next) {
4207                                 if (grandchild->type != WBXML_TREE_ELEMENT_NODE) continue;
4208
4209                                 const char *grandchild_xml_name = NULL;
4210                                 grandchild_xml_name = (const char *)wbxml_tag_get_xml_name(grandchild->name);
4211
4212                                 if (strcmp(grandchild_xml_name, ELEMENT_SOURCE) == 0) {
4213                                         Location *pSourceLocation = _get_location(grandchild);
4214                                         if (pSourceLocation == NULL) {
4215                                                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
4216                                                 goto return_part;
4217                                         }
4218                                         item->source = pSourceLocation;
4219                                 } else if (strcmp(grandchild_xml_name, ELEMENT_TARGET) == 0) {
4220                                         Location *pTargetLocation = _get_location(grandchild);
4221                                         if (pTargetLocation == NULL) {
4222                                                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
4223                                                 goto return_part;
4224                                         }
4225                                         item->target = pTargetLocation;
4226                                 } else if (strcmp(grandchild_xml_name, ELEMENT_META) == 0) {
4227                                         WBXMLTreeNode *grandgrandchild = NULL;
4228
4229                                         for (grandgrandchild = grandchild->children; grandgrandchild != NULL; grandgrandchild = grandgrandchild->next) {
4230                                                 if (grandgrandchild->type != WBXML_TREE_ELEMENT_NODE) continue;
4231
4232                                                 const char *grandgrandchild_xml_name = NULL;
4233                                                 grandgrandchild_xml_name = (const char *)wbxml_tag_get_xml_name(grandgrandchild->name);
4234
4235                                                 if (strcmp(grandgrandchild_xml_name, ELEMENT_TYPE) == 0) {
4236                                                         char *contentType = NULL;
4237                                                         err = get_text_pointer_from_wbxml_node(grandgrandchild, &contentType);
4238                                                         if (err != PROTOCOL_BINDER_OK) {
4239                                                                 goto return_part;
4240                                                         }
4241                                                         FW_LOGV("Content Type = [%s]" , contentType);
4242                                                         if (contentType != NULL)
4243                                                                 item->contenttype = strdup(contentType);
4244                                                 } else if (strcmp(grandgrandchild_xml_name, ELEMENT_SIZE) == 0) {
4245                                                         char *size = NULL;
4246                                                         err = get_text_pointer_from_wbxml_node(grandgrandchild, &size);
4247                                                         if (err != PROTOCOL_BINDER_OK) {
4248                                                                 goto return_part;
4249                                                         }
4250                                                         FW_LOGV("Size = [%s]" , size);
4251                                                         if (size != NULL)
4252                                                                 item->size = atoi(size);
4253                                                 }
4254                                         }
4255                                 } else if (strcmp(grandchild_xml_name, ELEMENT_DATA) == 0) {
4256                                         char *data = NULL;
4257                                         err = get_text_pointer_from_wbxml_cdata_node(grandchild, &data);
4258                                         if (err != PROTOCOL_BINDER_OK) {
4259                                                 goto return_part;
4260                                         }
4261                                         FW_LOGV("Data = [%s]" , data);
4262                                         if (data != NULL)
4263                                                 item->private.data = strdup(data);
4264                                         item->dataType = ITEM_DATA;
4265                                 } else if (strcmp(grandchild_xml_name, ELEMENT_MOREDATA) == 0) {
4266                                         FW_LOGV("MoreData");
4267                                         item->moreData = 1;
4268                                 }
4269                         }
4270                         pAdd->private.change.items = g_list_append(pAdd->private.change.items, item);
4271                         item = NULL;
4272                 }
4273         }
4274
4275 return_part:
4276         if (err == PROTOCOL_BINDER_OK) {
4277                 FW_LOGV("end");
4278                 *pContent = pAdd;
4279         } else{
4280                 FW_LOGE("error");
4281                 free_command(pAdd);
4282         }
4283         return err;
4284 }
4285
4286 static PROTOCOL_BINDER_ERROR __oma_ds_binder_replace_command_reverse_converter_function(Reverse_protocol_binder *pReverse_binder,
4287                                                                                                                                                         WBXMLTreeNode *wbxml_dom_node,
4288                                                                                                                                                         Content_Ptr *pContent)
4289 {
4290         FW_LOGV("start");
4291         PROTOCOL_BINDER_ERROR err = PROTOCOL_BINDER_OK;
4292
4293         SyncHdr *pSyncHdr = (SyncHdr *)reverse_protocol_binder_get_user_data(pReverse_binder);
4294
4295         /* get data from dom tree */
4296         Command *pReplace = (Command *)calloc(1, sizeof(Command));
4297         if (pReplace == NULL) {
4298                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
4299                 FW_LOGE("pReplace is null");
4300                 goto return_part;
4301         }
4302
4303         pReplace->type = COMMAND_TYPE_REPLACE;;
4304         pReplace->msgID = pSyncHdr->messageID;
4305         pReplace->private.change.type = CHANGE_REPLACE;
4306         pReplace->refCount  = 1;
4307
4308         Item *item = NULL;
4309
4310         WBXMLTreeNode *child = NULL;
4311
4312         for (child = wbxml_dom_node->children; child != NULL; child = child->next) {
4313                 if (child->type != WBXML_TREE_ELEMENT_NODE) continue;
4314
4315                 const char *child_xml_name = NULL;
4316                 child_xml_name = (const char *)wbxml_tag_get_xml_name(child->name);
4317
4318                 if (strcmp(child_xml_name, ELEMENT_CMDID) == 0) {
4319                         char *cmd_id = NULL;
4320                         err = get_text_pointer_from_wbxml_node(child, &cmd_id);
4321                         if (err != PROTOCOL_BINDER_OK) {
4322                                 goto return_part;
4323                         }
4324                         FW_LOGV("CmdID = [%s]" , cmd_id);
4325                         if (cmd_id != NULL)
4326                                 pReplace->cmdID = atoi(cmd_id);
4327
4328                 } else if (strcmp(child_xml_name, ELEMENT_NORESP) == 0) {
4329                         FW_LOGV("NoResp");
4330                         pReplace->noResp = 1;
4331                 } else if (strcmp(child_xml_name, ELEMENT_CRED) == 0) {
4332                         FW_LOGV("Cred\n");
4333                         Cred *pCred = NULL;
4334                         pCred = __get_cred(child);
4335                         if (pCred == NULL) {
4336                                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
4337                                 goto return_part;
4338                         }
4339                         pReplace->cred = pCred;
4340                 } else if (strcmp(child_xml_name, ELEMENT_META) == 0) {
4341
4342                         item = create_item();
4343                         if (item == NULL) {
4344                                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
4345                                 goto return_part;
4346                         }
4347                         WBXMLTreeNode *grandchild = NULL;
4348                         for (grandchild = child->children; grandchild != NULL; grandchild = grandchild->next) {
4349                                 if (grandchild->type != WBXML_TREE_ELEMENT_NODE) continue;
4350
4351                                 const char *grandchild_xml_name = NULL;
4352                                 grandchild_xml_name = (const char *)wbxml_tag_get_xml_name(grandchild->name);
4353
4354                                 if (strcmp(grandchild_xml_name, ELEMENT_TYPE) == 0) {
4355                                         char *contentType = NULL;
4356                                         err = get_text_pointer_from_wbxml_node(grandchild, &contentType);
4357                                         if (err != PROTOCOL_BINDER_OK) {
4358                                                 goto return_part;
4359                                         }
4360                                         FW_LOGV("Content Type = [%s]" , contentType);
4361                                         if (contentType != NULL)
4362                                                 item->contenttype = strdup(contentType);
4363                                 } else if (strcmp(grandchild_xml_name, ELEMENT_SIZE) == 0) {
4364                                         char *size = NULL;
4365                                         err = get_text_pointer_from_wbxml_node(grandchild, &size);
4366                                         if (err != PROTOCOL_BINDER_OK) {
4367                                                 goto return_part;
4368                                         }
4369                                         FW_LOGV("Size = [%s]" , size);
4370                                         if (size != NULL)
4371                                                 item->size = atoi(size);
4372                                 }
4373                         }
4374                 } else if (strcmp(child_xml_name, ELEMENT_ITEM) == 0) {
4375
4376                         if (!item) {
4377                                 item =  create_item();
4378                                 if (item == NULL) {
4379                                         err = PROTOCOL_BINDER_OUT_OF_MEMORY;
4380                                         goto return_part;
4381                                 }
4382                         }
4383
4384                         WBXMLTreeNode *grandchild = NULL;
4385                         for (grandchild = child->children; grandchild != NULL; grandchild = grandchild->next) {
4386                                 if (grandchild->type != WBXML_TREE_ELEMENT_NODE) continue;
4387
4388                                 const char *grandchild_xml_name = NULL;
4389                                 grandchild_xml_name = (const char *)wbxml_tag_get_xml_name(grandchild->name);
4390
4391                                 if (strcmp(grandchild_xml_name, ELEMENT_SOURCE) == 0) {
4392                                         Location *pSourceLocation = _get_location(grandchild);
4393                                         if (pSourceLocation == NULL) {
4394                                                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
4395                                                 goto return_part;
4396                                         }
4397                                         item->source = pSourceLocation;
4398                                 } else if (strcmp(grandchild_xml_name, ELEMENT_TARGET) == 0) {
4399                                         Location *pTargetLocation = _get_location(grandchild);
4400                                         if (pTargetLocation == NULL) {
4401                                                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
4402                                                 goto return_part;
4403                                         }
4404                                         item->target = pTargetLocation;
4405                                 } else if (strcmp(grandchild_xml_name, ELEMENT_META) == 0) {
4406                                         WBXMLTreeNode *grandgrandchild = NULL;
4407
4408                                         for (grandgrandchild = grandchild->children; grandgrandchild != NULL; grandgrandchild = grandgrandchild->next) {
4409                                                 if (grandgrandchild->type != WBXML_TREE_ELEMENT_NODE) continue;
4410
4411                                                 const char *grandgrandchild_xml_name = NULL;
4412                                                 grandgrandchild_xml_name = (const char *)wbxml_tag_get_xml_name(grandgrandchild->name);
4413
4414                                                 if (strcmp(grandgrandchild_xml_name, ELEMENT_TYPE) == 0) {
4415                                                         char *contentType = NULL;
4416                                                         err = get_text_pointer_from_wbxml_node(grandgrandchild, &contentType);
4417                                                         if (err != PROTOCOL_BINDER_OK) {
4418                                                                 goto return_part;
4419                                                         }
4420                                                         FW_LOGV("Content Type = [%s]" , contentType);
4421                                                         if (contentType != NULL)
4422                                                                 item->contenttype = strdup(contentType);
4423                                                 } else if (strcmp(grandgrandchild_xml_name, ELEMENT_SIZE) == 0) {
4424                                                         char *size = NULL;
4425                                                         err = get_text_pointer_from_wbxml_node(grandgrandchild, &size);
4426                                                         if (err != PROTOCOL_BINDER_OK) {
4427                                                                 goto return_part;
4428                                                         }
4429                                                         FW_LOGV("Size = [%s]" , size);
4430                                                         if (size != NULL)
4431                                                                 item->size = atoi(size);
4432                                                 }
4433                                         }
4434
4435                                 } else if (strcmp(grandchild_xml_name, ELEMENT_DATA) == 0) {
4436                                         char *data = NULL;
4437                                         err = get_text_pointer_from_wbxml_cdata_node(grandchild, &data);
4438                                         if (err != PROTOCOL_BINDER_OK) {
4439                                                 goto return_part;
4440                                         }
4441                                         FW_LOGV("Data = [%s]" , data);
4442                                         if (data != NULL)
4443                                                 item->private.data = strdup(data);
4444                                         item->dataType = ITEM_DATA;
4445                                 }
4446                         }
4447                         pReplace->private.change.items = g_list_append(pReplace->private.change.items, item);
4448                         item = NULL;
4449                 }
4450         }
4451
4452 return_part:
4453         if (err == PROTOCOL_BINDER_OK) {
4454                 FW_LOGV("end");
4455                 *pContent = pReplace;
4456         } else{
4457                 FW_LOGE("error");
4458                 free_command(pReplace);
4459         }
4460         return err;
4461 }
4462
4463 static PROTOCOL_BINDER_ERROR __oma_ds_binder_delete_command_reverse_converter_function(Reverse_protocol_binder *pReverse_binder,
4464                                                                                                                                                         WBXMLTreeNode *wbxml_dom_node,
4465                                                                                                                                                         Content_Ptr *pContent)
4466 {
4467         FW_LOGV("start");
4468         PROTOCOL_BINDER_ERROR err = PROTOCOL_BINDER_OK;
4469
4470         SyncHdr *pSyncHdr = (SyncHdr *)reverse_protocol_binder_get_user_data(pReverse_binder);
4471
4472         /* get data from dom tree */
4473         Command *pDelete = (Command *)calloc(1, sizeof(Command));
4474         if (pDelete == NULL) {
4475                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
4476                 FW_LOGE("pDelete is null");
4477                 goto return_part;
4478         }
4479
4480         pDelete->type = COMMAND_TYPE_DELETE;
4481         pDelete->msgID = pSyncHdr->messageID;
4482         pDelete->private.change.type = CHANGE_DELETE;
4483         pDelete->refCount = 1;
4484
4485         WBXMLTreeNode *child = NULL;
4486
4487         for (child = wbxml_dom_node->children; child != NULL; child = child->next) {
4488                 if (child->type != WBXML_TREE_ELEMENT_NODE) continue;
4489
4490                 const char *child_xml_name = NULL;
4491                 child_xml_name = (const char *)wbxml_tag_get_xml_name(child->name);
4492
4493                 Item *item = NULL;
4494                 if (strcmp(child_xml_name, ELEMENT_CMDID) == 0) {
4495                         char *cmd_id = NULL;
4496                         err = get_text_pointer_from_wbxml_node(child, &cmd_id);
4497                         if (err != PROTOCOL_BINDER_OK) {
4498                                 goto return_part;
4499                         }
4500                         FW_LOGV("CmdID = [%s]" , cmd_id);
4501                         if (cmd_id != NULL)
4502                                 pDelete->cmdID = atoi(cmd_id);
4503                 } else if (strcmp(child_xml_name, ELEMENT_NORESP) == 0) {
4504                         FW_LOGV("NoResp");
4505                         pDelete->noResp = 1;
4506                 } else if (strcmp(child_xml_name, ELEMENT_CRED) == 0) {
4507                         FW_LOGV("Cred\n");
4508                         Cred *pCred = NULL;
4509                         pCred = __get_cred(child);
4510                         if (pCred == NULL) {
4511                                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
4512                                 goto return_part;
4513                         }
4514                         pDelete->cred = pCred;
4515                 } else if (strcmp(child_xml_name, ELEMENT_META) == 0) {
4516                         WBXMLTreeNode *grandchild = NULL;
4517
4518
4519                         /* create Item */
4520                         item = create_item();
4521                         if (item == NULL) {
4522                                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
4523                                 goto return_part;
4524                         }
4525
4526                         for (grandchild = child->children; grandchild != NULL; grandchild = grandchild->next) {
4527                                 if (grandchild->type != WBXML_TREE_ELEMENT_NODE) continue;
4528
4529                                 const char *grandchild_xml_name = NULL;
4530                                 grandchild_xml_name = (const char *)wbxml_tag_get_xml_name(grandchild->name);
4531
4532                                 if (strcmp(grandchild_xml_name, ELEMENT_TYPE) == 0) {
4533                                         char *contentType = NULL;
4534                                         err = get_text_pointer_from_wbxml_node(grandchild, &contentType);
4535                                         if (err != PROTOCOL_BINDER_OK) {
4536                                                 goto return_part;
4537                                         }
4538                                         FW_LOGV("Content Type = [%s]" , contentType);
4539                                         if (contentType != NULL)
4540                                                 item->contenttype = strdup(contentType);
4541                                 }
4542                         }
4543                 } else if (strcmp(child_xml_name, ELEMENT_ITEM) == 0) {
4544                         /* create Item */
4545                         if (!item) {
4546                                 item = create_item();
4547                                 if (item == NULL) {
4548                                         err = PROTOCOL_BINDER_OUT_OF_MEMORY;
4549                                         goto return_part;
4550                                 }
4551                         }
4552                         WBXMLTreeNode *grandchild = NULL;
4553
4554                         for (grandchild = child->children; grandchild != NULL; grandchild = grandchild->next) {
4555                                 if (grandchild->type != WBXML_TREE_ELEMENT_NODE) continue;
4556
4557                                 const char *grandchild_xml_name = NULL;
4558                                 grandchild_xml_name = (const char *)wbxml_tag_get_xml_name(grandchild->name);
4559
4560                                 if (strcmp(grandchild_xml_name, ELEMENT_SOURCE) == 0) {
4561                                         Location *pSourceLocation = _get_location(grandchild);
4562                                         if (pSourceLocation == NULL) {
4563                                                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
4564                                                 goto return_part;
4565                                         }
4566                                         item->source = pSourceLocation;
4567                                 } else if (strcmp(grandchild_xml_name, ELEMENT_TARGET) == 0) {
4568                                         Location *pTargetLocation = _get_location(grandchild);
4569                                         if (pTargetLocation == NULL) {
4570                                                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
4571                                                 goto return_part;
4572                                         }
4573                                         item->target = pTargetLocation;
4574                                 } else if (strcmp(grandchild_xml_name, ELEMENT_META) == 0) {
4575
4576                                 } else if (strcmp(grandchild_xml_name, ELEMENT_DATA) == 0) {
4577
4578                                 }
4579                         }
4580                         pDelete->private.change.items = g_list_append(pDelete->private.change.items, item);
4581                 }
4582         }
4583
4584 return_part:
4585         if (err == PROTOCOL_BINDER_OK) {
4586                 FW_LOGV("end");
4587                 *pContent = pDelete;
4588         } else{
4589                 FW_LOGE("error");
4590                 free_command(pDelete);
4591         }
4592         return err;
4593 }
4594 static PROTOCOL_BINDER_ERROR __oma_ds_binder_final_reverse_converter_function(Reverse_protocol_binder *pReverse_binder,
4595                                                                                                                                                         WBXMLTreeNode *wbxml_dom_node,
4596                                                                                                                                                         Content_Ptr *pContent)
4597 {
4598         FW_LOGV("start");
4599         PROTOCOL_BINDER_ERROR err = PROTOCOL_BINDER_OK;
4600
4601         int *pFinal = (int *)1;
4602         *pContent = pFinal;
4603
4604         FW_LOGV("end");
4605         return err;
4606 }
4607
4608 static PROTOCOL_BINDER_ERROR __oma_ds_binder_status_reverse_converter_function(Reverse_protocol_binder *pReverse_binder,
4609                                                                                                                                                         WBXMLTreeNode *wbxml_dom_node,
4610                                                                                                                                                         Content_Ptr *pContent)
4611 {
4612         FW_LOGV("start");
4613         PROTOCOL_BINDER_ERROR err = PROTOCOL_BINDER_OK;
4614
4615         /* get data from dom tree */
4616         Status *pStatus = (Status *)calloc(1, sizeof(Status));
4617         if (pStatus == NULL) {
4618                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
4619                 FW_LOGE("pStatus is null");
4620                 goto return_part;
4621         }
4622
4623         WBXMLTreeNode *child = NULL;
4624         for (child = wbxml_dom_node->children; child != NULL; child = child->next) {
4625                 if (child->type != WBXML_TREE_ELEMENT_NODE) continue;
4626                 const char *child_xml_name = NULL;
4627                 child_xml_name = (const char *)wbxml_tag_get_xml_name(child->name);
4628
4629                 if (strcmp(child_xml_name, ELEMENT_CMDID) == 0) {
4630                         char *cmd_id = NULL;
4631                         err = get_text_pointer_from_wbxml_node(child, &cmd_id);
4632                         if (err != PROTOCOL_BINDER_OK) {
4633                                 goto return_part;
4634                         }
4635                         FW_LOGV("CmdID = [%s]" , cmd_id);
4636                         if (cmd_id != NULL)
4637                                 pStatus->cmdID = atoi(cmd_id);
4638                 } else if (strcmp(child_xml_name, ELEMENT_MSGREF) == 0) {
4639                         char *msgref = NULL;
4640                         err = get_text_pointer_from_wbxml_node(child, &msgref);
4641                         if (err != PROTOCOL_BINDER_OK) {
4642                                 goto return_part;
4643                         }
4644                         FW_LOGV("MsgRef = [%s]" , msgref);
4645                         if (msgref != NULL)
4646                                 pStatus->msgRef = atoi(msgref);
4647                 } else if (strcmp(child_xml_name, ELEMENT_CMDREF) == 0) {
4648                         char *cmdref = NULL;
4649                         err = get_text_pointer_from_wbxml_node(child, &cmdref);
4650                         if (err != PROTOCOL_BINDER_OK) {
4651                                 goto return_part;
4652                         }
4653                         FW_LOGV("CmdRef = [%s]" , cmdref);
4654                         if (cmdref != NULL)
4655                                 pStatus->cmdRef = atoi(cmdref);
4656                 } else if (strcmp(child_xml_name, ELEMENT_CMD) == 0) {
4657                         char *cmd = NULL;
4658                         err = get_text_pointer_from_wbxml_node(child, &cmd);
4659                         if (err != PROTOCOL_BINDER_OK) {
4660                                 goto return_part;
4661                         }
4662                         FW_LOGV("Cmd = [%s]" , cmd);
4663
4664                         pStatus->type = convert_command_type(cmd);
4665                 } else if (strcmp(child_xml_name, ELEMENT_TARGETREF) == 0) {
4666                         char *targetref = NULL;
4667                         Location *pLocation = NULL;
4668                         err = get_text_pointer_from_wbxml_node(child, &targetref);
4669                         if (err != PROTOCOL_BINDER_OK) {
4670                                 goto return_part;
4671                         }
4672                         FW_LOGV("TargetRef = [%s]" , targetref);
4673
4674                         create_location(targetref, NULL, &pLocation);
4675                         pStatus->targetRef = pLocation;
4676                 } else if (strcmp(child_xml_name, ELEMENT_SOURCEREF) == 0) {
4677                         char *sourceref = NULL;
4678                         Location *pLocation = NULL;
4679                         err = get_text_pointer_from_wbxml_node(child, &sourceref);
4680                         if (err != PROTOCOL_BINDER_OK) {
4681                                 goto return_part;
4682                         }
4683                         FW_LOGV("SourceRef = [%s]" , sourceref);
4684
4685                         create_location(sourceref, NULL, &pLocation);
4686                         pStatus->sourceRef = pLocation;
4687                 } else if (strcmp(child_xml_name, ELEMENT_CRED) == 0) {
4688                         FW_LOGV("Cred\n");
4689                         Cred *pCred = NULL;
4690                         pCred = __get_cred(child);
4691                         if (pCred == NULL) {
4692                                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
4693                                 goto return_part;
4694                         }
4695                         pStatus->cred = pCred;
4696                 } else if (strcmp(child_xml_name, ELEMENT_CHAL) == 0) {
4697                         FW_LOGV("Chal\n");
4698                         Chal *pChal = NULL;
4699                         pChal = _get_chal(child);
4700                         if (pChal == NULL) {
4701                                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
4702                                 goto return_part;
4703                         }
4704                         pStatus->chal = pChal;
4705                 } else if (strcmp(child_xml_name, ELEMENT_DATA) == 0) {
4706                         char *data = NULL;
4707                         err = get_text_pointer_from_wbxml_node(child, &data);
4708                         if (err != PROTOCOL_BINDER_OK) {
4709                                 goto return_part;
4710                         }
4711                         FW_LOGV("Data = [%s]\n" , data);
4712                         if (data != NULL)
4713                                 pStatus->data = strdup(data);
4714                 } else if (strcmp(child_xml_name, ELEMENT_ITEM) == 0) {
4715                         WBXMLTreeNode *grandchild = NULL;
4716
4717                         for (grandchild = child->children; grandchild != NULL; grandchild = grandchild->next) {
4718                                 if (grandchild->type != WBXML_TREE_ELEMENT_NODE) continue;
4719
4720                                 const char *grandchild_xml_name = NULL;
4721                                 grandchild_xml_name = (const char *)wbxml_tag_get_xml_name(grandchild->name);
4722
4723                                 if (strcmp(grandchild_xml_name, ELEMENT_SOURCE) == 0) {
4724                                         Location *pSourceLocation = _get_location(grandchild);
4725                                         if (pSourceLocation == NULL) {
4726                                                 err = PROTOCOL_BINDER_OUT_OF_MEMORY;
4727                                                 goto return_part;
4728                                         }
4729                                         pStatus->sourceRef =  pSourceLocation;
4730                                 } else if (strcmp(grandchild_xml_name, ELEMENT_TARGET) == 0) {
4731                                         /* need ? */
4732                                 } else if (strcmp(grandchild_xml_name, ELEMENT_DATA) == 0) {
4733                                         /* need ?*/
4734                                 }
4735                         }
4736                 }
4737         }
4738
4739 return_part:
4740         if (err == PROTOCOL_BINDER_OK) {
4741                 FW_LOGV("end");
4742                 *pContent = pStatus;
4743         } else{
4744                 FW_LOGE("error");
4745                 free_status(pStatus);
4746         }
4747         return err;
4748 }
4749
4750 PROTOCOL_BINDER_ERROR init_oma_ds_1_2_binder_function_set(Binder_function_set **pBinder_function_set)
4751 {
4752         PROTOCOL_BINDER_ERROR err = PROTOCOL_BINDER_OK;
4753
4754         err = init_binder_function_set(sizeof(oma_ds_binder_function_info)/sizeof(Binder_function_info),
4755                                                                         (Binder_function_info*)oma_ds_binder_function_info,
4756                                                                         pBinder_function_set);
4757
4758         return err;
4759 }
4760
4761 void free_oma_ds_1_2_binder_function_set(Binder_function_set *pBinder_function_set)
4762 {
4763         free_binder_function_set(pBinder_function_set);
4764 }
4765
4766 protocol_binder *oma_ds_1_2_binder_init(protocol_binder *pBinder, Encoding enc, bool encode_xml_header,
4767                                                                                         bool use_strtbl, bool produce_anonymous, bool use_flow_mode,
4768                                                                                         Binder_function_set *pBinder_function_set)
4769 {
4770         protocol_binder *pOutBinder = NULL;
4771
4772         pOutBinder = protocol_binder_init(pBinder, PROTOCOL_SYNCML_SYNCML12, NULL, enc,
4773                                                                 encode_xml_header, use_strtbl, produce_anonymous, use_flow_mode, NULL, NULL,
4774                                                                 pBinder_function_set);
4775
4776         if (pOutBinder == NULL) {
4777                 goto return_part;
4778         }
4779
4780 return_part:
4781         return pOutBinder;
4782 }
4783
4784
4785 PROTOCOL_BINDER_ERROR oma_ds_1_2_binder_append(protocol_binder *pBinder,
4786                                                                                                 OMA_DS_Protocol_Element protocol_element,
4787                                                                                                 Content_Ptr pContent)
4788 {
4789         PROTOCOL_BINDER_ERROR err = PROTOCOL_BINDER_OK;
4790
4791         err = protocol_binder_append(pBinder, protocol_element, pContent);
4792
4793         return err;
4794 }
4795
4796
4797 void oma_ds_1_2_binder_terminate(protocol_binder *pBinder)
4798 {
4799         protocol_binder_terminate(pBinder);
4800 }
4801
4802 PROTOCOL_BINDER_ERROR oma_ds_1_2_binder_get_stream(protocol_binder *pBinder,
4803                                                                                                         char **byte_stream,
4804                                                                                                         unsigned int *byte_stream_size)
4805 {
4806         PROTOCOL_BINDER_ERROR err =  PROTOCOL_BINDER_OK;
4807
4808         err = protocol_binder_get_stream(pBinder, byte_stream, byte_stream_size);
4809         if (err != PROTOCOL_BINDER_OK) {
4810                 goto return_part;
4811         }
4812
4813 return_part:
4814         return err;
4815 }
4816
4817 PROTOCOL_BINDER_ERROR oma_ds_1_2_binder_get_stream_size(protocol_binder *pBinder, unsigned int *byte_stream_size)
4818 {
4819         PROTOCOL_BINDER_ERROR err =  PROTOCOL_BINDER_OK;
4820
4821         err = protocol_binder_get_stream_size(pBinder, byte_stream_size);
4822         return err;
4823 }
4824
4825
4826 PROTOCOL_BINDER_ERROR oma_ds_1_2_binder_get_encoding(protocol_binder *pBinder, Encoding *enc)
4827 {
4828         PROTOCOL_BINDER_ERROR err =  PROTOCOL_BINDER_OK;
4829
4830         err = protocol_binder_get_encoding(pBinder, enc);
4831         return err;
4832 }
4833
4834 PROTOCOL_BINDER_ERROR reverse_oma_ds_1_2_binder_init(char *byte_stream,
4835                                                                                                         unsigned int byte_stream_len,
4836                                                                                                         Decoding dec,
4837                                                                                                         Binder_function_set *pBinder_function_set,
4838                                                                                                         void *user_data,
4839                                                                                                         Reverse_protocol_binder **ppBinder)
4840 {
4841         Protocol protocol = PROTOCOL_UNKNOWN;
4842         PROTOCOL_BINDER_ERROR err = reverse_protocol_binder_init(byte_stream, byte_stream_len, dec,
4843                                                                                         &protocol, pBinder_function_set, user_data, ppBinder);
4844
4845         return err;
4846 }
4847
4848 PROTOCOL_BINDER_ERROR reverse_oma_ds_1_2_binder_next(Reverse_protocol_binder *pBinder,
4849                                                                                                 OMA_DS_Protocol_Element *protocol_element,
4850                                                                                                 char **protocol_element_name,
4851                                                                                                 Content_Ptr *pContent)
4852 {
4853         PROTOCOL_BINDER_ERROR err = reverse_protocol_binder_next(pBinder,
4854                                                                                 protocol_element, protocol_element_name, pContent);
4855         return err;
4856 }