void cg_upnpav_content_copy(CgUpnpAvContent* destContent, CgUpnpAvContent* srcContent) { CgXmlAttribute* attr; CgUpnpAvContent* destNode; CgUpnpAvContent* srcNode; cg_xml_node_setname(destContent, cg_xml_node_getname(srcContent)); cg_xml_node_setvalue(destContent, cg_xml_node_getvalue(srcContent)); for (attr = cg_xml_node_getattributes(srcContent); attr; attr = cg_xml_attribute_next(attr)) cg_xml_node_setattribute(destContent, cg_xml_attribute_getname(attr), cg_xml_attribute_getvalue(attr)); for (srcNode = cg_xml_node_getchildnodes(srcContent); srcNode; srcNode = cg_xml_node_next(srcNode)) { if (cg_upnpav_content_gettype(srcNode) != CG_UPNPAV_CONTENT_NONE) continue; if (cg_streq(cg_xml_node_getname(srcNode), CG_UPNPAV_RESOURCE_NAME)) { destNode = cg_upnpav_resource_new(); cg_upnpav_resource_copy(destNode, srcNode); } else { destNode = cg_upnpav_content_new(); cg_xml_node_setname(destNode, cg_xml_node_getname(srcNode)); cg_xml_node_setvalue(destNode, cg_xml_node_getvalue(srcNode)); for (attr = cg_xml_node_getattributes(srcNode); attr; attr = cg_xml_attribute_next(attr)) cg_xml_node_setattribute(destNode, cg_xml_attribute_getname(attr), cg_xml_attribute_getvalue(attr)); } cg_xml_node_addchildnode(destContent, destNode); } }
CgXmlNode *cg_upnp_control_soap_response_createfaultresponsenode(int errCode, char *errDescr) { CgXmlNode *faultNode; CgXmlNode *faultCodeNode; CgXmlNode *faultStringNode; CgXmlNode *detailNode; CgXmlNode *upnpErrorNode; CgXmlNode *errorCodeNode; CgXmlNode *errorDesctiprionNode; cg_log_debug_l4("Entering...\n"); /**** <s:Fault> ****/ faultNode = cg_xml_node_new(); cg_xml_node_setname(faultNode, CG_SOAP_XMLNS CG_SOAP_DELIM CG_SOAP_FAULT); /**** <faultcode>s:Client</faultcode> ****/ faultCodeNode = cg_xml_node_new(); cg_xml_node_setname(faultCodeNode, CG_SOAP_FAULT_CODE); cg_xml_node_setvalue(faultCodeNode, CG_SOAP_XMLNS CG_SOAP_DELIM CG_UPNP_CONTROL_FAULT_CODE); cg_xml_node_addchildnode(faultNode, faultCodeNode); /**** <faultstring>UPnPError</faultstring> ****/ faultStringNode = cg_xml_node_new(); cg_xml_node_setname(faultStringNode, CG_SOAP_FAULT_STRING); cg_xml_node_setvalue(faultStringNode, CG_UPNP_CONTROL_FAULT_STRING); cg_xml_node_addchildnode(faultNode, faultStringNode); /**** <detail> ****/ detailNode = cg_xml_node_new(); cg_xml_node_setname(detailNode, CG_SOAP_DETAIL); cg_xml_node_addchildnode(faultNode, detailNode); /**** <UPnPError xmlns="urn:schemas-upnp-org:control-1-0"> ****/ upnpErrorNode = cg_xml_node_new(); cg_xml_node_setname(upnpErrorNode, CG_UPNP_CONTROL_FAULT_STRING); /**** Thanks for Visa Smolander (09/11/2005) ****/ cg_xml_node_setattribute(upnpErrorNode, CG_SOAP_ATTRIBUTE_XMLNS, CG_UPNP_CONTROL_XMLNS); cg_xml_node_addchildnode(detailNode, upnpErrorNode); /**** <errorCode>error code</errorCode> ****/ errorCodeNode = cg_xml_node_new(); cg_xml_node_setname(errorCodeNode, CG_UPNP_CONTROL_ERROR_CODE); cg_xml_node_setintvalue(errorCodeNode, errCode); cg_xml_node_addchildnode(upnpErrorNode, errorCodeNode); /**** <errorDescription>error string</errorDescription> ****/ errorDesctiprionNode = cg_xml_node_new(); cg_xml_node_setname(errorDesctiprionNode, CG_UPNP_CONTROL_ERROR_DESCRIPTION); cg_xml_node_setvalue(errorDesctiprionNode, errDescr); cg_xml_node_addchildnode(upnpErrorNode, errorDesctiprionNode); return faultNode; cg_log_debug_l4("Leaving...\n"); }
static CgXmlNode *cg_upnp_event_notify_request_createpropertysetnode(CgUpnpService* service, CgUpnpStateVariable *statVar) { CgXmlNode *propSetNode; CgXmlNode *propNode; CgXmlNode *varNode; cg_log_debug_l4("Entering...\n"); propSetNode = cg_xml_node_new(); cg_xml_node_setname(propSetNode, CG_UPNP_NOTIFY_XMLNS CG_SOAP_DELIM CG_UPNP_NOTIFY_PROPERTYSET); cg_xml_node_setnamespace(propSetNode, CG_UPNP_NOTIFY_XMLNS, CG_UPNP_SUBSCRIPTION_XMLNS); if (service) { for (statVar = cg_upnp_service_getstatevariables(service); statVar != NULL; statVar = cg_upnp_statevariable_next(statVar)) { if (!cg_upnp_statevariable_issendevents(statVar)) continue; propNode = cg_xml_node_new(); if (!propNode) continue; cg_xml_node_setname(propNode, CG_UPNP_NOTIFY_XMLNS CG_SOAP_DELIM CG_UPNP_NOTIFY_PROPERTY); cg_xml_node_addchildnode(propSetNode, propNode); varNode = cg_xml_node_new(); if (!varNode) { cg_xml_node_delete(propNode); continue; } cg_xml_node_setname(varNode, cg_upnp_statevariable_getname(statVar)); cg_xml_node_setvalue(varNode, cg_upnp_statevariable_getvalue(statVar)); cg_xml_node_addchildnode(propNode, varNode); } } else if (statVar) { propNode = cg_xml_node_new(); if (propNode) { cg_xml_node_setname(propNode, CG_UPNP_NOTIFY_XMLNS CG_SOAP_DELIM CG_UPNP_NOTIFY_PROPERTY); cg_xml_node_addchildnode(propSetNode, propNode); varNode = cg_xml_node_new(); if (varNode) { cg_xml_node_setname(varNode, cg_upnp_statevariable_getname(statVar)); cg_xml_node_setvalue(varNode, cg_upnp_statevariable_getvalue(statVar)); cg_xml_node_addchildnode(propNode, varNode); } else cg_xml_node_delete(propNode); } } cg_log_debug_l4("Leaving...\n"); return propSetNode; }
void cg_xml_node_copy(CgXmlNode *dstNode, CgXmlNode *srcNode) { CgXmlAttribute *attr; CgXmlNode *dstChildNode; CgXmlNode *srcChildNode; cg_log_debug_l4("Entering...\n"); if (!dstNode || !srcNode) return; cg_xml_node_setname(dstNode, cg_xml_node_getname(srcNode)); cg_xml_node_setvalue(dstNode, cg_xml_node_getvalue(srcNode)); for (attr = cg_xml_node_getattributes(srcNode); attr != NULL; attr = cg_xml_attribute_next(attr)) cg_xml_node_setattribute(dstNode, cg_xml_attribute_getname(attr), cg_xml_attribute_getvalue(attr)); for (srcChildNode = cg_xml_node_getchildnodes(srcNode); srcChildNode != NULL; srcChildNode = cg_xml_node_next(srcChildNode)) { dstChildNode = cg_xml_node_new(); cg_xml_node_copy(dstChildNode, srcChildNode); cg_xml_node_addchildnode(dstNode, dstChildNode); } cg_log_debug_l4("Leaving...\n"); }
void cg_xml_node_setchildnode(CgXmlNode *node, char *name, char *value) { CgXmlNode *childNode; cg_log_debug_l4("Entering...\n"); childNode = cg_xml_node_getchildnode(node, name); if (childNode != NULL) { cg_xml_node_setvalue(childNode, value); return; } childNode = cg_xml_node_new(); cg_xml_node_setname(childNode, name); cg_xml_node_setvalue(childNode, value); cg_xml_node_addchildnode(node, childNode); cg_log_debug_l4("Leaving...\n"); }
void cg_upnpav_resource_copy(CgUpnpAvResource *destRes, CgUpnpAvResource *srcRes) { CgXmlAttribute *attr; cg_xml_node_setname(destRes, cg_xml_node_getname(srcRes)); cg_xml_node_setvalue(destRes, cg_xml_node_getvalue(srcRes)); for (attr=cg_xml_node_getattributes(srcRes); attr; attr=cg_xml_attribute_next(attr)) cg_xml_node_setattribute(destRes, cg_xml_attribute_getname(attr), cg_xml_attribute_getvalue(attr)); cg_upnpav_resource_data_copy((CgUpnpAvResourceData *)cg_xml_node_getuserdata(destRes), (CgUpnpAvResourceData *)cg_xml_node_getuserdata(srcRes)); }
static CgXmlNode *cg_upnp_control_query_response_createresponsenode(CgUpnpStateVariable *statVar) { CgXmlNode *queryResNode; CgXmlNode *returnNode; cg_log_debug_l4("Entering...\n"); queryResNode = cg_xml_node_new(); cg_xml_node_setname(queryResNode, CG_UPNP_CONTROL_NS CG_SOAP_DELIM CG_UPNP_CONTROL_QUERY_STATE_VARIABLE_RESPONSE); cg_xml_node_setnamespace(queryResNode, CG_UPNP_CONTROL_NS, CG_UPNP_CONTROL_XMLNS); returnNode = cg_xml_node_new(); cg_xml_node_setname(returnNode, CG_UPNP_CONTROL_RETURN); cg_xml_node_setvalue(returnNode, cg_upnp_statevariable_getvalue(statVar)); cg_xml_node_addchildnode(queryResNode, returnNode); return queryResNode; cg_log_debug_l4("Leaving...\n"); }