コード例 #1
0
bool CI18N::SetLanguage(const std::string& strLanguageXMLPath)
{
    BP_RUN_LOG_INF("load language xml failed","strLanguageXMLPath %s", strLanguageXMLPath.c_str());
	CXml xml;
	if (!xml.Load(strLanguageXMLPath.c_str(), TIXML_ENCODING_UTF8))
	{
		//表示加载资源XML不成功
		BP_RUN_LOG_ERR(IVS_FAIL,"load language xml failed","NA");
		return false;
	}

	//如果加载成功了,就遍历xml将所有的资源和语言绑定并加入map表
	if (!xml.FindElemEx("Content"))
	{
		//没找到第一个结点
		return false;
	}

	//先进行清除
	Clear();

	do 
	{
		// 获取当前结点
		const char* ResourceNode = xml.GetElem();
		// 获取当前结点的值
		const char* ResourceNodeValue = xml.GetElemValue();
		// 转换编码,防止乱码
		char* xml2ANSI = CToolsHelp::UTF8ToANSI(ResourceNodeValue);
		//把结点和值绑定进行插入
		(void)VOS_MutexLock(m_pMutexLock);
		(void)m_mapResource2Language.insert(std::make_pair(ResourceNode, xml2ANSI));
		(void)VOS_MutexUnlock(m_pMutexLock);
		free(xml2ANSI);
	} while (xml.NextElem());

	return true;
}
コード例 #2
0
//对XML中的设备编码拼装与编码
int CSDKMainctrl::ModifyDevCode(CXml& xml, IVS_CHAR* pData)const
{
	CHECK_POINTER(pData, IVS_OPERATE_MEMORY_ERROR);

	if (!xml.Parse(pData))
	{
		BP_RUN_LOG_ERR(IVS_SMU_XML_INVALID, "xml.Parse(pData)", "NA");
		//IVS_DELETE(pData, MUILI);
		return IVS_SMU_XML_INVALID;
	}
	if (!xml.FindElemEx("Content/Action"))
	{
		BP_RUN_LOG_ERR(IVS_SMU_XML_INVALID, "xml.FindElem(Content/Action)", "NA");
		//IVS_DELETE(pData, MUILI);
		return IVS_SMU_XML_INVALID;		
	}
	// 若xml包含DevList,需要处理DevCode(拼接设备所在域编码DevDomainCode)
	if (xml.FindElem("DevList"))
	{
		xml.IntoElem();
		if (!xml.FindElem("DevInfo"))
		{
			BP_RUN_LOG_ERR(IVS_SMU_XML_INVALID, "xml.FindElem(DevInfo)", "NA");
			//IVS_DELETE(pData, MUILI);
			return IVS_SMU_XML_INVALID;		
		}
		do 
		{
			(void)xml.IntoElem();
			// 找到设备所在域编码拼在DevCode后面
			if (!xml.FindElem("DevDomainCode"))
			{
				BP_RUN_LOG_ERR(IVS_SMU_XML_INVALID, "xml.FindElem(DevCode)", "NA");
				//IVS_DELETE(pData, MUILI);
				return IVS_SMU_XML_INVALID;		
			}
			std::string strDevDomainCode;
            const IVS_CHAR* pDevDomainCode = xml.GetElemValue();
            if (NULL != pDevDomainCode)
            {
                strDevDomainCode = pDevDomainCode;
            }
			// 拼接设备所在域编码
			if (!xml.FindElem("DevCode"))
			{
				BP_RUN_LOG_ERR(IVS_SMU_XML_INVALID, "xml.FindElem(DevCode)", "NA");
				//IVS_DELETE(pData, MUILI);
				return IVS_SMU_XML_INVALID;		
			}
			std::string strDevCode;
            
            const IVS_CHAR* pDevCode = xml.GetElemValue();
            if (NULL != pDevCode)
            {
                strDevCode = pDevCode;
            }

			if (!strDevCode.empty())
			{
				strDevCode.append("#").append(strDevDomainCode);
				xml.ModifyElemValue(strDevCode.c_str());
			}
			xml.OutOfElem();
		} while (xml.NextElem());
		xml.OutOfElem();
	}
// 
// 	IVS_UINT32 uiXmlLen = 0;
// 	pDataXml = xml.GetXMLStream(uiXmlLen);
// 	CHECK_POINTER(pDataXml, IVS_OPERATE_MEMORY_ERROR);
	return IVS_SUCCEED;
}//lint !e818
コード例 #3
0
ファイル: XMLProcess.cpp プロジェクト: eSDK/esdk_elte
eLTE_RET XMLProcess::SetXmlStringEventNotifySDSReport(const std::string& strSrc,
	CString& xmlStr)
{
	/************************************************************************
			--- XML 格式 ---
			<Content>
			<SdsType>消息类型</SdsType>
			<SdsContent>消息内容</SdsContent>
			<SdsFrom>发件人</SdsFrom>
			<SdsMmsFileNameList>
				<SdsMmsFileName>附件文件名列表</SdsMmsFileName>
				<SdsMmsFileName>附件文件名列表</SdsMmsFileName>
			</SdsMmsFileNameList>
			<SdsSubject>消息主题</SdsSubject>
			<SdsDate>消息发送日期</SdsDate>
			<SdsTime>消息发送时间</SdsTime>
			</Content>
	************************************************************************/
	LOG_TRACE();

	CXml xmlParse;

	if (!xmlParse.Parse(strSrc.c_str()))
	{
		LOG_RUN_ERROR("parse xml failed.");
		return eLTE_ERR_FAILED;
	}
	if (!xmlParse.FindElem("Content"))
	{
		LOG_RUN_ERROR("FindElem Content failed.");
		return eLTE_ERR_FAILED;
	}
	(void)xmlParse.IntoElem();
	if (!xmlParse.FindElem("SdsType"))
	{
		LOG_RUN_ERROR("FindElem CallStatus failed.");
		return eLTE_ERR_FAILED;
	}
	std::string strSdsType = xmlParse.GetElemValue();

	std::string strSdsContent = "";
	if(xmlParse.FindElem("SdsContent"))
	{
		strSdsContent = xmlParse.GetElemValue();
	}

	if (!xmlParse.FindElem("SdsFrom"))
	{
		LOG_RUN_ERROR("FindElem SdsFrom failed.");
		return eLTE_ERR_FAILED;
	}
	std::string strSdsFrom = xmlParse.GetElemValue();

	std::list<std::string> fileNameList;
	//彩信
	if (xmlParse.FindElem("SdsMmsFileNameList") && xmlParse.IntoElem())
	{
		do 
		{																		
			std::string srcValue = xmlParse.GetElemValue();
			if(!srcValue.empty())
			{
				fileNameList.push_back(srcValue);
			}
		} while (xmlParse.NextElem());
		xmlParse.OutOfElem();
	}

	if (!xmlParse.FindElem("SdsSubject"))
	{
		LOG_RUN_ERROR("FindElem SdsSubject failed.");
		return eLTE_ERR_FAILED;
	}
	std::string strSdsSubject = xmlParse.GetElemValue();


	if (!xmlParse.FindElem("SdsDate"))
	{
		LOG_RUN_ERROR("FindElem SdsDate failed.");
		return eLTE_ERR_FAILED;
	}
	std::string strSdsDate = xmlParse.GetElemValue();

	if (!xmlParse.FindElem("SdsTime"))
	{
		LOG_RUN_ERROR("FindElem SdsTime failed.");
		return eLTE_ERR_FAILED;
	}
	std::string strSdsTime = xmlParse.GetElemValue();


	//拼接xml
	xmlStr.Append(_T("<Content>"));

	xmlStr.Append(_T("<SdsType>"));
	xmlStr.Append(eLTE_Tool::ANSIToUnicode(strSdsType).c_str());
	xmlStr.Append(_T("</SdsType>"));

	if(!strSdsContent.empty())
	{
		xmlStr.Append(_T("<SdsContent>"));
		xmlStr.Append(eLTE_Tool::UTF8ToUnicode(strSdsContent).c_str());
		xmlStr.Append(_T("</SdsContent>"));
	}

	xmlStr.Append(_T("<SdsFrom>"));
	xmlStr.Append(eLTE_Tool::ANSIToUnicode(strSdsFrom).c_str());
	xmlStr.Append(_T("</SdsFrom>"));

	if(0 < fileNameList.size())
	{
		xmlStr.Append(_T("<SdsMmsFileNameList>"));
		std::list<std::string>::iterator it = fileNameList.begin();

		for (; it != fileNameList.end(); ++it)
		{
			xmlStr.Append(_T("<SdsMmsFileName>"));
			xmlStr.Append(eLTE_Tool::UTF8ToUnicode(*it).c_str());
			xmlStr.Append(_T("</SdsMmsFileName>"));
		}

		xmlStr.Append(_T("</SdsMmsFileNameList>"));
	}

	xmlStr.Append(_T("<SdsSubject>"));
	xmlStr.Append(eLTE_Tool::UTF8ToUnicode(strSdsSubject).c_str());
	xmlStr.Append(_T("</SdsSubject>"));

	
	xmlStr.Append(_T("<SdsDirection>"));
	xmlStr.Append(_T("false"));
	xmlStr.Append(_T("</SdsDirection>"));

	xmlStr.Append(_T("<SdsDate>"));
	xmlStr.Append(eLTE_Tool::ANSIToUnicode(strSdsDate).c_str());
	xmlStr.Append(_T("</SdsDate>"));

	xmlStr.Append(_T("<SdsTime>"));
	xmlStr.Append(eLTE_Tool::ANSIToUnicode(strSdsTime).c_str());
	xmlStr.Append(_T("</SdsTime>"));
	xmlStr.Append(_T("</Content>"));

	return eLTE_ERR_SUCCESS;
}
コード例 #4
0
// 解析设置图形的XML
IVS_INT32 COCXDrawXMLProcess::SetGraphicsPraseXML(IA_GRAPHICS *pGraphicsArr, ULONG &ulNum, LPCTSTR pGraphicsXml, const SIZE &szGraphic, BOOL bPersent)
{
	CHECK_POINTER(pGraphicsArr, IVS_FAIL);
	CHECK_POINTER(pGraphicsXml, IVS_OPERATE_MEMORY_ERROR);

	IVS_DEBUG_TRACE("GraphicsXml: %s, GraphicWidth: %d, GraphicHeight: %d",pGraphicsXml, szGraphic.cx, szGraphic.cy);

	CXml xml;
	if (!xml.Parse(pGraphicsXml))
	{
		return IVS_FAIL;
	}

	CHECK_SUCCESS(xml.FindElem("Content"));
	CHECK_SUCCESS(xml.IntoElem());
	CHECK_SUCCESS(xml.FindElem("Graphics"));
	CHECK_SUCCESS(xml.IntoElem());

	const char *value = NULL;

	CHECK_SUCCESS(xml.FindElem("GraphicNum") && (NULL != (value = xml.GetElemValue())));
	ulNum = (ULONG)atoi(value);

	// 若设置的图形数大于图形数组长度,截断到最大画图个数
	if (ulNum > GRAPHICS_NUM_MAX)
	{
		BP_RUN_LOG_INF("COCXDrawXMLProcess::SetGraphicsPraseXML", "GraphicNum Truncated to GRAPHICS_NUM_MAX");
		ulNum = GRAPHICS_NUM_MAX;
	}

	CHECK_SUCCESS(xml.FindElem("GraphicList"));
	CHECK_SUCCESS(xml.IntoElem());

	for (ULONG i = 0; i < ulNum; i++)
	{
		// 给图形可选字段赋默认值
		memset(&pGraphicsArr[i], 0, sizeof(IA_GRAPHICS));
		pGraphicsArr[i].ulLineWidth = 3; // 默认基本线宽为3
		pGraphicsArr[i].bAllowDelete = TRUE; // 允许删除
		pGraphicsArr[i].bAllowModifySize = TRUE; // 允许修改矩形大小

		if (0 == i)
		{
			CHECK_SUCCESS(xml.FindElem("GraphicInfo"));
		} else {
			CHECK_SUCCESS(xml.NextElem());
		}
		CHECK_SUCCESS(xml.IntoElem());
		CHECK_SUCCESS(xml.FindElem("GraphicType") && (NULL != (value = xml.GetElemValue())));
		pGraphicsArr[i].ulGraphicType = (ULONG)atoi(value);

		GET_ELEMENT_ULONG(pGraphicsArr[i].ulGraphicGroup, GraphicGroup, xml);
		GET_ELEMENT_STRING(pGraphicsArr[i].GraphicGroupName, CHARACTER_NUM_MAX, GraphicGroupName, xml);

		if (xml.FindElem("GraphicBackgroundColor"))
		{
			CHECK_SUCCESS(xml.IntoElem());
			GET_ELEMENT_UCHAR(pGraphicsArr[i].BgColor.Alpha, Opacity, xml);
			GET_ELEMENT_UCHAR(pGraphicsArr[i].BgColor.Red, Red, xml);
			GET_ELEMENT_UCHAR(pGraphicsArr[i].BgColor.Green, Green, xml);
			GET_ELEMENT_UCHAR(pGraphicsArr[i].BgColor.Blue, Blue, xml);
			xml.OutOfElem();
		}

		if (xml.FindElem("GraphicLineColor"))
		{
			CHECK_SUCCESS(xml.IntoElem());
			GET_ELEMENT_UCHAR(pGraphicsArr[i].LineColor.Alpha, Opacity, xml);
			GET_ELEMENT_UCHAR(pGraphicsArr[i].LineColor.Red, Red, xml);
			GET_ELEMENT_UCHAR(pGraphicsArr[i].LineColor.Green, Green, xml);
			GET_ELEMENT_UCHAR(pGraphicsArr[i].LineColor.Blue, Blue, xml);
			xml.OutOfElem();
		}

		GET_ELEMENT_ULONG(pGraphicsArr[i].ulLineWidth, GraphicLineWidth, xml);

		CHECK_SUCCESS(xml.FindElem("PointNum") && (NULL != (value = xml.GetElemValue())));
		pGraphicsArr[i].ulPointsNum = (ULONG)atoi(value);

		CHECK_SUCCESS(xml.FindElem("PointList"));
		CHECK_SUCCESS(xml.IntoElem());

		for (ULONG j = 0; j < pGraphicsArr[i].ulPointsNum; j++)
		{
			if (0 == j)
			{
				CHECK_SUCCESS(xml.FindElem("Point"));
			} else {
				CHECK_SUCCESS(xml.NextElem());
			}
			CHECK_SUCCESS(xml.IntoElem());

			if ((0 == szGraphic.cx) || (0 == szGraphic.cy))
			{
				if (bPersent)
				{
					CHECK_SUCCESS(xml.FindElem("X") && (NULL != (value = xml.GetElemValue())));
					pGraphicsArr[i].IAPoints[j].x = (LONG)(atof(value) * FLOAT_TO_LONG_COEFF);
					CHECK_SUCCESS(xml.FindElem("Y") && (NULL != (value = xml.GetElemValue())));
					pGraphicsArr[i].IAPoints[j].y = (LONG)(atof(value) * FLOAT_TO_LONG_COEFF);
				} else {
					CHECK_SUCCESS(xml.FindElem("X") && (NULL != (value = xml.GetElemValue())));
					pGraphicsArr[i].IAPoints[j].x = (LONG)atoi(value);
					CHECK_SUCCESS(xml.FindElem("Y") && (NULL != (value = xml.GetElemValue())));
					pGraphicsArr[i].IAPoints[j].y = (LONG)atoi(value);
				}
			}
			else
			{
				CHECK_SUCCESS(xml.FindElem("X") && (NULL != (value = xml.GetElemValue())));
				pGraphicsArr[i].IAPoints[j].x = (LONG)(atof(value) * szGraphic.cx + 0.5);
				CHECK_SUCCESS(xml.FindElem("Y") && (NULL != (value = xml.GetElemValue())));
				pGraphicsArr[i].IAPoints[j].y = (LONG)(atof(value) * szGraphic.cy + 0.5);
			}

			xml.OutOfElem();
		}
		xml.OutOfElem();

		GET_ELEMENT_ULONG(pGraphicsArr[i].NamePosition, NamePosition, xml);
		GET_ELEMENT_BOOL(pGraphicsArr[i].bAllowDelete, DeleteByMouse, xml);
		GET_ELEMENT_BOOL(pGraphicsArr[i].bAllowAddNewPoint, AddNewPoint, xml);
		GET_ELEMENT_BOOL(pGraphicsArr[i].bAllowModifySize, AllowModifySize, xml);
		GET_ELEMENT_ULONG(pGraphicsArr[i].ulArrowType, ArrowType, xml);
		GET_ELEMENT_BOOL(pGraphicsArr[i].bKeepHorizon, KeepHorizon, xml);

		xml.OutOfElem();
	}
	xml.OutOfElem();
	xml.OutOfElem();

	return IVS_SUCCEED;
}
コード例 #5
0
//设置平台抓拍计划:将请求XML转换为结构体
IVS_INT32 OCXCapturePictureXMLProcess::SetSnapshotPlanGetXML(IVS_CHAR* pCameraCode,IVS_SNAPSHOT_PLAN* pSnapShotPlan, CXml &xml)
{ 
	CHECK_POINTER(pCameraCode,IVS_PARA_INVALID);
	CHECK_POINTER(pSnapShotPlan,IVS_PARA_INVALID);
	IVS_DEBUG_TRACE("");
	if (!xml.FindElemEx("Content/SnapshotPlanInfo"))
	{
		BP_RUN_LOG_ERR(IVS_XML_INVALID,"Set Snapshot Plan Get XML", "fail", "no 'SnapshotPlanInfo' elemenet");
		return IVS_XML_INVALID;
	}      
	(void)xml.IntoElem();
	const char* szElemValue = NULL;

	// 摄像机编码
	if (!xml.FindElem("CameraCode"))
	{
		BP_RUN_LOG_ERR(IVS_XML_INVALID,"Set Snapshot Plan Get XML", "faill", "no 'CameraCode' elemenet");
		return IVS_XML_INVALID;
	}
	GET_ELEM_VALUE_CHAR("CameraCode",szElemValue,pCameraCode,IVS_DEV_CODE_LEN,xml);
	// 是否启用 
	if (!xml.FindElem("IsEnable"))
	{
		BP_RUN_LOG_ERR(IVS_XML_INVALID,"Set Snapshot Plan Get XML", "faill", "no 'IsEnable' elemenet");
		return IVS_XML_INVALID;
	}
	const IVS_CHAR* cpszIsEnable = xml.GetElemValue();
	if (NULL == cpszIsEnable)
	{
		return IVS_XML_INVALID;
	}
	pSnapShotPlan->bEnable = static_cast<IVS_BOOL>(atoi(cpszIsEnable));

	// 计划方式(周计划 日计划 全程录像)
	if (!xml.FindElem("PlanType"))
	{
		BP_RUN_LOG_ERR(IVS_XML_INVALID,"Set Snapshot Plan Get XML", "faill", "no 'PlanType' elemenet");
		return IVS_XML_INVALID;
	}
	GET_ELEM_VALUE_NUM_FOR_UINT("PlanType",szElemValue,pSnapShotPlan->uiPlanType,xml);

	IVS_UINT32 iPlanInfoNum = 0;
	IVS_INT32 iTimeInfoNum = 0;
	if (xml.FindElemEx("Content/SnapshotPlanInfo/PlanList"))
	{
		do 
		{
			(void)xml.IntoElem();
			//解析PlanInfo
			(void)xml.IntoElem();
			memset(&pSnapShotPlan->stPlanInfo[iPlanInfoNum],0, sizeof(IVS_SNAPSHOT_PLAN_INFO));
			GET_ELEM_VALUE_NUM_FOR_UINT("DayType",szElemValue,pSnapShotPlan->stPlanInfo[iPlanInfoNum].uiDayType,xml);

			if (xml.FindElem("TimeList"))
			{
				xml.IntoElem();
			}
			if(xml.FindElem("TimeInfo"))
			{
				do{ 
					(void)xml.IntoElem();
					GET_ELEM_VALUE_CHAR("StartTime",szElemValue,  pSnapShotPlan->stPlanInfo[iPlanInfoNum].stTimeSpanInfo[iTimeInfoNum].cStart,IVS_TIME_LEN,xml);
					GET_ELEM_VALUE_CHAR("EndTime",szElemValue,  pSnapShotPlan->stPlanInfo[iPlanInfoNum].stTimeSpanInfo[iTimeInfoNum].cEnd,IVS_TIME_LEN,xml);
					GET_ELEM_VALUE_NUM_FOR_UINT("SnapInterval",szElemValue,pSnapShotPlan->stPlanInfo[iPlanInfoNum].stTimeSpanInfo[iTimeInfoNum].SnapInterval,xml);
					iTimeInfoNum++;
					xml.OutOfElem();
				}while(xml.NextElem());
			}
			pSnapShotPlan->stPlanInfo[iPlanInfoNum].uiTimeSpanInfoNum = static_cast<IVS_UINT32>(iTimeInfoNum);
			xml.OutOfElem();
			xml.OutOfElem();
			iPlanInfoNum++;
			iTimeInfoNum = 0;
		} while(xml.NextElem());
	}
	pSnapShotPlan->uiPlanInfoNum = iPlanInfoNum;
	xml.OutOfElem();

	return IVS_SUCCEED;
}
コード例 #6
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
コード例 #7
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
コード例 #8
0
IVS_INT32 CMediaXMLProcess::GetURLResponseData(CXml &xmlRsp, ST_MEDIA_RSP& stMediaRsp, bool& bAssociatedAudio)
{
	IVS_DEBUG_TRACE("");

	memset(&stMediaRsp, 0, sizeof(ST_MEDIA_RSP));
	const char*AttriValue = NULL;   //临时存储单个节点值
	bool bRet = false;

	CHECK_SUCCESS(xmlRsp.FindElem("Content"));
	CHECK_SUCCESS(xmlRsp.IntoElem());


	CHECK_SUCCESS(xmlRsp.FindElem("URL"));
	CHECK_SUCCESS(NULL != (AttriValue = xmlRsp.GetElemValue()));
	bRet = CToolsHelp::Memcpy(stMediaRsp.szURL, URL_LEN, AttriValue, strlen(AttriValue));
	if(!bRet)
	{
		BP_RUN_LOG_ERR(IVS_ALLOC_MEMORY_ERROR,"Get URL Response Data", "Memcpy error.");
		return IVS_ALLOC_MEMORY_ERROR;
	}

	if (xmlRsp.FindElem("AssociatedAudio"))
	{
		CHECK_SUCCESS(NULL != (AttriValue = xmlRsp.GetElemValue()));
		bAssociatedAudio = (bool)atoi(AttriValue);	
	}

	CHECK_SUCCESS(xmlRsp.FindElem("RtspIP"));
	CHECK_SUCCESS(NULL != (AttriValue = xmlRsp.GetElemValue()));
	bRet = CToolsHelp::Memcpy(stMediaRsp.szRTSPIP, IVS_IP_LEN, AttriValue, strlen(AttriValue));
	if(!bRet)
	{
		BP_RUN_LOG_ERR(IVS_ALLOC_MEMORY_ERROR,"Get URL Response Data", "Memcpy error.");
		return IVS_ALLOC_MEMORY_ERROR;
	}

	CHECK_SUCCESS(xmlRsp.FindElem("RtspPort"));
	CHECK_SUCCESS(NULL != (AttriValue = xmlRsp.GetElemValue()));
	bRet = CToolsHelp::Memcpy(stMediaRsp.szRTSPPORT, PORT_LEN, AttriValue, strlen(AttriValue));
	if(!bRet)
	{
		BP_RUN_LOG_ERR(IVS_ALLOC_MEMORY_ERROR,"Get URL Response Data", "Memcpy error.");
		return IVS_ALLOC_MEMORY_ERROR;
	}

	//add by zwx211831, Date:20140625, 在URL中添加UserID和DomainID,以实现查询点播业务。
	//如果是旧的版本,则不变。
	if (xmlRsp.FindElem("UserId") && xmlRsp.FindElem("DomainId"))
	{
		(void)xmlRsp.FindElem("DomainId");
		CHECK_SUCCESS(NULL != (AttriValue = xmlRsp.GetElemValue()));
		std::string strDomainCode("DomainCode=");
		strDomainCode += AttriValue;
		strDomainCode += "&";
		if(!CToolsHelp::Strncat(stMediaRsp.szURL, URL_LEN, strDomainCode.c_str()))
		{
			BP_RUN_LOG_ERR(IVS_ALLOC_MEMORY_ERROR,"Get URL Response Data", "Strncat error.");
			return IVS_ALLOC_MEMORY_ERROR;
		}

		(void)xmlRsp.FindElem("UserId");
		CHECK_SUCCESS(NULL != (AttriValue = xmlRsp.GetElemValue()));
		IVS_UINT32 uiUserID = 0;
		std::string strUserID("UserId=");
		GET_ELEM_VALUE_NUM_FOR_UINT("UserId", AttriValue, uiUserID, xmlRsp);
		strUserID += CToolsHelp::Int2Str(uiUserID);
		strUserID += "&";
		if(!CToolsHelp::Strncat(stMediaRsp.szURL, URL_LEN, strUserID.c_str()))
		{
			BP_RUN_LOG_ERR(IVS_ALLOC_MEMORY_ERROR,"Get URL Response Data", "Strncat error.");
			return IVS_ALLOC_MEMORY_ERROR;
		}
	}

	xmlRsp.OutOfElem();

	return IVS_SUCCEED;


#if 0  //XML增加AssociatedAudio字段

	(void)xmlRsp.GetElem();    // Content
	(void)xmlRsp.IntoElem();
	(void)xmlRsp.GetElem();     // URL
	AttriValue=xmlRsp.GetElemValue(); 
	if(AttriValue == NULL)
	{
		BP_RUN_LOG_INF("Get URL Response Data", "URL is  null");
		return IVS_SDK_RET_SMU_SDK_XML_INVALD;
	}
	bool bRet = CToolsHelp::Memcpy(stMediaRsp.szURL,URL_LEN, AttriValue, strlen(AttriValue));
	if(false == bRet)
	{
		BP_RUN_LOG_ERR(IVS_ALLOC_MEMORY_ERROR,"Get URL Response Data", "Memcpy error.");
		return IVS_ALLOC_MEMORY_ERROR;
	}

	(void)xmlRsp.NextElem();               // RtspIP
	(void)xmlRsp.GetElem();
	AttriValue = xmlRsp.GetElemValue();
	if(AttriValue == NULL)
	{
		BP_RUN_LOG_INF("Get URL Response Data", "RtspIP is null");
		return IVS_SDK_RET_SMU_SDK_XML_INVALD;
	}
	bRet = CToolsHelp::Memcpy(stMediaRsp.szRTSPIP,IVS_IP_LEN, AttriValue, strlen(AttriValue));
	if(false == bRet)
	{
		BP_RUN_LOG_ERR(IVS_ALLOC_MEMORY_ERROR,"Get URL Response Data", "Memcpy error.");
		return IVS_ALLOC_MEMORY_ERROR;
	}

	(void)xmlRsp.NextElem();               // RtspPort
	(void)xmlRsp.GetElem();
	AttriValue = xmlRsp.GetElemValue();
	if(AttriValue == NULL)
	{
		BP_RUN_LOG_INF("Get URL Response Data", "RtspPort is null");
		return IVS_SDK_RET_SMU_SDK_XML_INVALD;
	}
	bRet = CToolsHelp::Memcpy(stMediaRsp.szRTSPPORT,PORT_LEN, AttriValue, strlen(AttriValue));
	if(false == bRet)
	{
		BP_RUN_LOG_ERR(IVS_ALLOC_MEMORY_ERROR,"Get URL Response Data", "Memcpy error.");
		return IVS_ALLOC_MEMORY_ERROR;
	}

	return IVS_SUCCEED;
#endif
}