// GTSimplePhoneDlg.h : header file
//

#if !defined(AFX_GTSIMPLEPHONEDLG_H__2CF5FCAC_3849_4007_8ACF_6C64C73F4717__INCLUDED_)
#define AFX_GTSIMPLEPHONEDLG_H__2CF5FCAC_3849_4007_8ACF_6C64C73F4717__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

/////////////////////////////////////////////////////////////////////////////
// CGTSimplePhoneDlg dialog

#include "GTAPI_Face.h"

#define WM_USER        								0x0400
#define WM_SDKAPP_BASE 								(WM_USER+0x0F00)
#define WM_SDKAPP_OFFERED 							WM_SDKAPP_BASE+1
#define WM_SDKAPP_DIALING 							WM_SDKAPP_BASE+2
#define WM_SDKAPP_RINGING 							WM_SDKAPP_BASE+3
#define WM_SDKAPP_CONNECTED							WM_SDKAPP_BASE+4
#define WM_SDKAPP_IDLE								WM_SDKAPP_BASE+5
#define WM_SDKAPP_REGSTATUS							WM_SDKAPP_BASE+6


struct sdkapp_msg
{
	int eventID;
	int chanID;
	CString args[20];
};

#ifdef USE_GTAPI_NAMESPACE
using namespace GTAPI;
#endif

class CGTSimplePhoneDlg;

class CGTSIPSimplePhoneEnv : public CGTAPIEnv
{
public:
	CGTSIPSimplePhoneEnv();
	virtual ~CGTSIPSimplePhoneEnv();

	virtual bool StartServer();
	virtual bool StopServer();

	virtual void On_RecvConnected(int ch);
	virtual void On_RecvOffered(int ch, const char* sCaller, const char* sCallee, const char* sDestAddr, \
		const char* sViaAddr, const char* sFromIP, unsigned short nFromPort);
	virtual void On_RecvDialing(int ch, const char* sCaller, const char* sCallee);
	virtual void On_RecvIdle(int ch, int code, const char* desc);
	virtual void On_RecvRinging(int ch);
	virtual void On_RecvRegStatus(int user_id, int status, int regtime);

public:
	CGTSimplePhoneDlg*			m_pMainDlg;
};



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

	void On_RecvConnected(int ch);
	void On_RecvOffered(int ch, const char* sCaller, const char* sCallee, const char* sDestAddr, \
		const char* sViaAddr, const char* sFromIP, unsigned short nFromPort);
	void On_RecvDialing(int ch, const char* sCaller, const char* sCallee);
	void On_RecvIdle(int ch, int code, const char* desc);
	void On_RecvRinging(int ch);
	void On_RecvRegStatus(int user_id, int status, int regtime);

	void Log(const char* info);

// Dialog Data
	//{{AFX_DATA(CGTSimplePhoneDlg)
	enum { IDD = IDD_GTSIMPLEPHONE_DIALOG };
	CStatic	m_staticLog;
	CEdit	m_editPhoneNum;
	CButton	m_btnHungup;
	CButton	m_btnDial;
	//}}AFX_DATA

	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CGTSimplePhoneDlg)
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV support
	//}}AFX_VIRTUAL

// Implementation
protected:
	HICON m_hIcon;
	CGTSIPSimplePhoneEnv m_Env;

	// Generated message map functions
	//{{AFX_MSG(CGTSimplePhoneDlg)
	virtual BOOL OnInitDialog();
	afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
	afx_msg void OnPaint();
	afx_msg HCURSOR OnQueryDragIcon();
	afx_msg void OnButton1();
	afx_msg void OnButton2();
	afx_msg void OnButton3();
	afx_msg void OnButton4();
	afx_msg void OnButton5();
	afx_msg void OnButton6();
	afx_msg void OnButton7();
	afx_msg void OnButton8();
	afx_msg void OnButton9();
	afx_msg void OnButtonStar();
	afx_msg void OnButton11();
	afx_msg void OnButtonPound();
	afx_msg void OnButtonDial();
	afx_msg void OnButtonHungup();
	afx_msg void OnDestroy();
	afx_msg void OnButtonTest();
	afx_msg void OnCheckMuteSpeaker();
	afx_msg void OnCheckMuteMic();
	afx_msg LRESULT OnSDKAppMessage(WPARAM wParam, LPARAM lParam);
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_GTSIMPLEPHONEDLG_H__2CF5FCAC_3849_4007_8ACF_6C64C73F4717__INCLUDED_)
