Skip to content

Commit

Permalink
Converted to Objective-C ARC
Browse files Browse the repository at this point in the history
  • Loading branch information
jeevatkm committed Oct 26, 2013
1 parent c1e35bc commit 527371a
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 56 deletions.
4 changes: 4 additions & 0 deletions ReplyWithHeader.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ENABLE_OBJC_ARC = YES;
COMBINE_HIDPI_IMAGES = YES;
COPY_PHASE_STRIP = YES;
GCC_DYNAMIC_NO_PIC = NO;
Expand All @@ -460,6 +461,7 @@
dynamic_lookup,
);
PRODUCT_NAME = ReplyWithHeader;
SDKROOT = macosx;
STRIP_STYLE = "non-global";
WRAPPER_EXTENSION = mailbundle;
ZERO_LINK = YES;
Expand All @@ -470,6 +472,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ENABLE_OBJC_ARC = YES;
COMBINE_HIDPI_IMAGES = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
GCC_DYNAMIC_NO_PIC = NO;
Expand All @@ -487,6 +490,7 @@
dynamic_lookup,
);
PRODUCT_NAME = ReplyWithHeader;
SDKROOT = macosx;
STRIP_STYLE = "non-global";
WRAPPER_EXTENSION = mailbundle;
};
Expand Down
1 change: 0 additions & 1 deletion ReplyWithHeader/MHHeaderString.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,5 @@
- (WebArchive *)getWebArchive;
- (int)getHeaderItemCount;
- (BOOL)isSuppressLabelsFound;
- (void)dealloc;

@end
29 changes: 8 additions & 21 deletions ReplyWithHeader/MHHeaderString.m
Original file line number Diff line number Diff line change
Expand Up @@ -141,28 +141,15 @@ - (NSString *)stringValue
return headerString.string;
}

- (void)dealloc
{
headerString = nil;
headerItemCount = nil;
isSuppressLabelsFound = nil;

free(headerString);
free(headerItemCount);
free(isSuppressLabelsFound);

[super dealloc];
}

- (id)initWithMailMessage:(id)mailMessage
{
if (self = [super init])
{
[self init];
if (!(self = [self init])) return nil;

//initialze the value with a mutable copy of the attributed string
headerString = [[[mailMessage originalMessageHeaders]
attributedStringShowingHeaderDetailLevel:1] mutableCopy];
attributedStringShowingHeaderDetailLevel:[NSNumber numberWithInt:1]] mutableCopy];

// let's things going
[self fixHeaderString];
Expand Down Expand Up @@ -224,7 +211,7 @@ - (void)suppressImplicateHeaderLabels
{
isSuppressLabelsFound = YES;

NSAttributedString *replaceString = [[[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@""]] autorelease];
NSAttributedString *replaceString = [[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@""]];
[headerString
replaceCharactersInRange:NSMakeRange(range.location, ([headerString length] - range.location)) withAttributedString:replaceString];
}
Expand All @@ -246,15 +233,15 @@ - (void)applyHeaderOrderChange
attributedSubstringFromRange:NSMakeRange([headerString length] - 1, 1)];
if (![[last string] isEqualToString:@"\n"])
{
NSAttributedString *newLine = [[[NSAttributedString alloc] initWithString:@"\n"] autorelease];
NSAttributedString *newLine = [[NSAttributedString alloc] initWithString:@"\n"];
[headerString appendAttributedString:newLine];
}

// Subject: relocation
[headerString appendAttributedString:subAttStr];

// removal of old Subject:
NSAttributedString *replaceString = [[[NSAttributedString alloc] initWithString:@""] autorelease];
NSAttributedString *replaceString = [[NSAttributedString alloc] initWithString:@""];
[headerString replaceCharactersInRange:subCntRange withAttributedString:replaceString];
}
}
Expand Down Expand Up @@ -284,12 +271,12 @@ - (void)applyHeaderLabelChange
// captureing from email id for mailto:
NSString *emailId = [headerString.string substringWithRange:range];
// handling of mailto: for From: tag
NSMutableAttributedString *fromMailId = [[[NSMutableAttributedString alloc]
initWithString:emailId] autorelease];
NSMutableAttributedString *fromMailId = [[NSMutableAttributedString alloc]
initWithString:emailId];
[fromMailId replaceCharactersInRange:NSMakeRange(0, 2) withString:@" [mailto:"];
[fromMailId replaceCharactersInRange:NSMakeRange(fromMailId.length - 1, 1) withString:@"]"];

NSAttributedString *emlRplStr = [[[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@";"]] autorelease];
NSAttributedString *emlRplStr = [[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@";"]];
while (range.length != 0)
{
[headerString replaceCharactersInRange:range withAttributedString:emlRplStr];
Expand Down
2 changes: 0 additions & 2 deletions ReplyWithHeader/MHHeadersEditor.m
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ - (void)MHLoadHeadersFromBackEnd:(id)arg1

// cascading subject text change
[self _subjectChanged];

CLEAN(subjectText);
}
}

Expand Down
6 changes: 1 addition & 5 deletions ReplyWithHeader/MHMessage.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#import "MHHeaderString.h"

@interface MHMessage (MHNoImplementation)
- (id)type;
- (int)type;
@end

@implementation MHMessage
Expand All @@ -56,10 +56,6 @@ - (void)MH_continueToSetupContentsForView:(id)arg1 withParsedMessages:(id)arg2

//insert the new header text
[quotedText insertMailHeader:newheaderString msgComposeType:msgCompose];

// once done recycle it
CLEAN(newheaderString);
CLEAN(quotedText);
}
}

Expand Down
4 changes: 0 additions & 4 deletions ReplyWithHeader/MHPreferences.m
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,6 @@ - (IBAction)openFeedback:(id)sender
[infoAlert runModal];

[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"http://myjeeva.com/replywithheader#wp-comments"]];

CLEAN(infoAlert);
}

- (IBAction)openSupport:(id)sender
Expand Down Expand Up @@ -174,8 +172,6 @@ - (IBAction)notifyNewVersionPressed:(id)sender

[_MHNotifyNewVersion setState:YES];
}

CLEAN(alert);
}
}

Expand Down
13 changes: 7 additions & 6 deletions ReplyWithHeader/MHQuotedMailOriginal.m
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,13 @@
//
// MHQuotedMailOriginal Class refactored & completely rewritten by Jeevanandam M. on Sep 22, 2013

#import "WebKit/DOMHTMLBRElement.h"
#import "WebKit/DOMDocumentFragment.h"
#import "WebKit/DOMHTMLDivElement.h"
#import "WebKit/DOMHTMLDocument.h"
#import "WebKit/DOMNodeList.h"
#import "WebKit/DOMElement.h"
#import <WebKit/DOMHTMLBRElement.h>
#import <WebKit/DOMDocumentFragment.h>
#import <WebKit/DOMHTMLDivElement.h>
#import <WebKit/DOMHTMLDocument.h>
#import <WebKit/DOMHTMLCollection.h>
#import <WebKit/DOMNodeList.h>
#import <WebKit/DOMElement.h>

#import "MHQuotedMailOriginal.h"
#import "MHHeaderString.h"
Expand Down
10 changes: 0 additions & 10 deletions ReplyWithHeader/MHUpdater.m
Original file line number Diff line number Diff line change
Expand Up @@ -99,19 +99,9 @@ - (id)init
{
MHLog(@"RWH new version availabilty check failed. May be internet connection unavailable.");
}

CLEAN(appCastData);
}

return self;
}

- (void)dealloc
{
CLEAN(comparator);
CLEAN(jsonDic);
CLEAN(_alert);
[super dealloc];
}

@end
2 changes: 0 additions & 2 deletions ReplyWithHeader/MLog.m
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ + (void) logFile: (char *) sourceFile lineNumber: (int) lineNumber format: (NSSt
// NSLog handles synchronization issues
NSLog(@"%s: %d %@", [[file lastPathComponent] UTF8String], lineNumber, print);

[print release];
[file release];

return;
}
Expand Down
4 changes: 1 addition & 3 deletions ReplyWithHeader/MailHeader_Prefix.pch
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,4 @@
#define GET_DEFAULT_INT(k) [[NSUserDefaults standardUserDefaults] integerForKey: k]
#define SET_DEFAULT_INT(n,k)[[NSUserDefaults standardUserDefaults] setInteger: n forKey: k]

#define MHLocalizedString(key) [MailHeader localizedString:(key)]

#define CLEAN(o) { if(o) { [o release]; o = nil; } }
#define MHLocalizedString(key) [MailHeader localizedString:(key)]
4 changes: 2 additions & 2 deletions ReplyWithHeader/SUStandardVersionComparator.m
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ - (NSArray *)splitVersionString:(NSString *)version
// Nothing to do here
return parts;
}
s = [[[version substringToIndex:1] mutableCopy] autorelease];
s = [[version substringToIndex:1] mutableCopy];
oldType = [self typeOfCharacter:s];
n = [version length] - 1;
for (i = 1; i <= n; ++i) {
character = [version substringWithRange:NSMakeRange(i, 1)];
newType = [self typeOfCharacter:character];
if (oldType != newType || oldType == kSeparatorType) {
// We've reached a new segment
NSString *aPart = [[[NSString alloc] initWithString:s] autorelease];
NSString *aPart = [[NSString alloc] initWithString:s];
[parts addObject:aPart];
[s setString:character];
} else {
Expand Down

0 comments on commit 527371a

Please sign in to comment.