コード例 #1
0
bool SFServerConnectionManager::InitServerList(WCHAR* szFileName)
{
	CMarkup xml;
	xml.Load(L"ServerConnection.xml");

	while (xml.FindChildElem(L"SERVER"))
	{
		_ServerInfo serverInfo;
		xml.IntoElem();

		xml.FindChildElem(L"IP");
		serverInfo.szIP = xml.GetChildData();

		xml.FindChildElem(L"PORT");
		serverInfo.port = _ttoi(xml.GetChildData().c_str());

		xml.FindChildElem(L"IDENTIFER");
		serverInfo.identifer = _ttoi(xml.GetChildData().c_str());

		xml.FindChildElem(L"DESC");
		serverInfo.szDesc = xml.GetChildData();

		xml.OutOfElem();

		SFServerBridge* pServer = new SFServerBridge(serverInfo);

		m_mapServerInfo.insert(std::make_pair(serverInfo.identifer, pServer));
	}

	return true;
}
コード例 #2
0
void XMLFileRead()
{
	CMarkup xml;
	xml.Load(L"ServerConnection.xml");

	while (xml.FindChildElem(L"SERVER"))
	{
		_ConnectorInfo connectorInfo;
		xml.IntoElem();

		xml.FindChildElem(L"IP");
		connectorInfo.szIP = xml.GetChildData();

		xml.FindChildElem(L"PORT");
		connectorInfo.port = _ttoi(xml.GetChildData().c_str());

		xml.FindChildElem(L"IDENTIFER");
		connectorInfo.identifier = _ttoi(xml.GetChildData().c_str());

		xml.FindChildElem(L"DESC");
		connectorInfo.szDesc = xml.GetChildData();

		xml.OutOfElem();
	}

}
コード例 #3
0
// 根据配置索引获取配置信息
CString CVCheckerClsConfig::fGetConfigData(int nConfigIndex)
{
	if (m_strConfigFile == _T(""))
		return _T("");

	CMarkup xml;
	BOOL bLoad = FALSE;
	bLoad = xml.Load(m_strConfigFile);
	if (!bLoad)
		return _T(""); 

	xml.ResetPos();
	while ( xml.FindChildElem(_T("System_Config")))
	{
		xml.IntoElem();
		
		//xml.ResetMainPos();
		//xml.FindChildElem( "NAME" );
		////	xml.FindChildElem();
		//CString csName = xml.GetChildData();
		//AfxMessageBox(csName);

		//xml.ResetMainPos(); //注意复位
		//xml.FindChildElem( "SN" );
		////	xml.FindChildElem();
		//CString csSN = xml.GetChildData();
		//AfxMessageBox(csSN);

		xml.OutOfElem();
	}	

	return CString();
}
コード例 #4
0
ファイル: CRequestXmlMessage.cpp プロジェクト: ray-x/SMonitor
bool CRequestXmlMessage::treatMessage(const NetMessage& netMessage, CMessageFactory* pFactory, SocketContext* clientSocket)
{
	//请求XML时检测客户端ID,如果不存在,执行注册ID流程
	CMarkup xml;
	if(xml.SetDoc(netMessage.msgBuffer))
	{
		if(xml.FindChildElem("Info"))
		{
			xml.IntoElem();
			QString strId = QString::fromStdString(xml.GetAttrib("Id"));
			if(!DataManagerThread->IsClientExist(strId))
			{
				DataMotion dataMotion;
				dataMotion.msg = EMSG_REGISTERID;
				dataMotion.clientInfo.id = strId;
				dataMotion.clientInfo.version = ""; //yhb 版本号暂时不用
				DataManagerThread->AddDataMotion(dataMotion);
			}
		}
	}

	if(NULL != pFactory)
	{
		return pFactory->sendMessage(clientSocket, netMessage.msgHead);
	}

	return true;
}
コード例 #5
0
ファイル: db_leos.cpp プロジェクト: Fluffiest/splayer
void db_leos::DownloadLyrics(window_config *wcfg, lyric_data* data)
{
  data->Text = _T("");
  tstring xmltext;

  if (!ReadInternetTextFromUrl(xmltext, _T("FOO_UIE_LYRICS2"), data->Source, wcfg->cfg_timeout, wcfg))
    return ;

  tstring info_text;

  CMarkup xml;

  if (!xml.SetDoc(xmltext.c_str()))
    return ;

  if (xml.FindChildElem(_T("lyric")))
  {
    xml.IntoElem();

    if (xml.FindChildElem(_T("text")))
    {
      xml.IntoElem();

      info_text = xml.GetData();

      xml.OutOfElem();
    }

    xml.OutOfElem();
  }

  data->Text = info_text;

  data->Text = ReplaceString(_T("\r"), _T(""), data->Text);
  data->Text = ReplaceString(_T("\n"), _T("\r\n"), data->Text);
  data->IsLoaded = true;

  if (data->Text.find(_T("[")) != tstring::npos)
    data->IsTimestamped = true;
  else
    data->IsTimestamped = false;

}
コード例 #6
0
//del device
void CDeviceEditDlg::DeleteDevice()
{
	HTREEITEM hItem = m_deviceTree.GetSelectedItem();
	
	if ( hItem == NULL )
	{
		return;
	}
	
	DEV_INFO *pDev = (DEV_INFO *)m_deviceTree.GetItemData(hItem);
	if ( pDev )
	{
		if ( pDev->lLoginID > 0 )
		{
			H264_DVR_Logout(pDev->lLoginID);
		}
		
		Devc_Map::iterator bIter = m_devMap.find( pDev->lID );
		if ( bIter != m_devMap.end() )
		{
			m_devMap.erase(bIter);
		}
		m_deviceTree.DeleteItem(hItem);
		CMarkup xml;
		if (xml.Load(GET_MODULE_FILE_INFO.strPath + "UserInfo.xml"))
		{
			while(xml.FindChildElem("ip"))
			{
				xml.IntoElem();
				xml.FindChildElem("ip2");
				if(xml.GetChildData()==pDev->szIpaddress)
				{
					xml.RemoveElem();
					xml.Save(GET_MODULE_FILE_INFO.strPath + "UserInfo.xml");
				}
				xml.OutOfElem();
			}
			
		}
		delete pDev;
		pDev = NULL;
	}	
}
コード例 #7
0
void CDlgLianHaoLanQiu::OnBnClickedJingxuanBtn()
{
	CMarkup Xml;
	CString FormulaName=GetAppCurrentPath()+"FormulaNameList.xml";
	Xml.Load(FormulaName.GetBuffer());
	FormulaName.ReleaseBuffer();

	vector<CString> NameList;

	while(Xml.FindChildElem("FormulaInfo"))
	{
		Xml.IntoElem();
		Xml.FindChildElem("FormulaName");
		CString Name=Xml.GetChildData().c_str();

		Xml.FindChildElem("FormulaType");
		CString StrType=Xml.GetChildData().c_str();
		
		int Type = atoi(StrType.GetBuffer());
		StrType.ReleaseBuffer();

		if(Type == m_FormulaType && !Name.IsEmpty())
			NameList.push_back(Name);
			
		Xml.OutOfElem();
	}

	if(NameList.empty())
	{
		m_FormulaInfoList=CFormulaCenter::GetInstance()->GetFormulaInfoByType(m_FormulaType);
	}
	else
		m_FormulaInfoList=CFormulaCenter::GetInstance()->GetFormulaInfoByName(m_FormulaType,NameList);

	m_CurrentIndex=0;
	FillData(m_FormulaInfoList);
	UpdateBtnStatus();
}
コード例 #8
0
bool CSoftInstallMessage::treatMessage(const NetMessage& netMessage, CMessageFactory* pFactory, SocketContext* clientSocket)
{
	m_bAddSuccess = false;
	CMarkup xml;
	if(xml.SetDoc(netMessage.msgBuffer))
	{
		if(xml.FindChildElem("Info"))
		{
			xml.IntoElem();
			QString strId = QString::fromStdString(xml.GetAttrib("Id"));
			m_strName = QString::fromStdString(xml.GetAttrib("Name"));
			m_strVersion = QString::fromStdString(xml.GetAttrib("Version"));

			 /*&&  判断当前提交的软件名称,版本号是否与软件列表里的一致 */
			if(DatabaseManager::Instance()->IsSoftwareExist(m_strName, m_strVersion) && !DataManagerThread->IsSoftInstallInfoExist(strId, m_strName, m_strVersion))
			{
				//接上,软件列表为共用列表,不从数据库判断,节省效率 yhb

				DataMotion dataMotion;
				dataMotion.msg = netMessage.msgHead;
				dataMotion.clientInfo.id = strId;
				dataMotion.softwareInfo.name = m_strName;
				dataMotion.softwareInfo.version = m_strVersion;
				DataManagerThread->AddDataMotion(dataMotion);
			}
			xml.OutOfElem();
			m_bAddSuccess = true;
		}
	}

	if(NULL != pFactory)
	{
		return pFactory->sendMessage(clientSocket, netMessage.msgHead);
	}

	return true;
}
コード例 #9
0
CreatureType::CreatureType(const std::string& xmlstring)
    : age_(18,57), alignment_public_mood_(true),
      attribute_points_(40),
      gender_liberal_(GENDER_RANDOM), gender_conservative_(GENDER_RANDOM),
      infiltration_(0), juice_(0), money_(20,40)
{
    for(int i=0; i<ATTNUM; i++)
        attributes_[i].set_interval(1,10);

    id_=number_of_creaturetypes++;

    CMarkup xml;
    xml.SetDoc(xmlstring);
    xml.FindElem();

    idname_=xml.GetAttrib("idname");
    if(!len(idname_))
    {
        idname_ = "LACKS IDNAME "+tostring(id_);
        xmllog.log("Creature type "+tostring(id_)+" lacks idname.");
    }
    type_=creaturetype_string_to_enum(idname_);

    xml.IntoElem();
    // Loop over all the elements inside the creaturetype element.
    while(xml.FindElem())
    {
        std::string element = xml.GetTagName();

        if (element == "alignment")
        {
            std::string alignment = xml.GetData();
            if (alignment == "PUBLIC MOOD")
                alignment_public_mood_ = true;
            else if (alignment == "LIBERAL")
            {
                alignment_ = ALIGN_LIBERAL;
                alignment_public_mood_ = false;
            }
            else if (alignment == "MODERATE")
            {
                alignment_ = ALIGN_MODERATE;
                alignment_public_mood_ = false;
            }
            else if (alignment == "CONSERVATIVE")
            {
                alignment_ = ALIGN_CONSERVATIVE;
                alignment_public_mood_ = false;
            }
            else
                xmllog.log("Invalid alignment for " + idname_ + ": " + alignment);
        }
        else if (element == "age")
        {
            std::string age = xml.GetData();
            if (age == "DOGYEARS")
                age_.set_interval(2,6);
            else if (age == "CHILD")
                age_.set_interval(7,10);
            else if (age == "TEENAGER")
                age_.set_interval(14,17);
            else if (age == "YOUNGADULT")
                age_.set_interval(18,35);
            else if (age == "MATURE")
                age_.set_interval(20,59);
            else if (age == "GRADUATE")
                age_.set_interval(26,59);
            else if (age == "MIDDLEAGED")
                age_.set_interval(35,59);
            else if (age == "SENIOR")
                age_.set_interval(65,94);
            else
                assign_interval(age_, age, idname_, element);
        }
        else if (element == "attribute_points")
            assign_interval(attribute_points_, xml.GetData(), idname_, element);
        else if (element == "attributes")
        {
            while(xml.FindChildElem())
            {
                int attribute = attribute_string_to_enum(xml.GetChildTagName());
                if (attribute != -1)
                    assign_interval(attributes_[attribute], xml.GetChildData(), idname_, element);
                else
                    xmllog.log("Unknown attribute in " + idname_ + ": " + xml.GetTagName());
            }
        }
        else if (element == "juice")
            assign_interval(juice_, xml.GetData(), idname_, element);
        else if (element == "gender")
        {
            int gender = gender_string_to_enum(xml.GetData());
            if (gender != -1 && gender != GENDER_WHITEMALEPATRIARCH)
                gender_liberal_ = gender_conservative_ = gender;
            else
                xmllog.log("Invalid gender for " + idname_ + ": " + xml.GetData());
        }
        else if (element == "infiltration")
            assign_interval(infiltration_, xml.GetData(), idname_, element);
        else if (element == "money")
            assign_interval(money_, xml.GetData(), idname_, element);
        else if (element == "skills")
        {
            while(xml.FindChildElem())
            {
                int skill = skill_string_to_enum(xml.GetChildTagName());
                if (skill != -1)
                    assign_interval(skills_[skill], xml.GetChildData(), idname_, element);
                else
                    xmllog.log("Unknown skill for " + idname_ + ": " + xml.GetChildTagName());
            }
        }
        else if (element == "armor")
        {
            if (getarmortype(xml.GetData()) != -1)
                armortypes_.push_back(xml.GetData());
            else
                xmllog.log("Invalid armor type for " + idname_ + ": " + xml.GetData());;
        }
        else if (element == "weapon")
        {
            //xml.SavePos("creature");
            weapons_and_clips_.push_back(WeaponsAndClips(xml, idname_));
            //xml.RestorePos("creature");
        }
        else if (element == "encounter_name")
            encounter_name_ = xml.GetData();
        else if (element == "type_name")
            type_name_ = xml.GetData();
        else
            xmllog.log("Unknown element for " + idname_ + ": " + element);
    }

    if (!len(type_name_))
    {
        xmllog.log("type_name not defined for " + idname_ + ".");
        type_name_ = "UNDEFINED";
    }
    // If no weapon type has been given then use WEAPON_NONE.
    if (!len(weapons_and_clips_))
        weapons_and_clips_.push_back(WeaponsAndClips("WEAPON_NONE", 1, "NONE", 0));
    // If no armor type has been given then use ARMOR_NONE.
    if (!len(armortypes_))
        armortypes_.push_back("ARMOR_NONE");
}
コード例 #10
0
CreatureType::WeaponsAndClips::WeaponsAndClips(CMarkup& xml, const string& owner)
    : number_weapons(1),
      cliptype("APPROPRIATE"), number_clips(4)
{   // The main position of the CMarkup object is expected not to be changed here.
    weapontype = xml.GetData();

    // Read in values.
    if(!len(weapontype))
    {
        while(xml.FindChildElem())
        {
            std::string element=xml.GetChildTagName();
            if(element=="type") weapontype=xml.GetChildData();
            else if(element=="number_weapons")
                assign_interval(number_weapons,xml.GetChildData(),owner,element);
            else if(element=="cliptype") cliptype=xml.GetChildData();
            else if(element=="number_clips")
                assign_interval(number_clips,xml.GetChildData(),owner,element);
            else xmllog.log("Unknown element for weapon in "+owner+": "+element);
        }
    }

    // Check values.
    if (weapontype != "CIVILIAN")
    {
        if (getweapontype(weapontype) == -1)
        {
            xmllog.log("Invalid weapon type for " + owner + ": " + weapontype);
            weapontype = "WEAPON_NONE";
            cliptype = "NONE";
        }
        else
        {
            const vector<attackst*>& attacks = ::weapontype[getweapontype(weapontype)]->get_attacks();

            // Find a usable clip type for the weapon.
            if (cliptype == "APPROPRIATE")
            {
                cliptype = "NONE";
                for(int i=0; i<len(attacks); i++)
                {
                    if(attacks[i]->uses_ammo)
                    {
                        cliptype=attacks[i]->ammotype;
                        break;
                    }
                }
            }
            // Check clip is usable by the weapon.
            else if (getcliptype(cliptype) != -1) //Must be a clip type too.
            {
                int i;
                for(i=0; i<len(attacks)&&cliptype!=attacks[i]->ammotype; i++);
                if(i==len(attacks))
                {
                    xmllog.log("In " + owner + ", " + cliptype +
                               "can not be used by " + weapontype + ".");
                    cliptype = "NONE";
                }
            }
            // Undefined clip type.
            else
            {
                xmllog.log("Invalid clip type for " + owner + ": " + cliptype);
                cliptype = "NONE";
            }
        }
    }
}
コード例 #11
0
ファイル: db_leos.cpp プロジェクト: Fluffiest/splayer
void db_leos::GetResults(window_config *wcfg, std::vector<lyric_data>* results, tstring title, tstring artist, tstring album)
{

  title = ReplaceString(_T("&"), _T("and"), title);
  artist = ReplaceString(_T("&"), _T("and"), artist);
  title = ReplaceString(_T("pt."), _T("part"), title);
  artist = ReplaceString(_T("pt."), _T("part"), artist);

  tstring out;

  out = _T("api_search.php?auth=foo_uie_lyrics2&artist=");
  out += CURLEncode::Encode(artist);
  out += _T("&songtitle=");
  out += CURLEncode::Encode(title);

  tstring remoteText;

  if (!ReadInternetText(remoteText, _T("FOO_UIE_LYRICS2"), _T("api.leoslyrics.com"), 80, out, _T(""), false, wcfg->cfg_timeout, wcfg))
    return ;

  CMarkup xml;

  if (!xml.SetDoc(remoteText.c_str()))
    return ;

  if (xml.FindChildElem(_T("searchResults")))
  {
    xml.IntoElem();

    while (xml.FindChildElem(_T("result")))
    {
      xml.IntoElem();

      if (!_wcsicmp(_T("true"), xml.GetAttrib(_T("exactMatch")).c_str()))
      {
        tstring hid = xml.GetAttrib(_T("hid"));

        if (!hid.empty())
        {

          lyric_data newData(wcfg);
          newData.SourceType = ST_INTERNET;
          newData.IsLoaded = false;
          newData.IsTimestamped = false;
          newData.matchArtist = _T("");
          newData.matchAlbum = _T("");
          newData.matchTitle = title;
          newData.db = this;
          newData.OnlineService = LD_LEOS;
          newData.Quality = Q_MEDIUM;
          newData.Source = _T("http://api.leoslyrics.com/api_lyrics.php?auth=foo_uie_lyrics2&hid=");
          newData.Source += hid;

          results->push_back(newData);
        }
      }

      xml.OutOfElem();
    }

    xml.OutOfElem();
  }

}
コード例 #12
0
int parseProfessor(string path, dadosProfessor *temp){
    CMarkup xml;
    int nTrab = 0, nArt = 0;

    if(!xml.Load(path)){
        cout << "Erro de abertura do arquivo xml." << endl;
        return 1;
    }

// ========= DADOS GERAIS ===================
    if (!xml.FindElem("CURRICULO-VITAE")){
        cout << "Sem CV" << endl;
        return ERROR;
    }
    xml.IntoElem(); //seta CV como tag pai

    if(!xml.FindElem("DADOS-GERAIS")){
        cout << "Sem DADOS-GERAIS." << endl;
        return ERROR;
    }
    temp->nome = xml.GetAttrib("NOME-COMPLETO");
    //cout << temp.nome << endl;
    xml.IntoElem(); // define DADOS-GERAIS como parent

    if(!xml.FindElem("ATUACOES-PROFISSIONAIS")){
        cout << "Sem ATUACOES-PROFISSIONAIS" <<endl;
        return ERROR;
    }
    if(!xml.FindChildElem("ATUACAO-PROFISSIONAL")){
        cout << "Sem ATUACAO-PROFISSIONAL" << endl;
        return ERROR;
    }
    temp->instituicao = xml.GetChildAttrib("NOME-INSTITUICAO");
    //cout << temp.instituicao << endl;
    xml.IntoElem(); // define ATUACAO-PROFISSIONAL como parent

    if(!xml.FindChildElem("ATIVIDADES-DE-PESQUISA-E-DESENVOLVIMENTO")){
        cout << "Sem linha de pesquisa" << endl;
        return ERROR;
    }
    xml.IntoElem(); //define APD como parent

    if(!xml.FindChildElem("PESQUISA-E-DESENVOLVIMENTO")){
        cout << "Sem linha de pesquisa" << endl;
        return ERROR;
    }
    xml.IntoElem(); // define PD como parent

    if(!xml.FindChildElem("LINHA-DE-PESQUISA")){
        cout << "Sem linha de pesquisa" << endl;
        return ERROR;
    }
    temp->area = xml.GetChildAttrib("TITULO-DA-LINHA-DE-PESQUISA");
    //cout << temp.area << endl;

    xml.ResetPos();


// ========= TRABALHOS EM EVENTOS ===================
    xml.FindElem("CURRICULO-VITAE"); // se passou pelo primeiro findelem(curriculo vitae)
    //passa por esse
    xml.IntoElem(); //seta CV como tag pai

    if(!xml.FindElem("PRODUCAO-BIBLIOGRAFICA")){
        cout << "Sem PRODUCAO-BIBLIOGRAFICA." << endl;
        return ERROR;
    }
    xml.IntoElem();

    if(!xml.FindElem("TRABALHOS-EM-EVENTOS")){
        cout << "Sem TRABALHOS-EM-EVENTOS." << endl;
        return ERROR;
    }
    xml.IntoElem();// define TRABALHOS-EM-EVENTOS como parent

    while(xml.FindElem()){
        Trabalho trab;
        xml.FindChildElem("DADOS-BASICOS-DO-TRABALHO");
        trab.titulo = xml.GetChildAttrib("TITULO-DO-TRABALHO");
        trab.ano = xml.GetChildAttrib("ANO-DO-TRABALHO");
        temp->pubEventos.push_back(trab);
        nTrab++;
    }
    temp->nPubEventos = nTrab;
    xml.ResetPos();


// ========= ARTIGOS PUBLICADOS ===================
    xml.FindElem("CURRICULO-VITAE"); // se passou pelo primeiro findelem(curriculo vitae)
    //passa por esse
    xml.IntoElem(); //seta CV como tag pai

    if(!xml.FindElem("PRODUCAO-BIBLIOGRAFICA")){
        cout << "Sem PRODUCAO-BIBLIOGRAFICA." << endl;
        return ERROR;
    }
    xml.IntoElem();

    if(!xml.FindElem("ARTIGOS-PUBLICADOS")){
        cout << "Sem ARTIGOS-PUBLICADOS." << endl;
        return ERROR;
    }
    xml.IntoElem();// define ARTIGOS-PUBLICADOS como parent

    while(xml.FindElem()){
        Artigo artigo;
        xml.FindChildElem("DADOS-BASICOS-DO-ARTIGO");
        artigo.titulo = xml.GetChildAttrib("TITULO-DO-ARTIGO");
        artigo.ano = xml.GetChildAttrib("ANO-DO-ARTIGO");
        temp->pubPeriodicos.push_back(artigo);
        nArt++;
    }
    temp->nPubPeriodicos = nArt;


    return SUCCESS;
}
コード例 #13
0
ファイル: UpdateUtil.cpp プロジェクト: jongha/update-dll
/*			
SET_ITEM_DATA(type, Type, false);
SET_ITEM_DATA(version, Version, true);
SET_ITEM_DATA(downurl, DownURL, true);
SET_ITEM_DATA(downpath, DownPath, false);
SET_ITEM_DATA(description, Description, false);
SET_ITEM_DATA(force, Force, false);
SET_ITEM_DATA(regsrv, RegSrv, false);
*/
BOOL CUpdateUtil::ReadXML(CString& strXMLdoc, CItemList* pSourceItemList, int nKind)
{
	CString strData = "";
	
	if(strXMLdoc.IsEmpty())
		return FALSE;

	CMarkup xml;
	
	if(!xml.SetDoc(strXMLdoc))
		return FALSE;

	xml.ResetPos();

	if(!xml.FindElem(_T("update-data")))
		return FALSE;

	UTIL_CANCEL();
	while(xml.FindChildElem(_T("file")))
	{	
		UTIL_CANCEL();
		strData = "";
		strData = xml.GetChildAttrib(_T("name"));
		
		if(!strData.IsEmpty())
		{
			xml.IntoElem();
			if(nKind == UPDATE_KIND_SOURCE)
			{
				PUPDATE_DATA pFileData = (PUPDATE_DATA)pSourceItemList->GetNewItem();
				memset(pFileData, 0, sizeof(UPDATE_DATA));

				STRCPY(Name);
				if(xml.FindChildElem(_T("type")))
				{
					DATA_INIT_AND_DEPOSIT();
					STRCPY(Type);
				}

				if(xml.FindChildElem(_T("version")))
				{
					DATA_INIT_AND_DEPOSIT();
					STRCPY(Version);
				}
				
				if(xml.FindChildElem(_T("size")))
				{				
					DATA_INIT_AND_DEPOSIT();					
					pFileData->Size = CString2Integer(strData);
				}

				if(xml.FindChildElem(_T("downurl")))
				{				
					DATA_INIT_AND_DEPOSIT();
					STRCPY(DownURL);
				}
				else											
					return FALSE;							

				if(xml.FindChildElem(_T("downpath")))
				{				
					DATA_INIT_AND_DEPOSIT();
					strData = GetFolderPath(strData);
					STRCPY(DownPath);
				}
				
				if(xml.FindChildElem(_T("description")))
				{				
					DATA_INIT_AND_DEPOSIT();
					STRCPY(Description);
				}

				if(xml.FindChildElem(_T("force")))
				{				
					DATA_INIT_AND_DEPOSIT_NOCASE();
					STRCPY(Force);
				}

				if(xml.FindChildElem(_T("regsrv")))
				{				
					DATA_INIT_AND_DEPOSIT_NOCASE();
					STRCPY(RegSrv);
				}

				if(xml.FindChildElem(_T("checksum")))
				{
					DATA_INIT_AND_DEPOSIT_NOCASE();
					STRCPY(CheckSum);
				}
				
				if(xml.FindChildElem(_T("optionflag")))
				{
					DATA_INIT_AND_DEPOSIT();
					pFileData->OptionFlag = CString2Integer(strData);
				}
			}
			else
			{
				PUPDATE_DATA pFileData = (PUPDATE_DATA)pSourceItemList->GetNewItem();
				memset(pFileData, 0, sizeof(UPDATE_DATA));
				
				STRCPY(Name);
				if(xml.FindChildElem(_T("version")))
				{				
					DATA_INIT_AND_DEPOSIT();
					STRCPY(Version);
				}
				else
				{											
					return FALSE;							
				}

				if(xml.FindChildElem(_T("downpath")))
				{				
					DATA_INIT_AND_DEPOSIT();
					strData = GetFolderPath(strData);
					STRCPY(DownPath);
				}
			}
			xml.OutOfElem();
		}
	}
	
	return TRUE;
}
コード例 #14
0
ファイル: db_lyricsfly.cpp プロジェクト: Strongc/playasa
void db_lyricsfly::GetResults(window_config *wcfg, std::vector<lyric_data>* results, tstring title, tstring artist, tstring album)
{
  title = ReplaceString(_T("&"), _T("and"), title);
  artist = ReplaceString(_T("&"), _T("and"), artist);
  title = ReplaceString(_T("pt."), _T("part"), title);
  artist = ReplaceString(_T("pt."), _T("part"), artist);

  tstring out;
  out = _T("api/api.php?i=");
  out += _T("55562032656-reeloo.net/wordpress/lyrics-for-lastfm-radio");
  out += _T("&a=");
  out += CURLEncode::Encode(artist);
  out += _T("&t=");
  out += CURLEncode::Encode(title);

  tstring remoteText;

  if (!ReadInternetText(remoteText, _T("Mozilla/4.0 (compatible) Greasemonkey"), _T("api.lyricsfly.com"), 80, out, _T(""), false, wcfg->cfg_timeout, wcfg))
    return ;

  CMarkup xml;

  if (!xml.SetDoc(remoteText.c_str()))
    return ;

  while (xml.FindChildElem(_T("sg")))
  {
    xml.IntoElem();

    tstring info_artist, info_title, info_album, info_lyrics;

    if (xml.FindChildElem(_T("tx")))
    {
      info_lyrics = xml.GetChildData();
    }
    else
    {
      xml.OutOfElem();
      continue;
    }

    xml.ResetChildPos();

    if (xml.FindChildElem(_T("ar")))
    {
      info_artist = xml.GetChildData();
    }

    xml.ResetChildPos();

    if (xml.FindChildElem(_T("al")))
    {
      info_album = xml.GetChildData();
    }

    xml.ResetChildPos();

    if (xml.FindChildElem(_T("tt")))
    {
      info_title = xml.GetChildData();
    }

    lyric_data newData(wcfg);
    newData.SourceType = ST_INTERNET;
    newData.IsLoaded = true;
    newData.matchArtist = info_artist;
    newData.matchAlbum = info_album;
    newData.matchTitle = info_title;
    newData.db = this;
    newData.OnlineService = LD_LYRICSFLY;
    newData.Quality = Q_MEDIUM;
    newData.Source = _T("lyricsfly");

    newData.Text = info_lyrics;
    newData.Text = ReplaceString(_T("[br]"), _T(""), newData.Text);
    newData.Text = ReplaceString(_T("\r"), _T(""), newData.Text);
    newData.Text = ReplaceString(_T("\n"), _T("\r\n"), newData.Text);

    if (newData.Text.find(_T("[")) != tstring::npos)
      newData.IsTimestamped = true;
    else
      newData.IsTimestamped = false;

    results->push_back(newData);

    xml.OutOfElem();
  }

}
コード例 #15
0
BOOL CNetConfig::ReadXml()
{
    CMarkup xml;
    tstring strTmp;

    if (!xml.Load(_T("finet.xml"))) 
    {
	printf("load finet xml failed \n");
	return FALSE;
    }

    if (xml.FindChildElem(_T("iocpnum")))
    {
	xml.IntoElem();
	strTmp = xml.GetData();
	if (!strTmp.empty())
	{
#if (defined(_WIN32) || defined(_WIN64))
		char tmp[64];
		memset(tmp,0,64);

		UTF16ConvertANSI((WCHAR*)strTmp.c_str(), strTmp.length(), tmp, 64);
	    m_iocp_num = atoi(tmp);
#else
	    m_iocp_num = atoi(strTmp.c_str());
#endif
	}
	xml.OutOfElem();
    }

    if (xml.FindChildElem(_T("local")))
    {
	xml.IntoElem();

	CHostInfo hs;

	if (xml.FindChildElem(_T("host")))
	{
	    xml.IntoElem();
	    while (xml.FindChildElem(_T("ip")))
	    {
			xml.IntoElem();
			
			strTmp = xml.GetData();
			CStdString aa = strTmp.c_str();
			CNetCard nc(ConvertIPtoDWORD(aa));
			hs.AddCard(nc,FiGetPid());

			xml.OutOfElem();
	    }
	    xml.OutOfElem();
	}
	
        CProcId cid = hs.m_mapProcId.begin()->second;
	hs.m_identify = cid.m_mapIp.begin()->first;

	m_LocalIp = hs;

	xml.OutOfElem();
    }

    if (xml.FindChildElem(_T("remote")))
    {
	xml.IntoElem();

	while (xml.FindChildElem(_T("host")))
	{
	    CHostInfo *hs = new CHostInfo;

	    xml.IntoElem();
	    while (xml.FindChildElem(_T("ip")))
	    {
		xml.IntoElem();
		
		strTmp = xml.GetData();
		CStdString bb = strTmp.c_str();

		CNetCard nc(ConvertIPtoDWORD(bb));
		hs->AddCard(nc, FiGetPid());

		xml.OutOfElem();

		/// all remote ip can be indexed by ip (ip to all ip (hostinfo class)) 
		m_RemoteIp.insert(make_pair(nc.GetIp(),hs));
	    }
	    xml.OutOfElem();

	    
	}
	xml.OutOfElem();
    }

    return TRUE;
}
コード例 #16
0
ファイル: ConnectThread.cpp プロジェクト: niujingqian/haocai
//获取手机系统信息
bool CConnectThread::GetPhoneSystemInfo(sPhoneInfo& Info)
{
	bool Ret=false;
	CString CmdStr;
	CString CmdRetStr;
	CmdStr=_T("<?xml version='1.0'?><req><fun>GetSystemAgentVar</fun><ps count='0'></ps></req>");

	if(CCommunication::SendXmlToPhone(CmdStr,CmdRetStr) < 0x00)
		return Ret;
	if(CmdRetStr.IsEmpty())
		return Ret;

	CMarkup Xml;
	if(Xml.SetDoc(CmdRetStr))
	{
		CString strData;
		Xml.ResetMainPos();
		Xml.FindChildElem(_T("ps"));

		if (Xml.IntoElem())
		{
			Ret=true;
			while ( Xml.FindChildElem(_T("p")) )
			{
				
				CString strMsg;
				Xml.IntoElem();

				Xml.FindChildElem(_T("name"));
				strData = Xml.GetChildData().c_str();
				if (strData == _T("msg"))
				{
					Xml.FindChildElem(_T("value"));							
					strMsg = Xml.GetChildData().c_str();

					if (strMsg != _T("0"))
					{
						return false;
					}
				}else if  (strData == _T("var"))
				{				
					Xml.FindChildElem(_T("value"));							
					Info.m_PhoneOSVer = Xml.GetChildData().c_str();
					Info.m_PhoneOS = Info.m_PhoneOSVer.Mid(0x00, Info.m_PhoneOSVer.Find(_T(" "))); //Andriod 2.1-Update-1

				}else if  (strData == _T("agent"))
				{				
					Xml.FindChildElem(_T("value"));							
					Info.m_PhoneModel= Xml.GetChildData().c_str();

				}else if  (strData == _T("programver"))
				{				
					Xml.FindChildElem(_T("value"));							
					CString strApkVer = Xml.GetChildData().c_str();
				}else if  (strData == _T("imei"))
				{				
					Xml.FindChildElem(_T("value"));							
					Info.m_PhoneIMEI = Xml.GetChildData().c_str();

				}else if  (strData == _T("imsi"))
				{				
					Xml.FindChildElem(_T("value"));							
					Info.m_PhoneIMSI = Xml.GetChildData().c_str();

				}else{;}

				Xml.OutOfElem();
			}
		}
	}

	return Ret;
}
コード例 #17
0
// 初始化应用配置信息
BOOL COBDPNDConfigReadWrite::fInitAppConfig(void)
{
	CMarkup xml;
	CString strAppPath = fCommGetAppPath() + _T("\\");

	CString strAppConfigFile = strAppPath + _T("Config.xml");
	if (!xml.Load(strAppConfigFile))
	{		
		return CONFIG_ERR_LOAD_FILE; 
	}

	xml.ResetMainPos();
	xml.FindElem();	

	if(xml.FindChildElem(_T("System")))
	{		
		xml.IntoElem();	
		if(xml.FindChildElem(_T("Base")))
		{			
			m_tagAppConfig.bIsDemo			= (xml.GetChildAttrib(_T("Demo_Mode"))==_T("ON")?TRUE:FALSE);
			m_tagAppConfig.strTextFile		= xml.GetChildAttrib(_T("File_Text"));
			m_tagAppConfig.strFilterAppList = xml.GetChildAttrib(_T("FILTER_APP_LIST"));
		}
		if(xml.FindChildElem(_T("COM_OBD")))
		{			
			m_tagAppConfig.tagComOBD.wPort = (WORD)_ttoi(xml.GetChildAttrib(_T("Port")));
			m_tagAppConfig.tagComOBD.dwBPS =(WORD) _ttoi(xml.GetChildAttrib(_T("BPS")));
			m_tagAppConfig.tagComOBD.wData_Bits = (WORD)_ttoi(xml.GetChildAttrib(_T("Data_Bits")));
			m_tagAppConfig.tagComOBD.wStop_Bits = (WORD)_ttoi(xml.GetChildAttrib(_T("Stop_Bits")));
			m_tagAppConfig.tagComOBD.wParity = 0;//_ttoi(xml.GetChildAttrib(_T("Parity")));
		}
		if(xml.FindChildElem(_T("COM_GPS")))
		{			
			m_tagAppConfig.tagComGPS.wPort = (WORD)_ttoi(xml.GetChildAttrib(_T("Port")));
			m_tagAppConfig.tagComGPS.dwBPS = (WORD)_ttoi(xml.GetChildAttrib(_T("BPS")));
			m_tagAppConfig.tagComGPS.wData_Bits = (WORD)_ttoi(xml.GetChildAttrib(_T("Data_Bits")));
			m_tagAppConfig.tagComGPS.wStop_Bits = (WORD)_ttoi(xml.GetChildAttrib(_T("Stop_Bits")));
			m_tagAppConfig.tagComGPS.wParity = 0;//_ttoi(xml.GetChildAttrib(_T("Parity")));
		}
		if(xml.FindChildElem(_T("Setting")))
		{			
			m_tagAppConfig.tagSetting.strLanguage			= xml.GetChildAttrib(_T("LANGUAGE"));
			m_tagAppConfig.tagSetting.bSaveErrorLog			= (xml.GetChildAttrib(_T("Save_ErrorLog"))==_T("OFF")?FALSE:TRUE);
			m_tagAppConfig.tagSetting.wBacklightDay			= _ttoi(xml.GetChildAttrib(_T("BACKLIGHT_DAY")));
			m_tagAppConfig.tagSetting.wBacklightNight		= _ttoi(xml.GetChildAttrib(_T("BACKLIGHT_NIGHT")));
			m_tagAppConfig.tagSetting.wBacklightDayStart	= _ttoi(xml.GetChildAttrib(_T("BACKLIGHT_DAY_START")));
			m_tagAppConfig.tagSetting.wBackLightDayEnd		= _ttoi(xml.GetChildAttrib(_T("BACKLIGHT_DAY_END")));
			m_tagAppConfig.tagSetting.dwActiveEcuID			= _ttoi(xml.GetChildAttrib(_T("Active_EUC_ID")));
			m_tagAppConfig.tagSetting.str24or12				= xml.GetChildAttrib(_T("Time_24_12Hour"));
			m_tagAppConfig.tagSetting.dwSystemOffTime		= _ttoi(xml.GetChildAttrib(_T("System_Off_Time")));
			m_tagAppConfig.tagSetting.dwSystemOffMode		= _ttoi(xml.GetChildAttrib(_T("System_Off_Mode")));
			m_tagAppConfig.tagSetting.dwAutoSelPanelTime	= _ttoi(xml.GetChildAttrib(_T("Auto_Sel_Panel_Time")));
			m_tagAppConfig.tagSetting.fAvgFuelParameter		= wcstod(xml.GetChildAttrib(_T("Parameter_Fuel_Avg")),0);
			m_tagAppConfig.tagSetting.fInstantFuelParameter	= wcstod(xml.GetChildAttrib(_T("Parameter_Fuel_Instant")),0);
			m_tagAppConfig.tagSetting.fFuelPrice			= wcstod(xml.GetChildAttrib(_T("Fuel_Price")),0);
			m_tagAppConfig.tagSetting.dwActiveEcuID			= _ttoi(xml.GetChildAttrib(_T("Active_ECU_ID")));
		}
		if(xml.FindChildElem(_T("Language_list")))
		{
			xml.IntoElem(); 

			m_tagAppConfig.vecLanguage.clear();
			while(xml.FindChildElem(_T("LANGUAGE")))
			{	
				_TagLanguage tagLanData;
				tagLanData.strLanID		= xml.GetChildAttrib(_T("LANGUAGE_ID"));
				tagLanData.strLanName	= xml.GetChildAttrib(_T("LANGUAGE_NAME"));
				tagLanData.strLanSN		= xml.GetChildAttrib(_T("LANGUAGE_SN"));
				tagLanData.strResFiles	= xml.GetChildAttrib(_T("LANGUAGE_RES"));

				m_tagAppConfig.vecLanguage.push_back(tagLanData);
			}

			xml.OutOfElem();
		}
		if(xml.FindChildElem(_T("Set_Alarm")))
		{		
			m_tagAppConfig.tagAlarmSet.bTroubleCode				= xml.GetChildAttrib(_T("TroubleCode"))==_T("ON")?TRUE:FALSE;
			m_tagAppConfig.tagAlarmSet.wSpeed					= _ttoi(xml.GetChildAttrib(_T("Speed")));
			m_tagAppConfig.tagAlarmSet.wCoolant					= _ttoi(xml.GetChildAttrib(_T("Coolant")));
			m_tagAppConfig.tagAlarmSet.wFatigue_Driving			= _ttoi(xml.GetChildAttrib(_T("Fatigue_Driving")));
			m_tagAppConfig.tagAlarmSet.dbFuel					= wcstod(xml.GetChildAttrib(_T("Fuel")),0);

			xml.IntoElem();
			if(xml.FindChildElem(_T("Shift")))
			{
				m_tagAppConfig.tagAlarmSet.wShiftRpm				= _ttoi(xml.GetChildAttrib(_T("Shift_Rpm")));
				m_tagAppConfig.tagAlarmSet.wShiftSpeed			= _ttoi(xml.GetChildAttrib(_T("Shift_Speed")));
			}
			if(xml.FindChildElem(_T("Volt")))
			{
				m_tagAppConfig.tagAlarmSet.wVoltMin				= _ttoi(xml.GetChildAttrib(_T("Volt_Min")));
				m_tagAppConfig.tagAlarmSet.wVoltMax				= _ttoi(xml.GetChildAttrib(_T("Volt_Max")));
			}

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

	if(xml.FindChildElem(_T("Mini_Dlg")))
	{			
		m_tagAppConfig.tagMiniSpeed.dw480X272_X			= _ttoi(xml.GetChildAttrib(_T("X_480X272")));	
		m_tagAppConfig.tagMiniSpeed.dw480X272_Y			= _ttoi(xml.GetChildAttrib(_T("Y_480X272")));		
		m_tagAppConfig.tagMiniSpeed.dw800X480_X			= _ttoi(xml.GetChildAttrib(_T("X_800X480")));		
		m_tagAppConfig.tagMiniSpeed.dw800X480_Y			= _ttoi(xml.GetChildAttrib(_T("Y_800X480")));				
	}

	if(xml.FindChildElem(_T("UiData")))
	{		
		xml.IntoElem();	
		if(xml.FindChildElem(_T("Idle")))
		{	
			m_tagAppConfig.tagUiDataIdle.dwLeftUpID			= fCommStr2Hex(xml.GetChildAttrib(_T("ID_Left_Up")));
			m_tagAppConfig.tagUiDataIdle.dwLeftMiddleID		= fCommStr2Hex(xml.GetChildAttrib(_T("ID_Left_Middle")));
			m_tagAppConfig.tagUiDataIdle.dwLeftDownID		= fCommStr2Hex(xml.GetChildAttrib(_T("ID_Left_Down")));
			m_tagAppConfig.tagUiDataIdle.dwRightUpID		= fCommStr2Hex(xml.GetChildAttrib(_T("ID_Right_Up")));
			m_tagAppConfig.tagUiDataIdle.dwRightMiddleID	= fCommStr2Hex(xml.GetChildAttrib(_T("ID_Right_Middle")));
			m_tagAppConfig.tagUiDataIdle.dwRightDownID		= fCommStr2Hex(xml.GetChildAttrib(_T("ID_Right_Down")));
		}

		if(xml.FindChildElem(_T("Tour")))
		{		
			m_tagAppConfig.tagUiDataTour.dwLeftUpID			= fCommStr2Hex(xml.GetChildAttrib(_T("ID_Left_Up")));
			m_tagAppConfig.tagUiDataTour.dwLeftMiddleID		= fCommStr2Hex(xml.GetChildAttrib(_T("ID_Left_Middle")));
			m_tagAppConfig.tagUiDataTour.dwLeftDownID		= fCommStr2Hex(xml.GetChildAttrib(_T("ID_Left_Down")));
			m_tagAppConfig.tagUiDataTour.dwRightUpID		= fCommStr2Hex(xml.GetChildAttrib(_T("ID_Right_Up")));
			m_tagAppConfig.tagUiDataTour.dwRightMiddleID	= fCommStr2Hex(xml.GetChildAttrib(_T("ID_Right_Middle")));
			m_tagAppConfig.tagUiDataTour.dwRightDownID		= fCommStr2Hex(xml.GetChildAttrib(_T("ID_Right_Down")));
		}

		if(xml.FindChildElem(_T("Race")))
		{		
			m_tagAppConfig.tagUiDataRace.dwLeftUpID			= fCommStr2Hex(xml.GetChildAttrib(_T("ID_Left_Up")));
			m_tagAppConfig.tagUiDataRace.dwLeftDownID		= fCommStr2Hex(xml.GetChildAttrib(_T("ID_Left_Down")));
			m_tagAppConfig.tagUiDataRace.dwRightUpID		= fCommStr2Hex(xml.GetChildAttrib(_T("ID_Right_Up")));
			m_tagAppConfig.tagUiDataRace.dwRightDownID		= fCommStr2Hex(xml.GetChildAttrib(_T("ID_Right_Down")));
			m_tagAppConfig.tagUiDataRace.dwMiddleUpID		= fCommStr2Hex(xml.GetChildAttrib(_T("ID_Middle_Up")));
			m_tagAppConfig.tagUiDataRace.dwMiddleMiddleID	= fCommStr2Hex(xml.GetChildAttrib(_T("ID_Middle_Middle")));
			m_tagAppConfig.tagUiDataRace.dwMiddleDownID		= fCommStr2Hex(xml.GetChildAttrib(_T("ID_Middle_Down")));
		}
		xml.OutOfElem();
	}
	if(xml.FindChildElem(_T("Sound")))
	{
		m_tagAppConfig.tagSoundFile.strDong					=  strAppPath + xml.GetChildAttrib(_T("Dong"));
		m_tagAppConfig.tagSoundFile.strInitialze			=  strAppPath + xml.GetChildAttrib(_T("Initialze"));
		m_tagAppConfig.tagSoundFile.strStart				=  strAppPath + xml.GetChildAttrib(_T("Start"));
		m_tagAppConfig.tagSoundFile.strGetData				=  strAppPath + xml.GetChildAttrib(_T("GetData"));
		m_tagAppConfig.tagSoundFile.strAlarmCoolant			=  strAppPath + xml.GetChildAttrib(_T("AlarmCoolant"));
		m_tagAppConfig.tagSoundFile.strAlarmFatigueDriving	=  strAppPath + xml.GetChildAttrib(_T("AlarmFatigueDriving"));
		m_tagAppConfig.tagSoundFile.strAlarmOverSpeed		=  strAppPath + xml.GetChildAttrib(_T("AlarmOverSpeed"));
		m_tagAppConfig.tagSoundFile.strAlarmVoltHigh		=  strAppPath + xml.GetChildAttrib(_T("AlarmVoltHigh"));
		m_tagAppConfig.tagSoundFile.strAlarmVoltLow			=  strAppPath + xml.GetChildAttrib(_T("AlarmVoltLow"));
		m_tagAppConfig.tagSoundFile.strAlarmTrouble			=  strAppPath + xml.GetChildAttrib(_T("AlarmTrouble"));
	}
	if(xml.FindChildElem(_T("GPS_LIST")))
	{
		xml.IntoElem();

		m_vecGPSList.clear();
		while(xml.FindChildElem(_T("GPS")))
		{	
			TagAppInfo tagAppInfo;
			tagAppInfo.strAppID = xml.GetChildAttrib(_T("ID"));
			tagAppInfo.strAppName = xml.GetChildAttrib(_T("NAME_CHS"));
			tagAppInfo.strAppPath =  xml.GetChildAttrib(_T("FOLDER"));
			tagAppInfo.strAppExe = xml.GetChildAttrib(_T("EXE"));
			tagAppInfo.bAutoRun = FALSE;

			m_vecGPSList.push_back(tagAppInfo);
		}
		xml.OutOfElem();
	}	

	if(xml.FindChildElem(_T("DSA_LIST")))
	{
		xml.IntoElem();

		m_vecDSAList.clear();
		while(xml.FindChildElem(_T("DSA"))) 
		{	
			TagAppInfo tagAppInfo;
			tagAppInfo.strAppID = xml.GetChildAttrib(_T("ID"));
			tagAppInfo.strAppName = xml.GetChildAttrib(_T("NAME_CHS"));
			tagAppInfo.strAppPath =  xml.GetChildAttrib(_T("FOLDER"));
			tagAppInfo.strAppExe= xml.GetChildAttrib(_T("EXE"));
			tagAppInfo.bAutoRun = FALSE;

			m_vecDSAList.push_back(tagAppInfo);
		}
		xml.OutOfElem();
	}	
	
	if(xml.FindChildElem(_T("APP_START_LIST")))
	{
		xml.IntoElem();

		m_vecAppList.clear();
		while(xml.FindChildElem(_T("APP"))) 
		{	
			TagAppInfo tagAppInfo;
			tagAppInfo.strAppID = xml.GetChildAttrib(_T("ID"));
			if (tagAppInfo.strAppID == _T("1"))
				tagAppInfo.strAppName = theMainDlg->fGetBinText(DS_SETUP_GUIDE_DSA_TITLE);
			if (tagAppInfo.strAppID == _T("2"))
				tagAppInfo.strAppName = theMainDlg->fGetBinText(DS_SETUP_GUIDE_GPS_TITLE);
			tagAppInfo.strAppPath =  xml.GetChildAttrib(_T("PATH"));
			if (xml.GetChildAttrib(_T("AUTO_RUN")) == _T("1"))
				tagAppInfo.bAutoRun = TRUE;
			else
				tagAppInfo.bAutoRun = FALSE;

			m_vecAppList.push_back(tagAppInfo);
		}
		xml.OutOfElem();
	}	


	return TRUE;
}
コード例 #18
0
ファイル: ConnectThread.cpp プロジェクト: niujingqian/haocai
//获取手机统计信息
bool CConnectThread::GetPhoneCountInfo(sPhoneInfo& Info)
{
	bool Ret=false;

	CString CmdStr;
	CString CmdRetStr;


	CString TypeValue;
	TypeValue = _T("app;contacts;sms;music;video;picture");

	CmdStr  = _T("<?xml version='1.0'?>");
	CmdStr += _T("<req>");
	CmdStr += _T("<fun>GetStatisticsData</fun>");
	CmdStr += _T("<ps count='0'>");
	CmdStr += _T("<p>");
	CmdStr += _T("<name>request</name>");
	CmdStr += _T("<value>") + TypeValue + _T("</value>");
	CmdStr += _T("</p>");
	CmdStr += _T("</ps>\n");
	CmdStr += _T("</req>\n");

	CCommunication::SendXmlToPhone(CmdStr,CmdRetStr);

	//解析返回值
	//分析返回的XML数据
	CString strData;
	CString strMsg;

	if ( !CmdRetStr.IsEmpty())
	{

		CMarkup Xml;
		if (Xml.SetDoc(CmdStr) )
		{			
			Xml.FindChildElem(_T("ps"));
			if (Xml.IntoElem())
			{
				Ret = true;
				while ( Xml.FindChildElem(_T("p")) )
				{
					strMsg.Empty();

					Xml.IntoElem();

					Xml.FindChildElem(_T("name"));
					strData = Xml.GetChildData().c_str();
					if (strData == _T("msg"))
					{
						Xml.FindChildElem(_T("value"));							
						strMsg = Xml.GetChildData().c_str();

						if (strMsg != _T("0"))
						{
							return false;
						}
					}
					else
					{	
						if (strData == _T("app"))
						{
							Xml.FindChildElem(_T("value"));							
							strMsg = Xml.GetChildData().c_str();
							
							Info.m_AppSum = _wtoi(strMsg.GetBuffer());
							strMsg.ReleaseBuffer();
						}

						if (strData == _T("contacts"))
						{
							Xml.FindChildElem(_T("value"));							
							strMsg = Xml.GetChildData().c_str();

							Info.m_ContactSum = _wtoi(strMsg.GetBuffer());
							strMsg.ReleaseBuffer();
						}

						if (strData == _T("sms"))
						{
							Xml.FindChildElem(_T("value"));							
							strMsg = Xml.GetChildData().c_str();

							Info.m_SmsSum = _wtoi(strMsg.GetBuffer());
							strMsg.ReleaseBuffer();
						}

						if (strData == _T("music"))
						{
							Xml.FindChildElem(_T("value"));							
							strMsg = Xml.GetChildData().c_str();

							Info.m_MusicSum = _wtoi(strMsg.GetBuffer());
							strMsg.ReleaseBuffer();
						}

						if (strData == _T("video"))
						{
							Xml.FindChildElem(_T("value"));							
							strMsg = Xml.GetChildData().c_str();

							Info.m_VideoSum = _wtoi(strMsg.GetBuffer());
							strMsg.ReleaseBuffer();
						}

						if (strData == _T("picture"))
						{
							Xml.FindChildElem(_T("value"));							
							strMsg = Xml.GetChildData().c_str();

							Info.m_PicSum= _wtoi(strMsg.GetBuffer());
							strMsg.ReleaseBuffer();
						}

					}
					Xml.OutOfElem();
				}
			}
		}
	}

	return Ret;
}
コード例 #19
0
ファイル: ConnectThread.cpp プロジェクト: niujingqian/haocai
//获取手机内存信息
bool CConnectThread::GetPhoneMemInfo(sPhoneInfo& Info)
{
	bool Ret=false;
	CString CmdStr;
	CString CmdRetStr;

	CmdStr =_T("<?xml version='1.0'?><req><fun>GetMemSize</fun><ps count='0'>/ps></req>");
	if(CCommunication::SendXmlToPhone(CmdStr,CmdRetStr) < 0)
		return Ret;

	if (!CmdRetStr.IsEmpty())
	{
		CMarkup Xml;
		if (Xml.SetDoc(CmdRetStr) )
		{			
			CString strXmlName;
			Xml.FindChildElem(_T("ps"));
			if (Xml.IntoElem())
			{
				Ret = true;

				while ( Xml.FindChildElem(_T("p")) )
				{
					Xml.IntoElem();
					CString strXmlValue ;

					Xml.FindChildElem(_T("name"));
					strXmlName = Xml.GetChildData().c_str();
					if (strXmlName == _T("msg"))
					{
						Xml.FindChildElem(_T("value"));							
						strXmlValue = Xml.GetChildData().c_str();

						if (strXmlValue != _T("0"))
						{
							return false;
						}
					}
					else if (strXmlName == _T("sdcardall"))
					{
						Xml.FindChildElem(_T("value"));							
						strXmlValue = Xml.GetChildData().c_str();

						if (!strXmlValue.IsEmpty())
						{							
							Info.m_SDTotalMem = _wtoi(strXmlValue.GetBuffer());
							strXmlValue.ReleaseBuffer();
						}
						else
							Info.m_SDTotalMem = 0;
					}
					else if (strXmlName == _T("sdcarduse"))
					{

						Xml.FindChildElem(_T("value"));							
						strXmlValue = Xml.GetChildData().c_str();

						if (!strXmlValue.IsEmpty())
						{							
							Info.m_SDUsedMem = _wtoi(strXmlValue.GetBuffer());
							strXmlValue.ReleaseBuffer();
						}
						else
							Info.m_SDUsedMem= 0;
					}
					else if (strXmlName == _T("phoneall"))
					{
						Xml.FindChildElem(_T("value"));							
						strXmlValue = Xml.GetChildData().c_str();
						if (!strXmlValue.IsEmpty())
						{							
							Info.m_PhoneTotalMem = _wtoi(strXmlValue.GetBuffer());
							strXmlValue.ReleaseBuffer();
						}
						else
						{
							Info.m_PhoneTotalMem = 0;
						}
					}
					else if (strXmlName == _T("phoneuse"))
					{
						Xml.FindChildElem(_T("value"));							
						strXmlValue = Xml.GetChildData().c_str();

						if (!strXmlValue.IsEmpty())
						{							
							Info.m_PhoneUsedMem = _wtoi(strXmlValue.GetBuffer());
							strXmlValue.ReleaseBuffer();
						}
						else
						{
							Info.m_PhoneUsedMem = 0;
						}
					}/////////////////////////////////////////////
					else if (strXmlName == _T("sdcardimage"))
					{
						Xml.FindChildElem(_T("value"));							
						strXmlValue = Xml.GetChildData().c_str();

						if (!strXmlValue.IsEmpty())
						{							
							Info.m_PicMemInSD = _wtoi(strXmlValue.GetBuffer());
							strXmlValue.ReleaseBuffer();
						}
						else
						{
							Info.m_PicMemInSD = 0;
						}
					}else if (strXmlName == _T("sdcardmusic"))
					{
						Xml.FindChildElem(_T("value"));							
						strXmlValue = Xml.GetChildData().c_str();

						if (!strXmlValue.IsEmpty())
						{							
							Info.m_MusicMemInSD = _wtoi(strXmlValue.GetBuffer());
							strXmlValue.ReleaseBuffer();
						}
						else
						{
							Info.m_MusicMemInSD = 0;
						}
					}else if (strXmlName == _T("sdcardvideo"))
					{
						Xml.FindChildElem(_T("value"));							
						strXmlValue = Xml.GetChildData().c_str();

						if (!strXmlValue.IsEmpty())
						{							
							Info.m_VideoMemInSD = _wtoi(strXmlValue.GetBuffer());
							strXmlValue.ReleaseBuffer();
						}
						else
						{
							Info.m_VideoMemInSD = 0;
						}
					}else{;}

					Xml.OutOfElem();
				}
			}
		}
	}

	Info.m_PhoneFreeMem = Info.m_PhoneTotalMem - Info.m_PhoneUsedMem;
	Info.m_SDFreeMem    = Info.m_SDTotalMem - Info.m_SDUsedMem;
	return Ret;
}
コード例 #20
0
// 保存配置信息
BOOL COBDPNDConfigReadWrite::fSaveAppConfig(void)
{
	CMarkup xml;

	CString strAppConfigFile = fCommGetAppPath() + _T("\\Config.xml");
	if (!xml.Load(strAppConfigFile))
	{		
		return CONFIG_ERR_LOAD_FILE; 
	}
	CString strText;

	xml.ResetMainPos();
	xml.FindElem();	
	if(xml.FindChildElem(_T("System")))
	{		
		xml.IntoElem();	
		if(xml.FindChildElem(_T("COM_OBD")))
		{
			strText.Format(_T("%d"),m_tagAppConfig.tagComOBD.wPort);
			xml.SetChildAttrib(_T("Port"),strText);
			//strText.Format(_T("%d"),m_tagAppConfig.tagComOBD.dwBPS);
			//xml.SetChildAttrib(_T("BPS"),strText);
			//strText.Format(_T("%d"),m_tagAppConfig.tagComOBD.wData_Bits);
			//xml.SetChildAttrib(_T("Data_Bits"),strText);
			//strText.Format(_T("%d"),m_tagAppConfig.tagComOBD.wStop_Bits);
			//xml.SetChildAttrib(_T("Stop_Bits"),strText);
			//xml.SetChildAttrib(_T("Parity"),_T("None"));
		}

		//if(xml.FindChildElem(_T("COM_GPS")))
		//{
		//	strText.Format(_T("%d"),m_tagAppConfig.tagComGPS.wPort);
		//	xml.SetChildAttrib(_T("Port"),strText);
		//	strText.Format(_T("%d"),m_tagAppConfig.tagComGPS.dwBPS);
		//	xml.SetChildAttrib(_T("BPS"),strText);
		//	strText.Format(_T("%d"),m_tagAppConfig.tagComGPS.wData_Bits);
		//	xml.SetChildAttrib(_T("Data_Bits"),strText);
		//	strText.Format(_T("%d"),m_tagAppConfig.tagComGPS.wStop_Bits);
		//	xml.SetChildAttrib(_T("Stop_Bits"),strText);
		//	xml.SetChildAttrib(_T("Parity"),_T("None"));
		//}

		if(xml.FindChildElem(_T("Setting")))
		{

			xml.SetChildAttrib(_T("LANGUAGE"),m_tagAppConfig.tagSetting.strLanguage);

			if (m_tagAppConfig.tagSetting.bSaveErrorLog)
				xml.SetChildAttrib(_T("Save_ErrorLog"),_T("ON"));
			else
				xml.SetChildAttrib(_T("Save_ErrorLog"),_T("OFF"));

			strText.Format(_T("%d"),m_tagAppConfig.tagSetting.wBacklightDay);
			xml.SetChildAttrib(_T("BACKLIGHT_DAY"),strText);
			strText.Format(_T("%d"),m_tagAppConfig.tagSetting.wBacklightNight);
			xml.SetChildAttrib(_T("BACKLIGHT_NIGHT"),strText);
			strText.Format(_T("%d"),m_tagAppConfig.tagSetting.wBacklightDayStart);
			xml.SetChildAttrib(_T("BACKLIGHT_DAY_START"),strText);
			strText.Format(_T("%d"),m_tagAppConfig.tagSetting.wBackLightDayEnd);
			xml.SetChildAttrib(_T("BACKLIGHT_DAY_END"),strText);

			strText.Format(_T("%d"),m_tagAppConfig.tagSetting.dwSystemOffTime);
			xml.SetChildAttrib(_T("System_Off_Time"),strText);

			strText.Format(_T("%d"),m_tagAppConfig.tagSetting.dwSystemOffMode);
			xml.SetChildAttrib(_T("System_Off_Mode"),strText);


			strText.Format(_T("%d"),m_tagAppConfig.tagSetting.dwAutoSelPanelTime);
			xml.SetChildAttrib(_T("Auto_Sel_Panel_Time"),strText);

			strText.Format(_T("%d"),m_tagAppConfig.tagSetting.dwDefaultStartPanel);
			xml.SetChildAttrib(_T("Default_Start_Panel"),strText);

			strText.Format(_T("%0.5f"),m_tagAppConfig.tagSetting.fInstantFuelParameter);
			xml.SetChildAttrib(_T("Parameter_Fuel_Instant"),strText);

			strText.Format(_T("%0.5f"),m_tagAppConfig.tagSetting.fAvgFuelParameter);
			xml.SetChildAttrib(_T("Parameter_Fuel_Avg"),strText);

			strText.Format(_T("%0.5f"),m_tagAppConfig.tagSetting.fFuelPrice);
			xml.SetChildAttrib(_T("Fuel_Price"),strText);

			strText.Format(_T("0x%08X"),m_tagAppConfig.tagSetting.dwActiveEcuID);
			xml.SetChildAttrib(_T("Active_ECU_ID"),strText);
		}	
		if(xml.FindChildElem(_T("Set_Alarm")))
		{
			if (m_tagAppConfig.tagAlarmSet.bTroubleCode)
				xml.SetChildAttrib(_T("TroubleCode"),_T("ON"));
			else
				xml.SetChildAttrib(_T("TroubleCode"),_T("OFF"));

			strText.Format(_T("%d"),m_tagAppConfig.tagAlarmSet.wSpeed);
			xml.SetChildAttrib(_T("Speed"),strText);

			strText.Format(_T("%d"),m_tagAppConfig.tagAlarmSet.wCoolant);
			xml.SetChildAttrib(_T("Coolant"),strText);

			strText.Format(_T("%d"),m_tagAppConfig.tagAlarmSet.wFatigue_Driving);
			xml.SetChildAttrib(_T("Fatigue_Driving"),strText);

			strText.Format(_T("%0.2f"),m_tagAppConfig.tagAlarmSet.dbFuel);
			xml.SetChildAttrib(_T("Fuel"),strText);

			xml.IntoElem();
			if(xml.FindChildElem(_T("Shift")))
			{
				strText.Format(_T("%d"),m_tagAppConfig.tagAlarmSet.wShiftRpm);
				xml.SetChildAttrib(_T("Shift_Rpm"),strText);

				strText.Format(_T("%d"),m_tagAppConfig.tagAlarmSet.wShiftSpeed);
				xml.SetChildAttrib(_T("Shift_Speed"),strText);
			}
			if(xml.FindChildElem(_T("Volt")))
			{
				strText.Format(_T("%d"),m_tagAppConfig.tagAlarmSet.wVoltMin);
				xml.SetChildAttrib(_T("Volt_Min"),strText);

				strText.Format(_T("%d"),m_tagAppConfig.tagAlarmSet.wVoltMax);
				xml.SetChildAttrib(_T("Volt_Max"),strText);
			}
			xml.OutOfElem();
		}
		xml.OutOfElem();
	}

	if(xml.FindChildElem(_T("Mini_Dlg")))
	{
		strText.Format(_T("%d"),m_tagAppConfig.tagMiniSpeed.dw480X272_X);
		xml.SetChildAttrib(_T("X_480X272"),strText);
		strText.Format(_T("%d"),m_tagAppConfig.tagMiniSpeed.dw480X272_Y);
		xml.SetChildAttrib(_T("Y_480X272"),strText);
		strText.Format(_T("%d"),m_tagAppConfig.tagMiniSpeed.dw800X480_X);
		xml.SetChildAttrib(_T("X_800X480"),strText);
		strText.Format(_T("%d"),m_tagAppConfig.tagMiniSpeed.dw800X480_Y);
		xml.SetChildAttrib(_T("Y_800X480"),strText);
	}	

	if(xml.FindChildElem(_T("UiData")))
	{
		xml.IntoElem();

		if(xml.FindChildElem(_T("Idle")))
		{	
			strText.Format(_T("0x%08X"),m_tagAppConfig.tagUiDataIdle.dwLeftUpID);
			xml.SetChildAttrib(_T("ID_Left_Up"),strText);

			strText.Format(_T("0x%08X"),m_tagAppConfig.tagUiDataIdle.dwLeftMiddleID);
			xml.SetChildAttrib(_T("ID_Left_Middle"),strText);

			strText.Format(_T("0x%08X"),m_tagAppConfig.tagUiDataIdle.dwLeftDownID);
			xml.SetChildAttrib(_T("ID_Left_Down"),strText);

			strText.Format(_T("0x%08X"),m_tagAppConfig.tagUiDataIdle.dwRightUpID);
			xml.SetChildAttrib(_T("ID_Right_Up"),strText);

			strText.Format(_T("0x%08X"),m_tagAppConfig.tagUiDataIdle.dwRightMiddleID);
			xml.SetChildAttrib(_T("ID_Right_Middle"),strText);

			strText.Format(_T("0x%08X"),m_tagAppConfig.tagUiDataIdle.dwRightDownID);
			xml.SetChildAttrib(_T("ID_Right_Down"),strText);
		}
		if(xml.FindChildElem(_T("Tour")))
		{		
			strText.Format(_T("0x%08X"),m_tagAppConfig.tagUiDataTour.dwLeftUpID);
			xml.SetChildAttrib(_T("ID_Left_Up"),strText);

			strText.Format(_T("0x%08X"),m_tagAppConfig.tagUiDataTour.dwLeftMiddleID);
			xml.SetChildAttrib(_T("ID_Left_Middle"),strText);

			strText.Format(_T("0x%08X"),m_tagAppConfig.tagUiDataTour.dwLeftDownID);
			xml.SetChildAttrib(_T("ID_Left_Down"),strText);

			strText.Format(_T("0x%08X"),m_tagAppConfig.tagUiDataTour.dwRightUpID);
			xml.SetChildAttrib(_T("ID_Right_Up"),strText);

			strText.Format(_T("0x%08X"),m_tagAppConfig.tagUiDataTour.dwRightMiddleID);
			xml.SetChildAttrib(_T("ID_Right_Middle"),strText);

			strText.Format(_T("0x%08X"),m_tagAppConfig.tagUiDataTour.dwRightDownID);
			xml.SetChildAttrib(_T("ID_Right_Down"),strText);
		}

		if(xml.FindChildElem(_T("Race")))
		{		
			strText.Format(_T("0x%08X"),m_tagAppConfig.tagUiDataRace.dwLeftUpID);
			xml.SetChildAttrib(_T("ID_Left_Up"),strText);

			strText.Format(_T("0x%08X"),m_tagAppConfig.tagUiDataRace.dwLeftDownID);
			xml.SetChildAttrib(_T("ID_Left_Down"),strText);

			strText.Format(_T("0x%08X"),m_tagAppConfig.tagUiDataRace.dwMiddleUpID);
			xml.SetChildAttrib(_T("ID_Middle_Up"),strText);

			strText.Format(_T("0x%08X"),m_tagAppConfig.tagUiDataRace.dwMiddleMiddleID);
			xml.SetChildAttrib(_T("ID_Middle_Middle"),strText);

			strText.Format(_T("0x%08X"),m_tagAppConfig.tagUiDataRace.dwMiddleDownID);
			xml.SetChildAttrib(_T("ID_Middle_Down"),strText);

			strText.Format(_T("0x%08X"),m_tagAppConfig.tagUiDataRace.dwRightUpID);
			xml.SetChildAttrib(_T("ID_Right_Up"),strText);

			strText.Format(_T("0x%08X"),m_tagAppConfig.tagUiDataRace.dwRightDownID);
			xml.SetChildAttrib(_T("ID_Right_Down"),strText);
		}
		xml.OutOfElem();
	}

	if(xml.FindChildElem(_T("APP_START_LIST")))
	{
		xml.IntoElem();

		while(xml.FindChildElem(_T("APP"))) 
		{	
			for (int i=0;i<m_vecAppList.size();i++)
			{
				if (xml.GetChildAttrib(_T("ID")) == m_vecAppList[i].strAppID)
				{
					xml.SetChildAttrib(_T("PATH"),m_vecAppList[i].strAppPath);
					if (m_vecAppList[i].bAutoRun)
						xml.SetChildAttrib(_T("AUTO_RUN"),_T("1"));
					else
						xml.SetChildAttrib(_T("AUTO_RUN"),_T("0"));
				}
			}
		}
		xml.OutOfElem();
	}	



	xml.Save(strAppConfigFile);

	return TRUE;
}
コード例 #21
0
ファイル: makeframe.cpp プロジェクト: zhangxj/esbi
int CMakeFrame::InitUserInfo(const char *info)
{
	CMarkup xmlConfig;
	xmlConfig.SetDoc(info);
	xmlConfig.ResetPos();
	xmlConfig.FindChildElem( "all" );
	xmlConfig.IntoElem();
	xmlConfig.FindElem( "head");
	xmlConfig.IntoElem();

	xmlConfig.FindElem( "afn" );
	afn = atoi(xmlConfig.GetData().c_str()) % 256;

	if(afn == 0x04 || afn == 0x0c || 1)
	{
		xmlConfig.ResetPos();
		xmlConfig.FindChildElem( "all" );
		xmlConfig.IntoElem();
		xmlConfig.FindElem( "body" );
		xmlConfig.IntoElem();
		xmlConfig.FindElem( "index" );
		index = atoi(xmlConfig.GetData().c_str());

		xmlConfig.FindElem("fn");
		xmlConfig.IntoElem();
		FnTotalNum = 0;
		while(xmlConfig.FindElem()){
			FnTotalNum ++;
		}
		xmlConfig.ResetPos();
		xmlConfig.FindChildElem( "all" );
		xmlConfig.IntoElem();
		xmlConfig.FindElem( "body" );
		xmlConfig.IntoElem();
		xmlConfig.FindElem("fn");
		xmlConfig.IntoElem();
		int j;
		for(j=0;j<FnTotalNum;j++)
		{
			xmlConfig.FindElem( "value" );
			fnValue[j]= xmlConfig.GetData();
		}

		xmlConfig.ResetPos();
		xmlConfig.FindChildElem( "all" );
		xmlConfig.IntoElem();
		xmlConfig.FindElem( "body" );
		xmlConfig.IntoElem();
		xmlConfig.FindElem("pn");
		xmlConfig.IntoElem();
		PnTotalNum = 0;
		while(xmlConfig.FindElem()){
			PnTotalNum ++;
		}

		xmlConfig.ResetPos();
		xmlConfig.FindChildElem( "all" );
		xmlConfig.IntoElem();
		xmlConfig.FindElem( "body" );
		xmlConfig.IntoElem();
		xmlConfig.FindElem("pn");
		xmlConfig.IntoElem();

		for(j=0;j<PnTotalNum;j++)
		{
			xmlConfig.FindElem( "value" );
			pnValue[j]= xmlConfig.GetData();
		}
	}
	return 1;
}
コード例 #22
0
DEV_INFO CDeviceEditDlg::ReadXML()
{
	CMarkup xml;
	DEV_INFO devInfo;
	
	devInfo.nPort=0;
	devInfo.lLoginID=0;
	devInfo.lID=0;
	
	if(xml.Load(GET_MODULE_FILE_INFO.strPath + "UserInfo.xml"))
	{
		while(xml.FindChildElem("ip"))
		{
			//read the information from XML
			CString strIP="",strUserName="",strPsw="",strDevName="";
			UINT nPort;
			long byChanNum=0,lID=0;

			UINT bSerialID,nSerPort;
			CString szSerIP="",szSerialInfo="";			
			xml.IntoElem();		

			xml.FindChildElem("ip2");
			strIP=xml.GetChildData();
			xml.FindChildElem("DEVICENAME");
			strDevName=xml.GetChildData();
			xml.FindChildElem("username");
			strUserName=xml.GetChildData();
			xml.FindChildElem("port");
			nPort=atoi(xml.GetChildData());
			xml.FindChildElem("pwd");
			strPsw=xml.GetChildData();
			xml.FindChildElem("byChanNum");
			byChanNum=atoi(xml.GetChildData());
			xml.FindChildElem("lID");
			lID=atoi(xml.GetChildData());

			xml.FindChildElem("bSerialID");
			bSerialID=atoi(xml.GetChildData());
			xml.FindChildElem("szSerIP");
			szSerIP=xml.GetChildData();
			xml.FindChildElem("nSerPort");
			nSerPort=atoi(xml.GetChildData());
			xml.FindChildElem("szSerialInfo");
			szSerialInfo=xml.GetChildData();//新增ddns记录
			xml.OutOfElem();
			devInfo.nTotalChannel =byChanNum;
			devInfo.nPort = nPort;

			devInfo.bSerialID=bSerialID;		
			devInfo.nSerPort=nSerPort;
			strcpy(devInfo.szSerIP,szSerIP.GetBuffer(0));		
			strcpy(devInfo.szSerialInfo, szSerialInfo.GetBuffer(0));//新增ddns记录		
			strcpy(devInfo.szDevName, strDevName);
			strcpy(devInfo.szUserName, strUserName);
			strcpy(devInfo.szPsw, strPsw);
			strcpy(devInfo.szIpaddress, strIP);
			DEV_INFO *pDev = new DEV_INFO;
			memset( pDev, 0, sizeof(DEV_INFO) );
			memcpy( pDev, &devInfo, sizeof(DEV_INFO) );
			pDev->lID = (long)pDev;
			m_devMap[pDev->lID] = pDev;
			HTREEITEM hAddItem = m_deviceTree.InsertItem(strDevName);
			m_deviceTree.SetItemData(hAddItem, (DWORD)pDev);
			CString strName("");
			for ( int i = 0; i < byChanNum; i ++)
			{
				strName.Format("CAM %d", i+1);
				HTREEITEM item = m_deviceTree.InsertItem(strName, 0, 0, hAddItem);
				m_deviceTree.SetItemData(item, i);
			}
		}
	}
	return devInfo;
}
コード例 #23
0
CXMLArchiveNode* CXMLArchive::GetNode(LPCTSTR nodeNameStr)
{
	CString nodeName(nodeNameStr);

	try
	{
#ifdef USE_MSXML
		BSTR nodeNameBSTR = nodeName.AllocSysString();
		MSXML::IXMLDOMNodePtr fatherNodePtr;
#else
		CMarkup* fatherNodePtr;
#endif

		if (m_nodeList.size() == 0)
		{
			fatherNodePtr = m_xmlDocPtr;
		}
		else
		{
			fatherNodePtr = m_nodeList.top()->m_nodePtr;
		}

		if (fatherNodePtr == NULL)
		{
			return NULL;
		}


		if (IsStoring())
		{
#ifdef USE_MSXML
			// Archive is storing
			CXMLArchiveNode* xmlArchiveNodePtr = new CXMLArchiveNode(this, m_xmlDocPtr->createElement(nodeNameBSTR), fatherNodePtr);

			::SysFreeString(nodeNameBSTR);

			m_nodeList.push(xmlArchiveNodePtr);

			return xmlArchiveNodePtr;
#endif
			// Archive is storing
			m_xmlDocPtr->AddChildElem(nodeName);
			CMarkup* childnodep = new CMarkup(m_xmlDocPtr->GetDoc());
			childnodep = m_xmlDocPtr;
			m_xmlDocPtr->ResetChildPos();
			CXMLArchiveNode* xmlArchiveNodePtr = new CXMLArchiveNode(this, 
				childnodep,
				//m_xmlDocPtr->createElement(nodeNameBSTR),
				fatherNodePtr);

			m_nodeList.push(xmlArchiveNodePtr);

			return xmlArchiveNodePtr;
		}


		// Archive is Loading
		//MSXML::IXMLDOMNodeListPtr	nodeListPtr;
		//MSXML::IXMLDOMNodePtr		nodePtr;
		CMarkup*	nodeListPtr;
		CMarkup*		nodePtr;

		// If child node list is not empty, we are loading using the tags to
		// create CObject derived objects or collections (like CArray<Cobject* CObject*>, use child list

#ifdef USE_MSXML
		if (m_nodeList.size() > 0)
		{
			CXMLArchiveNode* xmlNodePtr = m_nodeList.top();
			nodeListPtr = xmlNodePtr->m_childNodeListPtr;

			if (nodeListPtr != NULL && nodeListPtr->length > 0)
			{
				int childIndex = xmlNodePtr->m_childIndex;

				if (childIndex < nodeListPtr->length)
				{
					nodeListPtr->get_item(childIndex, &nodePtr);

					CXMLArchiveNode* xmlArchiveNodePtr = new CXMLArchiveNode(this, nodePtr, m_xmlDocPtr);

					m_nodeList.push(xmlArchiveNodePtr);

					::SysFreeString(nodeNameBSTR);

					return xmlArchiveNodePtr;
				}

				ASSERT(FALSE);
			}
		}
#else
		if (m_nodeList.size() > 0)
		{
			CXMLArchiveNode* xmlNodePtr = m_nodeList.top();
			nodeListPtr = xmlNodePtr->m_childNodeListPtr;

			//Block added to calcule length when using CMarkup
			int length = 0;
			if (nodeListPtr != NULL){
				nodeListPtr->ResetMainPos();
				while (nodeListPtr->FindElem())
				{
					length++;
				}
				nodeListPtr->ResetMainPos();
			}

			if (nodeListPtr != NULL && length > 0)
			{
				int childIndex = xmlNodePtr->m_childIndex;

				if (childIndex < length)
				{
					int index = 0;

					/*if (nodeListPtr->FindChildElem())
					{*/
						while (nodeListPtr->FindElem() && index < childIndex)
						{
							index++;
						}

						nodePtr = new CMarkup();
						nodePtr = nodeListPtr;
						//nodeListPtr->ResetChildPos();
					/*}*/

					CXMLArchiveNode* xmlArchiveNodePtr = new CXMLArchiveNode(this, nodePtr, m_xmlDocPtr);

					m_nodeList.push(xmlArchiveNodePtr);

					return xmlArchiveNodePtr;
				}

				ASSERT(FALSE);
			}
		}
#endif

#ifdef USE_MSXML
		// Get all nodes with this name
		if (MSXML::IXMLDOMDocumentPtr(fatherNodePtr) != NULL)
		{
			// First level node in document
			ASSERT(!nodeName.IsEmpty());
			nodeListPtr = MSXML::IXMLDOMDocumentPtr(fatherNodePtr)->getElementsByTagName(nodeNameBSTR);
		}
		else
		{
			// Get node with desired name
			nodeListPtr = MSXML::IXMLDOMElementPtr(fatherNodePtr)->getElementsByTagName(nodeNameBSTR);
		}

		::SysFreeString(nodeNameBSTR);
#else
		bool bResult=fatherNodePtr->FindElem(nodeName);
		nodeListPtr = new CMarkup();
		nodeListPtr = fatherNodePtr;
#endif
		//Get child index from m_nodeList
		int childIndex = 0;
		if (m_nodeList.size() > 0)
		{
			childIndex = m_nodeList.top()->m_childIndex;
		}

#ifdef USE_MSXML
		if (childIndex < nodeListPtr->length)
		{
			nodeListPtr->get_item(childIndex, &nodePtr);
		}
#else
		//Block added to calcule length when using CMarkup
		int length = 0;
		nodeListPtr->ResetMainPos();
		while (nodeListPtr->FindElem())
		{
			length++;
		}
		nodeListPtr->ResetMainPos();

		if (childIndex < length)
		{
			int index = 0;

			//Check if it has child elements and go inside if so
			if (nodeName.MakeLower()=="svg" && nodeListPtr->FindChildElem())
			{
				while (index < childIndex && nodeListPtr->FindElem())
				{
					index++;
				}

				nodeListPtr->IntoElem();

				nodePtr = new CMarkup();
				nodePtr = nodeListPtr;

				nodeListPtr->ResetMainPos();
			}
			else
			{
				while (index < childIndex && nodeListPtr->FindElem(nodeName))
				{
					index++;
				}

				nodePtr = new CMarkup();
				nodePtr = nodeListPtr;
			}
		}
#endif
		CXMLArchiveNode* xmlArchiveNodePtr = new CXMLArchiveNode(this, nodePtr, m_xmlDocPtr);

		m_nodeList.push(xmlArchiveNodePtr);

		return xmlArchiveNodePtr;
	}

	catch (...)
	{

	}

	return NULL;
}