From e585fd9ac16072059d0c7ca8ab9c2ab4f00ea3ef Mon Sep 17 00:00:00 2001 From: Martin Fleisz Date: Tue, 30 Apr 2013 08:14:24 -0700 Subject: [PATCH] Android: Added support for TS Gateway --- .../Android/FreeRDPCore/jni/android_cliprdr.c | 2 +- .../Android/FreeRDPCore/jni/android_freerdp.c | 33 ++++- .../Android/FreeRDPCore/jni/android_freerdp.h | 1 + .../jni/generated/android_freerdp_jni.c | 6 + ..._freerdp_freerdpcore_services_LibFreeRDP.h | 8 ++ .../FreeRDPCore/res/values-es/strings.xml | 3 + .../FreeRDPCore/res/values-fr/strings.xml | 3 + .../FreeRDPCore/res/values/strings.xml | 3 + .../FreeRDPCore/res/xml/advanced_settings.xml | 11 +- .../FreeRDPCore/res/xml/gateway_settings.xml | 20 +++ .../freerdpcore/domain/ManualBookmark.java | 136 +++++++++++++++++- .../presentation/BookmarkActivity.java | 66 ++++++++- .../freerdpcore/services/BookmarkDB.java | 11 +- .../freerdpcore/services/LibFreeRDP.java | 11 ++ .../services/ManualBookmarkGateway.java | 29 +++- 15 files changed, 333 insertions(+), 10 deletions(-) create mode 100644 client/Android/FreeRDPCore/res/xml/gateway_settings.xml diff --git a/client/Android/FreeRDPCore/jni/android_cliprdr.c b/client/Android/FreeRDPCore/jni/android_cliprdr.c index 1c62d2b4c..f34014de5 100644 --- a/client/Android/FreeRDPCore/jni/android_cliprdr.c +++ b/client/Android/FreeRDPCore/jni/android_cliprdr.c @@ -586,7 +586,7 @@ void android_process_cliprdr_event(freerdp* inst, wMessage* event) break; default: - DEBUG_ANDROID("unknown event type %d", event->event_type); + DEBUG_ANDROID("unknown event type %d", GetMessageType(event->id)); break; } } diff --git a/client/Android/FreeRDPCore/jni/android_freerdp.c b/client/Android/FreeRDPCore/jni/android_freerdp.c index 10aa20926..51a6a4695 100644 --- a/client/Android/FreeRDPCore/jni/android_freerdp.c +++ b/client/Android/FreeRDPCore/jni/android_freerdp.c @@ -652,6 +652,37 @@ JNIEXPORT void JNICALL jni_freerdp_set_clipboard_redirection(JNIEnv *env, jclass settings->RedirectClipboard = enable ? TRUE : FALSE; } +JNIEXPORT void JNICALL jni_freerdp_set_gateway_info(JNIEnv *env, jclass cls, jint instance, jstring jgatewayhostname, jint port, + jstring jgatewayusername, jstring jgatewaypassword, jstring jgatewaydomain) +{ + freerdp* inst = (freerdp*)instance; + rdpSettings * settings = inst->settings; + + const jbyte *gatewayhostname = (*env)->GetStringUTFChars(env, jgatewayhostname, NULL); + const jbyte *gatewayusername = (*env)->GetStringUTFChars(env, jgatewayusername, NULL); + const jbyte *gatewaypassword = (*env)->GetStringUTFChars(env, jgatewaypassword, NULL); + const jbyte *gatewaydomain = (*env)->GetStringUTFChars(env, jgatewaydomain, NULL); + + DEBUG_ANDROID("gatewayhostname: %s", (char*) gatewayhostname); + DEBUG_ANDROID("gatewayport: %d", port); + DEBUG_ANDROID("gatewayusername: %s", (char*) gatewayusername); + DEBUG_ANDROID("gatewaypassword: %s", (char*) gatewaypassword); + DEBUG_ANDROID("gatewaydomain: %s", (char*) gatewaydomain); + + settings->GatewayHostname = strdup(gatewayhostname); + settings->GatewayPort = port; + settings->GatewayUsername = strdup(gatewayusername); + settings->GatewayPassword = strdup(gatewaypassword); + settings->GatewayDomain = strdup(gatewaydomain); + settings->GatewayUsageMethod = TRUE; + settings->GatewayUseSameCredentials = FALSE; + + (*env)->ReleaseStringUTFChars(env, jgatewayhostname, gatewayhostname); + (*env)->ReleaseStringUTFChars(env, jgatewayusername, gatewayusername); + (*env)->ReleaseStringUTFChars(env, jgatewaypassword, gatewaypassword); + (*env)->ReleaseStringUTFChars(env, jgatewaydomain, gatewaydomain); +} + void copy_pixel_buffer(UINT8* dstBuf, UINT8* srcBuf, int x, int y, int width, int height, int wBuf, int hBuf, int bpp) { int i, j; @@ -737,7 +768,7 @@ JNIEXPORT void JNICALL jni_freerdp_send_key_event( android_push_event(inst, event); - DEBUG_ANDROID("send_key_event: %d, %d", scancode, flags); + DEBUG_ANDROID("send_key_event: %d, %d", (int)scancode, flags); } JNIEXPORT void JNICALL jni_freerdp_send_unicodekey_event( diff --git a/client/Android/FreeRDPCore/jni/android_freerdp.h b/client/Android/FreeRDPCore/jni/android_freerdp.h index f4c660b3d..ad96bc398 100644 --- a/client/Android/FreeRDPCore/jni/android_freerdp.h +++ b/client/Android/FreeRDPCore/jni/android_freerdp.h @@ -46,6 +46,7 @@ JNIEXPORT void JNICALL jni_freerdp_set_performance_flags(JNIEnv *env, jclass cls JNIEXPORT void JNICALL jni_freerdp_set_advanced_settings(JNIEnv *env, jclass cls, jint instance, jstring jRemoteProgram, jstring jWorkDir); JNIEXPORT void JNICALL jni_freerdp_set_drive_redirection(JNIEnv *env, jclass cls, jint instance, jstring jpath); JNIEXPORT void JNICALL jni_freerdp_set_clipboard_redirection(JNIEnv *env, jclass cls, jint instance, jboolean enable); +JNIEXPORT void JNICALL jni_freerdp_set_gateway_info(JNIEnv *env, jclass cls, jint instance, jstring jgatewayhostname, jint port, jstring jgatewayusername, jstring jgatewaypassword, jstring jgatewaydomain); JNIEXPORT void JNICALL jni_freerdp_set_data_directory(JNIEnv *env, jclass cls, jint instance, jstring jdirectory); JNIEXPORT jboolean JNICALL jni_freerdp_update_graphics(JNIEnv *env, jclass cls, jint instance, jobject bitmap, jint x, jint y, jint width, jint height); JNIEXPORT void JNICALL jni_freerdp_send_cursor_event(JNIEnv *env, jclass cls, jint instance, jint x, jint y, jint flags); diff --git a/client/Android/FreeRDPCore/jni/generated/android_freerdp_jni.c b/client/Android/FreeRDPCore/jni/generated/android_freerdp_jni.c index 861a9087a..1aa889abe 100644 --- a/client/Android/FreeRDPCore/jni/generated/android_freerdp_jni.c +++ b/client/Android/FreeRDPCore/jni/generated/android_freerdp_jni.c @@ -82,6 +82,12 @@ JNIEXPORT void JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_ jni_freerdp_set_drive_redirection(env, cls, inst, path); } +JNIEXPORT void JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1set_1gateway_1info + (JNIEnv *env, jclass cls, jint inst, jstring hostname, jint port, jstring username, jstring password, jstring domain) +{ + jni_freerdp_set_gateway_info(env, cls, inst, hostname, port, username, password, domain); +} + JNIEXPORT jboolean JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1update_1graphics( JNIEnv *env, jclass cls, jint instance, jobject bitmap, jint x, jint y, jint width, jint height) { diff --git a/client/Android/FreeRDPCore/jni/generated/com_freerdp_freerdpcore_services_LibFreeRDP.h b/client/Android/FreeRDPCore/jni/generated/com_freerdp_freerdpcore_services_LibFreeRDP.h index 08188f700..1e6be8dff 100644 --- a/client/Android/FreeRDPCore/jni/generated/com_freerdp_freerdpcore_services_LibFreeRDP.h +++ b/client/Android/FreeRDPCore/jni/generated/com_freerdp_freerdpcore_services_LibFreeRDP.h @@ -95,6 +95,14 @@ JNIEXPORT void JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_ JNIEXPORT void JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1set_1drive_1redirection (JNIEnv *, jclass, jint, jstring); +/* + * Class: com_freerdp_freerdpcore_services_LibFreeRDP + * Method: freerdp_set_gateway_info + * Signature: (ILjava/lang/String;ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;)V + */ +JNIEXPORT void JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1set_1gateway_1info + (JNIEnv *, jclass, jint, jstring, jint, jstring, jstring, jstring); + /* * Class: com_freerdp_freerdpcore_services_LibFreeRDP * Method: freerdp_update_graphics diff --git a/client/Android/FreeRDPCore/res/values-es/strings.xml b/client/Android/FreeRDPCore/res/values-es/strings.xml index 93a16bdbf..cf9b933a9 100644 --- a/client/Android/FreeRDPCore/res/values-es/strings.xml +++ b/client/Android/FreeRDPCore/res/values-es/strings.xml @@ -105,6 +105,9 @@ Configuracion 3G Pantalla 3G Rendimiento 3G + Gateway + Enable Gateway + Gateway Settings Redirect SDCard Seguridad diff --git a/client/Android/FreeRDPCore/res/values-fr/strings.xml b/client/Android/FreeRDPCore/res/values-fr/strings.xml index a55366019..3e0f1711f 100644 --- a/client/Android/FreeRDPCore/res/values-fr/strings.xml +++ b/client/Android/FreeRDPCore/res/values-fr/strings.xml @@ -104,6 +104,9 @@ "Paramètres 3G" "Écran 3G" "Performance 3G" + Gateway + Enable Gateway + Gateway Settings "Redirect SDCard" "Securité" diff --git a/client/Android/FreeRDPCore/res/values/strings.xml b/client/Android/FreeRDPCore/res/values/strings.xml index 774e981d8..6110afd5d 100644 --- a/client/Android/FreeRDPCore/res/values/strings.xml +++ b/client/Android/FreeRDPCore/res/values/strings.xml @@ -105,6 +105,9 @@ 3G Settings 3G Screen 3G Performance + Gateway + Enable Gateway + Gateway Settings Redirect SDCard Security diff --git a/client/Android/FreeRDPCore/res/xml/advanced_settings.xml b/client/Android/FreeRDPCore/res/xml/advanced_settings.xml index 7fdabd5e6..61cd61d19 100644 --- a/client/Android/FreeRDPCore/res/xml/advanced_settings.xml +++ b/client/Android/FreeRDPCore/res/xml/advanced_settings.xml @@ -12,8 +12,15 @@ - - + + + + + + + + + + + + + + + + diff --git a/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/domain/ManualBookmark.java b/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/domain/ManualBookmark.java index 81d9b717c..b8e3da862 100644 --- a/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/domain/ManualBookmark.java +++ b/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/domain/ManualBookmark.java @@ -15,14 +15,111 @@ import android.os.Parcelable; public class ManualBookmark extends BookmarkBase { + // Gateway Settings class + public static class GatewaySettings implements Parcelable + { + private String hostname; + private int port; + private String username; + private String password; + private String domain; + + public GatewaySettings() { + hostname = ""; + port = 443; + username = ""; + password = ""; + domain = ""; + } + + public GatewaySettings(Parcel parcel) { + hostname = parcel.readString(); + port = parcel.readInt(); + username = parcel.readString(); + password = parcel.readString(); + domain = parcel.readString(); + } + + public void setHostname(String hostname) { + this.hostname = hostname; + } + + public String getHostname() { + return hostname; + } + + public void setPort(int port) { + this.port = port; + } + + public int getPort() { + return port; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getUsername() { + return username; + } + + public void setPassword(String password) { + this.password = password; + } + + public String getPassword() { + return password; + } + + public void setDomain(String domain) { + this.domain = domain; + } + + public String getDomain() { + return domain; + } + + @Override + public int describeContents() { + return 0; + } + + @Override + public void writeToParcel(Parcel out, int flags) + { + out.writeString(hostname); + out.writeInt(port); + out.writeString(username); + out.writeString(password); + out.writeString(domain); + } + + public static final Parcelable.Creator CREATOR = new Parcelable.Creator() + { + public GatewaySettings createFromParcel(Parcel in) { + return new GatewaySettings(in); + } + + @Override + public GatewaySettings[] newArray(int size) { + return new GatewaySettings[size]; + } + }; + } + private String hostname; private int port; + private boolean enableGatewaySettings; + private GatewaySettings gatewaySettings; private void init() { type = TYPE_MANUAL; hostname = ""; - port = 3389; + port = 3389; + enableGatewaySettings = false; + gatewaySettings = new GatewaySettings(); } public ManualBookmark(Parcel parcel) @@ -31,6 +128,9 @@ public class ManualBookmark extends BookmarkBase type = TYPE_MANUAL; hostname = parcel.readString(); port = parcel.readInt(); + + enableGatewaySettings = (parcel.readInt() == 1 ? true : false); + gatewaySettings = parcel.readParcelable(GatewaySettings.class.getClassLoader()); } public ManualBookmark() { @@ -53,7 +153,27 @@ public class ManualBookmark extends BookmarkBase public int getPort() { return port; } + + public boolean getEnableGatewaySettings() + { + return enableGatewaySettings; + } + + public void setEnableGatewaySettings(boolean enableGatewaySettings) + { + this.enableGatewaySettings = enableGatewaySettings; + } + + public GatewaySettings getGatewaySettings() + { + return gatewaySettings; + } + public void setGatewaySettings(GatewaySettings gatewaySettings) + { + this.gatewaySettings = gatewaySettings; + } + public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { public ManualBookmark createFromParcel(Parcel in) { @@ -77,6 +197,8 @@ public class ManualBookmark extends BookmarkBase super.writeToParcel(out, flags); out.writeString(hostname); out.writeInt(port); + out.writeInt(enableGatewaySettings ? 1 : 0); + out.writeParcelable(gatewaySettings, flags); } @Override @@ -87,6 +209,12 @@ public class ManualBookmark extends BookmarkBase SharedPreferences.Editor editor = sharedPrefs.edit(); editor.putString("bookmark.hostname", hostname); editor.putInt("bookmark.port", port); + editor.putBoolean("bookmark.enable_gateway_settings", enableGatewaySettings); + editor.putString("bookmark.gateway_hostname", gatewaySettings.getHostname()); + editor.putInt("bookmark.gateway_port", gatewaySettings.getPort()); + editor.putString("bookmark.gateway_username", gatewaySettings.getUsername()); + editor.putString("bookmark.gateway_password", gatewaySettings.getPassword()); + editor.putString("bookmark.gateway_domain", gatewaySettings.getDomain()); editor.commit(); } @@ -97,6 +225,12 @@ public class ManualBookmark extends BookmarkBase hostname = sharedPrefs.getString("bookmark.hostname", ""); port = sharedPrefs.getInt("bookmark.port", 3389); + enableGatewaySettings = sharedPrefs.getBoolean("bookmark.enable_gateway_settings", false); + gatewaySettings.setHostname(sharedPrefs.getString("bookmark.gateway_hostname", "")); + gatewaySettings.setPort(sharedPrefs.getInt("bookmark.gateway_port", 443)); + gatewaySettings.setUsername(sharedPrefs.getString("bookmark.gateway_username", "")); + gatewaySettings.setPassword(sharedPrefs.getString("bookmark.gateway_password", "")); + gatewaySettings.setDomain(sharedPrefs.getString("bookmark.gateway_domain", "")); } // Cloneable diff --git a/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/presentation/BookmarkActivity.java b/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/presentation/BookmarkActivity.java index 4d938f419..dbff71478 100644 --- a/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/presentation/BookmarkActivity.java +++ b/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/presentation/BookmarkActivity.java @@ -45,6 +45,7 @@ public class BookmarkActivity extends PreferenceActivity implements OnSharedPref private static final int PREFERENCES_ADVANCED = 5; private static final int PREFERENCES_SCREEN3G = 6; private static final int PREFERENCES_PERFORMANCE3G = 7; + private static final int PREFERENCES_GATEWAY = 8; // bookmark needs to be static because the activity is started for each subview // (we have to do this because Android has a bug where the style for Preferences @@ -112,6 +113,13 @@ public class BookmarkActivity extends PreferenceActivity implements OnSharedPref if(bookmark == null) bookmark = new ManualBookmark(); + // hide gateway settings if we edit a non-manual bookmark + if (current_preferences == PREFERENCES_ADVANCED && bookmark.getType() != ManualBookmark.TYPE_MANUAL) + { + getPreferenceScreen().removePreference(findPreference("bookmark.enable_gateway")); + getPreferenceScreen().removePreference(findPreference("bookmark.gateway")); + } + // update preferences from bookmark bookmark.writeToSharedPreferences(getPreferenceManager().getSharedPreferences()); @@ -155,6 +163,11 @@ public class BookmarkActivity extends PreferenceActivity implements OnSharedPref addPreferencesFromResource(R.xml.credentials_settings); current_preferences = PREFERENCES_CREDENTIALS; } + else if (getIntent().getData().toString().equals("preferences://gateway_settings")) + { + addPreferencesFromResource(R.xml.gateway_settings); + current_preferences = PREFERENCES_GATEWAY; + } else { addPreferencesFromResource(R.xml.bookmark_settings); @@ -230,7 +243,8 @@ public class BookmarkActivity extends PreferenceActivity implements OnSharedPref "bookmark.performance", "bookmark.advanced", "bookmark.screen_3g", - "bookmark.performance_3g" + "bookmark.performance_3g", + "bookmark.gateway_settings" }; for (int i = 0; i < prefKeys.length; ++i) @@ -264,6 +278,10 @@ public class BookmarkActivity extends PreferenceActivity implements OnSharedPref case PREFERENCES_SCREEN3G: screenSettingsChanged(sharedPreferences, key); break; + + case PREFERENCES_GATEWAY: + gatewaySettingsChanged(sharedPreferences, key); + break; } } @@ -291,6 +309,10 @@ public class BookmarkActivity extends PreferenceActivity implements OnSharedPref case PREFERENCES_SCREEN3G: initScreenSettings3G(sharedPreferences); break; + + case PREFERENCES_GATEWAY: + initGatewaySettings(sharedPreferences); + break; } } @@ -332,6 +354,7 @@ public class BookmarkActivity extends PreferenceActivity implements OnSharedPref private void initAdvancedSettings(SharedPreferences sharedPreferences) { + advancedSettingsChanged(sharedPreferences, "bookmark.enable_gateway_settings"); advancedSettingsChanged(sharedPreferences, "bookmark.enable_3g_settings"); advancedSettingsChanged(sharedPreferences, "bookmark.security"); advancedSettingsChanged(sharedPreferences, "bookmark.resolution_3g"); @@ -341,7 +364,12 @@ public class BookmarkActivity extends PreferenceActivity implements OnSharedPref private void advancedSettingsChanged(SharedPreferences sharedPreferences, String key) { - if (key.equals("bookmark.enable_3g_settings")) + if (key.equals("bookmark.enable_gateway_settings")) + { + boolean enabled = sharedPreferences.getBoolean(key, false); + findPreference("bookmark.gateway_settings").setEnabled(enabled); + } + else if (key.equals("bookmark.enable_3g_settings")) { boolean enabled = sharedPreferences.getBoolean(key, false); findPreference("bookmark.screen_3g").setEnabled(enabled); @@ -441,6 +469,40 @@ public class BookmarkActivity extends PreferenceActivity implements OnSharedPref findPreference(key).setSummary(String.valueOf(sharedPreferences.getInt(key, 600))); } + private void initGatewaySettings(SharedPreferences sharedPreferences) + { + gatewaySettingsChanged(sharedPreferences, "bookmark.gateway_hostname"); + gatewaySettingsChanged(sharedPreferences, "bookmark.gateway_port"); + gatewaySettingsChanged(sharedPreferences, "bookmark.gateway_username"); + gatewaySettingsChanged(sharedPreferences, "bookmark.gateway_password"); + gatewaySettingsChanged(sharedPreferences, "bookmark.gateway_domain"); + } + + private void gatewaySettingsChanged(SharedPreferences sharedPreferences, String key) + { + if (key.equals("bookmark.gateway_hostname")) + { + findPreference(key).setSummary(sharedPreferences.getString(key, "")); + } + else if (key.equals("bookmark.gateway_port")) + { + findPreference(key).setSummary(String.valueOf(sharedPreferences.getInt(key, 443))); + } + else if (key.equals("bookmark.gateway_username")) + { + findPreference(key).setSummary(sharedPreferences.getString(key, "")); + } + else if (key.equals("bookmark.gateway_password")) + { + if (sharedPreferences.getString(key, "").length() == 0) + findPreference(key).setSummary(getResources().getString(R.string.settings_password_empty)); + else + findPreference(key).setSummary(getResources().getString(R.string.settings_password_present)); + } + else if (key.equals("bookmark.gateway_domain")) + findPreference(key).setSummary(sharedPreferences.getString(key, "")); + } + private boolean verifySettings(SharedPreferences sharedPreferences) { boolean verifyFailed = false; diff --git a/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/services/BookmarkDB.java b/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/services/BookmarkDB.java index 61022b470..e54cc1502 100644 --- a/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/services/BookmarkDB.java +++ b/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/services/BookmarkDB.java @@ -22,7 +22,7 @@ import android.database.sqlite.SQLiteOpenHelper; public class BookmarkDB extends SQLiteOpenHelper { - private static final int DB_VERSION = 2; + private static final int DB_VERSION = 3; private static final String DB_NAME = "bookmarks.db"; public static final String ID = BaseColumns._ID; @@ -130,6 +130,13 @@ public class BookmarkDB extends SQLiteOpenHelper + "screen_settings INTEGER NOT NULL, " + "performance_flags INTEGER NOT NULL, " + + "enable_gateway_settings INTEGER DEFAULT 0, " + + "gateway_hostname TEXT, " + + "gateway_port INTEGER DEFAULT 443, " + + "gateway_username TEXT, " + + "gateway_password TEXT, " + + "gateway_domain TEXT, " + + "enable_3g_settings INTEGER DEFAULT 0, " + "screen_3g INTEGER NOT NULL, " + "performance_3g INTEGER NOT NULL, " @@ -138,7 +145,7 @@ public class BookmarkDB extends SQLiteOpenHelper + "remote_program TEXT, " + "work_dir TEXT, " + "console_mode INTEGER, " - + + "FOREIGN KEY(screen_settings) REFERENCES tbl_screen_settings(" + ID + "), " + "FOREIGN KEY(performance_flags) REFERENCES tbl_performance_flags(" + ID + "), " + "FOREIGN KEY(screen_3g) REFERENCES tbl_screen_settings(" + ID + "), " diff --git a/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/services/LibFreeRDP.java b/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/services/LibFreeRDP.java index 455d0a379..54de217c9 100644 --- a/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/services/LibFreeRDP.java +++ b/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/services/LibFreeRDP.java @@ -42,6 +42,9 @@ public class LibFreeRDP private static native void freerdp_set_clipboard_redirection(int inst, boolean enable); private static native void freerdp_set_drive_redirection(int inst, String path); + private static native void freerdp_set_gateway_info(int inst, String gatewayhostname, int port, + String gatewayusername, String gatewaypassword, String gatewaydomain); + private static native boolean freerdp_update_graphics(int inst, Bitmap bitmap, int x, int y, int width, int height); @@ -155,6 +158,14 @@ public class LibFreeRDP // always enable clipboard redirection freerdp_set_clipboard_redirection(inst, true); + // Gateway enabled? + if (bookmark.getType() == BookmarkBase.TYPE_MANUAL && bookmark.get().getEnableGatewaySettings()) + { + ManualBookmark.GatewaySettings gatewaySettings = bookmark.get().getGatewaySettings(); + freerdp_set_gateway_info(inst, gatewaySettings.getHostname(), gatewaySettings.getPort(), + gatewaySettings.getUsername(), gatewaySettings.getPassword(), gatewaySettings.getDomain()); + } + return true; } diff --git a/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/services/ManualBookmarkGateway.java b/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/services/ManualBookmarkGateway.java index 6b07850ac..146631544 100644 --- a/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/services/ManualBookmarkGateway.java +++ b/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/services/ManualBookmarkGateway.java @@ -39,12 +39,26 @@ public class ManualBookmarkGateway extends BookmarkBaseGateway { ManualBookmark bm = (ManualBookmark)bookmark; columns.put("hostname", bm.getHostname()); columns.put("port", bm.getPort()); + + // gateway settings + columns.put("enable_gateway_settings", bm.getEnableGatewaySettings()); + columns.put("gateway_hostname", bm.getGatewaySettings().getHostname()); + columns.put("gateway_port", bm.getGatewaySettings().getPort()); + columns.put("gateway_username", bm.getGatewaySettings().getUsername()); + columns.put("gateway_password", bm.getGatewaySettings().getPassword()); + columns.put("gateway_domain", bm.getGatewaySettings().getDomain()); } @Override protected void addBookmarkSpecificColumns(ArrayList columns) { columns.add("hostname"); columns.add("port"); + columns.add("enable_gateway_settings"); + columns.add("gateway_hostname"); + columns.add("gateway_port"); + columns.add("gateway_username"); + columns.add("gateway_password"); + columns.add("gateway_domain"); } @Override @@ -52,8 +66,11 @@ public class ManualBookmarkGateway extends BookmarkBaseGateway { ManualBookmark bm = (ManualBookmark)bookmark; bm.setHostname(cursor.getString(cursor.getColumnIndex("hostname"))); bm.setPort(cursor.getInt(cursor.getColumnIndex("port"))); - } + bm.setEnableGatewaySettings(cursor.getInt(cursor.getColumnIndex("enable_gateway_settings")) == 0 ? false : true); + readGatewaySettings(bm, cursor); + } + public BookmarkBase findByLabelOrHostname(String pattern) { if(pattern.length() == 0) @@ -84,4 +101,14 @@ public class ManualBookmarkGateway extends BookmarkBaseGateway { cursor.close(); return bookmarks; } + + private void readGatewaySettings(ManualBookmark bookmark, Cursor cursor) + { + ManualBookmark.GatewaySettings gatewaySettings = bookmark.getGatewaySettings(); + gatewaySettings.setHostname(cursor.getString(cursor.getColumnIndex("gateway_hostname"))); + gatewaySettings.setPort(cursor.getInt(cursor.getColumnIndex("gateway_port"))); + gatewaySettings.setUsername(cursor.getString(cursor.getColumnIndex("gateway_username"))); + gatewaySettings.setPassword(cursor.getString(cursor.getColumnIndex("gateway_password"))); + gatewaySettings.setDomain(cursor.getString(cursor.getColumnIndex("gateway_domain"))); + } }