[gtk-frdp] frdp-session: Update freerdp main loop and remove obsolete functions



commit 9604933a7069cbd3ef406fda7d7cc761d1ece2bd
Author: akallabeth <akallabeth posteo net>
Date:   Thu Nov 22 19:03:12 2018 +0100

    frdp-session: Update freerdp main loop and remove obsolete functions
    
    Fixes #5

 src/frdp-session.c | 50 ++++++++++++--------------------------------------
 src/meson.build    |  1 +
 2 files changed, 13 insertions(+), 38 deletions(-)
---
diff --git a/src/frdp-session.c b/src/frdp-session.c
index 6843ee2..cfd8b1d 100644
--- a/src/frdp-session.c
+++ b/src/frdp-session.c
@@ -310,54 +310,28 @@ idle_close (gpointer user_data)
 static gboolean
 update (gpointer user_data)
 {
+  DWORD status;
+  HANDLE handles[64];
+  DWORD usedHandles;
   FrdpSessionPrivate *priv;
-  struct timeval timeout;
   FrdpSession *self = (FrdpSession*) user_data;
-  fd_set rfds_set, wfds_set;
-  void *rfds[32], *wfds[32];
-  gint rcount = 0, wcount = 0;
-  gint fds, max_fds = 0;
-  gint result;
-  gint idx;
-
-  memset (rfds, 0, sizeof (rfds));
-  memset (wfds, 0, sizeof (wfds));
 
   priv = self->priv;
 
-  if (!freerdp_get_fds (priv->freerdp_session, rfds, &rcount, wfds, &wcount)) {
-      g_warning ("Failed to get FreeRDP file descriptor");
+  usedHandles = freerdp_get_event_handles (priv->freerdp_session->context,
+                                           handles, ARRAYSIZE(handles));
+  if (usedHandles == 0) {
+      g_warning ("Failed to get FreeRDP event handle");
       return FALSE;
   }
 
-  FD_ZERO (&rfds_set);
-  FD_ZERO (&wfds_set);
-
-  for (idx = 0; idx < rcount; idx++) {
-    fds = (int)(long) (rfds[idx]);
-
-    if (fds > max_fds)
-      max_fds = fds;
-
-    FD_SET (fds, &rfds_set);
-  }
-
-  if (max_fds == 0)
+  status = WaitForMultipleObjects (usedHandles, handles, FALSE, SELECT_TIMEOUT);
+  if (status == WAIT_TIMEOUT)
+    return TRUE;
+  if (status == WAIT_FAILED)
     return FALSE;
 
-  timeout.tv_sec = 0;
-  timeout.tv_usec = SELECT_TIMEOUT;
-
-  result = select (max_fds + 1, &rfds_set, NULL, NULL, &timeout);
-  if (result == -1) {
-    if (!((errno == EAGAIN) || (errno == EWOULDBLOCK) ||
-          (errno == EINPROGRESS) || (errno == EINTR))) {
-      g_warning ("update: select failed");
-      return FALSE;
-    }
-  }
-
-  if (!freerdp_check_fds (priv->freerdp_session)) {
+  if (!freerdp_check_event_handles (priv->freerdp_session->context)) {
       g_warning ("Failed to check FreeRDP file descriptor");
       return FALSE;
   }
diff --git a/src/meson.build b/src/meson.build
index a7a68ef..2078f4f 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -37,6 +37,7 @@ cc = meson.get_compiler('c')
 vala = meson.get_compiler('vala')
 
 gtk_frdp_deps = [
+  dependency('winpr2'),
   dependency('freerdp2'),
   dependency('gio-2.0', version: '>= 2.50'),
   dependency('gtk+-3.0'),


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]