Permalink
Browse files

Full Support for Google Reader Sync!

  • Loading branch information...
1 parent 5831876 commit d2d4ed04a076e5781c9eb59c2002d6ff22c7561f Salvatore Ansani committed Jan 9, 2012
Showing with 9,915 additions and 887 deletions.
  1. 0 ASICacheDelegate.h
  2. 0 ASIDataCompressor.h
  3. +5 −5 ASIDataCompressor.m
  4. 0 ASIDataDecompressor.h
  5. +5 −5 ASIDataDecompressor.m
  6. +4 −0 ASIDownloadCache.h
  7. +32 −29 ASIDownloadCache.m
  8. 0 ASIFormDataRequest.h
  9. +3 −2 ASIFormDataRequest.m
  10. +5 −0 ASIHTTPRequest.h
  11. +144 −98 ASIHTTPRequest.m
  12. +7 −1 ASIHTTPRequestConfig.h
  13. 0 ASIHTTPRequestDelegate.h
  14. 0 ASIInputStream.h
  15. +4 −2 ASIInputStream.m
  16. 0 ASINetworkQueue.h
  17. 0 ASINetworkQueue.m
  18. 0 ASIProgressDelegate.h
  19. +4 −2 AppController.h
  20. +135 −8 AppController.m
  21. +25 −18 ArticleController.m
  22. +1 −1 ArticleListView.h
  23. +2 −2 ArticleListView.m
  24. +3 −0 Database.h
  25. +32 −3 Database.m
  26. +1 −1 DownloadManager.h
  27. +1 −1 DownloadWindow.h
  28. +2 −0 Folder.h
  29. +6 −2 Folder.m
  30. +1 −1 FoldersTree.m
  31. +37 −16 GRSOperation.m
  32. +2 −2 GRSRefreshOperation.h
  33. +1 −1 GRSRefreshOperation.m
  34. +187 −0 GTMHTTPFetchHistory.h
  35. +591 −0 GTMHTTPFetchHistory.m
  36. +675 −0 GTMHTTPFetcher.h
  37. +1,604 −0 GTMHTTPFetcher.m
  38. +85 −0 GTMHTTPFetcherLogging.h
  39. +1,001 −0 GTMHTTPFetcherLogging.m
  40. +322 −0 GTMOAuth2Authentication.h
  41. +1,136 −0 GTMOAuth2Authentication.m
  42. +173 −0 GTMOAuth2SignIn.h
  43. +806 −0 GTMOAuth2SignIn.m
  44. +657 −0 GTMOAuth2Window.xib
  45. +332 −0 GTMOAuth2WindowController.h
  46. +727 −0 GTMOAuth2WindowController.m
  47. +17 −7 GoogleReader.h
  48. +703 −132 GoogleReader.m
  49. +1 −1 InfoWindow.h
  50. +23 −29 RefreshManager.m
  51. +2 −5 SNDisclosableView.m
  52. +2 −2 SyncMerge.h
  53. +19 −1 SyncMerge.m
  54. +7 −0 SyncPreferences.m
  55. +119 −419 SyncPreferences.xib
  56. +39 −0 VTPG_Common.h
  57. +98 −0 VTPG_Common.m
  58. +116 −80 Vienna.xcodeproj/project.pbxproj
  59. +11 −11 ViennaApp.m
  60. BIN googleFeed.tiff
View
0 ASICacheDelegate.h 100755 → 100644
No changes.
View
0 ASIDataCompressor.h 100755 → 100644
No changes.
View
10 ASIDataCompressor.m 100755 → 100644
@@ -78,7 +78,7 @@ - (NSData *)compressBytes:(Bytef *)bytes length:(NSUInteger)length error:(NSErro
int status;
zStream.next_in = bytes;
- zStream.avail_in = (NSUInteger )length;
+ zStream.avail_in = (unsigned int)length;
zStream.avail_out = 0;
NSInteger bytesProcessedAlready = zStream.total_out;
@@ -88,8 +88,8 @@ - (NSData *)compressBytes:(Bytef *)bytes length:(NSUInteger)length error:(NSErro
[outputData increaseLengthBy:halfLength];
}
- zStream.next_out = [outputData mutableBytes] + zStream.total_out-bytesProcessedAlready;
- zStream.avail_out = (NSUInteger )([outputData length] - (zStream.total_out-bytesProcessedAlready));
+ zStream.next_out = (Bytef*)[outputData mutableBytes] + zStream.total_out-bytesProcessedAlready;
+ zStream.avail_out = (unsigned int)([outputData length] - (zStream.total_out-bytesProcessedAlready));
status = deflate(&zStream, shouldFinish ? Z_FINISH : Z_NO_FLUSH);
if (status == Z_STREAM_END) {
@@ -184,12 +184,12 @@ + (BOOL)compressDataFromFile:(NSString *)sourcePath toFile:(NSString *)destinati
}
// Write the deflated data out to the destination file
- [outputStream write:[outputData bytes] maxLength:[outputData length]];
+ [outputStream write:(const uint8_t *)[outputData bytes] maxLength:[outputData length]];
// Make sure nothing went wrong
if ([inputStream streamStatus] == NSStreamEventErrorOccurred) {
if (err) {
- *err = [NSError errorWithDomain:NetworkRequestErrorDomain code:ASICompressionError userInfo:[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"Compression of %@ failed because we were unable to write to the destination data file at &@",sourcePath,destinationPath],NSLocalizedDescriptionKey,[outputStream streamError],NSUnderlyingErrorKey,nil]];
+ *err = [NSError errorWithDomain:NetworkRequestErrorDomain code:ASICompressionError userInfo:[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"Compression of %@ failed because we were unable to write to the destination data file at %@",sourcePath,destinationPath],NSLocalizedDescriptionKey,[outputStream streamError],NSUnderlyingErrorKey,nil]];
}
[compressor closeStream];
return NO;
View
0 ASIDataDecompressor.h 100755 → 100644
No changes.
View
10 ASIDataDecompressor.m 100755 → 100644
@@ -75,7 +75,7 @@ - (NSData *)uncompressBytes:(Bytef *)bytes length:(NSUInteger)length error:(NSEr
int status;
zStream.next_in = bytes;
- zStream.avail_in = (NSUInteger )length;
+ zStream.avail_in = (unsigned int)length;
zStream.avail_out = 0;
NSInteger bytesProcessedAlready = zStream.total_out;
@@ -85,8 +85,8 @@ - (NSData *)uncompressBytes:(Bytef *)bytes length:(NSUInteger)length error:(NSEr
[outputData increaseLengthBy:halfLength];
}
- zStream.next_out = [outputData mutableBytes] + zStream.total_out-bytesProcessedAlready;
- zStream.avail_out = (NSUInteger )([outputData length] - (zStream.total_out-bytesProcessedAlready));
+ zStream.next_out = (Bytef*)[outputData mutableBytes] + zStream.total_out-bytesProcessedAlready;
+ zStream.avail_out = (unsigned int)([outputData length] - (zStream.total_out-bytesProcessedAlready));
status = inflate(&zStream, Z_NO_FLUSH);
@@ -181,12 +181,12 @@ + (BOOL)uncompressDataFromFile:(NSString *)sourcePath toFile:(NSString *)destina
}
// Write the inflated data out to the destination file
- [outputStream write:[outputData bytes] maxLength:[outputData length]];
+ [outputStream write:(Bytef*)[outputData bytes] maxLength:[outputData length]];
// Make sure nothing went wrong
if ([inputStream streamStatus] == NSStreamEventErrorOccurred) {
if (err) {
- *err = [NSError errorWithDomain:NetworkRequestErrorDomain code:ASICompressionError userInfo:[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"Decompression of %@ failed because we were unable to write to the destination data file at &@",sourcePath,destinationPath],NSLocalizedDescriptionKey,[outputStream streamError],NSUnderlyingErrorKey,nil]];
+ *err = [NSError errorWithDomain:NetworkRequestErrorDomain code:ASICompressionError userInfo:[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"Decompression of %@ failed because we were unable to write to the destination data file at %@",sourcePath,destinationPath],NSLocalizedDescriptionKey,[outputStream streamError],NSUnderlyingErrorKey,nil]];
}
[decompressor closeStream];
return NO;
View
4 ASIDownloadCache.h 100755 → 100644
@@ -35,6 +35,10 @@
// A helper function that determines if the server has requested data should not be cached by looking at the request's response headers
+ (BOOL)serverAllowsResponseCachingForRequest:(ASIHTTPRequest *)request;
+// A list of file extensions that we know won't be readable by a webview when accessed locally
+// If we're asking for a path to cache a particular url and it has one of these extensions, we change it to '.html'
++ (NSArray *)fileExtensionsToHandleAsHTML;
+
@property (assign, nonatomic) ASICachePolicy defaultCachePolicy;
@property (retain, nonatomic) NSString *storagePath;
@property (retain) NSRecursiveLock *accessLock;
View
61 ASIDownloadCache.m 100755 → 100644
@@ -14,6 +14,7 @@
static NSString *sessionCacheFolder = @"SessionStore";
static NSString *permanentCacheFolder = @"PermanentStore";
+static NSArray *fileExtensionsToHandleAsHTML = nil;
@interface ASIDownloadCache ()
+ (NSString *)keyForURL:(NSURL *)url;
@@ -22,6 +23,15 @@ - (NSString *)pathToFile:(NSString *)file;
@implementation ASIDownloadCache
++ (void)initialize
+{
+ if (self == [ASIDownloadCache class]) {
+ // Obviously this is not an exhaustive list, but hopefully these are the most commonly used and this will 'just work' for the widest range of people
+ // I imagine many web developers probably use url rewriting anyway
+ fileExtensionsToHandleAsHTML = [[NSArray alloc] initWithObjects:@"asp",@"aspx",@"jsp",@"php",@"rb",@"py",@"pl",@"cgi", nil];
+ }
+}
+
- (id)init
{
self = [super init];
@@ -105,31 +115,7 @@ - (void)updateExpiryForRequest:(ASIHTTPRequest *)request maxAge:(NSTimeInterval)
- (NSDate *)expiryDateForRequest:(ASIHTTPRequest *)request maxAge:(NSTimeInterval)maxAge
{
- NSMutableDictionary *responseHeaders = [NSMutableDictionary dictionaryWithDictionary:[request responseHeaders]];
-
- // If we weren't given a custom max-age, lets look for one in the response headers
- if (!maxAge) {
- NSString *cacheControl = [[responseHeaders objectForKey:@"Cache-Control"] lowercaseString];
- if (cacheControl) {
- NSScanner *scanner = [NSScanner scannerWithString:cacheControl];
- [scanner scanUpToString:@"max-age" intoString:NULL];
- if ([scanner scanString:@"max-age" intoString:NULL]) {
- [scanner scanString:@"=" intoString:NULL];
- [scanner scanDouble:&maxAge];
- }
- }
- }
-
- // RFC 2612 says max-age must override any Expires header
- if (maxAge) {
- return [[NSDate date] addTimeInterval:maxAge];
- } else {
- NSString *expires = [responseHeaders objectForKey:@"Expires"];
- if (expires) {
- return [ASIHTTPRequest dateFromRFC1123String:expires];
- }
- }
- return nil;
+ return [ASIHTTPRequest expiryDateForRequest:request maxAge:maxAge];
}
- (void)storeResponseForRequest:(ASIHTTPRequest *)request maxAge:(NSTimeInterval)maxAge
@@ -183,9 +169,14 @@ - (void)storeResponseForRequest:(ASIHTTPRequest *)request maxAge:(NSTimeInterval
if ([request responseData]) {
[[request responseData] writeToFile:dataPath atomically:NO];
- } else if ([request downloadDestinationPath] && ![[request downloadDestinationPath] isEqualToString:dataPath]) {
+ } else if ([request downloadDestinationPath] && ![[request downloadDestinationPath] isEqualToString:dataPath]) {
NSError *error = nil;
- [[[[NSFileManager alloc] init] autorelease] copyItemAtPath:[request downloadDestinationPath] toPath:dataPath error:&error];
+ NSFileManager* manager = [[NSFileManager alloc] init];
+ if ([manager fileExistsAtPath:dataPath]) {
+ [manager removeItemAtPath:dataPath error:&error];
+ }
+ [manager copyItemAtPath:[request downloadDestinationPath] toPath:dataPath error:&error];
+ [manager release];
}
[[self accessLock] unlock];
}
@@ -212,12 +203,21 @@ - (NSString *)pathToCachedResponseDataForURL:(NSURL *)url
{
// Grab the file extension, if there is one. We do this so we can save the cached response with the same file extension - this is important if you want to display locally cached data in a web view
NSString *extension = [[url path] pathExtension];
- if (![extension length]) {
+
+ // If the url doesn't have an extension, we'll add one so a webview can read it when locally cached
+ // If the url has the extension of a common web scripting language, we'll change the extension on the cached path to html for the same reason
+ if (![extension length] || [[[self class] fileExtensionsToHandleAsHTML] containsObject:[extension lowercaseString]]) {
extension = @"html";
}
return [self pathToFile:[[[self class] keyForURL:url] stringByAppendingPathExtension:extension]];
}
++ (NSArray *)fileExtensionsToHandleAsHTML
+{
+ return fileExtensionsToHandleAsHTML;
+}
+
+
- (NSString *)pathToCachedResponseHeadersForURL:(NSURL *)url
{
return [self pathToFile:[[[self class] keyForURL:url] stringByAppendingPathExtension:@"cachedheaders"]];
@@ -262,7 +262,10 @@ - (NSString *)pathToStoreCachedResponseDataForRequest:(ASIHTTPRequest *)request
// Grab the file extension, if there is one. We do this so we can save the cached response with the same file extension - this is important if you want to display locally cached data in a web view
NSString *extension = [[[request url] path] pathExtension];
- if (![extension length]) {
+
+ // If the url doesn't have an extension, we'll add one so a webview can read it when locally cached
+ // If the url has the extension of a common web scripting language, we'll change the extension on the cached path to html for the same reason
+ if (![extension length] || [[[self class] fileExtensionsToHandleAsHTML] containsObject:[extension lowercaseString]]) {
extension = @"html";
}
path = [path stringByAppendingPathComponent:[[[self class] keyForURL:[request url]] stringByAppendingPathExtension:extension]];
View
0 ASIFormDataRequest.h 100755 → 100644
No changes.
View
5 ASIFormDataRequest.m 100755 → 100644
@@ -30,7 +30,7 @@ @implementation ASIFormDataRequest
#pragma mark utilities
- (NSString*)encodeURL:(NSString *)string
{
- NSString *newString = NSMakeCollectable([(NSString *)CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (CFStringRef)string, NULL, CFSTR(":/?#[]@!$ &'()*+,;=\"<>%{}|\\^~`"), CFStringConvertNSStringEncodingToEncoding([self stringEncoding])) autorelease]);
+ NSString *newString = [NSMakeCollectable(CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (CFStringRef)string, NULL, CFSTR(":/?#[]@!$ &'()*+,;=\"<>%{}|\\^~`"), CFStringConvertNSStringEncodingToEncoding([self stringEncoding]))) autorelease];
if (newString) {
return newString;
}
@@ -49,6 +49,7 @@ - (id)initWithURL:(NSURL *)newURL
self = [super initWithURL:newURL];
[self setPostFormat:ASIURLEncodedPostFormat];
[self setStringEncoding:NSUTF8StringEncoding];
+ [self setRequestMethod:@"POST"];
return self;
}
@@ -207,7 +208,7 @@ - (void)buildPostBody
[super buildPostBody];
#if DEBUG_FORM_DATA_REQUEST
- NSLog(@"%@",[self debugBodyString]);
+ ASI_DEBUG_LOG(@"%@",[self debugBodyString]);
[self setDebugBodyString:nil];
#endif
}
View
5 ASIHTTPRequest.h 100755 → 100644
@@ -873,6 +873,11 @@ typedef void (^ASIDataBlock)(NSData *data);
// And also by ASIS3Request
+ (NSString *)base64forData:(NSData *)theData;
+// Returns the expiration date for the request.
+// Calculated from the Expires response header property, unless maxAge is non-zero or
+// there exists a non-zero max-age property in the Cache-Control response header.
++ (NSDate *)expiryDateForRequest:(ASIHTTPRequest *)request maxAge:(NSTimeInterval)maxAge;
+
// Returns a date from a string in RFC1123 format
+ (NSDate *)dateFromRFC1123String:(NSString *)string;
Oops, something went wrong.

0 comments on commit d2d4ed0

Please sign in to comment.