Merge pull request #1533 from akallabeth/android_async

Android async
This commit is contained in:
Marc-André Moreau 2013-10-17 14:32:15 -07:00
commit 7ae818eef8
17 changed files with 539 additions and 152 deletions

View File

@ -3,7 +3,7 @@
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
<classpathentry kind="output" path="bin"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>

View File

@ -3,6 +3,7 @@
Copyright 2010-2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
Copyright 2013 Thinstuff Technologies GmbH, Author: Martin Fleisz
Copyright 2013 Thinstuff Technologies GmbH, Author: Armin Novak
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/.
@ -13,6 +14,7 @@
#endif
#include <assert.h>
#include <jni.h>
#include <stdio.h>
#include <stdlib.h>
@ -35,6 +37,7 @@
#include "android_debug.h"
#include "android_cliprdr.h"
#if defined(WITH_GPROF)
#include "jni/prof.h"
#endif
@ -139,7 +142,9 @@ BOOL android_post_connect(freerdp* instance)
{
DEBUG_ANDROID("android_post_connect");
freerdp_callback("OnSettingsChanged", "(IIII)V", instance, instance->settings->DesktopWidth, instance->settings->DesktopHeight, instance->settings->ColorDepth);
freerdp_callback("OnSettingsChanged", "(IIII)V", instance,
instance->settings->DesktopWidth, instance->settings->DesktopHeight,
instance->settings->ColorDepth);
instance->context->cache = cache_new(instance->settings);
@ -231,7 +236,7 @@ int android_receive_channel_data(freerdp* instance, int channelId, UINT8* data,
return freerdp_channels_data(instance, channelId, data, size, flags, total_size);
}
void android_process_channel_event(rdpChannels* channels, freerdp* instance)
static void android_process_channel_event(rdpChannels* channels, freerdp* instance)
{
wMessage* event;
@ -239,13 +244,15 @@ void android_process_channel_event(rdpChannels* channels, freerdp* instance)
if (event)
{
switch(GetMessageClass(event->id))
int ev = GetMessageClass(event->id);
switch(ev)
{
case CliprdrChannel_Class:
android_process_cliprdr_event(instance, event);
break;
default:
DEBUG_ANDROID("Unsupported channel event %08X", ev);
break;
}
@ -253,13 +260,121 @@ void android_process_channel_event(rdpChannels* channels, freerdp* instance)
}
}
int android_freerdp_run(freerdp* instance)
static void *jni_update_thread(void *arg)
{
int status;
wMessage message;
wMessageQueue* queue;
freerdp* instance = (freerdp*) arg;
assert( NULL != instance);
DEBUG_ANDROID("Start.");
status = 1;
queue = freerdp_get_message_queue(instance, FREERDP_UPDATE_MESSAGE_QUEUE);
while (MessageQueue_Wait(queue))
{
while (MessageQueue_Peek(queue, &message, TRUE))
{
status = freerdp_message_queue_process_message(instance, FREERDP_UPDATE_MESSAGE_QUEUE, &message);
if (!status)
break;
}
if (!status)
break;
}
DEBUG_ANDROID("Quit.");
ExitThread(0);
return NULL;
}
static void* jni_input_thread(void* arg)
{
HANDLE event[3];
wMessageQueue* queue;
freerdp* instance = (freerdp*) arg;
androidContext *aCtx = (androidContext*)instance->context;
assert(NULL != instance);
assert(NULL != aCtx);
DEBUG_ANDROID("Start.");
queue = freerdp_get_message_queue(instance, FREERDP_INPUT_MESSAGE_QUEUE);
event[0] = CreateFileDescriptorEvent(NULL, FALSE, FALSE, aCtx->event_queue->pipe_fd[0]);
event[1] = CreateFileDescriptorEvent(NULL, FALSE, FALSE, aCtx->event_queue->pipe_fd[1]);
event[2] = freerdp_get_message_queue_event_handle(instance, FREERDP_INPUT_MESSAGE_QUEUE);
do
{
DWORD rc = WaitForMultipleObjects(3, event, FALSE, INFINITE);
if (rc == WAIT_OBJECT_0 + 2)
{
wMessage msg;
MessageQueue_Peek(queue, &msg, FALSE);
if (msg.id == WMQ_QUIT)
break;
}
if ((rc < WAIT_OBJECT_0) && (rc > WAIT_OBJECT_0 + 1))
break;
if (android_check_fds(instance) != TRUE)
break;
}
while(1);
DEBUG_ANDROID("Quit.");
MessageQueue_PostQuit(queue, 0);
ExitThread(0);
return NULL;
}
static void* jni_channels_thread(void* arg)
{
int status;
HANDLE event;
rdpChannels* channels;
freerdp* instance = (freerdp*) arg;
assert(NULL != instance);
DEBUG_ANDROID("Start.");
channels = instance->context->channels;
event = freerdp_channels_get_event_handle(instance);
while (WaitForSingleObject(event, INFINITE) == WAIT_OBJECT_0)
{
status = freerdp_channels_process_pending_messages(instance);
if (!status)
break;
android_process_channel_event(channels, instance);
}
DEBUG_ANDROID("Quit.");
ExitThread(0);
return NULL;
}
static int android_freerdp_run(freerdp* instance)
{
int i;
int fds;
int max_fds;
int rcount;
int wcount;
int fd_input_event;
HANDLE input_event;
void* rfds[32];
void* wfds[32];
fd_set rfds_set;
@ -267,7 +382,21 @@ int android_freerdp_run(freerdp* instance)
int select_status;
struct timeval timeout;
assert(instance);
const rdpSettings* settings = instance->context->settings;
HANDLE update_thread;
HANDLE input_thread;
HANDLE channels_thread;
BOOL async_update = settings->AsyncUpdate;
BOOL async_input = settings->AsyncInput;
BOOL async_channels = settings->AsyncChannels;
BOOL async_transport = settings->AsyncTransport;
DEBUG_ANDROID("AsyncUpdate=%d", settings->AsyncUpdate);
DEBUG_ANDROID("AsyncInput=%d", settings->AsyncInput);
DEBUG_ANDROID("AsyncChannels=%d", settings->AsyncChannels);
DEBUG_ANDROID("AsyncTransport=%d", settings->AsyncTransport);
memset(rfds, 0, sizeof(rfds));
memset(wfds, 0, sizeof(wfds));
@ -277,27 +406,62 @@ int android_freerdp_run(freerdp* instance)
freerdp_callback("OnConnectionFailure", "(I)V", instance);
return 0;
}
if (async_update)
{
update_thread = CreateThread(NULL, 0,
(LPTHREAD_START_ROUTINE) jni_update_thread, instance, 0, NULL);
}
if (async_input)
{
input_thread = CreateThread(NULL, 0,
(LPTHREAD_START_ROUTINE) jni_input_thread, instance, 0, NULL);
}
if (async_channels)
{
channels_thread = CreateThread(NULL, 0,
(LPTHREAD_START_ROUTINE) jni_channels_thread, instance, 0, NULL);
}
((androidContext*)instance->context)->is_connected = TRUE;
while (!freerdp_shall_disconnect(instance))
{
rcount = 0;
wcount = 0;
if (freerdp_get_fds(instance, rfds, &rcount, wfds, &wcount) != TRUE)
if (!async_transport)
{
DEBUG_ANDROID("Failed to get FreeRDP file descriptor\n");
break;
if (freerdp_get_fds(instance, rfds, &rcount, wfds, &wcount) != TRUE)
{
DEBUG_ANDROID("Failed to get FreeRDP file descriptor\n");
break;
}
}
if (freerdp_channels_get_fds(instance->context->channels, instance, rfds, &rcount, wfds, &wcount) != TRUE)
if (!async_channels)
{
DEBUG_ANDROID("Failed to get channel manager file descriptor\n");
break;
if (freerdp_channels_get_fds(instance->context->channels, instance, rfds, &rcount, wfds, &wcount) != TRUE)
{
DEBUG_ANDROID("Failed to get channel manager file descriptor\n");
break;
}
}
if (android_get_fds(instance, rfds, &rcount, wfds, &wcount) != TRUE)
if (!async_input)
{
DEBUG_ANDROID("Failed to get android file descriptor\n");
break;
if (android_get_fds(instance, rfds, &rcount, wfds, &wcount) != TRUE)
{
DEBUG_ANDROID("Failed to get android file descriptor\n");
break;
}
}
else
{
input_event = freerdp_get_message_queue_event_handle(instance, FREERDP_INPUT_MESSAGE_QUEUE);
fd_input_event = GetEventFileDescriptor(input_event);
rfds[rcount++] = (void*) (long) fd_input_event;
}
max_fds = 0;
@ -340,33 +504,89 @@ int android_freerdp_run(freerdp* instance)
if (freerdp_shall_disconnect(instance))
break;
if (freerdp_check_fds(instance) != TRUE)
if (!async_transport)
{
DEBUG_ANDROID("Failed to check FreeRDP file descriptor\n");
break;
if (freerdp_check_fds(instance) != TRUE)
{
DEBUG_ANDROID("Failed to check FreeRDP file descriptor\n");
break;
}
}
if (android_check_fds(instance) != TRUE)
if (!async_input)
{
DEBUG_ANDROID("Failed to check android file descriptor\n");
break;
if (android_check_fds(instance) != TRUE)
{
DEBUG_ANDROID("Failed to check android file descriptor\n");
break;
}
}
if (freerdp_channels_check_fds(instance->context->channels, instance) != TRUE)
else
{
DEBUG_ANDROID("Failed to check channel manager file descriptor\n");
break;
if (WaitForSingleObject(input_event, 0) == WAIT_OBJECT_0)
{
if (!freerdp_message_queue_process_pending_messages(instance,
FREERDP_INPUT_MESSAGE_QUEUE))
{
DEBUG_ANDROID("User Disconnect");
break;
}
}
}
if (!async_channels)
{
if (freerdp_channels_check_fds(instance->context->channels, instance) != TRUE)
{
DEBUG_ANDROID("Failed to check channel manager file descriptor\n");
break;
}
android_process_channel_event(instance->context->channels, instance);
}
android_process_channel_event(instance->context->channels, instance);
}
DEBUG_ANDROID("Prepare shutdown...");
// issue another OnDisconnecting here in case the disconnect was initiated by the sever and not our client
freerdp_callback("OnDisconnecting", "(I)V", instance);
DEBUG_ANDROID("Close channels...");
freerdp_channels_close(instance->context->channels, instance);
DEBUG_ANDROID("Cleanup threads...");
if (async_update)
{
wMessageQueue* update_queue = freerdp_get_message_queue(instance, FREERDP_UPDATE_MESSAGE_QUEUE);
MessageQueue_PostQuit(update_queue, 0);
WaitForSingleObject(update_thread, INFINITE);
CloseHandle(update_thread);
}
if (async_input)
{
wMessageQueue* input_queue = freerdp_get_message_queue(instance, FREERDP_INPUT_MESSAGE_QUEUE);
MessageQueue_PostQuit(input_queue, 0);
WaitForSingleObject(input_thread, INFINITE);
CloseHandle(input_thread);
}
if (async_channels)
{
WaitForSingleObject(channels_thread, INFINITE);
CloseHandle(channels_thread);
}
DEBUG_ANDROID("Disconnecting...");
freerdp_channels_free(instance->context->channels);
freerdp_disconnect(instance);
gdi_free(instance);
cache_free(instance->context->cache);
android_cliprdr_uninit(instance);
freerdp_callback("OnDisconnected", "(I)V", instance);
DEBUG_ANDROID("Quit.");
return 0;
}
@ -377,13 +597,16 @@ void* android_thread_func(void* param)
assert(data);
assert(data->instance);
DEBUG_ANDROID("Start.");
freerdp* instance = data->instance;
android_freerdp_run(instance);
free(data);
pthread_detach(pthread_self());
DEBUG_ANDROID("Quit.");
ExitThread(0);
return NULL;
}
@ -578,8 +801,10 @@ JNIEXPORT void JNICALL jni_freerdp_set_connection_info(JNIEnv *env, jclass cls,
}
JNIEXPORT void JNICALL jni_freerdp_set_performance_flags(
JNIEnv *env, jclass cls, jint instance, jboolean remotefx, jboolean disableWallpaper, jboolean disableFullWindowDrag,
jboolean disableMenuAnimations, jboolean disableTheming, jboolean enableFontSmoothing, jboolean enableDesktopComposition)
JNIEnv *env, jclass cls, jint instance, jboolean remotefx,
jboolean disableWallpaper, jboolean disableFullWindowDrag,
jboolean disableMenuAnimations, jboolean disableTheming,
jboolean enableFontSmoothing, jboolean enableDesktopComposition)
{
freerdp* inst = (freerdp*)instance;
rdpSettings * settings = inst->settings;
@ -642,7 +867,10 @@ JNIEXPORT void JNICALL jni_freerdp_set_performance_flags(
DEBUG_ANDROID("performance_flags: %04X", settings->PerformanceFlags);
}
JNIEXPORT void JNICALL jni_freerdp_set_advanced_settings(JNIEnv *env, jclass cls, jint instance, jstring jRemoteProgram, jstring jWorkDir)
JNIEXPORT void JNICALL jni_freerdp_set_advanced_settings(JNIEnv *env, jclass cls,
jint instance, jstring jRemoteProgram, jstring jWorkDir,
jboolean async_channel, jboolean async_transport, jboolean async_input,
jboolean async_update)
{
freerdp* inst = (freerdp*)instance;
rdpSettings * settings = inst->settings;
@ -653,6 +881,12 @@ JNIEXPORT void JNICALL jni_freerdp_set_advanced_settings(JNIEnv *env, jclass cls
DEBUG_ANDROID("Remote Program: %s", (char*) remote_program);
DEBUG_ANDROID("Work Dir: %s", (char*) work_dir);
/* Enable async mode. */
settings->AsyncUpdate = async_update;
settings->AsyncChannels = async_channel;
settings->AsyncTransport = async_transport;
settings->AsyncInput = async_input;
if(remote_program && strlen(remote_program) > 0)
settings->AlternateShell = strdup(remote_program);

View File

@ -43,7 +43,10 @@ JNIEXPORT void JNICALL jni_freerdp_set_connection_info(JNIEnv *env, jclass cls,
jint height, jint color_depth, jint port, jboolean console, jint security, jstring jcertname);
JNIEXPORT void JNICALL jni_freerdp_set_performance_flags(JNIEnv *env, jclass cls, jint instance, jboolean remotefx, jboolean disableWallpaper, jboolean disableFullWindowDrag,
jboolean disableMenuAnimations, jboolean disableTheming, jboolean enableFontSmoothing, jboolean enableDesktopComposition);
JNIEXPORT void JNICALL jni_freerdp_set_advanced_settings(JNIEnv *env, jclass cls, jint instance, jstring jRemoteProgram, jstring jWorkDir);
JNIEXPORT void JNICALL jni_freerdp_set_advanced_settings(JNIEnv *env, jclass cls,
jint instance, jstring jRemoteProgram, jstring jWorkDir,
jboolean async_channel, jboolean async_transport, jboolean async_input,
jboolean async_update);
JNIEXPORT void JNICALL jni_freerdp_set_drive_redirection(JNIEnv *env, jclass cls, jint instance, jstring jpath);
JNIEXPORT void JNICALL jni_freerdp_set_sound_redirection(JNIEnv *env, jclass cls, jint instance, jint redirect);
JNIEXPORT void JNICALL jni_freerdp_set_microphone_redirection(JNIEnv *env, jclass cls, jint instance, jboolean enable);

View File

@ -53,9 +53,14 @@ JNIEXPORT void JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_
width, height, color_depth, port, console, security, certname);
}
JNIEXPORT void JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1set_1advanced_1settings(JNIEnv *env, jclass cls, jint instance, jstring remote_program, jstring work_dir)
JNIEXPORT void JNICALL
Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1set_1advanced_1settings(
JNIEnv *env, jclass cls, jint instance, jstring remote_program, jstring work_dir,
jboolean async_channel, jboolean async_transport, jboolean async_input,
jboolean async_update)
{
jni_freerdp_set_advanced_settings(env, cls, instance, remote_program, work_dir);
jni_freerdp_set_advanced_settings(env, cls, instance, remote_program, work_dir,
async_channel, async_transport, async_input, async_update);
}
JNIEXPORT void JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1set_1data_1directory(JNIEnv *env, jclass cls, jint instance, jstring directory)

View File

@ -66,10 +66,10 @@ JNIEXPORT void JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_
/*
* Class: com_freerdp_freerdpcore_services_LibFreeRDP
* Method: freerdp_set_advanced_settings
* Signature: (ILjava/lang/String;Ljava/lang/String;)V
* Signature: (ILjava/lang/String;Ljava/lang/String;ZZZZ)V
*/
JNIEXPORT void JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1set_1advanced_1settings
(JNIEnv *, jclass, jint, jstring, jstring);
(JNIEnv *, jclass, jint, jstring, jstring, jboolean, jboolean, jboolean, jboolean);
/*
* Class: com_freerdp_freerdpcore_services_LibFreeRDP

View File

@ -142,6 +142,10 @@
</string-array>
<string name="settings_remote_program">Programa Remoto</string>
<string name="settings_work_dir">Directorio de trabajo</string>
<string name="settings_async_channel">Async channel</string>
<string name="settings_async_transport">Async transport</string>
<string name="settings_async_input">Async input</string>
<string name="settings_async_update">Async update</string>
<string name="settings_console_mode">Modo Consola</string>
<!-- App settings strings -->
<string name="settings_password_present">*******</string>

View File

@ -141,6 +141,10 @@
</string-array>
<string name="settings_remote_program">"Lancement de programme"</string>
<string name="settings_work_dir">"Répertoire de travail"</string>
<string name="settings_async_channel">Async channel</string>
<string name="settings_async_transport">Async transport</string>
<string name="settings_async_input">Async input</string>
<string name="settings_async_update">Async update</string>
<string name="settings_console_mode">"Mode console"</string>
<!-- App settings strings -->
<string name="settings_password_present">"*******"</string>

View File

@ -142,6 +142,10 @@
</string-array>
<string name="settings_remote_program">Extern programma</string>
<string name="settings_work_dir">Werkmap</string>
<string name="settings_async_channel">Async channel</string>
<string name="settings_async_transport">Async transport</string>
<string name="settings_async_input">Async input</string>
<string name="settings_async_update">Async update</string>
<string name="settings_console_mode">Console modus</string>
<!-- App settings strings -->
<string name="settings_password_present">*******</string>

View File

@ -139,6 +139,10 @@
</string-array>
<string name="settings_remote_program">Remote Program</string>
<string name="settings_work_dir">Working Directory</string>
<string name="settings_async_channel">Async channel</string>
<string name="settings_async_transport">Async transport</string>
<string name="settings_async_input">Async input</string>
<string name="settings_async_update">Async update</string>
<string name="settings_console_mode">Console Mode</string>
<!-- App settings strings -->
<string name="settings_password_present">*******</string>

View File

@ -31,5 +31,13 @@
freerdp:bounds_min="0"
freerdp:bounds_max="10"
freerdp:bounds_default="0" />
<CheckBoxPreference android:key="bookmark.async_channel"
android:title="@string/settings_async_channel"/>
<CheckBoxPreference android:key="bookmark.async_transport"
android:title="@string/settings_async_transport"/>
<CheckBoxPreference android:key="bookmark.async_update"
android:title="@string/settings_async_update"/>
<CheckBoxPreference android:key="bookmark.async_input"
android:title="@string/settings_async_input"/>
</PreferenceCategory>
</PreferenceScreen>

View File

@ -5,7 +5,7 @@
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/.
*/
*/
package com.freerdp.freerdpcore.domain;
@ -23,7 +23,7 @@ public class BookmarkBase implements Parcelable, Cloneable {
public static final int TYPE_QUICKCONNECT = 2;
public static final int TYPE_PLACEHOLDER = 3;
public static final int TYPE_CUSTOM_BASE = 1000;
// performance flags
public static class PerformanceFlags implements Parcelable {
private boolean remotefx;
@ -33,7 +33,7 @@ public class BookmarkBase implements Parcelable, Cloneable {
private boolean menuAnimations;
private boolean fontSmoothing;
private boolean desktopComposition;
public PerformanceFlags() {
remotefx = false;
wallpaper = false;
@ -43,13 +43,13 @@ public class BookmarkBase implements Parcelable, Cloneable {
fontSmoothing = false;
desktopComposition = false;
}
public PerformanceFlags(Parcel parcel) {
remotefx = (parcel.readInt() == 1) ? true : false;
wallpaper = (parcel.readInt() == 1) ? true : false;
theming = (parcel.readInt() == 1) ? true : false;
fullWindowDrag = (parcel.readInt() == 1) ? true : false;
menuAnimations = (parcel.readInt() == 1) ? true : false;
wallpaper = (parcel.readInt() == 1) ? true : false;
theming = (parcel.readInt() == 1) ? true : false;
fullWindowDrag = (parcel.readInt() == 1) ? true : false;
menuAnimations = (parcel.readInt() == 1) ? true : false;
fontSmoothing = (parcel.readInt() == 1) ? true : false;
desktopComposition = (parcel.readInt() == 1) ? true : false;
}
@ -57,7 +57,7 @@ public class BookmarkBase implements Parcelable, Cloneable {
public boolean getRemoteFX() {
return remotefx;
}
public void setRemoteFX(boolean remotefx) {
this.remotefx = remotefx;
}
@ -65,15 +65,15 @@ public class BookmarkBase implements Parcelable, Cloneable {
public boolean getWallpaper() {
return wallpaper;
}
public void setWallpaper(boolean wallpaper) {
this.wallpaper = wallpaper;
}
public boolean getTheming() {
return theming;
}
public void setTheming(boolean theming) {
this.theming = theming;
}
@ -81,7 +81,7 @@ public class BookmarkBase implements Parcelable, Cloneable {
public boolean getFullWindowDrag() {
return fullWindowDrag;
}
public void setFullWindowDrag(boolean fullWindowDrag) {
this.fullWindowDrag = fullWindowDrag;
}
@ -89,7 +89,7 @@ public class BookmarkBase implements Parcelable, Cloneable {
public boolean getMenuAnimations() {
return menuAnimations;
}
public void setMenuAnimations(boolean menuAnimations) {
this.menuAnimations = menuAnimations;
}
@ -97,15 +97,15 @@ public class BookmarkBase implements Parcelable, Cloneable {
public boolean getFontSmoothing() {
return fontSmoothing;
}
public void setFontSmoothing(boolean fontSmoothing) {
this.fontSmoothing = fontSmoothing;
}
public boolean getDesktopComposition() {
return desktopComposition;
}
public void setDesktopComposition(boolean desktopComposition) {
this.desktopComposition = desktopComposition;
}
@ -129,13 +129,13 @@ public class BookmarkBase implements Parcelable, Cloneable {
@Override
public void writeToParcel(Parcel out, int flags) {
out.writeInt(remotefx ? 1 : 0);
out.writeInt(wallpaper ? 1 : 0);
out.writeInt(theming ? 1 : 0);
out.writeInt(fullWindowDrag ? 1 : 0);
out.writeInt(menuAnimations ? 1 : 0);
out.writeInt(wallpaper ? 1 : 0);
out.writeInt(theming ? 1 : 0);
out.writeInt(fullWindowDrag ? 1 : 0);
out.writeInt(menuAnimations ? 1 : 0);
out.writeInt(fontSmoothing ? 1 : 0);
out.writeInt(desktopComposition ? 1 : 0);
}
}
}
// Screen Settings class
@ -144,7 +144,7 @@ public class BookmarkBase implements Parcelable, Cloneable {
public static final int AUTOMATIC = -1;
public static final int CUSTOM = 0;
public static final int PREDEFINED = 1;
private int resolution;
private int colors;
private int width;
@ -160,23 +160,23 @@ public class BookmarkBase implements Parcelable, Cloneable {
width = parcel.readInt();
height = parcel.readInt();
}
private void init() {
resolution = AUTOMATIC;
colors = 16;
width = 0;
height = 0;
}
public void setResolution(int resolution) {
this.resolution = resolution;
if (resolution == AUTOMATIC || resolution == FITSCREEN) {
width = 0;
height = 0;
}
}
public void setResolution(String resolution, int width, int height) {
if (resolution.contains("x")) {
String[] dimensions = resolution.split("x");
@ -184,8 +184,8 @@ public class BookmarkBase implements Parcelable, Cloneable {
this.height = Integer.valueOf(dimensions[1]);
this.resolution = PREDEFINED;
} else if (resolution.equalsIgnoreCase("custom")) {
this.width = width;
this.height = height;
this.width = width;
this.height = height;
this.resolution = CUSTOM;
} else if (resolution.equalsIgnoreCase("fitscreen")) {
this.width = this.height = 0;
@ -199,7 +199,7 @@ public class BookmarkBase implements Parcelable, Cloneable {
public int getResolution() {
return resolution;
}
public String getResolutionString() {
if (isPredefined())
return (width + "x" + height);
@ -209,9 +209,9 @@ public class BookmarkBase implements Parcelable, Cloneable {
}
public boolean isPredefined() {
return (resolution == PREDEFINED);
return (resolution == PREDEFINED);
}
public boolean isAutomatic() {
return (resolution == AUTOMATIC);
}
@ -227,27 +227,27 @@ public class BookmarkBase implements Parcelable, Cloneable {
public void setWidth(int width) {
this.width = width;
}
public int getWidth() {
return width;
}
public int getHeight() {
return height;
}
public void setHeight(int height) {
this.height = height;
}
public void setColors(int colors) {
this.colors = colors;
}
public int getColors() {
return colors;
}
public static final Parcelable.Creator<ScreenSettings> CREATOR = new Parcelable.Creator<ScreenSettings>() {
public ScreenSettings createFromParcel(Parcel in) {
return new ScreenSettings(in);
@ -270,22 +270,35 @@ public class BookmarkBase implements Parcelable, Cloneable {
out.writeInt(colors);
out.writeInt(width);
out.writeInt(height);
}
}
}
public static class DebugSettings implements Parcelable {
private int debug;
private boolean asyncChannel;
private boolean asyncTransport;
private boolean asyncInput;
private boolean asyncUpdate;
public DebugSettings() {
init();
}
// Session Settings
public DebugSettings(Parcel parcel) {
asyncChannel = (parcel.readInt() == 1) ? true : false;
asyncTransport = (parcel.readInt() == 1) ? true : false;
asyncInput = (parcel.readInt() == 1) ? true : false;
asyncUpdate = (parcel.readInt() == 1) ? true : false;
debug = parcel.readInt();
}
private void init() {
debug = 0;
asyncChannel = true;
asyncTransport = true;
asyncInput = true;
asyncUpdate = true;
}
public int getDebugLevel() {
@ -296,6 +309,46 @@ public class BookmarkBase implements Parcelable, Cloneable {
this.debug = debug;
}
public boolean getAsyncTransport()
{
return asyncTransport;
}
public void setAsyncTransport(boolean enabled)
{
asyncTransport = enabled;
}
public boolean getAsyncUpdate()
{
return asyncUpdate;
}
public void setAsyncUpdate(boolean enabled)
{
asyncUpdate = enabled;
}
public boolean getAsyncInput()
{
return asyncInput;
}
public void setAsyncInput(boolean enabled)
{
asyncInput = enabled;
}
public void setAsyncChannel(boolean enabled)
{
asyncChannel = enabled;
}
public boolean getAsyncChannel()
{
return asyncChannel;
}
public static final Parcelable.Creator<DebugSettings> CREATOR = new Parcelable.Creator<DebugSettings>() {
public DebugSettings createFromParcel(Parcel in) {
return new DebugSettings(in);
@ -314,6 +367,10 @@ public class BookmarkBase implements Parcelable, Cloneable {
@Override
public void writeToParcel(Parcel out, int flags) {
out.writeInt(asyncChannel ? 1 : 0);
out.writeInt(asyncTransport ? 1 : 0);
out.writeInt(asyncInput ? 1 : 0);
out.writeInt(asyncUpdate ? 1 : 0);
out.writeInt(debug);
}
}
@ -347,9 +404,9 @@ public class BookmarkBase implements Parcelable, Cloneable {
security = parcel.readInt();
consoleMode = (parcel.readInt() == 1) ? true : false;
remoteProgram = parcel.readString();
workDir = parcel.readString();
workDir = parcel.readString();
}
private void init() {
enable3GSettings = false;
screen3G = new ScreenSettings();
@ -362,11 +419,11 @@ public class BookmarkBase implements Parcelable, Cloneable {
remoteProgram = "";
workDir = "";
}
public void setEnable3GSettings(boolean enable3GSettings) {
this.enable3GSettings = enable3GSettings;
}
public boolean getEnable3GSettings() {
return enable3GSettings;
}
@ -374,76 +431,77 @@ public class BookmarkBase implements Parcelable, Cloneable {
public ScreenSettings getScreen3G() {
return screen3G;
}
public void setScreen3G(ScreenSettings screen3G) {
this.screen3G = screen3G;
this.screen3G = screen3G;
}
public PerformanceFlags getPerformance3G() {
return performance3G;
}
public void setPerformance3G(PerformanceFlags performance3G) {
this.performance3G = performance3G;
this.performance3G = performance3G;
}
public void setRedirectSDCard(boolean redirectSDCard) {
this.redirectSDCard = redirectSDCard;
}
public boolean getRedirectSDCard() {
return redirectSDCard;
}
public void setRedirectSound(int redirect) {
this.redirectSound = redirect;
}
public int getRedirectSound() {
return redirectSound;
}
public void setRedirectMicrophone(boolean redirect) {
this.redirectMicrophone = redirect;
}
public boolean getRedirectMicrophone() {
return redirectMicrophone;
}
public void setSecurity(int security) {
this.security = security;
}
public int getSecurity() {
return security;
}
public void setConsoleMode(boolean consoleMode) {
this.consoleMode = consoleMode;
}
public boolean getConsoleMode() {
return consoleMode;
}
public void setRemoteProgram(String remoteProgram) {
this.remoteProgram = remoteProgram;
}
public String getRemoteProgram() {
return remoteProgram;
}
public void setWorkDir(String workDir) {
this.workDir = workDir;
}
public String getWorkDir() {
return workDir;
}
public static final Parcelable.Creator<AdvancedSettings> CREATOR = new Parcelable.Creator<AdvancedSettings>() {
}
public static final Parcelable.Creator<AdvancedSettings> CREATOR = new Parcelable.Creator<AdvancedSettings>()
{
public AdvancedSettings createFromParcel(Parcel in) {
return new AdvancedSettings(in);
}
@ -467,15 +525,15 @@ public class BookmarkBase implements Parcelable, Cloneable {
out.writeInt(redirectSDCard ? 1 : 0);
out.writeInt(redirectSound);
out.writeInt(redirectMicrophone ? 1 : 0);
out.writeInt(security);
out.writeInt(consoleMode ? 1 : 0);
out.writeInt(security);
out.writeInt(consoleMode ? 1 : 0);
out.writeString(remoteProgram);
out.writeString(workDir);
}
}
}
protected int type;
private long id;
protected int type;
private long id;
private String label;
private String username;
private String password;
@ -485,21 +543,21 @@ public class BookmarkBase implements Parcelable, Cloneable {
private PerformanceFlags performanceFlags;
private AdvancedSettings advancedSettings;
private DebugSettings debugSettings;
private void init() {
type = TYPE_INVALID;
id = -1;
label = "";
username = "";
password = "";
domain = "";
domain = "";
screenSettings = new ScreenSettings();
performanceFlags = new PerformanceFlags();
advancedSettings = new AdvancedSettings();
debugSettings = new DebugSettings();
}
public BookmarkBase(Parcel parcel) {
type = parcel.readInt();
id = parcel.readLong();
@ -517,7 +575,7 @@ public class BookmarkBase implements Parcelable, Cloneable {
debugSettings = parcel.readParcelable(DebugSettings.class
.getClassLoader());
}
public BookmarkBase() {
init();
}
@ -530,47 +588,47 @@ public class BookmarkBase implements Parcelable, Cloneable {
public int getType() {
return type;
}
public void setId(long id) {
this.id = id;
}
public long getId() {
return id;
}
public void setLabel(String label) {
this.label = label;
}
public String getLabel() {
return label;
}
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;
}
public void setScreenSettings(ScreenSettings screenSettings) {
this.screenSettings = screenSettings;
}
@ -582,11 +640,11 @@ public class BookmarkBase implements Parcelable, Cloneable {
public void setPerformanceFlags(PerformanceFlags performanceFlags) {
this.performanceFlags = performanceFlags;
}
public PerformanceFlags getPerformanceFlags() {
return performanceFlags;
}
public void setAdvancedSettings(AdvancedSettings advancedSettings) {
this.advancedSettings = advancedSettings;
}
@ -594,11 +652,11 @@ public class BookmarkBase implements Parcelable, Cloneable {
public AdvancedSettings getAdvancedSettings() {
return advancedSettings;
}
public void setDebugSettings(DebugSettings debugSettings) {
this.debugSettings = debugSettings;
}
public DebugSettings getDebugSettings() {
return debugSettings;
}
@ -625,7 +683,7 @@ public class BookmarkBase implements Parcelable, Cloneable {
return new BookmarkBase[size];
}
};
@Override
public int describeContents() {
return 0;
@ -677,7 +735,7 @@ public class BookmarkBase implements Parcelable, Cloneable {
editor.putBoolean("bookmark.perf_menu_animation",
performanceFlags.getMenuAnimations());
editor.putBoolean("bookmark.perf_themes", performanceFlags.getTheming());
editor.putBoolean("bookmark.enable_3g_settings",
advancedSettings.getEnable3GSettings());
@ -718,6 +776,10 @@ public class BookmarkBase implements Parcelable, Cloneable {
editor.putBoolean("bookmark.console_mode",
advancedSettings.getConsoleMode());
editor.putBoolean("bookmark.async_channel", debugSettings.getAsyncChannel());
editor.putBoolean("bookmark.async_transport", debugSettings.getAsyncTransport());
editor.putBoolean("bookmark.async_input", debugSettings.getAsyncInput());
editor.putBoolean("bookmark.async_update", debugSettings.getAsyncUpdate());
editor.putInt("bookmark.debug_level",
debugSettings.getDebugLevel());
@ -751,7 +813,7 @@ public class BookmarkBase implements Parcelable, Cloneable {
"bookmark.perf_menu_animation", false));
performanceFlags.setTheming(sharedPrefs.getBoolean(
"bookmark.perf_themes", false));
advancedSettings.setEnable3GSettings(sharedPrefs.getBoolean(
"bookmark.enable_3g_settings", false));
@ -781,28 +843,25 @@ public class BookmarkBase implements Parcelable, Cloneable {
advancedSettings.getPerformance3G().setTheming(
sharedPrefs.getBoolean("bookmark.perf_themes_3g", false));
advancedSettings.setRedirectSDCard(sharedPrefs.getBoolean(
"bookmark.redirect_sdcard", false));
advancedSettings.setRedirectSound(sharedPrefs.getInt(
"bookmark.redirect_sound", 0));
advancedSettings.setRedirectMicrophone(sharedPrefs.getBoolean(
"bookmark.redirect_microphone", false));
advancedSettings
.setSecurity(sharedPrefs.getInt("bookmark.security", 0));
advancedSettings.setRemoteProgram(sharedPrefs.getString(
"bookmark.remote_program", ""));
advancedSettings.setWorkDir(sharedPrefs.getString("bookmark.work_dir",
""));
advancedSettings.setConsoleMode(sharedPrefs.getBoolean(
"bookmark.console_mode", false));
advancedSettings.setRedirectSDCard(sharedPrefs.getBoolean("bookmark.redirect_sdcard", false));
advancedSettings.setRedirectSound(sharedPrefs.getInt("bookmark.redirect_sound", 0));
advancedSettings.setRedirectMicrophone(sharedPrefs.getBoolean("bookmark.redirect_microphone", false));
advancedSettings.setSecurity(sharedPrefs.getInt("bookmark.security", 0));
advancedSettings.setRemoteProgram(sharedPrefs.getString("bookmark.remote_program", ""));
advancedSettings.setWorkDir(sharedPrefs.getString("bookmark.work_dir", ""));
advancedSettings.setConsoleMode(sharedPrefs.getBoolean("bookmark.console_mode", false));
debugSettings.setAsyncChannel(sharedPrefs.getBoolean("bookmark.async_channel", true));
debugSettings.setAsyncTransport(sharedPrefs.getBoolean("bookmark.async_transport", true));
debugSettings.setAsyncInput(sharedPrefs.getBoolean("bookmark.async_input", true));
debugSettings.setAsyncUpdate(sharedPrefs.getBoolean("bookmark.async_update", true));
debugSettings.setDebugLevel(sharedPrefs.getInt("bookmark.debug_level", 0));
}
// Cloneable
public Object clone() {
try {
return super.clone();
return super.clone();
} catch (CloneNotSupportedException e) {
return null;
}

View File

@ -504,6 +504,10 @@ public class BookmarkActivity extends PreferenceActivity implements
private void initDebugSettings(SharedPreferences sharedPreferences) {
debugSettingsChanged(sharedPreferences, "bookmark.debug_level");
debugSettingsChanged(sharedPreferences, "bookmark.async_channel");
debugSettingsChanged(sharedPreferences, "bookmark.async_transport");
debugSettingsChanged(sharedPreferences, "bookmark.async_update");
debugSettingsChanged(sharedPreferences, "bookmark.async_input");
}
private void initGatewaySettings(SharedPreferences sharedPreferences) {
@ -520,6 +524,22 @@ public class BookmarkActivity extends PreferenceActivity implements
int level = sharedPreferences.getInt(key, 0);
Preference pref = findPreference("bookmark.debug_level");
pref.setDefaultValue(level);
} else if (key.equals("bookmark.async_channel")) {
boolean enabled = sharedPreferences.getBoolean(key, false);
Preference pref = findPreference("bookmark.async_channel");
pref.setDefaultValue(enabled);
}else if (key.equals("bookmark.async_transport")) {
boolean enabled = sharedPreferences.getBoolean(key, false);
Preference pref = findPreference("bookmark.async_transport");
pref.setDefaultValue(enabled);
}else if (key.equals("bookmark.async_update")) {
boolean enabled = sharedPreferences.getBoolean(key, false);
Preference pref = findPreference("bookmark.async_update");
pref.setDefaultValue(enabled);
}else if (key.equals("bookmark.async_input")) {
boolean enabled = sharedPreferences.getBoolean(key, false);
Preference pref = findPreference("bookmark.async_input");
pref.setDefaultValue(enabled);
}
}

View File

@ -71,6 +71,10 @@ public abstract class BookmarkBaseGateway
values.put("remote_program", bookmark.getAdvancedSettings().getRemoteProgram());
values.put("work_dir", bookmark.getAdvancedSettings().getWorkDir());
values.put("async_channel", bookmark.getDebugSettings().getAsyncChannel());
values.put("async_transport", bookmark.getDebugSettings().getAsyncTransport());
values.put("async_input", bookmark.getDebugSettings().getAsyncInput());
values.put("async_update", bookmark.getDebugSettings().getAsyncUpdate());
values.put("debug_level", bookmark.getDebugSettings().getDebugLevel());
// add any special columns
@ -111,6 +115,10 @@ public abstract class BookmarkBaseGateway
values.put("remote_program", bookmark.getAdvancedSettings().getRemoteProgram());
values.put("work_dir", bookmark.getAdvancedSettings().getWorkDir());
values.put("async_channel", bookmark.getDebugSettings().getAsyncChannel());
values.put("async_transport", bookmark.getDebugSettings().getAsyncTransport());
values.put("async_input", bookmark.getDebugSettings().getAsyncInput());
values.put("async_update", bookmark.getDebugSettings().getAsyncUpdate());
values.put("debug_level", bookmark.getDebugSettings().getDebugLevel());
addBookmarkSpecificColumns(bookmark, values);
@ -233,9 +241,13 @@ public abstract class BookmarkBaseGateway
columns.add("console_mode");
columns.add("remote_program");
columns.add("work_dir");
// debug settings
columns.add("debug_level");
columns.add("async_channel");
columns.add("async_transport");
columns.add("async_update");
columns.add("async_input");
addBookmarkSpecificColumns(columns);
}
@ -297,8 +309,16 @@ public abstract class BookmarkBaseGateway
bookmark.getAdvancedSettings().setRemoteProgram(cursor.getString(cursor.getColumnIndex("remote_program")));
bookmark.getAdvancedSettings().setWorkDir(cursor.getString(cursor.getColumnIndex("work_dir")));
bookmark.getDebugSettings().setAsyncChannel(
cursor.getInt(cursor.getColumnIndex("async_channel")) == 1 ? true : false);
bookmark.getDebugSettings().setAsyncTransport(
cursor.getInt(cursor.getColumnIndex("async_transport")) == 1 ? true : false);
bookmark.getDebugSettings().setAsyncInput(
cursor.getInt(cursor.getColumnIndex("async_input")) == 1 ? true : false);
bookmark.getDebugSettings().setAsyncUpdate(
cursor.getInt(cursor.getColumnIndex("async_update")) == 1 ? true : false);
bookmark.getDebugSettings().setDebugLevel(cursor.getInt(cursor.getColumnIndex("debug_level")));
readBookmarkSpecificColumns(bookmark, cursor);
return bookmark;

View File

@ -106,8 +106,12 @@ public class BookmarkDB extends SQLiteOpenHelper
+ "security, "
+ "remote_program, "
+ "work_dir, "
+ "async_channel, "
+ "async_transport, "
+ "async_input, "
+ "async_update, "
+ "console_mode, "
+ "debug_level ) "
+ "debug_level ) "
+ "VALUES ( "
+ "'Test Server', "
+ "'testservice.afreerdp.com', "
@ -115,7 +119,9 @@ public class BookmarkDB extends SQLiteOpenHelper
+ "'', "
+ "'', "
+ "3389, "
+ "1, 1, 2, 2, 0, 0, 0, 0, '', '', 0, 0);";
+ "1, 1, 2, 2, 0, 0, 0, 0, "
+ "'', '', "
+ "1, 1, 1, 1, 0, 0);";
db.execSQL(sqlInsertDefaultSessionEntry);
}
@ -149,6 +155,10 @@ public class BookmarkDB extends SQLiteOpenHelper
+ "security INTEGER, "
+ "remote_program TEXT, "
+ "work_dir TEXT, "
+ "async_channel INTEGER DEFAULT 0, "
+ "async_transport INTEGER DEFAULT 0, "
+ "async_input INTEGER DEFAULT 0, "
+ "async_update INTEGER DEFAULT 0, "
+ "console_mode INTEGER, "
+ "debug_level INTEGER DEFAULT 0, "

View File

@ -35,7 +35,9 @@ public class LibFreeRDP
boolean disableMenuAnimations, boolean disableTheming,
boolean enableFontSmoothing, boolean enableDesktopComposition);
private static native void freerdp_set_advanced_settings(int inst, String remoteProgram, String workDir);
private static native void freerdp_set_advanced_settings(int inst,
String remoteProgram, String workDir, boolean async_channel,
boolean async_transport, boolean async_input, boolean async_update);
private static native void freerdp_set_data_directory(int inst, String directory);
@ -151,7 +153,11 @@ public class LibFreeRDP
flags.getDesktopComposition());
BookmarkBase.AdvancedSettings advancedSettings = bookmark.getAdvancedSettings();
freerdp_set_advanced_settings(inst, advancedSettings.getRemoteProgram(), advancedSettings.getWorkDir());
BookmarkBase.DebugSettings debugSettings = bookmark.getDebugSettings();
freerdp_set_advanced_settings(inst, advancedSettings.getRemoteProgram(),
advancedSettings.getWorkDir(), debugSettings.getAsyncChannel(),
debugSettings.getAsyncTransport(), debugSettings.getAsyncInput(),
debugSettings.getAsyncUpdate());
// drive redirection enabled?
if (advancedSettings.getRedirectSDCard())

View File

@ -52,7 +52,10 @@ public class RDPFileParser {
lines++; ok = false;
if (errors > MAX_ERRORS || lines > MAX_LINES)
{
br.close();
throw new IOException("Parsing limits exceeded");
}
String[] fields = line.split(":", 3);
@ -81,6 +84,7 @@ public class RDPFileParser {
if (!ok) errors++;
}
br.close();
}
public String getString(String optionName)

View File

@ -3,5 +3,7 @@
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
<classpathentry kind="output" path="bin"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>