VirtualBox

Changeset 65543 in vbox


Ignore:
Timestamp:
Jan 31, 2017 2:55:32 PM (8 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
113189
Message:

Main/svcmain: coding style

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-server/win/svcmain.cpp

    r65525 r65543  
    2323
    2424#include "VBox/com/defs.h"
    25 
    2625#include "VBox/com/com.h"
    27 
    2826#include "VBox/com/VirtualBox.h"
    2927
     
    189187    switch (msg)
    190188    {
    191     case WM_QUERYENDSESSION:
    192     {
    193         if (g_pModule)
    194         {
    195             rc = !g_pModule->HasActiveConnection();
    196             if (!rc)
    197             {
    198                 /* place the VBoxSVC into system shutdown list */
    199                 ShutdownBlockReasonCreateAPI(hwnd, L"Has active connections.");
    200                 /* decrease a latency of MonitorShutdown loop */
    201                 ASMAtomicXchgU32(&dwTimeOut, 100);
    202                 Log(("VBoxSVCWinMain: WM_QUERYENDSESSION: VBoxSvc has active connections. bActivity = %d. Loc count = %d\n",
    203                     g_pModule->bActivity, g_pModule->GetLockCount()));
    204             }
    205         }
    206         else
    207         {
    208             Assert(g_pModule);
    209             Log(("VBoxSVCWinMain: WM_QUERYENDSESSION: Error: g_pModule is NULL"));
    210         }
    211      } break;
    212     case WM_ENDSESSION:
    213     {
    214         /* Restore timeout of Monitor Shutdown if user canceled system shutdown */
    215         if (wParam == FALSE)
    216         {
    217             ASMAtomicXchgU32(&dwTimeOut, dwNormalTimeout);
    218             Log(("VBoxSVCWinMain: user canceled system shutdown.\n"));
    219         }
    220     } break;
    221     case WM_DESTROY:
    222     {
    223         ShutdownBlockReasonDestroyAPI(hwnd);
    224         PostQuitMessage(0);
    225     } break;
    226 
    227     default:
    228     {
    229         rc = DefWindowProc(hwnd, msg, wParam, lParam);
    230     }
     189        case WM_QUERYENDSESSION:
     190        {
     191            if (g_pModule)
     192            {
     193                bool fActiveConnection = g_pModule->HasActiveConnection();
     194                if (fActiveConnection)
     195                {
     196                    /* place the VBoxSVC into system shutdown list */
     197                    ShutdownBlockReasonCreateAPI(hwnd, L"Has active connections.");
     198                    /* decrease a latency of MonitorShutdown loop */
     199                    ASMAtomicXchgU32(&dwTimeOut, 100);
     200                    Log(("VBoxSVCWinMain: WM_QUERYENDSESSION: VBoxSvc has active connections. bActivity = %d. Loc count = %d\n",
     201                         g_pModule->bActivity, g_pModule->GetLockCount()));
     202                }
     203                rc = !fActiveConnection;
     204            }
     205            else
     206                AssertMsgFailed(("VBoxSVCWinMain: WM_QUERYENDSESSION: Error: g_pModule is NULL"));
     207            break;
     208        }
     209        case WM_ENDSESSION:
     210        {
     211            /* Restore timeout of Monitor Shutdown if user canceled system shutdown */
     212            if (wParam == FALSE)
     213            {
     214                ASMAtomicXchgU32(&dwTimeOut, dwNormalTimeout);
     215                Log(("VBoxSVCWinMain: user canceled system shutdown.\n"));
     216            }
     217            break;
     218        }
     219        case WM_DESTROY:
     220        {
     221            ShutdownBlockReasonDestroyAPI(hwnd);
     222            PostQuitMessage(0);
     223            break;
     224        }
     225        default:
     226        {
     227            rc = DefWindowProc(hwnd, msg, wParam, lParam);
     228        }
    231229    }
    232230    return rc;
     
    253251    wc.lpszClassName = MAIN_WND_CLASS;
    254252
    255 
    256253    ATOM atomWindowClass = RegisterClass(&wc);
    257 
    258254    if (atomWindowClass == 0)
    259255    {
     
    265261        /* Create the window. */
    266262        g_hMainWindow = CreateWindowEx(WS_EX_TOOLWINDOW |  WS_EX_TOPMOST,
    267             MAIN_WND_CLASS, MAIN_WND_CLASS,
    268             WS_POPUPWINDOW,
    269             0, 0, 1, 1, NULL, NULL, g_hInstance, NULL);
    270 
     263                                       MAIN_WND_CLASS, MAIN_WND_CLASS,
     264                                       WS_POPUPWINDOW,
     265                                       0, 0, 1, 1, NULL, NULL, g_hInstance, NULL);
    271266        if (g_hMainWindow == NULL)
    272267        {
     
    277272        {
    278273            SetWindowPos(g_hMainWindow, HWND_TOPMOST, -200, -200, 0, 0,
    279                 SWP_NOACTIVATE | SWP_HIDEWINDOW | SWP_NOCOPYBITS | SWP_NOREDRAW | SWP_NOSIZE);
     274                         SWP_NOACTIVATE | SWP_HIDEWINDOW | SWP_NOCOPYBITS | SWP_NOREDRAW | SWP_NOSIZE);
    280275
    281276        }
     
    293288        DestroyWindow(g_hMainWindow);
    294289        g_hMainWindow = NULL;
    295 
    296290        if (g_hInstance != NULL)
    297291        {
     
    565559
    566560        if (RT_SUCCESS(CreateMainWindow()))
    567         {
    568561            Log(("SVCMain: Main window succesfully created\n"));
    569         }
    570562        else
    571         {
    572563            Log(("SVCMain: Failed to create main window\n"));
    573         }
    574564
    575565        MSG msg;
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