1999-01-19 12:58:53 +00:00
|
|
|
/* Interface for <NSUserDefaults> for GNUStep
|
1996-07-15 18:42:52 +00:00
|
|
|
Copyright (C) 1995, 1996 Free Software Foundation, Inc.
|
|
|
|
|
1998-11-30 10:04:24 +00:00
|
|
|
Written by: Georg Tuparev, EMBL & Academia Naturalis,
|
1996-07-15 18:42:52 +00:00
|
|
|
Heidelberg, Germany
|
|
|
|
Tuparev@EMBL-Heidelberg.de
|
|
|
|
|
|
|
|
This file is part of the GNUstep Base Library.
|
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Library General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2 of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Library General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Library General Public
|
|
|
|
License along with this library; if not, write to the Free
|
1999-09-09 02:56:20 +00:00
|
|
|
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
|
1996-07-15 18:42:52 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __NSUserDefaults_h_OBJECTS_INCLUDE
|
|
|
|
#define __NSUserDefaults_h_OBJECTS_INCLUDE
|
|
|
|
|
|
|
|
#include <Foundation/NSObject.h>
|
|
|
|
#include <Foundation/NSString.h>
|
|
|
|
|
|
|
|
@class NSArray;
|
|
|
|
@class NSMutableArray;
|
|
|
|
@class NSDictionary;
|
|
|
|
@class NSMutableDictionary;
|
|
|
|
@class NSData;
|
1999-01-19 12:58:53 +00:00
|
|
|
@class NSTimer;
|
2001-11-07 18:10:28 +00:00
|
|
|
@class NSRecursiveLock;
|
2002-08-27 08:52:14 +00:00
|
|
|
@class NSDistributedLock;
|
1996-07-15 18:42:52 +00:00
|
|
|
|
|
|
|
/* Standard domains */
|
2000-06-14 04:03:56 +00:00
|
|
|
GS_EXPORT NSString* const NSArgumentDomain;
|
|
|
|
GS_EXPORT NSString* const NSGlobalDomain;
|
|
|
|
GS_EXPORT NSString* const NSRegistrationDomain;
|
1996-07-15 18:42:52 +00:00
|
|
|
|
|
|
|
/* Public notification */
|
2000-06-14 04:03:56 +00:00
|
|
|
GS_EXPORT NSString* const NSUserDefaultsDidChangeNotification;
|
1998-09-04 06:50:18 +00:00
|
|
|
/* Backwards compatibility */
|
1998-11-09 20:24:09 +00:00
|
|
|
#define NSUserDefaultsChanged NSUserDefaultsDidChangeNotification
|
1996-07-15 18:42:52 +00:00
|
|
|
|
|
|
|
/* Keys for language-dependent information */
|
2000-06-14 04:03:56 +00:00
|
|
|
GS_EXPORT NSString* const NSWeekDayNameArray;
|
|
|
|
GS_EXPORT NSString* const NSShortWeekDayNameArray;
|
|
|
|
GS_EXPORT NSString* const NSMonthNameArray;
|
|
|
|
GS_EXPORT NSString* const NSShortMonthNameArray;
|
|
|
|
GS_EXPORT NSString* const NSTimeFormatString;
|
|
|
|
GS_EXPORT NSString* const NSDateFormatString;
|
2000-10-27 15:54:35 +00:00
|
|
|
GS_EXPORT NSString* const NSShortDateFormatString;
|
2000-06-14 04:03:56 +00:00
|
|
|
GS_EXPORT NSString* const NSTimeDateFormatString;
|
|
|
|
GS_EXPORT NSString* const NSShortTimeDateFormatString;
|
|
|
|
GS_EXPORT NSString* const NSCurrencySymbol;
|
|
|
|
GS_EXPORT NSString* const NSDecimalSeparator;
|
|
|
|
GS_EXPORT NSString* const NSThousandsSeparator;
|
|
|
|
GS_EXPORT NSString* const NSInternationalCurrencyString;
|
|
|
|
GS_EXPORT NSString* const NSCurrencyString;
|
|
|
|
GS_EXPORT NSString* const NSDecimalDigits;
|
|
|
|
GS_EXPORT NSString* const NSAMPMDesignation;
|
1996-07-15 18:42:52 +00:00
|
|
|
|
1998-12-02 20:16:23 +00:00
|
|
|
#ifndef STRICT_OPENSTEP
|
2000-06-14 04:03:56 +00:00
|
|
|
GS_EXPORT NSString* const NSHourNameDesignations;
|
|
|
|
GS_EXPORT NSString* const NSYearMonthWeekDesignations;
|
|
|
|
GS_EXPORT NSString* const NSEarlierTimeDesignations;
|
|
|
|
GS_EXPORT NSString* const NSLaterTimeDesignations;
|
|
|
|
GS_EXPORT NSString* const NSThisDayDesignations;
|
|
|
|
GS_EXPORT NSString* const NSNextDayDesignations;
|
|
|
|
GS_EXPORT NSString* const NSNextNextDayDesignations;
|
|
|
|
GS_EXPORT NSString* const NSPriorDayDesignations;
|
|
|
|
GS_EXPORT NSString* const NSDateTimeOrdering;
|
2000-10-27 15:54:35 +00:00
|
|
|
|
|
|
|
GS_EXPORT NSString* const NSLanguageName;
|
|
|
|
GS_EXPORT NSString* const NSLanguageCode;
|
|
|
|
GS_EXPORT NSString* const NSFormalName;
|
|
|
|
#ifndef NO_GNUSTEP
|
|
|
|
GS_EXPORT NSString* const NSLocale;
|
|
|
|
#endif
|
1998-12-02 20:16:23 +00:00
|
|
|
#endif
|
1996-07-15 18:42:52 +00:00
|
|
|
|
1998-11-30 10:04:24 +00:00
|
|
|
/* General implementation notes:
|
1996-07-15 18:42:52 +00:00
|
|
|
|
|
|
|
OpenStep spec currently is either complete nor consitent. Therefor
|
|
|
|
we had to take several implementation decisions which make vary in
|
|
|
|
different OpenStep implementations.
|
|
|
|
|
1998-11-30 10:04:24 +00:00
|
|
|
- We add a new instance method initWithFile: as a designated
|
1996-07-15 18:42:52 +00:00
|
|
|
initialization method because it allows to create user defaults
|
|
|
|
database from a "default user" and also it will work for various
|
|
|
|
non-posix implementations.
|
|
|
|
|
|
|
|
- We add two new class methods for getting and setting a list of
|
1998-11-30 10:04:24 +00:00
|
|
|
user languages (userLanguages and setUserLanguages: ). They are
|
1996-07-15 18:42:52 +00:00
|
|
|
somehow equivalent to the NS3.x Application's systemLanguages
|
|
|
|
method.
|
|
|
|
|
|
|
|
- Definition of argument (command line parameters)
|
|
|
|
(-GSxxxx || --GSxxx) [value]
|
|
|
|
|
1998-11-30 10:04:24 +00:00
|
|
|
Note: As far as I know, there is nothing like home directory for
|
1996-07-15 18:42:52 +00:00
|
|
|
the M$ hell. God help the Win95/WinNT users of NSUserDefaults ;-)
|
|
|
|
|
1998-11-30 10:04:24 +00:00
|
|
|
To Do:
|
1996-07-15 18:42:52 +00:00
|
|
|
- polish & optimize;
|
|
|
|
- when tested, fix NSBundle (the system languages stuff);
|
1998-11-30 10:04:24 +00:00
|
|
|
- write docs : -(
|
1996-07-15 18:42:52 +00:00
|
|
|
*/
|
|
|
|
|
1998-11-30 10:04:24 +00:00
|
|
|
@interface NSUserDefaults: NSObject
|
1996-07-15 18:42:52 +00:00
|
|
|
{
|
|
|
|
@private
|
1999-09-16 07:21:34 +00:00
|
|
|
NSMutableArray *_searchList; // Current search list;
|
|
|
|
NSMutableDictionary *_persDomains; // Contains persistent defaults info;
|
|
|
|
NSMutableDictionary *_tempDomains; // Contains volatile defaults info;
|
|
|
|
NSMutableArray *_changedDomains; /* ..after first time that persistent
|
1998-11-30 10:04:24 +00:00
|
|
|
user defaults are changed */
|
1999-09-16 07:21:34 +00:00
|
|
|
NSDictionary *_dictionaryRep; // Cached dictionary representation
|
1999-10-05 10:04:12 +00:00
|
|
|
NSString *_defaultsDatabase;
|
1999-09-16 07:21:34 +00:00
|
|
|
NSDate *_lastSync;
|
2001-11-07 18:10:28 +00:00
|
|
|
NSRecursiveLock *_lock;
|
2002-08-27 08:52:14 +00:00
|
|
|
NSDistributedLock *_fileLock;
|
1996-07-15 18:42:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Getting the Shared Instance */
|
1998-11-30 10:04:24 +00:00
|
|
|
+ (NSUserDefaults*) standardUserDefaults;
|
2001-11-13 07:44:57 +00:00
|
|
|
#ifndef STRICT_OPENSTEP
|
1999-02-20 21:19:15 +00:00
|
|
|
/*
|
|
|
|
* Called by GSSetUserName() to get the defaults system to use the defaults
|
|
|
|
* of a new user.
|
|
|
|
*/
|
2001-11-13 07:44:57 +00:00
|
|
|
+ (void) resetStandardUserDefaults;
|
1999-02-20 21:19:15 +00:00
|
|
|
#endif
|
2002-01-02 06:50:30 +00:00
|
|
|
#ifndef STRICT_OPENSTEP
|
|
|
|
#ifndef STRICT_MACOS_X
|
1998-11-30 10:04:24 +00:00
|
|
|
+ (NSArray*) userLanguages;
|
|
|
|
+ (void) setUserLanguages: (NSArray*)languages;
|
2002-01-02 06:50:30 +00:00
|
|
|
#endif
|
|
|
|
#endif
|
1996-07-15 18:42:52 +00:00
|
|
|
|
|
|
|
/* Initializing the User Defaults */
|
1998-11-30 10:04:24 +00:00
|
|
|
- (id) init;
|
|
|
|
- (id) initWithUser: (NSString*)userName;
|
|
|
|
- (id) initWithContentsOfFile: (NSString*)path; // This is a new method
|
1996-07-15 18:42:52 +00:00
|
|
|
|
|
|
|
/* Getting and Setting a Default */
|
1998-11-30 10:04:24 +00:00
|
|
|
- (NSArray*) arrayForKey: (NSString*)defaultName;
|
|
|
|
- (BOOL) boolForKey: (NSString*)defaultName;
|
|
|
|
- (NSData*) dataForKey: (NSString*)defaultName;
|
|
|
|
- (NSDictionary*) dictionaryForKey: (NSString*)defaultName;
|
|
|
|
- (float) floatForKey: (NSString*)defaultName;
|
|
|
|
- (int) integerForKey: (NSString*)defaultName;
|
|
|
|
- (id) objectForKey: (NSString*)defaultName;
|
|
|
|
- (void) removeObjectForKey: (NSString*)defaultName;
|
|
|
|
- (void) setBool: (BOOL)value forKey: (NSString*)defaultName;
|
|
|
|
- (void) setFloat: (float)value forKey: (NSString*)defaultName;
|
|
|
|
- (void) setInteger: (int)value forKey: (NSString*)defaultName;
|
|
|
|
- (void) setObject: (id)value forKey: (NSString*)defaultName;
|
|
|
|
- (NSArray*) stringArrayForKey: (NSString*)defaultName;
|
|
|
|
- (NSString*) stringForKey: (NSString*)defaultName;
|
1996-07-15 18:42:52 +00:00
|
|
|
|
|
|
|
/* Returning the Search List */
|
1998-11-30 10:04:24 +00:00
|
|
|
- (NSMutableArray*) searchList;
|
2003-04-17 06:20:17 +00:00
|
|
|
- (void) setSearchList: (NSArray*)newList;
|
2004-06-29 10:31:05 +00:00
|
|
|
#ifndef STRICT_OPENSTEP
|
|
|
|
- (void) addSuiteNamed: (NSString*)aName;
|
|
|
|
- (void) removeSuiteNamed: (NSString*)aName;
|
|
|
|
#endif
|
1996-07-15 18:42:52 +00:00
|
|
|
|
|
|
|
/* Maintaining Persistent Domains */
|
1998-11-30 10:04:24 +00:00
|
|
|
- (NSDictionary*) persistentDomainForName: (NSString*)domainName;
|
|
|
|
- (NSArray*) persistentDomainNames;
|
|
|
|
- (void) removePersistentDomainForName: (NSString*)domainName;
|
|
|
|
- (void) setPersistentDomain: (NSDictionary*)domain
|
|
|
|
forName: (NSString*)domainName;
|
|
|
|
- (BOOL) synchronize;
|
1996-07-15 18:42:52 +00:00
|
|
|
|
|
|
|
/* Maintaining Volatile Domains */
|
1998-11-30 10:04:24 +00:00
|
|
|
- (void) removeVolatileDomainForName: (NSString*)domainName;
|
|
|
|
- (void) setVolatileDomain: (NSDictionary*)domain
|
|
|
|
forName: (NSString*)domainName;
|
|
|
|
- (NSDictionary*) volatileDomainForName: (NSString*)domainName;
|
|
|
|
- (NSArray*) volatileDomainNames;
|
1996-07-15 18:42:52 +00:00
|
|
|
|
|
|
|
/* Making Advanced Use of Defaults */
|
1998-11-30 10:04:24 +00:00
|
|
|
- (NSDictionary*) dictionaryRepresentation;
|
2001-12-17 14:31:42 +00:00
|
|
|
- (void) registerDefaults: (NSDictionary*)newVals;
|
1996-07-15 18:42:52 +00:00
|
|
|
@end
|
|
|
|
|
|
|
|
#endif /* __NSUserDefaults_h_OBJECTS_INCLUDE */
|