You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

prpRootListController.m 1.4KB

6 jaren geleden
6 jaren geleden
6 jaren geleden
123456789101112131415161718192021222324252627282930313233
  1. #import <Preferences/PSSpecifier.h>
  2. #include "prpRootListController.h"
  3. @implementation prpRootListController
  4. - (id)readPreferenceValue:(PSSpecifier*)specifier {
  5. NSString *path = [NSString stringWithFormat:@"/var/mobile/Library/Preferences/%@.plist", specifier.properties[@"defaults"]];
  6. NSMutableDictionary *settings = [NSMutableDictionary dictionary];
  7. [settings addEntriesFromDictionary:[NSDictionary dictionaryWithContentsOfFile:path]];
  8. return (settings[specifier.properties[@"key"]]) ?: specifier.properties[@"default"];
  9. }
  10. - (void)setPreferenceValue:(id)value specifier:(PSSpecifier*)specifier {
  11. NSString *path = [NSString stringWithFormat:@"/var/mobile/Library/Preferences/%@.plist", specifier.properties[@"defaults"]];
  12. NSMutableDictionary *settings = [NSMutableDictionary dictionary];
  13. [settings addEntriesFromDictionary:[NSDictionary dictionaryWithContentsOfFile:path]];
  14. [settings setObject:value forKey:specifier.properties[@"key"]];
  15. [settings writeToFile:path atomically:YES];
  16. CFStringRef notificationName = (CFStringRef)specifier.properties[@"PostNotification"];
  17. if (notificationName) {
  18. CFNotificationCenterPostNotification(CFNotificationCenterGetDarwinNotifyCenter(), notificationName, NULL, NULL, YES);
  19. }
  20. }
  21. - (NSArray *)specifiers {
  22. if (!_specifiers) {
  23. _specifiers = [[self loadSpecifiersFromPlistName:@"Root" target:self] retain];
  24. }
  25. return _specifiers;
  26. }
  27. @end