int TNotification :: Subscribe(const char *sId, Handler *pHandler) { if (sId == NULL || pHandler == NULL) { return SWITCH_STATUS_FALSE; } m_mutex.Lock(); std::string strId(sId); m_msgRouteTable.insert(std::pair<std::string, Handler *>(strId, pHandler)); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "add notification map item: %s\n", sId); m_mutex.UnLock(); return SWITCH_STATUS_SUCCESS; }
//++ ------------------------------------------------------------------------------------ // Details: Given the client save its particular event requirements. // Type: Method. // Args: vClientName - (R) The Client's unique ID. // vBroadcasterClass - (R) The SBBroadcaster's class name targeted for the events. // vEventMask - (R) The mask of events to listen for. // Return: MIstatus::success - Functionality succeeded. // MIstatus::failure - Functionality failed. // Throws: None. //-- bool CMICmnLLDBDebugger::ClientSaveMask( const CMIUtilString & vClientName, const CMIUtilString & vBroadcasterClass, const MIuint vEventMask ) { if( vClientName.empty() ) { SetErrorDescription( CMIUtilString::Format( MIRSRC( IDS_LLDBDEBUGGER_ERR_INVALIDCLIENTNAME ), vClientName.c_str() ) ); return MIstatus::failure; } CMIUtilString strId( vBroadcasterClass ); strId += vClientName; ClientRemoveTheirMask( vClientName, vBroadcasterClass ); MapPairIdToEventMask_t pr( strId, vEventMask ); m_mapIdToEventMask.insert( pr ); return MIstatus::success; }
//++ //------------------------------------------------------------------------------------ // Details: Given the client remove it's particular event requirements. // Type: Method. // Args: vClientName - (R) The Client's unique ID. // vBroadcasterClass - (R) The SBBroadcaster's class name. // Return: MIstatus::success - Functionality succeeded. // MIstatus::failure - Functionality failed. // Throws: None. //-- bool CMICmnLLDBDebugger::ClientRemoveTheirMask( const CMIUtilString &vClientName, const CMIUtilString &vBroadcasterClass) { if (vClientName.empty()) { SetErrorDescription(CMIUtilString::Format( MIRSRC(IDS_LLDBDEBUGGER_ERR_INVALIDCLIENTNAME), vClientName.c_str())); return MIstatus::failure; } CMIUtilString strId(vBroadcasterClass); strId += vClientName; const MapIdToEventMask_t::const_iterator it = m_mapIdToEventMask.find(strId); if (it != m_mapIdToEventMask.end()) { m_mapIdToEventMask.erase(it); } return MIstatus::success; }
int TNotification :: Dispatch(const char *sId, int iType, const char *sMsg) { if (sId == NULL) { return SWITCH_STATUS_FALSE; } m_mutex.Lock(); std::map<std::string, Handler *>::iterator itr; std::string strId(sId); itr = m_msgRouteTable.find(strId); if (itr != m_msgRouteTable.end()) { itr->second->Handle(iType, sMsg); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "dispatch notification event: %s\n", sId); } m_mutex.UnLock(); return SWITCH_STATUS_SUCCESS; }
int TNotification :: Unsubscribe(const char *sId) { if (sId == NULL) { return SWITCH_STATUS_FALSE; } m_mutex.Lock(); std::map<std::string, Handler *>::iterator itr; std::string strId(sId); itr = m_msgRouteTable.find(strId); if (itr != m_msgRouteTable.end()) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "delete notification map item: %s\n", sId); m_msgRouteTable.erase(itr); } m_mutex.UnLock(); return SWITCH_STATUS_SUCCESS; }
//++ ------------------------------------------------------------------------------------ // Details: Retrieve the client's event mask used for on a particular SBBroadcaster. // Type: Method. // Args: vClientName - (R) The Client's unique ID. // vBroadcasterClass - (R) The SBBroadcaster's class name. // vwEventMask - (W) The client's mask. // Return: MIstatus::success - Functionality succeeded. // MIstatus::failure - Functionality failed. // Throws: None. //-- bool CMICmnLLDBDebugger::ClientGetTheirMask( const CMIUtilString & vClientName, const CMIUtilString & vBroadcasterClass, MIuint & vwEventMask ) { vwEventMask = 0; if( vClientName.empty() ) { SetErrorDescription( CMIUtilString::Format( MIRSRC( IDS_LLDBDEBUGGER_ERR_INVALIDCLIENTNAME ), vClientName.c_str() ) ); return MIstatus::failure; } CMIUtilString strId( vBroadcasterClass.c_str() ); strId += vClientName; const MapIdToEventMask_t::const_iterator it = m_mapIdToEventMask.find( strId ); if( it != m_mapIdToEventMask.end() ) { vwEventMask = (*it).second; } SetErrorDescription( CMIUtilString::Format( MIRSRC( IDS_LLDBDEBUGGER_ERR_CLIENTNOTREGISTERD ), vClientName.c_str() ) ); return MIstatus::failure; }
int Host::ShellEx(const OOBase::CmdArgs::results_t& args) { OOBase::LocalString strAppName(args.get_allocator()); if (!args.find("@0",strAppName)) LOG_ERROR_RETURN(("No arguments passed with --shellex"),EXIT_FAILURE); OOBase::TempPtr<wchar_t> wszAppName(args.get_allocator()); int err = OOBase::Win32::utf8_to_wchar_t(strAppName.c_str(),wszAppName); if (err) LOG_ERROR_RETURN(("Failed to convert string: %s",OOBase::system_error_text(err)),EXIT_FAILURE); OOBase::LocalString strCmdLine(args.get_allocator()); for (size_t i = 1;; ++i) { OOBase::LocalString strId(args.get_allocator()); int err = strId.printf("@%u",i); if (err) LOG_ERROR_RETURN(("Failed to format string: %s",OOBase::system_error_text(err)),EXIT_FAILURE); OOBase::LocalString strArg(args.get_allocator()); if (!args.find(strId,strArg)) break; err = strCmdLine.append(strArg.c_str()); if (!err && i != 0) err = strCmdLine.append(" "); if (err) LOG_ERROR_RETURN(("Failed to append string: %s",OOBase::system_error_text(err)),EXIT_FAILURE); } OOBase::TempPtr<wchar_t> wszCmdLine(args.get_allocator()); if (!strCmdLine.empty()) { err = OOBase::Win32::utf8_to_wchar_t(strCmdLine.c_str(),wszCmdLine); if (err) LOG_ERROR_RETURN(("Failed to convert string: %s",OOBase::system_error_text(err)),EXIT_FAILURE); } HRESULT hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE); if (FAILED(hr)) LOG_ERROR_RETURN(("CoInitializeEx failed: %s",OOBase::system_error_text()),EXIT_FAILURE); SHELLEXECUTEINFOW sei = {0}; sei.cbSize = sizeof(sei); sei.fMask = SEE_MASK_NOCLOSEPROCESS | SEE_MASK_NOASYNC | SEE_MASK_FLAG_NO_UI | SEE_MASK_NO_CONSOLE; sei.lpFile = wszAppName; sei.lpParameters = wszCmdLine; sei.nShow = SW_SHOWDEFAULT; if (!ShellExecuteExW(&sei)) LOG_ERROR_RETURN(("ShellExecuteExW failed: %s",OOBase::system_error_text()),EXIT_FAILURE); if (sei.hProcess) { WaitForSingleObject(sei.hProcess,INFINITE); CloseHandle(sei.hProcess); } CoUninitialize(); return EXIT_SUCCESS; }
void CVideoPlayBack::AddToListEnglish() { int j = m_iBeginNode; for(int i = 0; i< (int)m_storeLog.node_count; i++) { CString strId(_T("")); strId.Format(_T("%d"),j+1); CString strType = _T(""); if(m_SerachRecodeByType == ALL_RECODE) { if(m_storeLog.store[i].rec_type & TIMER_RECODE) { strType += _T(",TIMER_RECODE"); } if(m_storeLog.store[i].rec_type & ALARM_RECODE) { strType += _T(",ALARM_RECODE"); } if(m_storeLog.store[i].rec_type & MOVE_RECODE) { strType += _T(",MOVE_RECODE"); } if(m_storeLog.store[i].rec_type & MANUAL_RECODE) { strType += _T(",MANUAL_RECODE"); } if(m_storeLog.store[i].rec_type & LOST_RECODE) { strType += _T(",LOST_RECODE"); } if(m_storeLog.store[i].rec_type & HIDE_RECODE) { strType += _T(",HIDE_RECODE"); } if(m_storeLog.store[i].rec_type & NET_FAULT_RECODE) { strType += _T(",NET_FAULT_RECODE"); } if(m_storeLog.store[i].rec_type & PIR_RECODE) { strType += _T(",PIR_RECODE"); } strType = strType.Right(strType.GetLength() - 1 ); } else { if(m_storeLog.store[i].rec_type & TIMER_RECODE) { strType = _T("TIMER_RECODE"); } if(m_storeLog.store[i].rec_type & ALARM_RECODE) { strType = _T("ALARM_RECODE"); } if(m_storeLog.store[i].rec_type & MOVE_RECODE) { strType = _T("MOVE_RECODE"); } if(m_storeLog.store[i].rec_type & MANUAL_RECODE) { strType = _T("MANUAL_RECODE"); } if(m_storeLog.store[i].rec_type & LOST_RECODE) { strType = _T("LOST_RECODE"); } if(m_storeLog.store[i].rec_type & HIDE_RECODE) { strType = _T("HIDE_RECODE"); } if(m_storeLog.store[i].rec_type & NET_FAULT_RECODE) { strType = _T("NET_FAULT_RECODE"); } if(m_storeLog.store[i].rec_type & PIR_RECODE) { strType += _T("PIR_RECODE"); } } CString strStartTime = _T(""); CString strEndTime =_T(""); CString StartTime = _T(""); CString EndTime = _T(""); strStartTime.Format(_T("%d-%02d-%02d-%02d:%02d:%02d"),m_storeLog.store[i].beg_time.year+1900,m_storeLog.store[i].beg_time.month, m_storeLog.store[i].beg_time.date, m_storeLog.store[i].beg_time.hour , m_storeLog.store[i].beg_time.minute, m_storeLog.store[i].beg_time.second); strEndTime.Format(_T("%d-%02d-%02d-%02d:%02d:%02d"),m_storeLog.store[i].end_time.year+1900,m_storeLog.store[i].end_time.month, m_storeLog.store[i].end_time.date, m_storeLog.store[i].end_time.hour , m_storeLog.store[i].end_time.minute, m_storeLog.store[i].end_time.second); //计算时间段的差 COleDateTime tStartDateTime; COleDateTime tEndDateTime; tStartDateTime.SetDateTime(m_storeLog.store[i].beg_time.year+1900,m_storeLog.store[i].beg_time.month, m_storeLog.store[i].beg_time.date, m_storeLog.store[i].beg_time.hour , m_storeLog.store[i].beg_time.minute, m_storeLog.store[i].beg_time.second); tEndDateTime.SetDateTime(m_storeLog.store[i].end_time.year+1900,m_storeLog.store[i].end_time.month, m_storeLog.store[i].end_time.date, m_storeLog.store[i].end_time.hour , m_storeLog.store[i].end_time.minute, m_storeLog.store[i].end_time.second); m_lRecFileSize[j] = m_storeLog.store[i].file_size; //保存录像文件的大小 下载时计算进度 COleDateTimeSpan tMinute = tEndDateTime - tStartDateTime; // 计算两个日期时间的差值 DOUBLE dMinute = tMinute.GetTotalSeconds(); CString strFileTimes = _T(""); strFileTimes.Format(_T("%ld"), (LONG)dMinute); CString strFileSize = _T("");//录像大小 strFileSize.Format(_T("%d"), m_storeLog.store[i].file_size/(1024*1024)); m_VideoPlayBack.InsertItem(j,strId ); m_VideoPlayBack.SetItemText(j, 1, strType); m_VideoPlayBack.SetItemText(j, 2, strStartTime); m_VideoPlayBack.SetItemText(j, 3, strEndTime); m_VideoPlayBack.SetItemText(j, 4, strFileTimes); m_VideoPlayBack.SetItemText(j, 5, strFileSize); j++; } }