void vncPropertiesPoll::Load(BOOL usersettings) { if (m_dlgvisible) { vnclog.Print(LL_INTWARN, VNCLOG("service helper invoked while Properties panel displayed\n")); return; } // Set the default user prefs vnclog.Print(LL_INTINFO, VNCLOG("clearing user settings\n")); m_pref_TurboMode = FALSE; m_pref_PollUnderCursor=FALSE; m_pref_PollForeground=TRUE; m_pref_PollFullScreen=TRUE; m_pref_PollConsoleOnly=FALSE; m_pref_PollOnEventOnly=TRUE; #ifdef DRIVER m_pref_Driver=CheckVideoDriver(0); #else m_pref_Driver=false; #endif m_pref_Hook=TRUE; m_pref_Virtual=FALSE; // Make the loaded settings active.. ApplyUserPrefs(); // Note whether we loaded the user settings or just the default system settings m_usersettings = usersettings; }
void vncPropertiesPoll::LoadFromIniFile() { // if (m_dlgvisible) // { // vnclog.Print(LL_INTWARN, VNCLOG("service helper invoked while Properties panel displayed\n")); // return; // } m_pref_TurboMode = TRUE;//((vncService::VersionMajor() >= 6) ? TRUE : FALSE); m_pref_PollUnderCursor=FALSE; m_pref_PollForeground= FALSE; m_pref_PollFullScreen= TRUE;//((vncService::VersionMajor() >= 6) ? TRUE : FALSE); m_pref_PollConsoleOnly=FALSE; m_pref_PollOnEventOnly=FALSE; m_pref_MaxCpu=40; m_pref_Driver=CheckVideoDriver(0); m_pref_Hook=TRUE; m_pref_Virtual=FALSE; m_pref_SingleWindow = 0; *m_pref_szSingleWindowName = '\0'; LoadUserPrefsPollFromIniFile(); ApplyUserPrefs(); }
void vncProperties::Load(BOOL usersettings) { // Initialize to 'sane' defaults for our purposes m_pref_QuerySetting=2; m_pref_QueryTimeout=10; m_pref_IdleTimeout=0; m_pref_EnableRemoteInputs=TRUE; m_pref_DisableLocalInputs=TRUE; m_pref_PollUnderCursor=FALSE; m_pref_PollForeground=TRUE; m_pref_PollFullScreen=TRUE; return; char username[UNLEN+1]; HKEY hkLocal, hkLocalUser, hkDefault; DWORD dw; // NEW (R3) PREFERENCES ALGORITHM // 1. Look in HKEY_LOCAL_MACHINE/Software/ORL/WinVNC3/%username% // for sysadmin-defined, user-specific settings. // 2. If not found, fall back to %username%=Default // 3. If AllowOverrides is set then load settings from // HKEY_CURRENT_USER/Software/ORL/WinVNC3 // GET THE CORRECT KEY TO READ FROM // Get the user name / service name if (!vncService::CurrentUser((char *)&username, sizeof(username))) return; // If there is no user logged on them default to SYSTEM if (strcmp(username, "") == 0) strcpy((char *)&username, "SYSTEM"); // Try to get the machine registry key for WinVNC if (RegCreateKeyEx(HKEY_LOCAL_MACHINE, WINVNC_REGISTRY_KEY, 0, REG_NONE, REG_OPTION_NON_VOLATILE, KEY_READ, NULL, &hkLocal, &dw) != ERROR_SUCCESS) return; // Now try to get the per-user local key if (RegOpenKeyEx(hkLocal, username, 0, KEY_READ, &hkLocalUser) != ERROR_SUCCESS) hkLocalUser = NULL; // Get the default key if (RegCreateKeyEx(hkLocal, "Default", 0, REG_NONE, REG_OPTION_NON_VOLATILE, KEY_READ, NULL, &hkDefault, &dw) != ERROR_SUCCESS) hkDefault = NULL; // LOAD THE MACHINE-LEVEL PREFS // Logging/debugging prefs vnclog.Print(LL_INTINFO, VNCLOG("loading local-only settings\n")); vnclog.SetMode(LoadInt(hkLocal, "DebugMode", 0)); vnclog.SetLevel(LoadInt(hkLocal, "DebugLevel", 0)); // Authentication required, loopback allowed, loopbackOnly m_server->SetLoopbackOnly(LoadInt(hkLocal, "LoopbackOnly", false)); if (m_server->LoopbackOnly()) m_server->SetLoopbackOk(true); else m_server->SetLoopbackOk(LoadInt(hkLocal, "AllowLoopback", false)); m_server->SetAuthRequired(LoadInt(hkLocal, "AuthRequired", true)); m_server->SetConnectPriority(LoadInt(hkLocal, "ConnectPriority", 0)); if (!m_server->LoopbackOnly()) { char *authhosts = LoadString(hkLocal, "AuthHosts"); if (authhosts != 0) { m_server->SetAuthHosts(authhosts); delete [] authhosts; } else { m_server->SetAuthHosts(0); } } else { m_server->SetAuthHosts(0); } // LOAD THE USER PREFERENCES // Set the default user prefs vnclog.Print(LL_INTINFO, VNCLOG("clearing user settings\n")); m_pref_HTTPConnect = TRUE; m_pref_AutoPortSelect=TRUE; m_pref_PortNumber=5900; m_pref_SockConnect=TRUE; m_pref_CORBAConn=FALSE; { vncPasswd::FromClear crypt; memcpy(m_pref_passwd, crypt, MAXPWLEN); } m_pref_QuerySetting=2; m_pref_QueryTimeout=10; m_pref_IdleTimeout=0; m_pref_EnableRemoteInputs=TRUE; m_pref_DisableLocalInputs=FALSE; m_pref_LockSettings=-1; m_pref_PollUnderCursor=FALSE; m_pref_PollForeground=TRUE; m_pref_PollFullScreen=FALSE; m_pref_PollConsoleOnly=TRUE; m_pref_PollOnEventOnly=FALSE; m_pref_RemoveWallpaper=TRUE; m_alloweditclients = TRUE; m_allowshutdown = TRUE; m_allowproperties = TRUE; // Load the local prefs for this user if (hkDefault != NULL) { vnclog.Print(LL_INTINFO, VNCLOG("loading DEFAULT local settings\n")); LoadUserPrefs(hkDefault); m_allowshutdown = LoadInt(hkDefault, "AllowShutdown", m_allowshutdown); m_allowproperties = LoadInt(hkDefault, "AllowProperties", m_allowproperties); m_alloweditclients = LoadInt(hkDefault, "AllowEditClients", m_alloweditclients); } // Are we being asked to load the user settings, or just the default local system settings? if (usersettings) { // We want the user settings, so load them! if (hkLocalUser != NULL) { vnclog.Print(LL_INTINFO, VNCLOG("loading \"%s\" local settings\n"), username); LoadUserPrefs(hkLocalUser); m_allowshutdown = LoadInt(hkLocalUser, "AllowShutdown", m_allowshutdown); m_allowproperties = LoadInt(hkLocalUser, "AllowProperties", m_allowproperties); m_alloweditclients = LoadInt(hkLocalUser, "AllowEditClients", m_alloweditclients); } // Now override the system settings with the user's settings // If the username is SYSTEM then don't try to load them, because there aren't any... if (m_allowproperties && (strcmp(username, "SYSTEM") != 0)) { HKEY hkGlobalUser; if (RegCreateKeyEx(HKEY_CURRENT_USER, WINVNC_REGISTRY_KEY, 0, REG_NONE, REG_OPTION_NON_VOLATILE, KEY_READ, NULL, &hkGlobalUser, &dw) == ERROR_SUCCESS) { vnclog.Print(LL_INTINFO, VNCLOG("loading \"%s\" global settings\n"), username); LoadUserPrefs(hkGlobalUser); RegCloseKey(hkGlobalUser); // Close the user registry hive so it can unload if required RegCloseKey(HKEY_CURRENT_USER); } } } else { vnclog.Print(LL_INTINFO, VNCLOG("bypassing user-specific settings (both local and global)\n")); } if (hkLocalUser != NULL) RegCloseKey(hkLocalUser); if (hkDefault != NULL) RegCloseKey(hkDefault); RegCloseKey(hkLocal); // Make the loaded settings active.. ApplyUserPrefs(); // Note whether we loaded the user settings or just the default system settings m_usersettings = usersettings; }
void vncPropertiesPoll::Load(BOOL usersettings) { // if (m_dlgvisible) { // vnclog.Print(LL_INTWARN, VNCLOG("service helper invoked while Properties panel displayed\n")); // return; // } ResetRegistry(); char username[UNLEN+1]; HKEY hkLocal, hkLocalUser, hkDefault; DWORD dw; // NEW (R3) PREFERENCES ALGORITHM // 1. Look in HKEY_LOCAL_MACHINE/Software/ORL/WinVNC3/%username% // for sysadmin-defined, user-specific settings. // 2. If not found, fall back to %username%=Default // 3. If AllowOverrides is set then load settings from // HKEY_CURRENT_USER/Software/ORL/WinVNC3 // GET THE CORRECT KEY TO READ FROM // Get the user name / service name if (!vncService::CurrentUser((char *)&username, sizeof(username))) return; // If there is no user logged on them default to SYSTEM if (strcmp(username, "") == 0) strcpy((char *)&username, "SYSTEM"); // Try to get the machine registry key for WinVNC if (RegCreateKeyEx(HKEY_LOCAL_MACHINE, WINVNC_REGISTRY_KEY, 0, REG_NONE, REG_OPTION_NON_VOLATILE, KEY_READ, NULL, &hkLocal, &dw) != ERROR_SUCCESS) { hkLocalUser=NULL; hkDefault=NULL; goto LABELUSERSETTINGS; } // Now try to get the per-user local key if (RegOpenKeyEx(hkLocal, username, 0, KEY_READ, &hkLocalUser) != ERROR_SUCCESS) hkLocalUser = NULL; // Get the default key if (RegCreateKeyEx(hkLocal, "Default", 0, REG_NONE, REG_OPTION_NON_VOLATILE, KEY_READ, NULL, &hkDefault, &dw) != ERROR_SUCCESS) hkDefault = NULL; LABELUSERSETTINGS: // LOAD THE USER PREFERENCES // Set the default user prefs vnclog.Print(LL_INTINFO, VNCLOG("clearing user settings\n")); m_pref_TurboMode = TRUE;//((vncService::VersionMajor() >= 6) ? TRUE : FALSE); m_pref_PollUnderCursor=FALSE; m_pref_PollForeground= FALSE; m_pref_PollFullScreen= TRUE;//((vncService::VersionMajor() >= 6) ? TRUE : FALSE); m_pref_PollConsoleOnly=FALSE; m_pref_PollOnEventOnly=FALSE; m_pref_MaxCpu=40; m_pref_Driver=CheckVideoDriver(0); m_pref_Hook=TRUE; m_pref_Virtual=FALSE; // [v1.0.2-jp2 fix] m_pref_SingleWindow = 0; *m_pref_szSingleWindowName = '\0'; // Load the local prefs for this user if (hkDefault != NULL) { vnclog.Print(LL_INTINFO, VNCLOG("loading DEFAULT local settings\n")); LoadUserPrefsPoll(hkDefault); } if (m_usersettings) { // We want the user settings, so load them! if (hkLocalUser != NULL) { vnclog.Print(LL_INTINFO, VNCLOG("loading \"%s\" local settings\n"), username); LoadUserPrefsPoll(hkLocalUser); } // Now override the system settings with the user's settings // If the username is SYSTEM then don't try to load them, because there aren't any... if ((strcmp(username, "SYSTEM") != 0)) { HKEY hkGlobalUser; if (RegCreateKeyEx(HKEY_CURRENT_USER, WINVNC_REGISTRY_KEY, 0, REG_NONE, REG_OPTION_NON_VOLATILE, KEY_READ, NULL, &hkGlobalUser, &dw) == ERROR_SUCCESS) { vnclog.Print(LL_INTINFO, VNCLOG("loading \"%s\" global settings\n"), username); LoadUserPrefsPoll(hkGlobalUser); RegCloseKey(hkGlobalUser); // Close the user registry hive so it can unload if required RegCloseKey(HKEY_CURRENT_USER); } } } if (hkLocalUser != NULL) RegCloseKey(hkLocalUser); if (hkDefault != NULL) RegCloseKey(hkDefault); if (hkLocal != NULL) RegCloseKey(hkLocal); // Make the loaded settings active.. ApplyUserPrefs(); // Note whether we loaded the user settings or just the default system settings m_usersettings = usersettings; }