TileMap::TileMap(string sourceFile, ImageManager &ImageManager_)
{
	//Load the XML source file.
	string str = "Data/Arenas/";
	str = str + sourceFile;
	TiXmlDocument ArenaDocument(str.c_str());
	if(!ArenaDocument.LoadFile())
	{
		cerr<<"Error while loading "<<sourceFile<<endl;
		cerr<<ArenaDocument.ErrorDesc()<<endl;
	}
	
	TiXmlHandle ArenaHandle(&ArenaDocument);
	
	//Load the tile set.
	TiXmlNode* TileSetNode = ArenaHandle.FirstChild("Arena").FirstChild("TileSet").ToNode();
	TiXmlElement* TileElement = NULL;
	while(TileSetNode->IterateChildren("Tile", TileElement) != NULL)
	{
		TileElement = TileSetNode->IterateChildren("Tile", TileElement)->ToElement();
		str = "Data/Tiles/";
		str = str + TileElement->Attribute("file");
		TileSet.push_back(Tile(ImageManager_.Get(str)));
		TileSet.back().sourceFile = str;
		if(strcmp(TileElement->Attribute("isBlockingCharacters"),"true") == 0)
		{
			TileSet.back().blocksCharacters = true;
		}
		else
			TileSet.back().blocksCharacters = false;
		if(strcmp(TileElement->Attribute("isBlockingSpells"), "true") == 0)
			TileSet.back().blocksSpells = true;
		else
			TileSet.back().blocksSpells = false;
	}
	
	//Load the tile map.
	TiXmlNode* MapNode = ArenaHandle.FirstChildElement("Arena").FirstChild("Map").ToNode();
	TiXmlElement* Line = NULL;
	string tileLine;
	int temp;
	while(MapNode->IterateChildren("Line", Line) != NULL)
	{
		Line = MapNode->IterateChildren("Line", Line)->ToElement();
		tileLine = Line->Attribute("TileLine");
		Tiles.push_back(vector<int>(tileLine.size()));
		for(int i=0; i<tileLine.size(); i++)
		{
			temp = tileLine.c_str()[i] - '0';
			Tiles.back()[i] = temp;
		}
	}
}
OsStatus PresenceRoutingUserPreferences::parseDocument( TiXmlDocument* pDoc )
{
   TiXmlNode* presenceRoutingNode;
   
   if( (presenceRoutingNode = pDoc->FirstChild("presenceRoutingPrefs")) != NULL &&
         presenceRoutingNode->Type() == TiXmlNode::ELEMENT)
   {
      // Find all the <user> elements.
      for( TiXmlNode* userNode = 0;
      (userNode = presenceRoutingNode->IterateChildren( "user", userNode )); ) 
      {
         if (userNode->Type() == TiXmlNode::ELEMENT)
         {
            TiXmlNode* pChildNode;
            if( ( pChildNode = userNode->FirstChild( "userName" ) ) && pChildNode->FirstChild() )
            {
               UtlString* pUsername = new UtlString( pChildNode->FirstChild()->Value() );
               if( ( pChildNode = userNode->FirstChild( "vmOnDnd" ) ) && pChildNode->FirstChild() )
               {
                  UtlString vmOnDndAsString = pChildNode->FirstChild()->Value();
                  UtlBool* pbVmOnDnd = new UtlBool( FALSE );
                  if( vmOnDndAsString.compareTo("true", UtlString::ignoreCase) == 0 )
                  {
                     pbVmOnDnd->setValue(TRUE);
                  }
                  mUserVmOnDndPreferences.insertKeyAndValue( pUsername, pbVmOnDnd );
                  OsSysLog::add( FAC_NAT, PRI_DEBUG, "PresenceRoutingUserPreferences::parseDocument added %s %d"
                                ,pUsername->data(), pbVmOnDnd->getValue());
               }
            }
         }
      }
   }
}
Example #3
0
int CLayer::parseLayerData(TiXmlNode *xmlnLayer)
{
	TiXmlNode *xmlnData = xmlnLayer->FirstChild("data");
	TiXmlNode *xmlnTile = xmlnData->FirstChild("tile");
	TiXmlElement *xmleTile = NULL;
	CTile *tlTile = NULL;
	TileCoord tc;
	int nTileGId;

	tc.x = 0;
	tc.y = 0;

	while (xmlnTile) {
		xmleTile = xmlnTile->ToElement();
		nTileGId = atoi(xmleTile->Attribute("gid"));

		// If no valid GId is assigned, skip insertion
		if (nTileGId != 0) {
			m_mapTiles->insert(TileGrid::value_type(tc, CFactory::createTile(nTileGId)));
		}

		xmlnTile = xmlnData->IterateChildren("tile", xmlnTile);

		if (tc.x == m_nWidth - 1) {
			tc.y += 1;
			tc.x = 0;
		} else {
			tc.x += 1;
		}
	}

	return 0;
}
Example #4
0
MSBInfoPage* MSBInfo::Parse(TiXmlNode* page)
{
	if (page)
	{
		_page = new MSBInfoPage();

		TiXmlNode* child = 0;
		TiXmlNode* root = page;
		TiXmlElement* pageElement = page->ToElement();
		
		if (pageElement)
		{
			_page->EID = pageElement->Attribute("eid");
			_page->Category = pageElement->Attribute("category");
			_page->Type = pageElement->Attribute("type");
			_page->NodeName = pageElement->Attribute("nodeName");

			TiXmlNode* title = page->FirstChild("title");
			if (title)
				_page->Title = title->ToElement()->GetText();
			else
				Core::Dbg->Log(Warning, "No title node found");
		}
		else
			Core::Dbg->Log(Warning, "Page node not accessible");
		pageElement = 0;

		// Navigate to the 'background' part while adding skills
		while((child = root->IterateChildren(child)))
		{
			if (child->ValueStr().compare("skill") == 0)
			{
				TiXmlElement* skillelement = child->ToElement();
				if (skillelement)
				{
					Skill* sk = new Skill();
					sk->ID = skillelement->Attribute("kid");
					sk->Name = skillelement->GetText();
					_page->Skills.push_back(sk);
				}
				else
					Core::Dbg->Log(Warning, "Conversion error in Skill node");
			}
			if (child->ValueStr().compare("backgroundInfo") == 0)
			{
				// Handle background node
				XMLProcessBackground(child);
			}
		}
	
	}
	else
		Core::Dbg->Log(Warning, "XML parse error, no page element found");

	return _page;
}
Example #5
0
//---------------------------------------------------------------------------//
// LoadMaterialNeon
//
//---------------------------------------------------------------------------//
bool CMaterial::LoadMaterialNeon(const string &sFile)
{
  bool bRes = false;
  // XML Document
  TiXmlDocument XMLDoc(sFile.c_str());
  if (XMLDoc.LoadFile() && XMLDoc.FirstChild("material"))
  {
    // Material completo
    bRes        = true;
    m_bMaterial = true;

    TiXmlNode *pNode = XMLDoc.FirstChild("material");

    // NumTexturas
    if (GetNumSameChilds(pNode, "texture") > MAX_TEXTURES)
      GLOG(("WAR: Material %s specified more than %d textures\n", sFile.c_str(), MAX_TEXTURES));
    // Texturas
    TiXmlNode *pIter = NULL;
    int i = 0;
    do
    {
      pIter = pNode->IterateChildren("texture", pIter);
      if (pIter)
      {
        const char *pValue = pIter->ToElement()->Attribute("file");
        if (pValue && pValue[0])
        {
          // Añadir al gestor materiales
          m_pTexturas[i] = g_pGestorMateriales->AddTextura(pValue, 0);
          if (m_pTexturas[i] < 0)
            GLOG(("ERR: Can't load texture %s on Material %s\n", pValue, sFile.c_str()));
        }
        else
          GLOG(("ERR: Texture file not specified on Material %s\n", sFile.c_str()));
        m_iNumTexturas++;
      }
      i++;
    } while (pIter && i < MAX_TEXTURES);

    // Shader
    pIter = pNode->FirstChild("shader");
    if (pIter)
    {
      const char *pValue = pIter->ToElement()->Attribute("file");
      if (pValue && pValue[0])
      {
        m_iShader = g_pGestorMateriales->AddShader(pValue);
        if (m_iShader  < 0)
          GLOG(("ERR: Can't load Shader %s on Material %s\n", pValue, sFile.c_str()));
      }
      else
        GLOG(("ERR: Shader file not specified on Material %s\n", sFile.c_str()));
    }
  }
  return bRes;
}
Example #6
0
void XMLConfiguration::set_value(const string& section, const string& object, const string& value)
{
	bool section_found = false;
	bool object_found = false;
	
	TiXmlNode* child = 0;
	
	TiXmlNode* nephew = 0;
	
	if(m_document->NoChildren()==false)
	{
		
		while((!section_found) && ( child = m_document->IterateChildren( child ) ))
		{
			if(string(child->Value())==section)
			{
				section_found = true;
			}
		}
	}
		
	if(section_found == false)
	{
		LOG_INFO("XMLConfiguration: no section "<<section<<" found, creating.");
		child = new TiXmlElement( section.c_str() );
		m_document->LinkEndChild( child );
	}
	
	if(child->NoChildren()==false)
	{
		
		while((!object_found) &&( nephew = child->IterateChildren( nephew ) ))
		{
			if(string(nephew->Value())==object)
			{
				object_found = true;
			}
		}
	}
	
	if(object_found == false)
	{
		LOG_INFO("XMLConfiguration: no object "<<section<<"/"<<object<<" found, creating.");
		nephew = new TiXmlElement( object.c_str() );
		child->LinkEndChild( nephew );
	}
	
	nephew->Clear();
	
	TiXmlText* text_element = new TiXmlText( value.c_str() );
	nephew->LinkEndChild( text_element );
	
}
Example #7
0
void clsScriptManager::LoadXML() {
	// PPK ... first start all script in order from xml file
#ifdef _WIN32
	TiXmlDocument doc((clsServerManager::sPath+"\\cfg\\Scripts.xml").c_str());
#else
	TiXmlDocument doc((clsServerManager::sPath+"/cfg/Scripts.xml").c_str());
#endif
	if(doc.LoadFile() == false) {
        if(doc.ErrorId() != TiXmlBase::TIXML_ERROR_OPENING_FILE && doc.ErrorId() != TiXmlBase::TIXML_ERROR_DOCUMENT_EMPTY) {
            int iMsgLen = sprintf(clsServerManager::pGlobalBuffer, "Error loading file Scripts.xml. %s (Col: %d, Row: %d)", doc.ErrorDesc(), doc.Column(), doc.Row());
			CheckSprintf(iMsgLen, clsServerManager::szGlobalBufferSize, "clsScriptManager::LoadXML");
#ifdef _BUILD_GUI
			::MessageBox(NULL, clsServerManager::pGlobalBuffer, g_sPtokaXTitle, MB_OK | MB_ICONERROR);
#else
			AppendLog(clsServerManager::pGlobalBuffer);
#endif
            exit(EXIT_FAILURE);
        }
    } else {
		TiXmlHandle cfg(&doc);
		TiXmlNode *scripts = cfg.FirstChild("Scripts").Node();
		if(scripts != NULL) {
			TiXmlNode *child = NULL;
			while((child = scripts->IterateChildren(child)) != NULL) {
				TiXmlNode *script = child->FirstChild("Name");
    
				if(script == NULL || (script = script->FirstChild()) == NULL) {
					continue;
				}
    
				char *name = (char *)script->Value();

				if(FileExist((clsServerManager::sScriptPath+string(name)).c_str()) == false) {
					continue;
				}

				if((script = child->FirstChild("Enabled")) == NULL ||
					(script = script->FirstChild()) == NULL) {
					continue;
				}
    
				bool enabled = atoi(script->Value()) == 0 ? false : true;

				if(FindScript(name) != NULL) {
					continue;
				}

				AddScript(name, enabled, false);
            }
        }
    }
}
wxArrayString ConfigManager::EnumerateSubPaths(const wxString& path)
{
    wxString key(path + _T('/')); // the trailing slash hack is required because AssertPath expects a key name
    TiXmlNode* e = AssertPath(key);
    wxArrayString ret;

    TiXmlElement *curr = nullptr;
    if (e)
    {
        while (e->IterateChildren(curr) && (curr = e->IterateChildren(curr)->ToElement()))
        {
            #if wxCHECK_VERSION(2, 9, 0)
            wxUniChar c = cbC2U(curr->Value())[0];
            #else
            wxChar c = *(cbC2U(curr->Value()));
            #endif
            if (c < _T('A') || c > _T('Z')) // first char must be a letter, uppercase letters are key names
                ret.Add(cbC2U(curr->Value()));
        }
    }
    return ret;
}
wxArrayString ConfigManager::EnumerateKeys(const wxString& path)
{
    wxString key(path + _T('/')); // the trailing slash hack is required because AssertPath expects a key name
    TiXmlNode* e = AssertPath(key);
    wxArrayString ret;

    TiXmlElement *curr = nullptr;
    if (e)
    {
        while (e->IterateChildren(curr) && (curr = e->IterateChildren(curr)->ToElement()))
        {
            #if wxCHECK_VERSION(2, 9, 0)
            wxUniChar c = cbC2U(curr->Value())[0];
            #else
            wxChar c = *(cbC2U(curr->Value()));
            #endif
            if (c >= _T('A') && c <= _T('Z')) // opposite of the above
                ret.Add(cbC2U(curr->Value()));
        }
    }
    return ret;
}
Example #10
0
	bool Overlay::load(std::string name)
	{
		std::string fullpath = Engine::get().getGameDirectory() + "/overlays/" + name;
		TiXmlDocument doc(fullpath.c_str());
		if(!doc.LoadFile())
		{
			std::cerr << "Could not find overlay file " << fullpath << std::endl;
			return false;
		}
		TiXmlNode *xmlroot;
		TiXmlNode *xmlnode;
		TiXmlElement *xmlelement;
		if((xmlroot = doc.FirstChild("overlay")))
		{
			std::cerr << "Could not find <overlay> in " << fullpath << std::endl;
			return false;
		}
		xmlelement = xmlroot->ToElement();
		if(!xmlelement->Attribute("name"))
		{
			std::cerr << "Could not find \"name\" for <overlay> in overlay file " << fullpath << std::endl;
			return false;
		}
		name = xmlelement->Attribute("name");
		
		// Parsing groups
		xmlnode = xmlroot->FirstChild("group");
		while(xmlnode)
		{
			if((xmlelement = xmlnode->ToElement()))
			{
				if(!xmlelement->Attribute("name"))
				{
					std::cerr << "Could not find \"name\" for <group> in overlay file " << fullpath << std::endl;
					return false;
				}
				// Instantiate new group
				groups[xmlelement->Attribute("name")] = new OverlayGroup;
				// Load group from node
				if(!groups[xmlelement->Attribute("name")]->load(xmlnode))
				{
					std::cout << "Error on loading overlay group from " << fullpath << std::endl;
					return false;
				}
			}

			xmlnode = xmlroot->IterateChildren("group", xmlnode);
		}
		
		return true;
	}
Example #11
0
void ConfigManager::Read(const wxString& name, wxArrayString *arrayString)
{
    wxString key(name);
    TiXmlElement* e = AssertPath(key);

    TiXmlHandle parentHandle(e);
    TiXmlNode *asNode = parentHandle.FirstChild(cbU2C(key)).FirstChild("astr").Node();

    TiXmlNode *curr = nullptr;
    if (asNode)
    {
        while ((curr = asNode->IterateChildren("s", curr)))
            arrayString->Add(cbC2U(curr->FirstChild()->ToText()->Value()));
    }
}
Example #12
0
void ConfigManager::Read(const wxString& name, ConfigManagerContainer::StringToStringMap* map)
{
    wxString key(name);
    TiXmlElement* e = AssertPath(key);

    TiXmlHandle parentHandle(e);
    TiXmlNode *mNode = parentHandle.FirstChild(cbU2C(key)).FirstChild("ssmap").Node();

    TiXmlNode *curr = 0;
    if(mNode)
    {
        while((curr = mNode->IterateChildren(curr)))
            (*map)[cbC2U(curr->Value())] = cbC2U(curr->FirstChild()->ToText()->Value());
    }
}
Example #13
0
void ConfigManager::Read(const wxString& name, ConfigManagerContainer::StringSet* set)
{
    wxString key(name);
    TiXmlElement* e = AssertPath(key);

    TiXmlHandle parentHandle(e);
    TiXmlNode *mNode = parentHandle.FirstChild(cbU2C(key)).FirstChild("sset").Node();

    TiXmlNode *curr = nullptr;
    if (mNode)
    {
        while ((curr = mNode->IterateChildren(curr)))
            set->insert(cbC2U(curr->FirstChild()->ToText()->Value()));
    }
}
Example #14
0
void XMLConfiguration::remove_object(const string& section_name, const string& object_name)
{
	bool section_found = false;
	bool object_found = false;
	
	TiXmlNode* child = 0;
	
	TiXmlNode* nephew = 0;
	
	if(m_document->NoChildren()==false)
	{
		
		while((!section_found) && ( child = m_document->IterateChildren( child ) ))
		{
			if(string(child->Value())==section_name)
			{
				section_found = true;
			}
		}
	}
		
	if(section_found == false)
	{
		return;
	}
	
	if(child->NoChildren()==false)
	{
		
		while((!object_found) && ( nephew = child->IterateChildren( nephew ) ))
		{
			if(string(nephew->Value())==object_name)
			{
				object_found = true;
			}
		}
	}
	
	if(object_found == false)
	{
		return;
	}
	
	child->RemoveChild(nephew);
}
Example #15
0
void ConfigManager::Read(const wxString& name, ConfigManagerContainer::IntToStringMap* map)
{
    wxString key(name);
    TiXmlElement* e = AssertPath(key);

    TiXmlHandle parentHandle(e);
    TiXmlNode *mNode = parentHandle.FirstChild(cbU2C(key)).FirstChild("ismap").Node();

    TiXmlNode *curr = nullptr;
    long tmp;
    if (mNode)
    {
        while ((curr = mNode->IterateChildren(curr)))
        {
            cbC2U(curr->Value()).Mid(1).ToLong(&tmp);
            (*map)[tmp] = cbC2U(curr->FirstChild()->ToText()->Value());
        }
    }
}
Example #16
0
bool ContactListXMLSerializer1::unserialize(const std::string & data) {
	TiXmlDocument doc;
	bool result = true;

	doc.Parse(data.c_str());

	TiXmlHandle docHandle(&doc);
	TiXmlNode * contactlist = docHandle.FirstChild("contactlist").Node();

	if (contactlist) {
		//Retrieving Contacts
		TiXmlNode * lastChild = NULL;
		while (result && (lastChild = contactlist->IterateChildren("wgcard", lastChild))) {
			string nodeData;
			nodeData << *lastChild;
			ContactXMLSerializer1 serializer( *(_contactList.createContact()), _contactList, _imAccountList);	//VOXOX - JRT - 2009.04.26 
			result = serializer.unserialize(nodeData);
		}
		////
	}

	return result;
}
Example #17
0
bool PVRDemoData::LoadDemoData(void)
{
  TiXmlDocument xmlDoc;
  string strSettingsFile = GetSettingsFile();

  if (!xmlDoc.LoadFile(strSettingsFile))
  {
    XBMC->Log(LOG_ERROR, "invalid demo data (no/invalid data file found at '%s')", strSettingsFile.c_str());
    return false;
  }

  TiXmlElement *pRootElement = xmlDoc.RootElement();
  if (strcmp(pRootElement->Value(), "demo") != 0)
  {
    XBMC->Log(LOG_ERROR, "invalid demo data (no <demo> tag found)");
    return false;
  }

  /* load channels */
  int iUniqueChannelId = 0;
  TiXmlElement *pElement = pRootElement->FirstChildElement("channels");
  if (pElement)
  {
    TiXmlNode *pChannelNode = NULL;
    while ((pChannelNode = pElement->IterateChildren(pChannelNode)) != NULL)
    {
      CStdString strTmp;
      PVRDemoChannel channel;
      channel.iUniqueId = ++iUniqueChannelId;

      /* channel name */
      if (!XMLUtils::GetString(pChannelNode, "name", strTmp))
        continue;
      channel.strChannelName = strTmp;

      /* radio/TV */
      XMLUtils::GetBoolean(pChannelNode, "radio", channel.bRadio);

      /* channel number */
      if (!XMLUtils::GetInt(pChannelNode, "number", channel.iChannelNumber))
        channel.iChannelNumber = iUniqueChannelId;

      /* sub channel number */
      if (!XMLUtils::GetInt(pChannelNode, "subnumber", channel.iSubChannelNumber))
        channel.iSubChannelNumber = 0;

      /* CAID */
      if (!XMLUtils::GetInt(pChannelNode, "encryption", channel.iEncryptionSystem))
        channel.iEncryptionSystem = 0;

      /* icon path */
      if (!XMLUtils::GetString(pChannelNode, "icon", strTmp))
        channel.strIconPath = m_strDefaultIcon;
      else
        channel.strIconPath = strTmp;

      /* stream url */
      if (!XMLUtils::GetString(pChannelNode, "stream", strTmp))
        channel.strStreamURL = m_strDefaultMovie;
      else
        channel.strStreamURL = strTmp;

      m_channels.push_back(channel);
    }
  }

  /* load channel groups */
  int iUniqueGroupId = 0;
  pElement = pRootElement->FirstChildElement("channelgroups");
  if (pElement)
  {
    TiXmlNode *pGroupNode = NULL;
    while ((pGroupNode = pElement->IterateChildren(pGroupNode)) != NULL)
    {
      CStdString strTmp;
      PVRDemoChannelGroup group;
      group.iGroupId = ++iUniqueGroupId;

      /* group name */
      if (!XMLUtils::GetString(pGroupNode, "name", strTmp))
        continue;
      group.strGroupName = strTmp;

      /* radio/TV */
      XMLUtils::GetBoolean(pGroupNode, "radio", group.bRadio);
      
      /* sort position */
      XMLUtils::GetInt(pGroupNode, "position", group.iPosition);

      /* members */
      TiXmlNode* pMembers = pGroupNode->FirstChild("members");
      TiXmlNode *pMemberNode = NULL;
      while (pMembers != NULL && (pMemberNode = pMembers->IterateChildren(pMemberNode)) != NULL)
      {
        int iChannelId = atoi(pMemberNode->FirstChild()->Value());
        if (iChannelId > -1)
          group.members.push_back(iChannelId);
      }

      m_groups.push_back(group);
    }
  }

  /* load EPG entries */
  pElement = pRootElement->FirstChildElement("epg");
  if (pElement)
  {
    TiXmlNode *pEpgNode = NULL;
    while ((pEpgNode = pElement->IterateChildren(pEpgNode)) != NULL)
    {
      CStdString strTmp;
      int iTmp;
      PVRDemoEpgEntry entry;

      /* broadcast id */
      if (!XMLUtils::GetInt(pEpgNode, "broadcastid", entry.iBroadcastId))
        continue;

      /* channel id */
      if (!XMLUtils::GetInt(pEpgNode, "channelid", iTmp))
        continue;
      PVRDemoChannel &channel = m_channels.at(iTmp - 1);
      entry.iChannelId = channel.iUniqueId;

      /* title */
      if (!XMLUtils::GetString(pEpgNode, "title", strTmp))
        continue;
      entry.strTitle = strTmp;

      /* start */
      if (!XMLUtils::GetInt(pEpgNode, "start", iTmp))
        continue;
      entry.startTime = iTmp;

      /* end */
      if (!XMLUtils::GetInt(pEpgNode, "end", iTmp))
        continue;
      entry.endTime = iTmp;

      /* plot */
      if (XMLUtils::GetString(pEpgNode, "plot", strTmp))
        entry.strPlot = strTmp;

      /* plot outline */
      if (XMLUtils::GetString(pEpgNode, "plotoutline", strTmp))
        entry.strPlotOutline = strTmp;

      /* icon path */
      if (XMLUtils::GetString(pEpgNode, "icon", strTmp))
        entry.strIconPath = strTmp;

      /* genre type */
      XMLUtils::GetInt(pEpgNode, "genretype", entry.iGenreType);

      /* genre subtype */
      XMLUtils::GetInt(pEpgNode, "genresubtype", entry.iGenreSubType);

      if (!XMLUtils::GetInt(pEpgNode, "season", entry.iSeriesNumber))
        entry.iSeriesNumber = -1;

      if (!XMLUtils::GetInt(pEpgNode, "episode", entry.iEpisodeNumber))
       entry.iEpisodeNumber = -1;

      XBMC->Log(LOG_DEBUG, "loaded EPG entry '%s' channel '%d' start '%d' end '%d'", entry.strTitle.c_str(), entry.iChannelId, entry.startTime, entry.endTime);
      channel.epg.push_back(entry);
    }
  }

  /* load recordings */
  iUniqueGroupId = 0; // reset unique ids
  pElement = pRootElement->FirstChildElement("recordings");
  if (pElement)
  {
    TiXmlNode *pRecordingNode = NULL;
    while ((pRecordingNode = pElement->IterateChildren(pRecordingNode)) != NULL)
    {
      CStdString strTmp;
      PVRDemoRecording recording;

      /* recording title */
      if (!XMLUtils::GetString(pRecordingNode, "title", strTmp))
        continue;
      recording.strTitle = strTmp;

      /* episode name (sub-title)*/
      if (XMLUtils::GetString(pRecordingNode, "episodename", strTmp))
        recording.strEpisodeName = strTmp;

      /* recording url */
      if (!XMLUtils::GetString(pRecordingNode, "url", strTmp))
        recording.strStreamURL = m_strDefaultMovie;
      else
        recording.strStreamURL = strTmp;

      /* recording path */
      if (XMLUtils::GetString(pRecordingNode, "directory", strTmp))
        recording.strDirectory = strTmp;

      iUniqueGroupId++;
      strTmp.Format("%d", iUniqueGroupId);
      recording.strRecordingId = strTmp;

      /* channel name */
      if (XMLUtils::GetString(pRecordingNode, "channelname", strTmp))
        recording.strChannelName = strTmp;

      /* plot */
      if (XMLUtils::GetString(pRecordingNode, "plot", strTmp))
        recording.strPlot = strTmp;

      /* plot outline */
      if (XMLUtils::GetString(pRecordingNode, "plotoutline", strTmp))
        recording.strPlotOutline = strTmp;

      /* genre type */
      XMLUtils::GetInt(pRecordingNode, "genretype", recording.iGenreType);

      /* genre subtype */
      XMLUtils::GetInt(pRecordingNode, "genresubtype", recording.iGenreSubType);

      if (!XMLUtils::GetInt(pRecordingNode, "season", recording.iSeriesNumber))
        recording.iSeriesNumber = -1;

      if (!XMLUtils::GetInt(pRecordingNode, "episode", recording.iEpisodeNumber))
        recording.iEpisodeNumber = -1;

      /* duration */
      XMLUtils::GetInt(pRecordingNode, "duration", recording.iDuration);

      /* recording time */
      if (XMLUtils::GetString(pRecordingNode, "time", strTmp))
      {
        time_t timeNow = time(NULL);
        struct tm* now = localtime(&timeNow);

        CStdString::size_type delim = strTmp.Find(':');
        if (delim != CStdString::npos)
        {
          now->tm_hour = (int)strtol(strTmp.Left(delim), NULL, 0);
          now->tm_min  = (int)strtol(strTmp.Mid(delim + 1), NULL, 0);
          now->tm_mday--; // yesterday

          recording.recordingTime = mktime(now);
        }
      }

      m_recordings.push_back(recording);
    }
  }

  /* load deleted recordings */
  pElement = pRootElement->FirstChildElement("recordingsdeleted");
  if (pElement)
  {
    TiXmlNode *pRecordingNode = NULL;
    while ((pRecordingNode = pElement->IterateChildren(pRecordingNode)) != NULL)
    {
      CStdString strTmp;
      PVRDemoRecording recording;

      /* recording title */
      if (!XMLUtils::GetString(pRecordingNode, "title", strTmp))
        continue;
      recording.strTitle = strTmp;

      /* recording url */
      if (!XMLUtils::GetString(pRecordingNode, "url", strTmp))
        recording.strStreamURL = m_strDefaultMovie;
      else
        recording.strStreamURL = strTmp;

      /* recording path */
      if (XMLUtils::GetString(pRecordingNode, "directory", strTmp))
        recording.strDirectory = strTmp;

      iUniqueGroupId++;
      strTmp.Format("%d", iUniqueGroupId);
      recording.strRecordingId = strTmp;

      /* channel name */
      if (XMLUtils::GetString(pRecordingNode, "channelname", strTmp))
        recording.strChannelName = strTmp;

      /* plot */
      if (XMLUtils::GetString(pRecordingNode, "plot", strTmp))
        recording.strPlot = strTmp;

      /* plot outline */
      if (XMLUtils::GetString(pRecordingNode, "plotoutline", strTmp))
        recording.strPlotOutline = strTmp;

      /* genre type */
      XMLUtils::GetInt(pRecordingNode, "genretype", recording.iGenreType);

      /* genre subtype */
      XMLUtils::GetInt(pRecordingNode, "genresubtype", recording.iGenreSubType);

      /* duration */
      XMLUtils::GetInt(pRecordingNode, "duration", recording.iDuration);

      /* recording time */
      if (XMLUtils::GetString(pRecordingNode, "time", strTmp))
      {
        time_t timeNow = time(NULL);
        struct tm* now = localtime(&timeNow);

        CStdString::size_type delim = strTmp.Find(':');
        if (delim != CStdString::npos)
        {
          now->tm_hour = (int)strtol(strTmp.Left(delim), NULL, 0);
          now->tm_min  = (int)strtol(strTmp.Mid(delim + 1), NULL, 0);
          now->tm_mday--; // yesterday

          recording.recordingTime = mktime(now);
        }
      }

      m_recordingsDeleted.push_back(recording);
    }
  }

  /* load timers */
  pElement = pRootElement->FirstChildElement("timers");
  if (pElement)
  {
    TiXmlNode *pTimerNode = NULL;
    while ((pTimerNode = pElement->IterateChildren(pTimerNode)) != NULL)
    {
      CStdString strTmp;
      int iTmp;
      PVRDemoTimer timer;
      time_t timeNow = time(NULL);
      struct tm* now = localtime(&timeNow);

      /* channel id */
      if (!XMLUtils::GetInt(pTimerNode, "channelid", iTmp))
        continue;
      PVRDemoChannel &channel = m_channels.at(iTmp - 1);
      timer.iChannelId = channel.iUniqueId;

      /* state */
      if (XMLUtils::GetInt(pTimerNode, "state", iTmp))
        timer.state = (PVR_TIMER_STATE) iTmp;

      /* title */
      if (!XMLUtils::GetString(pTimerNode, "title", strTmp))
        continue;
      timer.strTitle = strTmp;

      /* summary */
      if (!XMLUtils::GetString(pTimerNode, "summary", strTmp))
        continue;
      timer.strSummary = strTmp;

      /* start time */
      if (XMLUtils::GetString(pTimerNode, "starttime", strTmp))
      {
        CStdString::size_type delim = strTmp.Find(':');
        if (delim != CStdString::npos)
        {
          now->tm_hour = (int)strtol(strTmp.Left(delim), NULL, 0);
          now->tm_min  = (int)strtol(strTmp.Mid(delim + 1), NULL, 0);

          timer.startTime = mktime(now);
        }
      }

      /* end time */
      if (XMLUtils::GetString(pTimerNode, "endtime", strTmp))
      {
        CStdString::size_type delim = strTmp.Find(':');
        if (delim != CStdString::npos)
        {
          now->tm_hour = (int)strtol(strTmp.Left(delim), NULL, 0);
          now->tm_min  = (int)strtol(strTmp.Mid(delim + 1), NULL, 0);

          timer.endTime = mktime(now);
        }
      }

      XBMC->Log(LOG_DEBUG, "loaded timer '%s' channel '%d' start '%d' end '%d'", timer.strTitle.c_str(), timer.iChannelId, timer.startTime, timer.endTime);
      m_timers.push_back(timer);
    }
  }

  return true;
}
Example #18
0
// Process a notify event callback.
void ResourceInstance::notifyEventCallback(const UtlString* dialogHandle,
                                           const UtlString* content)
{
   OsSysLog::add(FAC_RLS, PRI_DEBUG,
                 "ResourceInstance::notifyEventCallback mInstanceName = '%s', content = '%s'",
                 mInstanceName.data(), content->data());
   // Set to true if we find publishable data.
   bool publish = false;

   // Set the subscription state to "active".
   mSubscriptionState = "active";

   // Save the content as text for the RFC 4662 resource list events.
   mContent.remove(0);
   mContent.append(*content);
   mContentPresent = TRUE;

   // Dissect the XML for each dialog event and store it in a map
   // so we can construct BroadWorks-style resource list events
   // (which have to have full state).

   // Initialize Tiny XML document object.
   TiXmlDocument xmlDialogEvent;
   TiXmlNode* dialog_info_node;
   if (
       // Load the XML into it.
       xmlDialogEvent.Parse(mContent.data()) &&
       // Find the top element, which should be a <dialog-info>.
       (dialog_info_node = xmlDialogEvent.FirstChild("dialog-info")) != NULL &&
       dialog_info_node->Type() == TiXmlNode::ELEMENT)
   {
      // Check the state attribute.
      const char* p = dialog_info_node->ToElement()->Attribute("state");
      if (p && strcmp(p, "full") == 0)
      {
         // If the state is "full", terminate all non-terminated dialogs.  (XECS-1668)
         terminateXmlDialogs();
         publish = true;
         OsSysLog::add(FAC_RLS, PRI_DEBUG,
                       "ResourceInstance::notifyEventCallback all non-terminated dialogs");
      }

      // Find all the <dialog> elements.
      for (TiXmlNode* dialog_node = 0;
           (dialog_node = dialog_info_node->IterateChildren("dialog",
                                                            dialog_node));
         )
      {
         if (dialog_node->Type() == TiXmlNode::ELEMENT)
         {
            TiXmlElement* dialog_element = dialog_node->ToElement();

            // Determine if the <dialog> is a bogus report of a NAT Keepalive
            // OPTIONS message, as reported by Polycom SPIP firmware 3.1.2.
            // (XTRN-425)  If so, ignore it.

#ifdef NAT_KEEPALIVE_DETECT
            const char* call_id_attr = dialog_element->Attribute("call-id");
            // Reject <dialog>s on the narrowest grounds, that is, only if the
            // call-id attribute is present and contains NAT_KEEPALIVE_SIGNATURE.
            const bool ok =
               !(call_id_attr &&
                 strstr(call_id_attr,
                        NAT_KEEPALIVE_SIGNATURE) != NULL);
#else
            const bool ok = true;
#endif
            if (ok)
            {
               // Now that we've got a <dialog> element, edit it to fit
               // into a consolidated event notice.
               publish = true;

               // Prepend the resource instance name to the 'id'
               // attribute, so it is unique within the <resource>.
               UtlString id(mInstanceName);
               // mInstanceName is guaranteed to not contain ';', because
               // it is a dialog handle that we generate by concatenating
               // the Call-Id and tags using ',' as a separator.  And ';'
               // may not appear in Call-Ids or tags.
               id.append(";");
               id.append(dialog_element->Attribute("id"));
               dialog_element->SetAttribute("id", id.data());

               // Prepare the display name, so we can insert it easily
               // when we generate consolidated events.
               // Find or add the <local> element.
               TiXmlNode* local = dialog_element->FirstChild("local");
               if (!local)
               {
                  local = dialog_element->LinkEndChild(new TiXmlElement("local"));
               }
               // Find or add the <local><identity> element.
               TiXmlNode* identity = local->FirstChild("identity");
               if (!identity)
               {
                  identity =
                     local->LinkEndChild(new TiXmlElement("identity"));
               }
               // Clear the display attribute.
               identity->ToElement()->SetAttribute("display", "");

               // Put the resource URI as the content of the
               // <local><identity> element.
               // First, remove all text children.
               TiXmlNode* child;
               for (TiXmlNode* prev_child = 0;
                    (child = identity->IterateChildren(prev_child));
                  )
               {
                  if (child->Type() == TiXmlNode::TEXT)
                  {
                     identity->RemoveChild(child);
                     // Leave prev_child unchanged.
                  }
                  else
                  {
                     prev_child = child;
                  }
               }
               // Insert a text child containing the URI.
               identity->LinkEndChild(new TiXmlText(getResourceCached()->
                                                    getUri()->data()));

               // Now that we have the XML all nice and pretty, store a copy of
               // it in mXmlDialogs.
               // Clone the XML and create a UtlVoidPtr to wrap it.
               TiXmlElement* alloc_xml = dialog_element->Clone()->ToElement();

               // Look for an earlier version of this dialog in the hash map.
               UtlVoidPtr* p = dynamic_cast <UtlVoidPtr*> (mXmlDialogs.findValue(&id));
               if (p)
               {
                  // Replace the old XML with new XML.
                  delete static_cast <TiXmlElement*> (p->getValue());
                  p->setValue(alloc_xml);
                  OsSysLog::add(FAC_RLS, PRI_DEBUG,
                                "ResourceInstance::notifyEventCallback replaced dialog with id '%s'",
                                id.data());
               }
               else
               {
                  // Check that we don't have too many dialogs.
                  if (mXmlDialogs.entries() <
                      getResourceListServer()->getMaxDialogsInResInst())
                  {
                     mXmlDialogs.insertKeyAndValue(new UtlString(id),
                                                   new UtlVoidPtr(alloc_xml));
                     OsSysLog::add(FAC_RLS, PRI_DEBUG,
                                   "ResourceInstance::notifyEventCallback added dialog with id '%s'",
                                   id.data());
                  }
                  else
                  {
                     // Free alloc_xml, because we aren't saving a pointer to it.
                     delete alloc_xml;
                     OsSysLog::add(FAC_RLS, PRI_ERR,
                                   "ResourceInstance::notifyEventCallback cannot add dialog with id '%s', already %zu in ResourceInstance '%s'",                                id.data(), mXmlDialogs.entries(),
                                   mInstanceName.data());
                  }
               }
            }
            else
            {
               // The <dialog> was rejected because it appears to report
               // a NAT Maintainer OPTIONS message.
               // We log this at DEBUG level because if these appear,
               // there is likely to be one every 20 seconds.
               OsSysLog::add(FAC_RLS, PRI_DEBUG,
                             "ResourceInstance::notifyEventCallback "
                             "ignored <dialog> reporting a NAT Keepalive message "
                             "in subscription dialog handle '%s' - "
                             "see XTRN-426",
                             mInstanceName.data());
            }
         }
      }
   }
   else
   {
      // Report error parsing XML.
      OsSysLog::add(FAC_RLS, PRI_ERR,
                    "ResourceInstance::notifyEventCallback "
                    "Dialog event from '%s' not parsable.",
                    getResourceCached()->getUri()->data());
      OsSysLog::add(FAC_RLS, PRI_INFO,
                    "ResourceInstance::notifyEventCallback "
                    "Dialog event content is '%s'",
                    content->data());
      // Throw away the content, since we cannot generate matching
      // consolidated content.
      mContentPresent = FALSE;
      mContent.remove(0);
      destroyXmlDialogs();
   }

   // Get the change published, if we found <dialog> that was not incorrect.
   if (publish)
   {
      getResourceCached()->setToBePublished(FALSE, getResourceCached()->getUri());
   }
}
Example #19
0
	void Map::ParseText(const string &text) 
	{
		// Create a tiny xml document and use it to parse the text.
		TiXmlDocument doc;
		doc.Parse(text.c_str());
	
		// Check for parsing errors.
		if (doc.Error()) 
		{
			has_error = true;
			error_code = TMX_PARSING_ERROR;
			error_text = doc.ErrorDesc();
			return;
		}

		TiXmlNode *mapNode = doc.FirstChild("map");
		TiXmlElement* mapElem = mapNode->ToElement();

		// Read the map attributes.
		mapElem->Attribute("version", &version);
		mapElem->Attribute("width", &width);
		mapElem->Attribute("height", &height);
		mapElem->Attribute("tilewidth", &tile_width);
		mapElem->Attribute("tileheight", &tile_height);

		// Read the orientation
		std::string orientationStr = mapElem->Attribute("orientation");

		if (!orientationStr.compare("orthogonal")) 
		{
			orientation = TMX_MO_ORTHOGONAL;
		} 
		else if (!orientationStr.compare("isometric")) 
		{
			orientation = TMX_MO_ISOMETRIC;
		}

		// Read the map properties.
		const TiXmlNode *propertiesNode = mapElem->FirstChild("properties");
		if (propertiesNode) 
		{
			properties.Parse(propertiesNode);
		}

		// Iterate through all of the tileset elements.
		const TiXmlNode *tilesetNode = mapNode->FirstChild("tileset");
		while (tilesetNode) 
		{
			// Allocate a new tileset and parse it.
			Tileset *tileset = new Tileset();
			tileset->Parse(tilesetNode->ToElement());

			// Add the tileset to the list.
			tilesets.push_back(tileset);

			tilesetNode = mapNode->IterateChildren("tileset", tilesetNode);
		}

		// Find all layers and object groups.
		TiXmlNode *layerNode = mapNode->FirstChild();
		while( layerNode != 0 )
		{
			if( std::string("layer") == layerNode->Value() )
			{
				// Allocate a new layer and parse it.
				TileLayer *layer = new TileLayer(this);
				layer->Parse(layerNode);

				// Add the layer to the list.
				layers.push_back(layer);
			}

			if( std::string("objectgroup") == layerNode->Value() )
			{
				// Allocate a new object group and parse it.
				ObjectLayer *objectGroup = new ObjectLayer(this);
				objectGroup->Parse(layerNode);
		
				// Add the object group to the list.
				layers.push_back(objectGroup);
			}

			layerNode = layerNode->NextSibling();
		}
	}
Example #20
0
void SipRedirectorMPT::loadMappings(UtlString* file_name,
                                    UtlHashMap* mapUserToContacts,
                                    UtlHashMap* mapContactsToUser)
{
    // Load the XML file.
    TiXmlDocument *mDoc = new TiXmlDocument(file_name->data());
    if (mDoc->LoadFile())
    {
       // Look at the top element, which should be "MPT".
       TiXmlNode* MPTNode = mDoc->FirstChild("MPT");
       if (MPTNode)
       {
          mMapLock.acquire();

          for (TiXmlNode* mapNode = NULL;
               (mapNode = MPTNode->IterateChildren("map", mapNode));
             )
          {
             // Carefully get the <user> and <content> text.
             TiXmlNode* c1 = mapNode->FirstChild("user");
             if (!c1)
             {
                OsSysLog::add(FAC_SIP, PRI_ERR,
                              "%s::loadMappings cannot find <user> child", mLogName.data());
             }
             else
             {
                TiXmlNode* c2 = c1->FirstChild();
                if (!c2)
                {
                   OsSysLog::add(FAC_SIP, PRI_ERR,
                                 "%s::loadMappings cannot find text child of <user>", mLogName.data());
                }
                else
                {
                   const char* user = c2->Value();
                   if (user == NULL || *user == '\0')
                   {
                      OsSysLog::add(FAC_SIP, PRI_ERR,
                                    "%s::loadMappings text of <user> is null", mLogName.data());
                   }
                   else
                   {
                      TiXmlNode* c3 = mapNode->FirstChild("contacts");
                      if (!c3)
                      {
                         OsSysLog::add(FAC_SIP, PRI_ERR,
                                       "%s::loadMappings cannot find <contacts> child", mLogName.data());
                      }
                      else
                      {
                         TiXmlNode* c4 = c3->FirstChild();
                         if (!c4)
                         {
                            OsSysLog::add(FAC_SIP, PRI_ERR,
                                          "%s::loadMappings cannot find text child of <contacts>", mLogName.data());
                         }
                         else
                         {
                            const char* contact = c4->Value();
                            if (contact == NULL || *contact == '\0')
                            {
                               OsSysLog::add(FAC_SIP, PRI_ERR,
                                             "%s::loadMappings text of <contacts> is null", mLogName.data());
                            }
                            else
                            {
                               // Load the mapping into the maps.
                               OsSysLog::add(FAC_SIP, PRI_DEBUG,
                                             "%s::loadMappings added '%s' -> '%s'", mLogName.data(),
                                             user, contact);
                               UtlString* user_string = new UtlString(user);
                               UtlString* contact_string = new UtlString(contact);
                               mapUserToContacts->insertKeyAndValue(user_string,
                                                                    contact_string);
                               mapContactsToUser->insertKeyAndValue(contact_string,
                                                                    user_string);
                            }
                         }
                      }
                   }
                }
             }
          }

          mMapsModified = FALSE;

          mMapLock.release();

          OsSysLog::add(FAC_SIP, PRI_DEBUG,
                        "%s::loadMappings done loading mappings", mLogName.data());
       }
       else
       {
          OsSysLog::add(FAC_SIP, PRI_CRIT,
                        "%s::loadMappings unable to extract MPT element", mLogName.data());
       }

    }
    else
    {
       OsSysLog::add(FAC_SIP, PRI_CRIT,
                     "%s::loadMappings LoadFile() failed", mLogName.data());
    }
}
Example #21
0
int main(){
    //______________________________________________________________________  
    // Read information from xml file.  
      
    // define xml file path, as follow , we use relative path,  
    // but you can use absolute path also.  
    const char* filepath = "phonebookdata.xml";  
    TiXmlDocument doc(filepath);  
    bool loadOkay = doc.LoadFile();  
    // faile to load 'phonebookdata.xml'.  
    if (!loadOkay) {      
        printf( "Could not load test file %s. Error='%s'. Exiting.\n", filepath,doc.ErrorDesc() );  
        exit( 1 );  
    }  
      
    // get dom root of 'phonebookdata.xml', here root should be 'phonebook'.  
    TiXmlElement* root = doc.RootElement();  
      
    printf("_______________________________________\n\n");  
    printf("     contacted person information      \n\n");  
    // trace every items below root.  
    for( TiXmlNode*  item = root->FirstChild( "item" );  
             item;  
             item = item->NextSibling( "item" ) ) {  
        printf("_______________________________________\n");  
      
        // read name.  
        TiXmlNode* child = item->FirstChild();  
        const char* name = child->ToElement()->GetText();  
        if (name) {  
            printf("name:%s\n",name);  
        } else {  
            printf("name:\n");  
        }  
      
        // read address.  
        child = item->IterateChildren(child);  
        const char* addr = child->ToElement()->GetText();  
        if (addr) {  
            printf("addr:%s\n",addr);  
        } else {  
            printf("addr:\n");  
        }  
      
      
        // read telephone no.  
        child = item->IterateChildren(child);  
        const char* tel = child->ToElement()->GetText();  
            if (tel) {  
            printf("tel:%s\n",tel);  
        } else {  
            printf("tel:\n");  
        }  
      
        // read e-mail.  
        child = item->IterateChildren(child);  
        const char* email = child->ToElement()->GetText();  
        if(email) {  
            printf("email:%s\n",email);  
        } else {  
            printf("email:\n");  
        }  
          
        printf("\n");  
      
    }  
    //______________________________________________________________________  
      
      
    //______________________________________________________________________  
    // Add information to xml file and save it.  
    TiXmlElement* writeRoot = doc.RootElement();  
    TiXmlNode* newNode = new TiXmlElement("item");  
      
       const TiXmlNode* name4NewNode = new TiXmlElement("name");  
    newNode->InsertEndChild(*name4NewNode)->InsertEndChild(TiXmlText("pipi"));  
      
    const TiXmlNode* addr4NewNode = new TiXmlElement("addr");  
    newNode->InsertEndChild(*addr4NewNode)->InsertEndChild(TiXmlText("Shaanxi Xianyang"));  
      
    const TiXmlNode* tel4NewNode = new TiXmlElement("tel");  
    newNode->InsertEndChild(*tel4NewNode)->InsertEndChild(TiXmlText("02937310627"));  
      
    const TiXmlNode* email4NewNode = new TiXmlElement("email");  
    newNode->InsertEndChild(*email4NewNode)->InsertEndChild(TiXmlText("*****@*****.**"));  
      
    writeRoot->InsertEndChild(*newNode);  
    doc.SaveFile();  
    //______________________________________________________________________  

}
Example #22
0
/// Loads skeleton.
void IO::loadSkeleton(TiXmlNode *parent, Skeleton *skeleton, Mesh *m)
{
	// skeleton object is missing
	if (parent == NULL)
		return;

	// load joints
	TiXmlNode *jointsNode = parent->FirstChild("joints");
	if (jointsNode == NULL)
		return;
	TiXmlNode *jointNode = NULL;
	int jointCount = 0;
	int loadedJointCount = 0;
	while ((jointNode = jointsNode->IterateChildren(jointNode)))
	{
		TiXmlElement *j = jointNode->ToElement();

		const char *name;
		float x, y;
		int selected;
		int osc;
		int fixed;
		jointCount++;
		/* if there's a critical error the joint is skipped */
		QUERY_CRITICAL_ATTR(j, "x", x);
		QUERY_CRITICAL_ATTR(j, "y", y);
		/* loadedJointCount holds the number of actually loaded joints */
		loadedJointCount++;
		QUERY_ATTR(j, "selected", selected, 0);
		QUERY_ATTR(j, "osc", osc, 0);
		QUERY_ATTR(j, "fixed", fixed, 0);
		name = j->Attribute("name"); // can be NULL
		Joint *joint = skeleton->addJoint(x, y);
		joint->selected = selected;
		joint->osc = osc;
		joint->fixed = fixed;
		if (name)
			joint->setName(name);
		// add or remove the joint from the vector of joints
		// needed to be sent via OSC
		if (osc)
		{
			ui->editorBox->addToOSCJoints(joint);
		}
	}
	// skip the loading of bones if there was a problematic joint
	if (jointCount != loadedJointCount)
		return;

	// load bones
	TiXmlNode *bonesNode = parent->FirstChild("bones");
	if (bonesNode == NULL)
		return;
	TiXmlNode *boneNode = NULL;
	vector<Joint*> *joints = skeleton->getJoints();
	while ((boneNode = bonesNode->IterateChildren(boneNode)))
	{
		TiXmlElement *b = boneNode->ToElement();

		const char *name;
		int j0, j1;
		float size, stiffness, lengthMult;
		float lengthMultMin, lengthMultMax, time, tempo;
		int selected;
		float radius;

		name = b->Attribute("name"); // can be NULL
		QUERY_CRITICAL_ATTR(b, "j0", j0);
		QUERY_CRITICAL_ATTR(b, "j1", j1);
		QUERY_CRITICAL_ATTR(b, "size", size);
		QUERY_ATTR(b, "stiffness", stiffness, BONE_DEFAULT_DAMP);
		QUERY_ATTR(b, "lm", lengthMult, BONE_DEFAULT_LENGTH_MULT);
		QUERY_ATTR(b, "lmmin", lengthMultMin, BONE_DEFAULT_LENGTH_MULT_MIN);
		QUERY_ATTR(b, "lmmax", lengthMultMax, BONE_DEFAULT_LENGTH_MULT_MAX);
		QUERY_ATTR(b, "tempo", tempo, 0);
		QUERY_ATTR(b, "time", time, 0);
		QUERY_ATTR(b, "selected", selected, 0);
		QUERY_ATTR(b, "radius", radius, 1);

		if ((j0 >= jointCount) || (j1 >= jointCount))
			continue;
		Joint *j0p = (*joints)[j0];
		Joint *j1p = (*joints)[j1];
		Bone *bone = skeleton->addBone(j0p, j1p);
		if (name)
			bone->setName(name);
		bone->setOrigSize(size);
		bone->damp = stiffness;
		bone->setLengthMult(lengthMult);
		bone->setLengthMultMin(lengthMultMin);
		bone->setLengthMultMax(lengthMultMax);
		bone->setTempo(tempo);
		bone->setTime(time);
		bone->selected = selected;
		bone->setRadiusMult(radius);

		// load attached vertices
		TiXmlNode *attachedNode = boneNode->FirstChild("attached");
		if (attachedNode == NULL)
			continue;
		TiXmlNode *vertexNode = NULL;
		// vector to hold vertices to be attached
		vector<Vertex *> *vertsToAttach = new vector<Vertex *>;
		// all vertices in mesh
		vector<Vertex *> *vertices = m->getVertices();
		// iterate over children to find all vertices
		while ((vertexNode = attachedNode->IterateChildren(vertexNode)))
		{
			TiXmlElement *vertexXML = vertexNode->ToElement();

			int id;
			QUERY_CRITICAL_ATTR(vertexXML, "id", id);

			if ((id >= (int)(vertices->size())) || (id < 0))
				continue;

			Vertex *v = (*vertices)[id];
			vertsToAttach->push_back(v);
		}

		// setup parameter arrays
		vertexNode = NULL;
		float *dsts, *weights, *ca, *sa;
		int count = vertsToAttach->size();
		dsts = new float[count];
		weights = new float[count];
		ca = new float[count];
		sa = new float[count];

		// load parameters of attached vertices
		int i = 0;
		while ((vertexNode = attachedNode->IterateChildren(vertexNode)))
		{
			TiXmlElement *vertexXML = vertexNode->ToElement();

			int id;
			float d, w;
			float s, c;
			QUERY_CRITICAL_ATTR(vertexXML, "id", id);
			QUERY_CRITICAL_ATTR(vertexXML, "d", d);
			QUERY_CRITICAL_ATTR(vertexXML, "w", w);
			QUERY_CRITICAL_ATTR(vertexXML, "sa", s);
			QUERY_CRITICAL_ATTR(vertexXML, "ca", c);

			if ((id >= (int)(vertices->size())) || (id < 0))
				continue;

			dsts[i] = d;
			weights[i] = w;
			ca[i] = c;
			sa[i] = s;
			i++;
		}
		bone->attachVertices(vertsToAttach, dsts, weights, ca, sa);
		vertsToAttach->clear();
		delete vertsToAttach;
	}
}
Example #23
0
ResNickMan::ResNickMan() {
    ReservedNicks = NULL;

	TiXmlDocument doc;
#ifdef _WIN32
	if(doc.LoadFile((PATH+"\\cfg\\ReservedNicks.xml").c_str()) == false) {
		TiXmlDocument doc((PATH+"\\cfg\\ReservedNicks.xml").c_str());
#else
	if(doc.LoadFile((PATH+"/cfg/ReservedNicks.xml").c_str()) == false) {
		TiXmlDocument doc((PATH+"/cfg/ReservedNicks.xml").c_str());
#endif
		doc.InsertEndChild(TiXmlDeclaration("1.0", "windows-1252", "yes"));
		TiXmlElement reservednicks("ReservedNicks");
		const char* Nicks[] = { "Hub-Security", "Admin", "Client", "PtokaX", "OpChat" };
		for(uint8_t ui8i = 0; ui8i < 5; ui8i++) {
			AddReservedNick(Nicks[ui8i]);
			TiXmlElement reservednick("ReservedNick");
			reservednick.InsertEndChild(TiXmlText(Nicks[ui8i]));

			reservednicks.InsertEndChild(reservednick);
		}
		doc.InsertEndChild(reservednicks);
		doc.SaveFile();
    }

#ifdef _WIN32
	if(doc.LoadFile((PATH+"\\cfg\\ReservedNicks.xml").c_str())) {
#else
	if(doc.LoadFile((PATH+"/cfg/ReservedNicks.xml").c_str())) {
#endif
		TiXmlHandle cfg(&doc);
		TiXmlNode *reservednicks = cfg.FirstChild("ReservedNicks").Node();
		if(reservednicks != NULL) {
			TiXmlNode *child = NULL;
			while((child = reservednicks->IterateChildren(child)) != NULL) {
				TiXmlNode *reservednick = child->FirstChild();
                    
				if(reservednick == NULL) {
					continue;
				}

				char *sNick = (char *)reservednick->Value();
                    
				AddReservedNick(sNick);
			}
        }
    }
}
//---------------------------------------------------------------------------
	
ResNickMan::~ResNickMan() {
    ReservedNick *next = ReservedNicks;

    while(next != NULL) {
        ReservedNick *cur = next;
        next = cur->next;

        delete cur;
    }
}
//---------------------------------------------------------------------------

// Check for reserved nicks true = reserved
bool ResNickMan::CheckReserved(const char * sNick, const uint32_t &hash) const {
    ReservedNick *next = ReservedNicks;

    while(next != NULL) {
        ReservedNick *cur = next;
        next = cur->next;

		if(cur->ui32Hash == hash && strcasecmp(cur->sNick, sNick) == 0) {
            return true;
        }
    }

    return false;
}
Example #24
0
bool CPlayListASX::LoadData(istream& stream)
{
  CLog::Log(LOGNOTICE, "Parsing ASX");

  if(stream.peek() == '[')
  {
    return LoadAsxIniInfo(stream);
  }
  else
  {
    CXBMCTinyXML xmlDoc;
    stream >> xmlDoc;

    if (xmlDoc.Error())
    {
      CLog::Log(LOGERROR, "Unable to parse ASX info Error: %s", xmlDoc.ErrorDesc());
      return false;
    }

    TiXmlElement *pRootElement = xmlDoc.RootElement();

    // lowercase every element
    TiXmlNode *pNode = pRootElement;
    TiXmlNode *pChild = NULL;
    CStdString value;
    value = pNode->Value();
    value.ToLower();
    pNode->SetValue(value);
    while(pNode)
    {
      pChild = pNode->IterateChildren(pChild);
      if(pChild)
      {
        if (pChild->Type() == TiXmlNode::TINYXML_ELEMENT)
        {
          value = pChild->Value();
          value.ToLower();
          pChild->SetValue(value);

          TiXmlAttribute* pAttr = pChild->ToElement()->FirstAttribute();
          while(pAttr)
          {
            value = pAttr->Name();
            value.ToLower();
            pAttr->SetName(value);
            pAttr = pAttr->Next();
          }
        }

        pNode = pChild;
        pChild = NULL;
        continue;
      }

      pChild = pNode;
      pNode = pNode->Parent();
    }
    CStdString roottitle = "";
    TiXmlElement *pElement = pRootElement->FirstChildElement();
    while (pElement)
    {
      value = pElement->Value();
      if (value == "title")
      {
        roottitle = pElement->GetText();
      }
      else if (value == "entry")
      {
        CStdString title(roottitle);

        TiXmlElement *pRef = pElement->FirstChildElement("ref");
        TiXmlElement *pTitle = pElement->FirstChildElement("title");

        if(pTitle)
          title = pTitle->GetText();

        while (pRef)
        { // multiple references may apear for one entry
          // duration may exist on this level too
          value = pRef->Attribute("href");
          if (value != "")
          {
            if(title.IsEmpty())
              title = value;

            CLog::Log(LOGINFO, "Adding element %s, %s", title.c_str(), value.c_str());
            CFileItemPtr newItem(new CFileItem(title));
            newItem->SetPath(value);
            Add(newItem);
          }
          pRef = pRef->NextSiblingElement("ref");
        }
      }
      else if (value == "entryref")
      {
        value = pElement->Attribute("href");
        if (value != "")
        { // found an entryref, let's try loading that url
          auto_ptr<CPlayList> playlist(CPlayListFactory::Create(value));
          if (NULL != playlist.get())
            if (playlist->Load(value))
              Add(*playlist);
        }
      }
      pElement = pElement->NextSiblingElement();
    }
  }

  return true;
}
Example #25
0
bool PVRDemoData::LoadDemoData(void)
{
  TiXmlDocument xmlDoc;

  if (!xmlDoc.LoadFile(GetSettingsFile()))
  {
    XBMC->Log(LOG_ERROR, "invalid demo data (no/invalid data file found)");
    return false;
  }

  TiXmlElement *pRootElement = xmlDoc.RootElement();
  if (strcmp(pRootElement->Value(), "demo") != 0)
  {
    XBMC->Log(LOG_ERROR, "invalid demo data (no <demo> tag found)");
    return false;
  }

  /* load channels */
  int iUniqueChannelId = 0;
  TiXmlElement *pElement = pRootElement->FirstChildElement("channels");
  if (pElement)
  {
    TiXmlNode *pChannelNode = NULL;
    while ((pChannelNode = pElement->IterateChildren(pChannelNode)) != NULL)
    {
      CStdString strTmp;
      PVRDemoChannel channel;
      channel.iUniqueId = ++iUniqueChannelId;

      /* channel name */
      if (!XMLUtils::GetString(pChannelNode, "name", strTmp))
        continue;
      channel.strChannelName = strTmp;

      /* radio/TV */
      XMLUtils::GetBoolean(pChannelNode, "radio", channel.bRadio);

      /* channel number */
      if (!XMLUtils::GetInt(pChannelNode, "number", channel.iChannelNumber))
        channel.iChannelNumber = iUniqueChannelId;

      /* CAID */
      if (!XMLUtils::GetInt(pChannelNode, "encryption", channel.iEncryptionSystem))
        channel.iEncryptionSystem = 0;

      /* icon path */
      if (!XMLUtils::GetString(pChannelNode, "icon", strTmp))
        channel.strIconPath = m_strDefaultIcon;
      else
        channel.strIconPath = strTmp;

      /* stream url */
      if (!XMLUtils::GetString(pChannelNode, "stream", strTmp))
        channel.strStreamURL = m_strDefaultMovie;
      else
        channel.strStreamURL = strTmp;

      m_channels.push_back(channel);
    }
  }

  /* load channel groups */
  int iUniqueGroupId = 0;
  pElement = pRootElement->FirstChildElement("channelgroups");
  if (pElement)
  {
    TiXmlNode *pGroupNode = NULL;
    while ((pGroupNode = pElement->IterateChildren(pGroupNode)) != NULL)
    {
      CStdString strTmp;
      PVRDemoChannelGroup group;
      group.iGroupId = ++iUniqueGroupId;

      /* group name */
      if (!XMLUtils::GetString(pGroupNode, "name", strTmp))
        continue;
      group.strGroupName = strTmp;

      /* radio/TV */
      XMLUtils::GetBoolean(pGroupNode, "radio", group.bRadio);

      /* members */
      TiXmlNode* pMembers = pGroupNode->FirstChild("members");
      TiXmlNode *pMemberNode = NULL;
      while (pMembers != NULL && (pMemberNode = pMembers->IterateChildren(pMemberNode)) != NULL)
      {
        int iChannelId = atoi(pMemberNode->FirstChild()->Value());
        if (iChannelId > -1)
          group.members.push_back(iChannelId);
      }

      m_groups.push_back(group);
    }
  }

  /* load EPG entries */
  pElement = pRootElement->FirstChildElement("epg");
  if (pElement)
  {
    TiXmlNode *pEpgNode = NULL;
    while ((pEpgNode = pElement->IterateChildren(pEpgNode)) != NULL)
    {
      CStdString strTmp;
      int iTmp;
      PVRDemoEpgEntry entry;

      /* broadcast id */
      if (!XMLUtils::GetInt(pEpgNode, "broadcastid", entry.iBroadcastId))
        continue;

      /* channel id */
      if (!XMLUtils::GetInt(pEpgNode, "channelid", iTmp))
        continue;
      PVRDemoChannel &channel = m_channels.at(iTmp - 1);
      entry.iChannelId = channel.iUniqueId;

      /* title */
      if (!XMLUtils::GetString(pEpgNode, "title", strTmp))
        continue;
      entry.strTitle = strTmp;

      /* start */
      if (!XMLUtils::GetInt(pEpgNode, "start", iTmp))
        continue;
      entry.startTime = iTmp;

      /* end */
      if (!XMLUtils::GetInt(pEpgNode, "end", iTmp))
        continue;
      entry.endTime = iTmp;

      /* plot */
      if (XMLUtils::GetString(pEpgNode, "plot", strTmp))
        entry.strPlot = strTmp;

      /* plot outline */
      if (XMLUtils::GetString(pEpgNode, "plotoutline", strTmp))
        entry.strPlotOutline = strTmp;

      /* icon path */
      if (XMLUtils::GetString(pEpgNode, "icon", strTmp))
        entry.strIconPath = strTmp;

      /* genre type */
      XMLUtils::GetInt(pEpgNode, "genretype", entry.iGenreType);

      /* genre subtype */
      XMLUtils::GetInt(pEpgNode, "genresubtype", entry.iGenreSubType);

      XBMC->Log(LOG_DEBUG, "loaded EPG entry '%s' channel '%d' start '%d' end '%d'", entry.strTitle.c_str(), entry.iChannelId, entry.startTime, entry.endTime);
      channel.epg.push_back(entry);
    }
  }

  return true;
}
Example #26
0
/// Loads mesh.
void IO::loadMesh(TiXmlNode *parent, Mesh *mesh)
{
	// xml element is missing
	if (parent == NULL)
		return;

	// load vertices
	TiXmlNode *verticesNode = parent->FirstChild("vertices");
	if (verticesNode == NULL)
		return;
	TiXmlNode *vertexNode = NULL;
	int vertexCount = 0;
	int loadedVertexCount = 0;
	while ((vertexNode = verticesNode->IterateChildren(vertexNode)))
	{
		TiXmlElement *vert = vertexNode->ToElement();

		float x, y, u, v;
		int selected;
		vertexCount++;
		/* if there's a critical error the vertex is skipped */
		QUERY_CRITICAL_ATTR(vert, "x", x);
		QUERY_CRITICAL_ATTR(vert, "y", y);
		/* loadedVertexCount is incremented only if all the necessary
		 * attributes are set */
		loadedVertexCount++;
		QUERY_ATTR(vert, "u", u, 0);
		QUERY_ATTR(vert, "v", v, 0);
		QUERY_ATTR(vert, "selected", selected, 0);

		Vertex *vertex = mesh->addVertex(x, y);
		vertex->texCoord.x = u;
		vertex->texCoord.y = v;
		vertex->selected = selected;
	}

	// skip the loading of faces if there was an error during vertex loading
	if (vertexCount != loadedVertexCount)
		return;

	// load faces
	TiXmlNode *facesNode = parent->FirstChild("faces");
	if (facesNode == NULL)
		return;
	TiXmlNode *faceNode = NULL;
	while ((faceNode = facesNode->IterateChildren(faceNode)))
	{
		TiXmlElement *f = faceNode->ToElement();

		int v0, v1, v2;
		QUERY_CRITICAL_ATTR(f, "v0", v0);
		QUERY_CRITICAL_ATTR(f, "v1", v1);
		QUERY_CRITICAL_ATTR(f, "v2", v2);

		vector<Vertex*> *vertices = mesh->getVertices();
		int vertexCount = vertices->size();
		if ((v0 >= vertexCount) || (v1 >= vertexCount) || (v2 >= vertexCount))
			continue;
		Vertex *v0p = (*vertices)[v0];
		Vertex *v1p = (*vertices)[v1];
		Vertex *v2p = (*vertices)[v2];
		mesh->addFace(v0p, v1p, v2p);
	}
}
	bool XMLEntityFactory::load()
	{
		// FIXME: Thread safety
		// Open XML file
		if (!xml.LoadFile(file.c_str()) || xml.Error())
		{
			std::cout << "Could not load XML file " << file << ": "
				<< xml.ErrorDesc() << std::endl;
			return false;
		}
		TiXmlNode *root = xml.FirstChild("Entity");
		if (!root)
		{
			std::cerr << "Parser error: <Entity> not found." << std::endl;
			return false;
		}
		// Load properties
		// TODO
		// Load components
		TiXmlNode *componentnode = root->FirstChild("Component");
		while (componentnode)
		{
			TiXmlElement *componentelem = componentnode->ToElement();
			if (!componentelem)
			{
				componentnode = root->IterateChildren("Component", componentnode);
				continue;
			}
			if (!componentelem->Attribute("type"))
			{
				std::cout << "Entity: Component type missing." << std::endl;
				componentnode = root->IterateChildren("Component", componentnode);
				continue;
			}
			ComponentInfo info;
			info.type = componentelem->Attribute("type");
			info.loaded = false;
			info.xml = componentelem;
			info.tpl = 0;
			info.flagsset = 0;
			info.flagsunset = 0;
			if (componentelem->Attribute("flags"))
			{
				// Parse flag conditions
				std::string flags = componentelem->Attribute("flags");
				size_t tokenpos = 0;
				std::string flagstr;
				while (tokenpos < flags.size())
				{
					// Get next flag token
					size_t newtokenpos = flags.find(';', tokenpos);
					if (newtokenpos == std::string::npos)
						newtokenpos = flags.size();
					flagstr = flags.substr(tokenpos, newtokenpos - tokenpos);
					tokenpos = newtokenpos + 1;
					if (flagstr == "")
						continue;
					// Parse flag token
					unsigned int equalpos = flags.find('=');
					std::string flagname = flagstr.substr(0, equalpos);
					bool flagset = flagstr.substr(equalpos + 1,
						flagstr.size() - equalpos - 1) == "yes";
					std::cout << "Flag: " << flagname << ": " << flagset << std::endl;
					EntityFlag flag = Entity::getFlag(flagname);
					if (flag == EEF_Invalid)
					{
						std::cout << "Invalid flag." << std::endl;
						continue;
					}
					// TODO: Warn here
					if (flagset)
						info.flagsset |= flag;
					else
						info.flagsunset |= flag;
				}
			}
			components.push_back(info);
			componentnode = root->IterateChildren("Component", componentnode);
		}
		return true;
	}
Example #28
0
    bool OSMData::read( const std::string &path )
    {
        utm_zone = -1;
        
        TiXmlDocument doc( path.c_str() );
        
        doc.LoadFile();
        
        TiXmlNode *root = doc.RootElement();
        
        TiXmlNode *node;
        
        node = NULL;
        while ( (node = root->IterateChildren("node",node)) )
        {
            TiXmlElement *elem = node->ToElement(); 
            
            const char *text;
            
            OSMNode *osmnode = new OSMNode;
            
            text = elem->Attribute("id");
            if ( text != NULL ) {
                sscanf(text,"%lu",&osmnode->ID);
            } else {
                delete osmnode;
                continue;
            }
            
            text = elem->Attribute("lat");
            if ( text != NULL ) {
                sscanf(text,"%lf",&osmnode->lat);
            }
            
            text = elem->Attribute("lon");
            if ( text != NULL ) {
                sscanf(text,"%lf",&osmnode->lon);
            }
            
            double gamma;
            double k;
            GeographicLib::UTMUPS::Forward(osmnode->lat, osmnode->lon,
                                           this->utm_zone, this->utm_north,
                                           osmnode->east, osmnode->north,
                                           gamma, k );
            
            this->nodes[osmnode->ID] = osmnode;
        }

        node = NULL;
        while ( (node = root->IterateChildren("way",node)) )
        {
            TiXmlElement *elem = node->ToElement();
            
            const char *text;
            
            OSMWay *osmway = new OSMWay;
            osmway->building = false;
            
            text = elem->Attribute("id");
            if ( text != NULL ) {
                sscanf(text,"%lu",&osmway->ID);
            } else {
                delete osmway;
                continue;
            }
            
            TiXmlNode *child = NULL;
            while ( (child = node->IterateChildren( "nd", child ) ) )
            {
                TiXmlElement *childelem = child->ToElement();
                if ( childelem == NULL ) continue;
                
                text = childelem->Attribute("ref");
                if ( text != NULL ) {
                    size_t ID;
                    int nread = sscanf(text,"%lu",&ID);
                    if ( nread == 0 ) continue;
                    osmway->nodeids.push_back(ID);
                }
            }
            
            child = NULL;
            while ( (child = node->IterateChildren( "tag", child ) ) )
            {
                TiXmlElement *childelem = child->ToElement();
                if ( childelem == NULL ) continue;
                
                text = childelem->Attribute("k");
                if ( text != NULL ) {
                    if ( strcmp(text,"building")==0 ) osmway->building = true;
                }
            }

            
            this->ways[osmway->ID] = osmway;
        }
        
        return true;
    }
Example #29
0
BOOL CTrivia::BuiltTriviaIndex(void)
{
	
	WriteEchoText(m_dwTriviaID, "Indexing questions. This could take a moment...\n", RGB(0, 0, 255), RGB(230, 200, 0));

	CFileFind finder;
	
	BOOL bResult = finder.FindFile(m_strWd + "\\*.xml");
	
	while(bResult){

		bResult = finder.FindNextFile();

		TiXmlDocument doc(finder.GetFilePath());

 		if(doc.LoadFile() == false){

			CString strError;
			if(doc.ErrorRow() == 0){

				strError.Format("Error in %s: %s\nFile can not be loaded. Please correct the error.\n", finder.GetFilePath(), doc.ErrorDesc());
			}
			else{

				strError.Format("Error in %s line %d: %s\nFile can not be loaded. Please correct the error.\n", finder.GetFilePath(), doc.ErrorRow(), doc.ErrorDesc());
			}
			WriteEchoText(m_dwTriviaID, strError, RGB(0, 0, 255), RGB(255, 100, 100));
			
			continue;
		}

		TiXmlNode* mainNode = 0;
		mainNode = doc.FirstChild("config");

		if(mainNode == NULL){
			
			CString strError;
			strError.Format("Error in file %s: The <config> supernode is missing. Is this a Trivia file?", finder.GetFilePath());
			WriteEchoText(m_dwTriviaID, strError, RGB(0, 0, 255), RGB(255, 100, 100));

			continue;
		}

		TiXmlNode* triviaNode = 0;
		std::string strBuffer;

		TRIVIA t;
		t.strFile = finder.GetFilePath();
		t.dwNum   = 0;

		while((triviaNode = mainNode->IterateChildren("Trivia", triviaNode)) != NULL){

			t.dwNum++;
		}

		m_aTrivia.Add(t);

		m_dwTotal+= t.dwNum;
	}

	CString strText;
	strText.Format("Found %u questions in %u files\n", m_dwTotal, m_aTrivia.GetSize());
	WriteEchoText(m_dwTriviaID, strText, RGB(0, 0, 255), RGB(255, 230, 0));

	
	return !m_aTrivia.IsEmpty();
}
Example #30
0
void SipRedirectorGateway::loadMappings(UtlString* file_name,
                                    UtlHashMap* mapUserToContacts,
                                    UtlHashMap* mapContactsToUser)
{
    // Load the XML file.
    TiXmlDocument *mDoc = new TiXmlDocument(file_name->data());
    if (mDoc->LoadFile())
    {
       // Look at the top element, which should be "Gateway".
       TiXmlNode* GatewayNode = mDoc->FirstChild("Gateway");
       if (GatewayNode)
       {
          mMapLock.acquire();

          for (TiXmlNode* mapNode = NULL;
               (mapNode = GatewayNode->IterateChildren("map", mapNode));
             )
          {
             // Carefully get the <prefix> and <hostpart> text.
             TiXmlNode* c1 = mapNode->FirstChild("prefix");
             if (!c1)
             {
                OsSysLog::add(FAC_SIP, PRI_ERR,
                              "%s::loadMappings cannot find <prefix> child",
                              mLogName.data());
             }
             else
             {
                TiXmlNode* c2 = c1->FirstChild();
                if (!c2)
                {
                   OsSysLog::add(FAC_SIP, PRI_ERR,
                                 "%s::loadMappings cannot find text child of <prefix>",
                                 mLogName.data());
                }
                else
                {
                   const char* prefix = c2->Value();
                   if (prefix == NULL || *prefix == '\0')
                   {
                      OsSysLog::add(FAC_SIP, PRI_ERR,
                                    "%s::loadMappings text of <prefix> is null",
                                    mLogName.data());
                   }
                   else
                   {
                      TiXmlNode* c3 = mapNode->FirstChild("hostpart");
                      if (!c3)
                      {
                         OsSysLog::add(FAC_SIP, PRI_ERR,
                                       "%s::loadMappings cannot find <hostpart> child",
                                       mLogName.data());
                      }
                      else
                      {
                         TiXmlNode* c4 = c3->FirstChild();
                         if (!c4)
                         {
                            OsSysLog::add(FAC_SIP, PRI_ERR,
                                          "%s::loadMappings cannot find text child of <hostpart>",
                                          mLogName.data());
                         }
                         else
                         {
                            const char* hostpart = c4->Value();
                            if (hostpart == NULL || *hostpart == '\0')
                            {
                               OsSysLog::add(FAC_SIP, PRI_ERR,
                                             "%s::loadMappings text of <hostpart> is null",
                                             mLogName.data());
                            }
                            else
                            {
                               // Load the mapping into the maps.
                               OsSysLog::add(FAC_SIP, PRI_DEBUG,
                                             "%s::loadMappings added '%s' -> '%s'",
                                             mLogName.data(), prefix, hostpart);
                               UtlString* prefix_string = new UtlString(prefix);
                               UtlString* hostpart_string = new UtlString(hostpart);
                               mapUserToContacts->insertKeyAndValue(prefix_string,
                                                                    hostpart_string);
                               mapContactsToUser->insertKeyAndValue(hostpart_string,
                                                                    prefix_string);
                            }
                         }
                      }
                   }
                }
             }
          }

          mMapsModified = FALSE;

          mMapLock.release();

          OsSysLog::add(FAC_SIP, PRI_DEBUG,
                        "%s::loadMappings done loading mappings", mLogName.data());
       }
       else
       {
          OsSysLog::add(FAC_SIP, PRI_CRIT,
                        "%s::loadMappings unable to extract Gateway element",
                        mLogName.data());
       }

    }
    else
    {
       OsSysLog::add(FAC_SIP, PRI_CRIT,
                     "%s::loadMappings LoadFile() failed", mLogName.data());
    }
}