예제 #1
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");
}
예제 #2
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;
}
예제 #3
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");
}
예제 #4
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;
}
예제 #5
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;
}
예제 #6
0
bool mupnp_upnpav_dms_condir_actionreceived(mUpnpAction *action)
{
	mUpnpAvServer *dms;
	mUpnpDevice *dev;
	char *actionName;
	mUpnpArgument *arg;
	char *argValue;
	char intBuf[MUPNP_STRING_INTEGER_BUFLEN];

	actionName = (char*)mupnp_action_getname(action);
	if (mupnp_strlen(actionName) <= 0)
		return false;

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

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

	/* Browse */
	if (mupnp_streq(actionName, CG_UPNPAV_DMS_CONTENTDIRECTORY_BROWSE))
	{
		arg = mupnp_action_getargumentbyname(action, CG_UPNPAV_DMS_CONTENTDIRECTORY_BROWSE_BROWSE_FLAG);
		if (!arg)
			return false;
		argValue = mupnp_argument_getvalue(arg);
		if (mupnp_streq(argValue, CG_UPNPAV_DMS_CONTENTDIRECTORY_BROWSE_BROWSE_METADATA))
			return mupnp_upnpav_dms_condir_browsemetadata(dms, action);
		if (mupnp_streq(argValue, CG_UPNPAV_DMS_CONTENTDIRECTORY_BROWSE_BROWSE_DIRECT_CHILDREN))
			return mupnp_upnpav_dms_condir_browsedirectchildren(dms, action);
		return false;
	}

	/* Search */
	if (mupnp_streq(actionName, CG_UPNPAV_DMS_CONTENTDIRECTORY_SEARCH)) {
		/* Not Implemented */
		return false;
	}

	/* Sort Capabilities */
	if (mupnp_streq(actionName, CG_UPNPAV_DMS_CONTENTDIRECTORY_GET_SORT_CAPABILITIES)) {
		arg = mupnp_action_getargumentbyname(action, CG_UPNPAV_DMS_CONTENTDIRECTORY_SORT_CAPS);
		if (!arg)
			return false;
		mupnp_argument_setvalue(arg, "");
		return true;
	}

	/* Search Capabilities */
	if (mupnp_streq(actionName, CG_UPNPAV_DMS_CONTENTDIRECTORY_GET_SEARCH_CAPABILITIES)) {
		arg = mupnp_action_getargumentbyname(action, CG_UPNPAV_DMS_CONTENTDIRECTORY_SEARCH_CAPS);
		if (!arg)
			return false;
		mupnp_argument_setvalue(arg, "");
		return true;
	}

	/* System Update ID */
	if (mupnp_streq(actionName, CG_UPNPAV_DMS_CONTENTDIRECTORY_GET_SYSTEM_UPDATE_ID)) {
		arg = mupnp_action_getargumentbyname(action, CG_UPNPAV_DMS_CONTENTDIRECTORY_ID);
		if (!arg)
			return false;
		mupnp_argument_setvalue(arg, mupnp_int2str(mupnp_upnpav_dms_condir_getsystemupdateid(dms), intBuf, MUPNP_STRING_INTEGER_BUFLEN));
		return true;
	}

	return false;
}