To V0.3.4

Added OnUpdate event

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5707 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
gbamber
2017-01-26 16:53:05 +00:00
parent c088f351cf
commit f1a4e8043a
11 changed files with 132 additions and 58 deletions

View File

@ -32,7 +32,7 @@
A component for SourceForge and GitHub Project Developers and end-users to update their apps easily.
Drop onto a form, set a few properties and call the Method 'AutoUpdate' - as easy as pie!
Fully configurable.
Included in the source tree is Update Pack - an app that makes update maintenance simple and efficient. Also TrayUpdater - a systray app that scedules updates automatically.
Included in the source tree is Update Pack - an app that makes update maintenance simple and efficient. Also TrayUpdater - a systray app that schedules updates automatically.
Compiles and runs in Windows and Linux.
More information in the Wiki Home Page http://wiki.freepascal.org/LazAutoUpdater"/>
<License Value=" Modified GPL
@ -62,7 +62,7 @@ More information in the Wiki Home Page http://wiki.freepascal.org/LazAutoUpdater
along with this library; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
"/>
<Version Minor="3" Release="2"/>
<Version Minor="3" Release="3"/>
<Files Count="6">
<Item1>
<Filename Value="ulazautoupdate.pas"/>

View File

@ -22,8 +22,7 @@
</i18n>
<VersionInfo>
<UseVersionInfo Value="True"/>
<MinorVersionNr Value="1"/>
<RevisionNr Value="14"/>
<MinorVersionNr Value="2"/>
<StringTable CompanyName="minesadorada" FileDescription="Tray app that works with LazAutoUpdate apps" InternalName="lazautoupdater" LegalCopyright="LGPLv2" LegalTrademarks="(c)2014 Gordon Bamber" OriginalFilename="trayupdater" ProductName="Lazarus 1.x FPC 2.6.x" ProductVersion="0.1.11.2"/>
</VersionInfo>
<BuildModes Count="5">

View File

@ -8,10 +8,11 @@
<Unit0>
<Filename Value="trayupdater.lpr"/>
<IsPartOfProject Value="True"/>
<IsVisibleTab Value="True"/>
<EditorIndex Value="2"/>
<WindowIndex Value="1"/>
<TopLine Value="21"/>
<CursorPos X="54" Y="44"/>
<CursorPos X="101" Y="44"/>
<UsageCount Value="183"/>
<Loaded Value="True"/>
</Unit0>
@ -43,7 +44,6 @@
<ComponentName Value="configform"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<IsVisibleTab Value="True"/>
<EditorIndex Value="3"/>
<WindowIndex Value="1"/>
<TopLine Value="203"/>
@ -262,123 +262,123 @@
<JumpHistory Count="30" HistoryIndex="29">
<Position1>
<Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="852" Column="20" TopLine="814"/>
<Caret Line="932" Column="16" TopLine="894"/>
</Position1>
<Position2>
<Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="932" Column="16" TopLine="894"/>
<Caret Line="1120" Column="18" TopLine="1083"/>
</Position2>
<Position3>
<Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="1120" Column="18" TopLine="1083"/>
<Caret Line="1327" Column="18" TopLine="1290"/>
</Position3>
<Position4>
<Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="1327" Column="18" TopLine="1290"/>
<Caret Line="1460" Column="16" TopLine="1422"/>
</Position4>
<Position5>
<Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="1460" Column="16" TopLine="1422"/>
<Caret Line="1528" Column="16" TopLine="1490"/>
</Position5>
<Position6>
<Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="1528" Column="16" TopLine="1490"/>
<Caret Line="1572" Column="20" TopLine="1535"/>
</Position6>
<Position7>
<Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="1572" Column="20" TopLine="1535"/>
<Caret Line="1611" Column="20" TopLine="1573"/>
</Position7>
<Position8>
<Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="1611" Column="20" TopLine="1573"/>
<Caret Line="1696" Column="16" TopLine="1659"/>
</Position8>
<Position9>
<Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="1696" Column="16" TopLine="1659"/>
<Caret Line="1729" Column="20" TopLine="1692"/>
</Position9>
<Position10>
<Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="1729" Column="20" TopLine="1692"/>
<Caret Line="1820" Column="22" TopLine="1783"/>
</Position10>
<Position11>
<Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="1820" Column="22" TopLine="1783"/>
<Caret Line="1857" Column="25" TopLine="1820"/>
</Position11>
<Position12>
<Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="1857" Column="25" TopLine="1820"/>
<Caret Line="1892" Column="27" TopLine="1855"/>
</Position12>
<Position13>
<Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="1892" Column="27" TopLine="1855"/>
<Caret Line="1976" Column="22" TopLine="1939"/>
</Position13>
<Position14>
<Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="1976" Column="22" TopLine="1939"/>
<Caret Line="2030" Column="25" TopLine="1993"/>
</Position14>
<Position15>
<Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="2030" Column="25" TopLine="1993"/>
<Caret Line="2071" Column="27" TopLine="2034"/>
</Position15>
<Position16>
<Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="2071" Column="27" TopLine="2034"/>
<Filename Value="umainform.pas"/>
<Caret Line="407" Column="36" TopLine="386"/>
</Position16>
<Position17>
<Filename Value="umainform.pas"/>
<Caret Line="407" Column="36" TopLine="386"/>
<Caret Line="496" Column="46" TopLine="468"/>
</Position17>
<Position18>
<Filename Value="umainform.pas"/>
<Caret Line="496" Column="46" TopLine="468"/>
<Caret Line="497" Column="37" TopLine="468"/>
</Position18>
<Position19>
<Filename Value="umainform.pas"/>
<Caret Line="497" Column="37" TopLine="468"/>
<Caret Line="502" Column="46" TopLine="468"/>
</Position19>
<Position20>
<Filename Value="umainform.pas"/>
<Caret Line="502" Column="46" TopLine="468"/>
<Caret Line="73" Column="12" TopLine="50"/>
</Position20>
<Position21>
<Filename Value="umainform.pas"/>
<Caret Line="73" Column="12" TopLine="50"/>
<Caret Line="563" Column="9" TopLine="540"/>
</Position21>
<Position22>
<Filename Value="umainform.pas"/>
<Caret Line="563" Column="9" TopLine="540"/>
<Caret Line="572" Column="15" TopLine="540"/>
</Position22>
<Position23>
<Filename Value="umainform.pas"/>
<Caret Line="572" Column="15" TopLine="540"/>
<Caret Line="735" Column="27" TopLine="715"/>
</Position23>
<Position24>
<Filename Value="umainform.pas"/>
<Caret Line="735" Column="27" TopLine="715"/>
<Caret Line="77" Column="73" TopLine="50"/>
</Position24>
<Position25>
<Filename Value="umainform.pas"/>
<Caret Line="77" Column="73" TopLine="50"/>
<Caret Line="746" Column="26" TopLine="715"/>
</Position25>
<Position26>
<Filename Value="umainform.pas"/>
<Caret Line="746" Column="26" TopLine="715"/>
</Position26>
<Position27>
<Filename Value="trayupdater.lpr"/>
<Caret Line="36" Column="30" TopLine="21"/>
</Position27>
<Position28>
</Position26>
<Position27>
<Filename Value="umainform.pas"/>
<Caret Line="743" Column="48" TopLine="719"/>
</Position28>
<Position29>
</Position27>
<Position28>
<Filename Value="trayupdater.lpr"/>
<Caret Line="10" Column="19" TopLine="3"/>
</Position28>
<Position29>
<Filename Value="uconfigform.pas"/>
<Caret Line="11" Column="33"/>
</Position29>
<Position30>
<Filename Value="uconfigform.pas"/>
<Caret Line="11" Column="33"/>
<Caret Line="212" Column="3" TopLine="203"/>
</Position30>
</JumpHistory>
</ProjectSession>

View File

@ -138,9 +138,10 @@ const
V0.2.9: Added CreateLocalLauImportFile in UpdateToNewVersion
V0.3.1: Added SetExecutePermission (LINUX only)
V0.3.2: Bugfix for DoSilentUpdate
V0.3.3: ??
V0.3.3: Added event OnUpdate
V0.3.4: ??
}
C_TLazAutoUpdateComponentVersion = '0.3.2';
C_TLazAutoUpdateComponentVersion = '0.3.3';
C_TThreadedDownloadComponentVersion = '0.0.3';
{
V0.0.1: Initial alpha
@ -253,9 +254,9 @@ type
OnlineVersion: string) of object;
TOnDownloaded = procedure(Sender: TObject; ResultCode, BytesDownloaded: integer) of
object;
// ToDo: TOnUpdated??
TOnDebugEvent = procedure(Sender: TObject; lauMethodName, lauMessage: string) of
object;
TOnUpdated = Procedure(Sender:TObject;NewVersion,LauMessage:String) of Object;
TLazAutoUpdate = class(TAboutLazAutoUpdate)
private
@ -293,6 +294,7 @@ type
FOnNewVersionAvailable: TOnNewVersionAvailable;
FOnDownloaded: TOnDownloaded;
fOnDebugEvent: TOnDebugEvent;
fOnUpdated:TOnUpdated;
fLastError: string;
fVersionCountLimit, fDownloadCountLimit: cardinal;
fZipfileName: string;
@ -317,6 +319,8 @@ type
function GetThreadDownloadReturnCode: integer;
function IsOnlineVersionNewer(const sznewINIPath: string): boolean;
function DoSilentUpdate: boolean;
function GetUpdateSilentExe:String;
function GetUpdateExe:String;
protected
public
@ -394,6 +398,7 @@ type
read FOnNewVersionAvailable write FOnNewVersionAvailable;
property OnDownloaded: TOnDownloaded read fOnDownloaded write fOnDownloaded;
property OnDebugEvent: TOnDebugEvent read fOnDebugEvent write fOnDebugEvent;
property OnUpdated:TOnUpdated read fOnUpdated write fOnUpdated;
// Embedded class
property ThreadDownload: TThreadedDownload
@ -432,9 +437,9 @@ type
// Default is application filename.zip
property ZipfileName: string read fZipfileName write fZipfileName;
// Name of Console app
property UpdateExe: string read fUpdateExe;
property UpdateExe: string read GetUpdateExe;
// Name of Console app
property UpdateExeSilent: string read fUpdateSilentExe;
property UpdateExeSilent: string read GetUpdateSilentExe;
// Main project name/UserName
property GitHubProjectname: string read fGitHubProjectName write fGitHubProjectName;
// Name of your GitHub repository within the project/username
@ -726,9 +731,8 @@ begin
fZipfileName := ''; // assign later
// BE SURE TO CHANGE THE CONSTANTS IF YOU CHANGE THE UPDATE EXE NAME
fUpdateExe := C_UPDATEHMNAME;
fUpdateSilentExe := C_LAUUPDATENAME;
GetUpdateSilentExe;
GetUpdateExe;
// Assorted versioninfo properties
fLCLVersion := GetLCLVersion;
@ -771,6 +775,23 @@ begin
FreeAndNil(fThreadDownload);
inherited Destroy;
end;
function TLazAutoUpdate.GetUpdateSilentExe:String;
begin
fUpdateSilentExe := C_LAUUPDATENAME;
If csDesigning in ComponentState then
Result:='lauupdate'
else
Result:=fUpdateSilentExe;
end;
function TLazAutoUpdate.GetUpdateExe:String;
begin
fUpdateExe := C_UPDATEHMNAME;
If csDesigning in ComponentState then
Result:='updatehm'
else
Result:=fUpdateExe;
end;
function TLazAutoUpdate.AppIsActive(const ExeName: string): boolean;
begin
@ -844,6 +865,7 @@ begin
C_WhatsNewFilename);
Exit;
end;
// Create the form, memo and close button
if fParentForm <> nil then
WhatsNewForm := TForm.CreateNew(fParentForm)
@ -2116,14 +2138,32 @@ begin
begin
fParentApplication.ProcessMessages;
Inc(CCount);
if cCount > 10000000 then
if cCount > 100000 then
begin
// Fire the OnUpdated event
If Assigned(fOnUpdated) then
begin
fOnUpdated(Self,fGUIOnlineVersion,'Unsuccessful update');
Application.Processmessages;
Sleep(100);
end;
Break; // Get out of jail in case updatehm.exe fails to copy file
end;
end;
finally
FUpdateHMProcess.Free;
end;
{$ENDIF}
CreateLocalLauImportFile; // Creates a new import file in GetAppConfigDirUTF8
// Fire the OnUpdated event
If Assigned(fOnUpdated) then
begin
fOnUpdated(Self,fGUIOnlineVersion,'Successful update');
Application.Processmessages;
Sleep(100);
end;
if fFireDebugEvent then
fOndebugEvent(Self, 'UpdateToNewVersion',
'Success');

View File

@ -1,7 +1,7 @@
object mainform: Tmainform
Left = 1335
Left = 375
Height = 481
Top = 384
Top = 127
Width = 587
AllowDropFiles = True
BorderIcons = [biSystemMenu, biMinimize]
@ -706,7 +706,10 @@ object mainform: Tmainform
About.AuthorEmail = 'minesadorada@gmail.com'
About.ComponentName = 'Laz Auto-update v0.1.1'
About.LicenseType = abLGPL
OnNewVersionAvailable = LazAutoUpdate1NewVersionAvailable
OnDownloaded = LazAutoUpdate1Downloaded
OnDebugEvent = LazAutoUpdate1DebugEvent
OnUpdated = LazAutoUpdate1Updated
SFProjectName = 'lazautoupdate'
UpdatesFolder = 'updates'
VersionsININame = 'updatepack.ini'

View File

@ -182,6 +182,12 @@ type
procedure FormShow(Sender: TObject);
procedure grp_dragfilesDblClick(Sender: TObject);
procedure LazAutoUpdate1DebugEvent(Sender: TObject; WhereAt, Message: string);
procedure LazAutoUpdate1Downloaded(Sender: TObject; ResultCode,
BytesDownloaded: integer);
procedure LazAutoUpdate1NewVersionAvailable(Sender: TObject;
Newer: boolean; OnlineVersion: string);
procedure LazAutoUpdate1Updated(Sender: TObject; NewVersion,
LauMessage: String);
procedure lst_dragfilesDblClick(Sender: TObject);
procedure mnuoptionsDisplayFileMangerClick(Sender: TObject);
procedure mnuoptionsShowCodeInfoClick(Sender: TObject);
@ -419,27 +425,30 @@ begin
cmb_profile.Clear;
cmb_profile.Items := ProfileNameList;
cmb_profile.ItemIndex := cmb_profile.Items.IndexOf(szCurrentProfileName);
{
if LazAutoUpdate1.CreateLocalLauImportFile then
LazAutoUpdate1.RelocateLauImportFile;
}
if bIsVirgin then
PageControl1.ActivePage := tab_intro
else
PageControl1.ActivePage := tab_configure;
if DebugMode then
BEGIN
EventLog1.FileName := ChangeFileExt(ParamStr(0), '.log');
if DebugMode then
if FileExistsUTF8(EventLog1.FileName) then
SysUtils.DeleteFile(EventLog1.FileName);
if DebugMode then
EventLog1.AppendContent := True;
if DebugMode then
EventLog1.Active := True;
LazAutoUpdate1.DebugMode := DebugMode;
LazAutoUpdate1.DebugMode := DebugMode;
end;
end;
procedure Tmainform.FormDestroy(Sender: TObject);
begin
// No memory leaks!
If Assigned(EventLog1) then FreeAndNil(EventLog1);
FreeAndNil(ProfileConfig);
FreeAndNil(AppConfig);
FreeAndNil(ProfilenameList);
@ -494,6 +503,29 @@ begin
EventLog1.Log(Format('LazAutoUpdate: Source=%s, Message=%s', [WhereAt, Message]));
end;
procedure Tmainform.LazAutoUpdate1Downloaded(Sender: TObject; ResultCode,
BytesDownloaded: integer);
begin
if DebugMode and (EventLog1.Active = True) then
EventLog1.Log(Format('LazAutoUpdate: OnDownloaded ResultCode=%d BytesDownloaded=%d',
[ResultCode, BytesDownloaded]));
end;
procedure Tmainform.LazAutoUpdate1NewVersionAvailable(Sender: TObject;
Newer: boolean; OnlineVersion: string);
begin
if DebugMode and (EventLog1.Active = True) then
EventLog1.Log(Format('LazAutoUpdate: NewVersionAvailable OnlineVersion=%s',
[OnlineVersion]));
end;
procedure Tmainform.LazAutoUpdate1Updated(Sender: TObject; NewVersion,
LauMessage: String);
begin
if DebugMode and (EventLog1.Active = True) then
EventLog1.Log(Format('LazAutoUpdate: New Version=%s, Message=%s', [NewVersion, LauMessage]));
end;
procedure Tmainform.lst_dragfilesDblClick(Sender: TObject);
var
i: integer;

View File

@ -23,7 +23,7 @@
<UseVersionInfo Value="True"/>
<MajorVersionNr Value="1"/>
<MinorVersionNr Value="2"/>
<RevisionNr Value="4"/>
<RevisionNr Value="6"/>
<StringTable Comments="Updated Jan 2017" FileDescription="Companion to LazAutoUpdate component" InternalName="updatepack" LegalCopyright="(c)2015 minesadorada@charcodelvalle.com" OriginalFilename="updatepack" ProductName="Lazarus/FPC" ProductVersion="2.6.4"/>
</VersionInfo>
<BuildModes Count="5">

View File

@ -9,7 +9,7 @@
"ForceNotify" : false,
"InternalVersion" : 1,
"Name" : "lazupdate.lpk",
"Version" : "0.3.2.0"
"Version" : "0.3.3.0"
}
]
}