void UpdateChecker::parseData(const QByteArray &data) { QDomDocument domDocument; if (domDocument.setContent(data)){ QDomElement root = domDocument.documentElement(); if (root.tagName() != "versions") { if (!silent) txsWarning(tr("Update check failed (invalid update file format).")); return; } QDomNodeList nodes = root.elementsByTagName("stable"); if (nodes.count() == 1) { QDomElement latestRelease = nodes.at(0).toElement(); m_latestVersion = latestRelease.attribute("value"); VersionCompareResult res = versionCompare(m_latestVersion, TXSVERSION); if (res == Invalid) { if (!silent) txsWarning(tr("Update check failed (invalid update file format).")); return; } if (res == Higher) { QString text = QString(tr( "A new version of TeXstudio is available.<br><br>" "Current version: %1<br>" "Latest version: %2<br><br>" "You can download it from the <a href='%3'>TeXstudio website</a>." )).arg(TXSVERSION).arg(m_latestVersion).arg("http://texstudio.sourceforge.net"); QMessageBox msgBox; msgBox.setWindowTitle(tr("TeXstudio Update")); msgBox.setTextFormat(Qt::RichText); msgBox.setText(text); msgBox.setStandardButtons(QMessageBox::Ok); msgBox.exec(); } else { if (!silent) txsInformation(tr("TeXstudio is up-to-date.")); } ConfigManager::getInstance()->setOption("Update/LastCheck", QDateTime::currentDateTime()); emit checkCompleted(); } } }
/** Read a line of package information eg: \code Package: FoobarBaz \endcode */ void PackageInformationReader::readLine( const QString &line ) { if ( line.isEmpty() ) { checkCompleted(); return; } bool isDescContinuation = line.startsWith( " " ); QString lineStr = line.trimmed(); if ( lineStr.length() == 0 ) { checkCompleted(); return; } int colon = line.indexOf(':'); if ( colon == -1 ) { pkg.name = "corrupted"; // NO TR error = "No colon in package information"; // NO TR isError = true; return; } colon += 2; if ( isDescContinuation && accumulatingFullDesc ) { pkg.fullDescription += "\n"; pkg.fullDescription += line; return; } accumulatingFullDesc = false; if ( lineStr.startsWith( QLatin1String( "Package:" ))) { checkCompleted(); pkg.name = lineStr.mid( colon ).trimmed(); if ( !pkg.name.isEmpty() ) hasContent = true; } else if ( lineStr.startsWith( QLatin1String( "Description:" ), Qt::CaseInsensitive )) { pkg.description = lineStr.mid( colon ).trimmed(); if ( !pkg.description.isEmpty() ) hasContent = true; accumulatingFullDesc = true; } else if ( lineStr.startsWith( QLatin1String( "Size:" ), Qt::CaseInsensitive )) { pkg.downloadSize = lineStr.mid( colon ).trimmed(); if ( !pkg.description.isEmpty() ) hasContent = true; } else if ( lineStr.startsWith( QLatin1String( "Section:" ), Qt::CaseInsensitive )) { pkg.section = lineStr.mid( colon ).trimmed(); if ( !pkg.section.isEmpty() ) hasContent = true; } else if ( lineStr.startsWith( QLatin1String( "Domain:" ), Qt::CaseInsensitive )) { pkg.domain = lineStr.mid( colon ).trimmed(); #ifndef QT_NO_SXE if ( !DomainInfo::isDomainValid( pkg.domain ) ) pkg.domain = DomainInfo::defaultDomain(); #endif if ( !pkg.domain.isEmpty() ) hasContent = true; } else if ( lineStr.startsWith( QLatin1String( "Filename:" ), Qt::CaseInsensitive )) { pkg.packageFile = lineStr.mid( colon ).trimmed(); if ( !pkg.packageFile.isEmpty() ) hasContent = true; } else if ( lineStr.startsWith( QLatin1String( "MD5Sum:" ), Qt::CaseInsensitive )) { pkg.md5Sum = lineStr.mid( colon ).trimmed(); if ( !pkg.md5Sum.isEmpty() ) hasContent = true; } else if ( lineStr.startsWith( QLatin1String( "Trust:" ), Qt::CaseInsensitive )) { pkg.trust = lineStr.mid( colon ).trimmed(); if ( !pkg.trust.isEmpty() ) hasContent = true; } else if ( lineStr.startsWith( QLatin1String( "Version:" ), Qt::CaseInsensitive )) { pkg.version = lineStr.mid( colon ).trimmed(); if ( !pkg.version.isEmpty() ) hasContent = true; } else if ( lineStr.startsWith( QLatin1String( "Files:" ), Qt::CaseInsensitive )) {//Files field is deprecated QString fileList = lineStr.mid( colon ).trimmed(); pkg.files = fileList.split( QLatin1String( " " ), QString::SkipEmptyParts ); if ( !pkg.files.isEmpty() ) hasContent = true; } else if ( lineStr.startsWith( QLatin1String( "URL:" ), Qt::CaseInsensitive )) { pkg.url = lineStr.mid( colon ).trimmed(); if ( !pkg.url.isEmpty() ) hasContent = true; } else if ( lineStr.startsWith( QLatin1String( "QtopiaVersion:" ), Qt::CaseInsensitive )) { pkg.qtopiaVersion = lineStr.mid( colon ).trimmed(); if ( !pkg.qtopiaVersion.isEmpty() ) hasContent = true; } else if ( lineStr.startsWith( QLatin1String( "Devices:" ), Qt::CaseInsensitive )) { pkg.devices = lineStr.mid( colon ).trimmed(); if ( !pkg.devices.isEmpty() ) hasContent = true; } else if ( lineStr.startsWith( QLatin1String( "Installed-Size: " ), Qt::CaseInsensitive )) { pkg.installedSize = lineStr.mid( colon ).trimmed(); if ( !pkg.installedSize.isEmpty() ) hasContent = true; } else if ( lineStr.startsWith( QLatin1String( "File-Count: " ), Qt::CaseInsensitive )) { pkg.fileCount = lineStr.mid( colon ).trimmed(); if ( !pkg.fileCount.isEmpty() ) hasContent = true; } else if ( lineStr.startsWith( QLatin1String( "Type: " ), Qt::CaseInsensitive )) { pkg.type = lineStr.mid( colon ).trimmed(); if ( !pkg.type.isEmpty() ) hasContent = true; } else { // legacy/irrelevant fields not currently an error } }