bool PlayerInfoReader::readPlayerInfo() { if (tokenByName(reader.name()) != T_PlayerInfo) { return false; } while (reader.readNextStartElement()) { if (tokenByName(reader.name()) == T_Player) { Player p = readPlayer(); m_pinfo.players.append(p); } else { reader.skipCurrentElement(); } } return true; }
// GetVariable sends a message to the player that looks like this: // "Command Name\n", ie... "GetVariable var1\n". Then it waits // for the response with the type and value. GnashNPVariant GnashPluginScriptObject::GetVariable(const std::string &name) { std::vector<std::string> iargs; std::string str = plugin::ExternalInterface::makeString(name); iargs.push_back(str); str = plugin::ExternalInterface::makeInvoke("GetVariable", iargs); log_debug("Trying to get a value for %s.", name); size_t ret = writePlayer(str); if (ret != str.size()) { // If all the browser wants is the version, we don't need to // ask the standalone player for this value. YouTube at // least depends on this for some pages which want this to // be greater than 8.0.0. This appears to potentially be // Google's way of trying to revent downloaders, as this requires // plugin support. NPVariant value; if (name == "$version") { STRINGN_TO_NPVARIANT("LNX 10,0,r999", 13, value); } else { log_error("Couldn't send GetVariable request, network problems."); NULL_TO_NPVARIANT(value); } return value; } // Have the read function allocate the memory std::string data = readPlayer(); if (data.empty()) { return GnashNPVariant(); } GnashNPVariant parsed = plugin::ExternalInterface::parseXML(this, data); printNPVariant(&parsed.get()); return parsed; }
void xml_boatData::slot_readData(QString fname,bool readAll) { /* opening file */ QString errorStr; int errorLine; int errorColumn; bool hasVersion = false; QFile file(fname); if (!file.open(QIODevice::ReadOnly | QIODevice::Text )) return ; QDomDocument doc; if(!doc.setContent(&file,true,&errorStr,&errorLine,&errorColumn)) { QMessageBox::warning(0,QObject::tr("Lecture de parametre bateau"), QString("Erreur ligne %1, colonne %2:\n%3") .arg(errorLine) .arg(errorColumn) .arg(errorStr)); return ; } QDomElement root = doc.documentElement(); if(root.tagName() != ROOT_NAME) { qWarning() << "Wrong root name: " << root.tagName(); return ; } /* check for old version */ QDomNode node = root.firstChild(); while(!node.isNull()) { if(node.toElement().tagName() == VERSION_NAME) { QDomNode dataNode = node.firstChild(); if(dataNode.nodeType() == QDomNode::TextNode) { hasVersion = true; if(dataNode.toText().data().toInt()<VERSION_NUMBER) { QMessageBox::warning(this->main,tr("Chargement des comptes/bateaux"), tr("Ancienne version de fichier, demarrage avec une configuration vide")); file.close(); return; } } break; } } if(!hasVersion) { qWarning() << "Missing version number in boatAcc.dat"; return; } /* are we reading all ? */ PlayerMap *pList=new PlayerMap(); if(readAll) { /* start with players */ readPlayer(root.firstChild(),pList); /* now read boats */ readBoat(root.firstChild(),pList); } /* read race data */ readRace(root.firstChild()); delete pList; }
std::string GnashPluginScriptObject::readPlayer() { return readPlayer(_hostfd); }
logic::CScenario* CScenariosXmlDao::readScenario(const string& path){ TiXmlDocument doc(path.c_str()); if(!doc.LoadFile()) return false; // Creamos el escenario para comenzar a llenarlo logic::CScenario* scenario = new logic::CScenario(); TiXmlHandle hDoc(&doc); // Recuperamos el elemento del nodo raiz TiXmlElement* pElem = hDoc.FirstChildElement().Element(); TiXmlHandle hRoot(pElem); // Recorremos los graficos TiXmlElement* pGfxElement = hRoot.FirstChild("gfx").Element(); while(pGfxElement){ //cout<<"Etiqueta: "<<pGfxElement->Value()<<"\n"; // Recorremos los graficos estaticos TiXmlHandle hGfx(pGfxElement); TiXmlElement* pStaticGfxElement = hGfx.FirstChild("static_gfx").Element(); while(pStaticGfxElement){ //cout<<"Etiqueta: "<<pStaticGfxElement->Value()<<"\n"; // Recorremos cada elemento estatico y multimedia TiXmlHandle hStaticGfx(pStaticGfxElement); TiXmlElement* pStaticElement = hStaticGfx.FirstChild("static").Element(); TiXmlElement* pMultElement= hStaticGfx.FirstChild("multimedia").Element(); TiXmlElement* pScreenElement= hStaticGfx.FirstChild("screen").Element(); // Leemos las pantallas que haya while(pScreenElement){ logic::CScreen* screen = readScreen(pScreenElement); scenario->setScreen(screen); pScreenElement = pScreenElement->NextSiblingElement("screen"); } // Leo elementos multimedia while(pMultElement){ logic::CMultimediaFurniture* mult = readMultFur(pMultElement); scenario->addMultimediaFurniture(mult); pMultElement = pMultElement->NextSiblingElement("multimedia"); } // Leo elementos estaticos while(pStaticElement){ //cout<<"Etiqueta: "<<pStaticElement->Value()<<"\n"; logic::CEntity* entity = readStaticEntity(pStaticElement); if(entity->id() == "screen") scenario->setScreen(entity); scenario->addFurniture(entity); pStaticElement = pStaticElement->NextSiblingElement("static"); } pStaticGfxElement = pStaticGfxElement->NextSiblingElement("static_gfx"); } // Recorremos los graficos animados TiXmlElement* pAnimatedGfxElement = hGfx.FirstChild("animated_gfx").Element(); while(pAnimatedGfxElement){ //cout<<"Etiqueta: "<<pAnimatedGfxElement->Value()<<"\n"; TiXmlHandle hAnimatedGfx(pAnimatedGfxElement); // Recorremos cada jugador animado TiXmlElement* pPlayerElement = hAnimatedGfx.FirstChild("player").Element(); while(pPlayerElement){ logic::CPlayer* player = readPlayer(pPlayerElement); scenario->addPlayer(player); pPlayerElement = pPlayerElement->NextSiblingElement("player"); } // Recorremos cada personaje del publico TiXmlElement* pHostElement = hAnimatedGfx.FirstChild("host").Element(); while(pHostElement){ logic::CQuizShowHost* host = readHost(pHostElement); scenario->setHost(host); pHostElement = pHostElement->NextSiblingElement("host"); } // Recorremos cada personaje del publico TiXmlElement* pPublicElement = hAnimatedGfx.FirstChild("public").Element(); while(pPublicElement){ logic::CAvatar* audience = readAudience(pPublicElement); scenario->addAudience(audience); pPublicElement = pPublicElement->NextSiblingElement("public"); } pAnimatedGfxElement = pAnimatedGfxElement->NextSiblingElement("animated_gfx"); } pGfxElement = pGfxElement->NextSiblingElement("gfx"); } return scenario; }