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