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) - 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 54 of file RDPSession.h.

Method Documentation

◆ connect

- (void) connect

Definition at line 73 of file RDPSession.m.

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

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

◆ getScreenshotWithSize:

- (UIImage *) getScreenshotWithSize: (CGSize)  size

Definition at line 73 of file RDPSession.m.

449 :(CGSize)size
450{
451 NSAssert([self mfi]->bitmap_context != nil,
452 @"Screenshot requested while having no valid RDP drawing context");
453 CGImageRef cgImage = CGBitmapContextCreateImage([self mfi]->bitmap_context);
454 UIGraphicsBeginImageContext(size);
455 CGContextTranslateCTM(UIGraphicsGetCurrentContext(), 0, size.height);
456 CGContextScaleCTM(UIGraphicsGetCurrentContext(), 1.0, -1.0);
457 CGContextDrawImage(UIGraphicsGetCurrentContext(), CGRectMake(0, 0, size.width, size.height),
458 cgImage);
459 UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
460 UIGraphicsEndImageContext();
461 CGImageRelease(cgImage);
462 return viewImage;
463}

◆ getSessionParams

- (rdpSettings *) getSessionParams

Definition at line 73 of file RDPSession.m.

466{
467 return _freerdp->context->settings;
468}

◆ hideRemoteCursor

- (void) hideRemoteCursor

Definition at line 73 of file RDPSession.m.

429{
430 if ([[self delegate] respondsToSelector:@selector(sessionDidHideRemoteCursor:)])
431 [[self delegate] sessionDidHideRemoteCursor:self];
432}

◆ initWithBookmark:

- (id) initWithBookmark: (ComputerBookmark *)  bookmark

Definition at line 73 of file RDPSession.m.

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

◆ isSuspended

- (BOOL) isSuspended

Definition at line 73 of file RDPSession.m.

384{
385 return _suspended;
386}

◆ resume

- (void) resume

Definition at line 73 of file RDPSession.m.

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

◆ sendClipboardHasText:

- (void) sendClipboardHasText: (BOOL)  hasText

Definition at line 73 of file RDPSession.m.

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

◆ sendInputEvent:

- (void) sendInputEvent: (NSDictionary *)  event

Definition at line 73 of file RDPSession.m.

391 :(NSDictionary *)eventDescriptor
392{
393 if ([self mfi]->connection_state == TSXConnectionConnected)
394 ios_events_send([self mfi], eventDescriptor);
395}

◆ sessionName

- (NSString *) sessionName

Definition at line 73 of file RDPSession.m.

471{
472 return _name;
473}

◆ setDefaultRemoteCursor

- (void) setDefaultRemoteCursor

Definition at line 73 of file RDPSession.m.

435{
436 if ([[self delegate] respondsToSelector:@selector(sessionDidSetDefaultRemoteCursor:)])
437 [[self delegate] sessionDidSetDefaultRemoteCursor:self];
438}

◆ setNeedsDisplayInRectAsValue:

- (void) setNeedsDisplayInRectAsValue: (NSValue *)  rect_value

Definition at line 73 of file RDPSession.m.

410 :(NSValue *)rect_value
411{
412 if ([[self delegate] respondsToSelector:@selector(session:needsRedrawInRect:)])
413 [[self delegate] session:self needsRedrawInRect:[rect_value CGRectValue]];
414}

◆ setRemoteClipboardText:

- (void) setRemoteClipboardText: (NSString *)  text

Definition at line 73 of file RDPSession.m.

440 :(NSString *)text
441{
442 if ([[self delegate] respondsToSelector:@selector(session:didChangeRemoteClipboardText:)])
443 [[self delegate] session:self didChangeRemoteClipboardText:text];
444}

◆ setRemoteCursor:

- (void) setRemoteCursor: (RDPCursor *)  cursor

Definition at line 73 of file RDPSession.m.

416 :(RDPCursor *)cursor
417{
418 if ([[self delegate] respondsToSelector:@selector(session:didSetRemoteCursor:)])
419 [[self delegate] session:self didSetRemoteCursor:cursor];
420}

◆ setRemoteCursorPositionValue:

- (void) setRemoteCursorPositionValue: (NSValue *)  positionValue

Definition at line 73 of file RDPSession.m.

422 :(NSValue *)positionValue
423{
424 if ([[self delegate] respondsToSelector:@selector(session:didMoveRemoteCursor:)])
425 [[self delegate] session:self didMoveRemoteCursor:[positionValue CGPointValue]];
426}

◆ suspend

- (void) suspend

Definition at line 73 of file RDPSession.m.

357{
358 if (!_suspended)
359 {
360 _suspended = YES;
361 // instance->update->SuppressOutput(instance->context, 0, nullptr);
362 }
363}

Property Documentation

◆ bitmapContext

- (CGContextRef) bitmapContext
readatomicassign

Definition at line 80 of file RDPSession.h.

◆ bookmark

- (ComputerBookmark*) bookmark
readatomicassign

Definition at line 77 of file RDPSession.h.

◆ delegate

- (id<RDPSessionDelegate>) delegate
readwriteatomicassign

Definition at line 78 of file RDPSession.h.

◆ params

- (ConnectionParams*) params
readatomicassign

Definition at line 76 of file RDPSession.h.

◆ toolbarVisible

- (BOOL) toolbarVisible
readwriteatomicassign

Definition at line 79 of file RDPSession.h.

◆ uiRequestCompleted

- (NSCondition*) uiRequestCompleted
readatomicassign

Definition at line 81 of file RDPSession.h.


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