]> err.no Git - sope/blob - sope-appserver/NGObjWeb/WOApplication+defaults.m
bugfix, bumped dyld versions
[sope] / sope-appserver / NGObjWeb / WOApplication+defaults.m
1 /*
2   Copyright (C) 2000-2005 SKYRIX Software AG
3
4   This file is part of SOPE.
5
6   SOPE is free software; you can redistribute it and/or modify it under
7   the terms of the GNU Lesser General Public License as published by the
8   Free Software Foundation; either version 2, or (at your option) any
9   later version.
10
11   SOPE is distributed in the hope that it will be useful, but WITHOUT ANY
12   WARRANTY; without even the implied warranty of MERCHANTABILITY or
13   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
14   License for more details.
15
16   You should have received a copy of the GNU Lesser General Public
17   License along with SOPE; see the file COPYING.  If not, write to the
18   Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
19   02111-1307, USA.
20 */
21
22 #include <NGObjWeb/WOApplication.h>
23 #include "common.h"
24
25 @interface WOApplication(DefaultsPrivates)
26 + (NSUserDefaults *)userDefaults;
27 @end
28
29 @implementation WOApplication(Defaults)
30
31 static NSString *ck = nil;
32 static NSString *dk = nil;
33
34 + (void)setComponentRequestHandlerKey:(NSString *)_key {
35   [[self userDefaults]
36          setObject:_key
37          forKey:@"WOComponentRequestHandlerKey"];
38   [ck release]; ck = nil;
39 }
40 + (NSString *)componentRequestHandlerKey {
41   if (ck == nil)
42     ck = [[[self userDefaults] stringForKey:@"WOComponentRequestHandlerKey"]
43            copy];
44   return ck;
45 }
46
47 + (void)setDirectActionRequestHandlerKey:(NSString *)_key {
48   [[self userDefaults]
49          setObject:_key
50          forKey:@"WODirectActionRequestHandlerKey"];
51   [dk release]; dk = nil;
52 }
53 + (NSString *)directActionRequestHandlerKey {
54   if (dk == nil) {
55     dk = [[[self userDefaults] 
56       stringForKey:@"WODirectActionRequestHandlerKey"] copy];
57   }
58   return dk;
59 }
60
61 + (void)setResourceRequestHandlerKey:(NSString *)_key {
62   [[self userDefaults] setObject:_key forKey:@"WOResourceRequestHandlerKey"];
63 }
64 + (NSString *)resourceRequestHandlerKey {
65   return [[self userDefaults] stringForKey:@"WOResourceRequestHandlerKey"];
66 }
67
68 /* WODefaultSessionTimeOut */
69
70 + (void)setSessionTimeOut:(NSNumber *)_timeOut {
71   [[self userDefaults] setObject:_timeOut forKey:@"WODefaultSessionTimeOut"];
72 }
73
74 + (NSNumber *)sessionTimeOut {
75   NSUserDefaults *ud;
76   id o;
77
78   ud = [self userDefaults];
79   // Note: the second check is *intended* (Timeout vs TimeOut), it is
80   //       required for compatibility but should be phased out in the
81   //       long run. I don't know the proper default-name out of my
82   //       head (needs to be checked)
83   o  = [ud objectForKey:@"WODefaultSessionTimeout"];
84   if (o == nil) o = [ud objectForKey:@"WODefaultSessionTimeOut"];
85   return [NSNumber numberWithInt:[o intValue]];
86 }
87
88 /* WOCachingEnabled */
89
90 + (BOOL)isCachingEnabled {
91   return [[[self userDefaults]
92                  objectForKey:@"WOCachingEnabled"]
93                  boolValue];
94 }
95
96 /* WODebuggingEnabled */
97
98 + (BOOL)isDebuggingEnabled {
99   return [[[self userDefaults]
100                  objectForKey:@"WODebuggingEnabled"]
101                  boolValue];
102 }
103
104 /* WOCompatibility */
105
106 static BOOL directConnectEnabled = YES;
107
108 + (void)setDirectConnectEnabled:(BOOL)_flag {
109   directConnectEnabled = _flag;
110 }
111 + (BOOL)isDirectConnectEnabled {
112   return directConnectEnabled;
113 }
114
115 + (void)setCGIAdaptorURL:(NSString *)_url {
116   [[self userDefaults] setObject:_url forKey:@"WOCGIAdaptorURL"];
117 }
118 + (NSString *)cgiAdaptorURL {
119   return [[self userDefaults] stringForKey:@"WOCGIAdaptorURL"];
120 }
121
122 /* WOAutoOpenInBrowser */
123
124 + (void) setAutoOpenInBrowser:(BOOL)_flag {
125   [[self userDefaults] setBool:_flag forKey:@"WOAutoOpenInBrowser"];
126 }
127 + (BOOL)autoOpenInBrowser {
128   return [[self userDefaults] boolForKey:@"WOAutoOpenInBrowser"];
129 }
130
131 /* WOApplicationBaseURL */
132
133 + (void)setApplicationBaseURL:(NSString *)_url {
134   [[self userDefaults] setObject:_url forKey:@"WOApplicationBaseURL"];
135 }
136 + (NSString *)applicationBaseURL {
137   return [[self userDefaults] stringForKey:@"WOApplicationBaseURL"];
138 }
139
140 /* WOFrameworksBaseURL */
141
142 + (void)setFrameworksBaseURL:(NSString *)_url {
143   [[self userDefaults] setObject:_url forKey:@"WOFrameworksBaseURL"];
144 }
145 + (NSString *)frameworksBaseURL {
146   return [[self userDefaults] stringForKey:@"WOFrameworksBaseURL"];
147 }
148
149 @end /* WOApplication(Defaults) */