Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Experimental #27

Merged
merged 13 commits into from Mar 9, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
38 changes: 22 additions & 16 deletions ASIHTTPRequest.m 100644 → 100755
Expand Up @@ -460,6 +460,11 @@ - (void)releaseBlocksOnMainThread
[authenticationNeededBlock release];
authenticationNeededBlock = nil;
}
if (requestRedirectedBlock) {
[blocks addObject:requestRedirectedBlock];
[requestRedirectedBlock release];
requestRedirectedBlock = nil;
}
[[self class] performSelectorOnMainThread:@selector(releaseBlocks:) withObject:blocks waitUntilDone:[NSThread isMainThread]];
}
// Always called on main thread
Expand Down Expand Up @@ -843,18 +848,20 @@ - (void)main

#if TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_4_0
if ([ASIHTTPRequest isMultitaskingSupported] && [self shouldContinueWhenAppEntersBackground]) {
backgroundTask = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{
// Synchronize the cleanup call on the main thread in case
// the task actually finishes at around the same time.
dispatch_async(dispatch_get_main_queue(), ^{
if (backgroundTask != UIBackgroundTaskInvalid)
{
[[UIApplication sharedApplication] endBackgroundTask:backgroundTask];
backgroundTask = UIBackgroundTaskInvalid;
[self cancel];
}
});
}];
if (!backgroundTask || backgroundTask == UIBackgroundTaskInvalid) {
backgroundTask = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{
// Synchronize the cleanup call on the main thread in case
// the task actually finishes at around the same time.
dispatch_async(dispatch_get_main_queue(), ^{
if (backgroundTask != UIBackgroundTaskInvalid)
{
[[UIApplication sharedApplication] endBackgroundTask:backgroundTask];
backgroundTask = UIBackgroundTaskInvalid;
[self cancel];
}
});
}];
}
}
#endif

Expand Down Expand Up @@ -1214,6 +1221,7 @@ - (void)startRequest
CFReadStreamSetProperty((CFReadStreamRef)[self readStream],
kCFStreamPropertySSLSettings,
(CFTypeRef)sslProperties);
[sslProperties release];
}

// Tell CFNetwork to use a client certificate
Expand Down Expand Up @@ -3507,7 +3515,7 @@ - (void)handleStreamComplete

// If request has asked delegate or ASIAuthenticationDialog for credentials
} else if ([self authenticationNeeded]) {
CFRunLoopStop(CFRunLoopGetCurrent());
// Do nothing.
}

}
Expand Down Expand Up @@ -3547,8 +3555,6 @@ - (void)markAsFinished
if (!wasFinished)
[self didChangeValueForKey:@"isFinished"];

CFRunLoopStop(CFRunLoopGetCurrent());

#if TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_4_0
if ([ASIHTTPRequest isMultitaskingSupported] && [self shouldContinueWhenAppEntersBackground]) {
dispatch_async(dispatch_get_main_queue(), ^{
Expand Down Expand Up @@ -4787,7 +4793,7 @@ + (void)runRequests
BOOL runAlways = YES; // Introduced to cheat Static Analyzer
while (runAlways) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
CFRunLoopRun();
CFRunLoopRunInMode(kCFRunLoopDefaultMode, 1.0e10, true);
[pool drain];
}

Expand Down
1 change: 1 addition & 0 deletions AppController.h
Expand Up @@ -215,4 +215,5 @@
-(void)performWebSearch:(SearchMethod *)searchMethod;
-(void)performAllArticlesSearch;
-(void)performWebPageSearch;
+(NSCalendarDate *)getDateFromString:(NSString *)dateString;
@end
66 changes: 66 additions & 0 deletions AppController.m
Expand Up @@ -148,13 +148,45 @@ OSStatus openURLs(CFArrayRef urls, BOOL openLinksInBackground)

@implementation AppController

// C array of NSDateFormatter's : creating a NSDateFormatter is very expensive, so we create
// those we need early in the program launch and keep them in memory.
#define kNumberOfDateFormatters 7
static NSDateFormatter * dateFormatterArray[kNumberOfDateFormatters];

/* init
* Class instance initialisation.
*/
-(id)init
{
if ((self = [super init]) != nil)
{
if (dateFormatterArray[0] == NULL)
{
// Initializes the date formatters
NSLocale *enUS = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US"];

for (int i=0; i<kNumberOfDateFormatters; i++)
{
dateFormatterArray[i] = [[[NSDateFormatter alloc] init] retain];
[dateFormatterArray[i] setLocale:enUS];
}

//For the different date formats, see <http://unicode.org/reports/tr35/#Date_Format_Patterns>
// Fri, 12 Dec 2008 18:45:15 -0800
[dateFormatterArray[0] setDateFormat:@"EEE, dd MMM yyyy HH:mm:ss ZZ"];
// Sat, 13 Dec 2008 18:45:15 EAT
[dateFormatterArray[1] setDateFormat:@"EEE, dd MMM yyyy HH:mm:ss zzz"];
// 2010-09-28T15:31:25Z
[dateFormatterArray[2] setDateFormat:@"yyy-MM-dd'T'HH:mm:ss'Z'"];
[dateFormatterArray[3] setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss+HH:mm"];
[dateFormatterArray[4] setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss.SSS+HH:mm"];
[dateFormatterArray[5] setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"];
[dateFormatterArray[6] setDateFormat:@"EEE, dd MMM yyyy HH:mm:ss"];

[enUS release];
// end of initialization of date formatters
}

scriptPathMappings = [[NSMutableDictionary alloc] init];
progressCount = 0;
persistedStatusText = nil;
Expand Down Expand Up @@ -966,10 +998,13 @@ -(IBAction)unifiedLayout:(id)sender
*/
-(void)setLayout:(int)newLayout withRefresh:(BOOL)refreshFlag
{
BOOL visibleFilterBar = NO;
// Turn off the filter bar when switching layouts. This is simpler than
// trying to graft it onto the new layout.
if ([self isFilterBarVisible])
{ visibleFilterBar = YES;
[self setPersistedFilterBarState:NO withAnimation:NO];
}

switch (newLayout)
{
Expand All @@ -996,10 +1031,38 @@ -(void)setLayout:(int)newLayout withRefresh:(BOOL)refreshFlag
}

[[Preferences standardPreferences] setLayout:newLayout];
//restore filter bar state if necessary
if (visibleFilterBar)
[self setPersistedFilterBarState:YES withAnimation:NO];
[self updateSearchPlaceholderAndSearchMethod];
[[foldersTree mainView] setNextKeyView:[[browserView primaryTabItemView] mainView]];
}

+(NSDate *)getDateFromString:(NSString *)dateString
{

NSDate *date ;

for (int i=0; i<kNumberOfDateFormatters; i++)
{
@try
{
date = [dateFormatterArray[i] dateFromString:dateString];
if (date != nil) return date;
}
@catch (NSException * e)
{
NSLog(@"Exception: %@", e);
NSLog(@"while trying to convert datestring %@",dateString);
NSLog(@"with formatter %@",[dateFormatterArray[i] dateFormat]);

}
}

NSLog(@"Conversion error: %@",dateString);
return date;
}

#pragma mark Dock Menu

/* applicationDockMenu
Expand Down Expand Up @@ -4703,6 +4766,9 @@ -(void)dealloc
[searchField release];
[sourceWindows release];
[searchString release];
for (int i=0; i<kNumberOfDateFormatters; i++)
[dateFormatterArray[i] release];

[super dealloc];
}
@end
1 change: 0 additions & 1 deletion ArticleListView.h
Expand Up @@ -20,7 +20,6 @@

#import <Cocoa/Cocoa.h>
#import "Database.h"
#import "ExtDateFormatter.h"
#import "ArticleBaseView.h"
#import "BrowserView.h"
#import "PopupButton.h"
Expand Down
17 changes: 0 additions & 17 deletions CurlGetDate/CurlGetDate.h

This file was deleted.

20 changes: 0 additions & 20 deletions CurlGetDate/CurlGetDate.m

This file was deleted.