Satellites.cpp   Satellites.cpp 
skipping to change at line 45 skipping to change at line 45
#include "SatellitesListModel.hpp" #include "SatellitesListModel.hpp"
#include "Planet.hpp" #include "Planet.hpp"
#include "SolarSystem.hpp" #include "SolarSystem.hpp"
#include "StelJsonParser.hpp" #include "StelJsonParser.hpp"
#include "SatellitesDialog.hpp" #include "SatellitesDialog.hpp"
#include "LabelMgr.hpp" #include "LabelMgr.hpp"
#include "StelTranslator.hpp" #include "StelTranslator.hpp"
#include "StelProgressController.hpp" #include "StelProgressController.hpp"
#include "StelUtils.hpp" #include "StelUtils.hpp"
#include "external/qtcompress/qzipreader.h"
#include <QNetworkAccessManager> #include <QNetworkAccessManager>
#include <QNetworkReply> #include <QNetworkReply>
#include <QKeyEvent> #include <QKeyEvent>
#include <QDebug> #include <QDebug>
#include <QFileInfo> #include <QFileInfo>
#include <QFile> #include <QFile>
#include <QTimer> #include <QTimer>
#include <QVariantMap> #include <QVariantMap>
#include <QVariant> #include <QVariant>
#include <QDir> #include <QDir>
#include <QTemporaryFile>
StelModule* SatellitesStelPluginInterface::getStelModule() const StelModule* SatellitesStelPluginInterface::getStelModule() const
{ {
return new Satellites(); return new Satellites();
} }
StelPluginInfo SatellitesStelPluginInterface::getPluginInfo() const StelPluginInfo SatellitesStelPluginInterface::getPluginInfo() const
{ {
// Allow to load the resources when used as a static plugin // Allow to load the resources when used as a static plugin
Q_INIT_RESOURCE(Satellites); Q_INIT_RESOURCE(Satellites);
StelPluginInfo info; StelPluginInfo info;
info.id = "Satellites"; info.id = "Satellites";
info.displayedName = N_("Satellites"); info.displayedName = N_("Satellites");
info.authors = "Matthew Gates, Jose Luis Canales, Bogdan Marinov"; info.authors = "Matthew Gates, Jose Luis Canales";
info.contact = "http://stellarium.org/"; info.contact = "http://stellarium.org/";
info.description = N_("Prediction of artificial satellite positions in Earth orbit based on NORAD TLE data"); info.description = N_("Prediction of artificial satellite positions in Earth orbit based on NORAD TLE data");
info.version = SATELLITES_PLUGIN_VERSION; info.version = SATELLITES_PLUGIN_VERSION;
info.license = SATELLITES_PLUGIN_LICENSE;
return info; return info;
} }
Satellites::Satellites() Satellites::Satellites()
: satelliteListModel(Q_NULLPTR) : satelliteListModel(Q_NULLPTR)
, toolbarButton(Q_NULLPTR) , toolbarButton(Q_NULLPTR)
, earth(Q_NULLPTR) , earth(Q_NULLPTR)
, defaultHintColor(0.0f, 0.4f, 0.6f) , defaultHintColor(0.0f, 0.4f, 0.6f)
, defaultOrbitColor(0.0f, 0.3f, 0.6f) , defaultOrbitColor(0.0f, 0.3f, 0.6f)
, updateState(CompleteNoUpdates) , updateState(CompleteNoUpdates)
skipping to change at line 558 skipping to change at line 562
<< "http://www.celestrak.com/NORAD/elements/other-comm.txt" << "http://www.celestrak.com/NORAD/elements/other-comm.txt"
<< "1,http://www.celestrak.com/NORAD/elements/glo-ops.txt" << "1,http://www.celestrak.com/NORAD/elements/glo-ops.txt"
<< "http://www.celestrak.com/NORAD/elements/beidou.txt" << "http://www.celestrak.com/NORAD/elements/beidou.txt"
<< "http://www.celestrak.com/NORAD/elements/sbas.txt" << "http://www.celestrak.com/NORAD/elements/sbas.txt"
<< "http://www.celestrak.com/NORAD/elements/nnss.txt" << "http://www.celestrak.com/NORAD/elements/nnss.txt"
<< "http://www.celestrak.com/NORAD/elements/engineering.txt" << "http://www.celestrak.com/NORAD/elements/engineering.txt"
<< "http://www.celestrak.com/NORAD/elements/education.txt" << "http://www.celestrak.com/NORAD/elements/education.txt"
<< "http://www.celestrak.com/NORAD/elements/geodetic.txt" << "http://www.celestrak.com/NORAD/elements/geodetic.txt"
<< "http://www.celestrak.com/NORAD/elements/radar.txt" << "http://www.celestrak.com/NORAD/elements/radar.txt"
<< "http://www.celestrak.com/NORAD/elements/cubesat.txt" << "http://www.celestrak.com/NORAD/elements/cubesat.txt"
<< "http://www.celestrak.com/NORAD/elements/other.txt"; << "http://www.celestrak.com/NORAD/elements/other.txt"
<< "https://www.amsat.org/amsat/ftp/keps/current/nasabare.txt"
<< "1,https://www.prismnet.com/~mmccants/tles/classfd.zip";
saveTleSources(urls); saveTleSources(urls);
} }
void Satellites::restoreDefaultCatalog() void Satellites::restoreDefaultCatalog()
{ {
if (QFileInfo(catalogPath).exists()) if (QFileInfo(catalogPath).exists())
backupCatalog(true); backupCatalog(true);
QFile src(":/satellites/satellites.json"); QFile src(":/satellites/satellites.json");
if (!src.copy(catalogPath)) if (!src.copy(catalogPath))
skipping to change at line 1250 skipping to change at line 1257
{ {
updateSources.append(source); updateSources.append(source);
downloadMgr->get(QNetworkRequest(source.url)); downloadMgr->get(QNetworkRequest(source.url));
} }
} }
} }
void Satellites::saveDownloadedUpdate(QNetworkReply* reply) void Satellites::saveDownloadedUpdate(QNetworkReply* reply)
{ {
// check the download worked, and save the data to file if this is t he case. // check the download worked, and save the data to file if this is t he case.
if (reply->error() != QNetworkReply::NoError) if (reply->error() == QNetworkReply::NoError && reply->bytesAvailabl
{ e()>0)
qWarning() << "[Satellites] FAILED to download"
<< reply->url().toString(QUrl::RemoveUserInfo)
<< "Error:" << reply->errorString();
}
else
{ {
// download completed successfully. // download completed successfully.
QString name = QString("tle%1.txt").arg(numberDownloadsCompl ete); QString name = QString("tle%1.txt").arg(numberDownloadsCompl ete);
QString path = dataDir.absoluteFilePath(name); QString path = dataDir.absoluteFilePath(name);
// QFile as a child object to the plugin to ease memory mana gement // QFile as a child object to the plugin to ease memory mana gement
QFile* tmpFile = new QFile(path, this); QFile* tmpFile = new QFile(path, this);
if (tmpFile->exists()) if (tmpFile->exists())
tmpFile->remove(); tmpFile->remove();
if (tmpFile->open(QIODevice::WriteOnly | QIODevice::Text)) if (tmpFile->open(QIODevice::WriteOnly | QIODevice::Text))
{ {
tmpFile->write(reply->readAll()); QByteArray fd = reply->readAll();
// qWarning() << "[Satellites] Processing an URL:" <
< reply->url().toString();
if (reply->url().toString().contains(".zip", Qt::Cas
eInsensitive))
{
QTemporaryFile zip;
if (zip.open())
{
// qWarning() << "[Satellites] Proce
ssing a ZIP archive...";
zip.write(fd);
zip.close();
QString archive = zip.fileName();
QByteArray data;
Stel::QZipReader reader(archive);
if (reader.status() != Stel::QZipRea
der::NoError)
qWarning() << "[Satellites]
Unable to open as a ZIP archive";
else
{
QList<Stel::QZipReader::File
Info> infoList = reader.fileInfoList();
foreach(Stel::QZipReader::Fi
leInfo info, infoList)
{
// qWarning() << "[S
atellites] Processing:" << info.filePath;
if (info.isFile)
data.append(
reader.fileData(info.filePath));
}
// qWarning() << "[Satellite
s] Extracted data:" << data;
fd = data;
}
reader.close();
zip.remove();
}
else
qWarning() << "[Satellites] Unable t
o open a temporary file";
}
tmpFile->write(fd);
tmpFile->close(); tmpFile->close();
// The reply URL can be different form the requested one... // The reply URL can be different form the requested one...
QUrl url = reply->request().url(); QUrl url = reply->request().url();
for (int i = 0; i < updateSources.count(); i++) for (int i = 0; i < updateSources.count(); i++)
{ {
if (updateSources[i].url == url) if (updateSources[i].url == url)
{ {
updateSources[i].file = tmpFile; updateSources[i].file = tmpFile;
tmpFile = 0; tmpFile = 0;
skipping to change at line 1292 skipping to change at line 1327
if (tmpFile) // Something strange just happened... if (tmpFile) // Something strange just happened...
delete tmpFile; // ...so we have to clean. delete tmpFile; // ...so we have to clean.
} }
else else
{ {
qWarning() << "[Satellites] cannot save update file: " qWarning() << "[Satellites] cannot save update file: "
<< tmpFile->error() << tmpFile->error()
<< tmpFile->errorString(); << tmpFile->errorString();
} }
} }
else
qWarning() << "[Satellites] FAILED to download" << reply->ur
l().toString(QUrl::RemoveUserInfo) << "Error:" << reply->errorString();
numberDownloadsComplete++; numberDownloadsComplete++;
if (progressBar) if (progressBar)
progressBar->setValue(numberDownloadsComplete); progressBar->setValue(numberDownloadsComplete);
// Check if all files have been downloaded. // Check if all files have been downloaded.
// TODO: It's better to keep track of the network requests themselve s. --BM // TODO: It's better to keep track of the network requests themselve s. --BM
if (numberDownloadsComplete < updateSources.size()) if (numberDownloadsComplete < updateSources.size())
return; return;
if (progressBar) if (progressBar)
skipping to change at line 2035 skipping to change at line 2073
N_("galileo"); N_("galileo");
// TRANSLATORS: Satellite group: Satellites belonging to the Iridium constellation (Iridium is a proper name) // TRANSLATORS: Satellite group: Satellites belonging to the Iridium constellation (Iridium is a proper name)
N_("iridium"); N_("iridium");
// TRANSLATORS: Satellite group: Space stations // TRANSLATORS: Satellite group: Space stations
N_("stations"); N_("stations");
// TRANSLATORS: Satellite group: Education satellites // TRANSLATORS: Satellite group: Education satellites
N_("education"); N_("education");
// TRANSLATORS: Satellite group: Satellites belonging to the space o bservatories // TRANSLATORS: Satellite group: Satellites belonging to the space o bservatories
N_("observatory"); N_("observatory");
/* For copy/paste:
// TRANSLATORS: Satellite group:
N_("");
*/
// Satellite descriptions - bright and/or famous objects // Satellite descriptions - bright and/or famous objects
// Just A FEW objects please! (I'm looking at you, Alex!) // Just A FEW objects please! (I'm looking at you, Alex!)
// TRANSLATORS: Satellite description. "Hubble" is a person's name. // TRANSLATORS: Satellite description. "Hubble" is a person's name.
N_("The Hubble Space Telescope"); N_("The Hubble Space Telescope");
// TRANSLATORS: Satellite description. // TRANSLATORS: Satellite description.
N_("The International Space Station"); N_("The International Space Station");
// TRANSLATORS: Satellite description. // TRANSLATORS: Satellite description.
N_("China's first space station"); N_("China's first space station");
// TRANSLATORS: Satellite description. // TRANSLATORS: Satellite description.
N_("The russian space radio telescope RadioAstron"); N_("The russian space radio telescope RadioAstron");
 End of changes. 9 change blocks. 
15 lines changed or deleted 61 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/