// Grab the favicon.ico for each tracker to make the bug list prettier void MainWindow::fetchIcon(const QString &url, const QString &savePath, const QString &username, const QString &password) { QUrl u(url); QString fetch = "http://" + u.host() + "/favicon.ico"; qDebug() << "fetchIcon: " << fetch; QUrl iconUrl(fetch); if (!username.isEmpty()) { iconUrl.setUserName(username); iconUrl.setPassword(password); } QNetworkRequest req = QNetworkRequest(iconUrl); req.setAttribute(QNetworkRequest::User, QVariant(savePath)); // We set this to 0 for a first request, and then to 1 if the url is redirected. req.setAttribute((QNetworkRequest::Attribute)(QNetworkRequest::User+1), QVariant(0)); req.setAttribute((QNetworkRequest::Attribute)(QNetworkRequest::User+2), QVariant(username)); req.setAttribute((QNetworkRequest::Attribute)(QNetworkRequest::User+3), QVariant(password)); QNetworkReply *rep = pManager->get(req); connect(rep, SIGNAL(finished()), this, SLOT(iconDownloaded())); }
RssFeed::RssFeed(RssManager* manager, RssFolder* parent, const QString& url): m_manager(manager), m_parent(parent), m_url (QUrl::fromEncoded(url.toUtf8()).toString()), m_icon(":/Icons/oxygen/application-rss+xml.png"), m_unreadCount(0), m_dirty(false), m_inErrorState(false), m_loading(false) { qDebug() << Q_FUNC_INFO << m_url; // Listen for new RSS downloads connect(manager->rssDownloader(), SIGNAL(downloadFinished(QString,QString)), SLOT(handleFinishedDownload(QString,QString))); connect(manager->rssDownloader(), SIGNAL(downloadFailure(QString,QString)), SLOT(handleDownloadFailure(QString,QString))); connect(manager->rssParser(), SIGNAL(feedTitle(QString,QString)), SLOT(handleFeedTitle(QString,QString))); connect(manager->rssParser(), SIGNAL(newArticle(QString,QVariantHash)), SLOT(handleNewArticle(QString,QVariantHash))); connect(manager->rssParser(), SIGNAL(feedParsingFinished(QString,QString)), SLOT(handleFeedParsingFinished(QString,QString))); // Download the RSS Feed icon m_iconUrl = iconUrl(); manager->rssDownloader()->downloadUrl(m_iconUrl); // Load old RSS articles loadItemsFromDisk(); }
ChanInfo *XMLTVParser::parseChannel(QDomElement &element, QUrl baseUrl) { ChanInfo *chaninfo = new ChanInfo; QString xmltvid = element.attribute("id", ""); QStringList split = QStringList::split(" ", xmltvid); chaninfo->callsign = ""; chaninfo->chanstr = ""; chaninfo->xmltvid = xmltvid; chaninfo->iconpath = ""; chaninfo->name = ""; chaninfo->finetune = ""; chaninfo->tvformat = "Default"; for (QDomNode child = element.firstChild(); !child.isNull(); child = child.nextSibling()) { QDomElement info = child.toElement(); if (!info.isNull()) { if (info.tagName() == "icon") { QUrl iconUrl(baseUrl, info.attribute("src", ""), true); chaninfo->iconpath = iconUrl.toString(); } else if (info.tagName() == "display-name") { if (chaninfo->name.length() == 0) { chaninfo->name = info.text(); } else if (isJapan && chaninfo->callsign.length() == 0) { chaninfo->callsign = info.text(); } else if (chaninfo->chanstr.length() == 0) { chaninfo->chanstr = info.text(); } } } } chaninfo->freqid = chaninfo->chanstr; return chaninfo; }
/* * from khtml_part code */ QString errorPageHtml( int errorCode, const QString& text, const KUrl& reqUrl ) { QString errorName, techName, description; QStringList causes, solutions; QByteArray raw = KIO::rawErrorDetail( errorCode, text, &reqUrl ); QDataStream stream(raw); stream >> errorName >> techName >> description >> causes >> solutions; QString url, protocol, datetime; url = Qt::escape( reqUrl.prettyUrl() ); protocol = reqUrl.protocol(); datetime = KGlobal::locale()->formatDateTime( QDateTime::currentDateTime(), KLocale::LongDate ); QString filename( KStandardDirs::locate( "data", "khtml/error.html" ) ); QFile file( filename ); bool isOpened = file.open( QIODevice::ReadOnly ); if ( !isOpened ) kWarning(6050) << "Could not open error html template:" << filename; QString html = QString( QLatin1String( file.readAll() ) ); html.replace( QLatin1String( "TITLE" ), i18n( "Error: %1 - %2", errorName, url ) ); html.replace( QLatin1String( "DIRECTION" ), QApplication::isRightToLeft() ? "rtl" : "ltr" ); KUrl iconUrl(KIconLoader::global()->iconPath( "dialog-warning", -KIconLoader::SizeHuge )); iconUrl.setProtocol("file://"); html.replace( QLatin1String( "ICON_PATH" ), iconUrl.url()); QString doc = QLatin1String( "<h1>" ); doc += i18n( "The requested operation could not be completed" ); doc += QLatin1String( "</h1><h2>" ); doc += errorName; doc += QLatin1String( "</h2>" ); if ( !techName.isNull() ) { doc += QLatin1String( "<h2>" ); doc += i18n( "Technical Reason: " ); doc += techName; doc += QLatin1String( "</h2>" ); } doc += QLatin1String( "<h3>" ); doc += i18n( "Details of the Request:" ); doc += QLatin1String( "</h3><ul><li>" ); doc += i18n( "URL: %1" , url ); doc += QLatin1String( "</li><li>" ); if ( !protocol.isNull() ) { doc += i18n( "Protocol: %1", protocol ); doc += QLatin1String( "</li><li>" ); } doc += i18n( "Date and Time: %1" , datetime ); doc += QLatin1String( "</li><li>" ); doc += i18n( "Additional Information: %1" , text ); doc += QLatin1String( "</li></ul><h3>" ); doc += i18n( "Description:" ); doc += QLatin1String( "</h3><p>" ); doc += description; doc += QLatin1String( "</p>" ); if ( causes.count() ) { doc += QLatin1String( "<h3>" ); doc += i18n( "Possible Causes:" ); doc += QLatin1String( "</h3><ul><li>" ); doc += causes.join( "</li><li>" ); doc += QLatin1String( "</li></ul>" ); } if ( solutions.count() ) { doc += QLatin1String( "<h3>" ); doc += i18n( "Possible Solutions:" ); doc += QLatin1String( "</h3><ul><li>" ); doc += solutions.join( "</li><li>" ); doc += QLatin1String( "</li></ul>" ); } html.replace( QLatin1String("TEXT"), doc ); return html; }