| 847 | } |
| 848 | |
| 849 | bool |
| 850 | Singleton::registerTLE(std::string const &tleData) |
| 851 | { |
| 852 | Orbit newOrbit; |
| 853 | const char *userTLEDir; |
| 854 | QString fullTLEPath; |
| 855 | |
| 856 | if (newOrbit.loadFromTLE(tleData)) { |
| 857 | // Valid TLE file, overwrite current TLE |
| 858 | if ((userTLEDir = suscan_confdb_get_local_tle_path()) == nullptr) |
| 859 | return false; |
| 860 | |
| 861 | fullTLEPath = |
| 862 | userTLEDir + QString("/") |
| 863 | + normalizeTLEName(newOrbit.nameToQString()) + ".tle"; |
| 864 | |
| 865 | // Attempt to save it. If we could |
| 866 | QFile qFile(fullTLEPath); |
| 867 | if (qFile.open(QIODevice::WriteOnly)) { |
| 868 | bool ok; |
| 869 | QTextStream out(&qFile); |
| 870 | out << QString::fromStdString(tleData); |
| 871 | out.flush(); |
| 872 | |
| 873 | ok = !qFile.error(); |
| 874 | |
| 875 | qFile.close(); |
| 876 | |
| 877 | if (ok) { |
| 878 | this->satellites[newOrbit.nameToQString()] = newOrbit; |
| 879 | return true; |
| 880 | } |
| 881 | } |
| 882 | } |
| 883 | |
| 884 | return false; |
| 885 | } |
| 886 | |
| 887 | bool |
| 888 | Singleton::registerTLESource(TLESource const& tleSrc) |
no test coverage detected