[sword-cvs] sword/apps/windoze/CBuilder5/InstallMgr MainFrm.cpp,1.19,1.20 MainFrm.h,1.8,1.9 StatusFrm.cpp,1.16,1.17 StatusFrm.h,1.10,1.11

sword@www.crosswire.org sword@www.crosswire.org
Sun, 6 Jul 2003 17:26:01 -0700


Update of /usr/local/cvsroot/sword/apps/windoze/CBuilder5/InstallMgr
In directory www:/tmp/cvs-serv20766/apps/windoze/CBuilder5/InstallMgr

Modified Files:
	MainFrm.cpp MainFrm.h StatusFrm.cpp StatusFrm.h 
Log Message:
More install code into engine


Index: MainFrm.cpp
===================================================================
RCS file: /usr/local/cvsroot/sword/apps/windoze/CBuilder5/InstallMgr/MainFrm.cpp,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -d -r1.19 -r1.20
*** MainFrm.cpp	27 Jun 2003 01:41:06 -0000	1.19
--- MainFrm.cpp	7 Jul 2003 00:25:59 -0000	1.20
***************
*** 30,35 ****
  TMainForm *MainForm;
  
  
! __fastcall InstallSourceTab::InstallSourceTab(TComponent *Owner, const char *confEnt, const char *type) : TControl(Owner), is(confEnt, type) {
  }
  
--- 30,69 ----
  TMainForm *MainForm;
  
+ int InstallMgrWin::FTPCopy(InstallSource *is, const char *src, const char *dest, bool dirTransfer, const char *suffix) {
+ 	StatusForm->is = is;
+ 	StatusForm->src = src;
+ 	StatusForm->dest = dest;
+ 	StatusForm->suffix = suffix;
+ 	StatusForm->dirTransfer = dirTransfer;
+ 	Application->ProcessMessages();
+ 	if (StatusForm->ShowModal() == mrCancel)
+ 		return -1;
+ 	else	return 0;
+ }
  
! void InstallMgrWin::preDownloadStatus(long totalBytes, long completedBytes, const char *message) {
! 	StatusForm->totalBytes = totalBytes;
! 	StatusForm->completedBytes = completedBytes;
! 	StatusForm->buffer = message;
! 	StatusForm->PreDownload1();
! 	Application->ProcessMessages();
! }
! 
! void InstallMgrWin::statusUpdate(double dltotal, double dlnow) {
! 	if (!dltotal)
! 		return;	// prevent division by zero error below
! 	int filePercent  = (int)((float)(dlnow + 1) / (float)(dltotal) * 100);
! 	int totalPercent = (int)((float)(dlnow + StatusForm->completedBytes + 1) / (float)(StatusForm->totalBytes) * 100);
! 	StatusForm->statusBar->Caption = ::IntToStr((long)dlnow) + " bytes out of " + ::IntToStr((long)dltotal) + " transferred (file: " + IntToStr(filePercent) + "% / total: " + IntToStr(totalPercent) + "%)";
! 	StatusForm->fileProgress->Position = filePercent;
! 	StatusForm->totalProgress->Position = totalPercent;
! 	
! 	StatusForm->statusBar->Repaint();
! 	Application->ProcessMessages();
! }
! 
! 
! __fastcall InstallSourceTab::InstallSourceTab(TComponent *Owner, InstallSource *is) : TControl(Owner) {
! 	this->is = is;
  }
  
***************
*** 47,51 ****
             manager = new SWMgr();
       }
! 	installConf = new SWConfig("./InstallMgr.conf");
  	localMgr = 0;
  }
--- 81,85 ----
             manager = new SWMgr();
       }
! 	installMgr = new InstallMgrWin("./installMgr");
  	localMgr = 0;
  }
***************
*** 55,61 ****
  {
  	delete manager;
- 	delete installConf;
  	if (localMgr)
  		delete localMgr;
  }
  
--- 89,95 ----
  {
  	delete manager;
  	if (localMgr)
  		delete localMgr;
+ 	delete installMgr;
  }
  
***************
*** 70,81 ****
  
  	fillInstallTree();
! 	fillSourceTree(getLocalDir(), localTree);
  }
  
  
  void TMainForm::refreshPageControl() {
! 	SectionMap::iterator sources;
! 	ConfigEntMap::iterator sourceBegin;
! 	ConfigEntMap::iterator sourceEnd;
  
  	while (PageControl1->PageCount > 1) {
--- 104,113 ----
  
  	fillInstallTree();
! 	fillSourceTree(localTree);
  }
  
  
  void TMainForm::refreshPageControl() {
! 	InstallSourceMap::iterator source;
  
  	while (PageControl1->PageCount > 1) {
***************
*** 83,100 ****
  	}
  	
! 	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++;
! 			}
! 		}
  	}
  }
--- 115,122 ----
  	}
  	
! 	for (source = installMgr->sources.begin(); source != installMgr->sources.end(); source++) {
! 		InstallSourceTab *ist = new InstallSourceTab(this, source->second);
! 		source->second->userData = (void *)ist;
! 		addSource(ist);
  	}
  }
***************
*** 110,115 ****
  	SectionMap::iterator sit;
  	
! 	newtab->Caption = ist->is.caption.c_str();
! 	newtab->Hint = ist->is.source.c_str();
  	newtab->ShowHint = true;
  	newtab->PageControl = PageControl1;
--- 132,137 ----
  	SectionMap::iterator sit;
  	
! 	newtab->Caption = ist->is->caption.c_str();
! 	newtab->Hint = ist->is->source.c_str();
  	newtab->ShowHint = true;
  	newtab->PageControl = PageControl1;
***************
*** 133,151 ****
  	newtree->Images = ImageList1;
  	newtree->StateImages = ImageList2;
! 	SWBuf parent = (SWBuf)"./sources/" + ist->is.source + "/file";
! 	FileMgr::createParent(parent.c_str());
! 	parent = (SWBuf)"./sources/" + ist->is.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();
--- 155,169 ----
  	newtree->Images = ImageList1;
  	newtree->StateImages = ImageList2;
! 	fillSourceTree(newtree, ist->is);
  }
  
  
! const char *TMainForm::getLocalDir() {
  	ConfigEntMap::iterator entry;
  
! 	entry = installMgr->installConf->Sections["Sources"].find("LocalPath");
! 	if (entry == installMgr->installConf->Sections["Sources"].end()) {
! 		installMgr->installConf->Sections["Sources"].insert(ConfigEntMap::value_type("LocalPath", "d:/sword"));
! 		entry = installMgr->installConf->Sections["Sources"].find("LocalPath");
  	}
  	return entry->second.c_str();
***************
*** 154,160 ****
  
  
! void TMainForm::setLocalDir(const char *idir)
! {
! 	installConf->Sections["Sources"].erase("LocalPath"); installConf->Sections["Sources"].insert(ConfigEntMap::value_type("LocalPath", idir));
  }
  
--- 172,177 ----
  
  
! void TMainForm::setLocalDir(const char *idir) {
! 	(*(installMgr->installConf))["Sources"]["LocalPath"] = idir;
  }
  
***************
*** 163,193 ****
  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);
  }
  //---------------------------------------------------------------------------
--- 180,191 ----
  void __fastcall TMainForm::LocalPath1Click(TObject *Sender)
  {
! 	AnsiString Dir = "C:";
! 	WideString Root = getLocalDir();
! 	SelectDirectory("Select Local Path", Root , Dir);
  
! 	setLocalDir(Dir.c_str());
  
! 	installMgr->installConf->Save();
! 	fillSourceTree(localTree);
  }
  //---------------------------------------------------------------------------
***************
*** 229,234 ****
  
  
! void TMainForm::fillSourceTree(const char *sourceConf, TTreeView *tree)
! {
  	ModMap::iterator mods;
  	TTreeNode *node;
--- 227,231 ----
  
  
! void TMainForm::fillSourceTree(TTreeView *tree, InstallSource *is) {
  	ModMap::iterator mods;
  	TTreeNode *node;
***************
*** 248,258 ****
  		if (localMgr)
  			delete localMgr;
! 		mgr = localMgr = new SWMgr(sourceConf);
  	}
  	else {
  		InstallSourceTab *ist = (InstallSourceTab *) tree->Parent->Controls[0];
! 		if (ist->is.mgr)
! 			delete ist->is.mgr;
! 		mgr = ist->is.mgr = new SWMgr(sourceConf);
  	}
  	
--- 245,255 ----
  		if (localMgr)
  			delete localMgr;
! 		mgr = localMgr = new SWMgr(getLocalDir());
  	}
  	else {
  		InstallSourceTab *ist = (InstallSourceTab *) tree->Parent->Controls[0];
! 		if (ist->is->mgr)
! 			delete ist->is->mgr;
! 		mgr = ist->is->mgr = new SWMgr(is->localShadow.c_str());
  	}
  	
***************
*** 421,438 ****
  //---------------------------------------------------------------------------
  
- int TMainForm::removeModule(const char *modName)
- {
- 	return sword::removeModule(manager, modName);
- }
- 
- 
  
  void	TMainForm::fillAllSourceTrees()
  {
! 	fillSourceTree(getLocalDir(), localTree);
  	for (int i = 1; i < PageControl1->PageCount; i++) {
  		InstallSourceTab *ist = (InstallSourceTab *) MainForm->PageControl1->Pages[i]->Controls[0];
! 		SWBuf parent = (SWBuf)"./sources/" + ist->is.source;
! 		fillSourceTree(parent.c_str(), ist->tree);
  	}
  }
--- 418,428 ----
  //---------------------------------------------------------------------------
  
  
  void	TMainForm::fillAllSourceTrees()
  {
! 	fillSourceTree(localTree);
  	for (int i = 1; i < PageControl1->PageCount; i++) {
  		InstallSourceTab *ist = (InstallSourceTab *) MainForm->PageControl1->Pages[i]->Controls[0];
! 		fillSourceTree(ist->tree, ist->is);
  	}
  }
***************
*** 444,448 ****
  	if (node) {
  		if (node->Parent) {
! 			removeModule((const char *)node->Data);
  			delete manager;
  			manager = new SWMgr();
--- 434,438 ----
  	if (node) {
  		if (node->Parent) {
! 			installMgr->removeModule(manager, (const char *)node->Data);
  			delete manager;
  			manager = new SWMgr();
***************
*** 493,497 ****
  			CipherForm->cipherEdit->Text = "";
  			if ((node->ImageIndex == 2) || (node->ImageIndex == 4)) {	// if this is an upgrade
! 				removeModule((const char *)node->Data);
  			}
  				// install module
--- 483,487 ----
  			CipherForm->cipherEdit->Text = "";
  			if ((node->ImageIndex == 2) || (node->ImageIndex == 4)) {	// if this is an upgrade
! 				installMgr->removeModule(manager, (const char *)node->Data);
  			}
  				// install module
***************
*** 499,504 ****
  			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;
--- 489,494 ----
  			statusBar->Repaint();
  			if (tree == localTree)
! 				abort = installMgr->installModule(manager, getLocalDir(), (const char *)node->Data, 0);
! 			else	abort = installMgr->installModule(manager, 0, (const char *)node->Data, ((InstallSourceTab *) PageControl1->ActivePage->Controls[0])->is);
  			if (abort)
  				break;
***************
*** 515,533 ****
  
  
- 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)
  {
--- 505,508 ----
***************
*** 538,543 ****
  	SWBuf modDir;
  	SWBuf modFile;
! 	SWBuf root = "./sources/";
! 	root += ist->is.source.c_str();
  	SWBuf target = root + "/mods.d";
  
--- 513,518 ----
  	SWBuf modDir;
  	SWBuf modFile;
! 	SWBuf root = "./installMgr/";
! 	root += ist->is->source.c_str();
  	SWBuf target = root + "/mods.d";
  
***************
*** 556,571 ****
  
  
!     	SWBuf 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->is.source.c_str();
  
! 	fillSourceTree(target.c_str(), ist->tree);	
  }
  
--- 531,543 ----
  
  
! 	SWBuf archive = root + "/mods.d.tar.gz";
! 	if (!installMgr->FTPCopy(ist->is, "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	installMgr->FTPCopy(ist->is, "mods.d", target.c_str(), true, ".conf");
  
! 	fillSourceTree(ist->tree, ist->is);	
  }
  
***************
*** 580,586 ****
  	InfoForm->ShowModal();
  	if (RemoteMntForm->ShowModal() == mrOk) {
! 		delete installConf;
! 		installConf = new SWConfig("./InstallMgr.conf");
! 	
  		refreshPageControl();
  	}
--- 552,557 ----
  	InfoForm->ShowModal();
  	if (RemoteMntForm->ShowModal() == mrOk) {
! 		delete installMgr;
! 		installMgr = new InstallMgrWin("./installMgr");
  		refreshPageControl();
  	}
***************
*** 605,609 ****
  		if (node->Parent) {
  			if (ist)
! 				sourceDir = (SWBuf)"./sources/" + ist->is.source;
  			else	sourceDir = getLocalDir();
  			SWMgr *mgr = new SWMgr(sourceDir.c_str());
--- 576,580 ----
  		if (node->Parent) {
  			if (ist)
! 				sourceDir = (SWBuf)"./installMgr/" + ist->is->source;
  			else	sourceDir = getLocalDir();
  			SWMgr *mgr = new SWMgr(sourceDir.c_str());
***************
*** 691,695 ****
  		UninstallForm->Label1->Caption = label.c_str();
  		UninstallForm->Label1->Repaint();
! 		removeModule(it->second->Name());
  		UninstallForm->ProgressBar1->Position = UninstallForm->ProgressBar1->Position + 1;
  		UninstallForm->ProgressBar1->Repaint();
--- 662,666 ----
  		UninstallForm->Label1->Caption = label.c_str();
  		UninstallForm->Label1->Repaint();
! 		installMgr->removeModule(mgr, it->second->Name());
  		UninstallForm->ProgressBar1->Position = UninstallForm->ProgressBar1->Position + 1;
  		UninstallForm->ProgressBar1->Repaint();

Index: MainFrm.h
===================================================================
RCS file: /usr/local/cvsroot/sword/apps/windoze/CBuilder5/InstallMgr/MainFrm.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** MainFrm.h	27 Jun 2003 01:41:06 -0000	1.8
--- MainFrm.h	7 Jul 2003 00:25:59 -0000	1.9
***************
*** 28,37 ****
  class InstallSourceTab : public TControl {
  public:
! 	__fastcall InstallSourceTab(TComponent *Owner, const char *confEnt, const char *type);
  	__fastcall ~InstallSourceTab();
! 	InstallSource is;
  	TTreeView *tree;
  };
  
  
  //---------------------------------------------------------------------------
--- 28,44 ----
  class InstallSourceTab : public TControl {
  public:
! 	__fastcall InstallSourceTab(TComponent *Owner, InstallSource *is);
  	__fastcall ~InstallSourceTab();
! 	InstallSource *is;
  	TTreeView *tree;
  };
  
+ 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);
+ };
  
  //---------------------------------------------------------------------------
***************
*** 102,106 ****
  
  	SWMgr *manager;
- 	SWConfig *installConf;
  	const char *getLocalDir();
  	void setLocalDir(const char *idir);
--- 109,112 ----
***************
*** 115,125 ****
  	void __fastcall RefreshRemoteSource(TObject *Sender);
  	int selectAll(TTreeView *tree, bool sel);
- 	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);
  };
  
--- 121,130 ----
  	void __fastcall RefreshRemoteSource(TObject *Sender);
  	int selectAll(TTreeView *tree, bool sel);
  	SWMgr *localMgr;
! 	InstallMgrWin *installMgr;
  
  protected:
  	virtual void fillInstallTree();
! 	virtual void fillSourceTree(TTreeView *tree, InstallSource *is = 0);
  };
  

Index: StatusFrm.cpp
===================================================================
RCS file: /usr/local/cvsroot/sword/apps/windoze/CBuilder5/InstallMgr/StatusFrm.cpp,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** StatusFrm.cpp	27 Jun 2003 01:41:06 -0000	1.16
--- StatusFrm.cpp	7 Jul 2003 00:25:59 -0000	1.17
***************
*** 22,47 ****
  
  
- void status_callback(double dltotal, double dlnow) {
- 	int filePercent  = (int)((float)(dlnow + 1) / (float)(dltotal) * 100);
- 	int totalPercent = (int)((float)(dlnow + StatusForm->completedBytes + 1) / (float)(StatusForm->totalBytes) * 100);
- 	StatusForm->statusBar->Caption = ::IntToStr((long)dlnow) + " bytes out of " + ::IntToStr((long)dltotal) + " transferred (file: " + IntToStr(filePercent) + "% / total: " + IntToStr(totalPercent) + "%)";
- 	StatusForm->fileProgress->Position = filePercent;
- 	StatusForm->totalProgress->Position = totalPercent;
- 	
- 	StatusForm->statusBar->Repaint();
- }
- 
- 
  //---------------------------------------------------------------------------
  __fastcall TStatusForm::TStatusForm(TComponent* Owner)
  		: TForm(Owner) {
  	suffix = "";
- 	passive = false;
- 	ftpCon = new TFTPCon();
  }
  
  
  __fastcall TStatusForm::~TStatusForm() {
- 	delete ftpCon;
  }
  
--- 22,33 ----
***************
*** 50,63 ****
  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;
--- 36,48 ----
  void __fastcall TStatusForm::FormShow(TObject *Sender)
  {
! 	ftpThread = new TFTPThread(is, src.c_str(), dest.c_str(), dirTransfer, true, suffix.c_str());
  	ftpThread->OnTerminate = Cleanup;
  	ftpThread->Resume();
  }
  //---------------------------------------------------------------------------
! __fastcall TStatusForm::TFTPThread::TFTPThread(InstallSource *iis, const char *isrc, const char *idest, bool idirTransfer, bool CreateSuspended, const char *isuffix)
  	: TThread(CreateSuspended)
  {
! 	is = iis;
  	src = isrc;
  	dest = idest;
***************
*** 65,69 ****
  	dirTransfer = idirTransfer;
  	Priority = tpNormal;
- 	passive = ipassive;
  	FreeOnTerminate = true;
  	Synchronize((TThreadMethod)&CreateFTPObject);
--- 50,53 ----
***************
*** 75,174 ****
  
  
! void __fastcall TStatusForm::TFTPThread::Execute()
! {
! 	void *session = FTPOpenSession();
  
  	Synchronize((TThreadMethod)&PreConnect);
- 	StatusForm->ftpCon->Host = ist->is.source.c_str();
- 	StatusForm->ftpCon->Username = "ftp";
- 	StatusForm->ftpCon->Password = "installmgr@user.com";
- 	StatusForm->ftpCon->Passive = passive;
  
! 	
! /*
! 	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
! 	}
! */
! 	SWBuf url = (SWBuf)"ftp://" + ist->is.source + ist->is.directory.c_str() + "/"; //dont forget the final slash
! 	if (FTPURLGetFile(session, "dirlist", url.c_str())) {
! 		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());
! 
! 
! 	SWBuf url = (SWBuf)"ftp://" + ist->is.source + ist->is.directory.c_str() + "/" + src + "/"; //dont forget the final slash
! 	vector<struct ftpparse> dirList = FTPURLGetDir(session, url.c_str(), passive);
  
! 	if (!dirList.size()) {
  		MessageBox(0, "Can't connect.  Please check your configuration.", "Connection Error", MB_OK);
  		StatusForm->Button1Click(0);	// abort thread
  	}
! 					
! //			StatusForm->ftpCon->List(dirText, "*", true);
! //			TIdFTPListItems *dirList = StatusForm->ftpCon->DirectoryListing;
! 			StatusForm->totalBytes = 0;
! 			for (int i = 0; i < dirList.size(); i++)
! 				StatusForm->totalBytes += dirList[i].size;
! 			StatusForm->completedBytes = 0;
! 			for (int i = 0; i < dirList.size(); i++) {
! 				if (dirList[i].flagtrycwd != 1) {
! 					buffer = dest + "/" + (dirList[i].name);
! //                           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.size()).c_str();
! 						buffer2 += "): ";
! 						buffer2 += (dirList[i].name);
! 		//				SWLog::systemlog->LogInformation("%s", buffer.c_str());
! 						FileMgr::createParent(buffer.c_str());	// make sure parent directory exists
! 						Synchronize((TThreadMethod)&PreDownload1);
! 						try {
! //							StatusForm->ftpCon->Get(dirList->Items[i]->FileName.c_str(), buffer.c_str(), true, false);
! 
! 							SWBuf url = (SWBuf)"ftp://" + ist->is.source + ist->is.directory.c_str() + "/" + src + "/" + dirList[i].name; //dont forget the final slash
! 
! 							if (FTPURLGetFile(session, buffer.c_str(), url.c_str(), passive, status_callback)) {
! 								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
! 							}
! 							StatusForm->completedBytes += dirList[i].size;
! 						}
! 						catch (...) {}
! 						if (Terminated)
! 							break;
! 					}
! 				}
! 			}
! 		}
! 		else {
! 			Synchronize((TThreadMethod)&PreDownload2);
! 			try {
! //				StatusForm->ftpCon->Get(src.c_str(), dest.c_str(), true, false);
! 				SWBuf url = (SWBuf)"ftp://" + ist->is.source + ist->is.directory.c_str() + "/" + src.c_str(); //dont forget the final slash
! 				if (FTPURLGetFile(session, dest.c_str(), url.c_str(), status_callback)) {
! 					MessageBox(0, "Can't connect.  Please check your configuration.", "Connection Error", MB_OK);
! 					StatusForm->Button1Click(0);	// abort thread
! 				}
! 			}
! 			catch(...) {StatusForm->abort = true;}
! 		}
! 		try {
! //			StatusForm->ftpCon->Disconnect();
! 			FTPCloseSession(session);
! 		}
! 		catch(...){}
  	}
  }
  
--- 59,78 ----
  
  
! void __fastcall TStatusForm::TFTPThread::Execute() {
  
  	Synchronize((TThreadMethod)&PreConnect);
  
! 	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);
  		StatusForm->Button1Click(0);	// abort thread
  	}
! //	Synchronize((TThreadMethod)&PreDownload1);
! 	if (status == -2) {
! 		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
  	}
+ //	Synchronize((TThreadMethod)&PreDownload2);
  }
  
***************
*** 193,200 ****
  void __fastcall TStatusForm::TFTPThread::PreConnect(void)
  {
! 	buffer = "Connecting to server at ";
! 	buffer += ist->is.source.c_str();
! 	buffer += "...";
! 	StatusForm->actionBar->Caption = buffer.c_str();
  	StatusForm->statusBar->Caption = "";
  	StatusForm->Repaint();
--- 97,104 ----
  void __fastcall TStatusForm::TFTPThread::PreConnect(void)
  {
! 	StatusForm->buffer = "Connecting to server at ";
! 	StatusForm->buffer += is->source.c_str();
! 	StatusForm->buffer += "...";
! 	StatusForm->actionBar->Caption = StatusForm->buffer.c_str();
  	StatusForm->statusBar->Caption = "";
  	StatusForm->Repaint();
***************
*** 202,212 ****
  
  
! 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();
  }
  
--- 106,115 ----
  
  
! void __fastcall TStatusForm::PreDownload1(void) {
  //	SWLog::systemlog->LogInformation("Creating parent dir: %s", buffer.c_str());
  //	SWLog::systemlog->LogInformation("Return: %d", ret);
! 	actionBar->Caption = StatusForm->buffer2.c_str();
! 	statusBar->Caption = "";
! 	Repaint();
  }
  
***************
*** 214,220 ****
  void __fastcall TStatusForm::TFTPThread::PreDownload2(void)
  {
! 	buffer = "Downloading: ";
! 	buffer += src.c_str();
! 	StatusForm->actionBar->Caption = buffer.c_str();
  	StatusForm->statusBar->Caption = "";
  	StatusForm->Repaint();
--- 117,123 ----
  void __fastcall TStatusForm::TFTPThread::PreDownload2(void)
  {
! 	StatusForm->buffer = "Downloading: ";
! 	StatusForm->buffer += src.c_str();
! 	StatusForm->actionBar->Caption = StatusForm->buffer.c_str();
  	StatusForm->statusBar->Caption = "";
  	StatusForm->Repaint();
***************
*** 226,230 ****
  //void __fastcall TStatusForm::TFTPThread::Cleanup()
  {
! 	if (abort)
  		StatusForm->ModalResult = mrCancel;
  	else	StatusForm->ModalResult = mrOk;
--- 129,133 ----
  //void __fastcall TStatusForm::TFTPThread::Cleanup()
  {
! 	if (MainForm->installMgr->terminate)
  		StatusForm->ModalResult = mrCancel;
  	else	StatusForm->ModalResult = mrOk;
***************
*** 241,246 ****
  void __fastcall TStatusForm::Button1Click(TObject *Sender)
  {
! 	abort = true;
! //	ftpCon->Abort();
  	ftpThread->Terminate();
  }
--- 144,148 ----
  void __fastcall TStatusForm::Button1Click(TObject *Sender)
  {
! 	MainForm->installMgr->terminate = true;
  	ftpThread->Terminate();
  }

Index: StatusFrm.h
===================================================================
RCS file: /usr/local/cvsroot/sword/apps/windoze/CBuilder5/InstallMgr/StatusFrm.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** StatusFrm.h	27 Jun 2003 01:41:06 -0000	1.10
--- StatusFrm.h	7 Jul 2003 00:25:59 -0000	1.11
***************
*** 18,33 ****
  //---------------------------------------------------------------------------
  
! class TFTPCon {
! public:
! 	SWBuf Host;
! 	SWBuf Username;
! 	SWBuf Password;
! 	bool Passive;
! 	SWBuf cwd;
! 	
! };
! 
! class TStatusForm : public TForm
! {
  __published:	// IDE-managed Components
  	TPanel *Panel1;
--- 18,22 ----
  //---------------------------------------------------------------------------
  
! class TStatusForm : public TForm {
  __published:	// IDE-managed Components
  	TPanel *Panel1;
***************
*** 49,86 ****
  private:	// User declarations
  	class TFTPThread : public TThread {
! 		bool abort;
! 		InstallSourceTab *ist;
  		SWBuf src;
  		SWBuf dest;
- 		SWBuf buffer;
- 		SWBuf buffer2;
  		SWBuf 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 completedBytes;
  	long totalBytes;
! 	InstallSourceTab *ist;
  	SWBuf src;
  	SWBuf dest;
  	SWBuf suffix;
  	bool dirTransfer;
! 	bool passive;
! 	bool abort;
! 		void __fastcall UpdateBytes();
  	__fastcall TStatusForm(TComponent* Owner);
  	__fastcall ~TStatusForm();
--- 38,70 ----
  private:	// User declarations
  	class TFTPThread : public TThread {
! 		InstallSource *is;
  		SWBuf src;
  		SWBuf dest;
  		SWBuf suffix;
  		bool dirTransfer;
  	protected:
  		void __fastcall Execute();
  	public:
  //		TNMFTP *FTPLink;
! 		__fastcall TFTPThread(InstallSource *iis, const char *isrc, const char *idest, bool idirTransfer = false, bool CreateSuspended = false, const char *suffix = "");
  		__fastcall TFTPThread::~TFTPThread();
  		void __fastcall FTPLinkPacketRecvd(TObject *Sender);
  		void __fastcall CreateFTPObject(void);
  		void __fastcall PreConnect(void);
  		void __fastcall PreDownload2(void);
  //		void __fastcall Cleanup(void);
  	} *ftpThread;
  public:		// User declarations
! 	void __fastcall PreDownload1(void);
  	long completedBytes;
  	long totalBytes;
! 	InstallSource *is;
  	SWBuf src;
  	SWBuf dest;
  	SWBuf suffix;
+ 	SWBuf buffer;
+ 	SWBuf buffer2;
  	bool dirTransfer;
! 	void __fastcall UpdateBytes();
  	__fastcall TStatusForm(TComponent* Owner);
  	__fastcall ~TStatusForm();