Ejemplo n.º 1
0
mUpnpXmlNode *mupnp_control_action_request_createactionnode(mUpnpAction *action)
{
	mUpnpService *service;
	mUpnpXmlNode *actionNode;
	mUpnpArgument *arg;
	mUpnpXmlNode *argNode;
	mUpnpString *nameWithNamespace;
		
	mupnp_log_debug_l4("Entering...\n");

	service = mupnp_action_getservice(action);
	
	actionNode = mupnp_xml_node_new();
	/**** Thanks for Visa Smolander (10/31/2005) ****/
	nameWithNamespace = mupnp_string_new();
	mupnp_string_addvalue( nameWithNamespace, MUPNP_CONTROL_NS ":" );
	mupnp_string_addvalue( nameWithNamespace, mupnp_action_getname(action) );
	mupnp_xml_node_setname(actionNode, mupnp_string_getvalue( nameWithNamespace ) );
	mupnp_string_delete( nameWithNamespace );
	mupnp_xml_node_setnamespace(actionNode, MUPNP_CONTROL_NS, mupnp_service_getservicetype(service));
	
	for (arg = mupnp_action_getarguments(action); arg; arg = mupnp_argument_next(arg)) {
		if (mupnp_argument_isindirection(arg) == false)
			continue;
		argNode = mupnp_xml_node_new();
		mupnp_xml_node_setname(argNode, mupnp_argument_getname(arg));			
		mupnp_xml_node_setvalue(argNode, mupnp_argument_getvalue(arg));			
		mupnp_xml_node_addchildnode(actionNode, argNode);
	}
	
	mupnp_log_debug_l4("Leaving...\n");
	
	return actionNode;
}
Ejemplo n.º 2
0
void mupnp_service_ssdpmessagereceived(mUpnpService *service, mUpnpSSDPPacket *ssdpPkt)
{
    mUpnpDevice *dev;
    const char *ssdpST;
    const char *serviceType;
    char serviceNT[MUPNP_SSDP_HEADER_LINE_MAXSIZE];
    char serviceUSN[MUPNP_SSDP_HEADER_LINE_MAXSIZE];

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

    ssdpST = mupnp_ssdp_packet_getst(ssdpPkt);
    if (mupnp_strlen(ssdpST) <= 0)
        return;

    dev = mupnp_service_getdevice(service);

    mupnp_service_getnotifyservicetypent(service, serviceNT, sizeof(serviceNT));
    mupnp_service_getnotifyservicetypeusn(service, serviceUSN, sizeof(serviceUSN));

    if (mupnp_st_isalldevice(ssdpST) == true) {
        mupnp_device_postsearchresponse(dev, ssdpPkt, serviceNT, serviceUSN);
    }
    else if (mupnp_st_isurn(ssdpST)  == true) {
        serviceType = mupnp_service_getservicetype(service);
        if (mupnp_streq(ssdpST, serviceType) == true)
            mupnp_device_postsearchresponse(dev, ssdpPkt, serviceType, serviceUSN);
    }

    mupnp_log_debug_l4("Leaving...\n");
}
Ejemplo n.º 3
0
void mupnp_control_action_request_setaction(mUpnpActionRequest *actionReq, mUpnpAction *action)
{
	mUpnpService *service;
	mUpnpSoapRequest *soapReq;
	mUpnpString *soapAction;	
	mUpnpXmlNode *bodyNode;
	mUpnpXmlNode *contentNode;
	
	mupnp_log_debug_l4("Entering...\n");

	service = mupnp_action_getservice(action);
	soapReq = mupnp_control_action_request_getsoaprequest(actionReq);
	
	soapAction = mupnp_string_new();
	mupnp_string_addvalue(soapAction, "\"");
	mupnp_string_addvalue(soapAction, mupnp_service_getservicetype(service));
	mupnp_string_addvalue(soapAction, "#");
	mupnp_string_addvalue(soapAction, mupnp_action_getname(action));
	mupnp_string_addvalue(soapAction, "\"");
	mupnp_soap_request_setsoapaction(soapReq, mupnp_string_getvalue(soapAction));
	mupnp_string_delete(soapAction);
		
	mupnp_control_request_sethostfromservice(soapReq, service);
	
	mupnp_control_soap_request_initializeenvelopenode(soapReq);
	bodyNode = mupnp_soap_request_getbodynode(soapReq);
	contentNode = mupnp_control_action_request_createactionnode(action);
	mupnp_xml_node_addchildnode(bodyNode, contentNode);

	mupnp_soap_request_createcontent(soapReq);

	mupnp_log_debug_l4("Leaving...\n");
}
Ejemplo n.º 4
0
bool mupnp_upnpav_dms_queryreceived(mUpnpStateVariable *statVar)
{
	mUpnpDevice *dev;
	mUpnpService *service;
	mUpnpAvServer *dms;
	CG_UPNPAV_STATEVARIABLE_LISTNER userQueryListener;

	service = mupnp_statevariable_getservice(statVar);
	if (!service)
		return false;

	dev = (mUpnpDevice *)mupnp_service_getdevice(service);
	if (!dev)
		return false;

	dms = (mUpnpAvServer *)mupnp_device_getuserdata(dev);
	if (!dms)
		return false;

	userQueryListener = mupnp_upnpav_dms_getquerylistener(dms);
	if (userQueryListener) {
		if (userQueryListener(statVar))
			return true;
	}

	if (mupnp_streq(mupnp_service_getservicetype(service), CG_UPNPAV_DMS_CONTENTDIRECTORY_SERVICE_TYPE))
		return mupnp_upnpav_dms_condir_queryreceived(statVar);

	return false;
}
Ejemplo n.º 5
0
mUpnpService *SelectService(mUpnpDevice *dev)
{
	mUpnpService *service;
	int n;
	char key;
	int serviceNum;

	n = 0;
	for (service = mupnp_device_getservices(dev); service != NULL; service = mupnp_service_next(service)) {
		key = 'a' + n;
		if ('z' < key)
			break;
		printf(" [%c] = %s\n", key, mupnp_service_getservicetype(service));
		n++;
	}
	printf("Select Service : ");
	key = kbgetkey();
	key = tolower(key);
	printf("%c\n", key);
	
	if (!isalpha(key))
		return NULL;
	
	serviceNum = key - 'a';
	service = mupnp_device_getservices(dev);
	for (n=0; n<serviceNum; n++)
		service = mupnp_service_next(service);

	return service;
}
Ejemplo n.º 6
0
char *mupnp_service_getstddcp(mUpnpService *service)
{
	char *serviceType = mupnp_service_getservicetype(service);
	if (mupnp_streq(serviceType, "urn:schemas-upnp-org:service:ContentDirectory:1"))
		return MUPNP_AV_CONTENTDIRECTORY_SERVICE_DESCRIPTION;
	if (mupnp_streq(serviceType, "urn:schemas-upnp-org:service:ConnectionManager:1"))
		return MUPNP_AV_CONNECTIONMANAGER_SERVICE_DESCRIPTION;
	if (mupnp_streq(serviceType, "urn:schemas-upnp-org:service:AVTransport:1"))
		return MUPNP_AV_AVTRANSPORT_SERVICE_DESCRIPTION;
	return NULL;
}
Ejemplo n.º 7
0
static mUpnpXmlNode *mupnp_control_action_response_createresponsenode(mUpnpAction *action)
{
	mUpnpXmlNode *actionNameResNode;
	char nodeName[MUPNP_ACTOINNAME_LEN_MAX + sizeof(MUPNP_SOAP_METHODNS) + sizeof(MUPNP_SOAP_DELIM) + sizeof(MUPNP_SOAP_RESPONSE) + 1];
	char attrName[sizeof(MUPNP_SOAP_ATTRIBUTE_XMLNS) + sizeof(MUPNP_SOAP_DELIM) + sizeof(MUPNP_SOAP_METHODNS) + 1];
	const char *actionName;
	mUpnpXmlNode *serviceNode;
	mUpnpService *service;
	mUpnpArgumentList *argList;
	mUpnpArgument *arg;
	mUpnpXmlNode *argNode;
	
	mupnp_log_debug_l4("Entering...\n");

	actionNameResNode = mupnp_xml_node_new();

	/* action name */
	actionName = mupnp_action_getname(action);
	mupnp_strcpy(nodeName, MUPNP_SOAP_METHODNS);
	mupnp_strcat(nodeName, MUPNP_SOAP_DELIM);
	mupnp_strncat(nodeName, actionName, MUPNP_ACTOINNAME_LEN_MAX);
	mupnp_strcat(nodeName, MUPNP_SOAP_RESPONSE);
	mupnp_xml_node_setname(actionNameResNode, nodeName);

	/* service attribute */
	serviceNode = mupnp_service_getservicenode(mupnp_action_getservice(action));
	if (serviceNode != NULL) {
		service = mupnp_service_new();
		mupnp_service_setservicenode(service, serviceNode);
		mupnp_strcpy(attrName, MUPNP_SOAP_ATTRIBUTE_XMLNS);
		mupnp_strcat(attrName, MUPNP_SOAP_DELIM);
		mupnp_strcat(attrName, MUPNP_SOAP_METHODNS);
		mupnp_xml_node_setattribute(actionNameResNode, attrName, mupnp_service_getservicetype(service));
		mupnp_service_delete(service);
	}

	/* arguments */
	argList = mupnp_action_getargumentlist(action);
	for (arg = mupnp_argumentlist_gets(argList); arg != NULL; arg = mupnp_argument_next(arg)) {
		if (mupnp_argument_isoutdirection(arg) == false)
			continue;
		argNode = mupnp_xml_node_new();
		mupnp_xml_node_setname(argNode, mupnp_argument_getname(arg));		
		mupnp_xml_node_setvalue(argNode, mupnp_argument_getvalue(arg));
		mupnp_xml_node_addchildnode(actionNameResNode, argNode);
	}

	return actionNameResNode;

	mupnp_log_debug_l4("Leaving...\n");
}
Ejemplo n.º 8
0
bool mupnp_upnpav_dmr_queryreceived(mUpnpStateVariable *statVar)
{
	mUpnpDevice *dev;
	mUpnpService *service;
	mUpnpAvRenderer *dmr;
	CG_UPNPAV_STATEVARIABLE_LISTNER userQueryListener;

	service = mupnp_statevariable_getservice(statVar);
	if (!service)
		return false;

	dev = (mUpnpDevice *)mupnp_service_getdevice(service);
	if (!dev)
		return false;

	dmr = (mUpnpAvRenderer *)mupnp_device_getuserdata(dev);
	if (!dmr)
		return false;

	userQueryListener = mupnp_upnpav_dmr_getquerylistener(dmr);
	if (userQueryListener) {
		if (userQueryListener(statVar))
			return true;
	}

	if (mupnp_streq(mupnp_service_getservicetype(service), CG_UPNPAV_DMR_AVTRANSPORT_SERVICE_TYPE))
		return mupnp_upnpav_dmr_avtransport_queryreceived(statVar);

	if (mupnp_streq(mupnp_service_getservicetype(service), CG_UPNPAV_DMR_RENDERINGCONTROL_SERVICE_TYPE))
		return mupnp_upnpav_dmr_renderingctrl_queryreceived(statVar);

	if (mupnp_streq(mupnp_service_getservicetype(service), CG_UPNPAV_DMR_CONNECTIONMANAGER_SERVICE_TYPE))
		return mupnp_upnpav_dmr_conmgr_queryreceived(statVar);

	return false;
}
Ejemplo n.º 9
0
bool mupnp_upnpav_dmr_actionreceived(mUpnpAction *action)
{
	mUpnpDevice *dev;
	mUpnpService *service;
	mUpnpAvRenderer *dmr;
	CG_UPNPAV_ACTION_LISTNER userActionListener;

	service = mupnp_action_getservice(action);
	if (!service)
		return false;

	dev = (mUpnpDevice *)mupnp_service_getdevice(service);
	if (!dev)
		return false;

	dmr = (mUpnpAvRenderer *)mupnp_device_getuserdata(dev);
	if (!dmr)
		return false;

	userActionListener = mupnp_upnpav_dmr_getactionlistener(dmr);
	if (userActionListener) {
		if (userActionListener(action))
			return true;
	}

	if (mupnp_streq(mupnp_service_getservicetype(service), CG_UPNPAV_DMR_AVTRANSPORT_SERVICE_TYPE))
		return mupnp_upnpav_dmr_avtransport_actionreceived(action);

	if (mupnp_streq(mupnp_service_getservicetype(service), CG_UPNPAV_DMR_RENDERINGCONTROL_SERVICE_TYPE))
		return mupnp_upnpav_dmr_renderingctrl_actionreceived(action);

	if (mupnp_streq(mupnp_service_getservicetype(service), CG_UPNPAV_DMR_CONNECTIONMANAGER_SERVICE_TYPE))
		return mupnp_upnpav_dmr_conmgr_actionreceived(action);

	return false;
}
Ejemplo n.º 10
0
bool mupnp_upnpav_dms_actionreceived(mUpnpAction *action)
{
	mUpnpDevice *dev;
	mUpnpService *service;
	mUpnpAvServer *dms;
	CG_UPNPAV_ACTION_LISTNER userActionListener;

	service = mupnp_action_getservice(action);
	if (!service)
		return false;

	dev = (mUpnpDevice *)mupnp_service_getdevice(service);
	if (!dev)
		return false;

	dms = (mUpnpAvServer *)mupnp_device_getuserdata(dev);
	if (!dms)
		return false;

	userActionListener = mupnp_upnpav_dms_getactionlistener(dms);
	if (userActionListener) {
		if (userActionListener(action))
			return true;
	}

	if (mupnp_streq(mupnp_service_getservicetype(service), CG_UPNPAV_DMS_CONTENTDIRECTORY_SERVICE_TYPE))
		return mupnp_upnpav_dms_condir_actionreceived(action);

	if (mupnp_streq(mupnp_service_getservicetype(service), CG_UPNPAV_DMS_MEDIARECEIVER_SERVICE_TYPE))
		return mupnp_upnpav_dms_medrec_actionreceived(action);

	if (mupnp_streq(mupnp_service_getservicetype(service), CG_UPNPAV_DMS_CONNECTIONMANAGER_SERVICE_TYPE))
		return mupnp_upnpav_dms_conmgr_actionreceived(action);

	return false;
}
Ejemplo n.º 11
0
void PrintDeviceInfo(mUpnpDevice *dev, int indent)
{
	char indentStr[128];
	int n;
	mUpnpService *service;
	int serviceCnt;
	mUpnpAction *action;
	int actionCnt;
	mUpnpArgumentList *arg;
	int argCnt;
	mUpnpStateVariable *stateVar;
	int stateVarCnt;
	
	for (n=0; n<indent && n<(sizeof(indentStr)-1); n++)
		indentStr[n] = ' ';
	indentStr[n] = '\0';
	
	serviceCnt = 0;
	for (service = mupnp_device_getservices(dev); service != NULL; service = mupnp_service_next(service)) {
		printf("%s service[%d] = %s\n", indentStr, ++serviceCnt, mupnp_service_getservicetype(service));
		actionCnt = 0;
		for (action = mupnp_service_getactions(service); action != NULL; action = mupnp_action_next(action)) {
			printf("%s  action[%d] = %s\n", indentStr, ++actionCnt, mupnp_action_getname(action));
			argCnt = 0;
			for (arg = mupnp_action_getarguments(action); arg != NULL; arg = mupnp_argument_next(arg)) {
				printf("%s   arg[%d] = %s\n", indentStr, ++argCnt, mupnp_argument_getname(arg));
			}
		}
		stateVarCnt = 0;
		for (stateVar = mupnp_service_getstatevariables(service); stateVar != NULL; stateVar = mupnp_statevariable_next(stateVar)) {
			printf("%s  stateVar[%d] = %s = %s\n", 
			       indentStr, 
			       ++stateVarCnt, 
			       mupnp_statevariable_getname(stateVar),
			       mupnp_statevariable_getvalue(stateVar));
		}
	}
}