]> err.no Git - scalable-opengroupware.org/blob - UI/MailPartViewers/UIxKolabPartViewer.m
git-svn-id: http://svn.opengroupware.org/SOGo/inverse/trunk@1146 d1b88da0-ebda-0310...
[scalable-opengroupware.org] / UI / MailPartViewers / UIxKolabPartViewer.m
1 /*
2   Copyright (C) 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 #import <NGExtensions/NSNull+misc.h>
23 #import <DOM/DOMBuilderFactory.h>
24 #import <DOM/DOMProtocols.h>
25
26 #import "UIxKolabPartViewer.h"
27
28 @implementation UIxKolabPartViewer
29
30 static id<DOMBuilder> domBuilder = nil;
31
32 + (void)initialize {
33   DOMBuilderFactory *factory
34     = [DOMBuilderFactory standardDOMBuilderFactory];
35   
36   domBuilder = [[factory createDOMBuilderForMimeType:@"text/xml"] retain];
37   NSLog(@"Note(%@): using DOM builder: %@", 
38         NSStringFromClass(self), domBuilder);
39 }
40
41 - (void)dealloc {
42   [(id)self->domDocument release];
43   [self->item release];
44   [super dealloc];
45 }
46
47 /* maintain caches */
48
49 - (void)resetPathCaches {
50   [super resetPathCaches];
51   [(id)self->domDocument release]; self->domDocument = nil;
52   [self->item            release]; self->item        = nil;
53 }
54
55 /* getting a DOM representation */
56
57 - (id<DOMDocument>)domDocument {
58   /* 
59      Note: this ignores the charset MIME header and will rely on proper
60            encoding header in the XML.
61   */
62
63   if (self->domDocument != nil)
64     return [(id)self->domDocument isNotNull] ? self->domDocument : nil;
65   
66   self->domDocument =
67     [[domBuilder buildFromSource:[self decodedFlatContent]
68                  systemId:@"Kolab Mail Object"] retain];
69   return self->domDocument;
70 }
71
72 /* accessors */
73
74 - (void)setItem:(id)_item {
75   ASSIGN(self->item, _item);
76 }
77 - (id)item {
78   return self->item;
79 }
80
81 @end /* UIxKolabPartViewer */