#pragma once
|
|
#include "FTPUploadParam.h"
|
#include "TimerThreadPools.h"
|
#include <afxinet.h>
|
#include <deque>
|
|
#define MAX_BUFFER_COUNT 100
|
|
enum EnumFTPNotify
|
{
|
eFTPConnection = 0,
|
eFTPDisConnection,
|
eFTPConnectionFail,
|
eFTPFileUploadSuccess,
|
eFTPFileUploadFail,
|
eFTPFileDownloadSuccess,
|
eFTPFileDownloadFail,
|
eFTPError
|
};
|
|
enum FTPThreadType { FTPThreadType_Download=0, FTPThreadType_Upload, FTPThreadType_Count };
|
|
typedef std::deque<CFTPUploadParam> DeqFTPUploadParam;
|
typedef std::deque<CFTPUploadParam>::iterator DeqFTPUploadParamIt;
|
typedef std::deque<CFTPUploadParam>::const_iterator constDeqFTPUploadParamIt;
|
|
interface IFTPThreadPool2Parent
|
{
|
virtual void IFTP2P_DisplayLogMessage(int nType, int nLogIndex) = 0;
|
virtual void IFTP2P_DisplayNotifyMessage(int nType, int nNotifyType, int nLogIndex) = 0;
|
};
|
|
class CFTPThreadPool : public CTimerThreadPools
|
{
|
public:
|
CFTPThreadPool(int nType, DWORD dwPeriod=100);
|
virtual ~CFTPThreadPool(void);
|
|
virtual BOOL StartThread();
|
virtual void StopThread();
|
|
// process
|
BOOL AddUploadParam(const CFTPUploadParam& uploadParam);
|
|
// setter
|
void SetConnectionTimeout(int nTimeout);
|
void SetConnectionInfo(CString strIP, CString strUserID, CString strPassword, int nPort, int nTimeout, CString strHomePath, CString strIP2, CString strUserID2, CString strPassword2, int nPort2, int nTimeout2, CString strHomePath2, CString strIP3, CString strUserID3, CString strPassword3, int nPort3, int nTimeout3, CString strHomePath3, BOOL bPassive, BOOL WSIChk);
|
void SetIFTP2P(IFTPThreadPool2Parent *pIFTP2P) { m_pIFTP2P = pIFTP2P; }
|
|
// getter
|
const CString* GetLogBuffer(int nIndex);
|
int GetUploadListCount() { return (int)m_deqUploadList.size(); }
|
const CFTPUploadParam* GetUploadList(int nIdx);
|
void GetUploadListCountInfo( UINT& nReadyCount, UINT& nProcessCount, UINT& nCompletCount, UINT& nTotalCount );
|
void GetUploadList(DeqFTPUploadParam& deqUploadParam);
|
|
protected:
|
virtual void TimerThreadProcess(PVOID pParameter);
|
BOOL Process_Upload(CFTPUploadParam& uploadParam);
|
BOOL Process_Download(CFTPUploadParam& downloadParam);
|
BOOL Process_UploadAck(int nResultCode, const CFTPUploadParam& uploadParam);
|
BOOL Process_DownloadAck(int nResultCode, const CFTPUploadParam& uploadParam);
|
|
void DisplayLogMessage(const CString& strMessage);
|
void DisplayResultMessage(BOOL bResult, const CString& strServer, const CString& strLocal);
|
void DisplaynNotifyTypeMessage(int nNotifyType, const CString& strMessage);
|
CString GetInternetErrorCodeToString( DWORD dwErrorCode );
|
void NotifyMessage( int nNotifyType, const CString& strUploadPath, const CString& strLocalPath, BOOL bSendErrorCode );
|
|
|
BOOL ConnectMain();
|
BOOL Connect();
|
BOOL Disconnect();
|
BOOL ChangeDirectory(const CString& strPath, BOOL bCreate=FALSE);
|
BOOL Upload(const CFTPUploadParam& Param);
|
BOOL Upload_Signal(const CFTPUploadParam& Param);
|
BOOL Download(const CFTPUploadParam& Param);
|
|
static BOOL CreatePathDir(const CString& strFilename=_T(""))
|
{
|
CString csPrefix(_T("")), csToken(_T(""));
|
int nStart = 0, nEnd;
|
CFileFind filefinder;
|
CString strDirPath = strFilename;
|
BOOL bResult = FALSE;
|
while( (nEnd = strFilename.Find('\\', nStart)) >= 0)
|
{
|
csToken = strFilename.Mid(nStart, nEnd-nStart);
|
CreateDirectory(csPrefix + csToken, NULL);
|
|
csPrefix += csToken;
|
csPrefix += _T("\\");
|
nStart = nEnd+1;
|
}
|
strDirPath = strDirPath.Left(strDirPath.ReverseFind('\\'));
|
bResult = filefinder.FindFile(strDirPath,NULL);
|
|
return bResult;
|
}
|
|
|
protected:
|
int m_nType;
|
IFTPThreadPool2Parent* m_pIFTP2P;
|
|
BOOL m_bConnect;
|
|
CFtpFileFind* m_pFileFind;
|
CFtpConnection* m_pConnection;
|
CInternetSession* m_pSession;
|
|
CString m_strIP;
|
CString m_strID;
|
CString m_strPassword;
|
int m_nPort;
|
BOOL m_bPassive;
|
int m_nConnectionTimeout;
|
|
// [C-PRJ] Image Upload Define - KHT (2020/11/19)
|
CString m_strIP2;
|
CString m_strID2;
|
CString m_strPassword2;
|
int m_nPort2;
|
int m_nConnectionTimeout2;
|
CString m_strDefaultFolderPath2;
|
|
//201218 CJH - Download¿ë IP Ãß°¡
|
CString m_strIP3;
|
CString m_strID3;
|
CString m_strPassword3;
|
int m_nPort3;
|
int m_nConnectionTimeout3;
|
CString m_strDefaultFolderPath3;
|
|
DeqFTPUploadParam m_deqUploadList;
|
CCriticalSection m_csUploadList;
|
CCriticalSection m_csFtpProcess;
|
CCriticalSection m_csLogIndex;
|
|
CString m_strDefaultFolderPath;
|
CString m_strLastErrorMessage;
|
|
int m_nCurLogIndex;
|
CString m_strLogBuffer[MAX_BUFFER_COUNT];
|
|
UINT m_nProcessCount;
|
UINT m_nCompletCount;
|
UINT m_nTotalCount;
|
|
BOOL m_bSharedFolder;
|
BOOL m_bWSIChk;
|
};
|