summaryrefslogtreecommitdiffstats
path: root/xrdp
diff options
context:
space:
mode:
authorjsorg71 <jsorg71>2005-04-02 20:57:14 +0000
committerjsorg71 <jsorg71>2005-04-02 20:57:14 +0000
commit3a7093caacd542c9902e4c9fd62ca6cd8212296d (patch)
tree0aadb596881e8aa1c9fc6ac74b5881c8d27748c3 /xrdp
parent4c8ffafc9aad2397f6ccf7b5cb18520ce6bd231c (diff)
downloadxrdp-proprietary-3a7093caacd542c9902e4c9fd62ca6cd8212296d.tar.gz
xrdp-proprietary-3a7093caacd542c9902e4c9fd62ca6cd8212296d.zip
added more login options
Diffstat (limited to 'xrdp')
-rw-r--r--xrdp/constants.h2
-rw-r--r--xrdp/xrdp.ini16
-rw-r--r--xrdp/xrdp_bitmap.c34
-rw-r--r--xrdp/xrdp_login_wnd.c453
-rw-r--r--xrdp/xrdp_types.h6
5 files changed, 318 insertions, 193 deletions
diff --git a/xrdp/constants.h b/xrdp/constants.h
index 2ee617d8..6b15a91f 100644
--- a/xrdp/constants.h
+++ b/xrdp/constants.h
@@ -429,3 +429,5 @@
#define WM_BUTTON5UP 109
#define WM_BUTTON5DOWN 110
#define WM_INVALIDATE 200
+
+#define CB_ITEMCHANGE 300
diff --git a/xrdp/xrdp.ini b/xrdp/xrdp.ini
index 9a682181..84f526c0 100644
--- a/xrdp/xrdp.ini
+++ b/xrdp/xrdp.ini
@@ -6,17 +6,23 @@ bitmap_compression=yes
[vnc1]
name=sesman
lib=../vnc/libvnc.so
-auth=local
-ip=127.0.0.1
-port=-1
username=ask
password=ask
+ip=127.0.0.1
+port=-1
[vnc2]
name=console
lib=../vnc/libvnc.so
-auth=local
ip=127.0.0.1
port=5900
-username=ask
+username=na
+password=ask
+
+[vnc3]
+name=vnc-any
+lib=../vnc/libvnc.so
+ip=ask
+port=ask5900
+username=na
password=ask
diff --git a/xrdp/xrdp_bitmap.c b/xrdp/xrdp_bitmap.c
index 3e0262e9..7adf031d 100644
--- a/xrdp/xrdp_bitmap.c
+++ b/xrdp/xrdp_bitmap.c
@@ -139,6 +139,7 @@ struct xrdp_bitmap* xrdp_bitmap_create_with_data(int width, int height,
void xrdp_bitmap_delete(struct xrdp_bitmap* self)
{
int i;
+ struct xrdp_mod_data* mod_data;
if (self == 0)
{
@@ -194,8 +195,23 @@ void xrdp_bitmap_delete(struct xrdp_bitmap* self)
xrdp_list_remove_item(self->parent->child_list, i);
}
}
- xrdp_list_delete(self->string_list);
- xrdp_list_delete(self->data_list);
+ if (self->string_list != 0) /* for combo */
+ {
+ xrdp_list_delete(self->string_list);
+ }
+ if (self->data_list != 0) /* for combo */
+ {
+ for (i = 0; i < self->data_list->count; i++)
+ {
+ mod_data = (struct xrdp_mod_data*)xrdp_list_get_item(self->data_list, i);
+ if (mod_data != 0)
+ {
+ xrdp_list_delete(mod_data->names);
+ xrdp_list_delete(mod_data->values);
+ }
+ }
+ xrdp_list_delete(self->data_list);
+ }
if (!self->do_not_free_data)
{
g_free(self->data);
@@ -1343,6 +1359,10 @@ int xrdp_bitmap_def_proc(struct xrdp_bitmap* self, int msg,
{
self->item_index--;
xrdp_bitmap_invalidate(self, 0);
+ if (self->parent->notify != 0)
+ {
+ self->parent->notify(self->parent, self, CB_ITEMCHANGE, 0, 0);
+ }
}
}
/* right or down arrow */
@@ -1353,6 +1373,10 @@ int xrdp_bitmap_def_proc(struct xrdp_bitmap* self, int msg,
{
self->item_index++;
xrdp_bitmap_invalidate(self, 0);
+ if (self->parent->notify != 0)
+ {
+ self->parent->notify(self->parent, self, CB_ITEMCHANGE, 0, 0);
+ }
}
}
}
@@ -1379,6 +1403,12 @@ int xrdp_bitmap_def_proc(struct xrdp_bitmap* self, int msg,
{
self->popped_from->item_index = self->item_index;
xrdp_bitmap_invalidate(self->popped_from, 0);
+ if (self->popped_from->parent->notify != 0)
+ {
+ self->popped_from->parent->notify(self->popped_from->parent,
+ self->popped_from,
+ CB_ITEMCHANGE, 0, 0);
+ }
}
}
}
diff --git a/xrdp/xrdp_login_wnd.c b/xrdp/xrdp_login_wnd.c
index 126b54e6..4893ce60 100644
--- a/xrdp/xrdp_login_wnd.c
+++ b/xrdp/xrdp_login_wnd.c
@@ -146,150 +146,281 @@ int xrdp_wm_delete_all_childs(struct xrdp_wm* self)
}
/*****************************************************************************/
-/* all login screen events go here */
-int xrdp_wm_login_notify(struct xrdp_bitmap* wnd,
- struct xrdp_bitmap* sender,
- int msg, long param1, long param2)
+int set_mod_data_item(struct xrdp_mod_data* mod, char* name, char* value)
+{
+ int index;
+
+ for (index = 0; index < mod->names->count; index++)
+ {
+ if (g_strcmp(name, (char*)xrdp_list_get_item(mod->names, index)) == 0)
+ {
+ xrdp_list_remove_item(mod->values, index);
+ xrdp_list_insert_item(mod->values, index, (long)g_strdup(value));
+ }
+ }
+ return 0;
+}
+
+/*****************************************************************************/
+int xrdp_wm_help_clicked(struct xrdp_bitmap* wnd)
{
struct xrdp_bitmap* help;
struct xrdp_bitmap* but;
- struct xrdp_bitmap* b;
+
+ /* create help screen */
+ 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;
+ help->bg_color = wnd->wm->grey;
+ help->left = wnd->wm->screen->width / 2 - help->width / 2;
+ help->top = wnd->wm->screen->height / 2 - help->height / 2;
+ 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,
+ WND_TYPE_BUTTON, wnd->wm);
+ xrdp_list_insert_item(help->child_list, 0, (long)but);
+ but->parent = help;
+ but->owner = help;
+ but->left = 120;
+ but->top = 260;
+ but->id = 1;
+ but->tab_stop = 1;
+ set_string(&but->caption1, "OK");
+ /* draw it */
+ help->focused_control = but;
+ help->default_button = but;
+ help->esc_button = but;
+ xrdp_bitmap_invalidate(help, 0);
+ xrdp_wm_set_focused(wnd->wm, help);
+ return 0;
+}
+
+/*****************************************************************************/
+int xrdp_wm_cancel_clicked(struct xrdp_bitmap* wnd)
+{
+ if (wnd != 0)
+ {
+ if (wnd->wm != 0)
+ {
+ if (wnd->wm->pro_layer != 0)
+ {
+ wnd->wm->pro_layer->term = 1;
+ }
+ }
+ }
+ return 0;
+}
+
+/*****************************************************************************/
+int xrdp_wm_ok_clicked(struct xrdp_bitmap* wnd)
+{
struct xrdp_bitmap* combo;
+ struct xrdp_bitmap* label;
struct xrdp_bitmap* edit;
struct xrdp_wm* wm;
- struct xrdp_rect rect;
- struct xrdp_mod_data con_mod;
- struct xrdp_mod_data* mod;
+ struct xrdp_list* names;
+ struct xrdp_list* values;
+ struct xrdp_mod_data* mod_data;
int i;
- if (wnd->modal_dialog != 0 && msg != 100)
- {
- return 0;
- }
wm = wnd->wm;
- if (msg == 1) /* click */
+ combo = xrdp_bitmap_get_child_by_id(wnd, 6);
+ if (combo != 0)
{
- if (sender->id == 1) /* help button */
- {
- /* create help screen */
- 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;
- help->bg_color = wnd->wm->grey;
- help->left = wnd->wm->screen->width / 2 - help->width / 2;
- help->top = wnd->wm->screen->height / 2 - help->height / 2;
- 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,
- WND_TYPE_BUTTON, wnd->wm);
- xrdp_list_insert_item(help->child_list, 0, (long)but);
- but->parent = help;
- but->owner = help;
- but->left = 120;
- but->top = 260;
- but->id = 1;
- but->tab_stop = 1;
- set_string(&but->caption1, "OK");
- /* draw it */
- help->focused_control = but;
- help->default_button = but;
- help->esc_button = but;
- xrdp_bitmap_invalidate(help, 0);
- xrdp_wm_set_focused(wnd->wm, help);
- }
- else if (sender->id == 2) /* cancel button */
+ mod_data = (struct xrdp_mod_data*)
+ xrdp_list_get_item(combo->data_list, combo->item_index);
+ if (mod_data != 0)
{
- if (wnd != 0)
+ /* get the user typed values */
+ i = 100;
+ label = xrdp_bitmap_get_child_by_id(wnd, i);
+ edit = xrdp_bitmap_get_child_by_id(wnd, i + 1);
+ while (label != 0 && edit != 0)
{
- if (wnd->wm != 0)
+ set_mod_data_item(mod_data, label->caption1, edit->caption1);
+ i += 2;
+ label = xrdp_bitmap_get_child_by_id(wnd, i);
+ edit = xrdp_bitmap_get_child_by_id(wnd, i + 1);
+ }
+ if (xrdp_wm_setup_mod(wm, mod_data) == 0)
+ {
+ /* gota copy these cause dialog gets freed */
+ names = xrdp_list_create();
+ names->auto_free = 1;
+ for (i = 0; i < mod_data->names->count; i++)
+ {
+ xrdp_list_add_item(names,
+ (long)g_strdup((char*)xrdp_list_get_item(mod_data->names, i)));
+ }
+ values = xrdp_list_create();
+ values->auto_free = 1;
+ for (i = 0; i < mod_data->values->count; i++)
+ {
+ xrdp_list_add_item(values,
+ (long)g_strdup((char*)xrdp_list_get_item(mod_data->values, i)));
+ }
+ xrdp_wm_delete_all_childs(wm);
+ if (!wm->pro_layer->term)
{
- if (wnd->wm->pro_layer != 0)
+ if (wm->mod->mod_start(wm->mod, wm->screen->width,
+ wm->screen->height, wm->screen->bpp) != 0)
{
- wnd->wm->pro_layer->term = 1;
+ wm->pro_layer->term = 1; /* kill session */
}
}
- }
- }
- 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);
- if (mod != 0)
+ if (!wm->pro_layer->term)
{
- con_mod = *mod;
- if (g_strcmp(con_mod.username, "ask") == 0)
+ for (i = 0; i < names->count; i++)
{
- edit = xrdp_bitmap_get_child_by_id(wnd, 4);
- if (edit != 0)
- {
- g_strcpy(con_mod.username, edit->caption1);
- }
+ wm->mod->mod_set_param(wm->mod,
+ (char*)xrdp_list_get_item(names, i),
+ (char*)xrdp_list_get_item(values, i));
}
- if (g_strcmp(con_mod.password, "ask") == 0)
+ if (wm->mod->mod_connect(wm->mod) != 0)
{
- edit = xrdp_bitmap_get_child_by_id(wnd, 5);
- if (edit != 0)
- {
- g_strcpy(con_mod.password, edit->caption1);
- }
+ /* 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;
}
- if (xrdp_wm_setup_mod(wm, mod) == 0)
+ else /* close connection log window if connection is ok */
{
- xrdp_wm_delete_all_childs(wm);
- if (!wm->pro_layer->term)
+ if (wm->log_wnd != 0)
{
- if (wm->mod->mod_start(wm->mod, wm->screen->width,
- wm->screen->height, wm->screen->bpp) != 0)
- {
- wm->pro_layer->term = 1; /* kill session */
- }
+ xrdp_bitmap_delete(wm->log_wnd);
}
- if (!wm->pro_layer->term)
- {
- wm->mod->mod_set_param(wm->mod, "ip", con_mod.ip);
- wm->mod->mod_set_param(wm->mod, "port", con_mod.port);
- wm->mod->mod_set_param(wm->mod, "username", con_mod.username);
- wm->mod->mod_set_param(wm->mod, "password", con_mod.password);
- if (wm->mod->mod_connect(wm->mod) != 0)
- {
- /* 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;
- }
- else /* close connection log window if connection is ok */
- {
- if (wm->log_wnd != 0)
- {
- xrdp_bitmap_delete(wm->log_wnd);
- }
- }
- }
- if (!wm->pro_layer->term)
+ }
+ }
+ if (!wm->pro_layer->term)
+ {
+ if (wm->mod != 0)
+ {
+ if (wm->mod->sck != 0)
{
- if (wm->mod != 0)
- {
- if (wm->mod->sck != 0)
- {
- wm->pro_layer->app_sck = wm->mod->sck;
- }
- }
+ wm->pro_layer->app_sck = wm->mod->sck;
}
}
}
+ xrdp_list_delete(names);
+ xrdp_list_delete(values);
}
}
}
+ return 0;
+}
+
+/******************************************************************************/
+int xrdp_wm_show_edits(struct xrdp_wm* self, struct xrdp_bitmap* combo)
+{
+ int count;
+ int index;
+ int insert_index;
+ char* name;
+ char* value;
+ struct xrdp_mod_data* mod;
+ struct xrdp_bitmap* b;
+
+ /* free labels and edits, cause we gota create them */
+ /* creation or combo changed */
+ for (index = 100; index < 200; index++)
+ {
+ b = xrdp_bitmap_get_child_by_id(combo->parent, index);
+ xrdp_bitmap_delete(b);
+ }
+
+ insert_index = xrdp_list_index_of(self->login_window->child_list,
+ (long)combo);
+ insert_index++;
+ mod = (struct xrdp_mod_data*)
+ xrdp_list_get_item(combo->data_list, combo->item_index);
+ if (mod != 0)
+ {
+ count = 0;
+ for (index = 0; index < mod->names->count; index++)
+ {
+ value = (char*)xrdp_list_get_item(mod->values, index);
+ if (g_strncmp("ask", value, 3) == 0)
+ {
+ /* label */
+ b = xrdp_bitmap_create(60, 20, self->screen->bpp,
+ WND_TYPE_LABEL, self);
+ xrdp_list_insert_item(self->login_window->child_list, insert_index,
+ (long)b);
+ insert_index++;
+ b->parent = self->login_window;
+ b->owner = self->login_window;
+ b->left = 155;
+ b->top = 60 + 25 * count;
+ b->id = 100 + 2 * count;
+ name = (char*)xrdp_list_get_item(mod->names, index);
+ set_string(&b->caption1, name);
+ /* edit */
+ b = xrdp_bitmap_create(140, 20, self->screen->bpp,
+ WND_TYPE_EDIT, self);
+ xrdp_list_insert_item(self->login_window->child_list, insert_index,
+ (long)b);
+ insert_index++;
+ b->parent = self->login_window;
+ b->owner = self->login_window;
+ b->left = 220;
+ b->top = 60 + 25 * count;
+ b->id = 100 + 2 * count + 1;
+ b->pointer = 1;
+ b->tab_stop = 1;
+ b->caption1 = (char*)g_malloc(256, 1);
+ g_strcpy(b->caption1, value + 3);
+ b->edit_pos = g_strlen(b->caption1);
+ if (self->login_window->focused_control == 0)
+ {
+ self->login_window->focused_control = b;
+ }
+ if (g_strcmp(name, "password") == 0)
+ {
+ b->password_char = '*';
+ }
+ count++;
+ }
+ }
+ }
+ return 0;
+}
+
+/*****************************************************************************/
+/* all login screen events go here */
+int xrdp_wm_login_notify(struct xrdp_bitmap* wnd,
+ struct xrdp_bitmap* sender,
+ int msg, long param1, long param2)
+{
+ struct xrdp_bitmap* b;
+ struct xrdp_rect rect;
+ int i;
+
+ if (wnd->modal_dialog != 0 && msg != 100)
+ {
+ return 0;
+ }
+ if (msg == 1) /* click */
+ {
+ if (sender->id == 1) /* help button */
+ {
+ xrdp_wm_help_clicked(wnd);
+ }
+ else if (sender->id == 2) /* cancel button */
+ {
+ xrdp_wm_cancel_clicked(wnd);
+ }
+ else if (sender->id == 3) /* ok button */
+ {
+ xrdp_wm_ok_clicked(wnd);
+ }
+ }
else if (msg == 2) /* mouse move */
{
}
@@ -308,6 +439,11 @@ int xrdp_wm_login_notify(struct xrdp_bitmap* wnd,
xrdp_wm_set_focused(wnd->wm, wnd);
}
}
+ else if (msg == CB_ITEMCHANGE) /* combo box change */
+ {
+ xrdp_wm_show_edits(wnd->wm, sender);
+ xrdp_bitmap_invalidate(wnd, 0); /* invalidate the whole dialog for now */
+ }
return 0;
}
@@ -344,7 +480,11 @@ int xrdp_wm_login_fill_in_combo(struct xrdp_wm* self, struct xrdp_bitmap* b)
{
mod_data = (struct xrdp_mod_data*)
g_malloc(sizeof(struct xrdp_mod_data), 1);
- g_strcpy(mod_data->name, p);
+ mod_data->names = xrdp_list_create();
+ mod_data->names->auto_free = 1;
+ mod_data->values = xrdp_list_create();
+ 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++)
{
q = (char*)xrdp_list_get_item(section_names, j);
@@ -357,21 +497,10 @@ int xrdp_wm_login_fill_in_combo(struct xrdp_wm* self, struct xrdp_bitmap* b)
{
g_strcpy(mod_data->lib, r);
}
- else if (g_strcmp("ip", q) == 0)
- {
- g_strcpy(mod_data->ip, r);
- }
- else if (g_strcmp("port", q) == 0)
+ else
{
- g_strcpy(mod_data->port, r);
- }
- else if (g_strcmp("username", q) == 0)
- {
- g_strcpy(mod_data->username, r);
- }
- else if (g_strcmp("password", q) == 0)
- {
- g_strcpy(mod_data->password, r);
+ xrdp_list_add_item(mod_data->names, (long)g_strdup(q));
+ xrdp_list_add_item(mod_data->values, (long)g_strdup(r));
}
}
xrdp_list_add_item(b->string_list, (long)g_strdup(mod_data->name));
@@ -389,6 +518,7 @@ int xrdp_wm_login_fill_in_combo(struct xrdp_wm* self, struct xrdp_bitmap* b)
int xrdp_login_wnd_create(struct xrdp_wm* self)
{
struct xrdp_bitmap* but;
+ struct xrdp_bitmap* combo;
/* draw login window */
self->login_window = xrdp_bitmap_create(400, 200, self->screen->bpp,
@@ -428,63 +558,19 @@ int xrdp_login_wnd_create(struct xrdp_wm* self)
but->parent = self->login_window;
but->owner = self->login_window;
but->left = 155;
- but->top = 50;
- set_string(&but->caption1, "Username");
-
- /* edit */
- but = xrdp_bitmap_create(140, 20, self->screen->bpp, WND_TYPE_EDIT, self);
- xrdp_list_add_item(self->login_window->child_list, (long)but);
- but->parent = self->login_window;
- but->owner = self->login_window;
- but->left = 220;
- but->top = 50;
- but->id = 4;
- but->pointer = 1;
- but->tab_stop = 1;
- but->caption1 = (char*)g_malloc(256, 1);
- self->login_window->focused_control = but;
-
- /* label */
- but = xrdp_bitmap_create(60, 20, self->screen->bpp, WND_TYPE_LABEL, self);
- xrdp_list_add_item(self->login_window->child_list, (long)but);
- but->parent = self->login_window;
- but->owner = self->login_window;
- but->left = 155;
- but->top = 80;
- set_string(&but->caption1, "Password");
-
- /* edit */
- but = xrdp_bitmap_create(140, 20, self->screen->bpp, WND_TYPE_EDIT, self);
- xrdp_list_add_item(self->login_window->child_list, (long)but);
- but->parent = self->login_window;
- but->owner = self->login_window;
- but->left = 220;
- but->top = 80;
- but->id = 5;
- but->pointer = 1;
- but->tab_stop = 1;
- but->caption1 = (char*)g_malloc(256, 1);
- but->password_char = '*';
-
- /* label */
- but = xrdp_bitmap_create(60, 20, self->screen->bpp, WND_TYPE_LABEL, self);
- xrdp_list_add_item(self->login_window->child_list, (long)but);
- but->parent = self->login_window;
- but->owner = self->login_window;
- but->left = 155;
- but->top = 110;
+ but->top = 35;
set_string(&but->caption1, "Module");
/* combo */
- but = xrdp_bitmap_create(140, 20, self->screen->bpp, WND_TYPE_COMBO, self);
- xrdp_list_add_item(self->login_window->child_list, (long)but);
- but->parent = self->login_window;
- but->owner = self->login_window;
- but->left = 220;
- but->top = 110;
- but->id = 6;
- but->tab_stop = 1;
- xrdp_wm_login_fill_in_combo(self, but);
+ combo = xrdp_bitmap_create(140, 20, self->screen->bpp, WND_TYPE_COMBO, self);
+ xrdp_list_add_item(self->login_window->child_list, (long)combo);
+ combo->parent = self->login_window;
+ combo->owner = self->login_window;
+ combo->left = 220;
+ combo->top = 35;
+ combo->id = 6;
+ combo->tab_stop = 1;
+ xrdp_wm_login_fill_in_combo(self, combo);
/* button */
but = xrdp_bitmap_create(60, 25, self->screen->bpp, WND_TYPE_BUTTON, self);
@@ -521,5 +607,8 @@ int xrdp_login_wnd_create(struct xrdp_wm* self)
set_string(&but->caption1, "Help");
but->tab_stop = 1;
+ /* labels and edits */
+ xrdp_wm_show_edits(self, combo);
+
return 0;
}
diff --git a/xrdp/xrdp_types.h b/xrdp/xrdp_types.h
index 86fc569a..de687c67 100644
--- a/xrdp/xrdp_types.h
+++ b/xrdp/xrdp_types.h
@@ -525,8 +525,6 @@ struct xrdp_mod_data
{
char name[256];
char lib[256];
- char ip[256];
- char port[256];
- char username[256];
- char password[256];
+ struct xrdp_list* names;
+ struct xrdp_list* values;
};