From 8f44dc9a04485beb8317bed2a928ac65a4a5493a Mon Sep 17 00:00:00 2001 From: Siqi LIU Date: Wed, 14 Aug 2013 00:05:16 +0800 Subject: restart searching whenever connection failed Change-Id: I56bacb9953a07054da08546b982a1379de8e6642 --- .../xcdebugger/Breakpoints.xcbkptlist | 6 +++--- .../iosremote/Communication/CommunicationManager.m | 1 + ios/iosremote/iosremote/serverList_vc.h | 1 + ios/iosremote/iosremote/serverList_vc.m | 22 ++++++++++++++++------ 4 files changed, 21 insertions(+), 9 deletions(-) (limited to 'ios') diff --git a/ios/iosremote/iosremote.xcodeproj/xcuserdata/me.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist b/ios/iosremote/iosremote.xcodeproj/xcuserdata/me.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist index 10c0f6c2b8a2..382c35f789f2 100644 --- a/ios/iosremote/iosremote.xcodeproj/xcuserdata/me.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist +++ b/ios/iosremote/iosremote.xcodeproj/xcuserdata/me.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist @@ -8,11 +8,11 @@ ignoreCount = "0" continueAfterRunningActions = "No" filePath = "iosremote/Communication/CommunicationManager.m" - timestampString = "397932312.890248" + timestampString = "398102600.954242" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "77" - endingLineNumber = "77" + startingLineNumber = "78" + endingLineNumber = "78" landmarkName = "-connectionStatusHandler:" landmarkType = "5"> diff --git a/ios/iosremote/iosremote/Communication/CommunicationManager.m b/ios/iosremote/iosremote/Communication/CommunicationManager.m index a920f3f2fb88..c880fa1bf445 100644 --- a/ios/iosremote/iosremote/Communication/CommunicationManager.m +++ b/ios/iosremote/iosremote/Communication/CommunicationManager.m @@ -71,6 +71,7 @@ otherButtonTitles:NSLocalizedString(@"Help", nil), nil]; [message show]; }); + [(server_list_vc *)self.delegate startSearching]; } else { [[self.delegate navigationController] popToRootViewControllerAnimated:YES]; BasePresentationViewController *bpvc = [[(MainSplitViewController *)[self.delegate presentingViewController] viewControllers] objectAtIndex:1]; diff --git a/ios/iosremote/iosremote/serverList_vc.h b/ios/iosremote/iosremote/serverList_vc.h index 6052690dde93..3dacff1db163 100644 --- a/ios/iosremote/iosremote/serverList_vc.h +++ b/ios/iosremote/iosremote/serverList_vc.h @@ -14,4 +14,5 @@ @property (strong, nonatomic) IBOutlet UITableView *serverTable; +- (void) startSearching; @end diff --git a/ios/iosremote/iosremote/serverList_vc.m b/ios/iosremote/iosremote/serverList_vc.m index 63214e24f3bb..5095bf29b0d5 100644 --- a/ios/iosremote/iosremote/serverList_vc.m +++ b/ios/iosremote/iosremote/serverList_vc.m @@ -24,8 +24,8 @@ @property (nonatomic, strong) id slideShowPreviewStartObserver; @property (nonatomic, strong) id pinValidationObserver; @property (atomic, strong) NSIndexPath *lastSpinningCellIndex; - @property (nonatomic, strong) NSNetServiceBrowser *serviceBrowser; + @property (nonatomic, strong) NSTimer *searchLabelTimer; @property (nonatomic, strong) NSTimer *searchTimeoutTimer; @property (nonatomic, strong) NSString *searchStateText; @@ -46,6 +46,13 @@ @synthesize serviceBrowser = _serviceBrowser; #pragma mark - helper +- (void) startSearching +{ + [self.comManager.autoDiscoveryServers removeAllObjects]; + [self.serviceBrowser searchForServicesOfType:@"_impressremote._tcp" inDomain:@"local"]; + [self.serviceBrowser scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; +} + - (void) setSearchStateText:(NSString *)searchStateText { _searchStateText = searchStateText; @@ -75,6 +82,9 @@ -(void) netService:(NSNetService *)sender didNotResolve:(NSDictionary *)errorDict { NSLog(@"Failed to resolve"); + [self.comManager.autoDiscoveryServers removeAllObjects]; + [self startSearching]; + UIAlertView *message = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Failed to reach your computer", nil) message:NSLocalizedString(@"Please consider restart LibreOffice Impress on your computer.", nil) delegate:self @@ -140,7 +150,6 @@ - (void)netServiceBrowser:(NSNetServiceBrowser *)aNetServiceBrowser didNotSearch:(NSDictionary *)errorDict { NSLog(@"search error"); -// [self.serviceBrowser searchForServicesOfType:@"_impressRemote._tcp" inDomain:@"local"]; } - (void)netServiceBrowser:(NSNetServiceBrowser *)aNetServiceBrowser @@ -158,6 +167,9 @@ if(!moreComing) { [self.tableView reloadData]; + [self.serviceBrowser stop]; + [self.searchTimeoutTimer invalidate]; + [self.searchLabelTimer invalidate]; } } @@ -245,8 +257,7 @@ [self.serverTable reloadData]; self.serviceBrowser = [[NSNetServiceBrowser alloc] init]; [self.serviceBrowser setDelegate:self]; - [self.serviceBrowser searchForServicesOfType:@"_impressremote._tcp" inDomain:@"local"]; - [self.serviceBrowser scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; + [self startSearching]; [super viewDidAppear:animated]; } @@ -299,8 +310,7 @@ if ([self.comManager.autoDiscoveryServers count] == 0 && indexPath.section == 0){ // No discovered server and not searching => in a "click to refresh" state, so we restart searching process if (self.comManager.searchState == WAITING){ - [self.serviceBrowser searchForServicesOfType:@"_impressremote._tcp" inDomain:@"local"]; - [self.serviceBrowser scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; + [self startSearching]; } // Return when browser is still searching... return; -- cgit