Componentes.Terceros.RemObj.../official/5.0.35.741/RemObjects SDK for Delphi/Source/IDE/uROProductVersionInfo.pas
2009-02-27 15:16:56 +00:00

160 lines
3.6 KiB
ObjectPascal

unit uROProductVersionInfo;
{$IFNDEF MSWINDOWS}
{$I ../RemObjects.inc}
{$ELSE}
{$I ..\RemObjects.inc}
{$ENDIF}
{$DEFINE Use_WinInet}
{$DEFINE Use_Indy}
{$DEFINE Use_Synapse}
interface
procedure GetVersionInfos(const iTargetUrl:string='');
procedure RegisterProduct(const iProductID:string; iBuildNo:integer=-1);
procedure UnregisterProduct(const iProductID:string);
implementation
{$IFNDEF FPC}
{$IFDEF MSWINDOWS}
// delphi + CBuilder - use always WinInet
{$DEFINE Use_WinInet}
{$ELSE}
// linux
{$UNDEF Use_WinInet}
{$ENDIF}
{$ENDIF}
{$IFDEF FPC}
{$IFDEF FPC_no_WinINet}
{$UNDEF Use_WinInet}
{$ENDIF}
{$ENDIF}
{$IFDEF Use_WinInet}
{$UNDEF Use_Indy}
{$UNDEF Use_Synapse}
{$ELSE}
{$IFDEF Use_Synapse}
{$UNDEF Use_Indy}
{$ELSE}
{$DEFINE Use_Indy}
{$ENDIF}
{$ENDIF}
uses
uROPleaseWaitForm, uROProductVersionInfo_Intf, uROBinMessage,
{$IFDEF Use_WinInet}uROWinInetHttpChannel,{$ENDIF}
{$IFDEF Use_Synapse}uROSynapseHTTPChannel,{$ENDIF}
{$IFDEF Use_Indy}uROIndyHTTPChannel,{$ENDIF}
Classes, SysUtils, Forms, uRoProductVersionInfoForm,
Dialogs;
var
gProducts:TStringList;
type
{$IFDEF Use_WinInet}
TMyChannel = TROWinInetHTTPChannel;
{$ENDIF}
{$IFDEF Use_Synapse}
TMyChannel = TROSynapseHTTPChannel;
{$ENDIF}
{$IFDEF Use_Indy}
TMyChannel = TROIndyHTTPChannel;
{$ENDIF}
procedure GetVersionInfos(const iTargetUrl:string='');
var
lProducts:TProductInfoRequestArray;
lInfo:TProductInfoArray;
i:integer;
lMessage:TROBINMessage;
lChannel:TMyChannel;
begin
lProducts := TProductInfoRequestArray.Create();
try
for i := 0 to gProducts.Count-1 do begin
with lProducts.Add do begin
ProductID := gProducts[i];
CurrentBuild := integer(gProducts.Objects[i]);
end;
end;
lMessage := TROBinMessage.Create(nil);
lChannel := TMyChannel.Create(nil);
lChannel.TargetURL := iTargetUrl;
if lChannel.TargetURL = '' then
lChannel.TargetURL := 'http://www.remobjects.com/isapi/roversioninfo.dll/bin';
//lChannel.TargetURL := 'http://localhost:8099/bin';
try
with TPleaseWaitForm.Create(Application,'Checking for new product versions...','RemObjects Software') do try
Show();
with CoIProductVersionInfo.Create(lMessage,lChannel) do begin
lInfo := GetProductVersions(lProducts);
end;
try
Hide();
if Assigned(lInfo) and (lInfo.Count > 0) then begin
with TProductVersionInfoForm.Create(Application) do try
LoadFromInfo(lInfo);
ShowModal();
finally
Free();
end;
end
else begin
ShowMessage('You are running the latest versions of all installed products.');
end;
finally
FreeAndNil(lInfo);
end;
finally
Free();
end;
finally
FreeAndNil(lMessage);
FreeAndNil(lChannel);
end;
finally
lProducts.Free();
end;
end;
procedure RegisterProduct(const iProductID:string; iBuildNo:integer=-1);
begin
gProducts.AddObject(iProductID,pointer(iBuildNo));
end;
procedure UnregisterProduct(const iProductID:string);
var
lIndex:integer;
begin
lIndex := gProducts.IndexOf(iProductID);
if lIndex <> -1 then gProducts.Delete(lIndex);
end;
initialization
gProducts := TStringList.Create();
gProducts.Sorted := true;
gProducts.Duplicates := dupIgnore;
finalization
FreeAndNil(gProducts);
end.