Skip to content

Commit

Permalink
Applies the patch from Pierre Bernard (houdah.com) to build recent ad…
Browse files Browse the repository at this point in the history
…ditions on 10.4.

A few additions to ObjectiveFlickr were not buildable when project/targets are
10.4-SDK/10.4-targeting (but perfectly buildable with 10.5-SDK/10.4-targeting),
this patch addressed the problem. My thanks to Pierre for contributing this patch.
  • Loading branch information
Lukhnos D. Liu committed Aug 20, 2009
1 parent ed767f3 commit 024fc68
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 4 deletions.
6 changes: 6 additions & 0 deletions LFWebAPIKit/LFSiteReachability.h
Expand Up @@ -60,7 +60,13 @@ extern NSString *const LFSiteReachabilityConnectionTypeWWAN;
// "forget about network, it doesn't exist at all"
- (BOOL)networkConnectivityExists;

#if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4
- (id<LFSiteReachabilityDelegate>)delegate;
- (NSURL*)siteURL;
- (NSTimeInterval)timeoutInterval;
#else
@property (assign, nonatomic) id<LFSiteReachabilityDelegate> delegate;
@property (retain, nonatomic) NSURL *siteURL;
@property (nonatomic) NSTimeInterval timeoutInterval;
#endif
@end
17 changes: 17 additions & 0 deletions LFWebAPIKit/LFSiteReachability.m
Expand Up @@ -224,7 +224,11 @@ - (void)setTimeoutInterval:(NSTimeInterval)inInterval
[siteRequest setTimeoutInterval:inInterval];
}

#if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4
- (void)httpRequest:(LFHTTPRequest *)request didReceiveStatusCode:(int)statusCode URL:(NSURL *)url responseHeader:(CFHTTPMessageRef)header
#else
- (void)httpRequest:(LFHTTPRequest *)request didReceiveStatusCode:(NSUInteger)statusCode URL:(NSURL *)url responseHeader:(CFHTTPMessageRef)header
#endif
{
LFSRDebug(@"%s, code: %d, URL: %@, header: %@", __PRETTY_FUNCTION__, statusCode, url, (id)header);
}
Expand Down Expand Up @@ -253,8 +257,21 @@ - (void)httpRequest:(LFHTTPRequest *)request didFailWithError:(NSString *)error
}
}

#if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4
- (id<LFSiteReachabilityDelegate>)delegate
{
return delegate;
}

- (NSURL*)siteURL
{
return [[siteURL retain] autorelease];
}

#else
@synthesize delegate;
@synthesize siteURL;
#endif
@end


Expand Down
21 changes: 19 additions & 2 deletions Source/OFUtilities.h
Expand Up @@ -27,6 +27,18 @@

#import <CommonCrypto/CommonDigest.h>

#if !defined(NS_INLINE)
#if defined(__GNUC__)
#define NS_INLINE static __inline__ __attribute__((always_inline))
#elif defined(__MWERKS__) || defined(__cplusplus)
#define NS_INLINE static inline
#elif defined(_MSC_VER)
#define NS_INLINE static __inline
#elif defined(__WIN32__)
#define NS_INLINE static __inline__
#endif
#endif

NS_INLINE NSString *OFMD5HexStringFromNSString(NSString *inStr)
{
const char *data = [inStr UTF8String];
Expand All @@ -53,7 +65,7 @@ NS_INLINE NSString *OFEscapedURLStringFromNSString(NSString *inStr)
CFStringRef escaped = CFURLCreateStringByAddingPercentEscapes(NULL, (CFStringRef)inStr, NULL, CFSTR("&"), kCFStringEncodingUTF8);

#if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4
return (NSString *)[escaped autorelease];
return (NSString *)[(NSString*)escaped autorelease];
#else
return (NSString *)[NSMakeCollectable(escaped) autorelease];
#endif
Expand All @@ -64,5 +76,10 @@ NS_INLINE NSString *OFGenerateUUIDString()
CFUUIDRef uuid = CFUUIDCreate(NULL);
CFStringRef uuidStr = CFUUIDCreateString(NULL, uuid);
CFRelease(uuid);
return [NSMakeCollectable(uuidStr) autorelease];

#if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4
return (NSString *)[(NSString*)uuidStr autorelease];
#else
return (NSString *)[NSMakeCollectable(uuidStr) autorelease];
#endif
}
13 changes: 11 additions & 2 deletions Source/ObjectiveFlickr.m
Expand Up @@ -443,9 +443,14 @@ - (BOOL)uploadImageStream:(NSInputStream *)inImageStream suggestedFilename:(NSSt
NSAssert([outputStream write:(uint8_t *)UTF8String maxLength:writeLength] == writeLength, @"Must write multipartBegin");
[outputStream close];

#if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4
NSDictionary *fileInfo = [[NSFileManager defaultManager] fileAttributesAtPath:uploadTempFilename traverseLink:YES];
NSAssert(fileInfo, @"Must have upload temp file");
#else
NSError *error = nil;
NSDictionary *fileInfo = [[NSFileManager defaultManager] attributesOfItemAtPath:uploadTempFilename error:&error];
NSAssert(fileInfo && !error, @"Must have upload temp file");
#endif
NSNumber *fileSizeNumber = [fileInfo objectForKey:NSFileSize];
NSUInteger fileSize = 0;

Expand Down Expand Up @@ -534,8 +539,12 @@ - (void)cleanUpTempFile
if (uploadTempFilename) {
NSFileManager *fileManager = [NSFileManager defaultManager];
if ([fileManager fileExistsAtPath:uploadTempFilename]) {
NSError *error = nil;
NSAssert([fileManager removeItemAtPath:uploadTempFilename error:&error], @"Should be able to remove temp file");
#if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4
NSAssert([fileManager removeFileAtPath:uploadTempFilename handler:nil], @"Should be able to remove temp file");
#else
NSError *error = nil;
NSAssert([fileManager removeItemAtPath:uploadTempFilename error:&error], @"Should be able to remove temp file");
#endif
}

[uploadTempFilename release];
Expand Down

0 comments on commit 024fc68

Please sign in to comment.