Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

221 lines
5.7 KiB

  1. /*++
  2. Copyright (c) 1997-1999 Microsoft Corporation
  3. Module Name:
  4. Agent.h
  5. Abstract:
  6. Declaration of the CAgent & CAgentEvent Classes
  7. Author:
  8. noela - 11/04/97
  9. Notes:
  10. Revision History:
  11. --*/
  12. #ifndef __AGENT_H_
  13. #define __AGENT_H_
  14. #include "resource.h" // main symbols
  15. #include "agenthand.h"
  16. class CAgentHandler;
  17. class CTAPI;
  18. /////////////////////////////////////////////////////////////////////////////
  19. // CAgent
  20. class ATL_NO_VTABLE CAgent :
  21. public CTAPIComObjectRoot<CAgent>,
  22. public IDispatchImpl<ITAgent, &IID_ITAgent, &LIBID_TAPI3Lib>,
  23. public CObjectSafeImpl
  24. {
  25. private:
  26. PWSTR m_szAgentUserName;
  27. PWSTR m_szAgentID;
  28. PWSTR m_szPIN;
  29. HAGENT m_hAgent;
  30. CAgentHandler * m_pHandler;
  31. AgentSessionArray m_AgentSessionArray;
  32. BOOL m_bRequiresUpdating;
  33. AGENT_STATE m_AgentState;
  34. AGENT_STATE m_NextAgentState;
  35. DWORD m_dwMeasurementPeriod;
  36. CURRENCY m_cyOverallCallRate;
  37. DWORD m_dwNumberOfACDCalls;
  38. DWORD m_dwNumberOfIncomingCalls;
  39. DWORD m_dwNumberOfOutgoingCalls;
  40. DWORD m_dwTotalACDTalkTime;
  41. DWORD m_dwTotalACDCallTime;
  42. DWORD m_dwTotalACDWrapUpTime;
  43. BOOL m_bAgentHasBeenEnumerated;
  44. BOOL m_bRegisteredForAgentEvents;
  45. BOOL m_bRegisteredForAgentSessionEvents;
  46. public:
  47. CAgent(){}
  48. ~CAgent(){}
  49. BOOL wantsAgentEvents() {return m_bRegisteredForAgentEvents;}
  50. BOOL wantsAgentSessionEvents() {return m_bRegisteredForAgentSessionEvents;}
  51. BOOL agentHasID() { return ((m_szAgentID!=0)?1:0); }
  52. void SetState(AGENT_STATE state) { m_AgentState = state;}
  53. STDMETHOD(UpdateInfo) ();
  54. STDMETHOD(CheckIfUpToDate) ();
  55. inline void SetRequiresUpdate() {m_bRequiresUpdating = TRUE;}
  56. inline HAGENT getHandle() {return m_hAgent;}
  57. void FinalRelease();
  58. CAgentHandler * GetAgentHandler() { return m_pHandler; }
  59. STDMETHOD(InternalCreateSession)(ITACDGroup * pACDGroup,
  60. ITAddress * pAddress,
  61. PWSTR pszPIN,
  62. ITAgentSession ** ppAgentSession);
  63. STDMETHOD(put_PIN) (BSTR pPIN);
  64. DECLARE_DEBUG_ADDREF_RELEASE(CAgent)
  65. DECLARE_MARSHALQI(CAgent)
  66. DECLARE_QI()
  67. DECLARE_TRACELOG_CLASS(CAgent)
  68. BEGIN_COM_MAP(CAgent)
  69. COM_INTERFACE_ENTRY(ITAgent)
  70. COM_INTERFACE_ENTRY(IDispatch)
  71. COM_INTERFACE_ENTRY(IObjectSafety)
  72. COM_INTERFACE_ENTRY_FUNC(IID_IMarshal, 0, IMarshalQI)
  73. COM_INTERFACE_ENTRY_AGGREGATE(IID_IMarshal, m_pFTM)
  74. END_COM_MAP()
  75. // ITAgent
  76. public:
  77. STDMETHOD(get_TotalWrapUpTime) (long * pulWrapUpTime);
  78. STDMETHOD(get_TotalACDCallTime) (long * pulCallTime);
  79. STDMETHOD(get_TotalACDTalkTime) (long * pulTalkTime);
  80. STDMETHOD(get_NumberOfOutgoingCalls) (long * pulCalls);
  81. STDMETHOD(get_NumberOfIncomingCalls) (long * pulCalls);
  82. STDMETHOD(get_NumberOfACDCalls) (long * pulCalls);
  83. STDMETHOD(get_OverallCallRate) (CURRENCY *pcyCallrate);
  84. STDMETHOD(get_MeasurementPeriod) (long *pulPeriod);
  85. STDMETHOD(put_MeasurementPeriod) (long ulPeriod);
  86. STDMETHOD(get_State) (AGENT_STATE * pAgentState);
  87. STDMETHOD(put_State) (AGENT_STATE AgentState);
  88. STDMETHOD(get_User) (BSTR * ppUser);
  89. STDMETHOD(get_ID) (BSTR *pID);
  90. STDMETHOD(CreateSession) (ITACDGroup * pACDGroup,
  91. ITAddress * pAddress,
  92. ITAgentSession ** ppAgentSession
  93. );
  94. STDMETHOD(CreateSessionWithPIN) (ITACDGroup * pACDGroup,
  95. ITAddress * pAddress,
  96. BSTR pPIN,
  97. ITAgentSession ** ppAgentSession
  98. );
  99. STDMETHOD(RegisterAgentEvents) (VARIANT_BOOL bNotify);
  100. STDMETHOD(RegisterAgentSessionEvents) (VARIANT_BOOL bNotify);
  101. STDMETHOD(EnumerateAgentSessions) (IEnumAgentSession ** ppEnumAgentSession);
  102. STDMETHOD(get_AgentSessions) (VARIANT * pVariant);
  103. STDMETHOD(Initialize)
  104. (
  105. HAGENT hAgent,
  106. PWSTR pszUserName,
  107. PWSTR pszID,
  108. PWSTR pszPIN,
  109. CAgentHandler * pHandler
  110. );
  111. #if DBG
  112. STDMETHOD_(ULONG, InternalAddRef)()
  113. {
  114. DWORD dwR;
  115. dwR = InterlockedIncrement(&m_dwRef);;
  116. LogDebugAddRef(dwR);
  117. return dwR;
  118. }
  119. STDMETHOD_(ULONG, InternalRelease)()
  120. {
  121. DWORD dwR;
  122. dwR = InterlockedDecrement(&m_dwRef);
  123. LogDebugRelease( dwR );
  124. return dwR;
  125. }
  126. #endif
  127. };
  128. /////////////////////////////////////////////////////////////////////////////
  129. // CAgentEvent
  130. class ATL_NO_VTABLE CAgentEvent :
  131. public CTAPIComObjectRoot<CAgentEvent>,
  132. public IDispatchImpl<ITAgentEvent, &IID_ITAgentEvent, &LIBID_TAPI3Lib>,
  133. public CObjectSafeImpl
  134. {
  135. protected:
  136. AGENT_EVENT m_AgentEvent;
  137. ITAgent * m_pAgent;
  138. public:
  139. CAgentEvent()
  140. {
  141. }
  142. static HRESULT FireEvent(
  143. CAgent* pAgent,
  144. AGENT_EVENT Event
  145. );
  146. void FinalRelease();
  147. DECLARE_MARSHALQI(CAgentEvent)
  148. DECLARE_TRACELOG_CLASS(CAgentEvent)
  149. BEGIN_COM_MAP(CAgentEvent)
  150. COM_INTERFACE_ENTRY(ITAgentEvent)
  151. COM_INTERFACE_ENTRY(IDispatch)
  152. COM_INTERFACE_ENTRY(IObjectSafety)
  153. COM_INTERFACE_ENTRY_FUNC(IID_IMarshal, 0, IMarshalQI)
  154. COM_INTERFACE_ENTRY_AGGREGATE(IID_IMarshal, m_pFTM)
  155. END_COM_MAP()
  156. // ITAgentEvent
  157. public:
  158. STDMETHOD(get_Event)(AGENT_EVENT * pEvent);
  159. STDMETHOD(get_Agent)(ITAgent ** ppAgent);
  160. };
  161. #endif //__AGENT_H_