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