Page 227 - PDA Robotics Using Your Personal Digital Assistant to Control Your Robot
P. 227
PDA 10 5/27/03 8:51 AM Page 203
Chapter 10 / The PDA Robotics Command Center
{
// clean up any objects that are still lying around
if (m_pFtpConnection != NULL)
{
m_pFtpConnection->Close();
delete m_pFtpConnection;
}
if (m_pInetSession != NULL)
{
m_pInetSession->Close();
delete m_pInetSession;
}
}
// Update our file
BOOL CFtp::UpdateFtpFile(CString host, CString user, CString password, CString
remote_path, CString filename, CString remote_filename, CString& status_msg)
{
CString strFtpSite;
CString strServerName;
CString strObject;
INTERNET_PORT nPort;
DWORD dwServiceType;
if (!AfxParseURL(ftp_host, dwServiceType, strServerName, strObject, nPort))
{
// try adding the "ftp://" protocol
CString strFtpURL = _T("ftp://");
strFtpURL += host;
if (!AfxParseURL(strFtpURL, dwServiceType, strServerName, strObject, nPort))
{
// AfxMessageBox(IDS_INVALID_URL, MB_OK);
// m_FtpTreeCtl.PopulateTree();
status_msg = "Bad URL, please check host name";
return(FALSE);
}
}
// If the user has provided all the information in the
// host line then dwServiceType, strServerName, strObject, nPort will
// be filled in.. but since I've provided edit boxes for each we will use these.
// Now open an FTP connection to the server
if ((dwServiceType == INTERNET_SERVICE_FTP) && !strServerName.IsEmpty())
{
try
{
203