]> err.no Git - scalable-opengroupware.org/blob - SOGo/UI/Mailer/UIxMailMainFrame.m
2a732b69156627a4d3445af3d6895b1d3944be7d
[scalable-opengroupware.org] / SOGo / UI / Mailer / UIxMailMainFrame.m
1 /*
2   Copyright (C) 2004-2005 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
22 #include <SOGoUI/UIxComponent.h>
23
24 @interface UIxMailMainFrame : UIxComponent
25 {
26   NSString *title;
27   NSString *rootURL;
28   NSString *userRootURL;
29   id       item;
30   BOOL     hideFolderTree;
31 }
32
33 - (NSString *)rootURL;
34 - (NSString *)userRootURL;
35 - (NSString *)calendarRootURL;
36
37 @end
38
39 #include "common.h"
40 #include <NGObjWeb/SoComponent.h>
41
42 @implementation UIxMailMainFrame
43
44 - (void)dealloc {
45   [self->item        release];
46   [self->title       release];
47   [self->rootURL     release];
48   [self->userRootURL release];
49   [super dealloc];
50 }
51
52 /* accessors */
53
54 - (void)setHideFolderTree:(BOOL)_flag {
55    self->hideFolderTree = _flag;
56 }
57 - (BOOL)hideFolderTree {
58   return self->hideFolderTree;
59 }
60
61 - (void)setTitle:(NSString *)_value {
62   ASSIGNCOPY(self->title, _value);
63 }
64 - (NSString *)title {
65   if ([self->title length] == 0)
66     return @"OpenGroupware.org";
67   
68   return self->title;
69 }
70
71 - (void)setItem:(id)_item {
72   ASSIGN(self->item, _item);
73 }
74 - (id)item {
75   return self->item;
76 }
77
78 /* notifications */
79
80 - (void)sleep {
81   [self->item release]; self->item = nil;
82   [super sleep];
83 }
84
85 /* URL generation */
86 // TODO: I think all this should be done by the clientObject?!
87 // TODO: is the stuff below necessary at all in the mailer frame?
88
89 - (NSString *)rootURL {
90   WOContext *ctx;
91   NSArray   *traversalObjects;
92
93   if (self->rootURL != nil)
94     return self->rootURL;
95
96   ctx = [self context];
97   traversalObjects = [ctx objectTraversalStack];
98   self->rootURL = [[[traversalObjects objectAtIndex:0]
99                                       rootURLInContext:ctx]
100                                       copy];
101   return self->rootURL;
102 }
103
104 - (NSString *)userRootURL {
105   WOContext *ctx;
106   NSArray   *traversalObjects;
107
108   if (self->userRootURL)
109     return self->userRootURL;
110
111   ctx = [self context];
112   traversalObjects = [ctx objectTraversalStack];
113   self->userRootURL = [[[[traversalObjects objectAtIndex:1]
114                                            baseURLInContext:ctx]
115                                            stringByAppendingString:@"/"]
116                                            retain];
117   return self->userRootURL;
118 }
119
120 - (NSString *)calendarRootURL {
121   return [[self userRootURL] stringByAppendingString:@"Calendar/"];
122 }
123 - (NSString *)contactsRootURL {
124   return [[self userRootURL] stringByAppendingString:@"Contacts/"];
125 }
126
127 @end /* UIxMailMainFrame */