27 |
#include <sys/time.h> /* gettimeofday */ |
#include <sys/time.h> /* gettimeofday */ |
28 |
#include <sys/times.h> /* times */ |
#include <sys/times.h> /* times */ |
29 |
#include <ctype.h> /* toupper */ |
#include <ctype.h> /* toupper */ |
|
#include <limits.h> /* PATH_MAX */ |
|
30 |
#include <errno.h> |
#include <errno.h> |
31 |
#include "rdesktop.h" |
#include "rdesktop.h" |
32 |
|
|
91 |
uint32 g_embed_wnd; |
uint32 g_embed_wnd; |
92 |
uint32 g_rdp5_performanceflags = |
uint32 g_rdp5_performanceflags = |
93 |
RDP5_NO_WALLPAPER | RDP5_NO_FULLWINDOWDRAG | RDP5_NO_MENUANIMATIONS; |
RDP5_NO_WALLPAPER | RDP5_NO_FULLWINDOWDRAG | RDP5_NO_MENUANIMATIONS; |
94 |
|
/* Session Directory redirection */ |
95 |
|
BOOL g_redirect = False; |
96 |
|
char g_redirect_server[64]; |
97 |
|
char g_redirect_domain[16]; |
98 |
|
char g_redirect_password[64]; |
99 |
|
char g_redirect_username[64]; |
100 |
|
char g_redirect_cookie[128]; |
101 |
|
uint32 g_redirect_flags = 0; |
102 |
|
|
103 |
#ifdef WITH_RDPSND |
#ifdef WITH_RDPSND |
104 |
BOOL g_rdpsnd = False; |
BOOL g_rdpsnd = False; |
282 |
fprintf(stderr, "disconnect: %s.\n", text); |
fprintf(stderr, "disconnect: %s.\n", text); |
283 |
} |
} |
284 |
|
|
285 |
|
static void |
286 |
|
rdesktop_reset_state(void) |
287 |
|
{ |
288 |
|
rdp_reset_state(); |
289 |
|
} |
290 |
|
|
291 |
static BOOL |
static BOOL |
292 |
read_password(char *password, int size) |
read_password(char *password, int size) |
293 |
{ |
{ |
389 |
int c; |
int c; |
390 |
char *locale = NULL; |
char *locale = NULL; |
391 |
int username_option = 0; |
int username_option = 0; |
392 |
|
int run_count = 0; /* Session Directory support */ |
393 |
|
BOOL continue_connect = True; /* Session Directory support */ |
394 |
|
|
395 |
#ifdef HAVE_LOCALE_H |
#ifdef HAVE_LOCALE_H |
396 |
/* Set locale according to environment */ |
/* Set locale according to environment */ |
805 |
#endif |
#endif |
806 |
rdpdr_init(); |
rdpdr_init(); |
807 |
|
|
808 |
if (!rdp_connect(server, flags, domain, password, shell, directory)) |
while (run_count < 2 && continue_connect) /* add support for Session Directory; only reconnect once */ |
809 |
return 1; |
{ |
810 |
|
if (run_count == 0) |
811 |
|
{ |
812 |
|
if (!rdp_connect(server, flags, domain, password, shell, directory)) |
813 |
|
return 1; |
814 |
|
} |
815 |
|
else if (!rdp_reconnect |
816 |
|
(server, flags, domain, password, shell, directory, g_redirect_cookie)) |
817 |
|
return 1; |
818 |
|
|
819 |
/* By setting encryption to False here, we have an encrypted login |
/* By setting encryption to False here, we have an encrypted login |
820 |
packet but unencrypted transfer of other packets */ |
packet but unencrypted transfer of other packets */ |
821 |
if (!packet_encryption) |
if (!packet_encryption) |
822 |
g_encryption = False; |
g_encryption = False; |
823 |
|
|
824 |
|
|
825 |
DEBUG(("Connection successful.\n")); |
DEBUG(("Connection successful.\n")); |
826 |
memset(password, 0, sizeof(password)); |
memset(password, 0, sizeof(password)); |
827 |
|
|
828 |
if (ui_create_window()) |
if (run_count == 0) |
829 |
{ |
if (!ui_create_window()) |
830 |
rdp_main_loop(&deactivated, &ext_disc_reason); |
continue_connect = False; |
831 |
ui_destroy_window(); |
|
832 |
|
if (continue_connect) |
833 |
|
rdp_main_loop(&deactivated, &ext_disc_reason); |
834 |
|
|
835 |
|
DEBUG(("Disconnecting...\n")); |
836 |
|
rdp_disconnect(); |
837 |
|
|
838 |
|
if ((g_redirect == True) && (run_count == 0)) /* Support for Session Directory */ |
839 |
|
{ |
840 |
|
/* reset state of major globals */ |
841 |
|
rdesktop_reset_state(); |
842 |
|
|
843 |
|
STRNCPY(domain, g_redirect_domain, sizeof(domain)); |
844 |
|
STRNCPY(g_username, g_redirect_username, sizeof(g_username)); |
845 |
|
STRNCPY(password, g_redirect_password, sizeof(password)); |
846 |
|
STRNCPY(server, g_redirect_server, sizeof(server)); |
847 |
|
flags |= RDP_LOGON_AUTO; |
848 |
|
|
849 |
|
g_redirect = False; |
850 |
|
} |
851 |
|
else |
852 |
|
{ |
853 |
|
continue_connect = False; |
854 |
|
ui_destroy_window(); |
855 |
|
break; |
856 |
|
} |
857 |
|
|
858 |
|
run_count++; |
859 |
} |
} |
860 |
|
|
|
DEBUG(("Disconnecting...\n")); |
|
|
rdp_disconnect(); |
|
861 |
cache_save_state(); |
cache_save_state(); |
862 |
ui_deinit(); |
ui_deinit(); |
863 |
|
|