// FtpClientDlg.h : header file
//

#pragma once
#include "afxcmn.h"
#include "afxwin.h"

#include "..\..\..\..\Source\Bluetooth\wclBluetooth.h"
#include "..\..\..\..\Source\Communication\wclObex.h"

using namespace wclCommon;
using namespace wclCommunication;
using namespace wclBluetooth;

// CFtpClientDlg dialog
class CFtpClientDlg : public CDialog
{
// Construction
public:
	CFtpClientDlg(CWnd* pParent = NULL);	// standard constructor

// Dialog Data
	enum { IDD = IDD_FTPCLIENT_DIALOG };

	protected:
	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV support


// Implementation
protected:
	HICON m_hIcon;

	// Generated message map functions
	virtual BOOL OnInitDialog();
	afx_msg void OnPaint();
	afx_msg HCURSOR OnQueryDragIcon();
	DECLARE_MESSAGE_MAP()

private:
	CListCtrl lvDevices;
	CEdit edFileName;
	CProgressCtrl ProgressBar;
	CEdit edNewDirName;
	CListCtrl lvFiles;
	CListBox lbLog;

private:
	CwclBluetoothManager wclBluetoothManager;
	CwclRfCommClient wclRfCommClient;
	CwclObexFtpClient* FFtp;

	void ManagerAfterOpen(void* Sender);
	void ManagerAuthenticationCompleted(void* Sender, CwclBluetoothRadio* const Radio, const __int64 Address,
		const int Error);
	void ManagerDiscoveringCompleted(void* Sender, CwclBluetoothRadio* const Radio, const int Error);
	void ManagerDiscoveringStarted(void* Sender, CwclBluetoothRadio* const Radio);
	void ManagerNumericComparison(void* Sender, CwclBluetoothRadio* const Radio, const __int64 Address,
		const unsigned long Number, bool& Confirm);
	void ManagerPasskeyNotification(void* Sender, CwclBluetoothRadio* const Radio,
		const __int64 Address, const unsigned long Passkey);
	void ManagerPasskeyRequest(void* Sender, CwclBluetoothRadio* const Radio, const __int64 Address,
		unsigned long& Passkey);
	void ManagerPinRequest(void* Sender, CwclBluetoothRadio* const Radio, const __int64 Address,
		tstring& Pin);
	void ManagerDeviceFound(void* Sender, CwclBluetoothRadio* const Radio, const __int64 Address);

	void ClientDisconnect(void* Sender, const int Reason);
	void ClientConnect(void* Sender, const int Error);
	void ClientDestroyProcessor(void* Sender, CwclClientDataConnection* const Connection);
	void ClientCreateProcessor(void* Sender, CwclClientDataConnection* const Connection);

	void FtpConnect(void* Sender, int Error, const tstring& Description);
	void FtpDisconnect(void* Sender, int Error, const tstring& Description);
	void FtpPutComplete(void* Sender, int Error, const tstring& Description, CwclStream* const Stream);
	void FtpProgress(void* Sender, const unsigned long Size, const unsigned long Position);
	void FtpGetComplete(void* Sender, const int Error, const tstring& Description, CwclStream* const Stream);
	void FtpDirComplete(void* Sender, const int Error, const tstring& Description, const wclObexFileObjects& Dirs);
	void FtpChangeDirComplete(void* Sender, const int Error, const tstring& Description);
	void FtpDeleteComplete(void* Sender, const int Error, const tstring& Description);
	void FtpMakeDirComplete(void* Sender, const int Error, const tstring& Description);

	CwclBluetoothRadio* GetRadio() const;

public:
	afx_msg void OnBnClickedButtonClear();
	afx_msg void OnDestroy();
	afx_msg void OnBnClickedButtonDiscover();
	afx_msg void OnBnClickedButtonDisconnect();
	afx_msg void OnBnClickedButtonCloseSession();
	afx_msg void OnBnClickedButtonOpenSession();
	afx_msg void OnBnClickedButtonConnect();
	afx_msg void OnBnClickedButtonSelectFile();
	afx_msg void OnBnClickedButtonAbort();
	afx_msg void OnBnClickedButtonSendFile();
	afx_msg void OnBnClickedButtonDir();
	afx_msg void OnNMDblclkListFiles(NMHDR *pNMHDR, LRESULT *pResult);
	afx_msg void OnBnClickedButtonRoot();
	afx_msg void OnBnClickedButtonDelete();
	afx_msg void OnBnClickedButtonMkDir();
};
