From 5d9e8b2e28c8841f3327526ab2f74aa55ddc1b2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Sun, 16 Oct 2011 21:02:28 -0400 Subject: [PATCH] libfreerdp-core: cleanup of freerdp interface --- client/DirectFB/dfreerdp.c | 8 ++++---- client/X11/xf_gdi.c | 4 ++-- client/X11/xfreerdp.c | 14 +++++++------- client/test/freerdp.c | 6 +++--- include/freerdp/cache/bitmap.h | 8 ++++---- include/freerdp/cache/brush.h | 4 ++-- include/freerdp/cache/offscreen.h | 13 ++++--------- include/freerdp/freerdp.h | 31 ++++++++++++++----------------- include/freerdp/update.h | 12 +++++++----- libfreerdp-cache/brush.c | 4 ++-- libfreerdp-cache/offscreen.c | 8 ++++---- libfreerdp-channels/libchannels.c | 8 ++++---- libfreerdp-core/freerdp.c | 8 +++----- libfreerdp-gdi/gdi.c | 10 +++++----- 14 files changed, 65 insertions(+), 73 deletions(-) diff --git a/client/DirectFB/dfreerdp.c b/client/DirectFB/dfreerdp.c index fb6dc35a1..3d60b46c5 100644 --- a/client/DirectFB/dfreerdp.c +++ b/client/DirectFB/dfreerdp.c @@ -285,7 +285,7 @@ int dfreerdp_run(freerdp* instance) memset(rfds, 0, sizeof(rfds)); memset(wfds, 0, sizeof(wfds)); - if (!instance->Connect(instance)) + if (!freerdp_connect(instance)) return 0; context = (dfContext*) instance->context; @@ -298,7 +298,7 @@ int dfreerdp_run(freerdp* instance) rcount = 0; wcount = 0; - if (instance->GetFileDescriptor(instance, rfds, &rcount, wfds, &wcount) != True) + if (freerdp_get_fds(instance, rfds, &rcount, wfds, &wcount) != True) { printf("Failed to get FreeRDP file descriptor\n"); break; @@ -344,7 +344,7 @@ int dfreerdp_run(freerdp* instance) } } - if (instance->CheckFileDescriptor(instance) != True) + if (freerdp_check_fds(instance) != True) { printf("Failed to check FreeRDP file descriptor\n"); break; @@ -366,7 +366,7 @@ int dfreerdp_run(freerdp* instance) freerdp_channels_free(channels); df_free(dfi); gdi_free(instance); - instance->Disconnect(instance); + freerdp_disconnect(instance); freerdp_free(instance); return 0; diff --git a/client/X11/xf_gdi.c b/client/X11/xf_gdi.c index 65dd0b0ae..69cc5fc05 100644 --- a/client/X11/xf_gdi.c +++ b/client/X11/xf_gdi.c @@ -382,7 +382,7 @@ void xf_gdi_patblt(rdpUpdate* update, PATBLT_ORDER* patblt) if (brush->style & CACHED_BRUSH) { - brush->data = brush_get(cache->brush, brush->index, &brush->bpp); + brush->data = brush_cache_get(cache->brush, brush->index, &brush->bpp); brush->style = GDI_BS_PATTERN; } @@ -823,7 +823,7 @@ void xf_gdi_cache_glyph_v2(rdpUpdate* update, CACHE_GLYPH_V2_ORDER* cache_glyph_ void xf_gdi_cache_brush(rdpUpdate* update, CACHE_BRUSH_ORDER* cache_brush) { rdpCache* cache = update->context->cache; - brush_put(cache->brush, cache_brush->index, cache_brush->data, cache_brush->bpp); + brush_cache_put(cache->brush, cache_brush->index, cache_brush->data, cache_brush->bpp); } void xf_gdi_surface_bits(rdpUpdate* update, SURFACE_BITS_COMMAND* surface_bits_command) diff --git a/client/X11/xfreerdp.c b/client/X11/xfreerdp.c index 4e360032b..f7df3d2f4 100644 --- a/client/X11/xfreerdp.c +++ b/client/X11/xfreerdp.c @@ -731,9 +731,9 @@ boolean xf_post_connect(freerdp* instance) cache->bitmap->BitmapFree = (cbBitmapFree) xf_bitmap_free; offscreen_cache_register_callbacks(instance->update); - cache->offscreen->OffscreenBitmapSize = (cbOffscreenBitmapSize) xf_bitmap_size; - cache->offscreen->OffscreenBitmapNew = (cbOffscreenBitmapNew) xf_offscreen_bitmap_new; - cache->offscreen->OffscreenBitmapFree = (cbOffscreenBitmapFree) xf_bitmap_free; + cache->offscreen->BitmapSize = (cbBitmapSize) xf_bitmap_size; + cache->offscreen->BitmapNew = (cbBitmapNew) xf_offscreen_bitmap_new; + cache->offscreen->BitmapFree = (cbBitmapFree) xf_bitmap_free; cache->offscreen->SetSurface = (cbSetSurface) xf_set_surface; } @@ -910,7 +910,7 @@ int xfreerdp_run(freerdp* instance) memset(rfds, 0, sizeof(rfds)); memset(wfds, 0, sizeof(wfds)); - if (!instance->Connect(instance)) + if (!freerdp_connect(instance)) return 0; xfi = ((xfContext*) instance->context)->xfi; @@ -921,7 +921,7 @@ int xfreerdp_run(freerdp* instance) rcount = 0; wcount = 0; - if (instance->GetFileDescriptor(instance, rfds, &rcount, wfds, &wcount) != True) + if (freerdp_get_fds(instance, rfds, &rcount, wfds, &wcount) != True) { printf("Failed to get FreeRDP file descriptor\n"); break; @@ -967,7 +967,7 @@ int xfreerdp_run(freerdp* instance) } } - if (instance->CheckFileDescriptor(instance) != True) + if (freerdp_check_fds(instance) != True) { printf("Failed to check FreeRDP file descriptor\n"); break; @@ -987,7 +987,7 @@ int xfreerdp_run(freerdp* instance) freerdp_channels_close(channels, instance); freerdp_channels_free(channels); - instance->Disconnect(instance); + freerdp_disconnect(instance); gdi_free(instance); freerdp_free(instance); xf_free(xfi); diff --git a/client/test/freerdp.c b/client/test/freerdp.c index dad5fb05c..16ad43430 100644 --- a/client/test/freerdp.c +++ b/client/test/freerdp.c @@ -222,14 +222,14 @@ int tfreerdp_run(freerdp* instance) context = (tfContext*) instance->context; chanman = context->chanman; - instance->Connect(instance); + freerdp_connect(instance); while (1) { rcount = 0; wcount = 0; - if (instance->GetFileDescriptor(instance, rfds, &rcount, wfds, &wcount) != True) + if (freerdp_get_fds(instance, rfds, &rcount, wfds, &wcount) != True) { printf("Failed to get FreeRDP file descriptor\n"); break; @@ -269,7 +269,7 @@ int tfreerdp_run(freerdp* instance) } } - if (instance->CheckFileDescriptor(instance) != True) + if (freerdp_check_fds(instance) != True) { printf("Failed to check FreeRDP file descriptor\n"); break; diff --git a/include/freerdp/cache/bitmap.h b/include/freerdp/cache/bitmap.h index aa8ccd853..fb6e5d1a6 100644 --- a/include/freerdp/cache/bitmap.h +++ b/include/freerdp/cache/bitmap.h @@ -29,6 +29,10 @@ typedef struct _BITMAP_V2_CELL BITMAP_V2_CELL; typedef struct rdp_bitmap_cache rdpBitmapCache; +typedef void (*cbBitmapSize)(rdpUpdate* update, uint32* size); +typedef void (*cbBitmapNew)(rdpUpdate* update, rdpBitmap* bitmap); +typedef void (*cbBitmapFree)(rdpUpdate* update, rdpBitmap* bitmap); + #include struct _BITMAP_V2_CELL @@ -37,10 +41,6 @@ struct _BITMAP_V2_CELL rdpBitmap** entries; }; -typedef void (*cbBitmapSize)(rdpUpdate* update, uint32* size); -typedef void (*cbBitmapNew)(rdpUpdate* update, rdpBitmap* bitmap); -typedef void (*cbBitmapFree)(rdpUpdate* update, rdpBitmap* bitmap); - struct rdp_bitmap_cache { pcMemBlt MemBlt; diff --git a/include/freerdp/cache/brush.h b/include/freerdp/cache/brush.h index aad4afad5..767f3c22d 100644 --- a/include/freerdp/cache/brush.h +++ b/include/freerdp/cache/brush.h @@ -41,8 +41,8 @@ struct rdp_brush }; typedef struct rdp_brush rdpBrushCache; -FREERDP_API void* brush_get(rdpBrushCache* brush, uint8 index, uint8* bpp); -FREERDP_API void brush_put(rdpBrushCache* brush, uint8 index, void* entry, uint8 bpp); +FREERDP_API void* brush_cache_get(rdpBrushCache* brush, uint8 index, uint8* bpp); +FREERDP_API void brush_cache_put(rdpBrushCache* brush, uint8 index, void* entry, uint8 bpp); FREERDP_API rdpBrushCache* brush_cache_new(rdpSettings* settings); FREERDP_API void brush_cache_free(rdpBrushCache* brush); diff --git a/include/freerdp/cache/offscreen.h b/include/freerdp/cache/offscreen.h index 211a8e143..dac478a97 100644 --- a/include/freerdp/cache/offscreen.h +++ b/include/freerdp/cache/offscreen.h @@ -27,20 +27,15 @@ #include typedef struct rdp_offscreen_cache rdpOffscreenCache; +typedef void (*cbSetSurface)(rdpUpdate* update, rdpBitmap* bitmap, boolean primary); #include -typedef void (*cbOffscreenBitmapSize)(rdpUpdate* update, uint32* size); -typedef void (*cbOffscreenBitmapNew)(rdpUpdate* update, rdpBitmap* bitmap); -typedef void (*cbOffscreenBitmapFree)(rdpUpdate* update, rdpBitmap* bitmap); -typedef void (*cbSetSurface)(rdpUpdate* update, rdpBitmap* bitmap, boolean primary); - struct rdp_offscreen_cache { - cbOffscreenBitmapSize OffscreenBitmapSize; - cbOffscreenBitmapNew OffscreenBitmapNew; - cbOffscreenBitmapFree OffscreenBitmapFree; - + cbBitmapSize BitmapSize; + cbBitmapNew BitmapNew; + cbBitmapFree BitmapFree; cbSetSurface SetSurface; uint16 currentSurface; diff --git a/include/freerdp/freerdp.h b/include/freerdp/freerdp.h index 5fd28824a..c002cf52a 100644 --- a/include/freerdp/freerdp.h +++ b/include/freerdp/freerdp.h @@ -41,23 +41,17 @@ typedef struct rdp_context rdpContext; extern "C" { #endif -FREERDP_API boolean freerdp_global_init(); -FREERDP_API void freerdp_global_finish(); - -typedef boolean (*pcConnect)(freerdp* instance); -typedef boolean (*pcPreConnect)(freerdp* instance); -typedef boolean (*pcPostConnect)(freerdp* instance); -typedef boolean (*pcAuthenticate)(freerdp* instance, char** username, char** password, char** domain); -typedef boolean (*pcGetFileDescriptor)(freerdp* instance, void** rfds, int* rcount, void** wfds, int* wcount); -typedef boolean (*pcCheckFileDescriptor)(freerdp* instance); -typedef int (*pcSendChannelData)(freerdp* instance, int channelId, uint8* data, int size); -typedef int (*pcReceiveChannelData)(freerdp* instance, int channelId, uint8* data, int size, int flags, int total_size); -typedef void (*pcDisconnect)(freerdp* instance); - typedef void (*pcContextSize)(freerdp* instance, uint32* size); typedef void (*pcContextNew)(freerdp* instance, rdpContext* context); typedef void (*pcContextFree)(freerdp* instance, rdpContext* context); +typedef boolean (*pcPreConnect)(freerdp* instance); +typedef boolean (*pcPostConnect)(freerdp* instance); +typedef boolean (*pcAuthenticate)(freerdp* instance, char** username, char** password, char** domain); + +typedef int (*pcSendChannelData)(freerdp* instance, int channelId, uint8* data, int size); +typedef int (*pcReceiveChannelData)(freerdp* instance, int channelId, uint8* data, int size, int flags, int total_size); + struct rdp_context { freerdp* instance; @@ -83,20 +77,23 @@ struct rdp_freerdp pcContextNew ContextNew; pcContextFree ContextFree; - pcConnect Connect; pcPreConnect PreConnect; pcPostConnect PostConnect; pcAuthenticate Authenticate; - pcGetFileDescriptor GetFileDescriptor; - pcCheckFileDescriptor CheckFileDescriptor; + pcSendChannelData SendChannelData; pcReceiveChannelData ReceiveChannelData; - pcDisconnect Disconnect; }; FREERDP_API void freerdp_context_new(freerdp* instance); FREERDP_API void freerdp_context_free(freerdp* instance); +FREERDP_API boolean freerdp_connect(freerdp* instance); +FREERDP_API boolean freerdp_disconnect(freerdp* instance); + +FREERDP_API boolean freerdp_get_fds(freerdp* instance, void** rfds, int* rcount, void** wfds, int* wcount); +FREERDP_API boolean freerdp_check_fds(freerdp* instance); + FREERDP_API freerdp* freerdp_new(); FREERDP_API void freerdp_free(freerdp* instance); diff --git a/include/freerdp/update.h b/include/freerdp/update.h index a56cf65ef..dc4edee8c 100644 --- a/include/freerdp/update.h +++ b/include/freerdp/update.h @@ -1047,6 +1047,7 @@ typedef void (*pcDesktopResize)(rdpUpdate* update); typedef void (*pcBitmap)(rdpUpdate* update, BITMAP_UPDATE* bitmap); typedef void (*pcPalette)(rdpUpdate* update, PALETTE_UPDATE* palette); typedef void (*pcPlaySound)(rdpUpdate* update, PLAY_SOUND_UPDATE* play_sound); + typedef void (*pcPointerPosition)(rdpUpdate* update, POINTER_POSITION_UPDATE* pointer_position); typedef void (*pcPointerSystem)(rdpUpdate* update, POINTER_SYSTEM_UPDATE* pointer_system); typedef void (*pcPointerColor)(rdpUpdate* update, POINTER_COLOR_UPDATE* pointer_color); @@ -1117,10 +1118,6 @@ struct rdp_update { rdpContext* context; - boolean dump_rfx; - boolean play_rfx; - rdpPcap* pcap_rfx; - pcBeginPaint BeginPaint; pcEndPaint EndPaint; pcSetBounds SetBounds; @@ -1158,7 +1155,6 @@ struct rdp_update pcEllipseSC EllipseSC; pcEllipseCB EllipseCB; - boolean glyph_v2; pcCacheBitmap CacheBitmap; pcCacheBitmapV2 CacheBitmapV2; pcCacheBitmapV3 CacheBitmapV3; @@ -1196,6 +1192,12 @@ struct rdp_update pcBitmapDecompress BitmapDecompress; + boolean glyph_v2; + + boolean dump_rfx; + boolean play_rfx; + rdpPcap* pcap_rfx; + BITMAP_UPDATE bitmap_update; PALETTE_UPDATE palette_update; PLAY_SOUND_UPDATE play_sound; diff --git a/libfreerdp-cache/brush.c b/libfreerdp-cache/brush.c index 0d6b93b39..4ae83f828 100644 --- a/libfreerdp-cache/brush.c +++ b/libfreerdp-cache/brush.c @@ -22,7 +22,7 @@ #include -void* brush_get(rdpBrushCache* brush, uint8 index, uint8* bpp) +void* brush_cache_get(rdpBrushCache* brush, uint8 index, uint8* bpp) { void* entry; @@ -58,7 +58,7 @@ void* brush_get(rdpBrushCache* brush, uint8 index, uint8* bpp) return entry; } -void brush_put(rdpBrushCache* brush, uint8 index, void* entry, uint8 bpp) +void brush_cache_put(rdpBrushCache* brush, uint8 index, void* entry, uint8 bpp) { if (bpp == 1) { diff --git a/libfreerdp-cache/offscreen.c b/libfreerdp-cache/offscreen.c index c8f2542a8..2fdabd562 100644 --- a/libfreerdp-cache/offscreen.c +++ b/libfreerdp-cache/offscreen.c @@ -29,18 +29,18 @@ void update_gdi_create_offscreen_bitmap(rdpUpdate* update, CREATE_OFFSCREEN_BITM uint32 size = sizeof(rdpBitmap); rdpCache* cache = update->context->cache; - IFCALL(cache->offscreen->OffscreenBitmapSize, update, &size); + IFCALL(cache->offscreen->BitmapSize, update, &size); bitmap = (rdpBitmap*) xzalloc(size); bitmap->width = create_offscreen_bitmap->cx; bitmap->height = create_offscreen_bitmap->cy; - IFCALL(cache->offscreen->OffscreenBitmapNew, update, bitmap); + IFCALL(cache->offscreen->BitmapNew, update, bitmap); prevBitmap = offscreen_cache_get(cache->offscreen, create_offscreen_bitmap->id); if (prevBitmap != NULL) { - IFCALL(cache->offscreen->OffscreenBitmapFree, update, prevBitmap); + IFCALL(cache->offscreen->BitmapFree, update, prevBitmap); bitmap_free(prevBitmap); } @@ -142,7 +142,7 @@ void offscreen_cache_free(rdpOffscreenCache* offscreen_cache) if (bitmap != NULL) { - IFCALL(offscreen_cache->OffscreenBitmapFree, offscreen_cache->update, bitmap); + IFCALL(offscreen_cache->BitmapFree, offscreen_cache->update, bitmap); bitmap_free(bitmap); } } diff --git a/libfreerdp-channels/libchannels.c b/libfreerdp-channels/libchannels.c index 8607be0ea..4a78f109c 100644 --- a/libfreerdp-channels/libchannels.c +++ b/libfreerdp-channels/libchannels.c @@ -825,9 +825,9 @@ FREERDP_API int freerdp_channels_send_event(rdpChannels* chan_man, RDP_EVENT* ev */ static void freerdp_channels_process_sync(rdpChannels* chan_man, freerdp* instance) { - struct channel_data* lchan_data; rdpChannel* lrdp_chan; struct sync_data* item; + struct channel_data* lchan_data; while (chan_man->sync_data_list->head != NULL) { @@ -838,10 +838,10 @@ static void freerdp_channels_process_sync(rdpChannels* chan_man, freerdp* instan lchan_data = chan_man->chans + item->index; lrdp_chan = freerdp_channels_find_channel_by_name(chan_man, instance->settings, lchan_data->name, &item->index); + if (lrdp_chan != NULL) - { - IFCALL(instance->SendChannelData, instance, lrdp_chan->channel_id, item->data, item->data_length); - } + instance->SendChannelData(instance, lrdp_chan->channel_id, item->data, item->data_length); + if (lchan_data->open_event_proc != 0) { lchan_data->open_event_proc(lchan_data->open_handle, diff --git a/libfreerdp-core/freerdp.c b/libfreerdp-core/freerdp.c index 6c722fdf7..a23da105a 100644 --- a/libfreerdp-core/freerdp.c +++ b/libfreerdp-core/freerdp.c @@ -113,12 +113,14 @@ static int freerdp_send_channel_data(freerdp* instance, int channel_id, uint8* d return rdp_send_channel_data(instance->context->rdp, channel_id, data, size); } -void freerdp_disconnect(freerdp* instance) +boolean freerdp_disconnect(freerdp* instance) { rdpRdp* rdp; rdp = instance->context->rdp; transport_disconnect(rdp->transport); + + return True; } void freerdp_context_new(freerdp* instance) @@ -157,11 +159,7 @@ freerdp* freerdp_new() if (instance != NULL) { - instance->Connect = freerdp_connect; - instance->GetFileDescriptor = freerdp_get_fds; - instance->CheckFileDescriptor = freerdp_check_fds; instance->SendChannelData = freerdp_send_channel_data; - instance->Disconnect = freerdp_disconnect; } return instance; diff --git a/libfreerdp-gdi/gdi.c b/libfreerdp-gdi/gdi.c index 3ab2da9bd..cfddd27ed 100644 --- a/libfreerdp-gdi/gdi.c +++ b/libfreerdp-gdi/gdi.c @@ -558,7 +558,7 @@ void gdi_patblt(rdpUpdate* update, PATBLT_ORDER* patblt) if (brush->style & CACHED_BRUSH) { - brush->data = brush_get(cache->brush, brush->index, &brush->bpp); + brush->data = brush_cache_get(cache->brush, brush->index, &brush->bpp); brush->style = GDI_BS_PATTERN; } @@ -873,7 +873,7 @@ void gdi_cache_glyph_v2(rdpUpdate* update, CACHE_GLYPH_V2_ORDER* cache_glyph_v2) void gdi_cache_brush(rdpUpdate* update, CACHE_BRUSH_ORDER* cache_brush) { rdpCache* cache = update->context->cache; - brush_put(cache->brush, cache_brush->index, cache_brush->data, cache_brush->bpp); + brush_cache_put(cache->brush, cache_brush->index, cache_brush->data, cache_brush->bpp); } int tilenum = 0; @@ -1191,9 +1191,9 @@ int gdi_init(freerdp* instance, uint32 flags, uint8* buffer) cache->bitmap->BitmapFree = (cbBitmapFree) gdi_bitmap_free; offscreen_cache_register_callbacks(instance->update); - cache->offscreen->OffscreenBitmapSize = (cbOffscreenBitmapSize) gdi_bitmap_size; - cache->offscreen->OffscreenBitmapNew = (cbOffscreenBitmapNew) gdi_offscreen_bitmap_new; - cache->offscreen->OffscreenBitmapFree = (cbOffscreenBitmapFree) gdi_bitmap_free; + cache->offscreen->BitmapSize = (cbBitmapSize) gdi_bitmap_size; + cache->offscreen->BitmapNew = (cbBitmapNew) gdi_offscreen_bitmap_new; + cache->offscreen->BitmapFree = (cbBitmapFree) gdi_bitmap_free; cache->offscreen->SetSurface = (cbSetSurface) gdi_set_surface; gdi->rfx_context = rfx_context_new();