#include <freerdp/utils/event.h>
#include <freerdp/constants.h>
#include <freerdp/locale/keyboard.h>
+#include <freerdp/primitives.h>
+#include <freerdp/version.h>
#include <android/bitmap.h>
return TRUE;
}
-BOOL android_post_connect(freerdp* instance)
+static BOOL android_post_connect(freerdp* instance)
{
+ rdpSettings *settings = instance->settings;
+
DEBUG_ANDROID("android_post_connect");
+ assert(instance);
+ assert(settings);
+
freerdp_callback("OnSettingsChanged", "(IIII)V", instance,
- instance->settings->DesktopWidth, instance->settings->DesktopHeight,
- instance->settings->ColorDepth);
+ settings->DesktopWidth, settings->DesktopHeight,
+ settings->ColorDepth);
- instance->context->cache = cache_new(instance->settings);
+ instance->context->cache = cache_new(settings);
- gdi_init(instance, CLRCONV_ALPHA | ((instance->settings->ColorDepth > 16) ? CLRBUF_32BPP : CLRBUF_16BPP), NULL);
+ gdi_init(instance, CLRCONV_ALPHA | CLRCONV_INVERT |
+ ((instance->settings->ColorDepth > 16) ? CLRBUF_32BPP : CLRBUF_16BPP),
+ NULL);
instance->update->BeginPaint = android_begin_paint;
instance->update->EndPaint = android_end_paint;
return TRUE;
}
+static void android_post_disconnect(freerdp* instance)
+{
+ gdi_free(instance);
+ cache_free(instance->context->cache);
+ android_cliprdr_uninit(instance);
+}
+
BOOL android_authenticate(freerdp* instance, char** username, char** password, char** domain)
{
DEBUG_ANDROID("Authenticate user:");
int rcount;
int wcount;
int fd_input_event;
- HANDLE input_event;
+ HANDLE input_event = NULL;
void* rfds[32];
void* wfds[32];
fd_set rfds_set;
(LPTHREAD_START_ROUTINE) jni_update_thread, instance, 0, NULL);
}
- if (async_input)
+ if (async_input)
{
input_thread = CreateThread(NULL, 0,
(LPTHREAD_START_ROUTINE) jni_input_thread, instance, 0, NULL);
break;
}
}
- else
+ else if (input_event)
{
if (WaitForSingleObject(input_event, 0) == WAIT_OBJECT_0)
{
freerdp_channels_close(instance->context->channels, instance);
DEBUG_ANDROID("Cleanup threads...");
+
+ if (async_channels)
+ {
+ WaitForSingleObject(channels_thread, INFINITE);
+ CloseHandle(channels_thread);
+ }
+
if (async_update)
{
wMessageQueue* update_queue = freerdp_get_message_queue(instance, FREERDP_UPDATE_MESSAGE_QUEUE);
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.");
freerdp* instance;
#if defined(WITH_GPROF)
+ setenv("CPUPROFILE_FREQUENCY", "200", 1);
monstartup("libfreerdp-android.so");
#endif
instance = freerdp_new();
instance->PreConnect = android_pre_connect;
instance->PostConnect = android_post_connect;
+ instance->PostDisconnect = android_post_disconnect;
instance->Authenticate = android_authenticate;
instance->VerifyCertificate = android_verify_certificate;
instance->VerifyChangedCertificate = android_verify_changed_certificate;
JNIEXPORT void JNICALL jni_freerdp_free(JNIEnv *env, jclass cls, jint instance)
{
freerdp* inst = (freerdp*)instance;
+
+ freerdp_context_free(inst);
freerdp_free(inst);
#if defined(WITH_GPROF)
JNIEXPORT jboolean JNICALL jni_freerdp_disconnect(JNIEnv *env, jclass cls, jint instance)
{
freerdp* inst = (freerdp*)instance;
+ androidContext* ctx = (androidContext*)inst->context;
ANDROID_EVENT* event = (ANDROID_EVENT*)android_event_disconnect_new();
+
+ assert(inst);
+ assert(ctx);
+ assert(event);
+
android_push_event(inst, event);
+
+ pthread_join(ctx->thread, NULL);
freerdp_callback("OnDisconnecting", "(I)V", instance);
+
return (jboolean) JNI_TRUE;
}
{
DEBUG_ANDROID("Cancelling connection ...");
freerdp* inst = (freerdp*)instance;
+ androidContext* ctx = (androidContext*)inst->context;
+
ANDROID_EVENT* event = (ANDROID_EVENT*)android_event_disconnect_new();
android_push_event(inst, event);
+
+ pthread_join(ctx->thread, NULL);
freerdp_callback("OnDisconnecting", "(I)V", instance);
}
(*env)->ReleaseStringUTFChars(env, jgatewaydomain, gatewaydomain);
}
-void copy_pixel_buffer(UINT8* dstBuf, UINT8* srcBuf, int x, int y, int width, int height, int wBuf, int hBuf, int bpp)
+static void copy_pixel_buffer(UINT8* dstBuf, UINT8* srcBuf, int x, int y, int width, int height, int wBuf, int hBuf, int bpp)
{
int i, j;
int length;