The SWORD Project  1.9.0.svnversion
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
remotetrans.h
Go to the documentation of this file.
1 /******************************************************************************
2  *
3  * remotetrans.h - class RemoteTransport: the base for all communication
4  * transport drivers
5  *
6  * $Id: remotetrans.h 3820 2020-10-24 20:27:30Z scribe $
7  *
8  * Copyright 2004-2013 CrossWire Bible Society (http://www.crosswire.org)
9  * CrossWire Bible Society
10  * P. O. Box 2528
11  * Tempe, AZ 85280-2528
12  *
13  * This program is free software; you can redistribute it and/or modify it
14  * under the terms of the GNU General Public License as published by the
15  * Free Software Foundation version 2.
16  *
17  * This program is distributed in the hope that it will be useful, but
18  * WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20  * General Public License for more details.
21  *
22  */
23 
24 #ifndef REMOTETRANS_H
25 #define REMOTETRANS_H
26 
27 #include <vector>
28 #include <defs.h>
29 #include <swbuf.h>
30 
31 
33 
37 public:
38  virtual ~StatusReporter() {};
40  virtual void preStatus(long totalBytes, long completedBytes, const char *message);
41 
45  SWDEPRECATED virtual void statusUpdate(double dtTotal, double dlNow);
49  virtual void update(unsigned long totalBytes, unsigned long completedBytes);
50 };
51 
52 
57 
58 protected:
60  bool passive;
62  bool term;
67 
68 public:
69  RemoteTransport(const char *host, StatusReporter *statusReporter = 0);
70  virtual ~RemoteTransport();
71 
72  /***********
73  * override this method in your real impl
74  *
75  * if destBuf then write to buffer instead of file
76  * @return -1 operation error (e.g., resource not found); -2 connection error (e.g., connection timeout or login failure); -3 user requested termination
77  */
78  virtual char getURL(const char *destPath, const char *sourceURL, SWBuf *destBuf = 0);
79 
80  /***********
81  * override this method in your real impl
82  *
83  * if sourceBuf then read from buffer instead of file
84  * @return -1 operation error (e.g., permission denied); -2 connection error (e.g., connection timeout or login failure); -3 user requested termination
85  */
86  virtual char putURL(const char *destURL, const char *sourcePath, SWBuf *sourceBuf = 0);
87 
88 
89  int copyDirectory(const char *urlPrefix, const char *dir, const char *dest, const char *suffix);
90 
91  virtual std::vector<struct DirEntry> getDirList(const char *dirURL);
92  void setPassive(bool passive) { this->passive = passive; }
93  void setTimeoutMillis(long timeoutMillis) { this->timeoutMillis = timeoutMillis; }
94  long getTimeoutMillis() { return timeoutMillis; }
95  bool isPassive() { return passive; }
96  void setUser(const char *user) { u = user; }
97  void setPasswd(const char *passwd) { p = passwd; }
98  void setUnverifiedPeerAllowed(bool val) { this->unverifiedPeerAllowed = val; }
99  bool isUnverifiedPeerAllowed() { return unverifiedPeerAllowed; }
100  void terminate() { term = true; }
101 };
102 
103 
105 
106 #endif
#define SWORD_NAMESPACE_START
Definition: defs.h:39
void setUnverifiedPeerAllowed(bool val)
Definition: remotetrans.h:98
Definition: swbuf.h:47
#define SWDLLEXPORT
Definition: defs.h:171
void setTimeoutMillis(long timeoutMillis)
Definition: remotetrans.h:93
StatusReporter * statusReporter
Definition: installmgr.cpp:48
void setPassive(bool passive)
Definition: remotetrans.h:92
#define SWDEPRECATED
Definition: defs.h:174
virtual ~StatusReporter()
Definition: remotetrans.h:38
void setUser(const char *user)
Definition: remotetrans.h:96
bool isUnverifiedPeerAllowed()
Definition: remotetrans.h:99
long getTimeoutMillis()
Definition: remotetrans.h:94
void setPasswd(const char *passwd)
Definition: remotetrans.h:97
bool unverifiedPeerAllowed
Definition: remotetrans.h:63
#define SWORD_NAMESPACE_END
Definition: defs.h:40
bool isPassive()
Definition: remotetrans.h:95
StatusReporter * statusReporter
Definition: remotetrans.h:59