// OppServerDlg.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;


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

// Dialog Data
	enum { IDD = IDD_OPPSERVER_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 lvClients;
	CListBox lbLogs;

	CwclBluetoothManager wclBluetoothManager;
	CwclRfCommServer wclRfCommServer;

	tstring FFileName;

	void Trace(const CString& Msg);

	void wclRfCommServerListen(void* Sender);
	void wclRfCommServerClosed(void* Sender, const int Reason);
	void wclRfCommServerDisconnect(void* Sender, CwclRfCommServerClientConnection* const Client, const int Reason);
	void wclRfCommServerDestroyProcessor(void* Sender, CwclServerClientDataConnection* const Connection);
	void wclRfCommServerConnect(void* Sender, CwclRfCommServerClientConnection* const Client, const int Error);
	void wclRfCommServerCreateProcessor(void* Sender, CwclServerClientDataConnection* const Connection);
	void wclRfCommServerGetSdpAttributes(void* Sender, wclBluetoothSdpProtocols& Protocols,
		wclBluetoothSdpProfiles& Profiles, wclBluetoothSdpFormats& Formats, unsigned long& Cod);

	void OppClientConnect(void* Sender, const tstring& Description);
	void OppClientDisconnected(void* Sender, const int Reason, const tstring& Description);
	void OppClientPutBegin(void* Sender, const tstring& Name, const tstring& Description, const tstring& Mime,
		const unsigned long Length, bool& Accept);
	void OppClientPutCompleted(void* Sender, const int Error, CwclStream* const Stream, bool& Accept);
	void OppClientPutProgress(void* Sender, const unsigned long Position, const unsigned long Length, bool& Continue);
	void OppClientGetRequest(void* Sender, const tstring& aType, wclObexServerOperationResult& Result,
		CwclStream*& Stream);
	void OppClientGetCompleted(void* Sender, const int Error, CwclStream* const Stream);
	void OppClientProgress(void* Sender, const unsigned long Length, const unsigned long Position);

public:
	afx_msg void OnDestroy();
	afx_msg void OnBnClickedButtonClear();
	afx_msg void OnBnClickedButtonListen();
	afx_msg void OnBnClickedButtonClose();
	afx_msg void OnBnClickedButtonDisconnect();
};
