2 Copyright (C) 2000-2005 SKYRIX Software AG
4 This file is part of SOPE.
6 SOPE 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
11 SOPE 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.
16 You should have received a copy of the GNU Lesser General Public
17 License along with SOPE; see the file COPYING. If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
22 #include "NGMimeMessageGenerator.h"
23 #include "NGMimeMessage.h"
24 #include <NGMime/NGMimeFileData.h>
28 Mail_Use_8bit_Encoding_For_Text[BOOL] --
29 Use 8bit content-transfer-encoding for
34 _base64Encoding(NGMimeBodyGenerator *self,
37 NGMutableHashMap *_addHeaders)
39 NSString *transEnc = nil;
40 const char *bytes = NULL;
43 /* kinda hack, treat NGMimeFileData objects as already encoded */
45 if ([_data_ isKindOfClass:[NGMimeFileData class]])
50 bytes = [_data_ bytes];
51 length = [_data_ length];
54 if ((unsigned char)*bytes > 127) {
60 if (length > 0) { // should be encoded
63 type = [_part contentType];
65 if ([[type type] isEqualToString:@"text"]) {
69 ud = [NSUserDefaults standardUserDefaults];
70 use8bit = [ud boolForKey:@"Mail_Use_8bit_Encoding_For_Text"];
75 _data_ = [_data_ dataByEncodingQuotedPrintable];
76 transEnc = @"quoted-printable";
82 _data_ = [_data_ dataByEncodingBase64];
85 appOctet = [NGMimeType mimeType:@"application" subType:@"octet-stream"];
87 [_addHeaders setObject:appOctet forKey:@"content-type"];
90 else /* no encoding */
93 [_addHeaders setObject:transEnc forKey:@"content-transfer-encoding"];
94 [_addHeaders setObject:[NSNumber numberWithInt:[_data_ length]]
95 forKey:@"content-length"];