|
Packit |
8f70b4 |
/*
|
|
Packit |
8f70b4 |
* lftp - file transfer program
|
|
Packit |
8f70b4 |
*
|
|
Packit |
8f70b4 |
* Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net)
|
|
Packit |
8f70b4 |
*
|
|
Packit |
8f70b4 |
* This program is free software; you can redistribute it and/or modify
|
|
Packit |
8f70b4 |
* it under the terms of the GNU General Public License as published by
|
|
Packit |
8f70b4 |
* the Free Software Foundation; either version 3 of the License, or
|
|
Packit |
8f70b4 |
* (at your option) any later version.
|
|
Packit |
8f70b4 |
*
|
|
Packit |
8f70b4 |
* This program is distributed in the hope that it will be useful,
|
|
Packit |
8f70b4 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
8f70b4 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Packit |
8f70b4 |
* GNU General Public License for more details.
|
|
Packit |
8f70b4 |
*
|
|
Packit |
8f70b4 |
* You should have received a copy of the GNU General Public License
|
|
Packit |
8f70b4 |
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
Packit |
8f70b4 |
*/
|
|
Packit |
8f70b4 |
|
|
Packit |
8f70b4 |
#ifndef PGETJOB_H
|
|
Packit |
8f70b4 |
#define PGETJOB_H
|
|
Packit |
8f70b4 |
|
|
Packit |
8f70b4 |
#include "CopyJob.h"
|
|
Packit |
8f70b4 |
|
|
Packit |
8f70b4 |
class pgetJob : public CopyJob
|
|
Packit |
8f70b4 |
{
|
|
Packit |
8f70b4 |
class ChunkXfer : public CopyJob
|
|
Packit |
8f70b4 |
{
|
|
Packit |
8f70b4 |
friend class pgetJob;
|
|
Packit |
8f70b4 |
|
|
Packit |
8f70b4 |
off_t start;
|
|
Packit |
8f70b4 |
off_t limit;
|
|
Packit |
8f70b4 |
|
|
Packit |
8f70b4 |
ChunkXfer(FileCopy *c,const char *n,off_t start,off_t limit);
|
|
Packit |
8f70b4 |
};
|
|
Packit |
8f70b4 |
|
|
Packit |
8f70b4 |
TaskRefArray<ChunkXfer> chunks;
|
|
Packit |
8f70b4 |
int max_chunks;
|
|
Packit |
8f70b4 |
off_t chunks_bytes;
|
|
Packit |
8f70b4 |
void InitChunks(off_t offset,off_t size);
|
|
Packit |
8f70b4 |
|
|
Packit |
8f70b4 |
off_t start0;
|
|
Packit |
8f70b4 |
off_t limit0;
|
|
Packit |
8f70b4 |
|
|
Packit |
8f70b4 |
off_t total_xferred;
|
|
Packit |
8f70b4 |
float total_xfer_rate;
|
|
Packit |
8f70b4 |
|
|
Packit |
8f70b4 |
bool no_parallel:1;
|
|
Packit |
8f70b4 |
bool chunks_done:1;
|
|
Packit |
8f70b4 |
bool pget_cont:1;
|
|
Packit |
8f70b4 |
|
|
Packit |
8f70b4 |
void free_chunks();
|
|
Packit |
8f70b4 |
ChunkXfer *NewChunk(const char *remote,off_t start,off_t limit);
|
|
Packit |
8f70b4 |
|
|
Packit |
8f70b4 |
long total_eta;
|
|
Packit |
8f70b4 |
|
|
Packit |
8f70b4 |
Timer status_timer;
|
|
Packit |
8f70b4 |
xstring status_file;
|
|
Packit |
8f70b4 |
void SaveStatus();
|
|
Packit |
8f70b4 |
void LoadStatus();
|
|
Packit |
8f70b4 |
void LoadStatus0();
|
|
Packit |
8f70b4 |
|
|
Packit |
8f70b4 |
protected:
|
|
Packit |
8f70b4 |
void NextFile();
|
|
Packit |
8f70b4 |
|
|
Packit |
8f70b4 |
public:
|
|
Packit |
8f70b4 |
int Do();
|
|
Packit |
8f70b4 |
void ShowRunStatus(const SMTaskRef<StatusLine>&);
|
|
Packit |
8f70b4 |
xstring& FormatStatus(xstring&,int,const char *);
|
|
Packit |
8f70b4 |
xstring& FormatJobs(xstring&,int verbose,int indent);
|
|
Packit |
8f70b4 |
|
|
Packit |
8f70b4 |
pgetJob(FileCopy *c1,const char *n,int m=0);
|
|
Packit |
8f70b4 |
~pgetJob();
|
|
Packit |
8f70b4 |
void PrepareToDie();
|
|
Packit |
8f70b4 |
|
|
Packit |
8f70b4 |
void SetMaxConn(int n) { max_chunks=n; }
|
|
Packit |
8f70b4 |
|
|
Packit |
8f70b4 |
off_t GetBytesCount() { return total_xferred; }
|
|
Packit |
8f70b4 |
double GetTransferRate() { return total_xfer_rate; }
|
|
Packit |
8f70b4 |
};
|
|
Packit |
8f70b4 |
|
|
Packit |
8f70b4 |
class pCopyJobCreator : public CopyJobCreator
|
|
Packit |
8f70b4 |
{
|
|
Packit |
8f70b4 |
public:
|
|
Packit |
8f70b4 |
int max_chunks;
|
|
Packit |
8f70b4 |
pCopyJobCreator(int n) : max_chunks(n) {}
|
|
Packit |
8f70b4 |
CopyJob *New(FileCopy *c,const char *n,const char *o) const {
|
|
Packit |
8f70b4 |
return new pgetJob(c,n,max_chunks);
|
|
Packit |
8f70b4 |
}
|
|
Packit |
8f70b4 |
};
|
|
Packit |
8f70b4 |
|
|
Packit |
8f70b4 |
#endif//PGETJOB_H
|