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-nl/strings.xml b/client/Android/FreeRDPCore/res/values-nl/strings.xml new file mode 100644 index 000000000..5dfbf0c24 --- /dev/null +++ b/client/Android/FreeRDPCore/res/values-nl/strings.xml @@ -0,0 +1,175 @@ + + + + Ja + Nee + Annuleren + Doorgaan + Inloggen + Uitloggen + + Sluiten + Over + Help + Nieuwe connectie + Instellingen + + Connectie + Verbinden + Bewerken + Verwijderen + + Toetsenbord + Functietoetsen + Touch Pointer + home + Verbinding verbreken + + Handmatige connecties + Actieve sessies + + Verbinden met computer + + Login + Geen servers + Verbinden ... + Verbinding verbreken ... + Connectie verloren + Ongeldig wachtwoord + Ongeldige gebruikersnaam + Connectie toevoegen + + Host + Label + Host + Poort + Inloggegevens + Inloggegevens + Gebruikersnaam + Wachtwoord + Domein + Instellingen + Scherm + Scherminstellingen + Kleuren + + Hoge kleuren (16 Bit) + Ware kleuren (24 Bit) + Hoogste kwaliteit (32 Bit) + + + 16 + 24 + 32 + + Resolutie + Automatisch + Aangepast + + Automatisch + Aangepast + 640x480 + 720x480 + 800x600 + 1024x768 + 1280x1024 + 1440x900 + 1920x1080 + 1920x1200 + + + Automatisch + Aangepast + 640x480 + 720x480 + 800x600 + 1024x768 + 1280x1024 + 1440x900 + 1920x1080 + 1920x1200 + + Breedte + Hoogte + Prestatie + Prestatieinstellingen + RemoteFX + Bureaublad achtergrond + Lettertype Smoothing + Bureaublad compositie + Inhoud van het venster weergeven tijdens slepen + Menu animatie + Visuele stijlen + Geavanceerd + Geavanceerde instellingen + 3G Instellingen + 3G Scherm + 3G Prestatie + Beveiliging + + Automatisch + RDP + TLS + NLA + + + 0 + 1 + 2 + 3 + + Extern programma + Werkmap + Console modus + + ******* + Niet ingesteld + Gebruikersinterface + Verberg statusbalk + Verberg Zoom Controls + Wissel muisknoppen + Scrollen omkeren + Touch Pointer Auto Scroll + Toon dialoog bij sluiten + Energiebesparing + Sluit inactieve ingen + Beveiliging + Accepteer alle certificaten + Certificaat cache opschonen + na %1$d minuten + Uitgeschakeld + + Connectie instellingen + Instellingen + aFreeRDP - FreeRDP voor Android + RDP verbinding + Help + Over + + Annuleren zonder opslaan? + Druk op "Annuleren" om af te breken!\nKlik op "Doorgaan" om de verplichte velden op te geven! + Fout bij het verbinden met de server! + + De scherm instellingen zijn veranderd omdat de server de door u opgegeven instellingen niet ondersteunt! + Certificaat cache is verwijderd! + Fout bij het verwijderderen van certificaat cache! + + Controleer certificaat + De identiteit van de externe computer niet kan worden geverifieerd. Wilt u toch verbinden? + Vul uw gegevens in + Snelkoppeling maken + Snelkoppeling naam: + Verbinden ... + Aanmelden ... + Over aFreeRDP + Versie: %1$s\n\u00A9 2012 Thinstuff Technologies GmbH + Connectie instellingen opslaan? + Uw connectie instellingen zijn niet opgeslagen! Wilt u deze opslaan? + Verbinding opslaan? + Wilt u alle wijzigingen opslaan? + Niet opnieuw vragen + Toepassing sluiten? + Weet u zeker dat u de applicatie wilt sluiten? + Verwijder certificaten? + Weet u zeker dat u al uw cache certificaten wilt verwijderen? + 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..004a716e7 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; @@ -464,6 +526,7 @@ public class BookmarkActivity extends PreferenceActivity implements OnSharedPref private void finishAndResetBookmark() { bookmark = null; + getPreferenceManager().getSharedPreferences().unregisterOnSharedPreferenceChangeListener(this); finish(); } @@ -474,6 +537,7 @@ public class BookmarkActivity extends PreferenceActivity implements OnSharedPref if (current_preferences != PREFERENCES_BOOKMARK) { super.onBackPressed(); + getPreferenceManager().getSharedPreferences().unregisterOnSharedPreferenceChangeListener(this); return; } 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"))); + } } diff --git a/client/X11/xf_interface.c b/client/X11/xf_interface.c index ce4c26d01..1ffa502ba 100644 --- a/client/X11/xf_interface.c +++ b/client/X11/xf_interface.c @@ -1195,7 +1195,6 @@ void* xf_thread(void* param) exit_code = XF_EXIT_CONN_FAILED; ExitThread(exit_code); } - channels = instance->context->channels; settings = instance->context->settings; @@ -1224,6 +1223,11 @@ void* xf_thread(void* param) rcount = 0; wcount = 0; + if (freerdp_focus_required(instance)) + { + xf_kbd_focus_in(xfi); + } + if (!async_transport) { if (freerdp_get_fds(instance, rfds, &rcount, wfds, &wcount) != TRUE) diff --git a/client/X11/xf_keyboard.c b/client/X11/xf_keyboard.c index 73ae107da..a7ff67ce0 100644 --- a/client/X11/xf_keyboard.c +++ b/client/X11/xf_keyboard.c @@ -191,15 +191,16 @@ void xf_kbd_focus_in(xfInfo* xfi) { rdpInput* input; UINT32 syncFlags; + int dummy, mouseX, mouseY; + Window wdummy; + UINT32 state = 0; input = xfi->instance->input; - /* on focus in send a tab up like mstsc.exe */ - input->KeyboardEvent(input, KBD_FLAGS_RELEASE, 0x0F); - - /* synchronize toggle keys */ syncFlags = xf_kbd_get_toggle_keys_state(xfi); - input->SynchronizeEvent(input, syncFlags); + XQueryPointer(xfi->display, xfi->window->handle, &wdummy, &wdummy, &mouseX, &mouseY, &dummy, &dummy, &state); + + input->FocusInEvent(input, syncFlags, mouseX, mouseY); } BOOL xf_kbd_handle_special_keys(xfInfo* xfi, KeySym keysym) diff --git a/client/iOS/Controllers/AdvancedBookmarkEditorController.m b/client/iOS/Controllers/AdvancedBookmarkEditorController.m index 17b9750ba..a0357d9e6 100644 --- a/client/iOS/Controllers/AdvancedBookmarkEditorController.m +++ b/client/iOS/Controllers/AdvancedBookmarkEditorController.m @@ -13,6 +13,7 @@ #import "EditorSelectionController.h" #import "ScreenSelectionController.h" #import "PerformanceEditorController.h" +#import "BookmarkGatewaySettingsController.h" @interface AdvancedBookmarkEditorController () @@ -68,7 +69,7 @@ switch (section) { case SECTION_ADVANCED_SETTINGS: // advanced settings - return 7; + return 9; default: break; } @@ -100,23 +101,29 @@ { switch([indexPath row]) { - case 0: // 3G Settings + case 0: // Enable/Disable TSG Settings cellType = TableCellIdentifierYesNo; break; - case 1: // 3G screen/color depth - cellType = TableCellIdentifierSelection; - break; - case 2: // 3G performance settings + case 1: // TS Gateway Settings cellType = TableCellIdentifierSubEditor; break; - case 3: // security mode + case 2: // 3G Settings + cellType = TableCellIdentifierYesNo; + break; + case 3: // 3G screen/color depth cellType = TableCellIdentifierSelection; break; - case 4: // remote program - case 5: // work dir + case 4: // 3G performance settings + cellType = TableCellIdentifierSubEditor; + break; + case 5: // security mode + cellType = TableCellIdentifierSelection; + break; + case 6: // remote program + case 7: // work dir cellType = TableCellIdentifierText; break; - case 6: // console mode + case 8: // console mode cellType = TableCellIdentifierYesNo; break; default: @@ -153,6 +160,24 @@ switch(indexPath.row) { case 0: + { + EditFlagTableViewCell* flagCell = (EditFlagTableViewCell*)cell; + [[flagCell label] setText:NSLocalizedString(@"Enable TS Gateway", @"'Enable TS Gateway': Bookmark enable TSG settings")]; + [[flagCell toggle] setTag:GET_TAG_FROM_PATH(indexPath)]; + [[flagCell toggle] setOn:[_params boolForKey:@"enable_tsg_settings"]]; + [[flagCell toggle] addTarget:self action:@selector(toggleSettingValue:) forControlEvents:UIControlEventValueChanged]; + break; + } + case 1: + { + BOOL enable_tsg_settings = [_params boolForKey:@"enable_tsg_settings"]; + EditSubEditTableViewCell* editCell = (EditSubEditTableViewCell*)cell; + [[editCell label] setText:NSLocalizedString(@"TS Gateway Settings", @"'TS Gateway Settings': Bookmark TS Gateway Settings")]; + [[editCell label] setEnabled:enable_tsg_settings]; + [editCell setSelectionStyle:enable_tsg_settings ? UITableViewCellSelectionStyleBlue : UITableViewCellSelectionStyleNone]; + break; + } + case 2: { EditFlagTableViewCell* flagCell = (EditFlagTableViewCell*)cell; [[flagCell label] setText:NSLocalizedString(@"3G Settings", @"'3G Settings': Bookmark enable 3G settings")]; @@ -161,7 +186,7 @@ [[flagCell toggle] addTarget:self action:@selector(toggleSettingValue:) forControlEvents:UIControlEventValueChanged]; break; } - case 1: + case 3: { EditSelectionTableViewCell* selCell = (EditSelectionTableViewCell*)cell; [[selCell label] setText:NSLocalizedString(@"3G Screen", @"'3G Screen': Bookmark 3G Screen settings")]; @@ -172,8 +197,8 @@ [[selCell selection] setEnabled:enable_3G_settings]; [selCell setSelectionStyle:enable_3G_settings ? UITableViewCellSelectionStyleBlue : UITableViewCellSelectionStyleNone]; break; - } - case 2: + } + case 4: { EditSubEditTableViewCell* editCell = (EditSubEditTableViewCell*)cell; [[editCell label] setText:NSLocalizedString(@"3G Performance", @"'3G Performance': Bookmark 3G Performance Settings")]; @@ -181,14 +206,14 @@ [editCell setSelectionStyle:enable_3G_settings ? UITableViewCellSelectionStyleBlue : UITableViewCellSelectionStyleNone]; break; } - case 3: + case 5: { EditSelectionTableViewCell* selCell = (EditSelectionTableViewCell*)cell; [[selCell label] setText:NSLocalizedString(@"Security", @"'Security': Bookmark protocl security settings")]; [[selCell selection] setText:ProtocolSecurityDescription([_params intForKey:@"security"])]; break; } - case 4: + case 6: { EditTextTableViewCell* textCell = (EditTextTableViewCell*)cell; [[textCell label] setText:NSLocalizedString(@"Remote Program", @"'Remote Program': Bookmark remote program settings")]; @@ -198,7 +223,7 @@ [self adjustEditTextTableViewCell:textCell]; break; } - case 5: + case 7: { EditTextTableViewCell* textCell = (EditTextTableViewCell*)cell; [[textCell label] setText:NSLocalizedString(@"Working Directory", @"'Working Directory': Bookmark working directory settings")]; @@ -208,7 +233,7 @@ [self adjustEditTextTableViewCell:textCell]; break; } - case 6: + case 8: { EditFlagTableViewCell* flagCell = (EditFlagTableViewCell*)cell; [[flagCell label] setText:NSLocalizedString(@"Console Mode", @"'Console Mode': Bookmark console mode settings")]; @@ -233,14 +258,18 @@ switch ([indexPath row]) { case 1: + if ([_params boolForKey:@"enable_tsg_settings"]) + viewCtrl = [[[BookmarkGatewaySettingsController alloc] initWithBookmark:_bookmark] autorelease]; + break; + case 3: if ([_params boolForKey:@"enable_3g_settings"]) viewCtrl = [[[ScreenSelectionController alloc] initWithConnectionParams:_params keyPath:@"settings_3g"] autorelease]; break; - case 2: + case 4: if ([_params boolForKey:@"enable_3g_settings"]) viewCtrl = [[[PerformanceEditorController alloc] initWithConnectionParams:_params keyPath:@"settings_3g"] autorelease]; break; - case 3: + case 5: viewCtrl = [[[EditorSelectionController alloc] initWithConnectionParams:_params entries:[NSArray arrayWithObject:@"security"] selections:[NSArray arrayWithObject:SelectionForSecuritySetting()]] autorelease]; break; default: @@ -267,13 +296,13 @@ switch(textField.tag) { // update remote program/work dir settings - case GET_TAG(SECTION_ADVANCED_SETTINGS, 4): + case GET_TAG(SECTION_ADVANCED_SETTINGS, 6): { [_params setValue:[textField text] forKey:@"remote_program"]; break; } - case GET_TAG(SECTION_ADVANCED_SETTINGS, 5): + case GET_TAG(SECTION_ADVANCED_SETTINGS, 7): { [_params setValue:[textField text] forKey:@"working_dir"]; break; @@ -293,12 +322,22 @@ switch(valueSwitch.tag) { case GET_TAG(SECTION_ADVANCED_SETTINGS, 0): - [_params setBool:[valueSwitch isOn] forKey:@"enable_3g_settings"]; + { + [_params setBool:[valueSwitch isOn] forKey:@"enable_tsg_settings"]; NSArray* indexPaths = [NSArray arrayWithObjects:[NSIndexPath indexPathForRow:1 inSection:SECTION_ADVANCED_SETTINGS], [NSIndexPath indexPathForRow:2 inSection:SECTION_ADVANCED_SETTINGS], nil]; [[self tableView] reloadRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationNone]; break; + } + + case GET_TAG(SECTION_ADVANCED_SETTINGS, 2): + { + [_params setBool:[valueSwitch isOn] forKey:@"enable_3g_settings"]; + NSArray* indexPaths = [NSArray arrayWithObjects:[NSIndexPath indexPathForRow:3 inSection:SECTION_ADVANCED_SETTINGS], [NSIndexPath indexPathForRow:2 inSection:SECTION_ADVANCED_SETTINGS], nil]; + [[self tableView] reloadRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationNone]; + break; + } - case GET_TAG(SECTION_ADVANCED_SETTINGS, 6): + case GET_TAG(SECTION_ADVANCED_SETTINGS, 8): [_params setBool:[valueSwitch isOn] forKey:@"console"]; break; diff --git a/client/iOS/Controllers/BookmarkGatewaySettingsController.h b/client/iOS/Controllers/BookmarkGatewaySettingsController.h new file mode 100644 index 000000000..e2c8d5c01 --- /dev/null +++ b/client/iOS/Controllers/BookmarkGatewaySettingsController.h @@ -0,0 +1,25 @@ +/* + Controller to edit ts gateway bookmark settings + + Copyright 2013 Thinstuff Technologies GmbH, Author: Martin Fleisz + + This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. + If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#import "EditorBaseController.h" + +@class ComputerBookmark; +@class ConnectionParams; + +@interface BookmarkGatewaySettingsController : EditorBaseController +{ +@private + ComputerBookmark* _bookmark; + ConnectionParams* _params; +} + +// init for the given bookmark +- (id)initWithBookmark:(ComputerBookmark*)bookmark; + +@end diff --git a/client/iOS/Controllers/BookmarkGatewaySettingsController.m b/client/iOS/Controllers/BookmarkGatewaySettingsController.m new file mode 100644 index 000000000..586ead7c2 --- /dev/null +++ b/client/iOS/Controllers/BookmarkGatewaySettingsController.m @@ -0,0 +1,236 @@ +// +// BookmarkGatewaySettingsController.m +// FreeRDP +// +// Created by Thinstuff Developer on 4/30/13. +// +// + +#import "BookmarkGatewaySettingsController.h" +#import "Bookmark.h" +#import "Utils.h" +#import "EditorSelectionController.h" + +#define SECTION_TSGATEWAY_SETTINGS 0 +#define SECTION_COUNT 1 + +@interface BookmarkGatewaySettingsController () + +@end + +@implementation BookmarkGatewaySettingsController + +- (id)initWithBookmark:(ComputerBookmark*)bookmark +{ + if ((self = [super initWithStyle:UITableViewStyleGrouped])) + { + // set additional settings state according to bookmark data + _bookmark = [bookmark retain]; + _params = [bookmark params]; + } + return self; +} + +- (void)viewDidLoad +{ + [super viewDidLoad]; + [self setTitle:NSLocalizedString(@"TS Gateway Settings", @"TS Gateway Settings title")]; +} + +- (void)viewWillAppear:(BOOL)animated +{ + [super viewWillAppear:animated]; + + // we need to reload the table view data here to have up-to-date data for the + // advanced settings accessory items (like for resolution/color mode settings) + [[self tableView] reloadData]; +} + +- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation +{ + return YES; +} + +- (void)dealloc +{ + [super dealloc]; + [_bookmark release]; +} + +#pragma mark - Table view data source + +- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView +{ + // Return the number of sections. + return SECTION_COUNT; +} + +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section +{ + // Return the number of rows in the section. + switch (section) + { + case SECTION_TSGATEWAY_SETTINGS: // ts gateway settings + return 5; + default: + break; + } + + return 0; +} + +// set section headers +- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section +{ + switch(section) + { + case SECTION_TSGATEWAY_SETTINGS: + return NSLocalizedString(@"TS Gateway", @"'TS Gateway': ts gateway settings header"); + } + return @"unknown"; +} + +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath +{ + // determine the required cell type + NSString* cellType = nil; + switch([indexPath section]) + { + case SECTION_TSGATEWAY_SETTINGS: // advanced settings + { + switch([indexPath row]) + { + case 0: // hostname + case 1: // port + case 2: // username + case 4: // domain + cellType = TableCellIdentifierText; + break; + case 3: // password + cellType = TableCellIdentifierSecretText; + break; + default: + break; + } + break; + } + } + NSAssert(cellType != nil, @"Couldn't determine cell type"); + + // get the table view cell + UITableViewCell *cell = [self tableViewCellFromIdentifier:cellType]; + NSAssert(cell, @"Invalid cell"); + + // set cell values + switch([indexPath section]) + { + // advanced settings + case SECTION_TSGATEWAY_SETTINGS: + [self initGatewaySettings:indexPath cell:cell]; + break; + + default: + break; + } + + return cell; +} + +// updates server settings in the UI +- (void)initGatewaySettings:(NSIndexPath*)indexPath cell:(UITableViewCell*)cell +{ + EditTextTableViewCell* textCell = (EditTextTableViewCell*)cell; + [[textCell textfield] setTag:GET_TAG_FROM_PATH(indexPath)]; + switch([indexPath row]) + { + case 0: + { + [[textCell label] setText:NSLocalizedString(@"Host", @"'Host': Bookmark hostname")]; + [[textCell textfield] setText:[_params StringForKey:@"tsg_hostname"]]; + [[textCell textfield] setPlaceholder:NSLocalizedString(@"not set", @"not set placeholder")]; + break; + } + case 1: + { + int port = [_params intForKey:@"tsg_port"]; + if (port == 0) port = 443; + [[textCell label] setText:NSLocalizedString(@"Port", @"'Port': Bookmark port")]; + [[textCell textfield] setText:[NSString stringWithFormat:@"%d", port]]; + [[textCell textfield] setKeyboardType:UIKeyboardTypeNumberPad]; + break; + } + case 2: + { + [[textCell textfield] setTag:GET_TAG_FROM_PATH(indexPath)]; + [[textCell label] setText:NSLocalizedString(@"Username", @"'Username': Bookmark username")]; + [[textCell textfield] setText:[_params StringForKey:@"tsg_username"]]; + [[textCell textfield] setPlaceholder:NSLocalizedString(@"not set", @"not set placeholder")]; + break; + } + case 3: + { + [[textCell textfield] setTag:GET_TAG_FROM_PATH(indexPath)]; + [[textCell label] setText:NSLocalizedString(@"Password", @"'Password': Bookmark password")]; + [[textCell textfield] setText:[_params StringForKey:@"tsg_password"]]; + [[textCell textfield] setPlaceholder:NSLocalizedString(@"not set", @"not set placeholder")]; + break; + } + case 4: + { + [[textCell textfield] setTag:GET_TAG_FROM_PATH(indexPath)]; + [[textCell label] setText:NSLocalizedString(@"Domain", @"'Domain': Bookmark domain")]; + [[textCell textfield] setText:[_params StringForKey:@"tsg_domain"]]; + [[textCell textfield] setPlaceholder:NSLocalizedString(@"not set", @"not set placeholder")]; + break; + } + default: + NSLog(@"Invalid row index in settings table!"); + break; + } + + [self adjustEditTextTableViewCell:textCell]; +} + + +#pragma mark - +#pragma mark Text Field delegate + +- (BOOL)textFieldShouldReturn:(UITextField*)textField +{ + [textField resignFirstResponder]; + return NO; +} + +- (BOOL)textFieldShouldEndEditing:(UITextField *)textField +{ + switch(textField.tag) + { + // update server settings + case GET_TAG(SECTION_TSGATEWAY_SETTINGS, 0): + [_params setValue:[textField text] forKey:@"tsg_hostname"]; + break; + + case GET_TAG(SECTION_TSGATEWAY_SETTINGS, 1): + [_params setInt:[[textField text] intValue] forKey:@"tsg_port"]; + break; + + case GET_TAG(SECTION_TSGATEWAY_SETTINGS, 2): + [_params setValue:[textField text] forKey:@"tsg_username"]; + break; + + case GET_TAG(SECTION_TSGATEWAY_SETTINGS, 3): + [_params setValue:[textField text] forKey:@"tsg_password"]; + break; + + case GET_TAG(SECTION_TSGATEWAY_SETTINGS, 4): + [_params setValue:[textField text] forKey:@"tsg_domain"]; + break; + + default: + break; + } + return YES; +} + + +@end diff --git a/client/iOS/Controllers/CredentialsEditorController.m b/client/iOS/Controllers/CredentialsEditorController.m index 21e328ad5..a029ad3b6 100644 --- a/client/iOS/Controllers/CredentialsEditorController.m +++ b/client/iOS/Controllers/CredentialsEditorController.m @@ -56,6 +56,12 @@ return YES; } +- (void)dealloc +{ + [super dealloc]; + [_bookmark release]; +} + #pragma mark - #pragma mark Table view data source diff --git a/client/iOS/Controllers/EncryptionController.m b/client/iOS/Controllers/EncryptionController.m index 089e87a44..0f1ae7987 100644 --- a/client/iOS/Controllers/EncryptionController.m +++ b/client/iOS/Controllers/EncryptionController.m @@ -9,6 +9,7 @@ #import "EncryptionController.h" #import "SFHFKeychainUtils.h" +#import "TSXAdditions.h" @interface EncryptionController (Private) @@ -109,7 +110,14 @@ static EncryptionController* _shared_encryption_controller = nil; - (NSString*)keychainDefaultPassword { - return [[UIDevice currentDevice] uniqueIdentifier]; + NSString* password = [[NSUserDefaults standardUserDefaults] stringForKey:@"UUID"]; + if ([password length] == 0) + { + password = [NSString stringWithUUID]; + [[NSUserDefaults standardUserDefaults] setObject:password forKey:@"UUID"]; + [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"TSXMasterPasswordVerification"]; + } + return password; } #pragma mark - diff --git a/client/iOS/Controllers/PerformanceEditorController.m b/client/iOS/Controllers/PerformanceEditorController.m index 104b13c13..2e1d4e0eb 100644 --- a/client/iOS/Controllers/PerformanceEditorController.m +++ b/client/iOS/Controllers/PerformanceEditorController.m @@ -56,6 +56,12 @@ return key; } +- (void)dealloc +{ + [super dealloc]; + [_params release]; +} + #pragma mark - #pragma mark Table view data source diff --git a/client/iOS/Defaults.plist b/client/iOS/Defaults.plist index a60e3be19..801082384 100644 --- a/client/iOS/Defaults.plist +++ b/client/iOS/Defaults.plist @@ -65,6 +65,18 @@ console + enable_tsg_settings + + tsg_hostname + + tsg_port + 443 + tsg_username + + tsg_password + + tsg_domain + ui.auto_scroll_touchpointer diff --git a/client/iOS/Models/ConnectionParams.m b/client/iOS/Models/ConnectionParams.m index 030216af7..3d1a8605a 100644 --- a/client/iOS/Models/ConnectionParams.m +++ b/client/iOS/Models/ConnectionParams.m @@ -28,16 +28,21 @@ _connection_params = [dict mutableDeepCopy]; - if ([[_connection_params objectForKey:@"password"] isKindOfClass:[NSData class]]) - { - NSString* plaintext_password = [[[EncryptionController sharedEncryptionController] decryptor] decryptString:[_connection_params objectForKey:@"password"]]; - - [self setValue:plaintext_password forKey:@"password"]; - } + [self decryptPasswordForKey:@"password"]; + [self decryptPasswordForKey:@"tsg_password"]; return self; } +- (void)decryptPasswordForKey:(NSString*)key +{ + if ([[_connection_params objectForKey:key] isKindOfClass:[NSData class]]) + { + NSString* plaintext_password = [[[EncryptionController sharedEncryptionController] decryptor] decryptString:[_connection_params objectForKey:key]]; + [self setValue:plaintext_password forKey:key]; + } +} + - (id)initWithBaseDefaultParameters { return [self initWithDictionary:[[NSUserDefaults standardUserDefaults] dictionaryForKey:@"TSXDefaultComputerBookmarkSettings"]]; @@ -89,19 +94,23 @@ [serializable_params setObject:[_connection_params objectForKey:k] forKey:k]; if ([serializable_params objectForKey:@"password"] != nil) - { - NSData* encrypted_password = [[[EncryptionController sharedEncryptionController] encryptor] encryptString:[serializable_params objectForKey:@"password"]]; - - if (encrypted_password) - [serializable_params setObject:encrypted_password forKey:@"password"]; - else - [serializable_params removeObjectForKey:@"password"]; - } + [self serializeDecryptedForKey:@"password" forParams:serializable_params]; + if ([serializable_params objectForKey:@"tsg_password"] != nil) + [self serializeDecryptedForKey:@"tsg_password" forParams:serializable_params]; [coder encodeObject:serializable_params forKey:@"connectionParams"]; [serializable_params release]; } +- (void)serializeDecryptedForKey:(NSString*)key forParams:(NSMutableDictionary*)params +{ + NSData* encrypted_password = [[[EncryptionController sharedEncryptionController] encryptor] encryptString:[params objectForKey:key]]; + + if (encrypted_password) + [params setObject:encrypted_password forKey:key]; + else + [params removeObjectForKey:key]; +} #pragma mark - #pragma mark NSKeyValueCoding diff --git a/client/iOS/Models/RDPSession.m b/client/iOS/Models/RDPSession.m index 6144637d1..d43f27959 100644 --- a/client/iOS/Models/RDPSession.m +++ b/client/iOS/Models/RDPSession.m @@ -164,6 +164,18 @@ NSString* TSXSessionDidFailToConnectNotification = @"TSXSessionDidFailToConnect" break; } + // ts gateway settings + if ([_params boolForKey:@"enable_tsg_settings"]) + { + settings->GatewayHostname = strdup([_params UTF8StringForKey:@"tsg_hostname"]); + settings->GatewayPort = [_params intForKey:@"tsg_port"]; + settings->GatewayUsername = strdup([_params UTF8StringForKey:@"tsg_username"]); + settings->GatewayPassword = strdup([_params UTF8StringForKey:@"tsg_password"]); + settings->GatewayDomain = strdup([_params UTF8StringForKey:@"tsg_domain"]); + settings->GatewayUsageMethod = TRUE; + settings->GatewayUseSameCredentials = FALSE; + } + // Remote keyboard layout settings->KeyboardLayout = 0x409; diff --git a/docs/README.ios b/docs/README.ios index 38f6a24a7..ad7a045be 100644 --- a/docs/README.ios +++ b/docs/README.ios @@ -52,6 +52,14 @@ If you want to specify an output directory add CONFIGURATION_BUILD_DIR=finalize_sc_pdus |= FINALIZE_SC_CONTROL_GRANTED_PDU; + rdp->resendFocus = TRUE; break; } diff --git a/libfreerdp/core/capabilities.c b/libfreerdp/core/capabilities.c index 2ddacd9f8..011dafa5e 100644 --- a/libfreerdp/core/capabilities.c +++ b/libfreerdp/core/capabilities.c @@ -2197,9 +2197,6 @@ BOOL rdp_read_multifragment_update_capability_set(wStream* s, UINT16 length, rdp stream_read_UINT32(s, multifragMaxRequestSize); /* MaxRequestSize (4 bytes) */ - if (settings->MultifragMaxRequestSize < multifragMaxRequestSize) - settings->MultifragMaxRequestSize = multifragMaxRequestSize; - return TRUE; } diff --git a/libfreerdp/core/fastpath.c b/libfreerdp/core/fastpath.c index f8f92cde0..a02e8d9f1 100644 --- a/libfreerdp/core/fastpath.c +++ b/libfreerdp/core/fastpath.c @@ -244,6 +244,7 @@ static int fastpath_recv_update(rdpFastPath* fastpath, BYTE updateCode, UINT32 s case FASTPATH_UPDATETYPE_PTR_DEFAULT: update->pointer->pointer_system.type = SYSPTR_DEFAULT; IFCALL(pointer->PointerSystem, context, &pointer->pointer_system); + break; case FASTPATH_UPDATETYPE_PTR_POSITION: @@ -666,7 +667,7 @@ static UINT32 fastpath_get_sec_bytes(rdpRdp* rdp) return sec_bytes; } -wStream* fastpath_input_pdu_init(rdpFastPath* fastpath, BYTE eventFlags, BYTE eventCode) +wStream* fastpath_input_pdu_init_header(rdpFastPath* fastpath) { rdpRdp *rdp; wStream* s; @@ -686,12 +687,24 @@ wStream* fastpath_input_pdu_init(rdpFastPath* fastpath, BYTE eventFlags, BYTE ev } Stream_Seek(s, fastpath_get_sec_bytes(rdp)); + + return s; +} + +wStream* fastpath_input_pdu_init(rdpFastPath* fastpath, BYTE eventFlags, BYTE eventCode) +{ + rdpRdp *rdp; + wStream* s; + + rdp = fastpath->rdp; + + s = fastpath_input_pdu_init_header(fastpath); stream_write_BYTE(s, eventFlags | (eventCode << 5)); /* eventHeader (1 byte) */ return s; } -BOOL fastpath_send_input_pdu(rdpFastPath* fastpath, wStream* s) +BOOL fastpath_send_multiple_input_pdu(rdpFastPath* fastpath, wStream* s, int iNumEvents) { rdpRdp *rdp; UINT16 length; @@ -709,8 +722,12 @@ BOOL fastpath_send_input_pdu(rdpFastPath* fastpath, wStream* s) } eventHeader = FASTPATH_INPUT_ACTION_FASTPATH; +<<<<<<< HEAD eventHeader |= (1 << 2); /* numberEvents */ +======= + eventHeader |= (iNumEvents << 2); /* numberEvents */ +>>>>>>> f1672948ff0b5f6a9d3cda658a18104df3c3d1e4 if (rdp->sec_flags & SEC_ENCRYPT) eventHeader |= (FASTPATH_INPUT_ENCRYPTED << 6); if (rdp->sec_flags & SEC_SECURE_CHECKSUM) @@ -754,6 +771,11 @@ BOOL fastpath_send_input_pdu(rdpFastPath* fastpath, wStream* s) return TRUE; } +BOOL fastpath_send_input_pdu(rdpFastPath* fastpath, wStream* s) +{ + return fastpath_send_multiple_input_pdu(fastpath, s, 1); +} + wStream* fastpath_update_pdu_init(rdpFastPath* fastpath) { wStream* s; diff --git a/libfreerdp/core/fastpath.h b/libfreerdp/core/fastpath.h index 4603fc42c..3207576da 100644 --- a/libfreerdp/core/fastpath.h +++ b/libfreerdp/core/fastpath.h @@ -110,7 +110,9 @@ BOOL fastpath_read_header_rdp(rdpFastPath* fastpath, wStream* s, UINT16 *length) int fastpath_recv_updates(rdpFastPath* fastpath, wStream* s); int fastpath_recv_inputs(rdpFastPath* fastpath, wStream* s); +wStream* fastpath_input_pdu_init_header(rdpFastPath* fastpath); wStream* fastpath_input_pdu_init(rdpFastPath* fastpath, BYTE eventFlags, BYTE eventCode); +BOOL fastpath_send_multiple_input_pdu(rdpFastPath* fastpath, wStream* s, int iEventCount); BOOL fastpath_send_input_pdu(rdpFastPath* fastpath, wStream* s); wStream* fastpath_update_pdu_init(rdpFastPath* fastpath); diff --git a/libfreerdp/core/freerdp.c b/libfreerdp/core/freerdp.c index 68b4c9569..f0394c2da 100644 --- a/libfreerdp/core/freerdp.c +++ b/libfreerdp/core/freerdp.c @@ -275,6 +275,22 @@ BOOL freerdp_shall_disconnect(freerdp* instance) return instance->context->rdp->disconnect; } +FREERDP_API BOOL freerdp_focus_required(freerdp* instance) +{ + rdpRdp* rdp; + BOOL bRetCode = FALSE; + + rdp = instance->context->rdp; + + if (rdp->resendFocus) + { + bRetCode = TRUE; + rdp->resendFocus = FALSE; + } + + return bRetCode; +} + void freerdp_get_version(int* major, int* minor, int* revision) { if (major != NULL) diff --git a/libfreerdp/core/gateway/tsg.h b/libfreerdp/core/gateway/tsg.h index 40ba028a1..23b10155b 100644 --- a/libfreerdp/core/gateway/tsg.h +++ b/libfreerdp/core/gateway/tsg.h @@ -61,8 +61,8 @@ struct rdp_tsg LPWSTR MachineName; TSG_STATE state; BOOL PendingPdu; - BOOL BytesRead; - BOOL BytesAvailable; + UINT32 BytesRead; + UINT32 BytesAvailable; UINT32 StubOffset; UINT32 StubLength; rdpSettings* settings; diff --git a/libfreerdp/core/input.c b/libfreerdp/core/input.c index 143e6535e..0f7d5edaf 100644 --- a/libfreerdp/core/input.c +++ b/libfreerdp/core/input.c @@ -151,6 +151,21 @@ void input_send_extended_mouse_event(rdpInput* input, UINT16 flags, UINT16 x, UI rdp_send_client_input_pdu(rdp, s); } +void input_send_focus_in_event(rdpInput* input, UINT16 toggleStates, UINT16 x, UINT16 y) +{ + /* send a tab up like mstsc.exe */ + input_send_keyboard_event(input, KBD_FLAGS_RELEASE, 0x0f); + + /* send the toggle key states */ + input_send_synchronize_event(input, (toggleStates & 0x1F)); + + /* send another tab up like mstsc.exe */ + input_send_keyboard_event(input, KBD_FLAGS_RELEASE, 0x0f); + + /* finish with a mouse pointer position like mstsc.exe */ + input_send_extended_mouse_event(input, PTR_FLAGS_MOVE, x, y); +} + void input_send_fastpath_synchronize_event(rdpInput* input, UINT32 flags) { wStream* s; @@ -206,6 +221,35 @@ void input_send_fastpath_extended_mouse_event(rdpInput* input, UINT16 flags, UIN fastpath_send_input_pdu(rdp->fastpath, s); } +void input_send_fastpath_focus_in_event(rdpInput* input, UINT16 toggleStates, UINT16 x, UINT16 y) +{ + wStream* s; + rdpRdp* rdp = input->context->rdp; + BYTE eventFlags = 0; + + s = fastpath_input_pdu_init_header(rdp->fastpath); + /* send a tab up like mstsc.exe */ + eventFlags = FASTPATH_INPUT_KBDFLAGS_RELEASE | FASTPATH_INPUT_EVENT_SCANCODE << 5; + stream_write_BYTE(s, eventFlags); /* Key Release event (1 byte) */ + stream_write_BYTE(s, 0x0f); /* keyCode (1 byte) */ + + /* send the toggle key states */ + eventFlags = (toggleStates & 0x1F) | FASTPATH_INPUT_EVENT_SYNC << 5; + stream_write_BYTE(s, eventFlags); /* toggle state (1 byte) */ + + /* send another tab up like mstsc.exe */ + eventFlags = FASTPATH_INPUT_KBDFLAGS_RELEASE | FASTPATH_INPUT_EVENT_SCANCODE << 5; + stream_write_BYTE(s, eventFlags); /* Key Release event (1 byte) */ + stream_write_BYTE(s, 0x0f); /* keyCode (1 byte) */ + + /* finish with a mouse pointer position like mstsc.exe */ + eventFlags = 0 | FASTPATH_INPUT_EVENT_MOUSE << 5; + stream_write_BYTE(s, eventFlags); /* Mouse Pointer event (1 byte) */ + input_write_extended_mouse_event(s, PTR_FLAGS_MOVE, x, y); + + fastpath_send_multiple_input_pdu(rdp->fastpath, s, 4); +} + static BOOL input_recv_sync_event(rdpInput* input, wStream* s) { UINT32 toggleFlags; @@ -379,6 +423,7 @@ void input_register_client_callbacks(rdpInput* input) input->UnicodeKeyboardEvent = input_send_fastpath_unicode_keyboard_event; input->MouseEvent = input_send_fastpath_mouse_event; input->ExtendedMouseEvent = input_send_fastpath_extended_mouse_event; + input->FocusInEvent = input_send_fastpath_focus_in_event; } else { @@ -387,6 +432,7 @@ void input_register_client_callbacks(rdpInput* input) input->UnicodeKeyboardEvent = input_send_unicode_keyboard_event; input->MouseEvent = input_send_mouse_event; input->ExtendedMouseEvent = input_send_extended_mouse_event; + input->FocusInEvent = input_send_focus_in_event; } input->asynchronous = settings->AsyncInput; @@ -430,6 +476,11 @@ void freerdp_input_send_extended_mouse_event(rdpInput* input, UINT16 flags, UINT IFCALL(input->ExtendedMouseEvent, input, flags, x, y); } +void freerdp_input_send_focus_in_event(rdpInput* input, UINT16 toggleStates, UINT16 x, UINT16 y) +{ + IFCALL(input->FocusInEvent, input, toggleStates, x, y); +} + int input_process_events(rdpInput* input) { return input_message_queue_process_pending_messages(input); diff --git a/libfreerdp/core/rdp.h b/libfreerdp/core/rdp.h index ef1668515..b71413f55 100644 --- a/libfreerdp/core/rdp.h +++ b/libfreerdp/core/rdp.h @@ -156,6 +156,7 @@ struct rdp_rdp UINT32 errorInfo; UINT32 finalize_sc_pdus; BOOL disconnect; + BOOL resendFocus; }; BOOL rdp_read_security_header(wStream* s, UINT16* flags); diff --git a/libfreerdp/core/settings.c b/libfreerdp/core/settings.c index 8f22cc336..0807b5f67 100644 --- a/libfreerdp/core/settings.c +++ b/libfreerdp/core/settings.c @@ -377,7 +377,7 @@ rdpSettings* freerdp_settings_new(void* instance) settings->VirtualChannelChunkSize = CHANNEL_CHUNK_LENGTH; - settings->MultifragMaxRequestSize = 0x200000; + settings->MultifragMaxRequestSize = 0xFFFF; settings->GatewayUseSameCredentials = TRUE;