Changeset 47977 in vbox
- Timestamp:
- Aug 21, 2013 4:37:27 PM (11 years ago)
- Location:
- trunk/src/VBox/Additions
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxIPC.cpp
r47973 r47977 52 52 } VBOXIPCCONTEXT, *PVBOXIPCCONTEXT; 53 53 static VBOXIPCCONTEXT gCtx = {0}; 54 55 /** Function pointer for GetLastInputInfo(). */ 56 typedef BOOL (WINAPI *PFNGETLASTINPUTINFO)(PLASTINPUTINFO); 54 57 55 58 /** … … 69 72 /** The thread handle. */ 70 73 RTTHREAD hThread; 71 /** Pointer to GetLastInputInfo() function. */72 BOOL (WINAPI * pfnGetLastInputInfo)(PLASTINPUTINFO);73 74 74 75 } VBOXIPCSESSION, *PVBOXIPCSESSION; 76 77 /** Static pointer to GetLastInputInfo() function. */ 78 static PFNGETLASTINPUTINFO s_pfnGetLastInputInfo = NULL; 75 79 76 80 int vboxIPCSessionDestroyLocked(PVBOXIPCSESSION pSession); … … 118 122 bool fLastInputAvailable = false; 119 123 VBOXTRAYIPCRES_USERLASTINPUT ipcRes; 120 if ( pSession->pfnGetLastInputInfo)124 if (s_pfnGetLastInputInfo) 121 125 { 122 126 /* Note: This only works up to 49.7 days (= 2^32, 32-bit counter) … … 124 128 LASTINPUTINFO lastInput; 125 129 lastInput.cbSize = sizeof(LASTINPUTINFO); 126 BOOL fRc = pSession->pfnGetLastInputInfo(&lastInput);130 BOOL fRc = s_pfnGetLastInputInfo(&lastInput); 127 131 if (fRc) 128 132 { 129 VBOXTRAYIPCRES_USERLASTINPUT ipcRes;130 133 ipcRes.uLastInput = (GetTickCount() - lastInput.dwTime) / 1000; 131 134 fLastInputAvailable = true; … … 196 199 *ppInstance = &gCtx; 197 200 *pfStartThread = true; 201 202 /* GetLastInputInfo only is available starting at Windows 2000. */ 203 s_pfnGetLastInputInfo = (PFNGETLASTINPUTINFO) 204 RTLdrGetSystemSymbol("User32.dll", "GetLastInputInfo"); 198 205 199 206 LogRelFunc(("Local IPC server now running at \"%s\"\n", … … 438 445 rc = VERR_NO_MEMORY; 439 446 440 if (RT_SUCCESS(rc))441 {442 *(void **)&pSession->pfnGetLastInputInfo =443 RTLdrGetSystemSymbol("User32.dll", "GetLastInputInfo");444 /* GetLastInputInfo only is available starting at Windows 2000. */445 }446 447 447 int rc2 = RTCritSectLeave(&pCtx->CritSect); 448 448 AssertRC(rc2); … … 457 457 458 458 pSession->hThread = NIL_RTTHREAD; 459 pSession->pfnGetLastInputInfo = NULL;460 459 461 460 RTLOCALIPCSESSION hSession; -
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceVMInfo-win.cpp
r47973 r47977 814 814 AssertPtrReturn(pCache, VERR_INVALID_POINTER); 815 815 AssertPtrReturn(pszUser, VERR_INVALID_POINTER); 816 /* pszDomain is optional. */ 816 817 817 818 int rc = VINF_SUCCESS; … … 821 822 VBOXTRAY_IPC_PIPE_PREFIX, pszUser)) 822 823 { 824 bool fReportToHost = false; 825 VBoxGuestUserState userState = VBoxGuestUserState_Unknown; 826 823 827 RTLOCALIPCSESSION hSession; 824 828 rc = RTLocalIpcSessionConnect(&hSession, szPipeName, 0 /* Flags */); … … 839 843 && ipcRes.uLastInput != UINT32_MAX) 840 844 { 841 VBoxGuestUserStateuserState = (ipcRes.uLastInput * 1000) < g_uVMInfoUserIdleThresholdMS842 843 845 userState = (ipcRes.uLastInput * 1000) < g_uVMInfoUserIdleThresholdMS 846 ? VBoxGuestUserState_InUse 847 : VBoxGuestUserState_Idle; 844 848 845 849 rc = vboxServiceUserUpdateF(pCache, pszUser, pszDomain, "UsageState", … … 852 856 * new. 853 857 */ 854 if (rc == VINF_SUCCESS) 855 { 856 VBoxServiceVerbose(4, "User \"%s\" (domain \"%s\") is idle for %RU32s\n", 857 pszUser, pszDomain ? pszDomain : "<None>", ipcRes.uLastInput); 858 fReportToHost = rc == VINF_SUCCESS; 859 VBoxServiceVerbose(4, "User \"%s\" (domain \"%s\") is idle for %RU32, fReportToHost=%RTbool\n", 860 pszUser, pszDomain ? pszDomain : "<None>", ipcRes.uLastInput, fReportToHost); 858 861 859 862 #if 0 /* Do we want to write the idle time as well? */ … … 868 871 if (RT_SUCCESS(rc)) 869 872 #endif 870 rc = VbglR3GuestUserReportState(pszUser, pszDomain, userState,871 NULL /* No details */, 0);872 }873 873 } 874 874 #ifdef DEBUG 875 875 else if (ipcRes.uLastInput == UINT32_MAX) 876 VBoxServiceVerbose(4, "Last input for user \"%s\" is not available, skipping\n",876 VBoxServiceVerbose(4, "Last input for user \"%s\" is not supported, skipping\n", 877 877 pszUser, rc); 878 878 … … 889 889 { 890 890 case VERR_FILE_NOT_FOUND: 891 { 891 892 /* No VBoxTray (or too old version which does not support IPC) running 892 893 for the given user. Not much we can do then. */ 893 VBoxServiceVerbose(4, " User \"%s\" not logged in, no last input available\n",894 VBoxServiceVerbose(4, "VBoxTray for user \"%s\" not running (anymore), no last input available\n", 894 895 pszUser); 896 897 /* Overwrite rc from above. */ 898 rc = vboxServiceUserUpdateF(pCache, pszUser, pszDomain, 899 "UsageState", "Idle"); 900 901 fReportToHost = rc == VINF_SUCCESS; 902 if (fReportToHost) 903 userState = VBoxGuestUserState_Idle; 895 904 break; 905 } 896 906 897 907 default: 898 VBoxService Verbose(4,"Error querying last input for user \"%s\", rc=%Rrc\n",899 908 VBoxServiceError("Error querying last input for user \"%s\", rc=%Rrc\n", 909 pszUser, rc); 900 910 break; 901 911 } 902 903 rc = VINF_SUCCESS; 912 } 913 914 if (fReportToHost) 915 { 916 Assert(userState != VBoxGuestUserState_Unknown); 917 int rc2 = VbglR3GuestUserReportState(pszUser, pszDomain, userState, 918 NULL /* No details */, 0); 919 if (RT_FAILURE(rc2)) 920 VBoxServiceError("Error reporting usage state %ld for user \"%s\" to host, rc=%Rrc\n", 921 userState, pszUser, rc2); 922 923 if (RT_SUCCESS(rc)) 924 rc = rc2; 904 925 } 905 926 }
Note:
See TracChangeset
for help on using the changeset viewer.