#include <swmgr.h>
#include <installmgr.h>
#include <remotetrans.h>
#include <filemgr.h>
#include <iostream>
#include <map>
#include <swmodule.h>
#include <swoptfilter.h>
#include <stdio.h>
#include <swlog.h>
#include <swversion.h>
Go to the source code of this file.
|
void | createBasicConfig (bool enableRemote, bool addCrossWire, bool unverifiedPeerAllowed) |
|
void | finish (int status) |
|
void | init () |
|
void | initConfig () |
|
bool | isUnverifiedPeerAllowed () |
|
void | listModules (SWMgr *otherMgr=0, bool onlyNewAndUpdates=false, bool utilModules=false) |
|
void | listRemoteSources () |
|
void | localDirInstallModule (const char *dir, const char *modName) |
|
void | localDirListModules (const char *dir) |
|
int | main (int argc, char **argv) |
|
void | refreshRemoteSource (const char *sourceName) |
|
void | remoteDescribeModule (const char *sourceName, const char *modName) |
|
void | remoteInstallModule (const char *sourceName, const char *modName) |
|
void | remoteListModules (const char *sourceName, bool onlyNewAndUpdated=false, bool utilModules=false) |
|
void | syncConfig () |
|
void | uninstallModule (const char *modName) |
|
void | usage (const char *progName=0, const char *error=0) |
|
void createBasicConfig |
( |
bool |
enableRemote, |
|
|
bool |
addCrossWire, |
|
|
bool |
unverifiedPeerAllowed |
|
) |
| |
Definition at line 200 of file installmgr.cpp.
206 is.caption =
"CrossWire";
207 is.source =
"ftp.crosswire.org";
208 is.directory =
"/pub/sword/raw";
211 config[
"General"][
"PassiveFTP"] =
"true";
212 config[
"General"][
"TimeoutMillis"] =
"10000";
213 config[
"General"][
"UnverifiedPeerAllowed"] = (unverifiedPeerAllowed) ?
"true" :
"false";
215 config[
"Sources"][
"FTPSource"] = is.getConfEnt();
static int createParent(const char *pName)
virtual void save() const
void finish |
( |
int |
status | ) |
|
Definition at line 164 of file installmgr.cpp.
169 usage(0,
"ERROR: SWORD configuration not found. Please configure SWORD before using this program.");
172 if (baseDir.length() < 1) baseDir =
".";
173 baseDir +=
"/.sword/InstallMgr";
174 confPath = baseDir +
"/InstallMgr.conf";
StatusReporter * statusReporter
void setUserDisclaimerConfirmed(bool val)
void usage(const char *app)
static FileMgr * getSystemFileMgr()
Definition at line 221 of file installmgr.cpp.
229 cout <<
"\n\nInitialized basic config file at [" <<
confPath <<
"]\n";
230 cout <<
"with remote source features " << ((enable) ?
"ENABLED" :
"DISABLED") <<
"\n";
231 cout <<
"with unverified peers " << ((allowed) ?
"ALLOWED" :
"DISALLOWED") <<
"\n";
bool isUnverifiedPeerAllowed()
void createBasicConfig(bool enableRemote, bool addCrossWire, bool unverifiedPeerAllowed)
virtual bool isUserDisclaimerConfirmed() const
bool isUnverifiedPeerAllowed |
( |
| ) |
|
Definition at line 110 of file installmgr.cpp.
111 static bool allowed =
false;
118 cout <<
"While connecting to an encrypted install source, SWORD can allow\n";
119 cout <<
"unverified peers, e.g., self-signed certificates. While this is\n";
120 cout <<
"generally considered safe because SWORD only retrieves Bible content\n";
121 cout <<
"and does not send any data to the server, it could still possibly\n";
122 cout <<
"allow a malicious actor to sit between you and the server, as with\n";
123 cout <<
"unencrypted sources. Type no to turn this off.\n\n";
124 cout <<
"Would you like to allow unverified peers? [yes] ";
127 fgets(prompt, 9, stdin);
128 allowed = (strcmp(prompt,
"no\n"));
void listModules |
( |
SWMgr * |
otherMgr = 0 , |
|
|
bool |
onlyNewAndUpdates = false , |
|
|
bool |
utilModules = false |
|
) |
| |
Definition at line 294 of file installmgr.cpp.
297 if (!otherMgr) otherMgr =
mgr;
299 for (std::map<SWModule *, int>::iterator it = mods.begin(); it != mods.end(); it++) {
301 SWBuf version = module->getConfigEntry(
"Version");
307 if (!onlyNewAndUpdates || status ==
"*" || status ==
"+") {
308 cout << status <<
"[" << module->getName() <<
"] \t(" << version <<
") \t- " << module->getDescription() <<
"\n";
static const unsigned int MODSTAT_OLDER
static const unsigned int MODSTAT_NEW
static std::map< SWModule *, int > getModuleStatus(const SWMgr &base, const SWMgr &other, bool utilModules=false)
static const unsigned int MODSTAT_UPDATED
void listRemoteSources |
( |
| ) |
|
Definition at line 268 of file installmgr.cpp.
270 cout <<
"Remote Sources:\n\n";
272 cout <<
"[" << it->second->caption <<
"]\n";
273 cout <<
"\tType : " << it->second->type <<
"\n";
274 cout <<
"\tSource : " << it->second->source <<
"\n";
275 cout <<
"\tDirectory: " << it->second->directory <<
"\n";
void localDirInstallModule |
( |
const char * |
dir, |
|
|
const char * |
modName |
|
) |
| |
Definition at line 383 of file installmgr.cpp.
386 SWModule *
module = lmgr.getModule(modName);
388 fprintf(stderr,
"Module [%s] not available at path [%s]\n", modName, dir);
393 cout <<
"\nError installing module: [" << module->getName() <<
"] (write permissions?)\n";
394 }
else cout <<
"\nInstalled module: [" << module->getName() <<
"]\n";
virtual int installModule(SWMgr *destMgr, const char *fromLocation, const char *modName, InstallSource *is=0)
void localDirListModules |
( |
const char * |
dir | ) |
|
Definition at line 354 of file installmgr.cpp.
355 cout <<
"Available Modules:\n\n";
void listModules(SWMgr *otherMgr=0, bool onlyNewAndUpdates=false, bool utilModules=false)
int main |
( |
int |
argc, |
|
|
char ** |
argv |
|
) |
| |
Definition at line 436 of file installmgr.cpp.
441 if (argc < 2)
usage(*argv);
443 for (
int i = 1; i < argc; i++) {
444 if (!strcmp(argv[i],
"-d")) {
447 else if (!strcmp(argv[i],
"--allow-internet-access-and-risk-tracing-and-jail-or-martyrdom")) {
450 else if (!strcmp(argv[i],
"--allow-unverified-tls-peer")) {
453 else if (!strcmp(argv[i],
"-init")) {
456 else if (!strcmp(argv[i],
"-l")) {
457 cout <<
"Installed User Modules:\n\n";
460 else if (!strcmp(argv[i],
"-lu")) {
461 cout <<
"Installed Utility Modules:\n\n";
464 else if (!strcmp(argv[i],
"-ll")) {
466 else usage(*argv,
"-ll requires <path>");
468 else if (!strcmp(argv[i],
"-li")) {
470 const char *path = argv[++i];
471 const char *modName = argv[++i];
474 else usage(*argv,
"-li requires <path> <modName>");
476 else if (!strcmp(argv[i],
"-u")) {
478 else usage(*argv,
"-u requires <modName>");
480 else if (!strcmp(argv[i],
"-s")) {
483 else if (!strcmp(argv[i],
"-sc")) {
486 else if (!strcmp(argv[i],
"-r")) {
488 else usage(*argv,
"-r requires <remoteSrcName>");
490 else if (!strcmp(argv[i],
"-rl")) {
492 else usage(*argv,
"-rl requires <remoteSrcName>");
494 else if (!strcmp(argv[i],
"-rlu")) {
496 else usage(*argv,
"-rlu requires <remoteSrcName>");
498 else if (!strcmp(argv[i],
"-rd")) {
500 else usage(*argv,
"-rd requires <remoteSrcName>");
502 else if (!strcmp(argv[i],
"-rdu")) {
504 else usage(*argv,
"-rdu requires <remoteSrcName>");
506 else if (!strcmp(argv[i],
"-rdesc")) {
508 const char *source = argv[++i];
509 const char *modName = argv[++i];
512 else usage(*argv,
"-rdesc requires <remoteSrcName> <modName>");
514 else if (!strcmp(argv[i],
"-ri")) {
516 const char *source = argv[++i];
517 const char *modName = argv[++i];
520 else usage(*argv,
"-ri requires <remoteSrcName> <modName>");
522 else usage(*argv, (((SWBuf)
"Unknown argument: ")+ argv[i]).c_str());
void remoteListModules(const char *sourceName, bool onlyNewAndUpdated=false, bool utilModules=false)
static SWLog * getSystemLog()
void localDirListModules(const char *dir)
void refreshRemoteSource(const char *sourceName)
void uninstallModule(const char *modName)
void localDirInstallModule(const char *dir, const char *modName)
void listModules(SWMgr *otherMgr=0, bool onlyNewAndUpdates=false, bool utilModules=false)
void usage(const char *app)
void setLogLevel(char level)
void remoteInstallModule(const char *sourceName, const char *modName)
void remoteDescribeModule(const char *sourceName, const char *modName)
static const char LOG_DEBUG
void refreshRemoteSource |
( |
const char * |
sourceName | ) |
|
Definition at line 280 of file installmgr.cpp.
284 fprintf(stderr,
"Couldn't find remote source [%s]\n", sourceName);
289 cout <<
"\nRemote Source Refreshed\n";
290 else cerr <<
"\nError Refreshing Remote Source\n";
virtual int refreshRemoteSource(InstallSource *is)
void remoteDescribeModule |
( |
const char * |
sourceName, |
|
|
const char * |
modName |
|
) |
| |
Definition at line 326 of file installmgr.cpp.
330 fprintf(stderr,
"Couldn't find remote source [%s]\n", sourceName);
333 SWMgr *
mgr = source->second->getMgr();
334 SWModule *
m = mgr->getModule(modName);
336 fprintf(stderr,
"Couldn't find module [%s] in source [%s]\n", modName, sourceName);
339 cout <<
"Module Description\n\n";
340 for (ConfigEntMap::const_iterator it = m->getConfig().begin(); it != m->getConfig().end(); ++it) {
341 cout <<
"[" << it->first <<
"]:" << it->second <<
"\n";
343 cout <<
"\nOption Features available for module: " << m->getName() <<
"\n\n";
344 for (OptionFilterList::const_iterator it = m->getOptionFilters().begin(); it != m->getOptionFilters().end(); ++it) {
345 cout << (*it)->getOptionName() <<
" (" << (*it)->getOptionTip() <<
")\n";
346 StringList optionValues = (*it)->getOptionValues();
347 for (StringList::const_iterator it2 = optionValues.begin(); it2 != optionValues.end(); ++it2) {
348 cout <<
"\t" << *it2 <<
"\n";
std::list< SWBuf > StringList
void remoteInstallModule |
( |
const char * |
sourceName, |
|
|
const char * |
modName |
|
) |
| |
Definition at line 361 of file installmgr.cpp.
365 fprintf(stderr,
"Couldn't find remote source [%s]\n", sourceName);
369 SWMgr *rmgr = is->
getMgr();
370 SWModule *
module = rmgr->getModule(modName);
372 fprintf(stderr,
"Remote source [%s] does not make available module [%s]\n", sourceName, modName);
378 cout <<
"\nError installing module: [" << module->getName() <<
"] (write permissions?)\n";
379 }
else cout <<
"\nInstalled module: [" << module->getName() <<
"]\n";
virtual int installModule(SWMgr *destMgr, const char *fromLocation, const char *modName, InstallSource *is=0)
void remoteListModules |
( |
const char * |
sourceName, |
|
|
bool |
onlyNewAndUpdated = false , |
|
|
bool |
utilModules = false |
|
) |
| |
Definition at line 314 of file installmgr.cpp.
316 cout <<
"Available Modules:\n(be sure to refresh remote source (-r) first for most current list)\n\n";
319 fprintf(stderr,
"Couldn't find remote source [%s]\n", sourceName);
322 listModules(source->second->getMgr(), onlyNewAndUpdated, utilModules);
void listModules(SWMgr *otherMgr=0, bool onlyNewAndUpdates=false, bool utilModules=false)
Definition at line 235 of file installmgr.cpp.
239 cout <<
"\n\nDisclaimer not accepted. Aborting.";
251 cout <<
"\nSync'd config file with master remote source list.\n";
252 else cout <<
"\nFailed to sync config file with master remote source list.\n";
static signed char existsFile(const char *ipath, const char *ifileName=0)
virtual int refreshRemoteSourceConfiguration()
void createBasicConfig(bool enableRemote, bool addCrossWire, bool unverifiedPeerAllowed)
virtual bool isUserDisclaimerConfirmed() const
void uninstallModule |
( |
const char * |
modName | ) |
|
Definition at line 256 of file installmgr.cpp.
258 SWModule *
module =
mgr->getModule(modName);
260 fprintf(stderr,
"Couldn't find module [%s] to remove\n", modName);
264 cout <<
"Removed module: [" << modName <<
"]\n";
virtual int removeModule(SWMgr *manager, const char *modName)
void usage |
( |
const char * |
progName = 0 , |
|
|
const char * |
error = 0 |
|
) |
| |