From ce0ee502e12d16434979728495db4909f0c8e0d6 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Sun, 9 Nov 2014 12:46:25 -0800 Subject: [PATCH] Port settings to CFPreferences{Get,Copy}App*Value. --- Tweak.mm | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/Tweak.mm b/Tweak.mm index a944f09..31f7925 100644 --- a/Tweak.mm +++ b/Tweak.mm @@ -394,8 +394,6 @@ static void FixRecord(GSEventRecord *record) { } static void VNCSettings() { - NSDictionary *settings([NSDictionary dictionaryWithContentsOfFile:[NSString stringWithFormat:@"%@/Library/Preferences/com.saurik.Veency.plist", NSHomeDirectory()]]); - @synchronized (lock_) { for (NSValue *handler in handlers_) rfbUnregisterSecurityHandler(reinterpret_cast([handler pointerValue])); @@ -406,16 +404,19 @@ static void VNCSettings() { if (screen_ == NULL) return; - [reinterpret_cast(screen_->authPasswdData) release]; + [(NSString *) screen_->authPasswdData release]; screen_->authPasswdData = NULL; - if (settings != nil) - if (NSString *password = [settings objectForKey:@"Password"]) - if ([password length] != 0) - screen_->authPasswdData = [password retain]; + if (CFStringRef password = (CFStringRef) CFPreferencesCopyAppValue(CFSTR("Password"), CFSTR("com.saurik.Veency"))) + if (CFStringGetLength(password) == 0) + CFRelease(password); + else + screen_->authPasswdData = (void *) password; - NSNumber *cursor = [settings objectForKey:@"ShowCursor"]; - cursor_ = cursor == nil ? true : [cursor boolValue]; + Boolean valid; + cursor_ = CFPreferencesGetAppBooleanValue(CFSTR("ShowCursor"), CFSTR("com.saurik.Veency"), &valid); + if (!valid) + cursor_ = true; if (clients_ != 0) AshikaseSetEnabled(cursor_, true); @@ -922,10 +923,10 @@ static void VNCEnabled() { [lock_ lock]; - bool enabled(true); - if (NSDictionary *settings = [NSDictionary dictionaryWithContentsOfFile:[NSString stringWithFormat:@"%@/Library/Preferences/com.saurik.Veency.plist", NSHomeDirectory()]]) - if (NSNumber *number = [settings objectForKey:@"Enabled"]) - enabled = [number boolValue]; + Boolean valid; + bool enabled(CFPreferencesGetAppBooleanValue(CFSTR("Enabled"), CFSTR("com.saurik.Veency"), &valid)); + if (!valid) + enabled = true; if (enabled != running_) if (enabled) { -- 2.47.2