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