Esempio n. 1
0
/****************************************
* mupnp_control_action_response_geterror
****************************************/
bool mupnp_control_action_response_geterror(mUpnpActionResponse *actionRes, mUpnpAction *action)
{
	mUpnpXmlNode *resNode;
	mUpnpXmlNode *upnpErrorNode;
	mUpnpXmlNode *node;
	char *errDesc = NULL;
	char *errCode = NULL;
	
	mupnp_log_debug_l4("Entering...\n");

	resNode = mupnp_control_action_response_getactionresponsenode(actionRes);
	if (resNode == NULL)
	{
		return false;
	}
		
	/* Response node is FAULT node, there will be no output args,
	   but set action status and description */
	upnpErrorNode = mupnp_xml_node_getchildnodewithnamespace(resNode, MUPNP_SOAP_DETAIL, NULL, true);

	if (upnpErrorNode == NULL) return false;
		
	upnpErrorNode = mupnp_xml_node_getchildnodewithnamespace(upnpErrorNode, MUPNP_CONTROL_FAULT_STRING, 
							      NULL, true);

	if (upnpErrorNode == NULL) return false;
		
	node = mupnp_xml_node_getchildnodewithnamespace(upnpErrorNode, MUPNP_CONTROL_ERROR_DESCRIPTION, 
						     NULL, true);
	if (node)
		errDesc = mupnp_xml_node_getvalue(node);

	node = mupnp_xml_node_getchildnodewithnamespace(upnpErrorNode, MUPNP_CONTROL_ERROR_CODE, 
						     NULL, true);
	if (node)
		errCode = mupnp_xml_node_getvalue(node);

	if (errCode == NULL) return false;

	mupnp_action_setstatusdescription(action, errDesc);
	mupnp_action_setstatuscode(action, mupnp_str2int(errCode));
		
	return true;

	mupnp_log_debug_l4("Leaving...\n");
}
Esempio n. 2
0
int mupnp_upnpav_dms_condir_getsystemupdateid(mUpnpAvServer *dms)
{
	mUpnpDevice *dev;
	mUpnpStateVariable *var;

	dev = mupnp_upnpav_dms_getdevice(dms);
	if (!dev)
		return 0;

	var = mupnp_device_getstatevariablebyname(dev, CG_UPNPAV_DMS_CONTENTDIRECTORY_SYSTEM_UPDATE_ID);
	if (!var)
		return 0;

    /* Thanks for Jorgen Lundman(2011-05-09) */
    if (!mupnp_statevariable_getvalue(var))
        return 0;

	return mupnp_str2int(mupnp_statevariable_getvalue(var));
}
Esempio n. 3
0
static bool mupnp_upnpav_dms_condir_browsedirectchildren(mUpnpAvServer *dms, mUpnpAction *action)
{
	char *objectID;
	mUpnpAvContent *objectContent;
	mUpnpAvContent *content;
	mUpnpAvContent *copyContent;
	mUpnpAvContentList *sortedContentList;
	mUpnpAvContent **sortedContentArray;
	int startingIndex;
	int requestedCount;
	int numberReturned;
	int totalMachesCnt;
	char intBuf[MUPNP_STRING_INTEGER_BUFLEN];
	int n;
	mUpnpXmlNode *didlNode;
	mUpnpString *resultStr;

	objectID = mupnp_action_getargumentvaluebyname(action, CG_UPNPAV_DMS_CONTENTDIRECTORY_BROWSE_OBJECT_ID);
	if (mupnp_strlen(objectID) <= 0)
		return false;

	objectContent = mupnp_upnpav_dms_findcontentbyid(dms, objectID);
	if (!objectContent)
		return false;

	totalMachesCnt = 0;
	sortedContentList = mupnp_upnpav_contentlist_new();
	for (content=mupnp_upnpav_content_getchildcontents(objectContent); content; content=mupnp_upnpav_content_next(content)) {
		copyContent = mupnp_upnpav_content_new();
		mupnp_upnpav_content_copy(copyContent, content);
		mupnp_upnpav_contentlist_add(sortedContentList, copyContent);
		totalMachesCnt++;
	}

	/* Not Implemented
	// Sort Content Node Lists
	string sortCriteria = action->getSortCriteria();
	ContentNodeList sortedContentNodeBufList(false);
	ContentNodeList *sortedContentNodeList = sortContentNodeList(&contentNodeList, sortCriteria.c_str(), sortedContentNodeBufList);
	*/

	startingIndex = mupnp_str2int(mupnp_action_getargumentvaluebyname(action, CG_UPNPAV_DMS_CONTENTDIRECTORY_BROWSE_STARTING_INDEX));
	if (startingIndex <= 0)
		startingIndex = 0;

	requestedCount = mupnp_str2int(mupnp_action_getargumentvaluebyname(action, CG_UPNPAV_DMS_CONTENTDIRECTORY_BROWSE_REQUESTED_COUNT));
	if (requestedCount <= 0)
		requestedCount = mupnp_upnpav_contentlist_size(sortedContentList);

	numberReturned = 0;

	didlNode = mupnp_upnpav_didl_node_new();

	sortedContentArray = (mUpnpAvContent **)malloc(sizeof(mUpnpAvContent*) * totalMachesCnt);
	n = 0;
	for (content=mupnp_upnpav_contentlist_gets(sortedContentList); content; content=mupnp_upnpav_content_next(content)) {
		sortedContentArray[n] = content;
		n++;
	}

	for (n=startingIndex; (n<totalMachesCnt && numberReturned<requestedCount); n++) {
		content = sortedContentArray[n];
		mupnp_upnpav_content_remove(content);
		mupnp_upnpav_content_addchildcontent(didlNode, content);
		mupnp_upnpav_content_setparentid(content, objectID);
		numberReturned++;
	}

	resultStr = mupnp_string_new();
	mupnp_upnpav_didl_node_tostring(didlNode, resultStr);

	mupnp_action_setargumentvaluebyname(action, CG_UPNPAV_DMS_CONTENTDIRECTORY_BROWSE_RESULT, mupnp_string_getvalue(resultStr));
	mupnp_action_setargumentvaluebyname(action, CG_UPNPAV_DMS_CONTENTDIRECTORY_BROWSE_NUMBER_RETURNED, (char*)mupnp_int2str(numberReturned, intBuf, sizeof(intBuf)));
	mupnp_action_setargumentvaluebyname(action, CG_UPNPAV_DMS_CONTENTDIRECTORY_BROWSE_TOTAL_MACHES, (char*)mupnp_int2str(totalMachesCnt, intBuf, sizeof(intBuf)));
	mupnp_action_setargumentvaluebyname(action, CG_UPNPAV_DMS_CONTENTDIRECTORY_BROWSE_UPDATE_ID, (char*)mupnp_int2str(mupnp_upnpav_dms_condir_getsystemupdateid(dms), intBuf, sizeof(intBuf)));

	mupnp_string_delete(resultStr);
	free(sortedContentArray);
	mupnp_upnpav_didl_node_delete(didlNode);
	mupnp_upnpav_contentlist_delete(sortedContentList);

	return true;
}