| 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/remoting_client.h" | 9 #import "remoting/client/ios/session/remoting_client.h" |
| 10 | 10 |
| 11 #include <memory> |
| 12 |
| 11 #import "base/mac/bind_objc_block.h" | 13 #import "base/mac/bind_objc_block.h" |
| 12 #import "ios/third_party/material_components_ios/src/components/Dialogs/src/Mate
rialDialogs.h" | 14 #import "ios/third_party/material_components_ios/src/components/Dialogs/src/Mate
rialDialogs.h" |
| 13 #import "remoting/client/ios/display/gl_display_handler.h" | 15 #import "remoting/client/ios/display/gl_display_handler.h" |
| 14 #import "remoting/client/ios/domain/client_session_details.h" | 16 #import "remoting/client/ios/domain/client_session_details.h" |
| 15 #import "remoting/client/ios/domain/host_info.h" | 17 #import "remoting/client/ios/domain/host_info.h" |
| 16 | 18 |
| 17 #include "base/strings/sys_string_conversions.h" | 19 #include "base/strings/sys_string_conversions.h" |
| 18 #include "remoting/client/chromoting_client_runtime.h" | 20 #include "remoting/client/chromoting_client_runtime.h" |
| 19 #include "remoting/client/chromoting_session.h" | 21 #include "remoting/client/chromoting_session.h" |
| 20 #include "remoting/client/connect_to_host_info.h" | 22 #include "remoting/client/connect_to_host_info.h" |
| 23 #include "remoting/client/gesture_interpreter.h" |
| 21 #include "remoting/client/ios/session/remoting_client_session_delegate.h" | 24 #include "remoting/client/ios/session/remoting_client_session_delegate.h" |
| 22 #include "remoting/protocol/session.h" | 25 #include "remoting/protocol/session.h" |
| 23 #include "remoting/protocol/video_renderer.h" | 26 #include "remoting/protocol/video_renderer.h" |
| 24 | 27 |
| 25 NSString* const kHostSessionStatusChanged = @"kHostSessionStatusChanged"; | 28 NSString* const kHostSessionStatusChanged = @"kHostSessionStatusChanged"; |
| 26 NSString* const kHostSessionPinProvided = @"kHostSessionPinProvided"; | 29 NSString* const kHostSessionPinProvided = @"kHostSessionPinProvided"; |
| 27 | 30 |
| 28 NSString* const kSessionDetails = @"kSessionDetails"; | 31 NSString* const kSessionDetails = @"kSessionDetails"; |
| 29 NSString* const kSessonStateErrorCode = @"kSessonStateErrorCode"; | 32 NSString* const kSessonStateErrorCode = @"kSessonStateErrorCode"; |
| 30 NSString* const kHostSessionPin = @"kHostSessionPin"; | 33 NSString* const kHostSessionPin = @"kHostSessionPin"; |
| 31 | 34 |
| 32 @interface RemotingClient () { | 35 @interface RemotingClient () { |
| 33 remoting::ChromotingClientRuntime* _runtime; | 36 remoting::ChromotingClientRuntime* _runtime; |
| 34 std::unique_ptr<remoting::ChromotingSession> _session; | 37 std::unique_ptr<remoting::ChromotingSession> _session; |
| 35 remoting::RemotingClientSessonDelegate* _sessonDelegate; | 38 remoting::RemotingClientSessonDelegate* _sessonDelegate; |
| 36 ClientSessionDetails* _sessionDetails; | 39 ClientSessionDetails* _sessionDetails; |
| 37 // Call _secretFetchedCallback on the network thread. | 40 // Call _secretFetchedCallback on the network thread. |
| 38 remoting::protocol::SecretFetchedCallback _secretFetchedCallback; | 41 remoting::protocol::SecretFetchedCallback _secretFetchedCallback; |
| 42 std::unique_ptr<remoting::GestureInterpreter> _gestureInterpreter; |
| 39 } | 43 } |
| 40 @end | 44 @end |
| 41 | 45 |
| 42 @implementation RemotingClient | 46 @implementation RemotingClient |
| 43 | 47 |
| 44 @synthesize displayHandler = _displayHandler; | 48 @synthesize displayHandler = _displayHandler; |
| 45 | 49 |
| 46 - (instancetype)init { | 50 - (instancetype)init { |
| 47 self = [super init]; | 51 self = [super init]; |
| 48 if (self) { | 52 if (self) { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 object:self | 105 object:self |
| 102 userInfo:[NSDictionary | 106 userInfo:[NSDictionary |
| 103 dictionaryWithObject:_sessionDetails | 107 dictionaryWithObject:_sessionDetails |
| 104 forKey:kSessionDetails]]; | 108 forKey:kSessionDetails]]; |
| 105 }); | 109 }); |
| 106 | 110 |
| 107 // TODO(nicholss): Add audio support to iOS. | 111 // TODO(nicholss): Add audio support to iOS. |
| 108 base::WeakPtr<remoting::protocol::AudioStub> audioPlayer = nullptr; | 112 base::WeakPtr<remoting::protocol::AudioStub> audioPlayer = nullptr; |
| 109 | 113 |
| 110 _displayHandler = [[GlDisplayHandler alloc] init]; | 114 _displayHandler = [[GlDisplayHandler alloc] init]; |
| 115 __weak GlDisplayHandler* weakDisplayHandler = _displayHandler; |
| 116 _gestureInterpreter.reset(new remoting::GestureInterpreter( |
| 117 base::BindBlockArc(^(const remoting::ViewMatrix& matrix) { |
| 118 [weakDisplayHandler onPixelTransformationChanged:matrix]; |
| 119 }))); |
| 111 | 120 |
| 112 _runtime->ui_task_runner()->PostTask( | 121 _runtime->ui_task_runner()->PostTask( |
| 113 FROM_HERE, base::BindBlockArc(^{ | 122 FROM_HERE, base::BindBlockArc(^{ |
| 114 _session.reset(new remoting::ChromotingSession( | 123 _session.reset(new remoting::ChromotingSession( |
| 115 _sessonDelegate->GetWeakPtr(), | 124 _sessonDelegate->GetWeakPtr(), |
| 116 [_displayHandler CreateCursorShapeStub], | 125 [_displayHandler CreateCursorShapeStub], |
| 117 [_displayHandler CreateVideoRenderer], audioPlayer, info, | 126 [_displayHandler CreateVideoRenderer], audioPlayer, info, |
| 118 client_auth_config)); | 127 client_auth_config)); |
| 119 _session->Connect(); | 128 _session->Connect(); |
| 120 })); | 129 })); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 131 })); | 140 })); |
| 132 } | 141 } |
| 133 } | 142 } |
| 134 | 143 |
| 135 #pragma mark - Properties | 144 #pragma mark - Properties |
| 136 | 145 |
| 137 - (HostInfo*)hostInfo { | 146 - (HostInfo*)hostInfo { |
| 138 return _sessionDetails.hostInfo; | 147 return _sessionDetails.hostInfo; |
| 139 } | 148 } |
| 140 | 149 |
| 150 - (remoting::GestureInterpreter*)gestureInterpreter { |
| 151 return _gestureInterpreter.get(); |
| 152 } |
| 153 |
| 141 #pragma mark - ChromotingSession::Delegate | 154 #pragma mark - ChromotingSession::Delegate |
| 142 | 155 |
| 143 - (void)onConnectionState:(remoting::protocol::ConnectionToHost::State)state | 156 - (void)onConnectionState:(remoting::protocol::ConnectionToHost::State)state |
| 144 error:(remoting::protocol::ErrorCode)error { | 157 error:(remoting::protocol::ErrorCode)error { |
| 145 switch (state) { | 158 switch (state) { |
| 146 case remoting::protocol::ConnectionToHost::INITIALIZING: | 159 case remoting::protocol::ConnectionToHost::INITIALIZING: |
| 147 NSLog(@"State --> INITIALIZING"); | 160 NSLog(@"State --> INITIALIZING"); |
| 148 _sessionDetails.state = SessionInitializing; | 161 _sessionDetails.state = SessionInitializing; |
| 149 break; | 162 break; |
| 150 case remoting::protocol::ConnectionToHost::CONNECTING: | 163 case remoting::protocol::ConnectionToHost::CONNECTING: |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 NSLog(@"TODO(nicholss): implement this, setCapabilities."); | 208 NSLog(@"TODO(nicholss): implement this, setCapabilities."); |
| 196 } | 209 } |
| 197 | 210 |
| 198 - (void)handleExtensionMessageOfType:(NSString*)type | 211 - (void)handleExtensionMessageOfType:(NSString*)type |
| 199 message:(NSString*)message { | 212 message:(NSString*)message { |
| 200 NSLog(@"TODO(nicholss): implement this, handleExtensionMessageOfType %@:%@.", | 213 NSLog(@"TODO(nicholss): implement this, handleExtensionMessageOfType %@:%@.", |
| 201 type, message); | 214 type, message); |
| 202 } | 215 } |
| 203 | 216 |
| 204 @end | 217 @end |
| OLD | NEW |