More meaningful names + small bugfix.

git-svn-id: trunk@53573 -
This commit is contained in:
balazs 2016-12-06 13:52:26 +00:00
parent 11cc148c2f
commit 748497407b
4 changed files with 77 additions and 21 deletions

View File

@ -144,8 +144,6 @@ begin
PackageDownloader := TPackageDownloader.Create(Options.RemoteRepository);
PackageDownloader.OnJSONProgress := @DoOnJSONProgress;
PackageDownloader.OnJSONDownloadCompleted := @DoOnJSONDownloadCompleted;
Updates := TUpdates.Create(LocalRepositoryUpdatesFile);
Updates.OnUpdate := @DoOnUpdate;
InstallPackageList := TObjectList.Create(True);
FHintTimeOut := Application.HintHidePause;
Application.HintHidePause := 1000000;
@ -156,8 +154,11 @@ end;
procedure TMainFrm.FormDestroy(Sender: TObject);
begin
Updates.StopUpdate;
Updates.Terminate;
if Assigned(Updates) then
begin
Updates.StopUpdate;
Updates.Terminate;
end;
PackageDownloader.Free;
SerializablePackages.Free;
VisualTree.Free;
@ -296,7 +297,12 @@ begin
MessageDlgEx(rsMainFrm_rsMessageError1 + sLineBreak + SerializablePackages.LastError, mtInformation, [mbOk], Self);
Exit;
end;
Updates.StartUpdate;
if not Assigned(Updates) then
begin
Updates := TUpdates.Create(LocalRepositoryUpdatesFile);
Updates.OnUpdate := @DoOnUpdate;
Updates.StartUpdate;
end;
VisualTree.PopulateTree;
EnableDisableControls(True);
SetupMessage;
@ -518,6 +524,12 @@ end;
procedure TMainFrm.tbRefreshClick(Sender: TObject);
begin
if Assigned(Updates) then
begin
Updates.StopUpdate;
Updates.Terminate;
Updates := nil;
end;
VisualTree.VST.Clear;
VisualTree.VST.Invalidate;
GetPackageList;

View File

@ -32,7 +32,7 @@ interface
uses
Classes, SysUtils, FileUtil, Variants, fpjson, jsonparser, md5, contnrs,
PackageIntf;
PackageIntf, Laz2_XMLCfg;
type
@ -188,7 +188,7 @@ type
FPackageBaseDir: String;
FHomePageURL: String;
FDownloadURL: String;
FForceUpdate: Boolean;
FForceNotify: Boolean;
FDownloadZipURL: String;
FSVNURL: String;
FUpdateSize: Int64;
@ -208,7 +208,7 @@ type
property IsExtractable: Boolean read GetExtractable;
property UpdateSize: Int64 read FUpdateSize write FUpdateSize;
property IsDirZipped: Boolean read FIsDirZipped write FIsDirZipped;
property ForceUpdate: Boolean read FForceUpdate write FForceUpdate;
property ForceNotify: Boolean read FForceNotify write FForceNotify;
property DownloadZipURL: String read FDownloadZipURL write FDownloadZipURL;
published
property Name: String read FName write FName;
@ -249,6 +249,7 @@ type
function IsPackageExtracted(const APackage: TPackage): Boolean;
function IsPackageInstalled(const APackageFile: TPackageFile; const APackageBaseDir: String): Boolean;
function IsAtLeastOnePackageFileInstalled(const APackage: TPackage): Boolean;
function GetRuntimePackageVersion(const APath: String): String;
public
constructor Create;
destructor Destroy; override;
@ -1026,6 +1027,42 @@ begin
end;
end;
function TSerializablePackages.GetRuntimePackageVersion(const APath: String): String;
function VersionBound(const AVersion: Integer): Integer;
begin
if AVersion > 9999 then
Result := 9999
else if AVersion < 0 then
Result := 0
else
Result := AVersion;
end;
function GetVersion(const AXMLConfig: TXMLConfig; const APath: String): String;
var
Major, Minor, Release, Build: Integer;
begin
Major := VersionBound(AXMLConfig.GetValue(APath + '/Major', 0));
Minor := VersionBound(AXMLConfig.GetValue(APath + '/Minor', 0));
Release := VersionBound(AXMLConfig.GetValue(APath + '/Release', 0));
Build := VersionBound(AXMLConfig.GetValue(APath + '/Build', 0));
Result := IntToStr(Major) + '.' + IntToStr(Minor) + '.' + IntToStr(Release) + '.' + IntToStr(Build);
end;
var
XMLConfig: TXMLConfig;
begin
Result := '-';
XMLConfig := TXMLConfig.Create(APath);
try
Result := GetVersion(XMLConfig, 'Package/Version');
finally
XMLConfig.Free;
end;
end;
function TSerializablePackages.IsPackageInstalled(const APackageFile: TPackageFile;
const APackageBaseDir: String): Boolean;
@ -1065,8 +1102,8 @@ begin
FileExists(Options.LocalRepositoryPackages + APackageBaseDir + APackageFile.PackageRelativePath + FileName);
if Result then
begin
APackageFile.InstalledFileName := Options.LocalRepositoryPackages + APackageFile.FPackageRelativePath + APackageFile.Name;
APackageFile.InstalledFileVersion := APackageFile.VersionAsString;
APackageFile.InstalledFileName := Options.LocalRepositoryPackages + APackageBaseDir + APackageFile.FPackageRelativePath + APackageFile.Name;
APackageFile.InstalledFileVersion := GetRuntimePackageVersion(APackageFile.InstalledFileName);
Result := True;
end
else

View File

@ -30,7 +30,7 @@ type
TUpdatePackageData = class(TPersistent)
private
FDownloadZipURL: String;
FForceUpdate: boolean;
FForceNotify: boolean;
FName: String;
public
constructor Create;
@ -38,7 +38,7 @@ type
procedure Clear;
published
property Name: String read FName write FName;
property ForceUpdate: boolean read FForceUpdate write FForceUpdate;
property ForceNotify: boolean read FForceNotify write FForceNotify;
property DownloadZipURL: String read FDownloadZipURL write FDownloadZipURL;
end;
@ -159,7 +159,7 @@ end;
procedure TUpdatePackageData.Clear;
begin
FName := '';
FForceUpdate := False;
FForceNotify := False;
FDownloadZipURL := '';
end;
@ -215,7 +215,7 @@ begin
Package := SerializablePackages.FindPackage(PackageName, fpbPackageName);
if Package <> nil then
begin
Package.ForceUpdate := FXML.GetValue('Items/' + Path + '/ForceUpdate', False);
Package.ForceNotify := FXML.GetValue('Items/' + Path + '/ForceNotify', False);
Package.DownloadZipURL := FXML.GetValue('Items/' + Path + '/DownloadZipURL', '');
PackageFileName := FXML.GetValue('Items/' + Path + '/PackageFileName', '');
PackageFile := Package.FindPackageFile(PackageFileName);
@ -247,13 +247,13 @@ begin
Path := 'Item' + IntToStr(Count);
PackageFile := TPackageFile(SerializablePackages.Items[I].PackageFiles.Items[J]);
FXML.SetDeleteValue('Items/' + Path + '/PackageName', Package.Name, '');
FXML.SetDeleteValue('Items/' + Path + '/ForceUpdate', Package.ForceUpdate, False);
FXML.SetDeleteValue('Items/' + Path + '/ForceNotify', Package.ForceNotify, False);
FXML.SetDeleteValue('Items/' + Path + '/DownloadZipURL', Package.DownloadZipURL, '');
FXML.SetDeleteValue('Items/' + Path + '/PackageFileName', PackageFile.Name, '');
FXML.SetDeleteValue('Items/' + Path + '/UpdateVersion', PackageFile.UpdateVersion, '');
end;
end;
FXML.SetDeleteValue('Count/Value', Count, 0);
FXML.SetDeleteValue('Count/Value', Count + 1, 0);
FXML.Flush;
end;
@ -327,8 +327,8 @@ begin
if FUpdatePackage.LoadFromJSON(JSON) then
begin
SerializablePackages.Items[I].DownloadZipURL := FUpdatePackage.FUpdatePackageData.DownloadZipURL;
SerializablePackages.Items[I].ForceUpdate := FUpdatePackage.FUpdatePackageData.ForceUpdate;
NeedToUpdate := FUpdatePackage.FUpdatePackageData.ForceUpdate = True;
SerializablePackages.Items[I].ForceNotify := FUpdatePackage.FUpdatePackageData.ForceNotify;
NeedToUpdate := FUpdatePackage.FUpdatePackageData.ForceNotify = True;
for J := 0 to FUpdatePackage.FUpdatePackageFiles.Count - 1 do
begin
PackageFile := SerializablePackages.Items[I].FindPackageFile(TUpdatePackageFiles(FUpdatePackage.FUpdatePackageFiles.Items[J]).Name);
@ -374,6 +374,7 @@ procedure TUpdates.StopUpdate;
begin
FNeedToBreak := True;
FTimer.StopTimer;
FStarted := False;
FHTTPClient.NeedToBreak := True;
Save;
end;

View File

@ -985,10 +985,10 @@ begin
if Package <> nil then
begin
Data^.DownloadZipURL := Package.DownloadZipURL;
Data^.ForceUpadate := Package.ForceUpdate;
Data^.ForceUpadate := Package.ForceNotify;
FVST.ReinitNode(Node, False);
FVST.RepaintNode(Node);
if Package.ForceUpdate then
if Package.ForceNotify then
begin
Data^.HasUpdate := True;
FVST.ReinitNode(Node, False);
@ -1390,7 +1390,13 @@ begin
Data := FVST.GetNodeData(Node);
case column of
3: begin
TargetCanvas.Font.Style := TargetCanvas.Font.Style + [fsBold];
case Data^.DataType of
1: TargetCanvas.Font.Style := TargetCanvas.Font.Style + [fsBold];
2: if Data^.UpdateVersion > Data^.InstalledVersion then
TargetCanvas.Font.Style := TargetCanvas.Font.Style + [fsBold]
else
TargetCanvas.Font.Style := TargetCanvas.Font.Style - [fsBold];
end;
if Node <> Sender.FocusedNode then
TargetCanvas.Font.Color := clBlack
else