2 Copyright (C) 2004-2005 SKYRIX Software AG
4 This file is part of OpenGroupware.org.
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
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.
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
22 #include <SOGoUI/UIxComponent.h>
24 @interface UIxMailMainFrame : UIxComponent
28 NSString *userRootURL;
32 int hideFrame:1; /* completely disables all the frame around the comp. */
37 - (NSString *)rootURL;
38 - (NSString *)userRootURL;
39 - (NSString *)calendarRootURL;
44 #include <NGObjWeb/SoComponent.h>
46 @implementation UIxMailMainFrame
48 static NSString *treeRootClassName = nil;
51 NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
53 treeRootClassName = [[ud stringForKey:@"SOGoMailTreeRootClass"] copy];
54 if (treeRootClassName)
55 NSLog(@"Note: use class '%@' as root for mail tree.", treeRootClassName);
57 treeRootClassName = @"SOGoMailAccounts";
62 [self->title release];
63 [self->rootURL release];
64 [self->userRootURL release];
70 - (NSString *)treeRootClassName {
71 return treeRootClassName;
74 - (void)setHideFolderTree:(BOOL)_flag {
75 self->mmfFlags.hideFolderTree = _flag ? 1 : 0;
77 - (BOOL)hideFolderTree {
78 return self->mmfFlags.hideFolderTree ? YES : NO;
81 - (void)setHideFrame:(BOOL)_flag {
82 self->mmfFlags.hideFrame = _flag ? 1 : 0;
85 return self->mmfFlags.hideFrame ? YES : NO;
88 - (void)setTitle:(NSString *)_value {
89 ASSIGNCOPY(self->title, _value);
92 if ([self->title length] == 0)
93 return @"OpenGroupware.org";
98 - (void)setItem:(id)_item {
99 ASSIGN(self->item, _item);
105 - (NSString *)pageFormURL {
108 u = [[[self context] request] uri];
109 return [u hasSuffix:@"/"] ? @"view" : @"#";
112 - (BOOL)showLinkBanner {
113 if ([self hideFolderTree]) return NO;
116 - (NSString *)bannerToolbarStyle {
117 return [self showLinkBanner] ? @"top: 58px;" : nil /* fallback to CSS */;
119 - (NSString *)bannerConsumeStyle {
120 return [self showLinkBanner] ? @"height: 116px;" : nil /* fallback to CSS */;
126 [self->item release]; self->item = nil;
131 // TODO: I think all this should be done by the clientObject?!
132 // TODO: is the stuff below necessary at all in the mailer frame?
134 - (NSString *)rootURL {
136 NSArray *traversalObjects;
138 if (self->rootURL != nil)
139 return self->rootURL;
141 ctx = [self context];
142 traversalObjects = [ctx objectTraversalStack];
143 self->rootURL = [[[traversalObjects objectAtIndex:0]
144 rootURLInContext:ctx]
146 return self->rootURL;
149 - (NSString *)userRootURL {
151 NSArray *traversalObjects;
153 if (self->userRootURL)
154 return self->userRootURL;
156 ctx = [self context];
157 traversalObjects = [ctx objectTraversalStack];
158 self->userRootURL = [[[[traversalObjects objectAtIndex:1]
159 baseURLInContext:ctx]
160 stringByAppendingString:@"/"]
162 return self->userRootURL;
165 - (NSString *)calendarRootURL {
166 return [[self userRootURL] stringByAppendingString:@"Calendar/"];
168 - (NSString *)contactsRootURL {
169 return [[self userRootURL] stringByAppendingString:@"Contacts/"];
174 - (BOOL)hasErrorText {
175 return [[[[self context] request] formValueForKey:@"error"] length] > 0
178 - (NSString *)errorText {
179 return [[[self context] request] formValueForKey:@"error"];
182 - (NSString *)errorAlertJavaScript {
185 if ([(errorText = [self errorText]) length] == 0)
188 // TODO: proper JavaScript escaping
189 errorText = [errorText stringByEscapingHTMLString];
190 errorText = [errorText stringByReplacingString:@"\"" withString:@"'"];
192 return [NSString stringWithFormat:
193 @"<script language=\"JavaScript\">"
195 @"</script>", errorText];
198 @end /* UIxMailMainFrame */