uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, IdAntiFreezeBase, IdAntiFreeze, IdBaseComponent, IdComponent,
- IdTCPConnection, IdTCPClient, IdHTTP, StdCtrls, ExtCtrls;
+ IdTCPConnection, IdTCPClient, IdHTTP, StdCtrls, ExtCtrls, Buttons;
type
TUpdateCheckForm = class(TForm)
IdHTTP: TIdHTTP;
IdAntiFreeze: TIdAntiFreeze;
NightBuildCheckButton: TButton;
+ CancelBitBtn: TBitBtn;
procedure UpdateButtonClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure NightBuildCheckButtonClick(Sender: TObject);
+ procedure CancelBitBtnClick(Sender: TObject);
private
{ Private \90é\8c¾ }
FExecPath : string;
FExecArgs : string;
FAllowshutdown : Boolean;
+ FCanceled : Boolean;
function GetDesktopDir:string;
function GetDownloadFilePath(FileName: String): String;
function CreateShortCut(FileName, Argment, SavePath :string):boolean;
function TUpdateCheckForm.CheckUpdate(nightbuild :Boolean): Boolean;
const
{$IFDEF DEBUG}
- CHECK_URL = 'http://gikonavi.sourceforge.jp/updater/debug.txt';
+// CHECK_URL = 'http://gikonavi.sourceforge.jp/updater/debug.txt';
+ CHECK_URL = 'http://gikonavigoeson.sourceforge.jp/updater/debug.txt';
{$ELSE}
- CHECK_URL = 'http://gikonavi.sourceforge.jp/updater/latest.txt';
+// CHECK_URL = 'http://gikonavi.sourceforge.jp/updater/latest.txt';
+ CHECK_URL = 'http://gikonavigoeson.sourceforge.jp/updater/latest.txt';
{$ENDIF}
var
value, url : string;
ResultMemo.Lines.Clear;
Screen.Cursor := crHourGlass;
UpdateButton.Enabled := False;
+ NightBuildCheckButton.Enabled := False;
try
ResStream := TMemoryStream.Create;
IdHTTP.Request.CacheControl := 'no-cache';
IdHTTP.Request.CustomHeaders.Add('Pragma: no-cache');
+ IdHTTP.ReadTimeout := 0;
IdHTTP.HandleRedirects := true;
downResult := TStringList.Create;
newest := TStringList.Create;
try
try
ResStream.Clear;
+ FCanceled := False;
+ CancelBitBtn.Enabled := True;
IdHTTP.Get(CHECK_URL, ResStream);
+ CancelBitBtn.Enabled := False;
+ if (FCanceled) then begin
+ raise Exception.Create('\83_\83E\83\93\83\8d\81[\83h\82ª\83L\83\83\83\93\83Z\83\8b\82³\82ê\82Ü\82µ\82½\81B');
+ end;
value := GikoSys.GzipDecompress(ResStream,
IdHTTP.Response.ContentEncoding);
downResult.Text := value;
ResStream.Free;
end;
finally
+ NightBuildCheckButton.Enabled := True;
UpdateButton.Enabled := True;
Screen.Cursor := crDefault;
end;
filename := GetDownloadFilePath(Copy(url, LastDelimiter('/', url) + 1, Length(url)));
fileStrem := TFileStream.Create(filename, fmCreate);
try
+ CancelBitBtn.Enabled := True;
IdHTTP.Get(url, fileStrem);
+ CancelBitBtn.Enabled := False;
+ if (FCanceled) then begin
+ raise Exception.Create('\83_\83E\83\93\83\8d\81[\83h\82ª\83L\83\83\83\93\83Z\83\8b\82³\82ê\82Ü\82µ\82½\81B');
+ end;
ResultMemo.Lines.Add(
IdHttp.ResponseText + '(' + IntToStr(IdHttp.ResponseCode) + ')');
FExecPath := filename;
//! Form\83R\83\93\83X\83g\83\89\83N\83^
procedure TUpdateCheckForm.FormCreate(Sender: TObject);
+var
+ CenterForm: TCustomForm;
begin
+ CenterForm := TCustomForm(Owner);
+ if Assigned(CenterForm) then begin
+ Left := ((CenterForm.Width - Width) div 2) + CenterForm.Left;
+ Top := ((CenterForm.Height - Height) div 2) + CenterForm.Top;
+ end else begin
+ Left := (Screen.Width - Width) div 2;
+ Top := (Screen.Height - Height) div 2;
+ end;
+
ResultMemo.Lines.Clear;
FExecPath := '';
FExecArgs := '';
FAllowshutdown := False;
end;
+//! \83L\83\83\83\93\83Z\83\8b\83{\83^\83\93\89\9f\89º
+procedure TUpdateCheckForm.CancelBitBtnClick(Sender: TObject);
+begin
+ CancelBitBtn.Enabled := False;
+ FCanceled := True;
+ if IdHTTP.Connected then begin
+ IdHTTP.Disconnect;
+ end;
+end;
end.