]> err.no Git - scalable-opengroupware.org/blob - SOGo/UI/Mailer/UIxMailToolbar.m
changes to use NGLogging in all places
[scalable-opengroupware.org] / SOGo / UI / Mailer / UIxMailToolbar.m
1 /*
2   Copyright (C) 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 <SOGoUI/UIxComponent.h>
24
25 @class NSArray, NSDictionary;
26
27 @interface UIxMailToolbar : UIxComponent
28 {
29   NSArray      *toolbarConfig;
30   NSArray      *toolbarGroup;
31   NSDictionary *buttonInfo;
32 }
33 @end
34
35 #include <SOGo/SoObjects/Mailer/SOGoMailBaseObject.h>
36 #include "common.h"
37 #include <NGObjWeb/SoComponent.h>
38
39 @implementation UIxMailToolbar
40
41 - (void)dealloc {
42   [self->toolbarGroup  release];
43   [self->toolbarConfig release];
44   [self->buttonInfo    release];
45   [super dealloc];
46 }
47
48 /* notifications */
49
50 - (void)sleep {
51   [self->toolbarGroup  release]; self->toolbarGroup  = nil;
52   [self->toolbarConfig release]; self->toolbarConfig = nil;
53   [self->buttonInfo    release]; self->buttonInfo    = nil;
54   [super sleep];
55 }
56
57 /* accessors */
58
59 - (void)setToolbarGroup:(id)_group {
60   ASSIGN(self->toolbarGroup, _group);
61 }
62 - (id)toolbarGroup {
63   return self->toolbarGroup;
64 }
65
66 - (void)setButtonInfo:(id)_info {
67   ASSIGN(self->buttonInfo, _info);
68 }
69 - (id)buttonInfo {
70   return self->buttonInfo;
71 }
72
73 /* toolbar */
74
75 - (id)toolbarConfig {
76   id tmp;
77   
78   if (self->toolbarConfig != nil)
79     return [self->toolbarConfig isNotNull] ? self->toolbarConfig : nil;
80   
81   tmp = [[self clientObject] lookupName:@"toolbar" inContext:[self context]
82                              acquire:NO];
83   if ([tmp isKindOfClass:[NSException class]]) {
84     [self errorWithFormat:
85             @"not toolbar configuration found on SoObject: %@ (%@)",
86             [self clientObject], [[self clientObject] soClass]];
87     self->toolbarConfig = [[NSNull null] retain];
88     return nil;
89   }
90   self->toolbarConfig = [tmp retain];
91   return self->toolbarConfig;
92 }
93
94 /* labels */
95
96 - (NSString *)buttonLabel {
97   WOResourceManager *rm;
98   NSArray           *languages;
99   WOContext         *ctx;
100   NSString          *key, *label;
101
102   key = [[self buttonInfo] valueForKey:@"label"];
103   
104   /* lookup languages */
105   
106   ctx = [self context];
107   languages = [ctx hasSession]
108     ? [[ctx session] languages]
109     : [[ctx request] browserLanguages];
110
111   /* lookup resource manager */
112   
113   if ((rm = [self resourceManager]) == nil)
114     rm = [[WOApplication application] resourceManager];
115   if (rm == nil)
116     [self warnWithFormat:@"missing resource manager!"];
117   
118   /* lookup string */
119   
120   label = [rm stringForKey:key inTableNamed:nil withDefaultValue:key
121               languages:languages];
122   return label;
123 }
124
125 @end /* UIxMailToolbar */