Skip to content
Browse files

Start sync can now be called more than one from the iOS device

  • Loading branch information...
1 parent 1e55fa3 commit 1604cd262b9f7ecd64bd2964aaabe80ee74d70e7 Marcus S. Zarra committed Jun 18, 2010
View
1 DeviceCode/Reachability.m
@@ -166,7 +166,6 @@ + (Reachability*) reachabilityForInternetConnection;
+ (Reachability*) reachabilityForLocalWiFi;
{
- [super init];
struct sockaddr_in localWifiAddress;
bzero(&localWifiAddress, sizeof(localWifiAddress));
localWifiAddress.sin_len = sizeof(localWifiAddress);
View
42 DeviceCode/ZSyncTouchHandler.m
@@ -259,12 +259,13 @@ - (void)beginSyncWithService:(MYBonjourService*)service
- (void)services:(NSTimer*)timer
{
if (![[_serviceBrowser services] count]) {
- // TODO: This should time out at some point
if ([findServerTimeoutDate earlierDate:[NSDate date]] == findServerTimeoutDate) {
[findServerTimeoutDate release], findServerTimeoutDate = nil;
[timer invalidate];
[[self delegate] zSyncServerUnavailable:self];
[self setServerAction:ZSyncServerActionNoActivity];
+ [_serviceBrowser stop];
+ [_serviceBrowser release], _serviceBrowser = nil;
}
return;
}
@@ -276,28 +277,31 @@ - (void)services:(NSTimer*)timer
NSString *serverUUID = [[NSUserDefaults standardUserDefaults] valueForKey:zsServerUUID];
- if (!serverUUID) { //See if the server is in this list
- [[self delegate] zSyncNoServerPaired:[self availableServers]];
- return;
- }
-
- for (MYBonjourService *service in [_serviceBrowser services]) {
- NSString *serverName = [service name];
- NSArray *components = [serverName componentsSeparatedByString:zsServerNameSeperator];
- ZAssert([components count] == 2,@"Wrong number of components: %i\n%@", [components count], serverName);
- NSString *serverUUID = [components objectAtIndex:1];
- if (![serverUUID isEqualToString:serverUUID]) continue;
+ @try {
+ if (!serverUUID) { //See if the server is in this list
+ [[self delegate] zSyncNoServerPaired:[self availableServers]];
+ return;
+ }
- DLog(@"%s our server found", __PRETTY_FUNCTION__);
- //Found our server, start the sync
- [self beginSyncWithService:service];
+ for (MYBonjourService *service in [_serviceBrowser services]) {
+ NSString *serverName = [service name];
+ NSArray *components = [serverName componentsSeparatedByString:zsServerNameSeperator];
+ ZAssert([components count] == 2,@"Wrong number of components: %i\n%@", [components count], serverName);
+ NSString *serverUUID = [components objectAtIndex:1];
+ if (![serverUUID isEqualToString:serverUUID]) continue;
+
+ DLog(@"%s our server found", __PRETTY_FUNCTION__);
+ //Found our server, start the sync
+ [self beginSyncWithService:service];
+ return;
+ }
+ //Did not find our registered server. Fail
+ [[self delegate] zSyncServerUnavailable:self];
+ [self setServerAction:ZSyncServerActionNoActivity];
+ } @finally {
[_serviceBrowser stop];
[_serviceBrowser release], _serviceBrowser = nil;
- return;
}
- //Did not find our registered server. Fail
- [[self delegate] zSyncServerUnavailable:self];
- [self setServerAction:ZSyncServerActionNoActivity];
}
- (void)registerDelegate:(id<ZSyncDelegate>)delegate withPersistentStoreCoordinator:(NSPersistentStoreCoordinator*)coordinator;
View
4 SampleDesktop/SampleDesktop.xcodeproj/project.pbxproj
@@ -227,7 +227,7 @@
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
- 8D1107260486CEB800E47090 /* SampleDesktop */ = {
+ 8D1107260486CEB800E47090 /* ZSyncDaemon */ = {
isa = PBXNativeTarget;
buildConfigurationList = 26FC0A840875C7B200E6366F /* Build configuration list for PBXNativeTarget "SampleDesktop" */;
buildPhases = (
@@ -294,7 +294,7 @@
);
projectRoot = "";
targets = (
- 8D1107260486CEB800E47090 /* SampleDesktop */,
+ 8D1107260486CEB800E47090 /* ZSyncDaemon */,
B62DD00811BA1F5500AD6EAB /* SampleDesktopPlugin */,
);
};
View
12 ZSync.xcworkspace/contents.xcworkspacedata
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Workspace>
+ <FileRef
+ location = "container:Daemon/ZSyncDaemon.xcodeproj">
+ </FileRef>
+ <FileRef
+ location = "container:SampleTouch/SampleTouch.xcodeproj">
+ </FileRef>
+ <FileRef
+ location = "container:SampleDesktop/SampleDesktop.xcodeproj">
+ </FileRef>
+</Workspace>
View
1,524 ZSync.xcworkspace/xcuserdata/mzarra.xcuserdatad/WorkspaceState.xcuserstate
1,524 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.

0 comments on commit 1604cd2

Please sign in to comment.
Something went wrong with that request. Please try again.