sogo/SoObjects/Mailer/NSData+Mail.m
Wolfgang Sourdeau 746063a940 Monotone-Parent: 7ee0c1dd084226bd61d44f69428903723aac6bbc
Monotone-Revision: 99aecefc3b45bf70dccf3bc8c5f60e6017e3935b

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2007-10-25T15:23:17
Monotone-Branch: ca.inverse.sogo
2007-10-25 15:23:17 +00:00

56 lines
1.7 KiB
Objective-C

/* NSData+Mail.m - this file is part of SOGo
*
* Copyright (C) 2007 Inverse groupe conseil
*
* 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.
*/
#import <Foundation/NSString.h>
#import <NGExtensions/NGBase64Coding.h>
#import <NGExtensions/NGQuotedPrintableCoding.h>
#import "NSData+Mail.h"
@implementation NSData (SOGoMailUtilities)
- (NSData *) bodyDataFromEncoding: (NSString *) encoding
{
NSString *realEncoding;
NSData *decodedData;
realEncoding = [encoding lowercaseString];
if ([realEncoding isEqualToString: @"7bit"]
|| [realEncoding isEqualToString: @"8bit"])
decodedData = self;
else if ([realEncoding isEqualToString: @"base64"])
decodedData = [self dataByDecodingBase64];
else if ([realEncoding isEqualToString: @"quoted-printable"])
decodedData = [self dataByDecodingQuotedPrintable];
else
{
decodedData = nil;
NSLog (@"encoding '%@' unknown, returning nil data", realEncoding);
}
return decodedData;
}
@end