Skip to content

Commit

Permalink
Fixed overrelease
Browse files Browse the repository at this point in the history
  • Loading branch information
mzarra committed Apr 8, 2010
1 parent aabb274 commit 4c5ee64
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 38 deletions.
2 changes: 1 addition & 1 deletion DesktopCode/PairingCodeWindowController.m
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ - (void)windowDidLoad
[[self window] makeKeyAndOrderFront:self];
}

- (void)windowDidBecomeKey:(NSNotification *)notification
- (void)windowDidBecomeKey:(NSNotification*)notification
{
DLog(@"%s fired", __PRETTY_FUNCTION__);
[[self textField] becomeFirstResponder];
Expand Down
34 changes: 22 additions & 12 deletions DesktopCode/ZSyncConnectionDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ - (void)pairingCodeWindowController:(id)controller codeEntered:(NSString*)code;
{
NSMutableDictionary *dictionary = [NSMutableDictionary dictionary];
[dictionary setValue:zsActID(zsActionAuthenticatePairing) forKey:zsAction];
[dictionary setValue:[[NSUserDefaults standardUserDefaults] valueForKey:zsServerUUID] forKey:zsServerUUID];

NSData *data = [code dataUsingEncoding:NSUTF8StringEncoding];

Expand All @@ -214,42 +215,49 @@ - (void)pairingCodeWindowControllerCancelled:(PairingCodeWindowController*)contr
#pragma mark -
#pragma mark NSPersistentStoreCoordinatorSyncing

- (void)persistentStoreCoordinator:(NSPersistentStoreCoordinator*)coordinator didFinishSyncSession:(ISyncSession*)session
- (void)persistentStoreCoordinator:(NSPersistentStoreCoordinator*)coordinator
didFinishSyncSession:(ISyncSession*)session
{
DLog(@"%s sync is complete", __PRETTY_FUNCTION__);
}

- (NSArray *)managedObjectContextsToMonitorWhenSyncingPersistentStoreCoordinator:(NSPersistentStoreCoordinator *)coordinator;
- (NSArray*)managedObjectContextsToMonitorWhenSyncingPersistentStoreCoordinator:(NSPersistentStoreCoordinator*)coordinator;
{
return [NSArray arrayWithObject:managedObjectContext];
}

- (NSArray *)managedObjectContextsToReloadAfterSyncingPersistentStoreCoordinator:(NSPersistentStoreCoordinator *)coordinator;
- (NSArray*)managedObjectContextsToReloadAfterSyncingPersistentStoreCoordinator:(NSPersistentStoreCoordinator*)coordinator;
{
return [NSArray arrayWithObject:managedObjectContext];
}

- (void)persistentStoreCoordinator:(NSPersistentStoreCoordinator *)coordinator willPushChangesInSyncSession:(ISyncSession *)session;
- (void)persistentStoreCoordinator:(NSPersistentStoreCoordinator*)coordinator
willPushChangesInSyncSession:(ISyncSession*)session;
{
DLog(@"%s entered", __PRETTY_FUNCTION__);
}

- (void)persistentStoreCoordinator:(NSPersistentStoreCoordinator *)coordinator didPushChangesInSyncSession:(ISyncSession *)session;
- (void)persistentStoreCoordinator:(NSPersistentStoreCoordinator*)coordinator
didPushChangesInSyncSession:(ISyncSession*)session;
{
DLog(@"%s entered", __PRETTY_FUNCTION__);
}

- (void)persistentStoreCoordinator:(NSPersistentStoreCoordinator *)coordinator willPullChangesInSyncSession:(ISyncSession *)session;
- (void)persistentStoreCoordinator:(NSPersistentStoreCoordinator*)coordinator
willPullChangesInSyncSession:(ISyncSession*)session;
{
DLog(@"%s entered", __PRETTY_FUNCTION__);
}

- (void)persistentStoreCoordinator:(NSPersistentStoreCoordinator *)coordinator didPullChangesInSyncSession:(ISyncSession *)session;
- (void)persistentStoreCoordinator:(NSPersistentStoreCoordinator*)coordinator
didPullChangesInSyncSession:(ISyncSession*)session;
{
DLog(@"%s entered", __PRETTY_FUNCTION__);
}

- (void)persistentStoreCoordinator:(NSPersistentStoreCoordinator *)coordinator didCancelSyncSession:(ISyncSession *)session error:(NSError *)error;
- (void)persistentStoreCoordinator:(NSPersistentStoreCoordinator*)coordinator
didCancelSyncSession:(ISyncSession*)session
error:(NSError*)error;
{
DLog(@"%s entered", __PRETTY_FUNCTION__);
}
Expand All @@ -259,11 +267,14 @@ - (void)persistentStoreCoordinator:(NSPersistentStoreCoordinator *)coordinator d

- (void)registerSyncClient:(BLIPRequest*)request
{
NSString *clientID = [request bodyString];
// TODO: Compare version numbers
ZAssert([request bodyString] != nil, @"Body string is nil in request\n%@", [[request properties] allProperties]);
ZAssert(clientID != nil, @"Body string is nil in request\n%@", [[request properties] allProperties]);


NSString *clientDescription = [[NSBundle mainBundle] pathForResource:@"clientDescription" ofType:@"plist"];
ISyncClient *syncClient = [[ISyncManager sharedManager] registerClientWithIdentifier:[request bodyString] descriptionFilePath:clientDescription];
ISyncClient *syncClient = [[ISyncManager sharedManager] registerClientWithIdentifier:clientID
descriptionFilePath:clientDescription];
NSString *displayName = [syncClient displayName];
displayName = [displayName stringByAppendingFormat:@": %@", [request valueOfProperty:zsDeviceName]];
[syncClient setDisplayName:displayName];
Expand All @@ -275,7 +286,7 @@ - (void)registerSyncClient:(BLIPRequest*)request
BLIPResponse *response = [request response];

if (syncClient) {
[self setClientIdentifier:[request bodyString]];
[self setClientIdentifier:clientID];
[response setValue:zsActID(zsActionSchemaSupported) ofProperty:zsAction];
[response send];
return;
Expand All @@ -294,7 +305,6 @@ - (BOOL)connectionReceivedCloseRequest:(BLIPConnection*)connection;
[[ZSyncHandler shared] connectionClosed:self];
if (codeController) {
[[codeController window] orderOut:nil];
[codeController release], codeController = nil;
}
return YES;
}
Expand Down
4 changes: 2 additions & 2 deletions DeviceCode/ZSyncTouchHandler.m
Original file line number Diff line number Diff line change
Expand Up @@ -553,12 +553,12 @@ - (BOOL)connection:(BLIPConnection*)connection receivedRequest:(BLIPRequest*)req
case zsActionAuthenticatePairing:
if ([[request bodyString] isEqualToString:[self passcode]]) {
[[request response] setValue:zsActID(zsActionAuthenticatePassed) ofProperty:zsAction];
[[NSUserDefaults standardUserDefaults] setValue:[request valueOfProperty:zsServerUUID] forKey:zsServerUUID];
[self performSelector:@selector(uploadDataToServer) withObject:nil afterDelay:0.1];
} else {
[[request response] setValue:zsActID(zsActionAuthenticateFailed) ofProperty:zsAction];
}
[[self delegate] zSyncPairingCodeCompleted:self];
//Start a sync by pushing the data file to the server
[self uploadDataToServer];
return YES;
case zsActionTestFileTransfer:
[self processTestFileTransfer:request];
Expand Down
20 changes: 10 additions & 10 deletions GoogleToolboxSubset/GTMNSData+zlib.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,23 @@
/// Return an autoreleased NSData w/ the result of gzipping the bytes.
//
// Uses the default compression level.
+ (NSData *)gtm_dataByGzippingBytes:(const void *)bytes
+ (NSData*)gtm_dataByGzippingBytes:(const void*)bytes
length:(NSUInteger)length;

/// Return an autoreleased NSData w/ the result of gzipping the payload of |data|.
//
// Uses the default compression level.
+ (NSData *)gtm_dataByGzippingData:(NSData *)data;
+ (NSData*)gtm_dataByGzippingData:(NSData*)data;

/// Return an autoreleased NSData w/ the result of gzipping the bytes using |level| compression level.
//
// |level| can be 1-9, any other values will be clipped to that range.
+ (NSData *)gtm_dataByGzippingBytes:(const void *)bytes
+ (NSData*)gtm_dataByGzippingBytes:(const void*)bytes
length:(NSUInteger)length
compressionLevel:(int)level;

/// Return an autoreleased NSData w/ the result of gzipping the payload of |data| using |level| compression level.
+ (NSData *)gtm_dataByGzippingData:(NSData *)data
+ (NSData*)gtm_dataByGzippingData:(NSData*)data
compressionLevel:(int)level;

// NOTE: deflate is *NOT* gzip. deflate is a "zlib" stream. pick which one
Expand All @@ -50,35 +50,35 @@
/// Return an autoreleased NSData w/ the result of deflating the bytes.
//
// Uses the default compression level.
+ (NSData *)gtm_dataByDeflatingBytes:(const void *)bytes
+ (NSData*)gtm_dataByDeflatingBytes:(const void*)bytes
length:(NSUInteger)length;

/// Return an autoreleased NSData w/ the result of deflating the payload of |data|.
//
// Uses the default compression level.
+ (NSData *)gtm_dataByDeflatingData:(NSData *)data;
+ (NSData*)gtm_dataByDeflatingData:(NSData*)data;

/// Return an autoreleased NSData w/ the result of deflating the bytes using |level| compression level.
//
// |level| can be 1-9, any other values will be clipped to that range.
+ (NSData *)gtm_dataByDeflatingBytes:(const void *)bytes
+ (NSData*)gtm_dataByDeflatingBytes:(const void*)bytes
length:(NSUInteger)length
compressionLevel:(int)level;

/// Return an autoreleased NSData w/ the result of deflating the payload of |data| using |level| compression level.
+ (NSData *)gtm_dataByDeflatingData:(NSData *)data
+ (NSData*)gtm_dataByDeflatingData:(NSData*)data
compressionLevel:(int)level;


/// Return an autoreleased NSData w/ the result of decompressing the bytes.
//
// The bytes to decompress can be zlib or gzip payloads.
+ (NSData *)gtm_dataByInflatingBytes:(const void *)bytes
+ (NSData*)gtm_dataByInflatingBytes:(const void*)bytes
length:(NSUInteger)length;

/// Return an autoreleased NSData w/ the result of decompressing the payload of |data|.
//
// The data to decompress can be zlib or gzip payloads.
+ (NSData *)gtm_dataByInflatingData:(NSData *)data;
+ (NSData*)gtm_dataByInflatingData:(NSData*)data;

@end
24 changes: 12 additions & 12 deletions GoogleToolboxSubset/GTMNSData+zlib.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@
#define kChunkSize 1024

@interface NSData (GTMZlibAdditionsPrivate)
+ (NSData *)gtm_dataByCompressingBytes:(const void *)bytes
+ (NSData*)gtm_dataByCompressingBytes:(const void*)bytes
length:(NSUInteger)length
compressionLevel:(int)level
useGzip:(BOOL)useGzip;
@end

@implementation NSData (GTMZlibAdditionsPrivate)
+ (NSData *)gtm_dataByCompressingBytes:(const void *)bytes
+ (NSData*)gtm_dataByCompressingBytes:(const void*)bytes
length:(NSUInteger)length
compressionLevel:(int)level
useGzip:(BOOL)useGzip {
Expand Down Expand Up @@ -124,22 +124,22 @@ + (NSData *)gtm_dataByCompressingBytes:(const void *)bytes

@implementation NSData (GTMZLibAdditions)

+ (NSData *)gtm_dataByGzippingBytes:(const void *)bytes
+ (NSData*)gtm_dataByGzippingBytes:(const void*)bytes
length:(NSUInteger)length {
return [self gtm_dataByCompressingBytes:bytes
length:length
compressionLevel:Z_DEFAULT_COMPRESSION
useGzip:YES];
} // gtm_dataByGzippingBytes:length:

+ (NSData *)gtm_dataByGzippingData:(NSData *)data {
+ (NSData*)gtm_dataByGzippingData:(NSData*)data {
return [self gtm_dataByCompressingBytes:[data bytes]
length:[data length]
compressionLevel:Z_DEFAULT_COMPRESSION
useGzip:YES];
} // gtm_dataByGzippingData:

+ (NSData *)gtm_dataByGzippingBytes:(const void *)bytes
+ (NSData*)gtm_dataByGzippingBytes:(const void*)bytes
length:(NSUInteger)length
compressionLevel:(int)level {
return [self gtm_dataByCompressingBytes:bytes
Expand All @@ -148,30 +148,30 @@ + (NSData *)gtm_dataByGzippingBytes:(const void *)bytes
useGzip:YES];
} // gtm_dataByGzippingBytes:length:level:

+ (NSData *)gtm_dataByGzippingData:(NSData *)data
+ (NSData*)gtm_dataByGzippingData:(NSData*)data
compressionLevel:(int)level {
return [self gtm_dataByCompressingBytes:[data bytes]
length:[data length]
compressionLevel:level
useGzip:YES];
} // gtm_dataByGzippingData:level:

+ (NSData *)gtm_dataByDeflatingBytes:(const void *)bytes
+ (NSData*)gtm_dataByDeflatingBytes:(const void*)bytes
length:(NSUInteger)length {
return [self gtm_dataByCompressingBytes:bytes
length:length
compressionLevel:Z_DEFAULT_COMPRESSION
useGzip:NO];
} // gtm_dataByDeflatingBytes:length:

+ (NSData *)gtm_dataByDeflatingData:(NSData *)data {
+ (NSData*)gtm_dataByDeflatingData:(NSData*)data {
return [self gtm_dataByCompressingBytes:[data bytes]
length:[data length]
compressionLevel:Z_DEFAULT_COMPRESSION
useGzip:NO];
} // gtm_dataByDeflatingData:

+ (NSData *)gtm_dataByDeflatingBytes:(const void *)bytes
+ (NSData*)gtm_dataByDeflatingBytes:(const void*)bytes
length:(NSUInteger)length
compressionLevel:(int)level {
return [self gtm_dataByCompressingBytes:bytes
Expand All @@ -180,15 +180,15 @@ + (NSData *)gtm_dataByDeflatingBytes:(const void *)bytes
useGzip:NO];
} // gtm_dataByDeflatingBytes:length:level:

+ (NSData *)gtm_dataByDeflatingData:(NSData *)data
+ (NSData*)gtm_dataByDeflatingData:(NSData*)data
compressionLevel:(int)level {
return [self gtm_dataByCompressingBytes:[data bytes]
length:[data length]
compressionLevel:level
useGzip:NO];
} // gtm_dataByDeflatingData:level:

+ (NSData *)gtm_dataByInflatingBytes:(const void *)bytes
+ (NSData*)gtm_dataByInflatingBytes:(const void*)bytes
length:(NSUInteger)length {
if (!bytes || !length) {
return nil;
Expand Down Expand Up @@ -259,7 +259,7 @@ + (NSData *)gtm_dataByInflatingBytes:(const void *)bytes
return result;
} // gtm_dataByInflatingBytes:length:

+ (NSData *)gtm_dataByInflatingData:(NSData *)data {
+ (NSData*)gtm_dataByInflatingData:(NSData*)data {
return [self gtm_dataByInflatingBytes:[data bytes]
length:[data length]];
} // gtm_dataByInflatingData:
Expand Down
2 changes: 1 addition & 1 deletion SharedCode/MYDNSService.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
}

+ (MYDNSConnection*) sharedConnection;
- (id) initWithServiceRef: (struct _DNSServiceRef_t *)serviceRef;
- (id) initWithServiceRef: (struct _DNSServiceRef_t*)serviceRef;
@property (readonly) struct _DNSServiceRef_t* connectionRef;
- (BOOL) processResult;
- (void) close;
Expand Down

0 comments on commit 4c5ee64

Please sign in to comment.