Skip to content

Instantly share code, notes, and snippets.

@S1ReX
Created November 5, 2012 13:57
Show Gist options
  • Save S1ReX/4017301 to your computer and use it in GitHub Desktop.
Save S1ReX/4017301 to your computer and use it in GitHub Desktop.
static BOOL _enabled = YES;
%hook SBAssistantUserUtteranceController
- (BOOL)isCorrectable
{
if (_enabled)
return NO;
else
return %orig;
}
%end
static void noCorrectSettings() {
NSDictionary *prefrences = [[NSDictionary alloc] initWithContentsOfFile:@"/User/Library/Preferences/com.sirex.sirimod.plist"];
_enabled = (BOOL)[[prefrences objectForKey:@"noCorrect"] boolValue];
[prefrences release];
}
%hook SBAssistantBasicViewController
- (id)view
{
if (_enabled)
return nil;
else
return %orig;
}
%end
static void LoadSettings() {
NSDictionary *prefrences = [[NSDictionary alloc] initWithContentsOfFile:@"/User/Library/Preferences/com.sirex.sirimod.plist"];
_enabled = (BOOL)[[prefrences objectForKey:@"invisibleSiri"] boolValue];
[prefrences release];
}
static void SettingsChanged(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) {
LoadSettings();
}
%ctor {
LoadSettings();
CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, SettingsChanged, CFSTR("com.sirex.sirimod/updated"), NULL, CFNotificationSuspensionBehaviorCoalesce);
noCorrectSettings();
CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, SettingsChanged, CFSTR("com.sirex.sirimod/updated"), NULL, CFNotificationSuspensionBehaviorCoalesce);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment