static BOOL wl_post_connect(freerdp* instance) { rdpGdi* gdi; UwacWindow* window; wlfContext* context; if (!gdi_init(instance, CLRCONV_ALPHA | CLRBUF_32BPP, NULL)) return FALSE; gdi = instance->context->gdi; if (!gdi) return FALSE; context = (wlfContext*) instance->context; context->window = window = UwacCreateWindowShm(context->display, gdi->width, gdi->height, WL_SHM_FORMAT_XRGB8888); if (!window) return FALSE; UwacWindowSetTitle(window, "FreeRDP"); instance->update->BeginPaint = wl_begin_paint; instance->update->EndPaint = wl_end_paint; if (freerdp_channels_post_connect(instance->context->channels, instance) < 0) return FALSE; memcpy(UwacWindowGetDrawingBuffer(context->window), gdi->primary_buffer, gdi->width * gdi->height * 4); UwacWindowAddDamage(context->window, 0, 0, gdi->width, gdi->height); context->haveDamage = TRUE; return wl_update_content(context); }
void test_channels(void) { rdpChannels* chan_man; rdpSettings settings = { 0 }; freerdp instance = { 0 }; RDP_EVENT* event; settings.hostname = "testhost"; instance.settings = &settings; instance.SendChannelData = test_rdp_channel_data; chan_man = freerdp_channels_new(); freerdp_channels_load_plugin(chan_man, &settings, "../channels/rdpdbg/rdpdbg.so", NULL); freerdp_channels_pre_connect(chan_man, &instance); freerdp_channels_post_connect(chan_man, &instance); freerdp_channels_data(&instance, 0, "testdata", 8, CHANNEL_FLAG_FIRST | CHANNEL_FLAG_LAST, 8); freerdp_channels_data(&instance, 0, "testdata1", 9, CHANNEL_FLAG_FIRST | CHANNEL_FLAG_LAST, 9); freerdp_channels_data(&instance, 0, "testdata11", 10, CHANNEL_FLAG_FIRST | CHANNEL_FLAG_LAST, 10); freerdp_channels_data(&instance, 0, "testdata111", 11, CHANNEL_FLAG_FIRST | CHANNEL_FLAG_LAST, 11); event = freerdp_event_new(RDP_EVENT_CLASS_DEBUG, 0, NULL, NULL); freerdp_channels_send_event(chan_man, event); while ((event = freerdp_channels_pop_event(chan_man)) == NULL) { freerdp_channels_check_fds(chan_man, &instance); } printf("responded event_type %d\n", event->event_type); freerdp_event_free(event); freerdp_channels_close(chan_man, &instance); freerdp_channels_free(chan_man); }
BOOL rdp_freerdp_post_connect(freerdp* instance) { rdpContext* context = instance->context; guac_client* client = ((rdp_freerdp_context*) context)->client; rdpChannels* channels = instance->context->channels; /* Init channels (post-connect) */ if (freerdp_channels_post_connect(channels, instance)) { guac_client_abort(client, GUAC_PROTOCOL_STATUS_SERVER_ERROR, "Error initializing RDP client channel manager"); return FALSE; } /* Client handlers */ client->free_handler = rdp_guac_client_free_handler; client->handle_messages = rdp_guac_client_handle_messages; client->mouse_handler = rdp_guac_client_mouse_handler; client->key_handler = rdp_guac_client_key_handler; client->size_handler = rdp_guac_client_size_handler; /* Stream handlers */ client->clipboard_handler = guac_rdp_clipboard_handler; client->pipe_handler = guac_rdp_svc_pipe_handler; return TRUE; }
BOOL android_post_connect(freerdp* instance) { DEBUG_ANDROID("android_post_connect"); freerdp_callback("OnSettingsChanged", "(IIII)V", instance, instance->settings->DesktopWidth, instance->settings->DesktopHeight, instance->settings->ColorDepth); instance->context->cache = cache_new(instance->settings); gdi_init(instance, CLRCONV_ALPHA | ((instance->settings->ColorDepth > 16) ? CLRBUF_32BPP : CLRBUF_16BPP), NULL); instance->update->BeginPaint = android_begin_paint; instance->update->EndPaint = android_end_paint; instance->update->DesktopResize = android_desktop_resize; android_cliprdr_init(instance); freerdp_channels_post_connect(instance->context->channels, instance); // send notifications freerdp_callback("OnConnectionSuccess", "(I)V", instance); return TRUE; }
static BOOL android_post_connect(freerdp* instance) { UINT32 gdi_flags; rdpSettings *settings = instance->settings; DEBUG_ANDROID("android_post_connect"); assert(instance); assert(settings); freerdp_callback("OnSettingsChanged", "(IIII)V", instance, settings->DesktopWidth, settings->DesktopHeight, settings->ColorDepth); instance->context->cache = cache_new(settings); if (instance->settings->ColorDepth > 16) gdi_flags = CLRBUF_32BPP | CLRCONV_ALPHA | CLRCONV_INVERT; else gdi_flags = CLRBUF_16BPP; gdi_init(instance, gdi_flags, NULL); instance->update->BeginPaint = android_begin_paint; instance->update->EndPaint = android_end_paint; instance->update->DesktopResize = android_desktop_resize; freerdp_channels_post_connect(instance->context->channels, instance); freerdp_callback("OnConnectionSuccess", "(I)V", instance); return TRUE; }
void test_drdynvc(void) { rdpChannels* chan_man; rdpSettings settings = { 0 }; freerdp instance = { 0 }; settings.Hostname = "testhost"; instance.settings = &settings; instance.SendChannelData = test_rdp_channel_data; chan_man = freerdp_channels_new(); freerdp_channels_load_plugin(chan_man, &settings, "../channels/drdynvc/drdynvc.so", NULL); freerdp_channels_pre_connect(chan_man, &instance); freerdp_channels_post_connect(chan_man, &instance); /* server sends capability request PDU */ freerdp_channels_data(&instance, 0, (char*)test_capability_request_data, sizeof(test_capability_request_data) - 1, CHANNEL_FLAG_FIRST | CHANNEL_FLAG_LAST, sizeof(test_capability_request_data) - 1); /* drdynvc sends capability response PDU to server */ data_received = 0; while (!data_received) { freerdp_channels_check_fds(chan_man, &instance); } freerdp_channels_close(chan_man, &instance); freerdp_channels_free(chan_man); }
BOOL df_post_connect(freerdp* instance) { rdpGdi* gdi; dfInfo* dfi; dfContext* context; context = ((dfContext*) instance->context); dfi = context->dfi; gdi_init(instance, CLRCONV_ALPHA | CLRCONV_INVERT | CLRBUF_16BPP | CLRBUF_32BPP, NULL); gdi = instance->context->gdi; dfi->err = DirectFBCreate(&(dfi->dfb)); dfi->dsc.flags = DSDESC_CAPS; dfi->dsc.caps = DSCAPS_PRIMARY; dfi->err = dfi->dfb->CreateSurface(dfi->dfb, &(dfi->dsc), &(dfi->primary)); dfi->err = dfi->primary->GetSize(dfi->primary, &(gdi->width), &(gdi->height)); dfi->dfb->SetVideoMode(dfi->dfb, gdi->width, gdi->height, gdi->dstBpp); dfi->dfb->CreateInputEventBuffer(dfi->dfb, DICAPS_ALL, DFB_TRUE, &(dfi->event_buffer)); dfi->event_buffer->CreateFileDescriptor(dfi->event_buffer, &(dfi->read_fds)); dfi->dfb->GetDisplayLayer(dfi->dfb, 0, &(dfi->layer)); dfi->layer->EnableCursor(dfi->layer, 1); dfi->dsc.flags = DSDESC_CAPS | DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_PREALLOCATED | DSDESC_PIXELFORMAT; dfi->dsc.caps = DSCAPS_SYSTEMONLY; dfi->dsc.width = gdi->width; dfi->dsc.height = gdi->height; if (gdi->dstBpp == 32 || gdi->dstBpp == 24) dfi->dsc.pixelformat = DSPF_AiRGB; else if (gdi->dstBpp == 16 || gdi->dstBpp == 15) dfi->dsc.pixelformat = DSPF_RGB16; else if (gdi->dstBpp == 8) dfi->dsc.pixelformat = DSPF_RGB332; else dfi->dsc.pixelformat = DSPF_AiRGB; dfi->dsc.preallocated[0].data = gdi->primary_buffer; dfi->dsc.preallocated[0].pitch = gdi->width * gdi->bytesPerPixel; dfi->dfb->CreateSurface(dfi->dfb, &(dfi->dsc), &(dfi->surface)); instance->update->BeginPaint = df_begin_paint; instance->update->EndPaint = df_end_paint; df_keyboard_init(); pointer_cache_register_callbacks(instance->update); df_register_graphics(instance->context->graphics); freerdp_channels_post_connect(instance->context->channels, instance); return TRUE; }
boolean tf_post_connect(freerdp* instance) { rdpGdi* gdi; gdi_init(instance, CLRCONV_ALPHA | CLRCONV_INVERT | CLRBUF_16BPP | CLRBUF_32BPP, NULL); gdi = instance->context->gdi; instance->update->BeginPaint = tf_begin_paint; instance->update->EndPaint = tf_end_paint; freerdp_channels_post_connect(instance->context->channels, instance); return true; }
/** * Callback invoked by FreeRDP just after the connection is established with * the RDP server. Implementations are required to manually invoke * freerdp_channels_post_connect(). * * @param instance * The FreeRDP instance that has just connected. * * @return * TRUE if successful, FALSE if an error occurs. */ static BOOL rdp_freerdp_post_connect(freerdp* instance) { rdpContext* context = instance->context; guac_client* client = ((rdp_freerdp_context*) context)->client; rdpChannels* channels = instance->context->channels; /* Init channels (post-connect) */ if (freerdp_channels_post_connect(channels, instance)) { guac_client_abort(client, GUAC_PROTOCOL_STATUS_SERVER_ERROR, "Error initializing RDP client channel manager"); return FALSE; } return TRUE; }
BOOL rdp_client_reconnect(rdpRdp* rdp) { BOOL status; rdpContext* context = rdp->context; rdpChannels* channels = context->channels; freerdp_channels_disconnect(channels, context->instance); rdp_client_disconnect(rdp); status = rdp_client_connect(rdp); if (status) status = (freerdp_channels_post_connect(channels, context->instance) >= 0); return status; }
BOOL wl_post_connect(freerdp* instance) { struct window* window; struct wl_context* context; context = (struct wl_context*) instance->context; window = malloc(sizeof(*window)); window->width = instance->settings->DesktopWidth; window->height = instance->settings->DesktopHeight; window->buffers[0].busy = 0; window->buffers[1].busy = 0; window->callback = NULL; window->display = context->display; window->surface = wl_compositor_create_surface(window->display->compositor); window->shell_surface = wl_shell_get_shell_surface(window->display->shell, window->surface); wl_shell_surface_add_listener(window->shell_surface, &wl_shell_surface_listener, NULL); wl_shell_surface_set_title(window->shell_surface, "FreeRDP"); wl_shell_surface_set_toplevel(window->shell_surface); wl_surface_damage(window->surface, 0, 0, window->width, window->height); /* GC/GDI logic here */ rdpGdi* gdi; gdi_init(instance, CLRCONV_ALPHA | CLRCONV_INVERT | CLRBUF_32BPP, NULL); gdi = instance->context->gdi; /* fill buffer with first image here */ window->data = malloc (gdi->width * gdi->height *4); memcpy(window->data, (void*) gdi->primary_buffer, gdi->width * gdi->height * 4); instance->update->BeginPaint = wl_begin_paint; instance->update->EndPaint = wl_end_paint; /* put Wayland data in the context here */ context->window = window; freerdp_channels_post_connect(instance->context->channels, instance); window_redraw(window, NULL, 0); return TRUE; }
BOOL shw_post_connect(freerdp* instance) { rdpGdi* gdi; shwContext* shw; rdpSettings* settings; shw = (shwContext*) instance->context; settings = instance->settings; if (!gdi_init(instance, CLRBUF_32BPP, NULL)) return FALSE; gdi = instance->context->gdi; instance->update->BeginPaint = shw_begin_paint; instance->update->EndPaint = shw_end_paint; instance->update->DesktopResize = shw_desktop_resize; instance->update->SurfaceFrameMarker = shw_surface_frame_marker; return (freerdp_channels_post_connect(instance->context->channels, instance) == CHANNEL_RC_OK) ; }
boolean rdp_freerdp_post_connect(freerdp* instance) { rdpContext* context = instance->context; guac_client* client = ((rdp_freerdp_context*) context)->client; rdpChannels* channels = instance->context->channels; /* Init channels (post-connect) */ if (freerdp_channels_post_connect(channels, instance)) { guac_protocol_send_error(client->socket, "Error initializing RDP client channel manager"); guac_socket_flush(client->socket); return false; } /* Client handlers */ client->free_handler = rdp_guac_client_free_handler; client->handle_messages = rdp_guac_client_handle_messages; client->mouse_handler = rdp_guac_client_mouse_handler; client->key_handler = rdp_guac_client_key_handler; client->clipboard_handler = rdp_guac_client_clipboard_handler; return true; }
static BOOL wl_post_connect(freerdp* instance) { rdpGdi* gdi; wlfWindow* window; wlfContext* context; if (!gdi_init(instance, CLRCONV_ALPHA | CLRBUF_32BPP, NULL)) return FALSE; gdi = instance->context->gdi; if (!gdi) return FALSE; context = (wlfContext*) instance->context; window = wlf_CreateDesktopWindow(context, "FreeRDP", gdi->width, gdi->height, FALSE); if (!window) return FALSE; /* fill buffer with first image here */ window->data = malloc (gdi->width * gdi->height *4); if (!window->data) return FALSE; memcpy(window->data, (void*) gdi->primary_buffer, gdi->width * gdi->height * 4); instance->update->BeginPaint = wl_begin_paint; instance->update->EndPaint = wl_end_paint; /* put Wayland data in the context here */ context->window = window; if (freerdp_channels_post_connect(instance->context->channels, instance) < 0) return FALSE; wlf_UpdateWindowArea(context, window, 0, 0, gdi->width, gdi->height); return TRUE; }
//----------------------------------------------------------------------------- void test_rail_plugin(void) { thread_param param; pthread_t thread; rdpChannels* chan_man; rdpSettings settings = { 0 }; freerdp s_inst = { 0 }; freerdp* inst = &s_inst; size_t sn = 0; size_t en = 0; STREAM* ss = NULL; RAIL_EVENT* ee = NULL; printf("\n"); settings.hostname = "testhost"; inst->settings = &settings; inst->SendChannelData = emulate_client_send_channel_data; chan_man = freerdp_channels_new(); freerdp_channels_load_plugin(chan_man, &settings, "../channels/rail/rail.so", NULL); freerdp_channels_pre_connect(chan_man, inst); freerdp_channels_post_connect(chan_man, inst); memset(¶m, 0, sizeof(param)); param.chan_man = chan_man; param.instance = inst; param.th_count = 0; param.th_to_finish = 0; global_thread_params = ¶m; pthread_create(&thread, 0, thread_func, ¶m); // 1. Emulate server handshake binary EMULATE_SERVER_SEND_CHANNEL_DATA(inst, server_handshake); EMULATE_SERVER_SEND_CHANNEL_DATA(inst, server_exec_result_pdu); EMULATE_SERVER_SEND_CHANNEL_DATA(inst, server_sysparam1_pdu); EMULATE_SERVER_SEND_CHANNEL_DATA(inst, server_sysparam2_pdu); EMULATE_SERVER_SEND_CHANNEL_DATA(inst, server_localmovesize_start_pdu); EMULATE_SERVER_SEND_CHANNEL_DATA(inst, server_localmovesize_stop_pdu); EMULATE_SERVER_SEND_CHANNEL_DATA(inst, server_minmaxinfo_pdu); EMULATE_SERVER_SEND_CHANNEL_DATA(inst, server_langbar_pdu); EMULATE_SERVER_SEND_CHANNEL_DATA(inst, server_app_get_resp_pdu); // 2. Send UI events param.out_rail_orders.sysparam.params = 0; param.out_rail_orders.sysparam.params |= SPI_MASK_SET_HIGH_CONTRAST; param.out_rail_orders.sysparam.highContrast.flags = 0x7e; param.out_rail_orders.sysparam.highContrast.colorScheme.length = 0; param.out_rail_orders.sysparam.highContrast.colorScheme.string = NULL; param.out_rail_orders.sysparam.params |= SPI_MASK_TASKBAR_POS; param.out_rail_orders.sysparam.taskbarPos.left = 0; param.out_rail_orders.sysparam.taskbarPos.top = 0x039a; param.out_rail_orders.sysparam.taskbarPos.right = 0x0690; param.out_rail_orders.sysparam.taskbarPos.bottom = 0x03c2; param.out_rail_orders.sysparam.params |= SPI_MASK_SET_MOUSE_BUTTON_SWAP; param.out_rail_orders.sysparam.mouseButtonSwap = False; param.out_rail_orders.sysparam.params |= SPI_MASK_SET_KEYBOARD_PREF; param.out_rail_orders.sysparam.keyboardPref = False; param.out_rail_orders.sysparam.params |= SPI_MASK_SET_DRAG_FULL_WINDOWS; param.out_rail_orders.sysparam.dragFullWindows = True; param.out_rail_orders.sysparam.params |= SPI_MASK_SET_KEYBOARD_CUES; param.out_rail_orders.sysparam.keyboardCues = False; param.out_rail_orders.sysparam.params |= SPI_MASK_SET_WORK_AREA; param.out_rail_orders.sysparam.workArea.left = 0; param.out_rail_orders.sysparam.workArea.top = 0; param.out_rail_orders.sysparam.workArea.right = 0x0690; param.out_rail_orders.sysparam.workArea.bottom = 0x039a; send_ui_event2plugin(chan_man, RDP_EVENT_TYPE_RAIL_CLIENT_SET_SYSPARAMS, ¶m.out_rail_orders.sysparam); param.plugin_data.size = sizeof(RDP_PLUGIN_DATA); param.plugin_data.data[0] = "||iexplore"; param.plugin_data.data[1] = "f:\\windows\\system32"; param.plugin_data.data[2] = "www.bing.com"; send_ui_event2plugin(chan_man, RDP_EVENT_TYPE_RAIL_CLIENT_EXEC_REMOTE_APP, ¶m.plugin_data); param.out_rail_orders.activate.enabled = True; param.out_rail_orders.activate.windowId = 0x0007008e; send_ui_event2plugin(chan_man, RDP_EVENT_TYPE_RAIL_CLIENT_ACTIVATE, ¶m.out_rail_orders.activate); param.out_rail_orders.syscommand.windowId = 0x00020052; param.out_rail_orders.syscommand.command = 0xf020; send_ui_event2plugin(chan_man, RDP_EVENT_TYPE_RAIL_CLIENT_SYSCOMMAND, ¶m.out_rail_orders.syscommand); param.out_rail_orders.notify_event.windowId = 0x000201aa; param.out_rail_orders.notify_event.notifyIconId = 0x02; param.out_rail_orders.notify_event.message = 0x0204; send_ui_event2plugin(chan_man, RDP_EVENT_TYPE_RAIL_CLIENT_NOTIFY_EVENT, ¶m.out_rail_orders.notify_event); param.out_rail_orders.window_move.windowId = 0x00020020; param.out_rail_orders.window_move.left = 0x0309; param.out_rail_orders.window_move.top = 0x0100; param.out_rail_orders.window_move.right = 0x05db; param.out_rail_orders.window_move.bottom = 0x0188; send_ui_event2plugin(chan_man, RDP_EVENT_TYPE_RAIL_CLIENT_WINDOW_MOVE, ¶m.out_rail_orders.window_move); param.out_rail_orders.sysmenu.windowId = 0x00090122; param.out_rail_orders.sysmenu.left = 0xffa4; // TODO: possible negative values? param.out_rail_orders.sysmenu.top = 0x024a; send_ui_event2plugin(chan_man, RDP_EVENT_TYPE_RAIL_CLIENT_SYSMENU, ¶m.out_rail_orders.sysmenu); param.out_rail_orders.langbar_info.languageBarStatus = 0x00000001; send_ui_event2plugin(chan_man, RDP_EVENT_TYPE_RAIL_CLIENT_LANGBARINFO, ¶m.out_rail_orders.langbar_info); param.out_rail_orders.get_appid_req.windowId = 0x00020052; send_ui_event2plugin(chan_man, RDP_EVENT_TYPE_RAIL_CLIENT_APPID_REQ, ¶m.out_rail_orders.get_appid_req); // Waiting for possible events or data sleep(1); // Finishing thread and wait for it param.th_to_finish = 1; while (param.th_count > 0) { usleep(1000); } // We need to collected all events and data dumps and then to. // create CU_ASSERT series here! sn = param.in_streams_number; en = param.in_events_number; ss = ¶m.in_streams[0]; ee = ¶m.in_events[0]; CU_ASSERT(sn > 0 && STREAM_EQUAL_TO_DUMP(&ss[ 0], client_handshake)); CU_ASSERT(sn > 1 && STREAM_EQUAL_TO_DUMP(&ss[ 1], client_info_pdu)); CU_ASSERT(sn > 2 && STREAM_EQUAL_TO_DUMP(&ss[ 2], client_sysparam_highcontrast_pdu)); CU_ASSERT(sn > 3 && STREAM_EQUAL_TO_DUMP(&ss[ 3], client_sysparam_taskbarpos_pdu)); CU_ASSERT(sn > 4 && STREAM_EQUAL_TO_DUMP(&ss[ 4], client_sysparam_mousebuttonswap_pdu)); CU_ASSERT(sn > 5 && STREAM_EQUAL_TO_DUMP(&ss[ 5], client_sysparam_keyboardpref_pdu)); CU_ASSERT(sn > 6 && STREAM_EQUAL_TO_DUMP(&ss[ 6], client_sysparam_dragfullwindow_pdu)); CU_ASSERT(sn > 7 && STREAM_EQUAL_TO_DUMP(&ss[ 7], client_sysparam_keyboardcues_pdu)); CU_ASSERT(sn > 8 && STREAM_EQUAL_TO_DUMP(&ss[ 8], client_sysparam_setworkarea_pdu)); CU_ASSERT(sn > 9 && STREAM_EQUAL_TO_DUMP(&ss[ 9], client_execute_pdu)); CU_ASSERT(sn >10 && STREAM_EQUAL_TO_DUMP(&ss[10], client_activate_pdu)); CU_ASSERT(sn >11 && STREAM_EQUAL_TO_DUMP(&ss[11], client_syscommand_pdu)); CU_ASSERT(sn >12 && STREAM_EQUAL_TO_DUMP(&ss[12], client_notify_pdu)); CU_ASSERT(sn >13 && STREAM_EQUAL_TO_DUMP(&ss[13], client_windowmove_pdu)); CU_ASSERT(sn >14 && STREAM_EQUAL_TO_DUMP(&ss[14], client_system_menu_pdu)); CU_ASSERT(sn >15 && STREAM_EQUAL_TO_DUMP(&ss[15], client_langbar_pdu)); CU_ASSERT(sn >16 && STREAM_EQUAL_TO_DUMP(&ss[16], client_get_app_id_req_pdu)); CU_ASSERT(en > 0 && ee[ 0].event_type == RDP_EVENT_TYPE_RAIL_CHANNEL_GET_SYSPARAMS); CU_ASSERT(en > 1 && ee[ 1].event_type == RDP_EVENT_TYPE_RAIL_CHANNEL_EXEC_RESULTS && ee[ 1].order_info.exec_result.flags == 0x08 && ee[ 1].order_info.exec_result.execResult == 0x03 && UNICODE_STRING_EQUAL_TO_DUMP( &ee[ 1].order_info.exec_result.exeOrFile, server_exec_result_exe_or_file) ); CU_ASSERT(en > 2 && ee[ 2].event_type == RDP_EVENT_TYPE_RAIL_CHANNEL_SERVER_SYSPARAM && ee[ 2].order_info.sysparam.setScreenSaveSecure == False ); CU_ASSERT(en > 3 && ee[ 3].event_type == RDP_EVENT_TYPE_RAIL_CHANNEL_SERVER_SYSPARAM && ee[ 3].order_info.sysparam.setScreenSaveActive == False ); CU_ASSERT(en > 4 && ee[ 4].event_type == RDP_EVENT_TYPE_RAIL_CHANNEL_SERVER_LOCALMOVESIZE && ee[ 4].order_info.localmovesize.windowId == 0x0007008e && ee[ 4].order_info.localmovesize.isMoveSizeStart == True && ee[ 4].order_info.localmovesize.moveSizeType == RAIL_WMSZ_MOVE && ee[ 4].order_info.localmovesize.posX == 0x017e && ee[ 4].order_info.localmovesize.posY == 0x000a ); CU_ASSERT(en > 5 && ee[ 5].event_type == RDP_EVENT_TYPE_RAIL_CHANNEL_SERVER_LOCALMOVESIZE && ee[ 5].order_info.localmovesize.windowId == 0x0007008e && ee[ 5].order_info.localmovesize.isMoveSizeStart == False && ee[ 5].order_info.localmovesize.moveSizeType == RAIL_WMSZ_MOVE && ee[ 5].order_info.localmovesize.posX == 0x00a6 && ee[ 5].order_info.localmovesize.posY == 0x0044 ); CU_ASSERT(en > 6 && ee[ 6].event_type == RDP_EVENT_TYPE_RAIL_CHANNEL_SERVER_MINMAXINFO && ee[ 6].order_info.minmaxinfo.windowId == 0x0007008e && ee[ 6].order_info.minmaxinfo.maxWidth == 0x0408 && ee[ 6].order_info.minmaxinfo.maxHeight == 0x02d6 && ee[ 6].order_info.minmaxinfo.maxPosX == 0x0000 && ee[ 6].order_info.minmaxinfo.maxPosY == 0x0000 && ee[ 6].order_info.minmaxinfo.minTrackWidth == 0x0070 && ee[ 6].order_info.minmaxinfo.minTrackHeight == 0x001b && ee[ 6].order_info.minmaxinfo.maxTrackWidth == 0x040c && ee[ 6].order_info.minmaxinfo.maxTrackHeight == 0x030c ); CU_ASSERT(en > 7 && ee[ 7].event_type == RDP_EVENT_TYPE_RAIL_CHANNEL_LANGBARINFO && ee[ 7].order_info.langbar_info.languageBarStatus == TF_SFT_SHOWNORMAL ); CU_ASSERT(en > 8 && ee[ 8].event_type == RDP_EVENT_TYPE_RAIL_CHANNEL_APPID_RESP && ee[ 8].order_info.get_appid_resp.windowId == 0x00020052 && UNICODE_STRING_EQUAL_TO_DUMP( &ee[ 8].order_info.get_appid_resp.applicationId, server_app_get_resp_app_id ) ); freerdp_channels_close(chan_man, inst); freerdp_channels_free(chan_man); }
boolean wf_post_connect(freerdp* instance) { rdpGdi* gdi; wfInfo* wfi; rdpCache* cache; wfContext* context; int width, height; wchar_t win_title[64]; rdpSettings* settings; settings = instance->settings; context = (wfContext*) instance->context; cache = instance->context->cache; wfi = context->wfi; wfi->dstBpp = 32; width = settings->width; height = settings->height; if (wfi->sw_gdi) { gdi_init(instance, CLRCONV_ALPHA | CLRCONV_INVERT | CLRBUF_32BPP, NULL); gdi = instance->context->gdi; wfi->hdc = gdi->primary->hdc; wfi->primary = wf_image_new(wfi, width, height, wfi->dstBpp, gdi->primary_buffer); rfx_context_set_cpu_opt(gdi->rfx_context, wfi_detect_cpu()); } else { wf_gdi_register_update_callbacks(instance->update); wfi->srcBpp = instance->settings->color_depth; wfi->primary = wf_image_new(wfi, width, height, wfi->dstBpp, NULL); wfi->hdc = gdi_GetDC(); wfi->hdc->bitsPerPixel = wfi->dstBpp; wfi->hdc->bytesPerPixel = wfi->dstBpp / 8; wfi->hdc->alpha = wfi->clrconv->alpha; wfi->hdc->invert = wfi->clrconv->invert; wfi->hdc->hwnd = (HGDI_WND) xmalloc(sizeof(GDI_WND)); wfi->hdc->hwnd->invalid = gdi_CreateRectRgn(0, 0, 0, 0); wfi->hdc->hwnd->invalid->null = 1; wfi->hdc->hwnd->count = 32; wfi->hdc->hwnd->cinvalid = (HGDI_RGN) xmalloc(sizeof(GDI_RGN) * wfi->hdc->hwnd->count); wfi->hdc->hwnd->ninvalid = 0; wfi->image = wf_bitmap_new(wfi, 64, 64, 32, NULL); wfi->image->_bitmap.data = NULL; if (settings->rfx_codec) { wfi->tile = wf_bitmap_new(wfi, 64, 64, 32, NULL); wfi->rfx_context = rfx_context_new(); rfx_context_set_cpu_opt(wfi->rfx_context, wfi_detect_cpu()); } if (settings->ns_codec) wfi->nsc_context = nsc_context_new(); } if (settings->window_title != NULL) _snwprintf(win_title, sizeof(win_title), L"%S", settings->window_title); else if (settings->port == 3389) _snwprintf(win_title, ARRAY_SIZE(win_title), L"FreeRDP: %S", settings->hostname); else _snwprintf(win_title, ARRAY_SIZE(win_title), L"FreeRDP: %S:%d", settings->hostname, settings->port); if (wfi->hwnd == 0) { wfi->hwnd = CreateWindowEx((DWORD) NULL, g_wnd_class_name, win_title, 0, 0, 0, 0, 0, NULL, NULL, g_hInstance, NULL); SetWindowLongPtr(wfi->hwnd, GWLP_USERDATA, (LONG_PTR) wfi); } if (wfi->fullscreen) { SetWindowLongPtr(wfi->hwnd, GWL_STYLE, WS_POPUP); SetWindowPos(wfi->hwnd, HWND_TOP, 0, 0, width, height, SWP_FRAMECHANGED); } else { POINT diff; RECT rc_client, rc_wnd; SetWindowLongPtr(wfi->hwnd, GWL_STYLE, WS_CAPTION | WS_OVERLAPPED | WS_SYSMENU | WS_MINIMIZEBOX); /* Now resize to get full canvas size and room for caption and borders */ SetWindowPos(wfi->hwnd, HWND_TOP, 10, 10, width, height, SWP_FRAMECHANGED); GetClientRect(wfi->hwnd, &rc_client); GetWindowRect(wfi->hwnd, &rc_wnd); diff.x = (rc_wnd.right - rc_wnd.left) - rc_client.right; diff.y = (rc_wnd.bottom - rc_wnd.top) - rc_client.bottom; SetWindowPos(wfi->hwnd, HWND_TOP, -1, -1, width + diff.x, height + diff.y, SWP_NOMOVE | SWP_FRAMECHANGED); } BitBlt(wfi->primary->hdc, 0, 0, width, height, NULL, 0, 0, BLACKNESS); wfi->drawing = wfi->primary; ShowWindow(wfi->hwnd, SW_SHOWNORMAL); UpdateWindow(wfi->hwnd); if (wfi->sw_gdi) { instance->update->BeginPaint = wf_sw_begin_paint; instance->update->EndPaint = wf_sw_end_paint; } else { instance->update->BeginPaint = wf_hw_begin_paint; instance->update->EndPaint = wf_hw_end_paint; } pointer_cache_register_callbacks(instance->update); if (wfi->sw_gdi != true) { brush_cache_register_callbacks(instance->update); bitmap_cache_register_callbacks(instance->update); offscreen_cache_register_callbacks(instance->update); } wf_register_graphics(instance->context->graphics); freerdp_channels_post_connect(instance->context->channels, instance); return true; }
static BOOL remmina_rdp_post_connect(freerdp* instance) { rfContext* rfi; RemminaProtocolWidget* gp; RemminaPluginRdpUiObject* ui; rdpGdi* gdi; UINT32 flags; rfi = (rfContext*) instance->context; gp = rfi->protocol_widget; rfi->width = rfi->settings->DesktopWidth; rfi->height = rfi->settings->DesktopHeight; rfi->srcBpp = rfi->settings->ColorDepth; if (rfi->settings->RemoteFxCodec == FALSE) rfi->sw_gdi = TRUE; rf_register_graphics(instance->context->graphics); flags = CLRCONV_ALPHA; if (rfi->bpp == 32) { flags |= CLRBUF_32BPP; rfi->cairo_format = CAIRO_FORMAT_ARGB32; } else if (rfi->bpp == 24) { flags |= CLRBUF_24BPP; rfi->cairo_format = CAIRO_FORMAT_RGB24; } else { flags |= CLRBUF_16BPP; rfi->cairo_format = CAIRO_FORMAT_RGB16_565; } gdi_init(instance, flags, NULL); gdi = instance->context->gdi; rfi->primary_buffer = gdi->primary_buffer; rfi->hdc = gdi_GetDC(); rfi->hdc->bitsPerPixel = rfi->bpp; rfi->hdc->bytesPerPixel = rfi->bpp / 8; rfi->hdc->hwnd = (HGDI_WND) malloc(sizeof(GDI_WND)); rfi->hdc->hwnd->invalid = gdi_CreateRectRgn(0, 0, 0, 0); rfi->hdc->hwnd->invalid->null = 1; rfi->hdc->hwnd->count = 32; rfi->hdc->hwnd->cinvalid = (HGDI_RGN) malloc(sizeof(GDI_RGN) * rfi->hdc->hwnd->count); rfi->hdc->hwnd->ninvalid = 0; pointer_cache_register_callbacks(instance->update); /* if (rfi->sw_gdi != true) { glyph_cache_register_callbacks(instance->update); brush_cache_register_callbacks(instance->update); bitmap_cache_register_callbacks(instance->update); offscreen_cache_register_callbacks(instance->update); palette_cache_register_callbacks(instance->update); } */ instance->update->BeginPaint = rf_begin_paint; instance->update->EndPaint = rf_end_paint; instance->update->DesktopResize = rf_desktop_resize; freerdp_channels_post_connect(rfi->channels, instance); remmina_plugin_service->protocol_plugin_emit_signal(gp, "connect"); ui = g_new0(RemminaPluginRdpUiObject, 1); ui->type = REMMINA_RDP_UI_CONNECTED; rf_queue_ui(gp, ui); return True; }
void test_cliprdr(void) { int i; rdpChannels* channels; rdpSettings settings = { 0 }; freerdp instance = { 0 }; RDP_EVENT* event; RDP_CB_FORMAT_LIST_EVENT* format_list_event; RDP_CB_DATA_REQUEST_EVENT* data_request_event; RDP_CB_DATA_RESPONSE_EVENT* data_response_event; settings.hostname = "testhost"; instance.settings = &settings; instance.SendChannelData = test_rdp_channel_data; channels = freerdp_channels_new(); freerdp_channels_load_plugin(channels, &settings, "../channels/cliprdr/cliprdr.so", NULL); freerdp_channels_pre_connect(channels, &instance); freerdp_channels_post_connect(channels, &instance); /* server sends cliprdr capabilities and monitor ready PDU */ freerdp_channels_data(&instance, 0, (char*)test_clip_caps_data, sizeof(test_clip_caps_data) - 1, CHANNEL_FLAG_FIRST | CHANNEL_FLAG_LAST, sizeof(test_clip_caps_data) - 1); freerdp_channels_data(&instance, 0, (char*)test_monitor_ready_data, sizeof(test_monitor_ready_data) - 1, CHANNEL_FLAG_FIRST | CHANNEL_FLAG_LAST, sizeof(test_monitor_ready_data) - 1); /* cliprdr sends clipboard_sync event to UI */ while ((event = freerdp_channels_pop_event(channels)) == NULL) { freerdp_channels_check_fds(channels, &instance); } printf("Got event %d\n", event->event_type); CU_ASSERT(event->event_type == RDP_EVENT_TYPE_CB_MONITOR_READY); freerdp_event_free(event); /* UI sends format_list event to cliprdr */ event = freerdp_event_new(RDP_EVENT_CLASS_CLIPRDR, RDP_EVENT_TYPE_CB_FORMAT_LIST, event_process_callback, NULL); format_list_event = (RDP_CB_FORMAT_LIST_EVENT*) event; format_list_event->num_formats = 2; format_list_event->formats = (uint32*) xmalloc(sizeof(uint32) * 2); format_list_event->formats[0] = CB_FORMAT_TEXT; format_list_event->formats[1] = CB_FORMAT_HTML; event_processed = 0; freerdp_channels_send_event(channels, event); /* cliprdr sends format list PDU to server */ while (!event_processed) { freerdp_channels_check_fds(channels, &instance); } /* server sends format list response PDU to cliprdr */ freerdp_channels_data(&instance, 0, (char*)test_format_list_response_data, sizeof(test_format_list_response_data) - 1, CHANNEL_FLAG_FIRST | CHANNEL_FLAG_LAST, sizeof(test_format_list_response_data) - 1); /* server sends format list PDU to cliprdr */ freerdp_channels_data(&instance, 0, (char*)test_format_list_data, sizeof(test_format_list_data) - 1, CHANNEL_FLAG_FIRST | CHANNEL_FLAG_LAST, sizeof(test_format_list_data) - 1); /* cliprdr sends format_list event to UI */ while ((event = freerdp_channels_pop_event(channels)) == NULL) { freerdp_channels_check_fds(channels, &instance); } printf("Got event %d\n", event->event_type); CU_ASSERT(event->event_type == RDP_EVENT_TYPE_CB_FORMAT_LIST); if (event->event_type == RDP_EVENT_TYPE_CB_FORMAT_LIST) { format_list_event = (RDP_CB_FORMAT_LIST_EVENT*)event; for (i = 0; i < format_list_event->num_formats; i++) printf("Format: 0x%X\n", format_list_event->formats[i]); } freerdp_event_free(event); /* server sends data request PDU to cliprdr */ freerdp_channels_data(&instance, 0, (char*)test_data_request_data, sizeof(test_data_request_data) - 1, CHANNEL_FLAG_FIRST | CHANNEL_FLAG_LAST, sizeof(test_data_request_data) - 1); /* cliprdr sends data request event to UI */ while ((event = freerdp_channels_pop_event(channels)) == NULL) { freerdp_channels_check_fds(channels, &instance); } printf("Got event %d\n", event->event_type); CU_ASSERT(event->event_type == RDP_EVENT_TYPE_CB_DATA_REQUEST); if (event->event_type == RDP_EVENT_TYPE_CB_DATA_REQUEST) { data_request_event = (RDP_CB_DATA_REQUEST_EVENT*)event; printf("Requested format: 0x%X\n", data_request_event->format); } freerdp_event_free(event); /* UI sends data response event to cliprdr */ event = freerdp_event_new(RDP_EVENT_CLASS_CLIPRDR, RDP_EVENT_TYPE_CB_DATA_RESPONSE, event_process_callback, NULL); data_response_event = (RDP_CB_DATA_RESPONSE_EVENT*)event; data_response_event->data = (uint8*)xmalloc(6); strcpy((char*)data_response_event->data, "hello"); data_response_event->size = 6; event_processed = 0; freerdp_channels_send_event(channels, event); /* cliprdr sends data response PDU to server */ while (!event_processed) { freerdp_channels_check_fds(channels, &instance); } /* UI sends data request event to cliprdr */ event = freerdp_event_new(RDP_EVENT_CLASS_CLIPRDR, RDP_EVENT_TYPE_CB_DATA_REQUEST, event_process_callback, NULL); data_request_event = (RDP_CB_DATA_REQUEST_EVENT*)event; data_request_event->format = CB_FORMAT_UNICODETEXT; event_processed = 0; freerdp_channels_send_event(channels, event); /* cliprdr sends data request PDU to server */ while (!event_processed) { freerdp_channels_check_fds(channels, &instance); } /* server sends data response PDU to cliprdr */ freerdp_channels_data(&instance, 0, (char*)test_data_response_data, sizeof(test_data_response_data) - 1, CHANNEL_FLAG_FIRST | CHANNEL_FLAG_LAST, sizeof(test_data_response_data) - 1); /* cliprdr sends data response event to UI */ while ((event = freerdp_channels_pop_event(channels)) == NULL) { freerdp_channels_check_fds(channels, &instance); } printf("Got event %d\n", event->event_type); CU_ASSERT(event->event_type == RDP_EVENT_TYPE_CB_DATA_RESPONSE); if (event->event_type == RDP_EVENT_TYPE_CB_DATA_RESPONSE) { data_response_event = (RDP_CB_DATA_RESPONSE_EVENT*)event; printf("Data response size: %d\n", data_response_event->size); freerdp_hexdump(data_response_event->data, data_response_event->size); } freerdp_event_free(event); freerdp_channels_close(channels, &instance); freerdp_channels_free(channels); }
BOOL wf_post_connect(freerdp* instance) { rdpGdi* gdi; DWORD dwStyle; rdpCache* cache; wfContext* wfc; rdpContext* context; WCHAR lpWindowName[64]; rdpSettings* settings; EmbedWindowEventArgs e; settings = instance->settings; context = instance->context; wfc = (wfContext*) instance->context; cache = instance->context->cache; wfc->dstBpp = 32; wfc->width = settings->DesktopWidth; wfc->height = settings->DesktopHeight; if (settings->SoftwareGdi) { wfc->primary = wf_image_new(wfc, wfc->width, wfc->height, wfc->dstBpp, NULL); if (!gdi_init(instance, CLRCONV_ALPHA | CLRBUF_32BPP, wfc->primary->pdata)) return FALSE; gdi = instance->context->gdi; wfc->hdc = gdi->primary->hdc; } else { wf_gdi_register_update_callbacks(instance->update); wfc->srcBpp = instance->settings->ColorDepth; wfc->primary = wf_image_new(wfc, wfc->width, wfc->height, wfc->dstBpp, NULL); if (!(wfc->hdc = gdi_GetDC())) return FALSE; wfc->hdc->bitsPerPixel = wfc->dstBpp; wfc->hdc->bytesPerPixel = wfc->dstBpp / 8; wfc->hdc->alpha = wfc->clrconv->alpha; wfc->hdc->invert = wfc->clrconv->invert; wfc->hdc->hwnd = (HGDI_WND) malloc(sizeof(GDI_WND)); wfc->hdc->hwnd->invalid = gdi_CreateRectRgn(0, 0, 0, 0); wfc->hdc->hwnd->invalid->null = 1; wfc->hdc->hwnd->count = 32; wfc->hdc->hwnd->cinvalid = (HGDI_RGN) malloc(sizeof(GDI_RGN) * wfc->hdc->hwnd->count); wfc->hdc->hwnd->ninvalid = 0; if (settings->RemoteFxCodec) { wfc->tile = wf_image_new(wfc, 64, 64, 32, NULL); } } if (settings->WindowTitle != NULL) _snwprintf(lpWindowName, ARRAYSIZE(lpWindowName), L"%S", settings->WindowTitle); else if (settings->ServerPort == 3389) _snwprintf(lpWindowName, ARRAYSIZE(lpWindowName), L"FreeRDP: %S", settings->ServerHostname); else _snwprintf(lpWindowName, ARRAYSIZE(lpWindowName), L"FreeRDP: %S:%d", settings->ServerHostname, settings->ServerPort); if (settings->EmbeddedWindow) settings->Decorations = FALSE; if (wfc->fullscreen) dwStyle = WS_POPUP; else if (!settings->Decorations) dwStyle = WS_CHILD | WS_BORDER; else dwStyle = WS_CAPTION | WS_OVERLAPPED | WS_SYSMENU | WS_MINIMIZEBOX | WS_SIZEBOX | WS_MAXIMIZEBOX; if (!wfc->hwnd) { wfc->hwnd = CreateWindowEx((DWORD) NULL, wfc->wndClassName, lpWindowName, dwStyle, 0, 0, 0, 0, wfc->hWndParent, NULL, wfc->hInstance, NULL); SetWindowLongPtr(wfc->hwnd, GWLP_USERDATA, (LONG_PTR) wfc); } wf_resize_window(wfc); wf_add_system_menu(wfc); BitBlt(wfc->primary->hdc, 0, 0, wfc->width, wfc->height, NULL, 0, 0, BLACKNESS); wfc->drawing = wfc->primary; EventArgsInit(&e, "wfreerdp"); e.embed = FALSE; e.handle = (void*) wfc->hwnd; PubSub_OnEmbedWindow(context->pubSub, context, &e); ShowWindow(wfc->hwnd, SW_SHOWNORMAL); UpdateWindow(wfc->hwnd); if (settings->SoftwareGdi) { instance->update->BeginPaint = (pBeginPaint) wf_sw_begin_paint; instance->update->EndPaint = (pEndPaint) wf_sw_end_paint; instance->update->DesktopResize = (pDesktopResize) wf_sw_desktop_resize; } else { instance->update->BeginPaint = (pBeginPaint) wf_hw_begin_paint; instance->update->EndPaint = (pEndPaint) wf_hw_end_paint; instance->update->DesktopResize = (pDesktopResize) wf_hw_desktop_resize; } pointer_cache_register_callbacks(instance->update); wf_register_pointer(context->graphics); if (!settings->SoftwareGdi) { brush_cache_register_callbacks(instance->update); bitmap_cache_register_callbacks(instance->update); offscreen_cache_register_callbacks(instance->update); wf_register_graphics(context->graphics); instance->update->BitmapUpdate = wf_gdi_bitmap_update; } freerdp_channels_post_connect(context->channels, instance); if (wfc->fullscreen) floatbar_window_create(wfc); return TRUE; }
BOOL wf_post_connect(freerdp* instance) { rdpGdi* gdi; wfInfo* wfi; rdpCache* cache; wfContext* context; WCHAR lpWindowName[64]; rdpSettings* settings; settings = instance->settings; context = (wfContext*) instance->context; cache = instance->context->cache; wfi = context->wfi; wfi->dstBpp = 32; wfi->width = settings->DesktopWidth; wfi->height = settings->DesktopHeight; if (wfi->sw_gdi) { gdi_init(instance, CLRCONV_ALPHA | CLRCONV_INVERT | CLRBUF_32BPP, NULL); gdi = instance->context->gdi; wfi->hdc = gdi->primary->hdc; wfi->primary = wf_image_new(wfi, wfi->width, wfi->height, wfi->dstBpp, gdi->primary_buffer); } else { wf_gdi_register_update_callbacks(instance->update); wfi->srcBpp = instance->settings->ColorDepth; wfi->primary = wf_image_new(wfi, wfi->width, wfi->height, wfi->dstBpp, NULL); wfi->hdc = gdi_GetDC(); wfi->hdc->bitsPerPixel = wfi->dstBpp; wfi->hdc->bytesPerPixel = wfi->dstBpp / 8; wfi->hdc->alpha = wfi->clrconv->alpha; wfi->hdc->invert = wfi->clrconv->invert; wfi->hdc->hwnd = (HGDI_WND) malloc(sizeof(GDI_WND)); wfi->hdc->hwnd->invalid = gdi_CreateRectRgn(0, 0, 0, 0); wfi->hdc->hwnd->invalid->null = 1; wfi->hdc->hwnd->count = 32; wfi->hdc->hwnd->cinvalid = (HGDI_RGN) malloc(sizeof(GDI_RGN) * wfi->hdc->hwnd->count); wfi->hdc->hwnd->ninvalid = 0; if (settings->RemoteFxCodec) { wfi->tile = wf_image_new(wfi, 64, 64, 32, NULL); wfi->rfx_context = rfx_context_new(); } if (settings->NSCodec) { wfi->nsc_context = nsc_context_new(); } } if (settings->WindowTitle != NULL) _snwprintf(lpWindowName, ARRAYSIZE(lpWindowName), L"%S", settings->WindowTitle); else if (settings->ServerPort == 3389) _snwprintf(lpWindowName, ARRAYSIZE(lpWindowName), L"FreeRDP: %S", settings->ServerHostname); else _snwprintf(lpWindowName, ARRAYSIZE(lpWindowName), L"FreeRDP: %S:%d", settings->ServerHostname, settings->ServerPort); if (!wfi->hwnd) { wfi->hwnd = CreateWindowEx((DWORD) NULL, wfi->wndClassName, lpWindowName, 0, 0, 0, 0, 0, wfi->hWndParent, NULL, wfi->hInstance, NULL); SetWindowLongPtr(wfi->hwnd, GWLP_USERDATA, (LONG_PTR) wfi); } wf_resize_window(wfi); BitBlt(wfi->primary->hdc, 0, 0, wfi->width, wfi->height, NULL, 0, 0, BLACKNESS); wfi->drawing = wfi->primary; ShowWindow(wfi->hwnd, SW_SHOWNORMAL); UpdateWindow(wfi->hwnd); if (wfi->sw_gdi) { instance->update->BeginPaint = wf_sw_begin_paint; instance->update->EndPaint = wf_sw_end_paint; instance->update->DesktopResize = wf_sw_desktop_resize; } else { instance->update->BeginPaint = wf_hw_begin_paint; instance->update->EndPaint = wf_hw_end_paint; instance->update->DesktopResize = wf_hw_desktop_resize; } pointer_cache_register_callbacks(instance->update); if (wfi->sw_gdi != TRUE) { brush_cache_register_callbacks(instance->update); bitmap_cache_register_callbacks(instance->update); offscreen_cache_register_callbacks(instance->update); } wf_register_graphics(instance->context->graphics); freerdp_channels_post_connect(instance->context->channels, instance); wf_cliprdr_init(wfi, instance->context->channels); return TRUE; }
/** Creates a new connection based on the settings found in the "instance" parameter * It will use the callbacks registered on the structure to process the pre/post connect operations * that the caller requires. * @see struct rdp_freerdp in freerdp.h * * @param instance - pointer to a rdp_freerdp structure that contains base information to establish the connection. * On return, this function will be initialized with the new connection's settings. * * @return TRUE if successful. FALSE otherwise. * */ BOOL freerdp_connect(freerdp* instance) { UINT status2 = CHANNEL_RC_OK; rdpRdp* rdp; BOOL status = TRUE; rdpSettings* settings; ConnectionResultEventArgs e; if (!instance) return FALSE; /* We always set the return code to 0 before we start the connect sequence*/ connectErrorCode = 0; freerdp_set_last_error(instance->context, FREERDP_ERROR_SUCCESS); clearChannelError(instance->context); ResetEvent(instance->context->abortEvent); rdp = instance->context->rdp; settings = instance->settings; instance->context->codecs = codecs_new(instance->context); IFCALLRET(instance->PreConnect, status, instance); if (status) status2 = freerdp_channels_pre_connect(instance->context->channels, instance); if (settings->KeyboardLayout == KBD_JAPANESE_INPUT_SYSTEM_MS_IME2002) { settings->KeyboardType = 7; settings->KeyboardSubType = 2; settings->KeyboardFunctionKey = 12; } if (!status || (status2 != CHANNEL_RC_OK)) { if (!freerdp_get_last_error(rdp->context)) freerdp_set_last_error(instance->context, FREERDP_ERROR_PRE_CONNECT_FAILED); WLog_ERR(TAG, "freerdp_pre_connect failed"); goto freerdp_connect_finally; } status = rdp_client_connect(rdp); /* --authonly tests the connection without a UI */ if (instance->settings->AuthenticationOnly) { WLog_ERR(TAG, "Authentication only, exit status %"PRId32"", !status); goto freerdp_connect_finally; } if (!status) goto freerdp_connect_finally; if (status) { UINT status2; if (instance->settings->DumpRemoteFx) { instance->update->pcap_rfx = pcap_open(instance->settings->DumpRemoteFxFile, TRUE); if (instance->update->pcap_rfx) instance->update->dump_rfx = TRUE; } IFCALLRET(instance->PostConnect, status, instance); if (status) status2 = freerdp_channels_post_connect(instance->context->channels, instance); if (!status || (status2 != CHANNEL_RC_OK) || !update_post_connect(instance->update)) { WLog_ERR(TAG, "freerdp_post_connect failed"); if (!freerdp_get_last_error(rdp->context)) freerdp_set_last_error(instance->context, FREERDP_ERROR_POST_CONNECT_FAILED); status = FALSE; goto freerdp_connect_finally; } if (instance->settings->PlayRemoteFx) { wStream* s; rdpUpdate* update; pcap_record record; update = instance->update; update->pcap_rfx = pcap_open(settings->PlayRemoteFxFile, FALSE); if (!update->pcap_rfx) { status = FALSE; goto freerdp_connect_finally; } else { update->play_rfx = TRUE; } while (pcap_has_next_record(update->pcap_rfx)) { pcap_get_next_record_header(update->pcap_rfx, &record); if (!(s = StreamPool_Take(rdp->transport->ReceivePool, record.length))) break; record.data = Stream_Buffer(s); pcap_get_next_record_content(update->pcap_rfx, &record); Stream_SetLength(s, record.length); Stream_SetPosition(s, 0); update->BeginPaint(update->context); update_recv_surfcmds(update, Stream_Length(s), s); update->EndPaint(update->context); Stream_Release(s); } pcap_close(update->pcap_rfx); update->pcap_rfx = NULL; status = TRUE; goto freerdp_connect_finally; } } if (rdp->errorInfo == ERRINFO_SERVER_INSUFFICIENT_PRIVILEGES) freerdp_set_last_error(instance->context, FREERDP_ERROR_INSUFFICIENT_PRIVILEGES); SetEvent(rdp->transport->connectedEvent); freerdp_connect_finally: EventArgsInit(&e, "freerdp"); e.result = status ? 0 : -1; PubSub_OnConnectionResult(instance->context->pubSub, instance->context, &e); return status; }