2016-05-14 00:35:41 +00:00
|
|
|
#if __ORCAC__
|
|
|
|
#pragma lint -1
|
2015-09-24 00:40:17 +00:00
|
|
|
#pragma noroot
|
2016-05-14 02:44:12 +00:00
|
|
|
segment "VNCview GS";
|
2016-05-14 00:35:41 +00:00
|
|
|
#endif
|
2015-09-24 00:40:17 +00:00
|
|
|
|
|
|
|
#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>
|
2016-05-14 00:35:41 +00:00
|
|
|
#include <orca.h>
|
2015-09-24 00:40:17 +00:00
|
|
|
|
|
|
|
#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) {
|
2015-09-24 01:26:03 +00:00
|
|
|
unsigned long textLen;
|
2015-09-24 00:40:17 +00:00
|
|
|
unsigned long i;
|
|
|
|
|
2015-09-24 01:26:03 +00:00
|
|
|
if (! DoWaitingReadTCP (3)) { /* Read & ignore padding */
|
|
|
|
DoClose(vncWindow);
|
2015-09-24 00:40:17 +00:00
|
|
|
return;
|
2015-09-24 01:56:33 +00:00
|
|
|
}
|
2015-09-24 01:26:03 +00:00
|
|
|
if (! DoWaitingReadTCP (4)) {
|
|
|
|
DoClose(vncWindow);
|
2015-09-24 00:40:17 +00:00
|
|
|
return;
|
2015-09-24 01:56:33 +00:00
|
|
|
}
|
2015-09-24 00:40:17 +00:00
|
|
|
textLen = SwapBytes4((unsigned long) **readBufferHndl);
|
|
|
|
|
|
|
|
if (! DoWaitingReadTCP(textLen)) {
|
2015-09-24 01:26:03 +00:00
|
|
|
DoClose(vncWindow);
|
2015-09-24 00:40:17 +00:00
|
|
|
return;
|
2015-09-24 01:56:33 +00:00
|
|
|
};
|
2015-09-24 01:26:03 +00:00
|
|
|
if (allowClipboardTransfers) {
|
2015-09-24 00:40:17 +00:00
|
|
|
ZeroScrap();
|
|
|
|
|
|
|
|
/* Convert lf->cr; Use pointer arithmetic so we can go over 64k */
|
|
|
|
for (i = 0; i < textLen; i++)
|
2015-09-24 01:26:03 +00:00
|
|
|
if (*((*(char **)readBufferHndl)+i) == '\n')
|
2015-09-24 00:40:17 +00:00
|
|
|
*((*(char **)readBufferHndl)+i) = '\r';
|
|
|
|
|
2015-09-24 01:26:03 +00:00
|
|
|
/* Below function call requires <scrap.h> to be fixed */
|
2015-09-24 00:40:17 +00:00
|
|
|
PutScrap(textLen, textScrap, (Pointer) *readBufferHndl);
|
|
|
|
/* Potential errors (e.g. out of memory) ignored */
|
2016-05-29 02:59:35 +00:00
|
|
|
DoneWithReadBuffer();
|
2015-09-24 00:40:17 +00:00
|
|
|
}
|
2015-09-24 01:56:33 +00:00
|
|
|
}
|
2015-09-24 01:26:03 +00:00
|
|
|
|
2015-09-24 00:40:17 +00:00
|
|
|
void DoSendClipboard (void) {
|
2015-09-24 01:26:03 +00:00
|
|
|
static struct clientCutText {
|
|
|
|
unsigned char messageType;
|
2015-09-24 00:40:17 +00:00
|
|
|
unsigned char padding1;
|
|
|
|
unsigned int padding2;
|
|
|
|
unsigned long length;
|
2015-09-24 01:56:33 +00:00
|
|
|
} clientCutTextStruct = { 6 /* Message type 6 */ };
|
2015-09-24 00:40:17 +00:00
|
|
|
|
|
|
|
Handle scrapHandle;
|
|
|
|
unsigned long i;
|
|
|
|
|
2015-09-24 01:26:03 +00:00
|
|
|
/* Only proceed if we're connected to the server and not view-only */
|
|
|
|
if (vncConnected && !viewOnlyMode) {
|
|
|
|
clientCutTextStruct.length = GetScrapSize(textScrap);
|
2015-09-24 00:40:17 +00:00
|
|
|
|
|
|
|
if (clientCutTextStruct.length == 0)
|
2015-09-24 01:26:03 +00:00
|
|
|
return;
|
|
|
|
|
2015-09-24 00:40:17 +00:00
|
|
|
clientCutTextStruct.length = SwapBytes4(clientCutTextStruct.length);
|
2015-09-24 01:26:03 +00:00
|
|
|
|
2015-09-24 00:40:17 +00:00
|
|
|
scrapHandle = NewHandle(1, userid(), 0x0000, NULL);
|
|
|
|
GetScrap(scrapHandle, textScrap);
|
|
|
|
if (toolerror())
|
2015-09-24 01:26:03 +00:00
|
|
|
goto end; /* abort if error */
|
|
|
|
if (TCPIPWriteTCP(hostIpid, &clientCutTextStruct.messageType,
|
|
|
|
sizeof(clientCutTextStruct), FALSE, FALSE))
|
|
|
|
goto end; /* abort if error */
|
2015-09-24 00:40:17 +00:00
|
|
|
if (toolerror())
|
2015-09-24 01:26:03 +00:00
|
|
|
goto end;
|
|
|
|
|
|
|
|
clientCutTextStruct.length = SwapBytes4(clientCutTextStruct.length);
|
2015-09-24 00:40:17 +00:00
|
|
|
|
|
|
|
HLock(scrapHandle);
|
|
|
|
/* Convert cr->lf; Use pointer arithmetic so we can go over 64k */
|
|
|
|
for (i = 0; i < clientCutTextStruct.length; i++)
|
2015-09-24 01:26:03 +00:00
|
|
|
if (*((*(char **)scrapHandle)+i) == '\r')
|
2015-09-24 00:40:17 +00:00
|
|
|
*((*(char **)scrapHandle)+i) = '\n';
|
|
|
|
|
2015-09-24 01:26:03 +00:00
|
|
|
TCPIPWriteTCP(hostIpid, (Pointer) *scrapHandle,
|
|
|
|
clientCutTextStruct.length, TRUE, FALSE);
|
2015-09-24 00:40:17 +00:00
|
|
|
/* Can't handle errors usefully here */
|
|
|
|
HUnlock(scrapHandle);
|
|
|
|
|
|
|
|
end:
|
|
|
|
DisposeHandle(scrapHandle);
|
|
|
|
}
|
2015-09-24 01:56:33 +00:00
|
|
|
}
|
2015-09-24 00:40:17 +00:00
|
|
|
|