コード例 #1
0
/********************************************************************************
 * WscUPnPCPDeleteNode
 *
 * Description: 
 *       Delete a device node from the Wsc device list.  Note that this function is 
 *       NOT thread safe, and should be called from another function that has already 
 *       locked the Wsc device list.
 *
 * Parameters:
 *   node -- The device node
 *
 * Return:
 *    WSC_SYS_SUCCESS - if success
 *    WSC_SYS_ERROR   - if failure
 ********************************************************************************/
int WscUPnPCPDeleteNode(
	IN struct upnpDeviceNode *node)
{
	int rc, var;

	if (NULL == node) 
	{
		DBGPRINTF(RT_DBG_ERROR, "ERROR: WscUPnPCPDeleteNode: Node is empty\n");
		return WSC_SYS_ERROR;
	}

	/* If we have a valid control SID, then unsubscribe */
	if (strcmp(node->device.services.SID, "") != 0) 
	{
		rc = UpnpUnSubscribe(WscCPHandle, node->device.services.SID);
		if (rc == 0) 
			DBGPRINTF(RT_DBG_INFO, "Unsubscribed from WscService EventURL with SID=%s\n", node->device.services.SID);
		else
			DBGPRINTF(RT_DBG_ERROR, "Error unsubscribing to WscService EventURL -- %d\n", rc);
	}
			
	for (var = 0; var < WSC_STATE_VAR_COUNT; var++) 
	{
		if (node->device.services.StateVarVal[var])
			free(node->device.services.StateVarVal[var]);
	}

	//Notify New Device Added
//	WscCPDevUpdate(NULL, NULL, node->device.UDN, DEVICE_REMOVED);
	free(node);
	node = NULL;

	return WSC_SYS_SUCCESS;
}
コード例 #2
0
ファイル: tv_ctrlpt.c プロジェクト: Tieske/pupnp
/********************************************************************************
 * TvCtrlPointDeleteNode
 *
 * Description: 
 *       Delete a device node from the global device list.  Note that this
 *       function is NOT thread safe, and should be called from another
 *       function that has already locked the global device list.
 *
 * Parameters:
 *   node -- The device node
 *
 ********************************************************************************/
int
TvCtrlPointDeleteNode( struct TvDeviceNode *node )
{
	int rc, service, var;

	if (NULL == node) {
		SampleUtil_Print
		    ("ERROR: TvCtrlPointDeleteNode: Node is empty\n");
		return TV_ERROR;
	}

	for (service = 0; service < TV_SERVICE_SERVCOUNT; service++) {
		/*
		   If we have a valid control SID, then unsubscribe 
		 */
		if (strcmp(node->device.TvService[service].SID, "") != 0) {
			rc = UpnpUnSubscribe(ctrlpt_handle,
					     node->device.TvService[service].
					     SID);
			if (UPNP_E_SUCCESS == rc) {
				SampleUtil_Print
				    ("Unsubscribed from Tv %s EventURL with SID=%s\n",
				     TvServiceName[service],
				     node->device.TvService[service].SID);
			} else {
				SampleUtil_Print
				    ("Error unsubscribing to Tv %s EventURL -- %d\n",
				     TvServiceName[service], rc);
			}
		}

		for (var = 0; var < TvVarCount[service]; var++) {
			if (node->device.TvService[service].VariableStrVal[var]) {
				free(node->device.
				     TvService[service].VariableStrVal[var]);
			}
		}
	}

	/*Notify New Device Added */
	SampleUtil_StateUpdate(NULL, NULL, node->device.UDN, DEVICE_REMOVED);
	free(node);
	node = NULL;

	return TV_SUCCESS;
}
コード例 #3
0
ファイル: upnp_igd.c プロジェクト: Accontech/mediastreamer2
/********************************************************************************
 * upnp_igd_delete_node
 *
 * Description:
 *       Delete a device node from the context device list.  Note that this
 *       function is NOT thread safe, and should be called from another
 *       function that has already locked the global device list.
 *
 * Parameters:
 *   igd_ctxt -- The upnp igd context
 *   node     -- The device node
 *
 ********************************************************************************/
int upnp_igd_delete_node(upnp_igd_context *igd_ctxt, upnp_igd_device_node *node) {
	int rc, service, var;

	if (NULL == node) {
		upnp_igd_print(igd_ctxt, UPNP_IGD_ERROR, "upnp_igd_delete_node: Node is empty");
		return 0;
	}

	upnp_igd_print(igd_ctxt, UPNP_IGD_MESSAGE, "Remove IGD device: %s[%s]", node->device.friendly_name, node->device.udn);

	for (service = 0; service < IGD_SERVICE_SERVCOUNT; service++) {
		/*
		   If we have a valid control SID, then unsubscribe
		 */
		if (strcmp(node->device.services[service].sid, "") != 0) {
			rc = UpnpUnSubscribe(igd_ctxt->upnp_handle, node->device.services[service].sid);
			if (UPNP_E_SUCCESS == rc) {
				upnp_igd_print(igd_ctxt, UPNP_IGD_DEBUG, "Unsubscribed from IGD %s EventURL with SID=%s", IGDServiceName[service], node->device.services[service].sid);
			} else {
				upnp_igd_print(igd_ctxt, UPNP_IGD_ERROR, "Error unsubscribing to IGD %s EventURL -- %d", IGDServiceName[service], rc);
			}
		}

		for (var = 0; var < IGDVarCount[service]; var++) {
			if (node->device.services[service].variables[var]) {
				free(node->device.services[service].variables[var]);
			}
		}
	}

	free(node);
	node = NULL;

	upnp_context_add_callback(igd_ctxt, UPNP_IGD_DEVICE_REMOVED, NULL);

	return 0;
}