]> git.saurik.com Git - veency.git/commitdiff
Port settings to CFPreferences{Get,Copy}App*Value.
authorJay Freeman (saurik) <saurik@saurik.com>
Sun, 9 Nov 2014 20:46:25 +0000 (12:46 -0800)
committerJay Freeman (saurik) <saurik@saurik.com>
Sun, 9 Nov 2014 20:46:35 +0000 (12:46 -0800)
Tweak.mm

index a944f096b55b98217ce909a2ef9a86784f568ce4..31f7925d9d779c503eca82fd6e345e37a3e04dd8 100644 (file)
--- 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<rfbSecurityHandler *>([handler pointerValue]));
@@ -406,16 +404,19 @@ static void VNCSettings() {
         if (screen_ == NULL)
             return;
 
-        [reinterpret_cast<NSString *>(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) {