Changeset 40415 in vbox for trunk/src/VBox/Additions/common
- Timestamp:
- Mar 9, 2012 3:44:31 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibAutoLogon.cpp
r40414 r40415 1 /* $Id */1 /* $Id$ */ 2 2 /** @file 3 3 * VBoxGuestR3LibAutoLogon - Ring-3 utility functions for auto-logon modules 4 * (VBoxGINA / VBoxCredProv / pam_vbox).4 * (VBoxGINA / VBoxCredProv / pam_vbox). 5 5 */ 6 6 … … 30 30 * Header Files * 31 31 *******************************************************************************/ 32 #include <iprt/asm.h> 33 #include <iprt/mem.h> 34 #include <iprt/rand.h> 35 #include <iprt/string.h> 36 #include <VBox/log.h> 32 #ifdef RT_OS_WINDOWS 33 # include <Windows.h> 34 #endif 37 35 38 36 #include "VBGLR3Internal.h" … … 68 66 if (RT_SUCCESS(rc)) 69 67 { 70 /** @todo Move VBoxGuestStatusCurrent -> const char* to an own function. */ 71 char szStatus[RTPATH_MAX]; 72 size_t cbRet = 0; 68 const char *pszStatus; 73 69 switch (enmStatus) 74 70 { 75 case VBoxGuestFacilityStatus_Inactive: 76 cbRet = RTStrPrintf(szStatus, sizeof(szStatus), "Inactive"); 77 break; 78 case VBoxGuestFacilityStatus_Paused: 79 cbRet = RTStrPrintf(szStatus, sizeof(szStatus), "Disabled"); 80 break; 81 case VBoxGuestFacilityStatus_PreInit: 82 cbRet = RTStrPrintf(szStatus, sizeof(szStatus), "PreInit"); 83 break; 84 case VBoxGuestFacilityStatus_Init: 85 cbRet = RTStrPrintf(szStatus, sizeof(szStatus), "Init"); 86 break; 87 case VBoxGuestFacilityStatus_Active: 88 cbRet = RTStrPrintf(szStatus, sizeof(szStatus), "Active"); 89 break; 90 case VBoxGuestFacilityStatus_Terminating: 91 cbRet = RTStrPrintf(szStatus, sizeof(szStatus), "Terminating"); 92 break; 93 case VBoxGuestFacilityStatus_Terminated: 94 cbRet = RTStrPrintf(szStatus, sizeof(szStatus), "Terminated"); 95 break; 96 case VBoxGuestFacilityStatus_Failed: 97 cbRet = RTStrPrintf(szStatus, sizeof(szStatus), "Failed"); 98 break; 99 default: 100 /* cbRet will be 0. */ 101 break; 71 case VBoxGuestFacilityStatus_Inactive: pszStatus = "Inactive"; break; 72 case VBoxGuestFacilityStatus_Paused: pszStatus = "Disabled"; break; 73 case VBoxGuestFacilityStatus_PreInit: pszStatus = "PreInit"; break; 74 case VBoxGuestFacilityStatus_Init: pszStatus = "Init"; break; 75 case VBoxGuestFacilityStatus_Active: pszStatus = "Active"; break; 76 case VBoxGuestFacilityStatus_Terminating: pszStatus = "Terminating"; break; 77 case VBoxGuestFacilityStatus_Terminated: pszStatus = "Terminated"; break; 78 case VBoxGuestFacilityStatus_Failed: pszStatus = "Failed"; break; 79 default: pszStatus = NULL; 102 80 } 103 104 if (cbRet) 81 if (pszStatus) 105 82 { 106 const char szPath[] = "/VirtualBox/GuestInfo/OS/AutoLogonStatus";107 108 83 /* 109 * Because a value can be temporary we have to make sure it also 110 * gets deleted when the property cache did not have the chance to 111 * gracefully clean it up (due to a hard VM reset etc), so set this 112 * guest property using the TRANSRESET flag.. 84 * Use TRANSRESET when possible, fall back to TRANSIENT 85 * (generally sufficient unless the guest misbehaves). 113 86 */ 114 rc = VbglR3GuestPropWrite(u32ClientId, szPath, szStatus, "TRANSRESET"); 87 static const char s_szPath[] = "/VirtualBox/GuestInfo/OS/AutoLogonStatus"; 88 rc = VbglR3GuestPropWrite(u32ClientId, s_szPath, pszStatus, "TRANSRESET"); 115 89 if (rc == VERR_PARSE_ERROR) 116 { 117 /* Host does not support the "TRANSRESET" flag, so only 118 * use the "TRANSIENT" flag -- better than nothing :-). */ 119 rc = VbglR3GuestPropWrite(u32ClientId, szPath, szStatus, "TRANSIENT"); 120 } 90 rc = VbglR3GuestPropWrite(u32ClientId, s_szPath, pszStatus, "TRANSIENT"); 121 91 } 122 92 else … … 141 111 { 142 112 #ifdef RT_OS_WINDOWS 143 return (0 != GetSystemMetrics(SM_REMOTESESSION))? true : false;113 return GetSystemMetrics(SM_REMOTESESSION) != 0 ? true : false; 144 114 #else 145 115 return false; /* Not implemented. */ … … 147 117 } 148 118 149
Note:
See TracChangeset
for help on using the changeset viewer.