Opkman: Extend TOPMInterface.

git-svn-id: trunk@56711 -
This commit is contained in:
balazs 2017-12-13 07:27:52 +00:00
parent 48b785c072
commit 640a82f920

View File

@ -45,6 +45,8 @@ type
FPackageDependecies: TObjectList;
FPackageLinks: TObjectList;
FWaitForIDE: TThreadTimer;
FNeedToInit: Boolean;
FBusyUpdating: Boolean;
procedure DoWaitForIDE(Sender: TObject);
procedure DoUpdatePackageLinks(Sender: TObject);
procedure InitOPM;
@ -75,6 +77,7 @@ begin
FPackageLinks := TObjectList.Create(False);
FPackagesToInstall := TObjectList.Create(False);
FPackageDependecies := TObjectList.Create(False);
FNeedToInit := True;
FWaitForIDE := TThreadTimer.Create;
FWaitForIDE.Interval := 100;
FWaitForIDE.OnTimer := @DoWaitForIDE;
@ -83,6 +86,8 @@ end;
destructor TOPMInterfaceEx.Destroy;
begin
FWaitForIDE.StopTimer;
FWaitForIDE.Terminate;
FPackageLinks.Clear;
FPackageLinks.Free;
FPackagesToInstall.Clear;
@ -99,10 +104,26 @@ end;
procedure TOPMInterfaceEx.DoWaitForIDE(Sender: TObject);
begin
if Assigned(LazarusIDE) and Assigned(PackageEditingInterface) then
begin
if FNeedToInit then
begin
InitOPM;
FNeedToInit := False;
FWaitForIDE.StopTimer;
FWaitForIDE.Terminate;
FWaitForIDE.Interval := 5000;
FWaitForIDE.StartTimer;
end
else
begin
if FPackageLinks.Count = 0 then
begin
PackageDownloader.DownloadJSON(Options.ConTimeOut*1000);
Exit;
end;
if (not FBusyUpdating) then
if (Assigned(OnPackageListAvailable)) then
OnPackageListAvailable(Self);
end;
end;
end;
@ -114,7 +135,6 @@ begin
SerializablePackages.OnUpdatePackageLinks := @DoUpdatePackageLinks;
PackageDownloader := TPackageDownloader.Create(Options.RemoteRepository[Options.ActiveRepositoryIndex]);
InstallPackageList := TObjectList.Create(True);
PackageDownloader.DownloadJSON(Options.ConTimeOut*1000);
end;
procedure TOPMInterfaceEx.DoUpdatePackageLinks(Sender: TObject);
@ -147,6 +167,10 @@ var
PackageLink: TPackageLink;
FileName, Name, URL: String;
begin
if FBusyUpdating then
Exit;
FBusyUpdating := True;
try
PkgLinks.ClearOnlineLinks;
FPackageLinks.Clear;
for I := 0 to SerializablePackages.Count - 1 do
@ -170,6 +194,9 @@ begin
end;
end;
end;
finally
FBusyUpdating := False;
end;
end;
procedure TOPMInterfaceEx.AddToInstallList(const AName, AURL: String);