aboutsummaryrefslogtreecommitdiffstats
path: root/apps/windoze/CBuilder5/InstallMgr
diff options
context:
space:
mode:
authordanglassey <danglassey>2002-08-14 09:57:17 +0000
committerdanglassey <danglassey>2002-08-14 09:57:17 +0000
commitdaa67ff1f728c07f2a116ee9a9f4505479ca6808 (patch)
treec224a537d30480002ae0560cc9104b543b4d1b5e /apps/windoze/CBuilder5/InstallMgr
parent6d6973e035aac5ec1676efccd5b8ada70c40b639 (diff)
downloadsword-sf-cvs-import-1.1.1.tar.gz
Initial import from crosswire CVS for syncingimport-1.1.1
Diffstat (limited to 'apps/windoze/CBuilder5/InstallMgr')
-rw-r--r--apps/windoze/CBuilder5/InstallMgr/InstallMgr.bpg31
-rw-r--r--apps/windoze/CBuilder5/InstallMgr/InstallMgr.bpr136
-rw-r--r--apps/windoze/CBuilder5/InstallMgr/InstallMgr.cpp36
-rw-r--r--apps/windoze/CBuilder5/InstallMgr/InstallMgr.resbin0 -> 1852 bytes
-rw-r--r--apps/windoze/CBuilder5/InstallMgr/MainFrm.cpp1110
-rw-r--r--apps/windoze/CBuilder5/InstallMgr/MainFrm.h146
-rw-r--r--apps/windoze/CBuilder5/InstallMgr/RemoteMntFrm.cpp160
-rw-r--r--apps/windoze/CBuilder5/InstallMgr/RemoteMntFrm.h52
-rw-r--r--apps/windoze/CBuilder5/InstallMgr/StatusFrm.cpp273
-rw-r--r--apps/windoze/CBuilder5/InstallMgr/StatusFrm.dfmbin0 -> 1093 bytes
-rw-r--r--apps/windoze/CBuilder5/InstallMgr/StatusFrm.h89
-rw-r--r--apps/windoze/CBuilder5/InstallMgr/cipherfrm.cpp67
-rw-r--r--apps/windoze/CBuilder5/InstallMgr/installmgr.conf8
-rw-r--r--apps/windoze/CBuilder5/InstallMgr/zlib.bpr126
14 files changed, 2234 insertions, 0 deletions
diff --git a/apps/windoze/CBuilder5/InstallMgr/InstallMgr.bpg b/apps/windoze/CBuilder5/InstallMgr/InstallMgr.bpg
new file mode 100644
index 0000000..792eb7c
--- /dev/null
+++ b/apps/windoze/CBuilder5/InstallMgr/InstallMgr.bpg
@@ -0,0 +1,31 @@
+#------------------------------------------------------------------------------
+VERSION = BWS.01
+#------------------------------------------------------------------------------
+!ifndef ROOT
+ROOT = $(MAKEDIR)\..
+!endif
+#------------------------------------------------------------------------------
+MAKE = $(ROOT)\bin\make.exe -$(MAKEFLAGS) -f$**
+DCC = $(ROOT)\bin\dcc32.exe $**
+BRCC = $(ROOT)\bin\brcc32.exe $**
+#------------------------------------------------------------------------------
+PROJECTS = swordlib.lib zlib.lib libcurl.lib InstallMgr.exe
+#------------------------------------------------------------------------------
+default: $(PROJECTS)
+#------------------------------------------------------------------------------
+
+InstallMgr.exe: InstallMgr.bpr
+ $(MAKE)
+
+swordlib.lib: ..\BibleCS\swordlib.bpr
+ $(MAKE)
+
+zlib.lib: zlib.bpr
+ $(ROOT)\bin\bpr2mak -t$(ROOT)\bin\deflib.bmk $**
+ $(ROOT)\bin\make -$(MAKEFLAGS) -f$*.mak
+
+libcurl.lib: libcurl.bpr
+ $(ROOT)\bin\bpr2mak -t$(ROOT)\bin\deflib.bmk $**
+ $(ROOT)\bin\make -$(MAKEFLAGS) -f$*.mak
+
+
diff --git a/apps/windoze/CBuilder5/InstallMgr/InstallMgr.bpr b/apps/windoze/CBuilder5/InstallMgr/InstallMgr.bpr
new file mode 100644
index 0000000..1b2a792
--- /dev/null
+++ b/apps/windoze/CBuilder5/InstallMgr/InstallMgr.bpr
@@ -0,0 +1,136 @@
+<?xml version='1.0' encoding='utf-8' ?>
+<!-- C++Builder XML Project -->
+<PROJECT>
+ <MACROS>
+ <VERSION value="BCB.05.03"/>
+ <PROJECT value="InstallMgr.exe"/>
+ <OBJFILES value="InstallMgr.obj MainFrm.obj StatusFrm.obj RemoteMntFrm.obj InfoFrm.obj
+ cipherfrm.obj UninstallFrm.obj"/>
+ <RESFILES value="InstallMgr.res"/>
+ <IDLFILES value=""/>
+ <IDLGENFILES value=""/>
+ <DEFFILE value=""/>
+ <RESDEPEN value="$(RESFILES) MainFrm.dfm StatusFrm.dfm RemoteMntFrm.dfm InfoFrm.dfm
+ cipherfrm.dfm UninstallFrm.dfm"/>
+ <LIBFILES value="zlib.lib ..\..\..\..\lib\swordlib.lib libcurl.lib curl\lib\ws2_32.lib"/>
+ <LIBRARIES value="vclx50.lib vcl50.lib"/>
+ <SPARELIBS value="vcl50.lib vclx50.lib"/>
+ <PACKAGES value="vcl50.bpi vclx50.bpi vcljpg50.bpi bcbsmp50.bpi qrpt50.bpi vcldb50.bpi
+ vclbde50.bpi ibsmp50.bpi vcldbx50.bpi teeui50.bpi teedb50.bpi tee50.bpi
+ nmfast50.bpi dclocx50.bpi"/>
+ <PATHCPP value=".;"/>
+ <PATHPAS value=".;"/>
+ <PATHRC value=".;"/>
+ <PATHASM value=".;"/>
+ <DEBUGLIBPATH value="$(BCB)\lib\debug"/>
+ <RELEASELIBPATH value="$(BCB)\lib\release"/>
+ <LINKER value="ilink32"/>
+ <USERDEFINES value="VCL"/>
+ <SYSDEFINES value="NO_STRICT"/>
+ <MAINSOURCE value="InstallMgr.cpp"/>
+ <INCLUDEPATH value="curl\include;..\BibleCS;..\..\..\..\usr\src\sword\apps\windoze\CBuilder4\InstallMgr;$(BCB)\include;$(BCB)\include\vcl;..\..\..\..\include"/>
+ <LIBPATH value="..\BibleCS;..\..\..\..\usr\src\sword\apps\windoze\CBuilder4\InstallMgr;$(BCB)\lib\obj;$(BCB)\lib"/>
+ <WARNINGS value="-w-par -w-8027 -w-8026"/>
+ <WARNOPTSTR value=""/>
+ </MACROS>
+ <OPTIONS>
+ <IDLCFLAGS value="-I..\BibleCS -I..\..\..\..\usr\src\sword\apps\windoze\CBuilder4\InstallMgr
+ -I$(BCB)\include -I$(BCB)\include\vcl -I..\..\..\..\include -src_suffix
+ cpp -DVCL -boa"/>
+ <CFLAG1 value="-O2 -H=c:\PROGRA~1\borland\CBUILD~2\lib\vcl50.csm -Hc -Vx -Ve -RT- -X- -a8
+ -b- -k- -vi -c -tW -tWM"/>
+ <PFLAGS value="-$Y- -$L- -$D- -v -JPHNE -M"/>
+ <RFLAGS value=""/>
+ <AFLAGS value="/mx /w2 /zn"/>
+ <LFLAGS value="-D&quot;&quot; -aa -Tpe -x -Gn"/>
+ </OPTIONS>
+ <LINKER>
+ <ALLOBJ value="c0w32.obj sysinit.obj $(OBJFILES)"/>
+ <ALLRES value="$(RESFILES)"/>
+ <ALLLIB value="$(LIBFILES) $(LIBRARIES) import32.lib cp32mt.lib"/>
+ </LINKER>
+ <IDEOPTIONS>
+[Version Info]
+IncludeVerInfo=1
+AutoIncBuild=0
+MajorVer=1
+MinorVer=5
+Release=3
+Build=0
+Debug=0
+PreRelease=0
+Special=0
+Private=0
+DLL=0
+Locale=1033
+CodePage=1252
+
+[Version Info Keys]
+CompanyName=CrossWire Bible Society
+FileDescription=SWORD Installation Manager
+FileVersion=1.5.3.0
+InternalName=InstallMgr
+LegalCopyright=Copyright 2002 by CrossWire Bible Society
+LegalTrademarks=
+OriginalFilename=
+ProductName=The SWORD Project
+ProductVersion=1.5.3
+Comments=Seek Jesus who exchanges temporary for eternal
+
+[HistoryLists\hlIncludePath]
+Count=6
+Item0=curl\include;..\BibleCS;..\..\..\..\usr\src\sword\apps\windoze\CBuilder4\InstallMgr;$(BCB)\include;$(BCB)\include\vcl;..\..\..\..\include
+Item1=..\BibleCS;..\..\..\..\usr\src\sword\apps\windoze\CBuilder4\InstallMgr;$(BCB)\include;$(BCB)\include\vcl;..\..\..\..\include
+Item2=..\BibleCS;..\..\..\..\usr\src\sword\apps\windoze\CBuilder4\InstallMgr;$(BCB)\include;$(BCB)\include\vcl;..\..\..\..\include
+Item3=..\BibleCS;..\..\..\..\usr\src\sword\apps\windoze\CBuilder4\InstallMgr;$(BCB)\include;$(BCB)\include\vcl;..\..\..\..\include
+Item4=..\BibleCS;..\..\..\..\usr\src\sword\apps\windoze\CBuilder4\InstallMgr;$(BCB)\include;$(BCB)\include\vcl;..\..\..\..\include
+Item5=..\..\..\..\usr\src\sword\apps\windoze\CBuilder4\InstallMgr;$(BCB)\include;$(BCB)\include\vcl;..\..\..\..\include
+
+[HistoryLists\hlLibraryPath]
+Count=5
+Item0=..\BibleCS;..\..\..\..\usr\src\sword\apps\windoze\CBuilder4\InstallMgr;$(BCB)\lib\obj;$(BCB)\lib
+Item1=..\BibleCS;..\..\..\..\usr\src\sword\apps\windoze\CBuilder4\InstallMgr;$(BCB)\lib\obj;$(BCB)\lib
+Item2=..\BibleCS;..\..\..\..\usr\src\sword\apps\windoze\CBuilder4\InstallMgr;$(BCB)\lib\obj;$(BCB)\lib
+Item3=..\BibleCS;..\..\..\..\usr\src\sword\apps\windoze\CBuilder4\InstallMgr;$(BCB)\lib\obj;$(BCB)\lib
+Item4=..\..\..\..\usr\src\sword\apps\windoze\CBuilder4\InstallMgr;$(BCB)\lib\obj;$(BCB)\lib
+
+[HistoryLists\hlDebugSourcePath]
+Count=1
+Item0=$(BCB)\source\vcl
+
+[HistoryLists\hlConditionals]
+Count=8
+Item0=VCL
+Item1=VCL;__STDC__ true
+Item2=VCL;__STDC__
+Item3=VCL;_MSC_VER
+Item4=VCL __STDC__
+Item5=VCL;_DEBUG
+Item6=_DEBUG;VCL
+Item7=_DEBUG
+
+[HistoryLists\hlRunParameters]
+Count=1
+Item0=-uninstall
+
+[Debugging]
+DebugSourceDirs=$(BCB)\source\vcl
+
+[Parameters]
+RunParams=
+HostApplication=
+RemoteHost=
+RemotePath=
+RemoteDebug=0
+
+[Compiler]
+ShowInfoMsgs=0
+LinkDebugVcl=0
+LinkCGLIB=0
+
+[Language]
+ActiveLang=
+ProjectLang=
+RootDir=
+ </IDEOPTIONS>
+</PROJECT> \ No newline at end of file
diff --git a/apps/windoze/CBuilder5/InstallMgr/InstallMgr.cpp b/apps/windoze/CBuilder5/InstallMgr/InstallMgr.cpp
new file mode 100644
index 0000000..a269603
--- /dev/null
+++ b/apps/windoze/CBuilder5/InstallMgr/InstallMgr.cpp
@@ -0,0 +1,36 @@
+//---------------------------------------------------------------------------
+#include <vcl.h>
+#pragma hdrstop
+USERES("InstallMgr.res");
+USEFORM("MainFrm.cpp", MainForm);
+USEFORM("StatusFrm.cpp", StatusForm);
+USEFORM("RemoteMntFrm.cpp", RemoteMntForm);
+USEFORM("InfoFrm.cpp", InfoForm);
+USEFORM("cipherfrm.cpp", CipherForm);
+USEFORM("UninstallFrm.cpp", UninstallForm);
+USELIB("zlib.lib");
+USELIB("..\..\..\..\lib\swordlib.lib");
+USELIB("libcurl.lib");
+USELIB("curl\lib\ws2_32.lib");
+//---------------------------------------------------------------------------
+WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
+{
+ try
+ {
+ Application->Initialize();
+ Application->Title = "Install Manager";
+ Application->CreateForm(__classid(TMainForm), &MainForm);
+ Application->CreateForm(__classid(TStatusForm), &StatusForm);
+ Application->CreateForm(__classid(TRemoteMntForm), &RemoteMntForm);
+ Application->CreateForm(__classid(TInfoForm), &InfoForm);
+ Application->CreateForm(__classid(TCipherForm), &CipherForm);
+ Application->CreateForm(__classid(TUninstallForm), &UninstallForm);
+ Application->Run();
+ }
+ catch (Exception &exception)
+ {
+ Application->ShowException(&exception);
+ }
+ return 0;
+}
+//---------------------------------------------------------------------------
diff --git a/apps/windoze/CBuilder5/InstallMgr/InstallMgr.res b/apps/windoze/CBuilder5/InstallMgr/InstallMgr.res
new file mode 100644
index 0000000..67f5484
--- /dev/null
+++ b/apps/windoze/CBuilder5/InstallMgr/InstallMgr.res
Binary files differ
diff --git a/apps/windoze/CBuilder5/InstallMgr/MainFrm.cpp b/apps/windoze/CBuilder5/InstallMgr/MainFrm.cpp
new file mode 100644
index 0000000..42e0500
--- /dev/null
+++ b/apps/windoze/CBuilder5/InstallMgr/MainFrm.cpp
@@ -0,0 +1,1110 @@
+//---------------------------------------------------------------------------
+#include <vcl.h>
+#pragma hdrstop
+
+extern "C" {
+#include <untgz.h>
+}
+
+#include "MainFrm.h"
+#include "StatusFrm.h"
+#include "RemoteMntFrm.h"
+#include "InfoFrm.h"
+#include "cipherfrm.h"
+#include "UninstallFrm.h"
+//---------------------------------------------------------------------------
+#pragma package(smart_init)
+#pragma resource "*.dfm"
+
+#include <swwinlog.h>
+#include <shellapi.h>
+#include <dirent.h>
+#include <fcntl.h>
+#include <io.h>
+#include <sys/stat.h>
+#include <dir.h>
+#include <FileCtrl.hpp>
+
+TMainForm *MainForm;
+
+
+VersionInfo::VersionInfo(const char *version) {
+ char *buf = new char[ strlen(version) + 1 ];
+ char *tok;
+ major = minor = minor2 = minor3 = 0;
+
+ strcpy(buf, version);
+ tok = strtok(buf, ".");
+ if (tok)
+ major = atoi(tok);
+ tok = strtok(0, ".");
+ if (tok)
+ minor = atoi(tok);
+ tok = strtok(0, ".");
+ if (tok)
+ minor2 = atoi(tok);
+ tok = strtok(0, ".");
+ if (tok)
+ minor3 = atoi(tok);
+ delete [] buf;
+}
+
+
+int VersionInfo::compare(const VersionInfo &vi) const {
+ if (major == vi.major)
+ if (minor == vi.minor)
+ if (minor2 == vi.minor2)
+ if (minor3 == vi.minor3)
+ return 0;
+ else return minor3 - vi.minor3;
+ else return minor2 - vi.minor2;
+ else return minor - vi.minor;
+ else return major - vi.major;
+}
+
+
+__fastcall InstallSourceTab::InstallSourceTab(TComponent *Owner, const char *confEnt, const char *type) : TControl(Owner) {
+ char *buf = new char [ strlen(confEnt) + 1 ];
+
+ strcpy(buf, confEnt);
+
+ Caption = strtok(buf, "|");
+ Source = strtok(0, "|");
+ Directory = strtok(0, "|");
+ delete [] buf;
+ Type = type;
+ mgr = 0;
+}
+
+__fastcall InstallSourceTab::~InstallSourceTab() {
+ if (mgr)
+ delete mgr;
+}
+
+__fastcall TMainForm::TMainForm(TComponent* Owner)
+ : TForm(Owner)
+{
+ try {
+ manager = new SWMgr();
+ }
+ catch (...) {
+ createPathAndFile("./mods.d/globals.conf");
+ manager = new SWMgr();
+ }
+ installConf = new SWConfig("./InstallMgr.conf");
+ localMgr = 0;
+}
+
+
+__fastcall TMainForm::~TMainForm()
+{
+ delete manager;
+ delete installConf;
+ if (localMgr)
+ delete localMgr;
+}
+
+
+void __fastcall TMainForm::FormCreate(TObject *Sender) {
+
+ refreshPageControl();
+
+ if (SWLog::systemlog)
+ delete SWLog::systemlog;
+ SWLog::systemlog = new SWWinLog(this->Handle); // set the system logger to our MSWindows specific SWLog class
+
+ fillInstallTree();
+ fillSourceTree(getLocalDir(), localTree);
+}
+
+
+void TMainForm::refreshPageControl() {
+ SectionMap::iterator sources;
+ ConfigEntMap::iterator sourceBegin;
+ ConfigEntMap::iterator sourceEnd;
+
+ while (PageControl1->PageCount > 1) {
+ delete PageControl1->Pages[1];
+ }
+
+ sources = installConf->Sections.find("Sources");
+ passive = (!stricmp((*installConf)["General"]["PassiveFTP"].c_str(), "true"));
+
+ if (sources != installConf->Sections.end()) {
+ sourceBegin = sources->second.lower_bound("FTPSource");
+ sourceEnd = sources->second.upper_bound("FTPSource");
+
+ if (sourceBegin != sourceEnd) {
+ while (sourceBegin != sourceEnd) {
+ InstallSourceTab *ist = new InstallSourceTab(this, sourceBegin->second.c_str(), "FTP");
+ addSource(ist);
+ sourceBegin++;
+ }
+ }
+ }
+}
+
+
+void TMainForm::addSource(InstallSourceTab *ist)
+{
+ TTabSheet *newtab = new TTabSheet(this);
+ TTreeView *newtree = new TTreeView(this);
+ TSpeedButton *newbutton = new TSpeedButton(this);
+ TPanel *newpanel = new TPanel(this);
+ char buf[512];
+ SectionMap::iterator sit;
+
+ newtab->Caption = ist->Caption.c_str();
+ newtab->Hint = ist->Source.c_str();
+ newtab->ShowHint = true;
+ newtab->PageControl = PageControl1;
+ ist->Parent = newtab;
+ ist->tree = newtree;
+ newpanel->Parent = newtab;
+ newpanel->Align = alTop;
+ newpanel->BevelOuter = bvNone;
+ newpanel->BevelInner = bvNone;
+ newpanel->Height = 25;
+ newbutton->Parent = newpanel;
+ newbutton->Caption = "Refresh from Remote Source";
+ newbutton->Width = 210;
+ newbutton->OnClick = RefreshRemoteSource;
+ newbutton->Flat = true;
+ newbutton->Glyph = SpeedButton2->Glyph;
+ newtree->Parent = newtab;
+ newtree->Align = alClient;
+ newtree->ReadOnly = true;
+ newtree->OnDblClick = localTreeDblClick;
+ newtree->Images = ImageList1;
+ newtree->StateImages = ImageList2;
+ string parent = "./sources/" + ist->Source + "/file";
+ createParent(parent.c_str());
+ parent = "./sources/" + ist->Source;
+ fillSourceTree(parent.c_str(), newtree);
+}
+
+
+const char *TMainForm::getLocalDir()
+{
+ ConfigEntMap::iterator entry;
+
+ entry = installConf->Sections["Sources"].find("LocalPath");
+ if (entry == installConf->Sections["Sources"].end()) {
+ installConf->Sections["Sources"].insert(ConfigEntMap::value_type("LocalPath", "d:/sword"));
+ entry = installConf->Sections["Sources"].find("LocalPath");
+ }
+ return entry->second.c_str();
+
+}
+
+
+void TMainForm::setLocalDir(const char *idir)
+{
+ installConf->Sections["Sources"].erase("LocalPath"); installConf->Sections["Sources"].insert(ConfigEntMap::value_type("LocalPath", idir));
+}
+
+
+//---------------------------------------------------------------------------
+void __fastcall TMainForm::LocalPath1Click(TObject *Sender)
+{
+ AnsiString Dir = "C:";
+ WideString Root = getLocalDir();
+ SelectDirectory("Select Local Path", Root , Dir);
+
+/*
+ localPathDlg->Title = "Select a file in the directory to choose";
+ localPathDlg->InitialDir = getLocalDir();
+ if (localPathDlg->Execute()) {
+ char *buf = new char [ strlen(localPathDlg->FileName.c_str()) + 1 ];
+
+ strcpy(buf, localPathDlg->FileName.c_str());
+ int end = strlen(buf) - 1;
+ while (end) {
+ if ((buf[end] == '/') || (buf[end] == '\\'))
+ break;
+ end--;
+ }
+ buf[end+1] = 0;
+ setLocalDir(buf);
+ delete [] buf;
+ }
+*/
+
+ setLocalDir(Dir.c_str());
+
+ installConf->Save();
+ fillSourceTree(getLocalDir(), localTree);
+}
+//---------------------------------------------------------------------------
+
+void TMainForm::fillInstallTree()
+{
+ ModMap::iterator mods;
+ TTreeNode *node;
+ string nodeName;
+
+ installTree->Items->Clear();
+
+ if (!manager->configPath)
+ return;
+
+ for (mods = manager->Modules.begin(); mods != manager->Modules.end(); mods++) {
+ for (node = installTree->Items->GetFirstNode(); node; node = node->getNextSibling()) {
+ if (!strcmp(node->Text.c_str(), mods->second->Type())) {
+ break;
+ }
+ }
+ if (!node) { // Add Section
+ if (!strncmp(mods->second->Type(), "Bibl", 4)) // If Bibles, put first in list
+ node = installTree->Items->AddChildFirst(0, mods->second->Type());
+ else node = installTree->Items->AddChild(0, mods->second->Type());
+ }
+ nodeName = "[";
+ nodeName += mods->second->Name();
+ nodeName += "] ";
+ nodeName += mods->second->Description();
+ node = installTree->Items->AddChildObject(node, nodeName.c_str(), mods->second->Name());
+ }
+ for (node = installTree->Items->GetFirstNode(); node; node = node->getNextSibling())
+ node->Expand(true);
+ node = installTree->Items->GetFirstNode();
+ if (node)
+ node->MakeVisible();
+}
+
+
+void TMainForm::fillSourceTree(const char *sourceConf, TTreeView *tree)
+{
+ ModMap::iterator mods;
+ TTreeNode *node;
+ SectionMap::iterator sections, targetSection;
+ ConfigEntMap::iterator entry;
+ string secName;
+ const char * modDesc;
+ string nodeName;
+ string targetVersion;
+ string sourceVersion;
+ bool cipher;
+ bool showLocked = LockedModules1->Checked;
+
+ SWMgr *mgr;
+
+ if (tree == localTree) {
+ if (localMgr)
+ delete localMgr;
+ mgr = localMgr = new SWMgr(sourceConf);
+ }
+ else {
+
+ InstallSourceTab *ist = (InstallSourceTab *) tree->Parent->Controls[0];
+ if (ist->mgr)
+ delete ist->mgr;
+ mgr = ist->mgr = new SWMgr(sourceConf);
+ }
+
+ tree->Items->Clear();
+
+ if (!mgr->configPath)
+ return;
+
+ for (sections = mgr->config->Sections.begin(); sections != mgr->config->Sections.end(); sections++) {
+
+ cipher = false;
+
+ if (!strcmp(sections->first.c_str(), "Globals")) // skip [Globals]
+ continue;
+
+ entry = sections->second.find("CipherKey");
+ if (entry != sections->second.end()) {
+ if (showLocked)
+ cipher = true;
+ else continue;
+ }
+
+ mods = mgr->Modules.find(sections->first.c_str());
+ if (mods != mgr->Modules.end())
+ secName = mods->second->Type();
+ else {
+ secName = "Other";
+ }
+
+ string misc1 = ((entry = sections->second.find("Category")) != sections->second.end()) ? (*entry).second : (string)"";
+ if (misc1.length() > 0)
+ secName = misc1;
+
+ entry = sections->second.find("Description");
+ if (entry != sections->second.end())
+ modDesc = entry->second.c_str();
+ else modDesc = "";
+
+
+ targetVersion = "0.0";
+ sourceVersion = "1.0";
+
+ entry = sections->second.find("Version");
+ if (entry != sections->second.end())
+ sourceVersion = entry->second.c_str();
+
+ targetSection = manager->config->Sections.find(sections->first);
+ if (targetSection != manager->config->Sections.end()) {
+ targetVersion = "1.0";
+ entry = targetSection->second.find("Version");
+ if (entry != targetSection->second.end())
+ targetVersion = entry->second;
+ }
+
+ if (VersionInfo(sourceVersion.c_str()) > VersionInfo(targetVersion.c_str())) {
+ for (node = tree->Items->GetFirstNode(); node; node = node->getNextSibling()) {
+ if (!strcmp(node->Text.c_str(), secName.c_str())) {
+ break;
+ }
+ }
+
+ if (!node) { // Add Section
+ if (!strncmp(secName.c_str(), "Bibl", 4)) // If Bibles, put first in list
+ node = tree->Items->AddChildFirst(0, secName.c_str());
+ else node = tree->Items->AddChild(0, secName.c_str());
+ node->ImageIndex = 0;
+ }
+ nodeName = "[" + sections->first + "] " + modDesc;
+ node = tree->Items->AddChildObject(node, nodeName.c_str(), (void *) sections->first.c_str());
+ if (VersionInfo(targetVersion.c_str()) < VersionInfo("1.0")) {
+ node->ImageIndex = 1;
+ node->SelectedIndex = 1;
+ }
+ else {
+ node->ImageIndex = 2;
+ node->SelectedIndex = 2;
+ }
+ if (cipher) {
+ node->ImageIndex += 2;
+ node->SelectedIndex += 2;
+ }
+ node->StateIndex = 0;
+ }
+ }
+ for (node = tree->Items->GetFirstNode(); node; node = node->getNextSibling())
+ node->Expand(true);
+ node = tree->Items->GetFirstNode();
+ if (node)
+ node->MakeVisible();
+}
+
+
+void __fastcall TMainForm::Button5Click(TObject *Sender)
+{
+ TTreeView *tree;
+ for (int i = 0; i < PageControl1->ActivePage->ControlCount; i++) {
+ if (PageControl1->ActivePage->Controls[i]->ClassNameIs("TTreeView")) {
+ tree = (TTreeView*)(PageControl1->ActivePage->Controls[i]);
+ break;
+ }
+ }
+ TTreeNode *node = tree->Selected;
+ if (node) {
+ if (node->Parent) {
+ if (node->StateIndex == 1)
+ node->StateIndex = 0; //node->StateIndex;
+ else node->StateIndex = 1;
+ tree->Repaint();
+ }
+ }
+}
+//---------------------------------------------------------------------------
+
+void __fastcall TMainForm::localTreeDblClick(TObject *Sender)
+{
+ Button5Click(Sender);
+}
+//---------------------------------------------------------------------------
+
+int TMainForm::selectAll(TTreeView *tree, bool sel)
+{
+ TTreeNode *node;
+ TTreeNode *node2;
+ int retCount = 0;
+
+ for (node = tree->Items->GetFirstNode(); node; node = node->getNextSibling()) {
+ for (node2 = node->getFirstChild(); node2; node2 = node2->getNextSibling()) {
+ if (node2->StateIndex == 1) {
+ if (!sel) {
+ node2->StateIndex = 0; //node2->StateIndex;
+ retCount++;
+ }
+ }
+ else {
+ if (sel) {
+ node2->StateIndex = 1;
+ retCount++;
+ }
+ }
+ }
+ }
+ return retCount;
+}
+
+
+void __fastcall TMainForm::Button6Click(TObject *Sender) // SELECT ALL
+{
+ TTreeView *tree;
+ for (int i = 0; i < PageControl1->ActivePage->ControlCount; i++) {
+ if (PageControl1->ActivePage->Controls[i]->ClassNameIs("TTreeView")) {
+ tree = (TTreeView*)(PageControl1->ActivePage->Controls[i]);
+ break;
+ }
+ }
+ if (!selectAll(tree, true))
+ selectAll(tree, false);
+ tree->Repaint();
+}
+//---------------------------------------------------------------------------
+
+void __fastcall TMainForm::Image1Click(TObject *Sender)
+{
+ ShellExecute(this->Handle, "open", "http://www.crosswire.org", NULL, NULL, SW_SHOWNORMAL);
+
+}
+//---------------------------------------------------------------------------
+
+int TMainForm::removeModule(const char *modName)
+{
+ SectionMap::iterator module;
+ ConfigEntMap::iterator fileBegin;
+ ConfigEntMap::iterator fileEnd, entry;
+
+ module = manager->config->Sections.find(modName);
+
+ if (module != manager->config->Sections.end()) {
+ entry = module->second.find("CipherKey");
+ if (entry != module->second.end())
+ CipherForm->cipherEdit->Text = entry->second.c_str();
+
+ fileBegin = module->second.lower_bound("File");
+ fileEnd = module->second.upper_bound("File");
+
+ if (fileBegin != fileEnd) { // remove each file
+ while (fileBegin != fileEnd) {
+ //remove file
+ remove(fileBegin->second.c_str());
+ fileBegin++;
+ }
+ }
+ else { //remove all files in DataPath directory
+
+ DIR *dir;
+ struct dirent *ent;
+ ConfigEntMap::iterator entry;
+ string modDir;
+ string modFile;
+
+ entry = module->second.find("DataPath");
+ if (entry != module->second.end()) {
+ modDir = entry->second.c_str();
+ entry = module->second.find("ModDrv");
+ if (entry != module->second.end()) {
+ if (!strcmp(entry->second.c_str(), "RawLD") || !strcmp(entry->second.c_str(), "RawLD4") || !strcmp(entry->second.c_str(), "zLD") || !strcmp(entry->second.c_str(), "RawGenBook") || !strcmp(entry->second.c_str(), "zGenBook")) {
+ char *buf = new char [ strlen(modDir.c_str()) + 1 ];
+
+ strcpy(buf, modDir.c_str());
+ int end = strlen(buf) - 1;
+ while (end) {
+ if (buf[end] == '/')
+ break;
+ end--;
+ }
+ buf[end] = 0;
+ modDir = buf;
+ delete [] buf;
+ }
+ }
+
+ if (dir = opendir(modDir.c_str())) {
+ rewinddir(dir);
+ while ((ent = readdir(dir))) {
+ if ((strcmp(ent->d_name, ".")) && (strcmp(ent->d_name, ".."))) {
+ modFile = modDir;
+ modFile += "/";
+ modFile += ent->d_name;
+ remove(modFile.c_str());
+ }
+ }
+ closedir(dir);
+ }
+ if (dir = opendir(manager->configPath)) { // find and remove .conf file
+ rewinddir(dir);
+ while ((ent = readdir(dir))) {
+ if ((strcmp(ent->d_name, ".")) && (strcmp(ent->d_name, ".."))) {
+ modFile = manager->configPath;
+ modFile += "/";
+ modFile += ent->d_name;
+ SWConfig *config = new SWConfig(modFile.c_str());
+ if (config->Sections.find(modName) != config->Sections.end()) {
+ delete config;
+ remove(modFile.c_str());
+ }
+ else delete config;
+ }
+ }
+ closedir(dir);
+ }
+ }
+ }
+ return 0;
+ }
+ return 1;
+}
+
+
+int TMainForm::createParent(const char *pName)
+{
+ char *buf = new char [ strlen(pName) + 1 ];
+ int retCode = 0;
+
+ strcpy(buf, pName);
+ int end = strlen(buf) - 1;
+ while (end) {
+ if (buf[end] == '/')
+ break;
+ end--;
+ }
+ buf[end] = 0;
+ if (strlen(buf)>0) {
+ if (access(buf, 02)) { // not exists with write access?
+ if ((retCode = mkdir(buf))) {
+ createParent(buf);
+ retCode = mkdir(buf);
+ }
+ }
+ }
+ else retCode = -1;
+ delete [] buf;
+ return retCode;
+}
+
+
+int TMainForm::createPathAndFile(const char *fName)
+{
+ int fd;
+
+ fd = open(fName, O_CREAT|O_WRONLY|O_BINARY, S_IREAD|S_IWRITE);
+ if (fd < 1) {
+ createParent(fName);
+ fd = open(fName, O_CREAT|O_WRONLY|O_BINARY, S_IREAD|S_IWRITE);
+ }
+ return fd;
+}
+
+
+int TMainForm::copyFileToCWD(const char *sourceDir, const char *fName)
+{
+ string sourcePath = sourceDir;
+ sourcePath += fName;
+
+ string dest;
+ dest = manager->prefixPath;
+ if ((manager->prefixPath[strlen(manager->prefixPath)-1] != '\\') && ( manager->prefixPath[strlen(manager->prefixPath)-1] != '/'))
+ dest += "/";
+ dest += fName;
+
+ return copyFile(sourcePath.c_str(), dest.c_str());
+}
+
+
+int TMainForm::copyFile(const char *sourceFile, const char *targetFile)
+{
+ int sfd, dfd, len;
+ char buf[4096];
+
+ if ((sfd = open(sourceFile, O_RDONLY|O_BINARY)) < 1)
+ return -1;
+ if ((dfd = createPathAndFile(targetFile)) < 1)
+ return -1;
+
+ do {
+ len = read(sfd, buf, 4096);
+ write(dfd, buf, len);
+ }
+ while(len == 4096);
+ close(dfd);
+ close(sfd);
+
+ return 0;
+}
+
+
+int TMainForm::installModule(const char *modName, InstallSourceTab *ist)
+{
+ SectionMap::iterator module, section;
+ ConfigEntMap::iterator fileBegin;
+ ConfigEntMap::iterator fileEnd;
+ ConfigEntMap::iterator entry;
+ string sourceDir;
+ string buffer;
+ bool aborted = false;
+ bool cipher = false;
+
+ if (ist)
+ sourceDir = "./sources/" + ist->Source;
+ else sourceDir = getLocalDir();
+
+ SWMgr mgr(sourceDir.c_str());
+
+ module = mgr.config->Sections.find(modName);
+
+ if (module != mgr.config->Sections.end()) {
+
+ entry = module->second.find("CipherKey");
+ if (entry != module->second.end())
+ cipher = true;
+
+ fileEnd = module->second.upper_bound("File");
+ fileBegin = module->second.lower_bound("File");
+
+ if (fileBegin != fileEnd) { // copy each file
+ if (ist) {
+ while (fileBegin != fileEnd) { // ftp each file first
+ buffer = sourceDir + "/" + fileBegin->second;
+ if (FTPCopy(ist, fileBegin->second.c_str(), buffer.c_str())) {
+ aborted = true;
+ break; // user aborted
+ }
+ fileBegin++;
+ }
+ fileBegin = module->second.lower_bound("File");
+ }
+
+ if (!aborted) {
+ // DO THE INSTALL
+ while (fileBegin != fileEnd) {
+ copyFileToCWD(sourceDir.c_str(), fileBegin->second.c_str());
+ fileBegin++;
+ }
+ }
+ //---------------
+
+ if (ist) {
+ fileBegin = module->second.lower_bound("File");
+ while (fileBegin != fileEnd) { // delete each tmp ftp file
+ buffer = sourceDir + "/" + fileBegin->second;
+ remove(buffer.c_str());
+ fileBegin++;
+ }
+ }
+ }
+ else { //copy all files in DataPath directory
+ DIR *dir;
+ struct dirent *ent;
+ ConfigEntMap::iterator entry;
+ string modDir;
+ string modFile;
+ string sourceOrig = sourceDir;
+
+ entry = module->second.find("DataPath");
+ if (entry != module->second.end()) {
+ modDir = entry->second.c_str();
+ entry = module->second.find("ModDrv");
+ if (entry != module->second.end()) {
+ if (!strcmp(entry->second.c_str(), "RawLD") || !strcmp(entry->second.c_str(), "RawLD4") || !strcmp(entry->second.c_str(), "zLD") || !strcmp(entry->second.c_str(), "RawGenBook") || !strcmp(entry->second.c_str(), "zGenBook")) {
+ char *buf = new char [ strlen(modDir.c_str()) + 1 ];
+
+ strcpy(buf, modDir.c_str());
+ int end = strlen(buf) - 1;
+ while (end) {
+ if (buf[end] == '/')
+ break;
+ end--;
+ }
+ buf[end] = 0;
+ modDir = buf;
+ delete [] buf;
+ }
+ }
+
+ if (ist) {
+ buffer = sourceDir + "/" + modDir;
+ if (FTPCopy(ist, modDir.c_str(), buffer.c_str(), true)) {
+ aborted = true; // user aborted
+ }
+ }
+ sourceDir += "/";
+ sourceDir += modDir;
+ if (!aborted) {
+ if (dir = opendir(sourceDir.c_str())) {
+ rewinddir(dir);
+ while ((ent = readdir(dir))) {
+ if ((strcmp(ent->d_name, ".")) && (strcmp(ent->d_name, ".."))) {
+ modFile = modDir;
+ modFile += "/";
+ modFile += ent->d_name;
+ copyFileToCWD(sourceOrig.c_str(), modFile.c_str());
+ }
+ }
+ closedir(dir);
+ }
+ }
+ if (ist) { // delete tmp ftp files
+ if (dir = opendir(sourceDir.c_str())) {
+ rewinddir(dir);
+ while ((ent = readdir(dir))) {
+ if ((strcmp(ent->d_name, ".")) && (strcmp(ent->d_name, ".."))) {
+ modFile = sourceOrig + "/" + modDir;
+ modFile += "/";
+ modFile += ent->d_name;
+ remove(modFile.c_str());
+ }
+ }
+ closedir(dir);
+ }
+ }
+ sourceDir = sourceOrig;
+ sourceDir += "/mods.d/";
+ if (!aborted) {
+ if (dir = opendir(sourceDir.c_str())) { // find and copy .conf file
+ rewinddir(dir);
+ while ((ent = readdir(dir))) {
+ if ((strcmp(ent->d_name, ".")) && (strcmp(ent->d_name, ".."))) {
+ modFile = sourceDir;
+ modFile += ent->d_name;
+ SWConfig *config = new SWConfig(modFile.c_str());
+ if (config->Sections.find(modName) != config->Sections.end()) {
+ delete config;
+ string targetFile = manager->configPath; //"./mods.d/";
+ targetFile += "/";
+ targetFile += ent->d_name;
+ copyFile(modFile.c_str(), targetFile.c_str());
+ if (cipher) {
+ CipherForm->modName = modName;
+ CipherForm->confFile = targetFile;
+ if (CipherForm->ShowModal() == mrCancel) {
+ removeModule(modName);
+ aborted = true;
+ }
+ }
+ }
+ else delete config;
+ }
+ }
+ closedir(dir);
+ }
+ }
+ }
+ }
+ return (aborted) ? -1 : 0;
+ }
+ return 1;
+}
+
+
+void TMainForm::fillAllSourceTrees()
+{
+ fillSourceTree(getLocalDir(), localTree);
+ for (int i = 1; i < PageControl1->PageCount; i++) {
+ InstallSourceTab *ist = (InstallSourceTab *) MainForm->PageControl1->Pages[i]->Controls[0];
+ string parent = "./sources/" + ist->Source;
+ fillSourceTree(parent.c_str(), ist->tree);
+ }
+}
+
+
+void __fastcall TMainForm::Button4Click(TObject *Sender) // REMOVE MODULE
+{
+ TTreeNode *node = installTree->Selected;
+ if (node) {
+ if (node->Parent) {
+ removeModule((const char *)node->Data);
+ delete manager;
+ manager = new SWMgr();
+ fillInstallTree();
+ fillAllSourceTrees();
+ }
+ }
+}
+//---------------------------------------------------------------------------
+
+void __fastcall TMainForm::Button2Click(TObject *Sender) // INSTALL
+{
+ TTreeNode *node;
+ int count = 0;
+ int abort = 0;
+
+ class TWaitCursor {
+ public:
+ TWaitCursor() : oldc(Screen->Cursor) { Screen->Cursor = crHourGlass; }
+ ~TWaitCursor() { Screen->Cursor = oldc; }
+ private:
+ TCursor oldc;
+ } wait; // show hourglass
+
+ TTreeView *tree;
+ for (int i = 0; i < PageControl1->ActivePage->ControlCount; i++) {
+ if (PageControl1->ActivePage->Controls[i]->ClassNameIs("TTreeView")) {
+ tree = (TTreeView*)(PageControl1->ActivePage->Controls[i]);
+ break;
+ }
+ }
+
+ for (node = tree->Items->GetFirstNode(); node; node = node->GetNext()) {
+ if (node->StateIndex == 1)
+ count++;
+ } // do true progress bar
+
+ if (!count) {
+ 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;
+
+ for (node = tree->Items->GetFirstNode(); node; node = node->GetNext()) {
+ if (node->StateIndex == 1) { // if selected for install
+ CipherForm->cipherEdit->Text = "";
+ if ((node->ImageIndex == 2) || (node->ImageIndex == 4)) { // if this is an upgrade
+ removeModule((const char *)node->Data);
+ }
+ // install module
+ statusBar->Caption = "Installing: " + node->Text + "...";
+ statusBar->Repaint();
+ if (tree == localTree)
+ abort = installModule((const char *)node->Data);
+ else abort = installModule((const char *)node->Data, (InstallSourceTab *) PageControl1->ActivePage->Controls[0]);
+ if (abort)
+ break;
+ progressBar->Position++;
+ }
+ }
+ delete manager;
+ manager = new SWMgr();
+ fillInstallTree();
+ fillAllSourceTrees();
+ statusBar->Caption = "";
+ progressBar->Position = 0;
+}
+
+
+int TMainForm::FTPCopy(InstallSourceTab *ist, const char *src, const char *dest, bool dirTransfer, const char *suffix)
+{
+ StatusForm->ist = ist;
+ StatusForm->src = src;
+ StatusForm->dest = dest;
+ StatusForm->suffix = suffix;
+ StatusForm->dirTransfer = dirTransfer;
+ StatusForm->passive = passive;
+ Application->ProcessMessages();
+ if (StatusForm->ShowModal() == mrCancel)
+ return -1;
+ else return 0;
+}
+
+
+void __fastcall TMainForm::RefreshRemoteSource(TObject *Sender)
+{
+ InstallSourceTab *ist = (InstallSourceTab *) MainForm->PageControl1->ActivePage->Controls[0];
+ DIR *dir;
+ struct dirent *ent;
+ ConfigEntMap::iterator entry;
+ string modDir;
+ string modFile;
+ string root = "./sources/";
+ root += ist->Source.c_str();
+ string target = root + "/mods.d";
+
+ if (dir = opendir(target.c_str())) {
+ rewinddir(dir);
+ while ((ent = readdir(dir))) {
+ if ((strcmp(ent->d_name, ".")) && (strcmp(ent->d_name, ".."))) {
+ modFile = target;
+ modFile += "/";
+ modFile += ent->d_name;
+ remove(modFile.c_str());
+ }
+ }
+ closedir(dir);
+ }
+
+
+ string archive = root + "/mods.d.tar.gz";
+ if (!FTPCopy(ist, "mods.d.tar.gz", archive.c_str(), false)) {
+ int fd = open(archive.c_str(), O_RDONLY|O_BINARY);
+ untargz(fd, root.c_str());
+ close(fd);
+ }
+ else FTPCopy(ist, "mods.d", target.c_str(), true, ".conf");
+
+ target = "./sources/";
+ target += ist->Source.c_str();
+
+ fillSourceTree(target.c_str(), ist->tree);
+}
+
+
+
+void __fastcall TMainForm::SpeedButton1Click(TObject *Sender)
+{
+ InfoForm->Caption = "W A R N I N G";
+ InfoForm->info = "\\qc {\\b \\fs20 -=+* WARNING *+=- -=+* WARNING *+=-}\\par\\par\\pard ";
+ InfoForm->info += "Although Install Manager provides a convenient way for installing and upgrading SWORD components, it also uses a systematic method for accessing sites which gives packet sniffers a target to lock into for singling out users. \\par\\par ";
+ InfoForm->info += "\\b\\qc IF YOU LIVE IN A PERSECUTED COUNTRY AND DO NOT WISH TO RISK DETECTION, YOU SHOULD *NOT* USE INSTALL MANAGER'S REMOTE SOURCE FEATURES.";
+ InfoForm->ShowModal();
+ if (RemoteMntForm->ShowModal() == mrOk) {
+ delete installConf;
+ installConf = new SWConfig("./InstallMgr.conf");
+
+ refreshPageControl();
+ }
+}
+
+void __fastcall TMainForm::SpeedButton5Click(TObject *Sender)
+{
+ TTreeView *tree;
+ InstallSourceTab *ist = 0;
+ SectionMap::iterator module;
+ ConfigEntMap::iterator entry, entryEnd;
+ string sourceDir;
+
+ if (PageControl1->ActivePage != PageControl1->Pages[0]) {
+ ist = (InstallSourceTab *) PageControl1->ActivePage->Controls[0];
+ tree = ist->tree;
+ }
+ else tree = localTree;
+
+ TTreeNode *node = tree->Selected;
+ if (node) {
+ if (node->Parent) {
+ if (ist)
+ sourceDir = "./sources/" + ist->Source;
+ else sourceDir = getLocalDir();
+ SWMgr *mgr = new SWMgr(sourceDir.c_str());
+
+ module = mgr->config->Sections.find((const char *)node->Data);
+
+ if (module != mgr->config->Sections.end()) {
+ string targetVersion = "0.0";
+ string sourceVersion = "1.0";
+ SectionMap::iterator targetSection;
+
+ entry = module->second.find("Version");
+ if (entry != module->second.end())
+ sourceVersion = entry->second.c_str();
+
+ targetSection = manager->config->Sections.find(module->first);
+ if (targetSection != manager->config->Sections.end()) {
+ targetVersion = "1.0";
+ entry = targetSection->second.find("Version");
+ if (entry != targetSection->second.end())
+ targetVersion = entry->second;
+ }
+ if (VersionInfo(targetVersion.c_str()) < VersionInfo("1.0")) {
+ InfoForm->info = "\\pard{\\b * Additional Module Available for Install. } \\par ";
+ }
+ else {
+ InfoForm->info = "\\pard{\\b + Upgraded Module Available for Install.}\\par\\tab Current Version: \\tab " + targetVersion + " \\par\\tab Upgrade Version:\\tab " + sourceVersion + " \\par ";
+ bool changes = false;
+ for (entry = module->second.begin(); entry != module->second.end(); entry++) {
+ if (!strncmp(entry->first.c_str(), "History_", 8)) {
+ if (VersionInfo(&entry->first.c_str()[8]) > VersionInfo(targetVersion.c_str())) {
+ if (!changes) {
+ changes = true;
+ InfoForm->info += "\\par{\\b Changes: }\\par ";
+ }
+ InfoForm->info += "\\tab ";
+ InfoForm->info += entry->second.c_str();
+ InfoForm->info += "\\par ";
+ }
+ }
+ }
+ }
+
+ entry = module->second.find("About");
+ if (entry != module->second.end()) {
+ InfoForm->info += "\\par{\\b About: } \\par\\par ";
+ InfoForm->info += entry->second.c_str();
+ }
+ InfoForm->Caption = "Module Information";
+ InfoForm->ShowModal();
+ }
+ delete mgr;
+ }
+ }
+}
+//---------------------------------------------------------------------------
+
+void __fastcall TMainForm::Exit1Click(TObject *Sender)
+{
+ Close();
+}
+//---------------------------------------------------------------------------
+
+
+void TMainForm::deleteAllModules() {
+
+ SWMgr *mgr = new SWMgr();
+
+
+ int count = mgr->Modules.size();
+
+ if (!count)
+ return;
+
+ UninstallForm->Show();
+ UninstallForm->ProgressBar1->Max = count;
+ UninstallForm->ProgressBar1->Position = 0;
+
+ ModMap::iterator it;
+ for (it = mgr->Modules.begin(); it != mgr->Modules.end(); it++) {
+ string label = "Uninstalling: [";
+ label += it->second->Name();
+ label += "] ";
+ label += it->second->Description();
+ UninstallForm->Label1->Caption = label.c_str();
+ UninstallForm->Label1->Repaint();
+ removeModule(it->second->Name());
+ UninstallForm->ProgressBar1->Position = UninstallForm->ProgressBar1->Position + 1;
+ UninstallForm->ProgressBar1->Repaint();
+ }
+ delete mgr;
+ UninstallForm->Hide();
+ return;
+}
+void __fastcall TMainForm::FormShow(TObject *Sender)
+{
+ for (int i=0;i<=ParamCount();i++) {
+ if (LowerCase(ParamStr(i)) == "-uninstall") {
+ deleteAllModules();
+ Application->Terminate();
+ }
+ }
+
+}
+//---------------------------------------------------------------------------
+
+void __fastcall TMainForm::LockedModules1Click(TObject *Sender) {
+ LockedModules1->Checked = !(LockedModules1->Checked);
+
+ if (LockedModules1->Checked) {
+ InfoForm->Caption = "About Locked Modules";
+ InfoForm->info = "\\qc {\\b \\fs20 About Locked Modules}\\par\\par\\pard ";
+
+ InfoForm->info += "Unfortunately, we are unable to legally provide these modules to the general public at this time. We are making attempts to gain permission from the copyright holders, but until such an agreement is arranged, these modules are only available to our developers and testers. We hope to be able to provide some of these to you soon. \\par\\par\\pard ";
+ InfoForm->info += "If you would like to contribute to the project by contacting a publisher seeking distribution permission for CrossWire, your efforts would be very appreciated-- especially in regard to non-English texts. Please subscribe to our developers' forum per instructions on our website, following the [Mailing Lists] link, and post a message stating how you would like to help. Thank you. \\par\\par\\pard ";
+ InfoForm->info += "\t-CrossWire Bible Society. ";
+ InfoForm->ShowModal();
+ }
+ fillAllSourceTrees();
+}
+//---------------------------------------------------------------------------
+
+void __fastcall TMainForm::Contents1Click(TObject *Sender)
+{
+ SWConfig optionsconf("options.conf");
+ string helpDir;
+ ConfigEntMap::iterator it = optionsconf.Sections["Help"].find("Directory");
+ if (it != optionsconf.Sections["Help"].end())
+ helpDir = (*it).second;
+ else helpDir = ".\\help";
+
+ string helpExe = helpDir + "\\Sword.chm::modulesh.html#instmgr";
+ ShellExecute(this->Handle, "open", "hh", helpExe.c_str(), NULL, SW_SHOWNORMAL);
+}
+//---------------------------------------------------------------------------
+
diff --git a/apps/windoze/CBuilder5/InstallMgr/MainFrm.h b/apps/windoze/CBuilder5/InstallMgr/MainFrm.h
new file mode 100644
index 0000000..47fe65c
--- /dev/null
+++ b/apps/windoze/CBuilder5/InstallMgr/MainFrm.h
@@ -0,0 +1,146 @@
+//---------------------------------------------------------------------------
+#ifndef MainFrmH
+#define MainFrmH
+//---------------------------------------------------------------------------
+#include <Classes.hpp>
+#include <Controls.hpp>
+#include <StdCtrls.hpp>
+#include <Forms.hpp>
+#include <Dialogs.hpp>
+#include <Menus.hpp>
+#include <ExtCtrls.hpp>
+#include <MPlayer.hpp>
+#include <Graphics.hpp>
+#include <ComCtrls.hpp>
+#include <swmgr.h>
+#include <ImgList.hpp>
+#include <Buttons.hpp>
+#include <NMFtp.hpp>
+#include <NMHttp.hpp>
+#include <Psock.hpp>
+
+
+class VersionInfo {
+ public:
+ int major, minor, minor2, minor3;
+
+ VersionInfo(const char *version);
+ int compare(const VersionInfo &vi) const;
+ bool operator>(const VersionInfo &vi) const {return (compare(vi) > 0);}
+ bool operator<(const VersionInfo &vi) const {return (compare(vi) < 0);}
+ bool operator==(const VersionInfo &vi) const {return (compare(vi) == 0);}
+};
+
+
+class InstallSourceTab : public TControl {
+public:
+ __fastcall InstallSourceTab(TComponent *Owner, const char *confEnt, const char *type);
+ __fastcall ~InstallSourceTab();
+ string Type;
+ string Source;
+ string Directory;
+ string Caption;
+ TTreeView *tree;
+ SWMgr *mgr;
+};
+
+
+//---------------------------------------------------------------------------
+class TMainForm : public TForm
+{
+ class TWebThread;
+ friend class TWebThread;
+__published: // IDE-managed Components
+ TMainMenu *MainMenu1;
+ TMenuItem *File1;
+ TMenuItem *Exit1;
+ TMenuItem *Option1;
+ TMenuItem *LocalPath1;
+ TOpenDialog *localPathDlg;
+ TPanel *Panel1;
+ TMediaPlayer *MediaPlayer1;
+ TImage *Image1;
+ TPanel *pnlAvailable;
+ TPanel *pnlInstalled;
+ TSplitter *Splitter1;
+ TPanel *Panel2;
+ TPanel *Panel5;
+ TPageControl *PageControl1;
+ TTabSheet *TabSheet1;
+ TTreeView *localTree;
+ TPanel *Panel8;
+ TPanel *Panel7;
+ TPanel *Panel6;
+ TTreeView *installTree;
+ TTimer *Timer1;
+ TLabel *Label1;
+ TImageList *ImageList1;
+ TPanel *Panel3;
+ TImageList *ImageList2;
+ TPanel *statusBar;
+ TPanel *Panel4;
+ TProgressBar *progressBar;
+ TSpeedButton *SpeedButton2;
+ TImage *Image2;
+ TLabel *Label2;
+ TMenuItem *ManageRemoteSources1;
+ TSpeedButton *SpeedButton1;
+ TSpeedButton *SpeedButton3;
+ TSpeedButton *SpeedButton4;
+ TSpeedButton *SpeedButton5;
+ TSpeedButton *SpeedButton6;
+ TSpeedButton *SpeedButton7;
+ TMenuItem *View1;
+ TMenuItem *LockedModules1;
+ TMenuItem *Help1;
+ TMenuItem *Contents1;
+ void __fastcall LocalPath1Click(TObject *Sender);
+ void __fastcall FormCreate(TObject *Sender);
+ void __fastcall Button5Click(TObject *Sender);
+ void __fastcall localTreeDblClick(TObject *Sender);
+ void __fastcall Button6Click(TObject *Sender);
+ void __fastcall Image1Click(TObject *Sender);
+ void __fastcall Button4Click(TObject *Sender);
+ void __fastcall Button2Click(TObject *Sender);
+ void __fastcall SpeedButton1Click(TObject *Sender);
+ void __fastcall SpeedButton5Click(TObject *Sender);
+ void __fastcall Exit1Click(TObject *Sender);
+ void __fastcall FormShow(TObject *Sender);
+ void __fastcall LockedModules1Click(TObject *Sender);
+ void __fastcall Contents1Click(TObject *Sender);
+
+private: // User declarations
+
+ SWMgr *manager;
+ SWConfig *installConf;
+ const char *getLocalDir();
+ void setLocalDir(const char *idir);
+ void refreshPageControl();
+ void addSource(InstallSourceTab *ist);
+ void fillAllSourceTrees();
+ void deleteAllModules();
+
+public: // User declarations
+ __fastcall TMainForm(TComponent* Owner);
+ __fastcall ~TMainForm();
+ void __fastcall RefreshRemoteSource(TObject *Sender);
+ int selectAll(TTreeView *tree, bool sel);
+ int removeModule(const char *modName);
+ int installModule(const char *modName, InstallSourceTab *ist = 0);
+ static int createParent(const char *pName);
+ int createPathAndFile(const char *fName);
+ int copyFile(const char *sourceFile, const char *targetFile);
+ int copyFileToCWD(const char *sourceDir, const char *fName);
+ int FTPCopy(InstallSourceTab *ist, const char *src, const char *dest, bool dirTransfer = false, const char *suffix = "");
+ SWMgr *localMgr;
+ bool passive;
+
+protected:
+ virtual void fillInstallTree();
+ virtual void fillSourceTree(const char *sourceConf, TTreeView *tree);
+};
+
+//---------------------------------------------------------------------------
+extern PACKAGE TMainForm *MainForm;
+//---------------------------------------------------------------------------
+#endif
diff --git a/apps/windoze/CBuilder5/InstallMgr/RemoteMntFrm.cpp b/apps/windoze/CBuilder5/InstallMgr/RemoteMntFrm.cpp
new file mode 100644
index 0000000..148a7fd
--- /dev/null
+++ b/apps/windoze/CBuilder5/InstallMgr/RemoteMntFrm.cpp
@@ -0,0 +1,160 @@
+//---------------------------------------------------------------------------
+#include <vcl.h>
+#pragma hdrstop
+
+#include "RemoteMntFrm.h"
+//---------------------------------------------------------------------------
+#pragma package(smart_init)
+#pragma resource "*.dfm"
+
+TRemoteMntForm *RemoteMntForm;
+
+
+class TRemoteSource : public TObject {
+public:
+ string name;
+ string machine;
+ string dir;
+ TRemoteSource(const char *confEnt) {
+ char *buf = new char [ strlen(confEnt) + 1 ];
+
+ strcpy(buf, confEnt);
+
+ name = strtok(buf, "|");
+ machine = strtok(0, "|");
+ dir = strtok(0, "|");
+ delete [] buf;
+ }
+ string getConfEnt() {
+ return name +"|" + machine + "|" + dir;
+ }
+};
+
+
+//---------------------------------------------------------------------------
+__fastcall TRemoteMntForm::TRemoteMntForm(TComponent* Owner)
+ : TForm(Owner)
+{
+}
+//---------------------------------------------------------------------------
+void __fastcall TRemoteMntForm::FormShow(TObject *Sender)
+{
+ ConfigEntMap::iterator loop, end;
+ config = new SWConfig("./InstallMgr.conf");
+ ListBox1->Clear();
+ loop = config->Sections["Sources"].lower_bound("FTPSource");
+ end = config->Sections["Sources"].upper_bound("FTPSource");
+ while (loop != end) {
+ TRemoteSource *rs = new TRemoteSource(loop->second.c_str());
+ ListBox1->Items->AddObject(rs->name.c_str(), rs);
+ loop++;
+ }
+ ListBox1->ItemIndex = 0;
+ ListBox1Click(0);
+ CheckBox1->Checked = (!stricmp((*config)["General"]["PassiveFTP"].c_str(), "true"));
+ checkDisabled();
+}
+
+
+void TRemoteMntForm::checkDisabled() {
+ bool enabled = ListBox1->Items->Count;
+ NameEdit->Enabled = enabled;
+ MachineEdit->Enabled = enabled;
+ DirEdit->Enabled = enabled;
+}
+
+
+//---------------------------------------------------------------------------
+void __fastcall TRemoteMntForm::FormClose(TObject *Sender,
+ TCloseAction &Action)
+{
+ delete config;
+}
+
+
+void __fastcall TRemoteMntForm::SpeedButton4Click(TObject *Sender)
+{
+ ModalResult = mrCancel;
+}
+
+
+void __fastcall TRemoteMntForm::ListBox1Click(TObject *Sender)
+{
+ if (ListBox1->ItemIndex >= 0) {
+ TRemoteSource *rs = (TRemoteSource *)ListBox1->Items->Objects[ListBox1->ItemIndex];
+
+ NameEdit->Text = rs->name.c_str();
+ MachineEdit->Text = rs->machine.c_str();
+ DirEdit->Text = rs->dir.c_str();
+ }
+ else {
+ NameEdit->Text = "";
+ MachineEdit->Text = "";
+ DirEdit->Text = "";
+ }
+}
+
+
+void __fastcall TRemoteMntForm::NameEditChange(TObject *Sender)
+{
+ if (ListBox1->ItemIndex < 0)
+ return;
+ TRemoteSource *rs = (TRemoteSource *)ListBox1->Items->Objects[ListBox1->ItemIndex];
+ rs->name = NameEdit->Text.c_str();
+ ListBox1->Items->Strings[ListBox1->ItemIndex] = rs->name.c_str();
+}
+
+
+void __fastcall TRemoteMntForm::MachineEditChange(TObject *Sender)
+{
+ if (ListBox1->ItemIndex < 0)
+ return;
+ TRemoteSource *rs = (TRemoteSource *)ListBox1->Items->Objects[ListBox1->ItemIndex];
+ rs->machine = MachineEdit->Text.c_str();
+}
+
+
+void __fastcall TRemoteMntForm::DirEditChange(TObject *Sender)
+{
+ if (ListBox1->ItemIndex < 0)
+ return;
+ TRemoteSource *rs = (TRemoteSource *)ListBox1->Items->Objects[ListBox1->ItemIndex];
+ rs->dir = DirEdit->Text.c_str();
+}
+
+void __fastcall TRemoteMntForm::SpeedButton2Click(TObject *Sender)
+{
+ if (ListBox1->ItemIndex < 0)
+ return;
+ int delItem = ListBox1->ItemIndex;
+ ListBox1->Items->Delete(delItem);
+ ListBox1->ItemIndex = (delItem < ListBox1->Items->Count) ? delItem : delItem - 1;
+ checkDisabled();
+ ListBox1Click(0);
+}
+//---------------------------------------------------------------------------
+
+void __fastcall TRemoteMntForm::SpeedButton1Click(TObject *Sender)
+{
+ TRemoteSource *rs = new TRemoteSource("[New Remote Site]|ftp.domain.org|/pub/sword/raw/");
+ ListBox1->ItemIndex = ListBox1->Items->AddObject(rs->name.c_str(), rs);
+
+ checkDisabled();
+ ListBox1Click(0);
+}
+//---------------------------------------------------------------------------
+
+void __fastcall TRemoteMntForm::SpeedButton3Click(TObject *Sender)
+{
+ TRemoteSource *rs;
+ config->Sections["Sources"].erase("FTPSource");
+ for (int i = 0; i < ListBox1->Items->Count; i++) {
+ rs = (TRemoteSource *)ListBox1->Items->Objects[i];
+ config->Sections["Sources"].insert(ConfigEntMap::value_type("FTPSource", rs->getConfEnt().c_str()));
+ }
+ (*config)["General"]["PassiveFTP"] = (CheckBox1->Checked) ? "true" : "false";
+ config->Save();
+ ModalResult = mrOk;
+}
+//---------------------------------------------------------------------------
+
diff --git a/apps/windoze/CBuilder5/InstallMgr/RemoteMntFrm.h b/apps/windoze/CBuilder5/InstallMgr/RemoteMntFrm.h
new file mode 100644
index 0000000..67c825d
--- /dev/null
+++ b/apps/windoze/CBuilder5/InstallMgr/RemoteMntFrm.h
@@ -0,0 +1,52 @@
+//---------------------------------------------------------------------------
+#ifndef RemoteMntFrmH
+#define RemoteMntFrmH
+//---------------------------------------------------------------------------
+#include <Classes.hpp>
+#include <Controls.hpp>
+#include <StdCtrls.hpp>
+#include <Forms.hpp>
+#include <Buttons.hpp>
+#include <ExtCtrls.hpp>
+#include <swconfig.h>
+//---------------------------------------------------------------------------
+class TRemoteMntForm : public TForm
+{
+__published: // IDE-managed Components
+ TPanel *Panel1;
+ TPanel *Panel2;
+ TPanel *Panel3;
+ TListBox *ListBox1;
+ TSpeedButton *SpeedButton1;
+ TSpeedButton *SpeedButton2;
+ TEdit *NameEdit;
+ TEdit *MachineEdit;
+ TEdit *DirEdit;
+ TPanel *Panel4;
+ TSpeedButton *SpeedButton3;
+ TSpeedButton *SpeedButton4;
+ TLabel *Label1;
+ TLabel *Label2;
+ TLabel *Label3;
+ TCheckBox *CheckBox1;
+ void __fastcall FormShow(TObject *Sender);
+ void __fastcall FormClose(TObject *Sender, TCloseAction &Action);
+ void __fastcall NameEditChange(TObject *Sender);
+ void __fastcall SpeedButton4Click(TObject *Sender);
+ void __fastcall ListBox1Click(TObject *Sender);
+ void __fastcall MachineEditChange(TObject *Sender);
+ void __fastcall DirEditChange(TObject *Sender);
+ void __fastcall SpeedButton2Click(TObject *Sender);
+ void __fastcall SpeedButton1Click(TObject *Sender);
+ void __fastcall SpeedButton3Click(TObject *Sender);
+private: // User declarations
+ SWConfig *config;
+ void checkDisabled();
+
+public: // User declarations
+ __fastcall TRemoteMntForm(TComponent* Owner);
+};
+//---------------------------------------------------------------------------
+extern PACKAGE TRemoteMntForm *RemoteMntForm;
+//---------------------------------------------------------------------------
+#endif
diff --git a/apps/windoze/CBuilder5/InstallMgr/StatusFrm.cpp b/apps/windoze/CBuilder5/InstallMgr/StatusFrm.cpp
new file mode 100644
index 0000000..0abc9da
--- /dev/null
+++ b/apps/windoze/CBuilder5/InstallMgr/StatusFrm.cpp
@@ -0,0 +1,273 @@
+//---------------------------------------------------------------------------
+#include <vcl.h>
+#pragma hdrstop
+
+#include "StatusFrm.h"
+#include "MainFrm.h"
+//---------------------------------------------------------------------------
+#pragma package(smart_init)
+//#pragma link "IdBaseComponent"
+//#pragma link "IdComponent"
+//#pragma link "IdFTP"
+//#pragma link "IdTCPClient"
+//#pragma link "IdTCPConnection"
+#pragma resource "*.dfm"
+TStatusForm *StatusForm;
+
+
+
+
+struct FtpFile {
+ char *filename;
+ FILE *stream;
+};
+
+int my_fwrite(void *buffer, size_t size, size_t nmemb, void *stream)
+{
+ struct FtpFile *out=(struct FtpFile *)stream;
+ if(out && !out->stream) {
+ /* open file for writing */
+ out->stream=fopen(out->filename, "wb");
+ if(!out->stream)
+ return -1; /* failure, can't open file to write */
+ }
+ return fwrite(buffer, size, nmemb, out->stream);
+}
+
+
+
+
+
+//---------------------------------------------------------------------------
+__fastcall TStatusForm::TStatusForm(TComponent* Owner)
+ : TForm(Owner) {
+ suffix = "";
+ passive = false;
+ curl_global_init(CURL_GLOBAL_DEFAULT);
+}
+
+
+__fastcall TStatusForm::~TStatusForm() {
+ curl_global_cleanup();
+}
+
+
+//---------------------------------------------------------------------------
+void __fastcall TStatusForm::FormShow(TObject *Sender)
+{
+ abort = false;
+ ftpThread = new TFTPThread(ist, src.c_str(), dest.c_str(), dirTransfer, passive, true, suffix.c_str());
+ ftpThread->OnTerminate = Cleanup;
+ ftpThread->Resume();
+}
+//---------------------------------------------------------------------------
+__fastcall TStatusForm::TFTPThread::TFTPThread(InstallSourceTab *iist, const char *isrc, const char *idest, bool idirTransfer, bool CreateSuspended, bool ipassive, const char *isuffix)
+ : TThread(CreateSuspended)
+{
+ ist = iist;
+ src = isrc;
+ dest = idest;
+ suffix = isuffix;
+ dirTransfer = idirTransfer;
+ Priority = tpNormal;
+ passive = ipassive;
+ FreeOnTerminate = true;
+ Synchronize((TThreadMethod)&CreateFTPObject);
+}
+
+__fastcall TStatusForm::TFTPThread::~TFTPThread()
+{
+}
+
+
+void __fastcall TStatusForm::TFTPThread::Execute()
+{
+ CURL *curl;
+ CURLcode res;
+ struct FtpFile ftpfile={
+ "curl.tar.gz", /* name to store the file as if succesful */
+ NULL
+ };
+
+ Synchronize((TThreadMethod)&PreConnect);
+ StatusForm->ftpCon->Host = ist->Source.c_str();
+ StatusForm->ftpCon->Username = "ftp";
+ StatusForm->ftpCon->Password = "installmgr@user.com";
+ StatusForm->ftpCon->Passive = passive;
+
+
+ curl = curl_easy_init();
+
+ if (curl) {
+ /* Get curl 7.9.2 from sunet.se's FTP site: */
+ curl_easy_setopt(curl, CURLOPT_URL,
+ "ftp://ftp.sunet.se/pub/www/utilities/curl/curl-7.9.2.tar.gz");
+ /* Define our callback to get called when there's data to be written */
+ curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, my_fwrite);
+ /* Set a pointer to our struct to pass to the callback */
+ curl_easy_setopt(curl, CURLOPT_FILE, &ftpfile);
+
+ /* Switch on full protocol/debug output */
+ curl_easy_setopt(curl, CURLOPT_VERBOSE, TRUE);
+
+ res = curl_easy_perform(curl);
+
+ /* always cleanup */
+ curl_easy_cleanup(curl);
+
+ if(CURLE_OK != res) {
+ /* we failed */
+ fprintf(stderr, "curl told us %d\n", res);
+ }
+ }
+
+ if(ftpfile.stream)
+ fclose(ftpfile.stream); /* close the local file */
+
+/*
+ try {
+ StatusForm->ftpCon->Connect(true, -1);
+ StatusForm->ftpCon->TransferType = ftBinary;
+ StatusForm->ftpCon->ChangeDir(ist->Directory.c_str());
+ }
+ catch(...) {
+ MessageBox(0, "Can't connect. Please check your configuration.", "Connection Error", MB_OK);
+ StatusForm->Button1Click(0); // abort thread
+ }
+
+ if (!Terminated) {
+ if (dirTransfer) {
+ StatusForm->ftpCon->ChangeDir(src.c_str());
+ TStringList *dirText = new TStringList();
+ StatusForm->ftpCon->List(dirText, "*", true);
+ TIdFTPListItems *dirList = StatusForm->ftpCon->DirectoryListing;
+ for (int i = 0; i < dirList->Count; i++) {
+ if (dirList->Items[i]->ItemType != ditDirectory) {
+ buffer = dest + "/" + (dirList->Items[i]->FileName.c_str());
+// files->Strings[i].c_str();
+ if (!strcmp(&buffer.c_str()[buffer.length()-suffix.length()], suffix.c_str())) {
+ buffer2 = "Downloading (";
+ buffer2 += IntToStr(i+1).c_str();
+ buffer2 += " of ";
+ buffer2 += IntToStr(dirList->Count).c_str();
+ buffer2 += "): ";
+ buffer2 += (dirList->Items[i]->FileName.c_str());
+ // SWLog::systemlog->LogInformation("%s", buffer.c_str());
+ TMainForm::createParent(buffer.c_str()); // make sure parent directory exists
+ Synchronize((TThreadMethod)&PreDownload1);
+ try {
+ StatusForm->currentFileSize = dirList->Items[i]->Size;
+ StatusForm->ftpCon->Get(dirList->Items[i]->FileName.c_str(), buffer.c_str(), true, false);
+ }
+ catch(...) {
+ MessageBox(0, "Can't download file. If you have not done so recently, you might try pressing the Refresh from Remote Source button.", "Download Error", MB_OK);
+ StatusForm->Button1Click(0); // abort thread
+ }
+ if (Terminated)
+ break;
+ }
+ }
+ }
+ }
+ else {
+ Synchronize((TThreadMethod)&PreDownload2);
+ try {
+ StatusForm->ftpCon->Get(src.c_str(), dest.c_str(), true, false);
+ }
+ catch(...) {StatusForm->abort = true;}
+ }
+ try {
+ StatusForm->ftpCon->Disconnect();
+ }
+ catch(...){}
+ }
+*/
+}
+
+
+void __fastcall TStatusForm::TFTPThread::FTPLinkPacketRecvd(TObject *Sender)
+{
+// Synchronize((TThreadMethod)&UpdateBytes);
+}
+
+
+//void __fastcall TStatusForm::TFTPThread::UpdateBytes(void) {
+void __fastcall TStatusForm::UpdateBytes(void) {
+ StatusForm->statusBar->Caption = IntToStr(StatusForm->currentByteCount) + " bytes out of " + IntToStr(StatusForm->currentFileSize) + " transferred (" + IntToStr((int)((float)(StatusForm->currentByteCount + 1) / (float)(StatusForm->currentFileSize + 1) * 100)) + "%)";
+ StatusForm->statusBar->Repaint();
+}
+
+
+void __fastcall TStatusForm::TFTPThread::CreateFTPObject(void)
+{
+// FTPLink = new TNMFTP(0);
+}
+
+
+void __fastcall TStatusForm::TFTPThread::PreConnect(void)
+{
+ buffer = "Connecting to server at ";
+ buffer += ist->Source.c_str();
+ buffer += "...";
+ StatusForm->actionBar->Caption = buffer.c_str();
+ StatusForm->statusBar->Caption = "";
+ StatusForm->Repaint();
+}
+
+
+void __fastcall TStatusForm::TFTPThread::PreDownload1(void)
+{
+// SWLog::systemlog->LogInformation("Creating parent dir: %s", buffer.c_str());
+// SWLog::systemlog->LogInformation("Return: %d", ret);
+ StatusForm->actionBar->Caption = buffer2.c_str();
+ StatusForm->statusBar->Caption = "";
+ StatusForm->Repaint();
+}
+
+
+void __fastcall TStatusForm::TFTPThread::PreDownload2(void)
+{
+ buffer = "Downloading: ";
+ buffer += src.c_str();
+ StatusForm->actionBar->Caption = buffer.c_str();
+ StatusForm->statusBar->Caption = "";
+ StatusForm->Repaint();
+ MainForm->createParent(dest.c_str()); // make sure parent directory exists
+}
+
+
+void __fastcall TStatusForm::Cleanup(TObject *Sender)
+//void __fastcall TStatusForm::TFTPThread::Cleanup()
+{
+ if (abort)
+ StatusForm->ModalResult = mrCancel;
+ else StatusForm->ModalResult = mrOk;
+// StatusForm->Close();
+}
+
+void __fastcall TStatusForm::FormClose(TObject *Sender, TCloseAction &Action)
+{
+ suffix = "";
+ MainForm->SetFocus();
+}
+//---------------------------------------------------------------------------
+
+void __fastcall TStatusForm::Button1Click(TObject *Sender)
+{
+ abort = true;
+// ftpCon->Abort();
+ ftpThread->Terminate();
+}
+//---------------------------------------------------------------------------
+
+/*
+void __fastcall TStatusForm::ftpConWork(TObject *Sender,
+ TWorkMode AWorkMode, const int AWorkCount)
+{
+ currentByteCount = AWorkCount;
+// Synchronize((TThreadMethod)&UpdateBytes);
+ UpdateBytes();
+}
+*/
+//---------------------------------------------------------------------------
+
diff --git a/apps/windoze/CBuilder5/InstallMgr/StatusFrm.dfm b/apps/windoze/CBuilder5/InstallMgr/StatusFrm.dfm
new file mode 100644
index 0000000..bf8609e
--- /dev/null
+++ b/apps/windoze/CBuilder5/InstallMgr/StatusFrm.dfm
Binary files differ
diff --git a/apps/windoze/CBuilder5/InstallMgr/StatusFrm.h b/apps/windoze/CBuilder5/InstallMgr/StatusFrm.h
new file mode 100644
index 0000000..d4b2094
--- /dev/null
+++ b/apps/windoze/CBuilder5/InstallMgr/StatusFrm.h
@@ -0,0 +1,89 @@
+//---------------------------------------------------------------------------
+#ifndef StatusFrmH
+#define StatusFrmH
+//---------------------------------------------------------------------------
+#include <Classes.hpp>
+#include <Controls.hpp>
+#include <StdCtrls.hpp>
+#include <Forms.hpp>
+#include <ExtCtrls.hpp>
+//#include <NMFtp.hpp>
+#include "MainFrm.h"
+//#include "IdBaseComponent.hpp"
+//#include "IdComponent.hpp"
+//#include "IdFTP.hpp"
+//#include "IdTCPClient.hpp"
+//#include "IdTCPConnection.hpp"
+#include <curl/curl.h>
+#include <curl/types.h>
+#include <curl/easy.h>
+//---------------------------------------------------------------------------
+
+class TFTPCon {
+public:
+ string Host;
+ string Username;
+ string Password;
+ bool Passive;
+ string cwd;
+
+};
+
+class TStatusForm : public TForm
+{
+__published: // IDE-managed Components
+ TPanel *Panel1;
+ TPanel *Panel2;
+ TButton *Button1;
+ TPanel *statusBar;
+ TPanel *Panel3;
+ TPanel *actionBar;
+ void __fastcall FormShow(TObject *Sender);
+ void __fastcall Cleanup(TObject *Sender);
+ void __fastcall FormClose(TObject *Sender, TCloseAction &Action);
+ void __fastcall Button1Click(TObject *Sender);
+// void __fastcall ftpConWork(TObject *Sender, TWorkMode AWorkMode,
+// const int AWorkCount);
+private: // User declarations
+ class TFTPThread : public TThread {
+ bool abort;
+ InstallSourceTab *ist;
+ string src;
+ string dest;
+ string buffer;
+ string buffer2;
+ string suffix;
+ bool dirTransfer;
+ bool passive;
+ protected:
+ void __fastcall Execute();
+ public:
+// TNMFTP *FTPLink;
+ __fastcall TFTPThread(InstallSourceTab *iist, const char *isrc, const char *idest, bool idirTransfer = false, bool CreateSuspended = false, bool ipassive = false, const char *suffix = "");
+ __fastcall TFTPThread::~TFTPThread();
+ void __fastcall FTPLinkPacketRecvd(TObject *Sender);
+ void __fastcall CreateFTPObject(void);
+ void __fastcall PreConnect(void);
+ void __fastcall PreDownload1(void);
+ void __fastcall PreDownload2(void);
+// void __fastcall Cleanup(void);
+ } *ftpThread;
+public: // User declarations
+ TFTPCon *ftpCon;
+ long currentByteCount;
+ long currentFileSize;
+ InstallSourceTab *ist;
+ string src;
+ string dest;
+ string suffix;
+ bool dirTransfer;
+ bool passive;
+ bool abort;
+ void __fastcall UpdateBytes();
+ __fastcall TStatusForm(TComponent* Owner);
+ __fastcall ~TStatusForm();
+};
+//---------------------------------------------------------------------------
+extern PACKAGE TStatusForm *StatusForm;
+//---------------------------------------------------------------------------
+#endif
diff --git a/apps/windoze/CBuilder5/InstallMgr/cipherfrm.cpp b/apps/windoze/CBuilder5/InstallMgr/cipherfrm.cpp
new file mode 100644
index 0000000..5b77797
--- /dev/null
+++ b/apps/windoze/CBuilder5/InstallMgr/cipherfrm.cpp
@@ -0,0 +1,67 @@
+//---------------------------------------------------------------------------
+#include <vcl.h>
+#pragma hdrstop
+
+#include "cipherfrm.h"
+#include <swmgr.h>
+#include <swconfig.h>
+//---------------------------------------------------------------------------
+#pragma package(smart_init)
+#pragma resource "*.dfm"
+TCipherForm *CipherForm;
+//---------------------------------------------------------------------------
+__fastcall TCipherForm::TCipherForm(TComponent* Owner)
+ : TForm(Owner)
+{
+}
+//---------------------------------------------------------------------------
+void __fastcall TCipherForm::Button2Click(TObject *Sender)
+{
+ SectionMap::iterator section;
+ ConfigEntMap::iterator entry;
+ SWConfig *modconf = new SWConfig(confFile.c_str());
+ string tmpBuf;
+
+ section = modconf->Sections.find(modName);
+ if (section != modconf->Sections.end()) {
+ entry = section->second.find("CipherKey");
+ if (entry != section->second.end()) {
+ entry->second = CipherForm->cipherEdit->Text.c_str();
+ modconf->Save();
+ delete modconf; // close file
+ modconf = 0;
+ SWMgr *mgr = new SWMgr();
+ SWModule *mod = mgr->Modules[modName];
+ mod->SetKey("Ipet 2:12");
+ tmpBuf = mod->StripText();
+ mod->SetKey("gen 1:10");
+ tmpBuf += "\r\n\r\n";
+ tmpBuf += mod->StripText();
+ Memo1->Text = tmpBuf.c_str();
+ delete mgr;
+ }
+ }
+ if (modconf)
+ delete modconf;
+
+}
+//---------------------------------------------------------------------------
+
+void __fastcall TCipherForm::FormShow(TObject *Sender)
+{
+ string tmpCaption;
+ tmpCaption = "Cipher Key: [";
+ tmpCaption += modName;
+ tmpCaption += "]";
+ Caption = tmpCaption.c_str();
+}
+//---------------------------------------------------------------------------
+
+
+void __fastcall TCipherForm::FormClose(TObject *Sender,
+ TCloseAction &Action)
+{
+ Memo1->Text = "";
+}
+//---------------------------------------------------------------------------
+
diff --git a/apps/windoze/CBuilder5/InstallMgr/installmgr.conf b/apps/windoze/CBuilder5/InstallMgr/installmgr.conf
new file mode 100644
index 0000000..04a349b
--- /dev/null
+++ b/apps/windoze/CBuilder5/InstallMgr/installmgr.conf
@@ -0,0 +1,8 @@
+
+[General]
+PassiveFTP=true
+
+[Sources]
+FTPSource=crosswire|ftp.crosswire.org|/pub/sword/raw/
+LocalPath=C:\tmp
+
diff --git a/apps/windoze/CBuilder5/InstallMgr/zlib.bpr b/apps/windoze/CBuilder5/InstallMgr/zlib.bpr
new file mode 100644
index 0000000..635316b
--- /dev/null
+++ b/apps/windoze/CBuilder5/InstallMgr/zlib.bpr
@@ -0,0 +1,126 @@
+<?xml version='1.0' encoding='utf-8' ?>
+<!-- C++Builder XML Project -->
+<PROJECT>
+ <MACROS>
+ <VERSION value="BCB.05.03"/>
+ <PROJECT value="zlib.lib"/>
+ <OBJFILES value="..\..\..\..\src\utilfuns\zlib\adler32.obj
+ ..\..\..\..\src\utilfuns\zlib\compress.obj
+ ..\..\..\..\src\utilfuns\zlib\crc32.obj
+ ..\..\..\..\src\utilfuns\zlib\deflate.obj
+ ..\..\..\..\src\utilfuns\zlib\gzio.obj
+ ..\..\..\..\src\utilfuns\zlib\infblock.obj
+ ..\..\..\..\src\utilfuns\zlib\infcodes.obj
+ ..\..\..\..\src\utilfuns\zlib\inffast.obj
+ ..\..\..\..\src\utilfuns\zlib\inflate.obj
+ ..\..\..\..\src\utilfuns\zlib\inftrees.obj
+ ..\..\..\..\src\utilfuns\zlib\infutil.obj
+ ..\..\..\..\src\utilfuns\zlib\maketree.obj
+ ..\..\..\..\src\utilfuns\zlib\trees.obj
+ ..\..\..\..\src\utilfuns\zlib\uncompr.obj
+ ..\..\..\..\src\utilfuns\zlib\untgz.obj
+ ..\..\..\..\src\utilfuns\zlib\zutil.obj"/>
+ <RESFILES value=""/>
+ <IDLFILES value=""/>
+ <IDLGENFILES value=""/>
+ <DEFFILE value=""/>
+ <RESDEPEN value="$(RESFILES)"/>
+ <LIBFILES value=""/>
+ <LIBRARIES value=""/>
+ <PACKAGES value=""/>
+ <PATHCPP value=".;..\..\..\..\src\utilfuns\zlib"/>
+ <PATHPAS value=".;"/>
+ <PATHRC value=".;"/>
+ <PATHASM value=".;"/>
+ <LINKER value="TLib"/>
+ <USERDEFINES value=""/>
+ <SYSDEFINES value="_RTLDLL;NO_STRICT"/>
+ <MAINSOURCE value="zlib.bpf"/>
+ <INCLUDEPATH value="..\..\..\..\src\utilfuns\zlib;$(BCB)\include;$(BCB)\include\vcl;..\..\..\..\include"/>
+ <LIBPATH value="..\..\..\..\src\utilfuns\zlib;$(BCB)\lib\obj;$(BCB)\lib"/>
+ <WARNINGS value="-w-par"/>
+ <LISTFILE value=""/>
+ </MACROS>
+ <OPTIONS>
+ <IDLCFLAGS value="-I..\..\..\..\src\utilfuns\zlib -I$(BCB)\include -I$(BCB)\include\vcl
+ -I..\..\..\..\include -src_suffix cpp -boa"/>
+ <CFLAG1 value="-O2 -H=$(BCB)\lib\vcl50.csm -Hc -Vx -Ve -X- -a8 -b- -k- -vi -c -tW -tWM"/>
+ <PFLAGS value="-$Y- -$L- -$D- -v -JPHNE -M"/>
+ <AFLAGS value="/mx /w2 /zn"/>
+ <LFLAGS value=""/>
+ </OPTIONS>
+ <LINKER>
+ <ALLOBJ value="$(OBJFILES)"/>
+ <ALLLIB value=""/>
+ </LINKER>
+ <IDEOPTIONS>
+[Version Info]
+IncludeVerInfo=0
+AutoIncBuild=0
+MajorVer=1
+MinorVer=0
+Release=0
+Build=0
+Debug=0
+PreRelease=0
+Special=0
+Private=0
+DLL=0
+Locale=1033
+CodePage=1252
+
+[Version Info Keys]
+CompanyName=
+FileDescription=
+FileVersion=1.0.0.0
+InternalName=
+LegalCopyright=
+LegalTrademarks=
+OriginalFilename=
+ProductName=
+ProductVersion=1.0.0.0
+Comments=
+
+[HistoryLists\hlIncludePath]
+Count=2
+Item0=..\..\..\..\src\utilfuns\zlib;$(BCB)\include;$(BCB)\include\vcl;..\..\..\..\include
+Item1=..\..\..\..\src\utilfuns\zlib;$(BCB)\include;$(BCB)\include\vcl
+
+[HistoryLists\hlLibraryPath]
+Count=1
+Item0=..\..\..\..\src\utilfuns\zlib;$(BCB)\lib\obj;$(BCB)\lib
+
+[HistoryLists\hlDebugSourcePath]
+Count=1
+Item0=$(BCB)\source\vcl
+
+[HistoryLists\hlConditionals]
+Count=1
+Item0=_DEBUG
+
+[Debugging]
+DebugSourceDirs=$(BCB)\source\vcl
+
+[Parameters]
+RunParams=
+HostApplication=
+RemoteHost=
+RemotePath=
+RemoteDebug=0
+
+[Compiler]
+ShowInfoMsgs=0
+LinkDebugVcl=0
+LinkCGLIB=0
+
+[CORBA]
+AddServerUnit=1
+AddClientUnit=1
+PrecompiledHeaders=1
+
+[Language]
+ActiveLang=
+ProjectLang=
+RootDir=
+ </IDEOPTIONS>
+</PROJECT> \ No newline at end of file