| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 |
- #include "StdAfx.h"
- #include "OpMute.h"
- #include "VirtualChan.h"
- #include "OperationReactor.h"
- #include "FsProxy.h"
- COpMute::COpMute(COperationReactor* pParent, LONG Instance) : COperation(pParent, Instance), m_IsOff(false)
- {
- }
- COpMute::~COpMute(void)
- {
- }
- /*****************************************************************
- **【函数名称】 _end
- **【函数功能】 操作完成
- **【参数】 IsSucceed 操作是否成功
- lpData 随路数据
- **【返回值】
- ****************************************************************/
- void COpMute::_end( bool IsSucceed )
- {
- if(m_IsOff)
- {
- if(IsSucceed)
- LOGGER(LOG_LEVEL_NORMAL, _T("{OpMute}: 分机[%lu]取消静音成功"), m_pHostChan->no());
- else
- LOGGER(LOG_LEVEL_WARNING, _T("{OpMute}: 分机[%lu]取消静音失败"), m_pHostChan->no());
- m_pParent->onOpResult(m_InstanceCancel, IsSucceed);
- }
- else
- {
- if(IsSucceed)
- LOGGER(LOG_LEVEL_NORMAL, _T("{OpMute}: 分机[%lu]静音成功"), m_pHostChan->no());
- else
- LOGGER(LOG_LEVEL_WARNING, _T("{OpMute}: 分机[%lu]静音失败"), m_pHostChan->no());
- // 返回执行结果
- if(m_InstanceCancel != FS_LINK_INSTANCE_INVALID)
- m_pParent->onOpResult(m_InstanceCancel, !IsSucceed);
- m_pParent->onOpResult(m_Instance, this, IsSucceed);
- }
- }
- /*****************************************************************
- **【函数名称】 start
- **【函数功能】 执行操作
- **【参数】
- **【返回值】
- *****************************************************************/
- bool COpMute::start( LineOpParam* pParam )
- {
- // 校验状态
- if(m_pHostChan->state() != CHAN_LOGIC_STATE_TALKING)
- return false;
- LOGGER(LOG_LEVEL_NORMAL, _T("{OpMute}: 分机[%lu]执行静音"), m_pHostChan->no());
- return CFsProxy::GetInstance().muteOn(uniqueId(), m_pHostChan);
- }
- /*****************************************************************
- **【函数名称】 cancel
- **【函数功能】 取消操作
- **【参数】
- **【返回值】
- *****************************************************************/
- bool COpMute::cancel( LONG InstanceCancel )
- {
- LOGGER(LOG_LEVEL_NORMAL, _T("{OpMute}: 分机[%lu]取消静音"), m_pHostChan->no());
- m_InstanceCancel = InstanceCancel;
- m_IsOff = true;
- return CFsProxy::GetInstance().muteOff(uniqueId(), m_pHostChan);
- }
- /*****************************************************************
- **【函数名称】 hangup
- **【函数功能】 操作中挂机
- **【参数】
- **【返回值】
- *****************************************************************/
- bool COpMute::hangup( LONG InstanceHangup )
- {
- if(m_InstanceCancel != FS_LINK_INSTANCE_INVALID)
- return false;
- LOGGER(LOG_LEVEL_NORMAL, _T("{OpMute}: 分机[%lu]静音中挂机"), m_pHostChan->no());
- m_InstanceCancel = InstanceHangup;
- if(CFsProxy::GetInstance().kill(uniqueId(), m_pHostChan))
- {
- _end(false);
- return true;
- }
- else
- {
- _end(true);
- return false;
- }
- }
- /*****************************************************************
- **【函数名称】 onBackgroudJobDone
- **【函数功能】 后台命令执行结束事件处理
- **【参数】
- **【返回值】
- *****************************************************************/
- void COpMute::onBackgroudJobDone( PBG_JOB_NOTIFY pNotify )
- {
- if(m_IsOff)
- {
- if(strstr(pNotify->JobBody, ESL_JOB_DONE_RES_OK) == NULL)
- m_pParent->onOpResult(m_InstanceCancel, false); // 取消静音不成功不删该操作,以备再次取消静音之用
- else
- _end(true);
- }
- else
- {
- if(strstr(pNotify->JobBody, ESL_JOB_DONE_RES_OK) == NULL)
- _end(false);
- else
- m_pParent->onOpResult(m_Instance, true); // 静音成功不删该操作,以备取消静音之用
- }
- }
- /*****************************************************************
- **【函数名称】 onHostChanStateUpdated
- **【函数功能】 关联通道状态更新处理
- **【参数】
- **【返回值】
- *****************************************************************/
- void COpMute::onHostChanStateUpdated( CVirtualChan* pHostChan )
- {
- if(m_pHostChan->state() == CHAN_LOGIC_STATE_FREE)
- _end(false);
- }
|