Skip to content

Commit

Permalink
Added Pangu to list of protected applications.
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanb93 committed Nov 10, 2014
1 parent 2bb73c4 commit eadad9e
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 10 deletions.
27 changes: 21 additions & 6 deletions CyDelete8.xm
Original file line number Diff line number Diff line change
Expand Up @@ -47,24 +47,37 @@ static void initTranslation() {
cyDelBundle = [NSBundle bundleWithPath:@"/Library/MobileSubstrate/DynamicLibraries/CyDelete8.bundle"];
}

static bool getProtectCydia() {
static bool getCFBool(CFStringRef key, bool defaultValue) {
//Sync the latest version of the preferences.
bool synced = CFPreferencesAppSynchronize(CFSTR("com.ryanburke.cydelete8"));
//If the sync failed, lets just default to protecting Cydia for safety.
if(!synced) return true;
if(!synced) return defaultValue;
//Create a boolean object to hold the success value from next function.
Boolean success;
//Get the value of the "CDProtectCydia" key from the preferences.
bool result = CFPreferencesGetAppBooleanValue(CFSTR("CDProtectCydia"), CFSTR("com.ryanburke.cydelete8"), &success);
//Get the value of the key from the preferences.
bool result = CFPreferencesGetAppBooleanValue(key, CFSTR("com.ryanburke.cydelete8"), &success);
//If the enabled key existed and we got the value okay.
if(success) {
//Return the value of the key.
return result;
}
//If for some reason we couldn't get the value lets just default to protecting Cydia for safety.
return true;
return defaultValue;
}

static bool getProtectCydia() {
return getCFBool(CFSTR("CDProtectCydia"), true);
}

static bool getProtectPangu() {
return getCFBool(CFSTR("CDProtectPangu"), true);
}

static bool getEnabled() {
return getCFBool(CFSTR("enabled"), true);
}


// Thanks _BigBoss_!
__attribute__((unused)) static int getFreeMemory() {
vm_size_t pageSize;
Expand Down Expand Up @@ -313,8 +326,10 @@ static void uninstallClickedForIcon(SBIcon *self) {
bool isApple = ([bundle hasPrefix:@"com.apple."] && ![bundle hasPrefix:@"com.apple.samplecode."]);
//If the application is Cydia and user has protected it.
bool isCydia = ([bundle isEqualToString:@"com.saurik.Cydia"] && getProtectCydia());
//If the application is Cydia and user has protected it.
bool isPangu = ([bundle isEqualToString:@"io.pangu.loader"] && getProtectPangu());
//If any of these match then we don't want to allow uninstall.
if(isApple || isCydia || getFreeMemory() < 20 ) {
if(isApple || isCydia || isPangu || !getEnabled() || getFreeMemory() < 20 ) {
return NO;
}
return YES;
Expand Down
41 changes: 37 additions & 4 deletions Cydelete8/Resources/Cydelete8.plist
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,24 @@
<dict>
<key>items</key>
<array>
<dict>
<key>cell</key>
<string>PSGroupCell</string>
<key>label</key>
<string>Settings</string>
</dict>
<dict>
<key>cell</key>
<string>PSSwitchCell</string>
<key>default</key>
<true/>
<key>defaults</key>
<string>com.ryanburke.cydelete8</string>
<key>key</key>
<string>enabled</string>
<key>label</key>
<string>Enable</string>
</dict>
<dict>
<key>cell</key>
<string>PSGroupCell</string>
Expand All @@ -28,13 +46,28 @@
<key>icon</key>
<string>Cydia.png</string>
</dict>
<dict>
<key>cell</key>
<string>PSSwitchCell</string>
<key>default</key>
<true/>
<key>defaults</key>
<string>com.ryanburke.cydelete8</string>
<key>key</key>
<string>CDProtectPangu</string>
<key>label</key>
<string>Pangu</string>
<key>icon</key>
<string>Pangu.png</string>
</dict>
<dict>
<key>cell</key>
<string>PSGroupCell</string>
<key>footerText</key>
<string>CyDelete8 © 2014 Ryan Burke
CyDelete © 2009-2011 Dustin L. Howett
Released under the GPLv3 Licence.
<string>
CyDelete8 © 2014 Ryan Burke
CyDelete © 2009-2011 Dustin L. Howett
Released under the GPLv3 Licence.
</string>
</dict>
<dict>
Expand All @@ -43,7 +76,7 @@
<key>cell</key>
<string>PSButtonCell</string>
<key>label</key>
<string>Support</string>
<string>DONATE</string>
</dict>
<dict>
<key>action</key>
Expand Down
Binary file added Cydelete8/Resources/Pangu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit eadad9e

Please sign in to comment.