summaryrefslogtreecommitdiff
path: root/src/agent/service-adapter/protocol-binder/oma_ds_protocol_binder.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/agent/service-adapter/protocol-binder/oma_ds_protocol_binder.c')
-rwxr-xr-xsrc/agent/service-adapter/protocol-binder/oma_ds_protocol_binder.c5256
1 files changed, 5256 insertions, 0 deletions
diff --git a/src/agent/service-adapter/protocol-binder/oma_ds_protocol_binder.c b/src/agent/service-adapter/protocol-binder/oma_ds_protocol_binder.c
new file mode 100755
index 0000000..b6b14db
--- /dev/null
+++ b/src/agent/service-adapter/protocol-binder/oma_ds_protocol_binder.c
@@ -0,0 +1,5256 @@
+/*
+ * oma-ds-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @oma_ds_protocol_binder.c
+ * @version 0.1
+ * @brief This file is the source file of implementation of callback function for Protocol Binder
+ */
+
+#include <glib.h>
+
+#include <sync_agent.h>
+
+#include "service-adapter/protocol-binder/oma_ds_protocol_binder.h"
+#include "service-adapter/sa_elements_internal.h"
+#include "service-adapter/sa_command_internal.h"
+#include "service-adapter/sa_devinf_internal.h"
+#include "service-adapter/sa_command.h"
+#include "service-adapter/sa_elements.h"
+#include "service-adapter/sa_devinf.h"
+#include "service-adapter/sa_define.h"
+
+#ifndef OMADS_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "OMA_DS_BINDER"
+#endif
+
+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);
+
+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);
+
+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);
+
+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);
+
+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);
+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);
+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);
+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);
+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);
+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);
+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);
+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);
+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);
+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);
+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);
+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);
+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);
+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);
+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);
+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);
+
+static protocol_version_e __get_oma_ds_protocol_version(char *verdtd);
+static devinf_version_e __get_oma_ds_devInf_version(char *verdtd);
+static devinf_devtyp_e __get_oma_ds_devInf_device_type(char *dev_type);
+static devinf_content_type_s *__get_devinf_contenttype(WBXMLTreeNode * node);
+static location_s *_get_location(WBXMLTreeNode * node);
+static anchor_s *_get_anchor(WBXMLTreeNode * node);
+static cred_s *__get_cred(WBXMLTreeNode * node);
+static chal_s *_get_chal(WBXMLTreeNode * node);
+
+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);
+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);
+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);
+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);
+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);
+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);
+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);
+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);
+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);
+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);
+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);
+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);
+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);
+
+/*
+ PE_ADD,
+ PE_DELETE,
+ PE_REPLACE,
+ PE_ALERT,
+ PE_GET,
+ PE_MAP,
+ PE_PUT,
+ PE_RESULTS,
+ PE_STATUS,
+ PE_SYNC_START,
+ PE_SYNC_END,
+ PE_HEADER,
+ PE_FINAL
+
+ PE_COPY,
+ PE_EXEC,
+ PE_SEARCH,
+ PE_SEQUENCE_START,
+ PE_SEQUENCE_END,
+ PE_ATOMIC_START,
+ PE_ATOMIC_END,
+ PE_PUT_GET,
+ PE_CMD_GROUP,
+ PE_GENERIC,
+ */
+const sync_agent_pb_function_info_s oma_ds_binder_function_info[] = {
+ {PE_SYNCML_START, "SyncML", _oma_ds_binder_syncml_start_converter_function, NULL, false},
+ {PE_SYNCML_END, "/SyncML", NULL, NULL, false},
+ {PE_HEADER, "SyncHdr", _oma_ds_binder_header_converter_function, _oma_ds_binder_header_reverse_converter_function, true},
+ {PE_BODY_START, "SyncBody", _oma_ds_binder_body_start_converter_function, NULL, false},
+ {PE_BODY_END, "/SyncBody", NULL, NULL, false},
+ {PE_FINAL, "Final", _oma_ds_binder_final_converter_function, _oma_ds_binder_final_reverse_converter_function, true},
+ {PE_ALERT, "Alert", _oma_ds_binder_alert_command_converter_function, _oma_ds_binder_alert_command_reverse_converter_function, true},
+ {PE_STATUS, "Status", _oma_ds_binder_status_converter_function, _oma_ds_binder_status_reverse_converter_function, true},
+ {PE_RESULTS_START, "Results", _oma_ds_binder_results_command_converter_function, _oma_ds_binder_results_command_reverse_converter_function, false},
+ {PE_RESULTS_END, "/Results", NULL, NULL, false},
+ {PE_PUT_START, "Put", _oma_ds_binder_put_command_converter_function, _oma_ds_binder_put_command_reverse_converter_function, false},
+ {PE_PUT_END, "/Put", NULL, NULL, false},
+ {PE_GET, "Get", _oma_ds_binder_get_command_converter_function, _oma_ds_binder_get_command_reverse_converter_function, true},
+ {PE_SYNC_START, "Sync", _oma_ds_binder_sync_start_command_converter_function, _oma_ds_binder_sync_start_command_reverse_converter_function, false},
+ {PE_SYNC_END, "/Sync", _oma_ds_binder_sync_end_command_converter_function, _oma_ds_binder_sync_end_command_reverse_converter_function, false},
+ {PE_ADD, "Add", _oma_ds_binder_add_command_converter_function, _oma_ds_binder_add_command_reverse_converter_function, true},
+ {PE_REPLACE, "Replace", _oma_ds_binder_replace_command_converter_function, _oma_ds_binder_replace_command_reverse_converter_function, true},
+ {PE_DELETE, "Delete", _oma_ds_binder_delete_command_converter_function, _oma_ds_binder_delete_command_reverse_converter_function, true},
+ {PE_MAP, "Map", _oma_ds_binder_map_command_converter_function, NULL, true},
+ {PE_DEVINF, "DevInf", _oma_ds_binder_devinf_converter_function, _oma_ds_binder_devinf_reverse_converter_function, true}
+};
+
+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)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if(location == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "location is NULL");
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+ if (location->loc_uri != NULL) {
+ WBXMLTreeNode *LocURI = sync_agent_add_child_text_node(binder,
+ parent_node, ELEMENT_LOCURI, location->loc_uri, strlen(location->loc_uri));
+ if (LocURI == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ } else {
+ /* error case */
+ }
+
+ if (location->loc_name != NULL) {
+ WBXMLTreeNode *locName = sync_agent_add_child_text_node(binder,
+ parent_node, ELEMENT_LOCNAME, location->loc_name, strlen(location->loc_name));
+ if (locName == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ error:
+
+ _INNER_FUNC_EXIT;
+ return err;
+}
+
+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)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if(anchor == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "anchor is NULL");
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+ WBXMLTreeNode *meta_node = sync_agent_add_child_node(binder, parent_node, ELEMENT_META);
+ if (meta_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *anchor_node = sync_agent_add_child_node(binder, meta_node, ELEMENT_ANCHOR);
+ if (anchor_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ if (anchor->last_anchor != NULL) {
+ WBXMLTreeNode *last_node = sync_agent_add_child_text_node(binder,
+ anchor_node, ELEMENT_LAST, anchor->last_anchor, strlen(anchor->last_anchor));
+ if (last_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ if (anchor->next_anchor != NULL) {
+ WBXMLTreeNode *next_node = sync_agent_add_child_text_node(binder,
+ anchor_node, ELEMENT_NEXT, anchor->next_anchor, strlen(anchor->next_anchor));
+ if (next_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ error:
+
+ _INNER_FUNC_EXIT;
+ return err;
+}
+
+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)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if(devinf_content_type == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "devinf_content_type is NULL");
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+ WBXMLTreeNode *xnode = sync_agent_add_child_node(binder, parent_node, node);
+ if (xnode == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *cttype_node = sync_agent_add_child_text_node(binder,
+ xnode, "CTType", devinf_content_type->ct_type, strlen(devinf_content_type->ct_type));
+ if (cttype_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *verct_node = sync_agent_add_child_text_node(binder,
+ xnode, "VerCT", devinf_content_type->verct, strlen(devinf_content_type->verct));
+ if (verct_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ error:
+ _INNER_FUNC_EXIT;
+ return err;
+}
+
+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)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if(cred == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "cred is NULL");
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+ /* check validity */
+ WBXMLTreeNode *cred_node = sync_agent_add_child_node(binder, parent_node, ELEMENT_CRED);
+ if (cred_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *meta_node = sync_agent_add_child_node(binder, cred_node, ELEMENT_META);
+ if (meta_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *type_node = NULL;
+
+ switch (cred->type) {
+ case AUTH_TYPE_BASIC:
+
+ if (cred->format == FORMAT_TYPE_BASE64) {
+ WBXMLTreeNode *format_node = sync_agent_add_child_text_node(binder,
+ meta_node, ELEMENT_FORMAT, ELEMENT_FORMAT_BASE64, strlen(ELEMENT_FORMAT_BASE64));
+ if (format_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ type_node = sync_agent_add_child_text_node(binder, meta_node, ELEMENT_TYPE, ELEMENT_AUTH_BASIC, strlen(ELEMENT_AUTH_BASIC));
+ if (type_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ if (cred->data != NULL) {
+ WBXMLTreeNode *data_node = sync_agent_add_child_text_node(binder,
+ cred_node, ELEMENT_DATA, cred->data, strlen(cred->data));
+ if (data_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+ break;
+ case AUTH_TYPE_MD5:
+
+ if (cred->format == FORMAT_TYPE_BASE64) {
+ WBXMLTreeNode *format_node = sync_agent_add_child_text_node(binder,
+ meta_node, ELEMENT_FORMAT, ELEMENT_FORMAT_BASE64, strlen(ELEMENT_FORMAT_BASE64));
+ if (format_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ type_node = sync_agent_add_child_text_node(binder, meta_node, ELEMENT_TYPE, ELEMENT_AUTH_MD5, strlen(ELEMENT_AUTH_MD5));
+ if (type_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ if (cred->data != NULL) {
+ WBXMLTreeNode *data_node = sync_agent_add_child_text_node(binder,
+ cred_node, ELEMENT_DATA, cred->data, strlen(cred->data));
+ if (data_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+ break;
+ default:
+ break;
+ }
+
+ error:
+ _INNER_FUNC_EXIT;
+ return err;
+}
+
+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)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if(content == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "content is NULL");
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+ item_s *pItem = (item_s *) content;
+ devinf_s *pDevInf = pItem->private.devinf;
+
+ if (pItem != NULL) {
+ WBXMLTreeNode *item_node = sync_agent_create_node(binder, ELEMENT_ITEM);
+ if (item_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *source_node = sync_agent_add_child_node(binder, item_node, ELEMENT_SOURCE);
+ if (source_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ err = __append_location_to_wbxml_node(pItem->source, binder, source_node);
+ if (err != SYNC_AGENT_PB_RETURN_OK)
+ goto error;
+
+ WBXMLTreeNode *data_node = sync_agent_add_child_node(binder, item_node, ELEMENT_DATA);
+ if (data_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ /* devinf language setting */
+ sync_agent_switch_protocol(binder, SYNC_AGENT_PB_PROTOCOL_SYNCML_DEVINF12);
+ WBXMLTree *devinf_tree = sync_agent_create_wbxml_tree(binder);
+ if (devinf_tree == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ sync_agent_add_wbxml_tree_to_wbxml_node(data_node, devinf_tree);
+
+ /* create root node of devinf tree */
+ WBXMLTreeNode *devinf_node = sync_agent_create_node(binder, ELEMENT_DEVINF);
+ if (devinf_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ sync_agent_set_wbxml_tree_root(devinf_tree, devinf_node);
+
+ WBXMLTreeNode *verDTD_node = NULL;
+ switch (pDevInf->version) {
+ case DEVINF_VERSION_UNKNOWN:
+ verDTD_node = sync_agent_add_child_node(binder, devinf_node, ELEMENT_VERDTD);
+ break;
+ case DEVINF_VERSION_10:
+ verDTD_node = sync_agent_add_child_text_node(binder, devinf_node, ELEMENT_VERDTD, ELEMENT_VERDRD_10, strlen(ELEMENT_VERDRD_10));
+ break;
+ case DEVINF_VERSION_11:
+ verDTD_node = sync_agent_add_child_text_node(binder, devinf_node, ELEMENT_VERDTD, ELEMENT_VERDRD_11, strlen(ELEMENT_VERDRD_11));
+ break;
+ case DEVINF_VERSION_12:
+ verDTD_node = sync_agent_add_child_text_node(binder, devinf_node, ELEMENT_VERDTD, ELEMENT_VERDRD_12, strlen(ELEMENT_VERDRD_12));
+ break;
+ }
+
+ if (verDTD_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *man_node = sync_agent_add_child_text_node(binder,
+ devinf_node, ELEMENT_MAN, pDevInf->manufacturer, strlen(pDevInf->manufacturer));
+ if (man_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *mod_node = sync_agent_add_child_text_node(binder,
+ devinf_node, ELEMENT_MOD, pDevInf->model, strlen(pDevInf->model));
+ if (mod_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ if (pDevInf->oem != NULL) {
+ WBXMLTreeNode *oem_node = sync_agent_add_child_text_node(binder,
+ devinf_node, ELEMENT_OEM, pDevInf->oem, strlen(pDevInf->oem));
+ if (oem_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ WBXMLTreeNode *FwV_node = sync_agent_add_child_text_node(binder,
+ devinf_node, ELEMENT_FWV, pDevInf->firmware_version, strlen(pDevInf->firmware_version));
+ if (FwV_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *SwV_node = sync_agent_add_child_text_node(binder,
+ devinf_node, ELEMENT_SWV, pDevInf->software_version, strlen(pDevInf->software_version));
+ if (SwV_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *HwV_node = sync_agent_add_child_text_node(binder,
+ devinf_node, ELEMENT_HWV, pDevInf->hardware_version, strlen(pDevInf->hardware_version));
+ if (HwV_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *devID_node = sync_agent_add_child_text_node(binder,
+ devinf_node, ELEMENT_DEVID, pDevInf->dev_id, strlen(pDevInf->dev_id));
+ if (devID_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *devTyp_node = NULL;
+ switch (pDevInf->devtyp) {
+ case DEVINF_DEVTYPE_UNKNOWN:
+ devTyp_node = sync_agent_add_child_node(binder, devinf_node, ELEMENT_DEVTYP);
+ break;
+ case DEVINF_DEVTYPE_PAGER:
+ devTyp_node = sync_agent_add_child_text_node(binder, devinf_node, ELEMENT_DEVTYP, ELEMENT_PAGER, strlen(ELEMENT_PAGER));
+ break;
+ case DEVINF_DEVTYPE_HANDHELD:
+ devTyp_node = sync_agent_add_child_text_node(binder, devinf_node, ELEMENT_DEVTYP, ELEMENT_HANDHELD, strlen(ELEMENT_HANDHELD));
+ break;
+ case DEVINF_DEVTYPE_PDA:
+ devTyp_node = sync_agent_add_child_text_node(binder, devinf_node, ELEMENT_DEVTYP, ELEMENT_PDA, strlen(ELEMENT_PDA));
+ break;
+ case DEVINF_DEVTYPE_PHONE:
+ devTyp_node = sync_agent_add_child_text_node(binder, devinf_node, ELEMENT_DEVTYP, ELEMENT_PHONE, strlen(ELEMENT_PHONE));
+ break;
+ case DEVINF_DEVTYPE_SMARTPHONE:
+ devTyp_node = sync_agent_add_child_text_node(binder, devinf_node, ELEMENT_DEVTYP, ELEMENT_SMARTPHONE, strlen(ELEMENT_SMARTPHONE));
+ break;
+ case DEVINF_DEVTYPE_SERVER:
+ devTyp_node = sync_agent_add_child_text_node(binder, devinf_node, ELEMENT_DEVTYP, ELEMENT_SERVER, strlen(ELEMENT_SERVER));
+ break;
+ case DEVINF_DEVTYPE_WORKSTATION:
+ devTyp_node = sync_agent_add_child_text_node(binder, devinf_node, ELEMENT_DEVTYP, ELEMENT_WORKSTATION, strlen(ELEMENT_WORKSTATION));
+ break;
+ }
+
+ if (devTyp_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ if (pDevInf->supports_utc) {
+ WBXMLTreeNode *supportUTC_node = sync_agent_add_child_node(binder,
+ devinf_node, ELEMENT_UTC);
+ if (supportUTC_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ if (pDevInf->supports_large_objs) {
+ WBXMLTreeNode *supportLargeObjs_node = sync_agent_add_child_node(binder,
+ devinf_node, ELEMENT_SUPPORTLARGEOBJS);
+ if (supportLargeObjs_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ if (pDevInf->supports_number_of_changes) {
+ WBXMLTreeNode *supportNumberOfChanges_node = sync_agent_add_child_node(binder,
+ devinf_node, ELEMENT_SUPPORTNUMBEROFCHANGES);
+ if (supportNumberOfChanges_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ GList *datastoreIter = NULL;
+ devinf_datastore_s *devInfDataStore = NULL;
+ for (datastoreIter = pDevInf->datastores; datastoreIter != NULL; datastoreIter = g_list_next(datastoreIter)) {
+ devInfDataStore = datastoreIter->data;
+
+ WBXMLTreeNode *datastore_node = sync_agent_add_child_node(binder,
+ devinf_node, ELEMENT_DATASTORE);
+ if (datastore_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *sourceRef_node = sync_agent_add_child_text_node(binder,
+ datastore_node, ELEMENT_SOURCEREF, devInfDataStore->source_ref, strlen(devInfDataStore->source_ref));
+ if (sourceRef_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ if (devInfDataStore->display_name != NULL) {
+ WBXMLTreeNode *displayname_node = sync_agent_add_child_text_node(binder,
+ datastore_node, ELEMENT_DISPLAYNAME, devInfDataStore->display_name, strlen(devInfDataStore->display_name));
+ if (displayname_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ if (devInfDataStore->max_guid_size) {
+ char *str_maxguidsize = g_strdup_printf("%u", devInfDataStore->max_guid_size);
+ if (str_maxguidsize == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *maxguidsize_node = sync_agent_add_child_text_node(binder,
+ datastore_node, ELEMENT_MAXGUIDSIZE, str_maxguidsize, strlen(str_maxguidsize));
+
+ if (str_maxguidsize != NULL)
+ free(str_maxguidsize);
+
+ if (maxguidsize_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ __append_devinf_contenttype_to_wbxml_node(devInfDataStore->rx_pref, binder, datastore_node, ELEMENT_RX_PREF);
+ if (err != SYNC_AGENT_PB_RETURN_OK)
+ goto error;
+
+ GList *rxIter = NULL;
+ devinf_content_type_s *devInfContentType = NULL;
+ for (rxIter = devInfDataStore->rx; rxIter != NULL; rxIter = g_list_next(rxIter)) {
+ devInfContentType = rxIter->data;
+ __append_devinf_contenttype_to_wbxml_node(devInfContentType, binder, datastore_node, ELEMENT_RX);
+ if (err != SYNC_AGENT_PB_RETURN_OK)
+ goto error;
+ }
+
+ __append_devinf_contenttype_to_wbxml_node(devInfDataStore->tx_pref, binder, datastore_node, ELEMENT_TX_PREF);
+ if (err != SYNC_AGENT_PB_RETURN_OK)
+ goto error;
+
+ GList *txIter = NULL;
+ for (txIter = devInfDataStore->tx; txIter != NULL; txIter = g_list_next(txIter)) {
+ devInfContentType = txIter->data;
+ __append_devinf_contenttype_to_wbxml_node(devInfContentType, binder, datastore_node, ELEMENT_TX);
+ if (err != SYNC_AGENT_PB_RETURN_OK)
+ goto error;
+
+ }
+
+ GList *ctcapIter = NULL;
+ devinf_ct_cap_s *devInfCTCap = NULL;
+ for (ctcapIter = devInfDataStore->ct_caps; ctcapIter != NULL; ctcapIter = g_list_next(ctcapIter)) {
+ devInfCTCap = ctcapIter->data;
+
+ WBXMLTreeNode *ctcap_node = sync_agent_add_child_node(binder,
+ datastore_node, ELEMENT_CTCAP);
+ if (ctcap_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *cttype_node = sync_agent_add_child_text_node(binder,
+ ctcap_node, ELEMENT_CTTYPE, devInfCTCap->ct->ct_type, strlen(devInfCTCap->ct->ct_type));
+ if (cttype_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *verct_node = sync_agent_add_child_text_node(binder,
+ ctcap_node, ELEMENT_VERCT, devInfCTCap->ct->verct, strlen(devInfCTCap->ct->verct));
+ if (verct_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ /*TODO FieldLevel */
+
+ GList *propertyIter = NULL;
+ devinf_property_s *devInfProperty = NULL;
+ for (propertyIter = devInfCTCap->properties; propertyIter != NULL; propertyIter = g_list_next(propertyIter)) {
+ devInfProperty = propertyIter->data;
+
+ WBXMLTreeNode *property_node = sync_agent_add_child_node(binder,
+ ctcap_node, ELEMENT_PROPERTY);
+ if (property_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *propname_node = sync_agent_add_child_text_node(binder,
+ property_node, ELEMENT_PROPNAME, devInfProperty->prop_name, strlen(devInfProperty->prop_name));
+ if (propname_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ if (devInfProperty->data_type != NULL) {
+ WBXMLTreeNode *datatype_node = sync_agent_add_child_text_node(binder,
+ property_node, ELEMENT_DATATYPE, devInfProperty->data_type, strlen(devInfProperty->data_type));
+ if (datatype_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ if (devInfProperty->max_occur) {
+ char *str_maxoccur = g_strdup_printf("%u", devInfProperty->max_occur);
+ if (str_maxoccur == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *maxoccur_node = sync_agent_add_child_text_node(binder,
+ property_node, ELEMENT_MAXOCCUR, str_maxoccur, strlen(str_maxoccur));
+
+ if (str_maxoccur != NULL)
+ free(str_maxoccur);
+
+ if (maxoccur_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ if (devInfProperty->max_size) {
+ char *str_maxsize = g_strdup_printf("%u", devInfProperty->max_size);
+ if (str_maxsize == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *maxsize_node = sync_agent_add_child_text_node(binder,
+ property_node, ELEMENT_MAXSIZE, str_maxsize, strlen(str_maxsize));
+
+ if (str_maxsize != NULL)
+ free(str_maxsize);
+
+ if (maxsize_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ if (devInfProperty->no_truncate) {
+ WBXMLTreeNode *notruncate_node = sync_agent_add_child_node(binder,
+ property_node, ELEMENT_NOTRUNCATE);
+ if (notruncate_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ GList *valenum = NULL;
+ char *val = NULL;
+ for (valenum = devInfProperty->val_enums; valenum != NULL; valenum = g_list_next(valenum)) {
+ val = valenum->data;
+ WBXMLTreeNode *valenum_node = sync_agent_add_child_text_node(binder,
+ property_node, ELEMENT_VALENUM, val, strlen(val));
+ if (valenum_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ if (devInfProperty->display_name != NULL) {
+ WBXMLTreeNode *displayname_node = sync_agent_add_child_text_node(binder,
+ property_node, ELEMENT_DISPLAYNAME, devInfProperty->display_name, strlen(devInfProperty->display_name));
+ if (displayname_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ GList *propparamIter = NULL;
+ devinf_prop_param_s *devInfPropParam = NULL;
+ for (propparamIter = devInfProperty->prop_params; propparamIter != NULL; propparamIter = g_list_next(propparamIter)) {
+ devInfPropParam = propparamIter->data;
+
+ WBXMLTreeNode *propparam_node = sync_agent_add_child_node(binder,
+ property_node, ELEMENT_PROPPARAM);
+ if (propparam_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *paramname_node = sync_agent_add_child_text_node(binder,
+ propparam_node, ELEMENT_PARAMNAME, devInfPropParam->param_name, strlen(devInfPropParam->param_name));
+ if (paramname_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ if (devInfPropParam->data_type != NULL) {
+ WBXMLTreeNode *datatype_node = sync_agent_add_child_text_node(binder,
+ propparam_node, ELEMENT_DATATYPE, devInfPropParam->data_type, strlen(devInfPropParam->data_type));
+ if (datatype_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ valenum = NULL;
+ val = NULL;
+ for (valenum = devInfPropParam->val_enums; valenum != NULL; valenum = g_list_next(valenum)) {
+ val = valenum->data;
+ WBXMLTreeNode *valenum_node = sync_agent_add_child_text_node(binder,
+ propparam_node, ELEMENT_VALENUM, val, strlen(val));
+ if (valenum_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ if (devInfPropParam->display_name != NULL) {
+ WBXMLTreeNode *displayname_node = sync_agent_add_child_text_node(binder,
+ propparam_node, ELEMENT_DISPLAYNAME, devInfPropParam->display_name, strlen(devInfPropParam->display_name));
+ if (displayname_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+ }
+ }
+ }
+
+ /* DSMem */
+ WBXMLTreeNode *dsmem_node = sync_agent_add_child_node(binder,
+ datastore_node, ELEMENT_DSMEM);
+ if (dsmem_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ if (devInfDataStore->shared_mem) {
+ WBXMLTreeNode *sharedmem_node = sync_agent_add_child_node(binder,
+ dsmem_node, ELEMENT_SHAREDMEM);
+ if (sharedmem_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ if (devInfDataStore->max_mem) {
+ char *str_maxmem = g_strdup_printf("%u", devInfDataStore->max_mem);
+ WBXMLTreeNode *maxmem_node = sync_agent_add_child_text_node(binder,
+ dsmem_node, ELEMENT_MAXMEM, str_maxmem, strlen(str_maxmem));
+
+ if (str_maxmem != NULL)
+ free(str_maxmem);
+
+ if (maxmem_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ if (devInfDataStore->max_id) {
+ char *str_maxid = g_strdup_printf("%u", devInfDataStore->max_id);
+ WBXMLTreeNode *maxid_node = sync_agent_add_child_text_node(binder,
+ dsmem_node, ELEMENT_MAXID, str_maxid, strlen(str_maxid));
+
+ if (str_maxid != NULL)
+ free(str_maxid);
+
+ if (maxid_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ /* SupportHierarchicalSync */
+ if (devInfDataStore->supports_hierarchical_sync) {
+ WBXMLTreeNode *supportshierarchicalsync_node = sync_agent_add_child_node(binder,
+ datastore_node, ELEMENT_SUPPORTHIERARCHICALSYNC);
+ if (supportshierarchicalsync_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ WBXMLTreeNode *synccap_node = sync_agent_add_child_node(binder,
+ datastore_node, ELEMENT_SYNCCAP);
+ if (synccap_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ if (get_devinf_datastore_sync_cap(devInfDataStore, DEVINF_SYNCTYPE_TWO_WAY)) {
+ WBXMLTreeNode *synctype_node = sync_agent_add_child_text_node(binder,
+ synccap_node, ELEMENT_SYNCTYPE, ELEMENT_SYNCTYPE_1, strlen(ELEMENT_SYNCTYPE_1));
+ if (synctype_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+ if (get_devinf_datastore_sync_cap(devInfDataStore, DEVINF_SYNCTYPE_SLOW_SYNC)) {
+ WBXMLTreeNode *synctype_node = sync_agent_add_child_text_node(binder,
+ synccap_node, ELEMENT_SYNCTYPE, ELEMENT_SYNCTYPE_2, strlen(ELEMENT_SYNCTYPE_2));
+ if (synctype_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+ if (get_devinf_datastore_sync_cap(devInfDataStore, DEVINF_SYNCTYPE_ONE_WAY_FROM_CLIENT)) {
+ WBXMLTreeNode *synctype_node = sync_agent_add_child_text_node(binder,
+ synccap_node, ELEMENT_SYNCTYPE, ELEMENT_SYNCTYPE_3, strlen(ELEMENT_SYNCTYPE_3));
+ if (synctype_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+ if (get_devinf_datastore_sync_cap(devInfDataStore, DEVINF_SYNCTYPE_REFRESH_FROM_CLIENT)) {
+ WBXMLTreeNode *synctype_node = sync_agent_add_child_text_node(binder,
+ synccap_node, ELEMENT_SYNCTYPE, ELEMENT_SYNCTYPE_4, strlen(ELEMENT_SYNCTYPE_4));
+ if (synctype_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+ if (get_devinf_datastore_sync_cap(devInfDataStore, DEVINF_SYNCTYPE_ONE_WAY_FROM_SERVER)) {
+ WBXMLTreeNode *synctype_node = sync_agent_add_child_text_node(binder,
+ synccap_node, ELEMENT_SYNCTYPE, ELEMENT_SYNCTYPE_5, strlen(ELEMENT_SYNCTYPE_5));
+ if (synctype_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+ if (get_devinf_datastore_sync_cap(devInfDataStore, DEVINF_SYNCTYPE_REFRESH_FROM_SERVER)) {
+ WBXMLTreeNode *synctype_node = sync_agent_add_child_text_node(binder,
+ synccap_node, ELEMENT_SYNCTYPE, ELEMENT_SYNCTYPE_6, strlen(ELEMENT_SYNCTYPE_6));
+ if (synctype_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+ if (get_devinf_datastore_sync_cap(devInfDataStore, DEVINF_SYNCTYPE_SERVER_ALERTED_SYNC)) {
+ WBXMLTreeNode *synctype_node = sync_agent_add_child_text_node(binder,
+ synccap_node, ELEMENT_SYNCTYPE, ELEMENT_SYNCTYPE_7, strlen(ELEMENT_SYNCTYPE_7));
+ if (synctype_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+ /*TODO filter-rx, filterCap */
+ }
+ sync_agent_undo_switch_protocol(binder);
+ *wbxml_dom_node = item_node;
+ }
+
+ error:
+ _INNER_FUNC_EXIT;
+ return err;
+}
+
+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)
+{
+ _INNER_FUNC_ENTER;
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+ WBXMLTreeNode *syncml_node = sync_agent_create_node(binder, ELEMENT_SYNCML);
+ if (syncml_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ *wbxml_dom_node = syncml_node;
+
+ error:
+ _INNER_FUNC_EXIT;
+ return err;
+}
+
+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)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if(content == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "content is NULL");
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+ sync_hdr_s *pSyncHdr = (sync_hdr_s *) content;
+
+ /* add SyncHdr, VerDTD, VerProto node */
+ WBXMLTreeNode *synchdr_node = sync_agent_create_node(binder, ELEMENT_SYNCHDR);
+ if (synchdr_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ char *verDTD = ELEMENT_VERDTD;
+ char *verProto = ELEMENT_VERPROTO;
+
+ char *verDTD_data = NULL;
+ char *verProto_data = NULL;
+ if (pSyncHdr->version == VERSION_10) {
+ verDTD_data = ELEMENT_VERDRD_10;
+ verProto_data = ELEMENT_VERPROTO_10;
+ } else if (pSyncHdr->version == VERSION_11) {
+ verDTD_data = ELEMENT_VERDRD_11;
+ verProto_data = ELEMENT_VERPROTO_11;
+ } else if (pSyncHdr->version == VERSION_12) {
+ verDTD_data = ELEMENT_VERDRD_12;
+ verProto_data = ELEMENT_VERPROTO_12;
+ }
+
+ if (verDTD_data == NULL || verProto_data == NULL) {
+ err = SYNC_AGENT_PB_RETURN_NOT_DEFINED;
+ goto error;
+ }
+
+ WBXMLTreeNode *verdtd_node = sync_agent_add_child_text_node(binder,
+ synchdr_node, verDTD, verDTD_data, strlen(verDTD_data));
+ if (verdtd_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *verProto_node = sync_agent_add_child_text_node(binder,
+ synchdr_node, verProto, verProto_data, strlen(verProto_data));
+ if (verProto_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ /* session ID */
+ WBXMLTreeNode *sessionID_node = NULL;
+ if (pSyncHdr->session_id != NULL)
+ sessionID_node = sync_agent_add_child_text_node(binder, synchdr_node, ELEMENT_SESSIONID, pSyncHdr->session_id, strlen(pSyncHdr->session_id));
+ else
+ sessionID_node = sync_agent_add_child_node(binder, synchdr_node, ELEMENT_SESSIONID);
+
+ if (sessionID_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ /* msgID */
+ char *msgID_data = g_strdup_printf("%u", pSyncHdr->message_id);
+ if (msgID_data == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *msgID_node = sync_agent_add_child_text_node(binder,
+ synchdr_node, ELEMENT_MSGID, msgID_data, strlen(msgID_data));
+
+ if (msgID_data != NULL)
+ free(msgID_data);
+
+ if (msgID_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *target_node = sync_agent_add_child_node(binder,
+ synchdr_node, ELEMENT_TARGET);
+ if (target_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ err = __append_location_to_wbxml_node(pSyncHdr->target, binder, target_node);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto error;
+ }
+
+ WBXMLTreeNode *source_node = sync_agent_add_child_node(binder,
+ synchdr_node, ELEMENT_SOURCE);
+ if (source_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ err = __append_location_to_wbxml_node(pSyncHdr->source, binder, source_node);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto error;
+ }
+
+ if (pSyncHdr->response_uri != NULL) {
+ WBXMLTreeNode *respuri_node = sync_agent_add_child_text_node(binder,
+ synchdr_node, ELEMENT_RESPURI, pSyncHdr->response_uri, strlen(pSyncHdr->response_uri));
+ if (respuri_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ if (pSyncHdr->no_response) {
+ WBXMLTreeNode *noResponse_node = sync_agent_add_child_node(binder,
+ synchdr_node, ELEMENT_NORESP);
+ if (noResponse_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ if (pSyncHdr->cred != NULL) {
+ err = __append_cred_to_wbxml_node(pSyncHdr->cred, binder, synchdr_node);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto error;
+ }
+ }
+
+ char *meta = ELEMENT_META;
+ if (pSyncHdr->max_msg_size != 0 || pSyncHdr->max_obj_size != 0) {
+ WBXMLTreeNode *meta_node = sync_agent_add_child_node(binder,
+ synchdr_node, meta);
+ if (meta_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ unsigned int maxmsgsize = pSyncHdr->max_msg_size;
+ unsigned int maxobjsize = pSyncHdr->max_obj_size;
+
+ if (maxmsgsize != 0) {
+ char *str_maxmsgsize = g_strdup_printf("%u", maxmsgsize);
+ if (str_maxmsgsize == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *maxmsgsize_node = sync_agent_add_child_text_node(binder,
+ meta_node, ELEMENT_MAXMSGSIZE, str_maxmsgsize, strlen(str_maxmsgsize));
+ if (str_maxmsgsize != NULL)
+ free(str_maxmsgsize);
+
+ if (maxmsgsize_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ if (maxobjsize != 0) {
+ char *str_maxobjsize = g_strdup_printf("%u", maxobjsize);
+ if (str_maxobjsize == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *maxobjsize_node = sync_agent_add_child_text_node(binder,
+ meta_node, ELEMENT_MAXOBJSIZE, str_maxobjsize, strlen(str_maxobjsize));
+ if (str_maxobjsize != NULL)
+ free(str_maxobjsize);
+
+ if (maxobjsize_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+ }
+
+ *wbxml_dom_node = synchdr_node;
+ synchdr_node = NULL;
+
+ error:
+
+ if (synchdr_node != NULL)
+ sync_agent_destroy_wbxml_node(synchdr_node);
+
+ _INNER_FUNC_EXIT;
+ return err;
+}
+
+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)
+{
+ _INNER_FUNC_ENTER;
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+ WBXMLTreeNode *final_node = sync_agent_create_node(binder, "Final");
+ if (final_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ *wbxml_dom_node = final_node;
+
+ error:
+ _INNER_FUNC_EXIT;
+ return err;
+
+}
+
+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)
+{
+ _INNER_FUNC_ENTER;
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+ WBXMLTreeNode *syncbody_node = sync_agent_create_node(binder, ELEMENT_SYNCBODY);
+ if (syncbody_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ *wbxml_dom_node = syncbody_node;
+
+ error:
+ _INNER_FUNC_EXIT;
+ return err;
+}
+
+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)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if(content == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "content is NULL");
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+ status_s *pStatus = (status_s *) content;
+
+ command_type_e type = pStatus->type;
+
+ char *str_cmdID = NULL;
+ char *str_msgRef = NULL;
+ char *str_cmdRef = NULL;
+
+ WBXMLTreeNode *status_node = sync_agent_create_node(binder, ELEMENT_STATUS);
+ if (status_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ unsigned int cmdID = pStatus->cmd_id;
+ str_cmdID = g_strdup_printf("%u", cmdID);
+ if (str_cmdID == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *cmdid_node = sync_agent_add_child_text_node(binder,
+ status_node, ELEMENT_CMDID, str_cmdID, strlen(str_cmdID));
+ if (cmdid_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ unsigned int msgRef = pStatus->msg_ref;
+ str_msgRef = g_strdup_printf("%u", msgRef);
+ if (str_msgRef == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *msgref_node = sync_agent_add_child_text_node(binder,
+ status_node, ELEMENT_MSGREF, str_msgRef, strlen(str_msgRef));
+ if (msgref_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ unsigned int cmdRef = pStatus->cmd_ref;
+ str_cmdRef = g_strdup_printf("%u", cmdRef);
+ if (str_cmdRef == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *cmdref_node = sync_agent_add_child_text_node(binder,
+ status_node, ELEMENT_CMDREF, str_cmdRef, strlen(str_cmdRef));
+ if (cmdref_node == NULL) {
+ goto error;
+ }
+
+ char *str_command = NULL;
+ switch (type) {
+ case COMMAND_TYPE_ALERT:
+ {
+ str_command = ELEMENT_ALERT;
+ }
+ break;
+ case COMMAND_TYPE_SYNC_START:
+ {
+ str_command = ELEMENT_SYNC;
+ }
+ break;
+ case COMMAND_TYPE_PUT:
+ {
+ str_command = ELEMENT_PUT;
+ }
+ break;
+ case COMMAND_TYPE_HEADER:
+ {
+ str_command = ELEMENT_SYNCHDR;
+ }
+ break;
+ case COMMAND_TYPE_ADD:
+ {
+ str_command = ELEMENT_ADD;
+ }
+ break;
+ case COMMAND_TYPE_REPLACE:
+ {
+ str_command = ELEMENT_REPLACE;
+ }
+ break;
+ case COMMAND_TYPE_DELETE:
+ {
+ str_command = ELEMENT_DELETE;
+ }
+ break;
+ case COMMAND_TYPE_MAP:
+ {
+ str_command = ELEMENT_MAP;
+ }
+ break;
+ case COMMAND_TYPE_GET:
+ {
+ str_command = ELEMENT_GET;
+ }
+ break;
+ case COMMAND_TYPE_RESULTS:
+ {
+ str_command = ELEMENT_RESULTS;
+ }
+ break;
+ default:
+ break;
+ }
+
+ if (str_command == NULL) {
+ err = SYNC_AGENT_PB_RETURN_NOT_DEFINED;
+ goto error;
+ }
+
+ WBXMLTreeNode *command_node = sync_agent_add_child_text_node(binder,
+ status_node, ELEMENT_CMD, str_command, strlen(str_command));
+ if (command_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ if (pStatus->target_ref != NULL) {
+ WBXMLTreeNode *targetref_node = sync_agent_add_child_text_node(binder,
+ status_node, ELEMENT_TARGETREF, pStatus->target_ref->loc_uri, strlen(pStatus->target_ref->loc_uri));
+ if (targetref_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ if (pStatus->source_ref != NULL) {
+ WBXMLTreeNode *sourceref_node = sync_agent_add_child_text_node(binder,
+ status_node, ELEMENT_SOURCEREF, pStatus->source_ref->loc_uri, strlen(pStatus->source_ref->loc_uri));
+ if (sourceref_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ if (pStatus->cred != NULL) {
+ err = __append_cred_to_wbxml_node(pStatus->cred, binder, status_node);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto error;
+ }
+ }
+
+ if (pStatus->chal != NULL) {
+ /*TODO chal */
+ }
+
+ WBXMLTreeNode *data_node = sync_agent_add_child_text_node(binder,
+ status_node, ELEMENT_DATA, pStatus->data, strlen(pStatus->data));
+ if (data_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ if (type == COMMAND_TYPE_ALERT) {
+ if (pStatus->item != NULL) {
+ WBXMLTreeNode *item_node = sync_agent_add_child_node(binder,
+ status_node, ELEMENT_ITEM);
+ if (item_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *item_data_node = sync_agent_add_child_node(binder,
+ item_node, ELEMENT_DATA);
+ if (item_data_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *item_data_Anchor_node = sync_agent_add_child_node(binder,
+ item_data_node, ELEMENT_ANCHOR);
+ if (item_data_Anchor_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ if (pStatus->item->anchor != NULL) {
+ WBXMLTreeNode *item_data_Anchor_Next_node = sync_agent_add_child_text_node(binder,
+ item_data_Anchor_node, ELEMENT_NEXT, pStatus->item->anchor->next_anchor,
+ strlen(pStatus->item->anchor->next_anchor));
+
+ if (item_data_Anchor_Next_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+ }
+ }
+
+ *wbxml_dom_node = status_node;
+ status_node = NULL;
+
+ error:
+
+ if (status_node != NULL)
+ sync_agent_destroy_wbxml_node(status_node);
+
+ if (str_cmdID != NULL)
+ free(str_cmdID);
+
+ if (str_cmdRef != NULL)
+ free(str_cmdRef);
+
+ if (str_msgRef != NULL)
+ free(str_msgRef);
+
+ _INNER_FUNC_EXIT;
+ return err;
+}
+
+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)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if(content == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "content is NULL");
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+ char *str_cmdID = NULL;
+ char *str_alert_type = NULL;
+
+ WBXMLTreeNode *alert_node = NULL;
+
+ command_s *pCommand = (command_s *) content;
+
+ command_alert_private_s *pAlert = (command_alert_private_s *) (&(pCommand->private));
+ if (pAlert == NULL) {
+ err = SYNC_AGENT_PB_RETURN_NOT_DEFINED;
+ goto error;
+ }
+
+ if (pAlert->type == ALERT_UNKNOWN) {
+ /* error case */
+ err = SYNC_AGENT_PB_RETURN_INVALID_INPUT_PARAMETER;
+ goto error;
+ }
+
+ alert_node = sync_agent_create_node(binder, ELEMENT_ALERT);
+ if (alert_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ str_cmdID = g_strdup_printf("%u", pCommand->cmd_id);
+ if (str_cmdID == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *cmdid_node = sync_agent_add_child_text_node(binder,
+ alert_node, ELEMENT_CMDID, str_cmdID, strlen(str_cmdID));
+ if (cmdid_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ if (pCommand->no_resp) {
+ WBXMLTreeNode *noResp_node = sync_agent_add_child_node(binder,
+ alert_node, ELEMENT_NORESP);
+ if (noResp_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ if (pCommand->cred != NULL) {
+ err = __append_cred_to_wbxml_node(pCommand->cred, binder, alert_node);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto error;
+ }
+ }
+
+ str_alert_type = g_strdup_printf("%u", pAlert->type);
+ if (str_alert_type == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *data_node = sync_agent_add_child_text_node(binder,
+ alert_node, ELEMENT_DATA, str_alert_type, strlen(str_alert_type));
+ if (data_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ /* item */
+ if (pCommand->source != NULL && pCommand->target != NULL) {
+ WBXMLTreeNode *item_node = sync_agent_add_child_node(binder,
+ alert_node, ELEMENT_ITEM);
+ if (item_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *target_node = sync_agent_add_child_node(binder,
+ item_node, ELEMENT_TARGET);
+ if (target_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ err = __append_location_to_wbxml_node(pCommand->target, binder, target_node);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto error;
+ }
+
+ WBXMLTreeNode *source_node = sync_agent_add_child_node(binder,
+ item_node, ELEMENT_SOURCE);
+ if (source_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ err = __append_location_to_wbxml_node(pCommand->source, binder, source_node);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto error;
+ }
+
+ if (pAlert->anchor != NULL) {
+ err = __append_anchor_to_wbxml_node(pAlert->anchor, binder, item_node);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto error;
+ }
+ }
+ }
+
+ *wbxml_dom_node = alert_node;
+ alert_node = NULL;
+
+ error:
+
+ if (alert_node != NULL)
+ sync_agent_destroy_wbxml_node(alert_node);
+
+ if (str_cmdID != NULL)
+ free(str_cmdID);
+
+ if (str_alert_type != NULL)
+ free(str_alert_type);
+
+ _INNER_FUNC_EXIT;
+ return err;
+}
+
+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)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if(content == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "content is NULL");
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+ char *str_cmdID = NULL;
+ char *str_cmdRef = NULL;
+ char *str_msgRef = NULL;
+ WBXMLTreeNode *results_node = NULL;
+
+ command_s *pCommand = (command_s *) content;
+ command_results_private_s *pResults = (command_results_private_s *) (&(pCommand->private));
+ if (pResults == NULL) {
+ err = SYNC_AGENT_PB_RETURN_NOT_DEFINED;
+ goto error;
+ }
+
+ if (pResults->item == NULL) {
+ err = SYNC_AGENT_PB_RETURN_NOT_DEFINED;
+ goto error;
+ }
+
+ char *content_type = (pResults->item)->content_type;
+ if (content_type == NULL) {
+ /* error case */
+ err = SYNC_AGENT_PB_RETURN_NOT_DEFINED;
+ goto error;
+ }
+
+ results_node = sync_agent_create_node(binder, ELEMENT_RESULTS);
+ if (results_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ str_cmdID = g_strdup_printf("%u", pCommand->cmd_id);
+ if (str_cmdID != NULL) {
+ WBXMLTreeNode *cmdid_node = sync_agent_add_child_text_node(binder,
+ results_node, ELEMENT_CMDID, str_cmdID, strlen(str_cmdID));
+ if (cmdid_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ if (pResults->msg_ref) {
+ str_msgRef = g_strdup_printf("%u", pResults->msg_ref);
+ if (str_msgRef == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *msgref_node = sync_agent_add_child_text_node(binder,
+ results_node, ELEMENT_MSGREF, str_msgRef, strlen(str_msgRef));
+ if (msgref_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ str_cmdRef = g_strdup_printf("%u", pResults->cmd_ref);
+ if (str_cmdRef == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *msgref_node = sync_agent_add_child_text_node(binder,
+ results_node, ELEMENT_CMDREF, str_cmdRef, strlen(str_cmdRef));
+ if (msgref_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ if (content_type != NULL) {
+ WBXMLTreeNode *meta_node = sync_agent_add_child_node(binder,
+ results_node, ELEMENT_META);
+ if (meta_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *type_node = sync_agent_add_child_text_node(binder,
+ meta_node, ELEMENT_TYPE, content_type, strlen(content_type));
+ if (type_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ if (pResults->target_ref != NULL) {
+ WBXMLTreeNode *targetref_node = sync_agent_add_child_text_node(binder,
+ results_node, ELEMENT_TARGETREF, pResults->target_ref->loc_uri, strlen(pResults->target_ref->loc_uri));
+ if (targetref_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ *wbxml_dom_node = results_node;
+ results_node = NULL;
+
+ error:
+
+ if (results_node != NULL)
+ sync_agent_destroy_wbxml_node(results_node);
+
+ if (str_cmdID != NULL)
+ free(str_cmdID);
+
+ if (str_cmdRef != NULL)
+ free(str_cmdRef);
+
+ if (str_msgRef != NULL)
+ free(str_msgRef);
+
+ _INNER_FUNC_EXIT;
+ return err;
+}
+
+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)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if(content == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "content is NULL");
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+ char *str_cmdID = NULL;
+ WBXMLTreeNode *put_node = NULL;
+
+ command_s *pCommand = (command_s *) content;
+ command_access_private_s *pAccess = (command_access_private_s *) (&(pCommand->private));
+ if (pAccess == NULL) {
+ err = SYNC_AGENT_PB_RETURN_NOT_DEFINED;
+ goto error;
+ }
+
+ char *content_type = (pAccess->item)->content_type;
+ if (content_type == NULL) {
+ /* error case */
+ err = SYNC_AGENT_PB_RETURN_NOT_DEFINED;
+ goto error;
+ }
+
+ put_node = sync_agent_create_node(binder, ELEMENT_PUT);
+ if (put_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ str_cmdID = g_strdup_printf("%u", pCommand->cmd_id);
+ if (str_cmdID == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *cmdid_node = sync_agent_add_child_text_node(binder,
+ put_node, ELEMENT_CMDID, str_cmdID, strlen(str_cmdID));
+ if (cmdid_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ if (pCommand->no_resp) {
+ WBXMLTreeNode *noResp_node = sync_agent_add_child_node(binder,
+ put_node, ELEMENT_NORESP);
+ if (noResp_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ if (pCommand->cred != NULL) {
+ err = __append_cred_to_wbxml_node(pCommand->cred, binder, put_node);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto error;
+ }
+ }
+
+ if (content_type != NULL) {
+ WBXMLTreeNode *meta_node = sync_agent_add_child_node(binder,
+ put_node, ELEMENT_META);
+ if (meta_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *type_node = sync_agent_add_child_text_node(binder,
+ meta_node, ELEMENT_TYPE, content_type, strlen(content_type));
+ if (type_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ *wbxml_dom_node = put_node;
+ put_node = NULL;
+
+ error:
+
+ if (put_node != NULL)
+ sync_agent_destroy_wbxml_node(put_node);
+
+ if (str_cmdID != NULL)
+ free(str_cmdID);
+
+ _INNER_FUNC_EXIT;
+ return err;
+}
+
+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)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if(content == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "content is NULL");
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+ char *str_cmdID = NULL;
+ WBXMLTreeNode *get_node = NULL;
+
+ command_s *pCommand = (command_s *) content;
+ command_access_private_s *pAccess = (command_access_private_s *) (&(pCommand->private));
+ if (pAccess == NULL) {
+ err = SYNC_AGENT_PB_RETURN_NOT_DEFINED;
+ goto error;
+ }
+
+ if (pAccess->item == NULL) {
+ err = SYNC_AGENT_PB_RETURN_NOT_DEFINED;
+ goto error;
+ }
+
+ char *content_type = (pAccess->item)->content_type;
+ if (content_type == NULL) {
+ /* error case */
+ err = SYNC_AGENT_PB_RETURN_NOT_DEFINED;
+ goto error;
+ }
+
+ get_node = sync_agent_create_node(binder, ELEMENT_GET);
+
+ str_cmdID = g_strdup_printf("%u", pCommand->cmd_id);
+ if (str_cmdID == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *cmdid_node = sync_agent_add_child_text_node(binder,
+ get_node, ELEMENT_CMDID, str_cmdID, strlen(str_cmdID));
+ if (cmdid_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ if (pCommand->no_resp) {
+ WBXMLTreeNode *noResp_node = sync_agent_add_child_node(binder,
+ get_node, ELEMENT_NORESP);
+ if (noResp_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ if (pCommand->cred != NULL) {
+ err = __append_cred_to_wbxml_node(pCommand->cred, binder, get_node);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto error;
+ }
+ }
+
+ if (content_type != NULL) {
+ WBXMLTreeNode *meta_node = sync_agent_add_child_node(binder,
+ get_node, ELEMENT_META);
+ if (meta_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *type_node = sync_agent_add_child_text_node(binder,
+ meta_node, ELEMENT_TYPE, content_type, strlen(content_type));
+ if (type_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ if (pAccess->item != NULL) {
+ WBXMLTreeNode *item_node = sync_agent_add_child_node(binder,
+ get_node, ELEMENT_ITEM);
+ if (item_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *target_node = sync_agent_add_child_node(binder,
+ item_node, ELEMENT_TARGET);
+ if (target_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ err = __append_location_to_wbxml_node(pAccess->item->target, binder, target_node);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto error;
+ }
+ }
+
+ *wbxml_dom_node = get_node;
+ get_node = NULL;
+
+ error:
+
+ if (get_node != NULL)
+ sync_agent_destroy_wbxml_node(get_node);
+
+ if (str_cmdID != NULL)
+ free(str_cmdID);
+
+ _INNER_FUNC_EXIT;
+ return err;
+}
+
+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)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if(content == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "content is NULL");
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+ command_s *pCommand = (command_s *) content;
+
+ char *str_cmdID = NULL;
+ char *numChanged_str = NULL;
+ char *str_freemem = NULL;
+ char *str_freeid = NULL;
+
+ WBXMLTreeNode *sync_node = sync_agent_create_node(binder, ELEMENT_SYNC);
+ if (sync_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ str_cmdID = g_strdup_printf("%u", pCommand->cmd_id);
+ if (str_cmdID == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *cmdid_node = sync_agent_add_child_text_node(binder,
+ sync_node, ELEMENT_CMDID, str_cmdID, strlen(str_cmdID));
+ if (cmdid_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ if (pCommand->no_resp) {
+ WBXMLTreeNode *noResp_node = sync_agent_add_child_node(binder,
+ sync_node, ELEMENT_NORESP);
+ if (noResp_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ if (pCommand->cred != NULL) {
+ err = __append_cred_to_wbxml_node(pCommand->cred, binder, sync_node);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto error;
+ }
+ }
+
+ if (pCommand->source != NULL && pCommand->target != NULL) {
+ WBXMLTreeNode *target_node = sync_agent_add_child_node(binder,
+ sync_node, ELEMENT_TARGET);
+ if (target_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ err = __append_location_to_wbxml_node(pCommand->target, binder, target_node);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto error;
+ }
+
+ WBXMLTreeNode *source_node = sync_agent_add_child_node(binder,
+ sync_node, ELEMENT_SOURCE);
+ if (source_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ err = __append_location_to_wbxml_node(pCommand->source, binder, source_node);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto error;
+ }
+
+ }
+
+ /* Mem */
+ if (pCommand->private.sync.mem != NULL) {
+ WBXMLTreeNode *meta_node = sync_agent_add_child_node(binder, sync_node, ELEMENT_META);
+ if (meta_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *mem_node = sync_agent_add_child_node(binder, meta_node, ELEMENT_MEM);
+ if (mem_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ if (pCommand->private.sync.mem->sharedmem) {
+ WBXMLTreeNode *sharedmem_node = sync_agent_add_child_node(binder, mem_node, ELEMENT_SHAREDMEM);
+ if (sharedmem_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ if (pCommand->private.sync.mem->free_mem) {
+ str_freemem = g_strdup_printf("%u", pCommand->private.sync.mem->free_mem);
+ WBXMLTreeNode *freemem_node = sync_agent_add_child_text_node(binder,
+ mem_node, ELEMENT_FREEMEM, str_freemem, strlen(str_freemem));
+ if (freemem_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ if (pCommand->private.sync.mem->free_id) {
+ str_freeid = g_strdup_printf("%u", pCommand->private.sync.mem->free_id);
+ WBXMLTreeNode *freeid_node = sync_agent_add_child_text_node(binder,
+ mem_node, ELEMENT_FREEID, str_freeid, strlen(str_freeid));
+ if (freeid_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+ }
+
+ if (pCommand->private.sync.has_num_changed) {
+ numChanged_str = g_strdup_printf("%u", pCommand->private.sync.num_changed);
+ if (numChanged_str == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *numberOfChanges_node = sync_agent_add_child_text_node(binder,
+ sync_node, ELEMENT_NUMBEROFCHANGES, numChanged_str, strlen(numChanged_str));
+ if (numberOfChanges_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ *wbxml_dom_node = sync_node;
+ sync_node = NULL;
+
+ error:
+
+ if (sync_node != NULL)
+ sync_agent_destroy_wbxml_node(sync_node);
+
+ if (str_cmdID != NULL)
+ free(str_cmdID);
+
+ if (numChanged_str != NULL)
+ free(numChanged_str);
+
+ if (str_freemem != NULL)
+ free(str_freemem);
+
+ _INNER_FUNC_EXIT;
+ return err;
+}
+
+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)
+{
+ _INNER_FUNC_ENTER;
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+ _EXTERN_FUNC_EXIT;
+
+ return err;
+}
+
+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)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if(content == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "content is NULL");
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+ char *str_cmdID = NULL;
+ char *str_size = NULL;
+ WBXMLTreeNode *add_node = NULL;
+
+ command_s *pCommand = (command_s *) content;
+
+ command_change_private_s *pChange = (command_change_private_s *) (&(pCommand->private));
+ if (pChange == NULL) {
+ err = SYNC_AGENT_PB_RETURN_NOT_DEFINED;
+ goto error;
+ }
+
+ add_node = sync_agent_create_node(binder, ELEMENT_ADD);
+ if (add_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ str_cmdID = g_strdup_printf("%u", pCommand->cmd_id);
+ if (str_cmdID == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *cmdid_node = sync_agent_add_child_text_node(binder,
+ add_node, ELEMENT_CMDID, str_cmdID, strlen(str_cmdID));
+ if (cmdid_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ if (pCommand->no_resp) {
+ WBXMLTreeNode *noResp_node = sync_agent_add_child_node(binder,
+ add_node, ELEMENT_NORESP);
+ if (noResp_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ if (pCommand->cred != NULL) {
+ err = __append_cred_to_wbxml_node(pCommand->cred, binder, add_node);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto error;
+ }
+ }
+
+ GList *Iter = NULL;
+ item_s *item = NULL;
+ for (Iter = pChange->items; Iter != NULL; Iter = g_list_next(Iter)) {
+ item = (Iter->data);
+
+ WBXMLTreeNode *item_node = sync_agent_add_child_node(binder,
+ add_node, ELEMENT_ITEM);
+ if (item_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ if (item->source != NULL) {
+ WBXMLTreeNode *source_node = sync_agent_add_child_node(binder,
+ item_node, ELEMENT_SOURCE);
+ if (source_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ err = __append_location_to_wbxml_node(item->source, binder, source_node);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto error;
+ }
+ }
+
+ if (item->target != NULL) {
+ WBXMLTreeNode *target_node = sync_agent_add_child_node(binder,
+ item_node, ELEMENT_TARGET);
+ if (target_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ err = __append_location_to_wbxml_node(item->target, binder, target_node);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto error;
+ }
+ }
+
+ if (item->content_type != NULL) {
+ WBXMLTreeNode *meta_node = sync_agent_add_child_node(binder,
+ item_node, ELEMENT_META);
+ if (meta_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *type_node = sync_agent_add_child_text_node(binder,
+ meta_node, ELEMENT_TYPE, item->content_type, strlen(item->content_type));
+ if (type_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ if (item->more_data) {
+ if (item->size) {
+ str_size = g_strdup_printf("%u", item->size);
+ if (str_size == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *size_node = sync_agent_add_child_text_node(binder,
+ meta_node, ELEMENT_SIZE, str_size, strlen(str_size));
+ if (size_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+ }
+ }
+
+ if (item->data_type == ITEM_DATA) {
+ if (item->private.data != NULL) {
+ WBXMLTreeNode *data_node = sync_agent_add_child_cdata_node(binder,
+ item_node, ELEMENT_DATA, item->private.data, strlen(item->private.data));
+ if (data_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+ }
+
+ if (item->more_data) {
+ WBXMLTreeNode *moredata_node = sync_agent_add_child_node(binder,
+ item_node, ELEMENT_MOREDATA);
+ if (moredata_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+ }
+
+ *wbxml_dom_node = add_node;
+ add_node = NULL;
+
+ error:
+
+ if (add_node != NULL)
+ sync_agent_destroy_wbxml_node(add_node);
+
+ if (str_cmdID != NULL)
+ free(str_cmdID);
+
+ if (str_size != NULL)
+ free(str_size);
+
+ _EXTERN_FUNC_EXIT;
+ return err;
+}
+
+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)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if(content == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "content is NULL");
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+ char *str_cmdID = NULL;
+ char *str_size = NULL;
+ WBXMLTreeNode *replace_node = NULL;
+
+ command_s *pCommand = (command_s *) content;
+
+ command_change_private_s *pChange = (command_change_private_s *) (&(pCommand->private));
+
+ if (pChange == NULL) {
+ err = SYNC_AGENT_PB_RETURN_NOT_DEFINED;
+ goto error;
+ }
+
+ replace_node = sync_agent_create_node(binder, ELEMENT_REPLACE);
+ if (replace_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ str_cmdID = g_strdup_printf("%u", pCommand->cmd_id);
+ if (str_cmdID == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *cmdid_node = sync_agent_add_child_text_node(binder,
+ replace_node, ELEMENT_CMDID, str_cmdID, strlen(str_cmdID));
+ if (cmdid_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ if (pCommand->no_resp) {
+ WBXMLTreeNode *noResp_node = sync_agent_add_child_node(binder,
+ replace_node, ELEMENT_NORESP);
+ if (noResp_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ if (pCommand->cred != NULL) {
+ err = __append_cred_to_wbxml_node(pCommand->cred, binder, replace_node);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto error;
+ }
+ }
+
+ GList *Iter = NULL;
+ item_s *item = NULL;
+ for (Iter = pChange->items; Iter != NULL; Iter = g_list_next(Iter)) {
+ item = (Iter->data);
+
+ WBXMLTreeNode *item_node = sync_agent_add_child_node(binder,
+ replace_node, ELEMENT_ITEM);
+ if (item_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ if (item->source != NULL) {
+ WBXMLTreeNode *source_node = sync_agent_add_child_node(binder,
+ item_node, ELEMENT_SOURCE);
+ if (source_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ err = __append_location_to_wbxml_node(item->source, binder, source_node);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto error;
+ }
+ }
+
+ if (item->target != NULL) {
+ WBXMLTreeNode *target_node = sync_agent_add_child_node(binder,
+ item_node, ELEMENT_TARGET);
+ if (target_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ err = __append_location_to_wbxml_node(item->target, binder, target_node);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto error;
+ }
+ }
+
+ if (item->content_type != NULL) {
+ WBXMLTreeNode *meta_node = sync_agent_add_child_node(binder,
+ item_node, ELEMENT_META);
+ if (meta_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *type_node = sync_agent_add_child_text_node(binder,
+ meta_node, ELEMENT_TYPE, item->content_type, strlen(item->content_type));
+ if (type_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ if (item->more_data) {
+ if (item->size) {
+ str_size = g_strdup_printf("%u", item->size);
+ if (str_size == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *size_node = sync_agent_add_child_text_node(binder,
+ meta_node, ELEMENT_SIZE, str_size, strlen(str_size));
+ if (size_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+ }
+ }
+
+ if (item->data_type == ITEM_DATA) {
+ if (item->private.data != NULL) {
+ WBXMLTreeNode *data_node = sync_agent_add_child_cdata_node(binder,
+ item_node, ELEMENT_DATA, item->private.data, strlen(item->private.data));
+ if (data_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+ }
+
+ if (item->more_data) {
+ WBXMLTreeNode *moredata_node = sync_agent_add_child_node(binder,
+ item_node, ELEMENT_MOREDATA);
+ if (moredata_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ }
+
+ *wbxml_dom_node = replace_node;
+ replace_node = NULL;
+
+ error:
+
+ if (replace_node != NULL)
+ sync_agent_destroy_wbxml_node(replace_node);
+
+ if (str_cmdID != NULL)
+ free(str_cmdID);
+
+ if (str_size != NULL)
+ free(str_size);
+
+ _EXTERN_FUNC_EXIT;
+ return err;
+}
+
+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)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if(content == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "content is NULL");
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+ char *str_cmdID = NULL;
+ char *str_size = NULL;
+ WBXMLTreeNode *delete_node = NULL;
+
+ command_s *pCommand = (command_s *) content;
+
+ command_change_private_s *pChange = (command_change_private_s *) (&(pCommand->private));
+ if (pChange == NULL) {
+ err = SYNC_AGENT_PB_RETURN_NOT_DEFINED;
+ goto error;
+ }
+
+ delete_node = sync_agent_create_node(binder, ELEMENT_DELETE);
+ if (delete_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ str_cmdID = g_strdup_printf("%u", pCommand->cmd_id);
+ if (str_cmdID == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *cmdid_node = sync_agent_add_child_text_node(binder,
+ delete_node, ELEMENT_CMDID, str_cmdID, strlen(str_cmdID));
+ if (cmdid_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ if (pCommand->no_resp) {
+ WBXMLTreeNode *noResp_node = sync_agent_add_child_node(binder,
+ delete_node, ELEMENT_NORESP);
+ if (noResp_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ /*TODO Archive */
+ /*TODO sftDel */
+
+ if (pCommand->cred != NULL) {
+ err = __append_cred_to_wbxml_node(pCommand->cred, binder, delete_node);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto error;
+ }
+ }
+
+ GList *Iter = NULL;
+ item_s *item = NULL;
+ for (Iter = pCommand->private.change.items; Iter != NULL; Iter = g_list_next(Iter)) {
+ item = (Iter->data);
+
+ WBXMLTreeNode *item_node = sync_agent_add_child_node(binder,
+ delete_node, ELEMENT_ITEM);
+ if (item_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ if (item->source != NULL) {
+ WBXMLTreeNode *source_node = sync_agent_add_child_node(binder,
+ item_node, ELEMENT_SOURCE);
+ if (source_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ err = __append_location_to_wbxml_node(item->source, binder, source_node);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto error;
+ }
+ }
+
+ if (item->target != NULL) {
+ WBXMLTreeNode *target_node = sync_agent_add_child_node(binder,
+ item_node, ELEMENT_TARGET);
+ if (target_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ err = __append_location_to_wbxml_node(item->target, binder, target_node);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto error;
+ }
+ }
+
+ if (item->content_type != NULL) {
+ WBXMLTreeNode *meta_node = sync_agent_add_child_node(binder,
+ item_node, ELEMENT_META);
+ if (meta_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *type_node = sync_agent_add_child_text_node(binder,
+ meta_node, ELEMENT_TYPE, item->content_type, strlen(item->content_type));
+ if (type_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ if (item->size) {
+ str_size = g_strdup_printf("%u", item->size);
+ if (str_size == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *size_node = sync_agent_add_child_text_node(binder,
+ meta_node, ELEMENT_SIZE, str_size, strlen(str_size));
+ if (size_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+ }
+ }
+
+ *wbxml_dom_node = delete_node;
+ delete_node = NULL;
+
+ error:
+
+ if (delete_node != NULL)
+ sync_agent_destroy_wbxml_node(delete_node);
+
+ if (str_cmdID != NULL)
+ free(str_cmdID);
+
+ if (str_size != NULL)
+ free(str_size);
+
+ _EXTERN_FUNC_EXIT;
+ return err;
+}
+
+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)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if(content == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "content is NULL");
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+ char *str_cmdID = NULL;
+
+ command_s *pCommand = (command_s *) content;
+
+ WBXMLTreeNode *map_node = sync_agent_create_node(binder, ELEMENT_MAP);
+ if (map_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ str_cmdID = g_strdup_printf("%u", pCommand->cmd_id);
+ if (str_cmdID == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *cmdid_node = sync_agent_add_child_text_node(binder,
+ map_node, ELEMENT_CMDID, str_cmdID, strlen(str_cmdID));
+ if (cmdid_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ if (pCommand->source != NULL && pCommand->target != NULL) {
+ WBXMLTreeNode *target_node = sync_agent_add_child_node(binder,
+ map_node, ELEMENT_TARGET);
+ if (target_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ err = __append_location_to_wbxml_node(pCommand->target, binder, target_node);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto error;
+ }
+
+ WBXMLTreeNode *source_node = sync_agent_add_child_node(binder,
+ map_node, ELEMENT_SOURCE);
+ if (source_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ err = __append_location_to_wbxml_node(pCommand->source, binder, source_node);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto error;
+ }
+ }
+
+ if (pCommand->cred != NULL) {
+ err = __append_cred_to_wbxml_node(pCommand->cred, binder, map_node);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto error;
+ }
+ }
+
+ GList *iter = NULL;
+ item_s *item = NULL;
+ for (iter = pCommand->private.map.items; iter != NULL; iter = g_list_next(iter)) {
+ item = iter->data;
+ WBXMLTreeNode *mapItem_node = sync_agent_add_child_node(binder,
+ map_node, ELEMENT_MAPITEM);
+ if (mapItem_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ if (item->source != NULL && item->target != NULL) {
+ WBXMLTreeNode *item_target_node = sync_agent_add_child_node(binder,
+ mapItem_node, ELEMENT_TARGET);
+ if (item_target_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ err = __append_location_to_wbxml_node(item->target, binder, item_target_node);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto error;
+ }
+
+ WBXMLTreeNode *item_source_node = sync_agent_add_child_node(binder,
+ mapItem_node, ELEMENT_SOURCE);
+ if (item_source_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ err = __append_location_to_wbxml_node(item->source, binder, item_source_node);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto error;
+ }
+ }
+ }
+
+ *wbxml_dom_node = map_node;
+ map_node = NULL;
+
+ error:
+
+ if (map_node != NULL)
+ sync_agent_destroy_wbxml_node(map_node);
+
+ if (str_cmdID != NULL)
+ free(str_cmdID);
+
+ _EXTERN_FUNC_EXIT;
+ return err;
+}
+
+static protocol_version_e __get_oma_ds_protocol_version(char *verdtd)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if(verdtd == NULL, VERSION_UNKNOWN, "verdtd is NULL");
+
+ protocol_version_e protocol_version = VERSION_UNKNOWN;
+ if (strcmp(verdtd, ELEMENT_VERDRD_12) == 0) {
+ protocol_version = VERSION_12;
+ } else if (strcmp(verdtd, ELEMENT_VERDRD_11) == 0) {
+ protocol_version = VERSION_11;
+ } else if (strcmp(verdtd, ELEMENT_VERDRD_10) == 0) {
+ protocol_version = VERSION_10;
+ }
+
+ _INNER_FUNC_EXIT;
+ return protocol_version;
+}
+
+static devinf_version_e __get_oma_ds_devInf_version(char *verdtd)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if(verdtd == NULL, DEVINF_VERSION_UNKNOWN, "verdtd is NULL");
+
+ devinf_version_e devInf_version = DEVINF_VERSION_UNKNOWN;
+ if (strcmp(verdtd, ELEMENT_VERDRD_12) == 0) {
+ devInf_version = DEVINF_VERSION_12;
+ } else if (strcmp(verdtd, ELEMENT_VERDRD_11) == 0) {
+ devInf_version = DEVINF_VERSION_11;
+ } else if (strcmp(verdtd, ELEMENT_VERDRD_10) == 0) {
+ devInf_version = DEVINF_VERSION_10;
+ }
+
+ _INNER_FUNC_EXIT;
+ return devInf_version;
+}
+
+static devinf_devtyp_e __get_oma_ds_devInf_device_type(char *dev_type)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if(dev_type == NULL, DEVINF_DEVTYPE_UNKNOWN, "dev_type is NULL");
+
+ devinf_devtyp_e device_type = DEVINF_DEVTYPE_UNKNOWN;
+ if (strcmp(dev_type, ELEMENT_PAGER) == 0) {
+ device_type = DEVINF_DEVTYPE_PAGER;
+ } else if (strcmp(dev_type, ELEMENT_HANDHELD) == 0) {
+ device_type = DEVINF_DEVTYPE_HANDHELD;
+ } else if (strcmp(dev_type, ELEMENT_PDA) == 0) {
+ device_type = DEVINF_DEVTYPE_PDA;
+ } else if (strcmp(dev_type, ELEMENT_PHONE) == 0) {
+ device_type = DEVINF_DEVTYPE_PHONE;
+ } else if (strcmp(dev_type, ELEMENT_SMARTPHONE) == 0) {
+ device_type = DEVINF_DEVTYPE_SMARTPHONE;
+ } else if (strcmp(dev_type, ELEMENT_SERVER) == 0) {
+ device_type = DEVINF_DEVTYPE_SERVER;
+ } else if (strcmp(dev_type, ELEMENT_WORKSTATION) == 0) {
+ device_type = DEVINF_DEVTYPE_WORKSTATION;
+ }
+
+ _INNER_FUNC_EXIT;
+ return device_type;
+}
+
+static devinf_content_type_s *__get_devinf_contenttype(WBXMLTreeNode * node)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if(node == NULL, NULL, "node is NULL");
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+ devinf_content_type_s *devinf_content_type = NULL;
+
+ devinf_content_type = (devinf_content_type_s *) calloc(1, sizeof(devinf_content_type_s));
+ if (devinf_content_type == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ _DEBUG_ERROR("devinf_content_type is null");
+ goto return_part;
+ }
+
+ /* get first child */
+ WBXMLTreeNode *child = node->children;
+ for (; child != NULL && child->type != WBXML_TREE_ELEMENT_NODE; child = child->next) {
+ }
+
+ const char *first_child_name = NULL;
+ if (child != NULL) {
+ first_child_name = (const char *)wbxml_tag_get_xml_name(child->name);
+ if (strcmp(first_child_name, ELEMENT_CTTYPE) == 0) {
+ char *ctType = NULL;
+ err = sync_agent_get_text_from_node(child, &ctType);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ if (ctType != NULL)
+ devinf_content_type->ct_type = strdup(ctType);
+ } else {
+ /* error */
+ goto return_part;
+ }
+
+ /* get second child */
+ child = child->next;
+ for (; child != NULL && child->type != WBXML_TREE_ELEMENT_NODE; child = child->next) {
+ }
+
+ if (child != NULL) {
+ const char *second_child_name = NULL;
+ second_child_name = (const char *)wbxml_tag_get_xml_name(child->name);
+ if (strcmp(second_child_name, ELEMENT_VERCT) == 0) {
+ char *verCT = NULL;
+ err = sync_agent_get_text_from_node(child, &verCT);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ if (verCT != NULL)
+ devinf_content_type->verct = strdup(verCT);
+ } else {
+ /* error */
+ goto return_part;
+ }
+ }
+ }
+
+ _INNER_FUNC_EXIT;
+ return devinf_content_type;
+
+ return_part:
+
+ /* for prevent */
+ if (devinf_content_type != NULL)
+ free(devinf_content_type);
+
+ _INNER_FUNC_EXIT;
+ return NULL;
+
+}
+
+static location_s *_get_location(WBXMLTreeNode * node)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if(node == NULL, NULL, "node is NULL");
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+ location_s *location = NULL;
+
+ WBXMLTreeNode *child = NULL;
+
+ char *locURI = NULL;
+ char *locName = NULL;
+
+ /* get first child : required LocURI */
+ child = node->children;
+ for (; child != NULL && child->type != WBXML_TREE_ELEMENT_NODE; child = child->next) {
+ }
+
+ const char *first_child_name = NULL;
+ if (child != NULL) {
+ first_child_name = (const char *)wbxml_tag_get_xml_name(child->name);
+ _DEBUG_TRACE("child_name = %s", first_child_name);
+ if (strcmp(first_child_name, ELEMENT_LOCURI) == 0) {
+ err = sync_agent_get_text_from_node(child, &locURI);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ } else {
+ /* error */
+ goto return_part;
+ }
+
+ /* get second child : optional LocName */
+ child = child->next;
+ for (; child != NULL && child->type != WBXML_TREE_ELEMENT_NODE; child = child->next) {
+ }
+
+ if (child != NULL) {
+ const char *second_child_name = NULL;
+ second_child_name = (const char *)wbxml_tag_get_xml_name(child->name);
+ _DEBUG_TRACE("child_name = %s", second_child_name);
+ if (strcmp(second_child_name, ELEMENT_LOCNAME) == 0) {
+ err = sync_agent_get_text_from_node(child, &locName);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ } else {
+ /* error */
+ goto return_part;
+ }
+ }
+
+ sa_error_type_e error = create_location(locURI, locName, &location);
+ if (error != SA_INTERNAL_OK) {
+ _DEBUG_ERROR("create_location() failed !, error = %d", error);
+ goto return_part;
+ }
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return location;
+
+ return_part:
+
+ _EXTERN_FUNC_EXIT;
+ return NULL;
+}
+
+static anchor_s *_get_anchor(WBXMLTreeNode * node)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if(node == NULL, NULL, "node is NULL");
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+ anchor_s *anchor = NULL;
+
+ WBXMLTreeNode *child = NULL;
+
+ char *lastAnchor = NULL;
+ char *nextAnchor = NULL;
+ /* get first child : optional lastAnchor */
+ child = node->children;
+ for (; child != NULL && child->type != WBXML_TREE_ELEMENT_NODE; child = child->next) {
+ }
+
+ const char *first_child_name = NULL;
+ if (child != NULL) {
+ first_child_name = (const char *)wbxml_tag_get_xml_name(child->name);
+ _DEBUG_TRACE("child_name = %s", first_child_name);
+ if (strcmp(first_child_name, ELEMENT_LAST) == 0) {
+ err = sync_agent_get_text_from_node(child, &lastAnchor);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ child = child->next;
+ for (; child != NULL && child->type != WBXML_TREE_ELEMENT_NODE; child = child->next) {
+ }
+ } else if (strcmp(first_child_name, ELEMENT_NEXT) == 0) {
+ err = sync_agent_get_text_from_node(child, &nextAnchor);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ child = NULL;
+ }
+
+ /* get second child : required nextAnchor */
+ if (child != NULL) {
+ const char *second_child_name = NULL;
+ second_child_name = (const char *)wbxml_tag_get_xml_name(child->name);
+ _DEBUG_TRACE("child_name = %s", second_child_name);
+ if (strcmp(second_child_name, ELEMENT_NEXT) == 0) {
+ err = sync_agent_get_text_from_node(child, &nextAnchor);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ } else {
+ /* error */
+ goto return_part;
+ }
+ }
+
+ sa_error_type_e error = create_anchor(lastAnchor, nextAnchor, &anchor);
+ if (error != SA_INTERNAL_OK) {
+ _DEBUG_ERROR("create_anchor() failed !, error = %d", error);
+ goto return_part;
+ }
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return anchor;
+
+ return_part:
+
+ _EXTERN_FUNC_EXIT;
+ return NULL;
+}
+
+static cred_s *__get_cred(WBXMLTreeNode * node)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if(node == NULL, NULL, "node is NULL");
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+ cred_s *cred = NULL;
+
+ char *data = NULL;
+ char *type = NULL;
+ char *format = NULL;
+
+ WBXMLTreeNode *child = NULL;
+
+ for (child = node->children; child != NULL; child = child->next) {
+ if (child->type != WBXML_TREE_ELEMENT_NODE)
+ continue;
+
+ const char *child_xml_name = NULL;
+ child_xml_name = (const char *)wbxml_tag_get_xml_name(child->name);
+
+ if (strcmp(child_xml_name, ELEMENT_META) == 0) {
+ WBXMLTreeNode *grand_child = child->children;
+
+ const char *grand_child_xml_name = NULL;
+ grand_child_xml_name = (const char *)wbxml_tag_get_xml_name(grand_child->name);
+
+ if (strcmp(grand_child_xml_name, ELEMENT_TYPE) == 0) {
+ err = sync_agent_get_text_from_node(grand_child, &type);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ _DEBUG_VERBOSE("Type = [%s]", type);
+ } else if (strcmp(grand_child_xml_name, ELEMENT_FORMAT) == 0) {
+ err = sync_agent_get_text_from_node(grand_child, &format);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ _DEBUG_VERBOSE("Type = [%s]", format);
+ }
+ } else if (strcmp(child_xml_name, ELEMENT_DATA) == 0) {
+ err = sync_agent_get_text_from_node(child, &data);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ _DEBUG_VERBOSE("Data = [%s]", data);
+ }
+
+ }
+
+ cred = create_cred_with_data(convert_auth_type(type), data);
+
+ format_type_e formatType = FORMAT_TYPE_UNKNOWN;
+ if (format != NULL) {
+ if (strcmp(format, ELEMENT_B64) == 0)
+ formatType = FORMAT_TYPE_BASE64;
+ }
+
+ set_cred_format_type(cred, formatType);
+
+ _INNER_FUNC_EXIT;
+ return cred;
+
+ return_part:
+
+ _INNER_FUNC_EXIT;
+ return NULL;
+}
+
+static chal_s *_get_chal(WBXMLTreeNode * node)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if(node == NULL, NULL, "node is NULL");
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+ chal_s *pChal = (chal_s *) calloc(1, sizeof(chal_s));
+ if (pChal == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ _DEBUG_ERROR("pChal is null");
+ goto return_part;
+ }
+
+ WBXMLTreeNode *chal_child = node->children;
+
+ WBXMLTreeNode *meta_child = NULL;
+
+ for (meta_child = chal_child->children; meta_child != NULL; meta_child = meta_child->next) {
+ if (meta_child->type != WBXML_TREE_ELEMENT_NODE)
+ continue;
+
+ const char *meta_child_xml_name = NULL;
+ meta_child_xml_name = (const char *)wbxml_tag_get_xml_name(meta_child->name);
+
+ if (strcmp(meta_child_xml_name, ELEMENT_TYPE) == 0) {
+ char *type = NULL;
+ err = sync_agent_get_text_from_node(meta_child, &type);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ _DEBUG_TRACE("Type = [%s]", type);
+
+ pChal->type = convert_auth_type(type);
+ } else if (strcmp(meta_child_xml_name, ELEMENT_FORMAT) == 0) {
+ char *format = NULL;
+ err = sync_agent_get_text_from_node(meta_child, &format);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ _DEBUG_TRACE("Format = [%s]", format);
+
+ pChal->format = convert_format_type(format);
+ } else if (strcmp(meta_child_xml_name, ELEMENT_NEXTNONCE) == 0) {
+ char *nextnonce = NULL;
+ unsigned int nonce_len = 0;
+ err = sync_agent_get_binary_from_node(meta_child, &nextnonce, &nonce_len);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ _DEBUG_TRACE("NextNonce = [%s]", nextnonce);
+ if (pChal->format == FORMAT_TYPE_BASE64) {
+ if (nextnonce != NULL)
+ pChal->nonce_b64 = strdup(nextnonce);
+ } else {
+ pChal->nonce_plain = (char *)malloc(nonce_len + 1);
+ if (pChal->nonce_plain == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ memcpy(pChal->nonce_plain, nextnonce, nonce_len);
+ pChal->nonce_plain[nonce_len] = '\0';
+ }
+
+ pChal->nonce_length = nonce_len;
+ }
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return pChal;
+
+ return_part:
+
+ if (pChal != NULL)
+ free_chal(pChal);
+
+ _EXTERN_FUNC_EXIT;
+ return NULL;
+}
+
+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)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if(wbxml_dom_node == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "wbxml_dom_node is NULL");
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+ /* get data from dom tree */
+ devinf_s *pDevInf = (devinf_s *) calloc(1, sizeof(devinf_s));
+ if (pDevInf == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ _DEBUG_ERROR("pDevInf is null");
+ goto return_part;
+ }
+
+ WBXMLTreeNode *child = NULL;
+
+ for (child = wbxml_dom_node->children; child != NULL; child = child->next) {
+ if (child->type != WBXML_TREE_ELEMENT_NODE)
+ continue;
+
+ const char *child_xml_name = NULL;
+ child_xml_name = (const char *)wbxml_tag_get_xml_name(child->name);
+
+ if (strcmp(child_xml_name, ELEMENT_VERDTD) == 0) {
+ char *verdtd = NULL;
+ err = sync_agent_get_text_from_node(child, &verdtd);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ _DEBUG_TRACE("VerDTD = [%s]", verdtd);
+
+ pDevInf->version = __get_oma_ds_devInf_version(verdtd);
+ } else if (strcmp(child_xml_name, ELEMENT_MAN) == 0) {
+ char *man = NULL;
+ err = sync_agent_get_text_from_node(child, &man);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ _DEBUG_TRACE("Man = [%s]", man);
+ if (man != NULL)
+ pDevInf->manufacturer = strdup(man);
+ } else if (strcmp(child_xml_name, ELEMENT_MOD) == 0) {
+ char *mod = NULL;
+ err = sync_agent_get_text_from_node(child, &mod);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ _DEBUG_TRACE("Mod = [%s]", mod);
+ if (mod != NULL)
+ pDevInf->model = strdup(mod);
+ } else if (strcmp(child_xml_name, ELEMENT_OEM) == 0) {
+ char *oem = NULL;
+ err = sync_agent_get_text_from_node(child, &oem);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ _DEBUG_TRACE("OEM = [%s]", oem);
+ if (oem != NULL)
+ pDevInf->oem = strdup(oem);
+ } else if (strcmp(child_xml_name, ELEMENT_FWV) == 0) {
+ char *fwv = NULL;
+ err = sync_agent_get_text_from_node(child, &fwv);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ _DEBUG_TRACE("FwV = [%s]", fwv);
+ if (fwv != NULL)
+ pDevInf->firmware_version = strdup(fwv);
+ } else if (strcmp(child_xml_name, ELEMENT_SWV) == 0) {
+ char *swv = NULL;
+ err = sync_agent_get_text_from_node(child, &swv);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ _DEBUG_TRACE("SwV = [%s]", swv);
+ if (swv != NULL)
+ pDevInf->software_version = strdup(swv);
+ } else if (strcmp(child_xml_name, ELEMENT_HWV) == 0) {
+ char *hwv = NULL;
+ err = sync_agent_get_text_from_node(child, &hwv);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ _DEBUG_TRACE("HwV = [%s]", hwv);
+ if (hwv != NULL)
+ pDevInf->hardware_version = strdup(hwv);
+ } else if (strcmp(child_xml_name, ELEMENT_DEVID) == 0) {
+ char *devID = NULL;
+ err = sync_agent_get_text_from_node(child, &devID);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ _DEBUG_TRACE("DevID = [%s]", devID);
+ if (devID != NULL)
+ pDevInf->dev_id = strdup(devID);
+ } else if (strcmp(child_xml_name, ELEMENT_DEVTYP) == 0) {
+ char *devtyp = NULL;
+ err = sync_agent_get_text_from_node(child, &devtyp);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ _DEBUG_TRACE("DevTyp = [%s]", devtyp);
+
+ pDevInf->devtyp = __get_oma_ds_devInf_device_type(devtyp);
+ } else if (strcmp(child_xml_name, ELEMENT_UTC) == 0) {
+ _DEBUG_TRACE("UTC");
+ pDevInf->supports_utc = 1;
+ } else if (strcmp(child_xml_name, ELEMENT_SUPPORTLARGEOBJS) == 0) {
+ _DEBUG_TRACE("SupportLargeObjs");
+ pDevInf->supports_large_objs = 1;
+ } else if (strcmp(child_xml_name, ELEMENT_SUPPORTNUMBEROFCHANGES) == 0) {
+ _DEBUG_TRACE("SupportNumberOfChanges");
+ pDevInf->supports_number_of_changes = 1;
+ } else if (strcmp(child_xml_name, ELEMENT_DATASTORE) == 0) {
+
+ devinf_datastore_s *pDevInfDataStore = (devinf_datastore_s *) calloc(1, sizeof(devinf_datastore_s));
+ if (pDevInfDataStore == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ _DEBUG_ERROR("pDevInfDataStore is null");
+ goto return_part;
+ }
+
+ WBXMLTreeNode *datastore_child = NULL;
+
+ for (datastore_child = child->children; datastore_child != NULL; datastore_child = datastore_child->next) {
+ if (datastore_child->type != WBXML_TREE_ELEMENT_NODE)
+ continue;
+
+ const char *datastore_child_xml_name = NULL;
+ datastore_child_xml_name = (const char *)wbxml_tag_get_xml_name(datastore_child->name);
+
+ if (strcmp(datastore_child_xml_name, ELEMENT_SOURCEREF) == 0) {
+ char *sourceref = NULL;
+ err = sync_agent_get_text_from_node(datastore_child, &sourceref);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ if (pDevInfDataStore != NULL)
+ free(pDevInfDataStore);
+
+ goto return_part;
+ }
+ _DEBUG_TRACE("SourceRef = [%s]", sourceref);
+ if (sourceref != NULL)
+ pDevInfDataStore->source_ref = strdup(sourceref);
+ } else if (strcmp(datastore_child_xml_name, ELEMENT_DISPLAYNAME) == 0) {
+ char *displayname = NULL;
+ err = sync_agent_get_text_from_node(datastore_child, &displayname);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ if (pDevInfDataStore != NULL)
+ free(pDevInfDataStore);
+
+ goto return_part;
+ }
+ _DEBUG_TRACE("DisplayName = [%s]", displayname);
+ if (displayname != NULL)
+ pDevInfDataStore->display_name = strdup(displayname);
+ } else if (strcmp(datastore_child_xml_name, ELEMENT_MAXGUIDSIZE) == 0) {
+ char *maxguidsize = NULL;
+ err = sync_agent_get_text_from_node(datastore_child, &maxguidsize);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ if (pDevInfDataStore != NULL)
+ free(pDevInfDataStore);
+
+ goto return_part;
+ }
+ _DEBUG_TRACE("MaxGUIDSize = [%s]", maxguidsize);
+ if (maxguidsize != NULL)
+ pDevInfDataStore->max_guid_size = atoi(maxguidsize);
+ } else if (strcmp(datastore_child_xml_name, ELEMENT_RX_PREF) == 0) {
+ devinf_content_type_s *devinf_content_type = __get_devinf_contenttype(datastore_child);
+ if (devinf_content_type == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ if (pDevInfDataStore != NULL)
+ free(pDevInfDataStore);
+
+ goto return_part;
+ }
+ pDevInfDataStore->rx_pref = devinf_content_type;
+ } else if (strcmp(datastore_child_xml_name, ELEMENT_RX) == 0) {
+ devinf_content_type_s *devinf_content_type = __get_devinf_contenttype(datastore_child);
+ if (devinf_content_type == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ if (pDevInfDataStore != NULL)
+ free(pDevInfDataStore);
+
+ goto return_part;
+ }
+ pDevInfDataStore->rx = g_list_append(pDevInfDataStore->rx, devinf_content_type);
+ } else if (strcmp(datastore_child_xml_name, ELEMENT_TX_PREF) == 0) {
+ devinf_content_type_s *devinf_content_type = __get_devinf_contenttype(datastore_child);
+ if (devinf_content_type == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ if (pDevInfDataStore != NULL)
+ free(pDevInfDataStore);
+
+ goto return_part;
+ }
+ pDevInfDataStore->tx_pref = devinf_content_type;
+ } else if (strcmp(datastore_child_xml_name, ELEMENT_TX) == 0) {
+ devinf_content_type_s *devinf_content_type = __get_devinf_contenttype(datastore_child);
+ if (devinf_content_type == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ if (pDevInfDataStore != NULL)
+ free(pDevInfDataStore);
+
+ goto return_part;
+ }
+ pDevInfDataStore->tx = g_list_append(pDevInfDataStore->tx, devinf_content_type);
+ } else if (strcmp(datastore_child_xml_name, ELEMENT_CTCAP) == 0) {
+
+ devinf_ct_cap_s *pDevInfCtCap = (devinf_ct_cap_s *) calloc(1, sizeof(devinf_ct_cap_s));
+ if (pDevInfCtCap == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ _DEBUG_ERROR("pDevInfCtCap is null");
+ if (pDevInfDataStore != NULL)
+ free(pDevInfDataStore);
+
+ goto return_part;
+ }
+
+ devinf_content_type_s *devinf_content_type = NULL;
+ WBXMLTreeNode *ctcap_child = NULL;
+
+ for (ctcap_child = datastore_child->children; ctcap_child != NULL; ctcap_child = ctcap_child->next) {
+ if (ctcap_child->type != WBXML_TREE_ELEMENT_NODE)
+ continue;
+
+ const char *ctcap_child_xml_name = NULL;
+ ctcap_child_xml_name = (const char *)wbxml_tag_get_xml_name(ctcap_child->name);
+
+ if (strcmp(ctcap_child_xml_name, ELEMENT_CTTYPE) == 0) {
+ if (devinf_content_type == NULL) {
+ devinf_content_type = (devinf_content_type_s *) calloc(1, sizeof(devinf_content_type_s));
+ if (devinf_content_type == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ _DEBUG_ERROR("devinf_content_type is null");
+ if (pDevInfDataStore != NULL)
+ free(pDevInfDataStore);
+
+ if (pDevInfCtCap != NULL)
+ free(pDevInfCtCap);
+
+ goto return_part;
+ }
+ }
+
+ char *cttype = NULL;
+ err = sync_agent_get_text_from_node(ctcap_child, &cttype);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ if (pDevInfDataStore != NULL)
+ free(pDevInfDataStore);
+
+ if (pDevInfCtCap != NULL)
+ free(pDevInfCtCap);
+
+ if (devinf_content_type != NULL)
+ free(devinf_content_type);
+
+ goto return_part;
+ }
+ _DEBUG_TRACE("CTType = [%s]", cttype);
+ if (cttype != NULL)
+ devinf_content_type->ct_type = strdup(cttype);
+ } else if (strcmp(ctcap_child_xml_name, ELEMENT_VERCT) == 0) {
+ if (devinf_content_type == NULL) {
+ devinf_content_type = (devinf_content_type_s *) calloc(1, sizeof(devinf_content_type_s));
+ if (devinf_content_type == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ _DEBUG_ERROR("devinf_content_type is null");
+
+ if (pDevInfDataStore != NULL)
+ free(pDevInfDataStore);
+
+ if (pDevInfCtCap != NULL)
+ free(pDevInfCtCap);
+
+ if (devinf_content_type != NULL)
+ free(devinf_content_type);
+
+ goto return_part;
+ }
+ }
+
+ char *verct = NULL;
+ err = sync_agent_get_text_from_node(ctcap_child, &verct);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+
+ if (pDevInfDataStore != NULL)
+ free(pDevInfDataStore);
+
+ if (pDevInfCtCap != NULL)
+ free(pDevInfCtCap);
+
+ if (devinf_content_type != NULL)
+ free(devinf_content_type);
+
+ goto return_part;
+ }
+ _DEBUG_TRACE("VerCT = [%s]", verct);
+ if (verct != NULL)
+ devinf_content_type->verct = strdup(verct);
+ } else if (strcmp(ctcap_child_xml_name, ELEMENT_FIELDLEVEL) == 0) {
+ /*TODO fieldlevel */
+
+ } else if (strcmp(ctcap_child_xml_name, ELEMENT_PROPERTY) == 0) {
+
+ devinf_property_s *pDevInfProperty = (devinf_property_s *) calloc(1, sizeof(devinf_property_s));
+ if (pDevInfProperty == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ _DEBUG_ERROR("pDevInfProperty is null");
+
+ if (pDevInfDataStore != NULL)
+ free(pDevInfDataStore);
+
+ if (pDevInfCtCap != NULL)
+ free(pDevInfCtCap);
+
+ if (devinf_content_type != NULL)
+ free(devinf_content_type);
+
+ goto return_part;
+ }
+
+ WBXMLTreeNode *property_child = NULL;
+ for (property_child = ctcap_child->children; property_child != NULL; property_child = property_child->next) {
+ if (property_child->type != WBXML_TREE_ELEMENT_NODE)
+ continue;
+
+ const char *property_child_xml_name = NULL;
+ property_child_xml_name = (const char *)wbxml_tag_get_xml_name(property_child->name);
+
+ if (strcmp(property_child_xml_name, ELEMENT_PROPNAME) == 0) {
+ char *propname = NULL;
+ err = sync_agent_get_text_from_node(property_child, &propname);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+
+ if (pDevInfDataStore != NULL)
+ free(pDevInfDataStore);
+
+ if (pDevInfCtCap != NULL)
+ free(pDevInfCtCap);
+
+ if (devinf_content_type != NULL)
+ free(devinf_content_type);
+
+ if (pDevInfProperty != NULL)
+ free(pDevInfProperty);
+
+ goto return_part;
+ }
+ _DEBUG_TRACE("PropName = [%s]", propname);
+ if (propname != NULL)
+ pDevInfProperty->prop_name = strdup(propname);
+ } else if (strcmp(property_child_xml_name, ELEMENT_DATATYPE) == 0) {
+ char *datatype = NULL;
+ err = sync_agent_get_text_from_node(property_child, &datatype);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+
+ if (pDevInfDataStore != NULL)
+ free(pDevInfDataStore);
+
+ if (pDevInfCtCap != NULL)
+ free(pDevInfCtCap);
+
+ if (devinf_content_type != NULL)
+ free(devinf_content_type);
+
+ if (pDevInfProperty != NULL)
+ free(pDevInfProperty);
+
+ goto return_part;
+ }
+ _DEBUG_TRACE("DataType = [%s]", datatype);
+ if (datatype != NULL)
+ pDevInfProperty->data_type = strdup(datatype);
+ } else if (strcmp(property_child_xml_name, ELEMENT_MAXOCCUR) == 0) {
+ char *maxoccur = NULL;
+ err = sync_agent_get_text_from_node(property_child, &maxoccur);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+
+ if (pDevInfDataStore != NULL)
+ free(pDevInfDataStore);
+
+ if (pDevInfCtCap != NULL)
+ free(pDevInfCtCap);
+
+ if (devinf_content_type != NULL)
+ free(devinf_content_type);
+
+ if (pDevInfProperty != NULL)
+ free(pDevInfProperty);
+
+ goto return_part;
+ }
+ _DEBUG_TRACE("MaxOccur = [%s]", maxoccur);
+ if (maxoccur != NULL)
+ pDevInfProperty->max_occur = atoi(maxoccur);
+ } else if (strcmp(property_child_xml_name, ELEMENT_MAXSIZE) == 0) {
+ char *maxsize = NULL;
+ err = sync_agent_get_text_from_node(property_child, &maxsize);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+
+ if (pDevInfDataStore != NULL)
+ free(pDevInfDataStore);
+
+ if (pDevInfCtCap != NULL)
+ free(pDevInfCtCap);
+
+ if (devinf_content_type != NULL)
+ free(devinf_content_type);
+
+ if (pDevInfProperty != NULL)
+ free(pDevInfProperty);
+
+ goto return_part;
+ }
+ _DEBUG_TRACE("MaxSize = [%s]", maxsize);
+ if (maxsize != NULL)
+ pDevInfProperty->max_size = atoi(maxsize);
+ } else if (strcmp(property_child_xml_name, ELEMENT_NOTRUNCATE) == 0) {
+ _DEBUG_TRACE("NoTruncate");
+ pDevInfProperty->no_truncate = 1;
+ } else if (strcmp(property_child_xml_name, ELEMENT_VALENUM) == 0) {
+ char *valenum = NULL;
+ err = sync_agent_get_text_from_node(property_child, &valenum);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+
+ if (pDevInfDataStore != NULL)
+ free(pDevInfDataStore);
+
+ if (pDevInfCtCap != NULL)
+ free(pDevInfCtCap);
+
+ if (devinf_content_type != NULL)
+ free(devinf_content_type);
+
+ if (pDevInfProperty != NULL)
+ free(pDevInfProperty);
+
+ goto return_part;
+ }
+ _DEBUG_TRACE("ValEnum = [%s]", valenum);
+ if (valenum != NULL)
+ pDevInfProperty->val_enums = g_list_append(pDevInfProperty->val_enums, strdup(valenum));
+ } else if (strcmp(property_child_xml_name, ELEMENT_DISPLAYNAME) == 0) {
+ char *displayname = NULL;
+ err = sync_agent_get_text_from_node(property_child, &displayname);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+
+ if (pDevInfDataStore != NULL)
+ free(pDevInfDataStore);
+
+ if (pDevInfCtCap != NULL)
+ free(pDevInfCtCap);
+
+ if (devinf_content_type != NULL)
+ free(devinf_content_type);
+
+ if (pDevInfProperty != NULL)
+ free(pDevInfProperty);
+
+ goto return_part;
+ }
+ _DEBUG_TRACE("DisplayName = [%s]", displayname);
+ if (displayname != NULL)
+ pDevInfProperty->display_name = strdup(displayname);
+ } else if (strcmp(property_child_xml_name, ELEMENT_PROPPARAM) == 0) {
+
+ devinf_prop_param_s *pDevInfPropParam = (devinf_prop_param_s *) calloc(1, sizeof(devinf_prop_param_s));
+ if (pDevInfPropParam == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ _DEBUG_ERROR("pDevInfPropParam is null");
+
+ if (pDevInfDataStore != NULL)
+ free(pDevInfDataStore);
+
+ if (pDevInfCtCap != NULL)
+ free(pDevInfCtCap);
+
+ if (devinf_content_type != NULL)
+ free(devinf_content_type);
+
+ if (pDevInfProperty != NULL)
+ free(pDevInfProperty);
+
+ goto return_part;
+ }
+
+ WBXMLTreeNode *propparam_child = NULL;
+
+ for (propparam_child = property_child->children; propparam_child != NULL; propparam_child = propparam_child->next) {
+ if (propparam_child->type != WBXML_TREE_ELEMENT_NODE)
+ continue;
+
+ const char *propparam_child_xml_name = NULL;
+ propparam_child_xml_name = (const char *)wbxml_tag_get_xml_name(propparam_child->name);
+
+ if (strcmp(propparam_child_xml_name, ELEMENT_PARAMNAME) == 0) {
+ char *paramname = NULL;
+ err = sync_agent_get_text_from_node(propparam_child, &paramname);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+
+ if (pDevInfDataStore != NULL)
+ free(pDevInfDataStore);
+
+ if (pDevInfCtCap != NULL)
+ free(pDevInfCtCap);
+
+ if (devinf_content_type != NULL)
+ free(devinf_content_type);
+
+ if (pDevInfProperty != NULL)
+ free(pDevInfProperty);
+
+ goto return_part;
+ }
+ _DEBUG_TRACE("ParamName = [%s]", paramname);
+ if (paramname != NULL)
+ pDevInfPropParam->param_name = strdup(paramname);
+ } else if (strcmp(propparam_child_xml_name, ELEMENT_DATATYPE) == 0) {
+ char *datatype = NULL;
+ err = sync_agent_get_text_from_node(propparam_child, &datatype);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+
+ if (pDevInfDataStore != NULL)
+ free(pDevInfDataStore);
+
+ if (pDevInfCtCap != NULL)
+ free(pDevInfCtCap);
+
+ if (devinf_content_type != NULL)
+ free(devinf_content_type);
+
+ if (pDevInfProperty != NULL)
+ free(pDevInfProperty);
+
+ goto return_part;
+ }
+ _DEBUG_TRACE("DataType = [%s]", datatype);
+ if (datatype != NULL)
+ pDevInfPropParam->data_type = strdup(datatype);
+ } else if (strcmp(propparam_child_xml_name, ELEMENT_VALENUM) == 0) {
+ char *valenum = NULL;
+ err = sync_agent_get_text_from_node(propparam_child, &valenum);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+
+ if (pDevInfDataStore != NULL)
+ free(pDevInfDataStore);
+
+ if (pDevInfCtCap != NULL)
+ free(pDevInfCtCap);
+
+ if (devinf_content_type != NULL)
+ free(devinf_content_type);
+
+ if (pDevInfProperty != NULL)
+ free(pDevInfProperty);
+
+ goto return_part;
+ }
+ _DEBUG_TRACE("ValEnum = [%s]", valenum);
+ if (valenum != NULL)
+ pDevInfPropParam->val_enums = g_list_append(pDevInfPropParam->val_enums, strdup(valenum));
+ } else if (strcmp(propparam_child_xml_name, ELEMENT_DISPLAYNAME) == 0) {
+ char *displayname = NULL;
+ err = sync_agent_get_text_from_node(propparam_child, &displayname);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+
+ if (pDevInfDataStore != NULL)
+ free(pDevInfDataStore);
+
+ if (pDevInfCtCap != NULL)
+ free(pDevInfCtCap);
+
+ if (devinf_content_type != NULL)
+ free(devinf_content_type);
+
+ if (pDevInfProperty != NULL)
+ free(pDevInfProperty);
+
+ goto return_part;
+ }
+ _DEBUG_TRACE("DisplayName = [%s]", displayname);
+ if (displayname != NULL)
+ pDevInfPropParam->display_name = strdup(displayname);
+ }
+ }
+
+ pDevInfProperty->prop_params = g_list_append(pDevInfProperty->prop_params, pDevInfPropParam);
+ }
+ }
+
+ pDevInfCtCap->properties = g_list_append(pDevInfCtCap->properties, pDevInfProperty);
+ }
+ }
+ pDevInfCtCap->ct = devinf_content_type;
+ pDevInfDataStore->ct_caps = g_list_append(pDevInfDataStore->ct_caps, pDevInfCtCap);
+ } else if (strcmp(datastore_child_xml_name, ELEMENT_DSMEM) == 0) {
+
+ /*TODO DSMem */
+ } else if (strcmp(datastore_child_xml_name, ELEMENT_SUPPORTHIERARCHICALSYNC) == 0) {
+ _DEBUG_TRACE("SupportHierarchicalSync");
+ pDevInfDataStore->supports_hierarchical_sync = 1;
+ } else if (strcmp(datastore_child_xml_name, ELEMENT_SYNCCAP) == 0) {
+
+ WBXMLTreeNode *synccap_child = NULL;
+
+ for (synccap_child = datastore_child->children; synccap_child != NULL; synccap_child = synccap_child->next) {
+ if (synccap_child->type != WBXML_TREE_ELEMENT_NODE)
+ continue;
+
+ const char *synccap_child_xml_name = NULL;
+ synccap_child_xml_name = (const char *)wbxml_tag_get_xml_name(synccap_child->name);
+
+ if (strcmp(synccap_child_xml_name, ELEMENT_SYNCTYPE) == 0) {
+ char *synctype_str = NULL;
+ unsigned int synctype = 0;
+ err = sync_agent_get_text_from_node(synccap_child, &synctype_str);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+
+ if (pDevInfDataStore != NULL)
+ free(pDevInfDataStore);
+
+ goto return_part;
+ }
+ _DEBUG_TRACE("SyncType = [%s]", synctype_str);
+ if (synctype_str != NULL) {
+ synctype = atoi(synctype_str);
+ synctype = 1 << (synctype - 1);
+ }
+ /*DevInfSyncCap synccap = convert_devinf_synccap(synctype); */
+ set_devinf_datastore_sync_cap(pDevInfDataStore, synctype, 1);
+ }
+ }
+ } else if (strcmp(datastore_child_xml_name, ELEMENT_FILTER_RX) == 0) {
+ /*TODO filter-rx */
+ } else if (strcmp(datastore_child_xml_name, ELEMENT_FILTERCAP) == 0) {
+ /*TODO filtercap */
+ }
+ }
+ pDevInf->datastores = g_list_append(pDevInf->datastores, pDevInfDataStore);
+ }
+ }
+
+ return_part:
+ if (err == SYNC_AGENT_PB_RETURN_OK) {
+ *content = pDevInf;
+ } else {
+ _DEBUG_ERROR("error");
+ free_devinf(pDevInf);
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return err;
+}
+
+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)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if(wbxml_dom_node == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "wbxml_dom_node is NULL");
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+ /* get data from dom tree */
+ sync_hdr_s *pSyncHdr = (sync_hdr_s *) calloc(1, sizeof(sync_hdr_s));
+ if (pSyncHdr == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ _DEBUG_ERROR("pSyncHdr is null");
+ goto return_part;
+ }
+
+ WBXMLTreeNode *child = NULL;
+
+ for (child = wbxml_dom_node->children; child != NULL; child = child->next) {
+ if (child->type != WBXML_TREE_ELEMENT_NODE)
+ continue;
+
+ const char *child_xml_name = NULL;
+ child_xml_name = (const char *)wbxml_tag_get_xml_name(child->name);
+
+ if (strcmp(child_xml_name, ELEMENT_VERDTD) == 0) {
+ char *verdtd = NULL;
+ err = sync_agent_get_text_from_node(child, &verdtd);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ _DEBUG_TRACE("VerDTD = [%s]", verdtd);
+
+ pSyncHdr->version = __get_oma_ds_protocol_version(verdtd);
+ } else if (strcmp(child_xml_name, ELEMENT_SESSIONID) == 0) {
+ char *sessionID = NULL;
+ err = sync_agent_get_text_from_node(child, &sessionID);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ _DEBUG_TRACE("SessionID = [%s]", sessionID);
+
+ if (sessionID != NULL)
+ pSyncHdr->session_id = strdup(sessionID);
+ else
+ pSyncHdr->session_id = NULL;
+ } else if (strcmp(child_xml_name, ELEMENT_MSGID) == 0) {
+ char *msgID = NULL;
+ err = sync_agent_get_text_from_node(child, &msgID);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ _DEBUG_TRACE("MsgID = [%s]", msgID);
+ if (msgID != NULL)
+ pSyncHdr->message_id = atoi(msgID);
+ } else if (strcmp(child_xml_name, ELEMENT_TARGET) == 0) {
+ location_s *pTargetLocation = _get_location(child);
+ if (pTargetLocation == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ pSyncHdr->target = pTargetLocation;
+ } else if (strcmp(child_xml_name, ELEMENT_SOURCE) == 0) {
+ location_s *pSourceLocation = _get_location(child);
+ if (pSourceLocation == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ pSyncHdr->source = pSourceLocation;
+ } else if (strcmp(child_xml_name, ELEMENT_RESPURI) == 0) {
+ char *resp_uri = NULL;
+ err = sync_agent_get_text_from_node(child, &resp_uri);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ _DEBUG_TRACE("resp_uri = [%s]", resp_uri);
+ if (resp_uri != NULL)
+ pSyncHdr->response_uri = strdup(resp_uri);
+ } else if (strcmp(child_xml_name, ELEMENT_NORESP) == 0) {
+ _DEBUG_TRACE("noResp\n");
+ pSyncHdr->no_response = 1;
+ } else if (strcmp(child_xml_name, ELEMENT_CRED) == 0) {
+ _DEBUG_TRACE("Cred\n");
+ cred_s *cred = NULL;
+ cred = __get_cred(child);
+ if (cred == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ pSyncHdr->cred = cred;
+ } else if (strcmp(child_xml_name, ELEMENT_META) == 0) {
+
+ }
+ }
+
+ return_part:
+ if (err == SYNC_AGENT_PB_RETURN_OK) {
+ *content = pSyncHdr;
+ } else {
+ _DEBUG_ERROR("error");
+ free_sync_hdr(pSyncHdr);
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return err;
+}
+
+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)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if(wbxml_dom_node == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "wbxml_dom_node is NULL");
+ retvm_if(reverse_binder == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "reverse_binder is NULL");
+
+ sync_hdr_s *pSyncHdr = (sync_hdr_s *) sync_agent_get_user_data_from_reverse_protocol_binder(reverse_binder);
+ retvm_if(pSyncHdr == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "pSyncHdr is NULL");
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+ /* get data from dom tree */
+ command_s *pResults = (command_s *) calloc(1, sizeof(command_s));
+ if (pResults == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ _DEBUG_ERROR("pResults is null");
+ goto return_part;
+ }
+
+ pResults->type = COMMAND_TYPE_RESULTS;
+ pResults->msg_id = pSyncHdr->message_id;
+ pResults->ref_count = 1;
+
+ WBXMLTreeNode *child = NULL;
+
+ for (child = wbxml_dom_node->children; child != NULL; child = child->next) {
+ if (child->type != WBXML_TREE_ELEMENT_NODE)
+ continue;
+
+ const char *child_xml_name = NULL;
+ child_xml_name = (const char *)wbxml_tag_get_xml_name(child->name);
+
+ if (strcmp(child_xml_name, ELEMENT_CMDID) == 0) {
+ char *cmd_id = NULL;
+ err = sync_agent_get_text_from_node(child, &cmd_id);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ _DEBUG_TRACE("CmdID = [%s]", cmd_id);
+ if (cmd_id != NULL)
+ pResults->cmd_id = atoi(cmd_id);
+ } else if (strcmp(child_xml_name, ELEMENT_MSGREF) == 0) {
+ char *msg_ref = NULL;
+ err = sync_agent_get_text_from_node(child, &msg_ref);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ _DEBUG_TRACE("MsgRef = [%s]", msg_ref);
+ if (msg_ref != NULL)
+ pResults->private.results.msg_ref = atoi(msg_ref);
+ } else if (strcmp(child_xml_name, ELEMENT_CMDREF) == 0) {
+ char *cmd_ref = NULL;
+ err = sync_agent_get_text_from_node(child, &cmd_ref);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ _DEBUG_TRACE("MsgRef = [%s]", cmd_ref);
+ if (cmd_ref != NULL)
+ pResults->private.results.cmd_ref = atoi(cmd_ref);
+ } else if (strcmp(child_xml_name, ELEMENT_META) == 0) {
+
+ WBXMLTreeNode *grandchild = NULL;
+
+ for (grandchild = child->children; grandchild != NULL; grandchild = grandchild->next) {
+ if (grandchild->type != WBXML_TREE_ELEMENT_NODE)
+ continue;
+
+ const char *grandchild_xml_name = NULL;
+ grandchild_xml_name = (const char *)wbxml_tag_get_xml_name(grandchild->name);
+
+ if (strcmp(grandchild_xml_name, ELEMENT_TYPE) == 0) {
+ char *contentType = NULL;
+ err = sync_agent_get_text_from_node(grandchild, &contentType);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ _DEBUG_TRACE("Content Type = [%s]", contentType);
+ if (contentType != NULL)
+ pResults->private.results.type = strdup(contentType);
+ }
+ }
+ } else if (strcmp(child_xml_name, ELEMENT_TARGETREF) == 0) {
+ /*TODO targetRef */
+ } else if (strcmp(child_xml_name, ELEMENT_SOURCEREF) == 0) {
+ /*TODO sourceRef */
+ } else if (strcmp(child_xml_name, ELEMENT_ITEM) == 0) {
+ /*create item in results command */
+ item_s *item = create_item();
+ if (item == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ pResults->private.results.item = item;
+
+ WBXMLTreeNode *grandchild = NULL;
+
+ for (grandchild = child->children; grandchild != NULL; grandchild = grandchild->next) {
+ if (grandchild->type != WBXML_TREE_ELEMENT_NODE)
+ continue;
+
+ const char *grandchild_xml_name = NULL;
+ grandchild_xml_name = (const char *)wbxml_tag_get_xml_name(grandchild->name);
+
+ if (strcmp(grandchild_xml_name, ELEMENT_SOURCE) == 0) {
+ location_s *pSourceLocation = _get_location(grandchild);
+ if (pSourceLocation == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ pResults->private.results.item->source = pSourceLocation;
+ } else if (strcmp(grandchild_xml_name, ELEMENT_TARGET) == 0) {
+ location_s *pTargetLocation = _get_location(grandchild);
+ if (pTargetLocation == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ pResults->private.results.item->target = pTargetLocation;
+ } else if (strcmp(grandchild_xml_name, ELEMENT_DATA) == 0) {
+ /* TODO data */
+ }
+ }
+ }
+ }
+ return_part:
+ if (err == SYNC_AGENT_PB_RETURN_OK) {
+ *content = pResults;
+ } else {
+ _DEBUG_ERROR("error");
+ free_command(pResults);
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return err;
+}
+
+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)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if(wbxml_dom_node == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "wbxml_dom_node is NULL");
+ retvm_if(reverse_binder == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "reverse_binder is NULL");
+
+ sync_hdr_s *pSyncHdr = (sync_hdr_s *) sync_agent_get_user_data_from_reverse_protocol_binder(reverse_binder);
+ retvm_if(pSyncHdr == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "pSyncHdr is NULL");
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+ /* get data from dom tree */
+ command_s *pPut = (command_s *) calloc(1, sizeof(command_s));
+ if (pPut == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ _DEBUG_ERROR("pPut is null");
+ goto return_part;
+ }
+
+ pPut->type = COMMAND_TYPE_PUT;
+ pPut->msg_id = pSyncHdr->message_id;
+ pPut->ref_count = 1;
+
+ WBXMLTreeNode *child = NULL;
+
+ for (child = wbxml_dom_node->children; child != NULL; child = child->next) {
+ if (child->type != WBXML_TREE_ELEMENT_NODE)
+ continue;
+
+ const char *child_xml_name = NULL;
+ child_xml_name = (const char *)wbxml_tag_get_xml_name(child->name);
+
+ if (strcmp(child_xml_name, ELEMENT_CMDID) == 0) {
+ char *cmd_id = NULL;
+ err = sync_agent_get_text_from_node(child, &cmd_id);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ _DEBUG_TRACE("CmdID = [%s]", cmd_id);
+ if (cmd_id != NULL)
+ pPut->cmd_id = atoi(cmd_id);
+ } else if (strcmp(child_xml_name, ELEMENT_NORESP) == 0) {
+ _DEBUG_TRACE("NoResp");
+ pPut->no_resp = 1;
+ } else if (strcmp(child_xml_name, ELEMENT_CRED) == 0) {
+ _DEBUG_TRACE("Cred\n");
+ cred_s *cred = NULL;
+ cred = __get_cred(child);
+ if (cred == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ pPut->cred = cred;
+ } else if (strcmp(child_xml_name, ELEMENT_META) == 0) {
+ WBXMLTreeNode *grandchild = NULL;
+
+ for (grandchild = child->children; grandchild != NULL; grandchild = grandchild->next) {
+ if (grandchild->type != WBXML_TREE_ELEMENT_NODE)
+ continue;
+
+ const char *grandchild_xml_name = NULL;
+ grandchild_xml_name = (const char *)wbxml_tag_get_xml_name(grandchild->name);
+
+ if (strcmp(grandchild_xml_name, ELEMENT_TYPE) == 0) {
+ char *contentType = NULL;
+ err = sync_agent_get_text_from_node(grandchild, &contentType);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ _DEBUG_TRACE("Content Type = [%s]", contentType);
+ if (contentType != NULL)
+ pPut->private.access.type = strdup(contentType);
+ }
+ }
+ } else if (strcmp(child_xml_name, ELEMENT_ITEM) == 0) {
+ /*create item in put command */
+ item_s *item = create_item();
+ if (item == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ pPut->private.access.item = item;
+
+ WBXMLTreeNode *grandchild = NULL;
+
+ for (grandchild = child->children; grandchild != NULL; grandchild = grandchild->next) {
+ if (grandchild->type != WBXML_TREE_ELEMENT_NODE)
+ continue;
+
+ const char *grandchild_xml_name = NULL;
+ grandchild_xml_name = (const char *)wbxml_tag_get_xml_name(grandchild->name);
+
+ if (strcmp(grandchild_xml_name, ELEMENT_SOURCE) == 0) {
+ location_s *pSourceLocation = _get_location(grandchild);
+ if (pSourceLocation == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ pPut->private.access.item->source = pSourceLocation;
+ } else if (strcmp(grandchild_xml_name, ELEMENT_TARGET) == 0) {
+ location_s *pTargetLocation = _get_location(grandchild);
+ if (pTargetLocation == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ pPut->private.access.item->target = pTargetLocation;
+ } else if (strcmp(grandchild_xml_name, ELEMENT_DATA) == 0) {
+ /* TODO data */
+ }
+ }
+ }
+ }
+
+ return_part:
+ if (err == SYNC_AGENT_PB_RETURN_OK) {
+ *content = pPut;
+ } else {
+ _DEBUG_ERROR("error");
+ free_command(pPut);
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return err;
+}
+
+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)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if(wbxml_dom_node == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "wbxml_dom_node is NULL");
+ retvm_if(reverse_binder == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "reverse_binder is NULL");
+
+ sync_hdr_s *pSyncHdr = (sync_hdr_s *) sync_agent_get_user_data_from_reverse_protocol_binder(reverse_binder);
+ retvm_if(pSyncHdr == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "pSyncHdr is NULL");
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+ /* get data from dom tree */
+ command_s *pGet = (command_s *) calloc(1, sizeof(command_s));
+ if (pGet == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ _DEBUG_ERROR("pGet is null");
+ goto return_part;
+ }
+
+ pGet->type = COMMAND_TYPE_GET;
+ pGet->msg_id = pSyncHdr->message_id;
+ pGet->ref_count = 1;
+
+ WBXMLTreeNode *child = NULL;
+
+ for (child = wbxml_dom_node->children; child != NULL; child = child->next) {
+ if (child->type != WBXML_TREE_ELEMENT_NODE)
+ continue;
+
+ const char *child_xml_name = NULL;
+ child_xml_name = (const char *)wbxml_tag_get_xml_name(child->name);
+
+ if (strcmp(child_xml_name, ELEMENT_CMDID) == 0) {
+ char *cmd_id = NULL;
+ err = sync_agent_get_text_from_node(child, &cmd_id);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ _DEBUG_TRACE("CmdID = [%s]", cmd_id);
+ if (cmd_id != NULL)
+ pGet->cmd_id = atoi(cmd_id);
+ } else if (strcmp(child_xml_name, ELEMENT_NORESP) == 0) {
+ _DEBUG_TRACE("NoResp");
+ pGet->no_resp = 1;
+ } else if (strcmp(child_xml_name, ELEMENT_CRED) == 0) {
+ _DEBUG_TRACE("Cred\n");
+ cred_s *cred = NULL;
+ cred = __get_cred(child);
+ if (cred == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ pGet->cred = cred;
+ } else if (strcmp(child_xml_name, ELEMENT_META) == 0) {
+
+ WBXMLTreeNode *grandchild = NULL;
+
+ for (grandchild = child->children; grandchild != NULL; grandchild = grandchild->next) {
+ if (grandchild->type != WBXML_TREE_ELEMENT_NODE)
+ continue;
+
+ const char *grandchild_xml_name = NULL;
+ grandchild_xml_name = (const char *)wbxml_tag_get_xml_name(grandchild->name);
+
+ if (strcmp(grandchild_xml_name, ELEMENT_TYPE) == 0) {
+ char *contentType = NULL;
+ err = sync_agent_get_text_from_node(grandchild, &contentType);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ _DEBUG_TRACE("Content Type = [%s]", contentType);
+ if (contentType != NULL)
+ pGet->private.access.type = strdup(contentType);
+ }
+ }
+ } else if (strcmp(child_xml_name, ELEMENT_ITEM) == 0) {
+ /*create item in put command */
+ item_s *item = create_item();
+ if (item == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ pGet->private.access.item = item;
+
+ WBXMLTreeNode *grandchild = NULL;
+ for (grandchild = child->children; grandchild != NULL; grandchild = grandchild->next) {
+ if (grandchild->type != WBXML_TREE_ELEMENT_NODE)
+ continue;
+
+ const char *grandchild_xml_name = NULL;
+ grandchild_xml_name = (const char *)wbxml_tag_get_xml_name(grandchild->name);
+
+ if (strcmp(grandchild_xml_name, ELEMENT_SOURCE) == 0) {
+ location_s *pSourceLocation = _get_location(grandchild);
+ if (pSourceLocation == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ pGet->private.access.item->source = pSourceLocation;
+ } else if (strcmp(grandchild_xml_name, ELEMENT_TARGET) == 0) {
+ location_s *pTargetLocation = _get_location(grandchild);
+ if (pTargetLocation == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ pGet->private.access.item->target = pTargetLocation;
+ } else if (strcmp(grandchild_xml_name, ELEMENT_DATA) == 0) {
+ /* TODO data */
+ }
+ }
+ }
+ }
+
+ return_part:
+ if (err == SYNC_AGENT_PB_RETURN_OK) {
+ *content = pGet;
+ } else {
+ _DEBUG_ERROR("error");
+ free_command(pGet);
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return err;
+}
+
+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)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if(wbxml_dom_node == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "wbxml_dom_node is NULL");
+ retvm_if(reverse_binder == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "reverse_binder is NULL");
+
+ sync_hdr_s *pSyncHdr = (sync_hdr_s *) sync_agent_get_user_data_from_reverse_protocol_binder(reverse_binder);
+ retvm_if(pSyncHdr == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "pSyncHdr is NULL");
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+ /* get data from dom tree */
+ command_s *pAlert = (command_s *) calloc(1, sizeof(command_s));
+ if (pAlert == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ _DEBUG_ERROR("pAlert is null");
+ goto return_part;
+ }
+
+ pAlert->type = COMMAND_TYPE_ALERT;
+ pAlert->msg_id = pSyncHdr->message_id;
+ pAlert->ref_count = 1;
+
+ WBXMLTreeNode *child = NULL;
+
+ for (child = wbxml_dom_node->children; child != NULL; child = child->next) {
+ if (child->type != WBXML_TREE_ELEMENT_NODE)
+ continue;
+
+ const char *child_xml_name = NULL;
+ child_xml_name = (const char *)wbxml_tag_get_xml_name(child->name);
+
+ if (strcmp(child_xml_name, ELEMENT_CMDID) == 0) {
+ char *cmd_id = NULL;
+ err = sync_agent_get_text_from_node(child, &cmd_id);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ _DEBUG_TRACE("CmdID = [%s]", cmd_id);
+ if (cmd_id != NULL)
+ pAlert->cmd_id = atoi(cmd_id);
+ } else if (strcmp(child_xml_name, ELEMENT_NORESP) == 0) {
+ _DEBUG_TRACE("NoResp");
+ pAlert->no_resp = 1;
+ } else if (strcmp(child_xml_name, ELEMENT_CRED) == 0) {
+ _DEBUG_TRACE("Cred\n");
+ cred_s *cred = NULL;
+ cred = __get_cred(child);
+ if (cred == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ pAlert->cred = cred;
+ } else if (strcmp(child_xml_name, ELEMENT_DATA) == 0) {
+ char *data = NULL;
+ err = sync_agent_get_text_from_node(child, &data);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ _DEBUG_TRACE("Data = [%s]", data);
+ if (data != NULL)
+ pAlert->private.alert.type = atoi(data);
+ } else if (strcmp(child_xml_name, ELEMENT_ITEM) == 0) {
+ WBXMLTreeNode *grandchild = NULL;
+
+ for (grandchild = child->children; grandchild != NULL; grandchild = grandchild->next) {
+ if (grandchild->type != WBXML_TREE_ELEMENT_NODE)
+ continue;
+
+ const char *grandchild_xml_name = NULL;
+ grandchild_xml_name = (const char *)wbxml_tag_get_xml_name(grandchild->name);
+
+ if (strcmp(grandchild_xml_name, ELEMENT_SOURCE) == 0) {
+ location_s *pSourceLocation = _get_location(grandchild);
+ if (pSourceLocation == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ pAlert->source = pSourceLocation;
+ } else if (strcmp(grandchild_xml_name, ELEMENT_TARGET) == 0) {
+ location_s *pTargetLocation = _get_location(grandchild);
+ if (pTargetLocation == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ pAlert->target = pTargetLocation;
+ } else if (strcmp(grandchild_xml_name, ELEMENT_META) == 0) {
+
+ WBXMLTreeNode *grandgrandchild = NULL;
+ for (grandgrandchild = grandchild->children; grandgrandchild != NULL; grandgrandchild = grandgrandchild->next) {
+ if (grandgrandchild->type != WBXML_TREE_ELEMENT_NODE)
+ continue;
+
+ const char *grandgrandchild_xml_name = NULL;
+ grandgrandchild_xml_name = (const char *)wbxml_tag_get_xml_name(grandgrandchild->name);
+
+ if (strcmp(grandgrandchild_xml_name, ELEMENT_ANCHOR) == 0) {
+ anchor_s *anchor = _get_anchor(grandgrandchild);
+ if (anchor == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ pAlert->private.alert.anchor = anchor;
+ } else if (strcmp(grandgrandchild_xml_name, ELEMENT_MAXOBJSIZE) == 0) {
+ char *maxObjSize = NULL;
+ err = sync_agent_get_text_from_node(grandgrandchild, &maxObjSize);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ _DEBUG_TRACE("MaxObjSize = [%s]", maxObjSize);
+ if (maxObjSize != NULL)
+ pAlert->private.alert.max_obj_size = atoi(maxObjSize);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return_part:
+ if (err == SYNC_AGENT_PB_RETURN_OK) {
+ *content = pAlert;
+ } else {
+ _DEBUG_ERROR("error");
+ free_command(pAlert);
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return err;
+}
+
+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)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if(reverse_binder == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "reverse_binder is NULL");
+
+ sync_hdr_s *pSyncHdr = (sync_hdr_s *) sync_agent_get_user_data_from_reverse_protocol_binder(reverse_binder);
+ retvm_if(pSyncHdr == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "pSyncHdr is NULL");
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+ /* get data from dom tree */
+ command_s *pSyncEnd = (command_s *) calloc(1, sizeof(command_s));
+ if (pSyncEnd == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ _DEBUG_ERROR("pSyncEnd is null");
+ goto return_part;
+ }
+
+ pSyncEnd->type = COMMAND_TYPE_SYNC_END;;
+ pSyncEnd->msg_id = pSyncHdr->message_id;
+ pSyncEnd->ref_count = 1;
+
+ return_part:
+ if (err == SYNC_AGENT_PB_RETURN_OK) {
+ *content = pSyncEnd;
+ } else {
+ _DEBUG_ERROR("error");
+ free_command(pSyncEnd);
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return err;
+}
+
+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)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if(wbxml_dom_node == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "wbxml_dom_node is NULL");
+ retvm_if(reverse_binder == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "reverse_binder is NULL");
+
+ sync_hdr_s *pSyncHdr = (sync_hdr_s *) sync_agent_get_user_data_from_reverse_protocol_binder(reverse_binder);
+ retvm_if(pSyncHdr == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "pSyncHdr is NULL");
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+ /* get data from dom tree */
+ command_s *pSync = (command_s *) calloc(1, sizeof(command_s));
+ if (pSync == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ _DEBUG_ERROR("pSync is null");
+ goto return_part;
+ }
+
+ pSync->type = COMMAND_TYPE_SYNC_START;;
+ pSync->msg_id = pSyncHdr->message_id;
+ pSync->ref_count = 1;
+
+ WBXMLTreeNode *child = NULL;
+
+ for (child = wbxml_dom_node->children; child != NULL; child = child->next) {
+ if (child->type != WBXML_TREE_ELEMENT_NODE)
+ continue;
+
+ const char *child_xml_name = NULL;
+ child_xml_name = (const char *)wbxml_tag_get_xml_name(child->name);
+
+ if (strcmp(child_xml_name, ELEMENT_CMDID) == 0) {
+ char *cmd_id = NULL;
+ err = sync_agent_get_text_from_node(child, &cmd_id);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ _DEBUG_TRACE("CmdID = [%s]", cmd_id);
+ if (cmd_id != NULL)
+ pSync->cmd_id = atoi(cmd_id);
+ } else if (strcmp(child_xml_name, ELEMENT_NORESP) == 0) {
+ _DEBUG_TRACE("NoResp");
+ pSync->no_resp = 1;
+ } else if (strcmp(child_xml_name, ELEMENT_CRED) == 0) {
+ _DEBUG_TRACE("Cred\n");
+ cred_s *cred = NULL;
+ cred = __get_cred(child);
+ if (cred == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ pSync->cred = cred;
+ } else if (strcmp(child_xml_name, ELEMENT_TARGET) == 0) {
+ location_s *pTargetLocation = _get_location(child);
+ if (pTargetLocation == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ pSync->target = pTargetLocation;
+ } else if (strcmp(child_xml_name, ELEMENT_SOURCE) == 0) {
+ location_s *pSourceLocation = _get_location(child);
+ if (pSourceLocation == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ pSync->source = pSourceLocation;
+ } else if (strcmp(child_xml_name, ELEMENT_META) == 0) {
+ /*TODO meta */
+ } else if (strcmp(child_xml_name, ELEMENT_NUMBEROFCHANGES) == 0) {
+ char *numOfChanges = NULL;
+ err = sync_agent_get_text_from_node(child, &numOfChanges);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ _DEBUG_TRACE("NumberOfChanges = [%s]", numOfChanges);
+
+ pSync->private.sync.has_num_changed = 1;
+ if (numOfChanges != NULL)
+ pSync->private.sync.num_changed = atoi(numOfChanges);
+ }
+ }
+
+ return_part:
+ if (err == SYNC_AGENT_PB_RETURN_OK) {
+ *content = pSync;
+ } else {
+ _DEBUG_ERROR("error");
+ free_command(pSync);
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return err;
+}
+
+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)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if(wbxml_dom_node == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "wbxml_dom_node is NULL");
+ retvm_if(reverse_binder == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "reverse_binder is NULL");
+
+ sync_hdr_s *pSyncHdr = (sync_hdr_s *) sync_agent_get_user_data_from_reverse_protocol_binder(reverse_binder);
+ retvm_if(pSyncHdr == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "pSyncHdr is NULL");
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+ item_s *item = NULL;
+
+ /* get data from dom tree */
+ command_s *pAdd = (command_s *) calloc(1, sizeof(command_s));
+ if (pAdd == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ _DEBUG_ERROR("pAdd is null");
+ goto return_part;
+ }
+
+ pAdd->type = COMMAND_TYPE_ADD;;
+ pAdd->msg_id = pSyncHdr->message_id;
+ pAdd->private.change.type = CHANGE_ADD;
+ pAdd->ref_count = 1;
+
+ WBXMLTreeNode *child = NULL;
+
+ for (child = wbxml_dom_node->children; child != NULL; child = child->next) {
+ if (child->type != WBXML_TREE_ELEMENT_NODE)
+ continue;
+
+ const char *child_xml_name = NULL;
+ child_xml_name = (const char *)wbxml_tag_get_xml_name(child->name);
+
+ if (strcmp(child_xml_name, ELEMENT_CMDID) == 0) {
+ char *cmd_id = NULL;
+ err = sync_agent_get_text_from_node(child, &cmd_id);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ _DEBUG_TRACE("CmdID = [%s]", cmd_id);
+ if (cmd_id != NULL)
+ pAdd->cmd_id = atoi(cmd_id);
+ } else if (strcmp(child_xml_name, ELEMENT_NORESP) == 0) {
+ _DEBUG_TRACE("NoResp");
+ pAdd->no_resp = 1;
+ } else if (strcmp(child_xml_name, ELEMENT_CRED) == 0) {
+ _DEBUG_TRACE("Cred\n");
+ cred_s *cred = NULL;
+ cred = __get_cred(child);
+ if (cred == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ pAdd->cred = cred;
+ } else if (strcmp(child_xml_name, ELEMENT_META) == 0) {
+ WBXMLTreeNode *grandchild = NULL;
+
+ if (item == NULL) {
+ item = create_item();
+ if (item == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ }
+
+ for (grandchild = child->children; grandchild != NULL; grandchild = grandchild->next) {
+ if (grandchild->type != WBXML_TREE_ELEMENT_NODE)
+ continue;
+
+ const char *grandchild_xml_name = NULL;
+ grandchild_xml_name = (const char *)wbxml_tag_get_xml_name(grandchild->name);
+
+ if (strcmp(grandchild_xml_name, ELEMENT_TYPE) == 0) {
+ char *contentType = NULL;
+ err = sync_agent_get_text_from_node(grandchild, &contentType);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ _DEBUG_TRACE("Content Type = [%s]", contentType);
+ if (contentType != NULL)
+ item->content_type = strdup(contentType);
+ } else if (strcmp(grandchild_xml_name, ELEMENT_SIZE) == 0) {
+ char *size = NULL;
+ err = sync_agent_get_text_from_node(grandchild, &size);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ _DEBUG_TRACE("Size = [%s]", size);
+ if (size != NULL)
+ item->size = atoi(size);
+ }
+ }
+ } else if (strcmp(child_xml_name, ELEMENT_ITEM) == 0) {
+
+ if (item == NULL) {
+ item = create_item();
+ if (item == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ }
+
+ WBXMLTreeNode *grandchild = NULL;
+ for (grandchild = child->children; grandchild != NULL; grandchild = grandchild->next) {
+ if (grandchild->type != WBXML_TREE_ELEMENT_NODE)
+ continue;
+
+ const char *grandchild_xml_name = NULL;
+ grandchild_xml_name = (const char *)wbxml_tag_get_xml_name(grandchild->name);
+
+ if (strcmp(grandchild_xml_name, ELEMENT_SOURCE) == 0) {
+ location_s *pSourceLocation = _get_location(grandchild);
+ if (pSourceLocation == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ item->source = pSourceLocation;
+ } else if (strcmp(grandchild_xml_name, ELEMENT_TARGET) == 0) {
+ location_s *pTargetLocation = _get_location(grandchild);
+ if (pTargetLocation == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ item->target = pTargetLocation;
+ } else if (strcmp(grandchild_xml_name, ELEMENT_META) == 0) {
+ WBXMLTreeNode *grandgrandchild = NULL;
+
+ for (grandgrandchild = grandchild->children; grandgrandchild != NULL; grandgrandchild = grandgrandchild->next) {
+ if (grandgrandchild->type != WBXML_TREE_ELEMENT_NODE)
+ continue;
+
+ const char *grandgrandchild_xml_name = NULL;
+ grandgrandchild_xml_name = (const char *)wbxml_tag_get_xml_name(grandgrandchild->name);
+
+ if (strcmp(grandgrandchild_xml_name, ELEMENT_TYPE) == 0) {
+ char *contentType = NULL;
+ err = sync_agent_get_text_from_node(grandgrandchild, &contentType);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ _DEBUG_TRACE("Content Type = [%s]", contentType);
+ if (contentType != NULL)
+ item->content_type = strdup(contentType);
+ } else if (strcmp(grandgrandchild_xml_name, ELEMENT_SIZE) == 0) {
+ char *size = NULL;
+ err = sync_agent_get_text_from_node(grandgrandchild, &size);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ _DEBUG_TRACE("Size = [%s]", size);
+ if (size != NULL)
+ item->size = atoi(size);
+ }
+ }
+ } else if (strcmp(grandchild_xml_name, ELEMENT_DATA) == 0) {
+ char *data = NULL;
+ err = sync_agent_get_text_from_cdata_node(grandchild, &data);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ _DEBUG_TRACE("Data = [%s]", data);
+ if (data != NULL)
+ item->private.data = strdup(data);
+ item->data_type = ITEM_DATA;
+ } else if (strcmp(grandchild_xml_name, ELEMENT_MOREDATA) == 0) {
+ _DEBUG_TRACE("MoreData");
+ item->more_data = 1;
+ }
+ }
+ pAdd->private.change.items = g_list_append(pAdd->private.change.items, item);
+ item = NULL;
+ }
+ }
+
+ return_part:
+
+ if (item != NULL)
+ free_item(item);
+
+ if (err == SYNC_AGENT_PB_RETURN_OK) {
+ *content = pAdd;
+ } else {
+ _DEBUG_ERROR("error");
+ free_command(pAdd);
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return err;
+}
+
+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)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if(wbxml_dom_node == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "wbxml_dom_node is NULL");
+ retvm_if(reverse_binder == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "reverse_binder is NULL");
+
+ sync_hdr_s *pSyncHdr = (sync_hdr_s *) sync_agent_get_user_data_from_reverse_protocol_binder(reverse_binder);
+ retvm_if(pSyncHdr == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "pSyncHdr is NULL");
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+ item_s *item = NULL;
+
+ /* get data from dom tree */
+ command_s *pReplace = (command_s *) calloc(1, sizeof(command_s));
+ if (pReplace == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ _DEBUG_ERROR("pReplace is null");
+ goto return_part;
+ }
+
+ pReplace->type = COMMAND_TYPE_REPLACE;;
+ pReplace->msg_id = pSyncHdr->message_id;
+ pReplace->private.change.type = CHANGE_REPLACE;
+ pReplace->ref_count = 1;
+
+ WBXMLTreeNode *child = NULL;
+
+ for (child = wbxml_dom_node->children; child != NULL; child = child->next) {
+ if (child->type != WBXML_TREE_ELEMENT_NODE)
+ continue;
+
+ const char *child_xml_name = NULL;
+ child_xml_name = (const char *)wbxml_tag_get_xml_name(child->name);
+
+ if (strcmp(child_xml_name, ELEMENT_CMDID) == 0) {
+ char *cmd_id = NULL;
+ err = sync_agent_get_text_from_node(child, &cmd_id);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ _DEBUG_TRACE("CmdID = [%s]", cmd_id);
+ if (cmd_id != NULL)
+ pReplace->cmd_id = atoi(cmd_id);
+
+ } else if (strcmp(child_xml_name, ELEMENT_NORESP) == 0) {
+ _DEBUG_TRACE("NoResp");
+ pReplace->no_resp = 1;
+ } else if (strcmp(child_xml_name, ELEMENT_CRED) == 0) {
+ _DEBUG_TRACE("Cred\n");
+ cred_s *cred = NULL;
+ cred = __get_cred(child);
+ if (cred == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ pReplace->cred = cred;
+ } else if (strcmp(child_xml_name, ELEMENT_META) == 0) {
+
+ if (item == NULL) {
+ item = create_item();
+ if (item == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ }
+ WBXMLTreeNode *grandchild = NULL;
+ for (grandchild = child->children; grandchild != NULL; grandchild = grandchild->next) {
+ if (grandchild->type != WBXML_TREE_ELEMENT_NODE)
+ continue;
+
+ const char *grandchild_xml_name = NULL;
+ grandchild_xml_name = (const char *)wbxml_tag_get_xml_name(grandchild->name);
+
+ if (strcmp(grandchild_xml_name, ELEMENT_TYPE) == 0) {
+ char *contentType = NULL;
+ err = sync_agent_get_text_from_node(grandchild, &contentType);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ _DEBUG_TRACE("Content Type = [%s]", contentType);
+ if (contentType != NULL)
+ item->content_type = strdup(contentType);
+ } else if (strcmp(grandchild_xml_name, ELEMENT_SIZE) == 0) {
+ char *size = NULL;
+ err = sync_agent_get_text_from_node(grandchild, &size);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ _DEBUG_TRACE("Size = [%s]", size);
+ if (size != NULL)
+ item->size = atoi(size);
+ }
+ }
+ } else if (strcmp(child_xml_name, ELEMENT_ITEM) == 0) {
+
+ if (item == NULL) {
+ item = create_item();
+ if (item == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ }
+
+ WBXMLTreeNode *grandchild = NULL;
+ for (grandchild = child->children; grandchild != NULL; grandchild = grandchild->next) {
+ if (grandchild->type != WBXML_TREE_ELEMENT_NODE)
+ continue;
+
+ const char *grandchild_xml_name = NULL;
+ grandchild_xml_name = (const char *)wbxml_tag_get_xml_name(grandchild->name);
+
+ if (strcmp(grandchild_xml_name, ELEMENT_SOURCE) == 0) {
+ location_s *pSourceLocation = _get_location(grandchild);
+ if (pSourceLocation == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ item->source = pSourceLocation;
+ } else if (strcmp(grandchild_xml_name, ELEMENT_TARGET) == 0) {
+ location_s *pTargetLocation = _get_location(grandchild);
+ if (pTargetLocation == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ item->target = pTargetLocation;
+ } else if (strcmp(grandchild_xml_name, ELEMENT_META) == 0) {
+ WBXMLTreeNode *grandgrandchild = NULL;
+
+ for (grandgrandchild = grandchild->children; grandgrandchild != NULL; grandgrandchild = grandgrandchild->next) {
+ if (grandgrandchild->type != WBXML_TREE_ELEMENT_NODE)
+ continue;
+
+ const char *grandgrandchild_xml_name = NULL;
+ grandgrandchild_xml_name = (const char *)wbxml_tag_get_xml_name(grandgrandchild->name);
+
+ if (strcmp(grandgrandchild_xml_name, ELEMENT_TYPE) == 0) {
+ char *contentType = NULL;
+ err = sync_agent_get_text_from_node(grandgrandchild, &contentType);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ _DEBUG_TRACE("Content Type = [%s]", contentType);
+ if (contentType != NULL)
+ item->content_type = strdup(contentType);
+ } else if (strcmp(grandgrandchild_xml_name, ELEMENT_SIZE) == 0) {
+ char *size = NULL;
+ err = sync_agent_get_text_from_node(grandgrandchild, &size);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ _DEBUG_TRACE("Size = [%s]", size);
+ if (size != NULL)
+ item->size = atoi(size);
+ }
+ }
+
+ } else if (strcmp(grandchild_xml_name, ELEMENT_DATA) == 0) {
+ char *data = NULL;
+ err = sync_agent_get_text_from_cdata_node(grandchild, &data);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ _DEBUG_TRACE("Data = [%s]", data);
+ if (data != NULL)
+ item->private.data = strdup(data);
+ item->data_type = ITEM_DATA;
+ }
+ }
+ pReplace->private.change.items = g_list_append(pReplace->private.change.items, item);
+ item = NULL;
+ }
+ }
+
+ return_part:
+
+ if (item != NULL)
+ free_item(item);
+
+ if (err == SYNC_AGENT_PB_RETURN_OK) {
+ *content = pReplace;
+ } else {
+ _DEBUG_ERROR("error");
+ free_command(pReplace);
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return err;
+}
+
+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)
+{
+ _INNER_FUNC_ENTER;
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+ retvm_if(wbxml_dom_node == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "wbxml_dom_node is NULL");
+ retvm_if(reverse_binder == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "reverse_binder is NULL");
+
+ sync_hdr_s *pSyncHdr = (sync_hdr_s *) sync_agent_get_user_data_from_reverse_protocol_binder(reverse_binder);
+ retvm_if(pSyncHdr == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "pSyncHdr is NULL");
+
+ item_s *item = NULL;
+
+ /* get data from dom tree */
+ command_s *pDelete = (command_s *) calloc(1, sizeof(command_s));
+ if (pDelete == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ _DEBUG_ERROR("pDelete is null");
+ goto return_part;
+ }
+
+ pDelete->type = COMMAND_TYPE_DELETE;
+ pDelete->msg_id = pSyncHdr->message_id;
+ pDelete->private.change.type = CHANGE_DELETE;
+ pDelete->ref_count = 1;
+
+ WBXMLTreeNode *child = NULL;
+
+ for (child = wbxml_dom_node->children; child != NULL; child = child->next) {
+ if (child->type != WBXML_TREE_ELEMENT_NODE)
+ continue;
+
+ const char *child_xml_name = NULL;
+ child_xml_name = (const char *)wbxml_tag_get_xml_name(child->name);
+
+ if (strcmp(child_xml_name, ELEMENT_CMDID) == 0) {
+ char *cmd_id = NULL;
+ err = sync_agent_get_text_from_node(child, &cmd_id);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ _DEBUG_TRACE("CmdID = [%s]", cmd_id);
+ if (cmd_id != NULL)
+ pDelete->cmd_id = atoi(cmd_id);
+ } else if (strcmp(child_xml_name, ELEMENT_NORESP) == 0) {
+ _DEBUG_TRACE("NoResp");
+ pDelete->no_resp = 1;
+ } else if (strcmp(child_xml_name, ELEMENT_CRED) == 0) {
+ _DEBUG_TRACE("Cred\n");
+ cred_s *cred = NULL;
+ cred = __get_cred(child);
+ if (cred == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ pDelete->cred = cred;
+ } else if (strcmp(child_xml_name, ELEMENT_META) == 0) {
+ WBXMLTreeNode *grandchild = NULL;
+
+ /* create Item */
+ if (item == NULL) {
+ item = create_item();
+ if (item == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ }
+
+ for (grandchild = child->children; grandchild != NULL; grandchild = grandchild->next) {
+ if (grandchild->type != WBXML_TREE_ELEMENT_NODE)
+ continue;
+
+ const char *grandchild_xml_name = NULL;
+ grandchild_xml_name = (const char *)wbxml_tag_get_xml_name(grandchild->name);
+
+ if (strcmp(grandchild_xml_name, ELEMENT_TYPE) == 0) {
+ char *contentType = NULL;
+ err = sync_agent_get_text_from_node(grandchild, &contentType);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ _DEBUG_TRACE("Content Type = [%s]", contentType);
+ if (contentType != NULL)
+ item->content_type = strdup(contentType);
+ }
+ }
+ } else if (strcmp(child_xml_name, ELEMENT_ITEM) == 0) {
+ /* create Item */
+ if (item == NULL) {
+ item = create_item();
+ if (item == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ }
+ WBXMLTreeNode *grandchild = NULL;
+
+ for (grandchild = child->children; grandchild != NULL; grandchild = grandchild->next) {
+ if (grandchild->type != WBXML_TREE_ELEMENT_NODE)
+ continue;
+
+ const char *grandchild_xml_name = NULL;
+ grandchild_xml_name = (const char *)wbxml_tag_get_xml_name(grandchild->name);
+
+ if (strcmp(grandchild_xml_name, ELEMENT_SOURCE) == 0) {
+ location_s *pSourceLocation = _get_location(grandchild);
+ if (pSourceLocation == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ item->source = pSourceLocation;
+ } else if (strcmp(grandchild_xml_name, ELEMENT_TARGET) == 0) {
+ location_s *pTargetLocation = _get_location(grandchild);
+ if (pTargetLocation == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ item->target = pTargetLocation;
+ } else if (strcmp(grandchild_xml_name, ELEMENT_META) == 0) {
+
+ } else if (strcmp(grandchild_xml_name, ELEMENT_DATA) == 0) {
+
+ }
+ }
+ pDelete->private.change.items = g_list_append(pDelete->private.change.items, item);
+ item = NULL;
+ }
+ }
+
+ return_part:
+
+ if (item != NULL)
+ free_item(item);
+
+ if (err == SYNC_AGENT_PB_RETURN_OK) {
+ *content = pDelete;
+ } else {
+ _DEBUG_ERROR("error");
+ free_command(pDelete);
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return err;
+}
+
+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)
+{
+ _INNER_FUNC_ENTER;
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+ int *pFinal = (int *)1;
+ *content = pFinal;
+
+ _EXTERN_FUNC_EXIT;
+ return err;
+}
+
+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)
+{
+ _INNER_FUNC_ENTER;
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+ retvm_if(wbxml_dom_node == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "wbxml_dom_node is NULL");
+
+ /* get data from dom tree */
+ status_s *pStatus = (status_s *) calloc(1, sizeof(status_s));
+ if (pStatus == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ _DEBUG_ERROR("pStatus is null");
+ goto return_part;
+ }
+
+ WBXMLTreeNode *child = NULL;
+ for (child = wbxml_dom_node->children; child != NULL; child = child->next) {
+ if (child->type != WBXML_TREE_ELEMENT_NODE)
+ continue;
+ const char *child_xml_name = NULL;
+ child_xml_name = (const char *)wbxml_tag_get_xml_name(child->name);
+
+ if (strcmp(child_xml_name, ELEMENT_CMDID) == 0) {
+ char *cmd_id = NULL;
+ err = sync_agent_get_text_from_node(child, &cmd_id);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ _DEBUG_TRACE("CmdID = [%s]", cmd_id);
+ if (cmd_id != NULL)
+ pStatus->cmd_id = atoi(cmd_id);
+ } else if (strcmp(child_xml_name, ELEMENT_MSGREF) == 0) {
+ char *msgref = NULL;
+ err = sync_agent_get_text_from_node(child, &msgref);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ _DEBUG_TRACE("MsgRef = [%s]", msgref);
+ if (msgref != NULL)
+ pStatus->msg_ref = atoi(msgref);
+ } else if (strcmp(child_xml_name, ELEMENT_CMDREF) == 0) {
+ char *cmdref = NULL;
+ err = sync_agent_get_text_from_node(child, &cmdref);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ _DEBUG_TRACE("CmdRef = [%s]", cmdref);
+ if (cmdref != NULL)
+ pStatus->cmd_ref = atoi(cmdref);
+ } else if (strcmp(child_xml_name, ELEMENT_CMD) == 0) {
+ char *cmd = NULL;
+ err = sync_agent_get_text_from_node(child, &cmd);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ _DEBUG_TRACE("Cmd = [%s]", cmd);
+
+ pStatus->type = convert_command_type(cmd);
+ } else if (strcmp(child_xml_name, ELEMENT_TARGETREF) == 0) {
+ char *targetref = NULL;
+ location_s *location = NULL;
+ err = sync_agent_get_text_from_node(child, &targetref);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ _DEBUG_TRACE("TargetRef = [%s]", targetref);
+
+ sa_error_type_e error = create_location(targetref, NULL, &location);
+ if (error != SA_INTERNAL_OK) {
+ _DEBUG_ERROR("create_location() failed !, error = %d", error);
+ goto return_part;
+ }
+ pStatus->target_ref = location;
+ } else if (strcmp(child_xml_name, ELEMENT_SOURCEREF) == 0) {
+ char *sourceref = NULL;
+ location_s *location = NULL;
+ err = sync_agent_get_text_from_node(child, &sourceref);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ _DEBUG_TRACE("SourceRef = [%s]", sourceref);
+
+ sa_error_type_e error = create_location(sourceref, NULL, &location);
+ if (error != SA_INTERNAL_OK) {
+ _DEBUG_ERROR("create_location() failed !, error = %d", error);
+ goto return_part;
+ }
+ pStatus->source_ref = location;
+ } else if (strcmp(child_xml_name, ELEMENT_CRED) == 0) {
+ _DEBUG_TRACE("Cred\n");
+ cred_s *cred = NULL;
+ cred = __get_cred(child);
+ if (cred == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ pStatus->cred = cred;
+ } else if (strcmp(child_xml_name, ELEMENT_CHAL) == 0) {
+ _DEBUG_TRACE("Chal\n");
+ chal_s *pChal = NULL;
+ pChal = _get_chal(child);
+ if (pChal == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ pStatus->chal = pChal;
+ } else if (strcmp(child_xml_name, ELEMENT_DATA) == 0) {
+ char *data = NULL;
+ err = sync_agent_get_text_from_node(child, &data);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ _DEBUG_TRACE("Data = [%s]\n", data);
+ if (data != NULL)
+ pStatus->data = strdup(data);
+ } else if (strcmp(child_xml_name, ELEMENT_ITEM) == 0) {
+ WBXMLTreeNode *grandchild = NULL;
+
+ for (grandchild = child->children; grandchild != NULL; grandchild = grandchild->next) {
+ if (grandchild->type != WBXML_TREE_ELEMENT_NODE)
+ continue;
+
+ const char *grandchild_xml_name = NULL;
+ grandchild_xml_name = (const char *)wbxml_tag_get_xml_name(grandchild->name);
+
+ if (strcmp(grandchild_xml_name, ELEMENT_SOURCE) == 0) {
+ location_s *pSourceLocation = _get_location(grandchild);
+ if (pSourceLocation == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ pStatus->source_ref = pSourceLocation;
+ } else if (strcmp(grandchild_xml_name, ELEMENT_TARGET) == 0) {
+ /* need ? */
+ } else if (strcmp(grandchild_xml_name, ELEMENT_DATA) == 0) {
+ /* need ? */
+ }
+ }
+ }
+ }
+
+ return_part:
+ if (err == SYNC_AGENT_PB_RETURN_OK) {
+ *content = pStatus;
+ } else {
+ _DEBUG_ERROR("error");
+ free_status(pStatus);
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return err;
+}
+
+sync_agent_pb_error_e init_oma_ds_1_2_binder_function_set(sync_agent_pb_protocol_binder_function_set_s ** binder_function_set)
+{
+ _EXTERN_FUNC_ENTER;
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+ 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);
+
+ _EXTERN_FUNC_EXIT;
+ return err;
+}
+
+void free_oma_ds_1_2_binder_function_set(sync_agent_pb_protocol_binder_function_set_s * binder_function_set)
+{
+ _EXTERN_FUNC_ENTER;
+
+ sync_agent_free_binder_function_set(binder_function_set);
+
+ _EXTERN_FUNC_EXIT;
+}
+
+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,
+ 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)
+{
+ _EXTERN_FUNC_ENTER;
+
+ sync_agent_pb_protocol_binder_info_s *pOutBinder = NULL;
+
+ 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);
+
+ if (pOutBinder == NULL) {
+ goto return_part;
+ }
+
+ return_part:
+
+ _EXTERN_FUNC_EXIT;
+ return pOutBinder;
+}
+
+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)
+{
+ _EXTERN_FUNC_ENTER;
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+ err = sync_agent_append_element(binder, protocol_element, content);
+
+ _EXTERN_FUNC_EXIT;
+ return err;
+}
+
+void oma_ds_1_2_binder_terminate(sync_agent_pb_protocol_binder_info_s * binder)
+{
+ _EXTERN_FUNC_ENTER;
+
+ sync_agent_destroy_protocol_binder(binder);
+
+ _EXTERN_FUNC_EXIT;
+}
+
+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)
+{
+ _EXTERN_FUNC_ENTER;
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+ err = sync_agent_get_stream_from_protocol_binder(binder, byte_stream, byte_stream_size);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+
+ return_part:
+
+ _EXTERN_FUNC_EXIT;
+ return err;
+}
+
+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)
+{
+
+ _EXTERN_FUNC_ENTER;
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+ err = sync_agent_get_stream_size_from_protocol_binder(binder, byte_stream_size);
+
+ _EXTERN_FUNC_EXIT;
+ return err;
+}
+
+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)
+{
+ _EXTERN_FUNC_ENTER;
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+ err = sync_agent_get_encoding_from_protocol_binder(binder, enc);
+
+ _EXTERN_FUNC_EXIT;
+ return err;
+}
+
+sync_agent_pb_error_e reverse_oma_ds_1_2_binder_init(char *byte_stream,
+ 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)
+{
+ _EXTERN_FUNC_ENTER;
+
+ sync_agent_pb_protocol_e protocol = SYNC_AGENT_PB_PROTOCOL_UNKNOWN;
+ sync_agent_pb_error_e err = sync_agent_init_reverse_protocol_binder(byte_stream, byte_stream_len, dec,
+ &protocol, binder_function_set, user_data, binder);
+
+ _EXTERN_FUNC_EXIT;
+ return err;
+}
+
+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)
+{
+ _EXTERN_FUNC_ENTER;
+
+ sync_agent_pb_error_e err = sync_agent_next_element(pBinder,
+ protocol_element, protocol_element_name, content);
+
+ _EXTERN_FUNC_EXIT;
+ return err;
+}