~ubuntu-branches/debian/squeeze/sword/squeeze

« back to all changes in this revision

Viewing changes to include/installmgr.h

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Glassey
  • Date: 2004-01-15 15:50:07 UTC
  • Revision ID: james.westby@ubuntu.com-20040115155007-n9mz4x0zxrs1isd3
Tags: upstream-1.5.7
ImportĀ upstreamĀ versionĀ 1.5.7

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef INSTALLMGR_H
 
2
#define INSTALLMGR_H
 
3
 
 
4
#include <stdio.h>
 
5
#include <vector>
 
6
#include <defs.h>
 
7
#include <swbuf.h>
 
8
#include <swconfig.h>
 
9
#include <map>
 
10
 
 
11
SWORD_NAMESPACE_START
 
12
 
 
13
class SWMgr;
 
14
 
 
15
// move this include to cpp once struct ftpparse isn't exposed anymore
 
16
extern "C" {
 
17
#include <ftpparse.h>
 
18
}
 
19
 
 
20
 
 
21
// initialize/cleanup SYSTEMWIDE library with life of this static.
 
22
class InstallMgr_init {
 
23
public:
 
24
        InstallMgr_init();
 
25
        ~InstallMgr_init();
 
26
};
 
27
 
 
28
 
 
29
struct FtpFile {
 
30
  const char *filename;
 
31
  FILE *stream;
 
32
};
 
33
 
 
34
 
 
35
class InstallSource {
 
36
        SWMgr *mgr;
 
37
public:
 
38
        InstallSource(const char *type, const char *confEnt = 0);
 
39
        virtual ~InstallSource();
 
40
        SWBuf getConfEnt() {
 
41
                return caption +"|" + source + "|" + directory;
 
42
        }
 
43
        SWBuf type;
 
44
        SWBuf source;
 
45
        SWBuf directory;
 
46
        SWBuf caption;
 
47
        SWBuf localShadow;
 
48
        void *userData;
 
49
        SWMgr *getMgr();
 
50
        void flush();
 
51
};
 
52
 
 
53
typedef std::map < SWBuf, InstallSource * >InstallSourceMap;
 
54
 
 
55
class InstallMgr {
 
56
 
 
57
protected:
 
58
        char *privatePath;
 
59
        // probably change to group these ftp functions into some kind of FTPSession
 
60
        // class, and open/close functions become c_tor/d_tor.
 
61
public:
 
62
        SWConfig *installConf;
 
63
        InstallSourceMap sources;
 
64
        void *FTPOpenSession();
 
65
        void FTPCloseSession(void *session);
 
66
        char FTPURLGetFile(void *session, const char *dest, const char *sourceurl);
 
67
 
 
68
        // probably change to not expose struct ftpparse.  We probably need our
 
69
        // own FTPFile class or something that contains things like file name,
 
70
        // size, type (dir, file, special).  Then change to vector of this class
 
71
        // instead of ftpparse
 
72
        std::vector<struct ftpparse> FTPURLGetDir(void *session, const char *dirurl);
 
73
 
 
74
 
 
75
public:
 
76
        InstallMgr(const char *privatePath = "./");
 
77
        virtual ~InstallMgr();
 
78
        bool passive;
 
79
        bool terminate;
 
80
        virtual int removeModule(SWMgr *manager, const char *modName);
 
81
        virtual int FTPCopy(InstallSource *is, const char *src, const char *dest, bool dirTransfer = false, const char *suffix = "");
 
82
        virtual int installModule(SWMgr *destMgr, const char *fromLocation, const char *modName, InstallSource *is = 0);
 
83
        virtual int copyFileToSWORDInstall(SWMgr *manager, const char *sourceDir, const char *fName);
 
84
        virtual void refreshRemoteSource(InstallSource *is);
 
85
        virtual void statusUpdate(double dltotal, double dlnow);
 
86
        virtual void preDownloadStatus(long totalBytes, long completedBytes, const char *message);
 
87
        virtual bool getCipherCode(const char *modName, SWConfig *config);
 
88
};
 
89
 
 
90
 
 
91
SWORD_NAMESPACE_END
 
92
 
 
93
#endif