diff --git a/src/app/main.cpp b/src/app/main.cpp index e702fe022a33da59f1ade79b7c8d3bf9d4c6cb81..c5bbae573f49d3c2770463d83f73bf10e871ff8d 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -43,6 +43,8 @@ #include <QtCore/QSettings> #include <QtCore/QVariant> +#include <QtNetwork/QNetworkProxyFactory> + #include <QtGui/QMessageBox> #include <QtGui/QApplication> #include <QtGui/QMainWindow> @@ -216,6 +218,9 @@ int main(int argc, char **argv) } } + // Make sure we honor the system's proxy settings + QNetworkProxyFactory::setUseSystemConfiguration(true); + // Load ExtensionSystem::PluginManager pluginManager; pluginManager.setFileExtension(QLatin1String("pluginspec")); diff --git a/src/plugins/welcome/rssfetcher.cpp b/src/plugins/welcome/rssfetcher.cpp index 6f14715b7ddb0ec888e051a66c426de1569bee8c..418983576ab25fa4a24e7957d1be417d4147db95 100644 --- a/src/plugins/welcome/rssfetcher.cpp +++ b/src/plugins/welcome/rssfetcher.cpp @@ -32,7 +32,8 @@ #include <QtCore/QLocale> #include <QtGui/QDesktopServices> #include <QtGui/QLineEdit> -#include <QtNetwork/QHttp> +#include <QtNetwork/QNetworkReply> +#include <QtNetwork/QNetworkRequest> #include <QtNetwork/QNetworkProxyFactory> #include <coreplugin/coreconstants.h> @@ -111,45 +112,31 @@ static const QString getOsString() RSSFetcher::RSSFetcher(int maxItems, QObject *parent) : QObject(parent), m_items(0), m_maxItems(maxItems) { - connect(&m_http, SIGNAL(readyRead(const QHttpResponseHeader &)), - this, SLOT(readData(const QHttpResponseHeader &))); - - connect(&m_http, SIGNAL(requestFinished(int, bool)), - this, SLOT(finished(int, bool))); + connect(&m_networkAccessManager, SIGNAL(finished(QNetworkReply*)), + SLOT(fetchingFinished(QNetworkReply*))); } void RSSFetcher::fetch(const QUrl &url) { - QList<QNetworkProxy> proxies = QNetworkProxyFactory::systemProxyForQuery(QNetworkProxyQuery(url)); - if (proxies.count() > 0) - m_http.setProxy(proxies.first()); - m_http.setHost(url.host()); QString agentStr = QString("Qt-Creator/%1 (QHttp %2; %3; %4; %5 bit)") .arg(Core::Constants::IDE_VERSION_LONG).arg(qVersion()) .arg(getOsString()).arg(QLocale::system().name()) .arg(QSysInfo::WordSize); - QHttpRequestHeader header("GET", url.path()); - //qDebug() << agentStr; - header.setValue("User-Agent", agentStr); - header.setValue("Host", url.host()); - m_connectionId = m_http.request(header); + QNetworkRequest req(url); + req.setRawHeader("User-Agent", agentStr.toLatin1()); + m_networkAccessManager.get(req); } -void RSSFetcher::readData(const QHttpResponseHeader &resp) +void RSSFetcher::fetchingFinished(QNetworkReply *reply) { - if (resp.statusCode() != 200) - m_http.abort(); - else { - m_xml.addData(m_http.readAll()); + bool error = (reply->error() != QNetworkReply::NoError); + if (!error) { + m_xml.addData(reply->readAll()); parseXml(); + m_items = 0; } -} - -void RSSFetcher::finished(int id, bool error) -{ - Q_UNUSED(id) - m_items = 0; emit finished(error); + reply->deleteLater(); } void RSSFetcher::parseXml() @@ -182,6 +169,5 @@ void RSSFetcher::parseXml() } if (m_xml.error() && m_xml.error() != QXmlStreamReader::PrematureEndOfDocumentError) { qWarning() << "XML ERROR:" << m_xml.lineNumber() << ": " << m_xml.errorString(); - m_http.abort(); } } diff --git a/src/plugins/welcome/rssfetcher.h b/src/plugins/welcome/rssfetcher.h index d02e1ca956264e2b20f0c6e14a584ff07efc5caa..7bd1b92181013936422353563dea02c4a0a9d3d2 100644 --- a/src/plugins/welcome/rssfetcher.h +++ b/src/plugins/welcome/rssfetcher.h @@ -32,7 +32,11 @@ #include <QtCore/QUrl> #include <QtCore/QXmlStreamReader> -#include <QtNetwork/QHttp> +#include <QtNetwork/QNetworkAccessManager> + +QT_BEGIN_NAMESPACE +class QNetworkReply; +QT_END_NAMESPACE namespace Welcome { namespace Internal { @@ -45,14 +49,11 @@ public: signals: void newsItemReady(const QString& title, const QString& desciption, const QString& url); + void finished(bool error); public slots: + void fetchingFinished(QNetworkReply *reply); void fetch(const QUrl &url); - void finished(int id, bool error); - void readData(const QHttpResponseHeader &); - - signals: - void finished(bool error); private: void parseXml(); @@ -63,8 +64,7 @@ private: QString m_descriptionString; QString m_titleString; - QHttp m_http; - int m_connectionId; + QNetworkAccessManager m_networkAccessManager; int m_items; int m_maxItems; };