1 /* xscreensaver, Copyright (c) 2006-2013 Jamie Zawinski <jwz@jwz.org> 2 * 3 * Permission to use, copy, modify, distribute, and sell this software and its 4 * documentation for any purpose is hereby granted without fee, provided that 5 * the above copyright notice appear in all copies and that both that 6 * copyright notice and this permission notice appear in supporting 7 * documentation. No representations are made about the suitability of this 8 * software for any purpose. It is provided "as is" without express or 9 * implied warranty. 10 */ 11 12 /* This implements the substrate of the xscreensaver preferences code: 13 It does this by writing defaults to, and reading values from, the 14 NSUserDefaultsController (and ScreenSaverDefaults/NSUserDefaults) 15 and thereby reading the preferences that may have been edited by 16 the UI (XScreenSaverConfigSheet). 17 */ 18 19 #ifdef USE_IPHONE 20 # import <Foundation/Foundation.h> 21 # import <UIKit/UIKit.h> 22 # define NSUserDefaultsController NSUserDefaults 23 #else 24 # import <Cocoa/Cocoa.h> 25 #endif 26 27 28 #import "jwxyz.h" 29 30 @interface PrefsReader : NSObject 31 { 32 NSString *saver_name; 33 34 NSUserDefaults *userDefaults; // this is actually a 'ScreenSaverDefaults' 35 NSUserDefaultsController *userDefaultsController; 36 37 NSUserDefaults *globalDefaults; // for prefs shared by all xscreensavers. 38 NSUserDefaultsController *globalDefaultsController; 39 40 NSDictionary *defaultOptions; // Hardcoded defaults before any changes. 41 } 42 43 - (id) initWithName: (NSString *) name 44 xrmKeys: (const XrmOptionDescRec *) opts 45 defaults: (const char * const *) defs; 46 47 - (NSUserDefaultsController *) userDefaultsController; 48 - (NSUserDefaultsController *) globalDefaultsController; 49 - (NSDictionary *) defaultOptions; 50 51 - (char *) getStringResource: (const char *) name; 52 - (double) getFloatResource: (const char *) name; 53 - (int) getIntegerResource: (const char *) name; 54 - (BOOL) getBooleanResource: (const char *) name; 55 56 @end 57