Skip to content

Commit

Permalink
Merging v4.8 branch for release
Browse files Browse the repository at this point in the history
  • Loading branch information
jeevatkm committed Oct 13, 2014
2 parents 462c56e + a11f683 commit 28bca70
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 77 deletions.
73 changes: 42 additions & 31 deletions ReplyWithHeader/MHHeaderString.m
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ - (WebArchive *)getWebArchive
MHLog(@"final header values before web archiving %@", messageAttribution);

WebArchive *webarch = [finalHeader
webArchiveForRange:NSMakeRange(0, [finalHeader length])
fixUpNewlines:YES];
webArchiveForRange:NSMakeRange(0, [finalHeader length])
fixUpNewlines:YES];

return webarch;
}
Expand Down Expand Up @@ -164,19 +164,30 @@ - (id)initWithMailMessage:(id)mailMessage

if (!choosenLocaleIdentifier) {
choosenLocaleIdentifier = MHLocaleIdentifier;

MHLog(@"Fallback to default value of choosenLocaleIdentifier %@", choosenLocaleIdentifier);
}

choosenLocale = [[NSLocale alloc] initWithLocaleIdentifier:choosenLocaleIdentifier];

NSAttributedString *headerString = [[mailMessage originalMessageHeaders]
attributedStringShowingHeaderDetailLevel:[NSNumber numberWithInt:1]];
//for issue #71 - https://github.com/jeevatkm/ReplyWithHeader/issues/71
NSAttributedString *headerString = nil;
id mcMessageHeaders = [mailMessage originalMessageHeaders];

cleanHeaders = [mailMessage valueForKey:@"_cleanHeaders"];
if ([mcMessageHeaders respondsToSelector:@selector(attributedStringShowingHeaderDetailLevel:)])
{
headerString = [mcMessageHeaders
attributedStringShowingHeaderDetailLevel:[NSNumber numberWithInt:1]];
}
else
{
headerString = [mcMessageHeaders valueForKey:@"attributedString"];
}

NSArray *headers = [[headerString string]
componentsSeparatedByCharactersInSet:[NSCharacterSet newlineCharacterSet]];

cleanHeaders = [mailMessage valueForKey:@"_cleanHeaders"];
noOfHeaderLabels = [headers count];

MHLog(@"Original headers %@", headers);
Expand Down Expand Up @@ -251,7 +262,7 @@ - (void)applyHeaderOrderChange
}
@catch (NSException *exception) {
NSLog(@"Exception occured: %@", exception.description);
}
}
}
else
{
Expand Down Expand Up @@ -343,30 +354,30 @@ - (void)applyHeaderLabelChange
// Just realized, this might have to wait for a while
// thinking of universal solution
/*range.location = [dateToBePrefix length] + 2;
range.length = [row length] - ([dateToBePrefix length] + 2);
NSString *dateTimeString = [[row string] substringFromIndex:range.location];
NSDateFormatter *sourceFormatter = [NSDateFormatter new];
[sourceFormatter setLocale:[MailHeader currentLocale]];
[sourceFormatter setDateFormat:@"d MMM yyyy h:mm:ss a zzz"];
NSDate *fromDate = [sourceFormatter dateFromString:dateTimeString];
NSLog(@"fromDate %@", fromDate);
NSDateFormatter *targetFormatter = [NSDateFormatter new];
if ([[MailHeader localeIdentifier] isNotEqualTo:choosenLocaleIdentifier]) {
[targetFormatter setLocale:choosenLocale];
}
[targetFormatter setDateFormat:@"EEEE, LLLL d, yyyy h:mm a"];
[targetFormatter setAMSymbol:@"AM"];
[targetFormatter setPMSymbol:@"PM"];
NSString *toDate = [targetFormatter stringFromDate:fromDate];
NSLog(@"finalString of toDate %@", toDate);
[row replaceCharactersInRange:range withString:toDate];*/
range.length = [row length] - ([dateToBePrefix length] + 2);
NSString *dateTimeString = [[row string] substringFromIndex:range.location];
NSDateFormatter *sourceFormatter = [NSDateFormatter new];
[sourceFormatter setLocale:[MailHeader currentLocale]];
[sourceFormatter setDateFormat:@"d MMM yyyy h:mm:ss a zzz"];
NSDate *fromDate = [sourceFormatter dateFromString:dateTimeString];
NSLog(@"fromDate %@", fromDate);
NSDateFormatter *targetFormatter = [NSDateFormatter new];
if ([[MailHeader localeIdentifier] isNotEqualTo:choosenLocaleIdentifier]) {
[targetFormatter setLocale:choosenLocale];
}
[targetFormatter setDateFormat:@"EEEE, LLLL d, yyyy h:mm a"];
[targetFormatter setAMSymbol:@"AM"];
[targetFormatter setPMSymbol:@"PM"];
NSString *toDate = [targetFormatter stringFromDate:fromDate];
NSLog(@"finalString of toDate %@", toDate);
[row replaceCharactersInRange:range withString:toDate];*/
}

if ([[row string] hasPrefix:toPrefix] || [[row string] hasPrefix:ccPrefix])
Expand Down
1 change: 0 additions & 1 deletion ReplyWithHeader/MHQuotedMailOriginal.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
int textNodeLocation; //which
DOMNodeList *dhc; //document header children
int msgComposeType;
BOOL isBlockquotePresent;
}

- (id)initWithMailMessage:(id)mailMessage msgComposeType:(int)composeType;
Expand Down
50 changes: 8 additions & 42 deletions ReplyWithHeader/MHQuotedMailOriginal.m
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ @implementation MHQuotedMailOriginal

- (void)insertForHTMLMail:(DOMDocumentFragment *)headerFragment
{
if (isBlockquotePresent)
if ([self isBlockquoteTagPresent])
{
DOMNode *nodeRef = [self getBlockquoteTagNode];
[nodeRef insertBefore:headerFragment refChild:[nodeRef firstChild]];
Expand All @@ -85,7 +85,7 @@ - (void)insertForPlainMail:(DOMDocumentFragment *)headerFragment
{
if (textNodeLocation >= 0)
{
if (isBlockquotePresent) // include inside blockquote
if ([self isBlockquoteTagPresent]) // include inside blockquote
{
DOMNode *nodeRef = [self getBlockquoteTagNode];
[nodeRef insertBefore:headerFragment refChild:[nodeRef firstChild]];
Expand Down Expand Up @@ -164,7 +164,7 @@ - (id)initWithMailMessage:(id)mailMessage msgComposeType:(int)composeType
dhc = [originalEmail childNodes];

//identifying blockquote tag
isBlockquotePresent = [self isBlockquoteTagPresent]; //[self isTagPresent:TAG_BLOCKQUOTE];
MHLog(@"isBlockquotePresent = %@", [self isBlockquoteTagPresent] ? @"YES" : @"NO");

//now get the quoted content and remove the first part (where it says "On ... X wrote"
// "... message"
Expand Down Expand Up @@ -219,9 +219,9 @@ - (void)removePlainTextHeaderPrefix
DOMNodeList *nodeList;
DOMHTMLElement *emailDocument;

if (IS_MAC_YOSEMITE && isBlockquotePresent)
if (IS_MAC_YOSEMITE && [self isBlockquoteTagPresent])
{
emailDocument = (DOMHTMLElement *)[self getElementByName:TAG_BLOCKQUOTE];
emailDocument = (DOMHTMLElement *)[self getBlockquoteTagNode];
nodeList = [emailDocument childNodes];
}
else
Expand Down Expand Up @@ -270,9 +270,9 @@ - (void)removeHTMLHeaderPrefix
DOMNodeList *nodeList;
DOMHTMLElement *emailDocument;

if (IS_MAC_YOSEMITE && isBlockquotePresent)
if (IS_MAC_YOSEMITE && [self isBlockquoteTagPresent])
{
emailDocument = (DOMHTMLElement *)[self getElementByName:TAG_BLOCKQUOTE];
emailDocument = (DOMHTMLElement *)[self getBlockquoteTagNode];
nodeList = [emailDocument childNodes];
}
else
Expand Down Expand Up @@ -367,19 +367,7 @@ - (void)prepareQuotedPlainText

- (BOOL)isBlockquoteTagPresent
{
BOOL present = FALSE;

for (int i=0; i < dhc.length; i++)
{
if ([[[dhc item:i] nodeName] isEqualToString:TAG_BLOCKQUOTE])
{
present = TRUE;
MHLog(@"%@ Node found at %d", TAG_BLOCKQUOTE, i);
break;
}
}

return present;
return !GET_DEFAULT_BOOL(@"SupressQuoteBarsInComposeWindows");
}

- (DOMNode *)getBlockquoteTagNode
Expand All @@ -397,28 +385,6 @@ - (DOMNode *)getBlockquoteTagNode
return nil;
}

- (BOOL)isTagPresent:(NSString *)tagName
{
BOOL tag = FALSE;
DOMNodeList *nodeList = [self getElementsByName:tagName];
if (nodeList != nil && nodeList.length >= 1)
{
tag = TRUE;
}
MHLog(@"Tag '%@' is present: %@", tagName, tag ? @"YES" : @"NO");
return tag;
}

- (DOMNodeList *)getElementsByName:(NSString *)tagName
{
return [[document htmlDocument] getElementsByTagName:tagName];
}

- (DOMNode *)getElementByName:(NSString *)tagName
{
return [[[document htmlDocument] getElementsByTagName:tagName] item:0];
}

- (DOMDocumentFragment *)paragraphTagToSpanTag:(DOMDocumentFragment *) headerFragment
{
NSString *htmlString = [[headerFragment firstChild] outerHTML];
Expand Down
2 changes: 1 addition & 1 deletion ReplyWithHeader/MailHeader.m
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ + (void)assignUserDefaults
MHDefaultHeaderFontName, MHHeaderFontName,
MHDefaultHeaderFontSize, MHHeaderFontSize,
[NSArchiver archivedDataWithRootObject:[NSColor blackColor]], MHHeaderColor,
[NSNumber numberWithBool:YES], MHSubjectPrefixTextEnabled,
[NSNumber numberWithBool:NO], MHSubjectPrefixTextEnabled,
[NSNumber numberWithBool:NO], MHRemoveSignatureEnabled,
[NSNumber numberWithInt:2], MHHeaderLabelMode,
[NSNumber numberWithInt:2], MHHeaderOrderMode,
Expand Down
4 changes: 2 additions & 2 deletions ReplyWithHeader/Resources/en.lproj/MailHeader-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>4.7</string>
<string>4.8</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>4.7</string>
<string>4.8</string>
<key>LSMinimumSystemVersion</key>
<string>${MACOSX_DEPLOYMENT_TARGET}</string>
<key>MHAppCastURL</key>
Expand Down

0 comments on commit 28bca70

Please sign in to comment.