Skip to content

Commit

Permalink
Minor Bug Fixes (#19)
Browse files Browse the repository at this point in the history
- Adds proper confirmation for installing theme (original Enmity never had this)
- Adds data return for uninstalling plugins/themes so that it can be displayed in a toast (Enmity.js PR soon)
- Fixes Image Background randomly disappearing on TabsV1 due to the Image Subview Hook not using the correct index
- Returns a different response if the plugin/theme somehow got past the file extension check on the JS side (I suppose through the protocol) so that it can be displayed
- Uses an older version of Azule (the same one used to patch Enmity for 164) so that no $PWD is required in the file path, nor coreutils to be installed
  • Loading branch information
acquitelol authored Apr 14, 2023
1 parent 802ee60 commit 642da81
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 43 deletions.
34 changes: 16 additions & 18 deletions .github/workflows/stable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,36 +32,29 @@ jobs:
- name: Prepare Azule
run : |
git clone https://github.com/Al4ise/Azule ${{ github.workspace }}/Azule
cd Azule
git checkout 27c02b415cff15b1c131a0e95bcc2438023f86da
- name: Prepare Enmity Patcher
run : |
curl -L https://github.com/enmity-mod/patcher/releases/latest/download/patcher.mac-amd64 -o ${{ github.workspace }}/patcher
chmod +x patcher
- name: Prepare coreutils

run: brew install coreutils

- name: Patch Discord
run : |
${{ github.workspace }}/patcher
mkdir out
- name: Build package
- name: Retrieve version
id: version
run: echo "::set-output name=__ENMITY_VERSION::$(cat control | grep -E 'Version:(.*)' | awk '{ print $2 }')"

- name: Build deb
run: |
rm -f packages/*
gmake clean package FINALPACKAGE=1
mv $(find packages -name "*.deb" -print -quit) out/Enmity.deb
- name: Retrieve version
id: version
run: echo "::set-output name=EM_VERSION::$(cat control | grep -E 'Version:(.*)' | awk '{ print $2 }')"

- name: Create Enmity.ipa
run : |
${{ github.workspace }}/Azule/azule -i Enmity.ipa -o out -f $PWD/out/Enmity.deb
mv out/Enmity+Enmity.deb.ipa out/Enmity.ipa
- name: Build dev deb
run: |
rm -f packages/*
Expand All @@ -70,7 +63,7 @@ jobs:
gmake clean package FINALPACKAGE=1 DEVTOOLS=1
mv $(find packages -name "*.deb" -print -quit) out/Enmity.Development.deb
- name: Build regular rootless deb
- name: Build rootless deb
run: |
rm -f packages/*
echo $"$(sed 's/Name\:.*/Name\: Enmity (Rootless)/' control)" > control
Expand All @@ -86,16 +79,21 @@ jobs:
gmake clean package FINALPACKAGE=1 DEVTOOLS=1 THEOS_PACKAGE_SCHEME=rootless
mv $(find packages -name "*.deb" -print -quit) out/Enmity.Rootless.Development.deb
- name: Create Enmity.ipa
run : |
${{ github.workspace }}/Azule/azule -U -i Enmity.ipa -o out -f out/Enmity.deb
mv out/Enmity+Enmity.deb.ipa out/Enmity.ipa
- name: Create Enmity.Dev.ipa
run : |
${{ github.workspace }}/Azule/azule -i Enmity.ipa -o out -f $PWD/out/Enmity.Development.deb
${{ github.workspace }}/Azule/azule -U -i Enmity.ipa -o out -f out/Enmity.Development.deb
mv out/Enmity+Enmity.Development.deb.ipa out/Enmity.Development.ipa
- name: Create release
uses: marvinpinto/action-automatic-releases@latest
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
prerelease: false
automatic_release_tag: v${{ steps.version.outputs.EM_VERSION }}
title: "Enmity v${{ steps.version.outputs.EM_VERSION }}"
automatic_release_tag: v${{ steps.version.outputs.__ENMITY_VERSION }}
title: "Enmity v${{ steps.version.outputs.__ENMITY_VERSION }}"
files: out/*
2 changes: 1 addition & 1 deletion control
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: app.enmity
Name: Enmity
Version: 2.2.2
Version: 2.2.3
Architecture: iphoneos-arm
Description: The power of addons, all in your hand.
Maintainer: Rosie
Expand Down
95 changes: 75 additions & 20 deletions src/Commands.x
Original file line number Diff line number Diff line change
Expand Up @@ -75,21 +75,22 @@ NSDictionary* parseCommand(NSString *json) {
return [command copy];
}

void handleThemeInstall(NSString *uuid, NSURL *url, BOOL exists, NSString *themeName) {
BOOL handleThemeInstall(NSString *uuid, NSURL *url, BOOL exists, NSString *themeName) {
BOOL success = installTheme(url);
if (success) {
if ([uuid isEqualToString:@"-1"]) return;
if ([uuid isEqualToString:@"-1"]) return true;

sendResponse(createResponse(uuid, exists ? @"overridden_theme" : @"installed_theme"));
return;
return true;
}

if ([uuid isEqualToString:@"-1"]) {
alert([NSString stringWithFormat:@"An error happened while installing %@.", themeName]);
return;
return false;
}

sendResponse(createResponse(uuid, @"fucky_wucky"));
return false;
}

// Handle the command
Expand All @@ -106,12 +107,14 @@ void handleCommand(NSDictionary *command) {
if ([name isEqualToString:@"install-plugin"]) {
NSURL *url = [NSURL URLWithString:params[0]];
if (!url || ![[url pathExtension] isEqualToString:@"js"]) {
sendResponse(createResponse(uuid, @"invalid_plugin"));
return;
}

NSString *pluginName = getPluginName(url);
NSString *title = [[NSString alloc] init];
NSString *message = [[NSString alloc] init];

if (checkPlugin(pluginName)) {
title = @"Plugin already exists";
message = [NSString stringWithFormat:@"Are you sure you want to overwrite %@?", pluginName];
Expand Down Expand Up @@ -150,58 +153,110 @@ void handleCommand(NSDictionary *command) {

BOOL exists = checkPlugin(pluginName);
if (!exists) {
sendResponse(createResponse(uuid, [NSString stringWithFormat:@"**%@** isn't currently installed.", pluginName]));
if ([uuid isEqualToString:@"-1"]) {
alert([NSString stringWithFormat:@"**%@** isn't currently installed.", pluginName]);
return;
}

sendResponse(createResponse(uuid, @"fucky_wucky"));
return;
}

confirm(@"Uninstall plugin", [NSString stringWithFormat:@"Are you sure you want to uninstall %@?", pluginName], ^() {
BOOL success = deletePlugin(pluginName);
if (success) {
sendResponse(createResponse(uuid, [NSString stringWithFormat:@"**%@** has been removed.", pluginName]));
if ([uuid isEqualToString:@"-1"]) {
alert([NSString stringWithFormat:@"**%@** has been removed.", pluginName]);
return;
}

sendResponse(createResponse(uuid, @"uninstalled_plugin"));
return;
}

sendResponse(createResponse(uuid, [NSString stringWithFormat:@"An error happened while removed *%@*.", pluginName]));
if ([uuid isEqualToString:@"-1"]) {
alert([NSString stringWithFormat:@"An error happened while removing *%@*.", pluginName]);
return;
}

sendResponse(createResponse(uuid, @"fucky_wucky"));
});
}

if ([name isEqualToString:@"install-theme"]) {
NSURL *url = [NSURL URLWithString:params[0]];
if (!url || ![[url pathExtension] isEqualToString:@"json"]) {
sendResponse(createResponse(uuid, @"invalid_theme"));
return;
}

NSString *themeName = getThemeName(url);
BOOL exists = checkTheme(themeName);

if (exists) {
id title = @"Theme already exists";
id description = [NSString stringWithFormat:@"Are you sure you want to overwrite %@?", themeName];
confirm(title, description, ^() {
handleThemeInstall(uuid, url, exists, themeName);
});
} else {
handleThemeInstall(uuid, url, exists, themeName);
}
confirm(@"Install theme", [NSString stringWithFormat:@"Are you sure you want to install %@?", themeName], ^() {
__block BOOL success;

if (exists) {
id title = @"Theme already exists";
id description = [NSString stringWithFormat:@"Are you sure you want to overwrite %@?", themeName];
confirm(title, description, ^() {
success = handleThemeInstall(uuid, url, exists, themeName);
});
} else {
success = handleThemeInstall(uuid, url, exists, themeName);
}

if (success) {
if ([uuid isEqualToString:@"-1"]) {
alert([NSString stringWithFormat:@"%@ has been installed.", themeName]);
return;
}

sendResponse(createResponse(uuid, exists ? @"overridden_theme" : @"installed_theme"));
return;
}

if ([uuid isEqualToString:@"-1"]) {
alert([NSString stringWithFormat:@"An error happened while installing *%@*.", themeName]);
return;
}

sendResponse(createResponse(uuid, @"fucky_wucky"));
});
}

if ([name isEqualToString:@"uninstall-theme"]) {
NSString *themeName = params[0];

BOOL exists = checkTheme(themeName);
if (!exists) {
sendResponse(createResponse(uuid, [NSString stringWithFormat:@"**%@** isn't currently installed.", themeName]));
if ([uuid isEqualToString:@"-1"]) {
alert([NSString stringWithFormat:@"*%@* isn't currently installed.", themeName]);
return;
}

sendResponse(createResponse(uuid, @"fucky_wucky"));
return;
}

confirm(@"Uninstall theme", [NSString stringWithFormat:@"Are you sure you want to uninstall %@?", themeName], ^() {
BOOL success = uninstallTheme(params[0]);
BOOL success = uninstallTheme(themeName);
if (success) {
sendResponse(createResponse(uuid, @"Theme has been uninstalled."));
if ([uuid isEqualToString:@"-1"]) {
alert([NSString stringWithFormat:@"*%@* has been uninstalled.", themeName]);
return;
}

sendResponse(createResponse(uuid, @"uninstalled_theme"));
return;
}

if ([uuid isEqualToString:@"-1"]) {
alert([NSString stringWithFormat:@"An error happened while uninstalling *%@*.", themeName]);
return;
}

sendResponse(createResponse(uuid, @"An error happened while uninstalling the theme."));
sendResponse(createResponse(uuid, @"fucky_wucky"));
});
}

Expand Down
2 changes: 1 addition & 1 deletion src/Enmity.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#define ENMITY_PATH [NSString stringWithFormat:@"%@/%@", NSHomeDirectory(), @"Documents/Enmity.js"]
#define ENMITY_SOURCE [NSURL URLWithString:@"enmity"]
#define VERSION @"2.2.2"
#define VERSION @"2.2.3"
#define TYPE @"Regular"

// Disable logs in release mode
Expand Down
4 changes: 1 addition & 3 deletions src/Theme.xi
Original file line number Diff line number Diff line change
Expand Up @@ -488,9 +488,7 @@ HOOK_TABLE_CELL(DCDLoadingTableViewCell)
// 5. image is not positioned properly some of the time
//
// once i figure out how to properly do this on the js side (preferrably not patching View.render too) i will remove this implementation and do the proper js implementation.
UIView *subview = [self.subviews count] >= 3
? self.subviews[2]
: self.subviews[0];
UIView *subview = self.subviews[[self.subviews count] - 3];

if (subview && [subview isKindOfClass:[UIImageView class]]) {
return NSLog(@"Image is a UIImageView!: %@", (id)[NSNumber numberWithBool:[subview isKindOfClass:[UIImageView class]] ]);
Expand Down

0 comments on commit 642da81

Please sign in to comment.