示例#1
0
/**
 * Parse the service description from the service's SCPD URL. Do not call
 * this from user applications.
 * 
 * @param service The service in question
 * @return TRUE if successful; otherwise FALSE
 */
BOOL cg_upnp_controlpoint_parsescservicescpd(CgUpnpService *service)
{
	CgNetURL *scpdURL;
	BOOL scpdParseSuccess;
	
	cg_log_debug_l4("Entering...\n");

	scpdURL = cg_upnp_service_getscpdurl(service); 

	if ( NULL == scpdURL )		
		return FALSE;
	
	cg_log_debug_s("SCPD URL: %s\n", cg_net_url_getrequest(scpdURL));
	scpdParseSuccess = cg_upnp_service_parsedescriptionurl(service, scpdURL);
	
	cg_net_url_delete(scpdURL);
	if (scpdParseSuccess == TRUE)
		return TRUE;

#if defined(CG_UPNP_USE_STDDCP)
	if (cg_upnp_service_hasstddcp(service)) {
		char *stdDCP = cg_upnp_service_getstddcp(service);
		scpdParseSuccess = cg_upnp_service_parsedescription(service, stdDCP, cg_strlen(stdDCP));
	}
#endif

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

	return scpdParseSuccess;
}
void cg_upnp_control_request_sethostfromservice(CgSoapRequest *soapReq, CgUpnpService *service)
{
	CgHttpRequest *httpReq;
	CgNetURL *ctrlURL;
	
	cg_log_debug_l4("Entering...\n");

	httpReq = cg_soap_request_gethttprequest(soapReq);

	ctrlURL = cg_upnp_service_getcontrolurl(service);

	cg_log_debug_s("Ctrl URL: %s - %d -%s", 
			cg_net_url_gethost(ctrlURL), 
			cg_net_url_getport(ctrlURL), 
			cg_net_url_getpath(ctrlURL));

	//cg_http_request_seturi(httpReq, cg_xml_node_getchildnodevalue(cg_upnp_service_getservicenode(service), CG_UPNP_SERVICE_CONTROL_URL));
	cg_http_request_seturi(httpReq, cg_net_url_getrequest(ctrlURL));

	/**** Host ****/
	cg_net_url_delete(httpReq->postURL);
	httpReq->postURL = ctrlURL;

	cg_log_debug_s("Post URL: %s - %d -%s", 
			cg_net_url_gethost(httpReq->postURL), 
			cg_net_url_getport(httpReq->postURL), 
			cg_net_url_getpath(httpReq->postURL));

	cg_log_debug_l4("Leaving...\n");
}
static void cg_upnp_event_subscription_request_setservice(CgUpnpSubscriptionRequest *subReq, CgUpnpService *service)
{
    CgNetURL *eventSubURL;

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

    eventSubURL = cg_upnp_service_geteventsuburl(service);
    cg_http_request_seturi(subReq, cg_net_url_getrequest(eventSubURL));

    cg_net_url_delete(subReq->postURL);

    subReq->postURL = eventSubURL;

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