// Constructor/destructor vncServer::vncServer() { // Initialise some important stuffs... g_Server_running=true; m_socketConn = NULL; m_desktop = NULL; m_name = NULL; m_port = DISPLAY_TO_PORT(0); m_port_http = DISPLAY_TO_HPORT(0); // TightVNC 1.2.7 m_autoportselect = TRUE; m_passwd_required = TRUE; m_auth_hosts = 0; m_blacklist = 0; m_querysetting = 2; m_queryaccept = 0; m_querytimeout = 10; // Autolock settings m_lock_on_exit = 0; // Set the polling mode options m_poll_fullscreen = FALSE; m_poll_foreground = FALSE; m_poll_undercursor = TRUE; m_poll_oneventonly = FALSE; m_poll_consoleonly = TRUE; m_driver = FALSE; m_hook = FALSE; m_virtual = FALSE; sethook=false; // General options m_loopbackOnly = FALSE; m_loopback_allowed = FALSE; m_lock_on_exit = 0; m_connect_pri = 0; m_disableTrayIcon = FALSE; m_AllowEditClients = FALSE; // Set the input options m_enable_remote_inputs = TRUE; m_disable_local_inputs = FALSE; // Clear the client mapping table for (int x=0; x<MAX_CLIENTS; x++) m_clientmap[x] = NULL; m_nextid = 0; // Initialise the update tracker m_update_tracker.init(this); // Signal set when a client quits m_clientquitsig = new omni_condition(&m_clientsLock); // Modif sf@2002 m_SingleWindow = FALSE; strcpy(m_szWindowName, ""); // Modif sf@2002 m_TurboMode = false; // m_fCursorMoved = false; // sf@2002 - v1.1.2 // m_fQueuingEnabled = false; m_fFileTransferEnabled = true; m_nDefaultScale = 1; // sf@2002 - Data Stream Modification Plugin handling m_pDSMPlugin = new CDSMPlugin(); m_fDSMPluginEnabled = false; strcpy(m_szDSMPlugin, ""); m_fMSLogonRequired = false; m_fXRichCursor = false; // sf@2003 - Autoreconnect m_fAutoReconnect = false; m_AutoReconnectPort = 0; strcpy(m_szAutoReconnectAdr, ""); // sf@2005 - No FT User Impersonnation m_fFTUserImpersonation = true; m_fCaptureAlphaBlending = false; m_fBlackAlphaBlending = false; m_impersonationtoken=NULL; // Modif Jeremy C. }
// Socket connection handling BOOL vncServer::SockConnect(BOOL On) { // Are we being asked to switch socket connects on or off? if (On) { // Is there a listening socket? if (m_socketConn == NULL) { m_socketConn = new vncSockConnect(); if (m_socketConn == NULL) return FALSE; // Are we to use automatic port selection? if (m_autoportselect) { BOOL ok = FALSE; // Yes, so cycle through the ports, looking for a free one! for (int i=0; i < 99; i++) { m_port = DISPLAY_TO_PORT(i); m_port_http = DISPLAY_TO_HPORT(i); vnclog.Print(LL_CLIENTS, VNCLOG("trying port number %d\n"), m_port); // Attempt to connect to the port VSocket tempsock; if (tempsock.Create()) { if (!tempsock.Connect("localhost", m_port)) { // Couldn't connect, so this port is probably usable! if (m_socketConn->Init(this, m_port)) { ok = TRUE; break; } } } } if (!ok) { delete m_socketConn; m_socketConn = NULL; return FALSE; } } else { // No autoportselect if (!m_socketConn->Init(this, m_port)) { delete m_socketConn; m_socketConn = NULL; return FALSE; } } } } else { // *** JNW - Trying to fix up a lock-up when the listening socket closes KillAuthClients(); KillUnauthClients(); WaitUntilAuthEmpty(); WaitUntilUnauthEmpty(); // Is there a listening socket? if (m_socketConn != NULL) { // Close the socket delete m_socketConn; m_socketConn = NULL; } } return TRUE; }
void IncomingConnectionsControls::Apply() { // Save the password if one was entered BOOL isShort = SetPasswordSettings(IDC_PASSWORD); // Save the password (view only) if one was entered BOOL isShortViewOnly = SetPasswordSettings(IDC_PASSWORD_VIEWONLY); // Warn about passwords longer than eight characters if (!isShort || !isShortViewOnly) { MessageBox(NULL, "WARNING: You have entered passwords of length exceeding\n" "eight characters, but the standard VNC authentication scheme\n" "does not support such long passwords.\n\n" "Your passwords will be truncated to just eight characters.", szAppName, MB_ICONEXCLAMATION | MB_OK); } // Save the new settings to the server m_server->SetAutoPortSelect(IsChecked(IDC_PORTNO_AUTO)); // Save port numbers if we're not auto selecting if (!m_server->AutoPortSelect()) { if (IsChecked(IDC_SPECDISPLAY)) { // Display number was specified BOOL ok; UINT display = GetDlgItemInt(m_hwnd, IDC_DISPLAYNO, &ok, TRUE); if (ok) m_server->SetPorts(DISPLAY_TO_PORT(display), DISPLAY_TO_HPORT(display)); } else { // Assuming that port numbers were specified BOOL ok1, ok2; UINT port_rfb = GetDlgItemInt(m_hwnd, IDC_PORTRFB, &ok1, TRUE); UINT port_http = GetDlgItemInt(m_hwnd, IDC_PORTHTTP, &ok2, TRUE); if (port_rfb != port_http) { if (ok1 && ok2) m_server->SetPorts(port_rfb, port_http); } else { MessageBox(NULL, "WARNING: You have entered equal RFB and HTTP port numbers.\n\n" "Your changes to port numbers will not be saved.", szAppName, MB_ICONEXCLAMATION | MB_OK); } } } m_server->SockConnect(IsChecked(IDC_CONNECT_SOCK)); // Wallpaper handling m_server->EnableRemoveWallpaper(IsChecked(IDC_REMOVE_WALLPAPER)); m_server->SetBlankScreen(IsChecked(IDC_BLANK_SCREEN)); // Enabling/disabling file transfers m_server->EnableFileTransfers(IsChecked(IDC_ENABLE_FILE_TRANSFERS)); // Enabling/disabling Meta Window Manager m_server->EnableMetaWindowManager(IsChecked(IDC_ENABLE_METAWM)); Validate(TRUE); }
// Constructor/destructor vncServer::vncServer() { ResetPasswordsValidityInfo(); // Initialise some important stuff... m_socketConn = NULL; m_jingleConn = NULL; m_desktop = NULL; m_name = NULL; m_port = DISPLAY_TO_PORT(0); m_port_http = DISPLAY_TO_HPORT(0); m_autoportselect = TRUE; m_passwd_required = TRUE; m_beepConnect = FALSE; m_beepDisconnect = FALSE; m_auth_hosts = 0; m_blacklist = 0; { vncPasswd::FromClear clearPWD; memcpy(m_password, clearPWD, MAXPWLEN); m_password_set = FALSE; memcpy(m_password_viewonly, clearPWD, MAXPWLEN); m_password_viewonly_set = FALSE; } m_querysetting = 2; m_querytimeout = 10; m_queryaccept = FALSE; m_queryallownopass = FALSE; // Autolock settings m_lock_on_exit = 0; // Set the polling mode options m_poll_fullscreen = FALSE; m_poll_foreground = FALSE; m_poll_undercursor = TRUE; m_poll_oneventonly = FALSE; m_poll_consoleonly = TRUE; m_dont_set_hooks = FALSE; m_dont_use_driver = FALSE; m_driver_direct_access_en = TRUE; // General options m_loopbackOnly = FALSE; m_disableTrayIcon = FALSE; m_loopback_allowed = FALSE; m_httpd_enabled = TRUE; m_httpd_params_enabled = FALSE; m_lock_on_exit = 0; m_connect_pri = 0; // Set the input options m_enable_remote_inputs = TRUE; m_disable_local_inputs = FALSE; // Clear the client mapping table for (int x=0; x<MAX_CLIENTS; x++) m_clientmap[x] = NULL; m_nextid = 0; // Signal set when a client quits m_clientquitsig = new omni_condition(&m_clientsLock); m_clients_disabled = FALSE; m_local_input_priority = FALSE; m_full_screen = TRUE; m_WindowShared= FALSE; m_hwndShared = NULL; m_screen_area = FALSE; m_primary_display_only_shared = FALSE; m_disable_time = 3; SetSharedRect(GetScreenRect()); SetPollingCycle(300); PollingCycleChanged(false); m_cursor_pos.x = 0; m_cursor_pos.y = 0; // initialize m_enable_file_transfers = FALSE; m_remove_wallpaper = FALSE; m_blank_screen = FALSE; #ifdef HORIZONLIVE m_full_screen = FALSE; m_WindowShared= TRUE; m_local_input_priority = TRUE; m_remote_mouse = 1; m_remote_keyboard = 1; #endif m_wallpaper_wait = FALSE; }
// Socket connection handling BOOL vncServer::SockConnect(BOOL On) { // Are we being asked to switch socket connects on or off? if (On) { // Is there a listening socket? if (m_socketConn == NULL) { m_socketConn = new vncSockConnect(); if (m_socketConn == NULL) return FALSE; // Are we to use automatic port selection? if (m_autoportselect) { BOOL ok = FALSE; // Yes, so cycle through the ports, looking for a free one! for (int i = 0; i < 99; i++) { m_port = DISPLAY_TO_PORT(i); m_port_http = DISPLAY_TO_HPORT(i); vnclog.Print(LL_CLIENTS, VNCLOG("trying port number %d\n"), m_port); // Attempt to connect to the port VSocket tempsock; if (tempsock.Create()) { if (!tempsock.Connect("localhost", m_port)) { // Couldn't connect, so this port is probably usable! if (m_socketConn->Init(this, m_port)) { ok = TRUE; break; } } } } if (!ok) { delete m_socketConn; m_socketConn = NULL; return FALSE; } } else { // No autoportselect if (!m_socketConn->Init(this, m_port)) { delete m_socketConn; m_socketConn = NULL; return FALSE; } } // Now let's start the HTTP connection stuff if (m_port_http == m_port) { vnclog.Print(LL_INTERR, VNCLOG("cannot start both RFB and HTTP servers " "on the same port\n")); } if (m_httpConn == NULL && m_httpd_enabled && m_port_http != m_port) { m_httpConn = new vncHTTPConnect; if (m_httpConn != NULL) { // Start up the HTTP server if (!m_httpConn->Init(this, m_port_http, m_httpd_params_enabled)) { delete m_httpConn; m_httpConn = NULL; return FALSE; } } } } } else { // *** JNW - Trying to fix up a lock-up when the listening socket closes #ifndef HORIZONLIVE KillAuthClients(); KillUnauthClients(); WaitUntilAuthEmpty(); WaitUntilUnauthEmpty(); #endif // Is there a listening socket? if (m_socketConn != NULL) { // Close the socket delete m_socketConn; m_socketConn = NULL; } // Is there an HTTP socket active? if (m_httpConn != NULL) { // Close the socket delete m_httpConn; m_httpConn = NULL; } } return TRUE; }