示例#1
0
void mupnp_devicelist_delete(mUpnpDeviceList* devList)
{
  mupnp_log_debug_l4("Entering...\n");

  mupnp_devicelist_clear(devList);
  free(devList);

  mupnp_log_debug_l4("Leaving...\n");
}
示例#2
0
/**
 * Stop the control point. Stops sending/receiveing/responding to any messages.
 *
 * @param ctrlPoint The control point to stop
 *
 * @return true if successful; otherwise false
 *
 */
bool mupnp_controlpoint_stop(mUpnpControlPoint *ctrlPoint)
{
	mUpnpDevice *dev = NULL;
	mUpnpSSDPServerList *ssdpServerList;
	mUpnpSSDPResponseServerList *ssdpResServerList;
	mUpnpHttpServerList *httpServerList;
	const char *udn = NULL;
	MUPNP_DEVICE_LISTENER listener = mupnp_controlpoint_getdevicelistener(ctrlPoint);
	
	mupnp_log_debug_l4("Entering...\n");

	/* Stop expiration handling */
	mupnp_thread_stop_with_cond(ctrlPoint->expThread, ctrlPoint->expCond);
	mupnp_log_debug_s("Expiration thread stopped.\n");
	
	/**** SSDP Server ****/
	ssdpServerList = mupnp_controlpoint_getssdpserverlist(ctrlPoint);
	mupnp_log_debug_s("Stopping ssdp servers.\n");
  mupnp_ssdp_serverlist_setlistener(ssdpServerList, NULL);
  mupnp_ssdp_serverlist_setuserdata(ssdpServerList, NULL);
	mupnp_ssdp_serverlist_stop(ssdpServerList);
	mupnp_log_debug_s("Done\n");
	mupnp_ssdp_serverlist_close(ssdpServerList);
	mupnp_ssdp_serverlist_clear(ssdpServerList);
	
	/**** SSDP Response Server ****/
	ssdpResServerList = mupnp_controlpoint_getssdpresponseserverlist(ctrlPoint);
	mupnp_log_debug_s("Stopping ssdp response servers.\n");
  mupnp_ssdpresponse_serverlist_setlistener(ssdpResServerList, NULL);
  mupnp_ssdpresponse_serverlist_setuserdata(ssdpResServerList, NULL);
	mupnp_ssdpresponse_serverlist_stop(ssdpResServerList);
	mupnp_log_debug_s("Done\n");
	mupnp_ssdpresponse_serverlist_close(ssdpResServerList);
	mupnp_ssdpresponse_serverlist_clear(ssdpResServerList);
	
	/**** HTTP Server ****/
	httpServerList = mupnp_controlpoint_gethttpserverlist(ctrlPoint);
	mupnp_log_debug_s("Stopping http servers.\n");
  mupnp_http_serverlist_setlistener(httpServerList, NULL);
	mupnp_http_serverlist_stop(httpServerList);
	mupnp_log_debug_s("Done\n");
	mupnp_http_serverlist_close(httpServerList);
	mupnp_http_serverlist_clear(httpServerList);

	mupnp_controlpoint_lock(ctrlPoint);

	mupnp_log_debug_s("Got controlpoint lock.\n");
	
	/* Unsubscribe from all services */

	for (dev = mupnp_controlpoint_getdevices(ctrlPoint); 
	     dev != NULL;
	     dev = mupnp_device_next(dev))
	{
		udn = mupnp_device_getudn(dev);
		
		/* Call device listener for each device */
		if (udn != NULL && listener != NULL)
		{
			mupnp_controlpoint_unlock(ctrlPoint);
			listener(ctrlPoint, udn, mUpnpDeviceStatusRemoved);
			mupnp_controlpoint_lock(ctrlPoint);
		}
	}
	/* Empty device cache */
	mupnp_devicelist_clear(ctrlPoint->deviceList);
	mupnp_log_debug_s("Device list cleared.\n");

	mupnp_controlpoint_unlock(ctrlPoint);
		
	mupnp_log_debug_l4("Leaving...\n");

	return true;
}