StelLocationMgr.cpp   StelLocationMgr.cpp 
skipping to change at line 38 skipping to change at line 38
#include <QDir> #include <QDir>
#include <QtNetwork/QNetworkInterface> #include <QtNetwork/QNetworkInterface>
#include <QtNetwork/QNetworkAccessManager> #include <QtNetwork/QNetworkAccessManager>
#include <QNetworkRequest> #include <QNetworkRequest>
#include <QNetworkReply> #include <QNetworkReply>
#include <QUrl> #include <QUrl>
#include <QUrlQuery> #include <QUrlQuery>
#include <QSettings> #include <QSettings>
StelLocationMgr::StelLocationMgr() StelLocationMgr::StelLocationMgr()
: networkReply(NULL)
{ {
QSettings* conf = StelApp::getInstance().getSettings(); QSettings* conf = StelApp::getInstance().getSettings();
// The line below allows to re-generate the location file, you still need to gunzip it manually afterward. // The line below allows to re-generate the location file, you still need to gunzip it manually afterward.
// generateBinaryLocationFile("data/base_locations.txt", false, "dat a/base_locations.bin"); // generateBinaryLocationFile("data/base_locations.txt", false, "dat a/base_locations.bin");
locations = loadCitiesBin("data/base_locations.bin.gz"); locations = loadCitiesBin("data/base_locations.bin.gz");
locations.unite(loadCities("data/user_locations.txt", true)); locations.unite(loadCities("data/user_locations.txt", true));
modelAllLocation = new QStringListModel(this); modelAllLocation = new QStringListModel(this);
skipping to change at line 348 skipping to change at line 347
} }
sourcefile.close(); sourcefile.close();
return true; return true;
} }
// lookup location from IP address. // lookup location from IP address.
void StelLocationMgr::locationFromIP() void StelLocationMgr::locationFromIP()
{ {
QNetworkRequest req( QUrl( QString("http://freegeoip.net/csv/") ) ); QNetworkRequest req( QUrl( QString("http://freegeoip.net/csv/") ) );
networkReply=StelApp::getInstance().getNetworkAccessManager()->get(r eq); QNetworkReply* networkReply=StelApp::getInstance().getNetworkAccessM anager()->get(req);
connect(networkReply, SIGNAL(finished()), this, SLOT(changeLocationF romNetworkLookup())); connect(networkReply, SIGNAL(finished()), this, SLOT(changeLocationF romNetworkLookup()));
} }
// slot that receives IP-based location data from the network. // slot that receives IP-based location data from the network.
void StelLocationMgr::changeLocationFromNetworkLookup() void StelLocationMgr::changeLocationFromNetworkLookup()
{ {
StelLocation location; StelLocation location;
StelCore *core=StelApp::getInstance().getCore(); StelCore *core=StelApp::getInstance().getCore();
QNetworkReply* networkReply = qobject_cast<QNetworkReply*>(sender())
;
if (!networkReply)
return;
if (networkReply->error() == QNetworkReply::NoError) { if (networkReply->error() == QNetworkReply::NoError) {
//success //success
// Tested with and without working network connection. // Tested with and without working network connection.
QByteArray answer=networkReply->readAll(); QByteArray answer=networkReply->readAll();
qDebug() << "IP answer:" << answer; qDebug() << "IP answer:" << answer;
// answer/splitline example: "222.222.222.222","AT","Aus tria","","","","","47.3333","13.3333","","" // answer/splitline example: "222.222.222.222","AT","Aus tria","","","","","47.3333","13.3333","",""
// The parts from freegeoip are: ip,country_code,country_nam e,region_code,region_name,city,zipcode,latitude,longitude,metro_code,area_c ode // The parts from freegeoip are: ip,country_code,country_nam e,region_code,region_name,city,zipcode,latitude,longitude,metro_code,area_c ode
// Changed before 2014-11-21 to: 222.222.222.222,AT,Austria, "","","","",Europe/Vienna,47.33,13.33,0<CR><LF> (i.e., only empty strings h ave "") // Changed before 2014-11-21 to: 222.222.222.222,AT,Austria, "","","","",Europe/Vienna,47.33,13.33,0<CR><LF> (i.e., only empty strings h ave "")
// Now: ip,country_code,country_nam e,region_code,region_name,city,zipcode,Timezone_name,latitude,longitude,met ro_code // Now: ip,country_code,country_nam e,region_code,region_name,city,zipcode,Timezone_name,latitude,longitude,met ro_code
// longitude and latitude should always be filled. // longitude and latitude should always be filled.
 End of changes. 3 change blocks. 
2 lines changed or deleted 5 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/