void Parser3::UserRecived( BasePtr bInfo, QDomDocument Page ) { if( !bInfo ) { Error( "Null Pointer to Info!" ); return; } if( bInfo->getType() != IT_UserInfo ) { Error( "Info is not UserInfo!" ); return; } UserPtr Info = bInfo->cast_UserInfo(); QDomNode Entry = Page.namedItem("entry"); if( Entry.isNull() ) { Error( "Entry is null!, maybe page is not a userEntry?" ); return; } QStringList IDString = Entry.namedItem("id").namedItem("#text").nodeValue().split(':', QString::SkipEmptyParts ); if( IDString.size() != 4 || IDString.at(2) != "user" ) { Error( "Page is not a user Entry!!" ); return; } ParseUserEntry(Entry, Info ); const_cast<QString&>(Info->ID) = Info->Author.toLower(); UserParsed( Info ); return; }
void Parser3::VideoRecived( BasePtr bInfo, QDomDocument Page ) { if( !bInfo ) { Error( "Null pointer to Info!"); return; } if( bInfo->getType() != IT_VideoInfo ) { Error( "Info is not videoInfo! type("+QString::number(bInfo->getType())+")" ); return; } VideoPtr Info = bInfo->cast_VideoInfo(); QDomNode Entry = Page.namedItem("entry"); if( Entry.isNull() ) { Error( "Entry is null!, maybe page is not a videoEntry?" ); return; } QStringList IDString = Entry.namedItem("id").namedItem("#text").nodeValue().split(':', QString::SkipEmptyParts ); if( IDString.size() != 4 || IDString.at(2) != "video" ) { Error( "Page is not a video Entry!!" ); return; } ParseVideoEntry(Entry, Info); //(*Info) = vInfo; VideoParsed( Info ); return; }
void EqualizerPresetManager::slotDefault() { int button = KMessageBox::warningYesNo( this, i18n( "All presets will be deleted and defaults will be restored. Are you sure?" ) ); if ( button != KMessageBox::Yes ) return; // Preserve the 'Manual' preset QList<int> manualGains = m_presets[ i18n("Manual") ]; // Delete all presets m_presets.clear(); // Create predefined presets 'Zero' and 'Manual' QList<int> zeroGains; zeroGains << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0; m_presets[ i18n("Zero") ] = zeroGains; m_presets[ i18n("Manual") ] = manualGains; // Load the default presets QFile file( KStandardDirs::locate( "data", "amarok/data/equalizer_presets.xml" ) ); QTextStream stream( &file ); stream.setCodec( "UTF8" ); QDomDocument d; if( !file.open( QIODevice::ReadOnly ) || !d.setContent( stream.readAll() ) ) return; QDomNode n = d.namedItem( "equalizerpresets" ).namedItem("preset"); for( ; !n.isNull(); n = n.nextSibling() ) { QDomElement e = n.toElement(); QString title = e.attribute( "name" ); QList<int> gains; gains << e.namedItem( "b0" ).toElement().text().toInt(); gains << e.namedItem( "b1" ).toElement().text().toInt(); gains << e.namedItem( "b2" ).toElement().text().toInt(); gains << e.namedItem( "b3" ).toElement().text().toInt(); gains << e.namedItem( "b4" ).toElement().text().toInt(); gains << e.namedItem( "b5" ).toElement().text().toInt(); gains << e.namedItem( "b6" ).toElement().text().toInt(); gains << e.namedItem( "b7" ).toElement().text().toInt(); gains << e.namedItem( "b8" ).toElement().text().toInt(); gains << e.namedItem( "b9" ).toElement().text().toInt(); m_presets[ title ] = gains; } file.close(); // Update listview setPresets( m_presets ); }
void MainWindow::loadData() { QFile file(settings["xsplitPath"] + "streamcontrol.xml"); file.open(QIODevice::ReadOnly | QIODevice::Text); QDomDocument doc; doc.setContent(&file); file.close(); QDomElement items = doc.namedItem("items").toElement(); QDomElement pName1 = items.namedItem("pName1").toElement(); QDomElement pName2 = items.namedItem("pName2").toElement(); QDomElement pScore1 = items.namedItem("pScore1").toElement(); QDomElement pScore2 = items.namedItem("pScore2").toElement(); QDomElement rounds = items.namedItem("rounds").toElement(); QDomElement srText = items.namedItem("srText").toElement(); QDomElement cTitle1 = items.namedItem("cTitle1").toElement(); QDomElement cTitle2 = items.namedItem("cTitle2").toElement(); QDomElement mText1 = items.namedItem("mText1").toElement(); QDomElement mText2 = items.namedItem("mText2").toElement(); QDomElement mText3 = items.namedItem("mText3").toElement(); QDomElement mText4 = items.namedItem("mText4").toElement(); QDomElement game = items.namedItem("game").toElement(); QDomElement p1c = items.namedItem("p1c").toElement(); QDomElement p2c = items.namedItem("p2c").toElement(); ui->pName1->setText(pName1.text()); ui->pScore1->setValue(pScore1.text().toInt()); ui->pName2->setText(pName2.text()); ui->pScore2->setValue(pScore2.text().toInt()); ui->rounds->setValue(rounds.text().toInt()); ui->srText->setText(srText.text()); ui->cTitle1->setText(cTitle1.text()); ui->cTitle2->setText(cTitle2.text()); ui->mText1->setText(mText1.text()); ui->mText2->setText(mText2.text()); ui->mText3->setText(mText3.text()); ui->mText4->setText(mText4.text()); int gameIndex = gameComboBox->findText(game.text()); if (gameIndex != -1) { gameComboBox->setCurrentIndex(gameIndex); } else if (game.text() != "") { gameComboBox->addItem(game.text()); gameComboBox->setCurrentIndex(gameComboBox->findText(game.text())); saveSettings(); } int p1CIndex = ui->p1Color->findText(p1c.text()); ui->p1Color->setCurrentIndex(p1CIndex); int p2CIndex = ui->p2Color->findText(p2c.text()); ui->p2Color->setCurrentIndex(p2CIndex); }
void Parser3::VideoSeachRecived( BasePtr bInfo, QDomDocument Page ) { if( !bInfo ) { Error( "Null Pointer to Info!" ); return; } if( bInfo->getType() != IT_VideoFeed ) { Error( "Info is not playlist(videofeed)!" ); return; } VideoFeedPtr Info = bInfo->cast_VideoFeed(); QDomNode Feed = Page.namedItem("feed"); if( Feed.isNull() ) { Error( "Feed is null!, Maybe page is not a playlist(videofeed)" ); return; } QStringList IDString = Feed.namedItem("id").namedItem("#text").nodeValue().split(':', QString::SkipEmptyParts ); if( IDString.size() != 3 || IDString.at(2) != "videos" ) { Error( "Page is not a videoSeach!!" ); return; } ParseVideoFeed( Feed, Info ); Info->Title.remove("YouTube Videos matching query: "); // the id is const :/ const_cast<QString&>(Info->ID) = "[VideoSearch]"+Info->Title; /*If we don't have a thumbnail, we take the first video's thumbview*/ if( !Info->UrlThumbnail.isValid() ) { Info->UrlThumbnail = Info->Content.first()->UrlThumbnail; } if( Info->ParsedPages == 1 ) VideoSearchParsed(Info); else VideosAdded(Info); return; }
void Parser3::VideoReleatedRecived( BasePtr bInfo, QDomDocument Page ) { if( !bInfo ) { Error( "Null Pointer to Info!" ); return; } if( bInfo->getType() != IT_VideoFeed ) { Error( "Info is not a video Responce(videofeed)!" ); return; } VideoFeedPtr Info = bInfo->cast_VideoFeed(); QDomNode Feed = Page.namedItem("feed"); if( Feed.isNull() ) { Error( "Feed is null!, Maybe page is not a video Releated(videofeed)" ); return; } QStringList IDString = Feed.namedItem("id").namedItem("#text").nodeValue().split(':', QString::SkipEmptyParts ); if( IDString.size() != 5 || (IDString.at(2) != "video" && IDString.at(4) != "related" )) { Error( "Page is not a video Releated!!" ); return; } QString Title = Info->Title; ParseVideoFeed( Feed, Info ); /// Youtube will say that the title is some thing like "Videos related to 'TITLE'" /// But we really does not want it :) if( !Title.isNull() ) Info->Title = Title; // the id is const :/ const_cast<QString&>(Info->ID) = IDString.at(3).toLower(); // If we don't have a thumbnail, we take the first video's thumbview if( !Info->UrlThumbnail.isValid() ) { Info->UrlThumbnail = Info->Content.first()->UrlThumbnail; } VideoFeed *vInfo = Info; VideosAdded(Info); }
bool Exif2GPX::loadGPX(const QString& filename, bool useTracks, bool useWaypoints) { QDomDocument qdd; QFile file(filename); qdd.setContent(&file); QDomNode node, node2, node3, node4, node5; node = qdd.namedItem("gpx"); if (node.isNull()) { std::cerr<<"Could not load "<<filename<<std::endl; return false; } node2 = node.firstChild(); while (!node2.isNull()) { if (node2.nodeName() == "wpt" && useWaypoints) loadPoint(node2); else if (node2.nodeName() == "trk" && useTracks) { node3 = node2.firstChild(); while (!node3.isNull()) { if (node3.nodeName() == "trkseg") { node4 = node3.firstChild(); while (!node4.isNull()) { if (node4.nodeName() == "trkpt") loadPoint(node4); node4 = node4.nextSibling(); } } node3 = node3.nextSibling(); } } node2 = node2.nextSibling(); } // did we get any points? if (points.size() == 0) { std::cerr<<"No timestamped points found in "<<filename<<std::endl; return false; } return true; }
void Parser3::UserFavoritesRecived( BasePtr bInfo, QDomDocument Page ) { if( !bInfo ) { Error( "Null Pointer to Info!" ); return; } if( bInfo->getType() != IT_VideoFeed ) { Error( "Info is not UserFavorites(videofeed)!" ); return; } VideoFeedPtr Info = bInfo->cast_VideoFeed(); QDomNode Feed = Page.namedItem("feed"); if( Feed.isNull() ) { Error( "Feed is null!, Maybe page is not a UserFavorites(videofeed)" ); return; } QStringList IDString = Feed.namedItem("id").namedItem("#text").nodeValue().split(':', QString::SkipEmptyParts ); if( IDString.size() != 5 || IDString.at(4) != "favorites" ) { Error( "Page is not a UserFavorites!!" ); return; } ParseVideoFeed( Feed, Info ); /*If we don't have a thumbnail, we take the first video's thumbview*/ if( !Info->UrlThumbnail.isValid() ) { Info->UrlThumbnail = Info->Content.first()->UrlThumbnail; } VideosAdded(Info); return; }
QStringList KexiDBReportData::scriptList() const { QStringList scripts; if( d->connection) { QList<int> scriptids = d->connection->objectIds(KexiPart::ScriptObjectType); QStringList scriptnames = d->connection->objectNames(KexiPart::ScriptObjectType); qDebug() << scriptids << scriptnames; //A blank entry scripts << ""; int i = 0; foreach(int id, scriptids) { qDebug() << "ID:" << id; tristate res; QString script; res = d->connection->loadDataBlock(id, &script, QString()); if (res == true) { QDomDocument domdoc; bool parsed = domdoc.setContent(script, false); QDomElement scriptelem = domdoc.namedItem("script").toElement(); if (parsed && !scriptelem.isNull()) { if (scriptelem.attribute("scripttype") == "object" && isInterpreterSupported(scriptelem.attribute("language"))) { scripts << scriptnames[i]; } } else { qDebug() << "Unable to parse script"; } } else { qDebug() << "Unable to loadDataBlock"; } ++i; }
void MainWindow::loadSettings() { QFile file("settings.xml"); QString xsplitPath; if (file.open(QIODevice::ReadOnly | QIODevice::Text)) { QDomDocument doc; doc.setContent(&file); file.close(); QDomElement settingsXML = doc.namedItem("settings").toElement(); QDomElement xsplitPathE = settingsXML.namedItem("xsplitPath").toElement(); xsplitPath = xsplitPathE.text(); QDomElement useCDATAE = settingsXML.namedItem("useCDATA").toElement(); if (useCDATAE.text() == "1") { useCDATA = true; settings["useCDATA"] = "1"; } else { useCDATA = false; settings["useCDATA"] = "0"; } QDomElement gamesE = settingsXML.namedItem("games").toElement(); for(QDomNode n = gamesE.firstChild(); !n.isNull(); n = n.nextSibling()) { QDomElement gameE = n.toElement(); gameComboBox->addItem(gameE.text()); } QDomElement p1cE = settingsXML.namedItem("player1").toElement(); for(QDomNode n = p1cE.firstChild(); !n.isNull(); n = n.nextSibling()) { QDomElement p1colorE = n.toElement(); ui->p1Color->addItem(p1colorE.text()); } QDomElement p2cE = settingsXML.namedItem("player2").toElement(); for(QDomNode n = p2cE.firstChild(); !n.isNull(); n = n.nextSibling()) { QDomElement p2colorE = n.toElement(); ui->p2Color->addItem(p2colorE.text()); } settings["xsplitPath"] = xsplitPath; //gameComboBox->addItem("Persona 4: Arena"); } else { QFile xsplitExe32("C:\\Program Files\\SplitMediaLabs\\XSplit\\XSplit.Core.exe"); QFile xsplitExe("C:\\Program Files (x86)\\SplitMediaLabs\\XSplit\\XSplit.Core.exe"); if (xsplitExe.exists() || xsplitExe32.exists()) { if (xsplitExe.exists()) { xsplitPath = "C:\\Program Files (x86)\\SplitMediaLabs\\XSplit\\"; } else { xsplitPath = "C:\\Program Files\\SplitMediaLabs\\XSplit\\"; } QMessageBox msgBox; msgBox.setText("XSplit Installation detected at default location. Saving settings."); msgBox.exec(); settings["xsplitPath"] = xsplitPath; } else { QMessageBox msgBox; msgBox.setText("Please be sure to configure StreamControl before you start."); msgBox.exec(); xsplitPath = ""; } //set some default games if none already set gameComboBox->addItem("Super Street Fighter IV"); gameComboBox->addItem("Ultimate Marvel vs Capcom 3"); gameComboBox->addItem("Persona 4: Arena"); gameComboBox->addItem("Tekken Tag Tournament 2"); gameComboBox->addItem("Soul Calibur V"); gameComboBox->addItem("King of Fighters XIII"); ui->p1Color->addItem("B"); ui->p1Color->addItem("R"); ui->p1Color->addItem("G"); ui->p1Color->addItem("P"); ui->p2Color->addItem("B"); ui->p2Color->addItem("R"); ui->p2Color->addItem("G"); ui->p2Color->addItem("P"); saveSettings(); } }
Skin SkinFactory::skinInfo(const QString &skin_name, bool *ok) const { Skin skin; QFile skin_file(APP_SKIN_PATH + QDir::separator() + skin_name); QDomDocument dokument; if (!skin_file.open(QIODevice::Text | QIODevice::ReadOnly) || !dokument.setContent(&skin_file, true)) { if (ok) { *ok = false; } return skin; } const QDomNode skin_node = dokument.namedItem(QSL("skin")); // Obtain visible skin name. skin.m_visibleName = skin_node.namedItem(QSL("name")).toElement().text(); // Obtain author. skin.m_author = skin_node.namedItem(QSL("author")).namedItem(QSL("name")).toElement().text(); // Obtain email. skin.m_email = skin_node.namedItem(QSL("author")).namedItem(QSL("email")).toElement().text(); // Obtain version. skin.m_version = skin_node.attributes().namedItem(QSL("version")).toAttr().value(); // Obtain other information. skin.m_baseName = QString(skin_name).replace(QDir::separator(), '/'); // Obtain base folder. const QString base_folder = skin.m_baseName.split(QL1C('/'), QString::SkipEmptyParts).at(0); // Here we use "/" instead of QDir::separator() because CSS2.1 url field // accepts '/' as path elements separator. // // "##" is placeholder for the actual path to skin file. This is needed for using // images within the QSS file. // So if one uses "##/images/border.png" in QSS then it is // replaced by fully absolute path and target file can // be safely loaded. // Obtain layout markup wrapper. skin.m_layoutMarkupWrapper = skin_node.namedItem(QSL("markup_wrapper")).toElement().text(); skin.m_layoutMarkupWrapper = QByteArray::fromBase64(skin.m_layoutMarkupWrapper.toLocal8Bit()); skin.m_layoutMarkupWrapper = skin.m_layoutMarkupWrapper.replace(QSL("##"), APP_SKIN_PATH + QL1S("/") + base_folder); // Obtain enclosure image layout skin.m_enclosureImageMarkup = skin_node.namedItem(QSL("enclosure_image")).toElement().text(); skin.m_enclosureImageMarkup = QByteArray::fromBase64(skin.m_enclosureImageMarkup.toLocal8Bit()); skin.m_enclosureImageMarkup = skin.m_enclosureImageMarkup.replace(QSL("##"), APP_SKIN_PATH + QL1S("/") + base_folder); // Obtain layout markup. skin.m_layoutMarkup = skin_node.namedItem(QSL("markup")).toElement().text(); skin.m_layoutMarkup = QByteArray::fromBase64(skin.m_layoutMarkup.toLocal8Bit()); skin.m_layoutMarkup = skin.m_layoutMarkup.replace(QSL("##"), APP_SKIN_PATH + QL1S("/") + base_folder); // Obtain enclosure hyperlink wrapper. skin.m_enclosureMarkup = skin_node.namedItem(QSL("markup_enclosure")).toElement().text(); skin.m_enclosureMarkup = QByteArray::fromBase64(skin.m_enclosureMarkup.toLocal8Bit()); skin.m_enclosureMarkup = skin.m_enclosureMarkup.replace(QSL("##"), APP_SKIN_PATH + QL1S("/") + base_folder); // Obtain skin raw data. skin.m_rawData = skin_node.namedItem(QSL("data")).toElement().text(); skin.m_rawData = QByteArray::fromBase64(skin.m_rawData.toLocal8Bit()); skin.m_rawData = skin.m_rawData.replace(QSL("##"), APP_SKIN_PATH + QL1S("/") + base_folder); // Free resources. skin_file.close(); skin_file.deleteLater(); if (ok != nullptr) { *ok = !skin.m_author.isEmpty() && !skin.m_version.isEmpty() && !skin.m_baseName.isEmpty() && !skin.m_email.isEmpty() && !skin.m_layoutMarkup.isEmpty(); } return skin; }
UPnPResultCode MythXMLClient::GetConnectionInfo( const QString &sPin, DatabaseParams *pParams, QString &sMsg ) { if (pParams == NULL) return UPnPResult_InvalidArgs; int nErrCode = 0; QString sErrDesc; QStringMap list; sMsg.clear(); list.insert( "Pin", sPin ); if (SendSOAPRequest( "GetConnectionInfo", list, nErrCode, sErrDesc, m_bInQtThread )) { QString sXml = "<Info>" + list[ "Info" ] + "</Info>"; sMsg = sErrDesc; QDomDocument doc; if ( !doc.setContent( sXml, false, &sErrDesc, &nErrCode )) { sMsg = QObject::tr("Error Requesting Connection Info"); VERBOSE( VB_UPNP, QString( "Error Requesting Connection Info : (%1) - %2" ) .arg( nErrCode ) .arg( sErrDesc ) ); return UPnPResult_ActionFailed; } // -------------------------------------------------------------- // Is this a valid response? // -------------------------------------------------------------- QDomNode infoNode = doc.namedItem( "Info" ); if (!infoNode.isNull()) { QDomNode dbNode = infoNode.namedItem( "Database" ); pParams->dbHostName = GetNodeValue( dbNode, "Host" , QString( )); pParams->dbPort = GetNodeValue( dbNode, "Port" , 0 ); pParams->dbUserName = GetNodeValue( dbNode, "UserName" , QString( )); pParams->dbPassword = GetNodeValue( dbNode, "Password" , QString( )); pParams->dbName = GetNodeValue( dbNode, "Name" , QString( )); pParams->dbType = GetNodeValue( dbNode, "Type" , QString( )); QDomNode wolNode = infoNode.namedItem( "WOL" ); pParams->wolEnabled = GetNodeValue( wolNode, "Enabled" , false ); pParams->wolReconnect = GetNodeValue( wolNode, "Reconnect", 0 ); pParams->wolRetry = GetNodeValue( wolNode, "Retry" , 0 ); pParams->wolCommand = GetNodeValue( wolNode, "Command" , QString( )); return UPnPResult_Success; } else { if (sMsg.isEmpty()) sMsg = QObject::tr("Unexpected Response"); VERBOSE( VB_IMPORTANT, QString( "MythXMLClient::GetConnectionInfo Failed : Unexpected Response - %1" ) .arg( sXml )); } } else { sMsg = sErrDesc; if (sMsg.isEmpty()) sMsg = QObject::tr("Access Denied"); VERBOSE( VB_IMPORTANT, QString( "MythXMLClient::GetConnectionInfo Failed - (%1) %2" ) .arg( nErrCode ) .arg( sErrDesc )); } if (UPnPResult_HumanInterventionRequired == nErrCode || UPnPResult_ActionNotAuthorized == nErrCode) return (UPnPResultCode)nErrCode; return UPnPResult_ActionFailed; }
// The QHttp object retrieved data. void Service::slotRequestFinished() { QNetworkReply * reply = qobject_cast<QNetworkReply *>(sender()); qDebug() << "UPnP::Service: received HTTP response for request " << endl; if(!reply) { qWarning() << "UPnP::Service - HTTP Request failed: " << reply->errorString() << endl; m_iPendingRequests--; emit queryFinished(true); return; } if(reply->error() != QNetworkReply::NoError) { qWarning() << "UPnP::Service - HTTP Request failed: " << reply->errorString() << endl; m_iPendingRequests--; emit queryFinished(true); reply->deleteLater(); return; } // Get the XML content QByteArray response = reply->readAll(); QDomDocument xml; qDebug() << "Response:\n" << response << "\n---\n"; // Parse the XML QString errorMessage; bool error = !xml.setContent(response, false, &errorMessage); if(!error) { QString baseNamespace = xml.documentElement().tagName(); if(baseNamespace.length() > 0) { int cutAt = baseNamespace.indexOf(':'); if(cutAt > -1) { baseNamespace.truncate(cutAt); qDebug() << "Device is using " << baseNamespace << " as XML namespace" << endl; m_szBaseXmlPrefix = baseNamespace; } } // Determine how to process the data if(xml.namedItem(m_szBaseXmlPrefix + ":Envelope").isNull()) { qDebug() << "UPnP::Service: plain XML detected, calling gotInformationResponse()." << endl; // No SOAP envelope found, this is a normal response to callService() gotInformationResponse(xml.lastChild()); } else { qDebug() << xml.toString() << endl; // Got a SOAP message response to callAction() QDomNode resultNode = XmlFunctions::getNode(xml, "/" + m_szBaseXmlPrefix + ":Envelope/" + m_szBaseXmlPrefix + ":Body").firstChild(); error = (resultNode.nodeName() == m_szBaseXmlPrefix + ":Fault"); if(!error) { if(resultNode.nodeName().startsWith("m:") || resultNode.nodeName().startsWith("u:")) { qDebug() << "UPnP::Service: SOAP envelope detected, calling gotActionResponse()." << endl; // Action success, return SOAP body QMap<QString, QString> resultValues; // Parse all parameters // It's possible to pass the entire QDomNode object to the gotActionResponse() // function, but this is somewhat nicer, and reduces code boat in the subclasses QDomNodeList children = resultNode.childNodes(); for(int i = 0; i < children.count(); i++) { QString key = children.item(i).nodeName(); resultValues[key] = children.item(i).toElement().text(); } // Call the gotActionResponse() gotActionResponse(resultNode.nodeName().mid(2), resultValues); } } else { qDebug() << "UPnP::Service: SOAP error detected, calling gotActionResponse()." << endl; // Action failed gotActionErrorResponse(resultNode); } } } else { qWarning() << "UPnP::Service - XML parsing failed: " << errorMessage << endl; } // Only emit when bytes>0 m_iPendingRequests--; emit queryFinished(error); }
QDomNode KOfficePlugin::getBaseNode(const QDomDocument &doc) const { return doc.namedItem("office:document-meta").namedItem("office:meta"); }
UPnPResultCode MythXMLClient::GetConnectionInfo( const QString &sPin, DatabaseParams *pParams, QString &sMsg ) { if (pParams == NULL) return UPnPResult_InvalidArgs; int nErrCode = 0; QString sErrDesc; QStringMap list; sMsg.clear(); list.insert( "Pin", sPin ); QDomDocument xmlResults = SendSOAPRequest( "GetConnectionInfo", list, nErrCode, sErrDesc, m_bInQtThread); // -------------------------------------------------------------- // Is this a valid response? // -------------------------------------------------------------- QDomNode oNode = xmlResults.namedItem( "GetConnectionInfoResult" ); if (UPnPResult_Success == nErrCode && !oNode.isNull()) { QDomNode dbNode = oNode.namedItem( "Database" ); pParams->dbHostName = GetNodeValue( dbNode, "Host" , QString()); pParams->dbPort = GetNodeValue( dbNode, "Port" , 0 ); pParams->dbUserName = GetNodeValue( dbNode, "UserName" , QString()); pParams->dbPassword = GetNodeValue( dbNode, "Password" , QString()); pParams->dbName = GetNodeValue( dbNode, "Name" , QString()); pParams->dbType = GetNodeValue( dbNode, "Type" , QString()); QDomNode wolNode = oNode.namedItem( "WOL" ); pParams->wolEnabled = GetNodeValue( wolNode, "Enabled" , false ); pParams->wolReconnect = GetNodeValue( wolNode, "Reconnect", 0 ); pParams->wolRetry = GetNodeValue( wolNode, "Retry" , 0 ); pParams->wolCommand = GetNodeValue( wolNode, "Command" , QString()); return UPnPResult_Success; } else { sMsg = sErrDesc; LOG(VB_GENERAL, LOG_ERR, QString("MythXMLClient::GetConnectionInfo Failed - (%1) %2") .arg(nErrCode) .arg(sErrDesc)); } if (( nErrCode == UPnPResult_HumanInterventionRequired ) || ( nErrCode == UPnPResult_ActionNotAuthorized ) || ( nErrCode == 501 )) { // Service calls no longer return UPnPResult codes, // convert standard 501 to UPnPResult code for now. return UPnPResult_ActionNotAuthorized; } return UPnPResult_ActionFailed; }
QDomElement SmartPlaylistEditor::result() { QDomDocument doc; QDomNode node = doc.namedItem( "smartplaylists" ); QDomElement nodeE; nodeE = node.toElement(); QDomElement smartplaylist = doc.createElement( "smartplaylist" ); smartplaylist.setAttribute( "name", name() ); // Limit if ( m_limitCheck->isChecked() ) smartplaylist.setAttribute( "maxresults", m_limitSpin->value() ); nodeE.appendChild( smartplaylist ); // Matches if( m_matchAnyCheck->isChecked() ) { QDomElement matches = doc.createElement("matches"); smartplaylist.appendChild( matches ); // Iterate through all criteria list CriteriaEditor *criteriaeditor = m_criteriaEditorAnyList.first(); for( int i=0; criteriaeditor; criteriaeditor = m_criteriaEditorAnyList.next(), ++i ) { matches.appendChild( doc.importNode( criteriaeditor->getDomSearchCriteria( doc ), true ) ); } matches.setAttribute( "glue", "OR" ); smartplaylist.appendChild( matches ); } if( m_matchAllCheck->isChecked() ) { QDomElement matches = doc.createElement("matches"); smartplaylist.appendChild( matches ); // Iterate through all criteria list CriteriaEditor *criteriaeditor = m_criteriaEditorAllList.first(); for( int i=0; criteriaeditor; criteriaeditor = m_criteriaEditorAllList.next(), ++i ) { matches.appendChild( doc.importNode( criteriaeditor->getDomSearchCriteria( doc ), true ) ); } matches.setAttribute( "glue", "AND" ); smartplaylist.appendChild( matches ); } // Order By if( m_orderCheck->isChecked() ) { QDomElement orderby = doc.createElement("orderby"); if (m_orderCombo->currentItem() != m_orderCombo->count()-1) { orderby.setAttribute( "field", m_dbFields[ m_orderCombo->currentItem() ] ); orderby.setAttribute( "order", m_orderTypeCombo->currentItem() == 1 ? "DESC" : "ASC" ); } else { orderby.setAttribute( "field", "random" ); orderby.setAttribute( "order", m_orderTypeCombo->currentItem() == 1 ? "weighted" : "random" ); } smartplaylist.appendChild( orderby ); } QDomElement Sql = doc.createElement("sqlquery"); buildQuery(); Sql.appendChild( doc.createTextNode( m_query ) ); smartplaylist.appendChild( Sql ); if( m_expandCheck->isChecked() ) { QDomElement expandBy = doc.createElement("expandby"); expandBy.setAttribute( "field", m_expandableFields[ m_expandCombo->currentItem() ] ); QDomText t = doc.createTextNode( m_expandQuery ); expandBy.appendChild( t ); smartplaylist.appendChild( expandBy ); } return (smartplaylist); }
//XML //Parse XML into tasklist form int TaskList_Main::parseXML(QDomDocument &domTree){ QDomElement set = domTree.namedItem("listset").toElement(); QMessageBox msgBox; //If tree doesn't exist, stop if(set.isNull()){ msgBox.setText("No <listset> element at top level"); msgBox.setWindowTitle("Erorr parsing XML"); msgBox.exec(); return -1; } //Iterate through all "list" items QDomElement n = set.firstChildElement("list"); for( ; !n.isNull(); n = n.nextSiblingElement("list")){ emit createList(n.namedItem("list_title").toElement().text()); delListAction->setEnabled(true); printAction->setEnabled(true); printAllAction->setEnabled(true); //Iterate through all "task" items part of "list" QDomElement o = n.firstChildElement("task"); for( ; !o.isNull(); o = o.nextSiblingElement("task")){ my_listwidget *currList = notePane->listMap[notePane->currList]; QListWidgetItem *currItem; QString tempStr; //If task is 'main' (not subtext/subnote) if(o.attribute("task_type") == "main"){ //Change task name notePane->addItemAction(o.namedItem("task_title").toElement().text(), false); currItem = currList->currentItem(); //Change task check state tempStr = o.namedItem("task_check").toElement().text(); if(tempStr == "unchecked") currItem->setCheckState(Qt::Unchecked); else if (tempStr == "checked") currItem->setCheckState(Qt::Checked); else if (tempStr == "part_check") currItem->setCheckState(Qt::PartiallyChecked); else{ msgBox.setText("Unknown check state"); msgBox.setWindowTitle("Erorr parsing XML"); msgBox.exec(); return -1; } //Change task subnote currItem->setData(32, QVariant( o.namedItem("task_note").toElement().text())); //Change if task subnote is displayed tempStr = o.namedItem("task_display").toElement().text(); if(tempStr == "false"){ currItem->setData(33, QVariant(false)); currItem->setData(35, QVariant(false)); } else if(tempStr == "true"){ currItem->setData(33, QVariant(true)); currItem->setData(35, QVariant(true)); } else{ msgBox.setText("Unknown bool type - display"); msgBox.setWindowTitle("Erorr parsing XML"); msgBox.exec(); return -1; } //Change the task due date tempStr = o.namedItem("task_date").toElement().text(); qDebug((const char *)tempStr.toAscii().data()); QDate tempDate; int year = tempStr.left(4).toInt(); int month = tempStr.mid(5, 2).toInt(); int day = tempStr.right(2).toInt(); tempDate.setDate(year, month, day); if(!tempDate.isValid()){ msgBox.setText("Unknown date type"); msgBox.setWindowTitle("Erorr parsing XML"); msgBox.exec(); return -1; } currItem->setData(34, QVariant(tempDate)); //Change the task font tempStr = o.namedItem("task_font").toElement().text(); QFont tempFont; if(!tempFont.fromString(tempStr)){ msgBox.setText("Unknown font"); msgBox.setWindowTitle("Erorr parsing XML"); msgBox.exec(); return -1; } currItem->setFont(tempFont); } //Else if it is a subtext/subnote for a 'main' else if (o.attribute("task_type") == "sub"){ //Change note's text notePane->addItemAction(o.namedItem("task_title").toElement().text(), true); currItem = currList->currentItem(); currItem->setFlags(0); //Change note's font tempStr = o.namedItem("task_font").toElement().text(); QFont tempFont; if(!tempFont.fromString(tempStr)){ msgBox.setText("Unknown font"); msgBox.setWindowTitle("Erorr parsing XML"); msgBox.exec(); return -1; } currItem->setFont(tempFont); } //Else, exit gracefully else{ msgBox.setText("Unknown list type"); msgBox.setWindowTitle("Erorr parsing XML"); msgBox.exec(); return -1; } //Synchronize the option pane optionPane->itemSelectDataIn(*currItem); } } return 0; }
UPnPResultCode MythXMLClient::GetConnectionInfo( const QString &sPin, DatabaseParams *pParams, QString &sMsg ) { if (pParams == NULL) return UPnPResult_InvalidArgs; int nErrCode = 0; QString sErrDesc; QStringMap list; sMsg.clear(); list.insert( "Pin", sPin ); QDomDocument xmlResults = SendSOAPRequest( "GetConnectionInfo", list, nErrCode, sErrDesc, m_bInQtThread); // -------------------------------------------------------------- // Is this a valid response? // -------------------------------------------------------------- QDomNode oNode = xmlResults.namedItem( "GetConnectionInfoResult" ); if (UPnPResult_Success == nErrCode && !oNode.isNull()) { QDomNode dbNode = oNode.namedItem( "Database" ); pParams->dbHostName = GetNodeValue( dbNode, "Host" , QString()); pParams->dbPort = GetNodeValue( dbNode, "Port" , 0 ); pParams->dbUserName = GetNodeValue( dbNode, "UserName" , QString()); pParams->dbPassword = GetNodeValue( dbNode, "Password" , QString()); pParams->dbName = GetNodeValue( dbNode, "Name" , QString()); pParams->dbType = GetNodeValue( dbNode, "Type" , QString()); QDomNode wolNode = oNode.namedItem( "WOL" ); pParams->wolEnabled = GetNodeValue( wolNode, "Enabled" , false ); pParams->wolReconnect = GetNodeValue( wolNode, "Reconnect", 0 ); pParams->wolRetry = GetNodeValue( wolNode, "Retry" , 0 ); pParams->wolCommand = GetNodeValue( wolNode, "Command" , QString()); QDomNode verNode = oNode.namedItem( "Version" ); pParams->verVersion = GetNodeValue( verNode, "Version" , "" ); pParams->verBranch = GetNodeValue( verNode, "Branch" , "" ); pParams->verProtocol = GetNodeValue( verNode, "Protocol" , "" ); pParams->verBinary = GetNodeValue( verNode, "Binary" , "" ); pParams->verSchema = GetNodeValue( verNode, "Schema" , "" ); if ((pParams->verProtocol != MYTH_PROTO_VERSION) || (pParams->verSchema != MYTH_DATABASE_VERSION)) // incompatible version, we cannot use this backend { LOG(VB_GENERAL, LOG_ERR, QString("MythXMLClient::GetConnectionInfo Failed - " "Version Mismatch (%1,%2) != (%3,%4)") .arg(pParams->verProtocol) .arg(pParams->verSchema) .arg(MYTH_PROTO_VERSION) .arg(MYTH_DATABASE_VERSION)); sMsg = QObject::tr("Version Mismatch", "UPNP Errors"); return UPnPResult_ActionFailed; } return UPnPResult_Success; } else { sMsg = sErrDesc; LOG(VB_GENERAL, LOG_ERR, QString("MythXMLClient::GetConnectionInfo Failed - (%1) %2") .arg(nErrCode) .arg(sErrDesc)); } if (( nErrCode == UPnPResult_HumanInterventionRequired ) || ( nErrCode == UPnPResult_ActionNotAuthorized ) || ( nErrCode == 501 )) { // Service calls no longer return UPnPResult codes, // convert standard 501 to UPnPResult code for now. sMsg = QObject::tr("Not Authorized", "UPNP Errors"); return UPnPResult_ActionNotAuthorized; } sMsg = QObject::tr("Unknown Error", "UPNP Errors"); return UPnPResult_ActionFailed; }