1
0
mirror of https://github.com/winscp/winscp.git synced 2026-10-24 02:28:55 +03:00

Bug fix: Do not say "Terminated by user" when the session has actually timed out.

Source commit: 2cf1314a501f2dcade0f3d30f88c39a5eba906d8
This commit is contained in:
Martin Prikryl
2021-03-31 11:56:02 +00:00
parent d3cb369141
commit 1dc5bc03c9
10 changed files with 44 additions and 10 deletions

View File

@@ -77,6 +77,7 @@ TQueryParams::TQueryParams(unsigned int AParams, UnicodeString AHelpKeyword)
TimerQueryType = static_cast<TQueryType>(-1);
Timeout = 0;
TimeoutAnswer = 0;
TimeoutResponse = 0;
NoBatchAnswers = 0;
HelpKeyword = AHelpKeyword;
}

View File

@@ -125,6 +125,7 @@ struct TQueryParams
TQueryType TimerQueryType;
unsigned int Timeout;
unsigned int TimeoutAnswer;
unsigned int TimeoutResponse;
unsigned int NoBatchAnswers;
UnicodeString HelpKeyword;
};

View File

@@ -1263,6 +1263,7 @@ unsigned int __fastcall TSecureShell::TimeoutPrompt(TQueryParamsTimerEvent PoolE
{
Params.Timeout = FConfiguration->SessionReopenAutoStall;
Params.TimeoutAnswer = qaAbort;
Params.TimeoutResponse = qaNo;
}
Answer = FUI->QueryUser(MainInstructions(FMTLOAD(CONFIRM_PROLONG_TIMEOUT3, (FSessionData->Timeout))),
NULL, qaRetry | qaAbort, &Params);
@@ -1297,6 +1298,11 @@ void __fastcall TSecureShell::SendBuffer(unsigned int & Result)
}
}
//---------------------------------------------------------------------------
void TSecureShell::TimeoutAbort(unsigned int Answer)
{
FatalError(MainInstructions(LoadStr(Answer == qaAbort ? USER_TERMINATED : TIMEOUT_ERROR)));
}
//---------------------------------------------------------------------------
void __fastcall TSecureShell::DispatchSendBuffer(int BufSize)
{
TDateTime Start = Now();
@@ -1335,7 +1341,8 @@ void __fastcall TSecureShell::DispatchSendBuffer(int BufSize)
// fallthru
case qaAbort:
FatalError(MainInstructions(LoadStr(USER_TERMINATED)));
case qaNo:
TimeoutAbort(Answer);
break;
}
}
@@ -1869,7 +1876,8 @@ void __fastcall TSecureShell::WaitForData()
// fallthru
case qaAbort:
FatalError(MainInstructions(LoadStr(USER_TERMINATED)));
case qaNo:
TimeoutAbort(Answer);
break;
}
}

View File

@@ -99,6 +99,7 @@ private:
void __fastcall DispatchSendBuffer(int BufSize);
void __fastcall SendBuffer(unsigned int & Result);
unsigned int __fastcall TimeoutPrompt(TQueryParamsTimerEvent PoolEvent);
void TimeoutAbort(unsigned int Answer);
bool __fastcall TryFtp();
UnicodeString __fastcall ConvertInput(const RawByteString & Input);
void __fastcall GetRealHost(UnicodeString & Host, int & Port);

View File

@@ -2165,6 +2165,7 @@ bool __fastcall TTerminal::DoQueryReopen(Exception * E)
TQueryParams Params(qpAllowContinueOnError);
Params.Timeout = Configuration->SessionReopenAuto;
Params.TimeoutAnswer = qaRetry;
Params.TimeoutResponse = Params.TimeoutAnswer;
TQueryButtonAlias Aliases[1];
Aliases[0].Button = qaRetry;
Aliases[0].Alias = LoadStr(RECONNECT_BUTTON);

View File

@@ -330,6 +330,7 @@
#define S3_SECRET_ACCESS_KEY_PROMPT 359
#define DUPLICATE_FOLDER_NOT_SUPPORTED 360
#define MISSING_TARGET_BUCKET 361
#define TIMEOUT_ERROR 362
#define CORE_INFORMATION_STRINGS 400
#define YES_STR 401

View File

@@ -246,6 +246,7 @@ BEGIN
STREAM_IN_SCRIPT_ERROR, "When uploading streamed data, only one source can be specified and the target must specify a filename."
STREAM_READ_ERROR, "Error reading input stream."
S3_CONFIG_ERROR, "Error reading AWS configuration parameter %s"
TIMEOUT_ERROR, "Timeout waiting for server to respond."
CORE_CONFIRMATION_STRINGS, "CORE_CONFIRMATION"
CONFIRM_PROLONG_TIMEOUT3, "Host is not communicating for %d seconds.\n\nWait for another %0:d seconds?"

View File

@@ -1412,6 +1412,7 @@ void __fastcall TConsoleRunner::ScriptTerminalQueryUser(TObject * /*Sender*/,
unsigned int Timer = 0;
unsigned int Timeout = 0;
unsigned int TimeoutA = 0;
unsigned int TimeoutR = 0;
unsigned int NoBatchA = 0;
if (Params != NULL)
@@ -1420,6 +1421,8 @@ void __fastcall TConsoleRunner::ScriptTerminalQueryUser(TObject * /*Sender*/,
{
Timeout = Params->Timeout;
TimeoutA = Params->TimeoutAnswer;
TimeoutR = Params->TimeoutResponse;
DebugAssert((TimeoutA != 0) && (TimeoutR != 0));
}
if (Params->Timer > 0)
@@ -1449,8 +1452,10 @@ void __fastcall TConsoleRunner::ScriptTerminalQueryUser(TObject * /*Sender*/,
Timeout = InputTimeout();
if (Timeout != 0)
{
DebugAssert((TimeoutA == 0) && (TimeoutR == 0));
// See a duplicate AbortAnswer call below
TimeoutA = AbortAnswer(Answers & ~NoBatchA);
TimeoutR = TimeoutA;
}
}
}
@@ -1669,6 +1674,7 @@ void __fastcall TConsoleRunner::ScriptTerminalQueryUser(TObject * /*Sender*/,
else if (Timeouting && (Timeout < MSecsPerSec))
{
AnswerIndex = TimeoutIndex;
Answer = TimeoutR;
}
else
{

View File

@@ -64,6 +64,7 @@ TMessageParams::TMessageParams(const TQueryParams * AParams)
TimerQueryType = AParams->TimerQueryType;
Timeout = AParams->Timeout;
TimeoutAnswer = AParams->TimeoutAnswer;
TimeoutResponse = AParams->TimeoutResponse;
if (FLAGSET(AParams->Params, qpNeverAskAgainCheck))
{
@@ -88,6 +89,7 @@ inline void TMessageParams::Reset()
TimerQueryType = static_cast<TQueryType>(-1);
Timeout = 0;
TimeoutAnswer = 0;
TimeoutResponse = 0;
NeverAskAgainTitle = L"";
NeverAskAgainAnswer = 0;
NeverAskAgainCheckedInitially = false;
@@ -323,7 +325,7 @@ void __fastcall TMessageTimer::DoTimer(TObject * /*Sender*/)
class TMessageTimeout : public TTimer
{
public:
__fastcall TMessageTimeout(TComponent * AOwner, unsigned int Timeout, TButton * Button);
__fastcall TMessageTimeout(TComponent * AOwner, unsigned int Timeout, TButton * Button, unsigned int Answer);
protected:
unsigned int FOrigTimeout;
@@ -332,6 +334,7 @@ protected:
UnicodeString FOrigCaption;
TPoint FOrigCursorPos;
std::unique_ptr<TApplicationEvents> FApplicationEvents;
unsigned int FAnswer;
void __fastcall DoTimer(TObject * Sender);
void __fastcall UpdateButton();
@@ -341,8 +344,8 @@ protected:
};
//---------------------------------------------------------------------------
__fastcall TMessageTimeout::TMessageTimeout(TComponent * AOwner,
unsigned int Timeout, TButton * Button) :
TTimer(AOwner), FOrigTimeout(Timeout), FTimeout(Timeout), FButton(Button)
unsigned int Timeout, TButton * Button, unsigned int Answer) :
TTimer(AOwner), FOrigTimeout(Timeout), FTimeout(Timeout), FButton(Button), FAnswer(Answer)
{
OnTimer = DoTimer;
Interval = MSecsPerSec;
@@ -407,7 +410,16 @@ void __fastcall TMessageTimeout::DoTimer(TObject * /*Sender*/)
// Needed particularly for "keep up to date" dialog, which does not close on the button click
Enabled = false;
FButton->Click();
TModalResult PrevModalResult = FButton->ModalResult;
FButton->ModalResult = FAnswer;
try
{
FButton->Click();
}
__finally
{
FButton->ModalResult = PrevModalResult;
}
}
else
{
@@ -416,9 +428,9 @@ void __fastcall TMessageTimeout::DoTimer(TObject * /*Sender*/)
}
}
//---------------------------------------------------------------------------
void InitiateDialogTimeout(TForm * Dialog, unsigned int Timeout, TButton * Button)
void InitiateDialogTimeout(TForm * Dialog, unsigned int Timeout, TButton * Button, unsigned int Answer)
{
TMessageTimeout * MessageTimeout = new TMessageTimeout(Application, Timeout, Button);
TMessageTimeout * MessageTimeout = new TMessageTimeout(Application, Timeout, Button, Answer);
MessageTimeout->Name = L"MessageTimeout";
Dialog->InsertComponent(MessageTimeout);
}
@@ -471,7 +483,7 @@ TForm * __fastcall CreateMoreMessageDialogEx(const UnicodeString Message, TStrin
{
if (Params->Timeout > 0)
{
InitiateDialogTimeout(Dialog.get(), Params->Timeout, TimeoutButton);
InitiateDialogTimeout(Dialog.get(), Params->Timeout, TimeoutButton, Params->TimeoutResponse);
}
}
@@ -662,6 +674,7 @@ unsigned int __fastcall FatalExceptionMessageDialog(Exception * E, TQueryType Ty
{
AParams.Timeout = SessionReopenTimeout;
AParams.TimeoutAnswer = qaRetry;
AParams.TimeoutResponse = AParams.TimeoutAnswer;
}
DebugAssert(AParams.Aliases == NULL);
AParams.Aliases = Aliases;

View File

@@ -73,6 +73,7 @@ struct TMessageParams
TQueryType TimerQueryType;
unsigned int Timeout;
unsigned int TimeoutAnswer;
unsigned int TimeoutResponse;
UnicodeString NeverAskAgainTitle;
unsigned int NeverAskAgainAnswer;
bool NeverAskAgainCheckedInitially;
@@ -119,7 +120,7 @@ Tbx::TTBXSeparatorItem * __fastcall AddMenuSeparator(Tb2item::TTBCustomItem * Me
void __fastcall AddMenuLabel(Tb2item::TTBCustomItem * Menu, const UnicodeString & Label);
void __fastcall ClickToolbarItem(Tb2item::TTBCustomItem * Item, bool PositionCursor);
void InitiateDialogTimeout(TForm * Dialog, unsigned int Timeout, TButton * Button);
void InitiateDialogTimeout(TForm * Dialog, unsigned int Timeout, TButton * Button, unsigned int Answer = 0);
// windows\WinHelp.cpp
void __fastcall InitializeWinHelp();