HTML Composing, see changelog

Monotone-Parent: b895c283a3da52c67fd91339f704dc8cd49b743f
Monotone-Revision: 5f0e6bd5b6298ffdd908398135216841ba3b6909

Monotone-Author: crobert@inverse.ca
Monotone-Date: 2009-06-23T17:53:18
Monotone-Branch: ca.inverse.sogo
This commit is contained in:
C Robert
2009-06-23 17:53:18 +00:00
parent 445224aa8f
commit f9337f183f
13 changed files with 236 additions and 113 deletions
+1 -83
View File
@@ -33,92 +33,10 @@
#import <NGExtensions/NSString+misc.h>
#import <SoObjects/SOGo/NSString+Utilities.h>
#import <SoObjects/Mailer/NSString+Mail.h>
#import "UIxMailPartTextViewer.h"
@interface NSString (SOGoMailUIExtension)
- (NSString *) stringByConvertingCRLNToHTML;
@end
@implementation NSString (SOGoMailUIExtension)
#define paddingBuffer 8192
static inline char *
convertChars (const char *oldString, unsigned int oldLength,
unsigned int *newLength)
{
const char *currentChar, *upperLimit;
char *newString, *destChar, *reallocated;
unsigned int length, maxLength;
maxLength = oldLength + paddingBuffer;
newString = NSZoneMalloc (NULL, maxLength + 1);
destChar = newString;
currentChar = oldString;
length = 0;
upperLimit = oldString + oldLength;
while (currentChar < upperLimit)
{
switch (*currentChar)
{
case '\r': break;
case '\n':
length = destChar - newString;
if (length + paddingBuffer > maxLength - 6)
{
maxLength += paddingBuffer;
reallocated = NSZoneRealloc (NULL, newString, maxLength + 1);
if (reallocated)
{
newString = reallocated;
destChar = newString + length;
}
else
[NSException raise: NSMallocException
format: @"reallocation failed in %s",
__PRETTY_FUNCTION__];
}
strcpy (destChar, "<br />");
destChar += 6;
break;
default:
*destChar = *currentChar;
destChar++;
}
currentChar++;
}
*destChar = 0;
*newLength = destChar - newString;
return newString;
}
- (NSString *) stringByConvertingCRLNToHTML
{
NSString *convertedString;
char *newString;
unsigned int newLength;
newString
= convertChars ([self cStringUsingEncoding: NSUTF8StringEncoding],
[self lengthOfBytesUsingEncoding: NSUTF8StringEncoding],
&newLength);
convertedString = [[NSString alloc] initWithBytes: newString
length: newLength
encoding: NSUTF8StringEncoding];
[convertedString autorelease];
NSZoneFree (NULL, newString);
return convertedString;
}
@end
@implementation UIxMailPartTextViewer
- (NSString *) flatContentAsString