Skip to content

Commit

Permalink
Upd
Browse files Browse the repository at this point in the history
  • Loading branch information
HemulGM committed Feb 29, 2024
1 parent 3fbac74 commit bb7996b
Show file tree
Hide file tree
Showing 9 changed files with 2,027 additions and 2,436 deletions.
63 changes: 23 additions & 40 deletions HGI.GetItAPI.pas
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ interface
TGetIt = class
class var
Url, Version: string;
class function Get(out Items: TPackages; const Category, Order: Integer; const Search: string = ''; const Count: Integer = 0; const Offset: Integer = 0): Boolean;
class function Get(out Items: TPackages; const Category, Order: Integer; const Personalities: string; const Search: string = ''; const Count: Integer = 0; const Offset: Integer = 0): Boolean;
class function ParseDate(const Value: string): string; static;
end;

Expand All @@ -19,6 +19,7 @@ TIDEEntity = record
Personalities: string;
ServiceUrl: string;
RegPath: string;
IsCustom: Boolean;
Elements: TArray<string>;
function GetPathBin: string;
function GetPathGetItCmd: string;
Expand All @@ -42,10 +43,8 @@ implementation

class function TGetIt.ParseDate(const Value: string): string;
begin
var
FormatDate: TFormatSettings;
var
Date: TDateTime;
var FormatDate: TFormatSettings;
var Date: TDateTime;
FormatDate.DateSeparator := '-';
FormatDate.ShortDateFormat := 'YYYY-MM-DD';
if (not Value.IsEmpty) and TryStrToDateTime(Value, Date, FormatDate) then
Expand All @@ -54,18 +53,16 @@ class function TGetIt.ParseDate(const Value: string): string;
Result := 'Unkonwn';
end;

class function TGetIt.Get(out Items: TPackages; const Category, Order: Integer; const Search: string; const Count, Offset: Integer): Boolean;
class function TGetIt.Get(out Items: TPackages; const Category, Order: Integer; const Personalities: string; const Search: string; const Count, Offset: Integer): Boolean;
var
HTTP: THTTPClient;
begin
Result := False;
Items := nil;
HTTP := THTTPClient.Create;
try
var
Body := TMultipartFormData.Create;
var
Response := TStringStream.Create('', TEncoding.UTF8);
var Body := TMultipartFormData.Create;
var Response := TStringStream.Create('', TEncoding.UTF8);
try
if Category > 0 then
Body.AddField('Categories', Category.ToString);
Expand All @@ -74,12 +71,12 @@ class function TGetIt.Get(out Items: TPackages; const Category, Order: Integer;
if Offset > 0 then
Body.AddField('Start', Offset.ToString);
if Count > 0 then
Body.AddField('End', (Offset + Count).ToString);
Body.AddField('End', Count.ToString);
Body.AddField('Order', Order.ToString);
Body.AddField('Language', '0');
Body.AddField('CatalogVersion', '5');
Body.AddField('Personalities', '1'); // delphi
Body.AddField('Identity', 'DELPHI');
Body.AddField('Personalities', Personalities); // delphi 1
//Body.AddField('Identity', 'C++'); //DELPHI
Body.AddField('Version', Version);
// Body.AddField('BuildNumber', '28.0.47991.2819');

Expand All @@ -88,8 +85,7 @@ class function TGetIt.Get(out Items: TPackages; const Category, Order: Integer;
// https://getit-olympus.embarcadero.com
if HTTP.Post(Url + '/catalog/info', Body, Response).StatusCode = 200 then
begin
Items := TJson.JsonToObject<TPackages>
('{ "items": ' + Response.DataString + '}');
Items := TJson.JsonToObject<TPackages>('{ "items": ' + Response.DataString + '}');
Result := True;
end;
finally
Expand Down Expand Up @@ -163,14 +159,12 @@ class function TIDEList.List: TArray<TIDEEntity>;
Exit;
Entity.Personalities := Reg.ReadString('');
Reg.CloseKey;
if not Reg.OpenKeyReadOnly('Software\Embarcadero\BDS\' + Section +
'\CatalogRepository') then
if not Reg.OpenKeyReadOnly('Software\Embarcadero\BDS\' + Section + '\CatalogRepository') then
Exit;
Entity.ServiceUrl := Reg.ReadString('ServiceUrl');
if Reg.OpenKeyReadOnly('Elements') then
begin
var
Elements := TStringList.Create;
var Elements := TStringList.Create;
try
Reg.GetKeyNames(Elements);
Entity.Elements := Elements.ToStringArray;
Expand All @@ -186,18 +180,15 @@ class function TIDEList.List: TArray<TIDEEntity>;

begin
Result := [];
var
Reg := TRegistry.Create(KEY_QUERY_VALUE);
var Reg := TRegistry.Create(KEY_QUERY_VALUE);
try
Reg.RootKey := HKEY_CURRENT_USER;
if not Reg.OpenKeyReadOnly('Software\Embarcadero\BDS') then
Exit;
var
Sections := TStringList.Create;
var Sections := TStringList.Create;
try
Reg.GetKeyNames(Sections);
var
Entity: TIDEEntity;
var Entity: TIDEEntity;
for var Section in Sections do
if ReadSection(Reg, Section, Entity) then
begin
Expand Down Expand Up @@ -264,11 +255,9 @@ procedure TIDEEntity.LoadInstalled(out Items: TPackages; const Search: string);
Item.VendorUrl := Reg.ReadString('VendorUrl');
Item.Version := Reg.ReadString('Version');
Item.LibUrl := Reg.ReadString('Url');
var
List := TStringList.Create;
var List := TStringList.Create;
try
var
Tmp := Reg.ReadString('OSes');
var Tmp := Reg.ReadString('OSes');
List.Delimiter := ';';
List.DelimitedText := Tmp;
var LibOSes: TArray<TLibOS>;
Expand All @@ -292,17 +281,15 @@ procedure TIDEEntity.LoadInstalled(out Items: TPackages; const Search: string);
Tmp := Reg.ReadString('Platforms');
List.Delimiter := ';';
List.DelimitedText := Tmp;
var
Platforms: TArray<TLibPlatform>;
var Platforms: TArray<TLibPlatform>;
try
for var SItem in List do
begin
var
Arr := SItem.Split(['=']);
if Length(Arr) > 1 then
begin
var
LibPlatform := TLibPlatform.Create;
var LibPlatform := TLibPlatform.Create;
LibPlatform.Id := Arr[0];
LibPlatform.Name := Arr[1];
SetLength(Platforms, Length(Platforms) + 1);
Expand All @@ -326,22 +313,18 @@ procedure TIDEEntity.LoadInstalled(out Items: TPackages; const Search: string);
Reg := TRegistry.Create(KEY_QUERY_VALUE);
try
Reg.RootKey := HKEY_CURRENT_USER;
var
RegRoot := RegPath + '\CatalogRepository\Elements';
var RegRoot := RegPath + '\CatalogRepository\Elements';
if not Reg.OpenKeyReadOnly(RegRoot) then
Exit;
var
List := TStringList.Create;
var List := TStringList.Create;
try
Reg.GetKeyNames(List);
for var Key in List do
begin
Reg.CloseKey;
if Reg.OpenKeyReadOnly(RegRoot + '\' + Key) then
begin
var
Item: TGetItPackage;
Item := TGetItPackage.Create;
var Item := TGetItPackage.Create;
if not ReadItem(Item) then
begin
Item.Free;
Expand Down
Loading

0 comments on commit bb7996b

Please sign in to comment.