| 334 | } |
| 335 | |
| 336 | bool ProfileTransfer::validateImportFile(const QString& path, QString* error) const |
| 337 | { |
| 338 | const QFileInfo info(path); |
| 339 | if (!info.exists() || !info.isFile()) { |
| 340 | *error = QStringLiteral("Choose a readable .ssdr_cfg package to import."); |
| 341 | return false; |
| 342 | } |
| 343 | if (info.suffix().compare(QStringLiteral("ssdr_cfg"), Qt::CaseInsensitive) != 0) { |
| 344 | *error = QStringLiteral("Only SmartSDR .ssdr_cfg packages can be imported."); |
| 345 | return false; |
| 346 | } |
| 347 | if (info.size() <= 0) { |
| 348 | *error = QStringLiteral("The selected .ssdr_cfg package is empty."); |
| 349 | return false; |
| 350 | } |
| 351 | if (info.size() > kMaxImportSize) { |
| 352 | *error = QStringLiteral("The selected .ssdr_cfg package is larger than the safety limit."); |
| 353 | return false; |
| 354 | } |
| 355 | QFile file(path); |
| 356 | if (!file.open(QIODevice::ReadOnly)) { |
| 357 | *error = QStringLiteral("Cannot read the import package: %1").arg(file.errorString()); |
| 358 | return false; |
| 359 | } |
| 360 | return true; |
| 361 | } |
| 362 | |
| 363 | void ProfileTransfer::requestUploadPort(const QByteArray& payload, const QString& uploadKind) |
| 364 | { |