[sword-svn] r516 - branches/BCB5/apps/InstallMgr
scribe at crosswire.org
scribe at crosswire.org
Fri Jul 24 03:29:18 EDT 2020
Author: scribe
Date: 2020-07-24 03:29:18 -0400 (Fri, 24 Jul 2020)
New Revision: 516
Modified:
branches/BCB5/apps/InstallMgr/MainFrm.cpp
branches/BCB5/apps/InstallMgr/MainFrm.dfm
branches/BCB5/apps/InstallMgr/MainFrm.h
branches/BCB5/apps/InstallMgr/RemoteMntFrm.cpp
branches/BCB5/apps/InstallMgr/RemoteMntFrm.dfm
branches/BCB5/apps/InstallMgr/cipherfrm.cpp
branches/BCB5/apps/InstallMgr/cipherfrm.dfm
Log:
Adding createAllModules to fix cipherfrm unlock test
Modified: branches/BCB5/apps/InstallMgr/MainFrm.cpp
===================================================================
--- branches/BCB5/apps/InstallMgr/MainFrm.cpp 2020-07-19 19:42:58 UTC (rev 515)
+++ branches/BCB5/apps/InstallMgr/MainFrm.cpp 2020-07-24 07:29:18 UTC (rev 516)
@@ -29,6 +29,7 @@
TMainForm *MainForm;
+
int InstallMgrWin::ftpCopy(InstallSource *is, const char *src, const char *dest, bool dirTransfer, const char *suffix) {
termed = false;
StatusForm->is = is;
@@ -117,7 +118,7 @@
__fastcall InstallSourceTab::~InstallSourceTab() {
}
-
+
__fastcall TMainForm::TMainForm(TComponent* Owner)
: TForm(Owner) {
@@ -134,45 +135,59 @@
localTree->Align = alClient;
localTree->OnDblClick = localTreeDblClick;
localTree->Font->Name = "Arial";
-
-
+
+
// migrate really old data
if (FileMgr::existsFile("./InstallMgr.conf")) {
FileMgr::copyFile("./InstallMgr.conf", "installMgr/InstallMgr.conf");
FileMgr::removeFile("./InstallMgr.conf");
}
+ getDataRootPath();
manager = new SWMgr();
- if (!manager->config) {
- SWBuf envallusersdir = getenv("ALLUSERSPROFILE");
- if (envallusersdir.length()) {
- dataRootPath = envallusersdir;
- if ((!dataRootPath.endsWith("\\")) && (!dataRootPath.endsWith("/")))
- dataRootPath += "/";
- dataRootPath += "Application Data/sword/";
- }
- else {
- dataRootPath = "./";
- }
- SWBuf path = dataRootPath + "mods.d/globals.conf";
- int fd = FileMgr::createPathAndFile(path);
- SWBuf globals = "[Globals]\nAutoInstall=./newmods/\n";
- write(fd, globals.c_str(), globals.size());
- close(fd);
- delete manager;
- manager = new SWMgr();
- }
- else {
- dataRootPath = manager->prefixPath;
- }
-
statusReporter = new WinStatusReporter();
- installMgr = new InstallMgrWin((dataRootPath+"installMgr").c_str(), statusReporter);
+ installMgr = new InstallMgrWin((getDataRootPath()+"installMgr").c_str(), statusReporter);
localMgr = 0;
}
+SWBuf TMainForm::getDataRootPath(bool forceRefresh) {
+ static SWBuf dataRootPath = "";
+ if (!dataRootPath.length() || forceRefresh) {
+ SWMgr *letMgrTry = new SWMgr();
+ if (!letMgrTry->config) {
+ SWBuf envallusersdir = getenv("ALLUSERSPROFILE");
+ if (envallusersdir.length()) {
+ dataRootPath = envallusersdir;
+ if ((!dataRootPath.endsWith("\\")) && (!dataRootPath.endsWith("/")))
+ dataRootPath += "/";
+ dataRootPath += "Application Data/sword";
+ }
+ else {
+ dataRootPath = "./";
+ }
+ dataRootPath.replaceBytes("\\", '/');
+ // if our mgr couldn't find modules, then we probably need
+ // to initialize. Let's initialize!
+ SWBuf path = dataRootPath + "mods.d/globals.conf";
+
+ int fd = FileMgr::createPathAndFile(path);
+ SWBuf globals = "[Globals]\nAutoInstall=./newmods/\n";
+ write(fd, globals.c_str(), globals.size());
+ close(fd);
+ }
+ else {
+ dataRootPath = letMgrTry->prefixPath;
+ }
+ delete letMgrTry;
+ // Let's be sure our app-specific folder exists
+ if (!FileMgr::existsDir(dataRootPath+"/BibleCS")) FileMgr::createParent(dataRootPath+"/BibleCS/layout.conf");
+ }
+ return dataRootPath;
+}
+
+
__fastcall TMainForm::~TMainForm() {
}
@@ -180,7 +195,7 @@
void __fastcall TMainForm::FormCreate(TObject *Sender) {
refreshPageControl();
-
+
SWLog::setSystemLog(new SWWinLog(this->Handle)); // set the system logger to our MSWindows specific SWLog class
fillInstallTree();
@@ -579,7 +594,7 @@
MessageBox(this->WindowHandle, "Please first choose which modules you would like to install by double-clicking a module in the 'Available' tree.", "Please select modules first.", MB_OK);
return; // if nothing is selected, do nothing
}
-
+
progressBar->Max = count;
progressBar->Position = 0;
@@ -622,7 +637,7 @@
if (installMgr->isUserDisclaimerConfirmed()) {
RemoteMntForm->ShowModal();
delete installMgr;
- installMgr = new InstallMgrWin((dataRootPath+"installMgr").c_str(), statusReporter);
+ installMgr = new InstallMgrWin((getDataRootPath()+"installMgr").c_str(), statusReporter);
refreshPageControl();
}
}
@@ -650,7 +665,7 @@
SWBuf targetVersion = "0.0";
SWBuf sourceVersion = "1.0";
SectionMap::iterator targetSection;
-
+
entry = module->second.find("Version");
if (entry != module->second.end())
sourceVersion = entry->second.c_str();
@@ -802,35 +817,35 @@
if (localMgr)
delete localMgr;
delete installMgr;
-
+
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::BuildPortableApp1Click(TObject *Sender)
{
- if (dataRootPath != "./") {
+ if (getDataRootPath() != "./") {
// migrate old data
- if (FileMgr::existsDir(dataRootPath+"mods.d")) {
- FileMgr::copyDir(dataRootPath+"mods.d", "./mods.d");
+ if (FileMgr::existsDir(getDataRootPath()+"mods.d")) {
+ FileMgr::copyDir(getDataRootPath()+"mods.d", "./mods.d");
}
- if (FileMgr::existsDir(dataRootPath+"modules")) {
- FileMgr::copyDir(dataRootPath+"modules", "./modules");
+ if (FileMgr::existsDir(getDataRootPath()+"modules")) {
+ FileMgr::copyDir(getDataRootPath()+"modules", "./modules");
}
- SWBuf path = dataRootPath;
+ SWBuf path = getDataRootPath();
path.replaceBytes("\\", '/');
InfoForm->info = (SWBuf)"Library has been copied locally from: " + path + "\\par\\par\\pard ";
InfoForm->info += "You may now copy your SWORD program folder to a USB stick or other portable media to use as a self-contained portable app.";
delete manager;
manager = new SWMgr();
- dataRootPath = manager->prefixPath;
+ getDataRootPath(true);
delete installMgr;
- installMgr = new InstallMgrWin((dataRootPath+"installMgr").c_str(), statusReporter);
+ installMgr = new InstallMgrWin((getDataRootPath()+"installMgr").c_str(), statusReporter);
fillInstallTree();
refreshPageControl();
}
else {
- InfoForm->info = (SWBuf)"Library is already local at: " + dataRootPath;
+ InfoForm->info = (SWBuf)"Library is already local at: " + getDataRootPath();
}
InfoForm->Caption = "Build Portable App";
InfoForm->yesEdit->Visible = false;
@@ -842,6 +857,7 @@
void __fastcall TMainForm::MigrateBookLibraryPubliclytoLocalMachine1Click(
TObject *Sender)
{
+ SWBuf dataRootPath = getDataRootPath();
if (dataRootPath == "./") {
SWBuf envallusersdir = getenv("ALLUSERSPROFILE");
if (envallusersdir.length()) {
@@ -895,20 +911,20 @@
-
+
manager = new SWMgr();
- dataRootPath = manager->prefixPath;
+ dataRootPath = getDataRootPath(true);
installMgr = new InstallMgrWin((dataRootPath+"installMgr").c_str(), statusReporter);
fillInstallTree();
refreshPageControl();
}
- SWBuf path = dataRootPath;
+ SWBuf path = getDataRootPath();
path.replaceBytes("\\", '/');
InfoForm->info = (SWBuf)"Library has been migrated to: " + path + "\\par\\par\\pard";
InfoForm->info += "You may now use other SWORD programs with this library";
}
else {
- SWBuf path = dataRootPath;
+ SWBuf path = getDataRootPath();
path.replaceBytes("\\", '/');
InfoForm->info = (SWBuf)"Library is already public at: " + path;
}
Modified: branches/BCB5/apps/InstallMgr/MainFrm.dfm
===================================================================
(Binary files differ)
Modified: branches/BCB5/apps/InstallMgr/MainFrm.h
===================================================================
--- branches/BCB5/apps/InstallMgr/MainFrm.h 2020-07-19 19:42:58 UTC (rev 515)
+++ branches/BCB5/apps/InstallMgr/MainFrm.h 2020-07-24 07:29:18 UTC (rev 516)
@@ -137,7 +137,7 @@
__fastcall ~TMainForm();
void __fastcall RefreshRemoteSource(TObject *Sender);
int selectAll(TTntTreeView *tree, bool sel);
- SWBuf dataRootPath;
+ SWBuf getDataRootPath(bool forceRefresh = false);
SWMgr *localMgr;
WinStatusReporter *statusReporter;
InstallMgrWin *installMgr;
Modified: branches/BCB5/apps/InstallMgr/RemoteMntFrm.cpp
===================================================================
--- branches/BCB5/apps/InstallMgr/RemoteMntFrm.cpp 2020-07-19 19:42:58 UTC (rev 515)
+++ branches/BCB5/apps/InstallMgr/RemoteMntFrm.cpp 2020-07-24 07:29:18 UTC (rev 516)
@@ -34,7 +34,7 @@
{
ConfigEntMap::iterator loop, end;
delete config; // for reloads
- config = new SWConfig((MainForm->dataRootPath+"installMgr/InstallMgr.conf").c_str());
+ config = new SWConfig((MainForm->getDataRootPath()+"installMgr/InstallMgr.conf").c_str());
ListBox1->Clear();
loop = config->Sections["Sources"].lower_bound("FTPSource");
end = config->Sections["Sources"].upper_bound("FTPSource");
Modified: branches/BCB5/apps/InstallMgr/RemoteMntFrm.dfm
===================================================================
(Binary files differ)
Modified: branches/BCB5/apps/InstallMgr/cipherfrm.cpp
===================================================================
--- branches/BCB5/apps/InstallMgr/cipherfrm.cpp 2020-07-19 19:42:58 UTC (rev 515)
+++ branches/BCB5/apps/InstallMgr/cipherfrm.cpp 2020-07-24 07:29:18 UTC (rev 516)
@@ -6,6 +6,8 @@
#include <swmgr.h>
#include <swconfig.h>
#include <swmodule.h>
+#include <filemgr.h>
+#include "MainFrm.h"
using namespace std;
using namespace sword;
@@ -14,6 +16,31 @@
#pragma package(smart_init)
#pragma resource "*.dfm"
TCipherForm *CipherForm;
+
+
+class SWDLLEXPORT MyMgr : public SWMgr {
+
+public:
+ MyMgr(){
+ }
+protected:
+ virtual void createAllModules(bool multiMod = false);
+ virtual signed char load() {
+ SWMgr::load();
+ }
+};
+
+void MyMgr::createAllModules(bool multiMod) {
+ SWBuf extraConf = MainForm->getDataRootPath()+"/BibleCS/userprefs.conf";
+ bool exists = FileMgr::existsFile(extraConf);
+ if (exists) {
+ SWConfig addConfig(extraConf);
+ this->config->augment(addConfig);
+ }
+ SWMgr::createAllModules(multiMod);
+}
+
+
//---------------------------------------------------------------------------
__fastcall TCipherForm::TCipherForm(TComponent* Owner)
: TForm(Owner)
@@ -30,10 +57,11 @@
if (section != config->Sections.end()) {
entry = section->second.find("CipherKey");
if (entry != section->second.end()) {
- entry->second = CipherForm->cipherEdit->Text.c_str();
- config->Save();
- SWMgr *mgr = new SWMgr();
- SWModule *mod = mgr->Modules[modName];
+ SWConfig userPrefs(MainForm->getDataRootPath()+"/BibleCS/userprefs.conf");
+ userPrefs[modName]["CipherKey"] = CipherForm->cipherEdit->Text.c_str();
+ userPrefs.save();
+ SWMgr *mgr = new MyMgr();
+ SWModule *mod = mgr->getModule(modName);
mod->setKey("Ipet 2:12");
tmpBuf = mod->stripText();
mod->setKey("gen 1:10");
Modified: branches/BCB5/apps/InstallMgr/cipherfrm.dfm
===================================================================
(Binary files differ)
More information about the sword-cvs
mailing list