Exemplo n.º 1
0
void dvcman_free(IWTSVirtualChannelManager* pChannelMgr)
{
	int i;
	IWTSPlugin* pPlugin;
	DVCMAN_LISTENER* listener;
	DVCMAN_CHANNEL* channel;
	DVCMAN* dvcman = (DVCMAN*) pChannelMgr;

	while ((channel = (DVCMAN_CHANNEL*) list_dequeue(dvcman->channels)) != NULL)
		dvcman_channel_free(channel);

	list_free(dvcman->channels);

	for (i = 0; i < dvcman->num_listeners; i++)
	{
		listener = (DVCMAN_LISTENER*) dvcman->listeners[i];
		xfree(listener->channel_name);
		xfree(listener);
	}

	for (i = 0; i < dvcman->num_plugins; i++)
	{
		pPlugin = dvcman->plugins[i];

		if (pPlugin->Terminated)
			pPlugin->Terminated(pPlugin);
	}

	xfree(dvcman);
}
Exemplo n.º 2
0
static int dvcman_close_channel_iface(IWTSVirtualChannel *pChannel)
{
	DVCMAN_CHANNEL *channel = (DVCMAN_CHANNEL *) pChannel;
	DVCMAN *dvcman = channel->dvcman;
	assert(channel);
	assert(dvcman);
	DEBUG_DVC("id=%d", channel->channel_id);
	ArrayList_Remove(dvcman->channels, channel);
	dvcman_channel_free(channel);
	return 1;
}
Exemplo n.º 3
0
static int dvcman_close_channel_iface(IWTSVirtualChannel* pChannel)
{
    DVCMAN_CHANNEL* channel = (DVCMAN_CHANNEL*)pChannel;
    DVCMAN* dvcman = channel->dvcman;

    DEBUG_DVC("id=%d", channel->channel_id);

    if (list_remove(dvcman->channels, channel) == NULL)
        DEBUG_WARN("channel not found");
    dvcman_channel_free(channel);

    return 1;
}
Exemplo n.º 4
0
int dvcman_create_channel(IWTSVirtualChannelManager* pChannelMgr, uint32 ChannelId, const char* ChannelName)
{
	int i;
	int bAccept;
	DVCMAN_LISTENER* listener;
	DVCMAN_CHANNEL* channel;
	IWTSVirtualChannelCallback* pCallback;
	DVCMAN* dvcman = (DVCMAN*) pChannelMgr;

	for (i = 0; i < dvcman->num_listeners; i++)
	{
		listener = (DVCMAN_LISTENER*)dvcman->listeners[i];

		if (strcmp(listener->channel_name, ChannelName) == 0)
		{
			channel = xnew(DVCMAN_CHANNEL);
			channel->iface.Write = dvcman_write_channel;
			channel->iface.Close = dvcman_close_channel_iface;
			channel->dvcman = dvcman;
			channel->channel_id = ChannelId;

			bAccept = 1;
			pCallback = NULL;

			if (listener->listener_callback->OnNewChannelConnection(listener->listener_callback,
				(IWTSVirtualChannel*) channel, NULL, &bAccept, &pCallback) == 0 && bAccept == 1)
			{
				DEBUG_DVC("listener %s created new channel %d",
					  listener->channel_name, channel->channel_id);
				channel->channel_callback = pCallback;
				list_add(dvcman->channels, channel);

				return 0;
			}
			else
			{
				DEBUG_WARN("channel rejected by plugin");
				dvcman_channel_free(channel);
				return 1;
			}
		}
	}

	return 1;
}
Exemplo n.º 5
0
void dvcman_free(IWTSVirtualChannelManager* pChannelMgr)
{
	int i;
	int count;
	IWTSPlugin* pPlugin;
	DVCMAN_LISTENER* listener;
	DVCMAN_CHANNEL* channel;
	DVCMAN* dvcman = (DVCMAN*) pChannelMgr;

	ArrayList_Lock(dvcman->channels);

	count = ArrayList_Count(dvcman->channels);

	for (i = 0; i < count; i++)
	{
		channel = (DVCMAN_CHANNEL*) ArrayList_GetItem(dvcman->channels, i);
		dvcman_channel_free(channel);
	}

	ArrayList_Unlock(dvcman->channels);

	ArrayList_Free(dvcman->channels);

	for (i = 0; i < dvcman->num_listeners; i++)
	{
		listener = (DVCMAN_LISTENER*) dvcman->listeners[i];
		free(listener->channel_name);
		free(listener);
	}

	for (i = 0; i < dvcman->num_plugins; i++)
	{
		pPlugin = dvcman->plugins[i];

		if (pPlugin->Terminated)
			pPlugin->Terminated(pPlugin);
	}

	StreamPool_Free(dvcman->pool);
	free(dvcman);
}