Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Internet (https://www.clubdelphi.com/foros/forumdisplay.php?f=3)
-   -   componente MultiFileDownloader multithread para bajar http y ftp en indy 10 (https://www.clubdelphi.com/foros/showthread.php?t=65842)

softx2009 16-01-2010 17:22:52

componente MultiFileDownloader multithread para bajar http y ftp en indy 10
 
este es un componente que encontre en internet tenias unos errores que corregi pero ahora me funciona lo unico que el componente no se comunica
diciendome cuando termina la descarga ni cuantos bytes esta bajando si alguien me puede dar una mano se lo agradesco

Código:

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ComCtrls, Buttons, IndyDownloads, ExtCtrls;


 

type
  TForm1 = class(TForm)
    URL: TEdit;
    Redirections: TUpDown;
    Edit2: TEdit;
    Edit3: TEdit;
    Debit: TUpDown;
    Edit4: TEdit;
    Tentatives: TUpDown;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    StatusBar1: TStatusBar;
    Demarrer: TBitBtn;
    ProgressBar1: TProgressBar;                 
    Fichier: TEdit;
    Label1: TLabel;
    Button1: TButton;
    SaveDialog1: TSaveDialog;
    Arreter: TBitBtn;
    Retenter: TBitBtn;
    Pause: TBitBtn;
    Label6: TLabel;
    Timer1: TTimer;

    procedure DemarrerClick(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure IndyDownloads1Succeeded(Sender: TComponent;
      IndyDownloadableFile: TIndyDownloadableFile);
    procedure IndyDownloads1Failed(Sender: TComponent;
      IndyDownloadableFile: TIndyDownloadableFile);
    procedure IndyDownloads1Work(Sender: TComponent;
      IndyDownloadableFile: TIndyDownloadableFile);
    procedure IndyDownloads1Suspended(Sender: TComponent;
      IndyDownloadableFile: TIndyDownloadableFile);
    procedure ArreterClick(Sender: TObject);
    procedure RetenterClick(Sender: TObject);
    procedure PauseClick(Sender: TObject);
    procedure IndyDownloads1Redirect(Sender: TComponent;
      IndyDownloadableFile: TIndyDownloadableFile);

  private
    { Déclarations privées }
  public
     
    { Déclarations publiques }
  end;

var
  Form1: TForm1;
  IndyDownloads1: TIndyDownloads;
implementation

{$R *.dfm}



procedure TForm1.Button1Click(Sender: TObject);
begin if SaveDialog1.Execute then Fichier.Text:=SaveDialog1.FileName; end;

procedure TForm1.DemarrerClick(Sender: TObject);
begin
  if IndyDownloads1 = nil then
    IndyDownloads1:=TIndyDownloads.Create(self);
    IndyDownloads1.DownloadableFileList.Clear;
    ProgressBar1.Position:=0;
    StatusBar1.SimpleText:='En curso...';
    Demarrer.Enabled:=false; Arreter.Enabled:=true; Retenter.Enabled:=false; Pause.Enabled:=true;

    // Cada descarga (treahd) debe estar asociada con un identificador único para garantizar la coherencia con el hilo principal
    IndyDownloads1.DownloadableFileList.Add(TIndyDownloadableFile.Create(URL.Text, Fichier.Text, IndyDownloads1.GetNextUniqueID, Debit.Position, Tentatives.Position, Redirections.Position));
    // Ponemos en marcha la descarga

    TIndyDownloadableFile(IndyDownloads1.DownloadableFileList[0]).Start;

end;



procedure TForm1.IndyDownloads1Succeeded(Sender: TComponent; IndyDownloadableFile: TIndyDownloadableFile);
begin
    StatusBar1.SimpleText:='Termino';
    Demarrer.Enabled:=true; Arreter.Enabled:=false; Retenter.Enabled:=false; Pause.Enabled:=false;
end;

procedure TForm1.IndyDownloads1Failed(Sender: TComponent; IndyDownloadableFile: TIndyDownloadableFile);
begin
    StatusBar1.SimpleText:='Error';
    Demarrer.Enabled:=true; Arreter.Enabled:=true; Retenter.Enabled:=true; Pause.Enabled:=false;
end;

procedure TForm1.IndyDownloads1Work(Sender: TComponent; IndyDownloadableFile: TIndyDownloadableFile);
begin
    ProgressBar1.Max:= TIndyDownloadableFile(IndyDownloads1.DownloadableFileList[0]).TotalFileSize;
    ProgressBar1.Position:=TIndyDownloadableFile(IndyDownloads1.DownloadableFileList[0]).BytesDownloaded;
end;

procedure TForm1.IndyDownloads1Suspended(Sender: TComponent; IndyDownloadableFile: TIndyDownloadableFile);
begin
    Demarrer.Enabled:=true; Pause.Enabled:=false;
    if IndyDownloadableFile.State=si_Paused then
    begin
          StatusBar1.SimpleText:='Suspendido';
          Arreter.Enabled:=true; Retenter.Enabled:=true;
    end
    else
    begin
          StatusBar1.SimpleText:='Parado';
          Arreter.Enabled:=false; Retenter.Enabled:=false;
    end;
end;

procedure TForm1.ArreterClick(Sender: TObject);
begin
    if Assigned(IndyDownloads1.DownloadableFileList[0]) and
      (TIndyDownloadableFile(IndyDownloads1.DownloadableFileList[0]).State in [si_Downloading, si_Failed]) then
        TIndyDownloadableFile(IndyDownloads1.DownloadableFileList[0]).Stop;
    Demarrer.Enabled:=true; Arreter.Enabled:=false; Retenter.Enabled:=false; Pause.Enabled:=false;
    ProgressBar1.Position:=0; StatusBar1.SimpleText:='';
end;

procedure TForm1.RetenterClick(Sender: TObject);
begin
    if Assigned(IndyDownloads1.DownloadableFileList[0]) and
      (TIndyDownloadableFile(IndyDownloads1.DownloadableFileList[0]).State in [si_Paused, si_Failed]) then
    begin
          TIndyDownloadableFile(IndyDownloads1.DownloadableFileList[0]).Resume;
          StatusBar1.SimpleText:='En curso...';
    end;
    Demarrer.Enabled:=false; Arreter.Enabled:=true; Retenter.Enabled:=false; Pause.Enabled:=true;
end;

procedure TForm1.PauseClick(Sender: TObject);
begin
    if Assigned(IndyDownloads1.DownloadableFileList[0]) and
      (TIndyDownloadableFile(IndyDownloads1.DownloadableFileList[0]).State=si_Downloading) then
        TIndyDownloadableFile(IndyDownloads1.DownloadableFileList[0]).Pause;
    Demarrer.Enabled:=false; Arreter.Enabled:=true; Retenter.Enabled:=false; Pause.Enabled:=false;
end;

procedure TForm1.IndyDownloads1Redirect(Sender: TComponent; IndyDownloadableFile: TIndyDownloadableFile);
begin
StatusBar1.SimpleText:='Redirection : '+IndyDownloadableFile.URL;


end;



end.


Neftali [Germán.Estévez] 18-01-2010 10:03:06

1 Archivos Adjunto(s)
En estos casos creo que es más sencillo que crees un ZIP con el proyecto de ejemplo y lo subas como adjunto. Si todavía no tienes permisos o es demasiado grande envíamelo por privado o por correo que yo mismo lo subo.

Otra opción es utilizar algun servidor gratuíto tipo RapidShare/Megaupload o el propio FTP del Club.

He borrado los dos mensajes largos y aquí está el proyecto.

softx2009 18-01-2010 16:08:23

Tenes razon no se me habia ocurrido el subirlo a algun servidor gratuito
esta probado con indy 10
aca esta en dos servidores yo uso delphi 7 y indy 10
megaupload.com/?d=10EEBVKH
rapidshare.com/files/337244512/indydownloads.rar.html

le falta http ya que no tengo permiso para poner enlaces

Neftali [Germán.Estévez] 18-01-2010 16:17:47

Y ya está también en el FTP del Club.


La franja horaria es GMT +2. Ahora son las 00:00:23.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi