CgUpnpPropertyList *cg_upnp_event_notify_request_getpropertylist(CgUpnpNotifyRequest *notifyReq)
{
    CgUpnpPropertyList *propList;
    CgXmlNode *propSetNode;
    CgXmlNode *propNode;
    CgXmlNode *varNode;
    CgUpnpProperty *prop;
    const char *sid;
    size_t seq;

    cg_log_debug_l4("Entering...\n");

  sid = cg_upnp_event_notify_request_getsid(notifyReq);
    seq = cg_upnp_event_notify_request_getseq(notifyReq);

    propList = cg_upnp_event_notify_request_getpropertylistonly(notifyReq);
    cg_upnp_propertylist_clear(propList);

    propSetNode = cg_soap_request_getrootnoode(notifyReq);
    if (propSetNode == NULL)
        return propList;

    for (propNode = cg_xml_node_getchildnodes(propSetNode); propNode != NULL; propNode = cg_xml_node_next(propNode)) {
        varNode = cg_xml_node_getchildnodes(propNode);
        prop = cg_upnp_property_createfromnode(varNode);
        cg_upnp_property_setsid(prop, sid);
        cg_upnp_property_setseq(prop, seq);
        cg_upnp_propertylist_add(propList, prop);
    }

    cg_log_debug_l4("Leaving...\n");

    return propList;
}
CgXmlNode *cg_upnp_control_query_response_getreturnnode(CgUpnpQueryResponse *queryRes)
{
	CgSoapResponse *soapRes;	
	CgXmlNode *bodyNode;
	CgXmlNode *queryResNode;
	
	cg_log_debug_l4("Entering...\n");

	soapRes = cg_upnp_control_query_response_getsoapresponse(queryRes);
	
	bodyNode = cg_soap_response_getbodynode(soapRes);
	if (bodyNode == NULL)
		return NULL;
	if (cg_xml_node_haschildnodes(bodyNode) == FALSE)
		return NULL;

	queryResNode = cg_xml_node_getchildnodes(bodyNode);		
	if (queryResNode == NULL)
		return NULL;
	if (cg_xml_node_haschildnodes(queryResNode) == FALSE)
		return NULL;
		
	return cg_xml_node_getchildnodes(queryResNode);		

	cg_log_debug_l4("Leaving...\n");
}
示例#3
0
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");
}
示例#4
0
文件: ccontent.c 项目: Coramo/mupnp
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);
  }
}
示例#5
0
文件: ccontent.c 项目: Coramo/mupnp
BOOL cg_upnpav_content_haschildcontents(CgUpnpAvContent* con)
{
  CgXmlNode* childNode;
  for (childNode = cg_xml_node_getchildnodes(con); childNode; childNode = cg_xml_node_next(childNode)) {
    if (cg_upnpav_content_iscontentnode(childNode))
      return TRUE;
  }
  return FALSE;
}
示例#6
0
文件: ccontent.c 项目: Coramo/mupnp
CgUpnpAvContent* cg_upnpav_content_getchildcontents(CgUpnpAvContent* con)
{
  CgXmlNode* childNode;
  for (childNode = cg_xml_node_getchildnodes(con); childNode; childNode = cg_xml_node_next(childNode)) {
    if (cg_upnpav_content_iscontentnode(childNode))
      return childNode;
  }
  return NULL;
}
示例#7
0
文件: ccontent.c 项目: Coramo/mupnp
int cg_upnpav_content_getnchildcontents(CgUpnpAvContent* con)
{
  CgXmlNode* childNode;
  int contentNodeCnt;
  contentNodeCnt = 0;
  for (childNode = cg_xml_node_getchildnodes(con); childNode; childNode = cg_xml_node_next(childNode)) {
    if (cg_upnpav_content_iscontentnode(childNode))
      contentNodeCnt++;
  }
  return contentNodeCnt;
}
CgXmlNode *cg_upnp_event_notify_request_getvariablenode(CgUpnpNotifyRequest *nofityReq)
{
    CgXmlNode *propSetNode;
    CgXmlNode *propNode;

    cg_log_debug_l4("Entering...\n");

    propSetNode = cg_upnp_event_notify_request_getpropertysetnode(nofityReq);
    if (propSetNode == NULL)
        return NULL;
    if (cg_xml_node_haschildnodes(propSetNode) == FALSE)
        return NULL;

    propNode = cg_xml_node_getchildnodes(propSetNode);
    if (propNode == NULL)
        return NULL;
    if (cg_xml_node_haschildnodes(propNode) == FALSE)
        return NULL;

    cg_log_debug_l4("Leaving...\n");

    return cg_xml_node_getchildnodes(propNode);
}
示例#9
0
CgXmlNode *cg_soap_response_getbodynode(CgSoapResponse *soapRes)
{
	CgXmlNode *envNode;
	 
	cg_log_debug_l4("Entering...\n");

	envNode = cg_soap_response_getenvelopenode(soapRes);
	if (envNode == NULL)
		return NULL;
	if (cg_xml_node_haschildnodes(envNode) == FALSE)
		return NULL;
	return cg_xml_node_getchildnodes(envNode);

	cg_log_debug_l4("Leaving...\n");
}
示例#10
0
static char *cg_xml_node_tostring_indent(CgXmlNode *node, int indentLevel, BOOL withChildNode, CgString *str)
{
	char *name;
	char *value;
	CgString *valueStr;
	CgXmlNode *childNode;
	
	cg_log_debug_l4("Entering...\n");

	name = cg_xml_node_getname(node);
	value = cg_xml_node_getvalue(node);

	if (cg_xml_node_haschildnodes(node) == FALSE || withChildNode == FALSE) {
		cg_string_addrepvalue(str, CG_XML_INDENT_STRING, indentLevel);
		if (!cg_string_naddvalue(str, "<", 1) ||
		    !cg_string_addvalue(str, name) ||
		    !cg_xml_node_attribute_tostring(node, str))
			/* Memory allocation failed */
			return NULL;
		
		valueStr = cg_string_new();
		if (!valueStr)
			/* Memory allocation failed */
			return NULL;
		
		cg_string_setvalue(valueStr, value);
		cg_xml_escapechars(valueStr);

		if (!cg_string_naddvalue(str, ">", 1) ||
		    !cg_string_addvalue(str, cg_string_getvalue(valueStr)) ||
		    !cg_string_naddvalue(str, "</", 2) ||
		    !cg_string_addvalue(str, name) ||
		    !cg_string_naddvalue(str, ">", 1) ||
		    !cg_string_addvalue(str, "\n"))
		{
			/* Memory allocation failed */
			cg_string_delete(valueStr);
			return NULL;
		}

		cg_string_delete(valueStr);
		
		return cg_string_getvalue(str);
	}

	cg_string_addrepvalue(str, CG_XML_INDENT_STRING, indentLevel);
	if (!cg_string_naddvalue(str, "<", 1) ||
	    !cg_string_addvalue(str, name) ||
	    !cg_xml_node_attribute_tostring(node, str) ||
	    !cg_string_naddvalue(str, ">", 1) ||
	    !cg_string_addvalue(str, "\n"))
		/* Memory allocation failed */
		return NULL;

	for (childNode = cg_xml_node_getchildnodes(node); childNode != NULL; childNode = cg_xml_node_next(childNode))
		if (!cg_xml_node_tostring_indent(childNode, indentLevel+1, TRUE, str))
			/* Memory allocation failed */
			return NULL;

	cg_string_addrepvalue(str, CG_XML_INDENT_STRING, indentLevel);
	if (!cg_string_naddvalue(str, "</", 2) ||
	    !cg_string_addvalue(str, name) ||
	    !cg_string_naddvalue(str, ">", 1) ||
	    !cg_string_addvalue(str, "\n"))
		/* Memory allocation failed */
		return NULL;

	cg_log_debug_l4("Leaving...\n");
	
	return cg_string_getvalue(str);
}