From 7a79096feb6a692ae3cb73fb241ddb2fcd7723c3 Mon Sep 17 00:00:00 2001 From: mzarra Date: Sat, 28 Nov 2009 09:57:03 +0100 Subject: [PATCH] Fixed issue with auth code not matching --- DesktopCode/ZSyncHandler.m | 5 +++++ DeviceCode/ZSyncTouchHandler.m | 7 +++---- SampleDesktop/PairingCodeWindowController.m | 1 + SharedCode/ZSyncShared.h | 1 - 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/DesktopCode/ZSyncHandler.m b/DesktopCode/ZSyncHandler.m index 0e06ee3..1cd2ff8 100644 --- a/DesktopCode/ZSyncHandler.m +++ b/DesktopCode/ZSyncHandler.m @@ -139,6 +139,7 @@ @implementation ZSyncConnectionDelegate - (void)dealloc { + DLog(@"%s Releasing", __PRETTY_FUNCTION__); [_connection release], _connection = nil; [super dealloc]; } @@ -192,11 +193,15 @@ - (BOOL)connection:(BLIPConnection*)connection receivedRequest:(BLIPRequest*)req return YES; case zsActionAuthenticatePairing: if ([[self pairingCode] isEqualToString:[request bodyString]]) { + DLog(@"%s passed '%@' '%@'", __PRETTY_FUNCTION__, [request bodyString], [self pairingCode]); // TODO: Register the unique ID of this service [[ZSyncHandler shared] registerDeviceForPairing:[request valueOfProperty:zsDeviceID]]; [response setValue:[NSString stringWithFormat:@"%i", zsActionAuthenticatePassed] ofProperty:zsAction]; [response send]; + [codeController close]; + [codeController release], codeController = nil; } else { + DLog(@"%s failed '%@' '%@'", __PRETTY_FUNCTION__, [request bodyString], [self pairingCode]); [response setValue:[NSString stringWithFormat:@"%i", zsActionAuthenticateFailed] ofProperty:zsAction]; [response send]; } diff --git a/DeviceCode/ZSyncTouchHandler.m b/DeviceCode/ZSyncTouchHandler.m index d5eb490..b2170da 100644 --- a/DeviceCode/ZSyncTouchHandler.m +++ b/DeviceCode/ZSyncTouchHandler.m @@ -122,11 +122,10 @@ - (void)authenticatePairing:(NSString*)code; deviceUUID = [[NSProcessInfo processInfo] globallyUniqueString]; [[NSUserDefaults standardUserDefaults] setValue:deviceUUID forKey:zsDeviceID]; } - [dictionary setValue:code forKey:zsAuthenticationCode]; - [dictionary setValue:deviceUUID forKey:zsDeviceID]; - - BLIPRequest *request = [BLIPRequest requestWithBody:nil properties:dictionary]; + + NSData *codeData = [code dataUsingEncoding:NSUTF8StringEncoding]; + BLIPRequest *request = [BLIPRequest requestWithBody:codeData properties:dictionary]; [_connection sendRequest:request]; } diff --git a/SampleDesktop/PairingCodeWindowController.m b/SampleDesktop/PairingCodeWindowController.m index 8347cfb..cc81602 100644 --- a/SampleDesktop/PairingCodeWindowController.m +++ b/SampleDesktop/PairingCodeWindowController.m @@ -43,6 +43,7 @@ - (id)initWithCodeString:(NSString*)string; - (void) dealloc { + DLog(@"%s window released cleanly", __PRETTY_FUNCTION__); [codeString release], codeString = nil; [super dealloc]; } diff --git a/SharedCode/ZSyncShared.h b/SharedCode/ZSyncShared.h index e1289b2..73787f3 100644 --- a/SharedCode/ZSyncShared.h +++ b/SharedCode/ZSyncShared.h @@ -4,7 +4,6 @@ #define zsAction @"kZSyncAction" #define zsDeviceID @"kZSyncDeviceID" -#define zsAuthenticationCode @"zsAuthenticationCode" enum { zsActionRequestPairing = 1123,