got autologin working again and some other fixes

ulab-original
jsorg71 18 years ago
parent f2f8bb727d
commit d0e066ee8b

@ -317,13 +317,9 @@ int APP_CC
xrdp_mm_signal(struct xrdp_mm* self); xrdp_mm_signal(struct xrdp_mm* self);
int APP_CC int APP_CC
xrdp_mm_setup_mod1(struct xrdp_mm* self, xrdp_mm_setup_mod1(struct xrdp_mm* self);
struct list* names,
struct list* values);
int APP_CC int APP_CC
xrdp_mm_setup_mod2(struct xrdp_mm* self, xrdp_mm_setup_mod2(struct xrdp_mm* self);
struct list* names,
struct list* values);
int DEFAULT_CC int DEFAULT_CC
server_begin_update(struct xrdp_mod* mod); server_begin_update(struct xrdp_mod* mod);

@ -979,6 +979,16 @@ xrdp_bitmap_invalidate(struct xrdp_bitmap* self, struct xrdp_rect* rect)
0, 0); 0, 0);
} }
} }
else
{
x = 0;
y = 0;
w = self->wm->screen->width;
h = self->wm->screen->height;
self->wm->mm->mod->mod_event(self->wm->mm->mod, WM_INVALIDATE,
MAKELONG(y, x), MAKELONG(h, w),
0, 0);
}
} }
} }
else else

@ -93,15 +93,17 @@ xrdp_wm_popup_notify(struct xrdp_bitmap* wnd,
int APP_CC int APP_CC
xrdp_wm_delete_all_childs(struct xrdp_wm* self) xrdp_wm_delete_all_childs(struct xrdp_wm* self)
{ {
int i; int index;
struct xrdp_bitmap* b; struct xrdp_bitmap* b;
struct xrdp_rect rect;
for (i = self->screen->child_list->count - 1; i >= 0; i--) for (index = self->screen->child_list->count - 1; index >= 0; index--)
{ {
b = (struct xrdp_bitmap*)list_get_item(self->screen->child_list, i); b = (struct xrdp_bitmap*)list_get_item(self->screen->child_list, index);
MAKERECT(rect, b->left, b->top, b->width, b->height);
xrdp_bitmap_delete(b); xrdp_bitmap_delete(b);
xrdp_bitmap_invalidate(self->screen, &rect);
} }
xrdp_bitmap_invalidate(self->screen, 0);
return 0; return 0;
} }
@ -217,8 +219,6 @@ xrdp_wm_ok_clicked(struct xrdp_bitmap* wnd)
/* gota copy these cause dialog gets freed */ /* gota copy these cause dialog gets freed */
list_append_list_strdup(mod_data->names, wm->mm->login_names, 0); list_append_list_strdup(mod_data->names, wm->mm->login_names, 0);
list_append_list_strdup(mod_data->values, wm->mm->login_values, 0); list_append_list_strdup(mod_data->values, wm->mm->login_values, 0);
list_add_item(wm->mm->login_names, (long)g_strdup("lib"));
list_add_item(wm->mm->login_values, (long)g_strdup(mod_data->lib));
wm->login_mode = 2; wm->login_mode = 2;
} }
} }
@ -287,7 +287,7 @@ xrdp_wm_show_edits(struct xrdp_wm* self, struct xrdp_bitmap* combo)
b->pointer = 1; b->pointer = 1;
b->tab_stop = 1; b->tab_stop = 1;
b->caption1 = (char*)g_malloc(256, 1); b->caption1 = (char*)g_malloc(256, 1);
g_strcpy(b->caption1, value + 3); g_strncpy(b->caption1, value + 3, 255);
b->edit_pos = g_strlen(b->caption1); b->edit_pos = g_strlen(b->caption1);
if (self->login_window->focused_control == 0) if (self->login_window->focused_control == 0)
{ {
@ -295,7 +295,7 @@ xrdp_wm_show_edits(struct xrdp_wm* self, struct xrdp_bitmap* combo)
} }
if (g_strncmp(name, "username", 255) == 0) if (g_strncmp(name, "username", 255) == 0)
{ {
g_strcpy(b->caption1, self->session->client_info->username); g_strncpy(b->caption1, self->session->client_info->username, 255);
b->edit_pos = g_strlen(b->caption1); b->edit_pos = g_strlen(b->caption1);
if (g_strlen(b->caption1) > 0) if (g_strlen(b->caption1) > 0)
{ {
@ -389,6 +389,7 @@ xrdp_wm_login_fill_in_combo(struct xrdp_wm* self, struct xrdp_bitmap* b)
char* p; char* p;
char* q; char* q;
char* r; char* r;
char name[256];
struct xrdp_mod_data* mod_data; struct xrdp_mod_data* mod_data;
sections = list_create(); sections = list_create();
@ -408,32 +409,25 @@ xrdp_wm_login_fill_in_combo(struct xrdp_wm* self, struct xrdp_bitmap* b)
} }
else else
{ {
g_strncpy(name, p, 255);
mod_data = (struct xrdp_mod_data*) mod_data = (struct xrdp_mod_data*)
g_malloc(sizeof(struct xrdp_mod_data), 1); g_malloc(sizeof(struct xrdp_mod_data), 1);
mod_data->names = list_create(); mod_data->names = list_create();
mod_data->names->auto_free = 1; mod_data->names->auto_free = 1;
mod_data->values = list_create(); mod_data->values = list_create();
mod_data->values->auto_free = 1; mod_data->values->auto_free = 1;
g_strcpy(mod_data->name, p); /* set name in square bracket */
for (j = 0; j < section_names->count; j++) for (j = 0; j < section_names->count; j++)
{ {
q = (char*)list_get_item(section_names, j); q = (char*)list_get_item(section_names, j);
r = (char*)list_get_item(section_values, j); r = (char*)list_get_item(section_values, j);
if (g_strncmp("name", q, 255) == 0) if (g_strncmp("name", q, 255) == 0)
{ {
g_strcpy(mod_data->name, r); g_strncpy(name, r, 255);
}
else if (g_strncmp("lib", q, 255) == 0)
{
g_strcpy(mod_data->lib, r);
}
else
{
list_add_item(mod_data->names, (long)g_strdup(q));
list_add_item(mod_data->values, (long)g_strdup(r));
} }
list_add_item(mod_data->names, (long)g_strdup(q));
list_add_item(mod_data->values, (long)g_strdup(r));
} }
list_add_item(b->string_list, (long)g_strdup(mod_data->name)); list_add_item(b->string_list, (long)g_strdup(name));
list_add_item(b->data_list, (long)mod_data); list_add_item(b->data_list, (long)mod_data);
} }
} }

@ -254,9 +254,9 @@ xrdp_mm_process_login_response(struct xrdp_mm* self, struct stream* s)
self->display = display; self->display = display;
g_snprintf(text, 255, "login successful for display %d", display); g_snprintf(text, 255, "login successful for display %d", display);
xrdp_wm_log_msg(self->wm, text); xrdp_wm_log_msg(self->wm, text);
if (xrdp_mm_setup_mod1(self, self->login_names, self->login_values) == 0) if (xrdp_mm_setup_mod1(self) == 0)
{ {
if (xrdp_mm_setup_mod2(self, self->login_names, self->login_values) == 0) if (xrdp_mm_setup_mod2(self) == 0)
{ {
self->wm->login_mode = 10; self->wm->login_mode = 10;
self->wm->pro_layer->app_sck = self->mod->sck; self->wm->pro_layer->app_sck = self->mod->sck;
@ -457,9 +457,7 @@ xrdp_mm_get_lib(struct xrdp_mm* self, char* dest, int dest_len)
/*****************************************************************************/ /*****************************************************************************/
int APP_CC int APP_CC
xrdp_mm_setup_mod1(struct xrdp_mm* self, xrdp_mm_setup_mod1(struct xrdp_mm* self)
struct list* names,
struct list* values)
{ {
void* func; void* func;
char lib[256]; char lib[256];
@ -553,9 +551,7 @@ xrdp_mm_setup_mod1(struct xrdp_mm* self,
/*****************************************************************************/ /*****************************************************************************/
int APP_CC int APP_CC
xrdp_mm_setup_mod2(struct xrdp_mm* self, xrdp_mm_setup_mod2(struct xrdp_mm* self)
struct list* names,
struct list* values)
{ {
char text[256]; char text[256];
char* name; char* name;
@ -594,17 +590,17 @@ xrdp_mm_setup_mod2(struct xrdp_mm* self,
/* this adds the port to the end of the list, it will already be in /* this adds the port to the end of the list, it will already be in
the list as -1 the list as -1
the module should use the last one */ the module should use the last one */
list_add_item(names, (long)g_strdup("port")); list_add_item(self->login_names, (long)g_strdup("port"));
list_add_item(values, (long)g_strdup(text)); list_add_item(self->login_values, (long)g_strdup(text));
/* always set these */ /* always set these */
name = self->wm->session->client_info->hostname; name = self->wm->session->client_info->hostname;
self->mod->mod_set_param(self->mod, "hostname", name); self->mod->mod_set_param(self->mod, "hostname", name);
g_snprintf(text, 255, "%d", self->wm->session->client_info->keylayout); g_snprintf(text, 255, "%d", self->wm->session->client_info->keylayout);
self->mod->mod_set_param(self->mod, "keylayout", text); self->mod->mod_set_param(self->mod, "keylayout", text);
for (i = 0; i < names->count; i++) for (i = 0; i < self->login_names->count; i++)
{ {
name = (char*)list_get_item(names, i); name = (char*)list_get_item(self->login_names, i);
value = (char*)list_get_item(values, i); value = (char*)list_get_item(self->login_values, i);
self->mod->mod_set_param(self->mod, name, value); self->mod->mod_set_param(self->mod, name, value);
} }
/* connect */ /* connect */

@ -343,8 +343,6 @@ struct xrdp_font
/* module */ /* module */
struct xrdp_mod_data struct xrdp_mod_data
{ {
char name[256];
char lib[256];
struct list* names; struct list* names;
struct list* values; struct list* values;
}; };

@ -342,22 +342,17 @@ xrdp_wm_load_static_pointers(struct xrdp_wm* self)
int APP_CC int APP_CC
xrdp_wm_init(struct xrdp_wm* self) xrdp_wm_init(struct xrdp_wm* self)
{ {
#if 0
int fd; int fd;
int index; int index;
struct xrdp_mod_data* mod_data;
struct list* names; struct list* names;
struct list* values; struct list* values;
char* q; char* q;
char* r; char* r;
char section_name[256]; char section_name[256];
#endif
xrdp_wm_load_static_colors(self); xrdp_wm_load_static_colors(self);
xrdp_wm_load_static_pointers(self); xrdp_wm_load_static_pointers(self);
self->screen->bg_color = self->black; self->screen->bg_color = self->black;
#if 0
// todo, get autologin working
if (self->session->client_info->rdp_autologin) if (self->session->client_info->rdp_autologin)
{ {
fd = g_file_open(XRDP_CFG_FILE); /* xrdp.ini */ fd = g_file_open(XRDP_CFG_FILE); /* xrdp.ini */
@ -367,12 +362,6 @@ xrdp_wm_init(struct xrdp_wm* self)
names->auto_free = 1; names->auto_free = 1;
values = list_create(); values = list_create();
values->auto_free = 1; values->auto_free = 1;
mod_data = (struct xrdp_mod_data*)
g_malloc(sizeof(struct xrdp_mod_data), 1);
mod_data->names = list_create();
mod_data->names->auto_free = 1;
mod_data->values = list_create();
mod_data->values->auto_free = 1;
g_strncpy(section_name, self->session->client_info->domain, 255); g_strncpy(section_name, self->session->client_info->domain, 255);
if (section_name[0] == 0) if (section_name[0] == 0)
{ {
@ -396,95 +385,38 @@ xrdp_wm_init(struct xrdp_wm* self)
{ {
q = (char*)list_get_item(names, index); q = (char*)list_get_item(names, index);
r = (char*)list_get_item(values, index); r = (char*)list_get_item(values, index);
if (g_strncmp("name", q, 255) == 0) if (g_strncmp("password", q, 255) == 0)
{ {
g_strcpy(mod_data->name, r); list_add_item(self->mm->login_names, (long)g_strdup("password"));
list_add_item(self->mm->login_values,
(long)g_strdup(self->session->client_info->password));
} }
else if (g_strncmp("lib", q, 255) == 0) else if (g_strncmp("username", q, 255) == 0)
{ {
g_strcpy(mod_data->lib, r); list_add_item(self->mm->login_names, (long)g_strdup("username"));
list_add_item(self->mm->login_values,
(long)g_strdup(self->session->client_info->username));
} }
else else
{ {
if (g_strncmp("password", q, 255) == 0) list_add_item(self->mm->login_names, (long)g_strdup(q));
{ list_add_item(self->mm->login_values, (long)g_strdup(r));
list_add_item(mod_data->names, (long)g_strdup("password"));
list_add_item(mod_data->values,
(long)g_strdup(self->session->client_info->password));
}
else if (g_strncmp("username", q, 255) == 0)
{
list_add_item(mod_data->names, (long)g_strdup("username"));
list_add_item(mod_data->values,
(long)g_strdup(self->session->client_info->username));
}
else
{
list_add_item(mod_data->names, (long)g_strdup(q));
list_add_item(mod_data->values, (long)g_strdup(r));
}
}
}
if (xrdp_wm_setup_mod1(self, mod_data) != 0)
{
/* totaly free mod */
if (self->mod_exit != 0)
{
self->mod_exit(self->mod);
}
g_xrdp_sync(sync_unload, self->mod_handle, 0);
self->mod = 0;
self->mod_handle = 0;
self->mod_init = 0;
self->mod_exit = 0;
}
else if (xrdp_wm_setup_mod2(self, mod_data->names, mod_data->values) != 0)
{
/* totaly free mod */
if (self->mod_exit != 0)
{
self->mod_exit(self->mod);
}
g_xrdp_sync(sync_unload, self->mod_handle, 0);
self->mod = 0;
self->mod_handle = 0;
self->mod_init = 0;
self->mod_exit = 0;
/* don't close here so user can see error */
}
else /* close connection log window if connection is ok */
{
if (self->log_wnd != 0)
{
xrdp_bitmap_delete(self->log_wnd);
}
}
if (!self->pro_layer->term)
{
if (self->mod != 0)
{
if (self->mod->sck != 0)
{
self->pro_layer->app_sck = self->mod->sck;
}
} }
} }
self->login_mode = 2;
} }
list_delete(mod_data->names);
list_delete(mod_data->values);
list_delete(names); list_delete(names);
list_delete(values); list_delete(values);
g_free(mod_data);
g_file_close(fd); g_file_close(fd);
} }
} }
else else
#endif
{ {
xrdp_login_wnd_create(self); xrdp_login_wnd_create(self);
/* clear screen */ /* clear screen */
xrdp_bitmap_invalidate(self->screen, 0); xrdp_bitmap_invalidate(self->screen, 0);
xrdp_wm_set_focused(self, self->login_window); xrdp_wm_set_focused(self, self->login_window);
self->login_mode = 1;
} }
return 0; return 0;
} }
@ -1385,20 +1317,22 @@ xrdp_wm_idle(struct xrdp_wm* self)
if (self->login_mode == 0) if (self->login_mode == 0)
{ {
/* this is the inital state of the login window */ /* this is the inital state of the login window */
self->login_mode = 1; /* put the wm in login mode */
list_clear(self->log); list_clear(self->log);
xrdp_wm_delete_all_childs(self); xrdp_wm_delete_all_childs(self);
if (xrdp_wm_init(self) == 0) xrdp_wm_init(self);
{
/* put the wm in login mode */
self->login_mode = 1;
}
} }
else if (self->login_mode == 2) else if (self->login_mode == 2)
{ {
self->login_mode = 3; self->login_mode = 3; /* put the wm in connected mode */
xrdp_wm_delete_all_childs(self); xrdp_wm_delete_all_childs(self);
xrdp_mm_connect(self->mm); xrdp_mm_connect(self->mm);
} }
else if (self->login_mode == 10)
{
xrdp_wm_delete_all_childs(self);
self->login_mode = 11;
}
return 0; return 0;
} }
@ -1415,7 +1349,7 @@ xrdp_wm_app_sck_signal(struct xrdp_wm* self, int app_sck)
return 1; return 1;
} }
} }
else if (self->login_mode == 10) else if (self->login_mode > 9)
{ {
if (self->mm->mod == 0) if (self->mm->mod == 0)
{ {
@ -1467,9 +1401,11 @@ xrdp_wm_log_wnd_notify(struct xrdp_bitmap* wnd,
MAKERECT(rect, wnd->left, wnd->top, wnd->width, wnd->height); MAKERECT(rect, wnd->left, wnd->top, wnd->width, wnd->height);
xrdp_bitmap_delete(wnd); xrdp_bitmap_delete(wnd);
xrdp_bitmap_invalidate(wm->screen, &rect); xrdp_bitmap_invalidate(wm->screen, &rect);
/* if module is gone, end the session when ok is clicked */ /* if module is gone, reset the session when ok is clicked */
if (wm->mm->mod_handle == 0) if (wm->mm->mod_handle == 0)
{ {
/* make sure autologin is off */
wm->session->client_info->rdp_autologin = 0;
wm->login_mode = 0; /* reset session */ wm->login_mode = 0; /* reset session */
} }
} }

Loading…
Cancel
Save