From e45deb26844f027a370344fd763a9ce739d121b6 Mon Sep 17 00:00:00 2001 From: Dadoum Date: Sat, 6 Apr 2024 01:09:16 +0200 Subject: [PATCH] Fix the new #29 issue --- .github/workflows/build-qt.yml | 6 +-- dub.selections.json | 1 + frontends/gtk/source/ui/dependencieswindow.d | 1 - frontends/qt/resources/mainwindow.ui | 2 +- frontends/qt/source/main.d | 4 +- frontends/qt/source/ui/mainwindow.d | 45 +++++++++++++++----- source/sideload/package.d | 17 +------- source/sideload/sign.d | 14 ++++-- source/utils.d | 15 +++++++ 9 files changed, 69 insertions(+), 36 deletions(-) diff --git a/.github/workflows/build-qt.yml b/.github/workflows/build-qt.yml index bc362d4..da89715 100644 --- a/.github/workflows/build-qt.yml +++ b/.github/workflows/build-qt.yml @@ -136,7 +136,7 @@ jobs: - uses: actions/upload-artifact@v3 with: - name: sideloader-macOS-x86_64 + name: sideloader-qt-macOS-x86_64 path: | ${{github.workspace}}/Sideloader-qt.app.tgz @@ -236,7 +236,7 @@ jobs: - uses: actions/upload-artifact@v3 with: - name: sideloader-macOS-arm64 + name: sideloader-qt-macOS-arm64 path: | ${{github.workspace}}/Sideloader-qt.app.tgz @@ -288,6 +288,6 @@ jobs: - uses: actions/upload-artifact@v3 with: - name: sideloader-windows-x86_64 + name: sideloader-qt-windows-x86_64 path: | ${{github.workspace}}/sideloader-qt-windows.zip diff --git a/dub.selections.json b/dub.selections.json index 2ef5257..917037e 100644 --- a/dub.selections.json +++ b/dub.selections.json @@ -15,6 +15,7 @@ "concurrency": "5.0.4", "dfl": {"version":"224d9348286620c8ea4854690a09e7380d6f5b2f","repository":"git+https://github.com/Dadoum/dfl.git"}, "dlangui": "0.10.4", + "dqt": {"version":"6a44b55f3a3691da930cb9eefe2a745afe1b764d","repository":"git+https://github.com/tim-dlang/dqt.git"}, "dsfml": "2.1.1", "dxml": "0.4.4", "dynamic-loader": {"version":"65a8b8b8a6d44d47e63bddc985268592ecf47764","repository":"git+https://github.com/Dadoum/dynamicloader.git"}, diff --git a/frontends/gtk/source/ui/dependencieswindow.d b/frontends/gtk/source/ui/dependencieswindow.d index a3214f1..cd712b1 100644 --- a/frontends/gtk/source/ui/dependencieswindow.d +++ b/frontends/gtk/source/ui/dependencieswindow.d @@ -6,7 +6,6 @@ import std.format; import slf4d; - import glib.Timeout; import gtk.Box; diff --git a/frontends/qt/resources/mainwindow.ui b/frontends/qt/resources/mainwindow.ui index 7ded83d..2d14f91 100644 --- a/frontends/qt/resources/mainwindow.ui +++ b/frontends/qt/resources/mainwindow.ui @@ -181,7 +181,7 @@ - + Sideload diff --git a/frontends/qt/source/main.d b/frontends/qt/source/main.d index ddee935..7903331 100644 --- a/frontends/qt/source/main.d +++ b/frontends/qt/source/main.d @@ -57,12 +57,12 @@ int main(string[] args) { .orDefault("~/.config") .expandTilde(); } - configurationPath = configurationPath.buildPath(applicationName ~ "Qt"); + configurationPath = configurationPath.buildPath(applicationName); auto log = getLogger(); log.info(versionStr); - + log.infoF!"Configuration path: %s"(configurationPath); scope qtApp = new QApplication(Runtime.cArgs.argc, Runtime.cArgs.argv); DependenciesWindow.ensureDeps(configurationPath, (device, adi) { auto w = new MainWindow(configurationPath, device, adi); diff --git a/frontends/qt/source/ui/mainwindow.d b/frontends/qt/source/ui/mainwindow.d index 00749e1..16198c1 100644 --- a/frontends/qt/source/ui/mainwindow.d +++ b/frontends/qt/source/ui/mainwindow.d @@ -16,12 +16,14 @@ import provision; import qt.config; import qt.core.coreevent; +import qt.core.namespace; import qt.core.object; import qt.core.objectdefs; import qt.core.string; import qt.core.thread; import qt.core.translator; import qt.core.variant; +import qt.gui.cursor; import qt.helpers; import qt.widgets.action; import qt.widgets.combobox; @@ -76,18 +78,27 @@ class MainWindow: QMainWindow { *cpp_new!QString(format!rawAboutText(versionStr, "Qt")) ) ); + QObject.connect(this.signal!"sideloadProcedureTriggered", this.slot!"setSideloadTabEnabled"); QObject.connect( ui.selectIpaButton.signal!"clicked", delegate() { - QString filename = - QFileDialog.getOpenFileName( - this, - *cpp_new!QString("Open application"), - globalInitVar!QString, - *cpp_new!QString("iOS application bundle (*.ipa)") - ); - ui.ipaLine.setText(filename); - checkApplication(); + QString filename = QFileDialog.getOpenFileName( + this, + *cpp_new!QString("Open application"), + globalInitVar!QString, + *cpp_new!QString("iOS application bundle (*.ipa)") + ); + + if (!filename.isNull() && !filename.isEmpty()) { + ui.ipaLine.setText(filename); + checkApplication(); + } + } + ); + QObject.connect(ui.installButton.signal!"clicked", + delegate() { + log.info("Installing..."); + this.sideloadProcedureTriggered(false); } ); @@ -115,6 +126,7 @@ class MainWindow: QMainWindow { // ui.tabWidget.setVisible(false); } + @QSignal final void sideloadProcedureTriggered(bool isSideloadTabEnabled) { mixin(Q_SIGNAL_IMPL_D); } @QSignal final void deviceAdded(ref const(QString) udid) { mixin(Q_SIGNAL_IMPL_D); } @QSignal final void deviceRemoved(ref const(QString) udid) { mixin(Q_SIGNAL_IMPL_D); } @@ -235,7 +247,8 @@ class MainWindow: QMainWindow { ui.additionalToolsLayout.addWidget(button); } - // ui.tabWidget.setCurrentIndex(0); + +<<<<<<< Updated upstream // ui.tabWidget.setCurrentIndex(0); ui.stackedWidget.setCurrentIndex(1); } catch (iMobileDeviceException!lockdownd_error_t ex) { lockdowndClient = null; @@ -295,9 +308,19 @@ class MainWindow: QMainWindow { setErrorLabel(""); ui.bundleInfos.setVisible(true); ui.installButton.setEnabled(true); - } catch (InvalidBundleException ex) { + } catch (Exception ex) { log.infoF!"%s"(ex); setErrorLabel(ex.msg); } } + + @QSlot + void setSideloadTabEnabled(bool enabled) { + ui.sideloadTab.setEnabled(enabled); + if (enabled) { + ui.sideloadTab.unsetCursor(); + } else { + ui.sideloadTab.setCursor(*cpp_new!QCursor(CursorShape.WaitCursor)); + } + } } diff --git a/source/sideload/package.d b/source/sideload/package.d index f5cad61..6fb8448 100644 --- a/source/sideload/package.d +++ b/source/sideload/package.d @@ -22,6 +22,8 @@ public import sideload.bundle; import sideload.certificateidentity; import sideload.sign; +import utils; + void sideloadFull( string configurationPath, iDevice device, @@ -230,21 +232,6 @@ void sideloadFull( progressCallback(1.0, "Done!"); } -pragma(inline, true) -private string toForwardSlashes(string s) { - version (Windows) { - char[] str = s.dup; - foreach (ref c; str) { - if (c == '\\') { - c = '/'; - } - } - return cast(string) str; - } else { - return s; - } -} - class NoAppIdRemainingException: Exception { this(DateTime minExpirationDate, string file = __FILE__, int line = __LINE__) { super(format!"Cannot make any more app ID, you have to wait until %s to get a new app ID"(minExpirationDate.toSimpleString()), file, line); diff --git a/source/sideload/sign.d b/source/sideload/sign.d index 2dce45c..1ef9e1f 100644 --- a/source/sideload/sign.d +++ b/source/sideload/sign.d @@ -26,6 +26,8 @@ import sideload.bundle; import sideload.certificateidentity; import sideload.macho; +import utils; + Tuple!(PlistDict, PlistDict) sign( Bundle bundle, CertificateIdentity identity, @@ -167,6 +169,7 @@ Tuple!(PlistDict, PlistDict) sign( auto bundleFiles = file.dirEntries(bundleFolder, file.SpanMode.breadth); // double fileStepSize = stepSize / bundleFiles.length; TODO + // TODO re-use the original CodeResources if it already existed. if (bundleFolder[$ - 1] == '/' || bundleFolder[$ - 1] == '\\') bundleFolder.length -= 1; foreach(idx, absolutePath; parallel(bundleFiles)) { // scope(exit) addProgress(fileStepSize); @@ -177,10 +180,15 @@ Tuple!(PlistDict, PlistDict) sign( enum frameworksDir = "Frameworks/"; enum plugInsDir = "PlugIns/"; - if (!file.isFile(absolutePath) + if ( + // if it's a folder don't sign it + !file.isFile(absolutePath) + // if it's the executable skip it (it will be modified in the next step) || relativePath == executable - || (relativePath.startsWith(frameworksDir) && relativePath[frameworksDir.length..$].canFind('/')) - || (relativePath.startsWith(plugInsDir) && relativePath[plugInsDir.length..$].canFind('/')) + // if it's a file from a framework folder, skip it as it is processed by some other thread. + || (relativePath.startsWith(frameworksDir) && relativePath[frameworksDir.length..$].toForwardSlashes().canFind('/')) + // if it's a file from a plugins folder, skip it as it is processed by some other thread. + || (relativePath.startsWith(plugInsDir) && relativePath[plugInsDir.length..$].toForwardSlashes().canFind('/')) ) { continue; } diff --git a/source/utils.d b/source/utils.d index 185c6d8..db1a26c 100644 --- a/source/utils.d +++ b/source/utils.d @@ -56,3 +56,18 @@ auto c(alias U)() { return new Delegate!U().internalExpand; } + +pragma(inline, true) +private string toForwardSlashes(string s) { + version (Windows) { + char[] str = s.dup; + foreach (ref c; str) { + if (c == '\\') { + c = '/'; + } + } + return cast(string) str; + } else { + return s; + } +}