Skip to content

Commit

Permalink
Merge pull request #1145 from deXol/develop
Browse files Browse the repository at this point in the history
[BLE] Fetch and send password for special no bundle upload
  • Loading branch information
limpkin authored Feb 7, 2023
2 parents ac80162 + 67727ff commit d12b31b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions src/BleDev.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ bool BleDev::isValidBundleFile(QFile* file) const
return true;
}

bool BleDev::checkBundleFilePassword(const QFileInfo& fileInfo, QString &password)
bool BleDev::checkBundleFilePassword(const QFileInfo& fileInfo, QString &password, bool skipDeviceChecks /* =false */)
{
const auto baseFilename = fileInfo.baseName();
const auto baseNameWithExt = fileInfo.fileName();
Expand All @@ -157,14 +157,14 @@ bool BleDev::checkBundleFilePassword(const QFileInfo& fileInfo, QString &passwor
return false;
}
const auto serial = fileParts[SERIAL_FILE_PART].toUInt();
if (wsClient->get_hwSerial() != serial)
if (!skipDeviceChecks && wsClient->get_hwSerial() != serial)
{
QMessageBox::warning(this, INVALID_BUNDLE_TEXT,
tr("The device serial number is not correct in bundle filename."));
return false;
}
const auto bundleVersion = fileParts[BUNDLE_FILE_PART].toInt();
if (wsClient->get_bundleVersion() != bundleVersion)
if (!skipDeviceChecks && wsClient->get_bundleVersion() != bundleVersion)
{
QMessageBox::warning(this, INVALID_BUNDLE_TEXT,
tr("The bundle version is not correct in bundle filename."));
Expand All @@ -187,7 +187,7 @@ void BleDev::on_btnFileBrowser_clicked()
}
QSettings s;

bool skipFilePwdCheck = wsClient->get_status() == Common::NoBundle &&
bool skipDeviceChecks = wsClient->get_status() == Common::NoBundle &&
DeviceDetector::instance().isCtrlPressed();

QString fileName = QFileDialog::getOpenFileName(this, tr("Select bundle file"),
Expand Down Expand Up @@ -224,7 +224,7 @@ void BleDev::on_btnFileBrowser_clicked()
}

QString password = "";
if (!skipFilePwdCheck && !checkBundleFilePassword(QFileInfo{file}, password))
if (!checkBundleFilePassword(QFileInfo{file}, password, skipDeviceChecks))
{
qCritical() << "Invalid bundle file password";
return;
Expand Down
2 changes: 1 addition & 1 deletion src/BleDev.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ private slots:
void initUITexts();
void fetchData(const Common::FetchType &fetchType);
bool isValidBundleFile(QFile* file) const;
bool checkBundleFilePassword(const QFileInfo& fileInfo, QString& password);
bool checkBundleFilePassword(const QFileInfo& fileInfo, QString& password, bool skipDeviceChecks = false);

Ui::BleDev *ui;
WSClient *wsClient = nullptr;
Expand Down

0 comments on commit d12b31b

Please sign in to comment.