// 联动动作停止通知 int CSDKMainctrl::StopLinkageAction(CCmd* pCmd)const { // 获取通知内容 CHECK_POINTER(pCmd, IVS_OPERATE_MEMORY_ERROR); IVS_CHAR* pData = CSDKMainService::ProcessMAUCmd(pCmd); CHECK_POINTER(pData, IVS_OPERATE_MEMORY_ERROR); int iSessionID = CLinkRouteMgr::instance().FindSessionIDByLinkID(pCmd->GetNetLinkID()); //lint !e1013 !e1055 !e746 !e64 if (SDK_SESSIONID_INIT == iSessionID) { BP_RUN_LOG_ERR(IVS_SDK_RET_INVALID_SESSION_ID, "Stop linkage action", "iSessionID = %d", iSessionID); IVS_DELETE(pData, MUILI); return IVS_FAIL; } CXml xml; const IVS_CHAR* pDataXml = NULL; IVS_INT32 iRet = ModifyDevCode(xml, pData); if (IVS_SUCCEED != iRet) { IVS_DELETE(pData, MUILI); return iRet; } IVS_UINT32 uiXMLLen = 0; pDataXml = xml.GetXMLStream(uiXMLLen); IVS_DELETE(pData, MUILI); CHECK_POINTER(pDataXml, IVS_OPERATE_MEMORY_ERROR); CEventCallBackJob::instance().PostEvent(iSessionID, IVS_EVENT_STOP_LINKAGE_ACTION, pDataXml, static_cast<IVS_INT32>(strlen(pDataXml)) + 1); return IVS_SUCCEED; }
//Metoda ³aduj¹ca dane bool CBulletTemplate::Load(CXml &xml) { if (!CPhysicalTemplate::Load(xml)) return false; //sprawdzamy, czy xml zawiera informacjê, ¿e jest to bullet if (xml.GetString(xml.GetRootNode(), "type") != "bullet") return false; //plik xml pocisku przypomina plik physical'a //ewentualne ³adowanie danych generycznych pocisku... //if (xml_node<>* node = xml.GetChild(xml.GetRootNode(), "zabawa z pociskiem...")) //mMinDamage = xml.GetFloat( "damage", "min" ); //mMaxDamage = xml.GetFloat( "damage", "max" ); //node = xml.GetChild(0, "anim"); //if (node) // mAnimation = gAnimationManager.GetAnimation(xml.GetString(node,"name")); //for (node=xml.GetChild(0,"image"); node; node=xml.GetSibl(node,"image") ) // mImages.push_back( xml.GetString(node,"filename") ); //for (node=xml.GetChild(0,"effect"); node; node=xml.GetSibl(node,"effect") ) // mEffects.push_back( xml.GetString(node,"name") ); //for (node=xml.GetChild(0,"destroyEffect"); node; node=xml.GetSibl(node,"destroyEffect") ) // mDestroyEffects.push_back( xml.GetString(node,"name") ); return true; }
// 拼装客户端抓拍通用返回xml IVS_INT32 OCXCapturePictureXMLProcess::LocalCaptureBuildXMLGeneric(LONG iEventCode, ULONG iWndID, const IVS_CHAR* pFileName, CXml &xml) { // CHECK_POINTER(pFileName, IVS_OPERATE_MEMORY_ERROR); // 可以为空 IVS_DEBUG_TRACE(""); char buf[IVS_FILE_NAME_LEN + 1] = {0}; CHECK_SUCCESS(xml.AddDeclaration("1.0","UTF-8","")); CHECK_SUCCESS(xml.AddElem("Content")); CHECK_SUCCESS(xml.AddChildElem("WndID")); xml.IntoElem(); (void)_itoa_s((int)iWndID, buf, 10);//lint !e713 CHECK_SUCCESS(xml.SetElemValue(buf)); CHECK_SUCCESS(xml.AddElem("EventID")); (void)_itoa_s(iEventCode, buf, 10); CHECK_SUCCESS(xml.SetElemValue(buf)); if (NULL != pFileName) { CHECK_SUCCESS(xml.AddElem("FileName")); CHECK_SUCCESS(xml.SetElemValue(pFileName)); } xml.OutOfElem(); return IVS_SUCCEED; }
// 实现外域发送消息公共方法(支持重定向) IVS_INT32 CXmlProcess::GetCommSendMgrForRedirect(CXml &xml, CUserMgr* pUserMgr, NSS_MSG_TYPE_E msgType, IVS_INT32 iType, const IVS_CHAR* pCameraCode,const IVS_CHAR* pDomainCode) { CHECK_POINTER(pDomainCode, IVS_OPERATE_MEMORY_ERROR); CHECK_POINTER(pUserMgr, IVS_OPERATE_MEMORY_ERROR); IVS_UINT32 xmlLen = 0; const IVS_CHAR* pReq = xml.GetXMLStream(xmlLen); CHECK_POINTER(pReq, IVS_OPERATE_MEMORY_ERROR); BP_RUN_LOG_INF("Get CommSendMgr For Redirect", "send XML = %s", pReq); // 构造带域的请求消息,并发送 CSendNssMsgInfo sendNssMsgInfo; sendNssMsgInfo.SetNeedXml(TYPE_NSS_XML); sendNssMsgInfo.SetNetElemType(NET_ELE_SMU_NSS); sendNssMsgInfo.SetReqID(msgType); sendNssMsgInfo.SetReqData(pReq); sendNssMsgInfo.SetCameraCode(pCameraCode); sendNssMsgInfo.SetDomainCode(pDomainCode); std::string strpRsp; IVS_INT32 iNeedRedirect = IVS_FAIL; IVS_INT32 iRet = pUserMgr->SendCmd(sendNssMsgInfo,strpRsp,iNeedRedirect); if (IVS_SUCCEED != iRet) { BP_RUN_LOG_ERR(iRet,"Get CommSendMgr For Redirect", "seng cmd fail"); return iRet; } if(NSS_GET_VOICE_INFO_REQ == msgType || NSS_GET_CAMERA_CFG_REQ == msgType) { if (IVS_SUCCEED == iNeedRedirect) { iRet = pUserMgr->SendRedirectServe(sendNssMsgInfo,strpRsp); } } // 返回相应消息 if (BUILSTRING == iType) { if (strpRsp.empty()) { BP_RUN_LOG_ERR(iRet,"NULL == strpRsp", "iRet = %d", iRet); return iRet; } if(iRet == IVS_SUCCEED) { iRet = IVS_XML_INVALID; xml.RemoveElem(); if(xml.Parse(strpRsp.c_str())) { iRet = IVS_SUCCEED; } } BP_RUN_LOG_INF("Get CommSendMgr For Redirect", "revice XML = %s", strpRsp.c_str()); } return iRet; }
HRESULT CHandler::Open2(IInStream *stream) { UInt64 archiveStartPos; RINOK(stream->Seek(0, STREAM_SEEK_SET, &archiveStartPos)); const UInt32 kHeaderSize = 0x1C; Byte buf[kHeaderSize]; RINOK(ReadStream_FALSE(stream, buf, kHeaderSize)); UInt32 size = Get16(buf + 4); // UInt32 ver = Get16(buf + 6); // == 0 if (Get32(buf) != 0x78617221 || size != kHeaderSize) return S_FALSE; UInt64 packSize = Get64(buf + 8); UInt64 unpackSize = Get64(buf + 0x10); // UInt32 checkSumAlogo = Get32(buf + 0x18); if (unpackSize >= kXmlSizeMax) return S_FALSE; _dataStartPos = archiveStartPos + kHeaderSize + packSize; char *ss = _xml.GetBuffer((int)unpackSize + 1); NCompress::NZlib::CDecoder *zlibCoderSpec = new NCompress::NZlib::CDecoder(); CMyComPtr<ICompressCoder> zlibCoder = zlibCoderSpec; CLimitedSequentialInStream *inStreamLimSpec = new CLimitedSequentialInStream; CMyComPtr<ISequentialInStream> inStreamLim(inStreamLimSpec); inStreamLimSpec->SetStream(stream); inStreamLimSpec->Init(packSize); CBufPtrSeqOutStream *outStreamLimSpec = new CBufPtrSeqOutStream; CMyComPtr<ISequentialOutStream> outStreamLim(outStreamLimSpec); outStreamLimSpec->Init((Byte *)ss, (size_t)unpackSize); RINOK(zlibCoder->Code(inStreamLim, outStreamLim, NULL, NULL, NULL)); if (outStreamLimSpec->GetPos() != (size_t)unpackSize) return S_FALSE; ss[(size_t)unpackSize] = 0; _xml.ReleaseBuffer(); CXml xml; if (!xml.Parse(_xml)) return S_FALSE; if (!xml.Root.IsTagged("xar") || xml.Root.SubItems.Size() != 1) return S_FALSE; const CXmlItem &toc = xml.Root.SubItems[0]; if (!toc.IsTagged("toc")) return S_FALSE; if (!AddItem(toc, _files, -1)) return S_FALSE; return S_OK; }
ELTE_INT32 CMediaMgr::GetUserRECFileInfoList(const ELTE_CHAR* pQueryXml, ELTE_CHAR** pRspXml) const { LOG_TRACE(); if(NULL == m_pUserMgr) { LOG_RUN_ERROR("UserMgr is null."); return eLTE_SDK_ERR_NULL_POINTER; } CXml reqXml; if(!reqXml.Parse(pQueryXml)) { LOG_RUN_ERROR("ReqXml parse failed, param is %s.", pQueryXml); return eLTE_SDK_ERR_XML_PARSE; } //发送消息 SSL_Socket& socket = const_cast<SSL_Socket&>(m_pUserMgr->GetSSLSocket()); MutexLocker Locker(m_pUserMgr->GetMutexHandle()); ELTE_INT32 iRet = socket.SendMsg(ELTE_SERVICE_GETUSERRECFILEINFOLIST_REQ, reqXml, TRUE); if(eLTE_SDK_ERR_SUCCESS != iRet) { return iRet; } iRet = m_pUserMgr->WaitObject(WAIT_OBJECT_TIME); if (eLTE_SDK_ERR_SUCCESS != iRet) { CServerMgr& serverMgr = const_cast<CServerMgr&>(m_pUserMgr->GetServerMgr()); if(!serverMgr.ServerIsRunning() || 0 != m_pUserMgr->GetServerStatus()) { m_pUserMgr->SetServerStatus(0); return eLTE_SDK_ERR_SERVER_NOT_RUNNING; } return iRet; } const PACKET_DATA& packetData = m_pUserMgr->GetPacketData(); iRet = packetData.RspCode; ELTE_UINT32 uiDataLen = packetData.PacketLength - PACKET_HEAD_SIZE; if(uiDataLen > 0) { *pRspXml = new ELTE_CHAR[uiDataLen + 1]; if(NULL == *pRspXml) { LOG_RUN_ERROR("New RspXml failed."); ::ResetEvent(m_pUserMgr->GetEventHandle()); return eLTE_SDK_ERR_CREATE_OBJECT; } eSDK_MEMSET(*pRspXml, 0x00, uiDataLen + 1); eSDK_MEMCPY(*pRspXml, uiDataLen + 1, packetData.Value, uiDataLen); } else { *pRspXml = NULL; } ::ResetEvent(m_pUserMgr->GetEventHandle()); return iRet; }
eLTE_RET XMLProcess::SetXmlStringEventNotifySDSStatus(const SdsMessageInfo* pInfo, CString& xmlStr) { /************************************************************************ --- XML 格式 --- <Content> <SdsMsgId>消息ID</SdsMsgId> <SdsRetCode>消息发送状态</SdsRetCode> </Content> ************************************************************************/ LOG_TRACE(); CXml xml; (void)xml.AddElem("Content"); (void)xml.AddChildElem("SdsMsgId"); (void)xml.IntoElem(); (void)xml.SetElemValue(pInfo->strSubject.c_str()); (void)xml.AddElem("SdsRetCode"); (void)xml.SetElemValue(pInfo->strRetCode.c_str()); xml.OutOfElem(); IVS_UINT32 uiLen = 0; const char* pXmlStr = xml.GetXMLStream(uiLen); if (NULL == pXmlStr) { LOG_RUN_ERROR("pXmlStr is null."); return eLTE_ERR_FAILED; } xmlStr = eLTE_Tool::ANSIToUnicode(pXmlStr).c_str(); INFO_PARAM1(pXmlStr); return eLTE_ERR_SUCCESS; }
// 增加角色 IVS_INT32 CRoleMgr::AddRole(const IVS_ROLE_INFO* pRoleInfo, IVS_UINT32* puiRoleID) { //空校验 CHECK_POINTER(m_UserMgr, IVS_OPERATE_MEMORY_ERROR); CHECK_POINTER(pRoleInfo, IVS_PARA_INVALID); IVS_DEBUG_TRACE(""); IVS_INT32 iRet = IVS_FAIL; CXml xmlReq; std::string strDomainCode; // 防止域编码达到临界值无结束符“\0” modify by xiongfeng char cDomainCodeTmp[IVS_DOMAIN_CODE_LEN + 1] = {0}; (void)CToolsHelp::Memcpy(cDomainCodeTmp, IVS_DOMAIN_CODE_LEN, pRoleInfo->cDomainCode, IVS_DOMAIN_CODE_LEN); strDomainCode = cDomainCodeTmp; if (strDomainCode.empty()) { m_UserMgr->GetDomainCode(strDomainCode); } CUserInfoMgrXMLProcess::GetRoleXML(strDomainCode.c_str(), pRoleInfo, xmlReq); IVS_UINT32 xmlLen = 0; const IVS_CHAR* pReq = xmlReq.GetXMLStream(xmlLen); CHECK_POINTER(pReq, IVS_OPERATE_MEMORY_ERROR); // 构造带域的请求消息,并发送 CSendNssMsgInfo sendNssMsgInfo; sendNssMsgInfo.SetNeedXml(TYPE_NSS_XML); sendNssMsgInfo.SetNetElemType(NET_ELE_SMU_NSS); sendNssMsgInfo.SetReqID(NSS_ADD_ROLE_REQ); sendNssMsgInfo.SetReqData(pReq); sendNssMsgInfo.SetDomainCode(strDomainCode); //发送请求 std::string strRsp; IVS_INT32 iNeedRedirect = IVS_FAIL; iRet = m_UserMgr->SendCmd(sendNssMsgInfo,strRsp,iNeedRedirect); if(IVS_SUCCEED != iRet) { BP_RUN_LOG_ERR(iRet, "Add Role","SendCmd to SMU Return Failed"); return iRet; } //CHECK_POINTER(strRsp.c_str(), IVS_OPERATE_MEMORY_ERROR); CXml xmlRsp; if(!xmlRsp.Parse(strRsp.c_str())) { BP_RUN_LOG_ERR(IVS_XML_INVALID, "Add Role", "xml parsing error"); return IVS_XML_INVALID; } iRet = CUserInfoMgrXMLProcess::AddRoleParseXML(xmlRsp, puiRoleID); return iRet; }
// 构建去选中图形消息XML IVS_INT32 COCXDrawXMLProcess::UnSelectGraphicGetXML(CString &xmlToCU) { IVS_DEBUG_TRACE(""); CXml xmlGraphics; unsigned int uiLen = 0; CHECK_SUCCESS(xmlGraphics.AddDeclaration("1.0","UTF-8","")); CHECK_SUCCESS(xmlGraphics.AddElem("Content")); xmlToCU = xmlGraphics.GetXMLStream(uiLen); return IVS_SUCCEED; }
// 查询角色列表 IVS_INT32 CRoleMgr::GetRoleList(const IVS_CHAR* pDomainCode, const IVS_INDEX_RANGE* pIndexRange, IVS_ROLE_INFO_LIST* pRoleInfoList, IVS_UINT32 /*uiBufferSize*/) { CHECK_POINTER(m_UserMgr, IVS_OPERATE_MEMORY_ERROR); CHECK_POINTER(pIndexRange, IVS_PARA_INVALID); CHECK_POINTER(pRoleInfoList, IVS_PARA_INVALID); IVS_DEBUG_TRACE(""); std::string strDomainCode; if ( NULL == pDomainCode || '\0' == pDomainCode[0]) { m_UserMgr->GetDomainCode(strDomainCode); } else { strDomainCode = pDomainCode; } //构造请求xml IVS_INT32 iRet = IVS_FAIL; CXml xmlReq; CUserInfoMgrXMLProcess::CommDomainCodeXml(strDomainCode.c_str(), xmlReq); unsigned int xmlLen = 0; const IVS_CHAR* pReq = xmlReq.GetXMLStream(xmlLen); CHECK_POINTER(pReq, IVS_OPERATE_MEMORY_ERROR); // 构造带域的请求消息,并发送 CSendNssMsgInfo sendNssMsgInfo; sendNssMsgInfo.SetNeedXml(TYPE_NSS_XML); sendNssMsgInfo.SetNetElemType(NET_ELE_SMU_NSS); sendNssMsgInfo.SetReqID(NSS_GET_ROLE_LIST_REQ); sendNssMsgInfo.SetReqData(pReq); sendNssMsgInfo.SetDomainCode(strDomainCode); std::string strpRsp; IVS_INT32 iNeedRedirect = IVS_FAIL; iRet = m_UserMgr->SendCmd(sendNssMsgInfo,strpRsp,iNeedRedirect); if(IVS_SUCCEED != iRet) { BP_RUN_LOG_ERR(iRet, "Get Main DeviceList fail","SendCmd to SMU Return Failed"); return iRet; } //CHECK_POINTER(strpRsp.c_str(), IVS_XML_INVALID); CXml xmlRsp; if(!xmlRsp.Parse(strpRsp.c_str())) { BP_RUN_LOG_ERR(IVS_XML_INVALID, "Get Role List", "xml parsing error"); return IVS_XML_INVALID; } iRet = CUserInfoMgrXMLProcess::GetRoleListParseXML(xmlRsp, pRoleInfoList); return iRet; }
IVS_INT32 CXmlProcess::GetCommBuildRet( CXml &xml, NSS_MSG_TYPE_E msgType, IVS_INT32 iType, const std::string& strLinkID) { IVS_UINT32 xmlLen = 0; const IVS_CHAR* pReq = xml.GetXMLStream(xmlLen); CHECK_POINTER(pReq, IVS_OPERATE_MEMORY_ERROR); BP_RUN_LOG_INF("COCXXmlProcess::GetCommBuildRet", "send XML = %s", pReq); //创建要发送的CMD,拼装了NSS消息头 CCmd* pCmd = CNSSOperator::instance().BuildSMUCmd(msgType, pReq, strLinkID); CHECK_POINTER(pCmd, IVS_SDK_RET_BP_CMD_REQ_INVALID); //发送消息 CCmd *pCmdRsp = CNSSOperator::instance().SendSyncCmd(pCmd); CHECK_POINTER(pCmdRsp, IVS_NET_RECV_TIMEOUT); //返回响应消息 IVS_INT32 iRet = IVS_SUCCEED; const IVS_CHAR* pRsp = NULL; if (BUILDRET == iType) { iRet = CNSSOperator::instance().ParseCmd2NSS(pCmdRsp); } else { pRsp = CNSSOperator::instance().ParseCmd2XML(pCmdRsp, iRet); } BP_RUN_LOG_INF("GetCommBuildRet", "revice XML = %s", pRsp); HW_DELETE(pCmdRsp); if (BUILSTRING == iType) { if (NULL == pRsp) { BP_RUN_LOG_ERR(iRet,"NULL == pRsp", "iRet = %d", iRet); return iRet; } if(iRet == IVS_SUCCEED) { iRet = IVS_XML_INVALID; xml.RemoveElem(); if(xml.Parse(pRsp)) { iRet = IVS_SUCCEED; } IVS_DELETE(pRsp, MUILI); } } BP_RUN_LOG_INF("GetCommBuildRet", "iType = %d,iRet = %d", iType, iRet); return iRet; }
// 根据用户ID获取角色详细信息 IVS_INT32 CRoleMgr::GetRoleInfoByUserID(const IVS_CHAR* pDomainCode, IVS_UINT32 uiUserID, IVS_ROLE_INFO* pRoleInfo) { CHECK_POINTER(m_UserMgr, IVS_OPERATE_MEMORY_ERROR); CHECK_POINTER(pRoleInfo, IVS_PARA_INVALID); IVS_DEBUG_TRACE(""); std::string sDomainCode; if(NULL == pDomainCode) { m_UserMgr->GetDomainCode(sDomainCode); } else { sDomainCode = pDomainCode; } IVS_INT32 iRet = IVS_FAIL; CXml xmlReq; CUserInfoMgrXMLProcess::GetUserInfoGetXML(sDomainCode.c_str(), uiUserID, xmlReq); unsigned int xmlLen = 0; const IVS_CHAR* pReq = xmlReq.GetXMLStream(xmlLen); CHECK_POINTER(pReq, IVS_OPERATE_MEMORY_ERROR); // 构造带域的请求消息,并发送 CSendNssMsgInfo sendNssMsgInfo; sendNssMsgInfo.SetNeedXml(TYPE_NSS_XML); sendNssMsgInfo.SetNetElemType(NET_ELE_SMU_NSS); sendNssMsgInfo.SetReqID(NSS_GET_USER_ROLE_REQ); sendNssMsgInfo.SetReqData(pReq); sendNssMsgInfo.SetDomainCode(sDomainCode); std::string strpRsp; IVS_INT32 iNeedRedirect = IVS_FAIL; iRet = m_UserMgr->SendCmd(sendNssMsgInfo,strpRsp,iNeedRedirect); if(IVS_SUCCEED != iRet) { BP_RUN_LOG_ERR(iRet, "Get Role Info By UserID","SendCmd to SMU Return Failed"); return iRet; } //CHECK_POINTER(strpRsp.c_str(), IVS_OPERATE_MEMORY_ERROR); CXml xmlRsp; if(!xmlRsp.Parse(strpRsp.c_str())) { BP_RUN_LOG_ERR(IVS_XML_INVALID, "Get RoleInfo By UserID", "xml parsing error"); return IVS_XML_INVALID; } iRet = CUserInfoMgrXMLProcess::GetRoleInfoParseXML(xmlRsp, pRoleInfo); return iRet; }
//解析相应详细 IVS_INT32 CMediaXMLProcess::ParseVideoNumAndResource(CXml& xmlRsq,IVS_INT32& iReachLimit, IVS_INT32& iWhetherCited) { const char*AttriValue = NULL; //临时存储单个节点值 if (xmlRsq.FindElemEx("Content")) { (void)xmlRsq.IntoElem(); GET_ELEM_VALUE_NUM("ReachLimit", AttriValue, iReachLimit, xmlRsq); GET_ELEM_VALUE_NUM("WhetherCited", AttriValue, iWhetherCited, xmlRsq); return IVS_SUCCEED; } BP_RUN_LOG_ERR(IVS_FAIL, "Parse VideoNum And Resource XML", "Get VideoNum And Resource Error"); return IVS_FAIL; }
int CSDKMainctrl::OnUserOffLineNotify(CCmd* pCmd)const { // 从cmd中获取xml CHECK_POINTER(pCmd, IVS_OPERATE_MEMORY_ERROR); IVS_INT32 iRet = IVS_FAIL; IVS_CHAR *pszInfo = CNSSOperator::instance().ParseCmd2XML(pCmd, iRet); CHECK_POINTER(pszInfo, IVS_OPERATE_MEMORY_ERROR); IVS_USER_OFFLINE_INFO pstUserOffline; memset(&pstUserOffline, 0, sizeof(IVS_USER_OFFLINE_INFO)); IVS_CHAR cLoginID[LOGIN_ID_LEN + 1]; memset(cLoginID, 0, LOGIN_ID_LEN+1); if (IVS_SUCCEED == iRet) { CXml xmlRsp; if (!xmlRsp.Parse(pszInfo)) { BP_RUN_LOG_ERR(IVS_XML_INVALID, "UserOffLine Notify", "xml parsing error"); HW_DELETE_A(pszInfo); return IVS_XML_INVALID; } iRet = CLoginXMLProcess::ParseUserOffLineXML(xmlRsp, cLoginID, &pstUserOffline); } if (IVS_SUCCEED != iRet) { BP_RUN_LOG_ERR(IVS_XML_INVALID, "UserOffLine Notify", "xml parsing error"); HW_DELETE_A(pszInfo); return IVS_XML_INVALID; } //根据loginID获取sessionID //IVS_INT32 iSessionID = g_pNvs->GetSessionIDByLoginID(cLoginID); IVS_INT32 iSessionID = CLinkRouteMgr::instance().FindSessionIDByLinkID(pCmd->GetNetLinkID()); //lint !e1013 !e64 if (SDK_SESSIONID_INIT == iSessionID) { BP_RUN_LOG_ERR(IVS_SDK_RET_INVALID_SESSION_ID, "UserOffLine Notify", "iSessionID is -1"); HW_DELETE_A(pszInfo); return IVS_SDK_RET_INVALID_SESSION_ID; } pstUserOffline.iSessionID = iSessionID; (void)CEventCallBackJob::instance().PostEvent(iSessionID, IVS_EVENT_USER_OFFLINE, &pstUserOffline, sizeof(pstUserOffline)); HW_DELETE_A(pszInfo); //清理资源 (void)g_pNvs->Logout(iSessionID, false); return IVS_SUCCEED; }
// 获取用户权限信息 IVS_INT32 CRoleMgr::GetOperationRightGroup(const IVS_CHAR* pDomainCode, IVS_OPERATION_RIGHT_GROUP_LIST* pRightGroupList) { CHECK_POINTER(m_UserMgr, IVS_OPERATE_MEMORY_ERROR); IVS_DEBUG_TRACE(""); std::string strDomainCode; if(NULL == pDomainCode || '\0' == pDomainCode[0]) { m_UserMgr->GetDomainCode(strDomainCode); } else { strDomainCode = pDomainCode; } IVS_INT32 iRet = IVS_FAIL; CXml xmlReq; CUserInfoMgrXMLProcess::CommDomainCodeXml(strDomainCode.c_str(), xmlReq); unsigned int xmlLen = 0; const IVS_CHAR* pReq = xmlReq.GetXMLStream(xmlLen); CHECK_POINTER(pReq, IVS_OPERATE_MEMORY_ERROR); // 构造带域的请求消息,并发送 CSendNssMsgInfo sendNssMsgInfo; sendNssMsgInfo.SetNeedXml(TYPE_NSS_XML); sendNssMsgInfo.SetNetElemType(NET_ELE_SMU_NSS); sendNssMsgInfo.SetReqID(NSS_GET_ALL_OP_REQ); sendNssMsgInfo.SetReqData(pReq); sendNssMsgInfo.SetDomainCode(strDomainCode); std::string sRsp; IVS_INT32 iNeedRedirect = IVS_FAIL; iRet = m_UserMgr->SendCmd(sendNssMsgInfo,sRsp,iNeedRedirect); if(IVS_SUCCEED != iRet) { BP_RUN_LOG_ERR(iRet, "Get Operation Right Group","SendCmd to SMU Return Failed"); return iRet; } //CHECK_POINTER(sRsp.c_str(), IVS_OPERATE_MEMORY_ERROR); CXml xmlRsp; if(!xmlRsp.Parse(sRsp.c_str())) { BP_RUN_LOG_ERR(IVS_XML_INVALID, "Get Operation Right Group", "xml parsing error"); return IVS_XML_INVALID; } iRet = CUserInfoMgrXMLProcess::GetOperationRightGroupParseXML(xmlRsp, pRightGroupList); return iRet; }
// 构建获取图形失败的XML IVS_INT32 COCXDrawXMLProcess::GetGraphicsGetErrXML(IVS_INT32 iResultCode, CXml& xmlGraphics) { char val[64] = {0}; IVS_DEBUG_TRACE("iResultCode: %d", iResultCode); CHECK_SUCCESS(xmlGraphics.AddDeclaration("1.0","UTF-8","")); CHECK_SUCCESS(xmlGraphics.AddElem("Content")); CHECK_SUCCESS(xmlGraphics.AddChildElem("ResultCode")); CHECK_SUCCESS(xmlGraphics.IntoElem()); SET_ELEMENT_LONG(iResultCode, val, xmlGraphics); xmlGraphics.OutOfElem(); return IVS_SUCCEED; }
//获取平台录像计划; IVS_INT32 CRecordPlanMgr::GetRecordPlan(const char* pCameraCode,IVS_UINT32 uiRecordMethod, IVS_RECORD_PLAN* pRecordPlan) { CHECK_POINTER(pCameraCode, IVS_PARA_INVALID); CHECK_POINTER(pRecordPlan, IVS_PARA_INVALID); CHECK_POINTER(m_UserMgr, IVS_OPERATE_MEMORY_ERROR); IVS_DEBUG_TRACE(""); //数据结构拼装XML并转换为const IVS_CHAR * CXml xmlReq; IVS_INT32 iRet = CRecordXMLProcess::GetRecordPlanGetXML(pCameraCode, uiRecordMethod, xmlReq); unsigned int xmlLen = 0; const IVS_CHAR * pReqPlan = xmlReq.GetXMLStream(xmlLen); CHECK_POINTER(pReqPlan, IVS_OPERATE_MEMORY_ERROR); IVS_CHAR chDevCode[IVS_DEV_CODE_LEN+1]; memset(chDevCode, 0, sizeof(chDevCode)); IVS_CHAR chDomaCode[IVS_DOMAIN_CODE_LEN+1]; memset(chDomaCode, 0, sizeof(chDomaCode)); (IVS_VOID)CXmlProcess::ParseDevCode(pCameraCode, chDevCode, chDomaCode); //发送nss协议 CSendNssMsgInfo sendNssMsgInfo; sendNssMsgInfo.SetNeedXml(TYPE_NSS_XML); sendNssMsgInfo.SetNetElemType(NET_ELE_SMU_NSS); sendNssMsgInfo.SetReqID(NSS_GET_RECORD_PLAN_REQ); sendNssMsgInfo.SetReqData(pReqPlan); sendNssMsgInfo.SetCameraCode(chDevCode); sendNssMsgInfo.SetDomainCode(chDomaCode); std::string strpRsp; IVS_INT32 iNeedRedirect = IVS_FAIL; iRet = m_UserMgr->SendCmd(sendNssMsgInfo,strpRsp,iNeedRedirect); if(IVS_SUCCEED != iRet) { BP_RUN_LOG_INF("Get Platform Record Plan", "ok", "Get Platform RecordPlan Success.pResultList size is 0."); return iRet; } // 将xml转化成结构体返回 CXml xmlRsp; (void)xmlRsp.Parse(strpRsp.c_str()); IVS_INT32 iParseRSPRet = CRecordXMLProcess::GetRecordPlanParseRSP(pRecordPlan,xmlRsp); BP_RUN_LOG_INF("Get Record Plan", "ok", "msg have Parsed"); return iRet; }//lint !e1762 !e818 !e529
// 修改AlarmInCode IVS_INT32 CXmlProcess::SetAlarmInCodeValue(const IVS_CHAR* pPath, CXml& xml) { CHECK_POINTER(pPath, IVS_OPERATE_MEMORY_ERROR); if (!xml.FindElemEx(pPath)) { BP_RUN_LOG_ERR(IVS_XML_INVALID, "SetAlarmInCodeValue", "xml.FindElemEx(pPath)"); return IVS_XML_INVALID; } const IVS_CHAR* pElemValue = xml.GetElemValue(); IVS_CHAR szAlarmInCode[IVS_ALARM_CODE_LEN + 1] = {0}; IVS_CHAR szDomainCode[IVS_DOMAIN_CODE_LEN + 1] = {0}; IVS_INT32 iRet = CXmlProcess::ParseDevCode(pElemValue, szAlarmInCode, szDomainCode); xml.ModifyElemValue(szAlarmInCode); return iRet; }
//Wirtualna metoda ³aduj¹ca dane z xml ³aduje cechy CMonster bool CMonsterTemplate::Load(CXml &xml) { //sprawdzamy, czy xml zawiera informacjê, ¿e jest potwór if (xml.GetString(xml.GetRootNode(), "type") != "monster") return false; //sprawdzamy, czy mo¿na za³adowaæ dane z klasy bazowej if (!CActorTemplate::Load(xml)) return false; //gdyby w klasie CMonster by³y jakieœ pola //to tutaj, w klasie jej fabryki //nale¿a³oby wczytaæ te pola z pliku xml, //aby fabryka by³a kompletna return true; }
//视频上墙 ELTE_INT32 CMediaMgr::VWallStart(const ELTE_CHAR* pResourceID, const ELTE_CHAR* pVideoParam) const { LOG_TRACE(); if(NULL == m_pUserMgr) { LOG_RUN_ERROR("UserMgr is null."); return eLTE_SDK_ERR_NULL_POINTER; } CXml reqXml; if(!reqXml.Parse(pVideoParam)) { LOG_RUN_ERROR("ReqXml parse failed, param is %s.", pVideoParam); return eLTE_SDK_ERR_XML_PARSE; } if(!reqXml.FindElem("Content")) { LOG_RUN_ERROR("Find 'Content' failed, reqXml is %s.", pVideoParam); return eLTE_SDK_ERR_XML_FIND_ELEM; } (void)reqXml.IntoElem(); (void)reqXml.AddElemBeforeCurNode("ResourceID"); (void)reqXml.SetElemValue(pResourceID); ELTE_UINT32 xmlLen = 0; LOG_RUN_INFO("ReqXml is %s.", reqXml.GetXMLStream(xmlLen)); //发送消息 SSL_Socket& socket = const_cast<SSL_Socket&>(m_pUserMgr->GetSSLSocket()); MutexLocker Locker(m_pUserMgr->GetMutexHandle()); ELTE_INT32 iRet = socket.SendMsg(ELTE_SERVICE_VWALLSTART_REQ, reqXml, TRUE); if(eLTE_SDK_ERR_SUCCESS != iRet) { return iRet; } iRet = m_pUserMgr->WaitObject(WAIT_OBJECT_TIME); if (eLTE_SDK_ERR_SUCCESS != iRet) { CServerMgr& serverMgr = const_cast<CServerMgr&>(m_pUserMgr->GetServerMgr()); if(!serverMgr.ServerIsRunning() || 0 != m_pUserMgr->GetServerStatus()) { m_pUserMgr->SetServerStatus(0); return eLTE_SDK_ERR_SERVER_NOT_RUNNING; } return iRet; } const PACKET_DATA& packetData = m_pUserMgr->GetPacketData(); iRet = packetData.RspCode; ::ResetEvent(m_pUserMgr->GetEventHandle()); if (eLTE_SDK_ERR_SUCCESS != iRet) { LOG_RUN_ERROR("GetPacketData failed."); } return iRet; }
//解析密钥值 IVS_INT32 CMediaXMLProcess::ParseStreamencryKey(CXml& xmlRsq,char* pStreamencryKey) { if (NULL == pStreamencryKey) { BP_RUN_LOG_ERR(IVS_FAIL, "Streamencry Key Space is NULL", "Get Streamencry Key Error"); return IVS_FAIL; } const char*AttriValue = NULL; //临时存储单个节点值 if (xmlRsq.FindElemEx("Content")) { (void)xmlRsq.IntoElem(); GET_ELEM_VALUE_CHAR("StreamEncryPWD", AttriValue, pStreamencryKey, ENCRY_KEY_LEN, xmlRsq); // memcpy(pStreamencryKey,AttriValue,IVS_PWD_LEN); return IVS_SUCCEED; } BP_RUN_LOG_ERR(IVS_FAIL, "Parse Streamencry Key XML", "Get Streamencry Key Error"); return IVS_FAIL; }
//目录共享 IVS_INT32 CDomainRouteMgr::SetShareCatalog(const IVS_CHAR* pShareInfo) { if (NULL == pShareInfo) { BP_RUN_LOG_ERR(IVS_FAIL, "Share Cata log", "Cmd is NULL"); return IVS_FAIL; } std::string strShareCatalog(pShareInfo); std::string strSendCmd; CXml xml; if (!xml.Parse(pShareInfo)) { BP_RUN_LOG_ERR(IVS_XML_INVALID, "xml.Parse(pShareInfo) fail", "NA"); return IVS_XML_INVALID; } //if (!xml.FindElemEx("Content/ExDomainInfo/ExDomainCode")) //{ // BP_RUN_LOG_ERR(IVS_XML_INVALID, "xml.FindElemEx(Content/ExDomainInfo) fail", "NA"); // return IVS_XML_INVALID; //} //const IVS_CHAR* pExDomainCode = xml.GetElemValue(); IVS_INT32 iRet = SplitDevDomainCode(strShareCatalog,strSendCmd); if (IVS_SUCCEED != iRet) { BP_RUN_LOG_ERR(IVS_FAIL, "Share Cata log", "XML illegal "); return iRet; } // 构造带域的请求消息,并发送 CSendNssMsgInfo sendNssMsgInfo; sendNssMsgInfo.SetNeedXml(TYPE_NSS_XML); sendNssMsgInfo.SetNetElemType(NET_ELE_SMU_NSS); sendNssMsgInfo.SetReqID(NSS_SHARE_CATALOG_REQ); sendNssMsgInfo.SetReqData(strSendCmd.c_str()); std::string strpRsp; IVS_INT32 iNeedRedirect = IVS_FAIL; iRet = m_pUserMgr->SendCmd(sendNssMsgInfo,strpRsp,iNeedRedirect); return iRet; }//lint !e1762
ELTE_INT32 CMediaMgr::StopRealPlay(const ELTE_CHAR* pResourceID) const { LOG_TRACE(); if(NULL == m_pUserMgr) { LOG_RUN_ERROR("UserMgr is null."); return eLTE_SDK_ERR_NULL_POINTER; } CXml reqXml; (void)reqXml.AddElem("Content"); (void)reqXml.AddChildElem("ResourceID"); (void)reqXml.IntoElem(); (void)reqXml.SetElemValue(pResourceID); //发送消息 SSL_Socket& socket = const_cast<SSL_Socket&>(m_pUserMgr->GetSSLSocket()); MutexLocker Locker(m_pUserMgr->GetMutexHandle()); ELTE_INT32 iRet = socket.SendMsg(ELTE_SERVICE_STOPREALPLAY_REQ, reqXml, TRUE); if(eLTE_SDK_ERR_SUCCESS != iRet) { return iRet; } iRet = m_pUserMgr->WaitObject(WAIT_OBJECT_TIME); if (eLTE_SDK_ERR_SUCCESS != iRet) { CServerMgr& serverMgr = const_cast<CServerMgr&>(m_pUserMgr->GetServerMgr()); if(!serverMgr.ServerIsRunning() || 0 != m_pUserMgr->GetServerStatus()) { m_pUserMgr->SetServerStatus(0); return eLTE_SDK_ERR_SERVER_NOT_RUNNING; } return iRet; } iRet = m_pUserMgr->GetPacketData().RspCode; ::ResetEvent(m_pUserMgr->GetEventHandle()); if(eLTE_SDK_ERR_SUCCESS == iRet && !CUserMgr::m_iBypass) { SharedMemoryMgr::Instance().DeleteSharedMemory(pResourceID); } return iRet; }
// 删除角色 IVS_INT32 CRoleMgr::DeleteRole(const IVS_CHAR* pDomainCode, IVS_UINT32 uiRoleID) { CHECK_POINTER(m_UserMgr, IVS_OPERATE_MEMORY_ERROR); IVS_DEBUG_TRACE(""); std::string strDomainCode; if(NULL == pDomainCode || '\0' == pDomainCode[0]) { m_UserMgr->GetDomainCode(strDomainCode); } else { strDomainCode = pDomainCode; } IVS_ROLE_INFO pRoleInfo; memset(&pRoleInfo, 0, sizeof(IVS_ROLE_INFO)); pRoleInfo.uiRoleID = uiRoleID; //拼接请求信息 IVS_INT32 iRet = IVS_FAIL; CXml xmlReq; CUserInfoMgrXMLProcess::GetRoleXML(strDomainCode.c_str(), &pRoleInfo, xmlReq); unsigned int xmlLen = 0; const IVS_CHAR* pReq = xmlReq.GetXMLStream(xmlLen); CHECK_POINTER(pReq, IVS_OPERATE_MEMORY_ERROR); // 构造带域的请求消息,并发送 CSendNssMsgInfo sendNssMsgInfo; sendNssMsgInfo.SetNeedXml(TYPE_NSS_NOXML); sendNssMsgInfo.SetNetElemType(NET_ELE_SMU_NSS); sendNssMsgInfo.SetReqID(NSS_DEL_ROLE_REQ); sendNssMsgInfo.SetReqData(pReq); sendNssMsgInfo.SetDomainCode(strDomainCode); std::string strpRsp; IVS_INT32 iNeedRedirect = IVS_FAIL; iRet = m_UserMgr->SendCmd(sendNssMsgInfo,strpRsp,iNeedRedirect); return iRet; }
// add by zwx211831, Date:20140605 处理客户端关闭视频业务通知 int CSDKMainctrl::OnShutdownStreamNotify(CCmd* pCmd) const { CHECK_POINTER(pCmd, IVS_OPERATE_MEMORY_ERROR); IVS_INT32 iRet = IVS_FAIL; IVS_CHAR *pInfo = CNSSOperator::instance().ParseCmd2XML(pCmd, iRet); CHECK_POINTER(pInfo, IVS_OPERATE_MEMORY_ERROR); IVS_SHUTDOWN_NOTIFY_INFO stShutdownNotifyInfo = {0}; if (IVS_SUCCEED == iRet) { CXml xmlRsp; if (!xmlRsp.Parse(pInfo)) { BP_RUN_LOG_ERR(IVS_XML_INVALID, "OnShutdownStreamNotify", "XML parse failed"); HW_DELETE_A(pInfo); return IVS_XML_INVALID; } iRet = CRealXMLProcess::ParseShutdownNotifyXML(xmlRsp, &stShutdownNotifyInfo); } if (IVS_SUCCEED != iRet) { BP_RUN_LOG_ERR(IVS_XML_INVALID, "OnShutdownStreamNotify", "XML parse failed"); HW_DELETE_A(pInfo); return IVS_XML_INVALID; } IVS_INT32 iSessionID = CLinkRouteMgr::instance().FindSessionIDByLinkID(pCmd->GetNetLinkID()); if (SDK_SESSIONID_INIT == iSessionID) { BP_RUN_LOG_ERR(IVS_SDK_RET_INVALID_SESSION_ID, "OnShutdownStreamNotify", "iSessionID is -1"); HW_DELETE_A(pInfo); return IVS_SDK_RET_INVALID_SESSION_ID; } (void)CEventCallBackJob::instance().PostEvent(iSessionID, IVS_EVENT_SHUTDOWN_STREAM, &stShutdownNotifyInfo, sizeof(stShutdownNotifyInfo)); HW_DELETE_A(pInfo); return IVS_SUCCEED; }
// 修改角色 IVS_INT32 CRoleMgr::ModifyRole(const IVS_ROLE_INFO* pRoleInfo) { CHECK_POINTER(m_UserMgr, IVS_OPERATE_MEMORY_ERROR); CHECK_POINTER(pRoleInfo, IVS_PARA_INVALID); IVS_DEBUG_TRACE(""); // 防止域编码达到临界值无结束符“\0” modify by xiongfeng std::string strDomainCode; char cDomainCodeTmp[IVS_DOMAIN_CODE_LEN + 1] = {0}; (void)CToolsHelp::Memcpy(cDomainCodeTmp, IVS_DOMAIN_CODE_LEN, pRoleInfo->cDomainCode, IVS_DOMAIN_CODE_LEN); strDomainCode = cDomainCodeTmp; if (strDomainCode.empty()) { m_UserMgr->GetDomainCode(strDomainCode); } //拼接修改角色xml请求 IVS_INT32 iRet = IVS_FAIL; CXml xmlReq; CUserInfoMgrXMLProcess::GetRoleXML(strDomainCode.c_str(), pRoleInfo, xmlReq); unsigned int xmlLen = 0; const IVS_CHAR* pReq = xmlReq.GetXMLStream(xmlLen); CHECK_POINTER(pReq, IVS_OPERATE_MEMORY_ERROR); // 构造带域的请求消息,并发送 CSendNssMsgInfo sendNssMsgInfo; sendNssMsgInfo.SetNeedXml(TYPE_NSS_NOXML); sendNssMsgInfo.SetNetElemType(NET_ELE_SMU_NSS); sendNssMsgInfo.SetReqID(NSS_MOD_ROLE_REQ); sendNssMsgInfo.SetReqData(pReq); sendNssMsgInfo.SetDomainCode(strDomainCode); std::string strpRsp; IVS_INT32 iNeedRedirect = IVS_FAIL; iRet = m_UserMgr->SendCmd(sendNssMsgInfo,strpRsp,iNeedRedirect); return iRet; }
ELTE_INT32 CMediaMgr::PTZControl(const ELTE_CHAR* pResourceID, ELTE_UINT32 iPTZControlCode, ELTE_UINT32 iPTZControlValue) const { LOG_TRACE(); if(NULL == m_pUserMgr) { LOG_RUN_ERROR("UserMgr is null."); return eLTE_SDK_ERR_NULL_POINTER; } CXml reqXml; (void)reqXml.AddElem("Content"); (void)reqXml.AddChildElem("ResourceID"); (void)reqXml.IntoElem(); (void)reqXml.SetElemValue(pResourceID); (void)reqXml.AddElem("PTZControlCode"); (void)reqXml.SetElemValue(eLTE_Tool::UInt2String(iPTZControlCode).c_str()); (void)reqXml.AddElem("PTZControlValue"); (void)reqXml.SetElemValue(eLTE_Tool::UInt2String(iPTZControlValue).c_str()); //发送消息 SSL_Socket& socket = const_cast<SSL_Socket&>(m_pUserMgr->GetSSLSocket()); MutexLocker Locker(m_pUserMgr->GetMutexHandle()); ELTE_INT32 iRet = socket.SendMsg(ELTE_SERVICE_PTZCONTROL_REQ, reqXml, TRUE); if(eLTE_SDK_ERR_SUCCESS != iRet) { return iRet; } iRet = m_pUserMgr->WaitObject(WAIT_OBJECT_TIME); if (eLTE_SDK_ERR_SUCCESS != iRet) { CServerMgr& serverMgr = const_cast<CServerMgr&>(m_pUserMgr->GetServerMgr()); if(!serverMgr.ServerIsRunning() || 0 != m_pUserMgr->GetServerStatus()) { m_pUserMgr->SetServerStatus(0); return eLTE_SDK_ERR_SERVER_NOT_RUNNING; } return iRet; } iRet = m_pUserMgr->GetPacketData().RspCode; ::ResetEvent(m_pUserMgr->GetEventHandle()); return iRet; }
void CXmlProcess::SetElemValueStr(const IVS_CHAR* pXmlValue,IVS_UINT32 ulLength,CXml &xml) { CHECK_POINTER_VOID(pXmlValue); IVS_CHAR* pXmlNewValue = IVS_NEW((IVS_CHAR* &)pXmlNewValue,ulLength+1); CHECK_POINTER_VOID(pXmlNewValue); memset(pXmlNewValue,0,ulLength+1); if (!CToolsHelp::Memcpy(pXmlNewValue, ulLength+1, pXmlValue, ulLength)) { BP_RUN_LOG_ERR(IVS_ALLOC_MEMORY_ERROR, "CToolsHelp::Memcpy fail", "NA"); IVS_DELETE(pXmlNewValue,MUILI); return; } (void)xml.SetElemValue(pXmlNewValue); IVS_DELETE(pXmlNewValue,MUILI); }
//查询MU的资源预算是否达到上限及当前摄像机视频流是否被引用 IVS_INT32 CMediaXMLProcess::VideoNumAndResourceGetXML(const std::string& strCameraCode, CXml &xml) { IVS_DEBUG_TRACE(""); (void)xml.AddDeclaration("1.0", "UTF-8", ""); (void)xml.AddElem("Content"); (void)xml.AddChildElem("CameraCode"); (void)(xml.IntoElem()); (void)xml.SetElemValue(strCameraCode.c_str()); xml.OutOfElem(); return IVS_SUCCEED; }
// 构建选中图形消息XML IVS_INT32 COCXDrawXMLProcess::SelectGraphicGetXML(CString &xmlToCU, IVS_ULONG ulGraphicGroup) { IVS_DEBUG_TRACE("GraphicGroup: %lu", ulGraphicGroup); CXml xmlGraphics; char val[64] = {0}; unsigned int uiLen = 0; CHECK_SUCCESS(xmlGraphics.AddDeclaration("1.0","UTF-8","")); CHECK_SUCCESS(xmlGraphics.AddElem("Content")); CHECK_SUCCESS(xmlGraphics.AddChildElem("GraphicGroup")); CHECK_SUCCESS(xmlGraphics.IntoElem()); SET_ELEMENT_LONG(ulGraphicGroup, val, xmlGraphics); xmlGraphics.OutOfElem(); xmlToCU = xmlGraphics.GetXMLStream(uiLen); return IVS_SUCCEED; }