mirror of
https://github.com/sheumann/VNCviewGS.git
synced 2024-11-22 02:30:47 +00:00
ceeaeb7767
This is a prelude to revamping the read routines.
120 lines
3.3 KiB
C++
120 lines
3.3 KiB
C++
#if __ORCAC__
|
|
#pragma lint -1
|
|
#pragma noroot
|
|
segment "VNCview GS";
|
|
#endif
|
|
|
|
#include <window.h>
|
|
#include <quickdraw.h>
|
|
#include <qdaux.h>
|
|
#include <desk.h>
|
|
#include <memory.h>
|
|
#include <resources.h>
|
|
#include <tcpip.h>
|
|
#include <menu.h>
|
|
#include <control.h>
|
|
#include <misctool.h>
|
|
#include <scrap.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <event.h>
|
|
#include <limits.h>
|
|
#include <orca.h>
|
|
|
|
#include "vncsession.h"
|
|
#include "vncview.h"
|
|
#include "vncdisplay.h"
|
|
#include "colortables.h"
|
|
#include "menus.h"
|
|
#include "clipboard.h"
|
|
#include "desktopsize.h"
|
|
#include "mouse.h"
|
|
#include "keyboard.h"
|
|
#include "copyrect.h"
|
|
#include "raw.h"
|
|
#include "hextile.h"
|
|
|
|
/* Update the Scrap Manager clipboard with new data sent from server.
|
|
*/
|
|
void DoServerCutText (void) {
|
|
unsigned long textLen;
|
|
unsigned long i;
|
|
|
|
if (! DoWaitingReadTCP (3)) { /* Read & ignore padding */
|
|
DoClose(vncWindow);
|
|
return;
|
|
}
|
|
if (! DoWaitingReadTCP (4)) {
|
|
DoClose(vncWindow);
|
|
return;
|
|
}
|
|
textLen = SwapBytes4(*(unsigned long *)readBufferPtr);
|
|
|
|
if (! DoWaitingReadTCP(textLen)) {
|
|
DoClose(vncWindow);
|
|
return;
|
|
};
|
|
if (allowClipboardTransfers) {
|
|
ZeroScrap();
|
|
|
|
/* Convert lf->cr; Use pointer arithmetic so we can go over 64k */
|
|
for (i = 0; i < textLen; i++)
|
|
if (*(readBufferPtr+i) == '\n')
|
|
*(readBufferPtr+i) = '\r';
|
|
|
|
/* Below function call requires <scrap.h> to be fixed */
|
|
PutScrap(textLen, textScrap, (Pointer) readBufferPtr);
|
|
/* Potential errors (e.g. out of memory) ignored */
|
|
DoneWithReadBuffer();
|
|
}
|
|
}
|
|
|
|
void DoSendClipboard (void) {
|
|
static struct clientCutText {
|
|
unsigned char messageType;
|
|
unsigned char padding1;
|
|
unsigned int padding2;
|
|
unsigned long length;
|
|
} clientCutTextStruct = { 6 /* Message type 6 */ };
|
|
|
|
Handle scrapHandle;
|
|
unsigned long i;
|
|
|
|
/* Only proceed if we're connected to the server and not view-only */
|
|
if (vncConnected && !viewOnlyMode) {
|
|
clientCutTextStruct.length = GetScrapSize(textScrap);
|
|
|
|
if (clientCutTextStruct.length == 0)
|
|
return;
|
|
|
|
clientCutTextStruct.length = SwapBytes4(clientCutTextStruct.length);
|
|
|
|
scrapHandle = NewHandle(1, userid(), 0x0000, NULL);
|
|
GetScrap(scrapHandle, textScrap);
|
|
if (toolerror())
|
|
goto end; /* abort if error */
|
|
if (TCPIPWriteTCP(hostIpid, &clientCutTextStruct.messageType,
|
|
sizeof(clientCutTextStruct), FALSE, FALSE))
|
|
goto end; /* abort if error */
|
|
if (toolerror())
|
|
goto end;
|
|
|
|
clientCutTextStruct.length = SwapBytes4(clientCutTextStruct.length);
|
|
|
|
HLock(scrapHandle);
|
|
/* Convert cr->lf; Use pointer arithmetic so we can go over 64k */
|
|
for (i = 0; i < clientCutTextStruct.length; i++)
|
|
if (*((*(char **)scrapHandle)+i) == '\r')
|
|
*((*(char **)scrapHandle)+i) = '\n';
|
|
|
|
TCPIPWriteTCP(hostIpid, (Pointer) *scrapHandle,
|
|
clientCutTextStruct.length, TRUE, FALSE);
|
|
/* Can't handle errors usefully here */
|
|
HUnlock(scrapHandle);
|
|
|
|
end:
|
|
DisposeHandle(scrapHandle);
|
|
}
|
|
}
|
|
|