Skip to content

Commit

Permalink
Update to pairing code logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcus S. Zarra committed Jul 2, 2010
1 parent de4517f commit 320caf8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
6 changes: 5 additions & 1 deletion DesktopCode/ZSyncConnectionDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,11 @@ - (void)registerSyncClient:(BLIPRequest*)request
ISyncClient *syncClient = [[ISyncManager sharedManager] clientWithIdentifier:clientID];
if (!syncClient) {
NSString *clientDescription = [plugin pathForResource:@"clientDescription" ofType:@"plist"];
syncClient = [[ISyncManager sharedManager] registerClientWithIdentifier:clientID descriptionFilePath:clientDescription];
@try {
syncClient = [[ISyncManager sharedManager] registerClientWithIdentifier:clientID descriptionFilePath:clientDescription];
} @catch (NSException *exception) {
DLog(@"exception caught: %@", exception);
}
NSString *displayName = [syncClient displayName];
displayName = [displayName stringByAppendingFormat:@": %@", [request valueOfProperty:zsDeviceName]];
[syncClient setDisplayName:displayName];
Expand Down
12 changes: 4 additions & 8 deletions DeviceCode/ZSyncTouchHandler.m
Original file line number Diff line number Diff line change
Expand Up @@ -562,22 +562,18 @@ - (void)connectionEstablished
[self uploadDataToServer];
} else {
//We are not paired so we need to request a pairing session
NSMutableDictionary *dictionary = [NSMutableDictionary dictionary];
[dictionary setValue:zsActID(zsActionRequestPairing) forKey:zsAction];

NSString *deviceUUID = [[NSUserDefaults standardUserDefaults] valueForKey:zsDeviceID];
if (!deviceUUID) {
deviceUUID = [[NSProcessInfo processInfo] globallyUniqueString];
[[NSUserDefaults standardUserDefaults] setValue:deviceUUID forKey:zsDeviceID];
}

[dictionary setValue:deviceUUID forKey:zsDeviceID];

BLIPRequest *request = [BLIPRequest requestWithBody:nil properties:dictionary];
[self setPasscode:[self generatePairingCode]];
BLIPRequest *request = [BLIPRequest requestWithBodyString:[self passcode]];
[request setValue:zsActID(zsActionRequestPairing) ofProperty:zsAction];
[request setValue:deviceUUID ofProperty:zsDeviceID];
[[self connection] sendRequest:request];

//Need to push the passcode
[self setPasscode:[self generatePairingCode]];
[[self delegate] zSyncHandler:self displayPairingCode:[self passcode]];
}
break;
Expand Down

0 comments on commit 320caf8

Please sign in to comment.