Skip to content

Commit

Permalink
Merge pull request FreeRDP#1222 from mfleisz/andrtsg
Browse files Browse the repository at this point in the history
Android: Added support for TS Gateway
  • Loading branch information
Martin Fleisz committed Apr 30, 2013
2 parents 9064541 + e585fd9 commit ea443ac
Show file tree
Hide file tree
Showing 15 changed files with 333 additions and 10 deletions.
2 changes: 1 addition & 1 deletion client/Android/FreeRDPCore/jni/android_cliprdr.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
33 changes: 32 additions & 1 deletion client/Android/FreeRDPCore/jni/android_freerdp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(
Expand Down
1 change: 1 addition & 0 deletions client/Android/FreeRDPCore/jni/android_freerdp.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions client/Android/FreeRDPCore/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@
<string name="settings_enable_3g_settings">Configuracion 3G</string>
<string name="settings_screen_3g">Pantalla 3G</string>
<string name="settings_performance_3g">Rendimiento 3G</string>
<string name="settings_cat_gateway">Gateway</string>
<string name="settings_enable_gateway_settings">Enable Gateway</string>
<string name="settings_gateway_settings">Gateway Settings</string>
<string name="settings_redirect_sdcard">Redirect SDCard</string>
<string name="settings_security">Seguridad</string>
<string-array name="security_array">
Expand Down
3 changes: 3 additions & 0 deletions client/Android/FreeRDPCore/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@
<string name="settings_enable_3g_settings">"Paramètres 3G"</string>
<string name="settings_screen_3g">"Écran 3G"</string>
<string name="settings_performance_3g">"Performance 3G"</string>
<string name="settings_cat_gateway">Gateway</string>
<string name="settings_enable_gateway_settings">Enable Gateway</string>
<string name="settings_gateway_settings">Gateway Settings</string>
<string name="settings_redirect_sdcard">"Redirect SDCard"</string>
<string name="settings_security">"Securité"</string>
<string-array name="security_array">
Expand Down
3 changes: 3 additions & 0 deletions client/Android/FreeRDPCore/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@
<string name="settings_enable_3g_settings">3G Settings</string>
<string name="settings_screen_3g">3G Screen</string>
<string name="settings_performance_3g">3G Performance</string>
<string name="settings_cat_gateway">Gateway</string>
<string name="settings_enable_gateway_settings">Enable Gateway</string>
<string name="settings_gateway_settings">Gateway Settings</string>
<string name="settings_redirect_sdcard">Redirect SDCard</string>
<string name="settings_security">Security</string>
<string-array name="security_array">
Expand Down
11 changes: 9 additions & 2 deletions client/Android/FreeRDPCore/res/xml/advanced_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,15 @@
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
<PreferenceCategory android:title="Advanced">

<CheckBoxPreference android:key="bookmark.enable_3g_settings" android:title="@string/settings_enable_3g_settings" />

<CheckBoxPreference android:key="bookmark.enable_gateway_settings" android:title="@string/settings_enable_gateway_settings" />
<PreferenceScreen android:key="bookmark.gateway_settings" android:title="@string/settings_gateway_settings">
<intent android:action="android.intent.action.VIEW"
android:targetPackage="*"
android:targetClass="com.freerdp.freerdpcore.presentation.BookmarkActivity"
android:data="preferences://gateway_settings" />
</PreferenceScreen>

<CheckBoxPreference android:key="bookmark.enable_3g_settings" android:title="@string/settings_enable_3g_settings" />
<PreferenceScreen android:key="bookmark.screen_3g" android:title="@string/settings_screen_3g">
<intent android:action="android.intent.action.VIEW"
android:targetPackage="*"
Expand Down
20 changes: 20 additions & 0 deletions client/Android/FreeRDPCore/res/xml/gateway_settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
Credential Settings Layout
Copyright 2013 Felix Long
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/.
*/
-->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" xmlns:freerdp="http://schemas.android.com/apk/res-auto">
<PreferenceCategory android:title="@string/settings_cat_gateway">
<EditTextPreference android:key="bookmark.gateway_hostname" android:title="@string/settings_hostname" android:summary="Name or address of the target computer"/>
<com.freerdp.freerdpcore.utils.IntEditTextPreference android:key="bookmark.gateway_port" android:title="@string/settings_port" android:summary="Gateway Port on the target computer" android:numeric="integer" android:inputType="number" freerdp:bounds_min="10" freerdp:bounds_max="65535" freerdp:bounds_default="443" />
<EditTextPreference android:key="bookmark.gateway_username" android:title="@string/settings_username"/>
<EditTextPreference android:key="bookmark.gateway_password" android:title="@string/settings_password" android:inputType="textPassword" />
<EditTextPreference android:key="bookmark.gateway_domain" android:title="@string/settings_domain" android:summary="Optional"/>
</PreferenceCategory>
</PreferenceScreen>
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,111 @@

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<GatewaySettings> CREATOR = new Parcelable.Creator<GatewaySettings>()
{
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)
Expand All @@ -31,6 +128,9 @@ public ManualBookmark(Parcel parcel)
type = TYPE_MANUAL;
hostname = parcel.readString();
port = parcel.readInt();

enableGatewaySettings = (parcel.readInt() == 1 ? true : false);
gatewaySettings = parcel.readParcelable(GatewaySettings.class.getClassLoader());
}

public ManualBookmark() {
Expand All @@ -53,7 +153,27 @@ public void setPort(int port) {
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<ManualBookmark> CREATOR = new Parcelable.Creator<ManualBookmark>()
{
public ManualBookmark createFromParcel(Parcel in) {
Expand All @@ -77,6 +197,8 @@ public void writeToParcel(Parcel out, int flags)
super.writeToParcel(out, flags);
out.writeString(hostname);
out.writeInt(port);
out.writeInt(enableGatewaySettings ? 1 : 0);
out.writeParcelable(gatewaySettings, flags);
}

@Override
Expand All @@ -87,6 +209,12 @@ public void writeToSharedPreferences(SharedPreferences sharedPrefs)
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();
}

Expand All @@ -97,6 +225,12 @@ public void readFromSharedPreferences(SharedPreferences sharedPrefs)

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
Expand Down
Loading

0 comments on commit ea443ac

Please sign in to comment.