mirror of
https://github.com/autc04/Retro68.git
synced 2025-08-09 20:25:29 +00:00
LaunchAPPLServer: send response and shutdown connection before upgrading
This commit is contained in:
@@ -302,6 +302,7 @@ class LaunchServer : public StreamListener
|
|||||||
};
|
};
|
||||||
State state = State::command;
|
State state = State::command;
|
||||||
RemoteCommand command;
|
RemoteCommand command;
|
||||||
|
bool upgrade = false;
|
||||||
|
|
||||||
OSType type, creator;
|
OSType type, creator;
|
||||||
|
|
||||||
@@ -402,49 +403,58 @@ public:
|
|||||||
|
|
||||||
if(state == State::launch)
|
if(state == State::launch)
|
||||||
{
|
{
|
||||||
connection->suspend();
|
|
||||||
if(void *seg = connection->segmentToUnload())
|
|
||||||
UnloadSeg(seg);
|
|
||||||
gPrefs.inSubLaunch = true;
|
|
||||||
WritePrefs();
|
|
||||||
|
|
||||||
if(command == RemoteCommand::upgradeLauncher)
|
if(command == RemoteCommand::upgradeLauncher)
|
||||||
{
|
{
|
||||||
|
Stream *stream = connection->getStream();
|
||||||
if(creator == 'R68L' && type == 'APPL')
|
if(creator == 'R68L' && type == 'APPL')
|
||||||
{
|
{
|
||||||
FSDelete("\pLaunchAPPLServer.old", 0);
|
uint32_t zero = 0;
|
||||||
Rename(LMGetCurApName(), 0, "\pLaunchAPPLServer.old");
|
stream->write(&zero, 4);
|
||||||
Rename("\pRetro68App", 0, LMGetCurApName());
|
stream->write(&zero, 4);
|
||||||
|
|
||||||
LaunchParamBlockRec lpb;
|
upgrade = true;
|
||||||
memset(&lpb, 0, sizeof(lpb));
|
|
||||||
lpb.reserved1 = (unsigned long) LMGetCurApName();
|
|
||||||
lpb.reserved2 = 0;
|
|
||||||
OSErr err = LaunchApplication(&lpb);
|
|
||||||
ExitToShell();
|
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
|
{
|
||||||
if(type == 'MPST')
|
uint32_t error = 1;
|
||||||
appLauncher = CreateToolLauncher();
|
stream->write(&error, 4);
|
||||||
else
|
}
|
||||||
appLauncher = CreateAppLauncher();
|
stream->flushWrite();
|
||||||
|
outRefNum = 0;
|
||||||
bool launched = appLauncher->Launch("\pRetro68App");
|
outSizeRemaining = 0;
|
||||||
gPrefs.inSubLaunch = false;
|
outSize = 0;
|
||||||
WritePrefs();
|
state = State::respond;
|
||||||
|
|
||||||
if(launched)
|
|
||||||
{
|
|
||||||
state = State::wait;
|
|
||||||
nullEventCounter = 0;
|
|
||||||
|
|
||||||
statusDisplay->SetStatus(AppStatus::running, 0, 0);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
connection->resume();
|
connection->suspend();
|
||||||
onReset();
|
if(void *seg = connection->segmentToUnload())
|
||||||
|
UnloadSeg(seg);
|
||||||
|
gPrefs.inSubLaunch = true;
|
||||||
|
WritePrefs();
|
||||||
|
|
||||||
|
if(type == 'MPST')
|
||||||
|
appLauncher = CreateToolLauncher();
|
||||||
|
else
|
||||||
|
appLauncher = CreateAppLauncher();
|
||||||
|
|
||||||
|
bool launched = appLauncher->Launch("\pRetro68App");
|
||||||
|
gPrefs.inSubLaunch = false;
|
||||||
|
WritePrefs();
|
||||||
|
|
||||||
|
if(launched)
|
||||||
|
{
|
||||||
|
state = State::wait;
|
||||||
|
nullEventCounter = 0;
|
||||||
|
|
||||||
|
statusDisplay->SetStatus(AppStatus::running, 0, 0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
connection->resume();
|
||||||
|
onReset();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(state == State::wait && nullEventCounter > 3)
|
else if(state == State::wait && nullEventCounter > 3)
|
||||||
@@ -471,12 +481,27 @@ public:
|
|||||||
}
|
}
|
||||||
statusDisplay->SetStatus(AppStatus::uploading, outSize - outSizeRemaining, outSize);
|
statusDisplay->SetStatus(AppStatus::uploading, outSize - outSizeRemaining, outSize);
|
||||||
|
|
||||||
if(outSizeRemaining == 0)
|
if(outSizeRemaining == 0 && outRefNum)
|
||||||
{
|
{
|
||||||
FSClose(outRefNum);
|
FSClose(outRefNum);
|
||||||
}
|
}
|
||||||
if(outSizeRemaining == 0 && stream->allDataArrived())
|
if(outSizeRemaining == 0 && stream->allDataArrived())
|
||||||
{
|
{
|
||||||
|
if(upgrade)
|
||||||
|
{
|
||||||
|
connection.reset();
|
||||||
|
|
||||||
|
FSDelete("\pLaunchAPPLServer.old", 0);
|
||||||
|
Rename(LMGetCurApName(), 0, "\pLaunchAPPLServer.old");
|
||||||
|
Rename("\pRetro68App", 0, LMGetCurApName());
|
||||||
|
|
||||||
|
LaunchParamBlockRec lpb;
|
||||||
|
memset(&lpb, 0, sizeof(lpb));
|
||||||
|
lpb.reserved1 = (unsigned long) LMGetCurApName();
|
||||||
|
lpb.reserved2 = 0;
|
||||||
|
OSErr err = LaunchApplication(&lpb);
|
||||||
|
ExitToShell();
|
||||||
|
}
|
||||||
onReset();
|
onReset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user