diff options
author | dscho <dscho> | 2006-09-11 14:49:12 +0000 |
---|---|---|
committer | dscho <dscho> | 2006-09-11 14:49:12 +0000 |
commit | 6cfd9afee967ec1bd69c1ff2f9efb03c75d0a55d (patch) | |
tree | 02b8b661a512f3ca10ad349572e332ba3ee40f1a | |
parent | e4c85d48e68d5f135dd3a478aff8adb7697a1349 (diff) | |
download | libtdevnc-6cfd9afee967ec1bd69c1ff2f9efb03c75d0a55d.tar.gz libtdevnc-6cfd9afee967ec1bd69c1ff2f9efb03c75d0a55d.zip |
make cut text handling using a hook
-rw-r--r-- | libvncclient/rfbproto.c | 20 | ||||
-rw-r--r-- | rfb/rfbclient.h | 4 |
2 files changed, 11 insertions, 13 deletions
diff --git a/libvncclient/rfbproto.c b/libvncclient/rfbproto.c index 7572fd7..105e4e3 100644 --- a/libvncclient/rfbproto.c +++ b/libvncclient/rfbproto.c @@ -1019,10 +1019,6 @@ SendClientCutText(rfbClient* client, char *str, int len) { rfbClientCutTextMsg cct; - if (client->serverCutText) - free(client->serverCutText); - client->serverCutText = NULL; - if (!SupportsClient2Server(client, rfbClientCutText)) return TRUE; cct.type = rfbClientCutText; @@ -1481,23 +1477,25 @@ HandleRFBServerMessage(rfbClient* client) case rfbServerCutText: { + char *buffer; + if (!ReadFromRFBServer(client, ((char *)&msg) + 1, sz_rfbServerCutTextMsg - 1)) return FALSE; msg.sct.length = rfbClientSwap32IfLE(msg.sct.length); - if (client->serverCutText) - free(client->serverCutText); + buffer = malloc(msg.sct.length+1); - client->serverCutText = malloc(msg.sct.length+1); - - if (!ReadFromRFBServer(client, client->serverCutText, msg.sct.length)) + if (!ReadFromRFBServer(client, buffer, msg.sct.length)) return FALSE; - client->serverCutText[msg.sct.length] = 0; + buffer[msg.sct.length] = 0; + + if (client->GotXCutText) + client->GotXCutText(client, buffer, msg.sct.length); - client->newServerCutText = TRUE; + free(buffer); break; } diff --git a/rfb/rfbclient.h b/rfb/rfbclient.h index d8e3fdc..e8754fd 100644 --- a/rfb/rfbclient.h +++ b/rfb/rfbclient.h @@ -104,6 +104,7 @@ typedef void (*SoftCursorUnlockScreenProc)(struct _rfbClient* client); typedef void (*GotFrameBufferUpdateProc)(struct _rfbClient* client, int x, int y, int w, int h); typedef char* (*GetPasswordProc)(struct _rfbClient* client); typedef rfbBool (*MallocFrameBufferProc)(struct _rfbClient* client); +typedef void (*GotXCutTextProc)(struct _rfbClient* client, const char *text, int textlen); typedef void (*BellProc)(struct _rfbClient* client); typedef struct _rfbClient { @@ -136,8 +137,6 @@ typedef struct _rfbClient { char *desktopName; rfbPixelFormat format; rfbServerInitMsg si; - char *serverCutText; - rfbBool newServerCutText; /* sockets.c */ #define RFB_BUF_SIZE 8192 @@ -220,6 +219,7 @@ typedef struct _rfbClient { /* the pointer returned by GetPassword will be freed after use! */ GetPasswordProc GetPassword; MallocFrameBufferProc MallocFrameBuffer; + GotXCutTextProc GotXCutText; BellProc Bell; /* Which messages are supported by the server |