[sword-svn] r402 - trunk/apps/InstallMgr

scribe at crosswire.org scribe at crosswire.org
Fri Dec 31 21:11:19 MST 2004


Author: scribe
Date: 2004-12-31 21:11:19 -0700 (Fri, 31 Dec 2004)
New Revision: 402

Modified:
   trunk/apps/InstallMgr/InstallManager.bpr
   trunk/apps/InstallMgr/InstallManager.cpp
   trunk/apps/InstallMgr/MainFrm.cpp
   trunk/apps/InstallMgr/MainFrm.h
   trunk/apps/InstallMgr/StatusFrm.cpp
Log:
Updated to use new InstallMgr SWORD lib interface

Modified: trunk/apps/InstallMgr/InstallManager.bpr
===================================================================
--- trunk/apps/InstallMgr/InstallManager.bpr	2004-12-31 17:32:36 UTC (rev 401)
+++ trunk/apps/InstallMgr/InstallManager.bpr	2005-01-01 04:11:19 UTC (rev 402)
@@ -6,7 +6,8 @@
     <PROJECT value="InstallManager.exe"/>
     <OBJFILES value="InstallManager.obj MainFrm.obj StatusFrm.obj RemoteMntFrm.obj InfoFrm.obj 
       cipherfrm.obj UninstallFrm.obj ..\..\swwinlog.obj 
-      ..\..\..\sword\src\mgr\installmgr.obj"/>
+      ..\..\..\sword\src\mgr\installmgr.obj ..\..\..\sword\src\mgr\curlftpt.obj 
+      ..\..\..\sword\src\mgr\ftptrans.obj"/>
     <RESFILES value="InstallManager.res"/>
     <IDLFILES value=""/>
     <IDLGENFILES value=""/>

Modified: trunk/apps/InstallMgr/InstallManager.cpp
===================================================================
--- trunk/apps/InstallMgr/InstallManager.cpp	2004-12-31 17:32:36 UTC (rev 401)
+++ trunk/apps/InstallMgr/InstallManager.cpp	2005-01-01 04:11:19 UTC (rev 402)
@@ -16,6 +16,8 @@
 USELIB("..\..\..\sword\lib\libsword.lib");
 USELIB("..\..\..\icu-sword\as_is\borland\icuuc.lib");
 USELIB("..\..\..\icu-sword\as_is\borland\icuin.lib");
+USEUNIT("..\..\..\sword\src\mgr\curlftpt.cpp");
+USEUNIT("..\..\..\sword\src\mgr\ftptrans.cpp");
 //---------------------------------------------------------------------------
 WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
 {

Modified: trunk/apps/InstallMgr/MainFrm.cpp
===================================================================
--- trunk/apps/InstallMgr/MainFrm.cpp	2004-12-31 17:32:36 UTC (rev 401)
+++ trunk/apps/InstallMgr/MainFrm.cpp	2005-01-01 04:11:19 UTC (rev 402)
@@ -26,7 +26,8 @@
 
 TMainForm *MainForm;
 
-int InstallMgrWin::FTPCopy(InstallSource *is, const char *src, const char *dest, bool dirTransfer, const char *suffix) {
+int InstallMgrWin::ftpCopy(InstallSource *is, const char *src, const char *dest, bool dirTransfer, const char *suffix) {
+	termed = false;
 	StatusForm->is = is;
 	StatusForm->src = src;
 	StatusForm->dest = dest;
@@ -38,7 +39,7 @@
 	else	return 0;
 }
 
-void InstallMgrWin::preDownloadStatus(long totalBytes, long completedBytes, const char *message) {
+void WinStatusReporter::preStatus(long totalBytes, long completedBytes, const char *message) {
 	StatusForm->totalBytes = totalBytes;
 	StatusForm->completedBytes = completedBytes;
 	StatusForm->buffer = message;
@@ -46,7 +47,8 @@
 	Application->ProcessMessages();
 }
 
-void InstallMgrWin::statusUpdate(double dltotal, double dlnow) {
+
+void WinStatusReporter::statusUpdate(double dltotal, double dlnow) {
 	if (!dltotal || !StatusForm->totalBytes)
 		return;	// prevent division by zero error below
 	int filePercent  = (int)((float)(dlnow + 1) / (float)(dltotal) * 100);
@@ -59,18 +61,22 @@
 	Application->ProcessMessages();
 }
 
+
 bool InstallMgrWin::getCipherCode(const char *modName, SWConfig *config) {
 	CipherForm->modName = modName;
 	CipherForm->config = config;
 	return (CipherForm->ShowModal() == mrCancel);
 }
 
+
 __fastcall InstallSourceTab::InstallSourceTab(TComponent *Owner, InstallSource *is) : TControl(Owner) {
 	this->is = is;
 }
 
+
 __fastcall InstallSourceTab::~InstallSourceTab() {
 }
+
 	
 __fastcall TMainForm::TMainForm(TComponent* Owner)
 		: TForm(Owner) {
@@ -86,7 +92,8 @@
 		FileMgr::copyFile("./InstallMgr.conf", "installMgr/InstallMgr.conf");
 		FileMgr::removeFile("./InstallMgr.conf");
 	}
-	installMgr = new InstallMgrWin("./installMgr");
+	statusReporter = new WinStatusReporter();
+	installMgr = new InstallMgrWin("./installMgr", statusReporter);
 	localMgr = 0;
 }
 

Modified: trunk/apps/InstallMgr/MainFrm.h
===================================================================
--- trunk/apps/InstallMgr/MainFrm.h	2004-12-31 17:32:36 UTC (rev 401)
+++ trunk/apps/InstallMgr/MainFrm.h	2005-01-01 04:11:19 UTC (rev 402)
@@ -34,12 +34,17 @@
 	TTreeView *tree;
 };
 
+
+class WinStatusReporter : public StatusReporter {
+	virtual void statusUpdate(double dltotal, double dlnow);
+	virtual void preStatus(long totalBytes, long completedBytes, const char *message);
+};
+
 class InstallMgrWin : public InstallMgr {
 public:
-	InstallMgrWin(const char *privatePath = "./") : InstallMgr(privatePath) {}
-	virtual int FTPCopy(InstallSource *is, const char *src, const char *dest, bool dirTransfer = false, const char *suffix = "");
-	virtual void statusUpdate(double dltotal, double dlnow);
-	virtual void preDownloadStatus(long totalBytes, long completedBytes, const char *message);
+	bool termed;
+	InstallMgrWin(const char *privatePath = "./", StatusReporter *statusReporter = 0) : InstallMgr(privatePath, statusReporter) {}
+	virtual int ftpCopy(InstallSource *is, const char *src, const char *dest, bool dirTransfer = false, const char *suffix = "");
 	virtual bool getCipherCode(const char *modName, SWConfig *config);
 };
 
@@ -124,6 +129,7 @@
 	void __fastcall RefreshRemoteSource(TObject *Sender);
 	int selectAll(TTreeView *tree, bool sel);
 	SWMgr *localMgr;
+	WinStatusReporter *statusReporter;
 	InstallMgrWin *installMgr;
 
 protected:

Modified: trunk/apps/InstallMgr/StatusFrm.cpp
===================================================================
--- trunk/apps/InstallMgr/StatusFrm.cpp	2004-12-31 17:32:36 UTC (rev 401)
+++ trunk/apps/InstallMgr/StatusFrm.cpp	2005-01-01 04:11:19 UTC (rev 402)
@@ -62,7 +62,7 @@
 
 	Synchronize((TThreadMethod)&PreConnect);
 
-	int status = MainForm->installMgr->InstallMgr::FTPCopy(is, src, dest, dirTransfer, suffix);
+	int status = MainForm->installMgr->InstallMgr::ftpCopy(is, src, dest, dirTransfer, suffix);
 
 	if (status == -1) {
 		MessageBox(0, "Can't connect.  Please check your configuration.", "Connection Error", MB_OK);
@@ -128,7 +128,7 @@
 void __fastcall TStatusForm::Cleanup(TObject *Sender)
 //void __fastcall TStatusForm::TFTPThread::Cleanup()
 {
-	if (MainForm->installMgr->terminate)
+	if (MainForm->installMgr->termed)
 		StatusForm->ModalResult = mrCancel;
 	else	StatusForm->ModalResult = mrOk;
 //	StatusForm->Close();
@@ -143,7 +143,8 @@
 
 void __fastcall TStatusForm::Button1Click(TObject *Sender)
 {
-	MainForm->installMgr->terminate = true;
+	MainForm->installMgr->terminate();
+	MainForm->installMgr->termed = true;
 	ftpThread->Terminate();
 }
 //---------------------------------------------------------------------------



More information about the sword-cvs mailing list