Fixed: What's New list
This commit is contained in:
parent
f5535247fa
commit
bbe4c1822a
@ -13,6 +13,7 @@ interface
|
|||||||
uses
|
uses
|
||||||
Classes,
|
Classes,
|
||||||
|
|
||||||
|
IdHTTP,
|
||||||
IdHTTPHeaderInfo,
|
IdHTTPHeaderInfo,
|
||||||
XMLIntf;
|
XMLIntf;
|
||||||
|
|
||||||
@ -21,17 +22,20 @@ type
|
|||||||
|
|
||||||
TX2InetVersionInfo = class(TCollectionItem)
|
TX2InetVersionInfo = class(TCollectionItem)
|
||||||
private
|
private
|
||||||
|
FBuild: Integer;
|
||||||
FMajor: Integer;
|
FMajor: Integer;
|
||||||
FMinor: Integer;
|
FMinor: Integer;
|
||||||
FRelease: Integer;
|
|
||||||
FBuild: Integer;
|
|
||||||
FNewer: Boolean;
|
FNewer: Boolean;
|
||||||
|
FRelease: Integer;
|
||||||
FVersionType: TX2InetVersionType;
|
FVersionType: TX2InetVersionType;
|
||||||
FVersionTypeString: String;
|
FVersionTypeString: String;
|
||||||
FWhatsNewTemp: String;
|
FWhatsNew: TStrings;
|
||||||
protected
|
protected
|
||||||
procedure LoadFromNode(const ANode: IXMLNode);
|
procedure LoadFromNode(const ANode: IXMLNode);
|
||||||
public
|
public
|
||||||
|
constructor Create(Collection: TCollection); override;
|
||||||
|
destructor Destroy(); override;
|
||||||
|
|
||||||
property VersionType: TX2InetVersionType read FVersionType;
|
property VersionType: TX2InetVersionType read FVersionType;
|
||||||
property VersionTypeString: String read FVersionTypeString;
|
property VersionTypeString: String read FVersionTypeString;
|
||||||
property Major: Integer read FMajor;
|
property Major: Integer read FMajor;
|
||||||
@ -39,7 +43,7 @@ type
|
|||||||
property Release: Integer read FRelease;
|
property Release: Integer read FRelease;
|
||||||
property Build: Integer read FBuild;
|
property Build: Integer read FBuild;
|
||||||
property Newer: Boolean read FNewer;
|
property Newer: Boolean read FNewer;
|
||||||
property WhatsNewTemp: String read FWhatsNewTemp;
|
property WhatsNew: TStrings read FWhatsNew;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
TX2InetVersions = class(TCollection)
|
TX2InetVersions = class(TCollection)
|
||||||
@ -60,6 +64,7 @@ type
|
|||||||
FAppID: String;
|
FAppID: String;
|
||||||
FURL: String;
|
FURL: String;
|
||||||
FProxyParams: TIdProxyConnectionInfo;
|
FProxyParams: TIdProxyConnectionInfo;
|
||||||
|
FHTTP: TIdHTTP;
|
||||||
|
|
||||||
FApplicationURL: String;
|
FApplicationURL: String;
|
||||||
FVersions: TX2InetVersions;
|
FVersions: TX2InetVersions;
|
||||||
@ -69,6 +74,9 @@ type
|
|||||||
constructor Create();
|
constructor Create();
|
||||||
destructor Destroy(); override;
|
destructor Destroy(); override;
|
||||||
|
|
||||||
|
procedure Terminate();
|
||||||
|
|
||||||
|
|
||||||
property AppID: String read FAppID write FAppID;
|
property AppID: String read FAppID write FAppID;
|
||||||
property URL: String read FURL write FURL;
|
property URL: String read FURL write FURL;
|
||||||
property ProxyParams: TIdProxyConnectionInfo read FProxyParams;
|
property ProxyParams: TIdProxyConnectionInfo read FProxyParams;
|
||||||
@ -84,11 +92,25 @@ uses
|
|||||||
XMLDoc,
|
XMLDoc,
|
||||||
|
|
||||||
IdURI,
|
IdURI,
|
||||||
IdHTTP,
|
|
||||||
X2UtApp;
|
X2UtApp;
|
||||||
|
|
||||||
|
|
||||||
{ TX2InetVersionInfo }
|
{ TX2InetVersionInfo }
|
||||||
|
constructor TX2InetVersionInfo.Create(Collection: TCollection);
|
||||||
|
begin
|
||||||
|
inherited;
|
||||||
|
|
||||||
|
FWhatsNew := TStringList.Create();
|
||||||
|
end;
|
||||||
|
|
||||||
|
destructor TX2InetVersionInfo.Destroy();
|
||||||
|
begin
|
||||||
|
FreeAndNil(FWhatsNew);
|
||||||
|
|
||||||
|
inherited;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure TX2InetVersionInfo.LoadFromNode(const ANode: IXMLNode);
|
procedure TX2InetVersionInfo.LoadFromNode(const ANode: IXMLNode);
|
||||||
function GetVersion(const AName: String): Integer;
|
function GetVersion(const AName: String): Integer;
|
||||||
var
|
var
|
||||||
@ -127,7 +149,6 @@ begin
|
|||||||
((FMajor = Major) and (FMinor = Minor) and (FRelease > Release)) or
|
((FMajor = Major) and (FMinor = Minor) and (FRelease > Release)) or
|
||||||
((FMajor = Major) and (FMinor = Minor) and (FRelease = Release) and (FBuild > Build));
|
((FMajor = Major) and (FMinor = Minor) and (FRelease = Release) and (FBuild > Build));
|
||||||
|
|
||||||
FWhatsNewTemp := '';
|
|
||||||
xmlWhatsNew := ANode.ChildNodes.FindNode('whatsnew');
|
xmlWhatsNew := ANode.ChildNodes.FindNode('whatsnew');
|
||||||
if Assigned(xmlWhatsNew) then
|
if Assigned(xmlWhatsNew) then
|
||||||
begin
|
begin
|
||||||
@ -135,9 +156,7 @@ begin
|
|||||||
while Assigned(xmlItem) do
|
while Assigned(xmlItem) do
|
||||||
begin
|
begin
|
||||||
if xmlItem.NodeName = 'item' then
|
if xmlItem.NodeName = 'item' then
|
||||||
begin
|
FWhatsNew.Add(xmlItem.Text);
|
||||||
FWhatsNewTemp := FWhatsNewTemp + '- ' + xmlItem.Text + #13#10;
|
|
||||||
end;
|
|
||||||
|
|
||||||
xmlItem := xmlItem.NextSibling();
|
xmlItem := xmlItem.NextSibling();
|
||||||
end;
|
end;
|
||||||
@ -189,7 +208,6 @@ end;
|
|||||||
|
|
||||||
procedure TX2InetVersion.Execute();
|
procedure TX2InetVersion.Execute();
|
||||||
var
|
var
|
||||||
idHTTP: TIdHTTP;
|
|
||||||
memData: TMemoryStream;
|
memData: TMemoryStream;
|
||||||
xmlDoc: IXMLDocument;
|
xmlDoc: IXMLDocument;
|
||||||
xmlRoot: IXMLNode;
|
xmlRoot: IXMLNode;
|
||||||
@ -199,19 +217,25 @@ var
|
|||||||
begin
|
begin
|
||||||
CoInitialize(nil);
|
CoInitialize(nil);
|
||||||
|
|
||||||
idHTTP := TIdHTTP.Create(nil);
|
FHTTP := TIdHTTP.Create(nil);
|
||||||
try
|
try
|
||||||
idHTTP.ProxyParams.Assign(FProxyParams);
|
FHTTP.ProxyParams.Assign(FProxyParams);
|
||||||
memData := TMemoryStream.Create();
|
memData := TMemoryStream.Create();
|
||||||
try
|
try
|
||||||
idHTTP.Get(Format('%s?appid=%s', [FURL, TIdURI.ParamsEncode(FAppID)]), memData);
|
FHTTP.Get(Format('%s?appid=%s', [FURL, TIdURI.ParamsEncode(FAppID)]), memData);
|
||||||
memData.Seek(0, soFromBeginning);
|
memData.Seek(0, soFromBeginning);
|
||||||
|
|
||||||
|
if Terminated then
|
||||||
|
exit;
|
||||||
|
|
||||||
xmlDoc := TXMLDocument.Create(nil);
|
xmlDoc := TXMLDocument.Create(nil);
|
||||||
try
|
try
|
||||||
xmlDoc.LoadFromStream(memData);
|
xmlDoc.LoadFromStream(memData);
|
||||||
xmlRoot := xmlDoc.DocumentElement;
|
xmlRoot := xmlDoc.DocumentElement;
|
||||||
|
|
||||||
|
if Terminated then
|
||||||
|
exit;
|
||||||
|
|
||||||
if xmlRoot.NodeName <> 'application' then
|
if xmlRoot.NodeName <> 'application' then
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
@ -234,9 +258,18 @@ begin
|
|||||||
FreeAndNil(memData);
|
FreeAndNil(memData);
|
||||||
end;
|
end;
|
||||||
finally
|
finally
|
||||||
FreeAndNil(idHTTP);
|
FreeAndNil(FHTTP);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure TX2InetVersion.Terminate();
|
||||||
|
begin
|
||||||
|
inherited Terminate();
|
||||||
|
|
||||||
|
if Assigned(FHTTP) then
|
||||||
|
FHTTP.Disconnect();
|
||||||
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user