FreeRDP
Loading...
Searching...
No Matches
RDPSession Class Reference
Inheritance diagram for RDPSession:
Collaboration diagram for RDPSession:

Instance Methods

(id) - initWithBookmark:
(void) - connect
(void) - disconnect
(void) - suspend
(void) - resume
(BOOL) - isSuspended
(void) - sendInputEvent:
(void) - sendClipboardHasText:
(void) - sendMonitorLayoutWithSize:
(void) - setNeedsDisplayInRectAsValue:
(void) - setRemoteCursor:
(void) - setRemoteCursorPositionValue:
(void) - hideRemoteCursor
(void) - setDefaultRemoteCursor
(void) - setRemoteClipboardText:
(UIImage *) - getScreenshotWithSize:
(rdpSettings *) - getSessionParams
(NSString *) - sessionName

Properties

ConnectionParams * params
ComputerBookmark * bookmark
id< RDPSessionDelegate > delegate
BOOL toolbarVisible
CGContextRef bitmapContext
NSCondition * uiRequestCompleted

Detailed Description

Definition at line 55 of file RDPSession.h.

Method Documentation

◆ connect

- (void) connect

Definition at line 304 of file RDPSession.m.

305{
306 // Set Screen Size to automatic if width or height are still 0
307 rdpSettings *settings = _freerdp->context->settings;
308
309 if (freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth) == 0 ||
310 freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight) == 0)
311 {
312 CGSize size = CGSizeZero;
313
314 if ([[self delegate] respondsToSelector:@selector(sizeForFitScreenForSession:)])
315 size = [[self delegate] sizeForFitScreenForSession:self];
316
317 if (!CGSizeEqualToSize(CGSizeZero, size))
318 {
319 [_params setInt:size.width forKey:@"width"];
320 [_params setInt:size.height forKey:@"height"];
321 (void)freerdp_settings_set_uint32(settings, FreeRDP_DesktopWidth, size.width);
322 (void)freerdp_settings_set_uint32(settings, FreeRDP_DesktopHeight, size.height);
323 }
324 }
325
326 // TODO: This is a hack to ensure connections to RDVH with 16bpp don't have an odd screen
327 // resolution width
328 // Otherwise this could result in screen corruption ..
329 if (freerdp_settings_get_uint32(settings, FreeRDP_ColorDepth) <= 16)
330 {
331 const UINT32 w = freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth) & (~1);
332 (void)freerdp_settings_set_uint32(settings, FreeRDP_DesktopWidth, w);
333 }
334
335 [self performSelectorInBackground:@selector(runSession) withObject:nil];
336}
WINPR_ATTR_NODISCARD FREERDP_API BOOL freerdp_settings_set_uint32(rdpSettings *settings, FreeRDP_Settings_Keys_UInt32 id, UINT32 val)
Sets a UINT32 settings value.
WINPR_ATTR_NODISCARD FREERDP_API UINT32 freerdp_settings_get_uint32(const rdpSettings *settings, FreeRDP_Settings_Keys_UInt32 id)
Returns a UINT32 settings value.

◆ disconnect

- (void) disconnect

Definition at line 338 of file RDPSession.m.

339{
340 mfInfo *mfi = [self mfi];
341 ios_events_send(mfi, [NSDictionary dictionaryWithObject:@"disconnect" forKey:@"type"]);
342
343 if (mfi->connection_state == TSXConnectionConnecting)
344 {
345 mfi->unwanted = YES;
346
347 // disconnect
348 freerdp_abort_connect_context(_freerdp->context);
349 [self sessionDidDisconnect];
350 return;
351 }
352}

◆ getScreenshotWithSize:

- (UIImage *) getScreenshotWithSize: (CGSize) size

Definition at line 462 of file RDPSession.m.

462 :(CGSize)size
463{
464 NSAssert([self mfi]->bitmap_context != nil,
465 @"Screenshot requested while having no valid RDP drawing context");
466 CGImageRef cgImage = CGBitmapContextCreateImage([self mfi]->bitmap_context);
467 UIGraphicsBeginImageContext(size);
468 CGContextTranslateCTM(UIGraphicsGetCurrentContext(), 0, size.height);
469 CGContextScaleCTM(UIGraphicsGetCurrentContext(), 1.0, -1.0);
470 CGContextDrawImage(UIGraphicsGetCurrentContext(), CGRectMake(0, 0, size.width, size.height),
471 cgImage);
472 UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
473 UIGraphicsEndImageContext();
474 CGImageRelease(cgImage);
475 return viewImage;
476}

◆ getSessionParams

- (rdpSettings *) getSessionParams

Definition at line 478 of file RDPSession.m.

479{
480 return _freerdp->context->settings;
481}

◆ hideRemoteCursor

- (void) hideRemoteCursor

Definition at line 441 of file RDPSession.m.

442{
443 if ([[self delegate] respondsToSelector:@selector(sessionDidHideRemoteCursor:)])
444 [[self delegate] sessionDidHideRemoteCursor:self];
445}

◆ initWithBookmark:

- (id) initWithBookmark: (ComputerBookmark *) bookmark

Definition at line 83 of file RDPSession.m.

83 :(ComputerBookmark *)bookmark
84{
85 int status;
86 char **argv = nullptr;
87 int argc = 0;
88
89 if (!(self = [super init]))
90 return nil;
91
92 if (!bookmark)
93 [NSException raise:NSInvalidArgumentException
94 format:@"%s: params may not be nil.", __func__];
95
96 _bookmark = [bookmark retain];
97 _params = [[bookmark params] copy];
98 _name = [[bookmark label] retain];
99 _delegate = nil;
100 _toolbar_visible = YES;
101 _freerdp = ios_freerdp_new();
102 _ui_request_completed = [[NSCondition alloc] init];
103 BOOL connected_via_3g = ![bookmark conntectedViaWLAN];
104
105 if (!addArgument(&argc, &argv, "iFreeRDP"))
106 goto out_free;
107
108 if (!addArgument(&argc, &argv, "/gdi:sw"))
109 goto out_free;
110
111 if (!addArgument(&argc, &argv, "/relax-order-checks"))
112 goto out_free;
113 // Screen Size is set on connect (we need a valid delegate in case the user choose an automatic
114 // screen size)
115
116 // Other simple numeric settings
117 if ([_params hasValueForKey:@"colors"])
118 if (!addArgument(&argc, &argv, "/bpp:%d",
119 [_params intForKey:@"colors" with3GEnabled:connected_via_3g]))
120 goto out_free;
121
122 if ([_params hasValueForKey:@"port"])
123 if (!addArgument(&argc, &argv, "/port:%d", [_params intForKey:@"port"]))
124 goto out_free;
125
126 if ([_params boolForKey:@"console"])
127 if (!addArgument(&argc, &argv, "/admin"))
128 goto out_free;
129
130 if (!addArgument(&argc, &argv, "/v:%s", [_params UTF8StringForKey:@"hostname"]))
131 goto out_free;
132
133 // String settings
134 if ([[_params StringForKey:@"username"] length])
135 {
136 if (!addArgument(&argc, &argv, "/u:%s", [_params UTF8StringForKey:@"username"]))
137 goto out_free;
138 }
139
140 if ([[_params StringForKey:@"password"] length])
141 {
142 if (!addArgument(&argc, &argv, "/p:%s", [_params UTF8StringForKey:@"password"]))
143 goto out_free;
144 }
145
146 if ([[_params StringForKey:@"domain"] length])
147 {
148 if (!addArgument(&argc, &argv, "/d:%s", [_params UTF8StringForKey:@"domain"]))
149 goto out_free;
150 }
151
152 if ([[_params StringForKey:@"working_directory"] length])
153 {
154 if (!addArgument(&argc, &argv, "/shell-dir:%s",
155 [_params UTF8StringForKey:@"working_directory"]))
156 goto out_free;
157 }
158
159 if ([[_params StringForKey:@"remote_program"] length])
160 {
161 if (!addArgument(&argc, &argv, "/shell:%s", [_params UTF8StringForKey:@"remote_program"]))
162 goto out_free;
163 }
164
165 // RemoteFX
166 if ([_params boolForKey:@"perf_remotefx" with3GEnabled:connected_via_3g])
167 if (!addArgument(&argc, &argv, "/rfx"))
168 goto out_free;
169
170 if ([_params boolForKey:@"perf_gfx" with3GEnabled:connected_via_3g])
171 if (!addArgument(&argc, &argv, "/gfx"))
172 goto out_free;
173
174 if ([_params boolForKey:@"perf_h264" with3GEnabled:connected_via_3g])
175 if (!addArgument(&argc, &argv, "/gfx:AVC444"))
176 goto out_free;
177
178 if (![_params boolForKey:@"perf_remotefx" with3GEnabled:connected_via_3g] &&
179 ![_params boolForKey:@"perf_gfx" with3GEnabled:connected_via_3g] &&
180 ![_params boolForKey:@"perf_h264" with3GEnabled:connected_via_3g])
181 if (!addArgument(&argc, &argv, "/nsc"))
182 goto out_free;
183
184 if (!addArgument(&argc, &argv, "/cache:bitmap:on,glyph:on"))
185 goto out_free;
186
187 if (!addFlag(&argc, &argv, "wallpaper",
188 [_params boolForKey:@"perf_show_desktop" with3GEnabled:connected_via_3g]))
189 goto out_free;
190
191 if (!addFlag(&argc, &argv, "window-drag",
192 [_params boolForKey:@"perf_window_dragging" with3GEnabled:connected_via_3g]))
193 goto out_free;
194
195 if (!addFlag(&argc, &argv, "menu-anims",
196 [_params boolForKey:@"perf_menu_animation" with3GEnabled:connected_via_3g]))
197 goto out_free;
198
199 if (!addFlag(&argc, &argv, "themes",
200 [_params boolForKey:@"perf_windows_themes" with3GEnabled:connected_via_3g]))
201 goto out_free;
202
203 if (!addFlag(&argc, &argv, "fonts",
204 [_params boolForKey:@"perf_font_smoothing" with3GEnabled:connected_via_3g]))
205 goto out_free;
206
207 if (!addFlag(&argc, &argv, "aero",
208 [_params boolForKey:@"perf_desktop_composition" with3GEnabled:connected_via_3g]))
209 goto out_free;
210
211 if ([_params hasValueForKey:@"width"])
212 if (!addArgument(&argc, &argv, "/w:%d", [_params intForKey:@"width"]))
213 goto out_free;
214
215 if ([_params hasValueForKey:@"height"])
216 if (!addArgument(&argc, &argv, "/h:%d", [_params intForKey:@"height"]))
217 goto out_free;
218
219 if (!addArgument(&argc, &argv, "/disp"))
220 goto out_free;
221
222 // security
223 switch ([_params intForKey:@"security"])
224 {
225 case TSXProtocolSecurityNLA:
226 if (!addArgument(&argc, &argv, "/sec:NLA"))
227 goto out_free;
228
229 break;
230
231 case TSXProtocolSecurityTLS:
232 if (!addArgument(&argc, &argv, "/sec:TLS"))
233 goto out_free;
234
235 break;
236
237 case TSXProtocolSecurityRDP:
238 if (!addArgument(&argc, &argv, "/sec:RDP"))
239 goto out_free;
240
241 break;
242
243 default:
244 break;
245 }
246
247 // ts gateway settings
248 if ([_params boolForKey:@"enable_tsg_settings"])
249 {
250 if (!addArgument(&argc, &argv, "/gateway:g:%s:%d,u:%s,d:%s,p:%s",
251 [_params UTF8StringForKey:@"tsg_hostname"],
252 [_params intForKey:@"tsg_port"],
253 [_params UTF8StringForKey:@"tsg_username"],
254 [_params UTF8StringForKey:@"tsg_domain"],
255 [_params UTF8StringForKey:@"tsg_password"]))
256 goto out_free;
257 }
258
259 // Remote keyboard layout
260 if (!addArgument(&argc, &argv, "/kbd:layout:%d", 0x409))
261 goto out_free;
262
263 // send characters without a US scancode (e.g. Korean) as unicode input
264 if (!addArgument(&argc, &argv, "/kbd:unicode:on"))
265 goto out_free;
266
267 if (!addArgument(&argc, &argv, "/auto-reconnect"))
268 goto out_free;
269
270 status =
271 freerdp_client_settings_parse_command_line(_freerdp->context->settings, argc, argv, FALSE);
272
273 if (0 != status)
274 goto out_free;
275
276 freeArguments(argc, argv);
277 [self mfi]->session = self;
278 return self;
279out_free:
280 freeArguments(argc, argv);
281 [self release];
282 return nil;
283}

◆ isSuspended

- (BOOL) isSuspended

Definition at line 387 of file RDPSession.m.

388{
389 return _suspended;
390}

◆ resume

- (void) resume

Definition at line 370 of file RDPSession.m.

371{
372 if (_suspended)
373 {
374 /* RECTANGLE_16 rec;
375 rec.left = 0;
376 rec.top = 0;
377 rec.right = freerdp_settings_get_uint32(instance->settings, FreeRDP_DesktopWidth);
378 rec.bottom = freerdp_settings_get_uint32(instance->settings, FreeRDP_DesktopHeight);
379 */
380 _suspended = NO;
381 // instance->update->SuppressOutput(instance->context, 1, &rec);
382 // [delegate sessionScreenSettingsChanged:self];
383 }
384}

◆ sendClipboardHasText:

- (void) sendClipboardHasText: (BOOL) hasText

Definition at line 401 of file RDPSession.m.

401 :(BOOL)hasText
402{
403 // not sendInputEvent: the first check runs in sessionDidConnect, before the state is
404 // connected; the event waits in the pipe until the run loop starts
405 ios_events_send([self mfi],
406 [NSDictionary dictionaryWithObjectsAndKeys:@"clipboard", @"type",
407 [NSNumber numberWithBool:hasText],
408 @"has_text", nil]);
409}

◆ sendInputEvent:

- (void) sendInputEvent: (NSDictionary *) event

Definition at line 395 of file RDPSession.m.

395 :(NSDictionary *)eventDescriptor
396{
397 if ([self mfi]->connection_state == TSXConnectionConnected)
398 ios_events_send([self mfi], eventDescriptor);
399}

◆ sendMonitorLayoutWithSize:

- (void) sendMonitorLayoutWithSize: (CGSize) size

Definition at line 411 of file RDPSession.m.

411 :(CGSize)size
412{
413 NSNumber *width = [NSNumber numberWithUnsignedInt:(UINT32)size.width];
414 NSNumber *height = [NSNumber numberWithUnsignedInt:(UINT32)size.height];
415 [self sendInputEvent:[NSDictionary dictionaryWithObjectsAndKeys:@"resize", @"type", width,
416 @"width", height, @"height",
417 nil]];
418}

◆ sessionName

- (NSString *) sessionName

Definition at line 483 of file RDPSession.m.

484{
485 return _name;
486}

◆ setDefaultRemoteCursor

- (void) setDefaultRemoteCursor

Definition at line 447 of file RDPSession.m.

448{
449 if ([[self delegate] respondsToSelector:@selector(sessionDidSetDefaultRemoteCursor:)])
450 [[self delegate] sessionDidSetDefaultRemoteCursor:self];
451}

◆ setNeedsDisplayInRectAsValue:

- (void) setNeedsDisplayInRectAsValue: (NSValue *) rect_value

Definition at line 423 of file RDPSession.m.

423 :(NSValue *)rect_value
424{
425 if ([[self delegate] respondsToSelector:@selector(session:needsRedrawInRect:)])
426 [[self delegate] session:self needsRedrawInRect:[rect_value CGRectValue]];
427}

◆ setRemoteClipboardText:

- (void) setRemoteClipboardText: (NSString *) text

Definition at line 453 of file RDPSession.m.

453 :(NSString *)text
454{
455 if ([[self delegate] respondsToSelector:@selector(session:didChangeRemoteClipboardText:)])
456 [[self delegate] session:self didChangeRemoteClipboardText:text];
457}

◆ setRemoteCursor:

- (void) setRemoteCursor: (RDPCursor *) cursor

Definition at line 429 of file RDPSession.m.

429 :(RDPCursor *)cursor
430{
431 if ([[self delegate] respondsToSelector:@selector(session:didSetRemoteCursor:)])
432 [[self delegate] session:self didSetRemoteCursor:cursor];
433}

◆ setRemoteCursorPositionValue:

- (void) setRemoteCursorPositionValue: (NSValue *) positionValue

Definition at line 435 of file RDPSession.m.

435 :(NSValue *)positionValue
436{
437 if ([[self delegate] respondsToSelector:@selector(session:didMoveRemoteCursor:)])
438 [[self delegate] session:self didMoveRemoteCursor:[positionValue CGPointValue]];
439}

◆ suspend

- (void) suspend

Definition at line 360 of file RDPSession.m.

361{
362 if (!_suspended)
363 {
364 _suspended = YES;
365 // instance->update->SuppressOutput(instance->context, 0, nullptr);
366 }
367}

Property Documentation

◆ bitmapContext

- (CGContextRef) bitmapContext
readatomicassign

Definition at line 296 of file RDPSession.m.

297{
298 return [self mfi]->bitmap_context;
299}

◆ bookmark

- (ComputerBookmark*) bookmark
readatomicassign

Definition at line 78 of file RDPSession.h.

◆ delegate

- (id<RDPSessionDelegate>) delegate
readwriteatomicassign

Definition at line 79 of file RDPSession.h.

◆ params

- (ConnectionParams*) params
readatomicassign

Definition at line 77 of file RDPSession.h.

◆ toolbarVisible

- (BOOL) toolbarVisible
readwriteatomicassign

Definition at line 80 of file RDPSession.h.

◆ uiRequestCompleted

- (NSCondition*) uiRequestCompleted
readatomicassign

Definition at line 82 of file RDPSession.h.


The documentation for this class was generated from the following files: