Commit ce74cf20 authored by Bernhard Beschow's avatar Bernhard Beschow
Browse files

remove workaround for bug 257376

* the workaround shouldn't be needed any longer since commit 9e833bed
* bug 257376 was caused by QTBUG-15004

CCBUG: 257376
parent bb834f1d
......@@ -29,7 +29,7 @@ HostipRunner::HostipRunner( QObject *parent ) :
m_networkAccessManager( new QNetworkAccessManager( this ) )
{
connect( m_networkAccessManager, SIGNAL( finished( QNetworkReply* ) ),
this, SLOT( slotRequestFinished( QNetworkReply* ) ), Qt::DirectConnection );
this, SLOT( slotRequestFinished( QNetworkReply* ) ) );
}
HostipRunner::~HostipRunner()
......@@ -72,22 +72,17 @@ void HostipRunner::slotLookupFinished(const QHostInfo &info)
m_hostInfo = info;
QString hostAddress = info.addresses().first().toString();
QString query = QString( "http://api.hostip.info/get_html.php?ip=%1&position=true" ).arg( hostAddress );
m_request.setUrl( QUrl( query ) );
// @todo FIXME Must currently be done in the main thread, see bug 257376
QTimer::singleShot( 0, this, SLOT( get() ) );
QNetworkRequest request = QNetworkRequest( QUrl( query ) );
QNetworkReply *reply = m_networkAccessManager->get( request );
connect( reply, SIGNAL( error( QNetworkReply::NetworkError ) ),
this, SLOT( slotNoResults() ) );
}
else
slotNoResults();
}
void HostipRunner::get()
{
QNetworkReply *reply = m_networkAccessManager->get( m_request );
connect( reply, SIGNAL( error( QNetworkReply::NetworkError ) ),
this, SLOT( slotNoResults() ), Qt::DirectConnection );
}
void HostipRunner::slotRequestFinished( QNetworkReply* reply )
{
double lon(0.0), lat(0.0);
......
......@@ -14,7 +14,6 @@
#include <QtCore/QString>
#include <QtNetwork/QHostInfo>
#include <QtNetwork/QNetworkRequest>
class QNetworkAccessManager;
class QNetworkReply;
......@@ -34,8 +33,6 @@ public:
GeoDataFeature::GeoDataVisualCategory category() const;
private Q_SLOTS:
void get();
// Http request with hostip.info done
void slotRequestFinished( QNetworkReply* );
......@@ -51,8 +48,6 @@ private:
QHostInfo m_hostInfo;
QNetworkAccessManager *const m_networkAccessManager;
QNetworkRequest m_request;
};
}
......
......@@ -62,17 +62,19 @@ void OsmNominatimRunner::search( const QString &searchTerm )
QString query = "q=%1&format=xml&addressdetails=1&accept-language=%2";
QString url = QString(base + query).arg(searchTerm).arg(MarbleLocale::languageCode());
m_request.setUrl(QUrl(url));
m_request.setRawHeader("User-Agent", TinyWebBrowser::userAgent("Browser", "OsmNominatimRunner") );
QNetworkRequest networkRequest;
networkRequest.setUrl(QUrl(url));
networkRequest.setRawHeader("User-Agent", TinyWebBrowser::userAgent("Browser", "OsmNominatimRunner") );
QNetworkReply *reply = m_manager->get( networkRequest );
connect( reply, SIGNAL( error( QNetworkReply::NetworkError ) ),
this, SLOT( returnNoResults() ) );
QEventLoop eventLoop;
connect( this, SIGNAL( searchFinished( QVector<GeoDataPlacemark*> ) ),
&eventLoop, SLOT( quit() ) );
// @todo FIXME Must currently be done in the main thread, see bug 257376
QTimer::singleShot( 0, this, SLOT( startSearch() ) );
eventLoop.exec();
}
......@@ -86,34 +88,22 @@ void OsmNominatimRunner::reverseGeocoding( const GeoDataCoordinates &coordinates
double lat = coordinates.latitude( GeoDataCoordinates::Degree );
QString url = QString( base + query ).arg( lon ).arg( lat ).arg( MarbleLocale::languageCode() );
m_request.setUrl(QUrl(url));
m_request.setRawHeader("User-Agent", TinyWebBrowser::userAgent("Browser", "OsmNominatimRunner") );
QNetworkRequest networkRequest;
networkRequest.setUrl(QUrl(url));
networkRequest.setRawHeader("User-Agent", TinyWebBrowser::userAgent("Browser", "OsmNominatimRunner") );
QNetworkReply *reply = m_manager->get( networkRequest );
connect( reply, SIGNAL( error( QNetworkReply::NetworkError ) ),
this, SLOT( returnNoReverseGeocodingResult() ) );
QEventLoop eventLoop;
connect( this, SIGNAL( reverseGeocodingFinished( GeoDataCoordinates, GeoDataPlacemark ) ),
&eventLoop, SLOT( quit() ) );
// @todo FIXME Must currently be done in the main thread, see bug 257376
QTimer::singleShot( 0, this, SLOT( startReverseGeocoding() ) );
eventLoop.exec();
}
void OsmNominatimRunner::startSearch()
{
QNetworkReply *reply = m_manager->get( m_request );
connect(reply, SIGNAL(error(QNetworkReply::NetworkError)),
this, SLOT(returnNoResults()));
}
void OsmNominatimRunner::startReverseGeocoding()
{
QNetworkReply *reply = m_manager->get( m_request );
connect(reply, SIGNAL(error(QNetworkReply::NetworkError)),
this, SLOT(returnNoReverseGeocodingResult()));
}
void OsmNominatimRunner::handleResult( QNetworkReply* reply )
{
bool const isSearch = reply->url().path().endsWith( "search" );
......
......@@ -56,17 +56,11 @@ private Q_SLOTS:
void returnNoReverseGeocodingResult();
void startSearch();
void startReverseGeocoding();
private:
void addData( const QDomNodeList &node, const QString &key, GeoDataExtendedData *extendedData );
QNetworkAccessManager* m_manager;
QNetworkRequest m_request;
GeoDataCoordinates m_coordinates;
};
......
......@@ -85,28 +85,24 @@ void OpenRouteServiceRunner::retrieveRoute( const RouteRequest *route )
// Please refrain from making this URI public. To use it outside the scope
// of marble you need permission from the openrouteservice.org team.
QUrl url = QUrl( "http://openls.geog.uni-heidelberg.de/osm/eu/routing" );
m_request = QNetworkRequest( url );
m_request.setHeader( QNetworkRequest::ContentTypeHeader, "application/xml" );
m_requestData = request.toLatin1();
QNetworkRequest networkRequest = QNetworkRequest( url );
networkRequest.setHeader( QNetworkRequest::ContentTypeHeader, "application/xml" );
QByteArray requestData = request.toLatin1();
QNetworkReply *reply = m_networkAccessManager->post( networkRequest, requestData );
connect( reply, SIGNAL( error( QNetworkReply::NetworkError ) ),
this, SLOT( handleError( QNetworkReply::NetworkError ) ) );
QEventLoop eventLoop;
connect( this, SIGNAL( routeCalculated( GeoDataDocument* ) ),
&eventLoop, SLOT( quit() ) );
// @todo FIXME Must currently be done in the main thread, see bug 257376
QTimer::singleShot( 0, this, SLOT( get() ) );
eventLoop.exec();
}
void OpenRouteServiceRunner::get()
{
QNetworkReply *reply = m_networkAccessManager->post( m_request, m_requestData );
connect( reply, SIGNAL( error( QNetworkReply::NetworkError ) ),
this, SLOT( handleError( QNetworkReply::NetworkError ) ), Qt::DirectConnection );
}
void OpenRouteServiceRunner::retrieveData( QNetworkReply *reply )
{
if ( reply->isFinished() ) {
......
......@@ -17,7 +17,6 @@
#include <QtCore/QString>
#include <QtNetwork/QNetworkReply>
#include <QtNetwork/QHostInfo>
class QNetworkAccessManager;
......@@ -52,8 +51,6 @@ private Q_SLOTS:
/** A network error occurred */
void handleError( QNetworkReply::NetworkError );
void get();
private:
/** Builds the xml request header. */
QString xmlHeader() const;
......@@ -73,10 +70,6 @@ private:
GeoDataDocument* parse( const QByteArray &input ) const;
QNetworkAccessManager *m_networkAccessManager;
QNetworkRequest m_request;
QByteArray m_requestData;
};
}
......
......@@ -73,26 +73,20 @@ void YoursRunner::retrieveRoute( const RouteRequest *route )
QString request = base + args + preferences;
// mDebug() << "GET: " << request;
m_request = QNetworkRequest( QUrl( request ) );
QNetworkRequest networkRequest = QNetworkRequest( QUrl( request ) );
QNetworkReply *reply = m_networkAccessManager->get( networkRequest );
connect( reply, SIGNAL( error( QNetworkReply::NetworkError ) ),
this, SLOT( handleError( QNetworkReply::NetworkError ) ) );
QEventLoop eventLoop;
connect( this, SIGNAL( routeCalculated( GeoDataDocument* ) ),
&eventLoop, SLOT( quit() ) );
// @todo FIXME Must currently be done in the main thread, see bug 257376
QTimer::singleShot( 0, this, SLOT( get() ) );
eventLoop.exec();
}
void YoursRunner::get()
{
QNetworkReply *reply = m_networkAccessManager->get( m_request );
connect( reply, SIGNAL( error( QNetworkReply::NetworkError ) ),
this, SLOT( handleError( QNetworkReply::NetworkError ) ) );
}
void YoursRunner::retrieveData( QNetworkReply *reply )
{
if ( reply->isFinished() ) {
......
......@@ -44,16 +44,12 @@ private Q_SLOTS:
/** A network error occurred */
void handleError( QNetworkReply::NetworkError );
void get();
private:
GeoDataDocument* parse( const QByteArray &input ) const;
qreal distance( const GeoDataDocument* document ) const;
QNetworkAccessManager *m_networkAccessManager;
QNetworkRequest m_request;
};
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment