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