Esempio n. 1
0
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);
  }
}
Esempio n. 2
0
void cg_upnpav_content_settype(CgUpnpAvContent* con, int type)
{
  switch (type) {
  case CG_UPNPAV_CONTENT_CONTAINER: {
    cg_xml_node_setname(con, CG_UPNPAV_CONTENT_CONTAINER_STRING);
    cg_upnpav_content_setupnpclass(con, CG_UPNPAV_UPNPCLASS_CONTAINER);
  } break;
  case CG_UPNPAV_CONTENT_ITEM: {
    cg_xml_node_setname(con, CG_UPNPAV_CONTENT_ITEM_STRING);
  } break;
  }
}
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;
}
Esempio n. 4
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");
}
Esempio n. 5
0
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));
}
Esempio n. 6
0
CgXmlNode *cg_soap_createenvelopebodynode()
{
	CgXmlNode *envNode;
	CgXmlNode *bodyNode;
	
	cg_log_debug_l4("Entering...\n");

	envNode = cg_xml_node_new();
	cg_xml_node_setname(envNode, CG_SOAP_XMLNS CG_SOAP_DELIM CG_SOAP_ENVELOPE);
	cg_xml_node_setattribute(envNode, CG_SOAP_ATTRIBUTE_XMLNS CG_SOAP_DELIM CG_SOAP_XMLNS, CG_SOAP_XMLNS_URL);
	cg_xml_node_setattribute(envNode, CG_SOAP_XMLNS CG_SOAP_DELIM CG_SOAP_ENCORDING, CG_SOAP_ENCSTYLE_URL);

	bodyNode = cg_xml_node_new();
	cg_xml_node_setname(bodyNode, CG_SOAP_XMLNS CG_SOAP_DELIM CG_SOAP_BODY);
	cg_xml_node_addchildnode(envNode, bodyNode);

	return envNode;

	cg_log_debug_l4("Leaving...\n");
}
Esempio n. 7
0
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");
}
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");
}
Esempio n. 9
0
File: cdidl.c Progetto: Coramo/mupnp
CgXmlNode* cg_upnpav_didl_node_new()
{
  CgXmlNode* node;

  node = cg_xml_node_new();

  cg_xml_node_setname(node, CG_UPNPAV_DMS_DIDL_NAME);
  cg_xml_node_setattribute(node, CG_UPNPAV_DMS_DIDL_XMLNS, CG_UPNPAV_DMS_DIDL_XMLNS_URL);
  cg_xml_node_setattribute(node, CG_UPNPAV_DMS_DIDL_XMLNS_DC, CG_UPNPAV_DMS_DIDL_XMLNS_DC_URL);
  cg_xml_node_setattribute(node, CG_UPNPAV_DMS_DIDL_XMLNS_UPNP, CG_UPNPAV_DMS_DIDL_XMLNS_UPNP_URL);
  cg_xml_node_setattribute(node, CG_UPNPAV_DMS_DIDL_XMLNS_DLNA, CG_UPNPAV_DMS_DIDL_XMLNS_DLNA_URL);

  return node;
}
Esempio n. 10
0
CgUpnpAvResource *cg_upnpav_resource_new()
{
    CgUpnpAvResource *node;
    CgUpnpAvResourceData *nodeData;

    node = cg_xml_node_new();

    cg_xml_node_setname(node, CG_UPNPAV_RESOURCE_NAME);

    nodeData = cg_upnpav_resource_data_new();
    cg_xml_node_setuserdata(node, nodeData);

    return node;
}
static void XMLCALL cg_expat_element_start(void *userData, const char *el, const char **attr)
{
    CgExpatData *expatData;
    CgXmlNode *node;
    int n;
#if defined DEBUG_XML
    int out,j;
    char* outbuf;
    char* lpout;
#endif

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

#if defined DEBUG_XML
    outbuf = (char*) malloc(4096);
    lpout = outbuf;
    outbuf[4095] = (char)0;
    for (out = 0; out < indent; out++) outbuf[out] = (char)' ';
    lpout += out;
    for (j = 0; attr[j]; j += 2) {
         lpout += sprintf(lpout,"%s='%s'", attr[j], attr[j + 1]);
    }
    lpout[0] = 0;
    printf("%8x XML Node start %s - %d Attribute %s\n",userData,el,j/2,outbuf);
    free(outbuf);
    ++indent;
#endif
    //memdiags_memlist_report_unmarkedsize();

    expatData = (CgExpatData *)userData;

    node = cg_xml_node_new();
    cg_xml_node_setname(node, (char *)el);

    for (n = 0; attr[n]; n += 2)
        cg_xml_node_setattribute(node, (char *)attr[n], (char *)attr[n+1]);

    if (expatData->rootNode != NULL) {
        if (expatData->currNode != NULL)
            cg_xml_node_addchildnode(expatData->currNode, node);
        else
            cg_xml_node_addchildnode(expatData->rootNode, node);
    }
    else
        expatData->rootNode = node;

    expatData->currNode = node;

    cg_log_debug_l4("Leaving...\n");
}
Esempio n. 12
0
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");
}