]> err.no Git - scalable-opengroupware.org/blob - SoObjects/Mailer/SOGoMailForward.m
git-svn-id: http://svn.opengroupware.org/SOGo/inverse/trunk@1267 d1b88da0-ebda-0310...
[scalable-opengroupware.org] / SoObjects / Mailer / SOGoMailForward.m
1 /* SOGoMailForward.m - this file is part of SOGo
2  *
3  * Copyright (C) 2007 Inverse groupe conseil
4  *
5  * Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
6  *
7  * This file is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2, or (at your option)
10  * any later version.
11  *
12  * This file is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; see the file COPYING.  If not, write to
19  * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20  * Boston, MA 02111-1307, USA.
21  */
22
23 #import <NGObjWeb/WOContext+SoObjects.h>
24
25 #import <SoObjects/SOGo/SOGoDateFormatter.h>
26 #import <SoObjects/SOGo/SOGoUser.h>
27
28 #import "SOGoMailObject+Draft.h"
29 #import "SOGoMailForward.h"
30
31 @implementation SOGoMailForward
32
33 - (id) init
34 {
35   if ((self = [super init]))
36     {
37       sourceMail = nil;
38       currentValue = nil;
39     }
40
41   return self;
42 }
43
44 - (void) dealloc
45 {
46   [sourceMail release];
47   [currentValue release];
48   [super dealloc];
49 }
50
51 - (void) setForwardedMail: (SOGoMailObject *) newSourceMail
52 {
53   ASSIGN (sourceMail, newSourceMail);
54 }
55
56 - (NSString *) subject
57 {
58   return [sourceMail subject];
59 }
60
61 - (NSString *) date
62 {
63   SOGoDateFormatter *formatter;
64
65   formatter = [[context activeUser] dateFormatterInContext: context];
66
67   return [formatter formattedDateAndTime: [sourceMail date]];
68 }
69
70 - (NSString *) from
71 {
72   return [[sourceMail mailHeaders] objectForKey: @"from"];
73 }
74
75 - (NSString *) _headerField: (NSString *) fieldName
76 {
77   if (![field isEqualToString: fieldName])
78     {
79       [currentValue release];
80       currentValue = [[sourceMail mailHeaders] objectForKey: fieldName];
81       [currentValue retain];
82     }
83
84   return currentValue;
85 }
86
87 - (BOOL) hasReplyTo
88 {
89   return ([[self _headerField: @"reply-to"] length] > 0);
90 }
91
92 - (NSString *) replyTo
93 {
94   return ([NSString stringWithFormat: @"%@\n",
95                     [self _headerField: @"reply-to"]]);
96 }
97
98 - (BOOL) hasOrganization
99 {
100   return ([[self _headerField: @"organization"] length] > 0);
101 }
102
103 - (NSString *) organization
104 {
105   return ([NSString stringWithFormat: @"%@\n",
106                     [self _headerField: @"organization"]]);
107 }
108
109 - (NSString *) to
110 {
111   return [[sourceMail mailHeaders] objectForKey: @"to"];
112 }
113
114 - (BOOL) hasCc
115 {
116   return ([[self _headerField: @"cc"] length] > 0);
117 }
118
119 - (NSString *) cc
120 {
121   return ([NSString stringWithFormat: @"%@\n",
122                     [self _headerField: @"cc"]]);
123 }
124
125 - (BOOL) hasNewsGroups
126 {
127   return ([[self _headerField: @"newsgroups"] length] > 0);
128 }
129
130 - (NSString *) newsgroups
131 {
132   return ([NSString stringWithFormat: @"%@\n",
133                     [self _headerField: @"newsgroups"]]);
134 }
135
136 - (BOOL) hasReferences
137 {
138   return ([[self _headerField: @"references"] length] > 0);
139 }
140
141 - (NSString *) references
142 {
143   return ([NSString stringWithFormat: @"%@\n",
144                     [self _headerField: @"references"]]);
145 }
146
147 - (NSString *) messageBody
148 {
149   return [sourceMail contentForEditing];
150 }
151
152 - (NSString *) signature
153 {
154   NSString *signature, *mailSignature;
155
156   signature = [[context activeUser] signature];
157   if ([signature length])
158     mailSignature = [NSString stringWithFormat: @"--\r\n%@", signature];
159   else
160     mailSignature = @"";
161
162   return mailSignature;
163 }
164
165 @end
166
167 @implementation SOGoMailEnglishForward
168 @end
169
170 @implementation SOGoMailFrenchForward
171 @end
172
173 @implementation SOGoMailGermanForward
174 @end