Detect if AFPBridge and Marinetti are installed, and give an error/warning if not.

We indicate that AFPBridge is installed by creating a message in the message center (which also includes its version, in case we want to distinguish between different versions in the future).
This commit is contained in:
Stephen Heumann 2017-04-19 21:10:23 -05:00
parent 4bb7e378ba
commit 6be698833d
3 changed files with 73 additions and 5 deletions

View File

@ -7,17 +7,25 @@
#include <desk.h>
#include <orca.h>
#include <gsos.h>
#include <string.h>
#include "installcmds.h"
#include "aspinterface.h"
#include "asmglue.h"
const char bootInfoString[] = "AFPBridge v1.0b1";
LongWord version = 0x01006001; /* in rVersion format */
const char versionMessageString[] = "\pSTH~AFPBridge~Version~";
typedef struct VersionMessageRec {
Word blockLen;
char nameString[23];
LongWord dataBlock;
} VersionMessageRec;
extern Word *unloadFlagPtr;
extern void resetRoutine(void);
FSTInfoRecGS fstInfoRec;
void pollTask(void);
void notificationProc(void);
@ -40,9 +48,7 @@ static struct NotificationProcRec {
void (*proc)(void);
} notificationProcRec;
NotifyProcRecGS addNotifyProcRec;
LongWord *SoftResetPtr = (LongWord *)0xE11010;
#define SoftResetPtr ((LongWord *)0xE11010)
extern LongWord oldSoftReset;
#define JML 0x5C
@ -54,6 +60,9 @@ void setUnloadFlag(void) {
int main(void) {
unsigned int i;
FSTInfoRecGS fstInfoRec;
NotifyProcRecGS addNotifyProcRec;
VersionMessageRec versionMessageRec;
/*
* Check for presence of AppleShare FST. We error out and unload
@ -79,6 +88,14 @@ int main(void) {
if (toolerror() && toolerror() != terrINITNOTFOUND)
goto error;
versionMessageRec.blockLen = sizeof(versionMessageRec);
memcpy(versionMessageRec.nameString, versionMessageString,
sizeof(versionMessageRec.nameString));
versionMessageRec.dataBlock = version;
MessageByName(TRUE, (Pointer)&versionMessageRec);
if (toolerror())
goto error;
ShowBootInfo(bootInfoString, NULL);
/*

View File

@ -19,6 +19,7 @@
#include <desk.h>
#include <menu.h>
#include <finder.h>
#include <tcpip.h>
#include "afpoptions.h"
#include "afpurlparser.h"
#include "strncasecmp.h"
@ -56,6 +57,8 @@
#define aliasFileError 3003
#define tempFileNameError 3004
#define saveAliasError 3005
#define noAFPBridgeError 3006
#define noAFPBridgeWarning 3007
#define EM_filetype 0xE2
#define EM_auxtype 0xFFFF
@ -320,6 +323,25 @@ void ConnectOrSave(AFPURLParts* urlParts, GSString255Ptr file, Boolean connect)
}
}
Boolean checkVersions(void)
{
static struct {
Word blockLen;
char nameString[23];
} messageRec = { sizeof(messageRec), "\pSTH~AFPBridge~Version~" };
/* Check if AFPBridge is active (any version is OK) */
MessageByName(FALSE, (Pointer)&messageRec);
if (toolerror())
return FALSE;
/* Check for Marinetti (AFPBridge will keep it active if installed) */
if (!TCPIPStatus() || toolerror())
return FALSE;
return TRUE;
}
void DoConnect(void)
{
Word i;
@ -333,6 +355,11 @@ void DoConnect(void)
if (urlParts.protocol == proto_invalid)
goto fixcaret;
if (urlParts.protocol == proto_TCP && !checkVersions()) {
AlertWindow(awResource+awButtonLayout, NULL, noAFPBridgeError);
goto fixcaret;
}
/* Generate the path name for the temp file in same dir as the CDev */
getRefInfoRec.pCount = 3;
getRefInfoRec.refNum = GetOpenFileRefNum(0); /* current resource file */
@ -378,6 +405,11 @@ void DoSave(void)
if (urlParts.protocol == proto_invalid)
return;
if (urlParts.protocol == proto_TCP && !checkVersions()) {
if (AlertWindow(awResource+awButtonLayout, NULL, noAFPBridgeWarning)==0)
return;
}
/* Load Standard File toolset if necessary */
if (!SFStatus() || toolerror()) {
if (toolerror())

View File

@ -301,6 +301,8 @@ resource rPString(saveFilePrompt) { "Save server alias as:" };
#define aliasFileError 3003
#define tempFileNameError 3004
#define saveAliasError 3005
#define noAFPBridgeError 3006
#define noAFPBridgeWarning 3007
#define protoInvalidError 4000
#define noServerOrVolumeNameError 4001
@ -418,3 +420,20 @@ resource rAlertString (saveAliasError) {
"There was an error while attempting to save the alias file."
":^#0\$00"
};
resource rAlertString (noAFPBridgeError) {
"62:"
"To connect to AFP servers over TCP, AFPBridge and Marinetti "
"must be installed and enabled. Please install them and then "
"restart your system."
":^#0\$00"
};
resource rAlertString (noAFPBridgeWarning) {
"74:"
"To connect to AFP servers over TCP, AFPBridge and Marinetti "
"must be installed and enabled. You can continue to save an "
"alias now, but to connect to the server you will need to "
"install them and then restart your system."
":#1:^#6\$00"
};