Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(106)

Side by Side Diff: remoting/ios/app/client_connection_view_controller.mm

Issue 2971903002: Adding error handling to the connection flow. (Closed)
Patch Set: Minor cleanup before review. Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #if !defined(__has_feature) || !__has_feature(objc_arc) 5 #if !defined(__has_feature) || !__has_feature(objc_arc)
6 #error "This file requires ARC support." 6 #error "This file requires ARC support."
7 #endif 7 #endif
8 8
9 #import "remoting/ios/app/client_connection_view_controller.h" 9 #import "remoting/ios/app/client_connection_view_controller.h"
10 10
11 #import "base/mac/bind_objc_block.h" 11 #import "base/mac/bind_objc_block.h"
12 #import "ios/third_party/material_components_ios/src/components/ActivityIndicato r/src/MDCActivityIndicator.h" 12 #import "ios/third_party/material_components_ios/src/components/ActivityIndicato r/src/MDCActivityIndicator.h"
13 #import "ios/third_party/material_components_ios/src/components/Buttons/src/Mate rialButtons.h" 13 #import "ios/third_party/material_components_ios/src/components/Buttons/src/Mate rialButtons.h"
14 #import "ios/third_party/material_components_ios/src/components/NavigationBar/sr c/MaterialNavigationBar.h" 14 #import "ios/third_party/material_components_ios/src/components/NavigationBar/sr c/MaterialNavigationBar.h"
15 #import "ios/third_party/material_components_ios/src/components/Snackbar/src/Mat erialSnackbar.h"
15 #import "remoting/ios/app/host_view_controller.h" 16 #import "remoting/ios/app/host_view_controller.h"
16 #import "remoting/ios/app/pin_entry_view.h" 17 #import "remoting/ios/app/pin_entry_view.h"
17 #import "remoting/ios/app/remoting_theme.h" 18 #import "remoting/ios/app/remoting_theme.h"
19 #import "remoting/ios/app/session_error_view.h"
18 #import "remoting/ios/domain/client_session_details.h" 20 #import "remoting/ios/domain/client_session_details.h"
19 #import "remoting/ios/domain/host_info.h" 21 #import "remoting/ios/domain/host_info.h"
20 #import "remoting/ios/facade/remoting_authentication.h" 22 #import "remoting/ios/facade/remoting_authentication.h"
21 #import "remoting/ios/facade/remoting_service.h" 23 #import "remoting/ios/facade/remoting_service.h"
22 #import "remoting/ios/session/remoting_client.h" 24 #import "remoting/ios/session/remoting_client.h"
23 25
24 #include "base/strings/sys_string_conversions.h" 26 #include "base/strings/sys_string_conversions.h"
25 #include "remoting/protocol/client_authentication_config.h" 27 #include "remoting/protocol/client_authentication_config.h"
26 28
27 static const CGFloat kIconRadius = 30.f; 29 static const CGFloat kIconRadius = 30.f;
28 static const CGFloat kActivityIndicatorStrokeWidth = 3.f; 30 static const CGFloat kActivityIndicatorStrokeWidth = 3.f;
29 static const CGFloat kActivityIndicatorRadius = 33.f; 31 static const CGFloat kActivityIndicatorRadius = 33.f;
30 32
31 static const CGFloat kPinEntryViewWidth = 240.f; 33 static const CGFloat kPinEntryViewWidth = 240.f;
32 static const CGFloat kPinEntryViewHeight = 90.f; 34 static const CGFloat kPinEntryViewHeight = 90.f;
33 35
36 static const CGFloat kErrorViewWidth = 120.f;
37 static const CGFloat kErrorViewHeight = 90.f;
38
34 static const CGFloat kCenterShift = -80.f; 39 static const CGFloat kCenterShift = -80.f;
35 static const CGFloat kPadding = 20.f; 40 static const CGFloat kPadding = 20.f;
36 static const CGFloat kMargin = 20.f; 41 static const CGFloat kMargin = 20.f;
37 42
38 static const CGFloat kBarHeight = 58.f; 43 static const CGFloat kBarHeight = 58.f;
39 44
40 static const CGFloat kKeyboardAnimationTime = 0.3; 45 static const CGFloat kKeyboardAnimationTime = 0.3;
41 46
42 @interface ClientConnectionViewController ()<PinEntryDelegate> { 47 @interface ClientConnectionViewController ()<PinEntryDelegate,
48 SessionErrorViewDelegate> {
43 UIImageView* _iconView; 49 UIImageView* _iconView;
44 MDCActivityIndicator* _activityIndicator; 50 MDCActivityIndicator* _activityIndicator;
45 UILabel* _statusLabel; 51 UILabel* _statusLabel;
46 MDCNavigationBar* _navBar; 52 MDCNavigationBar* _navBar;
47 PinEntryView* _pinEntryView; 53 PinEntryView* _pinEntryView;
54 SessionErrorView* _errorView;
48 NSString* _remoteHostName; 55 NSString* _remoteHostName;
49 RemotingClient* _client; 56 RemotingClient* _client;
57 SessionErrorCode _lastError;
58 HostInfo* _hostInfo;
50 } 59 }
51 @end 60 @end
52 61
53 @implementation ClientConnectionViewController 62 @implementation ClientConnectionViewController
54 63
55 @synthesize state = _state; 64 @synthesize state = _state;
56 65
57 - (instancetype)initWithHostInfo:(HostInfo*)hostInfo { 66 - (instancetype)initWithHostInfo:(HostInfo*)hostInfo {
58 self = [super init]; 67 self = [super init];
59 if (self) { 68 if (self) {
60 _client = [[RemotingClient alloc] init]; 69 _hostInfo = hostInfo;
61
62 __weak RemotingClient* weakClient = _client;
63 [RemotingService.instance.authentication
64 callbackWithAccessToken:^(RemotingAuthenticationStatus status,
65 NSString* userEmail, NSString* accessToken) {
66 [weakClient connectToHost:hostInfo
67 username:userEmail
68 accessToken:accessToken];
69 }];
70
71 _remoteHostName = hostInfo.hostName; 70 _remoteHostName = hostInfo.hostName;
72 71
73 // TODO(yuweih): This logic may be reused by other views. 72 // TODO(yuweih): This logic may be reused by other views.
74 UIButton* cancelButton = [UIButton buttonWithType:UIButtonTypeSystem]; 73 UIButton* cancelButton = [UIButton buttonWithType:UIButtonTypeSystem];
75 [cancelButton setTitle:@"CANCEL" forState:UIControlStateNormal]; 74 [cancelButton setTitle:@"CANCEL" forState:UIControlStateNormal];
76 [cancelButton 75 [cancelButton
77 setImage:[RemotingTheme 76 setImage:[RemotingTheme
78 .backIcon imageFlippedForRightToLeftLayoutDirection] 77 .backIcon imageFlippedForRightToLeftLayoutDirection]
79 forState:UIControlStateNormal]; 78 forState:UIControlStateNormal];
80 [cancelButton addTarget:self 79 [cancelButton addTarget:self
(...skipping 14 matching lines...) Expand all
95 94
96 // Attach navBar to the top of the view. 95 // Attach navBar to the top of the view.
97 [NSLayoutConstraint activateConstraints:@[ 96 [NSLayoutConstraint activateConstraints:@[
98 [[_navBar topAnchor] constraintEqualToAnchor:[self.view topAnchor]], 97 [[_navBar topAnchor] constraintEqualToAnchor:[self.view topAnchor]],
99 [[_navBar leadingAnchor] 98 [[_navBar leadingAnchor]
100 constraintEqualToAnchor:[self.view leadingAnchor]], 99 constraintEqualToAnchor:[self.view leadingAnchor]],
101 [[_navBar trailingAnchor] 100 [[_navBar trailingAnchor]
102 constraintEqualToAnchor:[self.view trailingAnchor]], 101 constraintEqualToAnchor:[self.view trailingAnchor]],
103 [[_navBar heightAnchor] constraintEqualToConstant:kBarHeight], 102 [[_navBar heightAnchor] constraintEqualToConstant:kBarHeight],
104 ]]; 103 ]];
104
105 [self attemptConnectionToHost];
105 } 106 }
106 return self; 107 return self;
107 } 108 }
108 109
109 #pragma mark - UIViewController 110 #pragma mark - UIViewController
110 111
111 - (void)loadView { 112 - (void)loadView {
112 [super loadView]; 113 [super loadView];
113 114
114 self.view.backgroundColor = RemotingTheme.connectionViewBackgroundColor; 115 self.view.backgroundColor = RemotingTheme.connectionViewBackgroundColor;
115 116
116 _activityIndicator = [[MDCActivityIndicator alloc] initWithFrame:CGRectZero]; 117 _activityIndicator = [[MDCActivityIndicator alloc] initWithFrame:CGRectZero];
117 [self.view addSubview:_activityIndicator]; 118 [self.view addSubview:_activityIndicator];
118 119
119 _statusLabel = [[UILabel alloc] initWithFrame:CGRectZero]; 120 _statusLabel = [[UILabel alloc] initWithFrame:CGRectZero];
120 [self.view addSubview:_statusLabel]; 121 [self.view addSubview:_statusLabel];
121 122
122 _iconView = [[UIImageView alloc] initWithFrame:CGRectZero]; 123 _iconView = [[UIImageView alloc] initWithFrame:CGRectZero];
123 [self.view addSubview:_iconView]; 124 [self.view addSubview:_iconView];
124 125
126 _errorView = [[SessionErrorView alloc] initWithFrame:CGRectZero];
127 [self.view addSubview:_errorView];
128 _errorView.delegate = self;
129
125 _pinEntryView = [[PinEntryView alloc] init]; 130 _pinEntryView = [[PinEntryView alloc] init];
126 [self.view addSubview:_pinEntryView]; 131 [self.view addSubview:_pinEntryView];
127 _pinEntryView.delegate = self; 132 _pinEntryView.delegate = self;
128 } 133 }
129 134
130 - (void)viewDidLoad { 135 - (void)viewDidLoad {
131 [super viewDidLoad]; 136 [super viewDidLoad];
132 137
133 _iconView.contentMode = UIViewContentModeCenter; 138 _iconView.contentMode = UIViewContentModeCenter;
134 _iconView.alpha = 0.87f; 139 _iconView.alpha = 0.87f;
135 _iconView.backgroundColor = RemotingTheme.onlineHostColor; 140 _iconView.backgroundColor = RemotingTheme.onlineHostColor;
136 _iconView.layer.cornerRadius = kIconRadius; 141 _iconView.layer.cornerRadius = kIconRadius;
137 _iconView.layer.masksToBounds = YES; 142 _iconView.layer.masksToBounds = YES;
138 _iconView.image = RemotingTheme.desktopIcon; 143 _iconView.image = RemotingTheme.desktopIcon;
139 144
140 _activityIndicator.radius = kActivityIndicatorRadius; 145 _activityIndicator.radius = kActivityIndicatorRadius;
141 _activityIndicator.trackEnabled = YES; 146 _activityIndicator.trackEnabled = YES;
142 _activityIndicator.strokeWidth = kActivityIndicatorStrokeWidth; 147 _activityIndicator.strokeWidth = kActivityIndicatorStrokeWidth;
143 _activityIndicator.cycleColors = @[ UIColor.whiteColor ]; 148 _activityIndicator.cycleColors = @[ UIColor.whiteColor ];
144 149
145 _statusLabel.numberOfLines = 1; 150 _statusLabel.numberOfLines = 1;
146 _statusLabel.lineBreakMode = NSLineBreakByTruncatingTail; 151 _statusLabel.lineBreakMode = NSLineBreakByTruncatingTail;
147 _statusLabel.textColor = [UIColor whiteColor]; 152 _statusLabel.textColor = [UIColor whiteColor];
148 _statusLabel.textAlignment = NSTextAlignmentCenter; 153 _statusLabel.textAlignment = NSTextAlignmentCenter;
149 154
150 _pinEntryView.hidden = YES; 155 _pinEntryView.hidden = YES;
156
157 _errorView.hidden = YES;
151 } 158 }
152 159
153 - (void)viewWillLayoutSubviews { 160 - (void)viewWillLayoutSubviews {
154 [super viewWillLayoutSubviews]; 161 [super viewWillLayoutSubviews];
155 162
156 _iconView.frame = CGRectMake(0, 0, kIconRadius * 2, kIconRadius * 2.f); 163 _iconView.frame = CGRectMake(0, 0, kIconRadius * 2, kIconRadius * 2.f);
Yuwei 2017/07/05 21:43:42 FYI I think all these layout code need to be chang
nicholss 2017/07/06 20:49:02 Fixed up the main view. Need to do the pin entry v
157 _iconView.center = 164 _iconView.center =
158 CGPointMake(self.view.center.x, self.view.center.y + kCenterShift); 165 CGPointMake(self.view.center.x, self.view.center.y + kCenterShift);
159 166
160 [_activityIndicator sizeToFit]; 167 [_activityIndicator sizeToFit];
161 _activityIndicator.center = _iconView.center; 168 _activityIndicator.center = _iconView.center;
162 169
163 _statusLabel.frame = 170 _statusLabel.frame = CGRectMake(
164 CGRectMake(kMargin, _activityIndicator.center.y + kIconRadius + kPadding, 171 kMargin, _activityIndicator.center.y + kIconRadius + kPadding,
165 self.view.frame.size.width - kMargin * 2.f, 172 self.view.frame.size.width - kMargin * 2.f,
166 _statusLabel.font.pointSize * _statusLabel.numberOfLines); 173 _statusLabel.font.pointSize * _statusLabel.numberOfLines * 1.1);
Yuwei 2017/07/05 21:43:42 What is this 1.1 doing?
nicholss 2017/07/06 20:49:01 The bottom of the g was getting cut off, I guess
Yuwei 2017/07/06 21:52:39 I think point is a unit different than pixels. UIF
167 174
168 _pinEntryView.frame = CGRectMake( 175 _pinEntryView.frame = CGRectMake(
169 (self.view.frame.size.width - kPinEntryViewWidth) / 2.f, 176 (self.view.frame.size.width - kPinEntryViewWidth) / 2.f,
170 _statusLabel.frame.origin.y + _statusLabel.frame.size.height + kPadding, 177 _statusLabel.frame.origin.y + _statusLabel.frame.size.height + kPadding,
171 kPinEntryViewWidth, kPinEntryViewHeight); 178 kPinEntryViewWidth, kPinEntryViewHeight);
179
180 _errorView.frame = CGRectMake(
181 (self.view.frame.size.width - kErrorViewWidth) / 2.f,
182 _statusLabel.frame.origin.y + _statusLabel.frame.size.height + kPadding,
183 kErrorViewWidth, kErrorViewHeight);
184 [_errorView setNeedsLayout];
172 } 185 }
173 186
174 - (void)viewWillAppear:(BOOL)animated { 187 - (void)viewWillAppear:(BOOL)animated {
175 [super viewWillAppear:animated]; 188 [super viewWillAppear:animated];
176 [self.navigationController setNavigationBarHidden:YES animated:animated]; 189 [self.navigationController setNavigationBarHidden:YES animated:animated];
177 190
178 [[NSNotificationCenter defaultCenter] 191 [[NSNotificationCenter defaultCenter]
179 addObserver:self 192 addObserver:self
180 selector:@selector(hostSessionStatusChanged:) 193 selector:@selector(hostSessionStatusChanged:)
181 name:kHostSessionStatusChanged 194 name:kHostSessionStatusChanged
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 case ClientViewConnecting: 264 case ClientViewConnecting:
252 [self showConnectingState]; 265 [self showConnectingState];
253 break; 266 break;
254 case ClientViewPinPrompt: 267 case ClientViewPinPrompt:
255 [self showPinPromptState]; 268 [self showPinPromptState];
256 break; 269 break;
257 case ClientViewConnected: 270 case ClientViewConnected:
258 [self showConnectedState]; 271 [self showConnectedState];
259 break; 272 break;
260 case ClientViewClosed: 273 case ClientViewClosed:
261 [self dismissViewControllerAnimated:YES completion:nil]; 274 [self dismissViewControllerAnimated:YES completion:nil];
Yuwei 2017/07/05 21:43:42 Since you are here could you change this to [self.
nicholss 2017/07/06 20:49:02 Done.
262 break; 275 break;
276 case ClientViewError:
277 [self showError];
278 break;
263 } 279 }
264 } 280 }
265 281
282 #pragma mark - SessionErrorViewDelegate
283
284 - (void)didTapReconnect {
285 [self attemptConnectionToHost];
286 }
287
266 #pragma mark - Private 288 #pragma mark - Private
267 289
290 - (void)attemptConnectionToHost {
291 _client = [[RemotingClient alloc] init];
292 __weak RemotingClient* weakClient = _client;
293 __weak HostInfo* weakHostInfo = _hostInfo;
294 [RemotingService.instance.authentication
295 callbackWithAccessToken:^(RemotingAuthenticationStatus status,
296 NSString* userEmail, NSString* accessToken) {
297 [weakClient connectToHost:weakHostInfo
298 username:userEmail
299 accessToken:accessToken];
300 }];
301 [self setState:ClientViewConnecting];
302 }
303
268 - (void)showConnectingState { 304 - (void)showConnectingState {
269 [_pinEntryView endEditing:YES]; 305 [_pinEntryView endEditing:YES];
270 _statusLabel.text = 306 _statusLabel.text =
271 [NSString stringWithFormat:@"Connecting to %@", _remoteHostName]; 307 [NSString stringWithFormat:@"Connecting to %@", _remoteHostName];
272 [_activityIndicator stopAnimating]; 308 [_activityIndicator stopAnimating];
273 _activityIndicator.cycleColors = @[ [UIColor whiteColor] ]; 309 _activityIndicator.cycleColors = @[ [UIColor whiteColor] ];
274 _activityIndicator.indicatorMode = MDCActivityIndicatorModeIndeterminate; 310 _activityIndicator.indicatorMode = MDCActivityIndicatorModeIndeterminate;
275 _activityIndicator.hidden = NO; 311 _activityIndicator.hidden = NO;
276 _pinEntryView.hidden = YES; 312 _pinEntryView.hidden = YES;
313 _errorView.hidden = YES;
277 [_activityIndicator startAnimating]; 314 [_activityIndicator startAnimating];
278 } 315 }
279 316
280 - (void)showPinPromptState { 317 - (void)showPinPromptState {
281 _statusLabel.text = [NSString stringWithFormat:@"%@", _remoteHostName]; 318 _statusLabel.text = [NSString stringWithFormat:@"%@", _remoteHostName];
282 [_activityIndicator stopAnimating]; 319 [_activityIndicator stopAnimating];
283 _activityIndicator.hidden = YES; 320 _activityIndicator.hidden = YES;
284 _pinEntryView.hidden = NO; 321 _pinEntryView.hidden = NO;
322 _errorView.hidden = YES;
285 323
286 // TODO(yuweih): This may be called before viewDidAppear and miss the keyboard 324 // TODO(yuweih): This may be called before viewDidAppear and miss the keyboard
287 // callback. 325 // callback.
288 [_pinEntryView becomeFirstResponder]; 326 [_pinEntryView becomeFirstResponder];
289 } 327 }
290 328
291 - (void)showConnectedState { 329 - (void)showConnectedState {
292 [_pinEntryView endEditing:YES]; 330 [_pinEntryView endEditing:YES];
293 _statusLabel.text = 331 _statusLabel.text =
294 [NSString stringWithFormat:@"Connected to %@", _remoteHostName]; 332 [NSString stringWithFormat:@"Connected to %@", _remoteHostName];
295 _activityIndicator.progress = 0.0; 333 _activityIndicator.progress = 0.0;
296 _pinEntryView.hidden = YES; 334 _pinEntryView.hidden = YES;
297 _activityIndicator.hidden = NO; 335 _activityIndicator.hidden = NO;
298 _activityIndicator.indicatorMode = MDCActivityIndicatorModeDeterminate; 336 _activityIndicator.indicatorMode = MDCActivityIndicatorModeDeterminate;
299 _activityIndicator.cycleColors = @[ [UIColor greenColor] ]; 337 _activityIndicator.cycleColors = @[ [UIColor greenColor] ];
300 [_activityIndicator startAnimating]; 338 [_activityIndicator startAnimating];
301 _activityIndicator.progress = 1.0; 339 _activityIndicator.progress = 1.0;
340 _errorView.hidden = YES;
302 341
303 HostViewController* hostViewController = 342 HostViewController* hostViewController =
304 [[HostViewController alloc] initWithClient:_client]; 343 [[HostViewController alloc] initWithClient:_client];
305 _client = nil; 344 _client = nil;
306 345
307 // Replaces current (topmost) view controller with |hostViewController|. 346 // Replaces current (topmost) view controller with |hostViewController|.
308 NSMutableArray* controllers = 347 NSMutableArray* controllers =
309 [self.navigationController.viewControllers mutableCopy]; 348 [self.navigationController.viewControllers mutableCopy];
310 [controllers removeLastObject]; 349 [controllers removeLastObject];
311 [controllers addObject:hostViewController]; 350 [controllers addObject:hostViewController];
312 [self.navigationController setViewControllers:controllers animated:NO]; 351 [self.navigationController setViewControllers:controllers animated:NO];
313 } 352 }
314 353
354 - (void)showError {
355 _statusLabel.text =
356 [NSString stringWithFormat:@"Error connecting to %@", _remoteHostName];
357 _activityIndicator.progress = 0.0;
358 _pinEntryView.hidden = YES;
359 _activityIndicator.hidden = NO;
360 _activityIndicator.indicatorMode = MDCActivityIndicatorModeDeterminate;
361 _activityIndicator.cycleColors = @[ [UIColor redColor] ];
362 [_activityIndicator startAnimating];
363 _activityIndicator.progress = 1.0;
364 _errorView.hidden = NO;
365
366 MDCSnackbarMessage* message = nil;
367 switch (_lastError) {
368 case SessionErrorOk:
369 // Do nothing.
370 break;
371 case SessionErrorPeerIsOffline:
372 message = [MDCSnackbarMessage
373 messageWithText:@"Error: SessionErrorPeerIsOffline."];
374 break;
375 case SessionErrorSessionRejected:
376 message = [MDCSnackbarMessage
377 messageWithText:@"Error: SessionErrorSessionRejected."];
378 break;
379 case SessionErrorIncompatibleProtocol:
380 message = [MDCSnackbarMessage
381 messageWithText:@"Error: SessionErrorIncompatibleProtocol."];
382 break;
383 case SessionErrorAuthenticationFailed:
384 message = [MDCSnackbarMessage messageWithText:@"Error: Invalid Pin."];
385 [_pinEntryView clearPinEntry];
386 break;
387 case SessionErrorInvalidAccount:
388 message = [MDCSnackbarMessage
389 messageWithText:@"Error: SessionErrorInvalidAccount."];
390 break;
391 case SessionErrorChannelConnectionError:
392 message = [MDCSnackbarMessage
393 messageWithText:@"Error: SessionErrorChannelConnectionError."];
394 break;
395 case SessionErrorSignalingError:
396 message = [MDCSnackbarMessage
397 messageWithText:@"Error: SessionErrorSignalingError."];
398 break;
399 case SessionErrorSignalingTimeout:
400 message = [MDCSnackbarMessage
401 messageWithText:@"Error: SessionErrorSignalingTimeout."];
402 break;
403 case SessionErrorHostOverload:
404 message = [MDCSnackbarMessage
405 messageWithText:@"Error: SessionErrorHostOverload."];
406 break;
407 case SessionErrorMaxSessionLength:
408 message = [MDCSnackbarMessage
409 messageWithText:@"Error: SessionErrorMaxSessionLength."];
410 break;
411 case SessionErrorHostConfigurationError:
412 message = [MDCSnackbarMessage
413 messageWithText:@"Error: SessionErrorHostConfigurationError."];
414 break;
415 case SessionErrorUnknownError:
416 message = [MDCSnackbarMessage
417 messageWithText:@"Error: SessionErrorUnknownError."];
418 break;
419 }
420 if (message.text) {
421 [MDCSnackbarManager showMessage:message];
422 }
423 }
424
315 - (void)didProvidePin:(NSString*)pin createPairing:(BOOL)createPairing { 425 - (void)didProvidePin:(NSString*)pin createPairing:(BOOL)createPairing {
316 // TODO(nicholss): There is an open question if createPairing is supported on 426 // TODO(nicholss): There is an open question if createPairing is supported on
317 // iOS. Need to fingure this out. 427 // iOS. Need to fingure this out.
318 [[NSNotificationCenter defaultCenter] 428 [[NSNotificationCenter defaultCenter]
319 postNotificationName:kHostSessionPinProvided 429 postNotificationName:kHostSessionPinProvided
320 object:self 430 object:self
321 userInfo:[NSDictionary dictionaryWithObject:pin 431 userInfo:[NSDictionary dictionaryWithObject:pin
322 forKey:kHostSessionPin]]; 432 forKey:kHostSessionPin]];
323 } 433 }
324 434
(...skipping 15 matching lines...) Expand all
340 case SessionConnecting: 450 case SessionConnecting:
341 state = ClientViewConnecting; 451 state = ClientViewConnecting;
342 break; 452 break;
343 case SessionPinPrompt: 453 case SessionPinPrompt:
344 state = ClientViewPinPrompt; 454 state = ClientViewPinPrompt;
345 break; 455 break;
346 case SessionConnected: 456 case SessionConnected:
347 state = ClientViewConnected; 457 state = ClientViewConnected;
348 break; 458 break;
349 case SessionFailed: 459 case SessionFailed:
350 // TODO(nicholss): Implement an error screen. 460 state = ClientViewError;
461 break;
351 case SessionClosed: 462 case SessionClosed:
352 state = ClientViewClosed; 463 state = ClientViewClosed;
353 break; 464 break;
354 default: 465 default:
355 LOG(ERROR) << "Unknown State for Session, " << sessionDetails.state; 466 LOG(ERROR) << "Unknown State for Session, " << sessionDetails.state;
356 return; 467 return;
357 } 468 }
469 _lastError = sessionDetails.error;
358 [[NSOperationQueue mainQueue] addOperationWithBlock:^{ 470 [[NSOperationQueue mainQueue] addOperationWithBlock:^{
359 [self setState:state]; 471 [self setState:state];
360 }]; 472 }];
361 } 473 }
362 474
363 @end 475 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698