Skip to content

Commit

Permalink
When Activator is uninstalled, prompt the user to respring.
Browse files Browse the repository at this point in the history
- Eventually this should work for any application that depends on Cydia Substrate.
  • Loading branch information
ryanb93 committed Nov 13, 2014
1 parent c0759a2 commit 7881801
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion CyDelete.xm
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ static NSOperationQueue *uninstallQueue;
}
@end

@interface CDUninstallDpkgOperation : CDUninstallOperation {
@interface CDUninstallDpkgOperation : CDUninstallOperation<UIAlertViewDelegate> {
NSString *_package;
}
@property (nonatomic, retain) NSString *package;
Expand Down Expand Up @@ -222,11 +222,28 @@ static id ownerForSBApplication(SBApplication *application) {
[delView show];
}

-(void)displayRespring {
NSString *body = [NSString stringWithFormat:CDLocalizedString(@"PACKAGE_FINISH_BODY"), _package, @"respring"];
UIAlertView *respring = [[UIAlertView alloc] initWithTitle:CDLocalizedString(@"PACKAGE_FINISH_RESTART") message:body delegate:self cancelButtonTitle:@"Okay" otherButtonTitles:nil];
respring.tag = 100;
[respring show];
}

- (void)main {
NSString *command = [NSString stringWithFormat:@"/usr/libexec/cydelete/setuid /usr/libexec/cydelete/uninstall_dpkg.sh %@", _package];
NSString *output = outputForShellCommand(command);
if(!output) [self performSelectorOnMainThread:@selector(displayError) withObject:nil waitUntilDone:NO];
[self completeOperation];
//Horrible code - need a way to detect if an application needs a respring after uninstall. ("apt-cache depends pkgname" contains mobilesubstrate?)
if([_package isEqualToString:@"libactivator"]) {
[self performSelectorOnMainThread:@selector(displayRespring) withObject:nil waitUntilDone:NO];
}
}

-(void) alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
if (alertView.tag == 100) {
outputForShellCommand(@"killall -9 SpringBoard");
}
}

@end
Expand Down

0 comments on commit 7881801

Please sign in to comment.