libfreerdp-core: cleanup of freerdp interface

This commit is contained in:
Marc-André Moreau 2011-10-16 21:02:28 -04:00
parent 8df77dba71
commit 5d9e8b2e28
14 changed files with 65 additions and 73 deletions

View File

@ -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;

View File

@ -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)

View File

@ -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);

View File

@ -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;

View File

@ -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 <freerdp/cache/cache.h>
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;

View File

@ -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);

View File

@ -27,20 +27,15 @@
#include <freerdp/utils/stream.h>
typedef struct rdp_offscreen_cache rdpOffscreenCache;
typedef void (*cbSetSurface)(rdpUpdate* update, rdpBitmap* bitmap, boolean primary);
#include <freerdp/cache/cache.h>
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;

View File

@ -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);

View File

@ -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;

View File

@ -22,7 +22,7 @@
#include <freerdp/cache/brush.h>
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)
{

View File

@ -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);
}
}

View File

@ -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,

View File

@ -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;

View File

@ -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();