3 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 * Licensed under the Apache License, Version 2.0 (the License);
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
19 * @oma_ds_protocol_binder.c
21 * @brief This file is the source file of implementation of callback function for Protocol Binder
26 #include <sync_agent.h>
28 #include "service-adapter/protocol-binder/oma_ds_protocol_binder.h"
29 #include "service-adapter/sa_elements_internal.h"
30 #include "service-adapter/sa_command_internal.h"
31 #include "service-adapter/sa_devinf_internal.h"
32 #include "service-adapter/sa_command.h"
33 #include "service-adapter/sa_elements.h"
34 #include "service-adapter/sa_devinf.h"
35 #include "service-adapter/sa_define.h"
37 #ifndef OMADS_AGENT_LOG
39 #define LOG_TAG "OMA_DS_BINDER"
42 static sync_agent_pb_error_e __append_location_to_wbxml_node(location_s * location, sync_agent_pb_protocol_binder_info_s * binder, WBXMLTreeNode * parent_node);
44 static sync_agent_pb_error_e __append_anchor_to_wbxml_node(anchor_s * anchor, sync_agent_pb_protocol_binder_info_s * binder, WBXMLTreeNode * parent_node);
46 static sync_agent_pb_error_e __append_devinf_contenttype_to_wbxml_node(devinf_content_type_s * devinf_content_type, sync_agent_pb_protocol_binder_info_s * binder, WBXMLTreeNode * parent_node, char *node);
48 static sync_agent_pb_error_e __append_cred_to_wbxml_node(cred_s * cred, sync_agent_pb_protocol_binder_info_s * binder, WBXMLTreeNode * parent_node);
50 static sync_agent_pb_error_e _oma_ds_binder_devinf_converter_function(sync_agent_pb_protocol_binder_info_s * binder, Content_Ptr content, WBXMLTreeNode ** wbxml_dom_node);
51 static sync_agent_pb_error_e _oma_ds_binder_syncml_start_converter_function(sync_agent_pb_protocol_binder_info_s * binder, Content_Ptr content, WBXMLTreeNode ** wbxml_dom_node);
52 static sync_agent_pb_error_e _oma_ds_binder_header_converter_function(sync_agent_pb_protocol_binder_info_s * binder, Content_Ptr content, WBXMLTreeNode ** wbxml_dom_node);
53 static sync_agent_pb_error_e _oma_ds_binder_final_converter_function(sync_agent_pb_protocol_binder_info_s * binder, Content_Ptr content, WBXMLTreeNode ** wbxml_dom_node);
54 static sync_agent_pb_error_e _oma_ds_binder_body_start_converter_function(sync_agent_pb_protocol_binder_info_s * binder, Content_Ptr content, WBXMLTreeNode ** wbxml_dom_node);
55 static sync_agent_pb_error_e _oma_ds_binder_status_converter_function(sync_agent_pb_protocol_binder_info_s * binder, Content_Ptr content, WBXMLTreeNode ** wbxml_dom_node);
56 static sync_agent_pb_error_e _oma_ds_binder_alert_command_converter_function(sync_agent_pb_protocol_binder_info_s * binder, Content_Ptr content, WBXMLTreeNode ** wbxml_dom_node);
57 static sync_agent_pb_error_e _oma_ds_binder_results_command_converter_function(sync_agent_pb_protocol_binder_info_s * binder, Content_Ptr content, WBXMLTreeNode ** wbxml_dom_node);
58 static sync_agent_pb_error_e _oma_ds_binder_put_command_converter_function(sync_agent_pb_protocol_binder_info_s * binder, Content_Ptr content, WBXMLTreeNode ** wbxml_dom_node);
59 static sync_agent_pb_error_e _oma_ds_binder_get_command_converter_function(sync_agent_pb_protocol_binder_info_s * binder, Content_Ptr content, WBXMLTreeNode ** wbxml_dom_node);
60 static sync_agent_pb_error_e _oma_ds_binder_sync_start_command_converter_function(sync_agent_pb_protocol_binder_info_s * binder, Content_Ptr content, WBXMLTreeNode ** wbxml_dom_node);
61 static sync_agent_pb_error_e _oma_ds_binder_sync_end_command_converter_function(sync_agent_pb_protocol_binder_info_s * binder, Content_Ptr content, WBXMLTreeNode ** wbxml_dom_node);
62 static sync_agent_pb_error_e _oma_ds_binder_add_command_converter_function(sync_agent_pb_protocol_binder_info_s * binder, Content_Ptr content, WBXMLTreeNode ** wbxml_dom_node);
63 static sync_agent_pb_error_e _oma_ds_binder_replace_command_converter_function(sync_agent_pb_protocol_binder_info_s * binder, Content_Ptr content, WBXMLTreeNode ** wbxml_dom_node);
64 static sync_agent_pb_error_e _oma_ds_binder_delete_command_converter_function(sync_agent_pb_protocol_binder_info_s * binder, Content_Ptr content, WBXMLTreeNode ** wbxml_dom_node);
65 static sync_agent_pb_error_e _oma_ds_binder_map_command_converter_function(sync_agent_pb_protocol_binder_info_s * binder, Content_Ptr content, WBXMLTreeNode ** wbxml_dom_node);
67 static protocol_version_e __get_oma_ds_protocol_version(char *verdtd);
68 static devinf_version_e __get_oma_ds_devInf_version(char *verdtd);
69 static devinf_devtyp_e __get_oma_ds_devInf_device_type(char *dev_type);
70 static devinf_content_type_s *__get_devinf_contenttype(WBXMLTreeNode * node);
71 static location_s *_get_location(WBXMLTreeNode * node);
72 static anchor_s *_get_anchor(WBXMLTreeNode * node);
73 static cred_s *__get_cred(WBXMLTreeNode * node);
74 static chal_s *_get_chal(WBXMLTreeNode * node);
76 static sync_agent_pb_error_e _oma_ds_binder_devinf_reverse_converter_function(sync_agent_pb_protocol_binder_reverse_info_s * reverse_binder, WBXMLTreeNode * wbxml_dom_node, Content_Ptr * content);
77 static sync_agent_pb_error_e _oma_ds_binder_header_reverse_converter_function(sync_agent_pb_protocol_binder_reverse_info_s * reverse_binder, WBXMLTreeNode * wbxml_dom_node, Content_Ptr * content);
78 static sync_agent_pb_error_e _oma_ds_binder_results_command_reverse_converter_function(sync_agent_pb_protocol_binder_reverse_info_s * reverse_binder, WBXMLTreeNode * wbxml_dom_node, Content_Ptr * content);
79 static sync_agent_pb_error_e _oma_ds_binder_put_command_reverse_converter_function(sync_agent_pb_protocol_binder_reverse_info_s * reverse_binder, WBXMLTreeNode * wbxml_dom_node, Content_Ptr * content);
80 static sync_agent_pb_error_e _oma_ds_binder_get_command_reverse_converter_function(sync_agent_pb_protocol_binder_reverse_info_s * reverse_binder, WBXMLTreeNode * wbxml_dom_node, Content_Ptr * content);
81 static sync_agent_pb_error_e _oma_ds_binder_alert_command_reverse_converter_function(sync_agent_pb_protocol_binder_reverse_info_s * reverse_binder, WBXMLTreeNode * wbxml_dom_node, Content_Ptr * content);
82 static sync_agent_pb_error_e _oma_ds_binder_sync_end_command_reverse_converter_function(sync_agent_pb_protocol_binder_reverse_info_s * reverse_binder, WBXMLTreeNode * wbxml_dom_node, Content_Ptr * content);
83 static sync_agent_pb_error_e _oma_ds_binder_sync_start_command_reverse_converter_function(sync_agent_pb_protocol_binder_reverse_info_s * reverse_binder, WBXMLTreeNode * wbxml_dom_node, Content_Ptr * content);
84 static sync_agent_pb_error_e _oma_ds_binder_add_command_reverse_converter_function(sync_agent_pb_protocol_binder_reverse_info_s * reverse_binder, WBXMLTreeNode * wbxml_dom_node, Content_Ptr * content);
85 static sync_agent_pb_error_e _oma_ds_binder_replace_command_reverse_converter_function(sync_agent_pb_protocol_binder_reverse_info_s * reverse_binder, WBXMLTreeNode * wbxml_dom_node, Content_Ptr * content);
86 static sync_agent_pb_error_e _oma_ds_binder_delete_command_reverse_converter_function(sync_agent_pb_protocol_binder_reverse_info_s * reverse_binder, WBXMLTreeNode * wbxml_dom_node, Content_Ptr * content);
87 static sync_agent_pb_error_e _oma_ds_binder_final_reverse_converter_function(sync_agent_pb_protocol_binder_reverse_info_s * reverse_binder, WBXMLTreeNode * wbxml_dom_node, Content_Ptr * content);
88 static sync_agent_pb_error_e _oma_ds_binder_status_reverse_converter_function(sync_agent_pb_protocol_binder_reverse_info_s * reverse_binder, WBXMLTreeNode * wbxml_dom_node, Content_Ptr * content);
116 const sync_agent_pb_function_info_s oma_ds_binder_function_info[] = {
117 {PE_SYNCML_START, "SyncML", _oma_ds_binder_syncml_start_converter_function, NULL, false},
118 {PE_SYNCML_END, "/SyncML", NULL, NULL, false},
119 {PE_HEADER, "SyncHdr", _oma_ds_binder_header_converter_function, _oma_ds_binder_header_reverse_converter_function, true},
120 {PE_BODY_START, "SyncBody", _oma_ds_binder_body_start_converter_function, NULL, false},
121 {PE_BODY_END, "/SyncBody", NULL, NULL, false},
122 {PE_FINAL, "Final", _oma_ds_binder_final_converter_function, _oma_ds_binder_final_reverse_converter_function, true},
123 {PE_ALERT, "Alert", _oma_ds_binder_alert_command_converter_function, _oma_ds_binder_alert_command_reverse_converter_function, true},
124 {PE_STATUS, "Status", _oma_ds_binder_status_converter_function, _oma_ds_binder_status_reverse_converter_function, true},
125 {PE_RESULTS_START, "Results", _oma_ds_binder_results_command_converter_function, _oma_ds_binder_results_command_reverse_converter_function, false},
126 {PE_RESULTS_END, "/Results", NULL, NULL, false},
127 {PE_PUT_START, "Put", _oma_ds_binder_put_command_converter_function, _oma_ds_binder_put_command_reverse_converter_function, false},
128 {PE_PUT_END, "/Put", NULL, NULL, false},
129 {PE_GET, "Get", _oma_ds_binder_get_command_converter_function, _oma_ds_binder_get_command_reverse_converter_function, true},
130 {PE_SYNC_START, "Sync", _oma_ds_binder_sync_start_command_converter_function, _oma_ds_binder_sync_start_command_reverse_converter_function, false},
131 {PE_SYNC_END, "/Sync", _oma_ds_binder_sync_end_command_converter_function, _oma_ds_binder_sync_end_command_reverse_converter_function, false},
132 {PE_ADD, "Add", _oma_ds_binder_add_command_converter_function, _oma_ds_binder_add_command_reverse_converter_function, true},
133 {PE_REPLACE, "Replace", _oma_ds_binder_replace_command_converter_function, _oma_ds_binder_replace_command_reverse_converter_function, true},
134 {PE_DELETE, "Delete", _oma_ds_binder_delete_command_converter_function, _oma_ds_binder_delete_command_reverse_converter_function, true},
135 {PE_MAP, "Map", _oma_ds_binder_map_command_converter_function, NULL, true},
136 {PE_DEVINF, "DevInf", _oma_ds_binder_devinf_converter_function, _oma_ds_binder_devinf_reverse_converter_function, true}
139 static sync_agent_pb_error_e __append_location_to_wbxml_node(location_s * location, sync_agent_pb_protocol_binder_info_s * binder, WBXMLTreeNode * parent_node)
143 retvm_if(location == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "location is NULL");
145 sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
147 if (location->loc_uri != NULL) {
148 WBXMLTreeNode *LocURI = sync_agent_add_child_text_node(binder,
149 parent_node, ELEMENT_LOCURI, location->loc_uri, strlen(location->loc_uri));
150 if (LocURI == NULL) {
151 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
158 if (location->loc_name != NULL) {
159 WBXMLTreeNode *locName = sync_agent_add_child_text_node(binder,
160 parent_node, ELEMENT_LOCNAME, location->loc_name, strlen(location->loc_name));
161 if (locName == NULL) {
162 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
173 static sync_agent_pb_error_e __append_anchor_to_wbxml_node(anchor_s * anchor, sync_agent_pb_protocol_binder_info_s * binder, WBXMLTreeNode * parent_node)
177 retvm_if(anchor == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "anchor is NULL");
179 sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
181 WBXMLTreeNode *meta_node = sync_agent_add_child_node(binder, parent_node, ELEMENT_META);
182 if (meta_node == NULL) {
183 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
187 WBXMLTreeNode *anchor_node = sync_agent_add_child_node(binder, meta_node, ELEMENT_ANCHOR);
188 if (anchor_node == NULL) {
189 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
193 if (anchor->last_anchor != NULL) {
194 WBXMLTreeNode *last_node = sync_agent_add_child_text_node(binder,
195 anchor_node, ELEMENT_LAST, anchor->last_anchor, strlen(anchor->last_anchor));
196 if (last_node == NULL) {
197 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
202 if (anchor->next_anchor != NULL) {
203 WBXMLTreeNode *next_node = sync_agent_add_child_text_node(binder,
204 anchor_node, ELEMENT_NEXT, anchor->next_anchor, strlen(anchor->next_anchor));
205 if (next_node == NULL) {
206 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
217 static sync_agent_pb_error_e __append_devinf_contenttype_to_wbxml_node(devinf_content_type_s * devinf_content_type, sync_agent_pb_protocol_binder_info_s * binder, WBXMLTreeNode * parent_node, char *node)
221 retvm_if(devinf_content_type == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "devinf_content_type is NULL");
223 sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
224 WBXMLTreeNode *xnode = sync_agent_add_child_node(binder, parent_node, node);
226 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
230 WBXMLTreeNode *cttype_node = sync_agent_add_child_text_node(binder,
231 xnode, "CTType", devinf_content_type->ct_type, strlen(devinf_content_type->ct_type));
232 if (cttype_node == NULL) {
233 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
237 WBXMLTreeNode *verct_node = sync_agent_add_child_text_node(binder,
238 xnode, "VerCT", devinf_content_type->verct, strlen(devinf_content_type->verct));
239 if (verct_node == NULL) {
240 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
249 static sync_agent_pb_error_e __append_cred_to_wbxml_node(cred_s * cred, sync_agent_pb_protocol_binder_info_s * binder, WBXMLTreeNode * parent_node)
253 retvm_if(cred == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "cred is NULL");
255 sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
258 WBXMLTreeNode *cred_node = sync_agent_add_child_node(binder, parent_node, ELEMENT_CRED);
259 if (cred_node == NULL) {
260 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
264 WBXMLTreeNode *meta_node = sync_agent_add_child_node(binder, cred_node, ELEMENT_META);
265 if (meta_node == NULL) {
266 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
270 WBXMLTreeNode *type_node = NULL;
272 switch (cred->type) {
273 case AUTH_TYPE_BASIC:
275 if (cred->format == FORMAT_TYPE_BASE64) {
276 WBXMLTreeNode *format_node = sync_agent_add_child_text_node(binder,
277 meta_node, ELEMENT_FORMAT, ELEMENT_FORMAT_BASE64, strlen(ELEMENT_FORMAT_BASE64));
278 if (format_node == NULL) {
279 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
284 type_node = sync_agent_add_child_text_node(binder, meta_node, ELEMENT_TYPE, ELEMENT_AUTH_BASIC, strlen(ELEMENT_AUTH_BASIC));
285 if (type_node == NULL) {
286 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
290 if (cred->data != NULL) {
291 WBXMLTreeNode *data_node = sync_agent_add_child_text_node(binder,
292 cred_node, ELEMENT_DATA, cred->data, strlen(cred->data));
293 if (data_node == NULL) {
294 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
301 if (cred->format == FORMAT_TYPE_BASE64) {
302 WBXMLTreeNode *format_node = sync_agent_add_child_text_node(binder,
303 meta_node, ELEMENT_FORMAT, ELEMENT_FORMAT_BASE64, strlen(ELEMENT_FORMAT_BASE64));
304 if (format_node == NULL) {
305 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
310 type_node = sync_agent_add_child_text_node(binder, meta_node, ELEMENT_TYPE, ELEMENT_AUTH_MD5, strlen(ELEMENT_AUTH_MD5));
311 if (type_node == NULL) {
312 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
316 if (cred->data != NULL) {
317 WBXMLTreeNode *data_node = sync_agent_add_child_text_node(binder,
318 cred_node, ELEMENT_DATA, cred->data, strlen(cred->data));
319 if (data_node == NULL) {
320 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
334 static sync_agent_pb_error_e _oma_ds_binder_devinf_converter_function(sync_agent_pb_protocol_binder_info_s * binder, Content_Ptr content, WBXMLTreeNode ** wbxml_dom_node)
338 retvm_if(content == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "content is NULL");
340 sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
342 item_s *pItem = (item_s *) content;
343 devinf_s *pDevInf = pItem->private.devinf;
346 WBXMLTreeNode *item_node = sync_agent_create_node(binder, ELEMENT_ITEM);
347 if (item_node == NULL) {
348 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
352 WBXMLTreeNode *source_node = sync_agent_add_child_node(binder, item_node, ELEMENT_SOURCE);
353 if (source_node == NULL) {
354 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
358 err = __append_location_to_wbxml_node(pItem->source, binder, source_node);
359 if (err != SYNC_AGENT_PB_RETURN_OK)
362 WBXMLTreeNode *data_node = sync_agent_add_child_node(binder, item_node, ELEMENT_DATA);
363 if (data_node == NULL) {
364 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
368 /* devinf language setting */
369 sync_agent_switch_protocol(binder, SYNC_AGENT_PB_PROTOCOL_SYNCML_DEVINF12);
370 WBXMLTree *devinf_tree = sync_agent_create_wbxml_tree(binder);
371 if (devinf_tree == NULL) {
372 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
376 sync_agent_add_wbxml_tree_to_wbxml_node(data_node, devinf_tree);
378 /* create root node of devinf tree */
379 WBXMLTreeNode *devinf_node = sync_agent_create_node(binder, ELEMENT_DEVINF);
380 if (devinf_node == NULL) {
381 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
385 sync_agent_set_wbxml_tree_root(devinf_tree, devinf_node);
387 WBXMLTreeNode *verDTD_node = NULL;
388 switch (pDevInf->version) {
389 case DEVINF_VERSION_UNKNOWN:
390 verDTD_node = sync_agent_add_child_node(binder, devinf_node, ELEMENT_VERDTD);
392 case DEVINF_VERSION_10:
393 verDTD_node = sync_agent_add_child_text_node(binder, devinf_node, ELEMENT_VERDTD, ELEMENT_VERDRD_10, strlen(ELEMENT_VERDRD_10));
395 case DEVINF_VERSION_11:
396 verDTD_node = sync_agent_add_child_text_node(binder, devinf_node, ELEMENT_VERDTD, ELEMENT_VERDRD_11, strlen(ELEMENT_VERDRD_11));
398 case DEVINF_VERSION_12:
399 verDTD_node = sync_agent_add_child_text_node(binder, devinf_node, ELEMENT_VERDTD, ELEMENT_VERDRD_12, strlen(ELEMENT_VERDRD_12));
403 if (verDTD_node == NULL) {
404 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
408 WBXMLTreeNode *man_node = sync_agent_add_child_text_node(binder,
409 devinf_node, ELEMENT_MAN, pDevInf->manufacturer, strlen(pDevInf->manufacturer));
410 if (man_node == NULL) {
411 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
415 WBXMLTreeNode *mod_node = sync_agent_add_child_text_node(binder,
416 devinf_node, ELEMENT_MOD, pDevInf->model, strlen(pDevInf->model));
417 if (mod_node == NULL) {
418 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
422 if (pDevInf->oem != NULL) {
423 WBXMLTreeNode *oem_node = sync_agent_add_child_text_node(binder,
424 devinf_node, ELEMENT_OEM, pDevInf->oem, strlen(pDevInf->oem));
425 if (oem_node == NULL) {
426 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
431 WBXMLTreeNode *FwV_node = sync_agent_add_child_text_node(binder,
432 devinf_node, ELEMENT_FWV, pDevInf->firmware_version, strlen(pDevInf->firmware_version));
433 if (FwV_node == NULL) {
434 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
438 WBXMLTreeNode *SwV_node = sync_agent_add_child_text_node(binder,
439 devinf_node, ELEMENT_SWV, pDevInf->software_version, strlen(pDevInf->software_version));
440 if (SwV_node == NULL) {
441 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
445 WBXMLTreeNode *HwV_node = sync_agent_add_child_text_node(binder,
446 devinf_node, ELEMENT_HWV, pDevInf->hardware_version, strlen(pDevInf->hardware_version));
447 if (HwV_node == NULL) {
448 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
452 WBXMLTreeNode *devID_node = sync_agent_add_child_text_node(binder,
453 devinf_node, ELEMENT_DEVID, pDevInf->dev_id, strlen(pDevInf->dev_id));
454 if (devID_node == NULL) {
455 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
459 WBXMLTreeNode *devTyp_node = NULL;
460 switch (pDevInf->devtyp) {
461 case DEVINF_DEVTYPE_UNKNOWN:
462 devTyp_node = sync_agent_add_child_node(binder, devinf_node, ELEMENT_DEVTYP);
464 case DEVINF_DEVTYPE_PAGER:
465 devTyp_node = sync_agent_add_child_text_node(binder, devinf_node, ELEMENT_DEVTYP, ELEMENT_PAGER, strlen(ELEMENT_PAGER));
467 case DEVINF_DEVTYPE_HANDHELD:
468 devTyp_node = sync_agent_add_child_text_node(binder, devinf_node, ELEMENT_DEVTYP, ELEMENT_HANDHELD, strlen(ELEMENT_HANDHELD));
470 case DEVINF_DEVTYPE_PDA:
471 devTyp_node = sync_agent_add_child_text_node(binder, devinf_node, ELEMENT_DEVTYP, ELEMENT_PDA, strlen(ELEMENT_PDA));
473 case DEVINF_DEVTYPE_PHONE:
474 devTyp_node = sync_agent_add_child_text_node(binder, devinf_node, ELEMENT_DEVTYP, ELEMENT_PHONE, strlen(ELEMENT_PHONE));
476 case DEVINF_DEVTYPE_SMARTPHONE:
477 devTyp_node = sync_agent_add_child_text_node(binder, devinf_node, ELEMENT_DEVTYP, ELEMENT_SMARTPHONE, strlen(ELEMENT_SMARTPHONE));
479 case DEVINF_DEVTYPE_SERVER:
480 devTyp_node = sync_agent_add_child_text_node(binder, devinf_node, ELEMENT_DEVTYP, ELEMENT_SERVER, strlen(ELEMENT_SERVER));
482 case DEVINF_DEVTYPE_WORKSTATION:
483 devTyp_node = sync_agent_add_child_text_node(binder, devinf_node, ELEMENT_DEVTYP, ELEMENT_WORKSTATION, strlen(ELEMENT_WORKSTATION));
487 if (devTyp_node == NULL) {
488 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
492 if (pDevInf->supports_utc) {
493 WBXMLTreeNode *supportUTC_node = sync_agent_add_child_node(binder,
494 devinf_node, ELEMENT_UTC);
495 if (supportUTC_node == NULL) {
496 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
501 if (pDevInf->supports_large_objs) {
502 WBXMLTreeNode *supportLargeObjs_node = sync_agent_add_child_node(binder,
503 devinf_node, ELEMENT_SUPPORTLARGEOBJS);
504 if (supportLargeObjs_node == NULL) {
505 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
510 if (pDevInf->supports_number_of_changes) {
511 WBXMLTreeNode *supportNumberOfChanges_node = sync_agent_add_child_node(binder,
512 devinf_node, ELEMENT_SUPPORTNUMBEROFCHANGES);
513 if (supportNumberOfChanges_node == NULL) {
514 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
519 GList *datastoreIter = NULL;
520 devinf_datastore_s *devInfDataStore = NULL;
521 for (datastoreIter = pDevInf->datastores; datastoreIter != NULL; datastoreIter = g_list_next(datastoreIter)) {
522 devInfDataStore = datastoreIter->data;
524 WBXMLTreeNode *datastore_node = sync_agent_add_child_node(binder,
525 devinf_node, ELEMENT_DATASTORE);
526 if (datastore_node == NULL) {
527 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
531 WBXMLTreeNode *sourceRef_node = sync_agent_add_child_text_node(binder,
532 datastore_node, ELEMENT_SOURCEREF, devInfDataStore->source_ref, strlen(devInfDataStore->source_ref));
533 if (sourceRef_node == NULL) {
534 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
538 if (devInfDataStore->display_name != NULL) {
539 WBXMLTreeNode *displayname_node = sync_agent_add_child_text_node(binder,
540 datastore_node, ELEMENT_DISPLAYNAME, devInfDataStore->display_name, strlen(devInfDataStore->display_name));
541 if (displayname_node == NULL) {
542 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
547 if (devInfDataStore->max_guid_size) {
548 char *str_maxguidsize = g_strdup_printf("%u", devInfDataStore->max_guid_size);
549 if (str_maxguidsize == NULL) {
550 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
554 WBXMLTreeNode *maxguidsize_node = sync_agent_add_child_text_node(binder,
555 datastore_node, ELEMENT_MAXGUIDSIZE, str_maxguidsize, strlen(str_maxguidsize));
557 if (str_maxguidsize != NULL)
558 free(str_maxguidsize);
560 if (maxguidsize_node == NULL) {
561 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
566 err = __append_devinf_contenttype_to_wbxml_node(devInfDataStore->rx_pref, binder, datastore_node, ELEMENT_RX_PREF);
567 if (err != SYNC_AGENT_PB_RETURN_OK)
570 GList *rxIter = NULL;
571 devinf_content_type_s *devInfContentType = NULL;
572 for (rxIter = devInfDataStore->rx; rxIter != NULL; rxIter = g_list_next(rxIter)) {
573 devInfContentType = rxIter->data;
574 err = __append_devinf_contenttype_to_wbxml_node(devInfContentType, binder, datastore_node, ELEMENT_RX);
575 if (err != SYNC_AGENT_PB_RETURN_OK)
579 err = __append_devinf_contenttype_to_wbxml_node(devInfDataStore->tx_pref, binder, datastore_node, ELEMENT_TX_PREF);
580 if (err != SYNC_AGENT_PB_RETURN_OK)
583 GList *txIter = NULL;
584 for (txIter = devInfDataStore->tx; txIter != NULL; txIter = g_list_next(txIter)) {
585 devInfContentType = txIter->data;
586 err = __append_devinf_contenttype_to_wbxml_node(devInfContentType, binder, datastore_node, ELEMENT_TX);
587 if (err != SYNC_AGENT_PB_RETURN_OK)
592 GList *ctcapIter = NULL;
593 devinf_ct_cap_s *devInfCTCap = NULL;
594 for (ctcapIter = devInfDataStore->ct_caps; ctcapIter != NULL; ctcapIter = g_list_next(ctcapIter)) {
595 devInfCTCap = ctcapIter->data;
597 WBXMLTreeNode *ctcap_node = sync_agent_add_child_node(binder,
598 datastore_node, ELEMENT_CTCAP);
599 if (ctcap_node == NULL) {
600 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
604 WBXMLTreeNode *cttype_node = sync_agent_add_child_text_node(binder,
605 ctcap_node, ELEMENT_CTTYPE, devInfCTCap->ct->ct_type, strlen(devInfCTCap->ct->ct_type));
606 if (cttype_node == NULL) {
607 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
611 WBXMLTreeNode *verct_node = sync_agent_add_child_text_node(binder,
612 ctcap_node, ELEMENT_VERCT, devInfCTCap->ct->verct, strlen(devInfCTCap->ct->verct));
613 if (verct_node == NULL) {
614 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
620 GList *propertyIter = NULL;
621 devinf_property_s *devInfProperty = NULL;
622 for (propertyIter = devInfCTCap->properties; propertyIter != NULL; propertyIter = g_list_next(propertyIter)) {
623 devInfProperty = propertyIter->data;
625 WBXMLTreeNode *property_node = sync_agent_add_child_node(binder,
626 ctcap_node, ELEMENT_PROPERTY);
627 if (property_node == NULL) {
628 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
632 WBXMLTreeNode *propname_node = sync_agent_add_child_text_node(binder,
633 property_node, ELEMENT_PROPNAME, devInfProperty->prop_name, strlen(devInfProperty->prop_name));
634 if (propname_node == NULL) {
635 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
639 if (devInfProperty->data_type != NULL) {
640 WBXMLTreeNode *datatype_node = sync_agent_add_child_text_node(binder,
641 property_node, ELEMENT_DATATYPE, devInfProperty->data_type, strlen(devInfProperty->data_type));
642 if (datatype_node == NULL) {
643 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
648 if (devInfProperty->max_occur) {
649 char *str_maxoccur = g_strdup_printf("%u", devInfProperty->max_occur);
650 if (str_maxoccur == NULL) {
651 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
655 WBXMLTreeNode *maxoccur_node = sync_agent_add_child_text_node(binder,
656 property_node, ELEMENT_MAXOCCUR, str_maxoccur, strlen(str_maxoccur));
658 if (str_maxoccur != NULL)
661 if (maxoccur_node == NULL) {
662 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
667 if (devInfProperty->max_size) {
668 char *str_maxsize = g_strdup_printf("%u", devInfProperty->max_size);
669 if (str_maxsize == NULL) {
670 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
674 WBXMLTreeNode *maxsize_node = sync_agent_add_child_text_node(binder,
675 property_node, ELEMENT_MAXSIZE, str_maxsize, strlen(str_maxsize));
677 if (str_maxsize != NULL)
680 if (maxsize_node == NULL) {
681 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
686 if (devInfProperty->no_truncate) {
687 WBXMLTreeNode *notruncate_node = sync_agent_add_child_node(binder,
688 property_node, ELEMENT_NOTRUNCATE);
689 if (notruncate_node == NULL) {
690 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
695 GList *valenum = NULL;
697 for (valenum = devInfProperty->val_enums; valenum != NULL; valenum = g_list_next(valenum)) {
699 WBXMLTreeNode *valenum_node = sync_agent_add_child_text_node(binder,
700 property_node, ELEMENT_VALENUM, val, strlen(val));
701 if (valenum_node == NULL) {
702 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
707 if (devInfProperty->display_name != NULL) {
708 WBXMLTreeNode *displayname_node = sync_agent_add_child_text_node(binder,
709 property_node, ELEMENT_DISPLAYNAME, devInfProperty->display_name, strlen(devInfProperty->display_name));
710 if (displayname_node == NULL) {
711 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
716 GList *propparamIter = NULL;
717 devinf_prop_param_s *devInfPropParam = NULL;
718 for (propparamIter = devInfProperty->prop_params; propparamIter != NULL; propparamIter = g_list_next(propparamIter)) {
719 devInfPropParam = propparamIter->data;
721 WBXMLTreeNode *propparam_node = sync_agent_add_child_node(binder,
722 property_node, ELEMENT_PROPPARAM);
723 if (propparam_node == NULL) {
724 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
728 WBXMLTreeNode *paramname_node = sync_agent_add_child_text_node(binder,
729 propparam_node, ELEMENT_PARAMNAME, devInfPropParam->param_name, strlen(devInfPropParam->param_name));
730 if (paramname_node == NULL) {
731 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
735 if (devInfPropParam->data_type != NULL) {
736 WBXMLTreeNode *datatype_node = sync_agent_add_child_text_node(binder,
737 propparam_node, ELEMENT_DATATYPE, devInfPropParam->data_type, strlen(devInfPropParam->data_type));
738 if (datatype_node == NULL) {
739 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
746 for (valenum = devInfPropParam->val_enums; valenum != NULL; valenum = g_list_next(valenum)) {
748 WBXMLTreeNode *valenum_node = sync_agent_add_child_text_node(binder,
749 propparam_node, ELEMENT_VALENUM, val, strlen(val));
750 if (valenum_node == NULL) {
751 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
756 if (devInfPropParam->display_name != NULL) {
757 WBXMLTreeNode *displayname_node = sync_agent_add_child_text_node(binder,
758 propparam_node, ELEMENT_DISPLAYNAME, devInfPropParam->display_name, strlen(devInfPropParam->display_name));
759 if (displayname_node == NULL) {
760 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
769 WBXMLTreeNode *dsmem_node = sync_agent_add_child_node(binder,
770 datastore_node, ELEMENT_DSMEM);
771 if (dsmem_node == NULL) {
772 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
776 if (devInfDataStore->shared_mem) {
777 WBXMLTreeNode *sharedmem_node = sync_agent_add_child_node(binder,
778 dsmem_node, ELEMENT_SHAREDMEM);
779 if (sharedmem_node == NULL) {
780 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
785 if (devInfDataStore->max_mem) {
786 char *str_maxmem = g_strdup_printf("%u", devInfDataStore->max_mem);
787 WBXMLTreeNode *maxmem_node = sync_agent_add_child_text_node(binder,
788 dsmem_node, ELEMENT_MAXMEM, str_maxmem, strlen(str_maxmem));
790 if (str_maxmem != NULL)
793 if (maxmem_node == NULL) {
794 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
799 if (devInfDataStore->max_id) {
800 char *str_maxid = g_strdup_printf("%u", devInfDataStore->max_id);
801 WBXMLTreeNode *maxid_node = sync_agent_add_child_text_node(binder,
802 dsmem_node, ELEMENT_MAXID, str_maxid, strlen(str_maxid));
804 if (str_maxid != NULL)
807 if (maxid_node == NULL) {
808 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
813 /* SupportHierarchicalSync */
814 if (devInfDataStore->supports_hierarchical_sync) {
815 WBXMLTreeNode *supportshierarchicalsync_node = sync_agent_add_child_node(binder,
816 datastore_node, ELEMENT_SUPPORTHIERARCHICALSYNC);
817 if (supportshierarchicalsync_node == NULL) {
818 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
823 WBXMLTreeNode *synccap_node = sync_agent_add_child_node(binder,
824 datastore_node, ELEMENT_SYNCCAP);
825 if (synccap_node == NULL) {
826 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
830 if (get_devinf_datastore_sync_cap(devInfDataStore, DEVINF_SYNCTYPE_TWO_WAY)) {
831 WBXMLTreeNode *synctype_node = sync_agent_add_child_text_node(binder,
832 synccap_node, ELEMENT_SYNCTYPE, ELEMENT_SYNCTYPE_1, strlen(ELEMENT_SYNCTYPE_1));
833 if (synctype_node == NULL) {
834 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
838 if (get_devinf_datastore_sync_cap(devInfDataStore, DEVINF_SYNCTYPE_SLOW_SYNC)) {
839 WBXMLTreeNode *synctype_node = sync_agent_add_child_text_node(binder,
840 synccap_node, ELEMENT_SYNCTYPE, ELEMENT_SYNCTYPE_2, strlen(ELEMENT_SYNCTYPE_2));
841 if (synctype_node == NULL) {
842 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
846 if (get_devinf_datastore_sync_cap(devInfDataStore, DEVINF_SYNCTYPE_ONE_WAY_FROM_CLIENT)) {
847 WBXMLTreeNode *synctype_node = sync_agent_add_child_text_node(binder,
848 synccap_node, ELEMENT_SYNCTYPE, ELEMENT_SYNCTYPE_3, strlen(ELEMENT_SYNCTYPE_3));
849 if (synctype_node == NULL) {
850 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
854 if (get_devinf_datastore_sync_cap(devInfDataStore, DEVINF_SYNCTYPE_REFRESH_FROM_CLIENT)) {
855 WBXMLTreeNode *synctype_node = sync_agent_add_child_text_node(binder,
856 synccap_node, ELEMENT_SYNCTYPE, ELEMENT_SYNCTYPE_4, strlen(ELEMENT_SYNCTYPE_4));
857 if (synctype_node == NULL) {
858 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
862 if (get_devinf_datastore_sync_cap(devInfDataStore, DEVINF_SYNCTYPE_ONE_WAY_FROM_SERVER)) {
863 WBXMLTreeNode *synctype_node = sync_agent_add_child_text_node(binder,
864 synccap_node, ELEMENT_SYNCTYPE, ELEMENT_SYNCTYPE_5, strlen(ELEMENT_SYNCTYPE_5));
865 if (synctype_node == NULL) {
866 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
870 if (get_devinf_datastore_sync_cap(devInfDataStore, DEVINF_SYNCTYPE_REFRESH_FROM_SERVER)) {
871 WBXMLTreeNode *synctype_node = sync_agent_add_child_text_node(binder,
872 synccap_node, ELEMENT_SYNCTYPE, ELEMENT_SYNCTYPE_6, strlen(ELEMENT_SYNCTYPE_6));
873 if (synctype_node == NULL) {
874 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
878 if (get_devinf_datastore_sync_cap(devInfDataStore, DEVINF_SYNCTYPE_SERVER_ALERTED_SYNC)) {
879 WBXMLTreeNode *synctype_node = sync_agent_add_child_text_node(binder,
880 synccap_node, ELEMENT_SYNCTYPE, ELEMENT_SYNCTYPE_7, strlen(ELEMENT_SYNCTYPE_7));
881 if (synctype_node == NULL) {
882 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
886 /*TODO filter-rx, filterCap */
888 sync_agent_undo_switch_protocol(binder);
889 *wbxml_dom_node = item_node;
897 static sync_agent_pb_error_e _oma_ds_binder_syncml_start_converter_function(sync_agent_pb_protocol_binder_info_s * binder, Content_Ptr content, WBXMLTreeNode ** wbxml_dom_node)
901 sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
902 WBXMLTreeNode *syncml_node = sync_agent_create_node(binder, ELEMENT_SYNCML);
903 if (syncml_node == NULL) {
904 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
908 *wbxml_dom_node = syncml_node;
915 static sync_agent_pb_error_e _oma_ds_binder_header_converter_function(sync_agent_pb_protocol_binder_info_s * binder, Content_Ptr content, WBXMLTreeNode ** wbxml_dom_node)
919 retvm_if(content == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "content is NULL");
921 sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
922 sync_hdr_s *pSyncHdr = (sync_hdr_s *) content;
924 /* add SyncHdr, VerDTD, VerProto node */
925 WBXMLTreeNode *synchdr_node = sync_agent_create_node(binder, ELEMENT_SYNCHDR);
926 if (synchdr_node == NULL) {
927 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
931 char *verDTD = ELEMENT_VERDTD;
932 char *verProto = ELEMENT_VERPROTO;
934 char *verDTD_data = NULL;
935 char *verProto_data = NULL;
936 if (pSyncHdr->version == VERSION_10) {
937 verDTD_data = ELEMENT_VERDRD_10;
938 verProto_data = ELEMENT_VERPROTO_10;
939 } else if (pSyncHdr->version == VERSION_11) {
940 verDTD_data = ELEMENT_VERDRD_11;
941 verProto_data = ELEMENT_VERPROTO_11;
942 } else if (pSyncHdr->version == VERSION_12) {
943 verDTD_data = ELEMENT_VERDRD_12;
944 verProto_data = ELEMENT_VERPROTO_12;
947 if (verDTD_data == NULL || verProto_data == NULL) {
948 err = SYNC_AGENT_PB_RETURN_NOT_DEFINED;
952 WBXMLTreeNode *verdtd_node = sync_agent_add_child_text_node(binder,
953 synchdr_node, verDTD, verDTD_data, strlen(verDTD_data));
954 if (verdtd_node == NULL) {
955 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
959 WBXMLTreeNode *verProto_node = sync_agent_add_child_text_node(binder,
960 synchdr_node, verProto, verProto_data, strlen(verProto_data));
961 if (verProto_node == NULL) {
962 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
967 WBXMLTreeNode *sessionID_node = NULL;
968 if (pSyncHdr->session_id != NULL)
969 sessionID_node = sync_agent_add_child_text_node(binder, synchdr_node, ELEMENT_SESSIONID, pSyncHdr->session_id, strlen(pSyncHdr->session_id));
971 sessionID_node = sync_agent_add_child_node(binder, synchdr_node, ELEMENT_SESSIONID);
973 if (sessionID_node == NULL) {
974 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
979 char *msgID_data = g_strdup_printf("%u", pSyncHdr->message_id);
980 if (msgID_data == NULL) {
981 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
985 WBXMLTreeNode *msgID_node = sync_agent_add_child_text_node(binder,
986 synchdr_node, ELEMENT_MSGID, msgID_data, strlen(msgID_data));
988 if (msgID_data != NULL)
991 if (msgID_node == NULL) {
992 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
996 WBXMLTreeNode *target_node = sync_agent_add_child_node(binder,
997 synchdr_node, ELEMENT_TARGET);
998 if (target_node == NULL) {
999 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
1003 err = __append_location_to_wbxml_node(pSyncHdr->target, binder, target_node);
1004 if (err != SYNC_AGENT_PB_RETURN_OK) {
1008 WBXMLTreeNode *source_node = sync_agent_add_child_node(binder,
1009 synchdr_node, ELEMENT_SOURCE);
1010 if (source_node == NULL) {
1011 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
1015 err = __append_location_to_wbxml_node(pSyncHdr->source, binder, source_node);
1016 if (err != SYNC_AGENT_PB_RETURN_OK) {
1020 if (pSyncHdr->response_uri != NULL) {
1021 WBXMLTreeNode *respuri_node = sync_agent_add_child_text_node(binder,
1022 synchdr_node, ELEMENT_RESPURI, pSyncHdr->response_uri, strlen(pSyncHdr->response_uri));
1023 if (respuri_node == NULL) {
1024 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
1029 if (pSyncHdr->no_response) {
1030 WBXMLTreeNode *noResponse_node = sync_agent_add_child_node(binder,
1031 synchdr_node, ELEMENT_NORESP);
1032 if (noResponse_node == NULL) {
1033 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
1038 if (pSyncHdr->cred != NULL) {
1039 err = __append_cred_to_wbxml_node(pSyncHdr->cred, binder, synchdr_node);
1040 if (err != SYNC_AGENT_PB_RETURN_OK) {
1045 char *meta = ELEMENT_META;
1046 if (pSyncHdr->max_msg_size != 0 || pSyncHdr->max_obj_size != 0) {
1047 WBXMLTreeNode *meta_node = sync_agent_add_child_node(binder,
1048 synchdr_node, meta);
1049 if (meta_node == NULL) {
1050 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
1054 unsigned int maxmsgsize = pSyncHdr->max_msg_size;
1055 unsigned int maxobjsize = pSyncHdr->max_obj_size;
1057 if (maxmsgsize != 0) {
1058 char *str_maxmsgsize = g_strdup_printf("%u", maxmsgsize);
1059 if (str_maxmsgsize == NULL) {
1060 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
1064 WBXMLTreeNode *maxmsgsize_node = sync_agent_add_child_text_node(binder,
1065 meta_node, ELEMENT_MAXMSGSIZE, str_maxmsgsize, strlen(str_maxmsgsize));
1066 if (str_maxmsgsize != NULL)
1067 free(str_maxmsgsize);
1069 if (maxmsgsize_node == NULL) {
1070 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
1075 if (maxobjsize != 0) {
1076 char *str_maxobjsize = g_strdup_printf("%u", maxobjsize);
1077 if (str_maxobjsize == NULL) {
1078 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
1082 WBXMLTreeNode *maxobjsize_node = sync_agent_add_child_text_node(binder,
1083 meta_node, ELEMENT_MAXOBJSIZE, str_maxobjsize, strlen(str_maxobjsize));
1084 if (str_maxobjsize != NULL)
1085 free(str_maxobjsize);
1087 if (maxobjsize_node == NULL) {
1088 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
1094 *wbxml_dom_node = synchdr_node;
1095 synchdr_node = NULL;
1099 if (synchdr_node != NULL)
1100 sync_agent_destroy_wbxml_node(synchdr_node);
1106 static sync_agent_pb_error_e _oma_ds_binder_final_converter_function(sync_agent_pb_protocol_binder_info_s * binder, Content_Ptr content, WBXMLTreeNode ** wbxml_dom_node)
1110 sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
1112 WBXMLTreeNode *final_node = sync_agent_create_node(binder, "Final");
1113 if (final_node == NULL) {
1114 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
1118 *wbxml_dom_node = final_node;
1126 static sync_agent_pb_error_e _oma_ds_binder_body_start_converter_function(sync_agent_pb_protocol_binder_info_s * binder, Content_Ptr content, WBXMLTreeNode ** wbxml_dom_node)
1130 sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
1132 WBXMLTreeNode *syncbody_node = sync_agent_create_node(binder, ELEMENT_SYNCBODY);
1133 if (syncbody_node == NULL) {
1134 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
1138 *wbxml_dom_node = syncbody_node;
1145 static sync_agent_pb_error_e _oma_ds_binder_status_converter_function(sync_agent_pb_protocol_binder_info_s * binder, Content_Ptr content, WBXMLTreeNode ** wbxml_dom_node)
1149 retvm_if(content == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "content is NULL");
1151 sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
1153 status_s *pStatus = (status_s *) content;
1155 command_type_e type = pStatus->type;
1157 char *str_cmdID = NULL;
1158 char *str_msgRef = NULL;
1159 char *str_cmdRef = NULL;
1161 WBXMLTreeNode *status_node = sync_agent_create_node(binder, ELEMENT_STATUS);
1162 if (status_node == NULL) {
1163 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
1167 unsigned int cmdID = pStatus->cmd_id;
1168 str_cmdID = g_strdup_printf("%u", cmdID);
1169 if (str_cmdID == NULL) {
1170 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
1174 WBXMLTreeNode *cmdid_node = sync_agent_add_child_text_node(binder,
1175 status_node, ELEMENT_CMDID, str_cmdID, strlen(str_cmdID));
1176 if (cmdid_node == NULL) {
1177 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
1181 unsigned int msgRef = pStatus->msg_ref;
1182 str_msgRef = g_strdup_printf("%u", msgRef);
1183 if (str_msgRef == NULL) {
1184 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
1188 WBXMLTreeNode *msgref_node = sync_agent_add_child_text_node(binder,
1189 status_node, ELEMENT_MSGREF, str_msgRef, strlen(str_msgRef));
1190 if (msgref_node == NULL) {
1191 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
1195 unsigned int cmdRef = pStatus->cmd_ref;
1196 str_cmdRef = g_strdup_printf("%u", cmdRef);
1197 if (str_cmdRef == NULL) {
1198 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
1202 WBXMLTreeNode *cmdref_node = sync_agent_add_child_text_node(binder,
1203 status_node, ELEMENT_CMDREF, str_cmdRef, strlen(str_cmdRef));
1204 if (cmdref_node == NULL) {
1208 char *str_command = NULL;
1210 case COMMAND_TYPE_ALERT:
1212 str_command = ELEMENT_ALERT;
1215 case COMMAND_TYPE_SYNC_START:
1217 str_command = ELEMENT_SYNC;
1220 case COMMAND_TYPE_PUT:
1222 str_command = ELEMENT_PUT;
1225 case COMMAND_TYPE_HEADER:
1227 str_command = ELEMENT_SYNCHDR;
1230 case COMMAND_TYPE_ADD:
1232 str_command = ELEMENT_ADD;
1235 case COMMAND_TYPE_REPLACE:
1237 str_command = ELEMENT_REPLACE;
1240 case COMMAND_TYPE_DELETE:
1242 str_command = ELEMENT_DELETE;
1245 case COMMAND_TYPE_MAP:
1247 str_command = ELEMENT_MAP;
1250 case COMMAND_TYPE_GET:
1252 str_command = ELEMENT_GET;
1255 case COMMAND_TYPE_RESULTS:
1257 str_command = ELEMENT_RESULTS;
1264 if (str_command == NULL) {
1265 err = SYNC_AGENT_PB_RETURN_NOT_DEFINED;
1269 WBXMLTreeNode *command_node = sync_agent_add_child_text_node(binder,
1270 status_node, ELEMENT_CMD, str_command, strlen(str_command));
1271 if (command_node == NULL) {
1272 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
1276 if (pStatus->target_ref != NULL) {
1277 WBXMLTreeNode *targetref_node = sync_agent_add_child_text_node(binder,
1278 status_node, ELEMENT_TARGETREF, pStatus->target_ref->loc_uri, strlen(pStatus->target_ref->loc_uri));
1279 if (targetref_node == NULL) {
1280 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
1285 if (pStatus->source_ref != NULL) {
1286 WBXMLTreeNode *sourceref_node = sync_agent_add_child_text_node(binder,
1287 status_node, ELEMENT_SOURCEREF, pStatus->source_ref->loc_uri, strlen(pStatus->source_ref->loc_uri));
1288 if (sourceref_node == NULL) {
1289 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
1294 if (pStatus->cred != NULL) {
1295 err = __append_cred_to_wbxml_node(pStatus->cred, binder, status_node);
1296 if (err != SYNC_AGENT_PB_RETURN_OK) {
1301 if (pStatus->chal != NULL) {
1305 WBXMLTreeNode *data_node = sync_agent_add_child_text_node(binder,
1306 status_node, ELEMENT_DATA, pStatus->data, strlen(pStatus->data));
1307 if (data_node == NULL) {
1308 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
1312 if (type == COMMAND_TYPE_ALERT) {
1313 if (pStatus->item != NULL) {
1314 WBXMLTreeNode *item_node = sync_agent_add_child_node(binder,
1315 status_node, ELEMENT_ITEM);
1316 if (item_node == NULL) {
1317 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
1321 WBXMLTreeNode *item_data_node = sync_agent_add_child_node(binder,
1322 item_node, ELEMENT_DATA);
1323 if (item_data_node == NULL) {
1324 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
1328 WBXMLTreeNode *item_data_Anchor_node = sync_agent_add_child_node(binder,
1329 item_data_node, ELEMENT_ANCHOR);
1330 if (item_data_Anchor_node == NULL) {
1331 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
1335 if (pStatus->item->anchor != NULL) {
1336 WBXMLTreeNode *item_data_Anchor_Next_node = sync_agent_add_child_text_node(binder,
1337 item_data_Anchor_node, ELEMENT_NEXT, pStatus->item->anchor->next_anchor,
1338 strlen(pStatus->item->anchor->next_anchor));
1340 if (item_data_Anchor_Next_node == NULL) {
1341 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
1348 *wbxml_dom_node = status_node;
1353 if (status_node != NULL)
1354 sync_agent_destroy_wbxml_node(status_node);
1356 if (str_cmdID != NULL)
1359 if (str_cmdRef != NULL)
1362 if (str_msgRef != NULL)
1369 static sync_agent_pb_error_e _oma_ds_binder_alert_command_converter_function(sync_agent_pb_protocol_binder_info_s * binder, Content_Ptr content, WBXMLTreeNode ** wbxml_dom_node)
1373 retvm_if(content == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "content is NULL");
1375 sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
1377 char *str_cmdID = NULL;
1378 char *str_alert_type = NULL;
1380 WBXMLTreeNode *alert_node = NULL;
1382 command_s *pCommand = (command_s *) content;
1384 command_alert_private_s *pAlert = (command_alert_private_s *) (&(pCommand->private));
1385 if (pAlert == NULL) {
1386 err = SYNC_AGENT_PB_RETURN_NOT_DEFINED;
1390 if (pAlert->type == ALERT_UNKNOWN) {
1392 err = SYNC_AGENT_PB_RETURN_INVALID_INPUT_PARAMETER;
1396 alert_node = sync_agent_create_node(binder, ELEMENT_ALERT);
1397 if (alert_node == NULL) {
1398 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
1402 str_cmdID = g_strdup_printf("%u", pCommand->cmd_id);
1403 if (str_cmdID == NULL) {
1404 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
1408 WBXMLTreeNode *cmdid_node = sync_agent_add_child_text_node(binder,
1409 alert_node, ELEMENT_CMDID, str_cmdID, strlen(str_cmdID));
1410 if (cmdid_node == NULL) {
1411 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
1415 if (pCommand->no_resp) {
1416 WBXMLTreeNode *noResp_node = sync_agent_add_child_node(binder,
1417 alert_node, ELEMENT_NORESP);
1418 if (noResp_node == NULL) {
1419 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
1424 if (pCommand->cred != NULL) {
1425 err = __append_cred_to_wbxml_node(pCommand->cred, binder, alert_node);
1426 if (err != SYNC_AGENT_PB_RETURN_OK) {
1431 str_alert_type = g_strdup_printf("%u", pAlert->type);
1432 if (str_alert_type == NULL) {
1433 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
1437 WBXMLTreeNode *data_node = sync_agent_add_child_text_node(binder,
1438 alert_node, ELEMENT_DATA, str_alert_type, strlen(str_alert_type));
1439 if (data_node == NULL) {
1440 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
1445 if (pCommand->source != NULL && pCommand->target != NULL) {
1446 WBXMLTreeNode *item_node = sync_agent_add_child_node(binder,
1447 alert_node, ELEMENT_ITEM);
1448 if (item_node == NULL) {
1449 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
1453 WBXMLTreeNode *target_node = sync_agent_add_child_node(binder,
1454 item_node, ELEMENT_TARGET);
1455 if (target_node == NULL) {
1456 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
1460 err = __append_location_to_wbxml_node(pCommand->target, binder, target_node);
1461 if (err != SYNC_AGENT_PB_RETURN_OK) {
1465 WBXMLTreeNode *source_node = sync_agent_add_child_node(binder,
1466 item_node, ELEMENT_SOURCE);
1467 if (source_node == NULL) {
1468 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
1472 err = __append_location_to_wbxml_node(pCommand->source, binder, source_node);
1473 if (err != SYNC_AGENT_PB_RETURN_OK) {
1477 if (pAlert->anchor != NULL) {
1478 err = __append_anchor_to_wbxml_node(pAlert->anchor, binder, item_node);
1479 if (err != SYNC_AGENT_PB_RETURN_OK) {
1485 *wbxml_dom_node = alert_node;
1490 if (alert_node != NULL)
1491 sync_agent_destroy_wbxml_node(alert_node);
1493 if (str_cmdID != NULL)
1496 if (str_alert_type != NULL)
1497 free(str_alert_type);
1503 static sync_agent_pb_error_e _oma_ds_binder_results_command_converter_function(sync_agent_pb_protocol_binder_info_s * binder, Content_Ptr content, WBXMLTreeNode ** wbxml_dom_node)
1507 retvm_if(content == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "content is NULL");
1509 sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
1511 char *str_cmdID = NULL;
1512 char *str_cmdRef = NULL;
1513 char *str_msgRef = NULL;
1514 WBXMLTreeNode *results_node = NULL;
1516 command_s *pCommand = (command_s *) content;
1517 command_results_private_s *pResults = (command_results_private_s *) (&(pCommand->private));
1518 if (pResults == NULL) {
1519 err = SYNC_AGENT_PB_RETURN_NOT_DEFINED;
1523 if (pResults->item == NULL) {
1524 err = SYNC_AGENT_PB_RETURN_NOT_DEFINED;
1528 char *content_type = (pResults->item)->content_type;
1529 if (content_type == NULL) {
1531 err = SYNC_AGENT_PB_RETURN_NOT_DEFINED;
1535 results_node = sync_agent_create_node(binder, ELEMENT_RESULTS);
1536 if (results_node == NULL) {
1537 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
1541 str_cmdID = g_strdup_printf("%u", pCommand->cmd_id);
1542 if (str_cmdID != NULL) {
1543 WBXMLTreeNode *cmdid_node = sync_agent_add_child_text_node(binder,
1544 results_node, ELEMENT_CMDID, str_cmdID, strlen(str_cmdID));
1545 if (cmdid_node == NULL) {
1546 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
1551 if (pResults->msg_ref) {
1552 str_msgRef = g_strdup_printf("%u", pResults->msg_ref);
1553 if (str_msgRef == NULL) {
1554 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
1558 WBXMLTreeNode *msgref_node = sync_agent_add_child_text_node(binder,
1559 results_node, ELEMENT_MSGREF, str_msgRef, strlen(str_msgRef));
1560 if (msgref_node == NULL) {
1561 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
1566 str_cmdRef = g_strdup_printf("%u", pResults->cmd_ref);
1567 if (str_cmdRef == NULL) {
1568 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
1572 WBXMLTreeNode *msgref_node = sync_agent_add_child_text_node(binder,
1573 results_node, ELEMENT_CMDREF, str_cmdRef, strlen(str_cmdRef));
1574 if (msgref_node == NULL) {
1575 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
1579 if (content_type != NULL) {
1580 WBXMLTreeNode *meta_node = sync_agent_add_child_node(binder,
1581 results_node, ELEMENT_META);
1582 if (meta_node == NULL) {
1583 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
1587 WBXMLTreeNode *type_node = sync_agent_add_child_text_node(binder,
1588 meta_node, ELEMENT_TYPE, content_type, strlen(content_type));
1589 if (type_node == NULL) {
1590 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
1595 if (pResults->target_ref != NULL) {
1596 WBXMLTreeNode *targetref_node = sync_agent_add_child_text_node(binder,
1597 results_node, ELEMENT_TARGETREF, pResults->target_ref->loc_uri, strlen(pResults->target_ref->loc_uri));
1598 if (targetref_node == NULL) {
1599 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
1604 *wbxml_dom_node = results_node;
1605 results_node = NULL;
1609 if (results_node != NULL)
1610 sync_agent_destroy_wbxml_node(results_node);
1612 if (str_cmdID != NULL)
1615 if (str_cmdRef != NULL)
1618 if (str_msgRef != NULL)
1625 static sync_agent_pb_error_e _oma_ds_binder_put_command_converter_function(sync_agent_pb_protocol_binder_info_s * binder, Content_Ptr content, WBXMLTreeNode ** wbxml_dom_node)
1629 retvm_if(content == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "content is NULL");
1631 sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
1633 char *str_cmdID = NULL;
1634 WBXMLTreeNode *put_node = NULL;
1636 command_s *pCommand = (command_s *) content;
1637 command_access_private_s *pAccess = (command_access_private_s *) (&(pCommand->private));
1638 if (pAccess == NULL) {
1639 err = SYNC_AGENT_PB_RETURN_NOT_DEFINED;
1643 char *content_type = (pAccess->item)->content_type;
1644 if (content_type == NULL) {
1646 err = SYNC_AGENT_PB_RETURN_NOT_DEFINED;
1650 put_node = sync_agent_create_node(binder, ELEMENT_PUT);
1651 if (put_node == NULL) {
1652 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
1656 str_cmdID = g_strdup_printf("%u", pCommand->cmd_id);
1657 if (str_cmdID == NULL) {
1658 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
1662 WBXMLTreeNode *cmdid_node = sync_agent_add_child_text_node(binder,
1663 put_node, ELEMENT_CMDID, str_cmdID, strlen(str_cmdID));
1664 if (cmdid_node == NULL) {
1665 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
1669 if (pCommand->no_resp) {
1670 WBXMLTreeNode *noResp_node = sync_agent_add_child_node(binder,
1671 put_node, ELEMENT_NORESP);
1672 if (noResp_node == NULL) {
1673 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
1678 if (pCommand->cred != NULL) {
1679 err = __append_cred_to_wbxml_node(pCommand->cred, binder, put_node);
1680 if (err != SYNC_AGENT_PB_RETURN_OK) {
1685 if (content_type != NULL) {
1686 WBXMLTreeNode *meta_node = sync_agent_add_child_node(binder,
1687 put_node, ELEMENT_META);
1688 if (meta_node == NULL) {
1689 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
1693 WBXMLTreeNode *type_node = sync_agent_add_child_text_node(binder,
1694 meta_node, ELEMENT_TYPE, content_type, strlen(content_type));
1695 if (type_node == NULL) {
1696 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
1701 *wbxml_dom_node = put_node;
1706 if (put_node != NULL)
1707 sync_agent_destroy_wbxml_node(put_node);
1709 if (str_cmdID != NULL)
1716 static sync_agent_pb_error_e _oma_ds_binder_get_command_converter_function(sync_agent_pb_protocol_binder_info_s * binder, Content_Ptr content, WBXMLTreeNode ** wbxml_dom_node)
1720 retvm_if(content == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "content is NULL");
1722 sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
1724 char *str_cmdID = NULL;
1725 WBXMLTreeNode *get_node = NULL;
1727 command_s *pCommand = (command_s *) content;
1728 command_access_private_s *pAccess = (command_access_private_s *) (&(pCommand->private));
1729 if (pAccess == NULL) {
1730 err = SYNC_AGENT_PB_RETURN_NOT_DEFINED;
1734 if (pAccess->item == NULL) {
1735 err = SYNC_AGENT_PB_RETURN_NOT_DEFINED;
1739 char *content_type = (pAccess->item)->content_type;
1740 if (content_type == NULL) {
1742 err = SYNC_AGENT_PB_RETURN_NOT_DEFINED;
1746 get_node = sync_agent_create_node(binder, ELEMENT_GET);
1748 str_cmdID = g_strdup_printf("%u", pCommand->cmd_id);
1749 if (str_cmdID == NULL) {
1750 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
1754 WBXMLTreeNode *cmdid_node = sync_agent_add_child_text_node(binder,
1755 get_node, ELEMENT_CMDID, str_cmdID, strlen(str_cmdID));
1756 if (cmdid_node == NULL) {
1757 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
1761 if (pCommand->no_resp) {
1762 WBXMLTreeNode *noResp_node = sync_agent_add_child_node(binder,
1763 get_node, ELEMENT_NORESP);
1764 if (noResp_node == NULL) {
1765 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
1770 if (pCommand->cred != NULL) {
1771 err = __append_cred_to_wbxml_node(pCommand->cred, binder, get_node);
1772 if (err != SYNC_AGENT_PB_RETURN_OK) {
1777 if (content_type != NULL) {
1778 WBXMLTreeNode *meta_node = sync_agent_add_child_node(binder,
1779 get_node, ELEMENT_META);
1780 if (meta_node == NULL) {
1781 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
1785 WBXMLTreeNode *type_node = sync_agent_add_child_text_node(binder,
1786 meta_node, ELEMENT_TYPE, content_type, strlen(content_type));
1787 if (type_node == NULL) {
1788 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
1793 if (pAccess->item != NULL) {
1794 WBXMLTreeNode *item_node = sync_agent_add_child_node(binder,
1795 get_node, ELEMENT_ITEM);
1796 if (item_node == NULL) {
1797 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
1801 WBXMLTreeNode *target_node = sync_agent_add_child_node(binder,
1802 item_node, ELEMENT_TARGET);
1803 if (target_node == NULL) {
1804 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
1808 err = __append_location_to_wbxml_node(pAccess->item->target, binder, target_node);
1809 if (err != SYNC_AGENT_PB_RETURN_OK) {
1814 *wbxml_dom_node = get_node;
1819 if (get_node != NULL)
1820 sync_agent_destroy_wbxml_node(get_node);
1822 if (str_cmdID != NULL)
1829 static sync_agent_pb_error_e _oma_ds_binder_sync_start_command_converter_function(sync_agent_pb_protocol_binder_info_s * binder, Content_Ptr content, WBXMLTreeNode ** wbxml_dom_node)
1833 retvm_if(content == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "content is NULL");
1835 sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
1837 command_s *pCommand = (command_s *) content;
1839 char *str_cmdID = NULL;
1840 char *numChanged_str = NULL;
1841 char *str_freemem = NULL;
1842 char *str_freeid = NULL;
1844 WBXMLTreeNode *sync_node = sync_agent_create_node(binder, ELEMENT_SYNC);
1845 if (sync_node == NULL) {
1846 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
1850 str_cmdID = g_strdup_printf("%u", pCommand->cmd_id);
1851 if (str_cmdID == NULL) {
1852 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
1856 WBXMLTreeNode *cmdid_node = sync_agent_add_child_text_node(binder,
1857 sync_node, ELEMENT_CMDID, str_cmdID, strlen(str_cmdID));
1858 if (cmdid_node == NULL) {
1859 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
1863 if (pCommand->no_resp) {
1864 WBXMLTreeNode *noResp_node = sync_agent_add_child_node(binder,
1865 sync_node, ELEMENT_NORESP);
1866 if (noResp_node == NULL) {
1867 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
1872 if (pCommand->cred != NULL) {
1873 err = __append_cred_to_wbxml_node(pCommand->cred, binder, sync_node);
1874 if (err != SYNC_AGENT_PB_RETURN_OK) {
1879 if (pCommand->source != NULL && pCommand->target != NULL) {
1880 WBXMLTreeNode *target_node = sync_agent_add_child_node(binder,
1881 sync_node, ELEMENT_TARGET);
1882 if (target_node == NULL) {
1883 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
1887 err = __append_location_to_wbxml_node(pCommand->target, binder, target_node);
1888 if (err != SYNC_AGENT_PB_RETURN_OK) {
1892 WBXMLTreeNode *source_node = sync_agent_add_child_node(binder,
1893 sync_node, ELEMENT_SOURCE);
1894 if (source_node == NULL) {
1895 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
1899 err = __append_location_to_wbxml_node(pCommand->source, binder, source_node);
1900 if (err != SYNC_AGENT_PB_RETURN_OK) {
1907 if (pCommand->private.sync.mem != NULL) {
1908 WBXMLTreeNode *meta_node = sync_agent_add_child_node(binder, sync_node, ELEMENT_META);
1909 if (meta_node == NULL) {
1910 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
1914 WBXMLTreeNode *mem_node = sync_agent_add_child_node(binder, meta_node, ELEMENT_MEM);
1915 if (mem_node == NULL) {
1916 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
1920 if (pCommand->private.sync.mem->sharedmem) {
1921 WBXMLTreeNode *sharedmem_node = sync_agent_add_child_node(binder, mem_node, ELEMENT_SHAREDMEM);
1922 if (sharedmem_node == NULL) {
1923 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
1928 if (pCommand->private.sync.mem->free_mem) {
1929 str_freemem = g_strdup_printf("%u", pCommand->private.sync.mem->free_mem);
1930 WBXMLTreeNode *freemem_node = sync_agent_add_child_text_node(binder,
1931 mem_node, ELEMENT_FREEMEM, str_freemem, strlen(str_freemem));
1932 if (freemem_node == NULL) {
1933 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
1938 if (pCommand->private.sync.mem->free_id) {
1939 str_freeid = g_strdup_printf("%u", pCommand->private.sync.mem->free_id);
1940 WBXMLTreeNode *freeid_node = sync_agent_add_child_text_node(binder,
1941 mem_node, ELEMENT_FREEID, str_freeid, strlen(str_freeid));
1942 if (freeid_node == NULL) {
1943 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
1949 if (pCommand->private.sync.has_num_changed) {
1950 numChanged_str = g_strdup_printf("%u", pCommand->private.sync.num_changed);
1951 if (numChanged_str == NULL) {
1952 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
1956 WBXMLTreeNode *numberOfChanges_node = sync_agent_add_child_text_node(binder,
1957 sync_node, ELEMENT_NUMBEROFCHANGES, numChanged_str, strlen(numChanged_str));
1958 if (numberOfChanges_node == NULL) {
1959 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
1964 *wbxml_dom_node = sync_node;
1969 if (sync_node != NULL)
1970 sync_agent_destroy_wbxml_node(sync_node);
1972 if (str_cmdID != NULL)
1975 if (numChanged_str != NULL)
1976 free(numChanged_str);
1978 if (str_freemem != NULL)
1985 static sync_agent_pb_error_e _oma_ds_binder_sync_end_command_converter_function(sync_agent_pb_protocol_binder_info_s * binder, Content_Ptr content, WBXMLTreeNode ** wbxml_dom_node)
1989 sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
1996 static sync_agent_pb_error_e _oma_ds_binder_add_command_converter_function(sync_agent_pb_protocol_binder_info_s * binder, Content_Ptr content, WBXMLTreeNode ** wbxml_dom_node)
2000 retvm_if(content == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "content is NULL");
2002 sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
2004 char *str_cmdID = NULL;
2005 char *str_size = NULL;
2006 WBXMLTreeNode *add_node = NULL;
2008 command_s *pCommand = (command_s *) content;
2010 command_change_private_s *pChange = (command_change_private_s *) (&(pCommand->private));
2011 if (pChange == NULL) {
2012 err = SYNC_AGENT_PB_RETURN_NOT_DEFINED;
2016 add_node = sync_agent_create_node(binder, ELEMENT_ADD);
2017 if (add_node == NULL) {
2018 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
2022 str_cmdID = g_strdup_printf("%u", pCommand->cmd_id);
2023 if (str_cmdID == NULL) {
2024 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
2028 WBXMLTreeNode *cmdid_node = sync_agent_add_child_text_node(binder,
2029 add_node, ELEMENT_CMDID, str_cmdID, strlen(str_cmdID));
2030 if (cmdid_node == NULL) {
2031 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
2035 if (pCommand->no_resp) {
2036 WBXMLTreeNode *noResp_node = sync_agent_add_child_node(binder,
2037 add_node, ELEMENT_NORESP);
2038 if (noResp_node == NULL) {
2039 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
2044 if (pCommand->cred != NULL) {
2045 err = __append_cred_to_wbxml_node(pCommand->cred, binder, add_node);
2046 if (err != SYNC_AGENT_PB_RETURN_OK) {
2052 item_s *item = NULL;
2053 for (Iter = pChange->items; Iter != NULL; Iter = g_list_next(Iter)) {
2054 item = (Iter->data);
2056 WBXMLTreeNode *item_node = sync_agent_add_child_node(binder,
2057 add_node, ELEMENT_ITEM);
2058 if (item_node == NULL) {
2059 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
2063 if (item->source != NULL) {
2064 WBXMLTreeNode *source_node = sync_agent_add_child_node(binder,
2065 item_node, ELEMENT_SOURCE);
2066 if (source_node == NULL) {
2067 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
2071 err = __append_location_to_wbxml_node(item->source, binder, source_node);
2072 if (err != SYNC_AGENT_PB_RETURN_OK) {
2077 if (item->target != NULL) {
2078 WBXMLTreeNode *target_node = sync_agent_add_child_node(binder,
2079 item_node, ELEMENT_TARGET);
2080 if (target_node == NULL) {
2081 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
2085 err = __append_location_to_wbxml_node(item->target, binder, target_node);
2086 if (err != SYNC_AGENT_PB_RETURN_OK) {
2091 if (item->content_type != NULL) {
2092 WBXMLTreeNode *meta_node = sync_agent_add_child_node(binder,
2093 item_node, ELEMENT_META);
2094 if (meta_node == NULL) {
2095 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
2099 WBXMLTreeNode *type_node = sync_agent_add_child_text_node(binder,
2100 meta_node, ELEMENT_TYPE, item->content_type, strlen(item->content_type));
2101 if (type_node == NULL) {
2102 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
2106 if (item->more_data) {
2108 str_size = g_strdup_printf("%u", item->size);
2109 if (str_size == NULL) {
2110 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
2114 WBXMLTreeNode *size_node = sync_agent_add_child_text_node(binder,
2115 meta_node, ELEMENT_SIZE, str_size, strlen(str_size));
2116 if (size_node == NULL) {
2117 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
2124 if (item->data_type == ITEM_DATA) {
2125 if (item->private.data != NULL) {
2126 WBXMLTreeNode *data_node = sync_agent_add_child_cdata_node(binder,
2127 item_node, ELEMENT_DATA, item->private.data, strlen(item->private.data));
2128 if (data_node == NULL) {
2129 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
2135 if (item->more_data) {
2136 WBXMLTreeNode *moredata_node = sync_agent_add_child_node(binder,
2137 item_node, ELEMENT_MOREDATA);
2138 if (moredata_node == NULL) {
2139 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
2145 *wbxml_dom_node = add_node;
2150 if (add_node != NULL)
2151 sync_agent_destroy_wbxml_node(add_node);
2153 if (str_cmdID != NULL)
2156 if (str_size != NULL)
2163 static sync_agent_pb_error_e _oma_ds_binder_replace_command_converter_function(sync_agent_pb_protocol_binder_info_s * binder, Content_Ptr content, WBXMLTreeNode ** wbxml_dom_node)
2167 retvm_if(content == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "content is NULL");
2169 sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
2171 char *str_cmdID = NULL;
2172 char *str_size = NULL;
2173 WBXMLTreeNode *replace_node = NULL;
2175 command_s *pCommand = (command_s *) content;
2177 command_change_private_s *pChange = (command_change_private_s *) (&(pCommand->private));
2179 if (pChange == NULL) {
2180 err = SYNC_AGENT_PB_RETURN_NOT_DEFINED;
2184 replace_node = sync_agent_create_node(binder, ELEMENT_REPLACE);
2185 if (replace_node == NULL) {
2186 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
2190 str_cmdID = g_strdup_printf("%u", pCommand->cmd_id);
2191 if (str_cmdID == NULL) {
2192 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
2196 WBXMLTreeNode *cmdid_node = sync_agent_add_child_text_node(binder,
2197 replace_node, ELEMENT_CMDID, str_cmdID, strlen(str_cmdID));
2198 if (cmdid_node == NULL) {
2199 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
2203 if (pCommand->no_resp) {
2204 WBXMLTreeNode *noResp_node = sync_agent_add_child_node(binder,
2205 replace_node, ELEMENT_NORESP);
2206 if (noResp_node == NULL) {
2207 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
2212 if (pCommand->cred != NULL) {
2213 err = __append_cred_to_wbxml_node(pCommand->cred, binder, replace_node);
2214 if (err != SYNC_AGENT_PB_RETURN_OK) {
2220 item_s *item = NULL;
2221 for (Iter = pChange->items; Iter != NULL; Iter = g_list_next(Iter)) {
2222 item = (Iter->data);
2224 WBXMLTreeNode *item_node = sync_agent_add_child_node(binder,
2225 replace_node, ELEMENT_ITEM);
2226 if (item_node == NULL) {
2227 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
2231 if (item->source != NULL) {
2232 WBXMLTreeNode *source_node = sync_agent_add_child_node(binder,
2233 item_node, ELEMENT_SOURCE);
2234 if (source_node == NULL) {
2235 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
2238 err = __append_location_to_wbxml_node(item->source, binder, source_node);
2239 if (err != SYNC_AGENT_PB_RETURN_OK) {
2244 if (item->target != NULL) {
2245 WBXMLTreeNode *target_node = sync_agent_add_child_node(binder,
2246 item_node, ELEMENT_TARGET);
2247 if (target_node == NULL) {
2248 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
2251 err = __append_location_to_wbxml_node(item->target, binder, target_node);
2252 if (err != SYNC_AGENT_PB_RETURN_OK) {
2257 if (item->content_type != NULL) {
2258 WBXMLTreeNode *meta_node = sync_agent_add_child_node(binder,
2259 item_node, ELEMENT_META);
2260 if (meta_node == NULL) {
2261 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
2265 WBXMLTreeNode *type_node = sync_agent_add_child_text_node(binder,
2266 meta_node, ELEMENT_TYPE, item->content_type, strlen(item->content_type));
2267 if (type_node == NULL) {
2268 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
2272 if (item->more_data) {
2274 str_size = g_strdup_printf("%u", item->size);
2275 if (str_size == NULL) {
2276 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
2280 WBXMLTreeNode *size_node = sync_agent_add_child_text_node(binder,
2281 meta_node, ELEMENT_SIZE, str_size, strlen(str_size));
2282 if (size_node == NULL) {
2283 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
2290 if (item->data_type == ITEM_DATA) {
2291 if (item->private.data != NULL) {
2292 WBXMLTreeNode *data_node = sync_agent_add_child_cdata_node(binder,
2293 item_node, ELEMENT_DATA, item->private.data, strlen(item->private.data));
2294 if (data_node == NULL) {
2295 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
2301 if (item->more_data) {
2302 WBXMLTreeNode *moredata_node = sync_agent_add_child_node(binder,
2303 item_node, ELEMENT_MOREDATA);
2304 if (moredata_node == NULL) {
2305 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
2312 *wbxml_dom_node = replace_node;
2313 replace_node = NULL;
2317 if (replace_node != NULL)
2318 sync_agent_destroy_wbxml_node(replace_node);
2320 if (str_cmdID != NULL)
2323 if (str_size != NULL)
2330 static sync_agent_pb_error_e _oma_ds_binder_delete_command_converter_function(sync_agent_pb_protocol_binder_info_s * binder, Content_Ptr content, WBXMLTreeNode ** wbxml_dom_node)
2334 retvm_if(content == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "content is NULL");
2336 sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
2338 char *str_cmdID = NULL;
2339 char *str_size = NULL;
2340 WBXMLTreeNode *delete_node = NULL;
2342 command_s *pCommand = (command_s *) content;
2344 command_change_private_s *pChange = (command_change_private_s *) (&(pCommand->private));
2345 if (pChange == NULL) {
2346 err = SYNC_AGENT_PB_RETURN_NOT_DEFINED;
2350 delete_node = sync_agent_create_node(binder, ELEMENT_DELETE);
2351 if (delete_node == NULL) {
2352 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
2356 str_cmdID = g_strdup_printf("%u", pCommand->cmd_id);
2357 if (str_cmdID == NULL) {
2358 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
2362 WBXMLTreeNode *cmdid_node = sync_agent_add_child_text_node(binder,
2363 delete_node, ELEMENT_CMDID, str_cmdID, strlen(str_cmdID));
2364 if (cmdid_node == NULL) {
2365 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
2369 if (pCommand->no_resp) {
2370 WBXMLTreeNode *noResp_node = sync_agent_add_child_node(binder,
2371 delete_node, ELEMENT_NORESP);
2372 if (noResp_node == NULL) {
2373 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
2381 if (pCommand->cred != NULL) {
2382 err = __append_cred_to_wbxml_node(pCommand->cred, binder, delete_node);
2383 if (err != SYNC_AGENT_PB_RETURN_OK) {
2389 item_s *item = NULL;
2390 for (Iter = pCommand->private.change.items; Iter != NULL; Iter = g_list_next(Iter)) {
2391 item = (Iter->data);
2393 WBXMLTreeNode *item_node = sync_agent_add_child_node(binder,
2394 delete_node, ELEMENT_ITEM);
2395 if (item_node == NULL) {
2396 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
2400 if (item->source != NULL) {
2401 WBXMLTreeNode *source_node = sync_agent_add_child_node(binder,
2402 item_node, ELEMENT_SOURCE);
2403 if (source_node == NULL) {
2404 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
2408 err = __append_location_to_wbxml_node(item->source, binder, source_node);
2409 if (err != SYNC_AGENT_PB_RETURN_OK) {
2414 if (item->target != NULL) {
2415 WBXMLTreeNode *target_node = sync_agent_add_child_node(binder,
2416 item_node, ELEMENT_TARGET);
2417 if (target_node == NULL) {
2418 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
2422 err = __append_location_to_wbxml_node(item->target, binder, target_node);
2423 if (err != SYNC_AGENT_PB_RETURN_OK) {
2428 if (item->content_type != NULL) {
2429 WBXMLTreeNode *meta_node = sync_agent_add_child_node(binder,
2430 item_node, ELEMENT_META);
2431 if (meta_node == NULL) {
2432 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
2436 WBXMLTreeNode *type_node = sync_agent_add_child_text_node(binder,
2437 meta_node, ELEMENT_TYPE, item->content_type, strlen(item->content_type));
2438 if (type_node == NULL) {
2439 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
2444 str_size = g_strdup_printf("%u", item->size);
2445 if (str_size == NULL) {
2446 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
2450 WBXMLTreeNode *size_node = sync_agent_add_child_text_node(binder,
2451 meta_node, ELEMENT_SIZE, str_size, strlen(str_size));
2452 if (size_node == NULL) {
2453 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
2460 *wbxml_dom_node = delete_node;
2465 if (delete_node != NULL)
2466 sync_agent_destroy_wbxml_node(delete_node);
2468 if (str_cmdID != NULL)
2471 if (str_size != NULL)
2478 static sync_agent_pb_error_e _oma_ds_binder_map_command_converter_function(sync_agent_pb_protocol_binder_info_s * binder, Content_Ptr content, WBXMLTreeNode ** wbxml_dom_node)
2482 retvm_if(content == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "content is NULL");
2484 sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
2485 char *str_cmdID = NULL;
2487 command_s *pCommand = (command_s *) content;
2489 WBXMLTreeNode *map_node = sync_agent_create_node(binder, ELEMENT_MAP);
2490 if (map_node == NULL) {
2491 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
2495 str_cmdID = g_strdup_printf("%u", pCommand->cmd_id);
2496 if (str_cmdID == NULL) {
2497 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
2501 WBXMLTreeNode *cmdid_node = sync_agent_add_child_text_node(binder,
2502 map_node, ELEMENT_CMDID, str_cmdID, strlen(str_cmdID));
2503 if (cmdid_node == NULL) {
2504 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
2508 if (pCommand->source != NULL && pCommand->target != NULL) {
2509 WBXMLTreeNode *target_node = sync_agent_add_child_node(binder,
2510 map_node, ELEMENT_TARGET);
2511 if (target_node == NULL) {
2512 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
2516 err = __append_location_to_wbxml_node(pCommand->target, binder, target_node);
2517 if (err != SYNC_AGENT_PB_RETURN_OK) {
2521 WBXMLTreeNode *source_node = sync_agent_add_child_node(binder,
2522 map_node, ELEMENT_SOURCE);
2523 if (source_node == NULL) {
2524 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
2528 err = __append_location_to_wbxml_node(pCommand->source, binder, source_node);
2529 if (err != SYNC_AGENT_PB_RETURN_OK) {
2534 if (pCommand->cred != NULL) {
2535 err = __append_cred_to_wbxml_node(pCommand->cred, binder, map_node);
2536 if (err != SYNC_AGENT_PB_RETURN_OK) {
2542 item_s *item = NULL;
2543 for (iter = pCommand->private.map.items; iter != NULL; iter = g_list_next(iter)) {
2545 WBXMLTreeNode *mapItem_node = sync_agent_add_child_node(binder,
2546 map_node, ELEMENT_MAPITEM);
2547 if (mapItem_node == NULL) {
2548 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
2552 if (item->source != NULL && item->target != NULL) {
2553 WBXMLTreeNode *item_target_node = sync_agent_add_child_node(binder,
2554 mapItem_node, ELEMENT_TARGET);
2555 if (item_target_node == NULL) {
2556 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
2560 err = __append_location_to_wbxml_node(item->target, binder, item_target_node);
2561 if (err != SYNC_AGENT_PB_RETURN_OK) {
2565 WBXMLTreeNode *item_source_node = sync_agent_add_child_node(binder,
2566 mapItem_node, ELEMENT_SOURCE);
2567 if (item_source_node == NULL) {
2568 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
2572 err = __append_location_to_wbxml_node(item->source, binder, item_source_node);
2573 if (err != SYNC_AGENT_PB_RETURN_OK) {
2579 *wbxml_dom_node = map_node;
2584 if (map_node != NULL)
2585 sync_agent_destroy_wbxml_node(map_node);
2587 if (str_cmdID != NULL)
2594 static protocol_version_e __get_oma_ds_protocol_version(char *verdtd)
2598 retvm_if(verdtd == NULL, VERSION_UNKNOWN, "verdtd is NULL");
2600 protocol_version_e protocol_version = VERSION_UNKNOWN;
2601 if (strcmp(verdtd, ELEMENT_VERDRD_12) == 0) {
2602 protocol_version = VERSION_12;
2603 } else if (strcmp(verdtd, ELEMENT_VERDRD_11) == 0) {
2604 protocol_version = VERSION_11;
2605 } else if (strcmp(verdtd, ELEMENT_VERDRD_10) == 0) {
2606 protocol_version = VERSION_10;
2610 return protocol_version;
2613 static devinf_version_e __get_oma_ds_devInf_version(char *verdtd)
2617 retvm_if(verdtd == NULL, DEVINF_VERSION_UNKNOWN, "verdtd is NULL");
2619 devinf_version_e devInf_version = DEVINF_VERSION_UNKNOWN;
2620 if (strcmp(verdtd, ELEMENT_VERDRD_12) == 0) {
2621 devInf_version = DEVINF_VERSION_12;
2622 } else if (strcmp(verdtd, ELEMENT_VERDRD_11) == 0) {
2623 devInf_version = DEVINF_VERSION_11;
2624 } else if (strcmp(verdtd, ELEMENT_VERDRD_10) == 0) {
2625 devInf_version = DEVINF_VERSION_10;
2629 return devInf_version;
2632 static devinf_devtyp_e __get_oma_ds_devInf_device_type(char *dev_type)
2636 retvm_if(dev_type == NULL, DEVINF_DEVTYPE_UNKNOWN, "dev_type is NULL");
2638 devinf_devtyp_e device_type = DEVINF_DEVTYPE_UNKNOWN;
2639 if (strcmp(dev_type, ELEMENT_PAGER) == 0) {
2640 device_type = DEVINF_DEVTYPE_PAGER;
2641 } else if (strcmp(dev_type, ELEMENT_HANDHELD) == 0) {
2642 device_type = DEVINF_DEVTYPE_HANDHELD;
2643 } else if (strcmp(dev_type, ELEMENT_PDA) == 0) {
2644 device_type = DEVINF_DEVTYPE_PDA;
2645 } else if (strcmp(dev_type, ELEMENT_PHONE) == 0) {
2646 device_type = DEVINF_DEVTYPE_PHONE;
2647 } else if (strcmp(dev_type, ELEMENT_SMARTPHONE) == 0) {
2648 device_type = DEVINF_DEVTYPE_SMARTPHONE;
2649 } else if (strcmp(dev_type, ELEMENT_SERVER) == 0) {
2650 device_type = DEVINF_DEVTYPE_SERVER;
2651 } else if (strcmp(dev_type, ELEMENT_WORKSTATION) == 0) {
2652 device_type = DEVINF_DEVTYPE_WORKSTATION;
2659 static devinf_content_type_s *__get_devinf_contenttype(WBXMLTreeNode * node)
2663 retvm_if(node == NULL, NULL, "node is NULL");
2665 sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
2666 devinf_content_type_s *devinf_content_type = NULL;
2668 devinf_content_type = (devinf_content_type_s *) calloc(1, sizeof(devinf_content_type_s));
2669 if (devinf_content_type == NULL) {
2670 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
2671 _DEBUG_ERROR("devinf_content_type is null");
2675 /* get first child */
2676 WBXMLTreeNode *child = node->children;
2677 for (; child != NULL && child->type != WBXML_TREE_ELEMENT_NODE; child = child->next) {
2680 const char *first_child_name = NULL;
2681 if (child != NULL) {
2682 first_child_name = (const char *)wbxml_tag_get_xml_name(child->name);
2683 if (strcmp(first_child_name, ELEMENT_CTTYPE) == 0) {
2684 char *ctType = NULL;
2685 err = sync_agent_get_text_from_node(child, &ctType);
2686 if (err != SYNC_AGENT_PB_RETURN_OK) {
2690 devinf_content_type->ct_type = strdup(ctType);
2696 /* get second child */
2697 child = child->next;
2698 for (; child != NULL && child->type != WBXML_TREE_ELEMENT_NODE; child = child->next) {
2701 if (child != NULL) {
2702 const char *second_child_name = NULL;
2703 second_child_name = (const char *)wbxml_tag_get_xml_name(child->name);
2704 if (strcmp(second_child_name, ELEMENT_VERCT) == 0) {
2706 err = sync_agent_get_text_from_node(child, &verCT);
2707 if (err != SYNC_AGENT_PB_RETURN_OK) {
2711 devinf_content_type->verct = strdup(verCT);
2720 return devinf_content_type;
2725 if (devinf_content_type != NULL)
2726 free(devinf_content_type);
2733 static location_s *_get_location(WBXMLTreeNode * node)
2737 retvm_if(node == NULL, NULL, "node is NULL");
2739 sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
2740 location_s *location = NULL;
2742 WBXMLTreeNode *child = NULL;
2744 char *locURI = NULL;
2745 char *locName = NULL;
2747 /* get first child : required LocURI */
2748 child = node->children;
2749 for (; child != NULL && child->type != WBXML_TREE_ELEMENT_NODE; child = child->next) {
2752 const char *first_child_name = NULL;
2753 if (child != NULL) {
2754 first_child_name = (const char *)wbxml_tag_get_xml_name(child->name);
2755 _DEBUG_TRACE("child_name = %s", first_child_name);
2756 if (strcmp(first_child_name, ELEMENT_LOCURI) == 0) {
2757 err = sync_agent_get_text_from_node(child, &locURI);
2758 if (err != SYNC_AGENT_PB_RETURN_OK) {
2766 /* get second child : optional LocName */
2767 child = child->next;
2768 for (; child != NULL && child->type != WBXML_TREE_ELEMENT_NODE; child = child->next) {
2771 if (child != NULL) {
2772 const char *second_child_name = NULL;
2773 second_child_name = (const char *)wbxml_tag_get_xml_name(child->name);
2774 _DEBUG_TRACE("child_name = %s", second_child_name);
2775 if (strcmp(second_child_name, ELEMENT_LOCNAME) == 0) {
2776 err = sync_agent_get_text_from_node(child, &locName);
2777 if (err != SYNC_AGENT_PB_RETURN_OK) {
2786 sa_error_type_e error = create_location(locURI, locName, &location);
2787 if (error != SA_INTERNAL_OK) {
2788 _DEBUG_ERROR("create_location() failed !, error = %d", error);
2802 static anchor_s *_get_anchor(WBXMLTreeNode * node)
2806 retvm_if(node == NULL, NULL, "node is NULL");
2808 sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
2809 anchor_s *anchor = NULL;
2811 WBXMLTreeNode *child = NULL;
2813 char *lastAnchor = NULL;
2814 char *nextAnchor = NULL;
2815 /* get first child : optional lastAnchor */
2816 child = node->children;
2817 for (; child != NULL && child->type != WBXML_TREE_ELEMENT_NODE; child = child->next) {
2820 const char *first_child_name = NULL;
2821 if (child != NULL) {
2822 first_child_name = (const char *)wbxml_tag_get_xml_name(child->name);
2823 _DEBUG_TRACE("child_name = %s", first_child_name);
2824 if (strcmp(first_child_name, ELEMENT_LAST) == 0) {
2825 err = sync_agent_get_text_from_node(child, &lastAnchor);
2826 if (err != SYNC_AGENT_PB_RETURN_OK) {
2829 child = child->next;
2830 for (; child != NULL && child->type != WBXML_TREE_ELEMENT_NODE; child = child->next) {
2832 } else if (strcmp(first_child_name, ELEMENT_NEXT) == 0) {
2833 err = sync_agent_get_text_from_node(child, &nextAnchor);
2834 if (err != SYNC_AGENT_PB_RETURN_OK) {
2840 /* get second child : required nextAnchor */
2841 if (child != NULL) {
2842 const char *second_child_name = NULL;
2843 second_child_name = (const char *)wbxml_tag_get_xml_name(child->name);
2844 _DEBUG_TRACE("child_name = %s", second_child_name);
2845 if (strcmp(second_child_name, ELEMENT_NEXT) == 0) {
2846 err = sync_agent_get_text_from_node(child, &nextAnchor);
2847 if (err != SYNC_AGENT_PB_RETURN_OK) {
2856 sa_error_type_e error = create_anchor(lastAnchor, nextAnchor, &anchor);
2857 if (error != SA_INTERNAL_OK) {
2858 _DEBUG_ERROR("create_anchor() failed !, error = %d", error);
2872 static cred_s *__get_cred(WBXMLTreeNode * node)
2876 retvm_if(node == NULL, NULL, "node is NULL");
2878 sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
2879 cred_s *cred = NULL;
2883 char *format = NULL;
2885 WBXMLTreeNode *child = NULL;
2887 for (child = node->children; child != NULL; child = child->next) {
2888 if (child->type != WBXML_TREE_ELEMENT_NODE)
2891 const char *child_xml_name = NULL;
2892 child_xml_name = (const char *)wbxml_tag_get_xml_name(child->name);
2894 if (strcmp(child_xml_name, ELEMENT_META) == 0) {
2895 WBXMLTreeNode *grand_child = child->children;
2897 const char *grand_child_xml_name = NULL;
2898 grand_child_xml_name = (const char *)wbxml_tag_get_xml_name(grand_child->name);
2900 if (strcmp(grand_child_xml_name, ELEMENT_TYPE) == 0) {
2901 err = sync_agent_get_text_from_node(grand_child, &type);
2902 if (err != SYNC_AGENT_PB_RETURN_OK) {
2905 _DEBUG_VERBOSE("Type = [%s]", type);
2906 } else if (strcmp(grand_child_xml_name, ELEMENT_FORMAT) == 0) {
2907 err = sync_agent_get_text_from_node(grand_child, &format);
2908 if (err != SYNC_AGENT_PB_RETURN_OK) {
2911 _DEBUG_VERBOSE("Type = [%s]", format);
2913 } else if (strcmp(child_xml_name, ELEMENT_DATA) == 0) {
2914 err = sync_agent_get_text_from_node(child, &data);
2915 if (err != SYNC_AGENT_PB_RETURN_OK) {
2918 _DEBUG_VERBOSE("Data = [%s]", data);
2923 cred = create_cred_with_data(convert_auth_type(type), data);
2925 format_type_e formatType = FORMAT_TYPE_UNKNOWN;
2926 if (format != NULL) {
2927 if (strcmp(format, ELEMENT_B64) == 0)
2928 formatType = FORMAT_TYPE_BASE64;
2931 set_cred_format_type(cred, formatType);
2942 static chal_s *_get_chal(WBXMLTreeNode * node)
2946 retvm_if(node == NULL, NULL, "node is NULL");
2948 sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
2950 chal_s *pChal = (chal_s *) calloc(1, sizeof(chal_s));
2951 if (pChal == NULL) {
2952 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
2953 _DEBUG_ERROR("pChal is null");
2957 WBXMLTreeNode *chal_child = node->children;
2959 WBXMLTreeNode *meta_child = NULL;
2961 for (meta_child = chal_child->children; meta_child != NULL; meta_child = meta_child->next) {
2962 if (meta_child->type != WBXML_TREE_ELEMENT_NODE)
2965 const char *meta_child_xml_name = NULL;
2966 meta_child_xml_name = (const char *)wbxml_tag_get_xml_name(meta_child->name);
2968 if (strcmp(meta_child_xml_name, ELEMENT_TYPE) == 0) {
2970 err = sync_agent_get_text_from_node(meta_child, &type);
2971 if (err != SYNC_AGENT_PB_RETURN_OK) {
2974 _DEBUG_TRACE("Type = [%s]", type);
2976 pChal->type = convert_auth_type(type);
2977 } else if (strcmp(meta_child_xml_name, ELEMENT_FORMAT) == 0) {
2978 char *format = NULL;
2979 err = sync_agent_get_text_from_node(meta_child, &format);
2980 if (err != SYNC_AGENT_PB_RETURN_OK) {
2983 _DEBUG_TRACE("Format = [%s]", format);
2985 pChal->format = convert_format_type(format);
2986 } else if (strcmp(meta_child_xml_name, ELEMENT_NEXTNONCE) == 0) {
2987 char *nextnonce = NULL;
2988 unsigned int nonce_len = 0;
2989 err = sync_agent_get_binary_from_node(meta_child, &nextnonce, &nonce_len);
2990 if (err != SYNC_AGENT_PB_RETURN_OK) {
2993 _DEBUG_TRACE("NextNonce = [%s]", nextnonce);
2994 if (pChal->format == FORMAT_TYPE_BASE64) {
2995 if (nextnonce != NULL)
2996 pChal->nonce_b64 = strdup(nextnonce);
2998 pChal->nonce_plain = (char *)malloc(nonce_len + 1);
2999 if (pChal->nonce_plain == NULL) {
3000 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
3003 memcpy(pChal->nonce_plain, nextnonce, nonce_len);
3004 pChal->nonce_plain[nonce_len] = '\0';
3007 pChal->nonce_length = nonce_len;
3023 static sync_agent_pb_error_e _oma_ds_binder_devinf_reverse_converter_function(sync_agent_pb_protocol_binder_reverse_info_s * reverse_binder, WBXMLTreeNode * wbxml_dom_node, Content_Ptr * content)
3027 retvm_if(wbxml_dom_node == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "wbxml_dom_node is NULL");
3029 sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
3031 /* get data from dom tree */
3032 devinf_s *pDevInf = (devinf_s *) calloc(1, sizeof(devinf_s));
3033 if (pDevInf == NULL) {
3034 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
3035 _DEBUG_ERROR("pDevInf is null");
3039 WBXMLTreeNode *child = NULL;
3041 for (child = wbxml_dom_node->children; child != NULL; child = child->next) {
3042 if (child->type != WBXML_TREE_ELEMENT_NODE)
3045 const char *child_xml_name = NULL;
3046 child_xml_name = (const char *)wbxml_tag_get_xml_name(child->name);
3048 if (strcmp(child_xml_name, ELEMENT_VERDTD) == 0) {
3049 char *verdtd = NULL;
3050 err = sync_agent_get_text_from_node(child, &verdtd);
3051 if (err != SYNC_AGENT_PB_RETURN_OK) {
3054 _DEBUG_TRACE("VerDTD = [%s]", verdtd);
3056 pDevInf->version = __get_oma_ds_devInf_version(verdtd);
3057 } else if (strcmp(child_xml_name, ELEMENT_MAN) == 0) {
3059 err = sync_agent_get_text_from_node(child, &man);
3060 if (err != SYNC_AGENT_PB_RETURN_OK) {
3063 _DEBUG_TRACE("Man = [%s]", man);
3065 pDevInf->manufacturer = strdup(man);
3066 } else if (strcmp(child_xml_name, ELEMENT_MOD) == 0) {
3068 err = sync_agent_get_text_from_node(child, &mod);
3069 if (err != SYNC_AGENT_PB_RETURN_OK) {
3072 _DEBUG_TRACE("Mod = [%s]", mod);
3074 pDevInf->model = strdup(mod);
3075 } else if (strcmp(child_xml_name, ELEMENT_OEM) == 0) {
3077 err = sync_agent_get_text_from_node(child, &oem);
3078 if (err != SYNC_AGENT_PB_RETURN_OK) {
3081 _DEBUG_TRACE("OEM = [%s]", oem);
3083 pDevInf->oem = strdup(oem);
3084 } else if (strcmp(child_xml_name, ELEMENT_FWV) == 0) {
3086 err = sync_agent_get_text_from_node(child, &fwv);
3087 if (err != SYNC_AGENT_PB_RETURN_OK) {
3090 _DEBUG_TRACE("FwV = [%s]", fwv);
3092 pDevInf->firmware_version = strdup(fwv);
3093 } else if (strcmp(child_xml_name, ELEMENT_SWV) == 0) {
3095 err = sync_agent_get_text_from_node(child, &swv);
3096 if (err != SYNC_AGENT_PB_RETURN_OK) {
3099 _DEBUG_TRACE("SwV = [%s]", swv);
3101 pDevInf->software_version = strdup(swv);
3102 } else if (strcmp(child_xml_name, ELEMENT_HWV) == 0) {
3104 err = sync_agent_get_text_from_node(child, &hwv);
3105 if (err != SYNC_AGENT_PB_RETURN_OK) {
3108 _DEBUG_TRACE("HwV = [%s]", hwv);
3110 pDevInf->hardware_version = strdup(hwv);
3111 } else if (strcmp(child_xml_name, ELEMENT_DEVID) == 0) {
3113 err = sync_agent_get_text_from_node(child, &devID);
3114 if (err != SYNC_AGENT_PB_RETURN_OK) {
3117 _DEBUG_TRACE("DevID = [%s]", devID);
3119 pDevInf->dev_id = strdup(devID);
3120 } else if (strcmp(child_xml_name, ELEMENT_DEVTYP) == 0) {
3121 char *devtyp = NULL;
3122 err = sync_agent_get_text_from_node(child, &devtyp);
3123 if (err != SYNC_AGENT_PB_RETURN_OK) {
3126 _DEBUG_TRACE("DevTyp = [%s]", devtyp);
3128 pDevInf->devtyp = __get_oma_ds_devInf_device_type(devtyp);
3129 } else if (strcmp(child_xml_name, ELEMENT_UTC) == 0) {
3130 _DEBUG_TRACE("UTC");
3131 pDevInf->supports_utc = 1;
3132 } else if (strcmp(child_xml_name, ELEMENT_SUPPORTLARGEOBJS) == 0) {
3133 _DEBUG_TRACE("SupportLargeObjs");
3134 pDevInf->supports_large_objs = 1;
3135 } else if (strcmp(child_xml_name, ELEMENT_SUPPORTNUMBEROFCHANGES) == 0) {
3136 _DEBUG_TRACE("SupportNumberOfChanges");
3137 pDevInf->supports_number_of_changes = 1;
3138 } else if (strcmp(child_xml_name, ELEMENT_DATASTORE) == 0) {
3140 devinf_datastore_s *pDevInfDataStore = (devinf_datastore_s *) calloc(1, sizeof(devinf_datastore_s));
3141 if (pDevInfDataStore == NULL) {
3142 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
3143 _DEBUG_ERROR("pDevInfDataStore is null");
3147 WBXMLTreeNode *datastore_child = NULL;
3149 for (datastore_child = child->children; datastore_child != NULL; datastore_child = datastore_child->next) {
3150 if (datastore_child->type != WBXML_TREE_ELEMENT_NODE)
3153 const char *datastore_child_xml_name = NULL;
3154 datastore_child_xml_name = (const char *)wbxml_tag_get_xml_name(datastore_child->name);
3156 if (strcmp(datastore_child_xml_name, ELEMENT_SOURCEREF) == 0) {
3157 char *sourceref = NULL;
3158 err = sync_agent_get_text_from_node(datastore_child, &sourceref);
3159 if (err != SYNC_AGENT_PB_RETURN_OK) {
3160 if (pDevInfDataStore != NULL)
3161 free(pDevInfDataStore);
3165 _DEBUG_TRACE("SourceRef = [%s]", sourceref);
3166 if (sourceref != NULL)
3167 pDevInfDataStore->source_ref = strdup(sourceref);
3168 } else if (strcmp(datastore_child_xml_name, ELEMENT_DISPLAYNAME) == 0) {
3169 char *displayname = NULL;
3170 err = sync_agent_get_text_from_node(datastore_child, &displayname);
3171 if (err != SYNC_AGENT_PB_RETURN_OK) {
3172 if (pDevInfDataStore != NULL)
3173 free(pDevInfDataStore);
3177 _DEBUG_TRACE("DisplayName = [%s]", displayname);
3178 if (displayname != NULL)
3179 pDevInfDataStore->display_name = strdup(displayname);
3180 } else if (strcmp(datastore_child_xml_name, ELEMENT_MAXGUIDSIZE) == 0) {
3181 char *maxguidsize = NULL;
3182 err = sync_agent_get_text_from_node(datastore_child, &maxguidsize);
3183 if (err != SYNC_AGENT_PB_RETURN_OK) {
3184 if (pDevInfDataStore != NULL)
3185 free(pDevInfDataStore);
3189 _DEBUG_TRACE("MaxGUIDSize = [%s]", maxguidsize);
3190 if (maxguidsize != NULL)
3191 pDevInfDataStore->max_guid_size = atoi(maxguidsize);
3192 } else if (strcmp(datastore_child_xml_name, ELEMENT_RX_PREF) == 0) {
3193 devinf_content_type_s *devinf_content_type = __get_devinf_contenttype(datastore_child);
3194 if (devinf_content_type == NULL) {
3195 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
3196 if (pDevInfDataStore != NULL)
3197 free(pDevInfDataStore);
3201 pDevInfDataStore->rx_pref = devinf_content_type;
3202 } else if (strcmp(datastore_child_xml_name, ELEMENT_RX) == 0) {
3203 devinf_content_type_s *devinf_content_type = __get_devinf_contenttype(datastore_child);
3204 if (devinf_content_type == NULL) {
3205 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
3206 if (pDevInfDataStore != NULL)
3207 free(pDevInfDataStore);
3211 pDevInfDataStore->rx = g_list_append(pDevInfDataStore->rx, devinf_content_type);
3212 } else if (strcmp(datastore_child_xml_name, ELEMENT_TX_PREF) == 0) {
3213 devinf_content_type_s *devinf_content_type = __get_devinf_contenttype(datastore_child);
3214 if (devinf_content_type == NULL) {
3215 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
3216 if (pDevInfDataStore != NULL)
3217 free(pDevInfDataStore);
3221 pDevInfDataStore->tx_pref = devinf_content_type;
3222 } else if (strcmp(datastore_child_xml_name, ELEMENT_TX) == 0) {
3223 devinf_content_type_s *devinf_content_type = __get_devinf_contenttype(datastore_child);
3224 if (devinf_content_type == NULL) {
3225 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
3226 if (pDevInfDataStore != NULL)
3227 free(pDevInfDataStore);
3231 pDevInfDataStore->tx = g_list_append(pDevInfDataStore->tx, devinf_content_type);
3232 } else if (strcmp(datastore_child_xml_name, ELEMENT_CTCAP) == 0) {
3234 devinf_ct_cap_s *pDevInfCtCap = (devinf_ct_cap_s *) calloc(1, sizeof(devinf_ct_cap_s));
3235 if (pDevInfCtCap == NULL) {
3236 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
3237 _DEBUG_ERROR("pDevInfCtCap is null");
3238 if (pDevInfDataStore != NULL)
3239 free(pDevInfDataStore);
3244 devinf_content_type_s *devinf_content_type = NULL;
3245 WBXMLTreeNode *ctcap_child = NULL;
3247 for (ctcap_child = datastore_child->children; ctcap_child != NULL; ctcap_child = ctcap_child->next) {
3248 if (ctcap_child->type != WBXML_TREE_ELEMENT_NODE)
3251 const char *ctcap_child_xml_name = NULL;
3252 ctcap_child_xml_name = (const char *)wbxml_tag_get_xml_name(ctcap_child->name);
3254 if (strcmp(ctcap_child_xml_name, ELEMENT_CTTYPE) == 0) {
3255 if (devinf_content_type == NULL) {
3256 devinf_content_type = (devinf_content_type_s *) calloc(1, sizeof(devinf_content_type_s));
3257 if (devinf_content_type == NULL) {
3258 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
3259 _DEBUG_ERROR("devinf_content_type is null");
3260 if (pDevInfDataStore != NULL)
3261 free(pDevInfDataStore);
3263 if (pDevInfCtCap != NULL)
3270 char *cttype = NULL;
3271 err = sync_agent_get_text_from_node(ctcap_child, &cttype);
3272 if (err != SYNC_AGENT_PB_RETURN_OK) {
3273 if (pDevInfDataStore != NULL)
3274 free(pDevInfDataStore);
3276 if (pDevInfCtCap != NULL)
3279 if (devinf_content_type != NULL)
3280 free(devinf_content_type);
3284 _DEBUG_TRACE("CTType = [%s]", cttype);
3286 devinf_content_type->ct_type = strdup(cttype);
3287 } else if (strcmp(ctcap_child_xml_name, ELEMENT_VERCT) == 0) {
3288 if (devinf_content_type == NULL) {
3289 devinf_content_type = (devinf_content_type_s *) calloc(1, sizeof(devinf_content_type_s));
3290 if (devinf_content_type == NULL) {
3291 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
3292 _DEBUG_ERROR("devinf_content_type is null");
3294 if (pDevInfDataStore != NULL)
3295 free(pDevInfDataStore);
3297 if (pDevInfCtCap != NULL)
3300 if (devinf_content_type != NULL)
3301 free(devinf_content_type);
3308 err = sync_agent_get_text_from_node(ctcap_child, &verct);
3309 if (err != SYNC_AGENT_PB_RETURN_OK) {
3311 if (pDevInfDataStore != NULL)
3312 free(pDevInfDataStore);
3314 if (pDevInfCtCap != NULL)
3317 if (devinf_content_type != NULL)
3318 free(devinf_content_type);
3322 _DEBUG_TRACE("VerCT = [%s]", verct);
3324 devinf_content_type->verct = strdup(verct);
3325 } else if (strcmp(ctcap_child_xml_name, ELEMENT_FIELDLEVEL) == 0) {
3326 /*TODO fieldlevel */
3328 } else if (strcmp(ctcap_child_xml_name, ELEMENT_PROPERTY) == 0) {
3330 devinf_property_s *pDevInfProperty = (devinf_property_s *) calloc(1, sizeof(devinf_property_s));
3331 if (pDevInfProperty == NULL) {
3332 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
3333 _DEBUG_ERROR("pDevInfProperty is null");
3335 if (pDevInfDataStore != NULL)
3336 free(pDevInfDataStore);
3338 if (pDevInfCtCap != NULL)
3341 if (devinf_content_type != NULL)
3342 free(devinf_content_type);
3347 WBXMLTreeNode *property_child = NULL;
3348 for (property_child = ctcap_child->children; property_child != NULL; property_child = property_child->next) {
3349 if (property_child->type != WBXML_TREE_ELEMENT_NODE)
3352 const char *property_child_xml_name = NULL;
3353 property_child_xml_name = (const char *)wbxml_tag_get_xml_name(property_child->name);
3355 if (strcmp(property_child_xml_name, ELEMENT_PROPNAME) == 0) {
3356 char *propname = NULL;
3357 err = sync_agent_get_text_from_node(property_child, &propname);
3358 if (err != SYNC_AGENT_PB_RETURN_OK) {
3360 if (pDevInfDataStore != NULL)
3361 free(pDevInfDataStore);
3363 if (pDevInfCtCap != NULL)
3366 if (devinf_content_type != NULL)
3367 free(devinf_content_type);
3369 if (pDevInfProperty != NULL)
3370 free(pDevInfProperty);
3374 _DEBUG_TRACE("PropName = [%s]", propname);
3375 if (propname != NULL)
3376 pDevInfProperty->prop_name = strdup(propname);
3377 } else if (strcmp(property_child_xml_name, ELEMENT_DATATYPE) == 0) {
3378 char *datatype = NULL;
3379 err = sync_agent_get_text_from_node(property_child, &datatype);
3380 if (err != SYNC_AGENT_PB_RETURN_OK) {
3382 if (pDevInfDataStore != NULL)
3383 free(pDevInfDataStore);
3385 if (pDevInfCtCap != NULL)
3388 if (devinf_content_type != NULL)
3389 free(devinf_content_type);
3391 if (pDevInfProperty != NULL)
3392 free(pDevInfProperty);
3396 _DEBUG_TRACE("DataType = [%s]", datatype);
3397 if (datatype != NULL)
3398 pDevInfProperty->data_type = strdup(datatype);
3399 } else if (strcmp(property_child_xml_name, ELEMENT_MAXOCCUR) == 0) {
3400 char *maxoccur = NULL;
3401 err = sync_agent_get_text_from_node(property_child, &maxoccur);
3402 if (err != SYNC_AGENT_PB_RETURN_OK) {
3404 if (pDevInfDataStore != NULL)
3405 free(pDevInfDataStore);
3407 if (pDevInfCtCap != NULL)
3410 if (devinf_content_type != NULL)
3411 free(devinf_content_type);
3413 if (pDevInfProperty != NULL)
3414 free(pDevInfProperty);
3418 _DEBUG_TRACE("MaxOccur = [%s]", maxoccur);
3419 if (maxoccur != NULL)
3420 pDevInfProperty->max_occur = atoi(maxoccur);
3421 } else if (strcmp(property_child_xml_name, ELEMENT_MAXSIZE) == 0) {
3422 char *maxsize = NULL;
3423 err = sync_agent_get_text_from_node(property_child, &maxsize);
3424 if (err != SYNC_AGENT_PB_RETURN_OK) {
3426 if (pDevInfDataStore != NULL)
3427 free(pDevInfDataStore);
3429 if (pDevInfCtCap != NULL)
3432 if (devinf_content_type != NULL)
3433 free(devinf_content_type);
3435 if (pDevInfProperty != NULL)
3436 free(pDevInfProperty);
3440 _DEBUG_TRACE("MaxSize = [%s]", maxsize);
3441 if (maxsize != NULL)
3442 pDevInfProperty->max_size = atoi(maxsize);
3443 } else if (strcmp(property_child_xml_name, ELEMENT_NOTRUNCATE) == 0) {
3444 _DEBUG_TRACE("NoTruncate");
3445 pDevInfProperty->no_truncate = 1;
3446 } else if (strcmp(property_child_xml_name, ELEMENT_VALENUM) == 0) {
3447 char *valenum = NULL;
3448 err = sync_agent_get_text_from_node(property_child, &valenum);
3449 if (err != SYNC_AGENT_PB_RETURN_OK) {
3451 if (pDevInfDataStore != NULL)
3452 free(pDevInfDataStore);
3454 if (pDevInfCtCap != NULL)
3457 if (devinf_content_type != NULL)
3458 free(devinf_content_type);
3460 if (pDevInfProperty != NULL)
3461 free(pDevInfProperty);
3465 _DEBUG_TRACE("ValEnum = [%s]", valenum);
3466 if (valenum != NULL)
3467 pDevInfProperty->val_enums = g_list_append(pDevInfProperty->val_enums, strdup(valenum));
3468 } else if (strcmp(property_child_xml_name, ELEMENT_DISPLAYNAME) == 0) {
3469 char *displayname = NULL;
3470 err = sync_agent_get_text_from_node(property_child, &displayname);
3471 if (err != SYNC_AGENT_PB_RETURN_OK) {
3473 if (pDevInfDataStore != NULL)
3474 free(pDevInfDataStore);
3476 if (pDevInfCtCap != NULL)
3479 if (devinf_content_type != NULL)
3480 free(devinf_content_type);
3482 if (pDevInfProperty != NULL)
3483 free(pDevInfProperty);
3487 _DEBUG_TRACE("DisplayName = [%s]", displayname);
3488 if (displayname != NULL)
3489 pDevInfProperty->display_name = strdup(displayname);
3490 } else if (strcmp(property_child_xml_name, ELEMENT_PROPPARAM) == 0) {
3492 devinf_prop_param_s *pDevInfPropParam = (devinf_prop_param_s *) calloc(1, sizeof(devinf_prop_param_s));
3493 if (pDevInfPropParam == NULL) {
3494 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
3495 _DEBUG_ERROR("pDevInfPropParam is null");
3497 if (pDevInfDataStore != NULL)
3498 free(pDevInfDataStore);
3500 if (pDevInfCtCap != NULL)
3503 if (devinf_content_type != NULL)
3504 free(devinf_content_type);
3506 if (pDevInfProperty != NULL)
3507 free(pDevInfProperty);
3512 WBXMLTreeNode *propparam_child = NULL;
3514 for (propparam_child = property_child->children; propparam_child != NULL; propparam_child = propparam_child->next) {
3515 if (propparam_child->type != WBXML_TREE_ELEMENT_NODE)
3518 const char *propparam_child_xml_name = NULL;
3519 propparam_child_xml_name = (const char *)wbxml_tag_get_xml_name(propparam_child->name);
3521 if (strcmp(propparam_child_xml_name, ELEMENT_PARAMNAME) == 0) {
3522 char *paramname = NULL;
3523 err = sync_agent_get_text_from_node(propparam_child, ¶mname);
3524 if (err != SYNC_AGENT_PB_RETURN_OK) {
3526 if (pDevInfDataStore != NULL)
3527 free(pDevInfDataStore);
3529 if (pDevInfCtCap != NULL)
3532 if (devinf_content_type != NULL)
3533 free(devinf_content_type);
3535 if (pDevInfProperty != NULL)
3536 free(pDevInfProperty);
3540 _DEBUG_TRACE("ParamName = [%s]", paramname);
3541 if (paramname != NULL)
3542 pDevInfPropParam->param_name = strdup(paramname);
3543 } else if (strcmp(propparam_child_xml_name, ELEMENT_DATATYPE) == 0) {
3544 char *datatype = NULL;
3545 err = sync_agent_get_text_from_node(propparam_child, &datatype);
3546 if (err != SYNC_AGENT_PB_RETURN_OK) {
3548 if (pDevInfDataStore != NULL)
3549 free(pDevInfDataStore);
3551 if (pDevInfCtCap != NULL)
3554 if (devinf_content_type != NULL)
3555 free(devinf_content_type);
3557 if (pDevInfProperty != NULL)
3558 free(pDevInfProperty);
3562 _DEBUG_TRACE("DataType = [%s]", datatype);
3563 if (datatype != NULL)
3564 pDevInfPropParam->data_type = strdup(datatype);
3565 } else if (strcmp(propparam_child_xml_name, ELEMENT_VALENUM) == 0) {
3566 char *valenum = NULL;
3567 err = sync_agent_get_text_from_node(propparam_child, &valenum);
3568 if (err != SYNC_AGENT_PB_RETURN_OK) {
3570 if (pDevInfDataStore != NULL)
3571 free(pDevInfDataStore);
3573 if (pDevInfCtCap != NULL)
3576 if (devinf_content_type != NULL)
3577 free(devinf_content_type);
3579 if (pDevInfProperty != NULL)
3580 free(pDevInfProperty);
3584 _DEBUG_TRACE("ValEnum = [%s]", valenum);
3585 if (valenum != NULL)
3586 pDevInfPropParam->val_enums = g_list_append(pDevInfPropParam->val_enums, strdup(valenum));
3587 } else if (strcmp(propparam_child_xml_name, ELEMENT_DISPLAYNAME) == 0) {
3588 char *displayname = NULL;
3589 err = sync_agent_get_text_from_node(propparam_child, &displayname);
3590 if (err != SYNC_AGENT_PB_RETURN_OK) {
3592 if (pDevInfDataStore != NULL)
3593 free(pDevInfDataStore);
3595 if (pDevInfCtCap != NULL)
3598 if (devinf_content_type != NULL)
3599 free(devinf_content_type);
3601 if (pDevInfProperty != NULL)
3602 free(pDevInfProperty);
3606 _DEBUG_TRACE("DisplayName = [%s]", displayname);
3607 if (displayname != NULL)
3608 pDevInfPropParam->display_name = strdup(displayname);
3612 pDevInfProperty->prop_params = g_list_append(pDevInfProperty->prop_params, pDevInfPropParam);
3616 pDevInfCtCap->properties = g_list_append(pDevInfCtCap->properties, pDevInfProperty);
3619 pDevInfCtCap->ct = devinf_content_type;
3620 pDevInfDataStore->ct_caps = g_list_append(pDevInfDataStore->ct_caps, pDevInfCtCap);
3621 } else if (strcmp(datastore_child_xml_name, ELEMENT_DSMEM) == 0) {
3624 } else if (strcmp(datastore_child_xml_name, ELEMENT_SUPPORTHIERARCHICALSYNC) == 0) {
3625 _DEBUG_TRACE("SupportHierarchicalSync");
3626 pDevInfDataStore->supports_hierarchical_sync = 1;
3627 } else if (strcmp(datastore_child_xml_name, ELEMENT_SYNCCAP) == 0) {
3629 WBXMLTreeNode *synccap_child = NULL;
3631 for (synccap_child = datastore_child->children; synccap_child != NULL; synccap_child = synccap_child->next) {
3632 if (synccap_child->type != WBXML_TREE_ELEMENT_NODE)
3635 const char *synccap_child_xml_name = NULL;
3636 synccap_child_xml_name = (const char *)wbxml_tag_get_xml_name(synccap_child->name);
3638 if (strcmp(synccap_child_xml_name, ELEMENT_SYNCTYPE) == 0) {
3639 char *synctype_str = NULL;
3640 unsigned int synctype = 0;
3641 err = sync_agent_get_text_from_node(synccap_child, &synctype_str);
3642 if (err != SYNC_AGENT_PB_RETURN_OK) {
3644 if (pDevInfDataStore != NULL)
3645 free(pDevInfDataStore);
3649 _DEBUG_TRACE("SyncType = [%s]", synctype_str);
3650 if (synctype_str != NULL) {
3651 synctype = atoi(synctype_str);
3652 synctype = 1 << (synctype - 1);
3654 /*DevInfSyncCap synccap = convert_devinf_synccap(synctype); */
3655 set_devinf_datastore_sync_cap(pDevInfDataStore, synctype, 1);
3658 } else if (strcmp(datastore_child_xml_name, ELEMENT_FILTER_RX) == 0) {
3660 } else if (strcmp(datastore_child_xml_name, ELEMENT_FILTERCAP) == 0) {
3664 pDevInf->datastores = g_list_append(pDevInf->datastores, pDevInfDataStore);
3669 if (err == SYNC_AGENT_PB_RETURN_OK) {
3672 _DEBUG_ERROR("error");
3673 free_devinf(pDevInf);
3680 static sync_agent_pb_error_e _oma_ds_binder_header_reverse_converter_function(sync_agent_pb_protocol_binder_reverse_info_s * reverse_binder, WBXMLTreeNode * wbxml_dom_node, Content_Ptr * content)
3684 retvm_if(wbxml_dom_node == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "wbxml_dom_node is NULL");
3686 sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
3688 /* get data from dom tree */
3689 sync_hdr_s *pSyncHdr = (sync_hdr_s *) calloc(1, sizeof(sync_hdr_s));
3690 if (pSyncHdr == NULL) {
3691 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
3692 _DEBUG_ERROR("pSyncHdr is null");
3696 WBXMLTreeNode *child = NULL;
3698 for (child = wbxml_dom_node->children; child != NULL; child = child->next) {
3699 if (child->type != WBXML_TREE_ELEMENT_NODE)
3702 const char *child_xml_name = NULL;
3703 child_xml_name = (const char *)wbxml_tag_get_xml_name(child->name);
3705 if (strcmp(child_xml_name, ELEMENT_VERDTD) == 0) {
3706 char *verdtd = NULL;
3707 err = sync_agent_get_text_from_node(child, &verdtd);
3708 if (err != SYNC_AGENT_PB_RETURN_OK) {
3711 _DEBUG_TRACE("VerDTD = [%s]", verdtd);
3713 pSyncHdr->version = __get_oma_ds_protocol_version(verdtd);
3714 } else if (strcmp(child_xml_name, ELEMENT_SESSIONID) == 0) {
3715 char *sessionID = NULL;
3716 err = sync_agent_get_text_from_node(child, &sessionID);
3717 if (err != SYNC_AGENT_PB_RETURN_OK) {
3720 _DEBUG_TRACE("SessionID = [%s]", sessionID);
3722 if (sessionID != NULL)
3723 pSyncHdr->session_id = strdup(sessionID);
3725 pSyncHdr->session_id = NULL;
3726 } else if (strcmp(child_xml_name, ELEMENT_MSGID) == 0) {
3728 err = sync_agent_get_text_from_node(child, &msgID);
3729 if (err != SYNC_AGENT_PB_RETURN_OK) {
3732 _DEBUG_TRACE("MsgID = [%s]", msgID);
3734 pSyncHdr->message_id = atoi(msgID);
3735 } else if (strcmp(child_xml_name, ELEMENT_TARGET) == 0) {
3736 location_s *pTargetLocation = _get_location(child);
3737 if (pTargetLocation == NULL) {
3738 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
3741 pSyncHdr->target = pTargetLocation;
3742 } else if (strcmp(child_xml_name, ELEMENT_SOURCE) == 0) {
3743 location_s *pSourceLocation = _get_location(child);
3744 if (pSourceLocation == NULL) {
3745 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
3748 pSyncHdr->source = pSourceLocation;
3749 } else if (strcmp(child_xml_name, ELEMENT_RESPURI) == 0) {
3750 char *resp_uri = NULL;
3751 err = sync_agent_get_text_from_node(child, &resp_uri);
3752 if (err != SYNC_AGENT_PB_RETURN_OK) {
3755 _DEBUG_TRACE("resp_uri = [%s]", resp_uri);
3756 if (resp_uri != NULL)
3757 pSyncHdr->response_uri = strdup(resp_uri);
3758 } else if (strcmp(child_xml_name, ELEMENT_NORESP) == 0) {
3759 _DEBUG_TRACE("noResp\n");
3760 pSyncHdr->no_response = 1;
3761 } else if (strcmp(child_xml_name, ELEMENT_CRED) == 0) {
3762 _DEBUG_TRACE("Cred\n");
3763 cred_s *cred = NULL;
3764 cred = __get_cred(child);
3766 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
3769 pSyncHdr->cred = cred;
3770 } else if (strcmp(child_xml_name, ELEMENT_META) == 0) {
3776 if (err == SYNC_AGENT_PB_RETURN_OK) {
3777 *content = pSyncHdr;
3779 _DEBUG_ERROR("error");
3780 free_sync_hdr(pSyncHdr);
3787 static sync_agent_pb_error_e _oma_ds_binder_results_command_reverse_converter_function(sync_agent_pb_protocol_binder_reverse_info_s * reverse_binder, WBXMLTreeNode * wbxml_dom_node, Content_Ptr * content)
3791 retvm_if(wbxml_dom_node == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "wbxml_dom_node is NULL");
3792 retvm_if(reverse_binder == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "reverse_binder is NULL");
3794 sync_hdr_s *pSyncHdr = (sync_hdr_s *) sync_agent_get_user_data_from_reverse_protocol_binder(reverse_binder);
3795 retvm_if(pSyncHdr == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "pSyncHdr is NULL");
3797 sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
3799 /* get data from dom tree */
3800 command_s *pResults = (command_s *) calloc(1, sizeof(command_s));
3801 if (pResults == NULL) {
3802 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
3803 _DEBUG_ERROR("pResults is null");
3807 pResults->type = COMMAND_TYPE_RESULTS;
3808 pResults->msg_id = pSyncHdr->message_id;
3809 pResults->ref_count = 1;
3811 WBXMLTreeNode *child = NULL;
3813 for (child = wbxml_dom_node->children; child != NULL; child = child->next) {
3814 if (child->type != WBXML_TREE_ELEMENT_NODE)
3817 const char *child_xml_name = NULL;
3818 child_xml_name = (const char *)wbxml_tag_get_xml_name(child->name);
3820 if (strcmp(child_xml_name, ELEMENT_CMDID) == 0) {
3821 char *cmd_id = NULL;
3822 err = sync_agent_get_text_from_node(child, &cmd_id);
3823 if (err != SYNC_AGENT_PB_RETURN_OK) {
3826 _DEBUG_TRACE("CmdID = [%s]", cmd_id);
3828 pResults->cmd_id = atoi(cmd_id);
3829 } else if (strcmp(child_xml_name, ELEMENT_MSGREF) == 0) {
3830 char *msg_ref = NULL;
3831 err = sync_agent_get_text_from_node(child, &msg_ref);
3832 if (err != SYNC_AGENT_PB_RETURN_OK) {
3835 _DEBUG_TRACE("MsgRef = [%s]", msg_ref);
3836 if (msg_ref != NULL)
3837 pResults->private.results.msg_ref = atoi(msg_ref);
3838 } else if (strcmp(child_xml_name, ELEMENT_CMDREF) == 0) {
3839 char *cmd_ref = NULL;
3840 err = sync_agent_get_text_from_node(child, &cmd_ref);
3841 if (err != SYNC_AGENT_PB_RETURN_OK) {
3844 _DEBUG_TRACE("MsgRef = [%s]", cmd_ref);
3845 if (cmd_ref != NULL)
3846 pResults->private.results.cmd_ref = atoi(cmd_ref);
3847 } else if (strcmp(child_xml_name, ELEMENT_META) == 0) {
3849 WBXMLTreeNode *grandchild = NULL;
3851 for (grandchild = child->children; grandchild != NULL; grandchild = grandchild->next) {
3852 if (grandchild->type != WBXML_TREE_ELEMENT_NODE)
3855 const char *grandchild_xml_name = NULL;
3856 grandchild_xml_name = (const char *)wbxml_tag_get_xml_name(grandchild->name);
3858 if (strcmp(grandchild_xml_name, ELEMENT_TYPE) == 0) {
3859 char *contentType = NULL;
3860 err = sync_agent_get_text_from_node(grandchild, &contentType);
3861 if (err != SYNC_AGENT_PB_RETURN_OK) {
3864 _DEBUG_TRACE("Content Type = [%s]", contentType);
3865 if (contentType != NULL)
3866 pResults->private.results.type = strdup(contentType);
3869 } else if (strcmp(child_xml_name, ELEMENT_TARGETREF) == 0) {
3871 } else if (strcmp(child_xml_name, ELEMENT_SOURCEREF) == 0) {
3873 } else if (strcmp(child_xml_name, ELEMENT_ITEM) == 0) {
3874 /*create item in results command */
3875 item_s *item = create_item();
3877 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
3880 pResults->private.results.item = item;
3882 WBXMLTreeNode *grandchild = NULL;
3884 for (grandchild = child->children; grandchild != NULL; grandchild = grandchild->next) {
3885 if (grandchild->type != WBXML_TREE_ELEMENT_NODE)
3888 const char *grandchild_xml_name = NULL;
3889 grandchild_xml_name = (const char *)wbxml_tag_get_xml_name(grandchild->name);
3891 if (strcmp(grandchild_xml_name, ELEMENT_SOURCE) == 0) {
3892 location_s *pSourceLocation = _get_location(grandchild);
3893 if (pSourceLocation == NULL) {
3894 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
3897 pResults->private.results.item->source = pSourceLocation;
3898 } else if (strcmp(grandchild_xml_name, ELEMENT_TARGET) == 0) {
3899 location_s *pTargetLocation = _get_location(grandchild);
3900 if (pTargetLocation == NULL) {
3901 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
3904 pResults->private.results.item->target = pTargetLocation;
3905 } else if (strcmp(grandchild_xml_name, ELEMENT_DATA) == 0) {
3912 if (err == SYNC_AGENT_PB_RETURN_OK) {
3913 *content = pResults;
3915 _DEBUG_ERROR("error");
3916 free_command(pResults);
3923 static sync_agent_pb_error_e _oma_ds_binder_put_command_reverse_converter_function(sync_agent_pb_protocol_binder_reverse_info_s * reverse_binder, WBXMLTreeNode * wbxml_dom_node, Content_Ptr * content)
3927 retvm_if(wbxml_dom_node == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "wbxml_dom_node is NULL");
3928 retvm_if(reverse_binder == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "reverse_binder is NULL");
3930 sync_hdr_s *pSyncHdr = (sync_hdr_s *) sync_agent_get_user_data_from_reverse_protocol_binder(reverse_binder);
3931 retvm_if(pSyncHdr == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "pSyncHdr is NULL");
3933 sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
3935 /* get data from dom tree */
3936 command_s *pPut = (command_s *) calloc(1, sizeof(command_s));
3938 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
3939 _DEBUG_ERROR("pPut is null");
3943 pPut->type = COMMAND_TYPE_PUT;
3944 pPut->msg_id = pSyncHdr->message_id;
3945 pPut->ref_count = 1;
3947 WBXMLTreeNode *child = NULL;
3949 for (child = wbxml_dom_node->children; child != NULL; child = child->next) {
3950 if (child->type != WBXML_TREE_ELEMENT_NODE)
3953 const char *child_xml_name = NULL;
3954 child_xml_name = (const char *)wbxml_tag_get_xml_name(child->name);
3956 if (strcmp(child_xml_name, ELEMENT_CMDID) == 0) {
3957 char *cmd_id = NULL;
3958 err = sync_agent_get_text_from_node(child, &cmd_id);
3959 if (err != SYNC_AGENT_PB_RETURN_OK) {
3962 _DEBUG_TRACE("CmdID = [%s]", cmd_id);
3964 pPut->cmd_id = atoi(cmd_id);
3965 } else if (strcmp(child_xml_name, ELEMENT_NORESP) == 0) {
3966 _DEBUG_TRACE("NoResp");
3968 } else if (strcmp(child_xml_name, ELEMENT_CRED) == 0) {
3969 _DEBUG_TRACE("Cred\n");
3970 cred_s *cred = NULL;
3971 cred = __get_cred(child);
3973 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
3977 } else if (strcmp(child_xml_name, ELEMENT_META) == 0) {
3978 WBXMLTreeNode *grandchild = NULL;
3980 for (grandchild = child->children; grandchild != NULL; grandchild = grandchild->next) {
3981 if (grandchild->type != WBXML_TREE_ELEMENT_NODE)
3984 const char *grandchild_xml_name = NULL;
3985 grandchild_xml_name = (const char *)wbxml_tag_get_xml_name(grandchild->name);
3987 if (strcmp(grandchild_xml_name, ELEMENT_TYPE) == 0) {
3988 char *contentType = NULL;
3989 err = sync_agent_get_text_from_node(grandchild, &contentType);
3990 if (err != SYNC_AGENT_PB_RETURN_OK) {
3993 _DEBUG_TRACE("Content Type = [%s]", contentType);
3994 if (contentType != NULL)
3995 pPut->private.access.type = strdup(contentType);
3998 } else if (strcmp(child_xml_name, ELEMENT_ITEM) == 0) {
3999 /*create item in put command */
4000 item_s *item = create_item();
4002 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
4005 pPut->private.access.item = item;
4007 WBXMLTreeNode *grandchild = NULL;
4009 for (grandchild = child->children; grandchild != NULL; grandchild = grandchild->next) {
4010 if (grandchild->type != WBXML_TREE_ELEMENT_NODE)
4013 const char *grandchild_xml_name = NULL;
4014 grandchild_xml_name = (const char *)wbxml_tag_get_xml_name(grandchild->name);
4016 if (strcmp(grandchild_xml_name, ELEMENT_SOURCE) == 0) {
4017 location_s *pSourceLocation = _get_location(grandchild);
4018 if (pSourceLocation == NULL) {
4019 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
4022 pPut->private.access.item->source = pSourceLocation;
4023 } else if (strcmp(grandchild_xml_name, ELEMENT_TARGET) == 0) {
4024 location_s *pTargetLocation = _get_location(grandchild);
4025 if (pTargetLocation == NULL) {
4026 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
4029 pPut->private.access.item->target = pTargetLocation;
4030 } else if (strcmp(grandchild_xml_name, ELEMENT_DATA) == 0) {
4038 if (err == SYNC_AGENT_PB_RETURN_OK) {
4041 _DEBUG_ERROR("error");
4049 static sync_agent_pb_error_e _oma_ds_binder_get_command_reverse_converter_function(sync_agent_pb_protocol_binder_reverse_info_s * reverse_binder, WBXMLTreeNode * wbxml_dom_node, Content_Ptr * content)
4053 retvm_if(wbxml_dom_node == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "wbxml_dom_node is NULL");
4054 retvm_if(reverse_binder == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "reverse_binder is NULL");
4056 sync_hdr_s *pSyncHdr = (sync_hdr_s *) sync_agent_get_user_data_from_reverse_protocol_binder(reverse_binder);
4057 retvm_if(pSyncHdr == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "pSyncHdr is NULL");
4059 sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
4061 /* get data from dom tree */
4062 command_s *pGet = (command_s *) calloc(1, sizeof(command_s));
4064 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
4065 _DEBUG_ERROR("pGet is null");
4069 pGet->type = COMMAND_TYPE_GET;
4070 pGet->msg_id = pSyncHdr->message_id;
4071 pGet->ref_count = 1;
4073 WBXMLTreeNode *child = NULL;
4075 for (child = wbxml_dom_node->children; child != NULL; child = child->next) {
4076 if (child->type != WBXML_TREE_ELEMENT_NODE)
4079 const char *child_xml_name = NULL;
4080 child_xml_name = (const char *)wbxml_tag_get_xml_name(child->name);
4082 if (strcmp(child_xml_name, ELEMENT_CMDID) == 0) {
4083 char *cmd_id = NULL;
4084 err = sync_agent_get_text_from_node(child, &cmd_id);
4085 if (err != SYNC_AGENT_PB_RETURN_OK) {
4088 _DEBUG_TRACE("CmdID = [%s]", cmd_id);
4090 pGet->cmd_id = atoi(cmd_id);
4091 } else if (strcmp(child_xml_name, ELEMENT_NORESP) == 0) {
4092 _DEBUG_TRACE("NoResp");
4094 } else if (strcmp(child_xml_name, ELEMENT_CRED) == 0) {
4095 _DEBUG_TRACE("Cred\n");
4096 cred_s *cred = NULL;
4097 cred = __get_cred(child);
4099 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
4103 } else if (strcmp(child_xml_name, ELEMENT_META) == 0) {
4105 WBXMLTreeNode *grandchild = NULL;
4107 for (grandchild = child->children; grandchild != NULL; grandchild = grandchild->next) {
4108 if (grandchild->type != WBXML_TREE_ELEMENT_NODE)
4111 const char *grandchild_xml_name = NULL;
4112 grandchild_xml_name = (const char *)wbxml_tag_get_xml_name(grandchild->name);
4114 if (strcmp(grandchild_xml_name, ELEMENT_TYPE) == 0) {
4115 char *contentType = NULL;
4116 err = sync_agent_get_text_from_node(grandchild, &contentType);
4117 if (err != SYNC_AGENT_PB_RETURN_OK) {
4120 _DEBUG_TRACE("Content Type = [%s]", contentType);
4121 if (contentType != NULL)
4122 pGet->private.access.type = strdup(contentType);
4125 } else if (strcmp(child_xml_name, ELEMENT_ITEM) == 0) {
4126 /*create item in put command */
4127 item_s *item = create_item();
4129 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
4132 pGet->private.access.item = item;
4134 WBXMLTreeNode *grandchild = NULL;
4135 for (grandchild = child->children; grandchild != NULL; grandchild = grandchild->next) {
4136 if (grandchild->type != WBXML_TREE_ELEMENT_NODE)
4139 const char *grandchild_xml_name = NULL;
4140 grandchild_xml_name = (const char *)wbxml_tag_get_xml_name(grandchild->name);
4142 if (strcmp(grandchild_xml_name, ELEMENT_SOURCE) == 0) {
4143 location_s *pSourceLocation = _get_location(grandchild);
4144 if (pSourceLocation == NULL) {
4145 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
4148 pGet->private.access.item->source = pSourceLocation;
4149 } else if (strcmp(grandchild_xml_name, ELEMENT_TARGET) == 0) {
4150 location_s *pTargetLocation = _get_location(grandchild);
4151 if (pTargetLocation == NULL) {
4152 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
4155 pGet->private.access.item->target = pTargetLocation;
4156 } else if (strcmp(grandchild_xml_name, ELEMENT_DATA) == 0) {
4164 if (err == SYNC_AGENT_PB_RETURN_OK) {
4167 _DEBUG_ERROR("error");
4175 static sync_agent_pb_error_e _oma_ds_binder_alert_command_reverse_converter_function(sync_agent_pb_protocol_binder_reverse_info_s * reverse_binder, WBXMLTreeNode * wbxml_dom_node, Content_Ptr * content)
4179 retvm_if(wbxml_dom_node == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "wbxml_dom_node is NULL");
4180 retvm_if(reverse_binder == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "reverse_binder is NULL");
4182 sync_hdr_s *pSyncHdr = (sync_hdr_s *) sync_agent_get_user_data_from_reverse_protocol_binder(reverse_binder);
4183 retvm_if(pSyncHdr == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "pSyncHdr is NULL");
4185 sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
4187 /* get data from dom tree */
4188 command_s *pAlert = (command_s *) calloc(1, sizeof(command_s));
4189 if (pAlert == NULL) {
4190 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
4191 _DEBUG_ERROR("pAlert is null");
4195 pAlert->type = COMMAND_TYPE_ALERT;
4196 pAlert->msg_id = pSyncHdr->message_id;
4197 pAlert->ref_count = 1;
4199 WBXMLTreeNode *child = NULL;
4201 for (child = wbxml_dom_node->children; child != NULL; child = child->next) {
4202 if (child->type != WBXML_TREE_ELEMENT_NODE)
4205 const char *child_xml_name = NULL;
4206 child_xml_name = (const char *)wbxml_tag_get_xml_name(child->name);
4208 if (strcmp(child_xml_name, ELEMENT_CMDID) == 0) {
4209 char *cmd_id = NULL;
4210 err = sync_agent_get_text_from_node(child, &cmd_id);
4211 if (err != SYNC_AGENT_PB_RETURN_OK) {
4214 _DEBUG_TRACE("CmdID = [%s]", cmd_id);
4216 pAlert->cmd_id = atoi(cmd_id);
4217 } else if (strcmp(child_xml_name, ELEMENT_NORESP) == 0) {
4218 _DEBUG_TRACE("NoResp");
4219 pAlert->no_resp = 1;
4220 } else if (strcmp(child_xml_name, ELEMENT_CRED) == 0) {
4221 _DEBUG_TRACE("Cred\n");
4222 cred_s *cred = NULL;
4223 cred = __get_cred(child);
4225 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
4228 pAlert->cred = cred;
4229 } else if (strcmp(child_xml_name, ELEMENT_DATA) == 0) {
4231 err = sync_agent_get_text_from_node(child, &data);
4232 if (err != SYNC_AGENT_PB_RETURN_OK) {
4235 _DEBUG_TRACE("Data = [%s]", data);
4237 pAlert->private.alert.type = atoi(data);
4238 } else if (strcmp(child_xml_name, ELEMENT_ITEM) == 0) {
4239 WBXMLTreeNode *grandchild = NULL;
4241 for (grandchild = child->children; grandchild != NULL; grandchild = grandchild->next) {
4242 if (grandchild->type != WBXML_TREE_ELEMENT_NODE)
4245 const char *grandchild_xml_name = NULL;
4246 grandchild_xml_name = (const char *)wbxml_tag_get_xml_name(grandchild->name);
4248 if (strcmp(grandchild_xml_name, ELEMENT_SOURCE) == 0) {
4249 location_s *pSourceLocation = _get_location(grandchild);
4250 if (pSourceLocation == NULL) {
4251 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
4254 pAlert->source = pSourceLocation;
4255 } else if (strcmp(grandchild_xml_name, ELEMENT_TARGET) == 0) {
4256 location_s *pTargetLocation = _get_location(grandchild);
4257 if (pTargetLocation == NULL) {
4258 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
4261 pAlert->target = pTargetLocation;
4262 } else if (strcmp(grandchild_xml_name, ELEMENT_META) == 0) {
4264 WBXMLTreeNode *grandgrandchild = NULL;
4265 for (grandgrandchild = grandchild->children; grandgrandchild != NULL; grandgrandchild = grandgrandchild->next) {
4266 if (grandgrandchild->type != WBXML_TREE_ELEMENT_NODE)
4269 const char *grandgrandchild_xml_name = NULL;
4270 grandgrandchild_xml_name = (const char *)wbxml_tag_get_xml_name(grandgrandchild->name);
4272 if (strcmp(grandgrandchild_xml_name, ELEMENT_ANCHOR) == 0) {
4273 anchor_s *anchor = _get_anchor(grandgrandchild);
4274 if (anchor == NULL) {
4275 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
4278 pAlert->private.alert.anchor = anchor;
4279 } else if (strcmp(grandgrandchild_xml_name, ELEMENT_MAXOBJSIZE) == 0) {
4280 char *maxObjSize = NULL;
4281 err = sync_agent_get_text_from_node(grandgrandchild, &maxObjSize);
4282 if (err != SYNC_AGENT_PB_RETURN_OK) {
4285 _DEBUG_TRACE("MaxObjSize = [%s]", maxObjSize);
4286 if (maxObjSize != NULL)
4287 pAlert->private.alert.max_obj_size = atoi(maxObjSize);
4296 if (err == SYNC_AGENT_PB_RETURN_OK) {
4299 _DEBUG_ERROR("error");
4300 free_command(pAlert);
4307 static sync_agent_pb_error_e _oma_ds_binder_sync_end_command_reverse_converter_function(sync_agent_pb_protocol_binder_reverse_info_s * reverse_binder, WBXMLTreeNode * wbxml_dom_node, Content_Ptr * content)
4311 retvm_if(reverse_binder == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "reverse_binder is NULL");
4313 sync_hdr_s *pSyncHdr = (sync_hdr_s *) sync_agent_get_user_data_from_reverse_protocol_binder(reverse_binder);
4314 retvm_if(pSyncHdr == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "pSyncHdr is NULL");
4316 sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
4318 /* get data from dom tree */
4319 command_s *pSyncEnd = (command_s *) calloc(1, sizeof(command_s));
4320 if (pSyncEnd == NULL) {
4321 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
4322 _DEBUG_ERROR("pSyncEnd is null");
4326 pSyncEnd->type = COMMAND_TYPE_SYNC_END;;
4327 pSyncEnd->msg_id = pSyncHdr->message_id;
4328 pSyncEnd->ref_count = 1;
4331 if (err == SYNC_AGENT_PB_RETURN_OK) {
4332 *content = pSyncEnd;
4334 _DEBUG_ERROR("error");
4335 free_command(pSyncEnd);
4342 static sync_agent_pb_error_e _oma_ds_binder_sync_start_command_reverse_converter_function(sync_agent_pb_protocol_binder_reverse_info_s * reverse_binder, WBXMLTreeNode * wbxml_dom_node, Content_Ptr * content)
4346 retvm_if(wbxml_dom_node == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "wbxml_dom_node is NULL");
4347 retvm_if(reverse_binder == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "reverse_binder is NULL");
4349 sync_hdr_s *pSyncHdr = (sync_hdr_s *) sync_agent_get_user_data_from_reverse_protocol_binder(reverse_binder);
4350 retvm_if(pSyncHdr == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "pSyncHdr is NULL");
4352 sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
4354 /* get data from dom tree */
4355 command_s *pSync = (command_s *) calloc(1, sizeof(command_s));
4356 if (pSync == NULL) {
4357 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
4358 _DEBUG_ERROR("pSync is null");
4362 pSync->type = COMMAND_TYPE_SYNC_START;;
4363 pSync->msg_id = pSyncHdr->message_id;
4364 pSync->ref_count = 1;
4366 WBXMLTreeNode *child = NULL;
4368 for (child = wbxml_dom_node->children; child != NULL; child = child->next) {
4369 if (child->type != WBXML_TREE_ELEMENT_NODE)
4372 const char *child_xml_name = NULL;
4373 child_xml_name = (const char *)wbxml_tag_get_xml_name(child->name);
4375 if (strcmp(child_xml_name, ELEMENT_CMDID) == 0) {
4376 char *cmd_id = NULL;
4377 err = sync_agent_get_text_from_node(child, &cmd_id);
4378 if (err != SYNC_AGENT_PB_RETURN_OK) {
4381 _DEBUG_TRACE("CmdID = [%s]", cmd_id);
4383 pSync->cmd_id = atoi(cmd_id);
4384 } else if (strcmp(child_xml_name, ELEMENT_NORESP) == 0) {
4385 _DEBUG_TRACE("NoResp");
4387 } else if (strcmp(child_xml_name, ELEMENT_CRED) == 0) {
4388 _DEBUG_TRACE("Cred\n");
4389 cred_s *cred = NULL;
4390 cred = __get_cred(child);
4392 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
4396 } else if (strcmp(child_xml_name, ELEMENT_TARGET) == 0) {
4397 location_s *pTargetLocation = _get_location(child);
4398 if (pTargetLocation == NULL) {
4399 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
4402 pSync->target = pTargetLocation;
4403 } else if (strcmp(child_xml_name, ELEMENT_SOURCE) == 0) {
4404 location_s *pSourceLocation = _get_location(child);
4405 if (pSourceLocation == NULL) {
4406 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
4409 pSync->source = pSourceLocation;
4410 } else if (strcmp(child_xml_name, ELEMENT_META) == 0) {
4412 } else if (strcmp(child_xml_name, ELEMENT_NUMBEROFCHANGES) == 0) {
4413 char *numOfChanges = NULL;
4414 err = sync_agent_get_text_from_node(child, &numOfChanges);
4415 if (err != SYNC_AGENT_PB_RETURN_OK) {
4418 _DEBUG_TRACE("NumberOfChanges = [%s]", numOfChanges);
4420 pSync->private.sync.has_num_changed = 1;
4421 if (numOfChanges != NULL)
4422 pSync->private.sync.num_changed = atoi(numOfChanges);
4427 if (err == SYNC_AGENT_PB_RETURN_OK) {
4430 _DEBUG_ERROR("error");
4431 free_command(pSync);
4438 static sync_agent_pb_error_e _oma_ds_binder_add_command_reverse_converter_function(sync_agent_pb_protocol_binder_reverse_info_s * reverse_binder, WBXMLTreeNode * wbxml_dom_node, Content_Ptr * content)
4442 retvm_if(wbxml_dom_node == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "wbxml_dom_node is NULL");
4443 retvm_if(reverse_binder == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "reverse_binder is NULL");
4445 sync_hdr_s *pSyncHdr = (sync_hdr_s *) sync_agent_get_user_data_from_reverse_protocol_binder(reverse_binder);
4446 retvm_if(pSyncHdr == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "pSyncHdr is NULL");
4448 sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
4450 item_s *item = NULL;
4452 /* get data from dom tree */
4453 command_s *pAdd = (command_s *) calloc(1, sizeof(command_s));
4455 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
4456 _DEBUG_ERROR("pAdd is null");
4460 pAdd->type = COMMAND_TYPE_ADD;;
4461 pAdd->msg_id = pSyncHdr->message_id;
4462 pAdd->private.change.type = CHANGE_ADD;
4463 pAdd->ref_count = 1;
4465 WBXMLTreeNode *child = NULL;
4467 for (child = wbxml_dom_node->children; child != NULL; child = child->next) {
4468 if (child->type != WBXML_TREE_ELEMENT_NODE)
4471 const char *child_xml_name = NULL;
4472 child_xml_name = (const char *)wbxml_tag_get_xml_name(child->name);
4474 if (strcmp(child_xml_name, ELEMENT_CMDID) == 0) {
4475 char *cmd_id = NULL;
4476 err = sync_agent_get_text_from_node(child, &cmd_id);
4477 if (err != SYNC_AGENT_PB_RETURN_OK) {
4480 _DEBUG_TRACE("CmdID = [%s]", cmd_id);
4482 pAdd->cmd_id = atoi(cmd_id);
4483 } else if (strcmp(child_xml_name, ELEMENT_NORESP) == 0) {
4484 _DEBUG_TRACE("NoResp");
4486 } else if (strcmp(child_xml_name, ELEMENT_CRED) == 0) {
4487 _DEBUG_TRACE("Cred\n");
4488 cred_s *cred = NULL;
4489 cred = __get_cred(child);
4491 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
4495 } else if (strcmp(child_xml_name, ELEMENT_META) == 0) {
4496 WBXMLTreeNode *grandchild = NULL;
4499 item = create_item();
4501 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
4506 for (grandchild = child->children; grandchild != NULL; grandchild = grandchild->next) {
4507 if (grandchild->type != WBXML_TREE_ELEMENT_NODE)
4510 const char *grandchild_xml_name = NULL;
4511 grandchild_xml_name = (const char *)wbxml_tag_get_xml_name(grandchild->name);
4513 if (strcmp(grandchild_xml_name, ELEMENT_TYPE) == 0) {
4514 char *contentType = NULL;
4515 err = sync_agent_get_text_from_node(grandchild, &contentType);
4516 if (err != SYNC_AGENT_PB_RETURN_OK) {
4519 _DEBUG_TRACE("Content Type = [%s]", contentType);
4520 if (contentType != NULL)
4521 item->content_type = strdup(contentType);
4522 } else if (strcmp(grandchild_xml_name, ELEMENT_SIZE) == 0) {
4524 err = sync_agent_get_text_from_node(grandchild, &size);
4525 if (err != SYNC_AGENT_PB_RETURN_OK) {
4528 _DEBUG_TRACE("Size = [%s]", size);
4530 item->size = atoi(size);
4533 } else if (strcmp(child_xml_name, ELEMENT_ITEM) == 0) {
4536 item = create_item();
4538 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
4543 WBXMLTreeNode *grandchild = NULL;
4544 for (grandchild = child->children; grandchild != NULL; grandchild = grandchild->next) {
4545 if (grandchild->type != WBXML_TREE_ELEMENT_NODE)
4548 const char *grandchild_xml_name = NULL;
4549 grandchild_xml_name = (const char *)wbxml_tag_get_xml_name(grandchild->name);
4551 if (strcmp(grandchild_xml_name, ELEMENT_SOURCE) == 0) {
4552 location_s *pSourceLocation = _get_location(grandchild);
4553 if (pSourceLocation == NULL) {
4554 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
4557 item->source = pSourceLocation;
4558 } else if (strcmp(grandchild_xml_name, ELEMENT_TARGET) == 0) {
4559 location_s *pTargetLocation = _get_location(grandchild);
4560 if (pTargetLocation == NULL) {
4561 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
4564 item->target = pTargetLocation;
4565 } else if (strcmp(grandchild_xml_name, ELEMENT_META) == 0) {
4566 WBXMLTreeNode *grandgrandchild = NULL;
4568 for (grandgrandchild = grandchild->children; grandgrandchild != NULL; grandgrandchild = grandgrandchild->next) {
4569 if (grandgrandchild->type != WBXML_TREE_ELEMENT_NODE)
4572 const char *grandgrandchild_xml_name = NULL;
4573 grandgrandchild_xml_name = (const char *)wbxml_tag_get_xml_name(grandgrandchild->name);
4575 if (strcmp(grandgrandchild_xml_name, ELEMENT_TYPE) == 0) {
4576 char *contentType = NULL;
4577 err = sync_agent_get_text_from_node(grandgrandchild, &contentType);
4578 if (err != SYNC_AGENT_PB_RETURN_OK) {
4581 _DEBUG_TRACE("Content Type = [%s]", contentType);
4582 if (contentType != NULL)
4583 item->content_type = strdup(contentType);
4584 } else if (strcmp(grandgrandchild_xml_name, ELEMENT_SIZE) == 0) {
4586 err = sync_agent_get_text_from_node(grandgrandchild, &size);
4587 if (err != SYNC_AGENT_PB_RETURN_OK) {
4590 _DEBUG_TRACE("Size = [%s]", size);
4592 item->size = atoi(size);
4595 } else if (strcmp(grandchild_xml_name, ELEMENT_DATA) == 0) {
4597 err = sync_agent_get_text_from_cdata_node(grandchild, &data);
4598 if (err != SYNC_AGENT_PB_RETURN_OK) {
4601 _DEBUG_TRACE("Data = [%s]", data);
4603 item->private.data = strdup(data);
4604 item->data_type = ITEM_DATA;
4605 } else if (strcmp(grandchild_xml_name, ELEMENT_MOREDATA) == 0) {
4606 _DEBUG_TRACE("MoreData");
4607 item->more_data = 1;
4610 pAdd->private.change.items = g_list_append(pAdd->private.change.items, item);
4620 if (err == SYNC_AGENT_PB_RETURN_OK) {
4623 _DEBUG_ERROR("error");
4631 static sync_agent_pb_error_e _oma_ds_binder_replace_command_reverse_converter_function(sync_agent_pb_protocol_binder_reverse_info_s * reverse_binder, WBXMLTreeNode * wbxml_dom_node, Content_Ptr * content)
4635 retvm_if(wbxml_dom_node == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "wbxml_dom_node is NULL");
4636 retvm_if(reverse_binder == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "reverse_binder is NULL");
4638 sync_hdr_s *pSyncHdr = (sync_hdr_s *) sync_agent_get_user_data_from_reverse_protocol_binder(reverse_binder);
4639 retvm_if(pSyncHdr == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "pSyncHdr is NULL");
4641 sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
4642 item_s *item = NULL;
4644 /* get data from dom tree */
4645 command_s *pReplace = (command_s *) calloc(1, sizeof(command_s));
4646 if (pReplace == NULL) {
4647 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
4648 _DEBUG_ERROR("pReplace is null");
4652 pReplace->type = COMMAND_TYPE_REPLACE;;
4653 pReplace->msg_id = pSyncHdr->message_id;
4654 pReplace->private.change.type = CHANGE_REPLACE;
4655 pReplace->ref_count = 1;
4657 WBXMLTreeNode *child = NULL;
4659 for (child = wbxml_dom_node->children; child != NULL; child = child->next) {
4660 if (child->type != WBXML_TREE_ELEMENT_NODE)
4663 const char *child_xml_name = NULL;
4664 child_xml_name = (const char *)wbxml_tag_get_xml_name(child->name);
4666 if (strcmp(child_xml_name, ELEMENT_CMDID) == 0) {
4667 char *cmd_id = NULL;
4668 err = sync_agent_get_text_from_node(child, &cmd_id);
4669 if (err != SYNC_AGENT_PB_RETURN_OK) {
4672 _DEBUG_TRACE("CmdID = [%s]", cmd_id);
4674 pReplace->cmd_id = atoi(cmd_id);
4676 } else if (strcmp(child_xml_name, ELEMENT_NORESP) == 0) {
4677 _DEBUG_TRACE("NoResp");
4678 pReplace->no_resp = 1;
4679 } else if (strcmp(child_xml_name, ELEMENT_CRED) == 0) {
4680 _DEBUG_TRACE("Cred\n");
4681 cred_s *cred = NULL;
4682 cred = __get_cred(child);
4684 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
4687 pReplace->cred = cred;
4688 } else if (strcmp(child_xml_name, ELEMENT_META) == 0) {
4691 item = create_item();
4693 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
4697 WBXMLTreeNode *grandchild = NULL;
4698 for (grandchild = child->children; grandchild != NULL; grandchild = grandchild->next) {
4699 if (grandchild->type != WBXML_TREE_ELEMENT_NODE)
4702 const char *grandchild_xml_name = NULL;
4703 grandchild_xml_name = (const char *)wbxml_tag_get_xml_name(grandchild->name);
4705 if (strcmp(grandchild_xml_name, ELEMENT_TYPE) == 0) {
4706 char *contentType = NULL;
4707 err = sync_agent_get_text_from_node(grandchild, &contentType);
4708 if (err != SYNC_AGENT_PB_RETURN_OK) {
4711 _DEBUG_TRACE("Content Type = [%s]", contentType);
4712 if (contentType != NULL)
4713 item->content_type = strdup(contentType);
4714 } else if (strcmp(grandchild_xml_name, ELEMENT_SIZE) == 0) {
4716 err = sync_agent_get_text_from_node(grandchild, &size);
4717 if (err != SYNC_AGENT_PB_RETURN_OK) {
4720 _DEBUG_TRACE("Size = [%s]", size);
4722 item->size = atoi(size);
4725 } else if (strcmp(child_xml_name, ELEMENT_ITEM) == 0) {
4728 item = create_item();
4730 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
4735 WBXMLTreeNode *grandchild = NULL;
4736 for (grandchild = child->children; grandchild != NULL; grandchild = grandchild->next) {
4737 if (grandchild->type != WBXML_TREE_ELEMENT_NODE)
4740 const char *grandchild_xml_name = NULL;
4741 grandchild_xml_name = (const char *)wbxml_tag_get_xml_name(grandchild->name);
4743 if (strcmp(grandchild_xml_name, ELEMENT_SOURCE) == 0) {
4744 location_s *pSourceLocation = _get_location(grandchild);
4745 if (pSourceLocation == NULL) {
4746 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
4749 item->source = pSourceLocation;
4750 } else if (strcmp(grandchild_xml_name, ELEMENT_TARGET) == 0) {
4751 location_s *pTargetLocation = _get_location(grandchild);
4752 if (pTargetLocation == NULL) {
4753 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
4756 item->target = pTargetLocation;
4757 } else if (strcmp(grandchild_xml_name, ELEMENT_META) == 0) {
4758 WBXMLTreeNode *grandgrandchild = NULL;
4760 for (grandgrandchild = grandchild->children; grandgrandchild != NULL; grandgrandchild = grandgrandchild->next) {
4761 if (grandgrandchild->type != WBXML_TREE_ELEMENT_NODE)
4764 const char *grandgrandchild_xml_name = NULL;
4765 grandgrandchild_xml_name = (const char *)wbxml_tag_get_xml_name(grandgrandchild->name);
4767 if (strcmp(grandgrandchild_xml_name, ELEMENT_TYPE) == 0) {
4768 char *contentType = NULL;
4769 err = sync_agent_get_text_from_node(grandgrandchild, &contentType);
4770 if (err != SYNC_AGENT_PB_RETURN_OK) {
4773 _DEBUG_TRACE("Content Type = [%s]", contentType);
4774 if (contentType != NULL)
4775 item->content_type = strdup(contentType);
4776 } else if (strcmp(grandgrandchild_xml_name, ELEMENT_SIZE) == 0) {
4778 err = sync_agent_get_text_from_node(grandgrandchild, &size);
4779 if (err != SYNC_AGENT_PB_RETURN_OK) {
4782 _DEBUG_TRACE("Size = [%s]", size);
4784 item->size = atoi(size);
4788 } else if (strcmp(grandchild_xml_name, ELEMENT_DATA) == 0) {
4790 err = sync_agent_get_text_from_cdata_node(grandchild, &data);
4791 if (err != SYNC_AGENT_PB_RETURN_OK) {
4794 _DEBUG_TRACE("Data = [%s]", data);
4796 item->private.data = strdup(data);
4797 item->data_type = ITEM_DATA;
4800 pReplace->private.change.items = g_list_append(pReplace->private.change.items, item);
4810 if (err == SYNC_AGENT_PB_RETURN_OK) {
4811 *content = pReplace;
4813 _DEBUG_ERROR("error");
4814 free_command(pReplace);
4821 static sync_agent_pb_error_e _oma_ds_binder_delete_command_reverse_converter_function(sync_agent_pb_protocol_binder_reverse_info_s * reverse_binder, WBXMLTreeNode * wbxml_dom_node, Content_Ptr * content)
4824 sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
4826 retvm_if(wbxml_dom_node == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "wbxml_dom_node is NULL");
4827 retvm_if(reverse_binder == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "reverse_binder is NULL");
4829 sync_hdr_s *pSyncHdr = (sync_hdr_s *) sync_agent_get_user_data_from_reverse_protocol_binder(reverse_binder);
4830 retvm_if(pSyncHdr == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "pSyncHdr is NULL");
4832 item_s *item = NULL;
4834 /* get data from dom tree */
4835 command_s *pDelete = (command_s *) calloc(1, sizeof(command_s));
4836 if (pDelete == NULL) {
4837 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
4838 _DEBUG_ERROR("pDelete is null");
4842 pDelete->type = COMMAND_TYPE_DELETE;
4843 pDelete->msg_id = pSyncHdr->message_id;
4844 pDelete->private.change.type = CHANGE_DELETE;
4845 pDelete->ref_count = 1;
4847 WBXMLTreeNode *child = NULL;
4849 for (child = wbxml_dom_node->children; child != NULL; child = child->next) {
4850 if (child->type != WBXML_TREE_ELEMENT_NODE)
4853 const char *child_xml_name = NULL;
4854 child_xml_name = (const char *)wbxml_tag_get_xml_name(child->name);
4856 if (strcmp(child_xml_name, ELEMENT_CMDID) == 0) {
4857 char *cmd_id = NULL;
4858 err = sync_agent_get_text_from_node(child, &cmd_id);
4859 if (err != SYNC_AGENT_PB_RETURN_OK) {
4862 _DEBUG_TRACE("CmdID = [%s]", cmd_id);
4864 pDelete->cmd_id = atoi(cmd_id);
4865 } else if (strcmp(child_xml_name, ELEMENT_NORESP) == 0) {
4866 _DEBUG_TRACE("NoResp");
4867 pDelete->no_resp = 1;
4868 } else if (strcmp(child_xml_name, ELEMENT_CRED) == 0) {
4869 _DEBUG_TRACE("Cred\n");
4870 cred_s *cred = NULL;
4871 cred = __get_cred(child);
4873 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
4876 pDelete->cred = cred;
4877 } else if (strcmp(child_xml_name, ELEMENT_META) == 0) {
4878 WBXMLTreeNode *grandchild = NULL;
4882 item = create_item();
4884 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
4889 for (grandchild = child->children; grandchild != NULL; grandchild = grandchild->next) {
4890 if (grandchild->type != WBXML_TREE_ELEMENT_NODE)
4893 const char *grandchild_xml_name = NULL;
4894 grandchild_xml_name = (const char *)wbxml_tag_get_xml_name(grandchild->name);
4896 if (strcmp(grandchild_xml_name, ELEMENT_TYPE) == 0) {
4897 char *contentType = NULL;
4898 err = sync_agent_get_text_from_node(grandchild, &contentType);
4899 if (err != SYNC_AGENT_PB_RETURN_OK) {
4902 _DEBUG_TRACE("Content Type = [%s]", contentType);
4903 if (contentType != NULL)
4904 item->content_type = strdup(contentType);
4907 } else if (strcmp(child_xml_name, ELEMENT_ITEM) == 0) {
4910 item = create_item();
4912 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
4916 WBXMLTreeNode *grandchild = NULL;
4918 for (grandchild = child->children; grandchild != NULL; grandchild = grandchild->next) {
4919 if (grandchild->type != WBXML_TREE_ELEMENT_NODE)
4922 const char *grandchild_xml_name = NULL;
4923 grandchild_xml_name = (const char *)wbxml_tag_get_xml_name(grandchild->name);
4925 if (strcmp(grandchild_xml_name, ELEMENT_SOURCE) == 0) {
4926 location_s *pSourceLocation = _get_location(grandchild);
4927 if (pSourceLocation == NULL) {
4928 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
4931 item->source = pSourceLocation;
4932 } else if (strcmp(grandchild_xml_name, ELEMENT_TARGET) == 0) {
4933 location_s *pTargetLocation = _get_location(grandchild);
4934 if (pTargetLocation == NULL) {
4935 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
4938 item->target = pTargetLocation;
4939 } else if (strcmp(grandchild_xml_name, ELEMENT_META) == 0) {
4941 } else if (strcmp(grandchild_xml_name, ELEMENT_DATA) == 0) {
4945 pDelete->private.change.items = g_list_append(pDelete->private.change.items, item);
4955 if (err == SYNC_AGENT_PB_RETURN_OK) {
4958 _DEBUG_ERROR("error");
4959 free_command(pDelete);
4966 static sync_agent_pb_error_e _oma_ds_binder_final_reverse_converter_function(sync_agent_pb_protocol_binder_reverse_info_s * reverse_binder, WBXMLTreeNode * wbxml_dom_node, Content_Ptr * content)
4969 sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
4971 int *pFinal = (int *)1;
4978 static sync_agent_pb_error_e _oma_ds_binder_status_reverse_converter_function(sync_agent_pb_protocol_binder_reverse_info_s * reverse_binder, WBXMLTreeNode * wbxml_dom_node, Content_Ptr * content)
4981 sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
4983 retvm_if(wbxml_dom_node == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "wbxml_dom_node is NULL");
4985 /* get data from dom tree */
4986 status_s *pStatus = (status_s *) calloc(1, sizeof(status_s));
4987 if (pStatus == NULL) {
4988 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
4989 _DEBUG_ERROR("pStatus is null");
4993 WBXMLTreeNode *child = NULL;
4994 for (child = wbxml_dom_node->children; child != NULL; child = child->next) {
4995 if (child->type != WBXML_TREE_ELEMENT_NODE)
4997 const char *child_xml_name = NULL;
4998 child_xml_name = (const char *)wbxml_tag_get_xml_name(child->name);
5000 if (strcmp(child_xml_name, ELEMENT_CMDID) == 0) {
5001 char *cmd_id = NULL;
5002 err = sync_agent_get_text_from_node(child, &cmd_id);
5003 if (err != SYNC_AGENT_PB_RETURN_OK) {
5006 _DEBUG_TRACE("CmdID = [%s]", cmd_id);
5008 pStatus->cmd_id = atoi(cmd_id);
5009 } else if (strcmp(child_xml_name, ELEMENT_MSGREF) == 0) {
5010 char *msgref = NULL;
5011 err = sync_agent_get_text_from_node(child, &msgref);
5012 if (err != SYNC_AGENT_PB_RETURN_OK) {
5015 _DEBUG_TRACE("MsgRef = [%s]", msgref);
5017 pStatus->msg_ref = atoi(msgref);
5018 } else if (strcmp(child_xml_name, ELEMENT_CMDREF) == 0) {
5019 char *cmdref = NULL;
5020 err = sync_agent_get_text_from_node(child, &cmdref);
5021 if (err != SYNC_AGENT_PB_RETURN_OK) {
5024 _DEBUG_TRACE("CmdRef = [%s]", cmdref);
5026 pStatus->cmd_ref = atoi(cmdref);
5027 } else if (strcmp(child_xml_name, ELEMENT_CMD) == 0) {
5029 err = sync_agent_get_text_from_node(child, &cmd);
5030 if (err != SYNC_AGENT_PB_RETURN_OK) {
5033 _DEBUG_TRACE("Cmd = [%s]", cmd);
5035 pStatus->type = convert_command_type(cmd);
5036 } else if (strcmp(child_xml_name, ELEMENT_TARGETREF) == 0) {
5037 char *targetref = NULL;
5038 location_s *location = NULL;
5039 err = sync_agent_get_text_from_node(child, &targetref);
5040 if (err != SYNC_AGENT_PB_RETURN_OK) {
5043 _DEBUG_TRACE("TargetRef = [%s]", targetref);
5045 sa_error_type_e error = create_location(targetref, NULL, &location);
5046 if (error != SA_INTERNAL_OK) {
5047 _DEBUG_ERROR("create_location() failed !, error = %d", error);
5050 pStatus->target_ref = location;
5051 } else if (strcmp(child_xml_name, ELEMENT_SOURCEREF) == 0) {
5052 char *sourceref = NULL;
5053 location_s *location = NULL;
5054 err = sync_agent_get_text_from_node(child, &sourceref);
5055 if (err != SYNC_AGENT_PB_RETURN_OK) {
5058 _DEBUG_TRACE("SourceRef = [%s]", sourceref);
5060 sa_error_type_e error = create_location(sourceref, NULL, &location);
5061 if (error != SA_INTERNAL_OK) {
5062 _DEBUG_ERROR("create_location() failed !, error = %d", error);
5065 pStatus->source_ref = location;
5066 } else if (strcmp(child_xml_name, ELEMENT_CRED) == 0) {
5067 _DEBUG_TRACE("Cred\n");
5068 cred_s *cred = NULL;
5069 cred = __get_cred(child);
5071 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
5074 pStatus->cred = cred;
5075 } else if (strcmp(child_xml_name, ELEMENT_CHAL) == 0) {
5076 _DEBUG_TRACE("Chal\n");
5077 chal_s *pChal = NULL;
5078 pChal = _get_chal(child);
5079 if (pChal == NULL) {
5080 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
5083 pStatus->chal = pChal;
5084 } else if (strcmp(child_xml_name, ELEMENT_DATA) == 0) {
5086 err = sync_agent_get_text_from_node(child, &data);
5087 if (err != SYNC_AGENT_PB_RETURN_OK) {
5090 _DEBUG_TRACE("Data = [%s]\n", data);
5092 pStatus->data = strdup(data);
5093 } else if (strcmp(child_xml_name, ELEMENT_ITEM) == 0) {
5094 WBXMLTreeNode *grandchild = NULL;
5096 for (grandchild = child->children; grandchild != NULL; grandchild = grandchild->next) {
5097 if (grandchild->type != WBXML_TREE_ELEMENT_NODE)
5100 const char *grandchild_xml_name = NULL;
5101 grandchild_xml_name = (const char *)wbxml_tag_get_xml_name(grandchild->name);
5103 if (strcmp(grandchild_xml_name, ELEMENT_SOURCE) == 0) {
5104 location_s *pSourceLocation = _get_location(grandchild);
5105 if (pSourceLocation == NULL) {
5106 err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
5109 pStatus->source_ref = pSourceLocation;
5110 } else if (strcmp(grandchild_xml_name, ELEMENT_TARGET) == 0) {
5112 } else if (strcmp(grandchild_xml_name, ELEMENT_DATA) == 0) {
5120 if (err == SYNC_AGENT_PB_RETURN_OK) {
5123 _DEBUG_ERROR("error");
5124 free_status(pStatus);
5131 sync_agent_pb_error_e init_oma_ds_1_2_binder_function_set(sync_agent_pb_protocol_binder_function_set_s ** binder_function_set)
5135 sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
5137 err = sync_agent_init_binder_function_set(sizeof(oma_ds_binder_function_info) / sizeof(sync_agent_pb_function_info_s), (sync_agent_pb_function_info_s *) oma_ds_binder_function_info, binder_function_set);
5143 void free_oma_ds_1_2_binder_function_set(sync_agent_pb_protocol_binder_function_set_s * binder_function_set)
5147 sync_agent_free_binder_function_set(binder_function_set);
5152 sync_agent_pb_protocol_binder_info_s *oma_ds_1_2_binder_init(sync_agent_pb_protocol_binder_info_s * binder, sync_agent_pb_encoding_e enc, bool encode_xml_header,
5153 bool use_strtbl, bool produce_anonymous, bool use_flow_mode, bool text_public_id, sync_agent_pb_protocol_binder_function_set_s * binder_function_set)
5157 sync_agent_pb_protocol_binder_info_s *pOutBinder = NULL;
5159 pOutBinder = sync_agent_init_protocol_binder(binder, SYNC_AGENT_PB_PROTOCOL_SYNCML_SYNCML12, NULL, enc, encode_xml_header, use_strtbl, produce_anonymous, use_flow_mode, text_public_id, NULL, NULL, binder_function_set);
5161 if (pOutBinder == NULL) {
5171 sync_agent_pb_error_e oma_ds_1_2_binder_append(sync_agent_pb_protocol_binder_info_s * binder, oma_ds_protocol_element_e protocol_element, Content_Ptr content)
5175 sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
5177 err = sync_agent_append_element(binder, protocol_element, content);
5183 void oma_ds_1_2_binder_terminate(sync_agent_pb_protocol_binder_info_s * binder)
5187 sync_agent_destroy_protocol_binder(binder);
5192 sync_agent_pb_error_e oma_ds_1_2_binder_get_stream(sync_agent_pb_protocol_binder_info_s * binder, char **byte_stream, unsigned int *byte_stream_size)
5196 sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
5198 err = sync_agent_get_stream_from_protocol_binder(binder, byte_stream, byte_stream_size);
5199 if (err != SYNC_AGENT_PB_RETURN_OK) {
5209 sync_agent_pb_error_e oma_ds_1_2_binder_get_stream_size(sync_agent_pb_protocol_binder_info_s * binder, unsigned int *byte_stream_size)
5214 sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
5216 err = sync_agent_get_stream_size_from_protocol_binder(binder, byte_stream_size);
5222 sync_agent_pb_error_e oma_ds_1_2_binder_get_encoding(sync_agent_pb_protocol_binder_info_s * binder, sync_agent_pb_encoding_e * enc)
5226 sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
5228 err = sync_agent_get_encoding_from_protocol_binder(binder, enc);
5234 sync_agent_pb_error_e reverse_oma_ds_1_2_binder_init(char *byte_stream,
5235 unsigned int byte_stream_len, sync_agent_pb_decoding_e dec, sync_agent_pb_protocol_binder_function_set_s * binder_function_set, void *user_data, sync_agent_pb_protocol_binder_reverse_info_s ** binder)
5239 sync_agent_pb_protocol_e protocol = SYNC_AGENT_PB_PROTOCOL_UNKNOWN;
5240 sync_agent_pb_error_e err = sync_agent_init_reverse_protocol_binder(byte_stream, byte_stream_len, dec,
5241 &protocol, binder_function_set, user_data, binder);
5247 sync_agent_pb_error_e reverse_oma_ds_1_2_binder_next(sync_agent_pb_protocol_binder_reverse_info_s * pBinder, oma_ds_protocol_element_e * protocol_element, char **protocol_element_name, Content_Ptr * content)
5251 sync_agent_pb_error_e err = sync_agent_next_element(pBinder,
5252 protocol_element, protocol_element_name, content);