adium 4356:a0d4ead5c91e: Use a serial dispatch queue for all sha...
commits at adium.im
commits at adium.im
Thu Dec 8 23:28:37 UTC 2011
details: http://hg.adium.im/adium/rev/a0d4ead5c91e
revision: 4356:a0d4ead5c91e
branch: (none)
author: Thijs Alkemade <thijsalkemade at gmail.com>
date: Fri Dec 09 00:28:23 2011 +0100
Use a serial dispatch queue for all shared localized NSDateFormatter uses.
Refs #15556
diffs (572 lines):
diff -r 13a64cb2366c -r a0d4ead5c91e Frameworks/AIUtilities Framework/Source/AIDateFormatterAdditions.h
--- a/Frameworks/AIUtilities Framework/Source/AIDateFormatterAdditions.h Thu Dec 08 22:53:57 2011 +0100
+++ b/Frameworks/AIUtilities Framework/Source/AIDateFormatterAdditions.h Fri Dec 09 00:28:23 2011 +0100
@@ -16,9 +16,9 @@
@interface NSDateFormatter (AIDateFormatterAdditions)
-+ (NSDateFormatter *)localizedDateFormatter;
-+ (NSDateFormatter *)localizedShortDateFormatter;
-+ (NSDateFormatter *)localizedDateFormatterShowingSeconds:(BOOL)seconds showingAMorPM:(BOOL)showAmPm;
++ (void)withLocalizedDateFormatterPerform:(void (^)(NSDateFormatter *))block;
++ (void)withLocalizedShortDateFormatterPerform:(void (^)(NSDateFormatter *))block;
++ (void)withLocalizedDateFormatterShowingSeconds:(BOOL)seconds showingAMorPM:(BOOL)showAmPm perform:(void (^)(NSDateFormatter *))block;
+ (NSString *)localizedDateFormatStringShowingSeconds:(BOOL)seconds showingAMorPM:(BOOL)showAmPm;
+ (NSString *)stringForTimeIntervalSinceDate:(NSDate *)inDate;
+ (NSString *)stringForTimeIntervalSinceDate:(NSDate *)inDate showingSeconds:(BOOL)showSeconds abbreviated:(BOOL)abbreviate;
diff -r 13a64cb2366c -r a0d4ead5c91e Frameworks/AIUtilities Framework/Source/AIDateFormatterAdditions.m
--- a/Frameworks/AIUtilities Framework/Source/AIDateFormatterAdditions.m Thu Dec 08 22:53:57 2011 +0100
+++ b/Frameworks/AIUtilities Framework/Source/AIDateFormatterAdditions.m Fri Dec 09 00:28:23 2011 +0100
@@ -112,10 +112,57 @@
}
@end
+ at interface NSDateFormatter (PRIVATE)
++ (NSDateFormatter *)localizedDateFormatter;
++ (NSDateFormatter *)localizedShortDateFormatter;
++ (NSDateFormatter *)localizedDateFormatterShowingSeconds:(BOOL)seconds showingAMorPM:(BOOL)showAmPm;
+ at end
+
@implementation NSDateFormatter (AIDateFormatterAdditions)
++ (dispatch_queue_t)localizedFormatterQueue
+{
+ static dispatch_once_t onceToken;
+ static dispatch_queue_t localizedFormatterQueue;
+ dispatch_once(&onceToken, ^{
+ localizedFormatterQueue = dispatch_queue_create("im.adium.LocalizedDateFormatterQueue", NULL);
+ });
+
+ return localizedFormatterQueue;
+}
+
++ (void)withLocalizedDateFormatterPerform:(void (^)(NSDateFormatter *))block
+{
+ dispatch_queue_t localizedFormatterQueue = [self localizedFormatterQueue];
+
+ dispatch_sync(localizedFormatterQueue, ^{
+ block([self localizedDateFormatter]);
+ });
+}
+
++ (void)withLocalizedShortDateFormatterPerform:(void (^)(NSDateFormatter *))block
+{
+ dispatch_queue_t localizedFormatterQueue = [self localizedFormatterQueue];
+
+ dispatch_sync(localizedFormatterQueue, ^{
+ block([self localizedShortDateFormatter]);
+ });
+}
+
++ (void)withLocalizedDateFormatterShowingSeconds:(BOOL)seconds showingAMorPM:(BOOL)showAmPm perform:(void (^)(NSDateFormatter *))block
+{
+ dispatch_queue_t localizedFormatterQueue = [self localizedFormatterQueue];
+
+ dispatch_sync(localizedFormatterQueue, ^{
+ block([self localizedDateFormatterShowingSeconds:seconds showingAMorPM:showAmPm]);
+ });
+}
+
+
+ (NSDateFormatter *)localizedDateFormatter
{
+ NSAssert(dispatch_get_current_queue() == [self localizedFormatterQueue], @"Wrong queue");
+
// Thursday, July 31, 2008
NSDateFormatter **cachePointer = [[AIDateFormatterCache sharedInstance] formatter];
@@ -131,6 +178,8 @@
+ (NSDateFormatter *)localizedShortDateFormatter
{
+ NSAssert(dispatch_get_current_queue() == [self localizedFormatterQueue], @"Wrong queue");
+
// 7/31/08
NSDateFormatter **cachePointer = [[AIDateFormatterCache sharedInstance] shortFormatter];
@@ -146,6 +195,8 @@
+ (NSDateFormatter *)localizedDateFormatterShowingSeconds:(BOOL)seconds showingAMorPM:(BOOL)showAmPm
{
+ NSAssert(dispatch_get_current_queue() == [self localizedFormatterQueue], @"Wrong queue");
+
NSDateFormatter **cachePointer = [[AIDateFormatterCache sharedInstance] formatterShowingSeconds:seconds showingAMorPM:showAmPm];
if (!(*cachePointer)) {
@@ -157,6 +208,8 @@
+ (NSString *)localizedDateFormatStringShowingSeconds:(BOOL)seconds showingAMorPM:(BOOL)showAmPm
{
+ NSAssert(dispatch_get_current_queue() == [self localizedFormatterQueue], @"Wrong queue");
+
NSString *formatString;
NSDateFormatter **cachePointer = [[AIDateFormatterCache sharedInstance] formatterShowingSeconds:seconds showingAMorPM:showAmPm];
diff -r 13a64cb2366c -r a0d4ead5c91e Plugins/Dual Window Interface/ESDualWindowMessageAdvancedPreferences.m
--- a/Plugins/Dual Window Interface/ESDualWindowMessageAdvancedPreferences.m Thu Dec 08 22:53:57 2011 +0100
+++ b/Plugins/Dual Window Interface/ESDualWindowMessageAdvancedPreferences.m Fri Dec 09 00:28:23 2011 +0100
@@ -201,22 +201,44 @@
NSMenu *menu = [[NSMenu allocWithZone:[NSMenu menuZone]] initWithTitle:@""];
//Generate all the available time stamp formats
- NSDateFormatter *noSecondsNoAMPM = [NSDateFormatter localizedDateFormatterShowingSeconds:NO showingAMorPM:NO];
- NSDateFormatter *noSecondsAMPM = [NSDateFormatter localizedDateFormatterShowingSeconds:NO showingAMorPM:YES];
- NSDateFormatter *secondsNoAMPM = [NSDateFormatter localizedDateFormatterShowingSeconds:YES showingAMorPM:NO];
- NSDateFormatter *secondsAMPM = [NSDateFormatter localizedDateFormatterShowingSeconds:YES showingAMorPM:YES];
+// NSDateFormatter *noSecondsNoAMPM = [NSDateFormatter localizedDateFormatterShowingSeconds:NO showingAMorPM:NO];
+// NSDateFormatter *noSecondsAMPM = [NSDateFormatter localizedDateFormatterShowingSeconds:NO showingAMorPM:YES];
+// NSDateFormatter *secondsNoAMPM = [NSDateFormatter localizedDateFormatterShowingSeconds:YES showingAMorPM:NO];
+// NSDateFormatter *secondsAMPM = [NSDateFormatter localizedDateFormatterShowingSeconds:YES showingAMorPM:YES];
//If there is no difference between the time stamp with AM/PM and the one without, the localized time stamp must
//not include AM/PM. Since these menu items would appear as duplicates we exclude them.
- NSString *sampleStampA = [noSecondsAMPM stringForObjectValue:[NSDate date]];
- NSString *sampleStampB = [noSecondsNoAMPM stringForObjectValue:[NSDate date]];
+
+ __block NSString *sampleStampA, *sampleStampB;
+
+ [NSDateFormatter withLocalizedDateFormatterShowingSeconds:NO showingAMorPM:YES perform:^(NSDateFormatter *noSecondsAMPM){
+ sampleStampA = [[noSecondsAMPM stringForObjectValue:[NSDate date]] retain];
+ }];
+ [sampleStampA autorelease];
+
+ [NSDateFormatter withLocalizedDateFormatterShowingSeconds:NO showingAMorPM:NO perform:^(NSDateFormatter *noSecondsNoAMPM){
+ sampleStampB = [[noSecondsNoAMPM stringForObjectValue:[NSDate date]] retain];
+ }];
+ [sampleStampB autorelease];
+
BOOL noAMPM = [sampleStampA isEqualToString:sampleStampB];
//Build the menu from the available formats
- [self _addTimeStampChoice:noSecondsNoAMPM toMenu:menu];
- if (!noAMPM) [self _addTimeStampChoice:noSecondsAMPM toMenu:menu];
- [self _addTimeStampChoice:secondsNoAMPM toMenu:menu];
- if (!noAMPM) [self _addTimeStampChoice:secondsAMPM toMenu:menu];
+ [NSDateFormatter withLocalizedDateFormatterShowingSeconds:NO showingAMorPM:NO perform:^(NSDateFormatter *noSecondsNoAMPM){
+ [self _addTimeStampChoice:noSecondsNoAMPM toMenu:menu];
+ }];
+
+ [NSDateFormatter withLocalizedDateFormatterShowingSeconds:NO showingAMorPM:YES perform:^(NSDateFormatter *noSecondsAMPM){
+ if (!noAMPM) [self _addTimeStampChoice:noSecondsAMPM toMenu:menu];
+ }];
+
+ [NSDateFormatter withLocalizedDateFormatterShowingSeconds:YES showingAMorPM:NO perform:^(NSDateFormatter *secondsNoAMPM){
+ [self _addTimeStampChoice:secondsNoAMPM toMenu:menu];
+ }];
+
+ [NSDateFormatter withLocalizedDateFormatterShowingSeconds:YES showingAMorPM:YES perform:^(NSDateFormatter *secondsAMPM){
+ if (!noAMPM) [self _addTimeStampChoice:secondsAMPM toMenu:menu];
+ }];
return menu;
}
diff -r 13a64cb2366c -r a0d4ead5c91e Plugins/Error Message Handler/ErrorMessageHandlerPlugin.m
--- a/Plugins/Error Message Handler/ErrorMessageHandlerPlugin.m Thu Dec 08 22:53:57 2011 +0100
+++ b/Plugins/Error Message Handler/ErrorMessageHandlerPlugin.m Fri Dec 09 00:28:23 2011 +0100
@@ -108,7 +108,13 @@
- (BOOL)performActionID:(NSString *)actionID forListObject:(AIListObject *)listObject withDetails:(NSDictionary *)details triggeringEventID:(NSString *)eventID userInfo:(id)userInfo
{
- NSString *dateString = [[NSDateFormatter localizedDateFormatterShowingSeconds:NO showingAMorPM:YES] stringFromDate:[NSCalendarDate calendarDate]];
+ __block NSString *dateString;
+
+ [NSDateFormatter withLocalizedDateFormatterShowingSeconds:NO showingAMorPM:YES perform:^(NSDateFormatter *dateFormatter){
+ dateString = [[dateFormatter stringFromDate:[NSCalendarDate calendarDate]] retain];
+ }];
+ [dateString autorelease];
+
NSString *alertText = [[details objectForKey:KEY_ALERT_TEXT] lastPathComponent];
//Display an alert
diff -r 13a64cb2366c -r a0d4ead5c91e Plugins/Message Alias Support/AIMessageAliasPlugin.m
--- a/Plugins/Message Alias Support/AIMessageAliasPlugin.m Thu Dec 08 22:53:57 2011 +0100
+++ b/Plugins/Message Alias Support/AIMessageAliasPlugin.m Fri Dec 09 00:28:23 2011 +0100
@@ -172,8 +172,11 @@
//Current Date
if ([self string:str containsValidKeyword:@"%d"]) {
NSCalendarDate *currentDate = [NSCalendarDate calendarDate];
- NSDateFormatter *dateFormatter = [NSDateFormatter localizedShortDateFormatter];
- NSString *calendarFormat = [dateFormatter dateFormat];
+ __block NSString *calendarFormat;
+ [NSDateFormatter withLocalizedShortDateFormatterPerform:^(NSDateFormatter *dateFormatter){
+ calendarFormat = [[dateFormatter dateFormat] retain];
+ }];
+ [calendarFormat autorelease];
if (!newAttributedString) newAttributedString = [[attributedString mutableCopy] autorelease];
@@ -186,15 +189,15 @@
//Current Time
if ([self string:str containsValidKeyword:@"%t"]) {
NSCalendarDate *currentDate = [NSCalendarDate calendarDate];
- NSDateFormatter *localDateFormatter = [NSDateFormatter localizedDateFormatterShowingSeconds:YES
- showingAMorPM:YES];
if (!newAttributedString) newAttributedString = [[attributedString mutableCopy] autorelease];
- [newAttributedString replaceOccurrencesOfString:@"%t"
- withString:[localDateFormatter stringFromDate:currentDate]
- options:NSLiteralSearch
- range:NSMakeRange(0, [newAttributedString length])];
+ [NSDateFormatter withLocalizedDateFormatterShowingSeconds:YES showingAMorPM:YES perform:^(NSDateFormatter *localDateFormatter){
+ [newAttributedString replaceOccurrencesOfString:@"%t"
+ withString:[localDateFormatter stringFromDate:currentDate]
+ options:NSLiteralSearch
+ range:NSMakeRange(0, [newAttributedString length])];
+ }];
}
return newAttributedString;
diff -r 13a64cb2366c -r a0d4ead5c91e Plugins/Purple Service/CBPurpleOscarAccount.m
--- a/Plugins/Purple Service/CBPurpleOscarAccount.m Thu Dec 08 22:53:57 2011 +0100
+++ b/Plugins/Purple Service/CBPurpleOscarAccount.m Fri Dec 09 00:28:23 2011 +0100
@@ -819,12 +819,10 @@
- (NSString *)localizedDateAndTimeFromString:(NSString *)inDateAndTime includeTimeWithDay:(BOOL)includeTimeWithDay
{
NSString *replacementString = nil;
- NSDateFormatter *dayFormatter = [NSDateFormatter localizedDateFormatter];
- NSDateFormatter *timeFormatter = [NSDateFormatter localizedDateFormatterShowingSeconds:NO showingAMorPM:YES];
struct tm tm;
if (inDateAndTime && (strptime([inDateAndTime UTF8String], "%c", &tm) != NULL)) {
- NSString *valueDay, *valueTime;
+ __block NSString *valueDay, *valueTime;
NSDate *date;
/* Not set by strptime(); tells mktime()
* to determine whether daylight saving time
@@ -834,16 +832,29 @@
date = [NSDate dateWithTimeIntervalSince1970:mktime(&tm)];
//Get day & time strings
- valueDay = [dayFormatter stringForObjectValue:date];
- valueTime = [timeFormatter stringForObjectValue:date];
+ [NSDateFormatter withLocalizedDateFormatterPerform:^(NSDateFormatter *dayFormatter){
+ valueDay = [[dayFormatter stringForObjectValue:date] retain];
+ }];
+ [NSDateFormatter withLocalizedDateFormatterShowingSeconds:NO showingAMorPM:YES perform:^(NSDateFormatter *timeFormatter) {
+ valueTime = [[timeFormatter stringForObjectValue:date] retain];
+ }];
if (valueDay && valueTime) {
- if ([[dayFormatter stringForObjectValue:[NSDate date]] isEqualToString:valueDay])
+ __block BOOL cond;
+
+ [NSDateFormatter withLocalizedDateFormatterPerform:^(NSDateFormatter *dayFormatter){
+ cond = [[dayFormatter stringForObjectValue:[NSDate date]] isEqualToString:valueDay];
+ }];
+
+ if (cond)
//Show time
replacementString = valueTime;
else
replacementString = (includeTimeWithDay ? [NSString stringWithFormat:@"%@, %@", valueDay, valueTime] : valueDay);
}
+
+ [valueDay release];
+ [valueTime release];
}
return replacementString;
diff -r 13a64cb2366c -r a0d4ead5c91e Plugins/WebKit Message View/AIWebKitMessageViewController.m
--- a/Plugins/WebKit Message View/AIWebKitMessageViewController.m Thu Dec 08 22:53:57 2011 +0100
+++ b/Plugins/WebKit Message View/AIWebKitMessageViewController.m Fri Dec 09 00:28:23 2011 +0100
@@ -673,7 +673,11 @@
if ((!previousContent && [content isKindOfClass:[AIContentContext class]]) ||
(![content isFromSameDayAsContent:previousContent])) {
- NSString *dateMessage = [[NSDateFormatter localizedDateFormatter] stringFromDate:content.date];
+ __block NSString *dateMessage;
+ [NSDateFormatter withLocalizedDateFormatterPerform:^(NSDateFormatter *dateFormatter){
+ dateMessage = [[dateFormatter stringFromDate:content.date] retain];
+ }];
+ [dateMessage autorelease];
dateSeparator = [AIContentEvent statusInChat:content.chat
withSource:content.chat.listObject
diff -r 13a64cb2366c -r a0d4ead5c91e Plugins/WebKit Message View/AIWebkitMessageViewStyle.m
--- a/Plugins/WebKit Message View/AIWebkitMessageViewStyle.m Thu Dec 08 22:53:57 2011 +0100
+++ b/Plugins/WebKit Message View/AIWebkitMessageViewStyle.m Fri Dec 09 00:28:23 2011 +0100
@@ -771,7 +771,12 @@
[inString replaceKeyword:@"%time%"
withString:(date ? [timeStampFormatter stringFromDate:date] : @"")];
- NSString *shortTimeString = (date ? [[NSDateFormatter localizedDateFormatterShowingSeconds:NO showingAMorPM:NO] stringFromDate:date] : @"");
+ __block NSString *shortTimeString;
+ [NSDateFormatter withLocalizedDateFormatterShowingSeconds:NO showingAMorPM:NO perform:^(NSDateFormatter *dateFormatter){
+ shortTimeString = (date ? [[dateFormatter stringFromDate:date] retain] : @"");
+ }];
+ [shortTimeString autorelease];
+
[inString replaceKeyword:@"%shortTime%"
withString:shortTimeString];
@@ -1280,8 +1285,10 @@
}
} while (range.location != NSNotFound);
- [inString replaceKeyword:@"%dateOpened%"
- withString:[[NSDateFormatter localizedDateFormatter] stringFromDate:[chat dateOpened]]];
+ [NSDateFormatter withLocalizedDateFormatterPerform:^(NSDateFormatter *dateFormatter){
+ [inString replaceKeyword:@"%dateOpened%"
+ withString:[dateFormatter stringFromDate:[chat dateOpened]]];
+ }];
//Background
{
diff -r 13a64cb2366c -r a0d4ead5c91e Source/AIContactOnlineSincePlugin.m
--- a/Source/AIContactOnlineSincePlugin.m Thu Dec 08 22:53:57 2011 +0100
+++ b/Source/AIContactOnlineSincePlugin.m Fri Dec 09 00:28:23 2011 +0100
@@ -51,16 +51,21 @@
NSDate *signonDate;
if ([inObject isKindOfClass:[AIListContact class]] &&
- (signonDate = [(AIListContact *)inObject signonDate])) {
- //Create the formatters
- NSDateFormatter *dayFormatter = [NSDateFormatter localizedShortDateFormatter];
-
- NSDateFormatter *timeFormatter = [NSDateFormatter localizedDateFormatterShowingSeconds:NO showingAMorPM:YES];
+ (signonDate = [(AIListContact *)inObject signonDate])) {
//Get day & time strings
- NSString *currentDay = [dayFormatter stringForObjectValue:[NSDate date]];
- NSString *signonDay = [dayFormatter stringForObjectValue:signonDate];
- NSString *signonTime = [timeFormatter stringForObjectValue:signonDate];
+ __block NSString *currentDay, *signonDay, *signonTime;
+ [NSDateFormatter withLocalizedShortDateFormatterPerform:^(NSDateFormatter *dayFormatter){
+ currentDay = [[dayFormatter stringForObjectValue:[NSDate date]] retain];
+ signonDay = [[dayFormatter stringForObjectValue:signonDate] retain];
+ }];
+ [currentDay autorelease];
+ [signonDay autorelease];
+
+ [NSDateFormatter withLocalizedDateFormatterShowingSeconds:NO showingAMorPM:YES perform:^(NSDateFormatter *timeFormatter){
+ signonTime = [[timeFormatter stringForObjectValue:signonDate] retain];
+ }];
+ [signonTime autorelease];
if ([currentDay isEqualToString:signonDay]) { //Show time
entry = [[NSAttributedString alloc] initWithString:signonTime];
diff -r 13a64cb2366c -r a0d4ead5c91e Source/AIInfoInspectorPane.m
--- a/Source/AIInfoInspectorPane.m Thu Dec 08 22:53:57 2011 +0100
+++ b/Source/AIInfoInspectorPane.m Fri Dec 09 00:28:23 2011 +0100
@@ -702,10 +702,12 @@
break;
case kABMultiDateProperty:
if (innerValue) {
- [profileArray addObject:[NSDictionary dictionaryWithObjectsAndKeys:
- [NSString stringWithFormat:@"%@ (%@)", ABLocalizedPropertyOrLabel(property), label], KEY_KEY,
- [[NSDateFormatter localizedDateFormatter] stringFromDate:(NSDate *)innerValue], KEY_VALUE,
- nil]];
+ [NSDateFormatter withLocalizedShortDateFormatterPerform:^(NSDateFormatter *dateFormatter){
+ [profileArray addObject:[NSDictionary dictionaryWithObjectsAndKeys:
+ [NSString stringWithFormat:@"%@ (%@)", ABLocalizedPropertyOrLabel(property), label], KEY_KEY,
+ [dateFormatter stringFromDate:(NSDate *)innerValue], KEY_VALUE,
+ nil]];
+ }];
}
break;
case kABMultiArrayProperty:
@@ -798,10 +800,12 @@
}
case kABDateProperty:
if (value) {
- [profileArray addObject:[NSDictionary dictionaryWithObjectsAndKeys:
- ABLocalizedPropertyOrLabel(property), KEY_KEY,
- [[NSDateFormatter localizedDateFormatter] stringFromDate:(NSDate *)value], KEY_VALUE,
- nil]];
+ [NSDateFormatter withLocalizedDateFormatterPerform:^(NSDateFormatter *dateFormatter){
+ [profileArray addObject:[NSDictionary dictionaryWithObjectsAndKeys:
+ ABLocalizedPropertyOrLabel(property), KEY_KEY,
+ [dateFormatter stringFromDate:(NSDate *)value], KEY_VALUE,
+ nil]];
+ }];
}
case kABArrayProperty:
case kABDictionaryProperty:
diff -r 13a64cb2366c -r a0d4ead5c91e Source/AILogViewerWindowController.h
--- a/Source/AILogViewerWindowController.h Thu Dec 08 22:53:57 2011 +0100
+++ b/Source/AILogViewerWindowController.h Fri Dec 09 00:28:23 2011 +0100
@@ -109,7 +109,6 @@
NSImage *adiumIconHighlighted;
NSMutableArray *toArray; //Array of contacts
- NSDateFormatter *headerDateFormatter; //Format for dates displayed in the content text view
NSInteger cachedSelectionIndex;
BOOL deleteOccurred; // YES only if a delete occurs, allowing the table to preserve selection after a search begins
diff -r 13a64cb2366c -r a0d4ead5c91e Source/AILogViewerWindowController.m
--- a/Source/AILogViewerWindowController.m Thu Dec 08 22:53:57 2011 +0100
+++ b/Source/AILogViewerWindowController.m Fri Dec 09 00:28:23 2011 +0100
@@ -243,8 +243,6 @@
sortDirection = YES;
searchMode = LOG_SEARCH_CONTENT;
- headerDateFormatter = [[NSDateFormatter localizedDateFormatter] retain];
-
currentSearchResults = [[NSMutableArray alloc] init];
logFromGroupDict = [[NSMutableDictionary alloc] init];
toArray = [[NSMutableArray alloc] init];
@@ -271,7 +269,6 @@
[toArray release];
[currentSearchResults release];
[selectedColumn release];
- [headerDateFormatter release];
[displayedLogArray release];
[blankImage release];
[activeSearchString release];
@@ -758,13 +755,15 @@
horizontalRule = [[NSString alloc] initWithCharacters:separatorUTF16 length:HORIZONTAL_RULE_LENGTH];
}
- [displayText appendString:[NSString stringWithFormat:@"%@%@\n%@ - %@\n%@\n\n",
- (appendedFirstLog ? @"\n" : @""),
- horizontalRule,
- [headerDateFormatter stringFromDate:[theLog date]],
- [theLog to],
- horizontalRule]
- withAttributes:[[AITextAttributes textAttributesWithFontFamily:@"Helvetica" traits:NSBoldFontMask size:12] dictionary]];
+ [NSDateFormatter withLocalizedDateFormatterPerform:^(NSDateFormatter *headerDateFormatter){
+ [displayText appendString:[NSString stringWithFormat:@"%@%@\n%@ - %@\n%@\n\n",
+ (appendedFirstLog ? @"\n" : @""),
+ horizontalRule,
+ [headerDateFormatter stringFromDate:[theLog date]],
+ [theLog to],
+ horizontalRule]
+ withAttributes:[[AITextAttributes textAttributesWithFontFamily:@"Helvetica" traits:NSBoldFontMask size:12] dictionary]];
+ }];
}
if ([[theLog relativePath] hasSuffix:@".AdiumHTMLLog"] || [[theLog relativePath] hasSuffix:@".html"] || [[theLog relativePath] hasSuffix:@".html.bak"]) {
diff -r 13a64cb2366c -r a0d4ead5c91e Source/AIXMLChatlogConverter.m
--- a/Source/AIXMLChatlogConverter.m Thu Dec 08 22:53:57 2011 +0100
+++ b/Source/AIXMLChatlogConverter.m Fri Dec 09 00:28:23 2011 +0100
@@ -261,9 +261,10 @@
__block NSString *timestampStr = nil;
- dispatch_sync(dispatch_get_main_queue(), ^{
- timestampStr = [[[NSDateFormatter localizedDateFormatterShowingSeconds:YES showingAMorPM:YES] stringFromDate:date] retain];
- });
+ [NSDateFormatter withLocalizedDateFormatterShowingSeconds:YES showingAMorPM:YES perform:^(NSDateFormatter *dateFormatter){
+ timestampStr = [[dateFormatter stringFromDate:date] retain];
+ }];
+
[output appendAttributedString:[htmlDecoder decodeHTML:[NSString stringWithFormat:
@"<div class=\"%@\">%@<span class=\"sender\">%@%@:</span></div> ",
@@ -305,9 +306,9 @@
__block NSString *timestampStr = nil;
- dispatch_sync(dispatch_get_main_queue(), ^{
- timestampStr = [[[NSDateFormatter localizedDateFormatterShowingSeconds:YES showingAMorPM:YES] stringFromDate:date] retain];
- });
+ [NSDateFormatter withLocalizedDateFormatterShowingSeconds:YES showingAMorPM:YES perform:^(NSDateFormatter *dateFormatter){
+ timestampStr = [[dateFormatter stringFromDate:date] retain];
+ }];
if([displayMessage length]) {
[output appendAttributedString:[htmlDecoder decodeHTML:[NSString stringWithFormat:@"<div class=\"status\">%@ (%@)</div>\n",
diff -r 13a64cb2366c -r a0d4ead5c91e Source/CBContactLastSeenPlugin.m
--- a/Source/CBContactLastSeenPlugin.m Thu Dec 08 22:53:57 2011 +0100
+++ b/Source/CBContactLastSeenPlugin.m Fri Dec 09 00:28:23 2011 +0100
@@ -125,9 +125,11 @@
sinceDateFormatter = [[[NSDateFormatter alloc] init] autorelease];
[sinceDateFormatter setFormatterBehavior:NSDateFormatterBehavior10_4];
- [sinceDateFormatter setDateFormat:[NSString stringWithFormat:@"%@, %@",
- [[NSDateFormatter localizedShortDateFormatter] dateFormat],
- [NSDateFormatter localizedDateFormatStringShowingSeconds:NO showingAMorPM:YES]]];
+ [NSDateFormatter withLocalizedShortDateFormatterPerform:^(NSDateFormatter *dateFormatter){
+ [sinceDateFormatter setDateFormat:[NSString stringWithFormat:@"%@, %@",
+ [dateFormatter dateFormat],
+ [NSDateFormatter localizedDateFormatStringShowingSeconds:NO showingAMorPM:YES]]];
+ }];
//stringForTimeIntervalSinceDate may return @"" if it's too short of an interval.
timeElapsed = [NSDateFormatter stringForTimeIntervalSinceDate:lastSeenDate showingSeconds:NO abbreviated:NO];
diff -r 13a64cb2366c -r a0d4ead5c91e Source/ESAnnouncerPlugin.m
--- a/Source/ESAnnouncerPlugin.m Thu Dec 08 22:53:57 2011 +0100
+++ b/Source/ESAnnouncerPlugin.m Fri Dec 09 00:28:23 2011 +0100
@@ -148,13 +148,13 @@
}
- if ([userText rangeOfString:@"%t"].location != NSNotFound) {
- NSDateFormatter *timeFormatter = [NSDateFormatter localizedDateFormatterShowingSeconds:YES showingAMorPM:NO];
-
- [userText replaceOccurrencesOfString:@"%t"
- withString:[timeFormatter stringFromDate:[NSDate date]]
- options:NSLiteralSearch
- range:NSMakeRange(0,[userText length])];
+ if ([userText rangeOfString:@"%t"].location != NSNotFound) {
+ [NSDateFormatter withLocalizedDateFormatterShowingSeconds:YES showingAMorPM:NO perform:^(NSDateFormatter *timeFormatter){
+ [userText replaceOccurrencesOfString:@"%t"
+ withString:[timeFormatter stringFromDate:[NSDate date]]
+ options:NSLiteralSearch
+ range:NSMakeRange(0,[userText length])];
+ }];
}
@@ -188,11 +188,6 @@
} else { /*Speak Event*/
BOOL speakSender = [[details objectForKey:KEY_ANNOUNCER_SENDER] boolValue];
BOOL speakTime = [[details objectForKey:KEY_ANNOUNCER_TIME] boolValue];
- NSDateFormatter *timeFormatter;
-
- timeFormatter = (speakTime ?
- [NSDateFormatter localizedDateFormatterShowingSeconds:YES showingAMorPM:NO] :
- nil);
//Handle messages in a custom manner
if ([adium.contactAlertsController isMessageEvent:eventID] &&
@@ -233,8 +228,10 @@
}
//Append the date if desired, after the sender name if that was added
- if (timeFormatter) {
- [theMessage appendFormat:@" %@...", [timeFormatter stringFromDate:[content date]]];
+ if (speakTime) {
+ [NSDateFormatter withLocalizedDateFormatterShowingSeconds:YES showingAMorPM:NO perform:^(NSDateFormatter *timeFormatter){
+ [theMessage appendFormat:@" %@...", [timeFormatter stringFromDate:[content date]]];
+ }];
}
if (newParagraph) [theMessage appendFormat:@" [[pmod +1; pbas +1]]"];
@@ -255,10 +252,13 @@
userInfo:userInfo
includeSubject:YES];
- if (timeFormatter) {
- NSString *timeString;
+ if (speakTime) {
+ __block NSString *timeString;
- timeString = [NSString stringWithFormat:@"%@... ", [timeFormatter stringFromDate:[NSDate date]]];
+ [NSDateFormatter withLocalizedDateFormatterShowingSeconds:YES showingAMorPM:NO perform:^(NSDateFormatter *timeFormatter){
+ timeString = [[NSString stringWithFormat:@"%@... ", [timeFormatter stringFromDate:[NSDate date]]] retain];
+ }];
+ [timeString autorelease];
textToSpeak = [timeString stringByAppendingString:eventDescription];
} else {
diff -r 13a64cb2366c -r a0d4ead5c91e Source/LNAboutBoxController.m
--- a/Source/LNAboutBoxController.m Thu Dec 08 22:53:57 2011 +0100
+++ b/Source/LNAboutBoxController.m Fri Dec 09 00:28:23 2011 +0100
@@ -123,8 +123,13 @@
- (NSString *)AI_applicationDate
{
NSTimeInterval date = [[[NSBundle mainBundle] objectForInfoDictionaryKey:@"AIBuildDate"] doubleValue];
-
- return [[NSDateFormatter localizedShortDateFormatter] stringFromDate:[NSDate dateWithTimeIntervalSince1970:date]];
+ __block NSString *ret;
+
+ [NSDateFormatter withLocalizedShortDateFormatterPerform:^(NSDateFormatter *shortDateFormatter){
+ ret = [[shortDateFormatter stringFromDate:[NSDate dateWithTimeIntervalSince1970:date]] retain];
+ }];
+
+ return [ret autorelease];
}
#pragma mark Software License
More information about the commits
mailing list