diff --git a/lib/ipatool-go b/lib/ipatool-go index d4f0f34..6573e78 160000 --- a/lib/ipatool-go +++ b/lib/ipatool-go @@ -1 +1 @@ -Subproject commit d4f0f3448a8dd3d2f4d372eb53fe82988635a1d4 +Subproject commit 6573e7822c9bfc9e946d6fce256bd7af017d5699 diff --git a/src/appinstalldialog.cpp b/src/appinstalldialog.cpp index 6f59ab7..5e42e95 100644 --- a/src/appinstalldialog.cpp +++ b/src/appinstalldialog.cpp @@ -18,6 +18,22 @@ */ #include "appinstalldialog.h" +#include +#include +extern "C" { +char *IpaToolGetDownloadedFilePath(const char *bundleId); +} +static QString ipaPathFromIpatool(const QString &bundleId) +{ + QByteArray utf8 = bundleId.toUtf8(); + char *cPath = IpaToolGetDownloadedFilePath(utf8.constData()); + if (!cPath) { + return {}; + } + QString path = QString::fromUtf8(cPath); + std::free(cPath); + return path; +} AppInstallDialog::AppInstallDialog(const QString &appName, const QString &description, @@ -246,41 +262,28 @@ void AppInstallDialog::onInstallClicked() } startDownloadProcess(m_bundleId, m_tempDir->path(), buttonIndex, false, - false); + false, true); - // FIXME USE SAFETHIS connect( this, &AppDownloadBaseDialog::downloadFinished, this, [this, selectedDevice](bool success) { if (success) { qDebug() << "Download finished, starting installation..."; - /* - FIXME: libipatool generates random id and appends that - to the downloaded IPA filename, so we need to search for - it. - */ - // Find the actual downloaded IPA file - QDir outDir(m_tempDir->path()); - QStringList filters; - filters << m_bundleId + "*.ipa"; - QStringList matches = - outDir.entryList(filters, QDir::Files, QDir::Time); - if (matches.isEmpty()) { + + QString ipaFile = ipaPathFromIpatool(m_bundleId); + if (ipaFile.isEmpty()) { m_statusLabel->setText("Download failed - IPA not found"); setLabelTextColor(m_statusLabel, Qt::red); QMessageBox::critical( this, "Error", - QString("Downloaded IPA not found in %1") - .arg(outDir.absolutePath())); + QString( + "Downloaded IPA path not reported by libipatool")); return; } - qDebug() << "Found downloaded IPA:" << matches.first(); - QString ipaFile = outDir.filePath(matches.first()); - performInstallation(ipaFile, matches.first(), selectedDevice); - } else { - m_statusLabel->setText("Download failed"); - setLabelTextColor(m_statusLabel, Qt::red); + QFileInfo fi(ipaFile); + qDebug() << "IPA:" << ipaFile; + performInstallation(ipaFile, fi.fileName(), selectedDevice); } }); }