www.pudn.com > TAPI会议系统.rar > tapiline.h


// ---------------------------------------------------------------------------- 
// IP Office SDK (c) Avaya 2001. All rights reserved. 
// 
// PROJECT:  TapiSample 
// FILE:     tapiline.h 
// CREATED:  Geoff Froud, based on previous work by Carl Muller 
// 
// This header defines the TapiLine and TapiApplication classes. 
// TapiLine encapsulates a TAPI line. 
// TapiApplication contains data & functions for TAPI applications. 
// 
// See tapisample.h for an explanation of this program. 
// 
// This is the definition file for the tapi support classes. 
// See tapiline.cpp for the implementation of these classes 
// 
// ---------------------------------------------------------------------------- 
 
#define LINEDEVSTATE_ALL        0x01FFFFFF 
#define LINEADDRESSSTATE_ALL    0x000001FF 
 
 
class TapiApplication; 
class CTapisampleDlg; 
 
// ---------------------------------------------------------------------------- 
// Keep track of asynchronous replies from TAPI functions 
typedef struct { 
	LPCTSTR Name; // Name of the function that triggered the request 
	HCALL Call;   // Handle of the main call used in the request 
} REQUEST_INFO; 
 
// ---------------------------------------------------------------------------- 
class TapiLine { 
public: 
	TapiLine(TapiApplication &Parent); 
	~TapiLine(); 
	void OnEvent(DWORD Device, DWORD Msg, DWORD Param1, DWORD Param2, DWORD Param3); 
	HRESULT Open(DWORD LineID, DWORD CallPrivilege, DWORD MediaModes); 
 
	// Functions to support telephony commands 
	void MakeCall(LPCTSTR pszAddress); 
	void DropCall(); 
	void AnswerCall(); 
	void HoldCall(); 
	void UnholdCall(); 
	void ConferenceCall(); 
	void BlindTransferCall(LPCTSTR pszAddress); 
	void GetCallStatus(); 
	void SetupTransfer(); 
	void Dial(LPCTSTR pszAddress); 
	void CompleteTransfer(); 
	void SwapHold(); 
	void Park(LPCTSTR pszAddress); 
	void Unpark(LPCTSTR pszAddress); 
	void Redirect(LPCTSTR pszAddress); 
	void AddToConference(); 
	void RemoveFromConference(); 
	void AddressStatus(); 
	void GetCallInfo(); 
	void LogOn(LPCTSTR pszAddress); 
	void LogOff(); 
	void ConfigDialog(); 
	void DivertDestination(LPCTSTR pszAddress); 
	void SetDivertSettings(BOOL FwdAll, BOOL FwdBusy, BOOL FwdNoAnsw, BOOL DND); 
	void GetDivertSettings(); 
	void SetAppSpecific(DWORD num); 
	void SetMsgWaitLamp(DWORD num); 
	void SetInGroup(LPCTSTR pszGroup); 
	void SetOutGroup(LPCTSTR pszGroup); 
	void SetCallData(LPCTSTR pszData); 
 
public: 
	TapiApplication &m_Parent; // My parent object 
	DWORD m_extension; // The IP Office Extension number that relates to this line 
	DWORD m_LineID; // My index according to my parent 
	HLINE m_hLine; // My line handle according to TAPI 
 
	// Call handles 
	HCALL m_hConnectedCall;  // My current call handle according to TAPI (0 if idle) 
	HCALL m_hWaitingCall;    // I am ringing this call (0 if none) 
	HCALL m_hHeldCall;       // My held call handle according to TAPI (0 if nothing on hold) 
	HCALL m_hPendingCall;    // This call is waiting to be answered according to TAPI (0 if none) 
	HCALL m_hConferenceCall; // This is the conference call according to TAPI (0 if none) 
	HCALL m_hConsultationCall; // This is the call created by lineSetupTransfer 
	HCALL m_hLastCallIntoConf; // This is the last call added to a conference 
 
	// Request handles 
	CMap m_Requests; 
 
protected: 
	// Derived classes could override the behaviour when receiving TAPI events 
	virtual void OnReply(LONG RequestID, HRESULT Result); 
	virtual void OnClose(); 
	virtual void OnAddressState(DWORD AddressID, DWORD AddressState); 
	virtual void OnCallInfo(HCALL hCall, DWORD CallInfoState); 
	virtual void OnCallState(HCALL hCall, DWORD CallState, DWORD CallStateDetail, DWORD CallPrivilege); 
	virtual void OnNewCall(DWORD AddressID, HCALL hCall, DWORD CallPrivilege); 
	virtual void OnLineDevState(DWORD DeviceState, DWORD DeviceStateDetail1, DWORD DeviceStateDetail2); 
}; 
 
typedef TapiLine *PTAPILINE; 
 
// ---------------------------------------------------------------------------- 
// This class contains TAPI data and functions that are not specific to a 
// particular TAPI line. 
class TapiApplication 
{ 
public: 
	TapiApplication(CTapisampleDlg& Dlg); 
	~TapiApplication(); 
 
	// TAPI helper functions 
	void CheckError(HRESULT hr, LPCTSTR pszCommand); 
	void InitialiseTAPI(); 
	void ShutdownTAPI(); 
	void OpenValidLines(); 
	void SetExtension(int extension) { m_extension = extension; }; 
	void SetLine(int line) { m_CurrentLine = line; }; 
	TapiLine *GetTapiLine() // Return the current TAPI line 
	{ return (m_pLines && (m_CurrentLine != -1)) ? m_pLines[m_CurrentLine] : NULL; } 
 
	// Variables 
	CTapisampleDlg& m_Dlg; 
 
	HLINEAPP	m_hLineApp;		// Application handle returned from TAPI 
	DWORD		m_NumDevs;		// Number of devices (lines) available: 1 for INDeX. 
	DWORD		*m_ApiVersions; // API versions supported by each device 
	PTAPILINE	*m_pLines;		// Device variables 
	LONG        m_CurrentLine;	// The line that is currently selected 
	DWORD		m_extension;	// The extension number of the line that is  
								// currently selected. 
};