diff --git a/client/Android/FreeRDPCore/jni/android_event.c b/client/Android/FreeRDPCore/jni/android_event.c index 8038c6165..8e1b01bab 100644 --- a/client/Android/FreeRDPCore/jni/android_event.c +++ b/client/Android/FreeRDPCore/jni/android_event.c @@ -69,7 +69,7 @@ void android_clear_event(ANDROID_EVENT_QUEUE * queue) } } -void android_push_event(freerdp * inst, ANDROID_EVENT* event) +BOOL android_push_event(freerdp * inst, ANDROID_EVENT* event) { androidContext* aCtx = (androidContext*)inst->context; @@ -82,7 +82,7 @@ void android_push_event(freerdp * inst, ANDROID_EVENT* event) new_events = realloc((void*) aCtx->event_queue->events, sizeof(ANDROID_EVENT*) * new_size); if (!new_events) - return; + return FALSE; aCtx->event_queue->events = new_events; aCtx->event_queue->size = new_size; } @@ -90,6 +90,7 @@ void android_push_event(freerdp * inst, ANDROID_EVENT* event) aCtx->event_queue->events[(aCtx->event_queue->count)++] = event; android_set_event(aCtx->event_queue); + return TRUE; } ANDROID_EVENT* android_peek_event(ANDROID_EVENT_QUEUE * queue) @@ -226,8 +227,9 @@ ANDROID_EVENT_KEY* android_event_key_new(int flags, UINT16 scancode) { ANDROID_EVENT_KEY* event; - event = (ANDROID_EVENT_KEY*) malloc(sizeof(ANDROID_EVENT_KEY)); - memset(event, 0, sizeof(ANDROID_EVENT_KEY)); + event = (ANDROID_EVENT_KEY*) calloc(1, sizeof(ANDROID_EVENT_KEY)); + if (!event) + return NULL; event->type = EVENT_TYPE_KEY; event->flags = flags; @@ -245,8 +247,9 @@ ANDROID_EVENT_KEY* android_event_unicodekey_new(UINT16 key) { ANDROID_EVENT_KEY* event; - event = (ANDROID_EVENT_KEY*) malloc(sizeof(ANDROID_EVENT_KEY)); - memset(event, 0, sizeof(ANDROID_EVENT_KEY)); + event = (ANDROID_EVENT_KEY*) calloc(1, sizeof(ANDROID_EVENT_KEY)); + if (!event) + return NULL; event->type = EVENT_TYPE_KEY_UNICODE; event->scancode = key; @@ -263,8 +266,9 @@ ANDROID_EVENT_CURSOR* android_event_cursor_new(UINT16 flags, UINT16 x, UINT16 y) { ANDROID_EVENT_CURSOR* event; - event = (ANDROID_EVENT_CURSOR*) malloc(sizeof(ANDROID_EVENT_CURSOR)); - memset(event, 0, sizeof(ANDROID_EVENT_CURSOR)); + event = (ANDROID_EVENT_CURSOR*) calloc(1, sizeof(ANDROID_EVENT_CURSOR)); + if (!event) + return NULL; event->type = EVENT_TYPE_CURSOR; event->x = x; @@ -283,8 +287,9 @@ ANDROID_EVENT* android_event_disconnect_new() { ANDROID_EVENT* event; - event = (ANDROID_EVENT*) malloc(sizeof(ANDROID_EVENT)); - memset(event, 0, sizeof(ANDROID_EVENT)); + event = (ANDROID_EVENT*) calloc(1, sizeof(ANDROID_EVENT)); + if (!event) + return NULL; event->type = EVENT_TYPE_DISCONNECT; return event; @@ -299,13 +304,19 @@ ANDROID_EVENT_CLIPBOARD* android_event_clipboard_new(void* data, int data_length { ANDROID_EVENT_CLIPBOARD* event; - event = (ANDROID_EVENT_CLIPBOARD*) malloc(sizeof(ANDROID_EVENT_CLIPBOARD)); - memset(event, 0, sizeof(ANDROID_EVENT_CLIPBOARD)); + event = (ANDROID_EVENT_CLIPBOARD*) calloc(1, sizeof(ANDROID_EVENT_CLIPBOARD)); + if (!event) + return NULL; event->type = EVENT_TYPE_CLIPBOARD; if (data) { event->data = malloc(data_length); + if (!event->data) + { + free(event); + return NULL; + } memcpy(event->data, data, data_length); event->data_length = data_length; } @@ -322,12 +333,16 @@ void android_event_clipboard_free(ANDROID_EVENT_CLIPBOARD* event) } } -void android_event_queue_init(freerdp * inst) +BOOL android_event_queue_init(freerdp * inst) { androidContext* aCtx = (androidContext*)inst->context; - aCtx->event_queue = (ANDROID_EVENT_QUEUE*) malloc(sizeof(ANDROID_EVENT_QUEUE)); - memset(aCtx->event_queue, 0, sizeof(ANDROID_EVENT_QUEUE)); + aCtx->event_queue = (ANDROID_EVENT_QUEUE*) calloc(1, sizeof(ANDROID_EVENT_QUEUE)); + if (!aCtx->event_queue) + { + WLog_ERR(TAG, "android_event_queue_init: memory allocation failed"); + return FALSE; + } aCtx->event_queue->pipe_fd[0] = -1; aCtx->event_queue->pipe_fd[1] = -1; @@ -335,9 +350,21 @@ void android_event_queue_init(freerdp * inst) aCtx->event_queue->size = 16; aCtx->event_queue->count = 0; aCtx->event_queue->events = (ANDROID_EVENT**) malloc(sizeof(ANDROID_EVENT*) * aCtx->event_queue->size); + if (!aCtx->event_queue->events) + { + WLog_ERR(TAG, "android_event_queue_init: memory allocation failed"); + free(aCtx->event_queue); + return FALSE; + } if (pipe(aCtx->event_queue->pipe_fd) < 0) - WLog_ERR(TAG, "android_pre_connect: pipe failed"); + { + WLog_ERR(TAG, "android_event_queue_init: pipe creation failed"); + free(aCtx->event_queue->events); + free(aCtx->event_queue); + return FALSE; + } + return TRUE; } void android_event_queue_uninit(freerdp * inst) diff --git a/client/Android/FreeRDPCore/jni/android_event.h b/client/Android/FreeRDPCore/jni/android_event.h index 7872ec770..d1cb147fe 100644 --- a/client/Android/FreeRDPCore/jni/android_event.h +++ b/client/Android/FreeRDPCore/jni/android_event.h @@ -62,7 +62,7 @@ typedef struct _ANDROID_EVENT_QUEUE ANDROID_EVENT_QUEUE; int android_is_event_set(ANDROID_EVENT_QUEUE * queue); void android_set_event(ANDROID_EVENT_QUEUE * queue); void android_clear_event(ANDROID_EVENT_QUEUE * queue); -void android_push_event(freerdp * inst, ANDROID_EVENT* event); +BOOL android_push_event(freerdp * inst, ANDROID_EVENT* event); ANDROID_EVENT* android_peek_event(ANDROID_EVENT_QUEUE * queue); ANDROID_EVENT* android_pop_event(ANDROID_EVENT_QUEUE * queue); int android_process_event(ANDROID_EVENT_QUEUE * queue, freerdp * inst); @@ -79,7 +79,7 @@ void android_event_unicodekey_free(ANDROID_EVENT_KEY* event); void android_event_cursor_free(ANDROID_EVENT_CURSOR* event); void android_event_disconnect_free(ANDROID_EVENT* event); void android_event_clipboard_free(ANDROID_EVENT_CLIPBOARD* event); -void android_event_queue_init(freerdp * inst); +BOOL android_event_queue_init(freerdp * inst); void android_event_queue_uninit(freerdp * inst); #endif /* FREERDP_ANDROID_EVENT_H */ diff --git a/client/Android/FreeRDPCore/jni/android_freerdp.c b/client/Android/FreeRDPCore/jni/android_freerdp.c index 3f876e787..c80ba5b5b 100644 --- a/client/Android/FreeRDPCore/jni/android_freerdp.c +++ b/client/Android/FreeRDPCore/jni/android_freerdp.c @@ -4,6 +4,7 @@ Copyright 2010-2012 Marc-Andre Moreau Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz Copyright 2013 Thincast Technologies GmbH, Author: Armin Novak + Copyright 2015 Bernhard Miklautz 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/. @@ -48,15 +49,21 @@ #include "jni/prof.h" #endif -BOOL android_context_new(freerdp* instance, rdpContext* context) + +static BOOL android_context_new(freerdp* instance, rdpContext* context) { if (!(context->channels = freerdp_channels_new())) return FALSE; - android_event_queue_init(instance); + + if (!android_event_queue_init(instance)) + { + freerdp_channels_free(context->channels); + return FALSE; + } return TRUE; } -void android_context_free(freerdp* instance, rdpContext* context) +static void android_context_free(freerdp* instance, rdpContext* context) { if (context && context->channels) { @@ -67,14 +74,14 @@ void android_context_free(freerdp* instance, rdpContext* context) android_event_queue_uninit(instance); } -void android_OnChannelConnectedEventHandler(rdpContext* context, ChannelConnectedEventArgs* e) +static void android_OnChannelConnectedEventHandler(rdpContext* context, ChannelConnectedEventArgs* e) { rdpSettings* settings = context->settings; androidContext* afc = (androidContext*) context; if (strcmp(e->name, RDPEI_DVC_CHANNEL_NAME) == 0) { - + DEBUG_ANDROID("Unhandled case.. RDPEI_DVC_CHANNEL_NAME"); } else if (strcmp(e->name, RDPGFX_DVC_CHANNEL_NAME) == 0) { @@ -87,14 +94,14 @@ void android_OnChannelConnectedEventHandler(rdpContext* context, ChannelConnecte } } -void android_OnChannelDisconnectedEventHandler(rdpContext* context, ChannelDisconnectedEventArgs* e) +static void android_OnChannelDisconnectedEventHandler(rdpContext* context, ChannelDisconnectedEventArgs* e) { rdpSettings* settings = context->settings; androidContext* afc = (androidContext*) context; if (strcmp(e->name, RDPEI_DVC_CHANNEL_NAME) == 0) { - + DEBUG_ANDROID("Unhandled case.. RDPEI_DVC_CHANNEL_NAME"); } else if (strcmp(e->name, RDPGFX_DVC_CHANNEL_NAME) == 0) { @@ -107,7 +114,7 @@ void android_OnChannelDisconnectedEventHandler(rdpContext* context, ChannelDisco } } -BOOL android_begin_paint(rdpContext* context) +static BOOL android_begin_paint(rdpContext* context) { rdpGdi* gdi = context->gdi; gdi->primary->hdc->hwnd->invalid->null = 1; @@ -115,7 +122,7 @@ BOOL android_begin_paint(rdpContext* context) return TRUE; } -BOOL android_end_paint(rdpContext* context) +static BOOL android_end_paint(rdpContext* context) { int i; int ninvalid; @@ -158,7 +165,7 @@ BOOL android_end_paint(rdpContext* context) return TRUE; } -BOOL android_desktop_resize(rdpContext* context) +static BOOL android_desktop_resize(rdpContext* context) { DEBUG_ANDROID("ui_desktop_resize"); @@ -172,7 +179,7 @@ BOOL android_desktop_resize(rdpContext* context) return TRUE; } -BOOL android_pre_connect(freerdp* instance) +static BOOL android_pre_connect(freerdp* instance) { DEBUG_ANDROID("android_pre_connect"); @@ -256,11 +263,12 @@ static BOOL android_post_connect(freerdp* instance) static void android_post_disconnect(freerdp* instance) { + DEBUG_ANDROID("android_post_disconnect"); gdi_free(instance); cache_free(instance->context->cache); } -BOOL android_authenticate(freerdp* instance, char** username, char** password, char** domain) +static BOOL android_authenticate(freerdp* instance, char** username, char** password, char** domain) { DEBUG_ANDROID("Authenticate user:"); DEBUG_ANDROID(" Username: %s", *username); @@ -293,7 +301,7 @@ BOOL android_authenticate(freerdp* instance, char** username, char** password, c return ((res == JNI_TRUE) ? TRUE : FALSE); } -BOOL android_verify_certificate(freerdp* instance, char* subject, char* issuer, char* fingerprint) +static BOOL android_verify_certificate(freerdp* instance, char* subject, char* issuer, char* fingerprint) { DEBUG_ANDROID("Certificate details:"); DEBUG_ANDROID("\tSubject: %s", subject); @@ -317,7 +325,7 @@ BOOL android_verify_certificate(freerdp* instance, char* subject, char* issuer, return ((res == JNI_TRUE) ? TRUE : FALSE); } -BOOL android_verify_changed_certificate(freerdp* instance, char* subject, char* issuer, char* new_fingerprint, char* old_fingerprint) +static BOOL android_verify_changed_certificate(freerdp* instance, char* subject, char* issuer, char* new_fingerprint, char* old_fingerprint) { return android_verify_certificate(instance, subject, issuer, new_fingerprint); } @@ -332,7 +340,7 @@ static void* jni_input_thread(void* arg) assert(NULL != instance); assert(NULL != aCtx); - DEBUG_ANDROID("Start."); + DEBUG_ANDROID("input_thread Start."); if (!(queue = freerdp_get_message_queue(instance, FREERDP_INPUT_MESSAGE_QUEUE))) goto fail_get_message_queue; @@ -365,7 +373,7 @@ static void* jni_input_thread(void* arg) } while(1); - DEBUG_ANDROID("Quit."); + DEBUG_ANDROID("input_thread Quit."); fail_get_message_queue_event: CloseHandle(event[1]); @@ -388,7 +396,7 @@ static void* jni_channels_thread(void* arg) assert(NULL != instance); - DEBUG_ANDROID("Start."); + DEBUG_ANDROID("Channels_thread Start."); channels = instance->context->channels; event = freerdp_channels_get_event_handle(instance); @@ -401,7 +409,7 @@ static void* jni_channels_thread(void* arg) break; } - DEBUG_ANDROID("Quit."); + DEBUG_ANDROID("channels_thread Quit."); ExitThread(0); return NULL; @@ -613,11 +621,11 @@ disconnect: CloseHandle(input_thread); } - DEBUG_ANDROID("Disconnecting..."); + DEBUG_ANDROID("run Disconnecting..."); freerdp_disconnect(instance); freerdp_callback("OnDisconnected", "(I)V", instance); - DEBUG_ANDROID("Quit."); + DEBUG_ANDROID("run Quit."); return 0; } @@ -626,13 +634,13 @@ static void* android_thread_func(void* param) { freerdp* instance = param; - DEBUG_ANDROID("Start."); + DEBUG_ANDROID("android_thread_func Start."); assert(instance); android_freerdp_run(instance); - DEBUG_ANDROID("Quit."); + DEBUG_ANDROID("android_thread_func Quit."); ExitThread(0); return NULL; @@ -649,7 +657,7 @@ JNIEXPORT jint JNICALL jni_freerdp_new(JNIEnv *env, jclass cls) // create instance if (!(instance = freerdp_new())) - return NULL; + return (jint)NULL; instance->PreConnect = android_pre_connect; instance->PostConnect = android_post_connect; instance->PostDisconnect = android_post_disconnect; @@ -667,6 +675,7 @@ JNIEXPORT jint JNICALL jni_freerdp_new(JNIEnv *env, jclass cls) freerdp_free(instance); instance = NULL; } + WLog_SetLogLevel(WLog_GetRoot(), WLOG_DEBUG); return (jint) instance; } @@ -705,6 +714,8 @@ JNIEXPORT jboolean JNICALL jni_freerdp_disconnect(JNIEnv *env, jclass cls, jint freerdp* inst = (freerdp*)instance; androidContext* ctx = (androidContext*)inst->context; ANDROID_EVENT* event = (ANDROID_EVENT*)android_event_disconnect_new(); + DEBUG_ANDROID("DISCONNECT!"); + WLog_ERR(ANDROID_TAG, "Disconnect shit"); assert(inst); assert(ctx); @@ -721,43 +732,70 @@ JNIEXPORT jboolean JNICALL jni_freerdp_disconnect(JNIEnv *env, jclass cls, jint return (jboolean) JNI_TRUE; } -JNIEXPORT void JNICALL jni_freerdp_cancel_connection(JNIEnv *env, jclass cls, jint instance) +JNIEXPORT jboolean JNICALL jni_freerdp_cancel_connection(JNIEnv *env, jclass cls, jint instance) { - jni_freerdp_disconnect(env, cls, instance); + return jni_freerdp_disconnect(env, cls, instance); } -JNIEXPORT void JNICALL jni_freerdp_set_data_directory(JNIEnv *env, jclass cls, jint instance, jstring jdirectory) +JNIEXPORT jboolean JNICALL jni_freerdp_set_data_directory(JNIEnv *env, jclass cls, jint instance, jstring jdirectory) { freerdp* inst = (freerdp*)instance; rdpSettings * settings = inst->settings; - const jbyte *directory = (*env)->GetStringUTFChars(env, jdirectory, NULL); + const jbyte* directory = (*env)->GetStringUTFChars(env, jdirectory, NULL); + if (!directory) + return JNI_FALSE; free(settings->HomePath); free(settings->ConfigPath); int config_dir_len = strlen(directory) + 10; /* +9 chars for /.freerdp and +1 for \0 */ char* config_dir_buf = (char*)malloc(config_dir_len); + if (!config_dir_buf) + goto out_malloc_fail; + strcpy(config_dir_buf, directory); strcat(config_dir_buf, "/.freerdp"); settings->HomePath = strdup(directory); + if (!settings->HomePath) + goto out_strdup_fail; settings->ConfigPath = config_dir_buf; /* will be freed by freerdp library */ (*env)->ReleaseStringUTFChars(env, jdirectory, directory); + return JNI_TRUE; + +out_strdup_fail: + free(config_dir_buf); +out_malloc_fail: + (*env)->ReleaseStringUTFChars(env, jdirectory, directory); + return JNI_FALSE; + } -JNIEXPORT void JNICALL jni_freerdp_set_connection_info(JNIEnv *env, jclass cls, jint instance, +JNIEXPORT jboolean JNICALL jni_freerdp_set_connection_info(JNIEnv *env, jclass cls, jint instance, jstring jhostname, jstring jusername, jstring jpassword, jstring jdomain, jint width, jint height, jint color_depth, jint port, jboolean console, jint security, jstring jcertname) { freerdp* inst = (freerdp*)instance; rdpSettings * settings = inst->settings; - const jbyte *hostname = (*env)->GetStringUTFChars(env, jhostname, NULL); - const jbyte *username = (*env)->GetStringUTFChars(env, jusername, NULL); - const jbyte *password = (*env)->GetStringUTFChars(env, jpassword, NULL); - const jbyte *domain = (*env)->GetStringUTFChars(env, jdomain, NULL); - const jbyte *certname = (*env)->GetStringUTFChars(env, jcertname, NULL); + const jbyte *hostname; + const jbyte *username; + const jbyte *password; + const jbyte *domain; + const jbyte *certname; + + if(!(hostname = (*env)->GetStringUTFChars(env, jhostname, NULL))) + return JNI_FALSE; + if (!(username = (*env)->GetStringUTFChars(env, jusername, NULL))) + goto out_fail_username; + if (!(password = (*env)->GetStringUTFChars(env, jpassword, NULL))) + goto out_fail_password; + if (!(domain = (*env)->GetStringUTFChars(env, jdomain, NULL))) + goto out_fail_domain; + if (!(certname = (*env)->GetStringUTFChars(env, jcertname, NULL))) + goto out_fail_certname; + DEBUG_ANDROID("hostname: %s", (char*) hostname); DEBUG_ANDROID("username: %s", (char*) username); @@ -779,21 +817,30 @@ JNIEXPORT void JNICALL jni_freerdp_set_connection_info(JNIEnv *env, jclass cls, if (color_depth <= 16) settings->DesktopWidth &= (~1); - settings->ServerHostname = strdup(hostname); + if (!(settings->ServerHostname = strdup(hostname))) + goto out_fail_strdup; if (username && strlen(username) > 0) - settings->Username = strdup(username); + { + if (!(settings->Username = strdup(username))) + goto out_fail_strdup; + } if (password && strlen(password) > 0) { - settings->Password = strdup(password); + if (!(settings->Password = strdup(password))) + goto out_fail_strdup; settings->AutoLogonEnabled = TRUE; } - settings->Domain = strdup(domain); + if (!(settings->Domain = strdup(domain))) + goto out_fail_strdup; if (certname && strlen(certname) > 0) - settings->CertificateName = strdup(certname); + { + if (!(settings->CertificateName = strdup(certname))) + goto out_fail_strdup; + } settings->ConsoleSession = (console == JNI_TRUE) ? TRUE : FALSE; @@ -840,7 +887,20 @@ JNIEXPORT void JNICALL jni_freerdp_set_connection_info(JNIEnv *env, jclass cls, (*env)->ReleaseStringUTFChars(env, jdomain, domain); (*env)->ReleaseStringUTFChars(env, jcertname, certname); - return; + return JNI_TRUE; + + +out_fail_strdup: + (*env)->ReleaseStringUTFChars(env, jcertname, certname); +out_fail_certname: + (*env)->ReleaseStringUTFChars(env, jdomain, domain); +out_fail_domain: + (*env)->ReleaseStringUTFChars(env, jpassword, password); +out_fail_password: + (*env)->ReleaseStringUTFChars(env, jusername, username); +out_fail_username: + (*env)->ReleaseStringUTFChars(env, jhostname, hostname); + return JNI_FALSE; } JNIEXPORT void JNICALL jni_freerdp_set_performance_flags( @@ -881,16 +941,23 @@ 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, +JNIEXPORT jboolean 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; + jboolean ret = JNI_FALSE; - const jbyte *remote_program = (*env)->GetStringUTFChars(env, jRemoteProgram, NULL); - const jbyte *work_dir = (*env)->GetStringUTFChars(env, jWorkDir, NULL); + const jbyte *remote_program; + const jbyte *work_dir; + + if (!(remote_program = (*env)->GetStringUTFChars(env, jRemoteProgram, NULL))) + return JNI_FALSE; + + if (!(work_dir = (*env)->GetStringUTFChars(env, jWorkDir, NULL))) + goto out_fail_work_dir; DEBUG_ANDROID("Remote Program: %s", (char*) remote_program); DEBUG_ANDROID("Work Dir: %s", (char*) work_dir); @@ -902,32 +969,54 @@ JNIEXPORT void JNICALL jni_freerdp_set_advanced_settings(JNIEnv *env, jclass cls settings->AsyncInput = async_input; if (remote_program && strlen(remote_program) > 0) - settings->AlternateShell = strdup(remote_program); + { + if (!(settings->AlternateShell = strdup(remote_program))) + goto out_fail_strdup; + } if (work_dir && strlen(work_dir) > 0) - settings->ShellWorkingDirectory = strdup(work_dir); + { + if (!(settings->ShellWorkingDirectory = strdup(work_dir))) + goto out_fail_strdup; + } - (*env)->ReleaseStringUTFChars(env, jRemoteProgram, remote_program); + ret = JNI_TRUE; + +out_fail_strdup: (*env)->ReleaseStringUTFChars(env, jWorkDir, work_dir); +out_fail_work_dir: + (*env)->ReleaseStringUTFChars(env, jRemoteProgram, remote_program); + return ret; } -JNIEXPORT void JNICALL jni_freerdp_set_drive_redirection(JNIEnv *env, jclass cls, jint instance, jstring jpath) +JNIEXPORT jboolean JNICALL jni_freerdp_set_drive_redirection(JNIEnv *env, jclass cls, jint instance, jstring jpath) { freerdp* inst = (freerdp*)instance; rdpSettings * settings = inst->settings; char* args[] = {"drive", "Android", ""}; + jboolean ret = JNI_FALSE; const jbyte *path = (*env)->GetStringUTFChars(env, jpath, NULL); + if (!path) + return JNI_FALSE; DEBUG_ANDROID("drive redirect: %s", (char*)path); args[2] = (char*)path; - freerdp_client_add_device_channel(settings, 3, args); + if (freerdp_client_add_device_channel(settings, 3, args) == -1) + { + settings->DeviceRedirection = FALSE; + goto out_fail; + } + settings->DeviceRedirection = TRUE; + ret = JNI_TRUE; +out_fail: (*env)->ReleaseStringUTFChars(env, jpath, path); + return ret; } -JNIEXPORT void JNICALL jni_freerdp_set_sound_redirection(JNIEnv *env, +JNIEXPORT jboolean JNICALL jni_freerdp_set_sound_redirection(JNIEnv *env, jclass cls, jint instance, jint redirect) { char** p; @@ -939,19 +1028,28 @@ JNIEXPORT void JNICALL jni_freerdp_set_sound_redirection(JNIEnv *env, redirect ? ((redirect == 1) ? "Server" : "Redirect") : "None"); settings->AudioPlayback = (redirect == 2) ? TRUE : FALSE; - settings->RemoteConsoleAudio = (redirect == 1) ? TRUE : FALSE; if (settings->AudioPlayback) { + int ret; p = malloc(sizeof(char*)); + if (!p) + { + settings->AudioPlayback = FALSE; + return JNI_FALSE; + } p[0] = "rdpsnd"; - freerdp_client_add_static_channel(settings, count, p); - + ret = freerdp_client_add_static_channel(settings, count, p); free(p); + + if(ret == -1) + return JNI_FALSE; } + settings->RemoteConsoleAudio = (redirect == 1) ? TRUE : FALSE; + return JNI_TRUE; } -JNIEXPORT void JNICALL jni_freerdp_set_microphone_redirection(JNIEnv *env, +JNIEXPORT jboolean JNICALL jni_freerdp_set_microphone_redirection(JNIEnv *env, jclass cls, jint instance, jboolean enable) { char** p; @@ -964,13 +1062,23 @@ JNIEXPORT void JNICALL jni_freerdp_set_microphone_redirection(JNIEnv *env, settings->AudioCapture = enable; if (enable) { + int ret; p = malloc(sizeof(char*)); + if (!p) + { + settings->AudioCapture = FALSE; + return JNI_FALSE; + } p[0] = "audin"; - freerdp_client_add_dynamic_channel(settings, count, p); - + ret = freerdp_client_add_dynamic_channel(settings, count, p); free(p); + + if (ret == -1) + return JNI_FALSE; + } + return JNI_TRUE; } JNIEXPORT void JNICALL jni_freerdp_set_clipboard_redirection(JNIEnv *env, jclass cls, jint instance, jboolean enable) @@ -983,16 +1091,26 @@ 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, +JNIEXPORT jboolean 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; + jboolean ret = JNI_FALSE; - 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); + const jbyte *gatewayhostname; + const jbyte *gatewayusername; + const jbyte *gatewaypassword; + const jbyte *gatewaydomain; + + if (!(gatewayhostname = (*env)->GetStringUTFChars(env, jgatewayhostname, NULL))) + return JNI_FALSE; + if (!(gatewayusername = (*env)->GetStringUTFChars(env, jgatewayusername, NULL))) + goto out_fail_username; + if (!(gatewaypassword = (*env)->GetStringUTFChars(env, jgatewaypassword, NULL))) + goto out_fail_password; + if (!(gatewaydomain = (*env)->GetStringUTFChars(env, jgatewaydomain, NULL))) + goto out_fail_domain; DEBUG_ANDROID("gatewayhostname: %s", (char*) gatewayhostname); DEBUG_ANDROID("gatewayport: %d", port); @@ -1000,19 +1118,33 @@ JNIEXPORT void JNICALL jni_freerdp_set_gateway_info(JNIEnv *env, jclass cls, jin 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 = TSC_PROXY_MODE_DIRECT; settings->GatewayEnabled = TRUE; settings->GatewayUseSameCredentials = FALSE; + settings->GatewayHostname = strdup(gatewayhostname); + settings->GatewayUsername = strdup(gatewayusername); + settings->GatewayPassword = strdup(gatewaypassword); + settings->GatewayDomain = strdup(gatewaydomain); + if (!settings->GatewayHostname || !settings->GatewayUsername || + !settings->GatewayPassword || !settings->GatewayDomain) + { + goto out_fail_strdup; + } - (*env)->ReleaseStringUTFChars(env, jgatewayhostname, gatewayhostname); - (*env)->ReleaseStringUTFChars(env, jgatewayusername, gatewayusername); - (*env)->ReleaseStringUTFChars(env, jgatewaypassword, gatewaypassword); + + ret = JNI_TRUE; + +out_fail_strdup: (*env)->ReleaseStringUTFChars(env, jgatewaydomain, gatewaydomain); +out_fail_domain: + (*env)->ReleaseStringUTFChars(env, jgatewaypassword, gatewaypassword); +out_fail_password: + (*env)->ReleaseStringUTFChars(env, jgatewayusername, gatewayusername); +out_fail_username: + (*env)->ReleaseStringUTFChars(env, jgatewayhostname, gatewayhostname); + + return ret; } static void copy_pixel_buffer(UINT8* dstBuf, UINT8* srcBuf, int x, int y, int width, int height, int wBuf, int hBuf, int bpp) @@ -1065,7 +1197,7 @@ JNIEXPORT jboolean JNICALL jni_freerdp_update_graphics( return JNI_TRUE; } -JNIEXPORT void JNICALL jni_freerdp_send_key_event( +JNIEXPORT jboolean JNICALL jni_freerdp_send_key_event( JNIEnv *env, jclass cls, jint instance, jint keycode, jboolean down) { DWORD scancode; @@ -1077,54 +1209,86 @@ JNIEXPORT void JNICALL jni_freerdp_send_key_event( int flags = (down == JNI_TRUE) ? KBD_FLAGS_DOWN : KBD_FLAGS_RELEASE; flags |= (scancode & KBDEXT) ? KBD_FLAGS_EXTENDED : 0; event = (ANDROID_EVENT*) android_event_key_new(flags, scancode & 0xFF); + if (!event) + return JNI_FALSE; - android_push_event(inst, event); + if (!android_push_event(inst, event)) + { + android_event_key_free((ANDROID_EVENT_KEY *)event); + return JNI_FALSE; + } DEBUG_ANDROID("send_key_event: %d, %d", (int)scancode, flags); + return JNI_TRUE; } -JNIEXPORT void JNICALL jni_freerdp_send_unicodekey_event( +JNIEXPORT jboolean JNICALL jni_freerdp_send_unicodekey_event( JNIEnv *env, jclass cls, jint instance, jint keycode) { ANDROID_EVENT* event; freerdp* inst = (freerdp*)instance; event = (ANDROID_EVENT*) android_event_unicodekey_new(keycode); - android_push_event(inst, event); + if (!event) + return JNI_FALSE; + if (!android_push_event(inst, event)) + { + android_event_unicodekey_free((ANDROID_EVENT_KEY *)event); + return JNI_FALSE; + } DEBUG_ANDROID("send_unicodekey_event: %d", keycode); + return JNI_TRUE; } -JNIEXPORT void JNICALL jni_freerdp_send_cursor_event( +JNIEXPORT jboolean JNICALL jni_freerdp_send_cursor_event( JNIEnv *env, jclass cls, jint instance, jint x, jint y, jint flags) { ANDROID_EVENT* event; freerdp* inst = (freerdp*)instance; event = (ANDROID_EVENT*) android_event_cursor_new(flags, x, y); - android_push_event(inst, event); + if (!event) + return JNI_FALSE; + + if (!android_push_event(inst, event)) + { + android_event_cursor_free((ANDROID_EVENT_CURSOR *)event); + return JNI_FALSE; + } DEBUG_ANDROID("send_cursor_event: (%d, %d), %d", x, y, flags); + return JNI_TRUE; } -JNIEXPORT void JNICALL jni_freerdp_send_clipboard_data(JNIEnv *env, jclass cls, jint instance, jstring jdata) +JNIEXPORT jboolean JNICALL jni_freerdp_send_clipboard_data(JNIEnv *env, jclass cls, jint instance, jstring jdata) { ANDROID_EVENT* event; freerdp* inst = (freerdp*)instance; const jbyte *data = jdata != NULL ? (*env)->GetStringUTFChars(env, jdata, NULL) : NULL; int data_length = data ? strlen(data) : 0; + jboolean ret = JNI_FALSE;; event = (ANDROID_EVENT*) android_event_clipboard_new((void*)data, data_length); - android_push_event(inst, event); + if (!event) + goto out_fail; + + if (!android_push_event(inst, event)) + { + android_event_clipboard_free((ANDROID_EVENT_CLIPBOARD *)event); + goto out_fail; + } DEBUG_ANDROID("send_clipboard_data: (%s)", data); + ret = JNI_TRUE; +out_fail: if (data) (*env)->ReleaseStringUTFChars(env, jdata, data); + return ret; } JNIEXPORT jstring JNICALL jni_freerdp_get_version(JNIEnv *env, jclass cls) { return (*env)->NewStringUTF(env, GIT_REVISION); } - diff --git a/client/Android/FreeRDPCore/jni/android_freerdp.h b/client/Android/FreeRDPCore/jni/android_freerdp.h index dd36a65d1..d6f5f4dfe 100644 --- a/client/Android/FreeRDPCore/jni/android_freerdp.h +++ b/client/Android/FreeRDPCore/jni/android_freerdp.h @@ -44,27 +44,27 @@ JNIEXPORT jint JNICALL jni_freerdp_new(JNIEnv *env, jclass cls); JNIEXPORT void JNICALL jni_freerdp_free(JNIEnv *env, jclass cls, jint instance); JNIEXPORT jboolean JNICALL jni_freerdp_connect(JNIEnv *env, jclass cls, jint instance); JNIEXPORT jboolean JNICALL jni_freerdp_disconnect(JNIEnv *env, jclass cls, jint instance); -JNIEXPORT void JNICALL jni_freerdp_cancel_connection(JNIEnv *env, jclass cls, jint instance); -JNIEXPORT void JNICALL jni_freerdp_set_connection_info(JNIEnv *env, jclass cls, jint instance, +JNIEXPORT jboolean JNICALL jni_freerdp_cancel_connection(JNIEnv *env, jclass cls, jint instance); +JNIEXPORT jboolean JNICALL jni_freerdp_set_connection_info(JNIEnv *env, jclass cls, jint instance, jstring jhostname, jstring jusername, jstring jpassword, jstring jdomain, jint width, 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, +JNIEXPORT jboolean 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); +JNIEXPORT jboolean JNICALL jni_freerdp_set_drive_redirection(JNIEnv *env, jclass cls, jint instance, jstring jpath); +JNIEXPORT jboolean JNICALL jni_freerdp_set_sound_redirection(JNIEnv *env, jclass cls, jint instance, jint redirect); +JNIEXPORT jboolean JNICALL jni_freerdp_set_microphone_redirection(JNIEnv *env, jclass cls, jint instance, jboolean enable); 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_set_gateway_info(JNIEnv *env, jclass cls, jint instance, jstring jgatewayhostname, jint port, jstring jgatewayusername, jstring jgatewaypassword, jstring jgatewaydomain); +JNIEXPORT jboolean 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); -JNIEXPORT void JNICALL jni_freerdp_send_key_event(JNIEnv *env, jclass cls, jint instance, jint keycode, jboolean down); -JNIEXPORT void JNICALL jni_freerdp_send_unicodekey_event(JNIEnv *env, jclass cls, jint instance, jint keycode); -JNIEXPORT void JNICALL jni_freerdp_send_clipboard_data(JNIEnv *env, jclass cls, jint instance, jstring jdata); +JNIEXPORT jboolean JNICALL jni_freerdp_send_cursor_event(JNIEnv *env, jclass cls, jint instance, jint x, jint y, jint flags); +JNIEXPORT jboolean JNICALL jni_freerdp_send_key_event(JNIEnv *env, jclass cls, jint instance, jint keycode, jboolean down); +JNIEXPORT jboolean JNICALL jni_freerdp_send_unicodekey_event(JNIEnv *env, jclass cls, jint instance, jint keycode); +JNIEXPORT jboolean JNICALL jni_freerdp_send_clipboard_data(JNIEnv *env, jclass cls, jint instance, jstring jdata); JNIEXPORT jstring JNICALL jni_freerdp_get_version(JNIEnv *env, jclass cls); #endif /* __ANDROID_FREERDP_H */ diff --git a/client/Android/FreeRDPCore/jni/android_jni_utils.c b/client/Android/FreeRDPCore/jni/android_jni_utils.c index f83f74938..eef868789 100644 --- a/client/Android/FreeRDPCore/jni/android_jni_utils.c +++ b/client/Android/FreeRDPCore/jni/android_jni_utils.c @@ -99,6 +99,8 @@ char* get_string_from_string_builder(JNIEnv* env, jobject strBuilder) // read string native_str = (*env)->GetStringUTFChars(env, strObj, NULL); + if (!native_str) + return NULL; result = strdup(native_str); (*env)->ReleaseStringUTFChars(env, strObj, native_str); diff --git a/client/Android/FreeRDPCore/jni/generated/android_freerdp_jni.c b/client/Android/FreeRDPCore/jni/generated/android_freerdp_jni.c index bcc61ca94..77b9137fb 100644 --- a/client/Android/FreeRDPCore/jni/generated/android_freerdp_jni.c +++ b/client/Android/FreeRDPCore/jni/generated/android_freerdp_jni.c @@ -40,32 +40,32 @@ JNIEXPORT jboolean JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_free return jni_freerdp_disconnect(env, cls, instance); } -JNIEXPORT void JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1cancel_1connection(JNIEnv *env, jclass cls, jint instance) +JNIEXPORT jboolean JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1cancel_1connection(JNIEnv *env, jclass cls, jint instance) { - jni_freerdp_cancel_connection(env, cls, instance); + return jni_freerdp_cancel_connection(env, cls, instance); } -JNIEXPORT void JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1set_1connection_1info(JNIEnv *env, jclass cls, jint instance, +JNIEXPORT jboolean JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1set_1connection_1info(JNIEnv *env, jclass cls, jint instance, jstring jhostname, jstring jusername, jstring jpassword, jstring jdomain, jint width, jint height, jint color_depth, jint port, jboolean console, jint security, jstring certname) { - jni_freerdp_set_connection_info(env, cls, instance, jhostname, jusername, jpassword, jdomain, + return jni_freerdp_set_connection_info(env, cls, instance, jhostname, jusername, jpassword, jdomain, width, height, color_depth, port, console, security, certname); } -JNIEXPORT void JNICALL +JNIEXPORT jboolean 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, + return 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) +JNIEXPORT jboolean JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1set_1data_1directory(JNIEnv *env, jclass cls, jint instance, jstring directory) { - jni_freerdp_set_data_directory(env, cls, instance, directory); + return jni_freerdp_set_data_directory(env, cls, instance, directory); } JNIEXPORT void JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1set_1performance_1flags( @@ -81,28 +81,28 @@ JNIEXPORT void JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_ jni_freerdp_set_clipboard_redirection(env, cls, inst, enable); } -JNIEXPORT void JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1set_1sound_1redirection +JNIEXPORT jboolean JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1set_1sound_1redirection (JNIEnv *env, jclass cls, jint inst, jint redirect) { - jni_freerdp_set_sound_redirection(env, cls, inst, redirect); + return jni_freerdp_set_sound_redirection(env, cls, inst, redirect); } -JNIEXPORT void JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1set_1microphone_1redirection +JNIEXPORT jboolean JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1set_1microphone_1redirection (JNIEnv *env, jclass cls, jint inst, jboolean redirect) { - jni_freerdp_set_microphone_redirection(env, cls, inst, redirect); + return jni_freerdp_set_microphone_redirection(env, cls, inst, redirect); } -JNIEXPORT void JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1set_1drive_1redirection +JNIEXPORT jboolean JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1set_1drive_1redirection (JNIEnv *env, jclass cls, jint inst, jstring path) { - jni_freerdp_set_drive_redirection(env, cls, inst, path); + return jni_freerdp_set_drive_redirection(env, cls, inst, path); } -JNIEXPORT void JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1set_1gateway_1info +JNIEXPORT jboolean 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); + return 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( @@ -111,28 +111,28 @@ JNIEXPORT jboolean JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_free return jni_freerdp_update_graphics(env, cls, instance, bitmap, x, y, width, height); } -JNIEXPORT void JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1send_1cursor_1event( +JNIEXPORT jboolean JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1send_1cursor_1event( JNIEnv *env, jclass cls, jint instance, jint x, jint y, jint flags) { - jni_freerdp_send_cursor_event(env, cls, instance, x, y, flags); + return jni_freerdp_send_cursor_event(env, cls, instance, x, y, flags); } -JNIEXPORT void JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1send_1key_1event( +JNIEXPORT jboolean JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1send_1key_1event( JNIEnv *env, jclass cls, jint instance, jint keycode, jboolean down) { - jni_freerdp_send_key_event(env, cls, instance, keycode, down); + return jni_freerdp_send_key_event(env, cls, instance, keycode, down); } -JNIEXPORT void JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1send_1unicodekey_1event +JNIEXPORT jboolean JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1send_1unicodekey_1event (JNIEnv *env, jclass cls, jint instance, jint keycode) { - jni_freerdp_send_unicodekey_event(env, cls, instance, keycode); + return jni_freerdp_send_unicodekey_event(env, cls, instance, keycode); } -JNIEXPORT void JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1send_1clipboard_1data +JNIEXPORT jboolean JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1send_1clipboard_1data (JNIEnv *env, jclass cls, jint instance, jstring data) { - jni_freerdp_send_clipboard_data(env, cls, instance, data); + return jni_freerdp_send_clipboard_data(env, cls, instance, data); } JNIEXPORT jstring JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1get_1version(JNIEnv *env, jclass cls) 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 951567bbb..50b0c74f8 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 @@ -42,17 +42,17 @@ JNIEXPORT jboolean JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_free /* * Class: com_freerdp_freerdpcore_services_LibFreeRDP * Method: freerdp_cancel_connection - * Signature: (I)V + * Signature: (I)Z */ -JNIEXPORT void JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1cancel_1connection +JNIEXPORT jboolean JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1cancel_1connection (JNIEnv *, jclass, jint); /* * Class: com_freerdp_freerdpcore_services_LibFreeRDP * Method: freerdp_set_connection_info - * Signature: (ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;IIIIZILjava/lang/String;)V + * Signature: (ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;IIIIZILjava/lang/String;)Z */ -JNIEXPORT void JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1set_1connection_1info +JNIEXPORT jboolean JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1set_1connection_1info (JNIEnv *, jclass, jint, jstring, jstring, jstring, jstring, jint, jint, jint, jint, jboolean, jint, jstring); /* @@ -66,17 +66,17 @@ 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;ZZZZ)V + * Signature: (ILjava/lang/String;Ljava/lang/String;ZZZZ)Z */ -JNIEXPORT void JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1set_1advanced_1settings +JNIEXPORT jboolean JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1set_1advanced_1settings (JNIEnv *, jclass, jint, jstring, jstring, jboolean, jboolean, jboolean, jboolean); /* * Class: com_freerdp_freerdpcore_services_LibFreeRDP * Method: freerdp_set_data_directory - * Signature: (ILjava/lang/String;)V + * Signature: (ILjava/lang/String;)Z */ -JNIEXPORT void JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1set_1data_1directory +JNIEXPORT jboolean JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1set_1data_1directory (JNIEnv *, jclass, jint, jstring); /* @@ -90,33 +90,33 @@ JNIEXPORT void JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_ /* * Class: com_freerdp_freerdpcore_services_LibFreeRDP * Method: freerdp_set_sound_redirection - * Signature: (IZ)V + * Signature: (II)Z */ -JNIEXPORT void JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1set_1sound_1redirection +JNIEXPORT jboolean JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1set_1sound_1redirection (JNIEnv *, jclass, jint, jint); /* * Class: com_freerdp_freerdpcore_services_LibFreeRDP * Method: freerdp_set_microphone_redirection - * Signature: (IZ)V + * Signature: (IZ)Z */ -JNIEXPORT void JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1set_1microphone_1redirection +JNIEXPORT jboolean JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1set_1microphone_1redirection (JNIEnv *, jclass, jint, jboolean); /* * Class: com_freerdp_freerdpcore_services_LibFreeRDP * Method: freerdp_set_drive_redirection - * Signature: (ILjava/lang/String;)V + * Signature: (ILjava/lang/String;)Z */ -JNIEXPORT void JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1set_1drive_1redirection +JNIEXPORT jboolean 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 + * Signature: (ILjava/lang/String;ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;)Z */ -JNIEXPORT void JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1set_1gateway_1info +JNIEXPORT jboolean JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1set_1gateway_1info (JNIEnv *, jclass, jint, jstring, jint, jstring, jstring, jstring); /* @@ -130,33 +130,33 @@ JNIEXPORT jboolean JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_free /* * Class: com_freerdp_freerdpcore_services_LibFreeRDP * Method: freerdp_send_cursor_event - * Signature: (IIII)V + * Signature: (IIII)Z */ -JNIEXPORT void JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1send_1cursor_1event +JNIEXPORT jboolean JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1send_1cursor_1event (JNIEnv *, jclass, jint, jint, jint, jint); /* * Class: com_freerdp_freerdpcore_services_LibFreeRDP * Method: freerdp_send_key_event - * Signature: (IIZ)V + * Signature: (IIZ)Z */ -JNIEXPORT void JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1send_1key_1event +JNIEXPORT jboolean JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1send_1key_1event (JNIEnv *, jclass, jint, jint, jboolean); /* * Class: com_freerdp_freerdpcore_services_LibFreeRDP * Method: freerdp_send_unicodekey_event - * Signature: (II)V + * Signature: (II)Z */ -JNIEXPORT void JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1send_1unicodekey_1event +JNIEXPORT jboolean JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1send_1unicodekey_1event (JNIEnv *, jclass, jint, jint); /* * Class: com_freerdp_freerdpcore_services_LibFreeRDP * Method: freerdp_send_clipboard_data - * Signature: (ILjava/lang/String;)V + * Signature: (ILjava/lang/String;)Z */ -JNIEXPORT void JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1send_1clipboard_1data +JNIEXPORT jboolean JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1send_1clipboard_1data (JNIEnv *, jclass, jint, jstring); /* 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 934404a7a..c5e896f34 100644 --- a/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/services/LibFreeRDP.java +++ b/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/services/LibFreeRDP.java @@ -23,9 +23,9 @@ public class LibFreeRDP private static native void freerdp_free(int inst); private static native boolean freerdp_connect(int inst); private static native boolean freerdp_disconnect(int inst); - private static native void freerdp_cancel_connection(int inst); + private static native boolean freerdp_cancel_connection(int inst); - private static native void freerdp_set_connection_info(int inst, + private static native boolean freerdp_set_connection_info(int inst, String hostname, String username, String password, String domain, int width, int height, int color_depth, int port, boolean console, int security, String certname); @@ -35,27 +35,27 @@ public class LibFreeRDP boolean disableMenuAnimations, boolean disableTheming, boolean enableFontSmoothing, boolean enableDesktopComposition); - private static native void freerdp_set_advanced_settings(int inst, + private static native boolean 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); + private static native boolean freerdp_set_data_directory(int inst, String directory); private static native void freerdp_set_clipboard_redirection(int inst, boolean enable); - private static native void freerdp_set_sound_redirection(int inst, int redirect); - private static native void freerdp_set_microphone_redirection(int inst, boolean enable); - private static native void freerdp_set_drive_redirection(int inst, String path); + private static native boolean freerdp_set_sound_redirection(int inst, int redirect); + private static native boolean freerdp_set_microphone_redirection(int inst, boolean enable); + private static native boolean freerdp_set_drive_redirection(int inst, String path); - private static native void freerdp_set_gateway_info(int inst, String gatewayhostname, int port, + private static native boolean 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); - private static native void freerdp_send_cursor_event(int inst, int x, int y, int flags); - private static native void freerdp_send_key_event(int inst, int keycode, boolean down); - private static native void freerdp_send_unicodekey_event(int inst, int keycode); - private static native void freerdp_send_clipboard_data(int inst, String data); + private static native boolean freerdp_send_cursor_event(int inst, int x, int y, int flags); + private static native boolean freerdp_send_key_event(int inst, int keycode, boolean down); + private static native boolean freerdp_send_unicodekey_event(int inst, int keycode); + private static native boolean freerdp_send_clipboard_data(int inst, String data); private static native String freerdp_get_version(); @@ -106,9 +106,9 @@ public class LibFreeRDP return freerdp_disconnect(inst); } - public static void cancelConnection(int inst) + public static boolean cancelConnection(int inst) { - freerdp_cancel_connection(inst); + return freerdp_cancel_connection(inst); } public static boolean setConnectionInfo(int inst, BookmarkBase bookmark) @@ -185,9 +185,9 @@ public class LibFreeRDP return true; } - public static void setDataDirectory(int inst, String directory) + public static boolean setDataDirectory(int inst, String directory) { - freerdp_set_data_directory(inst, directory); + return freerdp_set_data_directory(inst, directory); } public static boolean updateGraphics(int inst, Bitmap bitmap, int x, int y, int width, int height) @@ -195,24 +195,24 @@ public class LibFreeRDP return freerdp_update_graphics(inst, bitmap, x, y, width, height); } - public static void sendCursorEvent(int inst, int x, int y, int flags) + public static boolean sendCursorEvent(int inst, int x, int y, int flags) { - freerdp_send_cursor_event(inst, x, y, flags); + return freerdp_send_cursor_event(inst, x, y, flags); } - public static void sendKeyEvent(int inst, int keycode, boolean down) + public static boolean sendKeyEvent(int inst, int keycode, boolean down) { - freerdp_send_key_event(inst, keycode, down); + return freerdp_send_key_event(inst, keycode, down); } - public static void sendUnicodeKeyEvent(int inst, int keycode) + public static boolean sendUnicodeKeyEvent(int inst, int keycode) { - freerdp_send_unicodekey_event(inst, keycode); + return freerdp_send_unicodekey_event(inst, keycode); } - public static void sendClipboardData(int inst, String data) + public static boolean sendClipboardData(int inst, String data) { - freerdp_send_clipboard_data(inst, data); + return freerdp_send_clipboard_data(inst, data); } private static void OnConnectionSuccess(int inst) diff --git a/cmake/ConfigOptionsAndroid.cmake b/cmake/ConfigOptionsAndroid.cmake index 6bf171869..780b4e18b 100644 --- a/cmake/ConfigOptionsAndroid.cmake +++ b/cmake/ConfigOptionsAndroid.cmake @@ -28,6 +28,6 @@ option(ANDROID_BUILD_JAVA_DEBUG "Create a android debug package" ${JAVA_DEBUG_DE set(ANDROID_APP_VERSION 3 CACHE STRING "Application version") set(ANDROID_APP_TARGET_SDK 21 CACHE STRING "Application target android SDK") -set(ANDROID_APP_MIN_SDK 9 CACHE STRING "Application minimum android SDK requirement") +set(ANDROID_APP_MIN_SDK 14 CACHE STRING "Application minimum android SDK requirement") set(ANDROID_APP_GOOGLE_TARGET_SDK "16" CACHE STRING "Application target google SDK") diff --git a/docs/README.android b/docs/README.android index d64bbd5df..32ee242c8 100644 --- a/docs/README.android +++ b/docs/README.android @@ -209,6 +209,6 @@ After that FreeRDP and the Android package need to be rebuilt to include the lat Android CMake related Variables ------------------------------- -ANDROID_APP_TARGET_SDK ... specifies the desired android target SDK, currently 11 -ANDROID_APP_MIN_SDK ... specifies the minimum android SDK version supported, currently 8 +ANDROID_APP_TARGET_SDK ... specifies the desired android target SDK, currently 21 +ANDROID_APP_MIN_SDK ... specifies the minimum android SDK version supported, currently 14 ANDROID_APP_GOOGLE_TARGET_SDK ... specifies the minimum google SDK requirement, currently 16