blob: 87502d24d6cc6149d9dc9c3b8a4fbe637371709e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
/******************************************************************************
* ftptrans.h - code for FTP Transport
*
* $Id: swbuf.h 2218 2008-12-23 09:33:38Z scribe $
*
* Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation version 2.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
*/
// TODO: Rename this to RemoteTransport in 1.7.x
#ifndef FTPTRANS_H
#define FTPTRANS_H
#include <vector>
#include <defs.h>
#include <swbuf.h>
SWORD_NAMESPACE_START
/** Class for reporting status
*/
class SWDLLEXPORT StatusReporter {
public:
virtual ~StatusReporter() {};
/** Messages before stages of a batch download */
virtual void preStatus(long totalBytes, long completedBytes, const char *message);
/** frequently called throughout a download, to report status */
virtual void statusUpdate(double dtTotal, double dlNow);
};
/** TODO: document
* A base class to be used for reimplementation of network services.
*/
class SWDLLEXPORT FTPTransport { // TODO: rename to more generic RemoteTransport
protected:
StatusReporter *statusReporter;
bool passive;
bool term;
SWBuf host;
SWBuf u;
SWBuf p;
public:
FTPTransport(const char *host, StatusReporter *statusReporter = 0);
virtual ~FTPTransport();
/***********
* override this method in your real impl
*
* if destBuf then write to buffer instead of file
*/
virtual char getURL(const char *destPath, const char *sourceURL, SWBuf *destBuf = 0);
int copyDirectory(const char *urlPrefix, const char *dir, const char *dest, const char *suffix);
virtual std::vector<struct DirEntry> getDirList(const char *dirURL);
void setPassive(bool passive) { this->passive = passive; }
void setUser(const char *user) { u = user; }
void setPasswd(const char *passwd) { p = passwd; }
void terminate() { term = true; }
};
SWORD_NAMESPACE_END
#endif
|