// MainFrm.h : CMainFrame 클래스의 인터페이스
//

#pragma once
#include "WebUtil.h"


#define WMU_UPDATE_CONTROL_STATUS (WM_USER + 1)

enum CLIPBOARD_STATE {
	CBS_NONE = 0,
	CBS_CUT,
	CBS_COPY,
};

typedef struct{
	CString	strName;
	int		nCountFolder;
	int		nCountFile;
	__int64	nSize;
}RFOLDERINFO_STRUCT,*LPRFOLDERINFO_STRUCT;

typedef struct {
	int          nClass;
	bool         bCached;
	CString      sName;
	CStringArray saAttr;
	CPtrArray    paObject;
} RTREEITEM_STRUCT, *PRTREEITEM_STRUCT;

typedef struct {
	bool         bFolder;
	CString      sName;
	__int64      nSize;
	int          iIcon;
	CStringArray saAttr;
} RLISTITEM_STRUCT, *PRLISTITEM_STRUCT;

enum TREENODE_CLASS {
	TNS_ROOT   = 0,
	TNS_VOLUME,
	TNS_FOLDER,
};


enum FOCUS_LOCATION {
	FL_LOCAL,
	FL_REMOTE
};


class CMainFrame : public CXTPFrameWnd
{
public:
	CMainFrame();

protected: 
	DECLARE_DYNAMIC(CMainFrame)

public:
	void ShowLoginDialog();

	void Connect();
	void Disconnect();

	bool ContNextOnError(LPCSTR pszErrMSg);
	int  ConfirmExists(LPCSTR pszName);

	bool MakeRemoteFolder(HTREEITEM hti, CString& sFolder);
	bool Move1RemoteObject(HTREEITEM hti, CString& sSrcPath, CString& sDstPath);
	bool Delete1RemoteObject(HTREEITEM hti, CString& sPath);
	bool Upload(bool bUseSelected = true);
	bool Download(bool bUseSelected = true);
	void CopyRemoteObject(HTREEITEM hti, CStringArray& saSrcPath, CString& sDstPath, CStringArray& saSucceed );
	void MoveRemoteObject(HTREEITEM hti, CStringArray& saSrcPath, CString& sDstPath, CStringArray& saSucceed );
	void DeleteRemoteObject(HTREEITEM hti, CStringArray& saPath, char* bFolder , CStringArray& saSucceed);
	void SaveUrl();
	void UpdateVolumeInfo(HTREEITEM hti);
	void GetFolderInfo(HTREEITEM hti,LPRFOLDERINFO_STRUCT pfolderinfo);

	void BeginWaitMessage(CCmdTarget *pct = NULL);
	void EndWaitMessage(CCmdTarget *pct = NULL);

	void SetFocus(CWnd* pwnd);

	CString GetProxyHost();
	int     GetProxyPort();

private:
	BOOL RestorePlacement();

	void RemoveDragSource(HTREEITEM hti, LPCTSTR pszPath);

	void SaveFileUrl(CString sURI, CStdioFile& file, CString sStag, CString sEtag);

// 특성
public:
	CFont m_font;

	class CRemoteView* m_pRemoteView;
	class CLocalView*  m_pLocalView;

	// 프레임 상태...
	BOOL m_bShowTopToolBar;
	BOOL m_bShowMidToolBar;
	BOOL m_bShowRemoteTree;
	BOOL m_bShowLocalTree;
	int  m_nRemoteListType;
	int  m_nLocalListType;
	BOOL m_bShowRemoteStatus;
	BOOL m_bShowLocalStatus;

	FOCUS_LOCATION m_fl;
	CWnd*          m_pwndRemote;
	CWnd*          m_pwndLocal;

	CLIPBOARD_STATE m_cbs;
	bool            m_bDragFromRemote;
	CStringArray    m_saDragSource;
	CString         m_sDragTarget;
	HTREEITEM       m_htiDragTarget;

	int m_iComputerIcon;
	int m_iNetworkIcon;
	int m_iDriveIcon;
	int m_iFolderIcon;
	int m_iAnonyAuthIcon;

	CBitmap m_bmFolder;
	CBitmap m_bmCopy;
	CBitmap m_bmCut;
	CBitmap m_bmPaste;

	CString m_sUserId;
	CString m_sPassword;

	bool m_bSizing;

	CMapPtrToPtr m_mapHcl;
	CWebUtil m_webutil;

	int m_passwordErrCnt;

private:
	CXTSplitterWnd m_splitter;

	bool m_bInitialzed;

// 재정의
public:
	virtual BOOL PreTranslateMessage(MSG* pMsg);
	virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
	virtual BOOL OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext);

// 구현
public:
	virtual ~CMainFrame();
#ifdef _DEBUG
	virtual void AssertValid() const;
	virtual void Dump(CDumpContext& dc) const;
#endif

// 메시지 맵 함수를 생성했습니다.
public:
	afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
	afx_msg void OnClose();
	afx_msg void OnSize(UINT nType, int cx, int cy);
	afx_msg BOOL OnEraseBkgnd(CDC* pDC);
	afx_msg void OnFileReconnect();
	afx_msg void OnUpdateFileReconnect(CCmdUI *pCmdUI);
	afx_msg void OnFileDisconnect();
	afx_msg void OnUpdateFileDisconnect(CCmdUI *pCmdUI);
	afx_msg void OnFileUpload();
	afx_msg void OnUpdateFileUpload(CCmdUI *pCmdUI);
	afx_msg void OnFileDownload();
	afx_msg void OnUpdateFileDownload(CCmdUI *pCmdUI);
	afx_msg void OnViewRefresh();
	afx_msg void OnViewLtree();
	afx_msg void OnUpdateViewLtree(CCmdUI *pCmdUI);
	afx_msg void OnViewRtree();
	afx_msg void OnUpdateViewRtree(CCmdUI *pCmdUI);
	afx_msg void OnViewLstatus();
	afx_msg void OnUpdateViewLstatus(CCmdUI *pCmdUI);
	afx_msg void OnViewRstatus();
	afx_msg void OnUpdateViewRstatus(CCmdUI *pCmdUI);
	afx_msg void OnViewMidToolbar();
	afx_msg void OnUpdateViewMidToolbar(CCmdUI *pCmdUI);
	afx_msg void OnViewRlistType1();
	afx_msg void OnUpdateViewRlistType1(CCmdUI *pCmdUI);
	afx_msg void OnViewRlistType2();
	afx_msg void OnUpdateViewRlistType2(CCmdUI *pCmdUI);
	afx_msg void OnViewRlistType3();
	afx_msg void OnUpdateViewRlistType3(CCmdUI *pCmdUI);
	afx_msg void OnViewRlistType4();
	afx_msg void OnUpdateViewRlistType4(CCmdUI *pCmdUI);
	afx_msg void OnViewLlistType0();
	afx_msg void OnUpdateViewLlistType0(CCmdUI *pCmdUI);
	afx_msg void OnViewLlistType1();
	afx_msg void OnUpdateViewLlistType1(CCmdUI *pCmdUI);
	afx_msg void OnViewLlistType2();
	afx_msg void OnUpdateViewLlistType2(CCmdUI *pCmdUI);
	afx_msg void OnViewLlistType3();
	afx_msg void OnUpdateViewLlistType3(CCmdUI *pCmdUI);
	afx_msg void OnViewLlistType4();
	afx_msg void OnUpdateViewLlistType4(CCmdUI *pCmdUI);
	afx_msg void OnCfgOverwriteAsk();
	afx_msg void OnUpdateCfgOverwriteAsk(CCmdUI *pCmdUI);
	afx_msg void OnCfgOverwrite1();
	afx_msg void OnUpdateCfgOverwrite1(CCmdUI *pCmdUI);
	afx_msg void OnCfgOverwrite2();
	afx_msg void OnUpdateCfgOverwrite2(CCmdUI *pCmdUI);
	afx_msg void OnCfgOverwrite3();
	afx_msg void OnUpdateCfgOverwrite3(CCmdUI *pCmdUI);
	afx_msg void OnCfgOverwrite4();
	afx_msg void OnUpdateCfgOverwrite4(CCmdUI *pCmdUI);
	afx_msg void OnCfgUpdate();
	afx_msg void OnUpdateCfgUpdate(CCmdUI *pCmdUI);
	afx_msg void OnCfgConfig();

	afx_msg LRESULT OnTransferDlgClose(WPARAM, LPARAM);
	afx_msg LRESULT OnUpdateControlStatus(WPARAM wParam, LPARAM lParam);

	afx_msg BOOL OnCopyData(CWnd* pWnd , COPYDATASTRUCT* pCodyDataStruct);

	int OnCreateControl(LPCREATECONTROLSTRUCT lpCreateControl);
	BOOL GetNewGUID(CString& strGUID);

	DECLARE_MESSAGE_MAP()
protected:
	void opt_file_log(CString , CString , char , char);
};

#define MIN_REMOTE_HEIGHT 100
#define MIN_TREE_WIDTH    90
#define MIN_LIST_WIDTH    150

#define HIGHLIGHT_SIZE     1
#define TOOLBAR_HEIGHT     42
#define TOOLBAR_BTN_HEIGHT 6
#define TOOLBAR_BTN_WIDTH  75
#define CAPTION_HEIGHT     22
#define ADDRESS_WIDTH      35
#define SPLITTER_SIZE      5
#define ADDRESS_BTN_WIDTH  23
#define HEADER_HEIGHT      (HIGHLIGHT_SIZE + CAPTION_HEIGHT)
#define STATUS_HEIGHT      19
#define STATUS_TEXT_HEIGHT 12

#define TIMER_ID_UPDATESTATUS 1
#define TIMER_ID_CHANGEFOLDER 2

#define PASSWORD_ERR_ADMIT_CNT	3
#define PASSWORD_ERR_WAIT_SEC	30
