diff options
author | jsorg71 <jsorg71> | 2007-05-18 03:49:21 +0000 |
---|---|---|
committer | jsorg71 <jsorg71> | 2007-05-18 03:49:21 +0000 |
commit | b2c524aee1a2291a548235ea7313e1d814e1802c (patch) | |
tree | 18832cfffaf489852fb1dc0dcec84e108a56ab4d | |
parent | 5c42176fbd3ac9392836a0e0466f97dea64ec1b5 (diff) | |
download | xrdp-proprietary-b2c524aee1a2291a548235ea7313e1d814e1802c.tar.gz xrdp-proprietary-b2c524aee1a2291a548235ea7313e1d814e1802c.zip |
work on getting the module manager working without using sesman
-rw-r--r-- | xrdp/xrdp.h | 5 | ||||
-rw-r--r-- | xrdp/xrdp_mm.c | 435 | ||||
-rw-r--r-- | xrdp/xrdp_wm.c | 19 |
3 files changed, 244 insertions, 215 deletions
diff --git a/xrdp/xrdp.h b/xrdp/xrdp.h index 0c058c75..c1a99909 100644 --- a/xrdp/xrdp.h +++ b/xrdp/xrdp.h @@ -316,11 +316,6 @@ xrdp_mm_connect(struct xrdp_mm* self); int APP_CC xrdp_mm_signal(struct xrdp_mm* self); -int APP_CC -xrdp_mm_setup_mod1(struct xrdp_mm* self); -int APP_CC -xrdp_mm_setup_mod2(struct xrdp_mm* self); - int DEFAULT_CC server_begin_update(struct xrdp_mod* mod); int DEFAULT_CC diff --git a/xrdp/xrdp_mm.c b/xrdp/xrdp_mm.c index 96f5947c..5bf9202c 100644 --- a/xrdp/xrdp_mm.c +++ b/xrdp/xrdp_mm.c @@ -54,14 +54,9 @@ sync_load(long param1, long param2) } /*****************************************************************************/ -void APP_CC -xrdp_mm_delete(struct xrdp_mm* self) +static void APP_CC +xrdp_mm_module_cleanup(struct xrdp_mm* self) { - if (self == 0) - { - return; - } - /* free any modual stuff */ if (self->mod != 0) { if (self->mod_exit != 0) @@ -73,6 +68,22 @@ xrdp_mm_delete(struct xrdp_mm* self) { g_xrdp_sync(sync_unload, self->mod_handle, 0); } + self->mod_init = 0; + self->mod_exit = 0; + self->mod = 0; + self->mod_handle = 0; +} + +/*****************************************************************************/ +void APP_CC +xrdp_mm_delete(struct xrdp_mm* self) +{ + if (self == 0) + { + return; + } + /* free any modual stuff */ + xrdp_mm_module_cleanup(self); if (self->sck != 0) { g_tcp_close(self->sck); @@ -238,6 +249,204 @@ xrdp_mm_send_login(struct xrdp_mm* self) } /*****************************************************************************/ +/* returns error */ +/* this goes through the login_names looking for one called 'lib' + then it copies the corisponding login_values item into 'dest' + 'dest' must be at least 'dest_len' + 1 bytes in size */ +static int APP_CC +xrdp_mm_get_lib(struct xrdp_mm* self, char* dest, int dest_len) +{ + char* name; + char* value; + int index; + int count; + int rv; + + rv = 1; + /* find the library name */ + dest[0] = 0; + count = self->login_names->count; + for (index = 0; index < count; index++) + { + name = (char*)list_get_item(self->login_names, index); + value = (char*)list_get_item(self->login_values, index); + if ((name == 0) || (value == 0)) + { + break; + } + if (g_strcasecmp(name, "lib") == 0) + { + g_strncpy(dest, value, dest_len); + rv = 0; + } + } + return rv; +} + +/*****************************************************************************/ +static int APP_CC +xrdp_mm_setup_mod1(struct xrdp_mm* self) +{ + void* func; + char lib[256]; + + if (self == 0) + { + return 1; + } + lib[0] = 0; + if (xrdp_mm_get_lib(self, lib, 255) != 0) + { + g_writeln("error finding lib"); + return 1; + } + if (lib[0] == 0) + { + g_writeln("error finding lib"); + return 1; + } + if (self->mod_handle == 0) + { + self->mod_handle = g_xrdp_sync(sync_load, (long)lib, 0); + if (self->mod_handle != 0) + { + func = g_get_proc_address(self->mod_handle, "mod_init"); + if (func == 0) + { + func = g_get_proc_address(self->mod_handle, "_mod_init"); + } + if (func == 0) + { + g_writeln("error finding proc mod_init in %s", lib); + } + self->mod_init = (struct xrdp_mod* (*)(void))func; + func = g_get_proc_address(self->mod_handle, "mod_exit"); + if (func == 0) + { + func = g_get_proc_address(self->mod_handle, "_mod_exit"); + } + if (func == 0) + { + g_writeln("error finding proc mod_exit in %s", lib); + } + self->mod_exit = (int (*)(struct xrdp_mod*))func; + if ((self->mod_init != 0) && (self->mod_exit != 0)) + { + self->mod = self->mod_init(); + } + } + else + { + g_writeln("error loading %s", lib); + } + if (self->mod != 0) + { + self->mod->wm = (long)(self->wm); + self->mod->server_begin_update = server_begin_update; + self->mod->server_end_update = server_end_update; + self->mod->server_fill_rect = server_fill_rect; + self->mod->server_screen_blt = server_screen_blt; + self->mod->server_paint_rect = server_paint_rect; + self->mod->server_set_pointer = server_set_pointer; + self->mod->server_palette = server_palette; + self->mod->server_msg = server_msg; + self->mod->server_is_term = server_is_term; + self->mod->server_set_clip = server_set_clip; + self->mod->server_reset_clip = server_reset_clip; + self->mod->server_set_fgcolor = server_set_fgcolor; + self->mod->server_set_bgcolor = server_set_bgcolor; + self->mod->server_set_opcode = server_set_opcode; + self->mod->server_set_mixmode = server_set_mixmode; + self->mod->server_set_brush = server_set_brush; + self->mod->server_set_pen = server_set_pen; + self->mod->server_draw_line = server_draw_line; + self->mod->server_add_char = server_add_char; + self->mod->server_draw_text = server_draw_text; + self->mod->server_reset = server_reset; + self->mod->server_query_channel = server_query_channel; + self->mod->server_get_channel_id = server_get_channel_id; + self->mod->server_send_to_channel = server_send_to_channel; + } + } + /* id self->mod is null, there must be a problem */ + if (self->mod == 0) + { + DEBUG(("problem loading lib in xrdp_mm_setup_mod1")); + return 1; + } + return 0; +} + +/*****************************************************************************/ +static int APP_CC +xrdp_mm_setup_mod2(struct xrdp_mm* self) +{ + char text[256]; + char* name; + char* value; + int i; + int rv; + + rv = 1; + text[0] = 0; + if (!(self->wm->pro_layer->term)) + { + if (self->mod->mod_start(self->mod, self->wm->screen->width, + self->wm->screen->height, + self->wm->screen->bpp) != 0) + { + self->wm->pro_layer->term = 1; /* kill session */ + } + } + if (!(self->wm->pro_layer->term)) + { + if (self->display > 0) + { + if (self->code == 0) /* Xvnc */ + { + g_snprintf(text, 255, "%d", 5900 + self->display); + } + else if (self->code == 10) /* X11rdp */ + { + g_snprintf(text, 255, "%d", 6200 + self->display); + } + else + { + self->wm->pro_layer->term = 1; /* kill session */ + } + } + } + if (!(self->wm->pro_layer->term)) + { + /* this adds the port to the end of the list, it will already be in + the list as -1 + the module should use the last one */ + if (g_strlen(text) > 0) + { + list_add_item(self->login_names, (long)g_strdup("port")); + list_add_item(self->login_values, (long)g_strdup(text)); + } + /* always set these */ + name = self->wm->session->client_info->hostname; + self->mod->mod_set_param(self->mod, "hostname", name); + g_snprintf(text, 255, "%d", self->wm->session->client_info->keylayout); + self->mod->mod_set_param(self->mod, "keylayout", text); + for (i = 0; i < self->login_names->count; i++) + { + name = (char*)list_get_item(self->login_names, i); + value = (char*)list_get_item(self->login_values, i); + self->mod->mod_set_param(self->mod, name, value); + } + /* connect */ + if (self->mod->mod_connect(self->mod) == 0) + { + rv = 0; + } + } + return rv; +} + +/*****************************************************************************/ static int APP_CC xrdp_mm_process_login_response(struct xrdp_mm* self, struct stream* s) { @@ -275,6 +484,7 @@ xrdp_mm_process_login_response(struct xrdp_mm* self, struct stream* s) { self->wm->pro_layer->app_sck = 0; self->wm->login_mode = 11; + xrdp_mm_module_cleanup(self); } return rv; } @@ -371,6 +581,23 @@ xrdp_mm_connect(struct xrdp_mm* self) rv = 1; } } + else /* no sesman */ + { + if (xrdp_mm_setup_mod1(self) == 0) + { + if (xrdp_mm_setup_mod2(self) == 0) + { + self->wm->login_mode = 10; + self->wm->pro_layer->app_sck = self->mod->sck; + } + } + if (self->wm->login_mode != 10) + { + self->wm->pro_layer->app_sck = 0; + self->wm->login_mode = 11; + xrdp_mm_module_cleanup(self); + } + } return rv; } @@ -412,7 +639,7 @@ xrdp_mm_signal(struct xrdp_mm* self) break; default: g_writeln("unknown code %d in xrdp_mm_signal", code); - break; + break; } } free_stream(s); @@ -421,198 +648,6 @@ xrdp_mm_signal(struct xrdp_mm* self) } /*****************************************************************************/ -/* returns error */ -/* this goes through the login_names looking for one called 'lib' - then it copies the corisponding login_values item into 'dest' - 'dest' must be at least 'dest_len' + 1 bytes in size */ -static int APP_CC -xrdp_mm_get_lib(struct xrdp_mm* self, char* dest, int dest_len) -{ - char* name; - char* value; - int index; - int count; - int rv; - - rv = 1; - /* find the library name */ - dest[0] = 0; - count = self->login_names->count; - for (index = 0; index < count; index++) - { - name = (char*)list_get_item(self->login_names, index); - value = (char*)list_get_item(self->login_values, index); - if ((name == 0) || (value == 0)) - { - break; - } - if (g_strcasecmp(name, "lib") == 0) - { - g_strncpy(dest, value, dest_len); - rv = 0; - } - } - return rv; -} - -/*****************************************************************************/ -int APP_CC -xrdp_mm_setup_mod1(struct xrdp_mm* self) -{ - void* func; - char lib[256]; - - if (self == 0) - { - return 1; - } - lib[0] = 0; - if (xrdp_mm_get_lib(self, lib, 255) != 0) - { - g_writeln("error finding lib"); - return 1; - } - if (lib[0] == 0) - { - g_writeln("error finding lib"); - return 1; - } - if (self->mod_handle == 0) - { - self->mod_handle = g_xrdp_sync(sync_load, (long)lib, 0); - if (self->mod_handle != 0) - { - func = g_get_proc_address(self->mod_handle, "mod_init"); - if (func == 0) - { - func = g_get_proc_address(self->mod_handle, "_mod_init"); - } - if (func == 0) - { - g_writeln("error finding proc mod_init in %s", lib); - } - self->mod_init = (struct xrdp_mod* (*)(void))func; - func = g_get_proc_address(self->mod_handle, "mod_exit"); - if (func == 0) - { - func = g_get_proc_address(self->mod_handle, "_mod_exit"); - } - if (func == 0) - { - g_writeln("error finding proc mod_exit in %s", lib); - } - self->mod_exit = (int (*)(struct xrdp_mod*))func; - if ((self->mod_init != 0) && (self->mod_exit != 0)) - { - self->mod = self->mod_init(); - } - } - else - { - g_writeln("error loading %s", lib); - } - if (self->mod != 0) - { - self->mod->wm = (long)(self->wm); - self->mod->server_begin_update = server_begin_update; - self->mod->server_end_update = server_end_update; - self->mod->server_fill_rect = server_fill_rect; - self->mod->server_screen_blt = server_screen_blt; - self->mod->server_paint_rect = server_paint_rect; - self->mod->server_set_pointer = server_set_pointer; - self->mod->server_palette = server_palette; - self->mod->server_msg = server_msg; - self->mod->server_is_term = server_is_term; - self->mod->server_set_clip = server_set_clip; - self->mod->server_reset_clip = server_reset_clip; - self->mod->server_set_fgcolor = server_set_fgcolor; - self->mod->server_set_bgcolor = server_set_bgcolor; - self->mod->server_set_opcode = server_set_opcode; - self->mod->server_set_mixmode = server_set_mixmode; - self->mod->server_set_brush = server_set_brush; - self->mod->server_set_pen = server_set_pen; - self->mod->server_draw_line = server_draw_line; - self->mod->server_add_char = server_add_char; - self->mod->server_draw_text = server_draw_text; - self->mod->server_reset = server_reset; - self->mod->server_query_channel = server_query_channel; - self->mod->server_get_channel_id = server_get_channel_id; - self->mod->server_send_to_channel = server_send_to_channel; - } - } - /* id self->mod is null, there must be a problem */ - if (self->mod == 0) - { - DEBUG(("problem loading lib in xrdp_mm_setup_mod1")); - return 1; - } - return 0; -} - -/*****************************************************************************/ -int APP_CC -xrdp_mm_setup_mod2(struct xrdp_mm* self) -{ - char text[256]; - char* name; - char* value; - int i; - int rv; - - rv = 1; - text[0] = 0; - if (!(self->wm->pro_layer->term)) - { - if (self->mod->mod_start(self->mod, self->wm->screen->width, - self->wm->screen->height, - self->wm->screen->bpp) != 0) - { - self->wm->pro_layer->term = 1; /* kill session */ - } - } - if (!(self->wm->pro_layer->term)) - { - if (self->code == 0) /* Xvnc */ - { - g_snprintf(text, 255, "%d", 5900 + self->display); - } - else if (self->code == 10) /* X11rdp */ - { - g_snprintf(text, 255, "%d", 6200 + self->display); - } - else - { - self->wm->pro_layer->term = 1; /* kill session */ - } - } - if (!(self->wm->pro_layer->term)) - { - /* this adds the port to the end of the list, it will already be in - the list as -1 - the module should use the last one */ - list_add_item(self->login_names, (long)g_strdup("port")); - list_add_item(self->login_values, (long)g_strdup(text)); - /* always set these */ - name = self->wm->session->client_info->hostname; - self->mod->mod_set_param(self->mod, "hostname", name); - g_snprintf(text, 255, "%d", self->wm->session->client_info->keylayout); - self->mod->mod_set_param(self->mod, "keylayout", text); - for (i = 0; i < self->login_names->count; i++) - { - name = (char*)list_get_item(self->login_names, i); - value = (char*)list_get_item(self->login_values, i); - self->mod->mod_set_param(self->mod, name, value); - } - /* connect */ - if (self->mod->mod_connect(self->mod) == 0) - { - rv = 0; - } - } - return rv; -} - -/*****************************************************************************/ int DEFAULT_CC server_begin_update(struct xrdp_mod* mod) { diff --git a/xrdp/xrdp_wm.c b/xrdp/xrdp_wm.c index 3cce8b18..4fa9f405 100644 --- a/xrdp/xrdp_wm.c +++ b/xrdp/xrdp_wm.c @@ -1195,50 +1195,50 @@ xrdp_wm_process_input_mouse(struct xrdp_wm* self, int device_flags, DEBUG(("mouse event flags %4.4x x %d y %d", device_flags, x, y)); if (device_flags & MOUSE_FLAG_MOVE) /* 0x0800 */ { - xrdp_wm_mouse_move(self->pro_layer->wm, x, y); + xrdp_wm_mouse_move(self, x, y); } if (device_flags & MOUSE_FLAG_BUTTON1) /* 0x1000 */ { if (device_flags & MOUSE_FLAG_DOWN) /* 0x8000 */ { - xrdp_wm_mouse_click(self->pro_layer->wm, x, y, 1, 1); + xrdp_wm_mouse_click(self, x, y, 1, 1); } else { - xrdp_wm_mouse_click(self->pro_layer->wm, x, y, 1, 0); + xrdp_wm_mouse_click(self, x, y, 1, 0); } } if (device_flags & MOUSE_FLAG_BUTTON2) /* 0x2000 */ { if (device_flags & MOUSE_FLAG_DOWN) /* 0x8000 */ { - xrdp_wm_mouse_click(self->pro_layer->wm, x, y, 2, 1); + xrdp_wm_mouse_click(self, x, y, 2, 1); } else { - xrdp_wm_mouse_click(self->pro_layer->wm, x, y, 2, 0); + xrdp_wm_mouse_click(self, x, y, 2, 0); } } if (device_flags & MOUSE_FLAG_BUTTON3) /* 0x4000 */ { if (device_flags & MOUSE_FLAG_DOWN) /* 0x8000 */ { - xrdp_wm_mouse_click(self->pro_layer->wm, x, y, 3, 1); + xrdp_wm_mouse_click(self, x, y, 3, 1); } else { - xrdp_wm_mouse_click(self->pro_layer->wm, x, y, 3, 0); + xrdp_wm_mouse_click(self, x, y, 3, 0); } } if (device_flags == MOUSE_FLAG_BUTTON4 || /* 0x0280 */ device_flags == 0x0278) { - xrdp_wm_mouse_click(self->pro_layer->wm, 0, 0, 4, 0); + xrdp_wm_mouse_click(self, 0, 0, 4, 0); } if (device_flags == MOUSE_FLAG_BUTTON5 || /* 0x0380 */ device_flags == 0x0388) { - xrdp_wm_mouse_click(self->pro_layer->wm, 0, 0, 5, 0); + xrdp_wm_mouse_click(self, 0, 0, 5, 0); } return 0; } @@ -1338,7 +1338,6 @@ xrdp_wm_idle(struct xrdp_wm* self) /******************************************************************************/ /* returns error */ -/* this gets called when there is nothing on any socket */ int APP_CC xrdp_wm_app_sck_signal(struct xrdp_wm* self, int app_sck) { |