| OLD | NEW |
| 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/client/ios/session/client.h" | 9 #import "remoting/client/ios/session/remoting_client.h" |
| 10 | 10 |
| 11 #import "base/mac/bind_objc_block.h" | 11 #import "base/mac/bind_objc_block.h" |
| 12 | 12 |
| 13 #include "remoting/client/chromoting_client_runtime.h" | 13 #include "remoting/client/chromoting_client_runtime.h" |
| 14 #include "remoting/client/chromoting_session.h" |
| 14 #include "remoting/client/connect_to_host_info.h" | 15 #include "remoting/client/connect_to_host_info.h" |
| 16 #include "remoting/client/ios/session/remoting_client_session_delegate.h" |
| 17 #include "remoting/protocol/video_renderer.h" |
| 15 | 18 |
| 16 @interface RemotingClient () { | 19 @interface RemotingClient () { |
| 17 GlDisplayHandler* _displayHandler; | |
| 18 remoting::ChromotingClientRuntime* _runtime; | 20 remoting::ChromotingClientRuntime* _runtime; |
| 19 std::unique_ptr<remoting::ChromotingSession> _session; | 21 std::unique_ptr<remoting::ChromotingSession> _session; |
| 20 remoting::RemotingClientSessonDelegate* _sessonDelegate; | 22 remoting::RemotingClientSessonDelegate* _sessonDelegate; |
| 21 } | 23 } |
| 22 @end | 24 @end |
| 23 | 25 |
| 24 @implementation RemotingClient | 26 @implementation RemotingClient |
| 25 | 27 |
| 28 @synthesize displayHandler = _displayHandler; |
| 29 |
| 26 - (instancetype)init { | 30 - (instancetype)init { |
| 27 self = [super init]; | 31 self = [super init]; |
| 28 if (self) { | 32 if (self) { |
| 29 _runtime = ChromotingClientRuntime::GetInstance(); | 33 _runtime = remoting::ChromotingClientRuntime::GetInstance(); |
| 30 _sessonDelegate = new remoting::RemotingClientSessonDelegate(self); | 34 _sessonDelegate = new remoting::RemotingClientSessonDelegate(self); |
| 31 } | 35 } |
| 32 return self; | 36 return self; |
| 33 } | 37 } |
| 34 | 38 |
| 35 - (void)connectToHost:(const remoting::ConnectToHostInfo&)info { | 39 - (void)connectToHost:(const remoting::ConnectToHostInfo&)info { |
| 36 _displayHandler = [[GlDisplayHandler alloc] initWithRuntime:_runtime]; | 40 remoting::ConnectToHostInfo hostInfo(info); |
| 37 | 41 |
| 38 protocol::ClientAuthenticationConfig client_auth_config; | 42 remoting::protocol::ClientAuthenticationConfig client_auth_config; |
| 39 client_auth_config.host_id = info.host_id; | 43 client_auth_config.host_id = info.host_id; |
| 40 client_auth_config.pairing_client_id = info.pairing_id; | 44 client_auth_config.pairing_client_id = info.pairing_id; |
| 41 client_auth_config.pairing_secret = info.pairing_secret; | 45 client_auth_config.pairing_secret = info.pairing_secret; |
| 42 client_auth_config.fetch_secret_callback = base::BindBlockArc( | 46 client_auth_config.fetch_secret_callback = base::BindBlockArc( |
| 43 ^(bool pairing_supported, | 47 ^(bool pairing_supported, const remoting::protocol::SecretFetchedCallback& |
| 44 const SecretFetchedCallback& secret_fetched_callback) { | 48 secret_fetched_callback) { |
| 45 NSLog(@"TODO(nicholss): Implement the FetchSecretCallback."); | 49 NSLog(@"TODO(nicholss): Implement the FetchSecretCallback."); |
| 50 // TODO(nicholss): For now we pass back a junk number. |
| 51 secret_fetched_callback.Run("000000"); |
| 46 }); | 52 }); |
| 47 | 53 |
| 48 // TODO(nicholss): Add audio support to iOS. | 54 // TODO(nicholss): Add audio support to iOS. |
| 49 base::WeakPtr<protocol::AudioStub> audioPlayer = nullptr; | 55 base::WeakPtr<remoting::protocol::AudioStub> audioPlayer = nullptr; |
| 50 | 56 |
| 51 _session.reset(new remoting::ChromotingSession( | 57 _displayHandler = [[GlDisplayHandler alloc] init]; |
| 52 _sessonDelegate->GetWeakPtr(), [_displayHandler CreateCursorShapeStub], | 58 |
| 53 [_displayHandler CreateVideoRenderer], audioPlayer, info, | 59 _runtime->ui_task_runner()->PostTask( |
| 54 client_auth_config)); | 60 FROM_HERE, base::BindBlockArc(^{ |
| 55 _session->Connect(); | 61 _session.reset(new remoting::ChromotingSession( |
| 62 _sessonDelegate->GetWeakPtr(), |
| 63 [_displayHandler CreateCursorShapeStub], |
| 64 [_displayHandler CreateVideoRenderer], audioPlayer, hostInfo, |
| 65 client_auth_config)); |
| 66 _session->Connect(); |
| 67 })); |
| 56 } | 68 } |
| 57 | 69 |
| 58 #pragma mark - ChromotingSession::Delegate | 70 #pragma mark - ChromotingSession::Delegate |
| 59 | 71 |
| 60 - (void)onConnectionState:(protocol::ConnectionToHost::State)state | 72 - (void)onConnectionState:(remoting::protocol::ConnectionToHost::State)state |
| 61 error:(protocol::ErrorCode)error { | 73 error:(remoting::protocol::ErrorCode)error { |
| 62 NSLog(@"TODO(nicholss): implement this."); | 74 NSLog(@"TODO(nicholss): implement this, onConnectionState: %d %d.", state, |
| 75 error); |
| 63 } | 76 } |
| 64 | 77 |
| 65 - (void)commitPairingCredentialsForHost:(NSString*)host | 78 - (void)commitPairingCredentialsForHost:(NSString*)host |
| 66 id:(NSString*)id | 79 id:(NSString*)id |
| 67 secret:(NSString*)secret { | 80 secret:(NSString*)secret { |
| 68 NSLog(@"TODO(nicholss): implement this."); | 81 NSLog(@"TODO(nicholss): implement this, commitPairingCredentialsForHost."); |
| 69 } | 82 } |
| 70 | 83 |
| 71 - (void)fetchThirdPartyTokenForUrl:(NSString*)tokenUrl | 84 - (void)fetchThirdPartyTokenForUrl:(NSString*)tokenUrl |
| 72 clientId:(NSString*)clientId | 85 clientId:(NSString*)clientId |
| 73 scope:(NSString*)scope { | 86 scope:(NSString*)scope { |
| 74 NSLog(@"TODO(nicholss): implement this."); | 87 NSLog(@"TODO(nicholss): implement this, fetchThirdPartyTokenForUrl."); |
| 75 } | 88 } |
| 76 | 89 |
| 77 - (void)setCapabilities:(NSString*)capabilities { | 90 - (void)setCapabilities:(NSString*)capabilities { |
| 78 NSLog(@"TODO(nicholss): implement this."); | 91 NSLog(@"TODO(nicholss): implement this, setCapabilities."); |
| 79 } | 92 } |
| 80 | 93 |
| 81 - (void)handleExtensionMessageOfType:(NSString*)type | 94 - (void)handleExtensionMessageOfType:(NSString*)type |
| 82 message:(NSString*)message { | 95 message:(NSString*)message { |
| 83 NSLog(@"TODO(nicholss): implement this."); | 96 NSLog(@"TODO(nicholss): implement this, handleExtensionMessageOfType %@:%@.", |
| 97 type, message); |
| 84 } | 98 } |
| 85 | 99 |
| 86 @end | 100 @end |
| OLD | NEW |