]> err.no Git - sope/blob - sope-appserver/NGObjWeb/WOApplication+defaults.m
renamed packages as discussed in the developer list
[sope] / sope-appserver / NGObjWeb / WOApplication+defaults.m
1 /*
2   Copyright (C) 2000-2004 SKYRIX Software AG
3
4   This file is part of OpenGroupware.org.
5
6   OGo 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   OGo 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 OGo; 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 // $Id$
22
23 #include <NGObjWeb/WOApplication.h>
24 #include "common.h"
25
26 @interface WOApplication(DefaultsPrivates)
27 + (NSUserDefaults *)userDefaults;
28 @end
29
30 @implementation WOApplication(Defaults)
31
32 static NSString *ck = nil;
33 static NSString *dk = nil;
34
35 + (void)setComponentRequestHandlerKey:(NSString *)_key {
36   [[self userDefaults]
37          setObject:_key
38          forKey:@"WOComponentRequestHandlerKey"];
39   [ck release]; ck = nil;
40 }
41 + (NSString *)componentRequestHandlerKey {
42   if (ck == nil)
43     ck = [[[self userDefaults] stringForKey:@"WOComponentRequestHandlerKey"]
44            copy];
45   return ck;
46 }
47
48 + (void)setDirectActionRequestHandlerKey:(NSString *)_key {
49   [[self userDefaults]
50          setObject:_key
51          forKey:@"WODirectActionRequestHandlerKey"];
52   [dk release]; dk = nil;
53 }
54 + (NSString *)directActionRequestHandlerKey {
55   if (dk == nil) {
56     dk = [[[self userDefaults] 
57       stringForKey:@"WODirectActionRequestHandlerKey"] copy];
58   }
59   return dk;
60 }
61
62 + (void)setResourceRequestHandlerKey:(NSString *)_key {
63   [[self userDefaults] setObject:_key forKey:@"WOResourceRequestHandlerKey"];
64 }
65 + (NSString *)resourceRequestHandlerKey {
66   return [[self userDefaults] stringForKey:@"WOResourceRequestHandlerKey"];
67 }
68
69 /* WODefaultSessionTimeOut */
70
71 + (void)setSessionTimeOut:(NSNumber *)_timeOut {
72   [[self userDefaults] setObject:_timeOut forKey:@"WODefaultSessionTimeOut"];
73 }
74
75 + (NSNumber *)sessionTimeOut {
76   NSUserDefaults *ud;
77   id o;
78
79   ud = [self userDefaults];
80   // Note: the second check is *intended* (Timeout vs TimeOut), it is
81   //       required for compatibility but should be phased out in the
82   //       long run. I don't know the proper default-name out of my
83   //       head (needs to be checked)
84   o  = [ud objectForKey:@"WODefaultSessionTimeout"];
85   if (o == nil) o = [ud objectForKey:@"WODefaultSessionTimeOut"];
86   return [NSNumber numberWithInt:[o intValue]];
87 }
88
89 /* WOCachingEnabled */
90
91 + (BOOL)isCachingEnabled {
92   return [[[self userDefaults]
93                  objectForKey:@"WOCachingEnabled"]
94                  boolValue];
95 }
96
97 /* WODebuggingEnabled */
98
99 + (BOOL)isDebuggingEnabled {
100   return [[[self userDefaults]
101                  objectForKey:@"WODebuggingEnabled"]
102                  boolValue];
103 }
104
105 /* WOCompatibility */
106
107 static BOOL directConnectEnabled = YES;
108
109 + (void)setDirectConnectEnabled:(BOOL)_flag {
110   directConnectEnabled = _flag;
111 }
112 + (BOOL)isDirectConnectEnabled {
113   return directConnectEnabled;
114 }
115
116 + (void)setCGIAdaptorURL:(NSString *)_url {
117   [[self userDefaults] setObject:_url forKey:@"WOCGIAdaptorURL"];
118 }
119 + (NSString *)cgiAdaptorURL {
120   return [[self userDefaults] stringForKey:@"WOCGIAdaptorURL"];
121 }
122
123 /* WOAutoOpenInBrowser */
124
125 + (void) setAutoOpenInBrowser:(BOOL)_flag {
126   [[self userDefaults] setBool:_flag forKey:@"WOAutoOpenInBrowser"];
127 }
128 + (BOOL)autoOpenInBrowser {
129   return [[self userDefaults] boolForKey:@"WOAutoOpenInBrowser"];
130 }
131
132 /* WOApplicationBaseURL */
133
134 + (void)setApplicationBaseURL:(NSString *)_url {
135   [[self userDefaults] setObject:_url forKey:@"WOApplicationBaseURL"];
136 }
137 + (NSString *)applicationBaseURL {
138   return [[self userDefaults] stringForKey:@"WOApplicationBaseURL"];
139 }
140
141 /* WOFrameworksBaseURL */
142
143 + (void)setFrameworksBaseURL:(NSString *)_url {
144   [[self userDefaults] setObject:_url forKey:@"WOFrameworksBaseURL"];
145 }
146 + (NSString *)frameworksBaseURL {
147   return [[self userDefaults] stringForKey:@"WOFrameworksBaseURL"];
148 }
149
150 @end /* WOApplication(Defaults) */