// 获取IADraw句柄
IVS_DRAW_API DRAW_HANDLE Draw_GetHandle()
{
	CIADrawer *pIADrawer = IVS_NEW(pIADrawer);
	if (NULL == pIADrawer)
	{
		IVS_LOG(IVS_LOG_ERR, "Get Handle", "ALLOC MEM ERROR.");
		return (DRAW_HANDLE)NULL;
	}
	return (DRAW_HANDLE)pIADrawer;
}
// 解析出内存的XML,需要释放返回的内存
char* CNSSOperator::ParseCmd2XML(CCmd* pCmd, int& iRspCode) const
{
	CHECK_POINTER(pCmd, NULL);

	// 解码出头部和xml放在m_nssXML对象中
	CNssXMLMsg nssXML;
	uint32_t iRet = nssXML.decode(pCmd->GetMsgBlock()); 
	if(NssRet_Succeed != iRet)
	{
        BP_RUN_LOG_ERR(IVS_FAIL,"decode cmd failed", "iDecodeRet = %d", iRet);
		iRspCode = IVS_FAIL;
		return NULL;
	}
	// 返回错误码
	iRspCode = nssXML.GetHeader().uiRspCode; //lint !e10 !e713 无此问题 
    
	// 拷贝XML 返回给外部调用
    const char* xml = nssXML.GetXML(); //lint !e64 匹配
    if (NULL  == xml)
    {
		BP_RUN_LOG_ERR(iRspCode, "xml is null", "NA");
        return NULL;
    }
	// 将utf8->ansi
	char* xml2ANSI = CToolsHelp::UTF8ToANSI(xml);
    if (NULL == xml2ANSI)
    {
        BP_RUN_LOG_ERR(iRspCode, "xml2ANSI is null", "NA");
        return NULL;
    }
	unsigned int length = strlen(xml2ANSI);

	char* xmlBuf = IVS_NEW(xmlBuf,length+1);
	if (NULL == xmlBuf)
	{
		BP_RUN_LOG_ERR(IVS_ALLOC_MEMORY_ERROR, "memcpy fail", "NA");
		free(xml2ANSI);
		return NULL;
	}
	if (!CToolsHelp::Memcpy(xmlBuf, length+1, xml2ANSI, length+1))
	{
		free(xml2ANSI);
		xml2ANSI = NULL;
		free(xmlBuf);
		xmlBuf = NULL;
		BP_RUN_LOG_ERR(IVS_ALLOC_MEMORY_ERROR, "memcpy fail", "NA");
		return NULL;
	}
	
	free(xml2ANSI);
	return xmlBuf;
}
//获取空闲的realplay对象;
CRealPlay *CRealPlayMgr::GetFreeRealPlay(IVS_ULONG& ulHandle)
{
	IVS_DEBUG_TRACE("");
	(void)VOS_MutexLock(m_pHanleRealPlayMutex);
	CRealPlay *pRealPlay = NULL;
	HandleRealPlayMapIter realplayIter = m_HanleRealPlayMap.begin();
    HandleRealPlayMapIter realplayIterEnd = m_HanleRealPlayMap.end();

	//查找空闲对象;
	for (; realplayIter != realplayIterEnd; realplayIter++)
	{
        pRealPlay = dynamic_cast<CRealPlay*>(realplayIter->second);//lint !e611
		if (NULL != pRealPlay)
		{
			if (pRealPlay->GetStatus() == MEDIA_STATUS_FREE)
			{
				break;
			}
		}
		pRealPlay = NULL;
	}

	if (NULL != pRealPlay)
	{
		m_HanleRealPlayMap.erase(realplayIter);
	}
	else
	{
		pRealPlay = IVS_NEW((CRealPlay*&)pRealPlay);
		if (NULL == pRealPlay)
		{
			BP_RUN_LOG_ERR(IVS_ALLOC_MEMORY_ERROR,"Get Free RealPlay", "create real play error");
			(void)VOS_MutexUnlock(m_pHanleRealPlayMutex);
			return NULL;
		}
	}

	//初始化realplay对象;
	pRealPlay->SetUserMgr(m_pUserMgr);
	pRealPlay->SetStatus(MEDIA_STATUS_BUSY);

	//插入列表;
    ulHandle = (unsigned long)pRealPlay;
	(void)m_HanleRealPlayMap.insert(std::make_pair(ulHandle, pRealPlay));

	pRealPlay->SetHandle(ulHandle);

	(void)VOS_MutexUnlock(m_pHanleRealPlayMutex);
	return pRealPlay;
}
 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);
 }
CTPPlayChannel* CTelepresenceMgr::GetPlayChannel(IVS_ULONG ulHandle, IVS_BOOL bCreate)
{
	IVS_DEBUG_TRACE("");
	CLockGuard autoLock(m_pChannelMapMutex);
	CTPPlayChannel* pPlayChannel = NULL;
	TP_PLAY_CHANNEL_MAP::iterator ite = m_channelMap.find(ulHandle);
	if(ite!=m_channelMap.end())
	{
		pPlayChannel = dynamic_cast<CTPPlayChannel*>(ite->second);//lint !e611
	}
	if(NULL==pPlayChannel && bCreate)
	{
		pPlayChannel = IVS_NEW(pPlayChannel);
		m_channelMap.insert(TP_PLAY_CHANNEL_MAP::value_type((IVS_ULONG)pPlayChannel, pPlayChannel));
	}
	return pPlayChannel;
}
예제 #6
0
//根据句柄获取空闲对象
CAudioObj* CAudioMgr::GetFreeTalkBack(IVS_ULONG& ulHandle)
{
    CLockGuard lock(m_pHandleTalkBackMutex);
    CAudioObj *pTalkback = NULL;
    HandleTalkBackMapIter talkbackIter = m_HanleTalkBackMap.begin();
    HandleTalkBackMapIter talkbackIterEnd = m_HanleTalkBackMap.end();

    //查找空闲对象;
    for (; talkbackIter != talkbackIterEnd; talkbackIter++)
    {
        pTalkback = dynamic_cast<CAudioObj*>(talkbackIter->second);//lint !e611
        if (NULL != pTalkback)
        {
            if (MEDIA_STATUS_FREE == pTalkback->GetStatus())
            {
                break;
            }
        }
        pTalkback = NULL;
    }

    if (NULL != pTalkback)
    {
        m_HanleTalkBackMap.erase(talkbackIter);
    }
    else
    {
        pTalkback = IVS_NEW((CAudioObj*&)pTalkback);
        if (NULL == pTalkback)
        {
            BP_RUN_LOG_ERR(IVS_OPERATE_MEMORY_ERROR, "Get Free Talkback", "create talkback error");
            return NULL;
        }
    }

    //初始化talkback对象;
    pTalkback->SetUserMgr(m_pUserMgr);
    pTalkback->SetStatus(MEDIA_STATUS_BUSY);

    //插入列表;
    ulHandle = reinterpret_cast<unsigned long>(pTalkback);
    (void)m_HanleTalkBackMap.insert(std::make_pair(ulHandle, pTalkback));

    pTalkback->SetHandle(ulHandle);
    return pTalkback;
}
// 获取Cmd中的数据指针,这块数据也要在外部释放
char* CNSSOperator::ParseCmd2Data(CCmd* pCmd, int& length)
{
	CHECK_POINTER(pCmd, NULL);
	CNssMsgBase nssMsg;
 	char* pData = nssMsg.GetContentBuff(pCmd->GetMsgBlock());
	if (NULL == pData)
	{
		BP_RUN_LOG_ERR(IVS_FAIL,"get buffer is null", "NA");
		length = 0;
		return NULL;
	}
	length = nssMsg.GetContentLength(pCmd->GetMsgBlock());
	char* xmlBuf = IVS_NEW(xmlBuf, (unsigned long)length); //lint !e737  // 这里的内存需要在外部释放掉
	if (!CToolsHelp::Memcpy(xmlBuf, (unsigned int)length, pData, (unsigned int)length))
	{
		BP_RUN_LOG_ERR(IVS_ALLOC_MEMORY_ERROR, "memcpy fail", "NA");
		return NULL;
	}

	return xmlBuf;
}//lint !e1762
// 断连通知
IVS_VOID CSDKDecoderMgr::NotifyDisConnect(IVS_ULONG ulIdentifyID)
{
	std::string strDecoderId;
	(void)VOS_MutexLock(m_pDecoderInfoMapMutex);
	for(SDK_DECODER_INFO_MAP::iterator ite=m_decoderInfoMap.begin();ite!=m_decoderInfoMap.end();ite++)
	{
		SDK_DECODER_INFO* pInfo = dynamic_cast<SDK_DECODER_INFO*>(ite->second);//lint !e611
		if(NULL!=pInfo)
		{
			if(ulIdentifyID==pInfo->ulIdentifyID)
			{
				strDecoderId = pInfo->szDecoderID;
				pInfo->bOnline = FALSE;
				pInfo->ulIdentifyID = 0;
				break;
			}
		}
	}
	(void)VOS_MutexUnlock(m_pDecoderInfoMapMutex);
	if(NULL!=m_pCallBackFun && NULL!=m_pUserData && strDecoderId.length()>0)
	{			
		CUMW_NOTIFY_INFO stNotifyInfo = {0};
		CUMW_NOTIFY_REMOTE_DECODER_OFF_LINE_INFO* pstOffline = IVS_NEW(pstOffline);
		if(NULL!=pstOffline)
		{
			stNotifyInfo.ulNotifyType = CUMW_NOTIFY_TYPE_REMOTE_DECODER_DISCONNECT;
			stNotifyInfo.pNotifyInfo = pstOffline;
			stNotifyInfo.ulNotifyInfoLen = sizeof(CUMW_NOTIFY_REMOTE_DECODER_OFF_LINE_INFO);
			if(CToolsHelp::Strncpy(pstOffline->szDecoderID, sizeof(pstOffline->szDecoderID), strDecoderId.c_str(), strDecoderId.length()))
			{
				(void)m_pCallBackFun(&stNotifyInfo, m_pUserData);
			}
			else
			{
				BP_RUN_LOG_ERR(IVS_ALLOC_MEMORY_ERROR, "Decoder disconnect", "Copy Decoder ID Failed");
			}
			IVS_DELETE(pstOffline);
		}
	}
}
CRealPlay *CRealPlayMgr::GetFreeRealPlayEx(IVS_ULONG& ulHandle)
{
	CRealPlay *pRealPlay = NULL;
	pRealPlay = IVS_NEW((CRealPlay*&)pRealPlay);
	if (NULL == pRealPlay)
	{
		BP_RUN_LOG_ERR(IVS_ALLOC_MEMORY_ERROR,"Get Free RealPlayEx", "create real play error");
		return NULL;
	}

	BP_DBG_LOG("Get Free RealPlayEx", "CreateHandle %u", (unsigned long)pRealPlay);
	
	ulHandle = (unsigned long)pRealPlay;
	pRealPlay->SetHandle(ulHandle);
	pRealPlay->SetUserMgr(m_pUserMgr);

	(void)VOS_MutexLock(m_pHanleRealPlayMutex);
	(void)m_HanleRealPlayMap.insert(std::make_pair(ulHandle, pRealPlay));
	(void)pRealPlay->GetRef();
	(void)VOS_MutexUnlock(m_pHanleRealPlayMutex);

	return pRealPlay;
}
int CSDKMainctrl::OnDevAlarmNotify(CCmd* pCmd)const
{
	BP_RUN_LOG_INF("OnDevAlarmNotify", "Begin");
	CHECK_POINTER(pCmd, IVS_OPERATE_MEMORY_ERROR);
	IVS_CHAR* pData = IVS_NEW(pData, sizeof(IVS_DEVICE_ALARM_NOTIFY));
    CHECK_POINTER(pData, IVS_OPERATE_MEMORY_ERROR);
	memset(pData, 0x0, sizeof(IVS_DEVICE_ALARM_NOTIFY));
	IVS_DEVICE_ALARM_NOTIFY* pDevAlarmNotify = reinterpret_cast<IVS_DEVICE_ALARM_NOTIFY*>(pData); //lint !e826
//     if (NULL == pDevAlarmNotify)
//     {
//         BP_RUN_LOG_ERR(IVS_SDK_RET_INTRINSIC_PTR_ERROR, "pDevAlarmNotify is null", "NA");
//         IVS_DELETE(pData, MUILI);
//         return IVS_SDK_RET_INTRINSIC_PTR_ERROR;
//     }
	IVS_INT32 iRet = CSDKMainService::ProcessDevAlarmNotify(pCmd, pDevAlarmNotify);
	
	// NSS头
	TNssMsgHeader m_header;
	memset(&m_header, 0, sizeof(TNssMsgHeader));
	m_header.usiProtocolVersion = 0x0100;
	m_header.usiMsgType = NSS_OMU_ALARM_CU_REPORT_RSP;
	m_header.uiSeqID = 0; 
	m_header.uiTraceID = 0;
	if (!CToolsHelp::Strncpy(m_header.szTransactionNo, TRANSACTIONNO_LEN, pCmd->GetTransID().c_str(), strlen(pCmd->GetTransID().c_str())))
	{
		BP_RUN_LOG_ERR(IVS_ALLOC_MEMORY_ERROR, "CToolsHelp::Strncpy(m_header.szTransactionNo, TRANSACTIONNO_LEN, pCmd->GetTransID().c_str(), 64)", "NA");
		IVS_DELETE(pData, MUILI);
		return IVS_ALLOC_MEMORY_ERROR;
	}
	m_header.uiRspCode = static_cast<IVS_UINT32>(iRet);  
	m_header.uiPacketLength = sizeof(TNssMsgHeader);

	// 转换网络字节序
	m_header.usiProtocolVersion = ntohs(m_header.usiProtocolVersion);
	m_header.usiMsgType = ntohs(m_header.usiMsgType);
	m_header.uiSeqID = ntohl(m_header.uiSeqID);
	m_header.uiTraceID = ntohl(m_header.uiTraceID);
	m_header.uiRspCode = ntohl(m_header.uiRspCode);
	m_header.uiPacketLength = ntohl(m_header.uiPacketLength);

	// 定义ACE的消息缓冲,这个在cmd里面去释放,这里不释放
	ACE_Message_Block* pMsgBlock = new ACE_Message_Block(sizeof(TNssMsgHeader)); 

	pMsgBlock->copy((char*)&m_header, sizeof(TNssMsgHeader));
	CDispatcher::instance().dispatcherOutWithoutTransaction(pCmd->GetNetElemType(), pCmd->GetNetLinkID().c_str(), pCmd->GetTransID().c_str(), NSS_OMU_ALARM_CU_REPORT_RSP, pMsgBlock);
	if (IVS_SUCCEED == iRet)
	{
		int iSessionID = CLinkRouteMgr::instance().FindSessionIDByLinkID(pCmd->GetNetLinkID());  //lint !e1013 !e1055 !e746 !e64
		if (SDK_SESSIONID_INIT == iSessionID)
		{
			BP_RUN_LOG_ERR(IVS_FAIL, "session id invalid","NA");
			IVS_DELETE(pData, MUILI);
			return IVS_FAIL;
		}	

		// utf8->ansi
		char cAlarmDest[IVS_ALARM_DESCRIPTION_LEN + 1] = {0};
		(void)CToolsHelp::Memcpy(cAlarmDest, IVS_ALARM_DESCRIPTION_LEN, pDevAlarmNotify->cAlarmDest,IVS_ALARM_DESCRIPTION_LEN);
		char* pAlarmDest = CToolsHelp::UTF8ToANSI(cAlarmDest);
		if (NULL != pAlarmDest)
		{
			// 清理掉先
			memset(pDevAlarmNotify->cAlarmDest, 0, IVS_ALARM_DESCRIPTION_LEN);
			(void)CToolsHelp::Memcpy(pDevAlarmNotify->cAlarmDest, IVS_ALARM_DESCRIPTION_LEN, pAlarmDest,strlen(pAlarmDest));
			free(pAlarmDest);
			pAlarmDest = NULL;
		}

		char cAlarmInName[IVS_ALARM_NAME_LEN + 1] = {0};
		(void)CToolsHelp::Memcpy(cAlarmInName, IVS_ALARM_NAME_LEN, pDevAlarmNotify->cAlarmInName,IVS_ALARM_NAME_LEN);
		char* pAlarmInName = CToolsHelp::UTF8ToANSI(cAlarmInName);
		if (NULL != pAlarmInName)
		{
			// 清理掉先
			memset(pDevAlarmNotify->cAlarmInName, 0, IVS_ALARM_NAME_LEN);
			(void)CToolsHelp::Memcpy(pDevAlarmNotify->cAlarmInName, IVS_ALARM_NAME_LEN, pAlarmInName,strlen(pAlarmInName));
			free(pAlarmInName);
			pAlarmInName = NULL;
		}

		CEventCallBackJob::instance().PostEvent(iSessionID, IVS_EVENT_OMU_REPORT_ALARM, pDevAlarmNotify, sizeof(IVS_DEVICE_ALARM_NOTIFY));
	}
    IVS_DELETE(pData, MUILI);
	BP_RUN_LOG_INF("OnDevAlarmNotify", "End");
	return iRet;
}
예제 #11
0
// 查询摄像机计划设置信息
IVS_INT32 CRecordPlanMgr::GetCameraPlanInfo(IVS_UINT32 uiPlanType, IVS_CHAR** pRspXml)
{
    CHECK_POINTER(m_UserMgr, IVS_OPERATE_MEMORY_ERROR);
    IVS_DEBUG_TRACE("");

    IVS_INT32 iRet = IVS_FAIL;
    std::vector<std::string> domainCodeList;
    domainCodeList.clear();
    iRet = m_UserMgr->GetDeviceMgr().GetDomainListByUserID(domainCodeList);
    if(IVS_SUCCEED != iRet)
    {
        BP_RUN_LOG_ERR(iRet, "Get Domain List By User ID","Failed");
        return iRet;
    }

    CmdMap cmdMap;

    std::map<std::string, std::string> domainCodeMap;
    std::map<std::string, std::string>::iterator domainCodeMapIter;
    IVS_UINT32 iSize = domainCodeList.size();
    for(IVS_UINT32 i = 0; i < iSize; i++)
    {
        std::string strDomainCode = domainCodeList.at(i);

        CXml xmlReq;
        CRecordXMLProcess::GetCameraPlanInfoGetXML(uiPlanType, strDomainCode.c_str(), 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_GET_CAMERA_PLAN_INFO_REQ);
        sendNssMsgInfo.SetReqData(pReq);
        sendNssMsgInfo.SetDomainCode(strDomainCode);

        CCmd *pCmd = m_UserMgr->BuildCmd(sendNssMsgInfo);
		if (NULL == pCmd)
		{
			BP_RUN_LOG_INF("build cmd error","cmd req id=%d, domain code=%s",NSS_GET_CAMERA_PLAN_INFO_REQ,strDomainCode.c_str());
			continue;
		}
        (void)domainCodeMap.insert(std::make_pair(pCmd->GetTransID(), strDomainCode));
        (void)cmdMap.insert(std::make_pair(pCmd->GetTransID(), pCmd));
    }

    if (cmdMap.empty())
    {
        return IVS_SUCCEED;
    }
    IVS_UINT32 uiTimeout = CSDKConfig::instance().GetTimeOutValue();
    iRet = CDispatcher::instance().dispatcherSyncMsgOutBatch(cmdMap, uiTimeout);
    if(IVS_SUCCEED != iRet)
    {
        BP_RUN_LOG_ERR(iRet, "Get Camera Plan Info fail","SendCmd to SMU Return Failed");
        return iRet;
    }

    std::map<std::string, PLAN_INFO_VEC> m_PlanMap;
    CmdMapIterator cmdMapIter;
    std::string strDomainCode;
    CCmd *pCmdRsp = NULL;
    for (cmdMapIter = cmdMap.begin(); cmdMapIter != cmdMap.end(); cmdMapIter++)
    {
        domainCodeMapIter = domainCodeMap.find(cmdMapIter->first);
        if (domainCodeMapIter != domainCodeMap.end())
        {
            strDomainCode = domainCodeMapIter->second;
        }
        if(strDomainCode.empty())
        {
            continue;
        }

        pCmdRsp = static_cast<CCmd *>(cmdMapIter->second);//lint !e63
        IVS_CHAR* pRsp = CNSSOperator::instance().ParseCmd2XML(pCmdRsp, iRet);

        if (NULL == pRsp)
        {
            continue;
        }
        CXml xmlRsp;
        if(!xmlRsp.Parse(pRsp))        
        {
            BP_RUN_LOG_ERR(IVS_XML_INVALID, "Get Camera Plan Info", "xml parsing error");
            continue;
        }
        PLAN_INFO_VEC m_PlanList;
        m_PlanList.clear();
        iRet = CRecordXMLProcess::GetCameraPlanInfoParseXML(xmlRsp, m_PlanList);
        if(IVS_SUCCEED != iRet)
        {
            BP_RUN_LOG_ERR(iRet, "Get Camera PlanInfo ParseXML", "xml parsing error");
            continue;
        }
        (void)m_PlanMap.insert(std::make_pair(strDomainCode, m_PlanList));
    }
    CXml rspXml;
    CRecordXMLProcess::GetCameraPlanInfoGetXml(m_PlanMap, rspXml);
    IVS_UINT32 iLen = 0;

    const IVS_CHAR* pRsq = rspXml.GetXMLStream(iLen);
    IVS_DELETE(*pRspXml, MUILI);
    CHECK_POINTER(pRsq, IVS_OPERATE_MEMORY_ERROR);
    IVS_CHAR* pResult = IVS_NEW(pResult, strlen(pRsq) + 1);
    memset(pResult, 0x0, strlen(pRsq) + 1);
    if (!CToolsHelp::Memcpy(pResult, strlen(pRsq) + 1, pRsq, strlen(pRsq) + 1))
    {
        BP_RUN_LOG_ERR(IVS_ALLOC_MEMORY_ERROR, "CToolsHelp::Memcpy pRsq to pResult failed", "NA");
        return IVS_ALLOC_MEMORY_ERROR;
    }
    *pRspXml = pResult;

    return iRet;
}
예제 #12
0
IVS_INT32 CDomainRouteMgr::GetShareCatalogList(const IVS_CHAR* pQueryInfo, IVS_CHAR** pRspXml)
{
    CHECK_POINTER(m_pUserMgr, IVS_OPERATE_MEMORY_ERROR);
	if (NULL == pQueryInfo)
	{
		BP_RUN_LOG_ERR(IVS_FAIL, "Get Share Cata log List", "Query Info is NULL");
		return IVS_FAIL;
	}
    // 获取本域SMU连接
    std::string strSMULinkID;
    IVS_INT32 iGetLinkRet = m_pUserMgr->GetLocalDomainLinkID(NET_ELE_SMU_NSS, strSMULinkID);
    if (IVS_SUCCEED != iGetLinkRet)
    {
        BP_RUN_LOG_ERR(iGetLinkRet, "Get LocalDomainLinkID failed", "NA");
        return iGetLinkRet;
    }
	CCmd* pCmd = CNSSOperator::instance().BuildSMUCmd(NSS_GET_SHARE_CATALOG_LIST_REQ, pQueryInfo, strSMULinkID);
	CHECK_POINTER(pCmd, IVS_OPERATE_MEMORY_ERROR);
	//发送消息
	IVS_INT32 iRet = IVS_FAIL;
	CCmd *pCmdRsp = CNSSOperator::instance().SendSyncCmd(pCmd);
	CHECK_POINTER(pCmdRsp, IVS_NET_RECV_TIMEOUT);
	const char* pBefore =  CNSSOperator::instance().ParseCmd2XML(pCmdRsp, iRet);
	if (IVS_SUCCEED != iRet || NULL == pBefore)
	{
		HW_DELETE(pCmdRsp);
		BP_RUN_LOG_ERR(iRet, "Share Cata log list", "XML illegal ");
		return iRet;
	}
	HW_DELETE(pCmdRsp);
	std::string strBefore = pBefore;
	IVS_DELETE(pBefore, MUILI);
	//std::string strBefore("<Content><ShareDevList><ShareDevInfo><OriginDevCode>123456</OriginDevCode><OriginDomainCode>0123456789</OriginDomainCode><LocalDevCode>0123#001</LocalDevCode></ShareDevInfo></ShareDevList></Content>");
	//std::string strBefore("<OriginDevCode>00000010000000000301</OriginDevCode><OriginDomainCode>001</OriginDomainCode><Latitude>0</Latitude><OriginDevCode>00000010000000000201#001</OriginDevCode><OriginDomainCode>001</OriginDomainCode><LocalDevCode /><Latitude>0</Latitude><OriginDevCode>00000010000000000101#001</OriginDevCode><OriginDomainCode>001</OriginDomainCode><OriginDevCode>1</OriginDevCode><OriginDomainCode /><LocalDevCode />");
	std::string strAfter;
	iRet = ComplicationDevDomainCode(strBefore,strAfter);

	CXml xml;
	std::string strDomainCode;
	m_pUserMgr->GetDomainCode(strDomainCode);
	std::string strLocalDevCode;
	if (!xml.Parse(strAfter.c_str()))
	{
		BP_RUN_LOG_ERR(IVS_OPERATE_MEMORY_ERROR, "xml.Parse(strAfter) fail", "NA");
		return IVS_OPERATE_MEMORY_ERROR;
	}
	if (!xml.FindElemEx("Content/ShareDevList"))
	{
		BP_RUN_LOG_ERR(IVS_SMU_DEV_REQ_XML_INVALID, "xml.FindElemEx(Content/ShareDevList) fail", "NA");
		return IVS_SMU_DEV_REQ_XML_INVALID;
	}
	if (!xml.FindElem("ShareDevInfo"))
	{
		IVS_UINT32 uiXmlLen = 0;
		const IVS_CHAR* pRsp = xml.GetXMLStream(uiXmlLen);
        if (NULL == pRsp)
        {
            return IVS_SMU_DEV_REQ_XML_INVALID;
        }

		IVS_CHAR *cTmp = IVS_NEW(cTmp,strlen(pRsp) + 1);
		if (NULL == cTmp)
		{
			return IVS_ALLOC_MEMORY_ERROR;
		}
		memset(cTmp, 0, strlen(pRsp) + 1);
		memcpy(cTmp, pRsp, strlen(pRsp));
		*pRspXml = cTmp;
		return IVS_SUCCEED;
	}
	do 
	{
		(void)xml.IntoElem();
		if (!xml.FindElem("LocalDevCode"))
		{
			BP_RUN_LOG_ERR(IVS_SMU_DEV_REQ_XML_INVALID, "xml.FindElem(LocalDevCode) fail", "NA");
			return IVS_SMU_DEV_REQ_XML_INVALID;
		}
        const IVS_CHAR* pLocalDevCode =  xml.GetElemValue();
        if (NULL != pLocalDevCode)
        {
            strLocalDevCode = pLocalDevCode;
        }

		if (0 != strcmp(strLocalDevCode.c_str(), ""))
		{
			strLocalDevCode.append("#");
			strLocalDevCode.append(strDomainCode);
			xml.ModifyElemValue(strLocalDevCode.c_str());
		}
		xml.OutOfElem();
	} while (xml.NextElem());

	IVS_UINT32 uiLen = 0;
	const IVS_CHAR* pRsq = xml.GetXMLStream(uiLen);

    if (NULL == pRsq)
    {
        return IVS_SMU_DEV_REQ_XML_INVALID;
    }

	IVS_CHAR *cTmp = IVS_NEW(cTmp,strlen(pRsq) + 1);
	if (NULL == cTmp)
	{
		return IVS_ALLOC_MEMORY_ERROR;
	}
	memset(cTmp, 0, strlen(pRsq) + 1);
	memcpy(cTmp, pRsq, strlen(pRsq));
	*pRspXml = cTmp;

	return iRet;
}//lint !e1762
예제 #13
0
// 解析域路由到List
IVS_INT32 CDomainRouteMgr::GetDomainRouteToListParseXML(DOMAIN_CODE_LIST& stCodeInfoList, CXml &xmlRsp)
{
    BP_RUN_LOG_INF("Parse XML to List", "Enter");

    if (!xmlRsp.FindElemEx("Content/DomainRoutes"))
    {
        BP_RUN_LOG_ERR(IVS_XML_INVALID, "Parse XML to List",
                       "no 'Content/DomainRoutes' elemenet");
        return IVS_XML_INVALID;
    }

    if (!xmlRsp.FindElem("DomainRoute"))
    {
        BP_RUN_LOG_ERR(IVS_XML_INVALID, "Parse XML to List",
                       "no 'DevInfo' elemenet");
        return IVS_XML_INVALID;
    }

    const IVS_CHAR *pSzElement = NULL;
    IVS_UINT32 uiSTLen = sizeof(IVS_DOMAIN_ROUTE);
    const int tempLength = 10;
    IVS_CHAR tempChar[tempLength]={0};
    do
    {
        if (!xmlRsp.FindElemValue("DomainRoute"))
        {
            break;
        }

        xmlRsp.IntoElem();

        IVS_DOMAIN_ROUTE *pDomain_route = IVS_NEW(pDomain_route);

        if (NULL == pDomain_route)
        {
            return IVS_FAIL;
        }

        memset(pDomain_route, 0, uiSTLen);

        //域编码
        GET_ELEM_VALUE_CHAR("DomainCode", pSzElement, pDomain_route->cDomainCode, IVS_DOMAIN_CODE_LEN, xmlRsp);

        //域名称
        GET_ELEM_VALUE_CHAR("DomainName", pSzElement, pDomain_route->cDomainName, IVS_NAME_LEN, xmlRsp);

        //域IP
        GET_ELEM_VALUE_CHAR("DomainIP", pSzElement, pDomain_route->stIP.cIP, IVS_IP_LEN, xmlRsp);

        //域端口
        //GET_ELEM_VALUE_NUM_FOR_UINT("DomainPort", pSzElement, pDomain_route->uiPort, xmlRsp);

        //域模式
        GET_ELEM_VALUE_NUM_FOR_UINT("DomainType", pSzElement, pDomain_route->uiDomainType, xmlRsp);

        //是否代理
        GET_ELEM_VALUE_NUM("IsProxy", pSzElement, pDomain_route->bIsAgent, xmlRsp);

        //代理网段
        //GET_ELEM_VALUE_NUM("ProxySegment", pSzElement, stDomainRoute.bIsAgent, xmlRsp);

        //上级域编码
        GET_ELEM_VALUE_CHAR("SuperDomain", pSzElement, pDomain_route->cSuperDomain, IVS_DOMAIN_CODE_LEN, xmlRsp);

        GET_ELEM_VALUE_CHAR("IsOnline", pSzElement, tempChar, sizeof(tempChar) - 1, xmlRsp);

        pDomain_route->uiStatus = CDevEnum::GetDevStatusEnum(tempChar);

        //是否本域
        GET_ELEM_VALUE_NUM("IsLocalDomain", pSzElement, pDomain_route->bIsLocalDomain, xmlRsp);


        pDomain_route->uiPort = DEFAULT_SMU_PORT;
        
        stCodeInfoList.push_back(pDomain_route);
        xmlRsp.OutOfElem();
    } while (xmlRsp.NextElem());

    BP_RUN_LOG_INF("Parse XML to List", "Leave");
    return IVS_SUCCEED;
} //lint !e1762