FreeRDP
Loading...
Searching...
No Matches
BookmarkBase.java
1/*
2 Defines base attributes of a bookmark object
3
4 Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
5
6 This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
7 If a copy of the MPL was not distributed with this file, You can obtain one at
8 http://mozilla.org/MPL/2.0/.
9*/
10
11package com.freerdp.freerdpcore.domain;
12
13import android.content.SharedPreferences;
14import android.os.Parcel;
15import android.os.Parcelable;
16
17import androidx.annotation.NonNull;
18
19import java.util.Locale;
20import java.util.Objects;
21
22public class BookmarkBase implements Parcelable, Cloneable
23{
24 private static final String keyLabel = "bookmark.label";
25 private static final String keyUsername = "bookmark.username";
26 private static final String keyPassword = "bookmark.password";
27 private static final String keyDomain = "bookmark.domain";
28
29 private static final String keyColors = "bookmark.colors";
30 private static final String keyResolution = "bookmark.resolution";
31 private static final String keyWidth = "bookmark.width";
32 private static final String keyScaleMode = "bookmark.scale_mode";
33 private static final String keyScaleDesktop = "bookmark.scale_desktop";
34 private static final String keyScaleDevice = "bookmark.scale_device";
35 private static final String keyHeight = "bookmark.height";
36
37 private static final String keyRFX = "bookmark.perf_remotefx";
38 private static final String keyGFX = "bookmark.perf_gfx";
39 private static final String keyH264 = "bookmark.perf_gfx_h264";
40 private static final String keyFlagWallpaper = "bookmark.perf_wallpaper";
41 private static final String keyFlagFonts = "bookmark.perf_font_smoothing";
42 private static final String keyFlagComposition = "bookmark.perf_desktop_composition";
43 private static final String keyFlagWindowDrag = "bookmark.perf_window_dragging";
44 private static final String keyFlagMenuAnim = "bookmark.perf_menu_animation";
45 private static final String keyFlagTheming = "bookmark.perf_themes";
46
47 private static final String keyTlsSecLevel = "bookmark.tlsSecLevel";
48 private static final String keyTlsMinLevel = "bookmark.tlsMinLevel";
49 private static final String keyLoadBalanceInfo = "bookmark.loadBalanceInfo";
50 private static final String keyRedirectSDCard = "bookmark.redirect_sdcard";
51 private static final String keySound = "bookmark.redirect_sound";
52 private static final String keyMicrophone = "bookmark.redirect_microphone";
53 private static final String keyCamera = "bookmark.redirect_camera";
54 private static final String keyPrinter = "bookmark.redirect_printer";
55 private static final String keySecurity = "bookmark.security";
56 private static final String keyRemoteApp = "bookmark.remote_program";
57 private static final String keyAlternateShell = "bookmark.alternate_shell";
58 private static final String keyWorkDir = "bookmark.work_dir";
59 private static final String keyConsoleMode = "bookmark.console_mode";
60 private static final String keyVmConnectMode = "bookmark.vmconnect_mode";
61 private static final String keyVmConnectGuid = "bookmark.vmconnect_guid";
62
63 private static final String keyAsyncChannel = "bookmark.async_channel";
64 private static final String keyAsyncUpdate = "bookmark.async_update";
65 private static final String keyDebugLevel = "bookmark.debug_level";
66
67 private static final String keyHostname = "bookmark.hostname";
68 private static final String keyPort = "bookmark.port";
69 private static final String keyGatewayEnabled = "bookmark.enable_gateway_settings";
70 private static final String keyGatewayHostname = "bookmark.gateway_hostname";
71 private static final String keyGatewayPort = "bookmark.gateway_port";
72 private static final String keyGatewyUser = "bookmark.gateway_username";
73 private static final String keyGatewayPassword = "bookmark.gateway_password";
74 private static final String keyGatewayDomain = "bookmark.gateway_domain";
75
76 public static final int TYPE_INVALID = -1;
77 public static final int TYPE_MANUAL = 1;
78 public static final int TYPE_QUICKCONNECT = 2;
79 public static final int TYPE_CUSTOM_BASE = 1000;
80 public static final Parcelable.Creator<BookmarkBase> CREATOR =
81 new Parcelable.Creator<BookmarkBase>() {
82 public BookmarkBase createFromParcel(Parcel in)
83 {
84 return new BookmarkBase(in);
85 }
86
87 @Override public BookmarkBase[] newArray(int size)
88 {
89 return new BookmarkBase[size];
90 }
91 };
92 protected int type = TYPE_MANUAL;
93 private long id = -1;
94
95 @NonNull private String label = "";
96
97 @NonNull private String username = "";
98
99 @NonNull private String password = "";
100
101 @NonNull private String domain = "";
102
103 @NonNull private ScreenSettings screenSettings = new ScreenSettings();
104
105 @NonNull private PerformanceFlags performanceFlags = new PerformanceFlags();
106
107 @NonNull private AdvancedSettings advancedSettings = new AdvancedSettings();
108
109 @NonNull private DebugSettings debugSettings = new DebugSettings();
110
111 @NonNull private String hostname = "";
112 private int port = 3389;
113 private boolean enableGatewaySettings = false;
114
115 @NonNull private GatewaySettings gatewaySettings = new GatewaySettings();
116 private boolean directConnect = false;
117
118 public BookmarkBase(Parcel parcel)
119 {
120 type = parcel.readInt();
121 id = parcel.readLong();
122 label = Objects.requireNonNull(parcel.readString());
123 username = Objects.requireNonNull(parcel.readString());
124 password = Objects.requireNonNull(parcel.readString());
125 domain = Objects.requireNonNull(parcel.readString());
126
127 screenSettings =
128 Objects.requireNonNull(parcel.readParcelable(ScreenSettings.class.getClassLoader()));
129 performanceFlags =
130 Objects.requireNonNull(parcel.readParcelable(PerformanceFlags.class.getClassLoader()));
131 advancedSettings =
132 Objects.requireNonNull(parcel.readParcelable(AdvancedSettings.class.getClassLoader()));
133 debugSettings =
134 Objects.requireNonNull(parcel.readParcelable(DebugSettings.class.getClassLoader()));
135 hostname = Objects.requireNonNull(parcel.readString());
136 port = parcel.readInt();
137 enableGatewaySettings = (parcel.readInt() == 1);
138 gatewaySettings =
139 Objects.requireNonNull(parcel.readParcelable(GatewaySettings.class.getClassLoader()));
140 directConnect = (parcel.readInt() == 1);
141 }
142
143 public BookmarkBase()
144 {
145 }
146
147 public int getType()
148 {
149 return type;
150 }
151
152 public void setType(int type)
153 {
154 this.type = type;
155 }
156
157 public long getId()
158 {
159 return id;
160 }
161
162 public void setId(long id)
163 {
164 this.id = id;
165 }
166
167 @NonNull public String getLabel()
168 {
169 return label;
170 }
171
172 public void setLabel(@NonNull String label)
173 {
174 this.label = label;
175 }
176
177 @NonNull public String getUsername()
178 {
179 return username;
180 }
181
182 public void setUsername(@NonNull String username)
183 {
184 this.username = username;
185 }
186
187 @NonNull public String getPassword()
188 {
189 return password;
190 }
191
192 public void setPassword(@NonNull String password)
193 {
194 this.password = password;
195 }
196
197 @NonNull public String getDomain()
198 {
199 return domain;
200 }
201
202 public void setDomain(@NonNull String domain)
203 {
204 this.domain = domain;
205 }
206
207 @NonNull public ScreenSettings getScreenSettings()
208 {
209 return screenSettings;
210 }
211
212 @NonNull public PerformanceFlags getPerformanceFlags()
213 {
214 return performanceFlags;
215 }
216
217 @NonNull public AdvancedSettings getAdvancedSettings()
218 {
219 return advancedSettings;
220 }
221
222 @NonNull public DebugSettings getDebugSettings()
223 {
224 return debugSettings;
225 }
226
227 @NonNull public String getHostname()
228 {
229 return hostname;
230 }
231
232 public void setHostname(@NonNull String hostname)
233 {
234 this.hostname = hostname;
235 }
236
237 public int getPort()
238 {
239 return port;
240 }
241
242 public void setPort(int port)
243 {
244 this.port = port;
245 }
246
247 public boolean getEnableGatewaySettings()
248 {
249 return enableGatewaySettings;
250 }
251
252 public void setEnableGatewaySettings(boolean enableGatewaySettings)
253 {
254 this.enableGatewaySettings = enableGatewaySettings;
255 }
256
257 @NonNull public GatewaySettings getGatewaySettings()
258 {
259 return gatewaySettings;
260 }
261
262 public boolean isDirectConnect()
263 {
264 return directConnect;
265 }
266
267 public void setDirectConnect(boolean directConnect)
268 {
269 this.directConnect = directConnect;
270 }
271
272 @NonNull public ScreenSettings getActiveScreenSettings()
273 {
274 return screenSettings;
275 }
276
277 @NonNull public PerformanceFlags getActivePerformanceFlags()
278 {
279 return performanceFlags;
280 }
281
282 @Override public int describeContents()
283 {
284 return 0;
285 }
286
287 @Override public void writeToParcel(Parcel out, int flags)
288 {
289 out.writeInt(type);
290 out.writeLong(id);
291 out.writeString(label);
292 out.writeString(username);
293 out.writeString(password);
294 out.writeString(domain);
295
296 out.writeParcelable(screenSettings, flags);
297 out.writeParcelable(performanceFlags, flags);
298 out.writeParcelable(advancedSettings, flags);
299 out.writeParcelable(debugSettings, flags);
300 out.writeString(hostname);
301 out.writeInt(port);
302 out.writeBoolean(enableGatewaySettings);
303 out.writeParcelable(gatewaySettings, flags);
304 out.writeBoolean(directConnect);
305 }
306
307 // write to shared preferences
308 public void writeToSharedPreferences(@NonNull SharedPreferences sharedPrefs)
309 {
310 Locale locale = Locale.ENGLISH;
311
312 SharedPreferences.Editor editor = sharedPrefs.edit();
313 editor.clear();
314 editor.putString(keyLabel, label);
315 editor.putString(keyUsername, username);
316 editor.putString(keyPassword, password);
317 editor.putString(keyDomain, domain);
318
319 editor.putInt(keyColors, screenSettings.getColors());
320 editor.putString(keyResolution, screenSettings.getResolutionString().toLowerCase(locale));
321 editor.putInt(keyWidth, screenSettings.getWidth());
322 editor.putInt(keyHeight, screenSettings.getHeight());
323 editor.putString(keyScaleMode, screenSettings.getScaleMode());
324 editor.putInt(keyScaleDesktop, screenSettings.getScaleDesktop());
325 editor.putInt(keyScaleDevice, screenSettings.getScaleDevice());
326
327 editor.putBoolean(keyRFX, performanceFlags.getRemoteFX());
328 editor.putBoolean(keyGFX, performanceFlags.getGfx());
329 editor.putBoolean(keyH264, performanceFlags.getH264());
330 editor.putBoolean(keyFlagWallpaper, performanceFlags.getWallpaper());
331 editor.putBoolean(keyFlagFonts, performanceFlags.getFontSmoothing());
332 editor.putBoolean(keyFlagComposition, performanceFlags.getDesktopComposition());
333 editor.putBoolean(keyFlagWindowDrag, performanceFlags.getFullWindowDrag());
334 editor.putBoolean(keyFlagMenuAnim, performanceFlags.getMenuAnimations());
335 editor.putBoolean(keyFlagTheming, performanceFlags.getTheming());
336
337 editor.putInt(keyTlsSecLevel, advancedSettings.tlsSecLevel);
338 editor.putInt(keyTlsMinLevel, advancedSettings.tlsMinLevel);
339
340 editor.putString(keyLoadBalanceInfo, advancedSettings.getLoadBalanceInfo());
341 editor.putBoolean(keyRedirectSDCard, advancedSettings.getRedirectSDCard());
342 editor.putInt(keySound, advancedSettings.getRedirectSound());
343 editor.putBoolean(keyMicrophone, advancedSettings.getRedirectMicrophone());
344 editor.putBoolean(keyCamera, advancedSettings.getRedirectCamera());
345 editor.putBoolean(keyPrinter, advancedSettings.getRedirectPrinter());
346 editor.putInt(keySecurity, advancedSettings.getSecurity());
347 editor.putString(keyRemoteApp, advancedSettings.getRemoteProgram());
348 editor.putString(keyAlternateShell, advancedSettings.getAlternateShell());
349 editor.putString(keyWorkDir, advancedSettings.getWorkDir());
350 editor.putBoolean(keyConsoleMode, advancedSettings.getConsoleMode());
351 editor.putBoolean(keyVmConnectMode, advancedSettings.getVmConnectMode());
352 editor.putString(keyVmConnectGuid, advancedSettings.getVmConnectGuid());
353
354 editor.putBoolean(keyAsyncChannel, debugSettings.getAsyncChannel());
355 editor.putBoolean(keyAsyncUpdate, debugSettings.getAsyncUpdate());
356 editor.putString(keyDebugLevel, debugSettings.getDebugLevel());
357
358 editor.putString(keyHostname, hostname);
359 editor.putInt(keyPort, port);
360 editor.putBoolean(keyGatewayEnabled, enableGatewaySettings);
361 editor.putString(keyGatewayHostname, gatewaySettings.getHostname());
362 editor.putInt(keyGatewayPort, gatewaySettings.getPort());
363 editor.putString(keyGatewyUser, gatewaySettings.getUsername());
364 editor.putString(keyGatewayPassword, gatewaySettings.getPassword());
365 editor.putString(keyGatewayDomain, gatewaySettings.getDomain());
366
367 editor.apply();
368 }
369
370 // read from shared preferences
371 public void readFromSharedPreferences(@NonNull SharedPreferences sharedPrefs)
372 {
373 label = sharedPrefs.getString(keyLabel, "");
374 username = sharedPrefs.getString(keyUsername, "");
375 password = sharedPrefs.getString(keyPassword, "");
376 domain = sharedPrefs.getString(keyDomain, "");
377
378 screenSettings.setColors(sharedPrefs.getInt(keyColors, 32));
379 screenSettings.setResolution(sharedPrefs.getString(keyResolution, "automatic"),
380 sharedPrefs.getInt(keyWidth, 800),
381 sharedPrefs.getInt(keyHeight, 600));
382 screenSettings.setScale(sharedPrefs.getString(keyScaleMode, "100"),
383 sharedPrefs.getInt(keyScaleDesktop, 100),
384 sharedPrefs.getInt(keyScaleDevice, 100));
385
386 performanceFlags.setRemoteFX(sharedPrefs.getBoolean(keyRFX, false));
387 performanceFlags.setGfx(sharedPrefs.getBoolean(keyGFX, true));
388 performanceFlags.setH264(sharedPrefs.getBoolean(keyH264, true));
389 performanceFlags.setWallpaper(sharedPrefs.getBoolean(keyFlagWallpaper, false));
390 performanceFlags.setFontSmoothing(sharedPrefs.getBoolean(keyFlagFonts, false));
391 performanceFlags.setDesktopComposition(sharedPrefs.getBoolean(keyFlagComposition, false));
392 performanceFlags.setFullWindowDrag(sharedPrefs.getBoolean(keyFlagWindowDrag, false));
393 performanceFlags.setMenuAnimations(sharedPrefs.getBoolean(keyFlagMenuAnim, false));
394 performanceFlags.setTheming(sharedPrefs.getBoolean(keyFlagTheming, false));
395
396 advancedSettings.setTlsSecLevel(sharedPrefs.getInt(keyTlsSecLevel, -1));
397 advancedSettings.setTlsMinLevel(sharedPrefs.getInt(keyTlsMinLevel, -1));
398
399 advancedSettings.setLoadBalanceInfo(sharedPrefs.getString(keyLoadBalanceInfo, ""));
400 advancedSettings.setRedirectSDCard(sharedPrefs.getBoolean(keyRedirectSDCard, false));
401 advancedSettings.setRedirectSound(sharedPrefs.getInt(keySound, 0));
402 advancedSettings.setRedirectMicrophone(sharedPrefs.getBoolean(keyMicrophone, false));
403 advancedSettings.setRedirectCamera(sharedPrefs.getBoolean(keyCamera, false));
404 advancedSettings.setRedirectPrinter(sharedPrefs.getBoolean(keyPrinter, false));
405 advancedSettings.setSecurity(sharedPrefs.getInt(keySecurity, 0));
406 advancedSettings.setRemoteProgram(sharedPrefs.getString(keyRemoteApp, ""));
407 advancedSettings.setAlternateShell(sharedPrefs.getString(keyAlternateShell, ""));
408 advancedSettings.setWorkDir(sharedPrefs.getString(keyWorkDir, ""));
409 advancedSettings.setConsoleMode(sharedPrefs.getBoolean(keyConsoleMode, false));
410 advancedSettings.setVmConnectMode(sharedPrefs.getBoolean(keyVmConnectMode, false));
411 advancedSettings.setVmConnectGuid(sharedPrefs.getString(keyVmConnectGuid, ""));
412
413 debugSettings.setAsyncChannel(sharedPrefs.getBoolean(keyAsyncChannel, true));
414 debugSettings.setAsyncUpdate(sharedPrefs.getBoolean(keyAsyncUpdate, true));
415 debugSettings.setDebugLevel(sharedPrefs.getString(keyDebugLevel, "INFO"));
416
417 hostname = sharedPrefs.getString(keyHostname, "");
418 port = sharedPrefs.getInt(keyPort, 3389);
419 enableGatewaySettings = sharedPrefs.getBoolean(keyGatewayEnabled, false);
420 gatewaySettings.setHostname(sharedPrefs.getString(keyGatewayHostname, ""));
421 gatewaySettings.setPort(sharedPrefs.getInt(keyGatewayPort, 443));
422 gatewaySettings.setUsername(sharedPrefs.getString(keyGatewyUser, ""));
423 gatewaySettings.setPassword(sharedPrefs.getString(keyGatewayPassword, ""));
424 gatewaySettings.setDomain(sharedPrefs.getString(keyGatewayDomain, ""));
425 }
426
427 @Override public Object clone() throws CloneNotSupportedException
428 {
429 return super.clone();
430 }
431
432 // performance flags
433 public static class PerformanceFlags implements Parcelable
434 {
435 public static final Parcelable.Creator<PerformanceFlags> CREATOR =
436 new Parcelable.Creator<PerformanceFlags>() {
437 @NonNull public PerformanceFlags createFromParcel(Parcel in)
438 {
439 return new PerformanceFlags(in);
440 }
441
442 @NonNull @Override public PerformanceFlags[] newArray(int size)
443 {
444 return new PerformanceFlags[size];
445 }
446 };
447 private boolean remotefx = true;
448 private boolean gfx = true;
449 private boolean h264 = true;
450 private boolean wallpaper = true;
451 private boolean theming = true;
452 private boolean fullWindowDrag = true;
453 private boolean menuAnimations = true;
454 private boolean fontSmoothing = true;
455 private boolean desktopComposition = true;
456
457 public PerformanceFlags()
458 {
459 }
460
461 public PerformanceFlags(Parcel parcel)
462 {
463 remotefx = parcel.readBoolean();
464 gfx = parcel.readBoolean();
465 h264 = parcel.readBoolean();
466 wallpaper = parcel.readBoolean();
467 theming = parcel.readBoolean();
468 fullWindowDrag = parcel.readBoolean();
469 menuAnimations = parcel.readBoolean();
470 fontSmoothing = parcel.readBoolean();
471 desktopComposition = parcel.readBoolean();
472 }
473
474 public boolean getRemoteFX()
475 {
476 return remotefx;
477 }
478
479 public void setRemoteFX(boolean remotefx)
480 {
481 this.remotefx = remotefx;
482 }
483
484 public boolean getGfx()
485 {
486 return gfx;
487 }
488
489 public void setGfx(boolean gfx)
490 {
491 this.gfx = gfx;
492 }
493
494 public boolean getH264()
495 {
496 return h264;
497 }
498
499 public void setH264(boolean h264)
500 {
501 this.h264 = h264;
502 }
503
504 public boolean getWallpaper()
505 {
506 return wallpaper;
507 }
508
509 public void setWallpaper(boolean wallpaper)
510 {
511 this.wallpaper = wallpaper;
512 }
513
514 public boolean getTheming()
515 {
516 return theming;
517 }
518
519 public void setTheming(boolean theming)
520 {
521 this.theming = theming;
522 }
523
524 public boolean getFullWindowDrag()
525 {
526 return fullWindowDrag;
527 }
528
529 public void setFullWindowDrag(boolean fullWindowDrag)
530 {
531 this.fullWindowDrag = fullWindowDrag;
532 }
533
534 public boolean getMenuAnimations()
535 {
536 return menuAnimations;
537 }
538
539 public void setMenuAnimations(boolean menuAnimations)
540 {
541 this.menuAnimations = menuAnimations;
542 }
543
544 public boolean getFontSmoothing()
545 {
546 return fontSmoothing;
547 }
548
549 public void setFontSmoothing(boolean fontSmoothing)
550 {
551 this.fontSmoothing = fontSmoothing;
552 }
553
554 public boolean getDesktopComposition()
555 {
556 return desktopComposition;
557 }
558
559 public void setDesktopComposition(boolean desktopComposition)
560 {
561 this.desktopComposition = desktopComposition;
562 }
563
564 @Override public int describeContents()
565 {
566 return 0;
567 }
568
569 @Override public void writeToParcel(@NonNull Parcel out, int flags)
570 {
571 out.writeBoolean(remotefx);
572 out.writeBoolean(gfx);
573 out.writeBoolean(h264);
574 out.writeBoolean(wallpaper);
575 out.writeBoolean(theming);
576 out.writeBoolean(fullWindowDrag);
577 out.writeBoolean(menuAnimations);
578 out.writeBoolean(fontSmoothing);
579 out.writeBoolean(desktopComposition);
580 }
581 }
582
583 // Screen Settings class
584 public static class ScreenSettings implements Parcelable
585 {
586 public static final int FITSCREEN = -2;
587 public static final int AUTOMATIC = -1;
588 public static final int CUSTOM = 0;
589 public static final int PREDEFINED = 1;
590 public static final Parcelable.Creator<ScreenSettings> CREATOR =
591 new Parcelable.Creator<ScreenSettings>() {
592 @NonNull public ScreenSettings createFromParcel(Parcel in)
593 {
594 return new ScreenSettings(in);
595 }
596
597 @NonNull @Override public ScreenSettings[] newArray(int size)
598 {
599 return new ScreenSettings[size];
600 }
601 };
602 private int resolution = AUTOMATIC;
603 private int colors = 32;
604 private int width = 0;
605 private int height = 0;
606 private String scaleMode = "100";
607 private int scaleDesktop = 100;
608 private int scaleDevice = 100;
609
610 public ScreenSettings()
611 {
612 }
613
614 public ScreenSettings(Parcel parcel)
615 {
616 resolution = parcel.readInt();
617 colors = parcel.readInt();
618 width = parcel.readInt();
619 height = parcel.readInt();
620 scaleMode = parcel.readString();
621 scaleDesktop = parcel.readInt();
622 scaleDevice = parcel.readInt();
623 }
624
625 private void validate()
626 {
627 switch (colors)
628 {
629 case 32:
630 case 24:
631 case 16:
632 case 15:
633 case 8:
634 break;
635 default:
636 colors = 32;
637 break;
638 }
639
640 if ((width <= 0) || (width > 65536))
641 {
642 width = 1024;
643 }
644
645 if ((height <= 0) || (height > 65536))
646 {
647 height = 768;
648 }
649
650 switch (resolution)
651 {
652 case FITSCREEN:
653 case AUTOMATIC:
654 case CUSTOM:
655 case PREDEFINED:
656 break;
657 default:
658 resolution = AUTOMATIC;
659 break;
660 }
661 }
662
663 public void setResolution(@NonNull String resolution, int width, int height)
664 {
665 if (resolution.contains("x"))
666 {
667 String[] dimensions = resolution.split("x");
668 this.width = Integer.parseInt(dimensions[0]);
669 this.height = Integer.parseInt(dimensions[1]);
670 this.resolution = PREDEFINED;
671 }
672 else if (resolution.equalsIgnoreCase("custom"))
673 {
674 this.width = width;
675 this.height = height;
676 this.resolution = CUSTOM;
677 }
678 else if (resolution.equalsIgnoreCase("fitscreen"))
679 {
680 this.width = this.height = 0;
681 this.resolution = FITSCREEN;
682 }
683 else
684 {
685 this.width = this.height = 0;
686 this.resolution = AUTOMATIC;
687 }
688 }
689
690 public int getResolution()
691 {
692 return resolution;
693 }
694
695 public void setResolution(int resolution)
696 {
697 this.resolution = resolution;
698
699 if (resolution == AUTOMATIC || resolution == FITSCREEN)
700 {
701 width = 0;
702 height = 0;
703 }
704 }
705
706 @NonNull public String getResolutionString()
707 {
708 if (isPredefined())
709 return (width + "x" + height);
710
711 return (isFitScreen() ? "fitscreen" : isAutomatic() ? "automatic" : "custom");
712 }
713
714 public boolean isPredefined()
715 {
716 validate();
717 return (resolution == PREDEFINED);
718 }
719
720 public boolean isAutomatic()
721 {
722 validate();
723 return (resolution == AUTOMATIC);
724 }
725
726 public boolean isFitScreen()
727 {
728 validate();
729 return (resolution == FITSCREEN);
730 }
731
732 public boolean isCustom()
733 {
734 validate();
735 return (resolution == CUSTOM);
736 }
737
738 public int getWidth()
739 {
740 validate();
741 return width;
742 }
743
744 public void setWidth(int width)
745 {
746 this.width = width;
747 }
748
749 public int getHeight()
750 {
751 validate();
752 return height;
753 }
754
755 public void setHeight(int height)
756 {
757 this.height = height;
758 }
759
760 public int getColors()
761 {
762 validate();
763 return colors;
764 }
765
766 public void setColors(int colors)
767 {
768 this.colors = colors;
769 }
770
771 public void setScale(@NonNull String mode, int desktop, int device)
772 {
773 scaleMode = "custom".equalsIgnoreCase(mode) ? "custom" : mode;
774 scaleDesktop = desktop;
775 scaleDevice = device;
776 }
777
778 public boolean isCustomScale()
779 {
780 return "custom".equalsIgnoreCase(scaleMode);
781 }
782
783 @NonNull public String getScaleMode()
784 {
785 return scaleMode;
786 }
787
788 public int getScalePreset()
789 {
790 if ("140".equals(scaleMode))
791 return 140;
792 if ("180".equals(scaleMode))
793 return 180;
794 return 100;
795 }
796
797 public int getScaleDesktop()
798 {
799 return scaleDesktop;
800 }
801
802 public int getScaleDevice()
803 {
804 return scaleDevice;
805 }
806
807 @Override public int describeContents()
808 {
809 return 0;
810 }
811
812 @Override public void writeToParcel(@NonNull Parcel out, int flags)
813 {
814 out.writeInt(resolution);
815 out.writeInt(colors);
816 out.writeInt(width);
817 out.writeInt(height);
818 out.writeString(scaleMode);
819 out.writeInt(scaleDesktop);
820 out.writeInt(scaleDevice);
821 }
822 }
823
824 public static class DebugSettings implements Parcelable
825 {
826 public static final Parcelable.Creator<DebugSettings> CREATOR =
827 new Parcelable.Creator<DebugSettings>() {
828 @NonNull public DebugSettings createFromParcel(Parcel in)
829 {
830 return new DebugSettings(in);
831 }
832
833 @NonNull @Override public DebugSettings[] newArray(int size)
834 {
835 return new DebugSettings[size];
836 }
837 };
838
839 @NonNull private String debug = "INFO";
840 private boolean asyncChannel = true;
841 private boolean asyncTransport = false;
842 private boolean asyncUpdate = true;
843
844 public DebugSettings()
845 {
846 }
847
848 // Session Settings
849 public DebugSettings(@NonNull Parcel parcel)
850 {
851 asyncChannel = parcel.readBoolean();
852 asyncTransport = parcel.readBoolean();
853 asyncUpdate = parcel.readBoolean();
854 debug = Objects.requireNonNull(parcel.readString());
855 }
856
857 private void validate()
858 {
859 final String[] levels = { "OFF", "FATAL", "ERROR", "WARN", "INFO", "DEBUG", "TRACE" };
860
861 for (String level : levels)
862 {
863 if (level.equalsIgnoreCase(this.debug))
864 {
865 return;
866 }
867 }
868
869 this.debug = "INFO";
870 }
871
872 @NonNull public String getDebugLevel()
873 {
874 validate();
875 return debug;
876 }
877
878 public void setDebugLevel(@NonNull String debug)
879 {
880 this.debug = debug;
881 }
882
883 public boolean getAsyncUpdate()
884 {
885 return asyncUpdate;
886 }
887
888 public void setAsyncUpdate(boolean enabled)
889 {
890 asyncUpdate = enabled;
891 }
892
893 public boolean getAsyncChannel()
894 {
895 return asyncChannel;
896 }
897
898 public void setAsyncChannel(boolean enabled)
899 {
900 asyncChannel = enabled;
901 }
902
903 @Override public int describeContents()
904 {
905 return 0;
906 }
907
908 @Override public void writeToParcel(@NonNull Parcel out, int flags)
909 {
910 out.writeBoolean(asyncChannel);
911 out.writeBoolean(asyncTransport);
912 out.writeBoolean(asyncUpdate);
913 out.writeString(debug);
914 }
915 }
916
917 // Session Settings
918 public static class AdvancedSettings implements Parcelable
919 {
920 public static final Parcelable.Creator<AdvancedSettings> CREATOR =
921 new Parcelable.Creator<AdvancedSettings>() {
922 @NonNull public AdvancedSettings createFromParcel(Parcel in)
923 {
924 return new AdvancedSettings(in);
925 }
926
927 @NonNull @Override public AdvancedSettings[] newArray(int size)
928 {
929 return new AdvancedSettings[size];
930 }
931 };
932
933 @NonNull private String loadBalanceInfo = "";
934 private boolean redirectSDCard = false;
935 private int redirectSound = 0;
936 private boolean redirectMicrophone = false;
937 private boolean redirectCamera = false;
938 private boolean redirectPrinter = false;
939 private int security = 0;
940 private boolean consoleMode = false;
941 private boolean vmConnectMode = false;
942 @NonNull private String vmConnectGuid = "";
943
944 @NonNull private String remoteProgram = "";
945
946 @NonNull private String alternateShell = "";
947
948 @NonNull private String workDir = "";
949 private int tlsSecLevel = -1;
950 private int tlsMinLevel = -1;
951
952 public AdvancedSettings()
953 {
954 }
955
956 public AdvancedSettings(@NonNull Parcel parcel)
957 {
958 loadBalanceInfo = Objects.requireNonNull(parcel.readString());
959 redirectSDCard = parcel.readBoolean();
960 redirectSound = parcel.readInt();
961 redirectMicrophone = parcel.readBoolean();
962 redirectCamera = parcel.readBoolean();
963 redirectPrinter = parcel.readBoolean();
964 security = parcel.readInt();
965 consoleMode = parcel.readBoolean();
966 vmConnectMode = parcel.readBoolean();
967 vmConnectGuid = Objects.requireNonNull(parcel.readString());
968 remoteProgram = Objects.requireNonNull(parcel.readString());
969 alternateShell = Objects.requireNonNull(parcel.readString());
970 workDir = Objects.requireNonNull(parcel.readString());
971 tlsSecLevel = parcel.readInt();
972 tlsMinLevel = parcel.readInt();
973 }
974
975 private void validate()
976 {
977 switch (redirectSound)
978 {
979 case 0:
980 case 1:
981 case 2:
982 break;
983 default:
984 redirectSound = 0;
985 break;
986 }
987
988 switch (security)
989 {
990 case 0:
991 case 1:
992 case 2:
993 case 3:
994 break;
995 default:
996 security = 0;
997 break;
998 }
999 }
1000
1001 public int getTlsSecLevel()
1002 {
1003 return tlsSecLevel;
1004 }
1005
1006 public void setTlsSecLevel(int level)
1007 {
1008 tlsSecLevel = level;
1009 }
1010
1011 public void setTlsMinLevel(int level)
1012 {
1013 tlsMinLevel = level;
1014 }
1015
1016 public int getTlsMinLevel()
1017 {
1018 return tlsMinLevel;
1019 }
1020
1021 @NonNull public String getLoadBalanceInfo()
1022 {
1023 return loadBalanceInfo;
1024 }
1025
1026 public void setLoadBalanceInfo(@NonNull String info)
1027 {
1028 loadBalanceInfo = info;
1029 }
1030 public boolean getRedirectSDCard()
1031 {
1032 return redirectSDCard;
1033 }
1034
1035 public void setRedirectSDCard(boolean redirectSDCard)
1036 {
1037 this.redirectSDCard = redirectSDCard;
1038 }
1039
1040 public boolean getRedirectPrinter()
1041 {
1042 return redirectPrinter;
1043 }
1044
1045 public void setRedirectPrinter(boolean redirectPrinter)
1046 {
1047 this.redirectPrinter = redirectPrinter;
1048 }
1049
1050 public int getRedirectSound()
1051 {
1052 validate();
1053 return redirectSound;
1054 }
1055
1056 public void setRedirectSound(int redirect)
1057 {
1058 this.redirectSound = redirect;
1059 }
1060
1061 public boolean getRedirectMicrophone()
1062 {
1063 return redirectMicrophone;
1064 }
1065
1066 public void setRedirectMicrophone(boolean redirect)
1067 {
1068 this.redirectMicrophone = redirect;
1069 }
1070
1071 public boolean getRedirectCamera()
1072 {
1073 return redirectCamera;
1074 }
1075
1076 public void setRedirectCamera(boolean redirect)
1077 {
1078 this.redirectCamera = redirect;
1079 }
1080
1081 public int getSecurity()
1082 {
1083 validate();
1084 return security;
1085 }
1086
1087 public void setSecurity(int security)
1088 {
1089 this.security = security;
1090 }
1091
1092 public boolean getConsoleMode()
1093 {
1094 return consoleMode;
1095 }
1096
1097 public void setConsoleMode(boolean consoleMode)
1098 {
1099 this.consoleMode = consoleMode;
1100 }
1101
1102 @NonNull public String getRemoteProgram()
1103 {
1104 return remoteProgram;
1105 }
1106
1107 public void setRemoteProgram(@NonNull String remoteProgram)
1108 {
1109 this.remoteProgram = remoteProgram;
1110 }
1111
1112 @NonNull public String getAlternateShell()
1113 {
1114 return alternateShell;
1115 }
1116
1117 public void setAlternateShell(@NonNull String alternateShell)
1118 {
1119 this.alternateShell = alternateShell;
1120 }
1121
1122 @NonNull public String getWorkDir()
1123 {
1124 return workDir;
1125 }
1126
1127 public void setWorkDir(@NonNull String workDir)
1128 {
1129 this.workDir = workDir;
1130 }
1131
1132 public boolean getVmConnectMode()
1133 {
1134 return vmConnectMode;
1135 }
1136
1137 public void setVmConnectMode(boolean vmConnectMode)
1138 {
1139 this.vmConnectMode = vmConnectMode;
1140 }
1141
1142 @NonNull public String getVmConnectGuid()
1143 {
1144 return vmConnectGuid;
1145 }
1146
1147 public void setVmConnectGuid(@NonNull String vmConnectGuid)
1148 {
1149 this.vmConnectGuid = vmConnectGuid;
1150 }
1151
1152 @Override public int describeContents()
1153 {
1154 return 0;
1155 }
1156
1157 @Override public void writeToParcel(@NonNull Parcel out, int flags)
1158 {
1159 out.writeString(loadBalanceInfo);
1160 out.writeBoolean(redirectSDCard);
1161 out.writeInt(redirectSound);
1162 out.writeBoolean(redirectMicrophone);
1163 out.writeBoolean(redirectCamera);
1164 out.writeBoolean(redirectPrinter);
1165 out.writeInt(security);
1166 out.writeBoolean(consoleMode);
1167 out.writeBoolean(vmConnectMode);
1168 out.writeString(vmConnectGuid);
1169 out.writeString(remoteProgram);
1170 out.writeString(alternateShell);
1171 out.writeString(workDir);
1172 out.writeInt(tlsSecLevel);
1173 out.writeInt(tlsMinLevel);
1174 }
1175 }
1176
1177 public static class GatewaySettings implements Parcelable
1178 {
1179 public static final Parcelable.Creator<GatewaySettings> CREATOR =
1180 new Parcelable.Creator<GatewaySettings>() {
1181 @NonNull public GatewaySettings createFromParcel(Parcel in)
1182 {
1183 return new GatewaySettings(in);
1184 }
1185
1186 @NonNull @Override public GatewaySettings[] newArray(int size)
1187 {
1188 return new GatewaySettings[size];
1189 }
1190 };
1191
1192 @NonNull private String hostname = "";
1193 private int port = 443;
1194
1195 @NonNull private String username = "";
1196
1197 @NonNull private String password = "";
1198
1199 @NonNull private String domain = "";
1200
1201 public GatewaySettings()
1202 {
1203 }
1204
1205 public GatewaySettings(Parcel parcel)
1206 {
1207 hostname = Objects.requireNonNull(parcel.readString());
1208 port = parcel.readInt();
1209 username = Objects.requireNonNull(parcel.readString());
1210 password = Objects.requireNonNull(parcel.readString());
1211 domain = Objects.requireNonNull(parcel.readString());
1212 }
1213
1214 @NonNull public String getHostname()
1215 {
1216 return hostname;
1217 }
1218
1219 public void setHostname(@NonNull String hostname)
1220 {
1221 this.hostname = hostname;
1222 }
1223
1224 public int getPort()
1225 {
1226 return port;
1227 }
1228
1229 public void setPort(int port)
1230 {
1231 this.port = port;
1232 }
1233
1234 @NonNull public String getUsername()
1235 {
1236 return username;
1237 }
1238
1239 public void setUsername(@NonNull String username)
1240 {
1241 this.username = username;
1242 }
1243
1244 @NonNull public String getPassword()
1245 {
1246 return password;
1247 }
1248
1249 public void setPassword(@NonNull String password)
1250 {
1251 this.password = password;
1252 }
1253
1254 @NonNull public String getDomain()
1255 {
1256 return domain;
1257 }
1258
1259 public void setDomain(@NonNull String domain)
1260 {
1261 this.domain = domain;
1262 }
1263
1264 @Override public int describeContents()
1265 {
1266 return 0;
1267 }
1268
1269 @Override public void writeToParcel(@NonNull Parcel out, int flags)
1270 {
1271 out.writeString(hostname);
1272 out.writeInt(port);
1273 out.writeString(username);
1274 out.writeString(password);
1275 out.writeString(domain);
1276 }
1277 }
1278}