中间件标准版5.1git,去除基础模块

TapiOpIntercept.cpp 4.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. #include "StdAfx.h"
  2. #include "TapiOpIntercept.h"
  3. #include "DevControl.h"
  4. #include "TapiLine.h"
  5. #include "LineOpExec.h"
  6. CTapiOpIntercept::CTapiOpIntercept(LONG Instance) : CTapiOpBase(Instance), m_PendingCall(NULL), m_Step(0)
  7. {
  8. }
  9. CTapiOpIntercept::~CTapiOpIntercept(void)
  10. {
  11. }
  12. /*****************************************************************
  13. **【函数名称】 start
  14. **【函数功能】 操作启动(命令方式)
  15. **【参数】 pParam 操作启动参数
  16. **【返回值】
  17. ****************************************************************/
  18. bool CTapiOpIntercept::start( LineOpParam* pParam )
  19. {
  20. // 校验状态
  21. if(m_pAssistLine->status() != INNER_STATE_TALKING)
  22. return false;
  23. // 通知启动日志
  24. CDevControl::GetInstance().onEventLog(LOG_LEVEL_NORMAL, _T("{OP_Intercept}: Exten[%s]执行强截, DestNum = %s"), m_pHostLine->extenID(), m_pAssistLine->extenID());
  25. // 开始Park活动呼叫
  26. m_PendingCall = m_pAssistLine->activeCall();
  27. m_Step = 1;
  28. return m_pAssistLine->linePark(m_PendingCall, CONST_TAPI_CODE_PARK);
  29. }
  30. /*****************************************************************
  31. **【函数名称】 cancel
  32. **【函数功能】 操作取消(命令方式)
  33. **【参数】
  34. **【返回值】
  35. ****************************************************************/
  36. bool CTapiOpIntercept::cancel( LONG InstanceCancel )
  37. {
  38. return false;
  39. }
  40. /*****************************************************************
  41. **【函数名称】 end
  42. **【函数功能】 操作完成
  43. **【参数】 IsSucceed 操作是否成功
  44. **【返回值】
  45. ****************************************************************/
  46. void CTapiOpIntercept::end( bool IsSucceed )
  47. {
  48. if(IsSucceed)
  49. {
  50. CDevControl::GetInstance().onEventLog(LOG_LEVEL_NORMAL, _T("{OP_Intercept}: Exten[%s]强截成功, DestNum = %s"), m_pHostLine->extenID(), m_pAssistLine->extenID());
  51. }
  52. else
  53. {
  54. CDevControl::GetInstance().onEventLog(LOG_LEVEL_WARNING, _T("{OP_Intercept}: Exten[%s]强截失败, DestNum = %s"), m_pHostLine->extenID(), m_pAssistLine->extenID());
  55. } // end if
  56. // 返回执行结果
  57. CLineOpExec::GetInstance().onTapiOpResult(m_Instance, this, IsSucceed);
  58. }
  59. /*****************************************************************
  60. **【函数名称】 onReply
  61. **【函数功能】 线路操作异步响应事件
  62. **【参数】 pEventLine 触发事件的线路
  63. RequestID
  64. Result
  65. **【返回值】
  66. ****************************************************************/
  67. void CTapiOpIntercept::onReply( CTapiLine* pEventLine, LONG RequestID, HRESULT Result )
  68. {
  69. switch(m_Step)
  70. {
  71. case 1: // 正在Parking
  72. {
  73. (Result == S_OK) ? m_Step = 2 : end(false);
  74. }
  75. break;
  76. case 2: // 正在UnParking
  77. {
  78. if(Result != S_OK)
  79. {
  80. m_pAssistLine->lineUnPark(m_PendingCall, CONST_TAPI_CODE_PARK);
  81. end(false);
  82. } // end if
  83. }
  84. break;
  85. } // end switch
  86. }
  87. /*****************************************************************
  88. **【函数名称】 onCallState
  89. **【函数功能】 呼叫状态事件
  90. **【参数】 pEventLine 触发事件的线路
  91. CallId 触发事件的呼叫句柄
  92. CallState 呼叫基本状态
  93. CallStateDetail 呼叫明细状态
  94. **【返回值】
  95. ****************************************************************/
  96. void CTapiOpIntercept::onCallState( CTapiLine* pEventLine, HCALL CallId, DWORD CallState, DWORD CallStateDetail )
  97. {
  98. // Parking 操作完成
  99. if(m_Step == 1 && (CallId == m_PendingCall) && (CallState & LINECALLSTATE_DISCONNECTED))
  100. {
  101. m_Step = 2;
  102. m_pAssistLine->redoCallStatus(CallId, CallState, CallStateDetail);
  103. m_pHostLine->lineUnPark(m_PendingCall, CONST_TAPI_CODE_PARK);
  104. } // end if
  105. // UnParking 操作完成
  106. if(m_Step == 2 && (pEventLine == m_pHostLine) && (CallState & LINECALLSTATE_CONNECTED))
  107. {
  108. end(true);
  109. } // end if
  110. }
  111. /*****************************************************************
  112. **【函数名称】 onDevLinkEventS
  113. **【函数功能】 DevLink中S事件响应
  114. **【参数】 pEventLine 触发事件的线路
  115. pInfoS DevLink S事件内容
  116. **【返回值】
  117. ****************************************************************/
  118. void CTapiOpIntercept::onDevLinkEventS( CTapiLine* pEventLine, DevLinkInfoS* pInfoS )
  119. {
  120. }
  121. /*****************************************************************
  122. **【函数名称】 onDevLinkEventD
  123. **【函数功能】 DevLink中D事件响应
  124. **【参数】 pEventLine 触发事件的线路
  125. DevLinkCallId DevLink事件CallId
  126. **【返回值】
  127. ****************************************************************/
  128. void CTapiOpIntercept::onDevLinkEventD( CTapiLine* pEventLine, int DevLinkCallId )
  129. {
  130. }
  131. /*****************************************************************
  132. **【函数名称】 onDevLinkEventA
  133. **【函数功能】 DevLink中A事件响应
  134. **【参数】 pEventLine 触发事件的线路
  135. DevLinkCallId DevLink事件CallId
  136. **【返回值】
  137. ****************************************************************/
  138. void CTapiOpIntercept::onDevLinkEventA( CTapiLine* pEventLine, int DevLinkCallId )
  139. {
  140. }