コード例 #1
0
ファイル: freerdp.c プロジェクト: BrianChangchien/FiWoRDC
/** Deallocator function for a rdp context.
 *  The function will deallocate the resources from the 'instance' parameter that were allocated from a call
 *  to freerdp_context_new().
 *  If the ContextFree callback is set in the 'instance' parameter, it will be called before deallocation occurs.
 *
 *  @param instance - Pointer to the rdp_freerdp structure that was initialized by a call to freerdp_context_new().
 *  				  On return, the fields associated to the context are invalid.
 */
void freerdp_context_free(freerdp* instance)
{
	if (!instance)
		return;

	if (!instance->context)
		return;

	IFCALL(instance->ContextFree, instance, instance->context);

	rdp_free(instance->context->rdp);
	instance->context->rdp = NULL;

	graphics_free(instance->context->graphics);
	instance->context->graphics = NULL;

	PubSub_Free(instance->context->pubSub);

	metrics_free(instance->context->metrics);

	CloseHandle(instance->context->channelErrorEvent);
	free(instance->context->errorDescription);

	CloseHandle(instance->context->abortEvent);
	instance->context->abortEvent = NULL;

	free(instance->context);
	instance->context = NULL;

}
コード例 #2
0
ファイル: freerdp.c プロジェクト: AhmadKabakibi/FreeRDP
/** Deallocator function for a rdp context.
 *  The function will deallocate the resources from the 'instance' parameter that were allocated from a call
 *  to freerdp_context_new().
 *  If the ContextFree callback is set in the 'instance' parameter, it will be called before deallocation occurs.
 *
 *  @param instance - Pointer to the rdp_freerdp structure that was initialized by a call to freerdp_context_new().
 *  				  On return, the fields associated to the context are invalid.
 */
void freerdp_context_free(freerdp* instance)
{
	if (!instance)
		return;

	if (!instance->context)
		return;

	IFCALL(instance->ContextFree, instance, instance->context);

	rdp_free(instance->context->rdp);
	instance->context->rdp = NULL;

	graphics_free(instance->context->graphics);
	instance->context->graphics = NULL;

	PubSub_Free(instance->context->pubSub);

	free(instance->context);
	instance->context = NULL;
}
コード例 #3
0
ファイル: TestPubSub.c プロジェクト: Russkowski/FreeRDP
int TestPubSub(int argc, char* argv[])
{
    wPubSub* node;

    node = PubSub_New(TRUE);
    if (!node)
        return -1;

    PubSub_AddEventTypes(node, Node_Events, NODE_EVENT_COUNT);

    PubSub_SubscribeMouseMotion(node, MouseMotionEventHandler);
    PubSub_SubscribeMouseButton(node, MouseButtonEventHandler);

    /* Call Event Handler */
    {
        MouseMotionEventArgs e;

        e.x = 64;
        e.y = 128;

        PubSub_OnMouseMotion(node, NULL, &e);
    }

    {
        MouseButtonEventArgs e;

        e.x = 23;
        e.y = 56;
        e.flags = 7;
        e.button = 1;

        PubSub_OnMouseButton(node, NULL, &e);
    }

    PubSub_Free(node);

    return 0;
}
コード例 #4
0
ファイル: freerdp.c プロジェクト: C4rt/FreeRDP
/** Allocator function for a rdp context.
 *  The function will allocate a rdpRdp structure using rdp_new(), then copy
 *  its contents to the appropriate fields in the rdp_freerdp structure given in parameters.
 *  It will also initialize the 'context' field in the rdp_freerdp structure as needed.
 *  If the caller has set the ContextNew callback in the 'instance' parameter, it will be called at the end of the function.
 *
 *  @param instance - Pointer to the rdp_freerdp structure that will be initialized with the new context.
 */
BOOL freerdp_context_new(freerdp* instance)
{
	rdpRdp* rdp;
	rdpContext* context;
	BOOL ret = TRUE;

	instance->context = (rdpContext*) calloc(1, instance->ContextSize);
	if (!instance->context)
		return FALSE;

	context = instance->context;
	context->instance = instance;

	context->ServerMode = FALSE;
	context->settings = instance->settings;

	context->pubSub = PubSub_New(TRUE);
	if(!context->pubSub)
		goto out_error_pubsub;
	PubSub_AddEventTypes(context->pubSub, FreeRDP_Events, sizeof(FreeRDP_Events) / sizeof(wEventType));

	context->metrics = metrics_new(context);
	if (!context->metrics)
		goto out_error_metrics_new;

	rdp = rdp_new(context);
	if (!rdp)
		goto out_error_rdp_new;

	instance->input = rdp->input;
	instance->update = rdp->update;
	instance->settings = rdp->settings;
	instance->autodetect = rdp->autodetect;

	context->graphics = graphics_new(context);
	if(!context->graphics)
		goto out_error_graphics_new;

	context->rdp = rdp;

	context->input = instance->input;
	context->update = instance->update;
	context->settings = instance->settings;
	context->autodetect = instance->autodetect;

	instance->update->context = instance->context;
	instance->update->pointer->context = instance->context;
	instance->update->primary->context = instance->context;
	instance->update->secondary->context = instance->context;
	instance->update->altsec->context = instance->context;

	instance->input->context = context;

	instance->autodetect->context = context;

	update_register_client_callbacks(rdp->update);

	IFCALLRET(instance->ContextNew, ret, instance, instance->context);

	if (ret)
		return TRUE;

out_error_graphics_new:
	rdp_free(rdp);
out_error_rdp_new:
	metrics_free(context->metrics);
out_error_metrics_new:
	PubSub_Free(context->pubSub);
out_error_pubsub:
	free(instance->context);
	return FALSE;
}
コード例 #5
0
ファイル: freerdp.c プロジェクト: BrianChangchien/FiWoRDC
/** Allocator function for a rdp context.
 *  The function will allocate a rdpRdp structure using rdp_new(), then copy
 *  its contents to the appropriate fields in the rdp_freerdp structure given in parameters.
 *  It will also initialize the 'context' field in the rdp_freerdp structure as needed.
 *  If the caller has set the ContextNew callback in the 'instance' parameter, it will be called at the end of the function.
 *
 *  @param instance - Pointer to the rdp_freerdp structure that will be initialized with the new context.
 */
BOOL freerdp_context_new(freerdp* instance)
{
	rdpRdp* rdp;
	rdpContext* context;
	BOOL ret = TRUE;

	instance->context = (rdpContext*) calloc(1, instance->ContextSize);
	if (!instance->context)
		return FALSE;

	context = instance->context;
	context->instance = instance;

	context->ServerMode = FALSE;
	context->settings = instance->settings;

	context->pubSub = PubSub_New(TRUE);
	if(!context->pubSub)
		goto out_error_pubsub;
	PubSub_AddEventTypes(context->pubSub, FreeRDP_Events, sizeof(FreeRDP_Events) / sizeof(wEventType));

	context->metrics = metrics_new(context);
	if (!context->metrics)
		goto out_error_metrics_new;

	rdp = rdp_new(context);
	if (!rdp)
		goto out_error_rdp_new;

	instance->input = rdp->input;
	instance->update = rdp->update;
	instance->settings = rdp->settings;
	instance->autodetect = rdp->autodetect;

	context->graphics = graphics_new(context);
	if(!context->graphics)
		goto out_error_graphics_new;

	context->rdp = rdp;

	context->input = instance->input;
	context->update = instance->update;
	context->settings = instance->settings;
	context->autodetect = instance->autodetect;

	instance->update->context = instance->context;
	instance->update->pointer->context = instance->context;
	instance->update->primary->context = instance->context;
	instance->update->secondary->context = instance->context;
	instance->update->altsec->context = instance->context;

	instance->input->context = context;

	instance->autodetect->context = context;

	if (!(context->errorDescription = calloc(1, 500)))
	{
		WLog_ERR(TAG, "calloc failed!");
		goto out_error_description;
	}

	if (!(context->channelErrorEvent = CreateEvent(NULL, TRUE, FALSE, NULL)))
	{
		WLog_ERR(TAG, "CreateEvent failed!");
		goto out_error_create_event;
	}

	update_register_client_callbacks(rdp->update);

	instance->context->abortEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
	if (!instance->context->abortEvent)
		goto out_error_abort_event;

	IFCALLRET(instance->ContextNew, ret, instance, instance->context);

	if (ret)
		return TRUE;

	CloseHandle(context->abortEvent);
out_error_abort_event:
	CloseHandle(context->channelErrorEvent);
out_error_create_event:
	free(context->errorDescription);
out_error_description:
	graphics_free(context->graphics);
out_error_graphics_new:
	rdp_free(rdp);
out_error_rdp_new:
	metrics_free(context->metrics);
out_error_metrics_new:
	PubSub_Free(context->pubSub);
out_error_pubsub:
	free(instance->context);
	return FALSE;
}