TestApp updated

LazAutoUpdate updated

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5680 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
gbamber
2017-01-20 11:11:56 +00:00
parent 02352e3d11
commit 01a2b58790
6 changed files with 123 additions and 68 deletions

View File

@ -19,7 +19,10 @@
</General>
<VersionInfo>
<UseVersionInfo Value="True"/>
<MajorVersionNr Value="1"/>
<MinorVersionNr Value="1"/>
<RevisionNr Value="1"/>
<BuildNr Value="1"/>
<StringTable ProductVersion="0.0.0.0"/>
</VersionInfo>
<BuildModes Count="5">
@ -50,6 +53,11 @@
</Win32>
</Options>
</Linking>
<Other>
<OtherDefines Count="1">
<Define0 Value="DEBUGMODE"/>
</OtherDefines>
</Other>
</CompilerOptions>
</Item2>
<Item3 Name="Win64">
@ -218,6 +226,13 @@
</Win32>
</Options>
</Linking>
<Other>
<CustomOptions Value="-FcUTF8
-dDEBUGMODE"/>
<OtherDefines Count="1">
<Define0 Value="DEBUGMODE"/>
</OtherDefines>
</Other>
</CompilerOptions>
<Debugging>
<Exceptions Count="3">

View File

@ -9,8 +9,8 @@
<Filename Value="testapp.lpr"/>
<IsPartOfProject Value="True"/>
<EditorIndex Value="2"/>
<CursorPos X="33" Y="27"/>
<UsageCount Value="51"/>
<CursorPos X="28" Y="19"/>
<UsageCount Value="53"/>
<Loaded Value="True"/>
</Unit0>
<Unit1>
@ -19,9 +19,10 @@
<ComponentName Value="mainform"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<TopLine Value="64"/>
<CursorPos X="19" Y="103"/>
<UsageCount Value="51"/>
<IsVisibleTab Value="True"/>
<TopLine Value="95"/>
<CursorPos X="23" Y="109"/>
<UsageCount Value="53"/>
<Loaded Value="True"/>
<LoadedDesigner Value="True"/>
</Unit1>
@ -32,7 +33,7 @@
<WindowIndex Value="1"/>
<TopLine Value="3"/>
<CursorPos X="76" Y="8"/>
<UsageCount Value="34"/>
<UsageCount Value="36"/>
<Loaded Value="True"/>
</Unit2>
<Unit3>
@ -46,13 +47,12 @@
<IsVisibleTab Value="True"/>
<WindowIndex Value="1"/>
<TopLine Value="184"/>
<CursorPos X="13" Y="221"/>
<CursorPos X="50" Y="204"/>
<ExtraEditorCount Value="2"/>
<ExtraEditor1>
<IsVisibleTab Value="True"/>
<EditorIndex Value="1"/>
<TopLine Value="45"/>
<CursorPos X="42" Y="69"/>
<TopLine Value="2255"/>
<CursorPos X="22" Y="2277"/>
</ExtraEditor1>
<ExtraEditor2>
<EditorIndex Value="-1"/>
@ -60,7 +60,7 @@
<TopLine Value="-1"/>
<CursorPos X="-1" Y="-1"/>
</ExtraEditor2>
<UsageCount Value="25"/>
<UsageCount Value="26"/>
<Loaded Value="True"/>
</Unit4>
<Unit5>
@ -147,7 +147,7 @@
<WindowIndex Value="1"/>
<TopLine Value="35"/>
<CursorPos X="40" Y="51"/>
<UsageCount Value="15"/>
<UsageCount Value="16"/>
<Loaded Value="True"/>
</Unit16>
<Unit17>
@ -159,129 +159,129 @@
<UsageCount Value="11"/>
</Unit17>
</Units>
<General>
<ActiveWindowIndexAtStart Value="1"/>
</General>
<OtherDefines Count="1">
<Define0 Value="DEBUGMODE"/>
</OtherDefines>
<JumpHistory Count="30" HistoryIndex="29">
<Position1>
<Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="55" Column="19" TopLine="28"/>
<Caret Line="1514" TopLine="1489"/>
</Position1>
<Position2>
<Filename Value="umainform.pas"/>
<Caret Line="53" Column="103" TopLine="32"/>
<Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="61" Column="80" TopLine="37"/>
</Position2>
<Position3>
<Filename Value="umainform.pas"/>
<Caret Line="82" Column="9" TopLine="47"/>
<Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="757" Column="2" TopLine="718"/>
</Position3>
<Position4>
<Filename Value="umainform.pas"/>
<Caret Line="89" Column="30" TopLine="58"/>
<Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="2282" Column="46" TopLine="2250"/>
</Position4>
<Position5>
<Filename Value="umainform.pas"/>
<Caret Line="15" Column="23"/>
<Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="592" Column="3" TopLine="567"/>
</Position5>
<Position6>
<Filename Value="umainform.pas"/>
<Caret Line="79" Column="26" TopLine="53"/>
<Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="982" TopLine="966"/>
</Position6>
<Position7>
<Filename Value="umainform.pas"/>
<Caret Line="157" Column="94" TopLine="115"/>
<Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="1745" Column="17" TopLine="1720"/>
</Position7>
<Position8>
<Filename Value="umainform.pas"/>
<Caret Line="95" TopLine="64"/>
<Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="1898" Column="17" TopLine="1873"/>
</Position8>
<Position9>
<Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="518" Column="16" TopLine="483"/>
<Caret Line="2267" TopLine="2247"/>
</Position9>
<Position10>
<Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="1823" Column="4" TopLine="1796"/>
<Caret Line="2286" Column="17" TopLine="2247"/>
</Position10>
<Position11>
<Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="577" Column="7" TopLine="544"/>
<Caret Line="2270" TopLine="2246"/>
</Position11>
<Position12>
<Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="539" Column="7" TopLine="516"/>
<Caret Line="2273" Column="17" TopLine="2246"/>
</Position12>
<Position13>
<Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="331" Column="71" TopLine="300"/>
<Caret Line="2269" TopLine="2244"/>
</Position13>
<Position14>
<Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="1869" TopLine="1830"/>
<Caret Line="592" Column="3" TopLine="567"/>
</Position14>
<Position15>
<Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="228" Column="23" TopLine="199"/>
<Filename Value="umainform.pas"/>
<Caret Line="99" Column="38" TopLine="64"/>
</Position15>
<Position16>
<Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="331" Column="88" TopLine="309"/>
<Filename Value="umainform.pas"/>
<Caret Line="127" Column="28" TopLine="123"/>
</Position16>
<Position17>
<Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="1514" TopLine="1489"/>
<Caret Line="472" Column="22" TopLine="446"/>
</Position17>
<Position18>
<Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="61" Column="80" TopLine="37"/>
<Caret Line="1094" Column="27" TopLine="1082"/>
</Position18>
<Position19>
<Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="757" Column="2" TopLine="718"/>
<Caret Line="1117" Column="23" TopLine="1082"/>
</Position19>
<Position20>
<Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="2282" Column="46" TopLine="2250"/>
<Caret Line="1120" Column="35" TopLine="1082"/>
</Position20>
<Position21>
<Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="592" Column="3" TopLine="567"/>
<Caret Line="1123" Column="35" TopLine="1082"/>
</Position21>
<Position22>
<Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="982" TopLine="966"/>
<Caret Line="1316" Column="25" TopLine="1298"/>
</Position22>
<Position23>
<Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="1745" Column="17" TopLine="1720"/>
<Caret Line="1324" Column="23" TopLine="1298"/>
</Position23>
<Position24>
<Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="1898" Column="17" TopLine="1873"/>
<Caret Line="1358" Column="73" TopLine="1264"/>
</Position24>
<Position25>
<Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="2267" TopLine="2247"/>
<Caret Line="2187" Column="58" TopLine="2140"/>
</Position25>
<Position26>
<Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="2286" Column="17" TopLine="2247"/>
<Caret Line="2216" Column="15" TopLine="2169"/>
</Position26>
<Position27>
<Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="2270" TopLine="2246"/>
<Caret Line="2231" Column="46" TopLine="2205"/>
</Position27>
<Position28>
<Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="2273" Column="17" TopLine="2246"/>
<Filename Value="umainform.pas"/>
<Caret Line="133" TopLine="113"/>
</Position28>
<Position29>
<Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="2269" TopLine="2244"/>
<Filename Value="umainform.pas"/>
<Caret Line="19" Column="43" TopLine="7"/>
</Position29>
<Position30>
<Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="592" Column="3" TopLine="567"/>
<Filename Value="umainform.pas"/>
<Caret Line="153" TopLine="123"/>
</Position30>
</JumpHistory>
</ProjectSession>

View File

@ -1,7 +1,7 @@
object mainform: Tmainform
Left = 125
Left = 771
Height = 209
Top = 292
Top = 224
Width = 335
BorderIcons = [biSystemMenu]
Caption = 'mainform'
@ -119,8 +119,6 @@ object mainform: Tmainform
CopyTree = False
UpdatesFolder = 'updates'
VersionsININame = 'testapp.ini'
ShowUpdateInCaption = True
ShowDialogs = True
VersionCountLimit = 1000000
DownloadCountLimit = 10000000
ZipfileName = 'testapp.zip'

View File

@ -7,14 +7,20 @@ interface
uses
Classes, SysUtils, Forms, ComCtrls,
Buttons, StdCtrls,LazFileUtils,FileUtil,
ulazautoupdate,eventlog;
ulazautoupdate,eventlog,Dialogs;
CONST
{$IFDEF WINDOWS}
{$IFDEF CPU32}
{$IFDEF DEBUGMODE}
C_VERSIONSINNAME = 'testappwin32debug.ini';
C_ZIPFILENAME = 'testappwin32debug.zip';
C_LogFileName = 'testappwin32debuglog.txt';
{$ELSE}
C_VERSIONSINNAME = 'testappwin32.ini';
C_ZIPFILENAME = 'testappwin32.zip';
C_LogFileName = 'testappwin32log.txt';
{$ENDIF}
{$ENDIF}
{$IFDEF CPU64}
C_VERSIONSINNAME = 'testappwin64.ini';
C_ZIPFILENAME = 'testappwin64.zip';
@ -87,20 +93,34 @@ begin
LazAutoUpdate1.DebugMode:=TRUE;
LazAutoUpdate1.VersionsININame:=C_VERSIONSINNAME;
LazAutoUpdate1.ZipfileName:=C_ZIPFILENAME;
lbl_Version.Caption:='Version: ' + LazAutoUpdate1.AppVersion;
LazAutoUpdate1.GitHubProjectname:='lazarusccr';
LazAutoUpdate1.GitHubRepositoryName:='TestApp';
LazAutoUpdate1.GitHubBranchOrTag:='updates';
LazAutoUpdate1.ShowUpdateInCaption:=TRUE;
Caption:=Application.Title;
If Assigned(Logger) then FreeAndNil(Logger);
if FileExistsUTF8(C_LogFileName) then
DeleteFile(C_LogFileName);
Application.Processmessages;
Logger := TEventLog.Create(nil);
TRY
Logger.LogType := ltFile;
Logger.FileName := C_LogFileName;
Logger.Active := True;
Logger.Info('Start of Log');
Except
Raise Exception.Create('Trouble with the logger. Click OK to quit');
If Assigned(Logger) then FreeAndNil(Logger);
Application.Terminate;
end;
// FORCE AN UPDATE EVERY TIME HERE?
// LazAutoUpdate1.AppVersion:='0.0.0.0';
lbl_Version.Caption:='Version: ' + LazAutoUpdate1.AppVersion;
end;
procedure Tmainform.FormDestroy(Sender: TObject);
begin
Logger.Info('End of Log');
If Assigned(Logger) then Logger.Info('End of Log');
FreeAndNil(Logger);
end;
@ -116,7 +136,11 @@ end;
procedure Tmainform.cmd_updateToNewVersionClick(Sender: TObject);
begin
{$IFDEF DEBUGMODE}
ShowMessage('Please do not try updating in DEBUG mode');
{$ELSE}
LazAutoUpdate1.UpdateToNewVersion;
{$ENDIF}
end;
procedure Tmainform.FormActivate(Sender: TObject);
@ -131,7 +155,11 @@ end;
procedure Tmainform.cmd_AutoUpdateClick(Sender: TObject);
begin
{$IFDEF DEBUGMODE}
ShowMessage('Please do not try updating in DEBUG mode');
{$ELSE}
LazAutoUpdate1.AutoUpdate;
{$ENDIF}
end;
procedure Tmainform.LazAutoUpdate1DebugEvent(Sender: TObject; lauMethodName,

View File

@ -1109,6 +1109,7 @@ begin
ReturnCode := 0;
DownloadSize := 0;
fDownloadInprogress := True;
DebugMode:=fDebugMode;
if not fSilentMode then
fParentForm.Caption := C_Checking;
CheckForOpenSSL;
@ -1314,6 +1315,7 @@ begin
ReturnCode := 0;
DownloadSize := 0;
fUnzipAfter := True;
DebugMode:=fDebugMode;
if not fSilentMode then
szOldCaption := fParentForm.Caption;
if not fSilentMode then
@ -1931,7 +1933,11 @@ begin
// Running update using updatehm?
if not AppIsRunning(ExtractFileName(fAppFilename)) then
Result := DoSilentUpdate
begin
if fFireDebugEvent then
fOndebugEvent(Self, 'UpdateToNewVersion','Doing SilentUpdate');
Result := DoSilentUpdate;
end
else
begin
cCount := 0;
@ -1972,10 +1978,18 @@ begin
szParams := szParams + ' ' + fParentApplication.Title;
if (fCopyTree = True) then
szParams := szParams + ' copytree';
if fFireDebugEvent then
fOndebugEvent(Self, 'UpdateToNewVersion',
Format('Executing %s', [szAppDir + C_UPDATER]));
RunAsAdmin(fParentForm.Handle, szAppDir + C_UPDATER, szParams);
if RunAsAdmin(fParentForm.Handle, szAppDir + C_UPDATER, szParams) then
begin
if fFireDebugEvent then
fOndebugEvent(Self, 'UpdateToNewVersion','RunAsAdmin succeeded');
end
else
begin
if fFireDebugEvent then
fOndebugEvent(Self, 'UpdateToNewVersion','RunAsAdmin failed');
end;
// Check for C_WhatsNewFilename in the app directory in a LOOP
if fFireDebugEvent then