Consistently use spaces for indentation

This commit is contained in:
Stephen Heumann 2015-09-23 20:26:03 -05:00
parent f44c7089d2
commit ab3210adb0
18 changed files with 1487 additions and 1487 deletions

View File

@ -32,15 +32,15 @@
/* Update the Scrap Manager clipboard with new data sent from server. /* Update the Scrap Manager clipboard with new data sent from server.
*/ */
void DoServerCutText (void) { void DoServerCutText (void) {
unsigned long textLen; unsigned long textLen;
unsigned long i; unsigned long i;
if (! DoWaitingReadTCP (3)) { /* Read & ignore padding */ if (! DoWaitingReadTCP (3)) { /* Read & ignore padding */
DoClose(vncWindow); DoClose(vncWindow);
return; return;
} }
if (! DoWaitingReadTCP (4)) { if (! DoWaitingReadTCP (4)) {
DoClose(vncWindow); DoClose(vncWindow);
return; return;
} }
HLock(readBufferHndl); HLock(readBufferHndl);
@ -48,65 +48,65 @@ void DoServerCutText (void) {
HUnlock(readBufferHndl); HUnlock(readBufferHndl);
if (! DoWaitingReadTCP(textLen)) { if (! DoWaitingReadTCP(textLen)) {
DoClose(vncWindow); DoClose(vncWindow);
return; return;
}; };
if (allowClipboardTransfers) { if (allowClipboardTransfers) {
ZeroScrap(); ZeroScrap();
HLock(readBufferHndl); HLock(readBufferHndl);
/* Convert lf->cr; Use pointer arithmetic so we can go over 64k */ /* Convert lf->cr; Use pointer arithmetic so we can go over 64k */
for (i = 0; i < textLen; i++) for (i = 0; i < textLen; i++)
if (*((*(char **)readBufferHndl)+i) == '\n') if (*((*(char **)readBufferHndl)+i) == '\n')
*((*(char **)readBufferHndl)+i) = '\r'; *((*(char **)readBufferHndl)+i) = '\r';
/* Below function call requires <scrap.h> to be fixed */ /* Below function call requires <scrap.h> to be fixed */
PutScrap(textLen, textScrap, (Pointer) *readBufferHndl); PutScrap(textLen, textScrap, (Pointer) *readBufferHndl);
/* Potential errors (e.g. out of memory) ignored */ /* Potential errors (e.g. out of memory) ignored */
HUnlock(readBufferHndl); HUnlock(readBufferHndl);
} }
} }
void DoSendClipboard (void) { void DoSendClipboard (void) {
static struct clientCutText { static struct clientCutText {
unsigned char messageType; unsigned char messageType;
unsigned char padding1; unsigned char padding1;
unsigned int padding2; unsigned int padding2;
unsigned long length; unsigned long length;
} clientCutTextStruct = { 6 /* Message type 6 */ }; } clientCutTextStruct = { 6 /* Message type 6 */ };
Handle scrapHandle; Handle scrapHandle;
unsigned long i; unsigned long i;
/* Only proceed if we're connected to the server and not view-only */ /* Only proceed if we're connected to the server and not view-only */
if (vncConnected && !viewOnlyMode) { if (vncConnected && !viewOnlyMode) {
clientCutTextStruct.length = GetScrapSize(textScrap); clientCutTextStruct.length = GetScrapSize(textScrap);
if (clientCutTextStruct.length == 0) if (clientCutTextStruct.length == 0)
return; return;
clientCutTextStruct.length = SwapBytes4(clientCutTextStruct.length); clientCutTextStruct.length = SwapBytes4(clientCutTextStruct.length);
scrapHandle = NewHandle(1, userid(), 0x0000, NULL); scrapHandle = NewHandle(1, userid(), 0x0000, NULL);
GetScrap(scrapHandle, textScrap); GetScrap(scrapHandle, textScrap);
if (toolerror()) if (toolerror())
goto end; /* abort if error */ goto end; /* abort if error */
if (TCPIPWriteTCP(hostIpid, &clientCutTextStruct.messageType, if (TCPIPWriteTCP(hostIpid, &clientCutTextStruct.messageType,
sizeof(clientCutTextStruct), FALSE, FALSE)) sizeof(clientCutTextStruct), FALSE, FALSE))
goto end; /* abort if error */ goto end; /* abort if error */
if (toolerror()) if (toolerror())
goto end; goto end;
clientCutTextStruct.length = SwapBytes4(clientCutTextStruct.length); clientCutTextStruct.length = SwapBytes4(clientCutTextStruct.length);
HLock(scrapHandle); HLock(scrapHandle);
/* Convert cr->lf; Use pointer arithmetic so we can go over 64k */ /* Convert cr->lf; Use pointer arithmetic so we can go over 64k */
for (i = 0; i < clientCutTextStruct.length; i++) for (i = 0; i < clientCutTextStruct.length; i++)
if (*((*(char **)scrapHandle)+i) == '\r') if (*((*(char **)scrapHandle)+i) == '\r')
*((*(char **)scrapHandle)+i) = '\n'; *((*(char **)scrapHandle)+i) = '\n';
TCPIPWriteTCP(hostIpid, (Pointer) *scrapHandle, TCPIPWriteTCP(hostIpid, (Pointer) *scrapHandle,
clientCutTextStruct.length, TRUE, FALSE); clientCutTextStruct.length, TRUE, FALSE);
/* Can't handle errors usefully here */ /* Can't handle errors usefully here */
HUnlock(scrapHandle); HUnlock(scrapHandle);

View File

@ -98,8 +98,8 @@ BOOLEAN MakeBigColorTables (unsigned int iters)
{ {
static unsigned int i = 0; static unsigned int i = 0;
unsigned int iMax = i + iters; unsigned int iMax = i + iters;
if (iMax < i) /* Deal with wraparound */ if (iMax < i) /* Deal with wraparound */
iMax = 0; iMax = 0;
/* The addressing scheme here depends on the IIgs's little-endianness */ /* The addressing scheme here depends on the IIgs's little-endianness */
do { do {
@ -110,9 +110,9 @@ BOOLEAN MakeBigColorTables (unsigned int iters)
} while (i != iMax); } while (i != iMax);
if (iMax == 0) if (iMax == 0)
return TRUE; /* Done */ return TRUE; /* Done */
else else
return FALSE; /* In progress */ return FALSE; /* In progress */
} }
#if 0 #if 0

View File

@ -31,21 +31,21 @@
void DoCopyRect (void) { void DoCopyRect (void) {
/* For use with GetContentOrigin() */ /* For use with GetContentOrigin() */
unsigned long contentOrigin; unsigned long contentOrigin;
Point * contentOriginPtr = (void *) &contentOrigin; Point * contentOriginPtr = (void *) &contentOrigin;
Rect srcRect; Rect srcRect;
unsigned int *dataPtr; /* Pointer to TCP data that was read */ unsigned int *dataPtr; /* Pointer to TCP data that was read */
//printf("Processing CopyRect rectangle\n"); //printf("Processing CopyRect rectangle\n");
if (! DoReadTCP ((unsigned long) 4)) if (! DoReadTCP ((unsigned long) 4))
return; /* Not ready yet; wait */ return; /* Not ready yet; wait */
contentOrigin = GetContentOrigin(vncWindow); contentOrigin = GetContentOrigin(vncWindow);
HLock(readBufferHndl); HLock(readBufferHndl);
dataPtr = (unsigned int *) ((char *) (*readBufferHndl)); dataPtr = (unsigned int *) ((char *) (*readBufferHndl));
srcRect.h1 = SwapBytes2(dataPtr[0]) - contentOriginPtr->h; srcRect.h1 = SwapBytes2(dataPtr[0]) - contentOriginPtr->h;
srcRect.v1 = SwapBytes2(dataPtr[1]) - contentOriginPtr->v; srcRect.v1 = SwapBytes2(dataPtr[1]) - contentOriginPtr->v;
HUnlock(readBufferHndl); HUnlock(readBufferHndl);
@ -57,7 +57,7 @@ void DoCopyRect (void) {
to send the update using some other encoding. to send the update using some other encoding.
*/ */
if (!RectInRgn(&srcRect, GetVisHandle())) { if (!RectInRgn(&srcRect, GetVisHandle())) {
SendFBUpdateRequest(FALSE, rectX, rectY, rectWidth, rectHeight); SendFBUpdateRequest(FALSE, rectX, rectY, rectWidth, rectHeight);
displayInProgress = FALSE; displayInProgress = FALSE;
return; return;
} }
@ -65,11 +65,11 @@ void DoCopyRect (void) {
/* We can use the window pointer as a LocInfo pointer because it starts /* We can use the window pointer as a LocInfo pointer because it starts
* with a grafPort structure, which in turn starts with a LocInfo structure. * with a grafPort structure, which in turn starts with a LocInfo structure.
*/ */
PPToPort((struct LocInfo *) vncWindow, &srcRect, PPToPort((struct LocInfo *) vncWindow, &srcRect,
rectX - contentOriginPtr->h, rectY - contentOriginPtr->v, modeCopy); rectX - contentOriginPtr->h, rectY - contentOriginPtr->v, modeCopy);
displayInProgress = FALSE; displayInProgress = FALSE;
NextRect(); /* Prepare for next rect */ NextRect(); /* Prepare for next rect */
} }

View File

@ -33,9 +33,9 @@
extern pascal void SetContentOrigin2(Word, Word, Word, GrafPortPtr) inline(0x570E,dispatcher); extern pascal void SetContentOrigin2(Word, Word, Word, GrafPortPtr) inline(0x570E,dispatcher);
void DoDesktopSize (void) { void DoDesktopSize (void) {
#define screenTooBigError 2010 #define screenTooBigError 2010
unsigned long contentOrigin; unsigned long contentOrigin;
Point * contentOriginPtr = (void *) &contentOrigin; Point * contentOriginPtr = (void *) &contentOrigin;
unsigned int newX, newY; unsigned int newX, newY;
Boolean changeOrigin = FALSE; Boolean changeOrigin = FALSE;
unsigned int oldWinHeight, oldWinWidth; unsigned int oldWinHeight, oldWinWidth;
@ -45,7 +45,7 @@ void DoDesktopSize (void) {
if ((fbWidth > 16384) || (fbHeight > 16384)) { if ((fbWidth > 16384) || (fbHeight > 16384)) {
AlertWindow(awResource, NULL, screenTooBigError); AlertWindow(awResource, NULL, screenTooBigError);
DoClose(vncWindow); DoClose(vncWindow);
} }
oldWinHeight = winHeight; oldWinHeight = winHeight;
@ -53,11 +53,11 @@ void DoDesktopSize (void) {
winHeight = 174; winHeight = 174;
winWidth = (hRez == 640) ? 613 : 302; winWidth = (hRez == 640) ? 613 : 302;
if (fbWidth < winWidth) if (fbWidth < winWidth)
winWidth = fbWidth; winWidth = fbWidth;
if (fbHeight < winHeight) if (fbHeight < winHeight)
winHeight = fbHeight; winHeight = fbHeight;
if (oldWinHeight != winHeight || oldWinWidth != winWidth) if (oldWinHeight != winHeight || oldWinWidth != winWidth)
SizeWindow(winWidth, winHeight, vncWindow); SizeWindow(winWidth, winHeight, vncWindow);
/* Scroll if area displayed is going away */ /* Scroll if area displayed is going away */
contentOrigin = GetContentOrigin(vncWindow); contentOrigin = GetContentOrigin(vncWindow);
@ -65,11 +65,11 @@ void DoDesktopSize (void) {
newY = contentOriginPtr->v; newY = contentOriginPtr->v;
if (contentOriginPtr->h + winWidth > fbWidth) { if (contentOriginPtr->h + winWidth > fbWidth) {
newX = fbWidth - winWidth; newX = fbWidth - winWidth;
changeOrigin = TRUE; changeOrigin = TRUE;
} }
if (contentOriginPtr->v + winHeight > fbHeight) { if (contentOriginPtr->v + winHeight > fbHeight) {
newY = fbHeight - winHeight; newY = fbHeight - winHeight;
changeOrigin = TRUE; changeOrigin = TRUE;
} }
SetContentOrigin2(1, newX, newY, vncWindow); SetContentOrigin2(1, newX, newY, vncWindow);
@ -79,6 +79,6 @@ void DoDesktopSize (void) {
displayInProgress = FALSE; displayInProgress = FALSE;
NextRect(); /* Prepare for next rect */ NextRect(); /* Prepare for next rect */
} }

View File

@ -29,7 +29,7 @@
#include "raw.h" #include "raw.h"
#include "hextile.h" #include "hextile.h"
unsigned int hexXTiles, hexYTiles; /* For in-process hextile processing */ unsigned int hexXTiles, hexYTiles; /* For in-process hextile processing */
unsigned int hexXTileNum, hexYTileNum; unsigned int hexXTileNum, hexYTileNum;
unsigned int hexTileWidth, hexTileHeight; unsigned int hexTileWidth, hexTileHeight;
unsigned char hexBackground, hexForeground; unsigned char hexBackground, hexForeground;
@ -37,40 +37,40 @@ unsigned char hexBackground, hexForeground;
static BOOLEAN extraByteAdvance; static BOOLEAN extraByteAdvance;
/* Used in Hextile encoding */ /* Used in Hextile encoding */
#define Raw 0x01 #define Raw 0x01
#define BackgroundSpecified 0x02 #define BackgroundSpecified 0x02
#define ForegroundSpecified 0x04 #define ForegroundSpecified 0x04
#define AnySubrects 0x08 #define AnySubrects 0x08
#define SubrectsColoured 0x10 #define SubrectsColoured 0x10
#define hexWaitingForSubencoding 1 #define hexWaitingForSubencoding 1
#define hexWaitingForMoreInfo 2 #define hexWaitingForMoreInfo 2
#define hexWaitingForSubrect 4 #define hexWaitingForSubrect 4
#define hexWaitingForRawData 8 #define hexWaitingForRawData 8
void HexNextTile (void) { void HexNextTile (void) {
hexXTileNum++; hexXTileNum++;
if (hexXTileNum == hexXTiles) { if (hexXTileNum == hexXTiles) {
hexYTileNum++; hexYTileNum++;
if (hexYTileNum == hexYTiles) { /* Done with this Hextile rect */ if (hexYTileNum == hexYTiles) { /* Done with this Hextile rect */
displayInProgress = FALSE; displayInProgress = FALSE;
NextRect(); NextRect();
return; return;
} }
hexXTileNum = 0; hexXTileNum = 0;
} }
hexTileWidth = (hexXTileNum == hexXTiles - 1) ? hexTileWidth = (hexXTileNum == hexXTiles - 1) ?
rectWidth - 16 * (hexXTiles - 1) : 16; rectWidth - 16 * (hexXTiles - 1) : 16;
hexTileHeight = (hexYTileNum == hexYTiles - 1) ? hexTileHeight = (hexYTileNum == hexYTiles - 1) ?
rectHeight - 16 * (hexYTiles - 1) : 16; rectHeight - 16 * (hexYTiles - 1) : 16;
} }
void HexRawDraw (Point *contentOriginPtr, int rectWidth, int rectHeight) { void HexRawDraw (Point *contentOriginPtr, int rectWidth, int rectHeight) {
unsigned int i, j; /* Loop indices */ unsigned int i, j; /* Loop indices */
unsigned int n = 0; unsigned int n = 0;
unsigned char *dataPtr; unsigned char *dataPtr;
unsigned char pixels[128]; unsigned char pixels[128];
static Rect srcRect = {0,0,0,0}; static Rect srcRect = {0,0,0,0};
@ -83,53 +83,53 @@ void HexRawDraw (Point *contentOriginPtr, int rectWidth, int rectHeight) {
extraByteAdvance = FALSE; extraByteAdvance = FALSE;
for (j = 0; j < rectHeight; j++) { for (j = 0; j < rectHeight; j++) {
for (i = 0; i < rectWidth; i++) { for (i = 0; i < rectWidth; i++) {
if (hRez == 640) { if (hRez == 640) {
switch (i & 0x03) { switch (i & 0x03) {
case 0x00: /* pixels 0, 4, 8, ... */ case 0x00: /* pixels 0, 4, 8, ... */
pixels[n] = pixTransTbl[ *(dataPtr + pixels[n] = pixTransTbl[ *(dataPtr +
(unsigned long) j*rectWidth + i) (unsigned long) j*rectWidth + i)
] & 0xC0; ] & 0xC0;
break; break;
case 0x01: /* pixels 1, 5, 9, ... */ case 0x01: /* pixels 1, 5, 9, ... */
pixels[n] += pixTransTbl[ *(dataPtr + pixels[n] += pixTransTbl[ *(dataPtr +
(unsigned long) j*rectWidth + i) (unsigned long) j*rectWidth + i)
] & 0x30; ] & 0x30;
break; break;
case 0x02: /* pixels 2, 6, 10, ... */ case 0x02: /* pixels 2, 6, 10, ... */
pixels[n] += pixTransTbl[ *(dataPtr + pixels[n] += pixTransTbl[ *(dataPtr +
(unsigned long) j*rectWidth + i) (unsigned long) j*rectWidth + i)
] & 0x0C; ] & 0x0C;
break; break;
case 0x03: /* pixels 3, 7, 11, ... */ case 0x03: /* pixels 3, 7, 11, ... */
pixels[n] += pixTransTbl[ *(dataPtr + pixels[n] += pixTransTbl[ *(dataPtr +
(unsigned long) j*rectWidth + i) (unsigned long) j*rectWidth + i)
] & 0x03; ] & 0x03;
n++; n++;
} /* switch */ } /* switch */
} /* if */ } /* if */
else { /* 320 mode */ else { /* 320 mode */
switch(i & 0x01) { switch(i & 0x01) {
case 0x00: /* pixels 0, 2, 4, ... */ case 0x00: /* pixels 0, 2, 4, ... */
pixels[n] = pixTransTbl[ *(dataPtr + pixels[n] = pixTransTbl[ *(dataPtr +
(unsigned long) j*rectWidth + i) (unsigned long) j*rectWidth + i)
] & 0xF0; ] & 0xF0;
break; break;
case 0x01: /* pixels 1, 3, 5, ... */ case 0x01: /* pixels 1, 3, 5, ... */
pixels[n] += pixTransTbl[ *(dataPtr + pixels[n] += pixTransTbl[ *(dataPtr +
(unsigned long) j*rectWidth + i) (unsigned long) j*rectWidth + i)
] & 0x0F; ] & 0x0F;
n++; n++;
} /* switch */ } /* switch */
} /* else */ } /* else */
} /* i loop */ } /* i loop */
/* When not ending a line on a byte boundary, the index isn't updated, /* When not ending a line on a byte boundary, the index isn't updated,
* so we do it here. * so we do it here.
*/ */
if (extraByteAdvance) if (extraByteAdvance)
n++; n++;
} /* j loop */ } /* j loop */
srcLocInfo.ptrToPixImage = (void *) pixels; srcLocInfo.ptrToPixImage = (void *) pixels;
srcLocInfo.boundsRect.v2 = rectHeight; srcLocInfo.boundsRect.v2 = rectHeight;
@ -137,65 +137,65 @@ void HexRawDraw (Point *contentOriginPtr, int rectWidth, int rectHeight) {
* padding must be accounted for here. * padding must be accounted for here.
*/ */
if (hRez == 640) { if (hRez == 640) {
switch (rectWidth & 0x03) { switch (rectWidth & 0x03) {
case 0x00: srcLocInfo.boundsRect.h2 = rectWidth; case 0x00: srcLocInfo.boundsRect.h2 = rectWidth;
srcLocInfo.width = rectWidth/4; break; srcLocInfo.width = rectWidth/4; break;
case 0x01: srcLocInfo.boundsRect.h2 = rectWidth+3; case 0x01: srcLocInfo.boundsRect.h2 = rectWidth+3;
srcLocInfo.width = rectWidth/4 + 1; break; srcLocInfo.width = rectWidth/4 + 1; break;
case 0x02: srcLocInfo.boundsRect.h2 = rectWidth+2; case 0x02: srcLocInfo.boundsRect.h2 = rectWidth+2;
srcLocInfo.width = rectWidth/4 + 1; break; srcLocInfo.width = rectWidth/4 + 1; break;
case 0x03: srcLocInfo.boundsRect.h2 = rectWidth+1; case 0x03: srcLocInfo.boundsRect.h2 = rectWidth+1;
srcLocInfo.width = rectWidth/4 + 1; srcLocInfo.width = rectWidth/4 + 1;
} }
} }
else { /* hRez == 320 */ else { /* hRez == 320 */
switch (rectWidth & 0x01) { switch (rectWidth & 0x01) {
case 0x00: srcLocInfo.boundsRect.h2 = rectWidth; case 0x00: srcLocInfo.boundsRect.h2 = rectWidth;
srcLocInfo.width = rectWidth/2; break; srcLocInfo.width = rectWidth/2; break;
case 0x01: srcLocInfo.boundsRect.h2 = rectWidth+1; case 0x01: srcLocInfo.boundsRect.h2 = rectWidth+1;
srcLocInfo.width = rectWidth/2 + 1; srcLocInfo.width = rectWidth/2 + 1;
} }
} }
srcRect.v2 = hexTileHeight; srcRect.v2 = hexTileHeight;
srcRect.h2 = hexTileWidth; srcRect.h2 = hexTileWidth;
PPToPort(&srcLocInfo, &srcRect, PPToPort(&srcLocInfo, &srcRect,
rectX + hexXTileNum * 16 - contentOriginPtr->h, rectX + hexXTileNum * 16 - contentOriginPtr->h,
rectY + hexYTileNum * 16 - contentOriginPtr->v, modeCopy); rectY + hexYTileNum * 16 - contentOriginPtr->v, modeCopy);
} }
/* The macros below are used in HexDispatch() */ /* The macros below are used in HexDispatch() */
#define HexDispatch_NextTile() do { \ #define HexDispatch_NextTile() do { \
HexNextTile(); \ HexNextTile(); \
HUnlock(readBufferHndl); \ HUnlock(readBufferHndl); \
/* Set up for next time */ \ /* Set up for next time */ \
status = hexWaitingForSubencoding; \ status = hexWaitingForSubencoding; \
bytesNeeded = 1; \ bytesNeeded = 1; \
return; \ return; \
} while (0) } while (0)
#define HexDispatch_DrawRect(color, X, Y, width, height) do { \ #define HexDispatch_DrawRect(color, X, Y, width, height) do { \
SetSolidPenPat((color)); \ SetSolidPenPat((color)); \
drawingRect.h1 = rectX + hexXTileNum * 16 + (X) - contentOriginPtr->h; \ drawingRect.h1 = rectX + hexXTileNum * 16 + (X) - contentOriginPtr->h; \
drawingRect.v1 = rectY + hexYTileNum * 16 + (Y) - contentOriginPtr->v; \ drawingRect.v1 = rectY + hexYTileNum * 16 + (Y) - contentOriginPtr->v; \
drawingRect.h2 = rectX + hexXTileNum * 16 + (X) + (width) - contentOriginPtr->h; \ drawingRect.h2 = rectX + hexXTileNum * 16 + (X) + (width) - contentOriginPtr->h; \
drawingRect.v2 = rectY + hexYTileNum * 16 + (Y) + (height) - contentOriginPtr->v; \ drawingRect.v2 = rectY + hexYTileNum * 16 + (Y) + (height) - contentOriginPtr->v; \
PaintRect(&drawingRect); \ PaintRect(&drawingRect); \
} while (0) } while (0)
#define HexDispatch_DrawBackground() \ #define HexDispatch_DrawBackground() \
HexDispatch_DrawRect(hexBackground, 0, 0, hexTileWidth, hexTileHeight) HexDispatch_DrawRect(hexBackground, 0, 0, hexTileWidth, hexTileHeight)
void HexDispatch (void) { void HexDispatch (void) {
static unsigned char status = hexWaitingForSubencoding; static unsigned char status = hexWaitingForSubencoding;
static unsigned long bytesNeeded = 1; static unsigned long bytesNeeded = 1;
static unsigned char subencoding; static unsigned char subencoding;
static unsigned int numSubrects; static unsigned int numSubrects;
int i; int i;
/* For use with GetContentOrigin() */ /* For use with GetContentOrigin() */
unsigned long contentOrigin; unsigned long contentOrigin;
Point * contentOriginPtr = (void *) &contentOrigin; Point * contentOriginPtr = (void *) &contentOrigin;
int tileBytes; int tileBytes;
unsigned int srX, srY, srWidth, srHeight; unsigned int srX, srY, srWidth, srHeight;
Rect drawingRect; Rect drawingRect;
@ -209,93 +209,93 @@ void HexDispatch (void) {
while (DoReadTCP(bytesNeeded)) { while (DoReadTCP(bytesNeeded)) {
HLock(readBufferHndl); HLock(readBufferHndl);
dataPtr = *(unsigned char **) readBufferHndl; dataPtr = *(unsigned char **) readBufferHndl;
/* If we're here, readBufferHndl contains bytesNeeded bytes of data. */ /* If we're here, readBufferHndl contains bytesNeeded bytes of data. */
switch (status) { switch (status) {
case hexWaitingForSubencoding: case hexWaitingForSubencoding:
subencoding = *dataPtr; subencoding = *dataPtr;
if (subencoding & Raw) { if (subencoding & Raw) {
bytesNeeded = hexTileWidth * hexTileHeight; bytesNeeded = hexTileWidth * hexTileHeight;
status = hexWaitingForRawData; status = hexWaitingForRawData;
} }
else { else {
bytesNeeded = 0; bytesNeeded = 0;
if (subencoding & BackgroundSpecified) if (subencoding & BackgroundSpecified)
bytesNeeded++; bytesNeeded++;
if (subencoding & ForegroundSpecified) if (subencoding & ForegroundSpecified)
bytesNeeded++; bytesNeeded++;
if (subencoding & AnySubrects) if (subencoding & AnySubrects)
bytesNeeded++; bytesNeeded++;
else if (bytesNeeded == 0) { else if (bytesNeeded == 0) {
/* No more data - just draw background */ /* No more data - just draw background */
HexDispatch_DrawBackground(); HexDispatch_DrawBackground();
HexDispatch_NextTile(); HexDispatch_NextTile();
} }
status = hexWaitingForMoreInfo; status = hexWaitingForMoreInfo;
} }
break; break;
case hexWaitingForRawData: case hexWaitingForRawData:
HexRawDraw(contentOriginPtr, hexTileWidth, hexTileHeight); HexRawDraw(contentOriginPtr, hexTileWidth, hexTileHeight);
HexDispatch_NextTile(); HexDispatch_NextTile();
break; break;
case hexWaitingForMoreInfo: case hexWaitingForMoreInfo:
if (subencoding & BackgroundSpecified) { if (subencoding & BackgroundSpecified) {
hexBackground = pixTransTbl[*(dataPtr++)]; hexBackground = pixTransTbl[*(dataPtr++)];
} }
if (subencoding & ForegroundSpecified) { if (subencoding & ForegroundSpecified) {
hexForeground = pixTransTbl[*(dataPtr++)]; hexForeground = pixTransTbl[*(dataPtr++)];
} }
if (subencoding & AnySubrects) { if (subencoding & AnySubrects) {
numSubrects = *dataPtr; numSubrects = *dataPtr;
if (numSubrects) { if (numSubrects) {
status = hexWaitingForSubrect; status = hexWaitingForSubrect;
bytesNeeded = numSubrects * ((subencoding & SubrectsColoured) ? 3 : 2); bytesNeeded = numSubrects * ((subencoding & SubrectsColoured) ? 3 : 2);
break; break;
} }
else else
HexDispatch_NextTile(); HexDispatch_NextTile();
} }
else { /* no subrects */ else { /* no subrects */
HexDispatch_DrawBackground(); HexDispatch_DrawBackground();
HexDispatch_NextTile(); HexDispatch_NextTile();
} }
case hexWaitingForSubrect: { case hexWaitingForSubrect: {
HexDispatch_DrawBackground(); HexDispatch_DrawBackground();
while (numSubrects-- > 0) { while (numSubrects-- > 0) {
if (subencoding & SubrectsColoured) { if (subencoding & SubrectsColoured) {
hexForeground = pixTransTbl[*(dataPtr++)]; hexForeground = pixTransTbl[*(dataPtr++)];
} }
srX = *dataPtr >> 4; srX = *dataPtr >> 4;
srY = *(dataPtr++) & 0x0F; srY = *(dataPtr++) & 0x0F;
srWidth = (*dataPtr >> 4) + 1; srWidth = (*dataPtr >> 4) + 1;
srHeight = (*(dataPtr++) & 0x0F) + 1; srHeight = (*(dataPtr++) & 0x0F) + 1;
HexDispatch_DrawRect(hexForeground, srX, srY, srWidth, srHeight); HexDispatch_DrawRect(hexForeground, srX, srY, srWidth, srHeight);
} }
HexDispatch_NextTile(); HexDispatch_NextTile();
} }
} }
HUnlock(readBufferHndl); HUnlock(readBufferHndl);
} }
} }
/* Called when we initially get a Hextile rect; set up to process it */ /* Called when we initially get a Hextile rect; set up to process it */
void DoHextileRect (void) { void DoHextileRect (void) {
hexXTiles = (rectWidth + 15) / 16; hexXTiles = (rectWidth + 15) / 16;
hexYTiles = (rectHeight + 15) / 16; hexYTiles = (rectHeight + 15) / 16;
hexXTileNum = 0; hexXTileNum = 0;
hexYTileNum = 0; hexYTileNum = 0;
displayInProgress = TRUE; displayInProgress = TRUE;
hexTileWidth = (hexYTileNum == hexXTiles - 1) ? hexTileWidth = (hexYTileNum == hexXTiles - 1) ?
rectWidth - 16 * (hexXTiles - 1) : 16; rectWidth - 16 * (hexXTiles - 1) : 16;
hexTileHeight = (hexYTileNum == hexYTiles - 1) ? hexTileHeight = (hexYTileNum == hexYTiles - 1) ?
rectHeight - 16 * (hexYTiles - 1) : 16; rectHeight - 16 * (hexYTiles - 1) : 16;
/* Set up for Hextile drawing */ /* Set up for Hextile drawing */
srcRect.v1 = 0; srcRect.v1 = 0;
srcRect.h1 = 0; srcRect.h1 = 0;
} }

View File

@ -33,36 +33,36 @@
*/ */
void SendKeyEvent (BOOLEAN keyDownFlag, unsigned long key) void SendKeyEvent (BOOLEAN keyDownFlag, unsigned long key)
{ {
struct KeyEvent { struct KeyEvent {
unsigned char messageType; unsigned char messageType;
unsigned char keyDownFlag; unsigned char keyDownFlag;
unsigned int padding; unsigned int padding;
unsigned long key; unsigned long key;
} keyEvent = { 4 /* Message Type 4 */, } keyEvent = { 4 /* Message Type 4 */,
0, 0,
0 /* Zero the padding */ 0 /* Zero the padding */
}; };
keyEvent.keyDownFlag = !!keyDownFlag; keyEvent.keyDownFlag = !!keyDownFlag;
keyEvent.key = SwapBytes4(key); keyEvent.key = SwapBytes4(key);
TCPIPWriteTCP(hostIpid, &keyEvent.messageType, sizeof(keyEvent), TCPIPWriteTCP(hostIpid, &keyEvent.messageType, sizeof(keyEvent),
TRUE, FALSE); TRUE, FALSE);
/* No error checking here -- Can't respond to one usefully. */ /* No error checking here -- Can't respond to one usefully. */
} }
/* Process a key down event and send it on to the server. */ /* Process a key down event and send it on to the server. */
void ProcessKeyEvent (void) void ProcessKeyEvent (void)
{ {
unsigned long key = myEvent.message & 0x0000007F; unsigned long key = myEvent.message & 0x0000007F;
if (viewOnlyMode) if (viewOnlyMode)
return; return;
/* Deal with extended keys that are mapped as keypad keys */ /* Deal with extended keys that are mapped as keypad keys */
if (myEvent.modifiers & keyPad) { if (myEvent.modifiers & keyPad) {
switch (key) { switch (key) {
case 0x7A: key = 0xFFBE; break; /* F1 */ case 0x7A: key = 0xFFBE; break; /* F1 */
case 0x78: key = 0xFFBF; break; /* F2 */ case 0x78: key = 0xFFBF; break; /* F2 */
case 0x63: key = 0xFFC0; break; /* F3 */ case 0x63: key = 0xFFC0; break; /* F3 */
case 0x76: key = 0xFFC1; break; /* F4 */ case 0x76: key = 0xFFC1; break; /* F4 */
@ -74,7 +74,7 @@ void ProcessKeyEvent (void)
case 0x6D: key = 0xFFC7; break; /* F10 */ case 0x6D: key = 0xFFC7; break; /* F10 */
case 0x67: key = 0xFFC8; break; /* F11 */ case 0x67: key = 0xFFC8; break; /* F11 */
case 0x6F: key = 0xFFC9; break; /* F12 */ case 0x6F: key = 0xFFC9; break; /* F12 */
case 0x69: key = 0xFF15; break; /* F13 / PrintScr -> SysRq */ case 0x69: key = 0xFF15; break; /* F13 / PrintScr -> SysRq */
case 0x6B: key = 0xFF14; break; /* F14 / ScrLock -> ScrLock */ case 0x6B: key = 0xFF14; break; /* F14 / ScrLock -> ScrLock */
case 0x71: key = 0xFF13; break; /* F15 / Pause -> Pause */ case 0x71: key = 0xFF13; break; /* F15 / Pause -> Pause */
case 0x72: key = 0xFF63; break; /* Help / Insert -> Insert */ case 0x72: key = 0xFF63; break; /* Help / Insert -> Insert */
@ -83,32 +83,32 @@ void ProcessKeyEvent (void)
case 0x77: key = 0xFF57; break; /* End */ case 0x77: key = 0xFF57; break; /* End */
case 0x74: key = 0xFF55; break; /* Page Up */ case 0x74: key = 0xFF55; break; /* Page Up */
case 0x79: key = 0xFF56; break; /* Page Down */ case 0x79: key = 0xFF56; break; /* Page Down */
} }
} }
if (key == 0x7f) if (key == 0x7f)
key = 0xFF08; /* Delete -> BackSpace */ key = 0xFF08; /* Delete -> BackSpace */
if (key < 0x20) { if (key < 0x20) {
if (myEvent.modifiers & controlKey) { if (myEvent.modifiers & controlKey) {
if (((myEvent.modifiers & shiftKey) || if (((myEvent.modifiers & shiftKey) ||
(myEvent.modifiers & capsLock)) (myEvent.modifiers & capsLock))
&& !((myEvent.modifiers & shiftKey) && && !((myEvent.modifiers & shiftKey) &&
(myEvent.modifiers & capsLock))) (myEvent.modifiers & capsLock)))
key += 0x40; /* Undo effect of control on upper-case char. */ key += 0x40; /* Undo effect of control on upper-case char. */
else else
key += 0x60; /* Undo effect of control */ key += 0x60; /* Undo effect of control */
} }
else switch (key) { else switch (key) {
case 0x1B: key = 0xFF1B; break; /* Escape */ case 0x1B: key = 0xFF1B; break; /* Escape */
case 0x09: key = 0xFF09; break; /* Tab */ case 0x09: key = 0xFF09; break; /* Tab */
case 0x0D: key = 0xFF0D; break; /* Return / Enter */ case 0x0D: key = 0xFF0D; break; /* Return / Enter */
case 0x08: key = 0xFF51; break; /* Left arrow */ case 0x08: key = 0xFF51; break; /* Left arrow */
case 0x0B: key = 0xFF52; break; /* Up arrow */ case 0x0B: key = 0xFF52; break; /* Up arrow */
case 0x15: key = 0xFF53; break; /* Right arrow */ case 0x15: key = 0xFF53; break; /* Right arrow */
case 0x0A: key = 0xFF54; break; /* Down arrow */ case 0x0A: key = 0xFF54; break; /* Down arrow */
case 0x18: key = 0xFF0B; break; /* Clear / NumLock -> Clear */ case 0x18: key = 0xFF0B; break; /* Clear / NumLock -> Clear */
} }
} }
/* Test if we seem to have a valid character and return if we don't. /* Test if we seem to have a valid character and return if we don't.
@ -117,7 +117,7 @@ void ProcessKeyEvent (void)
if we ever start generating valid keycodes outside of these ranges. if we ever start generating valid keycodes outside of these ranges.
*/ */
if ((key & 0xFF80) != 0xFF00 && (key & 0xFF80) != 0x0000) if ((key & 0xFF80) != 0xFF00 && (key & 0xFF80) != 0x0000)
return; return;
SendKeyEvent(TRUE, key); SendKeyEvent(TRUE, key);
SendKeyEvent(FALSE, key); SendKeyEvent(FALSE, key);
@ -125,28 +125,28 @@ void ProcessKeyEvent (void)
/* Send modifier keys that have changed since last update */ /* Send modifier keys that have changed since last update */
void SendModifiers (void) { void SendModifiers (void) {
static unsigned int oldModifiers = 0x00FF; /* So it runs 1st time */ static unsigned int oldModifiers = 0x00FF; /* So it runs 1st time */
unsigned int modifiers; unsigned int modifiers;
modifiers = myEvent.modifiers & 0x1B00; modifiers = myEvent.modifiers & 0x1B00;
/* If unchanged, do nothing. */ /* If unchanged, do nothing. */
if (modifiers == oldModifiers) if (modifiers == oldModifiers)
return; return;
/* Apple key is sent as "meta" */ /* Apple key is sent as "meta" */
if ((modifiers & appleKey) != (oldModifiers & appleKey)) if ((modifiers & appleKey) != (oldModifiers & appleKey))
SendKeyEvent(modifiers & appleKey, 0xFFE7); SendKeyEvent(modifiers & appleKey, 0xFFE7);
if ((modifiers & shiftKey) != (oldModifiers & shiftKey)) if ((modifiers & shiftKey) != (oldModifiers & shiftKey))
SendKeyEvent(modifiers & shiftKey, 0xFFE1); SendKeyEvent(modifiers & shiftKey, 0xFFE1);
/* Option key is sent as "alt," as per its labelling on some keyboards */ /* Option key is sent as "alt," as per its labelling on some keyboards */
if ((modifiers & optionKey) != (oldModifiers & optionKey)) if ((modifiers & optionKey) != (oldModifiers & optionKey))
SendKeyEvent(modifiers & optionKey, 0xFFE9); SendKeyEvent(modifiers & optionKey, 0xFFE9);
if ((modifiers & controlKey) != (oldModifiers & controlKey)) if ((modifiers & controlKey) != (oldModifiers & controlKey))
SendKeyEvent(modifiers & controlKey, 0xFFE3); SendKeyEvent(modifiers & controlKey, 0xFFE3);
oldModifiers = modifiers; oldModifiers = modifiers;
} }

24
make
View File

@ -7,21 +7,21 @@ clearmem
for {header} in vncview vncsession vncdisplay colortables menus \ for {header} in vncview vncsession vncdisplay colortables menus \
desktopsize mouse keyboard copyrect raw hextile clipboard desktopsize mouse keyboard copyrect raw hextile clipboard
unset exit unset exit
newer VNCview.GS {header}.h newer VNCview.GS {header}.h
if {status} != 0 if {status} != 0
set exit on set exit on
delete -P -W =.a delete -P -W =.a
end end
end end
for file in vncview vncsession vncdisplay colortables \ for file in vncview vncsession vncdisplay colortables \
desktopsize mouse keyboard copyrect raw hextile clipboard desktopsize mouse keyboard copyrect raw hextile clipboard
unset exit unset exit
newer {file}.a {file}.cc newer {file}.a {file}.cc
if {status} != 0 if {status} != 0
set exit on set exit on
compile +O {file}.cc keep={file} compile +O {file}.cc keep={file}
set link true set link true
end end
end end
@ -29,14 +29,14 @@ end
unset exit unset exit
newer vncview.rezfork vncview.rez newer vncview.rezfork vncview.rez
if {status} != 0 if {status} != 0
set exit on set exit on
compile vncview.rez keep=vncview.rezfork compile vncview.rez keep=vncview.rezfork
copy -C -P -R vncview.rezfork VNCview.GS copy -C -P -R vncview.rezfork VNCview.GS
end end
if {link} == true if {link} == true
link vncview vncsession vncdisplay colortables \ link vncview vncsession vncdisplay colortables \
desktopsize mouse keyboard copyrect raw hextile clipboard \ desktopsize mouse keyboard copyrect raw hextile clipboard \
keep=VNCview.GS keep=VNCview.GS
filetype VNCview.GS S16 $DB03 filetype VNCview.GS S16 $DB03
end end

28
menus.h
View File

@ -1,19 +1,19 @@
#define appleMenu 1 #define appleMenu 1
#define fileMenu 2 #define fileMenu 2
#define editMenu 3 #define editMenu 3
#define appleAbout 257 #define appleAbout 257
#define fileNewConnection 260 #define fileNewConnection 260
#define fileClose 255 #define fileClose 255
#define fileQuit 256 #define fileQuit 256
#define editUndo 250 #define editUndo 250
#define editCut 251 #define editCut 251
#define editCopy 252 #define editCopy 252
#define editPaste 253 #define editPaste 253
#define editClear 254 #define editClear 254
#define editSendClipboard 262 #define editSendClipboard 262
#define editShowClipboard 261 #define editShowClipboard 261
#define noKB 100 #define noKB 100

130
mouse.cc
View File

@ -29,29 +29,29 @@
#include "raw.h" #include "raw.h"
#include "hextile.h" #include "hextile.h"
unsigned char * cursor = NULL; /* Cursor from server */ unsigned char * cursor = NULL; /* Cursor from server */
/* Send a DoPointerEvent reflecting the status of the mouse to the server */ /* Send a DoPointerEvent reflecting the status of the mouse to the server */
/* This routine also maintains the appropriate cursor when using local cursor */ /* This routine also maintains the appropriate cursor when using local cursor */
void DoPointerEvent (void) { void DoPointerEvent (void) {
static struct { static struct {
unsigned char messageType; unsigned char messageType;
unsigned char buttonMask; unsigned char buttonMask;
unsigned int xPos; unsigned int xPos;
unsigned int yPos; unsigned int yPos;
} pointerEventStruct = { 5 /* message type */ }; } pointerEventStruct = { 5 /* message type */ };
Point mouseCoords; Point mouseCoords;
unsigned long contentOrigin; unsigned long contentOrigin;
Point * contentOriginPtr = (void *) &contentOrigin; Point * contentOriginPtr = (void *) &contentOrigin;
RegionHndl contentRgnHndl; RegionHndl contentRgnHndl;
unsigned int oldButtonMask; unsigned int oldButtonMask;
GrafPortPtr winPtr; GrafPortPtr winPtr;
unsigned long key1 = 0x0000; /* Keys to release & re-press, if any */ unsigned long key1 = 0x0000; /* Keys to release & re-press, if any */
unsigned long key2 = 0x0000; unsigned long key2 = 0x0000;
if (viewOnlyMode) if (viewOnlyMode)
return; return;
mouseCoords = myEvent.where; mouseCoords = myEvent.where;
@ -61,15 +61,15 @@ void DoPointerEvent (void) {
* updates if it isn't. * updates if it isn't.
*/ */
if (FindWindow(&winPtr, myEvent.where.h, myEvent.where.v) != wInContent || if (FindWindow(&winPtr, myEvent.where.h, myEvent.where.v) != wInContent ||
winPtr != vncWindow) { winPtr != vncWindow) {
if (cursor && GetCursorAdr() == cursor) if (cursor && GetCursorAdr() == cursor)
InitCursor(); InitCursor();
return; return;
} }
GlobalToLocal(&mouseCoords); GlobalToLocal(&mouseCoords);
contentOrigin = GetContentOrigin(vncWindow); contentOrigin = GetContentOrigin(vncWindow);
mouseCoords.h += contentOriginPtr->h; mouseCoords.h += contentOriginPtr->h;
mouseCoords.v += contentOriginPtr->v; mouseCoords.v += contentOriginPtr->v;
@ -80,51 +80,51 @@ void DoPointerEvent (void) {
oldButtonMask = pointerEventStruct.buttonMask; oldButtonMask = pointerEventStruct.buttonMask;
pointerEventStruct.buttonMask = 0x00; pointerEventStruct.buttonMask = 0x00;
if ((myEvent.modifiers & btn0State) == 0x00) { /* Mouse button pressed */ if ((myEvent.modifiers & btn0State) == 0x00) { /* Mouse button pressed */
if (emulate3ButtonMouse) { if (emulate3ButtonMouse) {
if (myEvent.modifiers & optionKey) { if (myEvent.modifiers & optionKey) {
pointerEventStruct.buttonMask = 0x02; pointerEventStruct.buttonMask = 0x02;
key1 = 0xFFE9; key1 = 0xFFE9;
} }
if (myEvent.modifiers & appleKey) { if (myEvent.modifiers & appleKey) {
pointerEventStruct.buttonMask |= 0x04; pointerEventStruct.buttonMask |= 0x04;
key2 = 0xFFE7; key2 = 0xFFE7;
} }
} }
/* If no modifiers, just send a normal left click. */ /* If no modifiers, just send a normal left click. */
if (pointerEventStruct.buttonMask == 0x00) if (pointerEventStruct.buttonMask == 0x00)
pointerEventStruct.buttonMask = 0x01; pointerEventStruct.buttonMask = 0x01;
} }
if ((myEvent.modifiers & btn1State) == 0x00) /* If 2nd (right) */ if ((myEvent.modifiers & btn1State) == 0x00) /* If 2nd (right) */
pointerEventStruct.buttonMask |= 0x04; /* button is pressed */ pointerEventStruct.buttonMask |= 0x04; /* button is pressed */
/* Don't waste bandwidth by sending update if mouse hasn't changed. /* Don't waste bandwidth by sending update if mouse hasn't changed.
* This may occasionally result in an initial mouse update not being * This may occasionally result in an initial mouse update not being
* sent. If this occurs, the user can simply move the mouse slightly * sent. If this occurs, the user can simply move the mouse slightly
* in order to send it. * in order to send it.
*/ */
if ( (pointerEventStruct.xPos == mouseCoords.h) && if ( (pointerEventStruct.xPos == mouseCoords.h) &&
(pointerEventStruct.yPos == mouseCoords.v) && (pointerEventStruct.yPos == mouseCoords.v) &&
(pointerEventStruct.buttonMask == oldButtonMask) ) (pointerEventStruct.buttonMask == oldButtonMask) )
return; return;
pointerEventStruct.xPos = mouseCoords.h; pointerEventStruct.xPos = mouseCoords.h;
pointerEventStruct.yPos = mouseCoords.v; pointerEventStruct.yPos = mouseCoords.v;
if (key1) if (key1)
SendKeyEvent(FALSE, key1); SendKeyEvent(FALSE, key1);
if (key2) if (key2)
SendKeyEvent(FALSE, key2); SendKeyEvent(FALSE, key2);
TCPIPWriteTCP(hostIpid, (Pointer) &pointerEventStruct.messageType, TCPIPWriteTCP(hostIpid, (Pointer) &pointerEventStruct.messageType,
sizeof(pointerEventStruct), TRUE, FALSE); sizeof(pointerEventStruct), TRUE, FALSE);
/* Can't do useful error checking here */ /* Can't do useful error checking here */
if (key1) if (key1)
SendKeyEvent(TRUE, key1); SendKeyEvent(TRUE, key1);
if (key2) if (key2)
SendKeyEvent(TRUE, key2); SendKeyEvent(TRUE, key2);
//printf("Sent mouse update: x = %u, y = %u\n", mouseCoords.h, mouseCoords.v); //printf("Sent mouse update: x = %u, y = %u\n", mouseCoords.h, mouseCoords.v);
//printf(" xPos = %x, yPos = %x, buttons = %x\n", pointerEventStruct.xPos, pointerEventStruct.yPos, (int) pointerEventStruct.buttonMask); //printf(" xPos = %x, yPos = %x, buttons = %x\n", pointerEventStruct.xPos, pointerEventStruct.yPos, (int) pointerEventStruct.buttonMask);
@ -134,7 +134,7 @@ void DoPointerEvent (void) {
*/ */
if (cursor && GetCursorAdr() != cursor) if (cursor && GetCursorAdr() != cursor)
SetCursor(cursor); SetCursor(cursor);
} }
void DoCursor (void) { void DoCursor (void) {
@ -147,16 +147,16 @@ void DoCursor (void) {
unsigned int *hotSpotYPtr, *hotSpotXPtr; unsigned int *hotSpotYPtr, *hotSpotXPtr;
unsigned long bitmaskByte; unsigned long bitmaskByte;
unsigned long bitmaskLineBytes, lineWords; unsigned long bitmaskLineBytes, lineWords;
unsigned int line, n, j; /* Loop counters */ unsigned int line, n, j; /* Loop counters */
unsigned char *maskLine, *imageLine; unsigned char *maskLine, *imageLine;
unsigned char *oldCursor = cursor; /* So we can free() it later */ unsigned char *oldCursor = cursor; /* So we can free() it later */
unsigned int outBytes640; unsigned int outBytes640;
unsigned long outBytes320; unsigned long outBytes320;
bitmaskLineBytes = (rectWidth + 7) / 8; bitmaskLineBytes = (rectWidth + 7) / 8;
if (!DoReadTCP(rectWidth*rectHeight + bitmaskLineBytes*rectHeight)) if (!DoReadTCP(rectWidth*rectHeight + bitmaskLineBytes*rectHeight))
return; /* Try again later */ return; /* Try again later */
HLock(readBufferHndl); HLock(readBufferHndl);
@ -164,17 +164,17 @@ void DoCursor (void) {
bitmask = (unsigned char *)(*readBufferHndl) + rectWidth*rectHeight; bitmask = (unsigned char *)(*readBufferHndl) + rectWidth*rectHeight;
if (hRez == 640) if (hRez == 640)
lineWords = (rectWidth + 7) / 8 + 1; lineWords = (rectWidth + 7) / 8 + 1;
else /* hRez == 320 */ else /* hRez == 320 */
lineWords = (rectWidth + 3) / 4 + 1; lineWords = (rectWidth + 3) / 4 + 1;
cursor = malloc(8 + 4 * lineWords * rectHeight); cursor = malloc(8 + 4 * lineWords * rectHeight);
/* Sub-optimal error handling */ /* Sub-optimal error handling */
if (cursor == NULL) if (cursor == NULL)
return; return;
/* Don't overflow loop indices */ /* Don't overflow loop indices */
if ((lineWords > UINT_MAX) || (rectHeight > UINT_MAX)) if ((lineWords > UINT_MAX) || (rectHeight > UINT_MAX))
return; return;
cursorHeightPtr = (unsigned int *)(void *)cursor; cursorHeightPtr = (unsigned int *)(void *)cursor;
cursorWidthPtr = cursorHeightPtr + 1; cursorWidthPtr = cursorHeightPtr + 1;
cursorImage = cursor + 4; cursorImage = cursor + 4;
@ -193,16 +193,16 @@ void DoCursor (void) {
dataPtr = cursorPixels; dataPtr = cursorPixels;
if (hRez == 320) { if (hRez == 320) {
for (line = 0; line < rectHeight; line++) { /* for each line ... */ for (line = 0; line < rectHeight; line++) { /* for each line ... */
maskLine = cursorMask + line * lineWords * 2; maskLine = cursorMask + line * lineWords * 2;
imageLine = cursorImage + line * lineWords * 2; imageLine = cursorImage + line * lineWords * 2;
for (j = 0; j < bitmaskLineBytes; j++) { for (j = 0; j < bitmaskLineBytes; j++) {
bitmaskByte = *(bitmask + line*bitmaskLineBytes + j); bitmaskByte = *(bitmask + line*bitmaskLineBytes + j);
outBytes320 = outBytes320 =
((bitmaskByte & 0x80) ) + ((bitmaskByte & 0x80) >> 1) + ((bitmaskByte & 0x80) ) + ((bitmaskByte & 0x80) >> 1) +
((bitmaskByte & 0x80) >> 2) + ((bitmaskByte & 0x80) >> 3) + ((bitmaskByte & 0x80) >> 2) + ((bitmaskByte & 0x80) >> 3) +
((bitmaskByte & 0x40) >> 3) + ((bitmaskByte & 0x40) >> 4) + ((bitmaskByte & 0x40) >> 3) + ((bitmaskByte & 0x40) >> 4) +
((bitmaskByte & 0x40) >> 5) + ((bitmaskByte & 0x40) >> 6) + ((bitmaskByte & 0x40) >> 5) + ((bitmaskByte & 0x40) >> 6) +
((bitmaskByte & 0x20) << 10) + ((bitmaskByte & 0x20) << 9) + ((bitmaskByte & 0x20) << 10) + ((bitmaskByte & 0x20) << 9) +
((bitmaskByte & 0x20) << 8) + ((bitmaskByte & 0x20) << 7) + ((bitmaskByte & 0x20) << 8) + ((bitmaskByte & 0x20) << 7) +
@ -223,12 +223,12 @@ void DoCursor (void) {
for (n = 0; n < rectWidth/2; n++) { for (n = 0; n < rectWidth/2; n++) {
*(imageLine + n) = coltab320[*(dataPtr++)] & 0xF0; *(imageLine + n) = coltab320[*(dataPtr++)] & 0xF0;
*(imageLine + n) += coltab320[*(dataPtr++)] & 0x0F; *(imageLine + n) += coltab320[*(dataPtr++)] & 0x0F;
*(imageLine + n) ^= 0xFF; /* Reverse color */ *(imageLine + n) ^= 0xFF; /* Reverse color */
*(imageLine + n) &= *(maskLine + n); *(imageLine + n) &= *(maskLine + n);
} }
if (rectWidth % 2) { if (rectWidth % 2) {
*(imageLine + n) = coltab320[*(dataPtr++)] & 0xF0; *(imageLine + n) = coltab320[*(dataPtr++)] & 0xF0;
*(imageLine + n) ^= 0xFF; /* Reverse color */ *(imageLine + n) ^= 0xFF; /* Reverse color */
*(imageLine + n) &= *(maskLine + n); *(imageLine + n) &= *(maskLine + n);
n++; n++;
} }
@ -237,16 +237,16 @@ void DoCursor (void) {
} }
} }
else { /* hRez == 640 */ else { /* hRez == 640 */
for (line = 0; line < rectHeight; line++) { /* for each line ... */ for (line = 0; line < rectHeight; line++) { /* for each line ... */
maskLine = cursorMask + line * lineWords * 2; maskLine = cursorMask + line * lineWords * 2;
imageLine = cursorImage + line * lineWords * 2; imageLine = cursorImage + line * lineWords * 2;
for (j = 0; j < bitmaskLineBytes; j++) { for (j = 0; j < bitmaskLineBytes; j++) {
bitmaskByte = *(bitmask + line*bitmaskLineBytes + j); bitmaskByte = *(bitmask + line*bitmaskLineBytes + j);
outBytes640 = outBytes640 =
((bitmaskByte & 0x80) ) + ((bitmaskByte & 0xC0) >> 1) + ((bitmaskByte & 0x80) ) + ((bitmaskByte & 0xC0) >> 1) +
((bitmaskByte & 0x60) >> 2) + ((bitmaskByte & 0x30) >> 3) + ((bitmaskByte & 0x60) >> 2) + ((bitmaskByte & 0x30) >> 3) +
((bitmaskByte & 0x10) >> 4) + ((bitmaskByte & 0x08) << 12) + ((bitmaskByte & 0x10) >> 4) + ((bitmaskByte & 0x08) << 12) +
((bitmaskByte & 0x0C) << 11) + ((bitmaskByte & 0x06) << 10) + ((bitmaskByte & 0x0C) << 11) + ((bitmaskByte & 0x06) << 10) +
((bitmaskByte & 0x03) << 9) + ((bitmaskByte & 0x01) << 8); ((bitmaskByte & 0x03) << 9) + ((bitmaskByte & 0x01) << 8);
*((unsigned int *)maskLine + j) = outBytes640; *((unsigned int *)maskLine + j) = outBytes640;
@ -258,7 +258,7 @@ void DoCursor (void) {
*(imageLine + n) += coltab640[*(dataPtr++)] & 0x30; *(imageLine + n) += coltab640[*(dataPtr++)] & 0x30;
*(imageLine + n) += coltab640[*(dataPtr++)] & 0x0C; *(imageLine + n) += coltab640[*(dataPtr++)] & 0x0C;
*(imageLine + n) += coltab640[*(dataPtr++)] & 0x03; *(imageLine + n) += coltab640[*(dataPtr++)] & 0x03;
*(imageLine + n) ^= 0xFF; /* Reverse color */ *(imageLine + n) ^= 0xFF; /* Reverse color */
*(imageLine + n) &= *(maskLine + n); *(imageLine + n) &= *(maskLine + n);
} }
*(imageLine + n) = 0; *(imageLine + n) = 0;
@ -275,7 +275,7 @@ void DoCursor (void) {
} }
} }
} }
*(imageLine + n) ^= 0xFF; /* Reverse color */ *(imageLine + n) ^= 0xFF; /* Reverse color */
*(imageLine + n) &= *(maskLine + n); *(imageLine + n) &= *(maskLine + n);
*(unsigned int *)(imageLine + n + 1) = 0; *(unsigned int *)(imageLine + n + 1) = 0;
} }
@ -283,10 +283,10 @@ void DoCursor (void) {
HUnlock(readBufferHndl); HUnlock(readBufferHndl);
if (GetCursorAdr() == oldCursor) if (GetCursorAdr() == oldCursor)
SetCursor(cursor); SetCursor(cursor);
if (oldCursor) if (oldCursor)
free(oldCursor); free(oldCursor);
#if 0 #if 0
/***************/ /***************/
@ -297,18 +297,18 @@ void DoCursor (void) {
rectWidth, rectHeight, rectX, rectY); rectWidth, rectHeight, rectX, rectY);
fprintf(foo, "\n"); fprintf(foo, "\n");
for (k = cursor; k < cursorImage; k++) for (k = cursor; k < cursorImage; k++)
fprintf(foo, "%02X ", *k); fprintf(foo, "%02X ", *k);
for (j = 0; j < lineWords * rectHeight * 4; j++) { for (j = 0; j < lineWords * rectHeight * 4; j++) {
fprintf(foo, "%02X", *(cursorImage + j)); fprintf(foo, "%02X", *(cursorImage + j));
if ((j+1) % (lineWords * 2) == 0) if ((j+1) % (lineWords * 2) == 0)
fprintf(foo, "\n"); fprintf(foo, "\n");
} }
for (k = cursorImage + j; k < cursorImage + j + 4; k = k + 1) for (k = cursorImage + j; k < cursorImage + j + 4; k = k + 1)
fprintf(foo, "%02X ", *k); fprintf(foo, "%02X ", *k);
//for (j = 0; j < bitmaskLineBytes*rectHeight; j++) { //for (j = 0; j < bitmaskLineBytes*rectHeight; j++) {
// fprintf(foo, "%02X", *(bitmask + j)); // fprintf(foo, "%02X", *(bitmask + j));
// if ((j+1) % bitmaskLineBytes == 0) // if ((j+1) % bitmaskLineBytes == 0)
// fprintf(foo, "\n"); // fprintf(foo, "\n");
// } // }
fprintf(foo, "\n"); fprintf(foo, "\n");
fclose(foo); fclose(foo);

View File

@ -1,3 +1,3 @@
extern unsigned char * cursor; /* Cursor from server */ extern unsigned char * cursor; /* Cursor from server */
extern void DoPointerEvent (void); extern void DoPointerEvent (void);
extern void DoCursor (void); extern void DoCursor (void);

372
raw.cc
View File

@ -30,10 +30,10 @@
#include "hextile.h" #include "hextile.h"
/* Data on state of raw rectangle drawing routines */ /* Data on state of raw rectangle drawing routines */
unsigned int lineBytes; /* Number of bytes in a line of GS pixels */ unsigned int lineBytes; /* Number of bytes in a line of GS pixels */
unsigned long pixels; unsigned long pixels;
unsigned int drawingLine; /* Line to be drawn while displaying */ unsigned int drawingLine; /* Line to be drawn while displaying */
static BOOLEAN extraByteAdvance; static BOOLEAN extraByteAdvance;
unsigned char *destPtr; unsigned char *destPtr;
@ -42,120 +42,120 @@ unsigned char *destPtr;
* because the rectangle is not visible. * because the rectangle is not visible.
*/ */
void StopRawDrawing (void) { void StopRawDrawing (void) {
HUnlock(readBufferHndl); HUnlock(readBufferHndl);
free(srcLocInfo.ptrToPixImage); /* Allocated as destPtr */ free(srcLocInfo.ptrToPixImage); /* Allocated as destPtr */
displayInProgress = FALSE; displayInProgress = FALSE;
NextRect(); /* Prepare for next rect */ NextRect(); /* Prepare for next rect */
} }
#pragma optimize 95 /* To work around an ORCA/C optimizer bug */ #pragma optimize 95 /* To work around an ORCA/C optimizer bug */
/* Draw one or more lines from a raw rectangle /* Draw one or more lines from a raw rectangle
*/ */
void RawDraw (void) { void RawDraw (void) {
unsigned int i; /* Loop indices */ unsigned int i; /* Loop indices */
unsigned char *dataPtr; unsigned char *dataPtr;
unsigned char *lineDataPtr, *initialLineDataPtr; unsigned char *lineDataPtr, *initialLineDataPtr;
unsigned char *finalDestPtr; unsigned char *finalDestPtr;
static EventRecord unusedEventRec; static EventRecord unusedEventRec;
/* For use with GetContentOrigin() */ /* For use with GetContentOrigin() */
unsigned long contentOrigin; unsigned long contentOrigin;
Point * contentOriginPtr = (void *) &contentOrigin; Point * contentOriginPtr = (void *) &contentOrigin;
SetPort(vncWindow); /* Drawing in VNC window */ SetPort(vncWindow); /* Drawing in VNC window */
dataPtr = (unsigned char *) *readBufferHndl; dataPtr = (unsigned char *) *readBufferHndl;
/* Check if what we're drawing is visible, and skip any invisible part /* Check if what we're drawing is visible, and skip any invisible part
* by skipping some lines or completely aborting drawing the rectangle. * by skipping some lines or completely aborting drawing the rectangle.
*/ */
if (checkBounds) { if (checkBounds) {
Rect drawingRect; Rect drawingRect;
contentOrigin = GetContentOrigin(vncWindow); contentOrigin = GetContentOrigin(vncWindow);
drawingRect.h1 = rectX - contentOriginPtr->h; drawingRect.h1 = rectX - contentOriginPtr->h;
drawingRect.h2 = rectX - contentOriginPtr->h + rectWidth; drawingRect.h2 = rectX - contentOriginPtr->h + rectWidth;
drawingRect.v1 = rectY - contentOriginPtr->v + drawingLine; drawingRect.v1 = rectY - contentOriginPtr->v + drawingLine;
drawingRect.v2 = rectY - contentOriginPtr->v + rectHeight; drawingRect.v2 = rectY - contentOriginPtr->v + rectHeight;
if (!RectInRgn(&drawingRect, GetVisHandle())) { if (!RectInRgn(&drawingRect, GetVisHandle())) {
StopRawDrawing(); StopRawDrawing();
return; return;
} }
else if (rectY + drawingLine < contentOriginPtr->v) { else if (rectY + drawingLine < contentOriginPtr->v) {
destPtr += (unsigned long)lineBytes * destPtr += (unsigned long)lineBytes *
(contentOriginPtr->v - rectY - drawingLine); (contentOriginPtr->v - rectY - drawingLine);
drawingLine = contentOriginPtr->v - rectY; drawingLine = contentOriginPtr->v - rectY;
if (drawingLine >= rectHeight) { /* Sanity check */ if (drawingLine >= rectHeight) { /* Sanity check */
StopRawDrawing(); StopRawDrawing();
return; return;
} }
} }
else if (rectY + rectHeight - 1 > contentOriginPtr->v + winHeight) else if (rectY + rectHeight - 1 > contentOriginPtr->v + winHeight)
rectHeight = contentOriginPtr->v + winHeight - rectY + 1; rectHeight = contentOriginPtr->v + winHeight - rectY + 1;
checkBounds = FALSE; checkBounds = FALSE;
} }
lineDataPtr = dataPtr + (unsigned long) drawingLine * rectWidth; lineDataPtr = dataPtr + (unsigned long) drawingLine * rectWidth;
do { /* We short-circuit back to here if there are no events pending */ do { /* We short-circuit back to here if there are no events pending */
finalDestPtr = destPtr + lineBytes - 1; finalDestPtr = destPtr + lineBytes - 1;
if (hRez == 640) { if (hRez == 640) {
initialLineDataPtr = lineDataPtr; initialLineDataPtr = lineDataPtr;
while (destPtr + 7 < finalDestPtr) { /* Unrolled loop */ while (destPtr + 7 < finalDestPtr) { /* Unrolled loop */
*(destPtr++) = bigcoltab640a[*(unsigned int*)(void*)lineDataPtr]
+ bigcoltab640b[*(unsigned int*)(void*)(lineDataPtr+2)];
lineDataPtr += 4;
*(destPtr++) = bigcoltab640a[*(unsigned int*)(void*)lineDataPtr]
+ bigcoltab640b[*(unsigned int*)(void*)(lineDataPtr+2)];
lineDataPtr += 4;
*(destPtr++) = bigcoltab640a[*(unsigned int*)(void*)lineDataPtr]
+ bigcoltab640b[*(unsigned int*)(void*)(lineDataPtr+2)];
lineDataPtr += 4;
*(destPtr++) = bigcoltab640a[*(unsigned int*)(void*)lineDataPtr]
+ bigcoltab640b[*(unsigned int*)(void*)(lineDataPtr+2)];
lineDataPtr += 4;
*(destPtr++) = bigcoltab640a[*(unsigned int*)(void*)lineDataPtr]
+ bigcoltab640b[*(unsigned int*)(void*)(lineDataPtr+2)];
lineDataPtr += 4;
*(destPtr++) = bigcoltab640a[*(unsigned int*)(void*)lineDataPtr]
+ bigcoltab640b[*(unsigned int*)(void*)(lineDataPtr+2)];
lineDataPtr += 4;
*(destPtr++) = bigcoltab640a[*(unsigned int*)(void*)lineDataPtr]
+ bigcoltab640b[*(unsigned int*)(void*)(lineDataPtr+2)];
lineDataPtr += 4;
*(destPtr++) = bigcoltab640a[*(unsigned int*)(void*)lineDataPtr]
+ bigcoltab640b[*(unsigned int*)(void*)(lineDataPtr+2)];
lineDataPtr += 4;
}
while (destPtr < finalDestPtr) {
*(destPtr++) = bigcoltab640a[*(unsigned int*)(void*)lineDataPtr] *(destPtr++) = bigcoltab640a[*(unsigned int*)(void*)lineDataPtr]
+ bigcoltab640b[*(unsigned int*)(void*)(lineDataPtr+2)]; + bigcoltab640b[*(unsigned int*)(void*)(lineDataPtr+2)];
lineDataPtr += 4; lineDataPtr += 4;
} *(destPtr++) = bigcoltab640a[*(unsigned int*)(void*)lineDataPtr]
+ bigcoltab640b[*(unsigned int*)(void*)(lineDataPtr+2)];
lineDataPtr += 4;
*(destPtr++) = bigcoltab640a[*(unsigned int*)(void*)lineDataPtr]
+ bigcoltab640b[*(unsigned int*)(void*)(lineDataPtr+2)];
lineDataPtr += 4;
*(destPtr++) = bigcoltab640a[*(unsigned int*)(void*)lineDataPtr]
+ bigcoltab640b[*(unsigned int*)(void*)(lineDataPtr+2)];
lineDataPtr += 4;
*(destPtr++) = bigcoltab640a[*(unsigned int*)(void*)lineDataPtr]
+ bigcoltab640b[*(unsigned int*)(void*)(lineDataPtr+2)];
lineDataPtr += 4;
*(destPtr++) = bigcoltab640a[*(unsigned int*)(void*)lineDataPtr]
+ bigcoltab640b[*(unsigned int*)(void*)(lineDataPtr+2)];
lineDataPtr += 4;
*(destPtr++) = bigcoltab640a[*(unsigned int*)(void*)lineDataPtr]
+ bigcoltab640b[*(unsigned int*)(void*)(lineDataPtr+2)];
lineDataPtr += 4;
*(destPtr++) = bigcoltab640a[*(unsigned int*)(void*)lineDataPtr]
+ bigcoltab640b[*(unsigned int*)(void*)(lineDataPtr+2)];
lineDataPtr += 4;
}
while (destPtr < finalDestPtr) {
*(destPtr++) = bigcoltab640a[*(unsigned int*)(void*)lineDataPtr]
+ bigcoltab640b[*(unsigned int*)(void*)(lineDataPtr+2)];
lineDataPtr += 4;
}
/* Final byte to produce */ /* Final byte to produce */
*destPtr = pixTransTbl[*(lineDataPtr++)] & 0xC0; *destPtr = pixTransTbl[*(lineDataPtr++)] & 0xC0;
for (i = lineDataPtr - initialLineDataPtr; i < rectWidth; i++) for (i = lineDataPtr - initialLineDataPtr; i < rectWidth; i++)
switch (i & 0x03) { switch (i & 0x03) {
case 0x01: /* pixels 1, 5, 9, ... */ case 0x01: /* pixels 1, 5, 9, ... */
*destPtr += pixTransTbl[*(lineDataPtr++)] & 0x30; *destPtr += pixTransTbl[*(lineDataPtr++)] & 0x30;
break; break;
case 0x02: /* pixels 2, 6, 10, ... */ case 0x02: /* pixels 2, 6, 10, ... */
*destPtr += pixTransTbl[*(lineDataPtr++)] & 0x0C; *destPtr += pixTransTbl[*(lineDataPtr++)] & 0x0C;
break; break;
case 0x03: /* pixels 3, 7, 11, ... */ case 0x03: /* pixels 3, 7, 11, ... */
*destPtr += pixTransTbl[*(lineDataPtr++)] & 0x03; *destPtr += pixTransTbl[*(lineDataPtr++)] & 0x03;
} }
destPtr++; destPtr++;
} }
else { /* 320 mode */ else { /* 320 mode */
while (destPtr + 7 < finalDestPtr) { /* Unrolled loop */ while (destPtr + 7 < finalDestPtr) { /* Unrolled loop */
*(destPtr++) = bigcoltab320[*(unsigned int*)(void*)lineDataPtr]; *(destPtr++) = bigcoltab320[*(unsigned int*)(void*)lineDataPtr];
lineDataPtr += 2; lineDataPtr += 2;
*(destPtr++) = bigcoltab320[*(unsigned int*)(void*)lineDataPtr]; *(destPtr++) = bigcoltab320[*(unsigned int*)(void*)lineDataPtr];
lineDataPtr += 2; lineDataPtr += 2;
@ -171,39 +171,39 @@ void RawDraw (void) {
lineDataPtr += 2; lineDataPtr += 2;
*(destPtr++) = bigcoltab320[*(unsigned int*)(void*)lineDataPtr]; *(destPtr++) = bigcoltab320[*(unsigned int*)(void*)lineDataPtr];
lineDataPtr += 2; lineDataPtr += 2;
} }
while (destPtr < finalDestPtr) { while (destPtr < finalDestPtr) {
*(destPtr++) = bigcoltab320[*(unsigned int*)(void*)lineDataPtr]; *(destPtr++) = bigcoltab320[*(unsigned int*)(void*)lineDataPtr];
lineDataPtr += 2; lineDataPtr += 2;
} }
/* Final byte to produce */ /* Final byte to produce */
*destPtr = pixTransTbl[*(lineDataPtr++)] & 0xF0; *destPtr = pixTransTbl[*(lineDataPtr++)] & 0xF0;
if (extraByteAdvance) if (extraByteAdvance)
destPtr++; /* Not ending on byte boundary - update index */ destPtr++; /* Not ending on byte boundary - update index */
else else
*(destPtr++) += pixTransTbl[*(lineDataPtr++)] & 0x0F; *(destPtr++) += pixTransTbl[*(lineDataPtr++)] & 0x0F;
} }
drawingLine++; drawingLine++;
if (pixels > 613 && !(drawingLine & 0x03)) { /* Draw every 4th line */ if (pixels > 613 && !(drawingLine & 0x03)) { /* Draw every 4th line */
srcRect.v2 = drawingLine; srcRect.v2 = drawingLine;
contentOrigin = GetContentOrigin(vncWindow); contentOrigin = GetContentOrigin(vncWindow);
PPToPort(&srcLocInfo, &srcRect, rectX - contentOriginPtr->h, PPToPort(&srcLocInfo, &srcRect, rectX - contentOriginPtr->h,
rectY + srcRect.v1 - contentOriginPtr->v, modeCopy); rectY + srcRect.v1 - contentOriginPtr->v, modeCopy);
srcRect.v1 = drawingLine; srcRect.v1 = drawingLine;
} }
/* Check whether we're done with this rectangle */ /* Check whether we're done with this rectangle */
if (drawingLine >= rectHeight) { if (drawingLine >= rectHeight) {
/* Draw final rect, if necessary */ /* Draw final rect, if necessary */
if (drawingLine > srcRect.v1) { if (drawingLine > srcRect.v1) {
srcRect.v2 = drawingLine; srcRect.v2 = drawingLine;
contentOrigin = GetContentOrigin(vncWindow); contentOrigin = GetContentOrigin(vncWindow);
PPToPort(&srcLocInfo, &srcRect, rectX - contentOriginPtr->h, PPToPort(&srcLocInfo, &srcRect, rectX - contentOriginPtr->h,
rectY + srcRect.v1 - contentOriginPtr->v, modeCopy); rectY + srcRect.v1 - contentOriginPtr->v, modeCopy);
} }
StopRawDrawing(); StopRawDrawing();
return; return;
} }
@ -215,37 +215,37 @@ void RawDraw (void) {
if (EventAvail(0xFFFF, &unusedEventRec)) if (EventAvail(0xFFFF, &unusedEventRec))
return; return;
SystemTask(); /* Let periodic Desk Accesories do their things */ SystemTask(); /* Let periodic Desk Accesories do their things */
TCPIPPoll(); /* Let Marinetti keep processing data */ TCPIPPoll(); /* Let Marinetti keep processing data */
} while (1); } while (1);
} }
#pragma optimize -1 #pragma optimize -1
/* Draw one line of Raw data - used if the complete rect isn't yet available */ /* Draw one line of Raw data - used if the complete rect isn't yet available */
void RawDrawLine (void) { void RawDrawLine (void) {
unsigned int i; unsigned int i;
unsigned char *dataPtr; unsigned char *dataPtr;
unsigned long contentOrigin; unsigned long contentOrigin;
Point * contentOriginPtr = (void *) &contentOrigin; Point * contentOriginPtr = (void *) &contentOrigin;
if (hRez == 640) { if (hRez == 640) {
if (rectWidth & 0x03) /* Width not an exact multiple of 4 */ if (rectWidth & 0x03) /* Width not an exact multiple of 4 */
lineBytes = rectWidth/4 + 1; lineBytes = rectWidth/4 + 1;
else /* Width is a multiple of 4 */ else /* Width is a multiple of 4 */
lineBytes = rectWidth/4; lineBytes = rectWidth/4;
} }
else { /* 320 mode */ else { /* 320 mode */
if (rectWidth & 0x01) /* Width not an exact multiple of 2 */ if (rectWidth & 0x01) /* Width not an exact multiple of 2 */
lineBytes = rectWidth/2 + 1; lineBytes = rectWidth/2 + 1;
else /* Width is a multiple of 2 */ else /* Width is a multiple of 2 */
lineBytes = rectWidth/2; lineBytes = rectWidth/2;
} }
destPtr = calloc(lineBytes, 1); destPtr = calloc(lineBytes, 1);
if (!destPtr) { /* Couldn't allocate memory */ if (!destPtr) { /* Couldn't allocate memory */
DoClose(vncWindow); DoClose(vncWindow);
return; return;
} }
@ -256,64 +256,64 @@ void RawDrawLine (void) {
* padding must be accounted for here. * padding must be accounted for here.
*/ */
if (hRez == 640) { if (hRez == 640) {
switch (rectWidth & 0x03) { switch (rectWidth & 0x03) {
case 0x00: srcLocInfo.boundsRect.h2 = rectWidth; break; case 0x00: srcLocInfo.boundsRect.h2 = rectWidth; break;
case 0x01: srcLocInfo.boundsRect.h2 = rectWidth+3; break; case 0x01: srcLocInfo.boundsRect.h2 = rectWidth+3; break;
case 0x02: srcLocInfo.boundsRect.h2 = rectWidth+2; break; case 0x02: srcLocInfo.boundsRect.h2 = rectWidth+2; break;
case 0x03: srcLocInfo.boundsRect.h2 = rectWidth+1; case 0x03: srcLocInfo.boundsRect.h2 = rectWidth+1;
} }
} }
else { else {
switch (rectWidth & 0x01) { switch (rectWidth & 0x01) {
case 0x00: srcLocInfo.boundsRect.h2 = rectWidth; break; case 0x00: srcLocInfo.boundsRect.h2 = rectWidth; break;
case 0x01: srcLocInfo.boundsRect.h2 = rectWidth+1; case 0x01: srcLocInfo.boundsRect.h2 = rectWidth+1;
} }
} }
/* Don't include padding in the area we will actually copy over */ /* Don't include padding in the area we will actually copy over */
srcRect.h2 = rectWidth; srcRect.h2 = rectWidth;
srcRect.v1 = 0; srcRect.v1 = 0;
srcRect.v2 = 1; srcRect.v2 = 1;
HLock(readBufferHndl); HLock(readBufferHndl);
dataPtr = (unsigned char *) *readBufferHndl; dataPtr = (unsigned char *) *readBufferHndl;
SetPort(vncWindow); /* Drawing in VNC window */ SetPort(vncWindow); /* Drawing in VNC window */
if (hRez == 640) if (hRez == 640)
for (i = 0; i < rectWidth; /* i is incremented in loop */) { for (i = 0; i < rectWidth; /* i is incremented in loop */) {
switch (i & 0x03) { switch (i & 0x03) {
case 0x00: /* pixels 0, 4, 8, ... */ case 0x00: /* pixels 0, 4, 8, ... */
*destPtr = pixTransTbl[dataPtr[i++]] & 0xC0; *destPtr = pixTransTbl[dataPtr[i++]] & 0xC0;
break; break;
case 0x01: /* pixels 1, 5, 9, ... */ case 0x01: /* pixels 1, 5, 9, ... */
*destPtr += pixTransTbl[dataPtr[i++]] & 0x30; *destPtr += pixTransTbl[dataPtr[i++]] & 0x30;
break; break;
case 0x02: /* pixels 2, 6, 10, ... */ case 0x02: /* pixels 2, 6, 10, ... */
*destPtr += pixTransTbl[dataPtr[i++]] & 0x0C; *destPtr += pixTransTbl[dataPtr[i++]] & 0x0C;
break; break;
case 0x03: /* pixels 3, 7, 11, ... */ case 0x03: /* pixels 3, 7, 11, ... */
*(destPtr++) += pixTransTbl[dataPtr[i++]] & 0x03; *(destPtr++) += pixTransTbl[dataPtr[i++]] & 0x03;
} }
} }
else /* 320 mode */ else /* 320 mode */
for (i = 0; i < rectWidth; /* i is incremented in loop */) { for (i = 0; i < rectWidth; /* i is incremented in loop */) {
if ((i & 0x01) == 0) /* pixels 0, 2, 4, ... */ if ((i & 0x01) == 0) /* pixels 0, 2, 4, ... */
*destPtr = pixTransTbl[dataPtr[i++]] & 0xF0; *destPtr = pixTransTbl[dataPtr[i++]] & 0xF0;
else { /* pixels 1, 3, 5, ... */ else { /* pixels 1, 3, 5, ... */
*(destPtr++) += pixTransTbl[dataPtr[i++]] & 0x0F; *(destPtr++) += pixTransTbl[dataPtr[i++]] & 0x0F;
} }
} }
HUnlock(readBufferHndl); HUnlock(readBufferHndl);
contentOrigin = GetContentOrigin(vncWindow); contentOrigin = GetContentOrigin(vncWindow);
PPToPort(&srcLocInfo, &srcRect, rectX - contentOriginPtr->h, PPToPort(&srcLocInfo, &srcRect, rectX - contentOriginPtr->h,
rectY - contentOriginPtr->v, modeCopy); rectY - contentOriginPtr->v, modeCopy);
free(srcLocInfo.ptrToPixImage); /* Allocated as destPtr */ free(srcLocInfo.ptrToPixImage); /* Allocated as destPtr */
TCPIPPoll(); TCPIPPoll();
rectHeight--; /* One less line left to draw */ rectHeight--; /* One less line left to draw */
rectY++; /* Rest of rect starts one line below this */ rectY++; /* Rest of rect starts one line below this */
} }
/* Process rectangle data in raw encoding and write it to screen. /* Process rectangle data in raw encoding and write it to screen.
@ -324,43 +324,43 @@ void DoRawRect (void) {
pixels = (unsigned long) rectWidth * rectHeight; pixels = (unsigned long) rectWidth * rectHeight;
/* Try to read data */ /* Try to read data */
if (! DoReadTCP (pixels)) { if (! DoReadTCP (pixels)) {
/* Only support line-by-line drawing if the connection is quite slow; /* Only support line-by-line drawing if the connection is quite slow;
* otherwise it's actually detrimental to overall speed. The Hextile * otherwise it's actually detrimental to overall speed. The Hextile
* setting is used as a hint at the connection speed. * setting is used as a hint at the connection speed.
*/ */
if (useHextile && rectHeight > 1 && DoReadTCP ((unsigned long) rectWidth)) if (useHextile && rectHeight > 1 && DoReadTCP ((unsigned long) rectWidth))
RawDrawLine(); /* Some data ready - draw first line */ RawDrawLine(); /* Some data ready - draw first line */
return; /* Not ready yet; wait */ return; /* Not ready yet; wait */
} }
/* Here if data is ready to be processed */ /* Here if data is ready to be processed */
if (hRez == 640) { if (hRez == 640) {
if (rectWidth & 0x03) { /* Width not an exact multiple of 4 */ if (rectWidth & 0x03) { /* Width not an exact multiple of 4 */
lineBytes = rectWidth/4 + 1; lineBytes = rectWidth/4 + 1;
extraByteAdvance = TRUE; extraByteAdvance = TRUE;
} }
else { /* Width is a multiple of 4 */ else { /* Width is a multiple of 4 */
lineBytes = rectWidth/4; lineBytes = rectWidth/4;
extraByteAdvance = FALSE; extraByteAdvance = FALSE;
} }
} }
else { /* 320 mode */ else { /* 320 mode */
if (rectWidth & 0x01) { /* Width not an exact multiple of 2 */ if (rectWidth & 0x01) { /* Width not an exact multiple of 2 */
lineBytes = rectWidth/2 + 1; lineBytes = rectWidth/2 + 1;
extraByteAdvance = TRUE; extraByteAdvance = TRUE;
} }
else { /* Width is a multiple of 2 */ else { /* Width is a multiple of 2 */
lineBytes = rectWidth/2; lineBytes = rectWidth/2;
extraByteAdvance = FALSE; extraByteAdvance = FALSE;
} }
} }
bufferLength = lineBytes * rectHeight; bufferLength = lineBytes * rectHeight;
destPtr = calloc(bufferLength, 1); destPtr = calloc(bufferLength, 1);
if (!destPtr) { /* Couldn't allocate memory */ if (!destPtr) { /* Couldn't allocate memory */
DoClose(vncWindow); DoClose(vncWindow);
return; return;
} }
@ -371,26 +371,26 @@ void DoRawRect (void) {
* padding must be accounted for here. * padding must be accounted for here.
*/ */
if (hRez == 640) { if (hRez == 640) {
switch (rectWidth & 0x03) { switch (rectWidth & 0x03) {
case 0x00: srcLocInfo.boundsRect.h2 = rectWidth; break; case 0x00: srcLocInfo.boundsRect.h2 = rectWidth; break;
case 0x01: srcLocInfo.boundsRect.h2 = rectWidth+3; break; case 0x01: srcLocInfo.boundsRect.h2 = rectWidth+3; break;
case 0x02: srcLocInfo.boundsRect.h2 = rectWidth+2; break; case 0x02: srcLocInfo.boundsRect.h2 = rectWidth+2; break;
case 0x03: srcLocInfo.boundsRect.h2 = rectWidth+1; case 0x03: srcLocInfo.boundsRect.h2 = rectWidth+1;
} }
} }
else { else {
switch (rectWidth & 0x01) { switch (rectWidth & 0x01) {
case 0x00: srcLocInfo.boundsRect.h2 = rectWidth; break; case 0x00: srcLocInfo.boundsRect.h2 = rectWidth; break;
case 0x01: srcLocInfo.boundsRect.h2 = rectWidth+1; case 0x01: srcLocInfo.boundsRect.h2 = rectWidth+1;
} }
} }
/* Don't include padding in the area we will actually copy over */ /* Don't include padding in the area we will actually copy over */
srcRect.h2 = rectWidth; srcRect.h2 = rectWidth;
srcRect.v1 = 0; srcRect.v1 = 0;
displayInProgress = TRUE; displayInProgress = TRUE;
drawingLine = 0; /* Drawing first line of rect */ drawingLine = 0; /* Drawing first line of rect */
checkBounds = TRUE; /* Flag to check bounds when drawing 1st line */ checkBounds = TRUE; /* Flag to check bounds when drawing 1st line */
HLock(readBufferHndl); /* Lock handle just once for efficiency */ HLock(readBufferHndl); /* Lock handle just once for efficiency */
} }

View File

@ -56,11 +56,11 @@ struct LocInfo srcLocInfo = {0, 0, 0, {0, 0, 0, 0} };
Rect srcRect = {0, 0, 0, 0}; Rect srcRect = {0, 0, 0, 0};
unsigned char *pixTransTbl; unsigned char *pixTransTbl;
BOOLEAN checkBounds = FALSE; /* Adjust drawing to stay in bounds */ BOOLEAN checkBounds = FALSE; /* Adjust drawing to stay in bounds */
#define txtColor 10 #define txtColor 10
#define txtGray 11 #define txtGray 11
#define txtTransfers 23 #define txtTransfers 23
/* Send a request to be sent the data to redraw the window when part of it has /* Send a request to be sent the data to redraw the window when part of it has
* been erased. It will be a while before the data is fully redrawn, but this * been erased. It will be a while before the data is fully redrawn, but this
@ -72,11 +72,11 @@ void VNCRedraw (void) {
updateRgnHndl = vncWindow->visRgn; updateRgnHndl = vncWindow->visRgn;
SendFBUpdateRequest(FALSE, SendFBUpdateRequest(FALSE,
(**updateRgnHndl).rgnBBox.h1, (**updateRgnHndl).rgnBBox.h1,
(**updateRgnHndl).rgnBBox.v1, (**updateRgnHndl).rgnBBox.v1,
(**updateRgnHndl).rgnBBox.h2 - (**updateRgnHndl).rgnBBox.h1, (**updateRgnHndl).rgnBBox.h2 - (**updateRgnHndl).rgnBBox.h1,
(**updateRgnHndl).rgnBBox.v2 - (**updateRgnHndl).rgnBBox.v1); (**updateRgnHndl).rgnBBox.v2 - (**updateRgnHndl).rgnBBox.v1);
checkBounds = TRUE; checkBounds = TRUE;
} }
@ -86,7 +86,7 @@ void VNCRedraw (void) {
* Uses the procedure described in IIgs Tech Note #4. * Uses the procedure described in IIgs Tech Note #4.
*/ */
void ChangeResolution(int rez) { void ChangeResolution(int rez) {
static Handle dpSpace; static Handle dpSpace;
unsigned int masterSCB; unsigned int masterSCB;
hRez = rez; hRez = rez;
@ -96,35 +96,35 @@ void ChangeResolution(int rez) {
/* Set up pixel translation table for correct graphics mode */ /* Set up pixel translation table for correct graphics mode */
if (rez == 320) if (rez == 320)
pixTransTbl = coltab320; pixTransTbl = coltab320;
else /* 640 mode */ else /* 640 mode */
pixTransTbl = coltab640; pixTransTbl = coltab640;
srcLocInfo.portSCB = (rez == 640) ? 0x87 : 0x00; srcLocInfo.portSCB = (rez == 640) ? 0x87 : 0x00;
/* Check if we need to change modes */ /* Check if we need to change modes */
masterSCB = GetMasterSCB(); masterSCB = GetMasterSCB();
if ( ( (masterSCB & 0x80) && (rez == 640)) || if ( ( (masterSCB & 0x80) && (rez == 640)) ||
(!(masterSCB & 0x80) && (rez == 320)) ) { (!(masterSCB & 0x80) && (rez == 320)) ) {
return; /* Already in right mode, so don't change things */ return; /* Already in right mode, so don't change things */
} }
/* Perform the basic procedure described in IIgs TN #4 */ /* Perform the basic procedure described in IIgs TN #4 */
CloseAllNDAs(); CloseAllNDAs();
QDAuxShutDown(); QDAuxShutDown();
QDShutDown(); QDShutDown();
if (dpSpace == NULL) if (dpSpace == NULL)
dpSpace = NewHandle(0x0300, userid(), dpSpace = NewHandle(0x0300, userid(),
attrLocked|attrFixed|attrNoCross|attrBank, 0x00000000); attrLocked|attrFixed|attrNoCross|attrBank, 0x00000000);
QDStartUp((Word) *dpSpace, (rez == 640) ? 0x87 : 0x00, 0, userid()); QDStartUp((Word) *dpSpace, (rez == 640) ? 0x87 : 0x00, 0, userid());
/* SCB 0x87 gives 640 mode with our custom gray palette */ /* SCB 0x87 gives 640 mode with our custom gray palette */
GrafOff(); GrafOff();
QDAuxStartUp(); QDAuxStartUp();
ClampMouse(0, (rez == 640) ? 639 : 319, 0, 199); ClampMouse(0, (rez == 640) ? 639 : 319, 0, 199);
HomeMouse(); HomeMouse();
ShowCursor(); ShowCursor();
WindNewRes(); WindNewRes();
InitPalette(); /* Set up Apple menu colors before it is redrawn */ InitPalette(); /* Set up Apple menu colors before it is redrawn */
MenuNewRes(); MenuNewRes();
CtlNewRes(); CtlNewRes();
RefreshDesktop(NULL); RefreshDesktop(NULL);
@ -132,16 +132,16 @@ void ChangeResolution(int rez) {
/* Position new connection window at default location for new mode */ /* Position new connection window at default location for new mode */
if (rez == 320) { if (rez == 320) {
MoveControl(25, 64, GetCtlHandleFromID(newConnWindow, txtColor)); MoveControl(25, 64, GetCtlHandleFromID(newConnWindow, txtColor));
MoveControl(25, 87, GetCtlHandleFromID(newConnWindow, txtGray)); MoveControl(25, 87, GetCtlHandleFromID(newConnWindow, txtGray));
MoveControl(134, 91, GetCtlHandleFromID(newConnWindow, txtTransfers)); MoveControl(134, 91, GetCtlHandleFromID(newConnWindow, txtTransfers));
MoveWindow(2, 42, newConnWindow); MoveWindow(2, 42, newConnWindow);
} }
else { else {
MoveControl(35, 64, GetCtlHandleFromID(newConnWindow, txtColor)); MoveControl(35, 64, GetCtlHandleFromID(newConnWindow, txtColor));
MoveControl(35, 87, GetCtlHandleFromID(newConnWindow, txtGray)); MoveControl(35, 87, GetCtlHandleFromID(newConnWindow, txtGray));
MoveControl(144, 91, GetCtlHandleFromID(newConnWindow, txtTransfers)); MoveControl(144, 91, GetCtlHandleFromID(newConnWindow, txtTransfers));
MoveWindow(162, 42, newConnWindow); MoveWindow(162, 42, newConnWindow);
} }
} }
@ -151,24 +151,24 @@ void ChangeResolution(int rez) {
void InitVNCWindow(void) { void InitVNCWindow(void) {
#define wrNum640 1003 #define wrNum640 1003
#define wrNum320 1004 #define wrNum320 1004
BOOLEAN resize = FALSE; BOOLEAN resize = FALSE;
ChangeResolution(hRez); ChangeResolution(hRez);
vncWindow = NewWindow2(NULL, 0, NULL, NULL, 0x02, vncWindow = NewWindow2(NULL, 0, NULL, NULL, 0x02,
(hRez == 640) ? wrNum640 : wrNum320, (hRez == 640) ? wrNum640 : wrNum320,
rWindParam1); rWindParam1);
if (fbWidth < winWidth) { if (fbWidth < winWidth) {
winWidth = fbWidth; winWidth = fbWidth;
resize = TRUE; resize = TRUE;
} }
if (fbHeight < winHeight) { if (fbHeight < winHeight) {
winHeight = fbHeight; winHeight = fbHeight;
resize = TRUE; resize = TRUE;
} }
if (resize) if (resize)
SizeWindow(winWidth, winHeight, vncWindow); SizeWindow(winWidth, winHeight, vncWindow);
SetContentDraw(VNCRedraw, vncWindow); SetContentDraw(VNCRedraw, vncWindow);
@ -176,7 +176,7 @@ void InitVNCWindow(void) {
DrawControls(vncWindow); DrawControls(vncWindow);
/* We also take the opportunity here to initialize the rectangle info. */ /* We also take the opportunity here to initialize the rectangle info. */
numRects = 0; numRects = 0;
displayInProgress = FALSE; displayInProgress = FALSE;
@ -188,11 +188,11 @@ void InitVNCWindow(void) {
* the frame buffer. * the frame buffer.
*/ */
void SendFBUpdateRequest (BOOLEAN incremental, unsigned int x, unsigned int y, void SendFBUpdateRequest (BOOLEAN incremental, unsigned int x, unsigned int y,
unsigned int width, unsigned int height) { unsigned int width, unsigned int height) {
struct FBUpdateRequest { struct FBUpdateRequest {
unsigned char messageType; unsigned char messageType;
unsigned char incremental; unsigned char incremental;
unsigned int x; unsigned int x;
unsigned int y; unsigned int y;
unsigned int width; unsigned int width;
@ -205,31 +205,31 @@ void SendFBUpdateRequest (BOOLEAN incremental, unsigned int x, unsigned int y,
fbUpdateRequest.width = SwapBytes2(width); fbUpdateRequest.width = SwapBytes2(width);
fbUpdateRequest.height = SwapBytes2(height); fbUpdateRequest.height = SwapBytes2(height);
TCPIPWriteTCP(hostIpid, &fbUpdateRequest.messageType, TCPIPWriteTCP(hostIpid, &fbUpdateRequest.messageType,
sizeof(fbUpdateRequest), TRUE, FALSE); sizeof(fbUpdateRequest), TRUE, FALSE);
/* No error checking here -- Can't respond to one usefully. */ /* No error checking here -- Can't respond to one usefully. */
} }
/* Start responding to a FramebufferUpdate from the server /* Start responding to a FramebufferUpdate from the server
*/ */
void DoFBUpdate (void) { void DoFBUpdate (void) {
unsigned int *dataPtr; /* Pointer to header data */ unsigned int *dataPtr; /* Pointer to header data */
if (!DoWaitingReadTCP(15)) { if (!DoWaitingReadTCP(15)) {
DoClose(vncWindow); DoClose(vncWindow);
//printf("Closing in DoFBUpdate\n"); //printf("Closing in DoFBUpdate\n");
return; return;
} }
HLock(readBufferHndl); HLock(readBufferHndl);
dataPtr = (unsigned int *) (((char *) (*readBufferHndl)) + 1); dataPtr = (unsigned int *) (((char *) (*readBufferHndl)) + 1);
numRects = SwapBytes2(dataPtr[0]); /* Get data */ numRects = SwapBytes2(dataPtr[0]); /* Get data */
rectX = SwapBytes2(dataPtr[1]); rectX = SwapBytes2(dataPtr[1]);
rectY = SwapBytes2(dataPtr[2]); rectY = SwapBytes2(dataPtr[2]);
rectWidth = SwapBytes2(dataPtr[3]); rectWidth = SwapBytes2(dataPtr[3]);
rectHeight = SwapBytes2(dataPtr[4]); rectHeight = SwapBytes2(dataPtr[4]);
rectEncoding = SwapBytes4(*(unsigned long *)(dataPtr + 5)); rectEncoding = SwapBytes4(*(unsigned long *)(dataPtr + 5));
HUnlock(readBufferHndl); HUnlock(readBufferHndl);
} }
/* The server should never send a color map, since we don't use a mapped /* The server should never send a color map, since we don't use a mapped
@ -240,7 +240,7 @@ void DoFBUpdate (void) {
* is actually working correctly. * is actually working correctly.
*/ */
void DoSetColourMapEntries (void) { void DoSetColourMapEntries (void) {
unsigned int numColors; unsigned int numColors;
DoWaitingReadTCP(3); DoWaitingReadTCP(3);
DoWaitingReadTCP(2); DoWaitingReadTCP(2);
@ -248,8 +248,8 @@ void DoSetColourMapEntries (void) {
numColors = SwapBytes2((unsigned int) **readBufferHndl); numColors = SwapBytes2((unsigned int) **readBufferHndl);
HUnlock(readBufferHndl); HUnlock(readBufferHndl);
for (; numColors > 0; numColors--) { for (; numColors > 0; numColors--) {
DoWaitingReadTCP(6); DoWaitingReadTCP(6);
} }
} }
@ -258,100 +258,100 @@ void DoSetColourMapEntries (void) {
* If no more rectangles are available, we send a FramebufferUpdateRequest. * If no more rectangles are available, we send a FramebufferUpdateRequest.
*/ */
void NextRect (void) { void NextRect (void) {
unsigned int *dataPtr; unsigned int *dataPtr;
numRects--; numRects--;
if (numRects) { /* Process next rectangle */ if (numRects) { /* Process next rectangle */
if (!DoWaitingReadTCP(12)) { if (!DoWaitingReadTCP(12)) {
//printf("Closing in NextRect\n"); //printf("Closing in NextRect\n");
DoClose(vncWindow); DoClose(vncWindow);
return; return;
} }
HLock(readBufferHndl); HLock(readBufferHndl);
dataPtr = (unsigned int *) ((char *) (*readBufferHndl)); dataPtr = (unsigned int *) ((char *) (*readBufferHndl));
rectX = SwapBytes2(dataPtr[0]); rectX = SwapBytes2(dataPtr[0]);
rectY = SwapBytes2(dataPtr[1]); rectY = SwapBytes2(dataPtr[1]);
rectWidth = SwapBytes2(dataPtr[2]); rectWidth = SwapBytes2(dataPtr[2]);
rectHeight = SwapBytes2(dataPtr[3]); rectHeight = SwapBytes2(dataPtr[3]);
rectEncoding = SwapBytes4(*(unsigned long *)(dataPtr + 4)); rectEncoding = SwapBytes4(*(unsigned long *)(dataPtr + 4));
HUnlock(readBufferHndl); HUnlock(readBufferHndl);
//printf("New Rect: X = %u, Y = %u, Width = %u, Height = %u\n", rectX, rectY, rectWidth, rectHeight); //printf("New Rect: X = %u, Y = %u, Width = %u, Height = %u\n", rectX, rectY, rectWidth, rectHeight);
} }
else { /* No more rectangles from last update */ else { /* No more rectangles from last update */
unsigned long contentOrigin; unsigned long contentOrigin;
Point * contentOriginPtr = (void *) &contentOrigin; Point * contentOriginPtr = (void *) &contentOrigin;
contentOrigin = GetContentOrigin(vncWindow); contentOrigin = GetContentOrigin(vncWindow);
SendFBUpdateRequest(TRUE, contentOriginPtr->h, contentOriginPtr->v, SendFBUpdateRequest(TRUE, contentOriginPtr->h, contentOriginPtr->v,
winWidth, winHeight); winWidth, winHeight);
} }
} }
void ConnectedEventLoop (void) { void ConnectedEventLoop (void) {
unsigned char messageType; unsigned char messageType;
#define FBUpdate 0 #define FBUpdate 0
#define SetColourMapEntries 1 #define SetColourMapEntries 1
#define Bell 2 #define Bell 2
#define ServerCutText 3 #define ServerCutText 3
if (FrontWindow() != vncWindow && menuOffset == noKB) if (FrontWindow() != vncWindow && menuOffset == noKB)
InitMenus(0); InitMenus(0);
else if (FrontWindow() == vncWindow && menuOffset != noKB) else if (FrontWindow() == vncWindow && menuOffset != noKB)
InitMenus(noKB); InitMenus(noKB);
if (displayInProgress) { if (displayInProgress) {
switch (rectEncoding) { switch (rectEncoding) {
case encodingRaw: RawDraw(); case encodingRaw: RawDraw();
return; return;
case encodingHextile: HexDispatch(); case encodingHextile: HexDispatch();
return; return;
default: DoClose(vncWindow); default: DoClose(vncWindow);
return; return;
} }
} }
else if (numRects) { else if (numRects) {
switch (rectEncoding) { switch (rectEncoding) {
case encodingHextile: case encodingHextile:
DoHextileRect(); DoHextileRect();
return;
case encodingRaw: DoRawRect();
return; return;
case encodingRaw: DoRawRect();
return;
case encodingCopyRect: case encodingCopyRect:
DoCopyRect(); DoCopyRect();
return; return;
case encodingDesktopSize: case encodingDesktopSize:
DoDesktopSize(); DoDesktopSize();
return; return;
case encodingCursor: case encodingCursor:
DoCursor(); DoCursor();
return; return;
default: DisplayConnectStatus ( default: DisplayConnectStatus (
"\pInvalid rectangle from server.", FALSE); "\pInvalid rectangle from server.", FALSE);
DoClose(vncWindow); DoClose(vncWindow);
//printf("Closing due to bad rectangle encoding %lu\n", rectEncoding); //printf("Closing due to bad rectangle encoding %lu\n", rectEncoding);
//printf("rectX = %u, rectY = %u, rectWidth = %u, rectHeight = %u\n", rectX, rectY, rectWidth, rectHeight); //printf("rectX = %u, rectY = %u, rectWidth = %u, rectHeight = %u\n", rectX, rectY, rectWidth, rectHeight);
return; return;
} }
} }
else if (DoReadTCP(1)) { /* Read message type byte */ else if (DoReadTCP(1)) { /* Read message type byte */
HLock(readBufferHndl); HLock(readBufferHndl);
messageType = ((unsigned char) **readBufferHndl); messageType = ((unsigned char) **readBufferHndl);
HUnlock(readBufferHndl); HUnlock(readBufferHndl);
switch (messageType) { switch (messageType) {
case FBUpdate: DoFBUpdate(); case FBUpdate: DoFBUpdate();
break; break;
case SetColourMapEntries: DoSetColourMapEntries(); case SetColourMapEntries: DoSetColourMapEntries();
break; break;
case Bell: SysBeep(); case Bell: SysBeep();
break; break;
case ServerCutText: DoServerCutText(); case ServerCutText: DoServerCutText();
break; break;
default: DisplayConnectStatus ( default: DisplayConnectStatus (
"\pInvalid message from server.", "\pInvalid message from server.",
FALSE); FALSE);
DoClose(vncWindow); DoClose(vncWindow);
return; return;
} }
} }
} }

View File

@ -10,14 +10,14 @@ extern unsigned int rectWidth;
extern unsigned int rectHeight; extern unsigned int rectHeight;
extern unsigned long rectEncoding; extern unsigned long rectEncoding;
#define encodingRaw 0 #define encodingRaw 0
#define encodingCopyRect 1 #define encodingCopyRect 1
#define encodingRRE 2 #define encodingRRE 2
#define encodingCoRRE 4 #define encodingCoRRE 4
#define encodingHextile 5 #define encodingHextile 5
#define encodingZRLE 16 #define encodingZRLE 16
#define encodingCursor 0xffffff11 #define encodingCursor 0xffffff11
#define encodingDesktopSize 0xffffff21 #define encodingDesktopSize 0xffffff21
extern GrafPortPtr vncWindow; extern GrafPortPtr vncWindow;
@ -34,12 +34,12 @@ extern struct LocInfo srcLocInfo;
extern Rect srcRect; extern Rect srcRect;
extern unsigned char *pixTransTbl; extern unsigned char *pixTransTbl;
extern BOOLEAN checkBounds; /* Adjust drawing to stay in bounds */ extern BOOLEAN checkBounds; /* Adjust drawing to stay in bounds */
void InitVNCWindow (void); void InitVNCWindow (void);
void SendFBUpdateRequest (BOOLEAN /*incremental*/, unsigned int /*x*/, void SendFBUpdateRequest (BOOLEAN /*incremental*/, unsigned int /*x*/,
unsigned int /*y*/, unsigned int /*width*/, unsigned int /*height*/); unsigned int /*y*/, unsigned int /*width*/, unsigned int /*height*/);
void ConnectedEventLoop (void); void ConnectedEventLoop (void);

View File

@ -1,6 +1,6 @@
/********************************************************************* /*********************************************************************
* vncsession.cc - Routines for initiating/conducting a VNC session * vncsession.cc - Routines for initiating/conducting a VNC session
* with the remote host * with the remote host
*********************************************************************/ *********************************************************************/
#if __ORCAC__ #if __ORCAC__
@ -38,183 +38,183 @@
#include "menus.h" #include "menus.h"
#include "colortables.h" #include "colortables.h"
#define linServer 3 #define linServer 3
#define linPassword 7 #define linPassword 7
#define noCryptoError 2005 #define noCryptoError 2005
#define authFailedError 2006 #define authFailedError 2006
#define authTooManyError 2007 #define authTooManyError 2007
#define noTCPIPConnectionError 2011 #define noTCPIPConnectionError 2011
#define badGetIpidError 2012 #define badGetIpidError 2012
#define badOptionNegotiationError 2013 #define badOptionNegotiationError 2013
#define badHandshakingError 2014 #define badHandshakingError 2014
#define badReadTCPError 2015 #define badReadTCPError 2015
GrafPortPtr connectStatusWindowPtr = NULL; GrafPortPtr connectStatusWindowPtr = NULL;
unsigned int hostIpid; unsigned int hostIpid;
void ** readBufferHndl; /* Handle to the data read by the last void ** readBufferHndl; /* Handle to the data read by the last
* DoReadTCP call. Copy this elsewhere if more * DoReadTCP call. Copy this elsewhere if more
* data may be read while it is still in use. * data may be read while it is still in use.
*/ */
BOOLEAN readError; BOOLEAN readError;
BOOLEAN alerted = FALSE; BOOLEAN alerted = FALSE;
#define buffTypePointer 0x0000 /* For TCPIPReadTCP() */ #define buffTypePointer 0x0000 /* For TCPIPReadTCP() */
#define buffTypeHandle 0x0001 #define buffTypeHandle 0x0001
#define buffTypeNewHandle 0x0002 #define buffTypeNewHandle 0x0002
#define vncConnectionFailed SwapBytes4(0) #define vncConnectionFailed SwapBytes4(0)
#define vncNoAuthentication SwapBytes4(1) #define vncNoAuthentication SwapBytes4(1)
#define vncVNCAuthentication SwapBytes4(2) #define vncVNCAuthentication SwapBytes4(2)
/*************************************************************** /***************************************************************
* DoConnect - establish connection to server * DoConnect - establish connection to server
***************************************************************/ ***************************************************************/
void DoConnect (void) { void DoConnect (void) {
int i; /* loop counter */ int i; /* loop counter */
if (colorTablesComplete == FALSE) { if (colorTablesComplete == FALSE) {
DisplayConnectStatus("\pGenerating color tables...", FALSE); DisplayConnectStatus("\pGenerating color tables...", FALSE);
MakeBigColorTables(65536); MakeBigColorTables(65536);
colorTablesComplete = TRUE; colorTablesComplete = TRUE;
CloseConnectStatusWindow(); CloseConnectStatusWindow();
} }
/* Get server & password */ /* Get server & password */
GetLETextByID(newConnWindow, linServer, (StringPtr) vncServer); GetLETextByID(newConnWindow, linServer, (StringPtr) vncServer);
GetLETextByID(newConnWindow, linPassword, (StringPtr) vncPassword); GetLETextByID(newConnWindow, linPassword, (StringPtr) vncPassword);
/* Try to establish connection before continuing; if unsuccessful, stop */ /* Try to establish connection before continuing; if unsuccessful, stop */
if (ConnectTCPIP() == FALSE) { if (ConnectTCPIP() == FALSE) {
SysBeep(); SysBeep();
AlertWindow(awResource, NULL, noTCPIPConnectionError); AlertWindow(awResource, NULL, noTCPIPConnectionError);
return; return;
} }
if (GetIpid() == FALSE) { if (GetIpid() == FALSE) {
SysBeep(); SysBeep();
AlertWindow(awResource, NULL, badGetIpidError); AlertWindow(awResource, NULL, badGetIpidError);
return; return;
} }
if (DoVNCHandshaking() == FALSE) { if (DoVNCHandshaking() == FALSE) {
SetHandleSize(1,readBufferHndl); SetHandleSize(1,readBufferHndl);
CloseConnectStatusWindow(); CloseConnectStatusWindow();
InitCursor(); InitCursor();
SysBeep(); SysBeep();
if (alerted == FALSE) if (alerted == FALSE)
AlertWindow(awResource, NULL, badHandshakingError); AlertWindow(awResource, NULL, badHandshakingError);
else else
alerted = FALSE; alerted = FALSE;
return; return;
} }
if (FinishVNCHandshaking() == FALSE) { if (FinishVNCHandshaking() == FALSE) {
SetHandleSize(1,readBufferHndl); SetHandleSize(1,readBufferHndl);
CloseConnectStatusWindow(); CloseConnectStatusWindow();
InitCursor(); InitCursor();
AlertWindow(awResource, NULL, badOptionNegotiationError); AlertWindow(awResource, NULL, badOptionNegotiationError);
SysBeep(); SysBeep();
return; return;
} }
InitVNCWindow(); InitVNCWindow();
CloseConnectStatusWindow(); CloseConnectStatusWindow();
InitCursor(); InitCursor();
DoClose(newConnWindow); DoClose(newConnWindow);
DisableMItem(fileNewConnection); DisableMItem(fileNewConnection);
myEvent.wmTaskMask = 0x001D79FE; /* don't let TaskMaster process keys */ myEvent.wmTaskMask = 0x001D79FE; /* don't let TaskMaster process keys */
InitMenus(noKB); InitMenus(noKB);
vncConnected = TRUE; vncConnected = TRUE;
} }
/******************************************************************* /*******************************************************************
* DisplayConnectStatus - Display modal dialog with status information * DisplayConnectStatus - Display modal dialog with status information
* statusString - P-String to display * statusString - P-String to display
* cancelMessage - determines whether to display string about OA-. * cancelMessage - determines whether to display string about OA-.
*******************************************************************/ *******************************************************************/
void DisplayConnectStatus(char *statusString, BOOLEAN cancelMessage) { void DisplayConnectStatus(char *statusString, BOOLEAN cancelMessage) {
#define wrNum 1002 #define wrNum 1002
#define cancelStr 10002 #define cancelStr 10002
GrafPortPtr oldPort; GrafPortPtr oldPort;
Rect bigRect = {0,9,15,293}; Rect bigRect = {0,9,15,293};
if (connectStatusWindowPtr == NULL) { if (connectStatusWindowPtr == NULL) {
connectStatusWindowPtr = NewWindow2(NULL, NULL, NULL, NULL, connectStatusWindowPtr = NewWindow2(NULL, NULL, NULL, NULL,
0x02, wrNum, rWindParam1); 0x02, wrNum, rWindParam1);
} }
if (connectStatusWindowPtr != NULL) { /* Only draw if window was */ if (connectStatusWindowPtr != NULL) { /* Only draw if window was */
if (GetMasterSCB() & 0x0080) /* If in 640 mode... */ if (GetMasterSCB() & 0x0080) /* If in 640 mode... */
MoveWindow(169, 85, connectStatusWindowPtr); MoveWindow(169, 85, connectStatusWindowPtr);
else /* If in 320 mode... */ else /* If in 320 mode... */
MoveWindow(9, 85, connectStatusWindowPtr); MoveWindow(9, 85, connectStatusWindowPtr);
oldPort = GetPort(); /* created successfully */ oldPort = GetPort(); /* created successfully */
SetPort(connectStatusWindowPtr); SetPort(connectStatusWindowPtr);
EraseRect(&bigRect); /* Clipped to window's GrafPort */ EraseRect(&bigRect); /* Clipped to window's GrafPort */
MoveTo(bigRect.h1, 13); MoveTo(bigRect.h1, 13);
DrawStringWidth(0x6000, (Long) statusString, bigRect.h2 - bigRect.h1); DrawStringWidth(0x6000, (Long) statusString, bigRect.h2 - bigRect.h1);
if (cancelMessage) { if (cancelMessage) {
MoveTo(bigRect.h1, 24); MoveTo(bigRect.h1, 24);
DrawStringWidth(0x0002, cancelStr, bigRect.h2 - bigRect.h1); DrawStringWidth(0x0002, cancelStr, bigRect.h2 - bigRect.h1);
} }
SetPort(oldPort); SetPort(oldPort);
} }
#undef wrNum #undef wrNum
#undef cancelStr #undef cancelStr
} }
/*********************************************************************** /***********************************************************************
* DisplayConnectStatusFromTool - Can be passed to Marinetti * DisplayConnectStatusFromTool - Can be passed to Marinetti
***********************************************************************/ ***********************************************************************/
#pragma databank 1 /* Set data bank register to access globals. */ #pragma databank 1 /* Set data bank register to access globals. */
#pragma toolparms 1 /* Use tool-style stack model */ #pragma toolparms 1 /* Use tool-style stack model */
void DisplayConnectStatusFromTool (char *statusString) { void DisplayConnectStatusFromTool (char *statusString) {
DisplayConnectStatus(statusString, TRUE); DisplayConnectStatus(statusString, TRUE);
} }
#pragma toolparms 0 /* Use ORCA stack model */ #pragma toolparms 0 /* Use ORCA stack model */
#pragma databank 0 /* Must restore data bank register on exit */ #pragma databank 0 /* Must restore data bank register on exit */
/*********************************************************************** /***********************************************************************
* CloseConnectStatusWindow - Close connect status window (if open) * CloseConnectStatusWindow - Close connect status window (if open)
***********************************************************************/ ***********************************************************************/
void CloseConnectStatusWindow (void) { void CloseConnectStatusWindow (void) {
if (connectStatusWindowPtr != NULL) { if (connectStatusWindowPtr != NULL) {
CloseWindow(connectStatusWindowPtr); CloseWindow(connectStatusWindowPtr);
connectStatusWindowPtr = NULL; connectStatusWindowPtr = NULL;
} }
} }
/*********************************************************************** /***********************************************************************
* ConnectTCPIP - Try to establish a TCP/IP connection through Marinetti * ConnectTCPIP - Try to establish a TCP/IP connection through Marinetti
***********************************************************************/ ***********************************************************************/
BOOLEAN ConnectTCPIP (void) BOOLEAN ConnectTCPIP (void)
{ {
BOOLEAN connected = FALSE; /* Are we connected to the network now? */ BOOLEAN connected = FALSE; /* Are we connected to the network now? */
if (TCPIPGetConnectStatus() == FALSE) { /* If no TCP/IP connection... */ if (TCPIPGetConnectStatus() == FALSE) { /* If no TCP/IP connection... */
WaitCursor(); WaitCursor();
TCPIPConnect(&DisplayConnectStatusFromTool); TCPIPConnect(&DisplayConnectStatusFromTool);
if (!toolerror()) if (!toolerror())
connected = TRUE; connected = TRUE;
CloseConnectStatusWindow(); CloseConnectStatusWindow();
InitCursor(); InitCursor();
} }
else /* Already connected */ else /* Already connected */
return TRUE; return TRUE;
if (connected) if (connected)
return TRUE; return TRUE;
return FALSE; return FALSE;
} }
/*********************************************************************** /***********************************************************************
@ -222,77 +222,77 @@ BOOLEAN ConnectTCPIP (void)
***********************************************************************/ ***********************************************************************/
BOOLEAN GetIpid (void) BOOLEAN GetIpid (void)
{ {
#define baseDisplayNum 5900 #define baseDisplayNum 5900
int i; int i;
long hostPort; long hostPort;
cvtRec hostInfo; cvtRec hostInfo;
static dnrBuffer dnrInfo; static dnrBuffer dnrInfo;
unsigned long initialTime; unsigned long initialTime;
/* Find ":" character that delimits name (or IP) from display number */ /* Find ":" character that delimits name (or IP) from display number */
for (i = vncServer[0]; isdigit(vncServer[i]) && i>0; i--); for (i = vncServer[0]; isdigit(vncServer[i]) && i>0; i--);
/* Set port to connect to */ /* Set port to connect to */
if (sscanf(&vncServer[i], ":%ld", &hostPort) == 0) if (sscanf(&vncServer[i], ":%ld", &hostPort) == 0)
hostPort = 0; hostPort = 0;
hostPort += baseDisplayNum; hostPort += baseDisplayNum;
/* Modify the string so it only contains the hostname or IP */ /* Modify the string so it only contains the hostname or IP */
if (vncServer[i] == ':') { if (vncServer[i] == ':') {
vncServer[0] = i - 1; vncServer[0] = i - 1;
vncServer[i] = 0; vncServer[i] = 0;
} }
/* If it's an IP address, then put it in the record */ /* If it's an IP address, then put it in the record */
if (TCPIPValidateIPString(vncServer)) if (TCPIPValidateIPString(vncServer))
TCPIPConvertIPToHex(&hostInfo, vncServer); TCPIPConvertIPToHex(&hostInfo, vncServer);
else { /* Do a DNS lookup */ else { /* Do a DNS lookup */
hostInfo.cvtPort = TCPIPMangleDomainName(0xF800, vncServer); hostInfo.cvtPort = TCPIPMangleDomainName(0xF800, vncServer);
TCPIPDNRNameToIP(vncServer, &dnrInfo); TCPIPDNRNameToIP(vncServer, &dnrInfo);
if (toolerror()) if (toolerror())
return FALSE; return FALSE;
WaitCursor(); WaitCursor();
DisplayConnectStatus("\pResolving domain name...", FALSE); DisplayConnectStatus("\pResolving domain name...", FALSE);
initialTime = TickCount(); initialTime = TickCount();
while (dnrInfo.DNRstatus == DNR_Pending) { while (dnrInfo.DNRstatus == DNR_Pending) {
if (TickCount() >= initialTime + 15*60) if (TickCount() >= initialTime + 15*60)
break; break;
TCPIPPoll(); /* Call TCPIPPoll() so that */ TCPIPPoll(); /* Call TCPIPPoll() so that */
} /* Marinetti can process data */ } /* Marinetti can process data */
CloseConnectStatusWindow(); CloseConnectStatusWindow();
InitCursor(); InitCursor();
if (dnrInfo.DNRstatus == DNR_OK) if (dnrInfo.DNRstatus == DNR_OK)
hostInfo.cvtIPAddress == dnrInfo.DNRIPaddress; hostInfo.cvtIPAddress == dnrInfo.DNRIPaddress;
else else
return FALSE; return FALSE;
} }
hostIpid = TCPIPLogin(userid(), hostInfo.cvtIPAddress, (int) hostPort, hostIpid = TCPIPLogin(userid(), hostInfo.cvtIPAddress, (int) hostPort,
0x0010 /* minimize latency */, 0x0010 /* minimize latency */,
0x0040 /* Normal TTL*/); 0x0040 /* Normal TTL*/);
if (toolerror()) if (toolerror())
return FALSE; return FALSE;
if (TCPIPOpenTCP(hostIpid) == tcperrOK) if (TCPIPOpenTCP(hostIpid) == tcperrOK)
if (!toolerror()) if (!toolerror())
return TRUE; return TRUE;
return FALSE; return FALSE;
#undef baseDisplayNum #undef baseDisplayNum
} }
/* Read data, waiting for up to 15 seconds for the data to be ready */ /* Read data, waiting for up to 15 seconds for the data to be ready */
BOOLEAN DoWaitingReadTCP(unsigned long dataLength) { BOOLEAN DoWaitingReadTCP(unsigned long dataLength) {
unsigned long stopTime; unsigned long stopTime;
BOOLEAN result = FALSE; BOOLEAN result = FALSE;
stopTime = TickCount() + 15 * 60; stopTime = TickCount() + 15 * 60;
do { do {
result = DoReadTCP(dataLength); result = DoReadTCP(dataLength);
} while (result == FALSE && TickCount() < stopTime); } while (result == FALSE && TickCount() < stopTime);
return result; return result;
} }
@ -300,36 +300,36 @@ BOOLEAN DoWaitingReadTCP(unsigned long dataLength) {
/* Fix things when TCPIPReadTCP returns less data than it's supposed to */ /* Fix things when TCPIPReadTCP returns less data than it's supposed to */
BOOLEAN ReadFixup (unsigned long requested, unsigned long returned) { BOOLEAN ReadFixup (unsigned long requested, unsigned long returned) {
static rrBuff theRRBuff; static rrBuff theRRBuff;
SetHandleSize(requested, readBufferHndl); SetHandleSize(requested, readBufferHndl);
if (toolerror()) if (toolerror())
return FALSE; return FALSE;
do { do {
TCPIPPoll(); TCPIPPoll();
if (TCPIPReadTCP(hostIpid, buffTypeNewHandle, NULL, if (TCPIPReadTCP(hostIpid, buffTypeNewHandle, NULL,
requested-returned, &theRRBuff) != tcperrOK) requested-returned, &theRRBuff) != tcperrOK)
return FALSE; return FALSE;
if (toolerror()) if (toolerror())
return FALSE; return FALSE;
if (theRRBuff.rrBuffCount == 0) /* To avoid infinite loops */ if (theRRBuff.rrBuffCount == 0) /* To avoid infinite loops */
return FALSE; return FALSE;
HandToPtr(theRRBuff.rrBuffHandle, (char *)*readBufferHndl + returned, HandToPtr(theRRBuff.rrBuffHandle, (char *)*readBufferHndl + returned,
theRRBuff.rrBuffCount); theRRBuff.rrBuffCount);
returned += theRRBuff.rrBuffCount; returned += theRRBuff.rrBuffCount;
} while (returned < requested); } while (returned < requested);
return TRUE; return TRUE;
} }
/********************************************************************** /**********************************************************************
* DoReadTCP() - Issue TCPIPReadTCP() call w/ appropriate parameters * DoReadTCP() - Issue TCPIPReadTCP() call w/ appropriate parameters
* Return value = did the read succeed? * Return value = did the read succeed?
**********************************************************************/ **********************************************************************/
BOOLEAN DoReadTCP (unsigned long dataLength) { BOOLEAN DoReadTCP (unsigned long dataLength) {
static srBuff theSRBuff; static srBuff theSRBuff;
@ -338,24 +338,24 @@ BOOLEAN DoReadTCP (unsigned long dataLength) {
TCPIPPoll(); TCPIPPoll();
if (TCPIPStatusTCP(hostIpid, &theSRBuff) != tcperrOK) if (TCPIPStatusTCP(hostIpid, &theSRBuff) != tcperrOK)
return FALSE; return FALSE;
if (toolerror()) if (toolerror())
return FALSE; return FALSE;
if (theSRBuff.srRcvQueued < dataLength) if (theSRBuff.srRcvQueued < dataLength)
return FALSE; return FALSE;
if (TCPIPReadTCP(hostIpid, buffTypeHandle, (Ref) readBufferHndl, if (TCPIPReadTCP(hostIpid, buffTypeHandle, (Ref) readBufferHndl,
dataLength, &theRRBuff) != tcperrOK) dataLength, &theRRBuff) != tcperrOK)
return FALSE; return FALSE;
if (toolerror()) if (toolerror())
return FALSE; return FALSE;
if (theRRBuff.rrBuffCount != dataLength) if (theRRBuff.rrBuffCount != dataLength)
return ReadFixup(dataLength, theRRBuff.rrBuffCount); return ReadFixup(dataLength, theRRBuff.rrBuffCount);
return TRUE; return TRUE;
} }
/********************************************************************** /**********************************************************************
@ -375,15 +375,15 @@ BOOLEAN DoVNCHandshaking (void) {
/* Read RFB version string from the server */ /* Read RFB version string from the server */
strcpy(versionString, ""); strcpy(versionString, "");
if (! DoWaitingReadTCP(12)) if (! DoWaitingReadTCP(12))
return FALSE; return FALSE;
HLock(readBufferHndl); HLock(readBufferHndl);
if ( ! ((strncmp((char *)*readBufferHndl, "RFB ", 4) == 0) && if ( ! ((strncmp((char *)*readBufferHndl, "RFB ", 4) == 0) &&
(strncmp((char *)*readBufferHndl+4, RFBMAJORVERSIONSTR, 3) >= 0) && (strncmp((char *)*readBufferHndl+4, RFBMAJORVERSIONSTR, 3) >= 0) &&
(strncmp((char *)*readBufferHndl+7, ".", 1) == 0) && (strncmp((char *)*readBufferHndl+7, ".", 1) == 0) &&
(strncmp((char *)*readBufferHndl+11, "\n", 1) == 0))) { (strncmp((char *)*readBufferHndl+11, "\n", 1) == 0))) {
HUnlock(readBufferHndl); HUnlock(readBufferHndl);
InitCursor(); InitCursor();
AlertWindow(awResource, NULL, badRFBVersionAlert); AlertWindow(awResource, NULL, badRFBVersionAlert);
alerted = TRUE; alerted = TRUE;
return FALSE; return FALSE;
} }
@ -391,54 +391,54 @@ BOOLEAN DoVNCHandshaking (void) {
strcpy(versionString, RFBVERSIONSTR); strcpy(versionString, RFBVERSIONSTR);
if (TCPIPWriteTCP(hostIpid, versionString, 12, TRUE, FALSE)) { if (TCPIPWriteTCP(hostIpid, versionString, 12, TRUE, FALSE)) {
return FALSE; return FALSE;
} }
if (toolerror()) { if (toolerror()) {
return FALSE; return FALSE;
} }
if (! DoWaitingReadTCP(4)) { /* Read authentication type */ if (! DoWaitingReadTCP(4)) { /* Read authentication type */
return FALSE; return FALSE;
} }
HLock(readBufferHndl); HLock(readBufferHndl);
switch ((unsigned long) (**readBufferHndl)) { switch ((unsigned long) (**readBufferHndl)) {
case vncConnectionFailed: HUnlock(readBufferHndl); case vncConnectionFailed: HUnlock(readBufferHndl);
if (! DoWaitingReadTCP(4)) if (! DoWaitingReadTCP(4))
return FALSE; return FALSE;
if (toolerror()) if (toolerror())
return FALSE; return FALSE;
HLock(readBufferHndl); HLock(readBufferHndl);
reasonLength = SwapBytes4(**readBufferHndl); reasonLength = SwapBytes4(**readBufferHndl);
HUnlock(readBufferHndl); HUnlock(readBufferHndl);
if (! DoWaitingReadTCP(reasonLength)) if (! DoWaitingReadTCP(reasonLength))
return FALSE; return FALSE;
if (toolerror()) if (toolerror())
return FALSE; return FALSE;
SetHandleSize( SetHandleSize(
GetHandleSize(readBufferHndl)+1, GetHandleSize(readBufferHndl)+1,
readBufferHndl); readBufferHndl);
if (! toolerror()) { if (! toolerror()) {
HLock(readBufferHndl); HLock(readBufferHndl);
*((char *) *readBufferHndl+reasonLength) *((char *) *readBufferHndl+reasonLength)
= 0; = 0;
InitCursor(); InitCursor();
AlertWindow(awResource, AlertWindow(awResource,
(Pointer) readBufferHndl, (Pointer) readBufferHndl,
connectionFailedAlert); connectionFailedAlert);
alerted = TRUE; alerted = TRUE;
HUnlock(readBufferHndl); HUnlock(readBufferHndl);
} }
return FALSE; return FALSE;
case vncNoAuthentication: break; case vncNoAuthentication: break;
case vncVNCAuthentication: if (DoDES()) case vncVNCAuthentication: if (DoDES())
break; break;
HUnlock(readBufferHndl); HUnlock(readBufferHndl);
return FALSE; return FALSE;
default: HUnlock(readBufferHndl); default: HUnlock(readBufferHndl);
AlertWindow(awResource, NULL, AlertWindow(awResource, NULL,
badAuthTypeAlert); badAuthTypeAlert);
alerted = TRUE; alerted = TRUE;
return FALSE; return FALSE;
} }
HUnlock(readBufferHndl); HUnlock(readBufferHndl);
@ -452,66 +452,66 @@ BOOLEAN DoVNCHandshaking (void) {
* DoDES() - Try to do DES (aka VNC) authentication * DoDES() - Try to do DES (aka VNC) authentication
**********************************************************************/ **********************************************************************/
BOOLEAN DoDES (void) { BOOLEAN DoDES (void) {
/* This reverses the order of the low 7 bits of a byte. */ /* This reverses the order of the low 7 bits of a byte. */
/* Uses the high bit (7) as scratch space. */ /* Uses the high bit (7) as scratch space. */
#define SwitchBits(x) do { x &= 0x7f; /* Clear 7 */ \ #define SwitchBits(x) do { x &= 0x7f; /* Clear 7 */ \
x ^= (x << 7) & 0x80; /* 0 -> 7 */ \ x ^= (x << 7) & 0x80; /* 0 -> 7 */ \
x &= 0xfe; /* Clear 0 */ \ x &= 0xfe; /* Clear 0 */ \
x ^= (x >> 6) & 0x01; /* 6 -> 0 */ \ x ^= (x >> 6) & 0x01; /* 6 -> 0 */ \
x &= 0xbf; /* Clear 6 */ \ x &= 0xbf; /* Clear 6 */ \
x ^= (x >> 1) & 0x40; /* 7 -> 6 */ \ x ^= (x >> 1) & 0x40; /* 7 -> 6 */ \
x &= 0x7f; /* Clear 7 */ \ x &= 0x7f; /* Clear 7 */ \
x ^= (x << 6) & 0x80; /* 1 -> 7 */ \ x ^= (x << 6) & 0x80; /* 1 -> 7 */ \
x &= 0xfd; /* Clear 1 */ \ x &= 0xfd; /* Clear 1 */ \
x ^= (x >> 4) & 0x02; /* 5 -> 1 */ \ x ^= (x >> 4) & 0x02; /* 5 -> 1 */ \
x &= 0xdf; /* Clear 5 */ \ x &= 0xdf; /* Clear 5 */ \
x ^= (x >> 2) & 0x20; /* 7 -> 5 */ \ x ^= (x >> 2) & 0x20; /* 7 -> 5 */ \
x &= 0x7f; /* Clear 7 */ \ x &= 0x7f; /* Clear 7 */ \
x ^= (x << 5) & 0x80; /* 2 -> 7 */ \ x ^= (x << 5) & 0x80; /* 2 -> 7 */ \
x &= 0xfb; /* Clear 2 */ \ x &= 0xfb; /* Clear 2 */ \
x ^= (x >> 2) & 0x04; /* 4 -> 2 */ \ x ^= (x >> 2) & 0x04; /* 4 -> 2 */ \
x &= 0xef; /* Clear 4 */ \ x &= 0xef; /* Clear 4 */ \
x ^= (x >> 3) & 0x10; /* 7 -> 4 */ \ x ^= (x >> 3) & 0x10; /* 7 -> 4 */ \
} while (0) } while (0)
#define statusOK SwapBytes4(0) #define statusOK SwapBytes4(0)
#define statusFailed SwapBytes4(1) #define statusFailed SwapBytes4(1)
#define statusTooMany SwapBytes4(2) #define statusTooMany SwapBytes4(2)
unsigned char theResponse[16]; unsigned char theResponse[16];
unsigned char theKey[8]; unsigned char theKey[8];
BOOLEAN success; BOOLEAN success;
BOOLEAN startedCrypto = FALSE; /* True if we started CryptoTool */ BOOLEAN startedCrypto = FALSE; /* True if we started CryptoTool */
Handle dpSpace; Handle dpSpace;
int i; int i;
DisplayConnectStatus("\pAuthenticating...", FALSE); DisplayConnectStatus("\pAuthenticating...", FALSE);
if (!(CryptoStatus() && !toolerror())) { /* if Crypto isn't started */ if (!(CryptoStatus() && !toolerror())) { /* if Crypto isn't started */
startedCrypto = TRUE; startedCrypto = TRUE;
LoadOneTool(129, 0x100); /* load Crypto tool 1.0+ */ LoadOneTool(129, 0x100); /* load Crypto tool 1.0+ */
if (toolerror()) { /* Check that it is available */ if (toolerror()) { /* Check that it is available */
AlertWindow(awResource, NULL, noCryptoError); AlertWindow(awResource, NULL, noCryptoError);
alerted = TRUE; alerted = TRUE;
return FALSE; return FALSE;
} }
dpSpace = NewHandle(0x0100, userid(), dpSpace = NewHandle(0x0100, userid(),
attrLocked|attrFixed|attrNoCross|attrBank, 0x00000000); attrLocked|attrFixed|attrNoCross|attrBank, 0x00000000);
CryptoStartUp((Word) *dpSpace); CryptoStartUp((Word) *dpSpace);
} }
if (! (DoWaitingReadTCP(16))) { if (! (DoWaitingReadTCP(16))) {
success = FALSE; success = FALSE;
goto UnloadCrypto; goto UnloadCrypto;
} }
/* Pad password with nulls, as per VNC precedent */ /* Pad password with nulls, as per VNC precedent */
for (i=vncPassword[0]+1; i<=8; i++) for (i=vncPassword[0]+1; i<=8; i++)
vncPassword[i] = 0; vncPassword[i] = 0;
/* Flip bits around to be in format expected by CryptoTool */ /* Flip bits around to be in format expected by CryptoTool */
for (i=1; i<9; i++) for (i=1; i<9; i++)
SwitchBits(vncPassword[i]); SwitchBits(vncPassword[i]);
/* Shift password to form 56-bit key */ /* Shift password to form 56-bit key */
vncPassword[1] <<= 1; vncPassword[1] <<= 1;
vncPassword[1] += (vncPassword[2] & 0x7f) >> 6; vncPassword[1] += (vncPassword[2] & 0x7f) >> 6;
@ -536,49 +536,49 @@ BOOLEAN DoDES (void) {
HUnlock(readBufferHndl); HUnlock(readBufferHndl);
if (TCPIPWriteTCP(hostIpid, theResponse, sizeof(theResponse), TRUE, FALSE)) if (TCPIPWriteTCP(hostIpid, theResponse, sizeof(theResponse), TRUE, FALSE))
{ {
success = FALSE; success = FALSE;
goto UnloadCrypto; goto UnloadCrypto;
} }
if (toolerror()) { if (toolerror()) {
success = FALSE; success = FALSE;
goto UnloadCrypto; goto UnloadCrypto;
} }
if (! (DoWaitingReadTCP(4))) { if (! (DoWaitingReadTCP(4))) {
success = FALSE; success = FALSE;
goto UnloadCrypto; goto UnloadCrypto;
} }
HLock(readBufferHndl); HLock(readBufferHndl);
if ((**readBufferHndl) == statusOK) { if ((**readBufferHndl) == statusOK) {
success = TRUE; success = TRUE;
goto UnloadCrypto; goto UnloadCrypto;
} }
else if ((**readBufferHndl) == statusFailed) { else if ((**readBufferHndl) == statusFailed) {
InitCursor(); InitCursor();
AlertWindow(awResource, NULL, authFailedError); AlertWindow(awResource, NULL, authFailedError);
alerted = TRUE; alerted = TRUE;
success = FALSE; success = FALSE;
goto UnloadCrypto; goto UnloadCrypto;
} }
else if ((**readBufferHndl) == statusTooMany) { else if ((**readBufferHndl) == statusTooMany) {
InitCursor(); InitCursor();
AlertWindow(awResource, NULL, authTooManyError); AlertWindow(awResource, NULL, authTooManyError);
alerted = TRUE; alerted = TRUE;
success = FALSE; success = FALSE;
goto UnloadCrypto; goto UnloadCrypto;
} }
/* else */ /* else */
success = FALSE; success = FALSE;
UnloadCrypto: UnloadCrypto:
HUnlock(readBufferHndl); HUnlock(readBufferHndl);
if (startedCrypto) { if (startedCrypto) {
CryptoShutDown(); /* Shut down Crypto tool set */ CryptoShutDown(); /* Shut down Crypto tool set */
DisposeHandle(dpSpace); DisposeHandle(dpSpace);
UnloadOneTool(129); UnloadOneTool(129);
} }
return success; return success;
@ -592,15 +592,15 @@ BOOLEAN DoDES (void) {
* FinishVNCHandshaking() - Complete VNC protocol initialization * FinishVNCHandshaking() - Complete VNC protocol initialization
**********************************************************************/ **********************************************************************/
BOOLEAN FinishVNCHandshaking (void) { BOOLEAN FinishVNCHandshaking (void) {
#define screenTooBigError 2010 #define screenTooBigError 2010
unsigned char sharedFlag; unsigned char sharedFlag;
unsigned long serverNameLen; unsigned long serverNameLen;
unsigned long encodingInfoSize; unsigned long encodingInfoSize;
struct PixelFormat { struct PixelFormat {
unsigned char messageType; unsigned char messageType;
unsigned char padding1; unsigned char padding1;
unsigned int padding2; unsigned int padding2;
unsigned char bitsPerPixel; unsigned char bitsPerPixel;
unsigned char depth; unsigned char depth;
unsigned char bigEndianFlag; unsigned char bigEndianFlag;
unsigned char trueColorFlag; unsigned char trueColorFlag;
@ -612,24 +612,24 @@ BOOLEAN FinishVNCHandshaking (void) {
unsigned char blueShift; unsigned char blueShift;
unsigned char padding3; unsigned char padding3;
unsigned int padding4; unsigned int padding4;
} pixelFormat = { } pixelFormat = {
0 /* message type - SetPixelFormat */, 0 /* message type - SetPixelFormat */,
0,0 /* padding */, 0,0 /* padding */,
8 /* bpp */, 8 /* bpp */,
8 /* depth */, 8 /* depth */,
0 /* big endian flag - irrelevant */, 0 /* big endian flag - irrelevant */,
TRUE /* true color flag */, TRUE /* true color flag */,
SwapBytes2(7) /* red-max */, SwapBytes2(7) /* red-max */,
SwapBytes2(7) /* green-max */, SwapBytes2(7) /* green-max */,
SwapBytes2(3) /* blue-max */, SwapBytes2(3) /* blue-max */,
0 /* red-shift */, 0 /* red-shift */,
3 /* green-shift */, 3 /* green-shift */,
6 /* blue-shift */, 6 /* blue-shift */,
0,0 /* padding */ 0,0 /* padding */
}; };
struct Encodings { struct Encodings {
unsigned char messageType; unsigned char messageType;
unsigned char padding; unsigned char padding;
unsigned int numberOfEncodings; unsigned int numberOfEncodings;
unsigned long firstEncoding; unsigned long firstEncoding;
@ -637,91 +637,91 @@ BOOLEAN FinishVNCHandshaking (void) {
unsigned long thirdEncoding; unsigned long thirdEncoding;
unsigned long fourthEncoding; unsigned long fourthEncoding;
} encodings = { } encodings = {
2, /* Message Type - SetEncodings */ 2, /* Message Type - SetEncodings */
0, /* padding */ 0, /* padding */
0, /* number of encodings - set below */ 0, /* number of encodings - set below */
SwapBytes4(0xffffff21), /* DesktopSize pseudo-encoding */ SwapBytes4(0xffffff21), /* DesktopSize pseudo-encoding */
SwapBytes4(0xffffff11), /* Cursor pseudo-encoding */ SwapBytes4(0xffffff11), /* Cursor pseudo-encoding */
SwapBytes4(1), /* CopyRect encoding */ SwapBytes4(1), /* CopyRect encoding */
SwapBytes4(5) /* Hextile encoding */ SwapBytes4(5) /* Hextile encoding */
/* Per the spec, raw encoding is supported even though /* Per the spec, raw encoding is supported even though
* it is not listed here explicitly. * it is not listed here explicitly.
*/ */
}; };
DisplayConnectStatus("\pNegotiating protocol options...", FALSE); DisplayConnectStatus("\pNegotiating protocol options...", FALSE);
/* ClientInitialisation */ /* ClientInitialisation */
sharedFlag = !!requestSharedSession; sharedFlag = !!requestSharedSession;
if (TCPIPWriteTCP(hostIpid, &sharedFlag, sizeof(sharedFlag), TRUE, FALSE)) if (TCPIPWriteTCP(hostIpid, &sharedFlag, sizeof(sharedFlag), TRUE, FALSE))
return FALSE; return FALSE;
if (toolerror()) if (toolerror())
return FALSE; return FALSE;
/* ServerInitialisation */ /* ServerInitialisation */
if (! DoWaitingReadTCP(2)) if (! DoWaitingReadTCP(2))
return FALSE; return FALSE;
HLock(readBufferHndl); HLock(readBufferHndl);
fbWidth = SwapBytes2(**(unsigned **)readBufferHndl); fbWidth = SwapBytes2(**(unsigned **)readBufferHndl);
HUnlock(readBufferHndl); HUnlock(readBufferHndl);
if (! DoWaitingReadTCP(2)) if (! DoWaitingReadTCP(2))
return FALSE; return FALSE;
HLock(readBufferHndl); HLock(readBufferHndl);
fbHeight = SwapBytes2(**(unsigned **)readBufferHndl); fbHeight = SwapBytes2(**(unsigned **)readBufferHndl);
HUnlock(readBufferHndl); HUnlock(readBufferHndl);
if ((fbWidth > 16384) || (fbHeight > 16384)) { if ((fbWidth > 16384) || (fbHeight > 16384)) {
AlertWindow(awResource, NULL, screenTooBigError); AlertWindow(awResource, NULL, screenTooBigError);
return FALSE; return FALSE;
} }
/* Ignore server's pixel format and display name */ /* Ignore server's pixel format and display name */
if (! DoWaitingReadTCP(16)) if (! DoWaitingReadTCP(16))
return FALSE; return FALSE;
if (! DoWaitingReadTCP(4)) if (! DoWaitingReadTCP(4))
return FALSE; return FALSE;
HLock(readBufferHndl); HLock(readBufferHndl);
serverNameLen = SwapBytes4(**(unsigned long **)readBufferHndl); serverNameLen = SwapBytes4(**(unsigned long **)readBufferHndl);
HUnlock(readBufferHndl); HUnlock(readBufferHndl);
if (! DoWaitingReadTCP(serverNameLen)) if (! DoWaitingReadTCP(serverNameLen))
return FALSE; return FALSE;
if (TCPIPWriteTCP(hostIpid, &pixelFormat.messageType, sizeof(pixelFormat), if (TCPIPWriteTCP(hostIpid, &pixelFormat.messageType, sizeof(pixelFormat),
TRUE, FALSE)) TRUE, FALSE))
return FALSE; return FALSE;
if (toolerror()) if (toolerror())
return FALSE; return FALSE;
if (useHextile) { if (useHextile) {
encodings.numberOfEncodings = SwapBytes2(4); encodings.numberOfEncodings = SwapBytes2(4);
encodingInfoSize = sizeof(encodings); encodingInfoSize = sizeof(encodings);
} else { } else {
/* No Hextile */ /* No Hextile */
encodings.numberOfEncodings = SwapBytes2(3); encodings.numberOfEncodings = SwapBytes2(3);
encodingInfoSize = sizeof(encodings) - 4; encodingInfoSize = sizeof(encodings) - 4;
} }
if (TCPIPWriteTCP(hostIpid, &encodings.messageType, encodingInfoSize, if (TCPIPWriteTCP(hostIpid, &encodings.messageType, encodingInfoSize,
TRUE, FALSE)) TRUE, FALSE))
return FALSE; return FALSE;
if (toolerror()) if (toolerror())
return FALSE; return FALSE;
return TRUE; return TRUE;
#undef screenTooBigError #undef screenTooBigError
} }
/********************************************************************** /**********************************************************************
* CloseTCPConnection() - Close the TCP connection to the host * CloseTCPConnection() - Close the TCP connection to the host
**********************************************************************/ **********************************************************************/
void CloseTCPConnection (void) { void CloseTCPConnection (void) {
TCPIPCloseTCP(hostIpid); TCPIPCloseTCP(hostIpid);
WaitCursor(); WaitCursor();
DisplayConnectStatus("\pClosing VNC session...", FALSE); DisplayConnectStatus("\pClosing VNC session...", FALSE);
do { do {
TCPIPPoll(); TCPIPPoll();
TCPIPLogout(hostIpid); TCPIPLogout(hostIpid);
} while (toolerror() == terrSOCKETOPEN); } while (toolerror() == terrSOCKETOPEN);
CloseConnectStatusWindow(); CloseConnectStatusWindow();
InitCursor(); InitCursor();

View File

@ -1,6 +1,6 @@
/******************************************************************** /********************************************************************
* vncsession.h - functions for establishing connection to VNC server * vncsession.h - functions for establishing connection to VNC server
* and communicating with it * and communicating with it
********************************************************************/ ********************************************************************/
#include <types.h> #include <types.h>
@ -8,11 +8,11 @@
#define RFBVERSIONSTR "RFB 003.003\n" #define RFBVERSIONSTR "RFB 003.003\n"
#define RFBMAJORVERSIONSTR "003" #define RFBMAJORVERSIONSTR "003"
#define SwapBytes2(x) (((unsigned int)x << 8) | ((unsigned int)x >> 8)) #define SwapBytes2(x) (((unsigned int)x << 8) | ((unsigned int)x >> 8))
#define SwapBytes4(x) (((unsigned long)x << 24) | \ #define SwapBytes4(x) (((unsigned long)x << 24) | \
((unsigned long)x >> 24) | \ ((unsigned long)x >> 24) | \
(((unsigned long)x & 0x0000FF00) << 8) | \ (((unsigned long)x & 0x0000FF00) << 8) | \
(((unsigned long)x & 0x00FF0000) >> 8)) (((unsigned long)x & 0x00FF0000) >> 8))
extern BOOLEAN readError; extern BOOLEAN readError;

View File

@ -37,44 +37,44 @@
#include "keyboard.h" #include "keyboard.h"
#include "clipboard.h" #include "clipboard.h"
#define noMarinettiError 2001 #define noMarinettiError 2001
#define outOfMemoryError 2002 #define outOfMemoryError 2002
#define disconnectTCPIPAlert 2003 #define disconnectTCPIPAlert 2003
#define NCWindow 1000 /* Offset for "New Connection" */ #define NCWindow 1000 /* Offset for "New Connection" */
/* window and its controls */ /* window and its controls */
#define winNewConnection 1 #define winNewConnection 1
#define btnConnect 1 #define btnConnect 1
#define btnCancel 2 #define btnCancel 2
#define linServer 3 #define linServer 3
#define txtServer 4 #define txtServer 4
#define txtServerInfo 5 #define txtServerInfo 5
#define txtPassword 6 #define txtPassword 6
#define linPassword 7 #define linPassword 7
#define txtDisplay 8 #define txtDisplay 8
#define rectDisplay 9 #define rectDisplay 9
#define txtColor 10 #define txtColor 10
#define txtGray 11 #define txtGray 11
#define rad320 12 #define rad320 12
#define rad640 13 #define rad640 13
#define chkShared 16 #define chkShared 16
#define chkClipboard 17 #define chkClipboard 17
#define txtTransfers 23 #define txtTransfers 23
#define chkEmul3Btn 18 #define chkEmul3Btn 18
#define chkViewOnly 19 #define chkViewOnly 19
#define txtPreferredEncoding 24 #define txtPreferredEncoding 24
#define radRaw 25 #define radRaw 25
#define radHextile 26 #define radHextile 26
BOOLEAN done = FALSE; /* are we done, yet? */ BOOLEAN done = FALSE; /* are we done, yet? */
EventRecord myEvent; /* event record for menu mode */ EventRecord myEvent; /* event record for menu mode */
GrafPortPtr newConnWindow; /* pointer to new connection window */ GrafPortPtr newConnWindow; /* pointer to new connection window */
BOOLEAN vncConnected = FALSE; /* are we connected to a VNC host */ BOOLEAN vncConnected = FALSE; /* are we connected to a VNC host */
int menuOffset; /* Indicates which menu bar is active */ int menuOffset; /* Indicates which menu bar is active */
Ref startStopParm; /* tool start/shutdown parameter */ Ref startStopParm; /* tool start/shutdown parameter */
BOOLEAN colorTablesComplete = FALSE; /* Are the big color tables complete */ BOOLEAN colorTablesComplete = FALSE; /* Are the big color tables complete */
/* Connection options */ /* Connection options */
@ -95,9 +95,9 @@ char vncPassword[10];
#pragma databank 1 #pragma databank 1
void DrawContents (void) { void DrawContents (void) {
PenNormal(); /* use a "normal" pen */ PenNormal(); /* use a "normal" pen */
DrawControls(GetPort()); /* draw controls in window */ DrawControls(GetPort()); /* draw controls in window */
} }
#pragma databank 0 #pragma databank 0
@ -106,12 +106,12 @@ void DrawContents (void) {
***************************************************************/ ***************************************************************/
void DoAbout (void) { void DoAbout (void) {
#define alertID 1 /* alert string resource ID */ #define alertID 1 /* alert string resource ID */
AlertWindow(awCString+awResource, NULL, alertID); AlertWindow(awCString+awResource, NULL, alertID);
#undef alertID #undef alertID
} }
/*************************************************************** /***************************************************************
* DoNewConnection - Show the New Connection window * DoNewConnection - Show the New Connection window
@ -119,183 +119,183 @@ void DoAbout (void) {
void DoNewConnection (void) { void DoNewConnection (void) {
unsigned int masterSCB; unsigned int masterSCB;
masterSCB = GetMasterSCB(); masterSCB = GetMasterSCB();
MakeThisCtlTarget(GetCtlHandleFromID(newConnWindow, linServer)); MakeThisCtlTarget(GetCtlHandleFromID(newConnWindow, linServer));
ShowWindow(newConnWindow); ShowWindow(newConnWindow);
SelectWindow(newConnWindow); SelectWindow(newConnWindow);
} }
/*************************************************************** /***************************************************************
* DoClose - Close the frontmost window/connection * DoClose - Close the frontmost window/connection
* Parameters: * Parameters:
* wPtr - window to close * wPtr - window to close
***************************************************************/ ***************************************************************/
void DoClose (GrafPortPtr wPtr) { void DoClose (GrafPortPtr wPtr) {
if (wPtr == newConnWindow) { if (wPtr == newConnWindow) {
HideWindow(wPtr); HideWindow(wPtr);
} }
else if (wPtr && vncConnected) { /* Close VNC session window */ else if (wPtr && vncConnected) { /* Close VNC session window */
CloseWindow(wPtr); CloseWindow(wPtr);
CloseTCPConnection(); CloseTCPConnection();
vncConnected = FALSE; vncConnected = FALSE;
EnableMItem(fileNewConnection); EnableMItem(fileNewConnection);
InitMenus(0); InitMenus(0);
myEvent.wmTaskMask = 0x001F79FF; /* let TaskMaster handle keys again */ myEvent.wmTaskMask = 0x001F79FF; /* let TaskMaster handle keys again */
if (cursor) { if (cursor) {
InitCursor(); InitCursor();
free(cursor); free(cursor);
} }
}; };
} }
/*************************************************************** /***************************************************************
* DoLEEdit - Handle edit menu items for LineEdit controls * DoLEEdit - Handle edit menu items for LineEdit controls
* Parameters: * Parameters:
* editAction: Action selected from edit menu * editAction: Action selected from edit menu
***************************************************************/ ***************************************************************/
void DoLEEdit (int editAction) { void DoLEEdit (int editAction) {
CtlRecHndl ctl; /* target control handle */ CtlRecHndl ctl; /* target control handle */
unsigned long id; /* control ID */ unsigned long id; /* control ID */
GrafPortPtr port; /* caller's GrafPort */ GrafPortPtr port; /* caller's GrafPort */
port = GetPort(); port = GetPort();
SetPort(newConnWindow); SetPort(newConnWindow);
ctl = FindTargetCtl(); ctl = FindTargetCtl();
id = GetCtlID(ctl); id = GetCtlID(ctl);
if ((id == linServer) || (id == linPassword)) { if ((id == linServer) || (id == linPassword)) {
LEFromScrap(); LEFromScrap();
switch (editAction) { switch (editAction) {
case editCut: if (id == linServer) { case editCut: if (id == linServer) {
LECut((LERecHndl) GetCtlTitle(ctl)); LECut((LERecHndl) GetCtlTitle(ctl));
}; };
LEToScrap(); LEToScrap();
break; break;
case editCopy: if (id == linServer) { case editCopy: if (id == linServer) {
LECopy((LERecHndl) GetCtlTitle(ctl)); LECopy((LERecHndl) GetCtlTitle(ctl));
}; };
LEToScrap(); LEToScrap();
break; break;
case editPaste: LEPaste((LERecHndl) GetCtlTitle(ctl)); case editPaste: LEPaste((LERecHndl) GetCtlTitle(ctl));
break; break;
case editClear: LEDelete((LERecHndl) GetCtlTitle(ctl)); case editClear: LEDelete((LERecHndl) GetCtlTitle(ctl));
break; break;
}; };
}; };
SetPort(port); SetPort(port);
} }
/*************************************************************** /***************************************************************
* HandleMenu - Initialize the menu bar. * HandleMenu - Initialize the menu bar.
***************************************************************/ ***************************************************************/
void HandleMenu (void) { void HandleMenu (void) {
int menuNum, menuItemNum; /* menu number & menu item number */ int menuNum, menuItemNum; /* menu number & menu item number */
menuNum = myEvent.wmTaskData >> 16; menuNum = myEvent.wmTaskData >> 16;
menuItemNum = myEvent.wmTaskData; menuItemNum = myEvent.wmTaskData;
switch (menuItemNum) { /* go handle the menu */ switch (menuItemNum) { /* go handle the menu */
case appleAbout: DoAbout(); break; case appleAbout: DoAbout(); break;
case fileNewConnection: DoNewConnection(); break; case fileNewConnection: DoNewConnection(); break;
case fileClose: DoClose(FrontWindow()); break; case fileClose: DoClose(FrontWindow()); break;
case fileQuit: Quit(); break; case fileQuit: Quit(); break;
case editCut: DoLEEdit(editCut); break; case editCut: DoLEEdit(editCut); break;
case editCopy: DoLEEdit(editCopy); break; case editCopy: DoLEEdit(editCopy); break;
case editPaste: DoLEEdit(editPaste); break; case editPaste: DoLEEdit(editPaste); break;
case editClear: DoLEEdit(editClear); break; case editClear: DoLEEdit(editClear); break;
case editShowClipboard: ShowClipboard(0x8000, 0); break; case editShowClipboard: ShowClipboard(0x8000, 0); break;
case editSendClipboard: DoSendClipboard(); break; case editSendClipboard: DoSendClipboard(); break;
} }
HiliteMenu(FALSE, menuNum); /* unhighlight the menu */ HiliteMenu(FALSE, menuNum); /* unhighlight the menu */
} }
/*************************************************************** /***************************************************************
* HandleControl - Handle a control press in the New Conn. window * HandleControl - Handle a control press in the New Conn. window
***************************************************************/ ***************************************************************/
void HandleControl (void) { void HandleControl (void) {
switch (myEvent.wmTaskData4) { switch (myEvent.wmTaskData4) {
case btnConnect: DoConnect(); break; case btnConnect: DoConnect(); break;
case btnCancel: DoClose(newConnWindow); break; case btnCancel: DoClose(newConnWindow); break;
case txtColor: SetCtlValueByID(TRUE, newConnWindow, case txtColor: SetCtlValueByID(TRUE, newConnWindow,
rad320); rad320);
/* Fall through */ /* Fall through */
case rad320: hRez = 320; /* "320x200" */ break; case rad320: hRez = 320; /* "320x200" */ break;
case txtGray: SetCtlValueByID(TRUE, newConnWindow, case txtGray: SetCtlValueByID(TRUE, newConnWindow,
rad640); rad640);
/* Fall through */ /* Fall through */
case rad640: hRez = 640; /* "640x200" */ break; case rad640: hRez = 640; /* "640x200" */ break;
case chkShared: requestSharedSession = !requestSharedSession; case chkShared: requestSharedSession = !requestSharedSession;
break; break;
case chkClipboard: allowClipboardTransfers = !allowClipboardTransfers; case chkClipboard: allowClipboardTransfers = !allowClipboardTransfers;
break; break;
case chkEmul3Btn: emulate3ButtonMouse = !emulate3ButtonMouse; break; case chkEmul3Btn: emulate3ButtonMouse = !emulate3ButtonMouse; break;
case chkViewOnly: viewOnlyMode = !viewOnlyMode; break; case chkViewOnly: viewOnlyMode = !viewOnlyMode; break;
case txtTransfers: allowClipboardTransfers = !allowClipboardTransfers; case txtTransfers: allowClipboardTransfers = !allowClipboardTransfers;
SetCtlValueByID(allowClipboardTransfers, SetCtlValueByID(allowClipboardTransfers,
newConnWindow, chkClipboard); break; newConnWindow, chkClipboard); break;
case radRaw: useHextile = FALSE; break; case radRaw: useHextile = FALSE; break;
case radHextile: useHextile = TRUE; break; case radHextile: useHextile = TRUE; break;
}; };
} }
/*************************************************************** /***************************************************************
* InitMenus - Initialize the menu bar. * InitMenus - Initialize the menu bar.
***************************************************************/ ***************************************************************/
void InitMenus (int offset) { void InitMenus (int offset) {
#define menuID 1 /* menu bar resource ID */ #define menuID 1 /* menu bar resource ID */
int height; /* height of the largest menu */ int height; /* height of the largest menu */
MenuBarRecHndl menuBarHand = 0; /* for 'handling' the menu bar */ MenuBarRecHndl menuBarHand = 0; /* for 'handling' the menu bar */
MenuBarRecHndl oldMenuBarHand; MenuBarRecHndl oldMenuBarHand;
/* create the menu bar */ /* create the menu bar */
oldMenuBarHand = menuBarHand; oldMenuBarHand = menuBarHand;
menuBarHand = NewMenuBar2(refIsResource, menuID+offset, NULL); menuBarHand = NewMenuBar2(refIsResource, menuID+offset, NULL);
SetSysBar(menuBarHand); SetSysBar(menuBarHand);
SetMenuBar(NULL); SetMenuBar(NULL);
FixAppleMenu(1); /* add desk accessories */ FixAppleMenu(1); /* add desk accessories */
height = FixMenuBar(); /* draw the completed menu bar */ height = FixMenuBar(); /* draw the completed menu bar */
DrawMenuBar(); DrawMenuBar();
if (oldMenuBarHand) if (oldMenuBarHand)
DisposeHandle((Handle) oldMenuBarHand); DisposeHandle((Handle) oldMenuBarHand);
menuOffset = offset; /* So we can tell which menu is active */ menuOffset = offset; /* So we can tell which menu is active */
#undef menuID #undef menuID
} }
/*************************************************************** /***************************************************************
* CheckMenus - Check the menus to see if they should be dimmed * CheckMenus - Check the menus to see if they should be dimmed
***************************************************************/ ***************************************************************/
void CheckMenus (void) { void CheckMenus (void) {
GrafPortPtr activeWindow; /* Front visible window */ GrafPortPtr activeWindow; /* Front visible window */
static GrafPortPtr lastActiveWindow; static GrafPortPtr lastActiveWindow;
activeWindow = FrontWindow(); activeWindow = FrontWindow();
/* Speed up common case (no change since last time) */ /* Speed up common case (no change since last time) */
if (activeWindow == lastActiveWindow) if (activeWindow == lastActiveWindow)
return; return;
lastActiveWindow = activeWindow; lastActiveWindow = activeWindow;
if (activeWindow) { if (activeWindow) {
if (GetSysWFlag(activeWindow)) { /* NDA window is active */ if (GetSysWFlag(activeWindow)) { /* NDA window is active */
EnableMItem(fileClose); EnableMItem(fileClose);
EnableMItem(editUndo); EnableMItem(editUndo);
EnableMItem(editCut); EnableMItem(editCut);
EnableMItem(editCopy); EnableMItem(editCopy);
EnableMItem(editPaste); EnableMItem(editPaste);
EnableMItem(editClear); EnableMItem(editClear);
} }
else if (activeWindow == newConnWindow) { /* New Connection window */ else if (activeWindow == newConnWindow) { /* New Connection window */
EnableMItem(fileClose); EnableMItem(fileClose);
DisableMItem(editUndo); DisableMItem(editUndo);
EnableMItem(editCut); EnableMItem(editCut);
EnableMItem(editCopy); EnableMItem(editCopy);
@ -303,117 +303,117 @@ void CheckMenus (void) {
EnableMItem(editClear); EnableMItem(editClear);
} }
else if (activeWindow == vncWindow) { else if (activeWindow == vncWindow) {
DisableMItem(editUndo); DisableMItem(editUndo);
DisableMItem(editCopy); DisableMItem(editCopy);
DisableMItem(editCut); DisableMItem(editCut);
DisableMItem(editPaste); DisableMItem(editPaste);
DisableMItem(editClear); DisableMItem(editClear);
} }
} }
else { /* no editable window on top */ else { /* no editable window on top */
DisableMItem(fileClose); DisableMItem(fileClose);
DisableMItem(editUndo); DisableMItem(editUndo);
DisableMItem(editCut); DisableMItem(editCut);
DisableMItem(editCopy); DisableMItem(editCopy);
DisableMItem(editPaste); DisableMItem(editPaste);
DisableMItem(editClear); DisableMItem(editClear);
}; };
if (vncConnected) { /* VNC connection present */ if (vncConnected) { /* VNC connection present */
DisableMItem(fileNewConnection); DisableMItem(fileNewConnection);
EnableMItem(fileClose); EnableMItem(fileClose);
if (viewOnlyMode) if (viewOnlyMode)
DisableMItem(editSendClipboard); DisableMItem(editSendClipboard);
else else
EnableMItem(editSendClipboard); EnableMItem(editSendClipboard);
} }
else { else {
DisableMItem(editSendClipboard); DisableMItem(editSendClipboard);
} }
} }
/* InitScreen - Set up color tables and SCBs to appropriate values /* InitScreen - Set up color tables and SCBs to appropriate values
*/ */
void InitScreen (void) { void InitScreen (void) {
static ColorTable gray640Colors = { static ColorTable gray640Colors = {
0x0000, 0x0555, 0x0AAA, 0x0FFF, 0x0000, 0x0555, 0x0AAA, 0x0FFF, 0x0000, 0x0555, 0x0AAA, 0x0FFF, 0x0000, 0x0555, 0x0AAA, 0x0FFF,
0x0000, 0x0555, 0x0AAA, 0x0FFF, 0x0000, 0x0555, 0x0AAA, 0x0FFF 0x0000, 0x0555, 0x0AAA, 0x0FFF, 0x0000, 0x0555, 0x0AAA, 0x0FFF
}; };
/* Apple menu uses color tables 1 through 6 */ /* Apple menu uses color tables 1 through 6 */
SetColorTable(7, &gray640Colors); SetColorTable(7, &gray640Colors);
SetAllSCBs(0x87); /* 640 mode with gray640Colors */ SetAllSCBs(0x87); /* 640 mode with gray640Colors */
InitPalette(); /* Restore Apple Menu colors */ InitPalette(); /* Restore Apple Menu colors */
} }
void Quit (void) { void Quit (void) {
/* Done with event loop - now quitting */ /* Done with event loop - now quitting */
if (vncConnected) /* Disconnect if still connected */ if (vncConnected) /* Disconnect if still connected */
CloseTCPConnection(); CloseTCPConnection();
if (readBufferHndl) if (readBufferHndl)
DisposeHandle(readBufferHndl); /* Get rid of TCPIP read buffer hndl */ DisposeHandle(readBufferHndl); /* Get rid of TCPIP read buffer hndl */
if (bigcoltab320) if (bigcoltab320)
free(bigcoltab320); free(bigcoltab320);
if (bigcoltab640a) if (bigcoltab640a)
free(bigcoltab640a); free(bigcoltab640a);
if (bigcoltab640b) if (bigcoltab640b)
free(bigcoltab640b); free(bigcoltab640b);
if (cursor) if (cursor)
free(cursor); free(cursor);
/* Ask the user if we should disconnect only if the connection */ /* Ask the user if we should disconnect only if the connection */
/* is not "permanent," i.e. started when the system boots up. */ /* is not "permanent," i.e. started when the system boots up. */
if (TCPIPGetConnectStatus() && (!TCPIPGetBootConnectFlag())) if (TCPIPGetConnectStatus() && (!TCPIPGetBootConnectFlag()))
if (AlertWindow(awResource+awButtonLayout, NULL, disconnectTCPIPAlert)) if (AlertWindow(awResource+awButtonLayout, NULL, disconnectTCPIPAlert))
{ {
WaitCursor(); WaitCursor();
/* Must use force flag below because Marinetti will still count /* Must use force flag below because Marinetti will still count
* our ipid as logged in (proventing non-forced disconnect) * our ipid as logged in (proventing non-forced disconnect)
* for several minutes after the TCPIPLogout call. */ * for several minutes after the TCPIPLogout call. */
TCPIPDisconnect(TRUE, &DisplayConnectStatus); TCPIPDisconnect(TRUE, &DisplayConnectStatus);
if (connectStatusWindowPtr != NULL) if (connectStatusWindowPtr != NULL)
CloseWindow(connectStatusWindowPtr); CloseWindow(connectStatusWindowPtr);
} }
UnloadScrap(); /* Save scrap to disk */ UnloadScrap(); /* Save scrap to disk */
TCPIPShutDown(); /* Shut down Marinetti */ TCPIPShutDown(); /* Shut down Marinetti */
UnloadOneTool(54); UnloadOneTool(54);
ShutDownTools(1, startStopParm); /* shut down the tools */ ShutDownTools(1, startStopParm); /* shut down the tools */
exit(0); exit(0);
} }
/*************************************************************** /***************************************************************
* Main - Initial startup function * Main - Initial startup function
***************************************************************/ ***************************************************************/
int main (void) { int main (void) {
int event; /* event type returned by TaskMaster */ int event; /* event type returned by TaskMaster */
#define wrNum 1001 /* New Conn. window resource number */ #define wrNum 1001 /* New Conn. window resource number */
startStopParm = /* start up the tools */ startStopParm = /* start up the tools */
StartUpTools(userid(), 2, 1); StartUpTools(userid(), 2, 1);
if (toolerror() != 0) { if (toolerror() != 0) {
GrafOff(); GrafOff();
SysFailMgr(toolerror(), "\pCould not start tools: "); SysFailMgr(toolerror(), "\pCould not start tools: ");
} }
readBufferHndl = NewHandle(1, userid(), 0, NULL); readBufferHndl = NewHandle(1, userid(), 0, NULL);
LoadOneTool(54, 0x200); /* load Marinetti 2.0+ */ LoadOneTool(54, 0x200); /* load Marinetti 2.0+ */
if (toolerror()) { /* Check that Marinetti is available */ if (toolerror()) { /* Check that Marinetti is available */
SysBeep(); /* Can't load Marinetti.. */ SysBeep(); /* Can't load Marinetti.. */
InitCursor(); /* Activate pointer cursor */ InitCursor(); /* Activate pointer cursor */
AlertWindow(awResource, NULL, noMarinettiError); AlertWindow(awResource, NULL, noMarinettiError);
Quit(); /* Can't proceed, so just quit */ Quit(); /* Can't proceed, so just quit */
} }
else /* Marinetti loaded successfully */ else /* Marinetti loaded successfully */
TCPIPStartUp(); /* ... so activate it now */ TCPIPStartUp(); /* ... so activate it now */
if (toolerror()) { /* Get handle for TCPIP read buffer */ if (toolerror()) { /* Get handle for TCPIP read buffer */
SysBeep(); SysBeep();
InitCursor(); InitCursor();
AlertWindow(awResource, NULL, outOfMemoryError); AlertWindow(awResource, NULL, outOfMemoryError);
@ -427,50 +427,50 @@ int main (void) {
Quit(); Quit();
} }
InitScreen(); /* Set up color tables */ InitScreen(); /* Set up color tables */
LoadScrap(); /* put scrap in memory */ LoadScrap(); /* put scrap in memory */
InitMenus(0); /* set up the menu bar */ InitMenus(0); /* set up the menu bar */
InitCursor(); /* start the arrow cursor */ InitCursor(); /* start the arrow cursor */
vncConnected = FALSE; /* Initially not connected */ vncConnected = FALSE; /* Initially not connected */
newConnWindow = NewWindow2("\p New VNC Connection ", 0, newConnWindow = NewWindow2("\p New VNC Connection ", 0,
DrawContents, NULL, 0x02, wrNum, rWindParam1); DrawContents, NULL, 0x02, wrNum, rWindParam1);
#undef wrNum #undef wrNum
DoNewConnection(); /* Display new connection window */ DoNewConnection(); /* Display new connection window */
/* main event loop */ /* main event loop */
myEvent.wmTaskMask = 0x001F79FF; /* let TaskMaster do everything needed */ myEvent.wmTaskMask = 0x001F79FF; /* let TaskMaster do everything needed */
while (!done) { while (!done) {
CheckMenus(); CheckMenus();
event = TaskMaster(everyEvent, &myEvent); event = TaskMaster(everyEvent, &myEvent);
if (vncConnected) if (vncConnected)
SendModifiers(); SendModifiers();
switch (event) { switch (event) {
case wInSpecial: case wInSpecial:
case wInMenuBar: HandleMenu(); case wInMenuBar: HandleMenu();
break; break;
case wInGoAway: DoClose((GrafPortPtr) myEvent.wmTaskData); case wInGoAway: DoClose((GrafPortPtr) myEvent.wmTaskData);
break; break;
case wInControl: HandleControl(); case wInControl: HandleControl();
break; break;
case wInContent: if (vncWindow && ((GrafPortPtr) case wInContent: if (vncWindow && ((GrafPortPtr)
myEvent.wmTaskData == vncWindow)) myEvent.wmTaskData == vncWindow))
DoPointerEvent(); DoPointerEvent();
break;
case nullEvt: if (vncConnected) DoPointerEvent();
break; break;
case nullEvt: if (vncConnected) DoPointerEvent();
break;
case keyDownEvt: case keyDownEvt:
case autoKeyEvt: ProcessKeyEvent(); case autoKeyEvt: ProcessKeyEvent();
} }
if (vncConnected) if (vncConnected)
ConnectedEventLoop(); ConnectedEventLoop();
else if (colorTablesComplete == FALSE) else if (colorTablesComplete == FALSE)
if (MakeBigColorTables(256)) if (MakeBigColorTables(256))
colorTablesComplete = TRUE; colorTablesComplete = TRUE;
} }
Quit(); Quit();
} }

View File

@ -22,9 +22,9 @@ extern unsigned long deleteKeysym;
extern char vncServer[257]; extern char vncServer[257];
extern char vncPassword[10]; extern char vncPassword[10];
extern EventRecord myEvent; /* Event Record for TaskMaster */ extern EventRecord myEvent; /* Event Record for TaskMaster */
extern BOOLEAN vncConnected; /* Is the GS desktop active */ extern BOOLEAN vncConnected; /* Is the GS desktop active */
extern BOOLEAN colorTablesComplete; /* Are the color tables complete */ extern BOOLEAN colorTablesComplete; /* Are the color tables complete */
extern void DoClose (GrafPortPtr wPtr); extern void DoClose (GrafPortPtr wPtr);
extern void DrawContents (void); extern void DrawContents (void);

View File

@ -6,69 +6,69 @@
/*- Constants --------------------------------------------------*/ /*- Constants --------------------------------------------------*/
#define appleMenu 1 #define appleMenu 1
#define fileMenu 2 #define fileMenu 2
#define editMenu 3 #define editMenu 3
#define editUndo 250 #define editUndo 250
#define editCut 251 #define editCut 251
#define editCopy 252 #define editCopy 252
#define editPaste 253 #define editPaste 253
#define editClear 254 #define editClear 254
#define editSendClipboard 262 #define editSendClipboard 262
#define editShowClipboard 261 #define editShowClipboard 261
#define fileNewConnection 260 #define fileNewConnection 260
#define fileClose 255 #define fileClose 255
#define fileQuit 256 #define fileQuit 256
#define appleAbout 257 #define appleAbout 257
#define noKB 100 #define noKB 100
#define noMarinettiError 2001 #define noMarinettiError 2001
#define outOfMemoryError 2002 #define outOfMemoryError 2002
#define disconnectTCPIPAlert 2003 #define disconnectTCPIPAlert 2003
#define connectionFailedAlert 2004 #define connectionFailedAlert 2004
#define noCryptoError 2005 #define noCryptoError 2005
#define authFailedError 2006 #define authFailedError 2006
#define authTooManyError 2007 #define authTooManyError 2007
#define badRFBVersionAlert 2008 #define badRFBVersionAlert 2008
#define badAuthTypeAlert 2009 #define badAuthTypeAlert 2009
#define screenTooBigError 2010 #define screenTooBigError 2010
#define noTCPIPConnectionError 2011 #define noTCPIPConnectionError 2011
#define badGetIpidError 2012 #define badGetIpidError 2012
#define badOptionNegotiationError 2013 #define badOptionNegotiationError 2013
#define badHandshakingError 2014 #define badHandshakingError 2014
#define badReadTCPError 2015 #define badReadTCPError 2015
#define linedColors 1 #define linedColors 1
#define NCWindow 1000 /* Offset for "New Connection" */ #define NCWindow 1000 /* Offset for "New Connection" */
/* window and its controls */ /* window and its controls */
#define VNCWindow 3000 #define VNCWindow 3000
#define winNewConnection 1 #define winNewConnection 1
#define btnConnect 1 #define btnConnect 1
#define btnCancel 2 #define btnCancel 2
#define linServer 3 #define linServer 3
#define txtServer 4 #define txtServer 4
#define txtServerInfo 5 #define txtServerInfo 5
#define txtPassword 6 #define txtPassword 6
#define linPassword 7 #define linPassword 7
#define txtDisplay 8 #define txtDisplay 8
#define rectDisplay 9 #define rectDisplay 9
#define txtColor 10 #define txtColor 10
#define txtGray 11 #define txtGray 11
#define rad320 12 #define rad320 12
#define rad640 13 #define rad640 13
#define chkShared 16 #define chkShared 16
#define chkClipboard 17 #define chkClipboard 17
#define txtTransfers 23 #define txtTransfers 23
#define chkEmul3Btn 18 #define chkEmul3Btn 18
#define chkViewOnly 19 #define chkViewOnly 19
#define txtPreferredEncoding 24 #define txtPreferredEncoding 24
#define radRaw 25 #define radRaw 25
#define radHextile 26 #define radHextile 26
/*- Tools ------------------------------------------------------*/ /*- Tools ------------------------------------------------------*/
@ -204,7 +204,7 @@ resource rMenuItem (editSendClipboard) {
editSendClipboard editSendClipboard
}; };
resource rMenuItem (fileNewConnection) { /* New menu item */ resource rMenuItem (fileNewConnection) { /* New menu item */
fileNewConnection, /* menu item ID */ fileNewConnection, /* menu item ID */
"N","n", /* key equivalents */ "N","n", /* key equivalents */
0, /* check character */ 0, /* check character */
@ -217,7 +217,7 @@ resource rMenuItem (fileClose) { /* Close menu item */
"W","w", /* key equivalents */ "W","w", /* key equivalents */
0, /* check character */ 0, /* check character */
refIsResource*itemTitleRefShift /* flags */ refIsResource*itemTitleRefShift /* flags */
+ fDivider, + fDivider,
fileClose /* menu item title resource ID */ fileClose /* menu item title resource ID */
}; };
@ -248,11 +248,11 @@ resource rPString (editCopy, noCrossBank) {"Copy"};
resource rPString (editPaste, noCrossBank) {"Paste"}; resource rPString (editPaste, noCrossBank) {"Paste"};
resource rPString (editClear, noCrossBank) {"Clear"}; resource rPString (editClear, noCrossBank) {"Clear"};
resource rPString (editShowClipboard, noCrossBank) resource rPString (editShowClipboard, noCrossBank)
{"Show Clipboard"}; {"Show Clipboard"};
resource rPString (editSendClipboard, noCrossBank) resource rPString (editSendClipboard, noCrossBank)
{"Send Clipboard"}; {"Send Clipboard"};
resource rPString (fileNewConnection, noCrossBank) resource rPString (fileNewConnection, noCrossBank)
{"New Connection..."}; {"New Connection..."};
resource rPString (fileClose, noCrossBank) {"Close"}; resource rPString (fileClose, noCrossBank) {"Close"};
resource rPString (fileQuit, noCrossBank) {"Quit"}; resource rPString (fileQuit, noCrossBank) {"Quit"};
resource rPString (appleAbout, noCrossBank) {"About VNCview GS..."}; resource rPString (appleAbout, noCrossBank) {"About VNCview GS..."};
@ -330,7 +330,7 @@ resource rMenuItem (editPaste+noKB) { /* Paste menu item */
editPaste /* menu item title resource ID */ editPaste /* menu item title resource ID */
}; };
resource rMenuItem (fileNewConnection+noKB) { /* New menu item */ resource rMenuItem (fileNewConnection+noKB) { /* New menu item */
fileNewConnection, /* menu item ID */ fileNewConnection, /* menu item ID */
"","", /* key equivalents */ "","", /* key equivalents */
0, /* check character */ 0, /* check character */
@ -343,7 +343,7 @@ resource rMenuItem (fileClose+noKB) { /* Close menu item */
"","", /* key equivalents */ "","", /* key equivalents */
0, /* check character */ 0, /* check character */
refIsResource*itemTitleRefShift /* flags */ refIsResource*itemTitleRefShift /* flags */
+ fDivider, + fDivider,
fileClose /* menu item title resource ID */ fileClose /* menu item title resource ID */
}; };
@ -370,26 +370,26 @@ resource rAlertString (1) {
/*- Resources used by Finder, etc. -----------------------------*/ /*- Resources used by Finder, etc. -----------------------------*/
resource rVersion (1) { resource rVersion (1) {
{ {
1,0,0, /* Version number */ 1,0,0, /* Version number */
beta, 1, /* Release version */ beta, 1, /* Release version */
}, },
verUS, /* Region code */ verUS, /* Region code */
"VNCview GS", /* Title */ "VNCview GS", /* Title */
"Copyright \$A9 2002\$D12004\n" "Copyright \$A9 2002\$D12004\n"
"by Stephen Heumann" "by Stephen Heumann"
}; };
resource rBundle (1, preload, nospecialmemory) { resource rBundle (1, preload, nospecialmemory) {
1, /* Icon ID */ 1, /* Icon ID */
1, /* rBundle ID */ 1, /* rBundle ID */
{ /* OneDoc structure to match the program */ { /* OneDoc structure to match the program */
{ {
$81, $81,
{0}, {0},
{1}, {1},
{2} {2}
}, },
$00000005, $00000005,
matchFileType {{$B3}}, matchFileType {{$B3}},
empty {}, empty {},
@ -403,172 +403,172 @@ resource rBundle (1, preload, nospecialmemory) {
empty {}, empty {},
empty {}, empty {},
empty {} empty {}
} }
}; };
resource rIcon (1, preload, nospecialmemory) { resource rIcon (1, preload, nospecialmemory) {
$8000, $8000,
22, 22,
24, 24,
$"000000000000000000000000" $"000000000000000000000000"
$"0F8EFF00F0FF00F0F0FFFFF0" $"0F8EFF00F0FF00F0F0FFFFF0"
$"0F45FF0F000F0F00F0FFFFF0" $"0F45FF0F000F0F00F0FFFFF0"
$"000000000000000000000000" $"000000000000000000000000"
$"0F99FF00FFF0F00FFFFFF0F0" $"0F99FF00FFF0F00FFFFFF0F0"
$"0F99FF0F0F00F0FFFFFFF030" $"0F99FF0F0F00F0FFFFFFF030"
$"0000000000000000000000F0" $"0000000000000000000000F0"
$"0999999999999999999990F0" $"0999999999999999999990F0"
$"099FFFF000F0F00FFF999030" $"099FFFF000F0F00FFF999030"
$"09FFFFFFFFFFFFFFFFF99030" $"09FFFFFFFFFFFFFFFFF99030"
$"09F88FFFFF88F1111FF99030" $"09F88FFFFF88F1111FF99030"
$"09FF88FFF88FF1FFF1F99030" $"09FF88FFF88FF1FFF1F99030"
$"09FF88FFF88FF1FFF1F99030" $"09FF88FFF88FF1FFF1F99030"
$"09FFF88F88FFFFFFFFF99030" $"09FFF88F88FFFFFFFFF99030"
$"09FFF88F88FFFF4444F99030" $"09FFF88F88FFFF4444F99030"
$"09FFFF888FFFF4FFFFF99030" $"09FFFF888FFFF4FFFFF99030"
$"09FFFF888FFFF4FFFFF99030" $"09FFFF888FFFF4FFFFF99030"
$"09FFFFF8FFFFFF4444F99030" $"09FFFFF8FFFFFF4444F99030"
$"09FFFFFFFFFFFFFFFFF990F0" $"09FFFFFFFFFFFFFFFFF990F0"
$"000000000000000000000000" $"000000000000000000000000"
$"0F3FFFFFF33333333333F0F0" $"0F3FFFFFF33333333333F0F0"
$"000000000000000000000000", $"000000000000000000000000",
$"FFFFFFFFFFFFFFFFFFFFFFFF"
$"FFFFFFFFFFFFFFFFFFFFFFFF" $"FFFFFFFFFFFFFFFFFFFFFFFF"
$"FFFFFFFFFFFFFFFFFFFFFFFF" $"FFFFFFFFFFFFFFFFFFFFFFFF"
$"FFFFFFFFFFFFFFFFFFFFFFFF" $"FFFFFFFFFFFFFFFFFFFFFFFF"
$"FFFFFFFFFFFFFFFFFFFFFFFF"
$"FFFFFFFFFFFFFFFFFFFFFFFF" $"FFFFFFFFFFFFFFFFFFFFFFFF"
$"FFFFFFFFFFFFFFFFFFFFFFFF" $"FFFFFFFFFFFFFFFFFFFFFFFF"
$"FFFFFFFFFFFFFFFFFFFFFFFF" $"FFFFFFFFFFFFFFFFFFFFFFFF"
$"FFFFFFFFFFFFFFFFFFFFFFFF"
$"FFFFFFFFFFFFFFFFFFFFFFFF" $"FFFFFFFFFFFFFFFFFFFFFFFF"
$"FFFFFFFFFFFFFFFFFFFFFFFF" $"FFFFFFFFFFFFFFFFFFFFFFFF"
$"FFFFFFFFFFFFFFFFFFFFFFFF" $"FFFFFFFFFFFFFFFFFFFFFFFF"
$"FFFFFFFFFFFFFFFFFFFFFFFF"
$"FFFFFFFFFFFFFFFFFFFFFFFF" $"FFFFFFFFFFFFFFFFFFFFFFFF"
$"FFFFFFFFFFFFFFFFFFFFFFFF" $"FFFFFFFFFFFFFFFFFFFFFFFF"
$"FFFFFFFFFFFFFFFFFFFFFFFF" $"FFFFFFFFFFFFFFFFFFFFFFFF"
$"FFFFFFFFFFFFFFFFFFFFFFFF"
$"FFFFFFFFFFFFFFFFFFFFFFFF" $"FFFFFFFFFFFFFFFFFFFFFFFF"
$"FFFFFFFFFFFFFFFFFFFFFFFF" $"FFFFFFFFFFFFFFFFFFFFFFFF"
$"FFFFFFFFFFFFFFFFFFFFFFFF" $"FFFFFFFFFFFFFFFFFFFFFFFF"
$"FFFFFFFFFFFFFFFFFFFFFFFF" $"FFFFFFFFFFFFFFFFFFFFFFFF"
$"FFFFFFFFFFFFFFFFFFFFFFFF"
$"FFFFFFFFFFFFFFFFFFFFFFFF"
$"FFFFFFFFFFFFFFFFFFFFFFFF"
$"FFFFFFFFFFFFFFFFFFFFFFFF"
$"FFFFFFFFFFFFFFFFFFFFFFFF"
$"FFFFFFFFFFFFFFFFFFFFFFFF" $"FFFFFFFFFFFFFFFFFFFFFFFF"
}; };
resource rIcon (2, preload, nospecialmemory) { resource rIcon (2, preload, nospecialmemory) {
0x8000, 0x8000,
8, 8,
8, 8,
$"F8F8F11F" $"F8F8F11F"
$"F8F8F1F1" $"F8F8F1F1"
$"F8F8F1F1" $"F8F8F1F1"
$"F8F8FFFF" $"F8F8FFFF"
$"F8F8FF44" $"F8F8FF44"
$"F8F8F4FF" $"F8F8F4FF"
$"FF8FF4FF" $"FF8FF4FF"
$"FF8FFF44", $"FF8FFF44",
$"0F0F0FF0" $"0F0F0FF0"
$"0F0F0F0F" $"0F0F0F0F"
$"0F0F0F0F" $"0F0F0F0F"
$"0F0F0000" $"0F0F0000"
$"0F0F00FF" $"0F0F00FF"
$"0F0F0F00" $"0F0F0F00"
$"00F00F00" $"00F00F00"
$"00F000FF" $"00F000FF"
}; };
/*- Error handler ----------------------------------------------*/ /*- Error handler ----------------------------------------------*/
resource rAlertString (noMarinettiError) { resource rAlertString (noMarinettiError) {
"42:" "42:"
"Could not load the Marinetti TCP/IP stack. Please ensure that " "Could not load the Marinetti TCP/IP stack. Please ensure that "
"you have Marinetti 2.0 or later installed on this computer." "you have Marinetti 2.0 or later installed on this computer."
":^#5\$00"; ":^#5\$00";
}; };
resource rAlertString (noCryptoError) { resource rAlertString (noCryptoError) {
"42:" "42:"
"Could not load the Crypto tool set. Please install the crypto " "Could not load the Crypto tool set. Please install the crypto "
"tool set version 1.0 or later to use passwords in VNCview GS." "tool set version 1.0 or later to use passwords in VNCview GS."
":^#6\$00"; ":^#6\$00";
}; };
resource rAlertString (outOfMemoryError) { resource rAlertString (outOfMemoryError) {
"42:" "42:"
"Could not allocate sufficient memory. Please reduce memory " "Could not allocate sufficient memory. Please reduce memory "
"usage and run VNCview GS again." "usage and run VNCview GS again."
":^#5\$00"; ":^#5\$00";
}; };
resource rAlertString (disconnectTCPIPAlert) { resource rAlertString (disconnectTCPIPAlert) {
"20:" "20:"
"Do you want to disconnect your TCP/IP connection?" "Do you want to disconnect your TCP/IP connection?"
":^#3:#2\$00"; ":^#3:#2\$00";
}; };
resource rAlertString (authFailedError) { resource rAlertString (authFailedError) {
"52:" "52:"
"Authentication failed. Please re-type your password and try again." "Authentication failed. Please re-type your password and try again."
":^#6\$00"; ":^#6\$00";
}; };
resource rAlertString (authTooManyError) { resource rAlertString (authTooManyError) {
"72:" "72:"
"Authentication has failed too many times. Please check that you are " "Authentication has failed too many times. Please check that you are "
"using the correct password and wait a while before connecting again." "using the correct password and wait a while before connecting again."
":^#6\$00"; ":^#6\$00";
}; };
resource rAlertString (connectionFailedAlert) { resource rAlertString (connectionFailedAlert) {
"92;" "92;"
"Connection failed:\n" "Connection failed:\n"
"*0" "*0"
";^#6\$00"; ";^#6\$00";
}; };
resource rAlertString (badRFBVersionAlert) { resource rAlertString (badRFBVersionAlert) {
"42:" "42:"
"The server reported an RFB protocal version incompatible with VNCview " "The server reported an RFB protocal version incompatible with VNCview "
"GS or is not an RFB server." "GS or is not an RFB server."
":^#6\$00"; ":^#6\$00";
}; };
resource rAlertString (badAuthTypeAlert) { resource rAlertString (badAuthTypeAlert) {
"42:" "42:"
"The connection failed because the server requested an authentication " "The connection failed because the server requested an authentication "
"type not recognized by VNCview GS." "type not recognized by VNCview GS."
":^#6\$00"; ":^#6\$00";
}; };
resource rAlertString (noTCPIPConnectionError) { resource rAlertString (noTCPIPConnectionError) {
"32:" "32:"
"A TCP/IP connection could not be established." "A TCP/IP connection could not be established."
":^#6\$00"; ":^#6\$00";
}; };
resource rAlertString (badGetIpidError) { resource rAlertString (badGetIpidError) {
"42:" "42:"
"There was an error while resolving the hostname you provided or " "There was an error while resolving the hostname you provided or "
"preparing to connect to it." "preparing to connect to it."
":^#6\$00"; ":^#6\$00";
}; };
resource rAlertString (badOptionNegotiationError) { resource rAlertString (badOptionNegotiationError) {
"32:" "32:"
"There was an error while negotiating protocol options." "There was an error while negotiating protocol options."
":^#6\$00"; ":^#6\$00";
}; };
resource rAlertString (badHandshakingError) { resource rAlertString (badHandshakingError) {
"32:" "32:"
"There was an error while establishing a VNC connection with the server." "There was an error while establishing a VNC connection with the server."
":^#6\$00"; ":^#6\$00";
}; };
resource rAlertString (screenTooBigError) { resource rAlertString (screenTooBigError) {
"72:" "72:"
"The server's framebuffer resolution is too big for VNCview GS. " "The server's framebuffer resolution is too big for VNCview GS. "
"VNCview GS does not support resolutions greater than 16,384 by 16,384." "VNCview GS does not support resolutions greater than 16,384 by 16,384."
":^#6\$00"; ":^#6\$00";
@ -576,7 +576,7 @@ resource rAlertString (screenTooBigError) {
#if 0 #if 0
resource rAlertString (badReadTCPError) { resource rAlertString (badReadTCPError) {
"72:" "72:"
"The TCP/IP stack did not return the amount of data expected. This " "The TCP/IP stack did not return the amount of data expected. This "
"may be indicative of a bug in Marinetti or in the VNC server software." "may be indicative of a bug in Marinetti or in the VNC server software."
":^#6\$00"; ":^#6\$00";
@ -584,7 +584,7 @@ resource rAlertString (badReadTCPError) {
#endif #endif
resource rAlertString (10000) { resource rAlertString (10000) {
"72:" "72:"
"*0" "*0"
":^#6\$00"; ":^#6\$00";
}; };
@ -592,28 +592,28 @@ resource rAlertString (10000) {
/*- New VNC Connection window resources ----------------------------------*/ /*- New VNC Connection window resources ----------------------------------*/
resource rWindParam1 (NCWindow+winNewConnection) { resource rWindParam1 (NCWindow+winNewConnection) {
fTitle+fClose+fFlex+fMove, /* wFrameBits */ fTitle+fClose+fFlex+fMove, /* wFrameBits */
nil, /* wTitle */ nil, /* wTitle */
0, /* wRefCon */ 0, /* wRefCon */
{0,0,0,0}, /* ZoomRect */ {0,0,0,0}, /* ZoomRect */
nil, /* wColor ID */ nil, /* wColor ID */
{0,0}, /* Origin */ {0,0}, /* Origin */
{0,0}, /* data size */ {0,0}, /* data size */
{0,0}, /* max height-width */ {0,0}, /* max height-width */
{0,0}, /* scroll vertical, horizontal */ {0,0}, /* scroll vertical, horizontal */
{0,0}, /* page vertical, horizontal */ {0,0}, /* page vertical, horizontal */
0, /* wInfoRefCon */ 0, /* wInfoRefCon */
0, /* wInfoHeight */ 0, /* wInfoHeight */
{40,162,181,478}, /* wPosition */ {40,162,181,478}, /* wPosition */
infront, /* wPlane */ infront, /* wPlane */
NCWindow+winNewConnection, /* wStorage */ NCWindow+winNewConnection, /* wStorage */
$0009 /* wInVerb */ $0009 /* wInVerb */
}; };
resource rControlList (NCWindow+winNewConnection) {{ resource rControlList (NCWindow+winNewConnection) {{
NCWindow+btnConnect, NCWindow+btnConnect,
NCWindow+btnCancel, NCWindow+btnCancel,
NCWindow+linServer, NCWindow+linServer,
NCWindow+txtServer, NCWindow+txtServer,
NCWindow+txtServerInfo, NCWindow+txtServerInfo,
NCWindow+txtPassword, NCWindow+txtPassword,
@ -635,267 +635,267 @@ resource rControlList (NCWindow+winNewConnection) {{
}}; }};
resource rControlTemplate (NCWindow+btnConnect) { resource rControlTemplate (NCWindow+btnConnect) {
btnConnect, /* Control ID */ btnConnect, /* Control ID */
{121,217,0,0}, /* Control Rect */ {121,217,0,0}, /* Control Rect */
SimpleButtonControl {{ SimpleButtonControl {{
$0001, /* flags */ $0001, /* flags */
$3002, /* more flags */ $3002, /* more flags */
0, /* refcon */ 0, /* refcon */
NCWindow+btnConnect, /* Title Ref */ NCWindow+btnConnect, /* Title Ref */
nil, /* color table ref */ nil, /* color table ref */
{"\$0D","\$0D",0,0} /* key equivalents (esc) */ {"\$0D","\$0D",0,0} /* key equivalents (esc) */
}}; }};
}; };
resource rPString (NCWindow+btnConnect) {"Connect"}; resource rPString (NCWindow+btnConnect) {"Connect"};
resource rControlTemplate (NCWindow+btnCancel) { resource rControlTemplate (NCWindow+btnCancel) {
btnCancel, /* Control ID */ btnCancel, /* Control ID */
{121,128,0,0}, /* Control Rect */ {121,128,0,0}, /* Control Rect */
SimpleButtonControl {{ SimpleButtonControl {{
$0000, /* flags */ $0000, /* flags */
$3002, /* more flags */ $3002, /* more flags */
0, /* refcon */ 0, /* refcon */
NCWindow+btnCancel, /* Title Ref */ NCWindow+btnCancel, /* Title Ref */
nil, /* color table ref */ nil, /* color table ref */
{"\$1B","\$1B",0,0} /* key equivalents (esc) */ {"\$1B","\$1B",0,0} /* key equivalents (esc) */
}}; }};
}; };
resource rPString (NCWindow+btnCancel) {"Cancel"}; resource rPString (NCWindow+btnCancel) {"Cancel"};
resource rControlTemplate (NCWindow+linServer) { resource rControlTemplate (NCWindow+linServer) {
linServer, linServer,
{4,87,16,310}, {4,87,16,310},
editLineControl {{ editLineControl {{
$0000, $0000,
$7000, $7000,
0, 0,
255, /* Max Size */ 255, /* Max Size */
0 /* text ref */ 0 /* text ref */
}}; }};
}; };
resource rControlTemplate (NCWindow+txtServer) { resource rControlTemplate (NCWindow+txtServer) {
txtServer, txtServer,
{5,3,15,86}, {5,3,15,86},
statTextControl {{ statTextControl {{
$0004, $0004,
$1002, $1002,
0, 0,
NCWindow+txtServer /* Title ref */ NCWindow+txtServer /* Title ref */
}}; }};
}; };
resource rTextForLETextBox2 (NCWindow+txtServer) {"VNC Server:"}; resource rTextForLETextBox2 (NCWindow+txtServer) {"VNC Server:"};
resource rControlTemplate (NCWindow+txtServerInfo) { resource rControlTemplate (NCWindow+txtServerInfo) {
txtServerInfo, txtServerInfo,
{16,0,26,316}, {16,0,26,316},
statTextControl {{ statTextControl {{
$0000, $0000,
$1002, $1002,
0, 0,
NCWindow+txtServerInfo /* Title ref */ NCWindow+txtServerInfo /* Title ref */
}}; }};
}; };
resource rTextForLETextBox2 (NCWindow+txtServerInfo) { resource rTextForLETextBox2 (NCWindow+txtServerInfo) {
"\$01J\$01\$00Use \$01S\$03\$00host:display\$01S\$00\$00 " "\$01J\$01\$00Use \$01S\$03\$00host:display\$01S\$00\$00 "
"(or \$01S\$03\$00host\$01S\$00\$00 for display 0)." "(or \$01S\$03\$00host\$01S\$00\$00 for display 0)."
}; };
resource rControlTemplate (NCWindow+txtPassword) { resource rControlTemplate (NCWindow+txtPassword) {
txtPassword, txtPassword,
{29,15,38,86}, {29,15,38,86},
statTextControl {{ statTextControl {{
$0004, $0004,
$1002, $1002,
0, 0,
NCWindow+txtPassword /* Title ref */ NCWindow+txtPassword /* Title ref */
}}; }};
}; };
resource rTextForLETextBox2 (NCWindow+txtPassword) {"Password:"}; resource rTextForLETextBox2 (NCWindow+txtPassword) {"Password:"};
resource rControlTemplate (NCWindow+linPassword) { resource rControlTemplate (NCWindow+linPassword) {
linPassword, linPassword,
{28,87,39,310}, {28,87,39,310},
editLineControl {{ editLineControl {{
$0000, $0000,
$7000, $7000,
0, 0,
8, /* Max Size */ 8, /* Max Size */
0, /* text ref */ 0, /* text ref */
$D7 /* password character */ $D7 /* password character */
}}; }};
}; };
resource rControlTemplate (NCWindow+txtDisplay) { resource rControlTemplate (NCWindow+txtDisplay) {
txtDisplay, txtDisplay,
{43,13,52,73}, {43,13,52,73},
statTextControl {{ statTextControl {{
$0000, $0000,
$1002, $1002,
0, 0,
NCWindow+txtDisplay /* Title ref */ NCWindow+txtDisplay /* Title ref */
}}; }};
}; };
resource rTextForLETextBox2 (NCWindow+txtDisplay) {" Display "}; resource rTextForLETextBox2 (NCWindow+txtDisplay) {" Display "};
resource rControlTemplate (NCWindow+rectDisplay) { resource rControlTemplate (NCWindow+rectDisplay) {
NCWindow+rectDisplay, NCWindow+rectDisplay,
{47,3,100,111}, {47,3,100,111},
rectangleControl {{ rectangleControl {{
$FF01, $FF01,
$1000, $1000,
0 0
}}; }};
}; };
resource rControlTemplate (NCWindow+rad320) { resource rControlTemplate (NCWindow+rad320) {
rad320, rad320,
{55,10,0,0}, {55,10,0,0},
RadioControl {{ RadioControl {{
$0002, $0002,
$1002, $1002,
0, 0,
NCWindow+rad320, /* Title ref */ NCWindow+rad320, /* Title ref */
1 /* initial value */ 1 /* initial value */
}}; }};
}; };
resource rPString (NCWindow+rad320) {"320 x 200"}; resource rPString (NCWindow+rad320) {"320 x 200"};
resource rControlTemplate (NCWindow+txtColor) { resource rControlTemplate (NCWindow+txtColor) {
txtColor, txtColor,
{64,35,73,90}, {64,35,73,90},
statTextControl {{ statTextControl {{
$000C, $000C,
$1002, $1002,
0, 0,
NCWindow+txtColor /* Title ref */ NCWindow+txtColor /* Title ref */
}}; }};
}; };
resource rTextForLETextBox2 (NCWindow+txtColor) {"Color"}; resource rTextForLETextBox2 (NCWindow+txtColor) {"Color"};
resource rControlTemplate (NCWindow+rad640) { resource rControlTemplate (NCWindow+rad640) {
rad640, rad640,
{78,10,0,0}, {78,10,0,0},
RadioControl {{ RadioControl {{
$0002, $0002,
$1002, $1002,
0, 0,
NCWindow+rad640, /* Title ref */ NCWindow+rad640, /* Title ref */
0 /* initial value */ 0 /* initial value */
}}; }};
}; };
resource rPString (NCWindow+rad640) {"640 x 200"}; resource rPString (NCWindow+rad640) {"640 x 200"};
resource rControlTemplate (NCWindow+txtGray) { resource rControlTemplate (NCWindow+txtGray) {
txtGray, txtGray,
{87,35,96,109}, {87,35,96,109},
statTextControl {{ statTextControl {{
$000C, $000C,
$1002, $1002,
0, 0,
NCWindow+txtGray /* Title ref */ NCWindow+txtGray /* Title ref */
}}; }};
}; };
resource rTextForLETextBox2 (NCWindow+txtGray) {"Grayscale"}; resource rTextForLETextBox2 (NCWindow+txtGray) {"Grayscale"};
resource rControlTemplate (NCWindow+chkShared) { resource rControlTemplate (NCWindow+chkShared) {
chkShared, chkShared,
{43,117,0,0}, {43,117,0,0},
CheckControl {{ CheckControl {{
$0000, $0000,
$1002, $1002,
0, 0,
NCWindow+chkShared, /* Title ref */ NCWindow+chkShared, /* Title ref */
1 /* initial value */ 1 /* initial value */
}}; }};
}; };
resource rPString (NCWindow+chkShared) {"Request Shared Session"}; resource rPString (NCWindow+chkShared) {"Request Shared Session"};
resource rControlTemplate (NCWindow+chkClipboard) { resource rControlTemplate (NCWindow+chkClipboard) {
chkClipboard, chkClipboard,
{82,117,0,0}, {82,117,0,0},
CheckControl {{ CheckControl {{
$0000, $0000,
$1002, $1002,
0, 0,
NCWindow+chkClipboard, /* Title ref */ NCWindow+chkClipboard, /* Title ref */
1 /* initial value */ 1 /* initial value */
}}; }};
}; };
resource rPString (NCWindow+chkClipboard) {"Allow Clipboard"}; resource rPString (NCWindow+chkClipboard) {"Allow Clipboard"};
resource rControlTemplate (NCWindow+txtTransfers) { resource rControlTemplate (NCWindow+txtTransfers) {
txtTransfers, txtTransfers,
{91,144,100,310}, {91,144,100,310},
statTextControl {{ statTextControl {{
$000C, $000C,
$1002, $1002,
0, 0,
NCWindow+txtTransfers /* Title ref */ NCWindow+txtTransfers /* Title ref */
}}; }};
}; };
resource rTextForLETextBox2 (NCWindow+txtTransfers) {"Transfers from Server"}; resource rTextForLETextBox2 (NCWindow+txtTransfers) {"Transfers from Server"};
resource rControlTemplate (NCWindow+chkEmul3Btn) { resource rControlTemplate (NCWindow+chkEmul3Btn) {
chkEmul3Btn, chkEmul3Btn,
{56,117,0,0}, {56,117,0,0},
CheckControl {{ CheckControl {{
$0000, $0000,
$1002, $1002,
0, 0,
NCWindow+chkEmul3Btn, /* Title ref */ NCWindow+chkEmul3Btn, /* Title ref */
1 /* initial value */ 1 /* initial value */
}}; }};
}; };
resource rPString (NCWindow+chkEmul3Btn) {"Emulate 3-Button Mouse"}; resource rPString (NCWindow+chkEmul3Btn) {"Emulate 3-Button Mouse"};
resource rControlTemplate (NCWindow+chkViewOnly) { resource rControlTemplate (NCWindow+chkViewOnly) {
chkViewOnly, chkViewOnly,
{69,117,0,0}, {69,117,0,0},
CheckControl {{ CheckControl {{
$0000, $0000,
$1002, $1002,
0, 0,
NCWindow+chkViewOnly, /* Title ref */ NCWindow+chkViewOnly, /* Title ref */
0 /* initial value */ 0 /* initial value */
}}; }};
}; };
resource rPString (NCWindow+chkViewOnly) {"View Only Mode"}; resource rPString (NCWindow+chkViewOnly) {"View Only Mode"};
resource rControlTemplate (NCWindow+txtPreferredEncoding) { resource rControlTemplate (NCWindow+txtPreferredEncoding) {
txtPreferredEncoding, txtPreferredEncoding,
{104,3,91,310}, {104,3,91,310},
statTextControl {{ statTextControl {{
$0004, $0004,
$1002, $1002,
0, 0,
NCWindow+txtPreferredEncoding /* Title ref */ NCWindow+txtPreferredEncoding /* Title ref */
}}; }};
}; };
resource rTextForLETextBox2 (NCWindow+txtPreferredEncoding) {"Preferred Encoding:"}; resource rTextForLETextBox2 (NCWindow+txtPreferredEncoding) {"Preferred Encoding:"};
resource rControlTemplate (NCWindow+radRaw) { resource rControlTemplate (NCWindow+radRaw) {
radRaw, radRaw,
{104,155,0,0}, {104,155,0,0},
RadioControl {{ RadioControl {{
$0003, $0003,
$1002, $1002,
0, 0,
NCWindow+radRaw, /* Title ref */ NCWindow+radRaw, /* Title ref */
1 /* initial value */ 1 /* initial value */
}}; }};
}; };
resource rPString (NCWindow+radRaw) {"Raw"}; resource rPString (NCWindow+radRaw) {"Raw"};
resource rControlTemplate (NCWindow+radHextile) { resource rControlTemplate (NCWindow+radHextile) {
radHextile, radHextile,
{104,220,0,0}, {104,220,0,0},
RadioControl {{ RadioControl {{
$0003, $0003,
$1002, $1002,
0, 0,
NCWindow+radHextile, /* Title ref */ NCWindow+radHextile, /* Title ref */
0 /* initial value */ 0 /* initial value */
}}; }};
}; };
resource rPString (NCWindow+radHextile) {"Hextile"}; resource rPString (NCWindow+radHextile) {"Hextile"};
@ -904,22 +904,22 @@ resource rPString (NCWindow+radHextile) {"Hextile"};
/*- TCP/IP Connection Status window resources ----------------------*/ /*- TCP/IP Connection Status window resources ----------------------*/
resource rWindParam1 (1002) { resource rWindParam1 (1002) {
fVis + fAlert, /* wFrameBits */ fVis + fAlert, /* wFrameBits */
nil, /* wTitle */ nil, /* wTitle */
0, /* wRefCon */ 0, /* wRefCon */
{0,0,0,0}, /* ZoomRect */ {0,0,0,0}, /* ZoomRect */
nil, /* wColor ID */ nil, /* wColor ID */
{0,0}, /* Origin */ {0,0}, /* Origin */
{0,0}, /* data size */ {0,0}, /* data size */
{0,0}, /* max height-width */ {0,0}, /* max height-width */
{0,0}, /* scroll vertical, horizontal */ {0,0}, /* scroll vertical, horizontal */
{0,0}, /* page vertical, horizontal */ {0,0}, /* page vertical, horizontal */
0, /* wInfoRefCon */ 0, /* wInfoRefCon */
0, /* wInfoHeight */ 0, /* wInfoHeight */
{85,169,115,471}, /* wPosition */ {85,169,115,471}, /* wPosition */
infront, /* wPlane */ infront, /* wPlane */
nil, /* wStorage */ nil, /* wStorage */
$0000 /* wInVerb */ $0000 /* wInVerb */
}; };
resource rPString(10002) {"Press \$11. to cancel."}; resource rPString(10002) {"Press \$11. to cancel."};
@ -928,46 +928,46 @@ resource rPString(10002) {"Press \$11. to cancel."};
/* 640 mode */ /* 640 mode */
resource rWindParam1 (1003) { resource rWindParam1 (1003) {
fRScroll + fBScroll + fVis + fCtlTie + fGrow, /* wFrameBits */ fRScroll + fBScroll + fVis + fCtlTie + fGrow, /* wFrameBits */
nil, /* wTitle */ nil, /* wTitle */
0, /* wRefCon */ 0, /* wRefCon */
{0,0,0,0}, /* ZoomRect */ {0,0,0,0}, /* ZoomRect */
1, /* wColor ID */ 1, /* wColor ID */
{0,0}, /* Origin */ {0,0}, /* Origin */
{0,0}, /* data size */ {0,0}, /* data size */
{0,0}, /* max height-width */ {0,0}, /* max height-width */
{8,8}, /* scroll vertical, horizontal */ {8,8}, /* scroll vertical, horizontal */
{0,608}, /* page vertical, horizontal */ {0,608}, /* page vertical, horizontal */
0, /* wInfoRefCon */ 0, /* wInfoRefCon */
0, /* wInfoHeight */ 0, /* wInfoHeight */
{13,1,187,614}, /* wPosition */ {13,1,187,614}, /* wPosition */
infront, /* wPlane */ infront, /* wPlane */
nil, /* wStorage */ nil, /* wStorage */
$0800 /* wInVerb */ $0800 /* wInVerb */
}; };
/* 320 mode */ /* 320 mode */
resource rWindParam1 (1004) { resource rWindParam1 (1004) {
fRScroll + fBScroll + fVis + fCtlTie + fGrow, /* wFrameBits */ fRScroll + fBScroll + fVis + fCtlTie + fGrow, /* wFrameBits */
nil, /* wTitle */ nil, /* wTitle */
0, /* wRefCon */ 0, /* wRefCon */
{0,0,0,0}, /* ZoomRect */ {0,0,0,0}, /* ZoomRect */
1, /* wColor ID */ 1, /* wColor ID */
{0,0}, /* Origin */ {0,0}, /* Origin */
{0,0}, /* data size */ {0,0}, /* data size */
{0,0}, /* max height-width */ {0,0}, /* max height-width */
{8,8}, /* scroll vertical, horizontal */ {8,8}, /* scroll vertical, horizontal */
{0,0}, /* page vertical, horizontal */ {0,0}, /* page vertical, horizontal */
0, /* wInfoRefCon */ 0, /* wInfoRefCon */
0, /* wInfoHeight */ 0, /* wInfoHeight */
{13,1,187,303}, /* wPosition */ {13,1,187,303}, /* wPosition */
infront, /* wPlane */ infront, /* wPlane */
nil, /* wStorage */ nil, /* wStorage */
$0800 /* wInVerb */ $0800 /* wInVerb */
}; };
resource rWindColor (1) { resource rWindColor (1) {
0x0000, 0x0000,
0x0FA0, 0x0FA0,
0x020F, 0x020F,
0xF0AA, 0xF0AA,