00001 #ifndef INSTALLMGR_H
00002 #define INSTALLMGR_H
00003
00004 #include <defs.h>
00005 #include <swbuf.h>
00006 #include <map>
00007 #include <set>
00008
00009 SWORD_NAMESPACE_START
00010
00011 class SWMgr;
00012 class SWModule;
00013 class SWConfig;
00014 class FTPTransport;
00015 class StatusReporter;
00016
00019 class SWDLLEXPORT InstallSource {
00020 SWMgr *mgr;
00021 public:
00022 InstallSource(const char *type, const char *confEnt = 0);
00023 virtual ~InstallSource();
00024 SWBuf getConfEnt() {
00025 return caption +"|" + source + "|" + directory + "|" + u + "|" + p + "|" + uid;
00026 }
00027 SWBuf caption;
00028 SWBuf source;
00029 SWBuf directory;
00030 SWBuf u;
00031 SWBuf p;
00032 SWBuf uid;
00033
00034 SWBuf type;
00035 SWBuf localShadow;
00036 void *userData;
00037 SWMgr *getMgr();
00038 void flush();
00039 };
00040
00043 typedef std::map<SWBuf, InstallSource *> InstallSourceMap;
00044
00047 class SWDLLEXPORT InstallMgr {
00048
00049 protected:
00050 bool userDisclaimerConfirmed;
00051 std::set<SWBuf> defaultMods;
00052 char *privatePath;
00053 SWBuf confPath;
00054 StatusReporter *statusReporter;
00055 bool passive;
00056 SWBuf u, p;
00057
00060 virtual FTPTransport *createFTPTransport(const char *host, StatusReporter *statusReporter);
00061
00064 virtual FTPTransport *createHTTPTransport(const char *host, StatusReporter *statusReporter);
00065
00066
00070 FTPTransport *transport;
00071
00072 public:
00073
00074 static const int MODSTAT_OLDER;
00075 static const int MODSTAT_SAMEVERSION;
00076 static const int MODSTAT_UPDATED;
00077 static const int MODSTAT_NEW;
00078 static const int MODSTAT_CIPHERED;
00079 static const int MODSTAT_CIPHERKEYPRESENT;
00080
00081 SWConfig *installConf;
00082
00086 InstallSourceMap sources;
00087
00093 InstallMgr(const char *privatePath = "./", StatusReporter *statusReporter = 0, SWBuf u="ftp", SWBuf p="installmgr@user.com");
00094 virtual ~InstallMgr();
00095
00098 void readInstallConf();
00099
00102 void saveInstallConf();
00103
00106 void clearSources();
00107
00110 virtual int removeModule(SWMgr *manager, const char *modName);
00111
00114 virtual int ftpCopy(InstallSource *is, const char *src, const char *dest, bool dirTransfer = false, const char *suffix = "");
00115
00118 virtual int installModule(SWMgr *destMgr, const char *fromLocation, const char *modName, InstallSource *is = 0);
00119
00122 virtual int refreshRemoteSource(InstallSource *is);
00123
00127 virtual int refreshRemoteSourceConfiguration();
00128
00173 virtual bool isUserDisclaimerConfirmed() const { return userDisclaimerConfirmed; }
00174
00179 void setUserDisclaimerConfirmed(bool val) { userDisclaimerConfirmed = val; }
00180
00181
00217 virtual bool getCipherCode(const char *modName, SWConfig *config) { (void) modName; (void) config; return false; }
00218
00219
00220
00223 void setFTPPassive(bool passive) { this->passive = passive; }
00224 bool isFTPPassive() { return passive; }
00225
00228 void terminate();
00229
00230
00231
00232
00233
00234 static std::map<SWModule *, int> getModuleStatus(const SWMgr &base, const SWMgr &other);
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248 bool isDefaultModule(const char *modName);
00249 };
00250
00251
00252 SWORD_NAMESPACE_END
00253
00254 #endif