2007-08-22 17:10:48 +02:00
|
|
|
/* SOGoMailForward.m - this file is part of SOGo
|
|
|
|
*
|
2008-09-27 03:13:41 +02:00
|
|
|
* Copyright (C) 2007 Inverse inc.
|
2007-08-22 17:10:48 +02:00
|
|
|
*
|
|
|
|
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
|
|
|
*
|
|
|
|
* This file is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
* any later version.
|
|
|
|
*
|
|
|
|
* This file is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; see the file COPYING. If not, write to
|
|
|
|
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
2010-04-21 16:35:58 +02:00
|
|
|
#import <Foundation/NSDictionary.h>
|
|
|
|
|
2007-08-22 17:10:48 +02:00
|
|
|
#import <NGObjWeb/WOContext+SoObjects.h>
|
2009-06-25 21:18:02 +02:00
|
|
|
#import <NGExtensions/NSString+misc.h>
|
2007-08-22 17:10:48 +02:00
|
|
|
|
2009-11-29 05:19:32 +01:00
|
|
|
#import <SOGo/SOGoDateFormatter.h>
|
|
|
|
#import <SOGo/SOGoUser.h>
|
|
|
|
#import <SOGo/SOGoUserDefaults.h>
|
2007-08-22 17:10:48 +02:00
|
|
|
|
2010-08-06 16:25:59 +02:00
|
|
|
#import "SOGoMailAccount.h"
|
2007-08-22 17:10:48 +02:00
|
|
|
#import "SOGoMailObject+Draft.h"
|
|
|
|
#import "SOGoMailForward.h"
|
|
|
|
|
|
|
|
@implementation SOGoMailForward
|
|
|
|
|
|
|
|
- (id) init
|
|
|
|
{
|
2010-01-04 17:05:12 +01:00
|
|
|
SOGoUserDefaults *ud;
|
|
|
|
|
2007-08-22 17:10:48 +02:00
|
|
|
if ((self = [super init]))
|
|
|
|
{
|
2009-06-25 21:18:02 +02:00
|
|
|
ud = [[context activeUser] userDefaults];
|
2010-01-04 17:05:12 +01:00
|
|
|
htmlComposition
|
|
|
|
= [[ud mailComposeMessageType] isEqualToString: @"html"];
|
2007-08-22 17:10:48 +02:00
|
|
|
sourceMail = nil;
|
|
|
|
currentValue = nil;
|
|
|
|
}
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) dealloc
|
|
|
|
{
|
|
|
|
[sourceMail release];
|
|
|
|
[currentValue release];
|
|
|
|
[super dealloc];
|
|
|
|
}
|
|
|
|
|
2008-09-05 18:50:22 +02:00
|
|
|
- (void) setSourceMail: (SOGoMailObject *) newSourceMail
|
2007-08-22 17:10:48 +02:00
|
|
|
{
|
|
|
|
ASSIGN (sourceMail, newSourceMail);
|
|
|
|
}
|
|
|
|
|
2009-06-25 21:18:02 +02:00
|
|
|
- (NSString *) newLine
|
|
|
|
{
|
|
|
|
NSString *rc = [NSString stringWithString: @" "];
|
|
|
|
|
|
|
|
if (htmlComposition)
|
|
|
|
rc = [NSString stringWithString: @"<br/>"];
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2007-08-22 17:10:48 +02:00
|
|
|
- (NSString *) subject
|
|
|
|
{
|
2007-11-25 18:26:56 +01:00
|
|
|
return [sourceMail decodedSubject];
|
2007-08-22 17:10:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) date
|
|
|
|
{
|
|
|
|
SOGoDateFormatter *formatter;
|
|
|
|
|
|
|
|
formatter = [[context activeUser] dateFormatterInContext: context];
|
|
|
|
|
|
|
|
return [formatter formattedDateAndTime: [sourceMail date]];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) from
|
|
|
|
{
|
2009-06-25 21:18:02 +02:00
|
|
|
NSString *rc;
|
|
|
|
|
|
|
|
if (htmlComposition)
|
2010-04-21 16:35:58 +02:00
|
|
|
rc = [[[sourceMail mailHeaders] objectForKey: @"from"]
|
|
|
|
stringByEscapingHTMLString];
|
2009-06-25 21:18:02 +02:00
|
|
|
else
|
|
|
|
rc = [[sourceMail mailHeaders] objectForKey: @"from"];
|
|
|
|
|
|
|
|
return rc;
|
2007-08-22 17:10:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) _headerField: (NSString *) fieldName
|
|
|
|
{
|
|
|
|
if (![field isEqualToString: fieldName])
|
|
|
|
{
|
|
|
|
[currentValue release];
|
|
|
|
currentValue = [[sourceMail mailHeaders] objectForKey: fieldName];
|
|
|
|
[currentValue retain];
|
|
|
|
}
|
|
|
|
|
|
|
|
return currentValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) hasReplyTo
|
|
|
|
{
|
|
|
|
return ([[self _headerField: @"reply-to"] length] > 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) replyTo
|
|
|
|
{
|
2009-06-25 21:18:02 +02:00
|
|
|
NSString *rc;
|
|
|
|
|
|
|
|
if (htmlComposition)
|
|
|
|
rc = [NSString stringWithFormat: @"%@<br/>",
|
|
|
|
[[self _headerField: @"reply-to"] stringByEscapingHTMLString]];
|
|
|
|
else
|
|
|
|
rc = ([NSString stringWithFormat: @"%@\n", [self _headerField: @"reply-to"]]);
|
|
|
|
|
|
|
|
return rc;
|
2007-08-22 17:10:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) hasOrganization
|
|
|
|
{
|
|
|
|
return ([[self _headerField: @"organization"] length] > 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) organization
|
|
|
|
{
|
2009-06-25 21:18:02 +02:00
|
|
|
NSString *rc;
|
|
|
|
|
|
|
|
if (htmlComposition)
|
|
|
|
rc = [NSString stringWithFormat: @"%@<br/>", [self _headerField: @"organization"]];
|
|
|
|
else
|
|
|
|
rc = [NSString stringWithFormat: @"%@\n", [self _headerField: @"organization"]];
|
|
|
|
|
|
|
|
return rc;
|
2007-08-22 17:10:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) to
|
|
|
|
{
|
2009-06-25 21:18:02 +02:00
|
|
|
NSString *rc;
|
|
|
|
|
|
|
|
if (htmlComposition)
|
|
|
|
rc = [[[sourceMail mailHeaders] objectForKey: @"to"] stringByEscapingHTMLString];
|
|
|
|
else
|
|
|
|
rc = [[sourceMail mailHeaders] objectForKey: @"to"];
|
|
|
|
|
|
|
|
return rc;
|
2007-08-22 17:10:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) hasCc
|
|
|
|
{
|
|
|
|
return ([[self _headerField: @"cc"] length] > 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) cc
|
|
|
|
{
|
2009-06-25 21:18:02 +02:00
|
|
|
NSString *rc;
|
|
|
|
|
|
|
|
if (htmlComposition)
|
|
|
|
rc = [NSString stringWithFormat: @"%@<br/>",
|
|
|
|
[[self _headerField: @"cc"] stringByEscapingHTMLString]];
|
|
|
|
else
|
|
|
|
rc = ([NSString stringWithFormat: @"%@\n", [self _headerField: @"cc"]]);
|
|
|
|
|
|
|
|
return rc;
|
2007-08-22 17:10:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) hasNewsGroups
|
|
|
|
{
|
|
|
|
return ([[self _headerField: @"newsgroups"] length] > 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) newsgroups
|
|
|
|
{
|
2009-06-25 21:18:02 +02:00
|
|
|
NSString *rc;
|
|
|
|
|
|
|
|
if (htmlComposition)
|
|
|
|
rc = [NSString stringWithFormat: @"%@<br/>", [self _headerField: @"newsgroups"]];
|
|
|
|
else
|
|
|
|
rc = [NSString stringWithFormat: @"%@\n", [self _headerField: @"newsgroups"]];
|
|
|
|
|
|
|
|
return rc;
|
2007-08-22 17:10:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) hasReferences
|
|
|
|
{
|
|
|
|
return ([[self _headerField: @"references"] length] > 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) references
|
|
|
|
{
|
2009-06-25 21:18:02 +02:00
|
|
|
NSString *rc;
|
|
|
|
|
|
|
|
if (htmlComposition)
|
|
|
|
rc = [NSString stringWithFormat: @"%@<br/>", [self _headerField: @"references"]];
|
|
|
|
else
|
|
|
|
rc = [NSString stringWithFormat: @"%@\n", [self _headerField: @"references"]];
|
|
|
|
|
|
|
|
return rc;
|
2007-08-22 17:10:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) messageBody
|
|
|
|
{
|
2008-09-05 18:50:22 +02:00
|
|
|
return [sourceMail contentForEditing];
|
2007-08-22 17:10:48 +02:00
|
|
|
}
|
|
|
|
|
2007-11-19 23:44:12 +01:00
|
|
|
- (NSString *) signature
|
|
|
|
{
|
|
|
|
NSString *signature, *mailSignature;
|
2009-11-29 05:19:32 +01:00
|
|
|
SOGoUserDefaults *ud;
|
2007-11-19 23:44:12 +01:00
|
|
|
|
2009-11-29 05:19:32 +01:00
|
|
|
ud = [[context activeUser] userDefaults];
|
2010-08-06 16:25:59 +02:00
|
|
|
signature = [[sourceMail mailAccountFolder] signature];
|
2007-11-19 23:44:12 +01:00
|
|
|
if ([signature length])
|
2007-11-25 18:26:56 +01:00
|
|
|
mailSignature = [NSString stringWithFormat: @"-- \n%@", signature];
|
2007-11-19 23:44:12 +01:00
|
|
|
else
|
|
|
|
mailSignature = @"";
|
|
|
|
|
|
|
|
return mailSignature;
|
|
|
|
}
|
|
|
|
|
2007-08-22 17:10:48 +02:00
|
|
|
@end
|
2007-08-23 18:13:24 +02:00
|
|
|
|
2009-08-05 13:30:23 +02:00
|
|
|
@implementation SOGoMailBrazilianPortugueseForward
|
|
|
|
@end
|
|
|
|
|
2010-11-17 14:43:07 +01:00
|
|
|
@implementation SOGoMailCatalanForward
|
|
|
|
@end
|
|
|
|
|
2009-08-05 13:06:06 +02:00
|
|
|
@implementation SOGoMailCzechForward
|
|
|
|
@end
|
|
|
|
|
2008-09-05 18:50:22 +02:00
|
|
|
@implementation SOGoMailDutchForward
|
|
|
|
@end
|
|
|
|
|
2007-08-23 18:13:24 +02:00
|
|
|
@implementation SOGoMailEnglishForward
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation SOGoMailFrenchForward
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation SOGoMailGermanForward
|
|
|
|
@end
|
2008-03-20 14:48:17 +01:00
|
|
|
|
2009-08-05 13:30:23 +02:00
|
|
|
@implementation SOGoMailHungarianForward
|
|
|
|
@end
|
|
|
|
|
2011-05-11 21:12:47 +02:00
|
|
|
@implementation SOGoMailIcelandicForward
|
|
|
|
@end
|
|
|
|
|
2008-03-20 14:48:17 +01:00
|
|
|
@implementation SOGoMailItalianForward
|
|
|
|
@end
|
|
|
|
|
2011-11-17 16:22:09 +01:00
|
|
|
@implementation SOGoMailNorwegianBokmalForward
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation SOGoMailNorwegianNynorskForward
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation SOGoMailSpanishSpainForward
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation SOGoMailSpanishArgentinaForward
|
2008-09-05 18:50:22 +02:00
|
|
|
@end
|
2009-05-23 13:12:34 +02:00
|
|
|
|
2011-08-17 18:05:49 +02:00
|
|
|
@implementation SOGoMailSwedishForward
|
|
|
|
@end
|
|
|
|
|
2010-08-03 17:13:58 +02:00
|
|
|
@implementation SOGoMailPolishForward
|
|
|
|
@end
|
|
|
|
|
2009-05-23 13:12:34 +02:00
|
|
|
@implementation SOGoMailRussianForward
|
|
|
|
@end
|
2009-08-05 13:30:23 +02:00
|
|
|
|
2010-09-13 23:37:07 +02:00
|
|
|
@implementation SOGoMailUkrainianForward
|
|
|
|
@end
|
|
|
|
|
2009-08-05 13:30:23 +02:00
|
|
|
@implementation SOGoMailWelshForward
|
|
|
|
@end
|