Changeset 47232 in vbox for trunk/src/VBox/Additions/common/VBoxService
- Timestamp:
- Jul 18, 2013 12:00:49 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceVMInfo-win.cpp
r46593 r47232 31 31 #include <iprt/assert.h> 32 32 #include <iprt/ldr.h> 33 #include <iprt/localipc.h> 33 34 #include <iprt/mem.h> 34 35 #include <iprt/thread.h> … … 40 41 #include "VBoxServiceInternal.h" 41 42 #include "VBoxServiceUtils.h" 43 #include "../../WINNT/VBoxTray/VBoxTrayMsg.h" /* For IPC. */ 42 44 43 45 static uint32_t s_uGuestPropClientID = 0; … … 90 92 int VBoxServiceVMInfoWinProcessesEnumerate(PVBOXSERVICEVMINFOPROC *ppProc, DWORD *pdwCount); 91 93 void VBoxServiceVMInfoWinProcessesFree(DWORD cProcs, PVBOXSERVICEVMINFOPROC paProcs); 94 int vboxServiceVMInfoWinWriteLastInput(char *pszUser); 92 95 93 96 typedef BOOL WINAPI FNQUERYFULLPROCESSIMAGENAME(HANDLE, DWORD, LPTSTR, PDWORD); … … 805 808 806 809 810 static int vboxServiceVMInfoWinWriteLastInput(char *pszUser) 811 { 812 AssertPtrReturn(pszUser, VERR_INVALID_POINTER); 813 814 int rc = VINF_SUCCESS; 815 816 char szPipeName[255]; 817 if (RTStrPrintf(szPipeName, sizeof(szPipeName), "%s%s", 818 VBOXTRAY_IPC_PIPE_PREFIX, pszUser)) 819 { 820 RTLOCALIPCSESSION hSession; 821 rc = RTLocalIpcSessionConnect(&hSession, szPipeName, 0 /* Flags */); 822 if (RT_SUCCESS(rc)) 823 { 824 VBOXTRAYIPCHEADER ipcHdr = { 0 /* Header version */, 825 VBOXTRAYIPCMSGTYPE_USERLASTINPUT, 0 /* No msg */ }; 826 827 rc = RTLocalIpcSessionWrite(hSession, &ipcHdr, sizeof(ipcHdr)); 828 829 VBOXTRAYIPCRES_USERLASTINPUT ipcRes; 830 if (RT_SUCCESS(rc)) 831 rc = RTLocalIpcSessionRead(hSession, &ipcRes, sizeof(ipcRes), 832 NULL /* Exact read */); 833 if (RT_SUCCESS(rc)) 834 { 835 if (ipcRes.uLastInputMs) 836 VBoxServiceVerbose(4, "User \"%s\" is idle for %RU32ms\n", 837 pszUser, ipcRes.uLastInputMs); 838 } 839 #ifdef DEBUG 840 VBoxServiceVerbose(4, "Querying last input for user \"%s\" ended with rc=%Rrc\n", 841 pszUser, rc); 842 #endif 843 int rc2 = RTLocalIpcSessionClose(hSession); 844 if (RT_SUCCESS(rc)) 845 rc = rc2; 846 } 847 else 848 { 849 switch (rc) 850 { 851 case VERR_FILE_NOT_FOUND: 852 /* No VBoxTray (or too old version which does not support IPC) running 853 for the given user. Not much we can do then. */ 854 VBoxServiceVerbose(4, "User \"%s\" not logged in, no last input available\n", 855 pszUser); 856 break; 857 858 default: 859 VBoxServiceVerbose(4, "Error querying last input for user \"%s\", rc=%Rrc\n", 860 pszUser, rc); 861 break; 862 } 863 864 rc = VINF_SUCCESS; 865 } 866 } 867 868 return rc; 869 } 870 871 807 872 /** 808 873 * Retrieves the currently logged in users and stores their names along with the … … 995 1060 *pcUsersInList += 1; 996 1061 997 char *psz Temp;998 int rc2 = RTUtf16ToUtf8(pUserInfo[i].wszUser, &psz Temp);1062 char *pszUser; 1063 int rc2 = RTUtf16ToUtf8(pUserInfo[i].wszUser, &pszUser); 999 1064 if (RT_SUCCESS(rc2)) 1000 1065 { 1001 rc = RTStrAAppend(ppszUserList, pszTemp); 1002 RTMemFree(pszTemp); 1066 rc = RTStrAAppend(ppszUserList, pszUser); 1067 if (RT_SUCCESS(rc)) 1068 rc = vboxServiceVMInfoWinWriteLastInput(pszUser); 1069 RTMemFree(pszUser); 1003 1070 } 1004 1071 else
Note:
See TracChangeset
for help on using the changeset viewer.