#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); }