Skip to content

Commit

Permalink
Fix the new #29 issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Dadoum committed Apr 5, 2024
1 parent 7f58c33 commit e45deb2
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 36 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build-qt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
1 change: 1 addition & 0 deletions dub.selections.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
Expand Down
1 change: 0 additions & 1 deletion frontends/gtk/source/ui/dependencieswindow.d
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import std.format;

import slf4d;


import glib.Timeout;

import gtk.Box;
Expand Down
2 changes: 1 addition & 1 deletion frontends/qt/resources/mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="sideloadTab_3">
<widget class="QWidget" name="sideloadTab">
<attribute name="title">
<string>Sideload</string>
</attribute>
Expand Down
4 changes: 2 additions & 2 deletions frontends/qt/source/main.d
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
45 changes: 34 additions & 11 deletions frontends/qt/source/ui/mainwindow.d
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
);

Expand Down Expand Up @@ -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); }

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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));
}
}
}
17 changes: 2 additions & 15 deletions source/sideload/package.d
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ public import sideload.bundle;
import sideload.certificateidentity;
import sideload.sign;

import utils;

void sideloadFull(
string configurationPath,
iDevice device,
Expand Down Expand Up @@ -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);
Expand Down
14 changes: 11 additions & 3 deletions source/sideload/sign.d
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import sideload.bundle;
import sideload.certificateidentity;
import sideload.macho;

import utils;

Tuple!(PlistDict, PlistDict) sign(
Bundle bundle,
CertificateIdentity identity,
Expand Down Expand Up @@ -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);
Expand All @@ -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;
}
Expand Down
15 changes: 15 additions & 0 deletions source/utils.d
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

0 comments on commit e45deb2

Please sign in to comment.