Пример #1
0
static void svc_plugin_process_data_in(rdpSvcPlugin* plugin)
{
	svc_data_in_item* item;

	while (1)
	{
		/* terminate signal */
		if (freerdp_thread_is_stopped(plugin->priv->thread))
			break;

		freerdp_thread_lock(plugin->priv->thread);
		item = list_dequeue(plugin->priv->data_in_list);
		freerdp_thread_unlock(plugin->priv->thread);

		if (item != NULL)
		{
			/* the ownership of the data is passed to the callback */
			if (item->data_in)
				IFCALL(plugin->receive_callback, plugin, item->data_in);
			if (item->event_in)
				IFCALL(plugin->event_callback, plugin, item->event_in);
			xfree(item);
		}
		else
			break;
	}
}
Пример #2
0
static void printer_irp_request(DEVICE* device, IRP* irp) {
	PRINTER_DEVICE* printer_dev = (PRINTER_DEVICE*) device;

	freerdp_thread_lock(printer_dev->thread);
	list_enqueue(printer_dev->irp_list, irp);
	freerdp_thread_unlock(printer_dev->thread);

	freerdp_thread_signal(printer_dev->thread);
}
Пример #3
0
static void serial_irp_request(DEVICE* device, IRP* irp)
{
    SERIAL_DEVICE* serial = (SERIAL_DEVICE*)device;

    freerdp_thread_lock(serial->thread);
    list_enqueue(serial->irp_list, irp);
    freerdp_thread_unlock(serial->thread);

    freerdp_thread_signal(serial->thread);
}
Пример #4
0
static void parallel_irp_request(DEVICE* device, IRP* irp)
{
    PARALLEL_DEVICE* parallel = (PARALLEL_DEVICE*) device;

    freerdp_thread_lock(parallel->thread);
    list_enqueue(parallel->irp_list, irp);
    freerdp_thread_unlock(parallel->thread);

    freerdp_thread_signal(parallel->thread);
}
Пример #5
0
static void svc_plugin_process_event(rdpSvcPlugin* plugin, RDP_EVENT* event_in)
{
	svc_data_in_item* item;

	item = xnew(svc_data_in_item);
	item->event_in = event_in;

	freerdp_thread_lock(plugin->priv->thread);
	list_enqueue(plugin->priv->data_in_list, item);
	freerdp_thread_unlock(plugin->priv->thread);

	freerdp_thread_signal(plugin->priv->thread);
}
Пример #6
0
static void
scard_irp_request(DEVICE* device, IRP* irp)
{
	COMPLETIONIDINFO* CompletionIdInfo;

	SCARD_DEVICE* scard = (SCARD_DEVICE*)device;

	/* Begin TS Client defect workaround. */
	CompletionIdInfo= xnew(COMPLETIONIDINFO);
	CompletionIdInfo->ID = irp->CompletionId;/* "duplicate" member is set 
	                                          * to false by "xnew()"
	                                          */
	freerdp_mutex_lock(scard->CompletionIdsMutex);
	scard_mark_duplicate_id(scard, irp->CompletionId);
	list_enqueue(scard->CompletionIds, CompletionIdInfo);
	freerdp_mutex_unlock(scard->CompletionIdsMutex);

	irp->Complete = scard_irp_complete;	/* Overwrite the previous
						 * assignment made in 
						 * "irp_new()".
						 */
	/* End TS Client defect workaround. */

	if (irp->MajorFunction == IRP_MJ_DEVICE_CONTROL &&
			scard_async_op(irp))
	{
		/*
		 * certain potentially long running operations
		 * get their own thread
		 * TODO: revise this mechanism.. maybe worker pool
		 */
		struct scard_irp_thread_args *args = xmalloc(sizeof(struct scard_irp_thread_args));


		args->thread = freerdp_thread_new();
		args->scard = scard;
		args->irp = irp;
		freerdp_thread_start(args->thread, scard_process_irp_thread_func, args);

		return;
	}

	freerdp_thread_lock(scard->thread);
	list_enqueue(scard->irp_list, irp);
	freerdp_thread_unlock(scard->thread);

	freerdp_thread_signal(scard->thread);
}
Пример #7
0
static void svc_plugin_process_received(rdpSvcPlugin* plugin, void* pData, uint32 dataLength,
	uint32 totalLength, uint32 dataFlags)
{
	STREAM* data_in;
	svc_data_in_item* item;
	
	if ( (dataFlags & CHANNEL_FLAG_SUSPEND) || (dataFlags & CHANNEL_FLAG_RESUME))
	{
		/* According to MS-RDPBCGR 2.2.6.1, "All virtual channel traffic MUST be suspended.
		This flag is only valid in server-to-client virtual channel traffic. It MUST be
		ignored in client-to-server data." Thus it would be best practice to cease data
		transmission. However, simply returing here avoids a crash. */
		return;
	}

	if (dataFlags & CHANNEL_FLAG_FIRST)
	{
		if (plugin->priv->data_in != NULL)
			stream_free(plugin->priv->data_in);
		plugin->priv->data_in = stream_new(totalLength);
	}

	data_in = plugin->priv->data_in;
	stream_check_size(data_in, (int) dataLength);
	stream_write(data_in, pData, dataLength);

	if (dataFlags & CHANNEL_FLAG_LAST)
	{
		if (stream_get_size(data_in) != stream_get_length(data_in))
		{
			printf("svc_plugin_process_received: read error\n");
		}

		plugin->priv->data_in = NULL;
		stream_set_pos(data_in, 0);

		item = xnew(svc_data_in_item);
		item->data_in = data_in;

		freerdp_thread_lock(plugin->priv->thread);
		list_enqueue(plugin->priv->data_in_list, item);
		freerdp_thread_unlock(plugin->priv->thread);

		freerdp_thread_signal(plugin->priv->thread);
	}
}
Пример #8
0
static void printer_process_irp_list(PRINTER_DEVICE* printer_dev) {
	IRP* irp;

	while (1) {
		if (freerdp_thread_is_stopped(printer_dev->thread))
			break;

		freerdp_thread_lock(printer_dev->thread);
		irp = (IRP*) list_dequeue(printer_dev->irp_list);
		freerdp_thread_unlock(printer_dev->thread);

		if (irp == NULL)
			break;

		printer_process_irp(printer_dev, irp);
	}
}
Пример #9
0
static void
scard_process_irp_list(SCARD_DEVICE* scard)
{
	IRP *irp;

	while (!freerdp_thread_is_stopped(scard->thread))
	{
		freerdp_thread_lock(scard->thread);
		irp = (IRP *) list_dequeue(scard->irp_list);
		freerdp_thread_unlock(scard->thread);

		if (irp == NULL)
			break;

		scard_process_irp(scard, irp);
	}
}
Пример #10
0
static void serial_process_irp_list(SERIAL_DEVICE* serial)
{
    IRP* irp;

    while (1)
    {
        if (freerdp_thread_is_stopped(serial->thread))
            break;

        freerdp_thread_lock(serial->thread);
        irp = (IRP*)list_dequeue(serial->irp_list);
        freerdp_thread_unlock(serial->thread);

        if (irp == NULL)
            break;

        serial_process_irp(serial, irp);
    }
}
Пример #11
0
static void parallel_process_irp_list(PARALLEL_DEVICE* parallel)
{
    IRP* irp;

    while (1)
    {
        if (freerdp_thread_is_stopped(parallel->thread))
            break;

        freerdp_thread_lock(parallel->thread);
        irp = (IRP*) list_dequeue(parallel->irp_list);
        freerdp_thread_unlock(parallel->thread);

        if (irp == NULL)
            break;

        parallel_process_irp(parallel, irp);
    }
}
Пример #12
0
static void svc_plugin_process_received(rdpSvcPlugin* plugin, void* pData, uint32 dataLength,
	uint32 totalLength, uint32 dataFlags)
{
	STREAM* data_in;
	svc_data_in_item* item;

	if (dataFlags & CHANNEL_FLAG_FIRST)
	{
		if (plugin->priv->data_in != NULL)
			stream_free(plugin->priv->data_in);
		plugin->priv->data_in = stream_new(totalLength);
	}

	data_in = plugin->priv->data_in;
	stream_check_size(data_in, (int) dataLength);
	stream_write(data_in, pData, dataLength);

	if (dataFlags & CHANNEL_FLAG_LAST)
	{
		if (stream_get_size(data_in) != stream_get_length(data_in))
		{
			printf("svc_plugin_process_received: read error\n");
		}

		plugin->priv->data_in = NULL;
		stream_set_pos(data_in, 0);

		item = xnew(svc_data_in_item);
		item->data_in = data_in;

		freerdp_thread_lock(plugin->priv->thread);
		list_enqueue(plugin->priv->data_in_list, item);
		freerdp_thread_unlock(plugin->priv->thread);

		freerdp_thread_signal(plugin->priv->thread);
	}
}