+/*
+ * oma-ds-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: JuHak Park <juhaki.park@samsung.com>,
+ * JuneHyuk Lee <junhyuk7.lee@samsung.com>,
+ * SunBong Ha <sunbong.ha@samsung.com>
+ *
+ * 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.
+ *
+ */
+
+
+
+
+/*
+ * For any sort of issue you concern as to this software,
+ * you may use following point of contact.
+ * All resources contributed on this software
+ * are orinigally written by S-Core Inc., a member of Samsung Group.
+ *
+ * SeongWon Shim <seongwon.shim@samsung.com>
+ */
+
+/**
+ * @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 <assert.h> /* TODO : replace this line to fw_assert.h */
+
+#include "agent-framework/Utility/fw_log.h"
+#include "agent-framework/NetworkAssistant/protocol_binder/protocol_binder_util.h"
+#include "ServiceAdapter/ProtocolBinder/oma_ds_protocol_binder.h"
+#include "ServiceAdapter/SA_Elements_Internal.h"
+#include "ServiceAdapter/SA_Command_Internal.h"
+#include "ServiceAdapter/SA_DevInf_Internal.h"
+#include "ServiceAdapter/SA_Command.h"
+#include "ServiceAdapter/SA_Elements.h"
+#include "ServiceAdapter/SA_DevInf.h"
+#include "ServiceAdapter/SA_Define.h"
+
+#define LOG_TAG "OMA_DS_BINDER"
+
+static PROTOCOL_BINDER_ERROR __append_location_to_wbxml_node(Location *pLocation,
+ protocol_binder *pBinder, WBXMLTreeNode *parent_node);
+
+static PROTOCOL_BINDER_ERROR __append_anchor_to_wbxml_node(Anchor *pAnchor,
+ protocol_binder *pBinder, WBXMLTreeNode *parent_node);
+
+static PROTOCOL_BINDER_ERROR __append_devinf_contenttype_to_wbxml_node(DevInfContentType *pDevInfContentType,
+ protocol_binder *pBinder, WBXMLTreeNode *parent_node, char *node);
+
+static PROTOCOL_BINDER_ERROR __append_cred_to_wbxml_node(Cred *pCred, protocol_binder *pBinder, WBXMLTreeNode *parent_node) ;
+
+static PROTOCOL_BINDER_ERROR __oma_ds_binder_devinf_converter_function(protocol_binder *pBinder,
+ Content_Ptr pContent, WBXMLTreeNode **ppWbxml_dom_node);
+static PROTOCOL_BINDER_ERROR __oma_ds_binder_syncml_start_converter_function(protocol_binder *pBinder,
+ Content_Ptr pContent, WBXMLTreeNode **ppWbxml_dom_node);
+static PROTOCOL_BINDER_ERROR __oma_ds_binder_header_converter_function(protocol_binder *pBinder,
+ Content_Ptr pContent, WBXMLTreeNode **ppWbxml_dom_node);
+static PROTOCOL_BINDER_ERROR __oma_ds_binder_final_converter_function(protocol_binder *pBinder,
+ Content_Ptr pContent, WBXMLTreeNode **ppWbxml_dom_node);
+static PROTOCOL_BINDER_ERROR __oma_ds_binder_body_start_converter_function(protocol_binder *pBinder,
+ Content_Ptr pContent, WBXMLTreeNode **ppWbxml_dom_node);
+static PROTOCOL_BINDER_ERROR __oma_ds_binder_status_converter_function(protocol_binder *pBinder,
+ Content_Ptr pContent, WBXMLTreeNode **ppWbxml_dom_node);
+static PROTOCOL_BINDER_ERROR __oma_ds_binder_alert_command_converter_function(protocol_binder *pBinder,
+ Content_Ptr pContent, WBXMLTreeNode **ppWbxml_dom_node);
+static PROTOCOL_BINDER_ERROR __oma_ds_binder_results_command_converter_function(protocol_binder *pBinder,
+ Content_Ptr pContent, WBXMLTreeNode **ppWbxml_dom_node);
+static PROTOCOL_BINDER_ERROR __oma_ds_binder_put_command_converter_function(protocol_binder *pBinder,
+ Content_Ptr pContent, WBXMLTreeNode **ppWbxml_dom_node);
+static PROTOCOL_BINDER_ERROR __oma_ds_binder_get_command_converter_function(protocol_binder *pBinder,
+ Content_Ptr pContent, WBXMLTreeNode **ppWbxml_dom_node);
+static PROTOCOL_BINDER_ERROR __oma_ds_binder_sync_start_command_converter_function(protocol_binder *pBinder,
+ Content_Ptr pContent, WBXMLTreeNode **ppWbxml_dom_node);
+static PROTOCOL_BINDER_ERROR __oma_ds_binder_sync_end_command_converter_function(protocol_binder *pBinder,
+ Content_Ptr pContent, WBXMLTreeNode **ppWbxml_dom_node);
+static PROTOCOL_BINDER_ERROR __oma_ds_binder_add_command_converter_function(protocol_binder *pBinder,
+ Content_Ptr pContent, WBXMLTreeNode **ppWbxml_dom_node);
+static PROTOCOL_BINDER_ERROR __oma_ds_binder_replace_command_converter_function(protocol_binder *pBinder,
+ Content_Ptr pContent, WBXMLTreeNode **ppWbxml_dom_node);
+static PROTOCOL_BINDER_ERROR __oma_ds_binder_delete_command_converter_function(protocol_binder *pBinder,
+ Content_Ptr pContent, WBXMLTreeNode **ppWbxml_dom_node);
+static PROTOCOL_BINDER_ERROR __oma_ds_binder_map_command_converter_function(protocol_binder *pBinder,
+ Content_Ptr pContent, WBXMLTreeNode **ppWbxml_dom_node);
+
+static ProtocolVersion __get_oma_ds_protocol_version(char *verdtd);
+static DevInfVersion __get_oma_ds_devInf_version(char *verdtd);
+static DevInfDevTyp __get_oma_ds_devInf_device_type(char *devType);
+static DevInfContentType *__get_devinf_contenttype(WBXMLTreeNode *node);
+static Location *_get_location(WBXMLTreeNode *node);
+static Anchor *_get_anchor(WBXMLTreeNode *node);
+static Cred *__get_cred(WBXMLTreeNode *node);
+static Chal *_get_chal(WBXMLTreeNode *node);
+
+static PROTOCOL_BINDER_ERROR __oma_ds_binder_devinf_reverse_converter_function(Reverse_protocol_binder *pReverse_binder,
+ WBXMLTreeNode *wbxml_dom_node, Content_Ptr *pContent);
+static PROTOCOL_BINDER_ERROR __oma_ds_binder_header_reverse_converter_function(Reverse_protocol_binder *pReverse_binder,
+ WBXMLTreeNode *wbxml_dom_node, Content_Ptr *pContent);
+static PROTOCOL_BINDER_ERROR __oma_ds_binder_results_command_reverse_converter_function(Reverse_protocol_binder *pReverse_binder,
+ WBXMLTreeNode *wbxml_dom_node, Content_Ptr *pContent);
+static PROTOCOL_BINDER_ERROR __oma_ds_binder_put_command_reverse_converter_function(Reverse_protocol_binder *pReverse_binder,
+ WBXMLTreeNode *wbxml_dom_node, Content_Ptr *pContent);
+static PROTOCOL_BINDER_ERROR __oma_ds_binder_get_command_reverse_converter_function(Reverse_protocol_binder *pReverse_binder,
+ WBXMLTreeNode *wbxml_dom_node, Content_Ptr *pContent);
+static PROTOCOL_BINDER_ERROR __oma_ds_binder_alert_command_reverse_converter_function(Reverse_protocol_binder *pReverse_binder,
+ WBXMLTreeNode *wbxml_dom_node, Content_Ptr *pContent);
+static PROTOCOL_BINDER_ERROR __oma_ds_binder_sync_end_command_reverse_converter_function(Reverse_protocol_binder *pReverse_binder,
+ WBXMLTreeNode *wbxml_dom_node, Content_Ptr *pContent);
+static PROTOCOL_BINDER_ERROR __oma_ds_binder_sync_start_command_reverse_converter_function(Reverse_protocol_binder *pReverse_binder,
+ WBXMLTreeNode *wbxml_dom_node, Content_Ptr *pContent);
+static PROTOCOL_BINDER_ERROR __oma_ds_binder_add_command_reverse_converter_function(Reverse_protocol_binder *pReverse_binder,
+ WBXMLTreeNode *wbxml_dom_node, Content_Ptr *pContent);
+static PROTOCOL_BINDER_ERROR __oma_ds_binder_replace_command_reverse_converter_function(Reverse_protocol_binder *pReverse_binder,
+ WBXMLTreeNode *wbxml_dom_node, Content_Ptr *pContent);
+static PROTOCOL_BINDER_ERROR __oma_ds_binder_delete_command_reverse_converter_function(Reverse_protocol_binder *pReverse_binder,
+ WBXMLTreeNode *wbxml_dom_node, Content_Ptr *pContent);
+static PROTOCOL_BINDER_ERROR __oma_ds_binder_final_reverse_converter_function(Reverse_protocol_binder *pReverse_binder,
+ WBXMLTreeNode *wbxml_dom_node, Content_Ptr *pContent);
+static PROTOCOL_BINDER_ERROR __oma_ds_binder_status_reverse_converter_function(Reverse_protocol_binder *pReverse_binder,
+ WBXMLTreeNode *wbxml_dom_node, Content_Ptr *pContent);
+
+
+/*
+ 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 Binder_function_info 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 PROTOCOL_BINDER_ERROR __append_location_to_wbxml_node(Location *pLocation,
+ protocol_binder *pBinder,
+ WBXMLTreeNode *parent_node)
+{
+ FW_LOGV("start");
+ PROTOCOL_BINDER_ERROR err = PROTOCOL_BINDER_OK;
+
+ if (pLocation->locURI != NULL) {
+ WBXMLTreeNode *LocURI = add_child_wbxml_node_using_xml_name_with_text(pBinder,
+ parent_node, ELEMENT_LOCURI, pLocation->locURI, strlen(pLocation->locURI));
+ if (LocURI == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+ } else {
+ /* error case */
+ }
+
+ if (pLocation->locName != NULL) {
+ WBXMLTreeNode *locName = add_child_wbxml_node_using_xml_name_with_text(pBinder,
+ parent_node, ELEMENT_LOCNAME, pLocation->locName, strlen(pLocation->locName));
+ if (locName == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ FW_LOGV("end");
+ return err;
+
+error:
+ FW_LOGE("error : %d", err);
+ return err;
+}
+
+static PROTOCOL_BINDER_ERROR __append_anchor_to_wbxml_node(Anchor *pAnchor,
+ protocol_binder *pBinder,
+ WBXMLTreeNode *parent_node)
+{
+ FW_LOGV("start");
+ PROTOCOL_BINDER_ERROR err = PROTOCOL_BINDER_OK;
+
+ WBXMLTreeNode *meta_node = add_child_wbxml_node_using_xml_name(pBinder, parent_node, ELEMENT_META);
+ if (meta_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *anchor_node = add_child_wbxml_node_using_xml_name(pBinder, meta_node, ELEMENT_ANCHOR);
+ if (anchor_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ if (pAnchor->lastAnchor) {
+ WBXMLTreeNode *last_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
+ anchor_node, ELEMENT_LAST, pAnchor->lastAnchor, strlen(pAnchor->lastAnchor));
+ if (last_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ if (pAnchor->nextAnchor) {
+ WBXMLTreeNode *next_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
+ anchor_node, ELEMENT_NEXT, pAnchor->nextAnchor, strlen(pAnchor->nextAnchor));
+ if (next_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ FW_LOGV("end");
+ return err;
+
+error:
+ FW_LOGE("error : %d", err);
+ return err;
+}
+
+static PROTOCOL_BINDER_ERROR __append_devinf_contenttype_to_wbxml_node(DevInfContentType *pDevInfContentType,
+ protocol_binder *pBinder,
+ WBXMLTreeNode *parent_node,
+ char *node)
+{
+ FW_LOGV("start");
+ PROTOCOL_BINDER_ERROR err = PROTOCOL_BINDER_OK;
+ WBXMLTreeNode *xnode = add_child_wbxml_node_using_xml_name(pBinder, parent_node, node);
+ if (xnode == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *cttype_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
+ xnode, "CTType", pDevInfContentType->cttype, strlen(pDevInfContentType->cttype));
+ if (cttype_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *verct_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
+ xnode, "VerCT", pDevInfContentType->verct, strlen(pDevInfContentType->verct));
+ if (verct_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ FW_LOGV("end");
+ return err;
+
+error:
+ FW_LOGE("error : %d", err);
+ return err;
+}
+
+static PROTOCOL_BINDER_ERROR __append_cred_to_wbxml_node(Cred *pCred,
+ protocol_binder *pBinder,
+ WBXMLTreeNode *parent_node)
+{
+ FW_LOGV("start");
+ PROTOCOL_BINDER_ERROR err = PROTOCOL_BINDER_OK;
+
+ /* check validity */
+ WBXMLTreeNode *cred_node = add_child_wbxml_node_using_xml_name(pBinder, parent_node, ELEMENT_CRED);
+ if (cred_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *meta_node = add_child_wbxml_node_using_xml_name(pBinder, cred_node, ELEMENT_META);
+ if (meta_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+
+ WBXMLTreeNode *type_node = NULL;
+
+ switch (pCred->type) {
+ case AUTH_TYPE_BASIC:
+
+ if (pCred->format == FORMAT_TYPE_BASE64) {
+ WBXMLTreeNode *format_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
+ meta_node, ELEMENT_FORMAT, ELEMENT_FORMAT_BASE64, strlen(ELEMENT_FORMAT_BASE64));
+ if (format_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ type_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
+ meta_node, ELEMENT_TYPE, ELEMENT_AUTH_BASIC, strlen(ELEMENT_AUTH_BASIC));
+ if (type_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ if (pCred->data) {
+ WBXMLTreeNode *data_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
+ cred_node, ELEMENT_DATA, pCred->data, strlen(pCred->data));
+ if (data_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+ break;
+ case AUTH_TYPE_MD5:
+
+ if (pCred->format == FORMAT_TYPE_BASE64) {
+ WBXMLTreeNode *format_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
+ meta_node, ELEMENT_FORMAT, ELEMENT_FORMAT_BASE64, strlen(ELEMENT_FORMAT_BASE64));
+ if (format_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ type_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
+ meta_node, ELEMENT_TYPE, ELEMENT_AUTH_MD5, strlen(ELEMENT_AUTH_MD5));
+ if (type_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ if (pCred->data) {
+ WBXMLTreeNode *data_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
+ cred_node, ELEMENT_DATA, pCred->data, strlen(pCred->data));
+ if (data_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+ break;
+ default:
+ break;
+ }
+
+ FW_LOGV("end");
+ return err;
+
+error:
+ FW_LOGE("error : %d", err);
+ return err;
+}
+
+
+static PROTOCOL_BINDER_ERROR __oma_ds_binder_devinf_converter_function(protocol_binder *pBinder,
+ Content_Ptr pContent, WBXMLTreeNode **ppWbxml_dom_node)
+{
+ FW_LOGV("start");
+ PROTOCOL_BINDER_ERROR err = PROTOCOL_BINDER_OK;
+
+ Item *pItem = (Item *)pContent;
+ DevInf *pDevInf = pItem->private.devInf;
+
+ if (pItem) {
+ WBXMLTreeNode *item_node = create_wbxml_node_using_xml_name(pBinder, ELEMENT_ITEM);
+ if (item_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *source_node = add_child_wbxml_node_using_xml_name(pBinder, item_node, ELEMENT_SOURCE);
+ if (source_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ err = __append_location_to_wbxml_node(pItem->source, pBinder, source_node);
+ if (err != PROTOCOL_BINDER_OK)
+ goto error;
+
+ WBXMLTreeNode *data_node = add_child_wbxml_node_using_xml_name(pBinder, item_node, ELEMENT_DATA);
+ if (data_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ /* devinf language setting */
+ switch_protocol(pBinder, PROTOCOL_SYNCML_DEVINF12);
+ WBXMLTree *devinf_tree = create_wbxml_tree(pBinder);
+ if (devinf_tree == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ add_wbxml_tree_to_wbxml_node(data_node, devinf_tree);
+
+ /* create root node of devinf tree*/
+ WBXMLTreeNode *devinf_node = create_wbxml_node_using_xml_name(pBinder, ELEMENT_DEVINF);
+ if (devinf_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ set_wbxml_tree_root(devinf_tree, devinf_node);
+
+ WBXMLTreeNode *verDTD_node = NULL;
+ switch (pDevInf->version) {
+ case DEVINF_VERSION_UNKNOWN:
+ verDTD_node = add_child_wbxml_node_using_xml_name(pBinder, devinf_node, ELEMENT_VERDTD);
+ break;
+ case DEVINF_VERSION_10:
+ verDTD_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
+ devinf_node, ELEMENT_VERDTD, ELEMENT_VERDRD_10, strlen(ELEMENT_VERDRD_10));
+ break;
+ case DEVINF_VERSION_11:
+ verDTD_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
+ devinf_node, ELEMENT_VERDTD, ELEMENT_VERDRD_11, strlen(ELEMENT_VERDRD_11));
+ break;
+ case DEVINF_VERSION_12:
+ verDTD_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
+ devinf_node, ELEMENT_VERDTD, ELEMENT_VERDRD_12, strlen(ELEMENT_VERDRD_12));
+ break;
+ }
+
+ if (verDTD_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *man_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
+ devinf_node, ELEMENT_MAN, pDevInf->manufacturer, strlen(pDevInf->manufacturer));
+ if (man_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *mod_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
+ devinf_node, ELEMENT_MOD, pDevInf->model, strlen(pDevInf->model));
+ if (mod_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+
+ if (pDevInf->oem) {
+ WBXMLTreeNode *oem_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
+ devinf_node, ELEMENT_OEM, pDevInf->oem, strlen(pDevInf->oem));
+ if (oem_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ WBXMLTreeNode *FwV_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
+ devinf_node, ELEMENT_FWV, pDevInf->firmwareVersion, strlen(pDevInf->firmwareVersion));
+ if (FwV_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *SwV_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
+ devinf_node, ELEMENT_SWV, pDevInf->softwareVersion, strlen(pDevInf->softwareVersion));
+ if (SwV_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *HwV_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
+ devinf_node, ELEMENT_HWV, pDevInf->hardwareVersion, strlen(pDevInf->hardwareVersion));
+ if (HwV_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *devID_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
+ devinf_node, ELEMENT_DEVID, pDevInf->devid, strlen(pDevInf->devid));
+ if (devID_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *devTyp_node = NULL;
+ switch (pDevInf->devtyp) {
+ case DEVINF_DEVTYPE_UNKNOWN:
+ devTyp_node = add_child_wbxml_node_using_xml_name(pBinder, devinf_node, ELEMENT_DEVTYP);
+ break;
+ case DEVINF_DEVTYPE_PAGER:
+ devTyp_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
+ devinf_node, ELEMENT_DEVTYP, ELEMENT_PAGER, strlen(ELEMENT_PAGER));
+ break;
+ case DEVINF_DEVTYPE_HANDHELD:
+ devTyp_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
+ devinf_node, ELEMENT_DEVTYP, ELEMENT_HANDHELD, strlen(ELEMENT_HANDHELD));
+ break;
+ case DEVINF_DEVTYPE_PDA:
+ devTyp_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
+ devinf_node, ELEMENT_DEVTYP, ELEMENT_PDA, strlen(ELEMENT_PDA));
+ break;
+ case DEVINF_DEVTYPE_PHONE:
+ devTyp_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
+ devinf_node, ELEMENT_DEVTYP, ELEMENT_PHONE, strlen(ELEMENT_PHONE));
+ break;
+ case DEVINF_DEVTYPE_SMARTPHONE:
+ devTyp_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
+ devinf_node, ELEMENT_DEVTYP, ELEMENT_SMARTPHONE, strlen(ELEMENT_SMARTPHONE));
+ break;
+ case DEVINF_DEVTYPE_SERVER:
+ devTyp_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
+ devinf_node, ELEMENT_DEVTYP, ELEMENT_SERVER, strlen(ELEMENT_SERVER));
+ break;
+ case DEVINF_DEVTYPE_WORKSTATION:
+ devTyp_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
+ devinf_node, ELEMENT_DEVTYP, ELEMENT_WORKSTATION, strlen(ELEMENT_WORKSTATION));
+ break;
+ }
+
+ if (devTyp_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ if (pDevInf->supportsUTC) {
+ WBXMLTreeNode *supportUTC_node = add_child_wbxml_node_using_xml_name(pBinder,
+ devinf_node, ELEMENT_UTC);
+ if (supportUTC_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ if (pDevInf->supportsLargeObjs) {
+ WBXMLTreeNode *supportLargeObjs_node = add_child_wbxml_node_using_xml_name(pBinder,
+ devinf_node, ELEMENT_SUPPORTLARGEOBJS);
+ if (supportLargeObjs_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ if (pDevInf->supportsNumberOfChanges) {
+ WBXMLTreeNode *supportNumberOfChanges_node = add_child_wbxml_node_using_xml_name(pBinder,
+ devinf_node, ELEMENT_SUPPORTNUMBEROFCHANGES);
+ if (supportNumberOfChanges_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ GList *datastoreIter = NULL;
+ DevInfDataStore *devInfDataStore = NULL;
+ for (datastoreIter = pDevInf->datastores; datastoreIter != NULL; datastoreIter = g_list_next(datastoreIter)) {
+ devInfDataStore = datastoreIter->data;
+
+ WBXMLTreeNode *datastore_node = add_child_wbxml_node_using_xml_name(pBinder,
+ devinf_node, ELEMENT_DATASTORE);
+ if (datastore_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *sourceRef_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
+ datastore_node, ELEMENT_SOURCEREF, devInfDataStore->sourceref, strlen(devInfDataStore->sourceref));
+ if (sourceRef_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ if (devInfDataStore->displayname) {
+ WBXMLTreeNode *displayname_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
+ datastore_node, ELEMENT_DISPLAYNAME, devInfDataStore->displayname, strlen(devInfDataStore->displayname));
+ if (displayname_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ if (devInfDataStore->maxGUIDSize) {
+ char *str_maxguidsize = g_strdup_printf("%u", devInfDataStore->maxGUIDSize);
+ if (str_maxguidsize == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *maxguidsize_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
+ datastore_node, ELEMENT_MAXGUIDSIZE, str_maxguidsize, strlen(str_maxguidsize));
+
+ if (str_maxguidsize != NULL)
+ free(str_maxguidsize);
+
+ if (maxguidsize_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ __append_devinf_contenttype_to_wbxml_node(devInfDataStore->rxPref, pBinder,
+ datastore_node, ELEMENT_RX_PREF);
+ if (err != PROTOCOL_BINDER_OK)
+ goto error;
+
+
+ GList *rxIter = NULL;
+ DevInfContentType *devInfContentType = NULL;
+ for (rxIter = devInfDataStore->rx; rxIter != NULL; rxIter = g_list_next(rxIter)) {
+ devInfContentType = rxIter->data;
+ __append_devinf_contenttype_to_wbxml_node(devInfContentType, pBinder,
+ datastore_node, ELEMENT_RX);
+ if (err != PROTOCOL_BINDER_OK)
+ goto error;
+ }
+
+ __append_devinf_contenttype_to_wbxml_node(devInfDataStore->txPref, pBinder,
+ datastore_node, ELEMENT_TX_PREF);
+ if (err != PROTOCOL_BINDER_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, pBinder,
+ datastore_node, ELEMENT_TX);
+ if (err != PROTOCOL_BINDER_OK)
+ goto error;
+
+ }
+
+ GList *ctcapIter = NULL;
+ DevInfCTCap *devInfCTCap = NULL;
+ for (ctcapIter = devInfDataStore->ctcaps; ctcapIter != NULL; ctcapIter = g_list_next(ctcapIter)) {
+ devInfCTCap = ctcapIter->data;
+
+ WBXMLTreeNode *ctcap_node = add_child_wbxml_node_using_xml_name(pBinder,
+ datastore_node, ELEMENT_CTCAP);
+ if (ctcap_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *cttype_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
+ ctcap_node, ELEMENT_CTTYPE, devInfCTCap->ct->cttype, strlen(devInfCTCap->ct->cttype));
+ if (cttype_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *verct_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
+ ctcap_node, ELEMENT_VERCT, devInfCTCap->ct->verct, strlen(devInfCTCap->ct->verct));
+ if (verct_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ /*TODO FieldLevel*/
+
+ GList *propertyIter = NULL;
+ DevInfProperty *devInfProperty = NULL;
+ for (propertyIter = devInfCTCap->properties; propertyIter != NULL; propertyIter = g_list_next(propertyIter)) {
+ devInfProperty = propertyIter->data;
+
+ WBXMLTreeNode *property_node = add_child_wbxml_node_using_xml_name(pBinder,
+ ctcap_node, ELEMENT_PROPERTY);
+ if (property_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *propname_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
+ property_node, ELEMENT_PROPNAME, devInfProperty->propName, strlen(devInfProperty->propName));
+ if (propname_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ if (devInfProperty->dataType) {
+ WBXMLTreeNode *datatype_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
+ property_node, ELEMENT_DATATYPE, devInfProperty->dataType, strlen(devInfProperty->dataType));
+ if (datatype_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ if (devInfProperty->maxOccur) {
+ char *str_maxoccur = g_strdup_printf("%u", devInfProperty->maxOccur);
+ if (str_maxoccur == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *maxoccur_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
+ property_node, ELEMENT_MAXOCCUR, str_maxoccur, strlen(str_maxoccur));
+
+ if (str_maxoccur != NULL)
+ free(str_maxoccur);
+
+ if (maxoccur_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ if (devInfProperty->maxSize) {
+ char *str_maxsize = g_strdup_printf("%u", devInfProperty->maxSize);
+ if (str_maxsize == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *maxsize_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
+ property_node, ELEMENT_MAXSIZE, str_maxsize, strlen(str_maxsize));
+
+ if (str_maxsize != NULL)
+ free(str_maxsize);
+
+ if (maxsize_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ if (devInfProperty->noTruncate) {
+ WBXMLTreeNode *notruncate_node = add_child_wbxml_node_using_xml_name(pBinder,
+ property_node, ELEMENT_NOTRUNCATE);
+ if (notruncate_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ GList *valenum = NULL;
+ char *val = NULL;
+ for (valenum = devInfProperty->valEnums; valenum != NULL; valenum = g_list_next(valenum)) {
+ val = valenum->data;
+ WBXMLTreeNode *valenum_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
+ property_node, ELEMENT_VALENUM, val, strlen(val));
+ if (valenum_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ if (devInfProperty->displayName) {
+ WBXMLTreeNode *displayname_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
+ property_node, ELEMENT_DISPLAYNAME, devInfProperty->displayName, strlen(devInfProperty->displayName));
+ if (displayname_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ GList *propparamIter = NULL;
+ DevInfPropParam *devInfPropParam = NULL;
+ for (propparamIter = devInfProperty->propParams; propparamIter != NULL; propparamIter = g_list_next(propparamIter)) {
+ devInfPropParam = propparamIter->data;
+
+ WBXMLTreeNode *propparam_node = add_child_wbxml_node_using_xml_name(pBinder,
+ property_node, ELEMENT_PROPPARAM);
+ if (propparam_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *paramname_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
+ propparam_node, ELEMENT_PARAMNAME, devInfPropParam->paramName, strlen(devInfPropParam->paramName));
+ if (paramname_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ if (devInfPropParam->dataType) {
+ WBXMLTreeNode *datatype_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
+ propparam_node, ELEMENT_DATATYPE, devInfPropParam->dataType, strlen(devInfPropParam->dataType));
+ if (datatype_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ valenum = NULL;
+ val = NULL;
+ for (valenum = devInfPropParam->valEnums; valenum != NULL; valenum = g_list_next(valenum)) {
+ val = valenum->data;
+ WBXMLTreeNode *valenum_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
+ propparam_node, ELEMENT_VALENUM, val, strlen(val));
+ if (valenum_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ if (devInfPropParam->displayName) {
+ WBXMLTreeNode *displayname_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
+ propparam_node, ELEMENT_DISPLAYNAME, devInfPropParam->displayName, strlen(devInfPropParam->displayName));
+ if (displayname_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+ }
+ }
+ }
+ /*TODO DSMem*/
+
+ if (devInfDataStore->supportsHierarchicalSync) {
+ WBXMLTreeNode *supportshierarchicalsync_node = add_child_wbxml_node_using_xml_name(pBinder,
+ datastore_node, ELEMENT_SUPPORTHIERARCHICALSYNC);
+ if (supportshierarchicalsync_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ WBXMLTreeNode *synccap_node = add_child_wbxml_node_using_xml_name(pBinder,
+ datastore_node, ELEMENT_SYNCCAP);
+ if (synccap_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ if (get_devinf_datastore_synccap(devInfDataStore, DEVINF_SYNCTYPE_TWO_WAY)) {
+ WBXMLTreeNode *synctype_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
+ synccap_node, ELEMENT_SYNCTYPE, ELEMENT_SYNCTYPE_1, strlen(ELEMENT_SYNCTYPE_1));
+ if (synctype_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+ if (get_devinf_datastore_synccap(devInfDataStore, DEVINF_SYNCTYPE_SLOW_SYNC)) {
+ WBXMLTreeNode *synctype_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
+ synccap_node, ELEMENT_SYNCTYPE, ELEMENT_SYNCTYPE_2, strlen(ELEMENT_SYNCTYPE_2));
+ if (synctype_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+ if (get_devinf_datastore_synccap(devInfDataStore, DEVINF_SYNCTYPE_ONE_WAY_FROM_CLIENT)) {
+ WBXMLTreeNode *synctype_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
+ synccap_node, ELEMENT_SYNCTYPE, ELEMENT_SYNCTYPE_3, strlen(ELEMENT_SYNCTYPE_3));
+ if (synctype_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+ if (get_devinf_datastore_synccap(devInfDataStore, DEVINF_SYNCTYPE_REFRESH_FROM_CLIENT)) {
+ WBXMLTreeNode *synctype_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
+ synccap_node, ELEMENT_SYNCTYPE, ELEMENT_SYNCTYPE_4, strlen(ELEMENT_SYNCTYPE_4));
+ if (synctype_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+ if (get_devinf_datastore_synccap(devInfDataStore, DEVINF_SYNCTYPE_ONE_WAY_FROM_SERVER)) {
+ WBXMLTreeNode *synctype_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
+ synccap_node, ELEMENT_SYNCTYPE, ELEMENT_SYNCTYPE_5, strlen(ELEMENT_SYNCTYPE_5));
+ if (synctype_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+ if (get_devinf_datastore_synccap(devInfDataStore, DEVINF_SYNCTYPE_REFRESH_FROM_SERVER)) {
+ WBXMLTreeNode *synctype_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
+ synccap_node, ELEMENT_SYNCTYPE, ELEMENT_SYNCTYPE_6, strlen(ELEMENT_SYNCTYPE_6));
+ if (synctype_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+ if (get_devinf_datastore_synccap(devInfDataStore, DEVINF_SYNCTYPE_SERVER_ALERTED_SYNC)) {
+ WBXMLTreeNode *synctype_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
+ synccap_node, ELEMENT_SYNCTYPE, ELEMENT_SYNCTYPE_7, strlen(ELEMENT_SYNCTYPE_7));
+ if (synctype_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+ /*TODO filter-rx, filterCap*/
+ }
+ undo_switch_protocol(pBinder);
+ *ppWbxml_dom_node = item_node;
+ }
+
+ FW_LOGV("end");
+ return err;
+
+error:
+ FW_LOGE("error : %d", err);
+ return err;
+}
+
+
+static PROTOCOL_BINDER_ERROR __oma_ds_binder_syncml_start_converter_function(protocol_binder *pBinder,
+ Content_Ptr pContent, WBXMLTreeNode **ppWbxml_dom_node)
+{
+ FW_LOGV("start");
+ PROTOCOL_BINDER_ERROR err = PROTOCOL_BINDER_OK;
+ WBXMLTreeNode *syncml_node = create_wbxml_node_using_xml_name(pBinder, ELEMENT_SYNCML);
+ if (syncml_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ *ppWbxml_dom_node = syncml_node;
+
+ FW_LOGV("end");
+ return err;
+
+error:
+ FW_LOGE("error :%d", err);
+ return err;
+}
+
+
+static PROTOCOL_BINDER_ERROR __oma_ds_binder_header_converter_function(protocol_binder *pBinder,
+ Content_Ptr pContent, WBXMLTreeNode **ppWbxml_dom_node)
+{
+ FW_LOGV("start");
+ PROTOCOL_BINDER_ERROR err = PROTOCOL_BINDER_OK;
+ SyncHdr *pSyncHdr = (SyncHdr *)pContent;
+
+ /* add SyncHdr, VerDTD, VerProto node */
+ WBXMLTreeNode *synchdr_node = create_wbxml_node_using_xml_name(pBinder, ELEMENT_SYNCHDR);
+ if (synchdr_node == NULL) {
+ err = PROTOCOL_BINDER_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 = PROTOCOL_BINDER_NOT_DEFINED;
+ goto error;
+ }
+
+ WBXMLTreeNode *verdtd_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
+ synchdr_node, verDTD, verDTD_data, strlen(verDTD_data));
+ if (verdtd_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *verProto_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
+ synchdr_node, verProto, verProto_data, strlen(verProto_data));
+ if (verProto_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ /* session ID */
+ WBXMLTreeNode *sessionID_node = NULL;
+ if (pSyncHdr->sessionID != NULL)
+ sessionID_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
+ synchdr_node, ELEMENT_SESSIONID, pSyncHdr->sessionID, strlen(pSyncHdr->sessionID));
+ else
+ sessionID_node = add_child_wbxml_node_using_xml_name(pBinder,
+ synchdr_node, ELEMENT_SESSIONID);
+
+ if (sessionID_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ /* msgID */
+ char *msgID_data = g_strdup_printf("%u", pSyncHdr->messageID);
+ if (msgID_data == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *msgID_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
+ synchdr_node, ELEMENT_MSGID, msgID_data, strlen(msgID_data));
+
+ if (msgID_data != NULL)
+ free(msgID_data);
+
+ if (msgID_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *target_node = add_child_wbxml_node_using_xml_name(pBinder,
+ synchdr_node, ELEMENT_TARGET);
+ if (target_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ err = __append_location_to_wbxml_node(pSyncHdr->target, pBinder, target_node);
+ if (err != PROTOCOL_BINDER_OK)
+ goto error;
+
+
+ WBXMLTreeNode *source_node = add_child_wbxml_node_using_xml_name(pBinder,
+ synchdr_node, ELEMENT_SOURCE);
+ if (source_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ err = __append_location_to_wbxml_node(pSyncHdr->source, pBinder, source_node);
+ if (err != PROTOCOL_BINDER_OK)
+ goto error;
+
+
+ if (pSyncHdr->responseURI) {
+ WBXMLTreeNode *respuri_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
+ synchdr_node, ELEMENT_RESPURI, pSyncHdr->responseURI, strlen(pSyncHdr->responseURI));
+ if (respuri_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+
+ if (pSyncHdr->noResponse) {
+ WBXMLTreeNode *noResponse_node = add_child_wbxml_node_using_xml_name(pBinder,
+ synchdr_node, ELEMENT_NORESP);
+ if (noResponse_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+
+ if (pSyncHdr->cred) {
+ err = __append_cred_to_wbxml_node(pSyncHdr->cred, pBinder, synchdr_node);
+ if (err != PROTOCOL_BINDER_OK)
+ goto error;
+ }
+
+
+ char *meta = ELEMENT_META;
+ if (pSyncHdr->maxmsgsize != 0 || pSyncHdr->maxobjsize != 0) {
+ WBXMLTreeNode *meta_node = add_child_wbxml_node_using_xml_name(pBinder,
+ synchdr_node, meta);
+ if (meta_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ unsigned int maxmsgsize = pSyncHdr->maxmsgsize;
+ unsigned int maxobjsize = pSyncHdr->maxobjsize;
+
+
+ if (maxmsgsize != 0) {
+ char *str_maxmsgsize = g_strdup_printf("%u", maxmsgsize);
+ if (str_maxmsgsize == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *maxmsgsize_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
+ meta_node, ELEMENT_MAXMSGSIZE, str_maxmsgsize, strlen(str_maxmsgsize));
+ if (str_maxmsgsize != NULL)
+ free(str_maxmsgsize);
+
+ if (maxmsgsize_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ if (maxobjsize != 0) {
+ char *str_maxobjsize = g_strdup_printf("%u", maxobjsize);
+ if (str_maxobjsize == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *maxobjsize_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
+ meta_node, ELEMENT_MAXOBJSIZE, str_maxobjsize, strlen(str_maxobjsize));
+ if (str_maxobjsize != NULL)
+ free(str_maxobjsize);
+
+ if (maxobjsize_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+ }
+
+ *ppWbxml_dom_node = synchdr_node;
+
+ FW_LOGV("end");
+ return err;
+
+error:
+ FW_LOGE("error :%d", err);
+ return err;
+}
+
+static PROTOCOL_BINDER_ERROR __oma_ds_binder_final_converter_function(protocol_binder *pBinder,
+ Content_Ptr pContent,
+ WBXMLTreeNode **ppWbxml_dom_node)
+{
+ FW_LOGV("start");
+ PROTOCOL_BINDER_ERROR err = PROTOCOL_BINDER_OK;
+
+ WBXMLTreeNode *final_node = create_wbxml_node_using_xml_name(pBinder, "Final");
+ if (final_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ *ppWbxml_dom_node = final_node;
+
+ FW_LOGV("end");
+ return err;
+
+error:
+ FW_LOGE("error :%d", err);
+ return err;
+
+}
+
+
+static PROTOCOL_BINDER_ERROR __oma_ds_binder_body_start_converter_function(protocol_binder *pBinder,
+ Content_Ptr pContent, WBXMLTreeNode **ppWbxml_dom_node)
+{
+ FW_LOGV("start");
+ PROTOCOL_BINDER_ERROR err = PROTOCOL_BINDER_OK;
+
+ WBXMLTreeNode *syncbody_node = create_wbxml_node_using_xml_name(pBinder, ELEMENT_SYNCBODY);
+ if (syncbody_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ *ppWbxml_dom_node = syncbody_node;
+
+ FW_LOGV("end");
+ return err;
+
+error:
+ FW_LOGE("error :%d", err);
+ return err;
+}
+
+static PROTOCOL_BINDER_ERROR __oma_ds_binder_status_converter_function(protocol_binder *pBinder,
+ Content_Ptr pContent, WBXMLTreeNode **ppWbxml_dom_node)
+{
+ FW_LOGV("start");
+ PROTOCOL_BINDER_ERROR err = PROTOCOL_BINDER_OK;
+
+ Status *pStatus = (Status *)pContent;
+ assert(pStatus != NULL);
+
+ CommandType type = pStatus->type;
+
+ char *str_cmdID = NULL;
+ char *str_msgRef = NULL;
+ char *str_cmdRef = NULL;
+
+ WBXMLTreeNode *status_node = create_wbxml_node_using_xml_name(pBinder, ELEMENT_STATUS);
+ if (status_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ unsigned int cmdID = pStatus->cmdID;
+ str_cmdID = g_strdup_printf("%u", cmdID);
+ if (str_cmdID == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *cmdid_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
+ status_node, ELEMENT_CMDID, str_cmdID, strlen(str_cmdID));
+ if (cmdid_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ unsigned int msgRef = pStatus->msgRef;
+ str_msgRef = g_strdup_printf("%u", msgRef);
+ if (str_msgRef == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *msgref_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
+ status_node, ELEMENT_MSGREF, str_msgRef, strlen(str_msgRef));
+ if (msgref_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ unsigned int cmdRef = pStatus->cmdRef;
+ str_cmdRef = g_strdup_printf("%u", cmdRef);
+ if (str_cmdRef == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *cmdref_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
+ status_node, ELEMENT_CMDREF, str_cmdRef, strlen(str_cmdRef));
+ if (cmdref_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ 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 = PROTOCOL_BINDER_NOT_DEFINED;
+ goto error;
+ }
+
+ WBXMLTreeNode *command_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
+ status_node, ELEMENT_CMD, str_command, strlen(str_command));
+ if (command_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ if (pStatus->targetRef) {
+ WBXMLTreeNode *targetref_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
+ status_node, ELEMENT_TARGETREF, pStatus->targetRef->locURI, strlen(pStatus->targetRef->locURI));
+ if (targetref_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ if (pStatus->sourceRef) {
+ WBXMLTreeNode *sourceref_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
+ status_node, ELEMENT_SOURCEREF, pStatus->sourceRef->locURI, strlen(pStatus->sourceRef->locURI));
+ if (sourceref_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ if (pStatus->cred) {
+ err = __append_cred_to_wbxml_node(pStatus->cred, pBinder, status_node);
+ if (err != PROTOCOL_BINDER_OK)
+ goto error;
+ }
+
+ if (pStatus->chal) {
+ /*TODO chal*/
+ }
+
+ WBXMLTreeNode *data_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
+ status_node, ELEMENT_DATA, pStatus->data, strlen(pStatus->data));
+ if (data_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ if (type == COMMAND_TYPE_ALERT) {
+ if (pStatus->item) {
+ WBXMLTreeNode *item_node = add_child_wbxml_node_using_xml_name(pBinder,
+ status_node, ELEMENT_ITEM);
+ if (item_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *item_data_node = add_child_wbxml_node_using_xml_name(pBinder,
+ item_node, ELEMENT_DATA);
+ if (item_data_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *item_data_Anchor_node = add_child_wbxml_node_using_xml_name(pBinder,
+ item_data_node, ELEMENT_ANCHOR);
+ if (item_data_Anchor_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ if (pStatus->item->anchor) {
+ WBXMLTreeNode *item_data_Anchor_Next_node =
+ add_child_wbxml_node_using_xml_name_with_text(pBinder,
+ item_data_Anchor_node, ELEMENT_NEXT, pStatus->item->anchor->nextAnchor,
+ strlen(pStatus->item->anchor->nextAnchor));
+
+ if (item_data_Anchor_Next_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+ }
+ }
+
+ if (str_cmdID != NULL)
+ free(str_cmdID);
+
+ if (str_cmdRef != NULL)
+ free(str_cmdRef);
+
+ if (str_msgRef != NULL)
+ free(str_msgRef);
+
+ *ppWbxml_dom_node = status_node;
+
+ FW_LOGV("end");
+ return err;
+
+error:
+
+ if (str_cmdID != NULL)
+ free(str_cmdID);
+
+ if (str_cmdRef != NULL)
+ free(str_cmdRef);
+
+ if (str_msgRef != NULL)
+ free(str_msgRef);
+
+ FW_LOGE("error :%d", err);
+ return err;
+
+}
+
+static PROTOCOL_BINDER_ERROR __oma_ds_binder_alert_command_converter_function(protocol_binder *pBinder,
+ Content_Ptr pContent, WBXMLTreeNode **ppWbxml_dom_node)
+{
+ FW_LOGV("start");
+ PROTOCOL_BINDER_ERROR err = PROTOCOL_BINDER_OK;
+
+ Command *pCommand = (Command *)pContent;
+
+ CommandAlertPrivate *pAlert = (CommandAlertPrivate *)(&(pCommand->private));
+
+ char *str_cmdID = NULL;
+ char *str_alert_type = NULL;
+
+ if (!pAlert) {
+ err = PROTOCOL_BINDER_NOT_DEFINED;
+ goto error;
+ }
+
+ if (pAlert->type == ALERT_UNKNOWN) {
+ /* error case */
+ err = PROTOCOL_BINDER_INVALID_INPUT_PARAMETER;
+ goto error;
+ }
+
+ WBXMLTreeNode *alert_node = create_wbxml_node_using_xml_name(pBinder, ELEMENT_ALERT);
+ if (alert_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ str_cmdID = g_strdup_printf("%u", pCommand->cmdID);
+ if (str_cmdID == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *cmdid_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
+ alert_node, ELEMENT_CMDID, str_cmdID, strlen(str_cmdID));
+ if (cmdid_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ if (pCommand->noResp) {
+ WBXMLTreeNode *noResp_node = add_child_wbxml_node_using_xml_name(pBinder,
+ alert_node, ELEMENT_NORESP);
+ if (noResp_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ if (pCommand->cred) {
+ err = __append_cred_to_wbxml_node(pCommand->cred, pBinder, alert_node);
+ if (err != PROTOCOL_BINDER_OK)
+ goto error;
+ }
+
+ str_alert_type = g_strdup_printf("%u", pAlert->type);
+ if (str_alert_type == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *data_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
+ alert_node, ELEMENT_DATA, str_alert_type, strlen(str_alert_type));
+ if (data_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ /* item */
+ if (pCommand->source != NULL && pCommand->target != NULL) {
+ WBXMLTreeNode *item_node = add_child_wbxml_node_using_xml_name(pBinder,
+ alert_node, ELEMENT_ITEM);
+ if (item_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *target_node = add_child_wbxml_node_using_xml_name(pBinder,
+ item_node, ELEMENT_TARGET);
+ if (target_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ err = __append_location_to_wbxml_node(pCommand->target, pBinder, target_node);
+ if (err != PROTOCOL_BINDER_OK)
+ goto error;
+
+
+ WBXMLTreeNode *source_node = add_child_wbxml_node_using_xml_name(pBinder,
+ item_node, ELEMENT_SOURCE);
+ if (source_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ err = __append_location_to_wbxml_node(pCommand->source, pBinder, source_node);
+ if (err != PROTOCOL_BINDER_OK)
+ goto error;
+
+
+ if (pAlert->anchor != NULL) {
+ err = __append_anchor_to_wbxml_node(pAlert->anchor, pBinder, item_node);
+ if (err != PROTOCOL_BINDER_OK)
+ goto error;
+ }
+ }
+
+ if (str_cmdID != NULL)
+ free(str_cmdID);
+
+ if (str_alert_type != NULL)
+ free(str_alert_type);
+
+ *ppWbxml_dom_node = alert_node;
+
+ FW_LOGV("end");
+ return err;
+
+error:
+
+ if (str_cmdID != NULL)
+ free(str_cmdID);
+
+ if (str_alert_type != NULL)
+ free(str_alert_type);
+
+ FW_LOGE("error :%d", err);
+ return err;
+}
+
+static PROTOCOL_BINDER_ERROR __oma_ds_binder_results_command_converter_function(protocol_binder *pBinder,
+ Content_Ptr pContent, WBXMLTreeNode **ppWbxml_dom_node)
+{
+ FW_LOGV("start");
+ PROTOCOL_BINDER_ERROR err = PROTOCOL_BINDER_OK;
+
+ Command *pCommand = (Command *)pContent;
+ CommandResultsPrivate *pResults = (CommandResultsPrivate *)(&(pCommand->private));
+
+ char *str_cmdID = NULL;
+ char *str_cmdRef = NULL;
+ char *str_msgRef = NULL;
+
+ if (!pResults) {
+ err = PROTOCOL_BINDER_NOT_DEFINED;
+ goto error;
+ }
+
+ if (pResults->item == NULL) {
+ err = PROTOCOL_BINDER_NOT_DEFINED;
+ goto error;
+ }
+
+ char *content_type = (pResults->item)->contenttype;
+ if (!content_type) {
+ /* error case */
+ err = PROTOCOL_BINDER_NOT_DEFINED;
+ goto error;
+ }
+
+
+ WBXMLTreeNode *results_node = create_wbxml_node_using_xml_name(pBinder, ELEMENT_RESULTS);
+ if (results_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ str_cmdID = g_strdup_printf("%u", pCommand->cmdID);
+ if (str_cmdID != NULL) {
+ WBXMLTreeNode *cmdid_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
+ results_node, ELEMENT_CMDID, str_cmdID, strlen(str_cmdID));
+ if (cmdid_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+
+ if (pResults->msgRef) {
+ str_msgRef = g_strdup_printf("%u", pResults->msgRef);
+ if (str_msgRef == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *msgref_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
+ results_node, ELEMENT_MSGREF, str_msgRef, strlen(str_msgRef));
+ if (msgref_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ str_cmdRef = g_strdup_printf("%u", pResults->cmdRef);
+ if (str_cmdRef == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *msgref_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
+ results_node, ELEMENT_CMDREF, str_cmdRef, strlen(str_cmdRef));
+ if (msgref_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ if (content_type) {
+ WBXMLTreeNode *meta_node = add_child_wbxml_node_using_xml_name(pBinder,
+ results_node, ELEMENT_META);
+ if (meta_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *type_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
+ meta_node, ELEMENT_TYPE, content_type, strlen(content_type));
+ if (type_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ if (pResults->targetRef) {
+ WBXMLTreeNode *targetref_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
+ results_node, ELEMENT_TARGETREF, pResults->targetRef->locURI, strlen(pResults->targetRef->locURI));
+ if (targetref_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ if (str_cmdID != NULL)
+ free(str_cmdID);
+
+ if (str_cmdRef != NULL)
+ free(str_cmdRef);
+
+ if (str_msgRef != NULL)
+ free(str_msgRef);
+
+ *ppWbxml_dom_node = results_node;
+
+ FW_LOGV("end");
+ return err;
+
+error:
+
+ if (str_cmdID != NULL)
+ free(str_cmdID);
+
+ if (str_cmdRef != NULL)
+ free(str_cmdRef);
+
+ if (str_msgRef != NULL)
+ free(str_msgRef);
+
+ FW_LOGE("error :%d", err);
+ return err;
+}
+
+
+static PROTOCOL_BINDER_ERROR __oma_ds_binder_put_command_converter_function(protocol_binder *pBinder,
+ Content_Ptr pContent, WBXMLTreeNode **ppWbxml_dom_node)
+{
+ FW_LOGV("start");
+ PROTOCOL_BINDER_ERROR err = PROTOCOL_BINDER_OK;
+
+ Command *pCommand = (Command *)pContent;
+ CommandAccessPrivate *pAccess = (CommandAccessPrivate *)(&(pCommand->private));
+ char *str_cmdID = NULL;
+
+ if (!pAccess) {
+ err = PROTOCOL_BINDER_NOT_DEFINED;
+ goto error;
+ }
+
+ char *content_type = (pAccess->item)->contenttype;
+ if (!content_type) {
+ /* error case */
+ err = PROTOCOL_BINDER_NOT_DEFINED;
+ goto error;
+ }
+
+ WBXMLTreeNode *put_node = create_wbxml_node_using_xml_name(pBinder, ELEMENT_PUT);
+ if (put_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ str_cmdID = g_strdup_printf("%u", pCommand->cmdID);
+ if (str_cmdID == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *cmdid_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
+ put_node, ELEMENT_CMDID, str_cmdID, strlen(str_cmdID));
+ if (cmdid_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ if (pCommand->noResp) {
+ WBXMLTreeNode *noResp_node = add_child_wbxml_node_using_xml_name(pBinder,
+ put_node, ELEMENT_NORESP);
+ if (noResp_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ if (pCommand->cred) {
+ err = __append_cred_to_wbxml_node(pCommand->cred, pBinder, put_node);
+ if (err != PROTOCOL_BINDER_OK)
+ goto error;
+ }
+
+ if (content_type) {
+ WBXMLTreeNode *meta_node = add_child_wbxml_node_using_xml_name(pBinder,
+ put_node, ELEMENT_META);
+ if (meta_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *type_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
+ meta_node, ELEMENT_TYPE, content_type, strlen(content_type));
+ if (type_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ if (str_cmdID != NULL)
+ free(str_cmdID);
+
+ *ppWbxml_dom_node = put_node;
+
+ FW_LOGV("end");
+ return err;
+
+error:
+
+ if (str_cmdID != NULL)
+ free(str_cmdID);
+
+ FW_LOGE("error :%d", err);
+ return err;
+}
+
+static PROTOCOL_BINDER_ERROR __oma_ds_binder_get_command_converter_function(protocol_binder *pBinder,
+ Content_Ptr pContent, WBXMLTreeNode **ppWbxml_dom_node)
+{
+ FW_LOGV("start");
+ PROTOCOL_BINDER_ERROR err = PROTOCOL_BINDER_OK;
+
+ Command *pCommand = (Command *)pContent;
+ CommandAccessPrivate *pAccess = (CommandAccessPrivate *)(&(pCommand->private));
+ char *str_cmdID = NULL;
+
+ if (!pAccess) {
+ err = PROTOCOL_BINDER_NOT_DEFINED;
+ goto error;
+ }
+
+ if (!pAccess->item) {
+ err = PROTOCOL_BINDER_NOT_DEFINED;
+ goto error;
+ }
+
+ char *content_type = (pAccess->item)->contenttype;
+
+ if (!content_type) {
+ /* error case */
+ err = PROTOCOL_BINDER_NOT_DEFINED;
+ goto error;
+ }
+
+ WBXMLTreeNode *get_node = create_wbxml_node_using_xml_name(pBinder, ELEMENT_GET);
+
+ str_cmdID = g_strdup_printf("%u", pCommand->cmdID);
+ if (str_cmdID == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *cmdid_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
+ get_node, ELEMENT_CMDID, str_cmdID, strlen(str_cmdID));
+ if (cmdid_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ if (pCommand->noResp) {
+ WBXMLTreeNode *noResp_node = add_child_wbxml_node_using_xml_name(pBinder,
+ get_node, ELEMENT_NORESP);
+ if (noResp_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ if (pCommand->cred) {
+ err = __append_cred_to_wbxml_node(pCommand->cred, pBinder, get_node);
+ if (err != PROTOCOL_BINDER_OK)
+ goto error;
+ }
+
+ if (content_type) {
+ WBXMLTreeNode *meta_node = add_child_wbxml_node_using_xml_name(pBinder,
+ get_node, ELEMENT_META);
+ if (meta_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *type_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
+ meta_node, ELEMENT_TYPE, content_type, strlen(content_type));
+ if (type_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ if (pAccess->item) {
+ WBXMLTreeNode *item_node = add_child_wbxml_node_using_xml_name(pBinder,
+ get_node, ELEMENT_ITEM);
+ if (item_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *target_node = add_child_wbxml_node_using_xml_name(pBinder,
+ item_node, ELEMENT_TARGET);
+ if (target_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ err = __append_location_to_wbxml_node(pAccess->item->target, pBinder, target_node);
+ if (err != PROTOCOL_BINDER_OK)
+ goto error;
+ }
+
+ *ppWbxml_dom_node = get_node;
+
+ if (str_cmdID)
+ free(str_cmdID);
+
+ FW_LOGV("end");
+ return err;
+
+error:
+ if (str_cmdID)
+ free(str_cmdID);
+
+ FW_LOGE("error :%d", err);
+ return err;
+}
+
+static PROTOCOL_BINDER_ERROR __oma_ds_binder_sync_start_command_converter_function(protocol_binder *pBinder,
+ Content_Ptr pContent, WBXMLTreeNode **ppWbxml_dom_node)
+{
+ FW_LOGV("start");
+ PROTOCOL_BINDER_ERROR err = PROTOCOL_BINDER_OK;
+
+ Command *pCommand = (Command *)pContent;
+
+ char *str_cmdID = NULL;
+ char *numChanged_str = NULL;
+
+ WBXMLTreeNode *sync_node = create_wbxml_node_using_xml_name(pBinder, ELEMENT_SYNC);
+ if (sync_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ str_cmdID = g_strdup_printf("%u", pCommand->cmdID);
+ if (str_cmdID == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *cmdid_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
+ sync_node, ELEMENT_CMDID, str_cmdID, strlen(str_cmdID));
+ if (cmdid_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ if (pCommand->noResp) {
+ WBXMLTreeNode *noResp_node = add_child_wbxml_node_using_xml_name(pBinder,
+ sync_node, ELEMENT_NORESP);
+ if (noResp_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ if (pCommand->cred) {
+ err = __append_cred_to_wbxml_node(pCommand->cred, pBinder, sync_node);
+ if (err != PROTOCOL_BINDER_OK)
+ goto error;
+ }
+
+ if (pCommand->source != NULL && pCommand->target != NULL) {
+ WBXMLTreeNode *target_node = add_child_wbxml_node_using_xml_name(pBinder,
+ sync_node, ELEMENT_TARGET);
+ if (target_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ err = __append_location_to_wbxml_node(pCommand->target, pBinder, target_node);
+ if (err != PROTOCOL_BINDER_OK)
+ goto error;
+
+
+ WBXMLTreeNode *source_node = add_child_wbxml_node_using_xml_name(pBinder,
+ sync_node, ELEMENT_SOURCE);
+ if (source_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ err = __append_location_to_wbxml_node(pCommand->source, pBinder, source_node);
+ if (err != PROTOCOL_BINDER_OK)
+ goto error;
+
+ }
+
+ if (pCommand->private.sync.hasNumChanged) {
+ numChanged_str = g_strdup_printf("%u", pCommand->private.sync.numChanged);
+ if (numChanged_str == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *numberOfChanges_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
+ sync_node, ELEMENT_NUMBEROFCHANGES, numChanged_str, strlen(numChanged_str));
+ if (numberOfChanges_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ if (str_cmdID != NULL)
+ free(str_cmdID);
+
+ if (numChanged_str != NULL)
+ free(numChanged_str);
+
+ *ppWbxml_dom_node = sync_node;
+
+ FW_LOGV("end");
+ return err;
+
+error:
+
+ if (str_cmdID != NULL)
+ free(str_cmdID);
+
+ if (numChanged_str != NULL)
+ free(numChanged_str);
+
+ FW_LOGE("error :%d", err);
+ return err;
+}
+
+
+static PROTOCOL_BINDER_ERROR __oma_ds_binder_sync_end_command_converter_function(protocol_binder *pBinder,
+ Content_Ptr pContent, WBXMLTreeNode **ppWbxml_dom_node)
+{
+ FW_LOGV("start");
+
+ PROTOCOL_BINDER_ERROR err = PROTOCOL_BINDER_OK;
+
+ FW_LOGV("end");
+
+ return err;
+}
+
+static PROTOCOL_BINDER_ERROR __oma_ds_binder_add_command_converter_function(protocol_binder *pBinder,
+ Content_Ptr pContent, WBXMLTreeNode **ppWbxml_dom_node)
+{
+ FW_LOGV("start");
+ PROTOCOL_BINDER_ERROR err = PROTOCOL_BINDER_OK;
+
+ char *str_cmdID = NULL;
+ char *str_size = NULL;
+
+ Command *pCommand = (Command *)pContent;
+
+ CommandChangePrivate *pChange = (CommandChangePrivate *)(&(pCommand->private));
+
+ if (!pChange) {
+ err = PROTOCOL_BINDER_NOT_DEFINED;
+ goto error;
+ }
+
+ WBXMLTreeNode *add_node = create_wbxml_node_using_xml_name(pBinder, ELEMENT_ADD);
+ if (add_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ str_cmdID = g_strdup_printf("%u", pCommand->cmdID);
+ if (str_cmdID == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *cmdid_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
+ add_node, ELEMENT_CMDID, str_cmdID, strlen(str_cmdID));
+ if (cmdid_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ if (pCommand->noResp) {
+ WBXMLTreeNode *noResp_node = add_child_wbxml_node_using_xml_name(pBinder,
+ add_node, ELEMENT_NORESP);
+ if (noResp_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ if (pCommand->cred) {
+ err = __append_cred_to_wbxml_node(pCommand->cred, pBinder, add_node);
+ if (err != PROTOCOL_BINDER_OK)
+ goto error;
+ }
+
+ GList *Iter = NULL;
+ Item *item = NULL;
+ for (Iter = pChange->items; Iter != NULL; Iter = g_list_next(Iter)) {
+ item = (Iter->data);
+
+ WBXMLTreeNode *item_node = add_child_wbxml_node_using_xml_name(pBinder,
+ add_node, ELEMENT_ITEM);
+ if (item_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ if (item->source != NULL) {
+ WBXMLTreeNode *source_node = add_child_wbxml_node_using_xml_name(pBinder,
+ item_node, ELEMENT_SOURCE);
+ if (source_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ err = __append_location_to_wbxml_node(item->source, pBinder, source_node);
+ if (err != PROTOCOL_BINDER_OK)
+ goto error;
+
+ }
+
+ if (item->target != NULL) {
+ WBXMLTreeNode *target_node = add_child_wbxml_node_using_xml_name(pBinder,
+ item_node, ELEMENT_TARGET);
+ if (target_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ err = __append_location_to_wbxml_node(item->target, pBinder, target_node);
+ if (err != PROTOCOL_BINDER_OK)
+ goto error;
+ }
+
+ if (item->contenttype) {
+ WBXMLTreeNode *meta_node = add_child_wbxml_node_using_xml_name(pBinder,
+ item_node, ELEMENT_META);
+ if (meta_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *type_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
+ meta_node, ELEMENT_TYPE, item->contenttype, strlen(item->contenttype));
+ if (type_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ if (item->moreData) {
+ if (item->size) {
+ str_size = g_strdup_printf("%u", item->size);
+ if (str_size == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *size_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
+ meta_node, ELEMENT_SIZE, str_size, strlen(str_size));
+ if (size_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+ }
+ }
+
+ if (item->dataType == ITEM_DATA) {
+ if (item->private.data) {
+ WBXMLTreeNode *data_node = add_child_wbxml_node_using_xml_name_with_cdata(pBinder,
+ item_node, ELEMENT_DATA, item->private.data, strlen(item->private.data));
+ if (data_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+ }
+
+ if (item->moreData) {
+ WBXMLTreeNode *moredata_node = add_child_wbxml_node_using_xml_name(pBinder,
+ item_node, ELEMENT_MOREDATA);
+ if (moredata_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+ }
+
+ if (str_cmdID != NULL)
+ free(str_cmdID);
+
+ if (str_size != NULL)
+ free(str_size);
+
+ *ppWbxml_dom_node = add_node;
+
+ FW_LOGV("end");
+ return err;
+
+error:
+
+ if (str_cmdID != NULL)
+ free(str_cmdID);
+
+ if (str_size != NULL)
+ free(str_size);
+
+ FW_LOGE("error :%d", err);
+ return err;
+}
+
+static PROTOCOL_BINDER_ERROR __oma_ds_binder_replace_command_converter_function(protocol_binder *pBinder,
+ Content_Ptr pContent, WBXMLTreeNode **ppWbxml_dom_node)
+{
+ FW_LOGV("start");
+ PROTOCOL_BINDER_ERROR err = PROTOCOL_BINDER_OK;
+
+ char *str_cmdID = NULL;
+ char *str_size = NULL;
+
+ Command *pCommand = (Command *)pContent;
+
+ CommandChangePrivate *pChange = (CommandChangePrivate *)(&(pCommand->private));
+
+ if (!pChange) {
+ err = PROTOCOL_BINDER_NOT_DEFINED;
+ goto error;
+ }
+
+ WBXMLTreeNode *replace_node = create_wbxml_node_using_xml_name(pBinder, ELEMENT_REPLACE);
+ if (replace_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ str_cmdID = g_strdup_printf("%u", pCommand->cmdID);
+ if (str_cmdID == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *cmdid_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
+ replace_node, ELEMENT_CMDID, str_cmdID, strlen(str_cmdID));
+ if (cmdid_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ if (pCommand->noResp) {
+ WBXMLTreeNode *noResp_node = add_child_wbxml_node_using_xml_name(pBinder,
+ replace_node, ELEMENT_NORESP);
+ if (noResp_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ if (pCommand->cred) {
+ err = __append_cred_to_wbxml_node(pCommand->cred, pBinder, replace_node);
+ if (err != PROTOCOL_BINDER_OK)
+ goto error;
+ }
+
+ GList *Iter = NULL;
+ Item *item = NULL;
+ for (Iter = pChange->items; Iter != NULL; Iter = g_list_next(Iter)) {
+ item = (Iter->data);
+
+ WBXMLTreeNode *item_node = add_child_wbxml_node_using_xml_name(pBinder,
+ replace_node, ELEMENT_ITEM);
+ if (item_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ if (item->source != NULL) {
+ WBXMLTreeNode *source_node = add_child_wbxml_node_using_xml_name(pBinder,
+ item_node, ELEMENT_SOURCE);
+ if (source_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+ err = __append_location_to_wbxml_node(item->source, pBinder, source_node);
+ if (err != PROTOCOL_BINDER_OK)
+ goto error;
+
+ }
+
+ if (item->target != NULL) {
+ WBXMLTreeNode *target_node = add_child_wbxml_node_using_xml_name(pBinder,
+ item_node, ELEMENT_TARGET);
+ if (target_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+ err = __append_location_to_wbxml_node(item->target, pBinder, target_node);
+ if (err != PROTOCOL_BINDER_OK)
+ goto error;
+
+ }
+
+ if (item->contenttype) {
+ WBXMLTreeNode *meta_node = add_child_wbxml_node_using_xml_name(pBinder,
+ item_node, ELEMENT_META);
+ if (meta_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *type_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
+ meta_node, ELEMENT_TYPE, item->contenttype, strlen(item->contenttype));
+ if (type_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ if (item->moreData) {
+ if (item->size) {
+ str_size = g_strdup_printf("%u", item->size);
+ if (str_size == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *size_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
+ meta_node, ELEMENT_SIZE, str_size, strlen(str_size));
+ if (size_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+ }
+ }
+
+ if (item->dataType == ITEM_DATA) {
+ if (item->private.data) {
+ WBXMLTreeNode *data_node = add_child_wbxml_node_using_xml_name_with_cdata(pBinder,
+ item_node, ELEMENT_DATA, item->private.data, strlen(item->private.data));
+ if (data_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+ }
+
+ if (item->moreData) {
+ WBXMLTreeNode *moredata_node = add_child_wbxml_node_using_xml_name(pBinder,
+ item_node, ELEMENT_MOREDATA);
+ if (moredata_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ }
+
+ if (str_cmdID != NULL)
+ free(str_cmdID);
+
+ if (str_size != NULL)
+ free(str_size);
+
+ *ppWbxml_dom_node = replace_node;
+
+ FW_LOGV("end");
+ return err;
+
+error:
+
+ if (str_cmdID != NULL)
+ free(str_cmdID);
+
+ if (str_size != NULL)
+ free(str_size);
+
+ FW_LOGE("error :%d", err);
+ return err;
+}
+
+static PROTOCOL_BINDER_ERROR __oma_ds_binder_delete_command_converter_function(protocol_binder *pBinder,
+ Content_Ptr pContent, WBXMLTreeNode **ppWbxml_dom_node)
+{
+ FW_LOGV("start");
+ PROTOCOL_BINDER_ERROR err = PROTOCOL_BINDER_OK;
+
+ char *str_cmdID = NULL;
+ char *str_size = NULL;
+
+ Command *pCommand = (Command *)pContent;
+
+ CommandChangePrivate *pChange = (CommandChangePrivate *)(&(pCommand->private));
+
+ if (!pChange) {
+ err = PROTOCOL_BINDER_NOT_DEFINED;
+ goto error;
+ }
+
+ WBXMLTreeNode *delete_node = create_wbxml_node_using_xml_name(pBinder, ELEMENT_DELETE);
+ if (delete_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ str_cmdID = g_strdup_printf("%u", pCommand->cmdID);
+ if (str_cmdID == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *cmdid_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
+ delete_node, ELEMENT_CMDID, str_cmdID, strlen(str_cmdID));
+ if (cmdid_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ if (pCommand->noResp) {
+ WBXMLTreeNode *noResp_node = add_child_wbxml_node_using_xml_name(pBinder,
+ delete_node, ELEMENT_NORESP);
+ if (noResp_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ /*TODO Archive*/
+ /*TODO sftDel*/
+
+ if (pCommand->cred) {
+ err = __append_cred_to_wbxml_node(pCommand->cred, pBinder, delete_node);
+ if (err != PROTOCOL_BINDER_OK)
+ goto error;
+ }
+
+ GList *Iter = NULL;
+ Item *item = NULL;
+ for (Iter = pCommand->private.change.items; Iter != NULL; Iter = g_list_next(Iter)) {
+ item = (Iter->data);
+
+ WBXMLTreeNode *item_node = add_child_wbxml_node_using_xml_name(pBinder,
+ delete_node, ELEMENT_ITEM);
+ if (item_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ if (item->source != NULL) {
+ WBXMLTreeNode *source_node = add_child_wbxml_node_using_xml_name(pBinder,
+ item_node, ELEMENT_SOURCE);
+ if (source_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ err = __append_location_to_wbxml_node(item->source, pBinder, source_node);
+ if (err != PROTOCOL_BINDER_OK)
+ goto error;
+
+ }
+
+ if (item->target != NULL) {
+ WBXMLTreeNode *target_node = add_child_wbxml_node_using_xml_name(pBinder,
+ item_node, ELEMENT_TARGET);
+ if (target_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ err = __append_location_to_wbxml_node(item->target, pBinder, target_node);
+ if (err != PROTOCOL_BINDER_OK)
+ goto error;
+
+ }
+
+ if (item->contenttype) {
+ WBXMLTreeNode *meta_node = add_child_wbxml_node_using_xml_name(pBinder,
+ item_node, ELEMENT_META);
+ if (meta_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *type_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
+ meta_node, ELEMENT_TYPE, item->contenttype, strlen(item->contenttype));
+ if (type_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ if (item->size) {
+ str_size = g_strdup_printf("%u", item->size);
+ if (str_size == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *size_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
+ meta_node, ELEMENT_SIZE, str_size, strlen(str_size));
+ if (size_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+ }
+ }
+
+ if (str_cmdID != NULL)
+ free(str_cmdID);
+
+ if (str_size != NULL)
+ free(str_size);
+
+ *ppWbxml_dom_node = delete_node;
+
+ FW_LOGV("end");
+ return err;
+
+error:
+
+ if (str_cmdID != NULL)
+ free(str_cmdID);
+
+ if (str_size != NULL)
+ free(str_size);
+
+ FW_LOGE("error :%d", err);
+ return err;
+}
+
+static PROTOCOL_BINDER_ERROR __oma_ds_binder_map_command_converter_function(protocol_binder *pBinder,
+ Content_Ptr pContent, WBXMLTreeNode **ppWbxml_dom_node)
+{
+ FW_LOGV("start");
+ PROTOCOL_BINDER_ERROR err = PROTOCOL_BINDER_OK;
+ char *str_cmdID = NULL;
+
+ Command *pCommand = (Command *)pContent;
+
+ WBXMLTreeNode *map_node = create_wbxml_node_using_xml_name(pBinder, ELEMENT_MAP);
+
+ str_cmdID = g_strdup_printf("%u", pCommand->cmdID);
+ if (str_cmdID == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *cmdid_node = add_child_wbxml_node_using_xml_name_with_text(pBinder,
+ map_node, ELEMENT_CMDID, str_cmdID, strlen(str_cmdID));
+ if (cmdid_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ if (pCommand->source != NULL && pCommand->target != NULL) {
+ WBXMLTreeNode *target_node = add_child_wbxml_node_using_xml_name(pBinder,
+ map_node, ELEMENT_TARGET);
+ if (target_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ err = __append_location_to_wbxml_node(pCommand->target, pBinder, target_node);
+ if (err != PROTOCOL_BINDER_OK)
+ goto error;
+
+
+ WBXMLTreeNode *source_node = add_child_wbxml_node_using_xml_name(pBinder,
+ map_node, ELEMENT_SOURCE);
+ if (source_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ err = __append_location_to_wbxml_node(pCommand->source, pBinder, source_node);
+ if (err != PROTOCOL_BINDER_OK)
+ goto error;
+
+ }
+
+ if (pCommand->cred) {
+ err = __append_cred_to_wbxml_node(pCommand->cred, pBinder, map_node);
+ if (err != PROTOCOL_BINDER_OK)
+ goto error;
+ }
+
+ GList *iter = NULL;
+ Item *item = NULL;
+ for (iter = pCommand->private.map.items; iter != NULL; iter = g_list_next(iter)) {
+ item = iter->data;
+ WBXMLTreeNode *mapItem_node = add_child_wbxml_node_using_xml_name(pBinder,
+ map_node, ELEMENT_MAPITEM);
+ if (mapItem_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ if (item->source != NULL && item->target != NULL) {
+ WBXMLTreeNode *item_target_node = add_child_wbxml_node_using_xml_name(pBinder,
+ mapItem_node, ELEMENT_TARGET);
+ if (item_target_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ err = __append_location_to_wbxml_node(item->target, pBinder, item_target_node);
+ if (err != PROTOCOL_BINDER_OK)
+ goto error;
+
+
+ WBXMLTreeNode *item_source_node = add_child_wbxml_node_using_xml_name(pBinder,
+ mapItem_node, ELEMENT_SOURCE);
+ if (item_source_node == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ err = __append_location_to_wbxml_node(item->source, pBinder, item_source_node);
+ if (err != PROTOCOL_BINDER_OK)
+ goto error;
+
+ }
+ }
+
+ if (str_cmdID != NULL)
+ free(str_cmdID);
+
+ *ppWbxml_dom_node = map_node;
+
+ FW_LOGV("end");
+ return err;
+
+error:
+
+ if (str_cmdID != NULL)
+ free(str_cmdID);
+
+ FW_LOGE("error :%d", err);
+ return err;
+}
+
+static ProtocolVersion __get_oma_ds_protocol_version(char *verdtd)
+{
+ ProtocolVersion 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;
+ }
+
+ return protocol_version;
+}
+
+static DevInfVersion __get_oma_ds_devInf_version(char *verdtd)
+{
+ DevInfVersion 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;
+ }
+
+ return devInf_version;
+}
+
+static DevInfDevTyp __get_oma_ds_devInf_device_type(char *devType)
+{
+ DevInfDevTyp device_type = DEVINF_DEVTYPE_UNKNOWN;
+ if (strcmp(devType, ELEMENT_PAGER) == 0) {
+ device_type = DEVINF_DEVTYPE_PAGER;
+ } else if (strcmp(devType, ELEMENT_HANDHELD) == 0) {
+ device_type = DEVINF_DEVTYPE_HANDHELD;
+ } else if (strcmp(devType, ELEMENT_PDA) == 0) {
+ device_type = DEVINF_DEVTYPE_PDA;
+ } else if (strcmp(devType, ELEMENT_PHONE) == 0) {
+ device_type = DEVINF_DEVTYPE_PHONE;
+ } else if (strcmp(devType, ELEMENT_SMARTPHONE) == 0) {
+ device_type = DEVINF_DEVTYPE_SMARTPHONE;
+ } else if (strcmp(devType, ELEMENT_SERVER) == 0) {
+ device_type = DEVINF_DEVTYPE_SERVER;
+ } else if (strcmp(devType, ELEMENT_WORKSTATION) == 0) {
+ device_type = DEVINF_DEVTYPE_WORKSTATION;
+ }
+
+ return device_type;
+}
+
+static DevInfContentType *__get_devinf_contenttype(WBXMLTreeNode *node)
+{
+ FW_LOGV("start");
+
+ PROTOCOL_BINDER_ERROR err = PROTOCOL_BINDER_OK;
+ DevInfContentType *pDevInfContentType = (DevInfContentType *)calloc(1, sizeof(DevInfContentType));
+ if (pDevInfContentType == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ FW_LOGE("pDevInfContentType 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;
+ first_child_name = (const char *)wbxml_tag_get_xml_name(child->name);
+ if (strcmp(first_child_name, ELEMENT_CTTYPE) == 0) {
+ char *ctType = NULL;
+ err = get_text_pointer_from_wbxml_node(child, &ctType);
+ if (err != PROTOCOL_BINDER_OK) {
+ goto return_part;
+ }
+ if (ctType != NULL)
+ pDevInfContentType->cttype = 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 = get_text_pointer_from_wbxml_node(child, &verCT);
+ if (err != PROTOCOL_BINDER_OK) {
+ goto return_part;
+ }
+ if (verCT != NULL)
+ pDevInfContentType->verct = strdup(verCT);
+ } else {
+ /* error */
+ goto return_part;
+ }
+ }
+
+ FW_LOGV("end");
+ return pDevInfContentType;
+
+return_part:
+ FW_LOGE("error : %d", err);
+ return NULL;
+
+}
+
+static Location *_get_location(WBXMLTreeNode *node)
+{
+ FW_LOGV("start");
+
+ PROTOCOL_BINDER_ERROR err = PROTOCOL_BINDER_OK;
+ Location *pLocation = 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;
+ first_child_name = (const char *)wbxml_tag_get_xml_name(child->name);
+ FW_LOGV("child_name = %s", first_child_name);
+ if (strcmp(first_child_name, ELEMENT_LOCURI) == 0) {
+ err = get_text_pointer_from_wbxml_node(child, &locURI);
+ if (err != PROTOCOL_BINDER_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);
+ FW_LOGV("child_name = %s", second_child_name);
+ if (strcmp(second_child_name, ELEMENT_LOCNAME) == 0) {
+ err = get_text_pointer_from_wbxml_node(child, &locName);
+ if (err != PROTOCOL_BINDER_OK) {
+ goto return_part;
+ }
+ } else {
+ /* error */
+ goto return_part;
+ }
+ }
+
+ create_location(locURI, locName, &pLocation);
+
+ FW_LOGV("end");
+ return pLocation;
+
+return_part:
+ FW_LOGE("error : %d", err);
+ free_location(pLocation);
+ return NULL;
+}
+
+static Anchor *_get_anchor(WBXMLTreeNode *node)
+{
+ FW_LOGV("start");
+
+ PROTOCOL_BINDER_ERROR err = PROTOCOL_BINDER_OK;
+ Anchor *pAnchor = 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;
+
+ first_child_name = (const char *)wbxml_tag_get_xml_name(child->name);
+ FW_LOGV("child_name = %s", first_child_name);
+ if (strcmp(first_child_name, ELEMENT_LAST) == 0) {
+ err = get_text_pointer_from_wbxml_node(child, &lastAnchor);
+ if (err != PROTOCOL_BINDER_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 = get_text_pointer_from_wbxml_node(child, &nextAnchor);
+ if (err != PROTOCOL_BINDER_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);
+ FW_LOGV("child_name = %s", second_child_name);
+ if (strcmp(second_child_name, ELEMENT_NEXT) == 0) {
+ err = get_text_pointer_from_wbxml_node(child, &nextAnchor);
+ if (err != PROTOCOL_BINDER_OK) {
+ goto return_part;
+ }
+ } else {
+ /* error */
+ goto return_part;
+ }
+ }
+
+ create_anchor(lastAnchor, nextAnchor, &pAnchor);
+
+ FW_LOGV("end");
+ return pAnchor;
+
+return_part:
+ FW_LOGE("error : %d", err);
+ free_anchor(pAnchor);
+ return NULL;
+}
+
+static Cred *__get_cred(WBXMLTreeNode *node)
+{
+ FW_LOGV("start");
+ PROTOCOL_BINDER_ERROR err = PROTOCOL_BINDER_OK;
+ Cred *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 = get_text_pointer_from_wbxml_node(grand_child, &type);
+ if (err != PROTOCOL_BINDER_OK) {
+ goto return_part;
+ }
+ FW_LOGV("Type = [%s]" , type);
+ } else if (strcmp(grand_child_xml_name, ELEMENT_FORMAT) == 0) {
+ err = get_text_pointer_from_wbxml_node(grand_child, &format);
+ if (err != PROTOCOL_BINDER_OK) {
+ goto return_part;
+ }
+ FW_LOGV("Type = [%s]" , format);
+ }
+ } else if (strcmp(child_xml_name, ELEMENT_DATA) == 0) {
+ err = get_text_pointer_from_wbxml_node(child, &data);
+ if (err != PROTOCOL_BINDER_OK) {
+ goto return_part;
+ }
+ FW_LOGV("Data = [%s]" , data);
+ }
+
+ }
+
+ cred = create_cred_with_data(convert_auth_type(type), data);
+
+ FormatType formatType = FORMAT_TYPE_UNKNOWN;
+ if (strcmp(format, ELEMENT_B64) == 0)
+ formatType = FORMAT_TYPE_BASE64;
+
+ set_cred_format_type(cred, formatType);
+
+ FW_LOGV("end");
+ return cred;
+
+return_part:
+ FW_LOGE("error");
+ free_cred(cred);
+ return NULL;
+}
+
+static Chal *_get_chal(WBXMLTreeNode *node)
+{
+ FW_LOGV("start");
+ PROTOCOL_BINDER_ERROR err = PROTOCOL_BINDER_OK;
+
+ Chal *pChal = (Chal *)calloc(1, sizeof(Chal));
+ if (pChal == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ FW_LOGE("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 = get_text_pointer_from_wbxml_node(meta_child, &type);
+ if (err != PROTOCOL_BINDER_OK) {
+ goto return_part;
+ }
+ FW_LOGV("Type = [%s]" , type);
+
+ pChal->type = convert_auth_type(type);
+ } else if (strcmp(meta_child_xml_name, ELEMENT_FORMAT) == 0) {
+ char *format = NULL;
+ err = get_text_pointer_from_wbxml_node(meta_child, &format);
+ if (err != PROTOCOL_BINDER_OK) {
+ goto return_part;
+ }
+ FW_LOGV("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 = get_binary_pointer_from_wbxml_node(meta_child, &nextnonce, &nonce_len);
+ if (err != PROTOCOL_BINDER_OK) {
+ goto return_part;
+ }
+ FW_LOGV("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 = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ memcpy(pChal->nonce_plain, nextnonce, nonce_len);
+ pChal->nonce_plain[nonce_len] = '\0';
+ }
+
+ pChal->nonce_length = nonce_len;
+ }
+ }
+
+ FW_LOGV("end");
+ return pChal;
+
+return_part:
+ FW_LOGE("error");
+ free_chal(pChal);
+ return NULL;
+}
+
+static PROTOCOL_BINDER_ERROR __oma_ds_binder_devinf_reverse_converter_function(Reverse_protocol_binder *pReverse_binder,
+ WBXMLTreeNode *wbxml_dom_node,
+ Content_Ptr *pContent)
+{
+ FW_LOGV("start");
+ PROTOCOL_BINDER_ERROR err = PROTOCOL_BINDER_OK;
+
+ /* get data from dom tree */
+ DevInf *pDevInf = (DevInf *)calloc(1, sizeof(DevInf));
+ if (pDevInf == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ FW_LOGE("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 = get_text_pointer_from_wbxml_node(child, &verdtd);
+ if (err != PROTOCOL_BINDER_OK) {
+ goto return_part;
+ }
+ FW_LOGV("VerDTD = [%s]" , verdtd);
+
+ pDevInf->version = __get_oma_ds_devInf_version(verdtd);
+ } else if (strcmp(child_xml_name, ELEMENT_MAN) == 0) {
+ char *man = NULL;
+ err = get_text_pointer_from_wbxml_node(child, &man);
+ if (err != PROTOCOL_BINDER_OK) {
+ goto return_part;
+ }
+ FW_LOGV("Man = [%s]" , man);
+ if (man != NULL)
+ pDevInf->manufacturer = strdup(man);
+ } else if (strcmp(child_xml_name, ELEMENT_MOD) == 0) {
+ char *mod = NULL;
+ err = get_text_pointer_from_wbxml_node(child, &mod);
+ if (err != PROTOCOL_BINDER_OK) {
+ goto return_part;
+ }
+ FW_LOGV("Mod = [%s]" , mod);
+ if (mod != NULL)
+ pDevInf->model = strdup(mod);
+ } else if (strcmp(child_xml_name, ELEMENT_OEM) == 0) {
+ char *oem = NULL;
+ err = get_text_pointer_from_wbxml_node(child, &oem);
+ if (err != PROTOCOL_BINDER_OK) {
+ goto return_part;
+ }
+ FW_LOGV("OEM = [%s]" , oem);
+ if (oem != NULL)
+ pDevInf->oem = strdup(oem);
+ } else if (strcmp(child_xml_name, ELEMENT_FWV) == 0) {
+ char *fwv = NULL;
+ err = get_text_pointer_from_wbxml_node(child, &fwv);
+ if (err != PROTOCOL_BINDER_OK) {
+ goto return_part;
+ }
+ FW_LOGV("FwV = [%s]" , fwv);
+ if (fwv != NULL)
+ pDevInf->firmwareVersion = strdup(fwv);
+ } else if (strcmp(child_xml_name, ELEMENT_SWV) == 0) {
+ char *swv = NULL;
+ err = get_text_pointer_from_wbxml_node(child, &swv);
+ if (err != PROTOCOL_BINDER_OK) {
+ goto return_part;
+ }
+ FW_LOGV("SwV = [%s]" , swv);
+ if (swv != NULL)
+ pDevInf->softwareVersion = strdup(swv);
+ } else if (strcmp(child_xml_name, ELEMENT_HWV) == 0) {
+ char *hwv = NULL;
+ err = get_text_pointer_from_wbxml_node(child, &hwv);
+ if (err != PROTOCOL_BINDER_OK) {
+ goto return_part;
+ }
+ FW_LOGV("HwV = [%s]" , hwv);
+ if (hwv != NULL)
+ pDevInf->hardwareVersion = strdup(hwv);
+ } else if (strcmp(child_xml_name, ELEMENT_DEVID) == 0) {
+ char *devID = NULL;
+ err = get_text_pointer_from_wbxml_node(child, &devID);
+ if (err != PROTOCOL_BINDER_OK) {
+ goto return_part;
+ }
+ FW_LOGV("DevID = [%s]" , devID);
+ if (devID != NULL)
+ pDevInf->devid = strdup(devID);
+ } else if (strcmp(child_xml_name, ELEMENT_DEVTYP) == 0) {
+ char *devtyp = NULL;
+ err = get_text_pointer_from_wbxml_node(child, &devtyp);
+ if (err != PROTOCOL_BINDER_OK) {
+ goto return_part;
+ }
+ FW_LOGV("DevTyp = [%s]" , devtyp);
+
+ pDevInf->devtyp = __get_oma_ds_devInf_device_type(devtyp);
+ } else if (strcmp(child_xml_name, ELEMENT_UTC) == 0) {
+ FW_LOGV("UTC");
+ pDevInf->supportsUTC = 1;
+ } else if (strcmp(child_xml_name, ELEMENT_SUPPORTLARGEOBJS) == 0) {
+ FW_LOGV("SupportLargeObjs");
+ pDevInf->supportsLargeObjs = 1;
+ } else if (strcmp(child_xml_name, ELEMENT_SUPPORTNUMBEROFCHANGES) == 0) {
+ FW_LOGV("SupportNumberOfChanges");
+ pDevInf->supportsNumberOfChanges = 1;
+ } else if (strcmp(child_xml_name, ELEMENT_DATASTORE) == 0) {
+
+ DevInfDataStore *pDevInfDataStore = (DevInfDataStore *)calloc(1, sizeof(DevInfDataStore));
+
+ 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 = get_text_pointer_from_wbxml_node(datastore_child, &sourceref);
+ if (err != PROTOCOL_BINDER_OK) {
+ goto return_part;
+ }
+ FW_LOGV("SourceRef = [%s]" , sourceref);
+ if (sourceref != NULL)
+ pDevInfDataStore->sourceref = strdup(sourceref);
+ } else if (strcmp(datastore_child_xml_name, ELEMENT_DISPLAYNAME) == 0) {
+ char *displayname = NULL;
+ err = get_text_pointer_from_wbxml_node(datastore_child, &displayname);
+ if (err != PROTOCOL_BINDER_OK) {
+ goto return_part;
+ }
+ FW_LOGV("DisplayName = [%s]" , displayname);
+ if (displayname != NULL)
+ pDevInfDataStore->displayname = strdup(displayname);
+ } else if (strcmp(datastore_child_xml_name, ELEMENT_MAXGUIDSIZE) == 0) {
+ char *maxguidsize = NULL;
+ err = get_text_pointer_from_wbxml_node(datastore_child, &maxguidsize);
+ if (err != PROTOCOL_BINDER_OK) {
+ goto return_part;
+ }
+ FW_LOGV("MaxGUIDSize = [%s]" , maxguidsize);
+ if (maxguidsize != NULL)
+ pDevInfDataStore->maxGUIDSize = atoi(maxguidsize);
+ } else if (strcmp(datastore_child_xml_name, ELEMENT_RX_PREF) == 0) {
+ DevInfContentType *pDevInfContentType = __get_devinf_contenttype(datastore_child);
+ if (pDevInfContentType == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ pDevInfDataStore->rxPref = pDevInfContentType;
+ } else if (strcmp(datastore_child_xml_name, ELEMENT_RX) == 0) {
+ DevInfContentType *pDevInfContentType = __get_devinf_contenttype(datastore_child);
+ if (pDevInfContentType == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ pDevInfDataStore->rx = g_list_append(pDevInfDataStore->rx, pDevInfContentType);
+ } else if (strcmp(datastore_child_xml_name, ELEMENT_TX_PREF) == 0) {
+ DevInfContentType *pDevInfContentType = __get_devinf_contenttype(datastore_child);
+ if (pDevInfContentType == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ pDevInfDataStore->txPref = pDevInfContentType;
+ } else if (strcmp(datastore_child_xml_name, ELEMENT_TX) == 0) {
+ DevInfContentType *pDevInfContentType = __get_devinf_contenttype(datastore_child);
+ if (pDevInfContentType == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ pDevInfDataStore->tx = g_list_append(pDevInfDataStore->tx, pDevInfContentType);
+ } else if (strcmp(datastore_child_xml_name, ELEMENT_CTCAP) == 0) {
+
+ DevInfCTCap *pDevInfCtCap = (DevInfCTCap *)calloc(1, sizeof(DevInfCTCap));
+
+ DevInfContentType *pDevInfContentType = 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 (pDevInfContentType == NULL)
+ pDevInfContentType = (DevInfContentType *)calloc(1, sizeof(DevInfContentType));
+
+ char *cttype = NULL;
+ err = get_text_pointer_from_wbxml_node(ctcap_child, &cttype);
+ if (err != PROTOCOL_BINDER_OK) {
+ goto return_part;
+ }
+ FW_LOGV("CTType = [%s]" , cttype);
+ if (cttype != NULL)
+ pDevInfContentType->cttype = strdup(cttype);
+ } else if (strcmp(ctcap_child_xml_name, ELEMENT_VERCT) == 0) {
+ if (pDevInfContentType == NULL)
+ pDevInfContentType = (DevInfContentType *)calloc(1, sizeof(DevInfContentType));
+
+ char *verct = NULL;
+ err = get_text_pointer_from_wbxml_node(ctcap_child, &verct);
+ if (err != PROTOCOL_BINDER_OK) {
+ goto return_part;
+ }
+ FW_LOGV("VerCT = [%s]" , verct);
+ if (verct != NULL)
+ pDevInfContentType->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) {
+
+ DevInfProperty *pDevInfProperty = (DevInfProperty *)calloc(1, sizeof(DevInfProperty));
+
+ 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 = get_text_pointer_from_wbxml_node(property_child, &propname);
+ if (err != PROTOCOL_BINDER_OK) {
+ goto return_part;
+ }
+ FW_LOGV("PropName = [%s]" , propname);
+ if (propname != NULL)
+ pDevInfProperty->propName = strdup(propname);
+ } else if (strcmp(property_child_xml_name, ELEMENT_DATATYPE) == 0) {
+ char *datatype = NULL;
+ err = get_text_pointer_from_wbxml_node(property_child, &datatype);
+ if (err != PROTOCOL_BINDER_OK) {
+ goto return_part;
+ }
+ FW_LOGV("DataType = [%s]" , datatype);
+ if (datatype != NULL)
+ pDevInfProperty->dataType = strdup(datatype);
+ } else if (strcmp(property_child_xml_name, ELEMENT_MAXOCCUR) == 0) {
+ char *maxoccur = NULL;
+ err = get_text_pointer_from_wbxml_node(property_child, &maxoccur);
+ if (err != PROTOCOL_BINDER_OK) {
+ goto return_part;
+ }
+ FW_LOGV("MaxOccur = [%s]" , maxoccur);
+ if (maxoccur != NULL)
+ pDevInfProperty->maxOccur = atoi(maxoccur);
+ } else if (strcmp(property_child_xml_name, ELEMENT_MAXSIZE) == 0) {
+ char *maxsize = NULL;
+ err = get_text_pointer_from_wbxml_node(property_child, &maxsize);
+ if (err != PROTOCOL_BINDER_OK) {
+ goto return_part;
+ }
+ FW_LOGV("MaxSize = [%s]" , maxsize);
+ if (maxsize != NULL)
+ pDevInfProperty->maxSize = atoi(maxsize);
+ } else if (strcmp(property_child_xml_name, ELEMENT_NOTRUNCATE) == 0) {
+ FW_LOGV("NoTruncate");
+ pDevInfProperty->noTruncate = 1;
+ } else if (strcmp(property_child_xml_name, ELEMENT_VALENUM) == 0) {
+ char *valenum = NULL;
+ err = get_text_pointer_from_wbxml_node(property_child, &valenum);
+ if (err != PROTOCOL_BINDER_OK) {
+ goto return_part;
+ }
+ FW_LOGV("ValEnum = [%s]" , valenum);
+ pDevInfProperty->valEnums = g_list_append(pDevInfProperty->valEnums, strdup(valenum));
+ } else if (strcmp(property_child_xml_name, ELEMENT_DISPLAYNAME) == 0) {
+ char *displayname = NULL;
+ err = get_text_pointer_from_wbxml_node(property_child, &displayname);
+ if (err != PROTOCOL_BINDER_OK) {
+ goto return_part;
+ }
+ FW_LOGV("DisplayName = [%s]" , displayname);
+ if (displayname != NULL)
+ pDevInfProperty->displayName = strdup(displayname);
+ } else if (strcmp(property_child_xml_name, ELEMENT_PROPPARAM) == 0) {
+
+ DevInfPropParam *pDevInfPropParam = (DevInfPropParam *)calloc(1, sizeof(DevInfPropParam));
+
+ 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 = get_text_pointer_from_wbxml_node(propparam_child, ¶mname);
+ if (err != PROTOCOL_BINDER_OK) {
+ goto return_part;
+ }
+ FW_LOGV("ParamName = [%s]" , paramname);
+ if (paramname != NULL)
+ pDevInfPropParam->paramName = strdup(paramname);
+ } else if (strcmp(propparam_child_xml_name, ELEMENT_DATATYPE) == 0) {
+ char *datatype = NULL;
+ err = get_text_pointer_from_wbxml_node(propparam_child, &datatype);
+ if (err != PROTOCOL_BINDER_OK) {
+ goto return_part;
+ }
+ FW_LOGV("DataType = [%s]" , datatype);
+ if (datatype != NULL)
+ pDevInfPropParam->dataType = strdup(datatype);
+ } else if (strcmp(propparam_child_xml_name, ELEMENT_VALENUM) == 0) {
+ char *valenum = NULL;
+ err = get_text_pointer_from_wbxml_node(propparam_child, &valenum);
+ if (err != PROTOCOL_BINDER_OK) {
+ goto return_part;
+ }
+ FW_LOGV("ValEnum = [%s]" , valenum);
+ if (valenum != NULL)
+ pDevInfPropParam->valEnums = g_list_append(pDevInfPropParam->valEnums, strdup(valenum));
+ } else if (strcmp(propparam_child_xml_name, ELEMENT_DISPLAYNAME) == 0) {
+ char *displayname = NULL;
+ err = get_text_pointer_from_wbxml_node(propparam_child, &displayname);
+ if (err != PROTOCOL_BINDER_OK) {
+ goto return_part;
+ }
+ FW_LOGV("DisplayName = [%s]" , displayname);
+ if (displayname != NULL)
+ pDevInfPropParam->displayName = strdup(displayname);
+ }
+ }
+
+ pDevInfProperty->propParams = g_list_append(pDevInfProperty->propParams, pDevInfPropParam);
+ }
+ }
+
+ pDevInfCtCap->properties = g_list_append(pDevInfCtCap->properties, pDevInfProperty);
+ }
+ }
+ pDevInfCtCap->ct = pDevInfContentType;
+ pDevInfDataStore->ctcaps = g_list_append(pDevInfDataStore->ctcaps, pDevInfCtCap);
+ } else if (strcmp(datastore_child_xml_name, ELEMENT_DSMEM) == 0) {
+
+ /*TODO DSMem*/
+ } else if (strcmp(datastore_child_xml_name, ELEMENT_SUPPORTHIERARCHICALSYNC) == 0) {
+ FW_LOGV("SupportHierarchicalSync");
+ pDevInfDataStore->supportsHierarchicalSync = 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 = get_text_pointer_from_wbxml_node(synccap_child, &synctype_str);
+ if (err != PROTOCOL_BINDER_OK) {
+ goto return_part;
+ }
+ FW_LOGV("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_synccap(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 == PROTOCOL_BINDER_OK) {
+ FW_LOGV("end");
+ *pContent = pDevInf;
+ } else{
+ FW_LOGE("error");
+ free_devinf(pDevInf);
+ }
+
+ return err;
+}
+static PROTOCOL_BINDER_ERROR __oma_ds_binder_header_reverse_converter_function(Reverse_protocol_binder *pReverse_binder,
+ WBXMLTreeNode *wbxml_dom_node,
+ Content_Ptr *pContent)
+{
+ FW_LOGV("start");
+ PROTOCOL_BINDER_ERROR err = PROTOCOL_BINDER_OK;
+
+ /* get data from dom tree */
+ SyncHdr *pSyncHdr = (SyncHdr *)calloc(1, sizeof(SyncHdr));
+ if (pSyncHdr == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ FW_LOGE("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 = get_text_pointer_from_wbxml_node(child, &verdtd);
+ if (err != PROTOCOL_BINDER_OK) {
+ goto return_part;
+ }
+ FW_LOGV("VerDTD = [%s]" , verdtd);
+
+ pSyncHdr->version = __get_oma_ds_protocol_version(verdtd);
+ } else if (strcmp(child_xml_name, ELEMENT_SESSIONID) == 0) {
+ char *sessionID = NULL;
+ err = get_text_pointer_from_wbxml_node(child, &sessionID);
+ if (err != PROTOCOL_BINDER_OK) {
+ goto return_part;
+ }
+ FW_LOGV("SessionID = [%s]" , sessionID);
+
+ if (sessionID)
+ pSyncHdr->sessionID = strdup(sessionID);
+ else
+ pSyncHdr->sessionID = NULL;
+ } else if (strcmp(child_xml_name, ELEMENT_MSGID) == 0) {
+ char *msgID = NULL;
+ err = get_text_pointer_from_wbxml_node(child, &msgID);
+ if (err != PROTOCOL_BINDER_OK) {
+ goto return_part;
+ }
+ FW_LOGV("MsgID = [%s]" , msgID);
+ if (msgID != NULL)
+ pSyncHdr->messageID = atoi(msgID);
+ } else if (strcmp(child_xml_name, ELEMENT_TARGET) == 0) {
+ Location *pTargetLocation = _get_location(child);
+ if (pTargetLocation == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ pSyncHdr->target = pTargetLocation;
+ } else if (strcmp(child_xml_name, ELEMENT_SOURCE) == 0) {
+ Location *pSourceLocation = _get_location(child);
+ if (pSourceLocation == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ pSyncHdr->source = pSourceLocation;
+ } else if (strcmp(child_xml_name, ELEMENT_RESPURI) == 0) {
+ char *resp_uri = NULL;
+ err = get_text_pointer_from_wbxml_node(child, &resp_uri);
+ if (err != PROTOCOL_BINDER_OK) {
+ goto return_part;
+ }
+ FW_LOGV("resp_uri = [%s]" , resp_uri);
+ if (resp_uri != NULL)
+ pSyncHdr->responseURI = strdup(resp_uri);
+ } else if (strcmp(child_xml_name, ELEMENT_NORESP) == 0) {
+ FW_LOGV("noResp\n");
+ pSyncHdr->noResponse = 1;
+ } else if (strcmp(child_xml_name, ELEMENT_CRED) == 0) {
+ FW_LOGV("Cred\n");
+ Cred *pCred = NULL;
+ pCred = __get_cred(child);
+ if (pCred == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ pSyncHdr->cred = pCred;
+ } else if (strcmp(child_xml_name, ELEMENT_META) == 0) {
+
+ }
+ }
+
+return_part:
+ if (err == PROTOCOL_BINDER_OK) {
+ FW_LOGV("end");
+ *pContent = pSyncHdr;
+ } else{
+ FW_LOGE("error");
+ free_synchdr(pSyncHdr);
+ }
+
+ return err;
+}
+
+static PROTOCOL_BINDER_ERROR __oma_ds_binder_results_command_reverse_converter_function(Reverse_protocol_binder *pReverse_binder,
+ WBXMLTreeNode *wbxml_dom_node,
+ Content_Ptr *pContent)
+{
+ FW_LOGV("start");
+ PROTOCOL_BINDER_ERROR err = PROTOCOL_BINDER_OK;
+
+ SyncHdr *pSyncHdr = (SyncHdr *)reverse_protocol_binder_get_user_data(pReverse_binder);
+
+ /* get data from dom tree */
+ Command *pResults = (Command *)calloc(1, sizeof(Command));
+ if (pResults == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ FW_LOGE("pResults is null");
+ goto return_part;
+ }
+
+ pResults->type = COMMAND_TYPE_RESULTS;
+ pResults->msgID = pSyncHdr->messageID;
+ pResults->refCount = 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 = get_text_pointer_from_wbxml_node(child, &cmd_id);
+ if (err != PROTOCOL_BINDER_OK) {
+ goto return_part;
+ }
+ FW_LOGV("CmdID = [%s]" , cmd_id);
+ if (cmd_id != NULL)
+ pResults->cmdID = atoi(cmd_id);
+ } else if (strcmp(child_xml_name, ELEMENT_MSGREF) == 0) {
+ char *msg_ref = NULL;
+ err = get_text_pointer_from_wbxml_node(child, &msg_ref);
+ if (err != PROTOCOL_BINDER_OK) {
+ goto return_part;
+ }
+ FW_LOGV("MsgRef = [%s]" , msg_ref);
+ if (msg_ref != NULL)
+ pResults->private.results.msgRef = atoi(msg_ref);
+ } else if (strcmp(child_xml_name, ELEMENT_CMDREF) == 0) {
+ char *cmd_ref = NULL;
+ err = get_text_pointer_from_wbxml_node(child, &cmd_ref);
+ if (err != PROTOCOL_BINDER_OK) {
+ goto return_part;
+ }
+ FW_LOGV("MsgRef = [%s]" , cmd_ref);
+ if (cmd_ref != NULL)
+ pResults->private.results.cmdRef = 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 = get_text_pointer_from_wbxml_node(grandchild, &contentType);
+ if (err != PROTOCOL_BINDER_OK) {
+ goto return_part;
+ }
+ FW_LOGV("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 *item = create_item();
+ if (item == NULL) {
+ err = PROTOCOL_BINDER_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 *pSourceLocation = _get_location(grandchild);
+ if (pSourceLocation == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ pResults->private.results.item->source = pSourceLocation;
+ } else if (strcmp(grandchild_xml_name, ELEMENT_TARGET) == 0) {
+ Location *pTargetLocation = _get_location(grandchild);
+ if (pTargetLocation == NULL) {
+ err = PROTOCOL_BINDER_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 == PROTOCOL_BINDER_OK) {
+ FW_LOGV("end");
+ *pContent = pResults;
+ } else{
+ FW_LOGE("error");
+ free_command(pResults);
+ }
+ return err;
+}
+
+static PROTOCOL_BINDER_ERROR __oma_ds_binder_put_command_reverse_converter_function(Reverse_protocol_binder *pReverse_binder,
+ WBXMLTreeNode *wbxml_dom_node,
+ Content_Ptr *pContent)
+{
+ FW_LOGV("start");
+ PROTOCOL_BINDER_ERROR err = PROTOCOL_BINDER_OK;
+
+ SyncHdr *pSyncHdr = (SyncHdr *)reverse_protocol_binder_get_user_data(pReverse_binder);
+
+ /* get data from dom tree */
+ Command *pPut = (Command *)calloc(1, sizeof(Command));
+ if (pPut == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ FW_LOGE("pPut is null");
+ goto return_part;
+ }
+
+ pPut->type = COMMAND_TYPE_PUT;
+ pPut->msgID = pSyncHdr->messageID;
+ pPut->refCount = 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 = get_text_pointer_from_wbxml_node(child, &cmd_id);
+ if (err != PROTOCOL_BINDER_OK) {
+ goto return_part;
+ }
+ FW_LOGV("CmdID = [%s]" , cmd_id);
+ if (cmd_id != NULL)
+ pPut->cmdID = atoi(cmd_id);
+ } else if (strcmp(child_xml_name, ELEMENT_NORESP) == 0) {
+ FW_LOGV("NoResp");
+ pPut->noResp = 1;
+ } else if (strcmp(child_xml_name, ELEMENT_CRED) == 0) {
+ FW_LOGV("Cred\n");
+ Cred *pCred = NULL;
+ pCred = __get_cred(child);
+ if (pCred == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ pPut->cred = pCred;
+ } 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 = get_text_pointer_from_wbxml_node(grandchild, &contentType);
+ if (err != PROTOCOL_BINDER_OK) {
+ goto return_part;
+ }
+ FW_LOGV("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 *item = create_item();
+ if (item == NULL) {
+ err = PROTOCOL_BINDER_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 *pSourceLocation = _get_location(grandchild);
+ if (pSourceLocation == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ pPut->private.access.item->source = pSourceLocation;
+ } else if (strcmp(grandchild_xml_name, ELEMENT_TARGET) == 0) {
+ Location *pTargetLocation = _get_location(grandchild);
+ if (pTargetLocation == NULL) {
+ err = PROTOCOL_BINDER_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 == PROTOCOL_BINDER_OK) {
+ FW_LOGV("end");
+ *pContent = pPut;
+ } else{
+ FW_LOGE("error");
+ free_command(pPut);
+ }
+ return err;
+}
+
+static PROTOCOL_BINDER_ERROR __oma_ds_binder_get_command_reverse_converter_function(Reverse_protocol_binder *pReverse_binder,
+ WBXMLTreeNode *wbxml_dom_node,
+ Content_Ptr *pContent)
+{
+ FW_LOGV("start");
+ PROTOCOL_BINDER_ERROR err = PROTOCOL_BINDER_OK;
+
+ SyncHdr *pSyncHdr = (SyncHdr *)reverse_protocol_binder_get_user_data(pReverse_binder);
+
+ /* get data from dom tree */
+ Command *pGet = (Command *)calloc(1, sizeof(Command));
+ if (pGet == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ FW_LOGE("pGet is null");
+ goto return_part;
+ }
+
+ pGet->type = COMMAND_TYPE_GET;
+ pGet->msgID = pSyncHdr->messageID;
+ pGet->refCount = 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 = get_text_pointer_from_wbxml_node(child, &cmd_id);
+ if (err != PROTOCOL_BINDER_OK) {
+ goto return_part;
+ }
+ FW_LOGV("CmdID = [%s]" , cmd_id);
+ if (cmd_id != NULL)
+ pGet->cmdID = atoi(cmd_id);
+ } else if (strcmp(child_xml_name, ELEMENT_NORESP) == 0) {
+ FW_LOGV("NoResp");
+ pGet->noResp = 1;
+ } else if (strcmp(child_xml_name, ELEMENT_CRED) == 0) {
+ FW_LOGV("Cred\n");
+ Cred *pCred = NULL;
+ pCred = __get_cred(child);
+ if (pCred == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ pGet->cred = pCred;
+ } 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 = get_text_pointer_from_wbxml_node(grandchild, &contentType);
+ if (err != PROTOCOL_BINDER_OK) {
+ goto return_part;
+ }
+ FW_LOGV("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 *item = create_item();
+ if (item == NULL) {
+ err = PROTOCOL_BINDER_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 *pSourceLocation = _get_location(grandchild);
+ if (pSourceLocation == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ pGet->private.access.item->source = pSourceLocation;
+ } else if (strcmp(grandchild_xml_name, ELEMENT_TARGET) == 0) {
+ Location *pTargetLocation = _get_location(grandchild);
+ if (pTargetLocation == NULL) {
+ err = PROTOCOL_BINDER_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 == PROTOCOL_BINDER_OK) {
+ FW_LOGV("end");
+ *pContent = pGet;
+ } else{
+ FW_LOGE("error");
+ free_command(pGet);
+ }
+ return err;
+}
+
+
+static PROTOCOL_BINDER_ERROR __oma_ds_binder_alert_command_reverse_converter_function(Reverse_protocol_binder *pReverse_binder,
+ WBXMLTreeNode *wbxml_dom_node,
+ Content_Ptr *pContent)
+{
+ FW_LOGV("start");
+ PROTOCOL_BINDER_ERROR err = PROTOCOL_BINDER_OK;
+
+ SyncHdr *pSyncHdr = (SyncHdr *)reverse_protocol_binder_get_user_data(pReverse_binder);
+
+ /* get data from dom tree */
+ Command *pAlert = (Command *)calloc(1, sizeof(Command));
+ if (pAlert == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ FW_LOGE("pAlert is null");
+ goto return_part;
+ }
+
+ pAlert->type = COMMAND_TYPE_ALERT;
+ pAlert->msgID = pSyncHdr->messageID;
+ pAlert->refCount = 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 = get_text_pointer_from_wbxml_node(child, &cmd_id);
+ if (err != PROTOCOL_BINDER_OK) {
+ goto return_part;
+ }
+ FW_LOGV("CmdID = [%s]" , cmd_id);
+ if (cmd_id != NULL)
+ pAlert->cmdID = atoi(cmd_id);
+ } else if (strcmp(child_xml_name, ELEMENT_NORESP) == 0) {
+ FW_LOGV("NoResp");
+ pAlert->noResp = 1;
+ } else if (strcmp(child_xml_name, ELEMENT_CRED) == 0) {
+ FW_LOGV("Cred\n");
+ Cred *pCred = NULL;
+ pCred = __get_cred(child);
+ if (pCred == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ pAlert->cred = pCred;
+ } else if (strcmp(child_xml_name, ELEMENT_DATA) == 0) {
+ char *data = NULL;
+ err = get_text_pointer_from_wbxml_node(child, &data);
+ if (err != PROTOCOL_BINDER_OK) {
+ goto return_part;
+ }
+ FW_LOGV("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 *pSourceLocation = _get_location(grandchild);
+ if (pSourceLocation == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ pAlert->source = pSourceLocation;
+ } else if (strcmp(grandchild_xml_name, ELEMENT_TARGET) == 0) {
+ Location *pTargetLocation = _get_location(grandchild);
+ if (pTargetLocation == NULL) {
+ err = PROTOCOL_BINDER_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 *pAnchor = _get_anchor(grandgrandchild);
+ if (pAnchor == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ pAlert->private.alert.anchor = pAnchor;
+ } else if (strcmp(grandgrandchild_xml_name, ELEMENT_MAXOBJSIZE) == 0) {
+ char *maxObjSize = NULL;
+ err = get_text_pointer_from_wbxml_node(grandgrandchild, &maxObjSize);
+ if (err != PROTOCOL_BINDER_OK) {
+ goto return_part;
+ }
+ FW_LOGV("MaxObjSize = [%s]" , maxObjSize);
+ if (maxObjSize != NULL)
+ pAlert->private.alert.maxObjSize = atoi(maxObjSize);
+ }
+ }
+ }
+ }
+ }
+ }
+
+return_part:
+ if (err == PROTOCOL_BINDER_OK) {
+ FW_LOGV("end");
+ *pContent = pAlert;
+ } else{
+ FW_LOGE("error");
+ free_command(pAlert);
+ }
+ return err;
+}
+
+static PROTOCOL_BINDER_ERROR __oma_ds_binder_sync_end_command_reverse_converter_function(Reverse_protocol_binder *pReverse_binder,
+ WBXMLTreeNode *wbxml_dom_node,
+ Content_Ptr *pContent)
+{
+ FW_LOGV("start");
+ PROTOCOL_BINDER_ERROR err = PROTOCOL_BINDER_OK;
+
+ SyncHdr *pSyncHdr = (SyncHdr *)reverse_protocol_binder_get_user_data(pReverse_binder);
+
+ /* get data from dom tree */
+ Command *pSyncEnd = (Command *)calloc(1, sizeof(Command));
+ if (pSyncEnd == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ FW_LOGE("pSyncEnd is null");
+ goto return_part;
+ }
+
+ pSyncEnd->type = COMMAND_TYPE_SYNC_END;;
+ pSyncEnd->msgID = pSyncHdr->messageID;
+ pSyncEnd->refCount = 1;
+
+return_part:
+ if (err == PROTOCOL_BINDER_OK) {
+ FW_LOGV("end");
+ *pContent = pSyncEnd;
+ } else{
+ FW_LOGE("error");
+ free_command(pSyncEnd);
+ }
+ return err;
+}
+
+
+
+static PROTOCOL_BINDER_ERROR __oma_ds_binder_sync_start_command_reverse_converter_function(Reverse_protocol_binder *pReverse_binder,
+ WBXMLTreeNode *wbxml_dom_node,
+ Content_Ptr *pContent)
+{
+ FW_LOGV("start");
+ PROTOCOL_BINDER_ERROR err = PROTOCOL_BINDER_OK;
+
+ SyncHdr *pSyncHdr = (SyncHdr *)reverse_protocol_binder_get_user_data(pReverse_binder);
+
+ /* get data from dom tree */
+ Command *pSync = (Command *)calloc(1, sizeof(Command));
+ if (pSync == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ FW_LOGE("pSync is null");
+ goto return_part;
+ }
+
+ pSync->type = COMMAND_TYPE_SYNC_START;;
+ pSync->msgID = pSyncHdr->messageID;
+ pSync->refCount = 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 = get_text_pointer_from_wbxml_node(child, &cmd_id);
+ if (err != PROTOCOL_BINDER_OK) {
+ goto return_part;
+ }
+ FW_LOGV("CmdID = [%s]" , cmd_id);
+ if (cmd_id != NULL)
+ pSync->cmdID = atoi(cmd_id);
+ } else if (strcmp(child_xml_name, ELEMENT_NORESP) == 0) {
+ FW_LOGV("NoResp");
+ pSync->noResp = 1;
+ } else if (strcmp(child_xml_name, ELEMENT_CRED) == 0) {
+ FW_LOGV("Cred\n");
+ Cred *pCred = NULL;
+ pCred = __get_cred(child);
+ if (pCred == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ pSync->cred = pCred;
+ } else if (strcmp(child_xml_name, ELEMENT_TARGET) == 0) {
+ Location *pTargetLocation = _get_location(child);
+ if (pTargetLocation == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ pSync->target = pTargetLocation;
+ } else if (strcmp(child_xml_name, ELEMENT_SOURCE) == 0) {
+ Location *pSourceLocation = _get_location(child);
+ if (pSourceLocation == NULL) {
+ err = PROTOCOL_BINDER_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 = get_text_pointer_from_wbxml_node(child, &numOfChanges);
+ if (err != PROTOCOL_BINDER_OK) {
+ goto return_part;
+ }
+ FW_LOGV("NumberOfChanges = [%s]" , numOfChanges);
+
+ pSync->private.sync.hasNumChanged = 1;
+ if (numOfChanges != NULL)
+ pSync->private.sync.numChanged = atoi(numOfChanges);
+ }
+ }
+
+return_part:
+ if (err == PROTOCOL_BINDER_OK) {
+ FW_LOGV("end");
+ *pContent = pSync;
+ } else{
+ FW_LOGE("error");
+ free_command(pSync);
+ }
+ return err;
+}
+
+static PROTOCOL_BINDER_ERROR __oma_ds_binder_add_command_reverse_converter_function(Reverse_protocol_binder *pReverse_binder,
+ WBXMLTreeNode *wbxml_dom_node,
+ Content_Ptr *pContent)
+{
+ FW_LOGV("start");
+ PROTOCOL_BINDER_ERROR err = PROTOCOL_BINDER_OK;
+
+ SyncHdr *pSyncHdr = (SyncHdr *)reverse_protocol_binder_get_user_data(pReverse_binder);
+
+ /* get data from dom tree */
+ Command *pAdd = (Command *)calloc(1, sizeof(Command));
+ if (pAdd == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ FW_LOGE("pAdd is null");
+ goto return_part;
+ }
+
+ pAdd->type = COMMAND_TYPE_ADD;;
+ pAdd->msgID = pSyncHdr->messageID;
+ pAdd->private.change.type = CHANGE_ADD;
+ pAdd->refCount = 1;
+
+ Item *item = NULL;
+
+ 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 = get_text_pointer_from_wbxml_node(child, &cmd_id);
+ if (err != PROTOCOL_BINDER_OK) {
+ goto return_part;
+ }
+ FW_LOGV("CmdID = [%s]" , cmd_id);
+ if (cmd_id != NULL)
+ pAdd->cmdID = atoi(cmd_id);
+ } else if (strcmp(child_xml_name, ELEMENT_NORESP) == 0) {
+ FW_LOGV("NoResp");
+ pAdd->noResp = 1;
+ } else if (strcmp(child_xml_name, ELEMENT_CRED) == 0) {
+ FW_LOGV("Cred\n");
+ Cred *pCred = NULL;
+ pCred = __get_cred(child);
+ if (pCred == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ pAdd->cred = pCred;
+ } else if (strcmp(child_xml_name, ELEMENT_META) == 0) {
+ WBXMLTreeNode *grandchild = NULL;
+
+
+ item = create_item();
+ if (item == NULL) {
+ err = PROTOCOL_BINDER_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 = get_text_pointer_from_wbxml_node(grandchild, &contentType);
+ if (err != PROTOCOL_BINDER_OK) {
+ goto return_part;
+ }
+ FW_LOGV("Content Type = [%s]" , contentType);
+ if (contentType != NULL)
+ item->contenttype = strdup(contentType);
+ } else if (strcmp(grandchild_xml_name, ELEMENT_SIZE) == 0) {
+ char *size = NULL;
+ err = get_text_pointer_from_wbxml_node(grandchild, &size);
+ if (err != PROTOCOL_BINDER_OK) {
+ goto return_part;
+ }
+ FW_LOGV("Size = [%s]" , size);
+ if (size != NULL)
+ item->size = atoi(size);
+ }
+ }
+ } else if (strcmp(child_xml_name, ELEMENT_ITEM) == 0) {
+
+ if (!item) {
+ item = create_item();
+ if (item == NULL) {
+ err = PROTOCOL_BINDER_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 *pSourceLocation = _get_location(grandchild);
+ if (pSourceLocation == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ item->source = pSourceLocation;
+ } else if (strcmp(grandchild_xml_name, ELEMENT_TARGET) == 0) {
+ Location *pTargetLocation = _get_location(grandchild);
+ if (pTargetLocation == NULL) {
+ err = PROTOCOL_BINDER_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 = get_text_pointer_from_wbxml_node(grandgrandchild, &contentType);
+ if (err != PROTOCOL_BINDER_OK) {
+ goto return_part;
+ }
+ FW_LOGV("Content Type = [%s]" , contentType);
+ if (contentType != NULL)
+ item->contenttype = strdup(contentType);
+ } else if (strcmp(grandgrandchild_xml_name, ELEMENT_SIZE) == 0) {
+ char *size = NULL;
+ err = get_text_pointer_from_wbxml_node(grandgrandchild, &size);
+ if (err != PROTOCOL_BINDER_OK) {
+ goto return_part;
+ }
+ FW_LOGV("Size = [%s]" , size);
+ if (size != NULL)
+ item->size = atoi(size);
+ }
+ }
+ } else if (strcmp(grandchild_xml_name, ELEMENT_DATA) == 0) {
+ char *data = NULL;
+ err = get_text_pointer_from_wbxml_cdata_node(grandchild, &data);
+ if (err != PROTOCOL_BINDER_OK) {
+ goto return_part;
+ }
+ FW_LOGV("Data = [%s]" , data);
+ if (data != NULL)
+ item->private.data = strdup(data);
+ item->dataType = ITEM_DATA;
+ } else if (strcmp(grandchild_xml_name, ELEMENT_MOREDATA) == 0) {
+ FW_LOGV("MoreData");
+ item->moreData = 1;
+ }
+ }
+ pAdd->private.change.items = g_list_append(pAdd->private.change.items, item);
+ item = NULL;
+ }
+ }
+
+return_part:
+ if (err == PROTOCOL_BINDER_OK) {
+ FW_LOGV("end");
+ *pContent = pAdd;
+ } else{
+ FW_LOGE("error");
+ free_command(pAdd);
+ }
+ return err;
+}
+
+static PROTOCOL_BINDER_ERROR __oma_ds_binder_replace_command_reverse_converter_function(Reverse_protocol_binder *pReverse_binder,
+ WBXMLTreeNode *wbxml_dom_node,
+ Content_Ptr *pContent)
+{
+ FW_LOGV("start");
+ PROTOCOL_BINDER_ERROR err = PROTOCOL_BINDER_OK;
+
+ SyncHdr *pSyncHdr = (SyncHdr *)reverse_protocol_binder_get_user_data(pReverse_binder);
+
+ /* get data from dom tree */
+ Command *pReplace = (Command *)calloc(1, sizeof(Command));
+ if (pReplace == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ FW_LOGE("pReplace is null");
+ goto return_part;
+ }
+
+ pReplace->type = COMMAND_TYPE_REPLACE;;
+ pReplace->msgID = pSyncHdr->messageID;
+ pReplace->private.change.type = CHANGE_REPLACE;
+ pReplace->refCount = 1;
+
+ Item *item = NULL;
+
+ 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 = get_text_pointer_from_wbxml_node(child, &cmd_id);
+ if (err != PROTOCOL_BINDER_OK) {
+ goto return_part;
+ }
+ FW_LOGV("CmdID = [%s]" , cmd_id);
+ if (cmd_id != NULL)
+ pReplace->cmdID = atoi(cmd_id);
+
+ } else if (strcmp(child_xml_name, ELEMENT_NORESP) == 0) {
+ FW_LOGV("NoResp");
+ pReplace->noResp = 1;
+ } else if (strcmp(child_xml_name, ELEMENT_CRED) == 0) {
+ FW_LOGV("Cred\n");
+ Cred *pCred = NULL;
+ pCred = __get_cred(child);
+ if (pCred == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ pReplace->cred = pCred;
+ } else if (strcmp(child_xml_name, ELEMENT_META) == 0) {
+
+ item = create_item();
+ if (item == NULL) {
+ err = PROTOCOL_BINDER_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 = get_text_pointer_from_wbxml_node(grandchild, &contentType);
+ if (err != PROTOCOL_BINDER_OK) {
+ goto return_part;
+ }
+ FW_LOGV("Content Type = [%s]" , contentType);
+ if (contentType != NULL)
+ item->contenttype = strdup(contentType);
+ } else if (strcmp(grandchild_xml_name, ELEMENT_SIZE) == 0) {
+ char *size = NULL;
+ err = get_text_pointer_from_wbxml_node(grandchild, &size);
+ if (err != PROTOCOL_BINDER_OK) {
+ goto return_part;
+ }
+ FW_LOGV("Size = [%s]" , size);
+ if (size != NULL)
+ item->size = atoi(size);
+ }
+ }
+ } else if (strcmp(child_xml_name, ELEMENT_ITEM) == 0) {
+
+ if (!item) {
+ item = create_item();
+ if (item == NULL) {
+ err = PROTOCOL_BINDER_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 *pSourceLocation = _get_location(grandchild);
+ if (pSourceLocation == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ item->source = pSourceLocation;
+ } else if (strcmp(grandchild_xml_name, ELEMENT_TARGET) == 0) {
+ Location *pTargetLocation = _get_location(grandchild);
+ if (pTargetLocation == NULL) {
+ err = PROTOCOL_BINDER_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 = get_text_pointer_from_wbxml_node(grandgrandchild, &contentType);
+ if (err != PROTOCOL_BINDER_OK) {
+ goto return_part;
+ }
+ FW_LOGV("Content Type = [%s]" , contentType);
+ if (contentType != NULL)
+ item->contenttype = strdup(contentType);
+ } else if (strcmp(grandgrandchild_xml_name, ELEMENT_SIZE) == 0) {
+ char *size = NULL;
+ err = get_text_pointer_from_wbxml_node(grandgrandchild, &size);
+ if (err != PROTOCOL_BINDER_OK) {
+ goto return_part;
+ }
+ FW_LOGV("Size = [%s]" , size);
+ if (size != NULL)
+ item->size = atoi(size);
+ }
+ }
+
+ } else if (strcmp(grandchild_xml_name, ELEMENT_DATA) == 0) {
+ char *data = NULL;
+ err = get_text_pointer_from_wbxml_cdata_node(grandchild, &data);
+ if (err != PROTOCOL_BINDER_OK) {
+ goto return_part;
+ }
+ FW_LOGV("Data = [%s]" , data);
+ if (data != NULL)
+ item->private.data = strdup(data);
+ item->dataType = ITEM_DATA;
+ }
+ }
+ pReplace->private.change.items = g_list_append(pReplace->private.change.items, item);
+ item = NULL;
+ }
+ }
+
+return_part:
+ if (err == PROTOCOL_BINDER_OK) {
+ FW_LOGV("end");
+ *pContent = pReplace;
+ } else{
+ FW_LOGE("error");
+ free_command(pReplace);
+ }
+ return err;
+}
+
+static PROTOCOL_BINDER_ERROR __oma_ds_binder_delete_command_reverse_converter_function(Reverse_protocol_binder *pReverse_binder,
+ WBXMLTreeNode *wbxml_dom_node,
+ Content_Ptr *pContent)
+{
+ FW_LOGV("start");
+ PROTOCOL_BINDER_ERROR err = PROTOCOL_BINDER_OK;
+
+ SyncHdr *pSyncHdr = (SyncHdr *)reverse_protocol_binder_get_user_data(pReverse_binder);
+
+ /* get data from dom tree */
+ Command *pDelete = (Command *)calloc(1, sizeof(Command));
+ if (pDelete == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ FW_LOGE("pDelete is null");
+ goto return_part;
+ }
+
+ pDelete->type = COMMAND_TYPE_DELETE;
+ pDelete->msgID = pSyncHdr->messageID;
+ pDelete->private.change.type = CHANGE_DELETE;
+ pDelete->refCount = 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);
+
+ Item *item = NULL;
+ if (strcmp(child_xml_name, ELEMENT_CMDID) == 0) {
+ char *cmd_id = NULL;
+ err = get_text_pointer_from_wbxml_node(child, &cmd_id);
+ if (err != PROTOCOL_BINDER_OK) {
+ goto return_part;
+ }
+ FW_LOGV("CmdID = [%s]" , cmd_id);
+ if (cmd_id != NULL)
+ pDelete->cmdID = atoi(cmd_id);
+ } else if (strcmp(child_xml_name, ELEMENT_NORESP) == 0) {
+ FW_LOGV("NoResp");
+ pDelete->noResp = 1;
+ } else if (strcmp(child_xml_name, ELEMENT_CRED) == 0) {
+ FW_LOGV("Cred\n");
+ Cred *pCred = NULL;
+ pCred = __get_cred(child);
+ if (pCred == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ pDelete->cred = pCred;
+ } else if (strcmp(child_xml_name, ELEMENT_META) == 0) {
+ WBXMLTreeNode *grandchild = NULL;
+
+
+ /* create Item */
+ item = create_item();
+ if (item == NULL) {
+ err = PROTOCOL_BINDER_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 = get_text_pointer_from_wbxml_node(grandchild, &contentType);
+ if (err != PROTOCOL_BINDER_OK) {
+ goto return_part;
+ }
+ FW_LOGV("Content Type = [%s]" , contentType);
+ if (contentType != NULL)
+ item->contenttype = strdup(contentType);
+ }
+ }
+ } else if (strcmp(child_xml_name, ELEMENT_ITEM) == 0) {
+ /* create Item */
+ if (!item) {
+ item = create_item();
+ if (item == NULL) {
+ err = PROTOCOL_BINDER_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 *pSourceLocation = _get_location(grandchild);
+ if (pSourceLocation == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ item->source = pSourceLocation;
+ } else if (strcmp(grandchild_xml_name, ELEMENT_TARGET) == 0) {
+ Location *pTargetLocation = _get_location(grandchild);
+ if (pTargetLocation == NULL) {
+ err = PROTOCOL_BINDER_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);
+ }
+ }
+
+return_part:
+ if (err == PROTOCOL_BINDER_OK) {
+ FW_LOGV("end");
+ *pContent = pDelete;
+ } else{
+ FW_LOGE("error");
+ free_command(pDelete);
+ }
+ return err;
+}
+static PROTOCOL_BINDER_ERROR __oma_ds_binder_final_reverse_converter_function(Reverse_protocol_binder *pReverse_binder,
+ WBXMLTreeNode *wbxml_dom_node,
+ Content_Ptr *pContent)
+{
+ FW_LOGV("start");
+ PROTOCOL_BINDER_ERROR err = PROTOCOL_BINDER_OK;
+
+ int *pFinal = (int *)1;
+ *pContent = pFinal;
+
+ FW_LOGV("end");
+ return err;
+}
+
+static PROTOCOL_BINDER_ERROR __oma_ds_binder_status_reverse_converter_function(Reverse_protocol_binder *pReverse_binder,
+ WBXMLTreeNode *wbxml_dom_node,
+ Content_Ptr *pContent)
+{
+ FW_LOGV("start");
+ PROTOCOL_BINDER_ERROR err = PROTOCOL_BINDER_OK;
+
+ /* get data from dom tree */
+ Status *pStatus = (Status *)calloc(1, sizeof(Status));
+ if (pStatus == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ FW_LOGE("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 = get_text_pointer_from_wbxml_node(child, &cmd_id);
+ if (err != PROTOCOL_BINDER_OK) {
+ goto return_part;
+ }
+ FW_LOGV("CmdID = [%s]" , cmd_id);
+ if (cmd_id != NULL)
+ pStatus->cmdID = atoi(cmd_id);
+ } else if (strcmp(child_xml_name, ELEMENT_MSGREF) == 0) {
+ char *msgref = NULL;
+ err = get_text_pointer_from_wbxml_node(child, &msgref);
+ if (err != PROTOCOL_BINDER_OK) {
+ goto return_part;
+ }
+ FW_LOGV("MsgRef = [%s]" , msgref);
+ if (msgref != NULL)
+ pStatus->msgRef = atoi(msgref);
+ } else if (strcmp(child_xml_name, ELEMENT_CMDREF) == 0) {
+ char *cmdref = NULL;
+ err = get_text_pointer_from_wbxml_node(child, &cmdref);
+ if (err != PROTOCOL_BINDER_OK) {
+ goto return_part;
+ }
+ FW_LOGV("CmdRef = [%s]" , cmdref);
+ if (cmdref != NULL)
+ pStatus->cmdRef = atoi(cmdref);
+ } else if (strcmp(child_xml_name, ELEMENT_CMD) == 0) {
+ char *cmd = NULL;
+ err = get_text_pointer_from_wbxml_node(child, &cmd);
+ if (err != PROTOCOL_BINDER_OK) {
+ goto return_part;
+ }
+ FW_LOGV("Cmd = [%s]" , cmd);
+
+ pStatus->type = convert_command_type(cmd);
+ } else if (strcmp(child_xml_name, ELEMENT_TARGETREF) == 0) {
+ char *targetref = NULL;
+ Location *pLocation = NULL;
+ err = get_text_pointer_from_wbxml_node(child, &targetref);
+ if (err != PROTOCOL_BINDER_OK) {
+ goto return_part;
+ }
+ FW_LOGV("TargetRef = [%s]" , targetref);
+
+ create_location(targetref, NULL, &pLocation);
+ pStatus->targetRef = pLocation;
+ } else if (strcmp(child_xml_name, ELEMENT_SOURCEREF) == 0) {
+ char *sourceref = NULL;
+ Location *pLocation = NULL;
+ err = get_text_pointer_from_wbxml_node(child, &sourceref);
+ if (err != PROTOCOL_BINDER_OK) {
+ goto return_part;
+ }
+ FW_LOGV("SourceRef = [%s]" , sourceref);
+
+ create_location(sourceref, NULL, &pLocation);
+ pStatus->sourceRef = pLocation;
+ } else if (strcmp(child_xml_name, ELEMENT_CRED) == 0) {
+ FW_LOGV("Cred\n");
+ Cred *pCred = NULL;
+ pCred = __get_cred(child);
+ if (pCred == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ pStatus->cred = pCred;
+ } else if (strcmp(child_xml_name, ELEMENT_CHAL) == 0) {
+ FW_LOGV("Chal\n");
+ Chal *pChal = NULL;
+ pChal = _get_chal(child);
+ if (pChal == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ pStatus->chal = pChal;
+ } else if (strcmp(child_xml_name, ELEMENT_DATA) == 0) {
+ char *data = NULL;
+ err = get_text_pointer_from_wbxml_node(child, &data);
+ if (err != PROTOCOL_BINDER_OK) {
+ goto return_part;
+ }
+ FW_LOGV("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 *pSourceLocation = _get_location(grandchild);
+ if (pSourceLocation == NULL) {
+ err = PROTOCOL_BINDER_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ pStatus->sourceRef = 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 == PROTOCOL_BINDER_OK) {
+ FW_LOGV("end");
+ *pContent = pStatus;
+ } else{
+ FW_LOGE("error");
+ free_status(pStatus);
+ }
+ return err;
+}
+
+PROTOCOL_BINDER_ERROR init_oma_ds_1_2_binder_function_set(Binder_function_set **pBinder_function_set)
+{
+ PROTOCOL_BINDER_ERROR err = PROTOCOL_BINDER_OK;
+
+ err = init_binder_function_set(sizeof(oma_ds_binder_function_info)/sizeof(Binder_function_info),
+ (Binder_function_info*)oma_ds_binder_function_info,
+ pBinder_function_set);
+
+ return err;
+}
+
+void free_oma_ds_1_2_binder_function_set(Binder_function_set *pBinder_function_set)
+{
+ free_binder_function_set(pBinder_function_set);
+}
+
+protocol_binder *oma_ds_1_2_binder_init(protocol_binder *pBinder, Encoding enc, bool encode_xml_header,
+ bool use_strtbl, bool produce_anonymous, bool use_flow_mode,
+ Binder_function_set *pBinder_function_set)
+{
+ protocol_binder *pOutBinder = NULL;
+
+ pOutBinder = protocol_binder_init(pBinder, PROTOCOL_SYNCML_SYNCML12, NULL, enc,
+ encode_xml_header, use_strtbl, produce_anonymous, use_flow_mode, NULL, NULL,
+ pBinder_function_set);
+
+ if (pOutBinder == NULL) {
+ goto return_part;
+ }
+
+return_part:
+ return pOutBinder;
+}
+
+
+PROTOCOL_BINDER_ERROR oma_ds_1_2_binder_append(protocol_binder *pBinder,
+ OMA_DS_Protocol_Element protocol_element,
+ Content_Ptr pContent)
+{
+ PROTOCOL_BINDER_ERROR err = PROTOCOL_BINDER_OK;
+
+ err = protocol_binder_append(pBinder, protocol_element, pContent);
+
+ return err;
+}
+
+
+void oma_ds_1_2_binder_terminate(protocol_binder *pBinder)
+{
+ protocol_binder_terminate(pBinder);
+}
+
+PROTOCOL_BINDER_ERROR oma_ds_1_2_binder_get_stream(protocol_binder *pBinder,
+ char **byte_stream,
+ unsigned int *byte_stream_size)
+{
+ PROTOCOL_BINDER_ERROR err = PROTOCOL_BINDER_OK;
+
+ err = protocol_binder_get_stream(pBinder, byte_stream, byte_stream_size);
+ if (err != PROTOCOL_BINDER_OK) {
+ goto return_part;
+ }
+
+return_part:
+ return err;
+}
+
+PROTOCOL_BINDER_ERROR oma_ds_1_2_binder_get_stream_size(protocol_binder *pBinder, unsigned int *byte_stream_size)
+{
+ PROTOCOL_BINDER_ERROR err = PROTOCOL_BINDER_OK;
+
+ err = protocol_binder_get_stream_size(pBinder, byte_stream_size);
+ return err;
+}
+
+
+PROTOCOL_BINDER_ERROR oma_ds_1_2_binder_get_encoding(protocol_binder *pBinder, Encoding *enc)
+{
+ PROTOCOL_BINDER_ERROR err = PROTOCOL_BINDER_OK;
+
+ err = protocol_binder_get_encoding(pBinder, enc);
+ return err;
+}
+
+PROTOCOL_BINDER_ERROR reverse_oma_ds_1_2_binder_init(char *byte_stream,
+ unsigned int byte_stream_len,
+ Decoding dec,
+ Binder_function_set *pBinder_function_set,
+ void *user_data,
+ Reverse_protocol_binder **ppBinder)
+{
+ Protocol protocol = PROTOCOL_UNKNOWN;
+ PROTOCOL_BINDER_ERROR err = reverse_protocol_binder_init(byte_stream, byte_stream_len, dec,
+ &protocol, pBinder_function_set, user_data, ppBinder);
+
+ return err;
+}
+
+PROTOCOL_BINDER_ERROR reverse_oma_ds_1_2_binder_next(Reverse_protocol_binder *pBinder,
+ OMA_DS_Protocol_Element *protocol_element,
+ char **protocol_element_name,
+ Content_Ptr *pContent)
+{
+ PROTOCOL_BINDER_ERROR err = reverse_protocol_binder_next(pBinder,
+ protocol_element, protocol_element_name, pContent);
+ return err;
+}