VirtualBox

Ignore:
Timestamp:
Feb 16, 2012 5:06:35 PM (13 years ago)
Author:
vboxsync
Message:

VBoxService/users-win: Added session change detection, more fun with logged-in user detection.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/VBoxService/VBoxServiceVMInfo.cpp

    r39129 r40158  
    8383
    8484
    85 #ifdef RT_OS_WINDOWS
    86 static BOOL WINAPI VBoxServiceVMInfoConsoleControlHandler(DWORD dwCtrlType)
    87 {
    88     int rc = VINF_SUCCESS;
    89     bool fEventHandled = FALSE;
    90     switch (dwCtrlType)
    91     {
    92         case CTRL_LOGOFF_EVENT:
    93             VBoxServiceVerbose(2, "VMInfo: Received logged-off event\n");
    94             /* Trigger a re-enumeration of all logged-in users by unblocking
    95              * the multi event semaphore of the VMInfo thread. */
    96             if (g_hVMInfoEvent)
    97                 rc = RTSemEventMultiSignal(g_hVMInfoEvent);
    98             fEventHandled = TRUE;
    99             break;
    100         default:
    101             break;
    102         /** @todo Add other events here. */
    103     }
    104 
    105     if (RT_FAILURE(rc))
    106         VBoxServiceError("VMInfo: Event %ld handled with error rc=%Rrc\n",
    107                          dwCtrlType, rc);
    108     return fEventHandled;
     85
     86/**
     87 * Signals the event so that a re-enumeration of VM-specific
     88 * information (like logged in users) can happen.
     89 *
     90 * @return  IPRT status code.
     91 */
     92int VBoxServiceVMInfoSignal(void)
     93{
     94    /* Trigger a re-enumeration of all logged-in users by unblocking
     95     * the multi event semaphore of the VMInfo thread. */
     96    if (g_hVMInfoEvent)
     97        return RTSemEventMultiSignal(g_hVMInfoEvent);
     98
     99    return VINF_SUCCESS;
    109100}
    110 #endif /* RT_OS_WINDOWS */
    111101
    112102
     
    182172        VBoxServicePropCacheUpdateEntry(&g_VMInfoPropCache, "/VirtualBox/GuestInfo/Net/Count",
    183173                                        VBOXSERVICEPROPCACHEFLAG_TEMPORARY | VBOXSERVICEPROPCACHEFLAG_ALWAYS_UPDATE, NULL /* Delete on exit */);
    184 
    185 #ifdef RT_OS_WINDOWS
    186 # ifndef RT_OS_NT4
    187     /* Install console control handler. */
    188     if (!SetConsoleCtrlHandler((PHANDLER_ROUTINE)VBoxServiceVMInfoConsoleControlHandler, TRUE /* Add handler */))
    189     {
    190         VBoxServiceError("VMInfo: Unable to add console control handler, error=%ld\n", GetLastError());
    191         /* Just skip this error, not critical. */
    192     }
    193 # endif /* !RT_OS_NT4 */
    194 #endif /* RT_OS_WINDOWS */
    195174    }
    196175    return rc;
     
    301280           && RT_SUCCESS(rc))
    302281    {
    303         VBoxServiceVerbose(4, "VMInfo/Users: Found logged in user \"%s\"\n",
     282        VBoxServiceVerbose(4, "Found logged in user \"%s\"\n",
    304283                           ut_user->ut_user);
    305284        if (cUsersInList > cListSize)
     
    369348            static int s_iVMInfoBitchedOOM = 0;
    370349            if (s_iVMInfoBitchedOOM++ < 3)
    371                 VBoxServiceVerbose(0, "VMInfo/Users: Warning: Not enough memory available to enumerate users! Keeping old value (%u)\n",
     350                VBoxServiceVerbose(0, "Warning: Not enough memory available to enumerate users! Keeping old value (%u)\n",
    372351                                   g_cVMInfoLoggedInUsers);
    373352            cUsersInList = g_cVMInfoLoggedInUsers;
     
    377356    }
    378357
    379     VBoxServiceVerbose(4, "VMInfo/Users: cUsersInList: %u, pszUserList: %s, rc=%Rrc\n",
     358    VBoxServiceVerbose(4, "cUsersInList: %u, pszUserList: %s, rc=%Rrc\n",
    380359                       cUsersInList, pszUserList ? pszUserList : "<NULL>", rc);
    381360
     
    878857static DECLCALLBACK(void) VBoxServiceVMInfoTerm(void)
    879858{
    880     int rc;
    881 
    882 #ifdef RT_OS_WINDOWS
    883 # ifndef RT_OS_NT4
    884     /* Uninstall console control handler. */
    885     if (!SetConsoleCtrlHandler((PHANDLER_ROUTINE)NULL, FALSE /* Remove handler */))
    886     {
    887         VBoxServiceError("VMInfo: Unable to remove console control handler, error=%ld\n", GetLastError());
    888         /* Just skip this error, not critical. */
    889     }
    890 # endif /* !RT_OS_NT4 */
    891 #endif
    892 
    893859    if (g_hVMInfoEvent != NIL_RTSEMEVENTMULTI)
    894860    {
     
    906872        /* Delete the "../Net" branch. */
    907873        const char *apszPat[1] = { "/VirtualBox/GuestInfo/Net/*" };
    908         rc = VbglR3GuestPropDelSet(g_uVMInfoGuestPropSvcClientID, &apszPat[0], RT_ELEMENTS(apszPat));
     874        int rc = VbglR3GuestPropDelSet(g_uVMInfoGuestPropSvcClientID, &apszPat[0], RT_ELEMENTS(apszPat));
    909875
    910876        /* Destroy property cache. */
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette