Esempio n. 1
0
BOOL upnp_clock_actionreceived(mUpnpAction *action)
{
	mUpnpTime currTime;
	const char *actionName;
	mUpnpArgument *currTimeArg;
	char sysTimeStr[SYSTEM_TIME_BUF_LEN];
	mUpnpArgument *newTimeArg, *resultArg;

	currTime = mupnp_getcurrentsystemtime();
	
	actionName = mupnp_action_getname(action);
	if (strcmp("GetTime", actionName) == 0) {
		GetSystemTimeString(currTime, sysTimeStr);
		currTimeArg = mupnp_action_getargumentbyname(action, "CurrentTime");
		mupnp_argument_setvalue(currTimeArg, sysTimeStr);
		return TRUE;
	}
	if (strcmp(actionName, "SetTime") == 0) {
		newTimeArg = mupnp_action_getargumentbyname(action, "NewTime");
		resultArg = mupnp_action_getargumentbyname(action, "Result");
		mupnp_argument_setvalue(resultArg, "Not implemented");
		return TRUE;
	}

	return FALSE;
}
Esempio n. 2
0
bool mupnp_control_action_response_getresult(mUpnpActionResponse *actionRes, mUpnpAction *action)
{
	mUpnpXmlNode *resNode;
	mUpnpXmlNode *argNode;
	char *argName;
	mUpnpArgument *arg;
	
	mupnp_log_debug_l4("Entering...\n");

	resNode = mupnp_control_action_response_getactionresponsenode(actionRes);
	if (resNode == NULL)
		return false;
		
	for (argNode = mupnp_xml_node_getchildnodes(resNode); argNode != NULL; argNode = mupnp_xml_node_next(argNode)) {
		argName = mupnp_xml_node_getname(argNode);
		arg = mupnp_action_getargumentbyname(action, argName);
		if (arg == NULL)
			continue;
		mupnp_argument_setvalue(arg, mupnp_xml_node_getvalue(argNode));
	}

	return true;

	mupnp_log_debug_l4("Leaving...\n");
}
Esempio n. 3
0
void mupnp_control_action_request_setsoaprequest(mUpnpActionRequest *actionReq, mUpnpSoapRequest *soapReq)
{
	mUpnpXmlNode *actionNode;
	mUpnpXmlNode *argNode;
	mUpnpArgument *arg;
	
	mupnp_log_debug_l4("Entering...\n");

	if (actionReq->isSoapReqCreated == true)
		mupnp_soap_request_delete(actionReq->soapReq);
	actionReq->soapReq = soapReq;
	actionReq->isSoapReqCreated = false;
	
	mupnp_argumentlist_clear(actionReq->argList);
	
	actionNode = mupnp_control_action_request_getactionnode(actionReq);
	if (actionNode == NULL)
		return;
	
	for (argNode = mupnp_xml_node_getchildnodes(actionNode); argNode != NULL; argNode = mupnp_xml_node_next(argNode)) {
		arg = mupnp_argument_new();
		mupnp_argument_setargumentnode(arg, argNode);
		mupnp_argument_setname(arg, mupnp_xml_node_getname( argNode ) );
		mupnp_argument_setvalue(arg, mupnp_xml_node_getvalue( argNode ) );
		mupnp_argumentlist_add(actionReq->argList, arg);
	}

	mupnp_soap_request_createcontent(soapReq);

	mupnp_log_debug_l4("Leaving...\n");
}
Esempio n. 4
0
bool mupnp_action_setargumentvaluebyname(mUpnpAction *action, const char *name, const char *value)
{
	mUpnpArgument *arg;

	arg = mupnp_action_getargumentbyname(action, name);
	if (!arg)
		return false;
	mupnp_argument_setvalue(arg, value);
	return true;
}
Esempio n. 5
0
// Used for xbox360 support, see README.360
bool mupnp_upnpav_dms_medrec_actionreceived(mUpnpAction *action)
{
    char *actionName;
    mUpnpArgument *arg;

    actionName = (char*)mupnp_action_getname(action);

    if (mupnp_strlen(actionName) <= 0)
        return false;


    if (mupnp_streq(actionName, CG_UPNPAV_DMS_MEDIARECEIVER_IS_AUTHORIZED )) {
        arg = mupnp_action_getargumentbyname(action,
                                               CG_UPNPAV_DMS_MEDIARECEIVER_RESULT);
        if (!arg)
            return false;
        mupnp_argument_setvalue(arg, "1");
        return true;
    }

    if (mupnp_streq(actionName, CG_UPNPAV_DMS_MEDIARECEIVER_IS_VALIDATED)) {
        arg = mupnp_action_getargumentbyname(action,
                                               CG_UPNPAV_DMS_MEDIARECEIVER_RESULT);
        if (!arg)
            return false;
        mupnp_argument_setvalue(arg, "1");
        return true;
    }

    if (mupnp_streq(actionName, CG_UPNPAV_DMS_MEDIARECEIVER_REGISTER_DEVICE)) {
        arg = mupnp_action_getargumentbyname(action,
                                               CG_UPNPAV_DMS_MEDIARECEIVER_REGISTRATION_RESP_MSG);
        if (!arg)
            return false;
        // Specifications say to return base64 message.
        mupnp_argument_setvalue(arg, "1");
        return true;
    }


    return true;
}
Esempio n. 6
0
void mupnp_action_clearoutputargumentvalues(mUpnpAction *action)
{
	mUpnpArgumentList *argList;
	mUpnpArgument *arg;
	
	mupnp_log_debug_l4("Entering...\n");

	argList = mupnp_action_getargumentlist(action);
	for (arg=mupnp_argumentlist_gets(argList); arg != NULL; arg = mupnp_argument_next(arg)) {
		if (mupnp_argument_isoutdirection(arg) == true)
			mupnp_argument_setvalue(arg, "");
	}

	mupnp_log_debug_l4("Leaving...\n");
}
Esempio n. 7
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;
}
Esempio n. 8
0
void ControlDeviceAlter(mUpnpControlPoint *ctrlPoint, int alteration_mask)
{
	mUpnpDevice *selDev;
	mUpnpService *selService;
	mUpnpAction *selAction;
	bool actionSuccess;
	mUpnpArgument *arg;
	char argValue[2048];
	
	printf("Control Device\n");
	
	selDev = SelectDevice(ctrlPoint);
	if (selDev == NULL)
		return;
	selService = SelectService(selDev);
	if (selService == NULL)
		return;
	selAction = SelectAction(selService);
	if (selAction == NULL)
		return;
	
	for (arg = mupnp_action_getarguments(selAction); arg; arg = mupnp_argument_next(arg)) {
		if (mupnp_argument_isindirection(arg) == true) {
			printf("%s : ", mupnp_argument_getname(arg));
			if (scanf("%s", argValue) == 1)
				mupnp_argument_setvalue(arg, argValue);
		}
	}

	/* NOTE: Go through selAction memory management... */
	if (alteration_mask & CMD_LOOP_ACTION_CALLS)
	{
		int loop_count, i;

		printf("\nHow many times action should be sent?");
		
		if ( 1 == scanf("%d", &loop_count) )
		{
			printf("\n");
			for (i=0; i<loop_count; i++)
			{
				actionSuccess = mupnp_action_post(selAction);
				printf("Control Result(%d)\n", (int)actionSuccess);
			}

			mupnp_sleep(3000);

			for (	arg = mupnp_action_getarguments(selAction); 
				arg; 
				arg = mupnp_argument_next(arg)) 
			{
				if (mupnp_argument_isoutdirection(arg) == true)
					printf(" %s = %s\n", 
							mupnp_argument_getname(arg), 
							mupnp_argument_getvalue(arg));
			}

			mupnp_sleep(2000);
		}
	}

	if ((alteration_mask & CMD_NO_ALTERATIONS) == CMD_NO_ALTERATIONS)
	{	
		actionSuccess = mupnp_action_post(selAction);
		
		printf("Control Result(%d)\n", (int)actionSuccess);
		for (arg = mupnp_action_getarguments(selAction); arg; arg = mupnp_argument_next(arg)) {
			if (mupnp_argument_isoutdirection(arg) == true)
				printf(" %s = %s\n", mupnp_argument_getname(arg), mupnp_argument_getvalue(arg));
		}
	}
}