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