server: proxy: use new hooks api
authorkubistika <kmizrachi18@gmail.com>
Mon, 19 Aug 2019 13:06:42 +0000 (16:06 +0300)
committerakallabeth <akallabeth@users.noreply.github.com>
Fri, 23 Aug 2019 09:58:08 +0000 (11:58 +0200)
server/proxy/pf_channels.c
server/proxy/pf_client.c
server/proxy/pf_input.c

index 37102ce..d17f6d4 100644 (file)
@@ -39,6 +39,7 @@
 #include "pf_cliprdr.h"
 #include "pf_disp.h"
 #include "pf_log.h"
+#include "pf_modules.h"
 
 #define TAG PROXY_TAG("channels")
 
@@ -151,7 +152,7 @@ BOOL pf_server_channels_init(pServerContext* ps)
                        return FALSE;
        }
 
-       return TRUE;
+       return pf_modules_run_hook(HOOK_TYPE_SERVER_CHANNELS_INIT, context);
 }
 
 void pf_server_channels_free(pServerContext* ps)
@@ -173,4 +174,6 @@ void pf_server_channels_free(pServerContext* ps)
                cliprdr_server_context_free(ps->cliprdr);
                ps->cliprdr = NULL;
        }
+
+       pf_modules_run_hook(HOOK_TYPE_SERVER_CHANNELS_FREE, (rdpContext*) ps);
 }
index f465311..5ba201f 100644 (file)
@@ -49,6 +49,7 @@
 #include "pf_context.h"
 #include "pf_update.h"
 #include "pf_log.h"
+#include "pf_modules.h"
 
 #define TAG PROXY_TAG("client")
 
@@ -94,6 +95,9 @@ static BOOL pf_client_pre_connect(freerdp* instance)
        pServerContext* ps = pc->pdata->ps;
        rdpSettings* settings = instance->settings;
 
+       if (!pf_modules_run_hook(HOOK_TYPE_CLIENT_PRE_CONNECT, (rdpContext*)ps))
+               return FALSE;
+
        /*
         * as the client's settings are copied from the server's, GlyphSupportLevel might not be
         * GLYPH_SUPPORT_NONE. the proxy currently do not support GDI & GLYPH_SUPPORT_CACHE, so
index 01b8862..5e273cd 100644 (file)
@@ -21,6 +21,7 @@
 
 #include "pf_input.h"
 #include "pf_context.h"
+#include "pf_modules.h"
 
 static BOOL pf_server_synchronize_event(rdpInput* input, UINT32 flags)
 {
@@ -32,7 +33,6 @@ static BOOL pf_server_synchronize_event(rdpInput* input, UINT32 flags)
 
 static BOOL pf_server_keyboard_event(rdpInput* input, UINT16 flags, UINT16 code)
 {
-       BOOL result = FALSE;
        pServerContext* ps = (pServerContext*)input->context;
        pClientContext* pc = ps->pdata->pc;
        rdpContext* context = (rdpContext*) pc;
@@ -45,9 +45,10 @@ static BOOL pf_server_keyboard_event(rdpInput* input, UINT16 flags, UINT16 code)
        event.flags = flags;
        event.rdp_scan_code = code;
 
-       RUN_FILTER(config->Filters, FILTER_TYPE_KEYBOARD, ps->pdata->info, &event, result,
-                         freerdp_input_send_keyboard_event, context->input, flags, code);
-       return result;
+       if (pf_modules_run_filter(FILTER_TYPE_KEYBOARD, input->context, &event))
+               return freerdp_input_send_keyboard_event(context->input, flags, code);
+
+       return TRUE;
 }
 
 static BOOL pf_server_unicode_keyboard_event(rdpInput* input, UINT16 flags, UINT16 code)
@@ -65,7 +66,6 @@ static BOOL pf_server_unicode_keyboard_event(rdpInput* input, UINT16 flags, UINT
 
 static BOOL pf_server_mouse_event(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y)
 {
-       BOOL result = FALSE;
        pServerContext* ps = (pServerContext*)input->context;
        pClientContext* pc = ps->pdata->pc;
        rdpContext* context = (rdpContext*) pc;
@@ -79,9 +79,10 @@ static BOOL pf_server_mouse_event(rdpInput* input, UINT16 flags, UINT16 x, UINT1
        event.x = x;
        event.y = y;
 
-       RUN_FILTER(config->Filters, FILTER_TYPE_MOUSE, ps->pdata->info, &event, result,
-                         freerdp_input_send_mouse_event, context->input, flags, x, y);
-       return result;
+       if (pf_modules_run_filter(FILTER_TYPE_MOUSE, input->context, &event))
+               return freerdp_input_send_mouse_event(context->input, flags, x, y);
+
+       return TRUE;
 }
 
 static BOOL pf_server_extended_mouse_event(rdpInput* input, UINT16 flags, UINT16 x,