diff options
author | Jay Freeman (saurik) <saurik@saurik.com> | 2011-02-18 17:56:24 -0800 |
---|---|---|
committer | Jay Freeman (saurik) <saurik@saurik.com> | 2011-02-18 17:56:24 -0800 |
commit | e5e703586bb55739784c7275b985860b13f6848c (patch) | |
tree | ed3dd309e5968c5fdf1888fb85f459255a998b16 | |
parent | 4ba8f30aea8b6c587ebb4d241a3324630c1496f1 (diff) |
Implement package hold (ignored) switch.
-rw-r--r-- | MobileCydia.mm | 41 |
1 files changed, 36 insertions, 5 deletions
diff --git a/MobileCydia.mm b/MobileCydia.mm index 133fbcf..c2a02e6 100644 --- a/MobileCydia.mm +++ b/MobileCydia.mm @@ -7620,8 +7620,43 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { [delegate_ updateData]; } +- (void) _updateIgnored { + const char *package([name_ UTF8String]); + bool on([ignoredSwitch_ isOn]); + + pid_t pid(ExecFork()); + if (pid == 0) { + FILE *dpkg(popen("dpkg --set-selections", "w")); + fwrite(package, strlen(package), 1, dpkg); + + if (on) + fwrite(" hold\n", 6, 1, dpkg); + else + fwrite(" install\n", 9, 1, dpkg); + + pclose(dpkg); + + exit(0); + _assert(false); + } + + _forever { + int status; + int result(waitpid(pid, &status, 0)); + + if (result != -1) { + _assert(result == pid); + break; + } + } +} + - (void) onIgnored:(id)control { - // TODO: set Held state - possibly call out to dpkg, etc. + NSInvocation *invocation([NSInvocation invocationWithMethodSignature:[self methodSignatureForSelector:@selector(_updateIgnored)]]); + [invocation setTarget:self]; + [invocation setSelector:@selector(_updateIgnored)]; + + [delegate_ reloadDataWithInvocation:invocation]; } - (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { @@ -7654,8 +7689,6 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { ignoredSwitch_ = [[UISwitch alloc] initWithFrame:CGRectMake(0, 0, 50, 20)]; [ignoredSwitch_ setAutoresizingMask:UIViewAutoresizingFlexibleLeftMargin]; [ignoredSwitch_ addTarget:self action:@selector(onIgnored:) forEvents:UIControlEventValueChanged]; - // Disable this switch, since it only reflects (not modifies) the ignored state. - [ignoredSwitch_ setUserInteractionEnabled:NO]; subscribedCell_ = [[UITableViewCell alloc] init]; [subscribedCell_ setText:UCLocalize("SHOW_ALL_CHANGES")]; @@ -7666,8 +7699,6 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { [ignoredCell_ setText:UCLocalize("IGNORE_UPGRADES")]; [ignoredCell_ setAccessoryView:ignoredSwitch_]; [ignoredCell_ setSelectionStyle:UITableViewCellSelectionStyleNone]; - // FIXME: Ignored state is not saved. - [ignoredCell_ setUserInteractionEnabled:NO]; } - (void) viewDidLoad { |