You've already forked lina-components
mirror of
https://bitbucket.org/Dennis07/lina-components.git
synced 2025-08-24 21:49:04 +02:00
Version 1.0 DEV 1.17c
Signed-off-by: dennis07 <den.goehlert@t-online.de>
This commit is contained in:
@@ -5,36 +5,115 @@
|
||||
//////////////////////////////////////
|
||||
|
||||
{$DEFINE LINA}
|
||||
{ Bedingte Compilerversions-Ausdr�cke }
|
||||
{$DEFINE VER_UNKNOWN}
|
||||
{$IFDEF CONDITIONALEXPRESSIONS}
|
||||
{$IF Defined(VER320)}
|
||||
{$DEFINE VER_10_2}
|
||||
{$UNDEF VER_UNKNOWN}
|
||||
{$ENDIF}
|
||||
{$IF Defined(VER310) OR (NOT Defined(VER_UNKNOWN))}
|
||||
{$DEFINE VER_10_1_UP}
|
||||
{$UNDEF VER_UNKNOWN}
|
||||
{$ENDIF}
|
||||
{$IF Defined(VER300) OR (NOT Defined(VER_UNKNOWN))}
|
||||
{$DEFINE VER_10_UP}
|
||||
{$UNDEF VER_UNKNOWN}
|
||||
{$ENDIF}
|
||||
{$IF Defined(VER290) OR (NOT Defined(VER_UNKNOWN))}
|
||||
{$DEFINE VER_XE8_UP}
|
||||
{$UNDEF VER_UNKNOWN}
|
||||
{$ENDIF}
|
||||
{$IF Defined(VER280) OR (NOT Defined(VER_UNKNOWN))}
|
||||
{$DEFINE VER_XE7_UP}
|
||||
{$UNDEF VER_UNKNOWN}
|
||||
{$ENDIF}
|
||||
{$IF Defined(VER270) OR (NOT Defined(VER_UNKNOWN))}
|
||||
{$DEFINE VER_XE6_UP}
|
||||
{$UNDEF VER_UNKNOWN}
|
||||
{$ENDIF}
|
||||
{$IF Defined(VER260) OR (NOT Defined(VER_UNKNOWN))}
|
||||
{$DEFINE VER_XE5_UP}
|
||||
{$UNDEF VER_UNKNOWN}
|
||||
{$ENDIF}
|
||||
{$IF Defined(VER250) OR (NOT Defined(VER_UNKNOWN))}
|
||||
{$DEFINE VER_XE4_UP}
|
||||
{$UNDEF VER_UNKNOWN}
|
||||
{$ENDIF}
|
||||
{$IF Defined(VER240) OR (NOT Defined(VER_UNKNOWN))}
|
||||
{$DEFINE VER_XE3_UP}
|
||||
{$UNDEF VER_UNKNOWN}
|
||||
{$ENDIF}
|
||||
{$IF Defined(VER230) OR (NOT Defined(VER_UNKNOWN))}
|
||||
{$DEFINE VER_XE2_UP}
|
||||
{$UNDEF VER_UNKNOWN}
|
||||
{$ENDIF}
|
||||
{$IF Defined(VER220) OR (NOT Defined(VER_UNKNOWN))}
|
||||
{$DEFINE VER_XE_UP}
|
||||
{$UNDEF VER_UNKNOWN}
|
||||
{$ENDIF}
|
||||
{$IF Defined(VER210) OR (NOT Defined(VER_UNKNOWN))}
|
||||
{$DEFINE VER_2010_UP}
|
||||
{$UNDEF VER_UNKNOWN}
|
||||
{$ENDIF}
|
||||
{$IF Defined(VER200) OR (NOT Defined(VER_UNKNOWN))}
|
||||
{$DEFINE VER_2009_UP}
|
||||
{$UNDEF VER_UNKNOWN}
|
||||
{$ENDIF}
|
||||
{$IF Defined(VER185) OR (NOT Defined(VER_UNKNOWN))}
|
||||
{$DEFINE VER_2007_UP}
|
||||
{$UNDEF VER_UNKNOWN}
|
||||
{$ENDIF}
|
||||
{$IF Defined(VER180) OR (NOT Defined(VER_UNKNOWN))}
|
||||
{$DEFINE VER_2006_UP}
|
||||
{$UNDEF VER_UNKNOWN}
|
||||
{$ENDIF}
|
||||
{$IF Defined(VER170) OR (NOT Defined(VER_UNKNOWN))}
|
||||
{$DEFINE VER_2005_UP}
|
||||
{$UNDEF VER_UNKNOWN}
|
||||
{$ENDIF}
|
||||
{$IF Defined(VER150) OR (NOT Defined(VER_UNKNOWN))}
|
||||
{$DEFINE VER_7_UP}
|
||||
{$UNDEF VER_UNKNOWN}
|
||||
{$ENDIF}
|
||||
{$ENDIF}
|
||||
{ Globale Einstellungen }
|
||||
{$DEFINE ADD_SPLASHENTRY}
|
||||
{$DEFINE ADD_ABOUTENTRY}
|
||||
{$DEFINE ADD_COMPONENTREG}
|
||||
{$DEFINE ADD_DEPENDENCIES}
|
||||
{$DEFINE ADD_SINGLECATEGORY}
|
||||
{$DEFINE WARN_INCOMPATIBLEPLATFORM}
|
||||
{$DEFINE WARN_INCOMPATIBLECOMPILER}
|
||||
{$DEFINE WARN_INCOMPATIBLEVERSION}
|
||||
{ Globale Einschr�nkungen }
|
||||
{$IFDEF CONDITIONALEXPRESSIONS}
|
||||
{$IF NOT Defined(VER_XE2_UP)}
|
||||
{ Unter fr�heren Delphi-Versionen als XE2 stand lediglich eine Ziel-Platform
|
||||
f�r kompilierte Anwendungen zur Verf�gung. Deshalb brauchte noch nicht auf
|
||||
Kompatibilit�t zu mehrfacher Platform-Unterst�tzung geachtet werden. }
|
||||
{$DEFINE NO_MULTIPLATFORM}
|
||||
{$IFEND}
|
||||
{$IF (NOT Defined(DCC)) AND Defined(WARN_INCOMPATIBLECOMPILER)}
|
||||
{ Nur der Delphi-Compiler wird (offiziell) unterst�tzt. }
|
||||
{$MESSAGE ERROR 'Lina Components requires Delphi'}
|
||||
{$IFEND}
|
||||
{$IF (NOT Defined(MSWINDOWS)) AND Defined(WARN_INCOMPATIBLECOMPILER)}
|
||||
{$IF (NOT Defined(NO_MULTIPLATFORM)) AND (NOT Defined(MSWINDOWS)) AND Defined(WARN_INCOMPATIBLECOMPILER)}
|
||||
{ Nur Windows wird (offiziell) als Ziel-Platform unterst�tzt. }
|
||||
{$MESSAGE ERROR 'Lina Components requires Microsoft Windows'}
|
||||
{$IFEND}
|
||||
{$IF (CompilerVersion < 15.0) AND Defined(WARN_INCOMPATIBLEVERSION)}
|
||||
{$IF Defined(VER_UNKNOWN) AND Defined(WARN_INCOMPATIBLEVERSION)}
|
||||
{ Fr�here Delphi-Versionen als Delphi 7 werden nicht (offiziell)
|
||||
unterst�tzt. }
|
||||
{$MESSAGE ERROR 'Lina Components requires Delphi 7 or higher'}
|
||||
{$IFEND}
|
||||
{$IF CompilerVersion < 17.0}
|
||||
{$IF NOT Defined(VER_2005_UP)}
|
||||
{ Unter fr�heren Delphi-Versionen als 2005 gab es noch nicht die
|
||||
M�glichkeit, Records mit methoden zu versehen. Die Implementierung von
|
||||
Prozeduren und/oder Funktionen war Klassen vorenthalten. }
|
||||
{$DEFINE NO_RECORDMETHODS}
|
||||
{$IFEND}
|
||||
{$IF CompilerVersion < 18.5}
|
||||
{$IF NOT Defined(VER_2007_UP)}
|
||||
{ Unter fr�heren Delphi-Versionen als 2007 gab es (offiziell) noch keine
|
||||
Unterst�tzung f�r Windows-Vista-spezifische funktionen wie die TaskDialog-
|
||||
Komponente oder einige Funktionen.
|
||||
@@ -42,7 +121,7 @@
|
||||
dieser Direktive ein. }
|
||||
{$DEFINE NO_VISTA}
|
||||
{$IFEND}
|
||||
{$IF CompilerVersion < 20.0}
|
||||
{$IF NOT Defined(VER_2009_UP)}
|
||||
{ Unter fr�heren Delphi-Versionen als 2009 war die Nutzung generischer
|
||||
Datentypen (Generics) nicht m�glich. Da es ohne diese nahezu unm�glich
|
||||
scheint, typisierte Objekte, wie zum Beispiel typisierte TObjectList's
|
||||
@@ -58,8 +137,14 @@
|
||||
Zu beachten ist jedoch, dass Delphi 2009 und h�her AnsiStrings implizit
|
||||
in UnicodeStrings umwandelt und umgekehrt (sofern m�glich). }
|
||||
{$DEFINE NO_UNICODE}
|
||||
{ Unter fr�heren Delphi-Versionen als 2009 standen Namensr�ume noch nicht
|
||||
zur verf�gung. Daher sind Unitnamen wie zB. "System.Win.Registry" nicht
|
||||
verf�gbar. Allerdings m�ssen diese trotzdem in nicht-GUI-Anwendungen
|
||||
verwendet werden, da dort keine Unit-Aliase f�r VCL/FMX voreingestellt
|
||||
sind. }
|
||||
{$DEFINE NO_NAMESPACE}
|
||||
{$IFEND}
|
||||
{$IF CompilerVersion < 21.0}
|
||||
{$IF NOT Defined(VER_2010_UP)}
|
||||
{ Unter fr�heren Delphi-Versionen als 2010 gab es ein Problem mit dem
|
||||
"crHandPoint" cursor, sodass dieser nicht korrekt unter Windows Vista oder
|
||||
h�her dargestellt wurde, sondern stattdessen im alten Windows-Look.
|
||||
@@ -67,10 +152,4 @@
|
||||
Komponente zur Behebung dieses Problems zur Verf�gung. }
|
||||
{$DEFINE NO_HANDPOINT}
|
||||
{$IFEND}
|
||||
{$IF CompilerVersion < 23.0}
|
||||
{ Unter fr�heren Delphi-Versionen als XE2 stand lediglich eine Ziel-Platform
|
||||
f�r kompilierte Anwendungen zur Verf�gung. Deshalb brauchte noch nicht auf
|
||||
Kompatibilit�t zu mehrfacher Platform-Unterst�tzung geachtet werden. }
|
||||
{$DEFINE NO_MULTIPLATFORM}
|
||||
{$IFEND}
|
||||
{$ENDIF}
|
||||
|
@@ -815,7 +815,7 @@ begin
|
||||
begin
|
||||
OnOpenTargetQuery(Self,CanOpen);
|
||||
end;
|
||||
if CanOpen then
|
||||
if CanOpen then
|
||||
begin
|
||||
ExecuteFile(Target);
|
||||
if StoreVisited then
|
||||
|
@@ -28,7 +28,7 @@ type
|
||||
{ Hilfsklassen }
|
||||
TSplashScreenMode = (ssmDefault,ssmModal);
|
||||
TSplashScreenAnimation = (ssaNone,ssaShallow);
|
||||
TProgressBarManagerMode = (pmmNone,pmmBattery,pmmDownload);
|
||||
TProgressBarManagerMode = (pmmNone,pmmBattery{$IFDEF ADD_DEPENDENCIES},pmmDownload{$ENDIF});
|
||||
TListBoxManagerMode = (lmmNone,lmmEdit,lmmComboBox);
|
||||
TDiagramLayout = (dloColumns,dloPoints,dloStraightLines,dloCurvedLines,dloCustom);
|
||||
TDiagramGridLines = (dglHorizontal,dglVertical,dglBoth);
|
||||
@@ -321,12 +321,16 @@ type
|
||||
{ Private-Deklarationen }
|
||||
FTarget: TProgressBar;
|
||||
FSourceBattery: TBattery;
|
||||
FSourceDownload: TDownload;
|
||||
{$IFDEF ADD_DEPENDENCIES}
|
||||
FSourceDownload: TDownload;
|
||||
{$ENDIF}
|
||||
FMode: TProgressBarManagerMode;
|
||||
{ Methoden }
|
||||
procedure SetTarget(Value: TProgressBar);
|
||||
procedure SetSourceBattery(Value: TBattery);
|
||||
procedure SetSourceDownload(Value: TDownload);
|
||||
{$IFDEF ADD_DEPENDENCIES}
|
||||
procedure SetSourceDownload(Value: TDownload);
|
||||
{$ENDIF}
|
||||
procedure SetMode(Value: TProgressBarManagerMode);
|
||||
public
|
||||
{ Public-Deklarationen }
|
||||
@@ -337,7 +341,9 @@ type
|
||||
{ Published-Deklarationen }
|
||||
property Target: TProgressBar read FTarget write SetTarget;
|
||||
property SourceBattery: TBattery read FSourceBattery write SetSourceBattery;
|
||||
property SourceDownload: TDownload read FSourceDownload write SetSourceDownload;
|
||||
{$IFDEF ADD_DEPENDENCIES}
|
||||
property SourceDownload: TDownload read FSourceDownload write SetSourceDownload;
|
||||
{$ENDIF}
|
||||
property Mode: TProgressBarManagerMode read FMode write SetMode default pmmNone;
|
||||
end;
|
||||
|
||||
@@ -1885,7 +1891,7 @@ begin
|
||||
if Mode <> pmmNone then
|
||||
begin
|
||||
if (Mode = pmmBattery) and (not Assigned(SourceBattery))
|
||||
or (Mode = pmmDownload) and (not Assigned(SourceDownload)) then
|
||||
{$IFDEF ADD_DEPENDENCIES}or (Mode = pmmDownload) and (not Assigned(SourceDownload)){$ENDIF} then
|
||||
begin
|
||||
Exit;
|
||||
end;
|
||||
@@ -1894,10 +1900,12 @@ begin
|
||||
begin
|
||||
Target.Position := (Target.Max div 100) * SourceBattery.GetBatteryPercent;
|
||||
end;
|
||||
if Mode = pmmDownload then
|
||||
begin
|
||||
Target.Position := (Target.Max div 100) * SourceDownload.GetProgressPercent;
|
||||
end;
|
||||
{$IFDEF ADD_DEPENDENCIES}
|
||||
if Mode = pmmDownload then
|
||||
begin
|
||||
Target.Position := (Target.Max div 100) * SourceDownload.GetProgressPercent;
|
||||
end;
|
||||
{$ENDIF}
|
||||
inherited;
|
||||
end;
|
||||
|
||||
@@ -1916,14 +1924,16 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TProgressBarManager.SetSourceDownload(Value: TDownload);
|
||||
begin
|
||||
FSourceDownload := Value;
|
||||
if Mode = pmmDownload then
|
||||
{$IFDEF ADD_DEPENDENCIES}
|
||||
procedure TProgressBarManager.SetSourceDownload(Value: TDownload);
|
||||
begin
|
||||
Update;
|
||||
FSourceDownload := Value;
|
||||
if Mode = pmmDownload then
|
||||
begin
|
||||
Update;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
{$ENDIF}
|
||||
|
||||
procedure TProgressBarManager.SetMode(Value: TProgressBarManagerMode);
|
||||
begin
|
||||
|
@@ -14,13 +14,17 @@ uses
|
||||
{ Standard-Units }
|
||||
SysUtils, Classes, UITypes,
|
||||
{ Indy-Units }
|
||||
idHTTP, idSSLOpenSSL, idComponent,
|
||||
{$IFDEF ADD_DEPENDENCIES}
|
||||
idHTTP, idSSLOpenSSL, idComponent,
|
||||
{$ENDIF}
|
||||
{ Andere Package-Units }
|
||||
uBase, uSysTools;
|
||||
|
||||
type
|
||||
{ Fehlermeldungen }
|
||||
EInvalidWebAddress = class(Exception);
|
||||
{$IFDEF ADD_DEPENDENCIES}
|
||||
EInvalidWebAddress = class(Exception);
|
||||
{$ENDIF}
|
||||
EInvalidTagChar = class(Exception);
|
||||
EHtmlParse = class(Exception);
|
||||
ECssParse = class(Exception);
|
||||
@@ -29,9 +33,11 @@ type
|
||||
TCssDocumentRuleKind = (cssNone,cssTag,cssClass,cssID);
|
||||
|
||||
{ Ereignisse }
|
||||
TDownloadWorkEvent = procedure(Sender: TObject; AWorkMode: TWorkMode) of object;
|
||||
TDownloadWorkBeginEvent = procedure(Sender: TObject; AWorkMode: TWorkMode) of object;
|
||||
TDownloadWorkEndEvent = procedure(Sender: TObject; AWorkMode: TWorkMode) of object;
|
||||
{$IFDEF ADD_DEPENDENCIES}
|
||||
TDownloadWorkEvent = procedure(Sender: TObject; AWorkMode: TWorkMode) of object;
|
||||
TDownloadWorkBeginEvent = procedure(Sender: TObject; AWorkMode: TWorkMode) of object;
|
||||
TDownloadWorkEndEvent = procedure(Sender: TObject; AWorkMode: TWorkMode) of object;
|
||||
{$ENDIF}
|
||||
THtmlDocumentTag = class;
|
||||
THtmlDocumentTagAddEvent = procedure(Sender: TObject; Tag: THtmlDocumentTag) of object;
|
||||
THtmlDocumentParseEvent = procedure(Sender: TObject) of object;
|
||||
@@ -39,54 +45,56 @@ type
|
||||
THtmlDocumentParseFailEvent = procedure(Sender: TObject) of object;
|
||||
|
||||
{ Hauptklassen }
|
||||
{$IFNDEF NO_MULTIPLATFORM}
|
||||
[ComponentPlatformsAttribute(pidWin32 or pidWin64)]
|
||||
{$IFDEF ADD_DEPENDENCIES}
|
||||
{$IFNDEF NO_MULTIPLATFORM}
|
||||
[ComponentPlatformsAttribute(pidWin32 or pidWin64)]
|
||||
{$ENDIF}
|
||||
TDownload = class(TComponent)
|
||||
private
|
||||
{ Private-Deklarationen }
|
||||
idHTTPObject: TidHTTP;
|
||||
SSLHandler: TIdSSLIOHandlerSocketOpenSSL;
|
||||
FAbout: TComponentAbout;
|
||||
FAddress: String;
|
||||
FProgress: Int64;
|
||||
FProgressMax: Int64;
|
||||
FSSL: Boolean;
|
||||
{ Ereignisse }
|
||||
FWorkEvent: TDownloadWorkEvent;
|
||||
FWorkBeginEvent: TDownloadWorkBeginEvent;
|
||||
FWorkEndEvent: TDownloadWorkEndEvent;
|
||||
{ Methoden }
|
||||
procedure SetAddress(Value: String);
|
||||
procedure idHTTPObjectWork(ASender: TObject; AWorkMode: TWorkMode; AWorkCount: Int64);
|
||||
procedure idHTTPObjectWorkBegin(ASender: TObject; AWorkMode: TWorkMode; AWorkCountMax: Int64);
|
||||
procedure idHTTPObjectWorkEnd(ASender: TObject; AWorkMode: TWorkMode);
|
||||
protected
|
||||
{ Protected-Deklarationen }
|
||||
procedure Prepare;
|
||||
public
|
||||
{ Public-Deklarationen }
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
destructor Destroy; override;
|
||||
{ Fortschritt }
|
||||
function GetProgress: Int64;
|
||||
function GetProgressMax: Int64;
|
||||
function GetProgressPercent: Byte;
|
||||
{ Herunterladen }
|
||||
function GetText: String;
|
||||
procedure SaveToFile(const FileName: TFileName);
|
||||
procedure SaveToStream(var Stream: TStream);
|
||||
published
|
||||
{ Published-Deklarationen }
|
||||
{ Ereignisse }
|
||||
property OnWork: TDownloadWorkEvent read FWorkEvent write FWorkEvent;
|
||||
property OnWorkBegin: TDownloadWorkBeginEvent read FWorkBeginEvent write FWorkBeginEvent;
|
||||
property OnWorkEnd: TDownloadWorkEndEvent read FWorkEndEvent write FWorkEndEvent;
|
||||
{ Eigenschaften }
|
||||
property About: TComponentAbout read FAbout;
|
||||
property Address: String read FAddress write SetAddress;
|
||||
property SSL: Boolean read FSSL write FSSL default False;
|
||||
end;
|
||||
{$ENDIF}
|
||||
TDownload = class(TComponent)
|
||||
private
|
||||
{ Private-Deklarationen }
|
||||
idHTTPObject: TidHTTP;
|
||||
SSLHandler: TIdSSLIOHandlerSocketOpenSSL;
|
||||
FAbout: TComponentAbout;
|
||||
FAddress: String;
|
||||
FProgress: Int64;
|
||||
FProgressMax: Int64;
|
||||
FSSL: Boolean;
|
||||
{ Ereignisse }
|
||||
FWorkEvent: TDownloadWorkEvent;
|
||||
FWorkBeginEvent: TDownloadWorkBeginEvent;
|
||||
FWorkEndEvent: TDownloadWorkEndEvent;
|
||||
{ Methoden }
|
||||
procedure SetAddress(Value: String);
|
||||
procedure idHTTPObjectWork(ASender: TObject; AWorkMode: TWorkMode; AWorkCount: Int64);
|
||||
procedure idHTTPObjectWorkBegin(ASender: TObject; AWorkMode: TWorkMode; AWorkCountMax: Int64);
|
||||
procedure idHTTPObjectWorkEnd(ASender: TObject; AWorkMode: TWorkMode);
|
||||
protected
|
||||
{ Protected-Deklarationen }
|
||||
procedure Prepare;
|
||||
public
|
||||
{ Public-Deklarationen }
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
destructor Destroy; override;
|
||||
{ Fortschritt }
|
||||
function GetProgress: Int64;
|
||||
function GetProgressMax: Int64;
|
||||
function GetProgressPercent: Byte;
|
||||
{ Herunterladen }
|
||||
function GetText: String;
|
||||
procedure SaveToFile(const FileName: TFileName);
|
||||
procedure SaveToStream(var Stream: TStream);
|
||||
published
|
||||
{ Published-Deklarationen }
|
||||
{ Ereignisse }
|
||||
property OnWork: TDownloadWorkEvent read FWorkEvent write FWorkEvent;
|
||||
property OnWorkBegin: TDownloadWorkBeginEvent read FWorkBeginEvent write FWorkBeginEvent;
|
||||
property OnWorkEnd: TDownloadWorkEndEvent read FWorkEndEvent write FWorkEndEvent;
|
||||
{ Eigenschaften }
|
||||
property About: TComponentAbout read FAbout;
|
||||
property Address: String read FAddress write SetAddress;
|
||||
property SSL: Boolean read FSSL write FSSL default False;
|
||||
end;
|
||||
|
||||
THtmlDocumentTagParam = record
|
||||
Name: String;
|
||||
@@ -312,7 +320,7 @@ implementation
|
||||
{$IFDEF ADD_COMPONENTREG}
|
||||
procedure Register;
|
||||
begin
|
||||
RegisterComponents(ComponentsPage,[TDownload]);
|
||||
RegisterComponents(ComponentsPage,[{$IFDEF ADD_DEPENDENCIES}TDownload{$ENDIF}]);
|
||||
end;
|
||||
{$ENDIF}
|
||||
|
||||
@@ -437,7 +445,7 @@ begin
|
||||
Ignore := True;
|
||||
Equal := False;
|
||||
Block := '';
|
||||
Current := @S[1];
|
||||
Current := PChar(S);
|
||||
while True do
|
||||
begin
|
||||
if InTag then
|
||||
@@ -583,121 +591,123 @@ end;
|
||||
TDownload
|
||||
---------------------------------------------------------------------------- }
|
||||
|
||||
constructor TDownload.Create(AOwner: TComponent);
|
||||
begin
|
||||
inherited;
|
||||
FAbout := TComponentAbout.Create(TDownload);
|
||||
idHTTPObject := TidHTTP.Create(Self);
|
||||
idHTTPObject.HandleRedirects := True;
|
||||
idHTTPObject.OnWork := idHTTPObjectWork;
|
||||
idHTTPObject.OnWorkBegin := idHTTPObjectWorkBegin;
|
||||
idHTTPObject.OnWorkEnd := idHTTPObjectWorkEnd;
|
||||
SSLHandler := TIdSSLIOHandlerSocketOpenSSL.Create(Self);
|
||||
SSL := False;
|
||||
end;
|
||||
|
||||
destructor TDownload.Destroy;
|
||||
begin
|
||||
FAbout.Free;
|
||||
inherited;
|
||||
end;
|
||||
|
||||
procedure TDownload.SetAddress(Value: String);
|
||||
begin
|
||||
if StrIsURL(Value) or (Length(Value) = 0) then
|
||||
{$IFDEF ADD_DEPENDENCIES}
|
||||
constructor TDownload.Create(AOwner: TComponent);
|
||||
begin
|
||||
FAddress := Value;
|
||||
end else
|
||||
begin
|
||||
raise EInvalidWebAddress.Create('"' + Value + '" is not a valid URL address');
|
||||
inherited;
|
||||
FAbout := TComponentAbout.Create(TDownload);
|
||||
idHTTPObject := TidHTTP.Create(Self);
|
||||
idHTTPObject.HandleRedirects := True;
|
||||
idHTTPObject.OnWork := idHTTPObjectWork;
|
||||
idHTTPObject.OnWorkBegin := idHTTPObjectWorkBegin;
|
||||
idHTTPObject.OnWorkEnd := idHTTPObjectWorkEnd;
|
||||
SSLHandler := TIdSSLIOHandlerSocketOpenSSL.Create(Self);
|
||||
SSL := False;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TDownload.idHTTPObjectWork(ASender: TObject; AWorkMode: TWorkMode; AWorkCount: Int64);
|
||||
begin
|
||||
FProgress := AWorkCount;
|
||||
if Assigned(OnWork) then
|
||||
destructor TDownload.Destroy;
|
||||
begin
|
||||
OnWork(Self,AWorkMode);
|
||||
FAbout.Free;
|
||||
inherited;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TDownload.idHTTPObjectWorkBegin(ASender: TObject; AWorkMode: TWorkMode; AWorkCountMax: Int64);
|
||||
begin
|
||||
FProgressMax := AWorkCountMax;
|
||||
if Assigned(OnWorkBegin) then
|
||||
procedure TDownload.SetAddress(Value: String);
|
||||
begin
|
||||
OnWorkBegin(Self,AWorkMode);
|
||||
if StrIsURL(Value) or (Length(Value) = 0) then
|
||||
begin
|
||||
FAddress := Value;
|
||||
end else
|
||||
begin
|
||||
raise EInvalidWebAddress.Create('"' + Value + '" is not a valid URL address');
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TDownload.idHTTPObjectWorkEnd(ASender: TObject; AWorkMode: TWorkMode);
|
||||
begin
|
||||
if Assigned(OnWorkEnd) then
|
||||
procedure TDownload.idHTTPObjectWork(ASender: TObject; AWorkMode: TWorkMode; AWorkCount: Int64);
|
||||
begin
|
||||
OnWorkEnd(Self,AWorkMode);
|
||||
FProgress := AWorkCount;
|
||||
if Assigned(OnWork) then
|
||||
begin
|
||||
OnWork(Self,AWorkMode);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TDownload.GetProgress: Int64;
|
||||
begin
|
||||
Result := FProgress;
|
||||
end;
|
||||
|
||||
function TDownload.GetProgressMax: Int64;
|
||||
begin
|
||||
Result := FProgressMax;
|
||||
end;
|
||||
|
||||
function TDownload.GetProgressPercent: Byte;
|
||||
begin
|
||||
if FProgressMax > 0 then
|
||||
procedure TDownload.idHTTPObjectWorkBegin(ASender: TObject; AWorkMode: TWorkMode; AWorkCountMax: Int64);
|
||||
begin
|
||||
Result := (FProgress div FProgressMax) * 100;
|
||||
end else
|
||||
begin
|
||||
{ Bei aktivierter SSL-Verschl�sselung wird keine insgesamte Dateigr��e
|
||||
�bermittelt. Deshalb wird hier eine 0 angegeben, um das Ergebnis nicht
|
||||
undefiniert zu lassen. }
|
||||
Result := 0;
|
||||
FProgressMax := AWorkCountMax;
|
||||
if Assigned(OnWorkBegin) then
|
||||
begin
|
||||
OnWorkBegin(Self,AWorkMode);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TDownload.GetText: String;
|
||||
begin
|
||||
Prepare;
|
||||
Result := idHTTPObject.Get(Address);
|
||||
end;
|
||||
|
||||
procedure TDownload.SaveToFile(const FileName: TFileName);
|
||||
var
|
||||
FS: TFileStream;
|
||||
begin
|
||||
Prepare;
|
||||
FS := TFileStream.Create(FileName,fmCreate or fmShareDenyWrite);
|
||||
try
|
||||
idHTTPObject.Get(Address,FS);
|
||||
finally
|
||||
FS.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TDownload.SaveToStream(var Stream: TStream);
|
||||
begin
|
||||
Prepare;
|
||||
idHTTPObject.Get(Address,Stream);
|
||||
end;
|
||||
|
||||
procedure TDownload.Prepare;
|
||||
begin
|
||||
if SSL then
|
||||
procedure TDownload.idHTTPObjectWorkEnd(ASender: TObject; AWorkMode: TWorkMode);
|
||||
begin
|
||||
idHTTPObject.IOHandler := SSLHandler;
|
||||
end else
|
||||
begin
|
||||
idHTTPObject := nil;
|
||||
if Assigned(OnWorkEnd) then
|
||||
begin
|
||||
OnWorkEnd(Self,AWorkMode);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TDownload.GetProgress: Int64;
|
||||
begin
|
||||
Result := FProgress;
|
||||
end;
|
||||
|
||||
function TDownload.GetProgressMax: Int64;
|
||||
begin
|
||||
Result := FProgressMax;
|
||||
end;
|
||||
|
||||
function TDownload.GetProgressPercent: Byte;
|
||||
begin
|
||||
if FProgressMax > 0 then
|
||||
begin
|
||||
Result := (FProgress div FProgressMax) * 100;
|
||||
end else
|
||||
begin
|
||||
{ Bei aktivierter SSL-Verschl�sselung wird keine insgesamte Dateigr��e
|
||||
�bermittelt. Deshalb wird hier eine 0 angegeben, um das Ergebnis nicht
|
||||
undefiniert zu lassen. }
|
||||
Result := 0;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TDownload.GetText: String;
|
||||
begin
|
||||
Prepare;
|
||||
Result := idHTTPObject.Get(Address);
|
||||
end;
|
||||
|
||||
procedure TDownload.SaveToFile(const FileName: TFileName);
|
||||
var
|
||||
FS: TFileStream;
|
||||
begin
|
||||
Prepare;
|
||||
FS := TFileStream.Create(FileName,fmCreate or fmShareDenyWrite);
|
||||
try
|
||||
idHTTPObject.Get(Address,FS);
|
||||
finally
|
||||
FS.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TDownload.SaveToStream(var Stream: TStream);
|
||||
begin
|
||||
Prepare;
|
||||
idHTTPObject.Get(Address,Stream);
|
||||
end;
|
||||
|
||||
procedure TDownload.Prepare;
|
||||
begin
|
||||
if SSL then
|
||||
begin
|
||||
idHTTPObject.IOHandler := SSLHandler;
|
||||
end else
|
||||
begin
|
||||
idHTTPObject := nil;
|
||||
end;
|
||||
end;
|
||||
{$ENDIF}
|
||||
|
||||
{ ----------------------------------------------------------------------------
|
||||
THtmlDocumentTag
|
||||
|
Reference in New Issue
Block a user