added connection log

ulab-original
jsorg71 20 years ago
parent 8e807eefd2
commit d5dea39baf

@ -141,7 +141,9 @@ int lib_mod_event(struct vnc* v, int msg, int param1, int param2)
/* just send tab and if the shift modifier is down */
/* the server will know */
/* for now, sending left tab, I don't know which is best */
key = (v->shift_state) ? 0xfe20 : 0xff09;
/* nope, sending tab always */
/* key = (v->shift_state) ? 0xfe20 : 0xff09; */
key = 0xff09;
break;
case 0x001c: /* enter */
key = 0xff0d;
@ -692,20 +694,13 @@ int lib_mod_start(struct vnc* v, int w, int h, int bpp)
/******************************************************************************/
/*
return error
these are wrong.....
1 - authentation failed
2 - authentation failed
3 - server name length received from server too long
4 - server and client bpp do not match
5 - no more available X desktops when spawning a new session
6 - no ip
7 - sck closed
*/
int lib_mod_connect(struct vnc* v)
{
char cursor_data[32 * (32 * 3)];
char cursor_mask[32 * (32 / 8)];
char con_port[256];
char text[256];
struct stream* s;
struct stream* pixel_format;
int error;
@ -717,24 +712,29 @@ int lib_mod_connect(struct vnc* v)
int ok;
int display;
v->server_msg(v, "started connecting");
check_sec_result = 1;
/* only support 8 and 16 bpp connections from rdp client */
if (v->server_bpp != 8 && v->server_bpp != 16)
{
v->server_msg(v, "error - only supporting 8 and 16 bpp rdp connections");
return 1;
}
if (g_strcmp(v->ip, "") == 0)
{
return 6;
v->server_msg(v, "error - no ip set");
return 1;
}
make_stream(s);
/* if port = -1, use sesman to get port / desktop */
if (g_strcmp(v->port, "-1") == 0)
{
i = 0;
display = 0;
error = 0;
init_stream(s, 8192);
v->sck = g_tcp_socket();
v->sck_closed = 0;
v->server_msg(v, "connecting to sesman");
if (g_tcp_connect(v->sck, v->ip, "3350") == 0)
{
g_tcp_set_non_blocking(v->sck);
@ -754,10 +754,12 @@ int lib_mod_connect(struct vnc* v)
s_pop_layer(s, channel_hdr);
out_uint32_be(s, 0); // version
out_uint32_be(s, s->end - s->data); // size
v->server_msg(v, "sending login info to sesman");
error = lib_send(v, s->data, s->end - s->data);
if (error == 0)
{
init_stream(s, 8192);
v->server_msg(v, "receiving sesman header");
error = lib_recv(v, s->data, 8);
}
if (error == 0)
@ -765,6 +767,7 @@ int lib_mod_connect(struct vnc* v)
in_uint32_be(s, version);
in_uint32_be(s, size);
init_stream(s, 8192);
v->server_msg(v, "receiving sesman data");
error = lib_recv(v, s->data, size - 8);
}
if (error == 0)
@ -775,23 +778,33 @@ int lib_mod_connect(struct vnc* v)
if (code == 3)
{
in_uint16_be(s, ok);
in_uint16_be(s, display);
if (ok)
{
i = display;
in_uint16_be(s, display);
}
else
{
in_uint8s(s, 2);
v->server_msg(v, "error - sesman returned no");
}
}
}
}
}
else
{
v->server_msg(v, "error - connecting to sesman");
}
g_tcp_close(v->sck);
if (error != 0 || i == 0)
if (error != 0 || display == 0)
{
v->server_msg(v, "error - connection failed");
free_stream(s);
return 5;
return 1;
}
g_sprintf(con_port, "%d", 5900 + i);
v->vnc_desktop = i;
v->server_msg(v, "sesman started a session");
g_sprintf(con_port, "%d", 5900 + display);
v->vnc_desktop = display;
}
else
{
@ -800,9 +813,12 @@ int lib_mod_connect(struct vnc* v)
make_stream(pixel_format);
v->sck = g_tcp_socket();
v->sck_closed = 0;
g_sprintf(text, "connecting to %s %s", v->ip, con_port);
v->server_msg(v, text);
error = g_tcp_connect(v->sck, v->ip, con_port);
if (error == 0)
{
v->server_msg(v, "tcp connected");
g_tcp_set_non_blocking(v->sck);
g_tcp_set_no_delay(v->sck);
/* protocal version */
@ -821,6 +837,8 @@ int lib_mod_connect(struct vnc* v)
if (error == 0)
{
in_uint32_be(s, i);
g_sprintf(text, "security level is %d (1 = none, 2 = standard)", i);
v->server_msg(v, text);
if (i == 1) /* none */
{
check_sec_result = 0;
@ -851,18 +869,25 @@ int lib_mod_connect(struct vnc* v)
in_uint32_be(s, i);
if (i != 0)
{
v->server_msg(v, "password failed");
error = 2;
}
else
{
v->server_msg(v, "password ok");
}
}
}
if (error == 0)
{
v->server_msg(v, "sending share flag");
init_stream(s, 8192);
s->data[0] = 1;
error = lib_send(v, s->data, 1); /* share flag */
}
if (error == 0)
{
v->server_msg(v, "receiving server init");
error = lib_recv(v, s->data, 4); /* server init */
}
if (error == 0)
@ -870,12 +895,14 @@ int lib_mod_connect(struct vnc* v)
in_uint16_be(s, v->mod_width);
in_uint16_be(s, v->mod_height);
init_stream(pixel_format, 8192);
v->server_msg(v, "receiving pixel format");
error = lib_recv(v, pixel_format->data, 16);
}
if (error == 0)
{
v->mod_bpp = v->server_bpp;
init_stream(s, 8192);
v->server_msg(v, "receiving name length");
error = lib_recv(v, s->data, 4); /* name len */
}
if (error == 0)
@ -887,6 +914,7 @@ int lib_mod_connect(struct vnc* v)
}
else
{
v->server_msg(v, "receiving name");
error = lib_recv(v, v->mod_name, i);
v->mod_name[i] = 0;
}
@ -930,6 +958,7 @@ int lib_mod_connect(struct vnc* v)
out_uint8s(pixel_format, 3); /* pad */
}
out_uint8a(s, pixel_format->data, 16);
v->server_msg(v, "sending pixel format");
error = lib_send(v, s->data, 20);
}
if (error == 0)
@ -942,6 +971,7 @@ int lib_mod_connect(struct vnc* v)
out_uint32_be(s, 0); /* raw */
out_uint32_be(s, 1); /* copy rect */
out_uint32_be(s, 0xffffff11); /* cursor */
v->server_msg(v, "sending encodings");
error = lib_send(v, s->data, 4 + 3 * 4);
}
if (error == 0)
@ -954,28 +984,38 @@ int lib_mod_connect(struct vnc* v)
out_uint16_be(s, 0);
out_uint16_be(s, v->mod_width);
out_uint16_be(s, v->mod_height);
v->server_msg(v, "sending framebuffer update request");
error = lib_send(v, s->data, 10);
}
if (error == 0)
{
v->server_error_popup(v, "hi", "Hi");
if (v->server_bpp != v->mod_bpp)
{
error = 4;
v->server_msg(v, "error - server and client bpp don't match");
error = 1;
}
}
if (error == 0)
{
/* set almost null cursor */
/* set almost null cursor, this is the little dot cursor */
g_memset(cursor_data, 0, 32 * (32 * 3));
g_memset(cursor_data + (32 * (32 * 3) - 1 * 32 * 3), 0xff, 9);
g_memset(cursor_data + (32 * (32 * 3) - 2 * 32 * 3), 0xff, 9);
g_memset(cursor_data + (32 * (32 * 3) - 3 * 32 * 3), 0xff, 9);
g_memset(cursor_mask, 0xff, 32 * (32 / 8));
v->server_msg(v, "sending cursor");
error = v->server_set_cursor(v, 3, 3, cursor_data, cursor_mask);
}
free_stream(s);
free_stream(pixel_format);
if (error == 0)
{
v->server_msg(v, "connection complete, connected ok");
}
else
{
v->server_msg(v, "error - problem connecting");
}
return error;
}
@ -1011,7 +1051,7 @@ int lib_mod_set_param(struct vnc* v, char* name, char* value)
}
/******************************************************************************/
int mod_init()
struct vnc* mod_init(void)
{
struct vnc* v;
@ -1025,7 +1065,7 @@ int mod_init()
v->mod_signal = lib_mod_signal;
v->mod_end = lib_mod_end;
v->mod_set_param = lib_mod_set_param;
return (int)v;
return v;
}
/******************************************************************************/

@ -48,10 +48,10 @@ struct vnc
char* data);
int (*server_set_cursor)(struct vnc* v, int x, int y, char* data, char* mask);
int (*server_palette)(struct vnc* v, int* palette);
int (*server_error_popup)(struct vnc* v, char* error, char* caption);
int (*server_msg)(struct vnc* v, char* msg);
int (*server_is_term)(struct vnc* v);
/* common */
long handle; /* pointer to self as int */
long handle; /* pointer to self as long */
long wm;
long painter;
int sck;

@ -23,16 +23,25 @@
#include "xrdp.h"
/*****************************************************************************/
/* returns boolean */
int rect_contains_pt(struct xrdp_rect* in, int x, int y)
{
if (x < in->left)
{
return 0;
}
if (y < in->top)
{
return 0;
}
if (x >= in->right)
{
return 0;
}
if (y >= in->bottom)
{
return 0;
}
return 1;
}
@ -44,19 +53,31 @@ int rect_intersect(struct xrdp_rect* in1, struct xrdp_rect* in2,
struct xrdp_rect dumby;
if (out == 0)
{
out = &dumby;
}
*out = *in1;
if (in2->left > in1->left)
{
out->left = in2->left;
}
if (in2->top > in1->top)
{
out->top = in2->top;
}
if (in2->right < in1->right)
{
out->right = in2->right;
}
if (in2->bottom < in1->bottom)
{
out->bottom = in2->bottom;
}
rv = !ISRECTEMPTY(*out);
if (!rv)
{
g_memset(out, 0, sizeof(struct xrdp_rect));
}
return rv;
}
@ -66,9 +87,13 @@ int rect_intersect(struct xrdp_rect* in1, struct xrdp_rect* in2,
int check_bounds(struct xrdp_bitmap* b, int* x, int* y, int* cx, int* cy)
{
if (*x >= b->width)
{
return 0;
}
if (*y >= b->height)
{
return 0;
}
if (*x < 0)
{
*cx += *x;
@ -80,16 +105,25 @@ int check_bounds(struct xrdp_bitmap* b, int* x, int* y, int* cx, int* cy)
*y = 0;
}
if (*cx <= 0)
{
return 0;
}
if (*cy <= 0)
{
return 0;
}
if (*x + *cx > b->width)
{
*cx = b->width - *x;
}
if (*y + *cy > b->height)
{
*cy = b->height - *y;
}
return 1;
}
/*****************************************************************************/
/* scan codes
1 esc
2 1 or ?
@ -253,19 +287,29 @@ char get_char_from_scan_code(int device_flags, int scan_code, int* keys,
if (ext)
{
if (scan_code == 53)
{
rv = '/';
}
}
else
{
if (shift)
{
rv = chars2[scan_code];
}
else
{
rv = chars1[scan_code];
}
if (rv >= 'a' && rv <= 'z' && caps_lock)
{
rv = rv - ('a' - 'A');
}
else if (rv >= 'A' && rv <= 'Z' && caps_lock)
{
rv = rv + ('a' - 'A');
}
}
return rv;
}

@ -138,6 +138,9 @@ int xrdp_cache_add_char(struct xrdp_cache* self,
struct xrdp_font_item* font_item);
int xrdp_cache_add_pointer(struct xrdp_cache* self,
struct xrdp_pointer_item* pointer_item);
int xrdp_cache_add_pointer_static(struct xrdp_cache* self,
struct xrdp_pointer_item* pointer_item,
int index);
/* xrdp_wm.c */
struct xrdp_wm* xrdp_wm_create(struct xrdp_process* owner,
@ -292,6 +295,6 @@ int server_paint_rect(struct xrdp_mod* mod, int x, int y, int cx, int cy,
int server_set_pointer(struct xrdp_mod* mod, int x, int y,
char* data, char* mask);
int server_palette(struct xrdp_mod* mod, int* palette);
int server_error_popup(struct xrdp_mod* mod, char* error, char* caption);
int server_msg(struct xrdp_mod* mod, char* msg);
int server_is_term(struct xrdp_mod* mod);
#endif

@ -173,6 +173,10 @@ void xrdp_bitmap_delete(struct xrdp_bitmap* self)
{
self->wm->login_window = 0;
}
if (self->wm->log_wnd == self)
{
self->wm->log_wnd = 0;
}
}
if (self->child_list != 0)
{
@ -825,14 +829,20 @@ int xrdp_bitmap_invalidate(struct xrdp_bitmap* self, struct xrdp_rect* rect)
char* p;
if (self == 0) /* if no bitmap */
{
return 0;
}
if (self->type == WND_TYPE_BITMAP) /* if 0, bitmap, leave */
{
return 0;
}
painter = xrdp_painter_create(self->wm);
xrdp_painter_font_needed(painter);
painter->rop = 0xcc; /* copy */
if (rect == 0)
{
painter->use_clip = 0;
}
else
{
if (ISRECTEMPTY(*rect))
@ -899,11 +909,14 @@ int xrdp_bitmap_invalidate(struct xrdp_bitmap* self, struct xrdp_rect* rect)
y = rect->top;
w = rect->right - rect->left;
h = rect->bottom - rect->top;
self->wm->mod->mod_event(self->wm->mod, WM_INVALIDATE, /* 200 */
if (check_bounds(self->wm->screen, &x, &y, &w, &h))
{
self->wm->mod->mod_event(self->wm->mod, WM_INVALIDATE,
MAKELONG(x, y), MAKELONG(w, h));
}
}
}
}
else
{
painter->fg_color = self->bg_color;

@ -340,7 +340,7 @@ int xrdp_cache_add_pointer(struct xrdp_cache* self,
}
self->pointer_stamp++;
/* look for match */
for (i = 0; i < self->pointer_cache_entries; i++)
for (i = 2; i < self->pointer_cache_entries; i++)
{
if (self->pointer_items[i].x == pointer_item->x &&
self->pointer_items[i].y == pointer_item->y &&
@ -351,14 +351,15 @@ int xrdp_cache_add_pointer(struct xrdp_cache* self,
{
self->pointer_items[i].stamp = self->pointer_stamp;
xrdp_wm_set_pointer(self->wm, i);
self->wm->current_pointer = i;
DEBUG(("found pointer at %d\n\r", i));
return i;
}
}
/* look for oldest */
index = 0;
index = 2;
oldest = 0x7fffffff;
for (i = 0; i < self->pointer_cache_entries; i++)
for (i = 2; i < self->pointer_cache_entries; i++)
{
if (self->pointer_items[i].stamp < oldest)
{
@ -378,6 +379,34 @@ int xrdp_cache_add_pointer(struct xrdp_cache* self,
self->pointer_items[index].mask,
self->pointer_items[index].x,
self->pointer_items[index].y);
self->wm->current_pointer = index;
DEBUG(("adding pointer at %d\n\r", index));
return index;
}
/*****************************************************************************/
int xrdp_cache_add_pointer_static(struct xrdp_cache* self,
struct xrdp_pointer_item* pointer_item,
int index)
{
if (self == 0)
{
return 0;
}
self->pointer_items[index].x = pointer_item->x;
self->pointer_items[index].y = pointer_item->y;
g_memcpy(self->pointer_items[index].data,
pointer_item->data, 32 * 32 * 3);
g_memcpy(self->pointer_items[index].mask,
pointer_item->mask, 32 * 32 / 8);
self->pointer_items[index].stamp = self->pointer_stamp;
xrdp_wm_send_pointer(self->wm, index,
self->pointer_items[index].data,
self->pointer_items[index].mask,
self->pointer_items[index].x,
self->pointer_items[index].y);
self->wm->current_pointer = index;
DEBUG(("adding pointer at %d\n\r", index));
return index;
}

@ -215,6 +215,61 @@ int server_palette(int* palette)
#else
/*****************************************************************************/
/* this is the log windows nofity function */
int xrdp_wm_log_wnd_notify(struct xrdp_bitmap* wnd,
struct xrdp_bitmap* sender,
int msg, int param1, int param2)
{
struct xrdp_painter* painter;
struct xrdp_wm* wm;
struct xrdp_rect rect;
int index;
char* text;
if (wnd == 0)
{
return 0;
}
if (sender == 0)
{
return 0;
}
if (wnd->owner == 0)
{
return 0;
}
wm = wnd->wm;
if (msg == 1) /* click */
{
if (sender->id == 1) /* ok button */
{
/* close the log window */
MAKERECT(rect, wnd->left, wnd->top, wnd->width, wnd->height);
xrdp_bitmap_delete(wnd);
xrdp_bitmap_invalidate(wm->screen, &rect);
if (wm->mod_handle == 0)
{
wm->pro_layer->term = 1; /* kill session */
}
}
}
else if (msg == WM_PAINT) /* 3 */
{
painter = (struct xrdp_painter*)param1;
if (painter != 0)
{
painter->font->color = wnd->wm->black;
for (index = 0; index < wnd->wm->log->count; index++)
{
text = (char*)xrdp_list_get_item(wnd->wm->log, index);
xrdp_painter_draw_text(painter, wnd, 10, 30 + index * 15, text);
}
}
}
return 0;
}
/*****************************************************************************/
int server_begin_update(struct xrdp_mod* mod)
{
@ -308,39 +363,40 @@ int server_palette(struct xrdp_mod* mod, int* palette)
}
/*****************************************************************************/
int server_error_popup(struct xrdp_mod* mod, char* error, char* caption)
int server_msg(struct xrdp_mod* mod, char* msg)
{
#if 0
struct xrdp_wm* wm;
struct xrdp_bitmap* wnd;
struct xrdp_bitmap* but;
wm = (struct xrdp_wm*)mod->wm;
wnd = xrdp_bitmap_create(400, 200, wm->screen->bpp, WND_TYPE_WND, wm);
xrdp_list_add_item(wm->screen->child_list, (int)wnd);
wnd->parent = wm->screen;
wnd->owner = wm->screen;
wnd->bg_color = wm->grey;
wnd->left = wm->screen->width / 2 - wnd->width / 2;
wnd->top = wm->screen->height / 2 - wnd->height / 2;
wnd->notify = xrdp_wm_popup_notify;
g_strcpy(wnd->caption, caption);
/* button */
xrdp_list_add_item(wm->log, (long)g_strdup(msg));
if (wm->log_wnd == 0)
{
/* log window */
wm->log_wnd = xrdp_bitmap_create(400, 400, wm->screen->bpp,
WND_TYPE_WND, wm);
xrdp_list_add_item(wm->screen->child_list, (long)wm->log_wnd);
wm->log_wnd->parent = wm->screen;
wm->log_wnd->owner = wm->screen;
wm->log_wnd->bg_color = wm->grey;
wm->log_wnd->left = 10;
wm->log_wnd->top = 10;
set_string(&wm->log_wnd->caption1, "Connection Log");
/* ok button */
but = xrdp_bitmap_create(60, 25, wm->screen->bpp, WND_TYPE_BUTTON, wm);
xrdp_list_add_item(wnd->child_list, (int)but);
but->parent = wnd;
but->owner = wnd;
but->left = 180;
but->top = 160;
xrdp_list_insert_item(wm->log_wnd->child_list, 0, (long)but);
but->parent = wm->log_wnd;
but->owner = wm->log_wnd;
but->left = (400 - 60) - 10;
but->top = (400 - 25) - 10;
but->id = 1;
g_strcpy(but->caption, "OK");
but->tab_stop = 1;
xrdp_bitmap_invalidate(wm->screen, 0);
//xrdp_bitmap_invalidate(wnd, 0);
g_sleep(2000);
#endif
set_string(&but->caption1, "OK");
wm->log_wnd->focused_control = but;
/* set notify function */
wm->log_wnd->notify = xrdp_wm_log_wnd_notify;
}
xrdp_bitmap_invalidate(wm->log_wnd, 0);
return 0;
}

@ -31,11 +31,17 @@ int xrdp_wm_login_help_notify(struct xrdp_bitmap* wnd,
struct xrdp_painter* p;
if (wnd == 0)
{
return 0;
}
if (sender == 0)
{
return 0;
}
if (wnd->owner == 0)
{
return 0;
}
if (msg == 1) /* click */
{
if (sender->id == 1) /* ok button */
@ -90,13 +96,13 @@ int xrdp_wm_setup_mod(struct xrdp_wm* self,
self->mod_handle = g_load_library(mod_data->lib);
if (self->mod_handle != 0)
{
self->mod_init = (int(*)())
self->mod_init = (struct xrdp_mod* (*)(void))
g_get_proc_address(self->mod_handle, "mod_init");
self->mod_exit = (int(*)(int))
self->mod_exit = (int (*)(struct xrdp_mod*))
g_get_proc_address(self->mod_handle, "mod_exit");
if (self->mod_init != 0 && self->mod_exit != 0)
{
self->mod = (struct xrdp_mod*)self->mod_init();
self->mod = self->mod_init();
}
}
if (self->mod != 0)
@ -109,7 +115,7 @@ int xrdp_wm_setup_mod(struct xrdp_wm* self,
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_error_popup= server_error_popup;
self->mod->server_msg = server_msg;
self->mod->server_is_term = server_is_term;
}
}
@ -159,8 +165,9 @@ int xrdp_wm_login_notify(struct xrdp_bitmap* wnd,
if (sender->id == 1) /* help button */
{
/* create help screen */
help = xrdp_bitmap_create(300, 300, wnd->wm->screen->bpp, 1, wnd->wm);
xrdp_list_insert_item(wnd->wm->screen->child_list, 0, (int)help);
help = xrdp_bitmap_create(300, 300, wnd->wm->screen->bpp,
WND_TYPE_WND, wnd->wm);
xrdp_list_insert_item(wnd->wm->screen->child_list, 0, (long)help);
help->parent = wnd->wm->screen;
help->owner = wnd;
wnd->modal_dialog = help;
@ -170,8 +177,9 @@ int xrdp_wm_login_notify(struct xrdp_bitmap* wnd,
help->notify = xrdp_wm_login_help_notify;
set_string(&help->caption1, "Login help");
/* ok button */
but = xrdp_bitmap_create(60, 25, wnd->wm->screen->bpp, 3, wnd->wm);
xrdp_list_insert_item(help->child_list, 0, (int)but);
but = xrdp_bitmap_create(60, 25, wnd->wm->screen->bpp,
WND_TYPE_BUTTON, wnd->wm);
xrdp_list_insert_item(help->child_list, 0, (long)but);
but->parent = help;
but->owner = help;
but->left = 120;
@ -181,25 +189,29 @@ int xrdp_wm_login_notify(struct xrdp_bitmap* wnd,
set_string(&but->caption1, "OK");
/* draw it */
help->focused_control = but;
//wnd->wm->focused_window = help;
xrdp_bitmap_invalidate(help, 0);
xrdp_wm_set_focused(wnd->wm, help);
//xrdp_bitmap_invalidate(wnd->focused_control, 0);
}
else if (sender->id == 2) /* cancel button */
{
if (wnd != 0)
{
if (wnd->wm != 0)
{
if (wnd->wm->pro_layer != 0)
{
wnd->wm->pro_layer->term = 1;
}
}
}
}
else if (sender->id == 3) /* ok button */
{
combo = xrdp_bitmap_get_child_by_id(wnd, 6);
if (combo != 0)
{
mod = (struct xrdp_mod_data*)xrdp_list_get_item(combo->data_list,
combo->item_index);
mod = (struct xrdp_mod_data*)
xrdp_list_get_item(combo->data_list, combo->item_index);
if (mod != 0)
{
con_mod = *mod;
@ -238,10 +250,19 @@ int xrdp_wm_login_notify(struct xrdp_bitmap* wnd,
wm->mod->mod_set_param(wm->mod, "password", con_mod.password);
if (wm->mod->mod_connect(wm->mod) != 0)
{
wm->pro_layer->term = 1; /* kill session */
/* totaly free mod */
wm->mod_exit(wm->mod);
g_free_library(wm->mod_handle);
wm->mod = 0;
wm->mod_handle = 0;
wm->mod_init = 0;
wm->mod_exit = 0;
//wm->pro_layer->app_sck = 0;
}
}
if (!wm->pro_layer->term)
{
if (wm->mod != 0)
{
if (wm->mod->sck != 0)
{
@ -253,12 +274,13 @@ int xrdp_wm_login_notify(struct xrdp_bitmap* wnd,
}
}
}
}
else if (msg == 2) /* mouse move */
{
}
else if (msg == 100) /* modal result is done */
{
i = xrdp_list_index_of(wnd->wm->screen->child_list, (int)sender);
i = xrdp_list_index_of(wnd->wm->screen->child_list, (long)sender);
if (i >= 0)
{
b = (struct xrdp_bitmap*)
@ -337,8 +359,8 @@ int xrdp_wm_login_fill_in_combo(struct xrdp_wm* self, struct xrdp_bitmap* b)
g_strcpy(mod_data->password, r);
}
}
xrdp_list_add_item(b->string_list, (int)g_strdup(mod_data->name));
xrdp_list_add_item(b->data_list, (int)mod_data);
xrdp_list_add_item(b->string_list, (long)g_strdup(mod_data->name));
xrdp_list_add_item(b->data_list, (long)mod_data);
}
}
g_file_close(fd);
@ -356,7 +378,7 @@ int xrdp_login_wnd_create(struct xrdp_wm* self)
/* draw login window */
self->login_window = xrdp_bitmap_create(400, 200, self->screen->bpp,
WND_TYPE_WND, self);
xrdp_list_add_item(self->screen->child_list, (int)self->login_window);
xrdp_list_add_item(self->screen->child_list, (long)self->login_window);
self->login_window->parent = self->screen;
self->login_window->owner = self->screen;
self->login_window->bg_color = self->grey;
@ -374,7 +396,7 @@ int xrdp_login_wnd_create(struct xrdp_wm* self)
but->owner = self->screen;
but->left = self->screen->width - but->width;
but->top = self->screen->height - but->height;
xrdp_list_add_item(self->screen->child_list, (int)but);
xrdp_list_add_item(self->screen->child_list, (long)but);
/* image */
but = xrdp_bitmap_create(4, 4, self->screen->bpp, WND_TYPE_IMAGE, self);
@ -383,11 +405,11 @@ int xrdp_login_wnd_create(struct xrdp_wm* self)
but->owner = self->login_window;
but->left = 10;
but->top = 30;
xrdp_list_add_item(self->login_window->child_list, (int)but);
xrdp_list_add_item(self->login_window->child_list, (long)but);
/* label */
but = xrdp_bitmap_create(60, 20, self->screen->bpp, WND_TYPE_LABEL, self);
xrdp_list_add_item(self->login_window->child_list, (int)but);
xrdp_list_add_item(self->login_window->child_list, (long)but);
but->parent = self->login_window;
but->owner = self->login_window;
but->left = 155;
@ -396,7 +418,7 @@ int xrdp_login_wnd_create(struct xrdp_wm* self)
/* edit */
but = xrdp_bitmap_create(140, 20, self->screen->bpp, WND_TYPE_EDIT, self);
xrdp_list_add_item(self->login_window->child_list, (int)but);
xrdp_list_add_item(self->login_window->child_list, (long)but);
but->parent = self->login_window;
but->owner = self->login_window;
but->left = 220;
@ -409,7 +431,7 @@ int xrdp_login_wnd_create(struct xrdp_wm* self)
/* label */
but = xrdp_bitmap_create(60, 20, self->screen->bpp, WND_TYPE_LABEL, self);
xrdp_list_add_item(self->login_window->child_list, (int)but);
xrdp_list_add_item(self->login_window->child_list, (long)but);
but->parent = self->login_window;
but->owner = self->login_window;
but->left = 155;
@ -418,7 +440,7 @@ int xrdp_login_wnd_create(struct xrdp_wm* self)
/* edit */
but = xrdp_bitmap_create(140, 20, self->screen->bpp, WND_TYPE_EDIT, self);
xrdp_list_add_item(self->login_window->child_list, (int)but);
xrdp_list_add_item(self->login_window->child_list, (long)but);
but->parent = self->login_window;
but->owner = self->login_window;
but->left = 220;
@ -431,7 +453,7 @@ int xrdp_login_wnd_create(struct xrdp_wm* self)
/* label */
but = xrdp_bitmap_create(60, 20, self->screen->bpp, WND_TYPE_LABEL, self);
xrdp_list_add_item(self->login_window->child_list, (int)but);
xrdp_list_add_item(self->login_window->child_list, (long)but);
but->parent = self->login_window;
but->owner = self->login_window;
but->left = 155;
@ -440,7 +462,7 @@ int xrdp_login_wnd_create(struct xrdp_wm* self)
/* combo */
but = xrdp_bitmap_create(140, 20, self->screen->bpp, WND_TYPE_COMBO, self);
xrdp_list_add_item(self->login_window->child_list, (int)but);
xrdp_list_add_item(self->login_window->child_list, (long)but);
but->parent = self->login_window;
but->owner = self->login_window;
but->left = 220;
@ -451,7 +473,7 @@ int xrdp_login_wnd_create(struct xrdp_wm* self)
/* button */
but = xrdp_bitmap_create(60, 25, self->screen->bpp, WND_TYPE_BUTTON, self);
xrdp_list_add_item(self->login_window->child_list, (int)but);
xrdp_list_add_item(self->login_window->child_list, (long)but);
but->parent = self->login_window;
but->owner = self->login_window;
but->left = 180;
@ -462,7 +484,7 @@ int xrdp_login_wnd_create(struct xrdp_wm* self)
/* button */
but = xrdp_bitmap_create(60, 25, self->screen->bpp, WND_TYPE_BUTTON, self);
xrdp_list_add_item(self->login_window->child_list, (int)but);
xrdp_list_add_item(self->login_window->child_list, (long)but);
but->parent = self->login_window;
but->owner = self->login_window;
but->left = 250;
@ -473,7 +495,7 @@ int xrdp_login_wnd_create(struct xrdp_wm* self)
/* button */
but = xrdp_bitmap_create(60, 25, self->screen->bpp, WND_TYPE_BUTTON, self);
xrdp_list_add_item(self->login_window->child_list, (int)but);
xrdp_list_add_item(self->login_window->child_list, (long)but);
but->parent = self->login_window;
but->owner = self->login_window;
but->left = 320;

@ -42,7 +42,7 @@ struct xrdp_mod
char* data);
int (*server_set_pointer)(struct xrdp_mod* v, int x, int y, char* data, char* mask);
int (*server_palette)(struct xrdp_mod* v, int* palette);
int (*server_error_popup)(struct xrdp_mod* v, char* error, char* caption);
int (*server_msg)(struct xrdp_mod* v, char* msg);
int (*server_is_term)(struct xrdp_mod* v);
/* common */
long handle; /* pointer to self as int */
@ -398,12 +398,15 @@ struct xrdp_wm
int scroll_lock;
int num_lock;
/* mod vars */
int mod_handle;
int (*mod_init)();
int (*mod_exit)(int);
int mod_handle; /* returned from g_load_library */
struct xrdp_mod* (*mod_init)(void);
int (*mod_exit)(struct xrdp_mod*);
struct xrdp_mod* mod;
/* client info */
struct xrdp_client_info* client_info;
/* session log */
struct xrdp_list* log;
struct xrdp_bitmap* log_wnd;
};
/* rdp process */

@ -40,6 +40,8 @@ struct xrdp_wm* xrdp_wm_create(struct xrdp_process* owner,
self->painter = xrdp_painter_create(self);
self->rdp_layer = owner->rdp_layer;
self->cache = xrdp_cache_create(self, self->orders, self->client_info);
self->log = xrdp_list_create();
self->log->auto_free = 1;
return self;
}
@ -58,7 +60,7 @@ void xrdp_wm_delete(struct xrdp_wm* self)
{
if (self->mod_exit != 0)
{
self->mod_exit((int)self->mod);
self->mod_exit(self->mod);
}
}
if (self->mod_handle != 0)
@ -236,7 +238,9 @@ int xrdp_wm_send_bitmap(struct xrdp_wm* self, struct xrdp_bitmap* bitmap,
{
lines_sending = 4096 / (line_size + e * Bpp);
if (i + lines_sending > total_lines)
{
lines_sending = total_lines - i;
}
p = p + line_size * lines_sending;
xrdp_rdp_init_data(self->rdp_layer, s);
out_uint16_le(s, RDP_UPDATE_BITMAP);
@ -340,7 +344,7 @@ int xrdp_wm_pointer(struct xrdp_wm* self, char* data, char* mask, int x, int y)
pointer_item.y = y;
g_memcpy(pointer_item.data, data, 32 * 32 * 3);
g_memcpy(pointer_item.mask, mask, 32 * 32 / 8);
xrdp_cache_add_pointer(self->cache, &pointer_item);
self->screen->pointer = xrdp_cache_add_pointer(self->cache, &pointer_item);
return 0;
}
@ -468,7 +472,6 @@ int xrdp_wm_set_pointer(struct xrdp_wm* self, int cache_idx)
out_uint16_le(s, RDP_POINTER_CACHED);
out_uint16_le(s, 0); /* pad */
out_uint16_le(s, cache_idx); /* cache_idx */
//g_printf("%d\n", cache_idx);
s_mark_end(s);
xrdp_rdp_send_data(self->rdp_layer, s, RDP_DATA_PDU_POINTER);
free_stream(s);
@ -479,13 +482,10 @@ int xrdp_wm_set_pointer(struct xrdp_wm* self, int cache_idx)
int xrdp_wm_init(struct xrdp_wm* self)
{
#ifndef XRDP_LIB /* if lib, dodn't create login screen */
char data[32 * (32 * 3)];
char mask[32 * (32 / 8)];
int x;
int y;
int bindex;
int gindex;
int rindex;
struct xrdp_pointer_item pointer_item;
if (self->screen->bpp == 8)
{
@ -547,12 +547,13 @@ int xrdp_wm_init(struct xrdp_wm* self)
self->green = COLOR24(0x00, 0xff, 0x00);
}
DEBUG(("sending cursor\n\r"));
xrdp_wm_load_pointer(self, "cursor1.cur", data, mask, &x, &y);
xrdp_wm_send_pointer(self, 1, data, mask, x, y);
xrdp_wm_load_pointer(self, "cursor1.cur", pointer_item.data,
pointer_item.mask, &pointer_item.x, &pointer_item.y);
xrdp_cache_add_pointer_static(self->cache, &pointer_item, 1);
DEBUG(("sending cursor\n\r"));
xrdp_wm_load_pointer(self, "cursor0.cur", data, mask, &x, &y);
xrdp_wm_send_pointer(self, 0, data, mask, x, y);
xrdp_wm_load_pointer(self, "cursor0.cur", pointer_item.data,
pointer_item.mask, &pointer_item.x, &pointer_item.y);
xrdp_cache_add_pointer_static(self->cache, &pointer_item, 0);
xrdp_login_wnd_create(self);
/* clear screen */
self->screen->bg_color = self->black;
@ -738,7 +739,7 @@ int xrdp_wm_is_rect_vis(struct xrdp_wm* self, struct xrdp_bitmap* wnd,
return 0;
}
i = xrdp_list_index_of(self->screen->child_list, (int)wnd);
i = xrdp_list_index_of(self->screen->child_list, (long)wnd);
i--;
while (i >= 0)
{
@ -842,8 +843,13 @@ int xrdp_wm_mouse_move(struct xrdp_wm* self, int x, int y)
return 0;
}
b = xrdp_wm_at_pos(self->screen, x, y, 0);
if (b == 0)
if (b == 0) /* if b is null, the movment must be over the screen */
{
if (self->screen->pointer != self->current_pointer)
{
xrdp_wm_set_pointer(self, self->screen->pointer);
self->current_pointer = self->screen->pointer;
}
if (self->mod != 0) /* if screen is mod controled */
{
if (self->mod->mod_event != 0)
@ -900,7 +906,7 @@ int xrdp_wm_clear_popup(struct xrdp_wm* self)
if (self->popup_wnd != 0)
{
//b = self->popup_wnd->popped_from;
i = xrdp_list_index_of(self->screen->child_list, (int)self->popup_wnd);
i = xrdp_list_index_of(self->screen->child_list, (long)self->popup_wnd);
xrdp_list_remove_item(self->screen->child_list, i);
MAKERECT(rect, self->popup_wnd->left, self->popup_wnd->top,
self->popup_wnd->width, self->popup_wnd->height);
@ -1218,7 +1224,7 @@ int xrdp_wm_pu(struct xrdp_wm* self, struct xrdp_bitmap* control)
self->popup_wnd->left = x;
self->popup_wnd->top = y + control->height;
self->popup_wnd->item_index = control->item_index;
xrdp_list_insert_item(self->screen->child_list, 0, (int)self->popup_wnd);
xrdp_list_insert_item(self->screen->child_list, 0, (long)self->popup_wnd);
xrdp_bitmap_invalidate(self->popup_wnd, 0);
return 0;
}

Loading…
Cancel
Save