| 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/ios/session/remoting_client.h" | 9 #import "remoting/ios/session/remoting_client.h" |
| 10 | 10 |
| 11 #include <memory> | 11 #include <memory> |
| 12 | 12 |
| 13 #import "base/mac/bind_objc_block.h" | 13 #import "base/mac/bind_objc_block.h" |
| 14 #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" |
| 15 #import "remoting/ios/display/gl_display_handler.h" | 15 #import "remoting/ios/display/gl_display_handler.h" |
| 16 #import "remoting/ios/domain/client_session_details.h" | 16 #import "remoting/ios/domain/client_session_details.h" |
| 17 #import "remoting/ios/domain/host_info.h" | 17 #import "remoting/ios/domain/host_info.h" |
| 18 | 18 |
| 19 #include "base/strings/sys_string_conversions.h" | 19 #include "base/strings/sys_string_conversions.h" |
| 20 #include "remoting/client/chromoting_client_runtime.h" | 20 #include "remoting/client/chromoting_client_runtime.h" |
| 21 #include "remoting/client/chromoting_session.h" | 21 #include "remoting/client/chromoting_session.h" |
| 22 #include "remoting/client/connect_to_host_info.h" | 22 #include "remoting/client/connect_to_host_info.h" |
| 23 #include "remoting/client/input/keyboard_interpreter.h" |
| 23 #include "remoting/client/ui/gesture_interpreter.h" | 24 #include "remoting/client/ui/gesture_interpreter.h" |
| 24 #include "remoting/client/ui/renderer_proxy.h" | 25 #include "remoting/client/ui/renderer_proxy.h" |
| 25 #include "remoting/ios/session/remoting_client_session_delegate.h" | 26 #include "remoting/ios/session/remoting_client_session_delegate.h" |
| 26 #include "remoting/protocol/session.h" | 27 #include "remoting/protocol/session.h" |
| 27 #include "remoting/protocol/video_renderer.h" | 28 #include "remoting/protocol/video_renderer.h" |
| 28 | 29 |
| 29 NSString* const kHostSessionStatusChanged = @"kHostSessionStatusChanged"; | 30 NSString* const kHostSessionStatusChanged = @"kHostSessionStatusChanged"; |
| 30 NSString* const kHostSessionPinProvided = @"kHostSessionPinProvided"; | 31 NSString* const kHostSessionPinProvided = @"kHostSessionPinProvided"; |
| 31 | 32 |
| 32 NSString* const kSessionDetails = @"kSessionDetails"; | 33 NSString* const kSessionDetails = @"kSessionDetails"; |
| 33 NSString* const kSessonStateErrorCode = @"kSessonStateErrorCode"; | 34 NSString* const kSessonStateErrorCode = @"kSessonStateErrorCode"; |
| 34 NSString* const kHostSessionPin = @"kHostSessionPin"; | 35 NSString* const kHostSessionPin = @"kHostSessionPin"; |
| 35 | 36 |
| 36 @interface RemotingClient () { | 37 @interface RemotingClient () { |
| 37 remoting::ChromotingClientRuntime* _runtime; | 38 remoting::ChromotingClientRuntime* _runtime; |
| 38 std::unique_ptr<remoting::ChromotingSession> _session; | 39 std::unique_ptr<remoting::ChromotingSession> _session; |
| 39 remoting::RemotingClientSessonDelegate* _sessonDelegate; | 40 remoting::RemotingClientSessonDelegate* _sessonDelegate; |
| 40 ClientSessionDetails* _sessionDetails; | 41 ClientSessionDetails* _sessionDetails; |
| 41 // Call _secretFetchedCallback on the network thread. | 42 // Call _secretFetchedCallback on the network thread. |
| 42 remoting::protocol::SecretFetchedCallback _secretFetchedCallback; | 43 remoting::protocol::SecretFetchedCallback _secretFetchedCallback; |
| 43 std::unique_ptr<remoting::RendererProxy> _renderer; | 44 std::unique_ptr<remoting::RendererProxy> _renderer; |
| 44 std::unique_ptr<remoting::GestureInterpreter> _gestureInterpreter; | 45 std::unique_ptr<remoting::GestureInterpreter> _gestureInterpreter; |
| 45 // std::unique_ptr<remoting::KeyboardInterpreter> _keyboardInterpreter; | 46 std::unique_ptr<remoting::KeyboardInterpreter> _keyboardInterpreter; |
| 46 } | 47 } |
| 47 @end | 48 @end |
| 48 | 49 |
| 49 @implementation RemotingClient | 50 @implementation RemotingClient |
| 50 | 51 |
| 51 @synthesize displayHandler = _displayHandler; | 52 @synthesize displayHandler = _displayHandler; |
| 52 | 53 |
| 53 - (instancetype)init { | 54 - (instancetype)init { |
| 54 self = [super init]; | 55 self = [super init]; |
| 55 if (self) { | 56 if (self) { |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 // TODO(nicholss): Add audio support to iOS. | 116 // TODO(nicholss): Add audio support to iOS. |
| 116 base::WeakPtr<remoting::protocol::AudioStub> audioPlayer = nullptr; | 117 base::WeakPtr<remoting::protocol::AudioStub> audioPlayer = nullptr; |
| 117 | 118 |
| 118 _displayHandler = [[GlDisplayHandler alloc] init]; | 119 _displayHandler = [[GlDisplayHandler alloc] init]; |
| 119 _displayHandler.delegate = self; | 120 _displayHandler.delegate = self; |
| 120 | 121 |
| 121 _session.reset(new remoting::ChromotingSession( | 122 _session.reset(new remoting::ChromotingSession( |
| 122 _sessonDelegate->GetWeakPtr(), [_displayHandler CreateCursorShapeStub], | 123 _sessonDelegate->GetWeakPtr(), [_displayHandler CreateCursorShapeStub], |
| 123 [_displayHandler CreateVideoRenderer], audioPlayer, info, | 124 [_displayHandler CreateVideoRenderer], audioPlayer, info, |
| 124 client_auth_config)); | 125 client_auth_config)); |
| 125 | |
| 126 _renderer = [_displayHandler CreateRendererProxy]; | 126 _renderer = [_displayHandler CreateRendererProxy]; |
| 127 | |
| 128 _gestureInterpreter.reset( | 127 _gestureInterpreter.reset( |
| 129 new remoting::GestureInterpreter(_renderer.get(), _session.get())); | 128 new remoting::GestureInterpreter(_renderer.get(), _session.get())); |
| 129 _keyboardInterpreter.reset(new remoting::KeyboardInterpreter(_session.get())); |
| 130 | 130 |
| 131 _session->Connect(); | 131 _session->Connect(); |
| 132 } | 132 } |
| 133 | 133 |
| 134 - (void)disconnectFromHost { | 134 - (void)disconnectFromHost { |
| 135 if (_session) { | 135 if (_session) { |
| 136 _session->Disconnect(); | 136 _session->Disconnect(); |
| 137 } | 137 } |
| 138 _displayHandler = nil; | 138 _displayHandler = nil; |
| 139 // TODO(nicholss): Do we need to cleanup more? | 139 // TODO(nicholss): Do we need to cleanup more? |
| (...skipping 14 matching lines...) Expand all Loading... |
| 154 #pragma mark - Properties | 154 #pragma mark - Properties |
| 155 | 155 |
| 156 - (HostInfo*)hostInfo { | 156 - (HostInfo*)hostInfo { |
| 157 return _sessionDetails.hostInfo; | 157 return _sessionDetails.hostInfo; |
| 158 } | 158 } |
| 159 | 159 |
| 160 - (remoting::GestureInterpreter*)gestureInterpreter { | 160 - (remoting::GestureInterpreter*)gestureInterpreter { |
| 161 return _gestureInterpreter.get(); | 161 return _gestureInterpreter.get(); |
| 162 } | 162 } |
| 163 | 163 |
| 164 - (remoting::KeyboardInterpreter*)keyboardInterpreter { |
| 165 return _keyboardInterpreter.get(); |
| 166 } |
| 167 |
| 164 #pragma mark - ChromotingSession::Delegate | 168 #pragma mark - ChromotingSession::Delegate |
| 165 | 169 |
| 166 - (void)onConnectionState:(remoting::protocol::ConnectionToHost::State)state | 170 - (void)onConnectionState:(remoting::protocol::ConnectionToHost::State)state |
| 167 error:(remoting::protocol::ErrorCode)error { | 171 error:(remoting::protocol::ErrorCode)error { |
| 168 switch (state) { | 172 switch (state) { |
| 169 case remoting::protocol::ConnectionToHost::INITIALIZING: | 173 case remoting::protocol::ConnectionToHost::INITIALIZING: |
| 170 NSLog(@"State --> INITIALIZING"); | 174 NSLog(@"State --> INITIALIZING"); |
| 171 _sessionDetails.state = SessionInitializing; | 175 _sessionDetails.state = SessionInitializing; |
| 172 break; | 176 break; |
| 173 case remoting::protocol::ConnectionToHost::CONNECTING: | 177 case remoting::protocol::ConnectionToHost::CONNECTING: |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 | 240 |
| 237 - (void)canvasSizeChanged:(CGSize)size { | 241 - (void)canvasSizeChanged:(CGSize)size { |
| 238 _gestureInterpreter->OnDesktopSizeChanged(size.width, size.height); | 242 _gestureInterpreter->OnDesktopSizeChanged(size.width, size.height); |
| 239 } | 243 } |
| 240 | 244 |
| 241 - (void)rendererTicked { | 245 - (void)rendererTicked { |
| 242 _gestureInterpreter->ProcessAnimations(); | 246 _gestureInterpreter->ProcessAnimations(); |
| 243 } | 247 } |
| 244 | 248 |
| 245 @end | 249 @end |
| OLD | NEW |