|
@@ -212,156 +212,170 @@ void __fastcall ShowExtendedExceptionEx(TTerminal * Terminal,
|
|
// swallow
|
|
// swallow
|
|
}
|
|
}
|
|
|
|
|
|
- if (!DoNotDisplay)
|
|
|
|
|
|
+ TTerminalManager * Manager = TTerminalManager::Instance(false);
|
|
|
|
+ bool HookedDialog = false;
|
|
|
|
+ try
|
|
{
|
|
{
|
|
- TTerminalManager * Manager = TTerminalManager::Instance(false);
|
|
|
|
-
|
|
|
|
- ESshTerminate * Terminate = dynamic_cast<ESshTerminate*>(E);
|
|
|
|
- bool CloseOnCompletion = (Terminate != NULL);
|
|
|
|
-
|
|
|
|
- bool ForActiveTerminal =
|
|
|
|
- E->InheritsFrom(__classid(EFatal)) && (Terminal != NULL) &&
|
|
|
|
- (Manager != NULL) && (Manager->ActiveTerminal == Terminal);
|
|
|
|
-
|
|
|
|
- unsigned int Result;
|
|
|
|
- if (CloseOnCompletion)
|
|
|
|
|
|
+ if (!DoNotDisplay)
|
|
{
|
|
{
|
|
- if (ForActiveTerminal)
|
|
|
|
- {
|
|
|
|
- DebugAssert(!Terminal->Active);
|
|
|
|
- Manager->DisconnectActiveTerminal();
|
|
|
|
- }
|
|
|
|
|
|
+ ESshTerminate * Terminate = dynamic_cast<ESshTerminate*>(E);
|
|
|
|
+ bool CloseOnCompletion = (Terminate != NULL);
|
|
|
|
|
|
- if (Terminate->Operation == odoSuspend)
|
|
|
|
- {
|
|
|
|
- // suspend, so that exit prompt is shown only after windows resume
|
|
|
|
- SuspendWindows();
|
|
|
|
- }
|
|
|
|
|
|
+ bool ForActiveTerminal =
|
|
|
|
+ E->InheritsFrom(__classid(EFatal)) && (Terminal != NULL) &&
|
|
|
|
+ (Manager != NULL) && (Manager->ActiveTerminal == Terminal);
|
|
|
|
|
|
- DebugAssert(Show);
|
|
|
|
- bool ConfirmExitOnCompletion =
|
|
|
|
- CloseOnCompletion &&
|
|
|
|
- ((Terminate->Operation == odoDisconnect) || (Terminate->Operation == odoSuspend)) &&
|
|
|
|
- WinConfiguration->ConfirmExitOnCompletion;
|
|
|
|
-
|
|
|
|
- if (ConfirmExitOnCompletion)
|
|
|
|
|
|
+ unsigned int Result;
|
|
|
|
+ if (CloseOnCompletion)
|
|
{
|
|
{
|
|
- TMessageParams Params(mpNeverAskAgainCheck);
|
|
|
|
- unsigned int Answers = 0;
|
|
|
|
- TQueryButtonAlias Aliases[1];
|
|
|
|
- TOpenLocalPathHandler OpenLocalPathHandler;
|
|
|
|
- if (!Terminate->TargetLocalPath.IsEmpty() && !ForActiveTerminal)
|
|
|
|
|
|
+ if (ForActiveTerminal)
|
|
{
|
|
{
|
|
- OpenLocalPathHandler.LocalPath = Terminate->TargetLocalPath;
|
|
|
|
- OpenLocalPathHandler.LocalFileName = Terminate->DestLocalFileName;
|
|
|
|
-
|
|
|
|
- Aliases[0].Button = qaIgnore;
|
|
|
|
- Aliases[0].Alias = LoadStr(OPEN_BUTTON);
|
|
|
|
- Aliases[0].OnSubmit = OpenLocalPathHandler.Open;
|
|
|
|
- Aliases[0].MenuButton = true;
|
|
|
|
- Answers |= Aliases[0].Button;
|
|
|
|
- Params.Aliases = Aliases;
|
|
|
|
- Params.AliasesCount = LENOF(Aliases);
|
|
|
|
|
|
+ DebugAssert(!Terminal->Active);
|
|
|
|
+ Manager->DisconnectActiveTerminal();
|
|
}
|
|
}
|
|
|
|
|
|
- if (ForActiveTerminal)
|
|
|
|
|
|
+ if (Terminate->Operation == odoSuspend)
|
|
{
|
|
{
|
|
- UnicodeString MessageFormat =
|
|
|
|
- (Manager->Count > 1) ?
|
|
|
|
- FMTLOAD(DISCONNECT_ON_COMPLETION, (Manager->Count - 1)) :
|
|
|
|
- LoadStr(EXIT_ON_COMPLETION);
|
|
|
|
- // Remove the leading "%s\n\n" (not to change the translation originals - previously the error message was prepended)
|
|
|
|
- MessageFormat = FORMAT(MessageFormat, (UnicodeString())).Trim();
|
|
|
|
- MessageFormat = MainInstructions(MessageFormat) + L"\n\n%s";
|
|
|
|
- Result = FatalExceptionMessageDialog(E, qtInformation, 0,
|
|
|
|
- MessageFormat,
|
|
|
|
- Answers | qaYes | qaNo, HELP_NONE, &Params);
|
|
|
|
|
|
+ // suspend, so that exit prompt is shown only after windows resume
|
|
|
|
+ SuspendWindows();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ DebugAssert(Show);
|
|
|
|
+ bool ConfirmExitOnCompletion =
|
|
|
|
+ CloseOnCompletion &&
|
|
|
|
+ ((Terminate->Operation == odoDisconnect) || (Terminate->Operation == odoSuspend)) &&
|
|
|
|
+ WinConfiguration->ConfirmExitOnCompletion;
|
|
|
|
+
|
|
|
|
+ if (ConfirmExitOnCompletion)
|
|
|
|
+ {
|
|
|
|
+ TMessageParams Params(mpNeverAskAgainCheck);
|
|
|
|
+ unsigned int Answers = 0;
|
|
|
|
+ TQueryButtonAlias Aliases[1];
|
|
|
|
+ TOpenLocalPathHandler OpenLocalPathHandler;
|
|
|
|
+ if (!Terminate->TargetLocalPath.IsEmpty() && !ForActiveTerminal)
|
|
|
|
+ {
|
|
|
|
+ OpenLocalPathHandler.LocalPath = Terminate->TargetLocalPath;
|
|
|
|
+ OpenLocalPathHandler.LocalFileName = Terminate->DestLocalFileName;
|
|
|
|
+
|
|
|
|
+ Aliases[0].Button = qaIgnore;
|
|
|
|
+ Aliases[0].Alias = LoadStr(OPEN_BUTTON);
|
|
|
|
+ Aliases[0].OnSubmit = OpenLocalPathHandler.Open;
|
|
|
|
+ Aliases[0].MenuButton = true;
|
|
|
|
+ Answers |= Aliases[0].Button;
|
|
|
|
+ Params.Aliases = Aliases;
|
|
|
|
+ Params.AliasesCount = LENOF(Aliases);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (ForActiveTerminal)
|
|
|
|
+ {
|
|
|
|
+ UnicodeString MessageFormat =
|
|
|
|
+ (Manager->Count > 1) ?
|
|
|
|
+ FMTLOAD(DISCONNECT_ON_COMPLETION, (Manager->Count - 1)) :
|
|
|
|
+ LoadStr(EXIT_ON_COMPLETION);
|
|
|
|
+ // Remove the leading "%s\n\n" (not to change the translation originals - previously the error message was prepended)
|
|
|
|
+ MessageFormat = FORMAT(MessageFormat, (UnicodeString())).Trim();
|
|
|
|
+ MessageFormat = MainInstructions(MessageFormat) + L"\n\n%s";
|
|
|
|
+ Result = FatalExceptionMessageDialog(E, qtInformation,
|
|
|
|
+ MessageFormat,
|
|
|
|
+ Answers | qaYes | qaNo, HELP_NONE, &Params);
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ Result =
|
|
|
|
+ ExceptionMessageDialog(E, qtInformation, L"", Answers | qaOK, HELP_NONE, &Params);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- Result =
|
|
|
|
- ExceptionMessageDialog(E, qtInformation, L"", Answers | qaOK, HELP_NONE, &Params);
|
|
|
|
|
|
+ Result = qaYes;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- Result = qaYes;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- if (Show)
|
|
|
|
- {
|
|
|
|
- if (ForActiveTerminal)
|
|
|
|
|
|
+ if (Show)
|
|
{
|
|
{
|
|
- int SessionReopenTimeout = 0;
|
|
|
|
- if (DebugAlwaysTrue(Manager->ActiveTerminal != NULL) &&
|
|
|
|
- ((Configuration->SessionReopenTimeout == 0) ||
|
|
|
|
- ((double)Manager->ActiveTerminal->ReopenStart == 0) ||
|
|
|
|
- (int(double(Now() - Manager->ActiveTerminal->ReopenStart) * MSecsPerDay) < Configuration->SessionReopenTimeout)))
|
|
|
|
|
|
+ if (ForActiveTerminal)
|
|
|
|
+ {
|
|
|
|
+ TMessageParams Params;
|
|
|
|
+ if (DebugAlwaysTrue(Manager->ActiveTerminal != NULL) &&
|
|
|
|
+ ((Configuration->SessionReopenTimeout == 0) ||
|
|
|
|
+ ((double)Manager->ActiveTerminal->ReopenStart == 0) ||
|
|
|
|
+ (int(double(Now() - Manager->ActiveTerminal->ReopenStart) * MSecsPerDay) < Configuration->SessionReopenTimeout)))
|
|
|
|
+ {
|
|
|
|
+ Params.Timeout = GUIConfiguration->SessionReopenAutoIdle;
|
|
|
|
+ Params.TimeoutAnswer = qaRetry;
|
|
|
|
+ Params.TimeoutResponse = Params.TimeoutAnswer;
|
|
|
|
+ HookedDialog = Manager->HookFatalExceptionMessageDialog(Params);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Result = FatalExceptionMessageDialog(E, qtError, EmptyStr, qaOK, EmptyStr, &Params);
|
|
|
|
+ }
|
|
|
|
+ else
|
|
{
|
|
{
|
|
- SessionReopenTimeout = GUIConfiguration->SessionReopenAutoIdle;
|
|
|
|
|
|
+ Result = ExceptionMessageDialog(E, qtError);
|
|
}
|
|
}
|
|
- Result = FatalExceptionMessageDialog(E, qtError, SessionReopenTimeout);
|
|
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- Result = ExceptionMessageDialog(E, qtError);
|
|
|
|
|
|
+ Result = qaOK;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- else
|
|
|
|
|
|
+
|
|
|
|
+ if (Result == qaNeverAskAgain)
|
|
{
|
|
{
|
|
- Result = qaOK;
|
|
|
|
|
|
+ DebugAssert(CloseOnCompletion);
|
|
|
|
+ Result = qaYes;
|
|
|
|
+ WinConfiguration->ConfirmExitOnCompletion = false;
|
|
}
|
|
}
|
|
- }
|
|
|
|
-
|
|
|
|
- if (Result == qaNeverAskAgain)
|
|
|
|
- {
|
|
|
|
- DebugAssert(CloseOnCompletion);
|
|
|
|
- Result = qaYes;
|
|
|
|
- WinConfiguration->ConfirmExitOnCompletion = false;
|
|
|
|
- }
|
|
|
|
|
|
|
|
- if (Result == qaYes)
|
|
|
|
- {
|
|
|
|
- DebugAssert(CloseOnCompletion);
|
|
|
|
- DebugAssert(Terminate != NULL);
|
|
|
|
- DebugAssert(Terminate->Operation != odoIdle);
|
|
|
|
- TerminateApplication();
|
|
|
|
-
|
|
|
|
- switch (Terminate->Operation)
|
|
|
|
|
|
+ if (Result == qaYes)
|
|
{
|
|
{
|
|
- case odoDisconnect:
|
|
|
|
- break;
|
|
|
|
|
|
+ DebugAssert(CloseOnCompletion);
|
|
|
|
+ DebugAssert(Terminate != NULL);
|
|
|
|
+ DebugAssert(Terminate->Operation != odoIdle);
|
|
|
|
+ TerminateApplication();
|
|
|
|
|
|
- case odoSuspend:
|
|
|
|
- // suspended before already
|
|
|
|
- break;
|
|
|
|
|
|
+ switch (Terminate->Operation)
|
|
|
|
+ {
|
|
|
|
+ case odoDisconnect:
|
|
|
|
+ break;
|
|
|
|
|
|
- case odoShutDown:
|
|
|
|
- ShutDownWindows();
|
|
|
|
- break;
|
|
|
|
|
|
+ case odoSuspend:
|
|
|
|
+ // suspended before already
|
|
|
|
+ break;
|
|
|
|
|
|
- default:
|
|
|
|
- DebugFail();
|
|
|
|
|
|
+ case odoShutDown:
|
|
|
|
+ ShutDownWindows();
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ default:
|
|
|
|
+ DebugFail();
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- }
|
|
|
|
- else if (Result == qaRetry)
|
|
|
|
- {
|
|
|
|
- // qaRetry is used by FatalExceptionMessageDialog
|
|
|
|
- if (DebugAlwaysTrue(ForActiveTerminal))
|
|
|
|
|
|
+ else if (Result == qaRetry)
|
|
{
|
|
{
|
|
- Manager->ReconnectActiveTerminal();
|
|
|
|
|
|
+ // qaRetry is used by FatalExceptionMessageDialog
|
|
|
|
+ if (DebugAlwaysTrue(ForActiveTerminal))
|
|
|
|
+ {
|
|
|
|
+ Manager->ReconnectActiveTerminal();
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- if (ForActiveTerminal)
|
|
|
|
|
|
+ else
|
|
{
|
|
{
|
|
- Manager->DisconnectActiveTerminalIfPermanentFreeOtherwise();
|
|
|
|
|
|
+ if (ForActiveTerminal)
|
|
|
|
+ {
|
|
|
|
+ Manager->DisconnectActiveTerminalIfPermanentFreeOtherwise();
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ __finally
|
|
|
|
+ {
|
|
|
|
+ if (HookedDialog)
|
|
|
|
+ {
|
|
|
|
+ Manager->UnhookFatalExceptionMessageDialog();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
//---------------------------------------------------------------------------
|
|
void __fastcall ShowNotification(TTerminal * Terminal, const UnicodeString & Str,
|
|
void __fastcall ShowNotification(TTerminal * Terminal, const UnicodeString & Str,
|