mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2025-08-06 18:24:26 +08:00
Issue #3334:
* Decrease connect timeout for donation state check from 30s down to 3s, so especially on application start noone has to wait too long only because heidisql.com is down again. * Return TThreeStateBoolean in HasDonated(), so we can display an appropriate warning when the HTTP check was unsuccessful
This commit is contained in:
@ -7,7 +7,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: HeidiSQL\n"
|
||||
"POT-Creation-Date: 2012-11-05 21:40\n"
|
||||
"PO-Revision-Date: 2013-09-14 06:56+0100\n"
|
||||
"PO-Revision-Date: 2013-09-17 20:06+0100\n"
|
||||
"Last-Translator: Ansgar Becker <heidisql@anse.de>\n"
|
||||
"Language-Team: English (http://www.transifex.com/projects/p/heidisql/"
|
||||
"language/en/)\n"
|
||||
@ -49,6 +49,10 @@ msgstr "Thanks for donating!"
|
||||
msgid "Not a valid donators email address"
|
||||
msgstr "Not a valid donators email address"
|
||||
|
||||
#. About dialog
|
||||
msgid "Could not check donation state, gracefully assuming you have donated."
|
||||
msgstr "Could not check donation state, gracefully assuming you have donated."
|
||||
|
||||
#. frmBinEditor..Caption
|
||||
#: bineditor.dfm:4
|
||||
msgid "Binary editor"
|
||||
|
@ -63,15 +63,22 @@ end;
|
||||
|
||||
|
||||
procedure TAboutBox.btnDonatedOKClick(Sender: TObject);
|
||||
var
|
||||
Check: TThreeStateBoolean;
|
||||
begin
|
||||
AppSettings.WriteString(asDonatedEmail, editDonated.Text);
|
||||
if MainForm.HasDonated(True) then
|
||||
MessageDialog(_('Thanks for donating!'), mtInformation, [mbOK])
|
||||
else
|
||||
ErrorDialog(_('Not a valid donators email address'));
|
||||
imgDonate.Visible := not MainForm.HasDonated(False);
|
||||
Check := MainForm.HasDonated(True);
|
||||
case Check of
|
||||
nbUnset:
|
||||
MessageDialog(_('Could not check donation state, gracefully assuming you have donated.'), mtWarning, [mbOK]);
|
||||
nbFalse:
|
||||
ErrorDialog(_('Not a valid donators email address'));
|
||||
nbTrue:
|
||||
MessageDialog(_('Thanks for donating!'), mtInformation, [mbOK]);
|
||||
end;
|
||||
imgDonate.Visible := Check = nbFalse;
|
||||
MainForm.imgDonate.Width := 122;
|
||||
MainForm.imgDonate.Visible := not MainForm.HasDonated(False);
|
||||
MainForm.imgDonate.Visible := imgDonate.Visible;
|
||||
end;
|
||||
|
||||
|
||||
@ -99,7 +106,7 @@ begin
|
||||
lblAppName.Font.Size := 14;
|
||||
InheritFont(lblAppWebpage.Font);
|
||||
imgDonate.Hint := APPDOMAIN + imgDonate.Hint;
|
||||
imgDonate.Visible := not MainForm.HasDonated(False);
|
||||
imgDonate.Visible := MainForm.HasDonated(False) = nbFalse;
|
||||
editDonated.Text := AppSettings.ReadString(asDonatedEmail);
|
||||
|
||||
// Assign text
|
||||
|
@ -80,12 +80,14 @@ type
|
||||
FURL: String;
|
||||
FBytesRead: Integer;
|
||||
FContentLength: Integer;
|
||||
FTimeOut: Cardinal;
|
||||
FOnProgress: TNotifyEvent;
|
||||
public
|
||||
constructor Create(Owner: TComponent);
|
||||
procedure SendRequest(Filename: String);
|
||||
property OnProgress: TNotifyEvent read FOnProgress write FOnProgress;
|
||||
property URL: String read FURL write FURL;
|
||||
property TimeOut: Cardinal read FTimeOut write FTimeOut;
|
||||
property BytesRead: Integer read FBytesRead;
|
||||
property ContentLength: Integer read FContentLength;
|
||||
end;
|
||||
@ -3026,6 +3028,7 @@ begin
|
||||
FBytesRead := -1;
|
||||
FContentLength := -1;
|
||||
FOwner := Owner;
|
||||
FTimeOut := 10;
|
||||
end;
|
||||
|
||||
|
||||
@ -3035,7 +3038,7 @@ var
|
||||
UrlHandle: HINTERNET;
|
||||
Buffer: array[1..4096] of Byte;
|
||||
Head: array[1..1024] of Char;
|
||||
BytesInChunk, HeadSize, Reserved: Cardinal;
|
||||
BytesInChunk, HeadSize, Reserved, TimeOutSeconds: Cardinal;
|
||||
LocalFile: File;
|
||||
DoStore: Boolean;
|
||||
UserAgent, OS: String;
|
||||
@ -3048,8 +3051,12 @@ begin
|
||||
OS := 'Windows NT '+IntToStr(Win32MajorVersion)+'.'+IntToStr(Win32MinorVersion);
|
||||
UserAgent := APPNAME+'/'+MainForm.AppVersion+' ('+OS+'; '+ExtractFilename(Application.ExeName)+'; '+FOwner.Name+')';
|
||||
NetHandle := InternetOpen(PChar(UserAgent), INTERNET_OPEN_TYPE_PRECONFIG, nil, nil, 0);
|
||||
UrlHandle := nil;
|
||||
|
||||
// Do not let the user wait 30s
|
||||
TimeOutSeconds := FTimeOut * 1000;
|
||||
InternetSetOption(NetHandle, INTERNET_OPTION_CONNECT_TIMEOUT, @TimeOutSeconds, SizeOf(TimeOutSeconds));
|
||||
|
||||
UrlHandle := nil;
|
||||
try
|
||||
UrlHandle := InternetOpenURL(NetHandle, PChar(FURL), nil, 0, INTERNET_FLAG_RELOAD, 0);
|
||||
if not Assigned(UrlHandle) then
|
||||
|
@ -1071,7 +1071,7 @@ type
|
||||
procedure ProgressStep;
|
||||
procedure SetProgressState(State: TProgressbarState);
|
||||
procedure TaskDialogHyperLinkClicked(Sender: TObject);
|
||||
function HasDonated(ForceCheck: Boolean): Boolean;
|
||||
function HasDonated(ForceCheck: Boolean): TThreeStateBoolean;
|
||||
end;
|
||||
|
||||
|
||||
@ -1683,7 +1683,7 @@ begin
|
||||
imgDonate.Width := 122;
|
||||
imgDonate.Height := 22;
|
||||
imgDonate.Hint := APPDOMAIN + imgDonate.Hint;
|
||||
imgDonate.Visible := not HasDonated(True);
|
||||
imgDonate.Visible := HasDonated(True) = nbFalse;
|
||||
|
||||
FileEncodings := Explode(',', _('Auto detect (may fail)')+',ANSI,ASCII,Unicode,Unicode Big Endian,UTF-8,UTF-7');
|
||||
|
||||
@ -11297,7 +11297,7 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
function TMainForm.HasDonated(ForceCheck: Boolean): Boolean;
|
||||
function TMainForm.HasDonated(ForceCheck: Boolean): TThreeStateBoolean;
|
||||
var
|
||||
Email, TempFileName, CheckResult: String;
|
||||
rx: TRegExpr;
|
||||
@ -11318,6 +11318,7 @@ begin
|
||||
rx := TRegExpr.Create;
|
||||
CheckWebpage := THttpDownload.Create(MainForm);
|
||||
CheckWebpage.URL := APPDOMAIN + 'hasdonated.php?email='+EncodeURLElementUnicode(Email);
|
||||
CheckWebpage.TimeOut := 3;
|
||||
TempFileName := GetTempDir + '\' + APPNAME + '_hasdonated_check.tmp';
|
||||
try
|
||||
CheckWebpage.SendRequest(TempFileName);
|
||||
@ -11340,8 +11341,7 @@ begin
|
||||
rx.Free;
|
||||
end;
|
||||
end;
|
||||
// Gracefully return true if webpage access was not successful
|
||||
Result := FHasDonatedDatabaseCheck in [nbUnset, nbTrue];
|
||||
Result := FHasDonatedDatabaseCheck;
|
||||
Screen.Cursor := crDefault;
|
||||
end;
|
||||
|
||||
|
@ -59,7 +59,7 @@ begin
|
||||
InheritFont(Font);
|
||||
TranslateComponent(Self);
|
||||
imgDonate.Hint := APPDOMAIN + imgDonate.Hint;
|
||||
imgDonate.Visible := not MainForm.HasDonated(False);
|
||||
imgDonate.Visible := MainForm.HasDonated(False) = nbFalse;
|
||||
end;
|
||||
|
||||
{**
|
||||
|
Reference in New Issue
Block a user