Changeset 106411 in vbox for trunk/src/VBox/Additions/WINNT/VBoxTray
- Timestamp:
- Oct 17, 2024 7:44:43 AM (4 months ago)
- Location:
- trunk/src/VBox/Additions/WINNT/VBoxTray
- Files:
-
- 1 added
- 21 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/VBoxTray/Makefile.kmk
r106061 r106411 49 49 VBoxTray_SOURCES = \ 50 50 VBoxTray.cpp \ 51 VBoxTrayLogging.cpp \ 51 52 VBoxCaps.cpp \ 52 53 VBoxConsole.cpp \ -
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxClipboard.cpp
r106061 r106411 34 34 35 35 #include "VBoxTray.h" 36 #include "VBoxTrayInternal.h" 36 37 #include "VBoxHelpers.h" 37 38 … … 62 63 { 63 64 /** Pointer to the VBoxClient service environment. */ 64 const VBOX SERVICEENV *pEnv;65 const VBOXTRAYSVCENV *pEnv; 65 66 /** Command context. */ 66 67 VBGLR3SHCLCMDCTX CmdCtx; … … 315 316 316 317 if (RT_FAILURE(rc)) 317 LogRel(("Shared Clipboard: Starting transfer failed, rc=%Rrc\n", rc));318 VBoxTrayError("Shared Clipboard: Starting transfer failed, rc=%Rrc\n", rc); 318 319 } 319 320 … … 326 327 LogFlowFunc(("rcCompletion=%Rrc\n", rcCompletion)); 327 328 328 LogRel2(("Shared Clipboard: Transfer %RU16 %s\n",329 ShClTransferGetID(pCbCtx->pTransfer), rcCompletion == VERR_CANCELLED ? "canceled" : "complete"));329 VBoxTrayVerbose(1, "Shared Clipboard: Transfer %RU16 %s\n", 330 ShClTransferGetID(pCbCtx->pTransfer), rcCompletion == VERR_CANCELLED ? "canceled" : "complete"); 330 331 331 332 SHCLTRANSFERSTATUS enmSts; … … 356 357 AssertPtr(pCtx); 357 358 358 LogRel(("Shared Clipboard: Transfer %RU16 failed with %Rrc\n", ShClTransferGetID(pCbCtx->pTransfer), rcError));359 VBoxTrayError("Shared Clipboard: Transfer %RU16 failed with %Rrc\n", ShClTransferGetID(pCbCtx->pTransfer), rcError); 359 360 360 361 if (g_cVerbosity) /* Only show this in verbose mode. */ … … 368 369 "Transfer %RU16 failed with %Rrc", ShClTransferGetID(pCbCtx->pTransfer), rcError); 369 370 370 hlpShowBalloonTip(g_hInstance, g_hwndToolWindow, ID_TRAYICON,371 szMsg, szTitle,372 5000 /* Time to display in msec */, NIIF_INFO);371 VBoxTrayHlpShowBalloonTipEx(g_hInstance, g_hwndToolWindow, ID_TRAYICON, 372 szMsg, szTitle, 373 5000 /* Time to display in msec */, NIIF_INFO); 373 374 } 374 375 … … 426 427 427 428 if (RT_FAILURE(rc)) 428 LogRel(("Shared Clipboard: WM_CLIPBOARDUPDATE failed with %Rrc\n", rc));429 VBoxTrayError("Shared Clipboard: WM_CLIPBOARDUPDATE failed with %Rrc\n", rc); 429 430 430 431 break; … … 495 496 496 497 LogFunc(("WM_RENDERFORMAT: uFmtWin=%u -> uFmtVBox=0x%x\n", uFmtWin, uFmtVBox)); 497 #ifdef LOG_ENABLED 498 498 499 char *pszFmts = ShClFormatsToStrA(uFmtVBox); 499 500 AssertPtrReturn(pszFmts, 0); 500 LogRel(("Shared Clipboard: Rendering Windows format %#x as VBox format '%s'\n", uFmtWin, pszFmts));501 VBoxTrayVerbose(1, "Shared Clipboard: Rendering Windows format %#x as VBox format '%s'\n", uFmtWin, pszFmts); 501 502 RTStrFree(pszFmts); 502 #endif 503 503 504 if (uFmtVBox == VBOX_SHCL_FMT_NONE) 504 505 { 505 LogRel(("Shared Clipboard: Unsupported format (%#x) requested\n", uFmtWin));506 VBoxTrayInfo("Shared Clipboard: Unsupported format (%#x) requested\n", uFmtWin); 506 507 ShClWinClear(); 507 508 } … … 523 524 cbData = (uint32_t)((cwcActual + 1 /* '\0' */) * sizeof(RTUTF16)); 524 525 else 525 LogRel(("Shared Clipboard: Invalid UTF16 string from host: cb=%RU32, cwcActual=%zu, rc=%Rrc\n",526 cbData, cwcActual, rc));526 VBoxTrayError("Shared Clipboard: Invalid UTF16 string from host: cb=%RU32, cwcActual=%zu, rc=%Rrc\n", 527 cbData, cwcActual, rc); 527 528 } 528 529 else if (uFmtVBox == VBOX_SHCL_FMT_HTML) … … 549 550 550 551 if (RT_FAILURE(rc)) 551 LogRel(("Shared Clipboard: Cannot convert HTML clipboard data into CF_HTML clipboard format, rc=%Rrc\n", rc));552 VBoxTrayError("Shared Clipboard: Cannot convert HTML clipboard data into CF_HTML clipboard format, rc=%Rrc\n", rc); 552 553 } 553 554 } … … 569 570 } 570 571 else 571 LogRel(("Shared Clipboard: Setting host data buffer to clipboard failed with %Rrc\n",572 RTErrConvertFromWin32(GetLastError())));572 VBoxTrayError("Shared Clipboard: Setting host data buffer to clipboard failed with %Rrc\n", 573 RTErrConvertFromWin32(GetLastError())); 573 574 } 574 575 else 575 LogRel(("Shared Clipboard: Failed to lock memory (%Rrc)\n", RTErrConvertFromWin32(GetLastError())));576 VBoxTrayError("Shared Clipboard: Failed to lock memory (%Rrc)\n", RTErrConvertFromWin32(GetLastError())); 576 577 GlobalFree(hMem); 577 578 } 578 579 else 579 LogRel(("Shared Clipboard: No memory for allocating host data buffer\n"));580 VBoxTrayError("Shared Clipboard: No memory for allocating host data buffer\n"); 580 581 } 581 582 } … … 605 606 const SHCLFORMATS fFormats = pEvent->u.fReportedFormats; 606 607 607 #ifdef LOG_ENABLED608 608 char *pszFmts = ShClFormatsToStrA(fFormats); 609 609 AssertPtrReturn(pszFmts, 0); 610 LogRel(("Shared Clipboard: Host reported formats '%s'\n", pszFmts));610 VBoxTrayVerbose(1, "Shared Clipboard: Host reported formats '%s'\n", pszFmts); 611 611 RTStrFree(pszFmts); 612 #endif 612 613 613 if (fFormats != VBOX_SHCL_FMT_NONE) /* Could arrive with some older GA versions. */ 614 614 { … … 647 647 648 648 LogFlowFunc(("SHCL_WIN_WM_READ_DATA: fFormat=%#x\n", fFormat)); 649 #ifdef LOG_ENABLED 649 650 650 char *pszFmts = ShClFormatsToStrA(fFormat); 651 651 AssertPtrReturn(pszFmts, 0); 652 LogRel(("Shared Clipboard: Sending data to host as '%s'\n", pszFmts));652 VBoxTrayVerbose(1, "Shared Clipboard: Sending data to host as '%s'\n", pszFmts); 653 653 RTStrFree(pszFmts); 654 #endif 654 655 655 int rc = ShClWinOpen(hwnd); 656 656 HANDLE hClip = NULL; … … 838 838 if (FAILED(hr)) 839 839 { 840 LogRel(("Shared Clipboard: Initializing OLE in window thread failed (%Rhrc) -- file transfers unavailable\n", hr));840 VBoxTrayError("Shared Clipboard: Initializing OLE in window thread failed (%Rhrc) -- file transfers unavailable\n", hr); 841 841 /* Not critical, the rest of the clipboard might work. */ 842 842 } 843 843 else 844 LogRel(("Shared Clipboard: Initialized OLE in window thread\n"));844 VBoxTrayInfo("Shared Clipboard: Initialized OLE in window thread\n"); 845 845 #endif /* VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS */ 846 846 … … 848 848 if (RT_FAILURE(rc)) 849 849 { 850 LogRel(("Shared Clipboard: Unable to create window, rc=%Rrc\n", rc));850 VBoxTrayError("Shared Clipboard: Unable to create window, rc=%Rrc\n", rc); 851 851 return rc; 852 852 } … … 857 857 bool fSignalled = RT_SUCCESS(rc2); 858 858 859 LogRel2(("Shared Clipboard: Window thread running\n"));859 VBoxTrayInfo("Shared Clipboard: Window thread running\n"); 860 860 861 861 if (RT_SUCCESS(rc)) … … 890 890 #endif 891 891 892 LogRel(("Shared Clipboard: Window thread ended\n"));892 VBoxTrayInfo("Shared Clipboard: Window thread ended\n"); 893 893 894 894 LogFlowFuncLeaveRC(rc); … … 905 905 } 906 906 907 DECLCALLBACK(int) vbtrShClInit(const PVBOXSERVICEENV pEnv, void **ppInstance) 907 /** 908 * @interface_method_impl{VBOXSERVICEDESC,pfnPreInit} 909 */ 910 static DECLCALLBACK(int) vbtrShClPreInit(void) 911 { 912 return VINF_SUCCESS; 913 } 914 915 /** 916 * @interface_method_impl{VBOXSERVICEDESC,pfnOption} 917 */ 918 static DECLCALLBACK(int) vbtrShClOption(const char **ppszShort, int argc, char **argv, int *pi) 919 { 920 RT_NOREF(ppszShort, argc, argv, pi); 921 922 return -1; 923 } 924 925 /** 926 * @interface_method_impl{VBOXSERVICEDESC,pfnInit} 927 */ 928 DECLCALLBACK(int) vbtrShClInit(const PVBOXTRAYSVCENV pEnv, void **ppInstance) 908 929 { 909 930 LogFlowFuncEnter(); … … 921 942 { 922 943 /* Do not use clipboard for remote sessions. */ 923 LogRel(("Shared Clipboard: Clipboard has been disabled for a remote session\n"));944 VBoxTrayInfo("Shared Clipboard: Clipboard has been disabled for a remote session\n"); 924 945 return VERR_NOT_SUPPORTED; 925 946 } … … 966 987 967 988 if (RT_FAILURE(rc)) 968 LogRel(("Shared Clipboard: Unable to initialize, rc=%Rrc\n", rc));989 VBoxTrayError("Shared Clipboard: Unable to initialize, rc=%Rrc\n", rc); 969 990 970 991 LogFlowFuncLeaveRC(rc); … … 972 993 } 973 994 995 /** 996 * @interface_method_impl{VBOXSERVICEDESC,pfnWorker} 997 */ 974 998 DECLCALLBACK(int) vbtrShClWorker(void *pInstance, bool volatile *pfShutdown) 975 999 { … … 988 1012 const PSHCLWINCTX pWinCtx = &pCtx->Win; 989 1013 990 LogRel2(("Shared Clipboard: Worker loop running\n"));1014 VBoxTrayVerbose(1, "Shared Clipboard: Worker loop running\n"); 991 1015 992 1016 #ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS … … 994 1018 if (FAILED(hr)) 995 1019 { 996 LogRel(("Shared Clipboard: Initializing OLE in worker thread failed (%Rhrc) -- file transfers unavailable\n", hr));1020 VBoxTrayError("Shared Clipboard: Initializing OLE in worker thread failed (%Rhrc) -- file transfers unavailable\n", hr); 997 1021 /* Not critical, the rest of the clipboard might work. */ 998 1022 } 999 1023 else 1000 LogRel(("Shared Clipboard: Initialized OLE in worker thread\n"));1024 VBoxTrayInfo("Shared Clipboard: Initialized OLE in worker thread\n"); 1001 1025 1002 1026 /* … … 1093 1117 case VBGLR3CLIPBOARDEVENTTYPE_QUIT: 1094 1118 { 1095 LogRel2(("Shared Clipboard: Host requested termination\n"));1119 VBoxTrayVerbose(1, "Shared Clipboard: Host requested termination\n"); 1096 1120 ASMAtomicXchgBool(pfShutdown, true); 1097 1121 break; … … 1130 1154 } 1131 1155 1132 LogRel2(("Shared Clipboard: Worker loop ended\n"));1156 VBoxTrayVerbose(1, "Shared Clipboard: Worker loop ended\n"); 1133 1157 1134 1158 #ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS … … 1141 1165 } 1142 1166 1167 /** 1168 * @interface_method_impl{VBOXSERVICEDESC,pfnStop} 1169 */ 1143 1170 DECLCALLBACK(int) vbtrShClStop(void *pInstance) 1144 1171 { … … 1165 1192 } 1166 1193 1194 /** 1195 * @interface_method_impl{VBOXSERVICEDESC,pfnDestroy} 1196 */ 1167 1197 DECLCALLBACK(void) vbtrShClDestroy(void *pInstance) 1168 1198 { … … 1177 1207 LogFlowFunc(("pCtx=%p\n", pCtx)); 1178 1208 1179 LogRel2(("Shared Clipboard: Destroying ...\n"));1209 VBoxTrayVerbose(1, "Shared Clipboard: Destroying ...\n"); 1180 1210 1181 1211 const PSHCLWINCTX pWinCtx = &pCtx->Win; … … 1206 1236 RTReqQueueDestroy(pCtx->Win.hReqQ); 1207 1237 1208 LogRel2(("Shared Clipboard: Destroyed\n"));1238 VBoxTrayVerbose(1, "Shared Clipboard: Destroyed\n"); 1209 1239 1210 1240 return; … … 1214 1244 * The service description. 1215 1245 */ 1216 VBOX SERVICEDESC g_SvcDescClipboard =1246 VBOXTRAYSVCDESC g_SvcDescClipboard = 1217 1247 { 1218 1248 /* pszName. */ … … 1220 1250 /* pszDescription. */ 1221 1251 "Shared Clipboard", 1252 /* pszUsage. */ 1253 NULL, 1254 /* pszOptions. */ 1255 NULL, 1222 1256 /* methods */ 1257 vbtrShClPreInit, 1258 vbtrShClOption, 1223 1259 vbtrShClInit, 1224 1260 vbtrShClWorker, -
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxDesktopTracking.cpp
r106061 r106411 216 216 gVBoxDt.fIsInputDesktop = TRUE; 217 217 218 if (RT_FAILURE(rc)) 219 VBoxTrayError("Initializing desktop tracking failed with %Rrc\n", rc); 220 218 221 return rc; 219 222 } -
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxDisplay.cpp
r106061 r106411 51 51 typedef struct _VBOXDISPLAYCONTEXT 52 52 { 53 const VBOX SERVICEENV *pEnv;53 const VBOXTRAYSVCENV *pEnv; 54 54 BOOL fAnyX; 55 55 /** ChangeDisplaySettingsEx does not exist in NT. ResizeDisplayDevice uses the function. */ … … 83 83 84 84 85 static DECLCALLBACK(int) VBoxDisplayInit(const PVBOXSERVICEENV pEnv, void **ppInstance) 85 /** 86 * @interface_method_impl{VBOXSERVICEDESC,pfnPreInit} 87 */ 88 static DECLCALLBACK(int) vbtrDispPreInit(void) 89 { 90 return VINF_SUCCESS; 91 } 92 93 /** 94 * @interface_method_impl{VBOXSERVICEDESC,pfnOption} 95 */ 96 static DECLCALLBACK(int) vbtrDispOption(const char **ppszShort, int argc, char **argv, int *pi) 97 { 98 RT_NOREF(ppszShort, argc, argv, pi); 99 100 return -1; 101 } 102 103 /** 104 * @interface_method_impl{VBOXSERVICEDESC,pfnInit} 105 */ 106 static DECLCALLBACK(int) vbtrDisplayInit(const PVBOXTRAYSVCENV pEnv, void **ppInstance) 86 107 { 87 108 LogFlowFuncEnter(); … … 172 193 } 173 194 174 static DECLCALLBACK(void) VBoxDisplayDestroy(void *pInstance) 195 /** 196 * @interface_method_impl{VBOXSERVICEDESC,pfnDestroy} 197 */ 198 static DECLCALLBACK(void) vbtrDisplayDestroy(void *pInstance) 175 199 { 176 200 RT_NOREF(pInstance); … … 898 922 899 923 /** 900 * Thread function to wait for and process display change requests.924 * @interface_method_impl{VBOXSERVICEDESC,pfnWorker} 901 925 */ 902 static DECLCALLBACK(int) VBoxDisplayWorker(void *pvInstance, bool volatile *pfShutdown)926 static DECLCALLBACK(int) vbtrDisplayWorker(void *pvInstance, bool volatile *pfShutdown) 903 927 { 904 928 AssertPtr(pvInstance); … … 989 1013 * The service description. 990 1014 */ 991 VBOX SERVICEDESC g_SvcDescDisplay =1015 VBOXTRAYSVCDESC g_SvcDescDisplay = 992 1016 { 993 1017 /* pszName. */ … … 995 1019 /* pszDescription. */ 996 1020 "Display Notifications", 1021 /* pszUsage. */ 1022 NULL, 1023 /* pszOptions. */ 1024 NULL, 997 1025 /* methods */ 998 VBoxDisplayInit, 999 VBoxDisplayWorker, 1026 vbtrDispPreInit, 1027 vbtrDispOption, 1028 vbtrDisplayInit, 1029 vbtrDisplayWorker, 1000 1030 NULL /* pfnStop */, 1001 VBoxDisplayDestroy1031 vbtrDisplayDestroy 1002 1032 }; 1003 1033 -
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxDnD.cpp
r106061 r106411 35 35 #include <iprt/win/windows.h> 36 36 #include "VBoxTray.h" 37 #include "VBoxTrayInternal.h" 37 38 #include "VBoxHelpers.h" 38 39 #include "VBoxDnD.h" … … 130 131 * Initializes the proxy window with a given DnD context. 131 132 * 132 * @return IPRTstatus code.133 * @return VBox status code. 133 134 * @param a_pCtx Pointer to context to use. 134 135 */ … … 161 162 162 163 if (RT_FAILURE(rc)) 163 LogRel(("DnD: Failed to initialize proxy window, rc=%Rrc\n", rc));164 VBoxTrayError("DnD: Failed to initialize proxy window, rc=%Rrc\n", rc); 164 165 165 166 LogFlowThisFunc(("Returning rc=%Rrc\n", rc)); … … 203 204 * Thread for handling the window's message pump. 204 205 * 205 * @return IPRTstatus code.206 * @return VBox status code. 206 207 * @param hThread Handle to this thread. 207 208 * @param pvUser Pointer to VBoxDnDWnd instance which … … 312 313 else 313 314 { 314 LogRel(("DnD: Unable to initialize OLE, hr=%Rhrc\n", hr));315 VBoxTrayError("DnD: Unable to initialize OLE, hr=%Rhrc\n", hr); 315 316 rc = VERR_COM_UNEXPECTED; 316 317 } … … 415 416 if (RT_FAILURE(rc)) 416 417 { 417 LogRel(("DnD: Failed to create proxy window, rc=%Rrc\n", rc));418 VBoxTrayError("DnD: Failed to create proxy window, rc=%Rrc\n", rc); 418 419 return -1; 419 420 } … … 626 627 case VBGLR3DNDEVENTTYPE_QUIT: 627 628 { 628 LogRel(("DnD: Received quit message, shutting down ...\n"));629 VBoxTrayInfo("DnD: Received quit message, shutting down ...\n"); 629 630 PostQuitMessage(0); 630 631 } … … 652 653 default: 653 654 { 654 LogRel(("DnD: Received unsupported message '%RU32'\n", pVbglR3Event->enmType));655 VBoxTrayVerbose(1, "DnD: Received unsupported message '%RU32'\n", pVbglR3Event->enmType); 655 656 rc = VERR_NOT_SUPPORTED; 656 657 break; … … 662 663 { 663 664 /* Tell the user. */ 664 LogRel(("DnD: Processing message %RU32 failed with %Rrc\n", pVbglR3Event->enmType, rc));665 VBoxTrayError("DnD: Processing message %RU32 failed with %Rrc\n", pVbglR3Event->enmType, rc); 665 666 666 667 /* If anything went wrong, do a reset and start over. */ … … 691 692 * Registers this proxy window as a local drop target. 692 693 * 693 * @return IPRTstatus code.694 * @return VBox status code. 694 695 */ 695 696 int VBoxDnDWnd::RegisterAsDropTarget(void) … … 721 722 } 722 723 if (hrc != DRAGDROP_E_INVALIDHWND) /* Could be because the DnD host service is not available. */ 723 LogRel(("DnD: Creating drop target failed with hr=%Rhrc\n", hrc)); 724 VBoxTrayError("DnD: Creating drop target failed with hr=%Rhrc\n", hrc); 725 724 726 LogFlowFuncLeaveRC(VERR_NOT_SUPPORTED); 725 727 return VERR_NOT_SUPPORTED; /* Report back DnD as not being supported. */ … … 729 731 * Unregisters this proxy as a drop target. 730 732 * 731 * @return IPRTstatus code.733 * @return VBox status code. 732 734 */ 733 735 int VBoxDnDWnd::UnregisterAsDropTarget(void) … … 761 763 * Handles the creation of a proxy window. 762 764 * 763 * @return IPRTstatus code.765 * @return VBox status code. 764 766 */ 765 767 int VBoxDnDWnd::OnCreate(void) … … 769 771 if (RT_FAILURE(rc)) 770 772 { 771 LogRel(("DnD: Connection to host service failed, rc=%Rrc\n", rc));773 VBoxTrayError("DnD: Connection to host service failed, rc=%Rrc\n", rc); 772 774 return rc; 773 775 } … … 796 798 { 797 799 LogFlowThisFunc(("mMode=%ld, mState=%RU32\n", m_enmMode, m_enmState)); 798 LogRel(("DnD: Drag and drop operation aborted\n"));800 VBoxTrayInfo("DnD: Drag and drop operation aborted\n"); 799 801 800 802 int rc = RTCritSectEnter(&m_CritSect); … … 820 822 * the guest's screen to initiate a host -> guest DnD operation. 821 823 * 822 * @return IPRTstatus code.824 * @return VBox status code. 823 825 * @param a_lstFormats Supported formats offered by the host. 824 826 * @param a_fDndLstActionsAllowed Supported actions offered by the host. … … 859 861 AssertReturnStmt(paFormatEtc, RTMemTmpFree(paFormatEtc), VERR_NO_TMP_MEMORY); 860 862 861 LogRel2(("DnD: Reported formats:\n"));863 VBoxTrayVerbose(1, "DnD: Reported formats:\n"); 862 864 for (size_t i = 0; i < a_lstFormats.size(); i++) 863 865 { … … 908 910 } 909 911 910 LogRel2(("DnD: \t%s: %RTbool\n", a_lstFormats.at(i).c_str(), fSupported));912 VBoxTrayVerbose(1, "DnD: \t%s: %RTbool\n", a_lstFormats.at(i).c_str(), fSupported); 911 913 } 912 914 … … 927 929 } 928 930 929 hlpShowBalloonTip(g_hInstance, g_hwndToolWindow, ID_TRAYICON,930 strMsg.c_str(), VBOX_DND_SHOWBALLOON_HEADER,931 15 * 1000 /* Time to display in msec */, NIIF_INFO);931 VBoxTrayHlpShowBalloonTipEx(g_hInstance, g_hwndToolWindow, ID_TRAYICON, 932 strMsg.c_str(), VBOX_DND_SHOWBALLOON_HEADER, 933 15 * 1000 /* Time to display in msec */, NIIF_INFO); 932 934 } 933 935 … … 938 940 if (cFormatsActive) 939 941 { 940 LogRel2(("DnD: %RU32 supported formats found:\n", cFormatsActive));942 VBoxTrayVerbose(1, "DnD: %RU32 supported formats found:\n", cFormatsActive); 941 943 for (size_t i = 0; i < cFormatsActive; i++) 942 LogRel2(("DnD: \t%s\n", this->m_lstFmtActive.at(i).c_str()));944 VBoxTrayVerbose(1, "DnD: \t%s\n", this->m_lstFmtActive.at(i).c_str()); 943 945 } 944 946 else 945 LogRel(("DnD: Warning: No supported drag and drop formats on the guest found!\n"));947 VBoxTrayInfo("DnD: Warning: No supported drag and drop formats on the guest found!\n"); 946 948 947 949 /* … … 961 963 } 962 964 963 LogRel2(("DnD: Supported drop actions: 0x%x\n", m_startupInfo.dwOKEffects));965 VBoxTrayVerbose(1, "DnD: Supported drop actions: 0x%x\n", m_startupInfo.dwOKEffects); 964 966 965 967 #ifdef RT_EXCEPTIONS_ENABLED … … 994 996 * the guest's screen. 995 997 * 996 * @return IPRTstatus code.998 * @return VBox status code. 997 999 * @param u32xPos Absolute X position (in pixels) of the host cursor 998 1000 * inside the guest. … … 1044 1046 * the guest's screen again. 1045 1047 * 1046 * @return IPRTstatus code.1048 * @return VBox status code. 1047 1049 */ 1048 1050 int VBoxDnDWnd::OnHgLeave(void) … … 1052 1054 1053 1055 if (g_cVerbosity) 1054 hlpShowBalloonTip(g_hInstance, g_hwndToolWindow, ID_TRAYICON,1055 "Leave: Host -> Guest", VBOX_DND_SHOWBALLOON_HEADER,1056 15 * 1000 /* Time to display in msec */, NIIF_INFO);1056 VBoxTrayHlpShowBalloonTipEx(g_hInstance, g_hwndToolWindow, ID_TRAYICON, 1057 "Leave: Host -> Guest", VBOX_DND_SHOWBALLOON_HEADER, 1058 15 * 1000 /* Time to display in msec */, NIIF_INFO); 1057 1059 1058 1060 int rc = Abort(); … … 1066 1068 * and therefore start a "drop" action in the guest. 1067 1069 * 1068 * @return IPRTstatus code.1070 * @return VBox status code. 1069 1071 */ 1070 1072 int VBoxDnDWnd::OnHgDrop(void) … … 1079 1081 { 1080 1082 if (g_cVerbosity) 1081 hlpShowBalloonTip(g_hInstance, g_hwndToolWindow, ID_TRAYICON,1082 "Drop: Host -> Guest", VBOX_DND_SHOWBALLOON_HEADER,1083 15 * 1000 /* Time to display in msec */, NIIF_INFO);1083 VBoxTrayHlpShowBalloonTipEx(g_hInstance, g_hwndToolWindow, ID_TRAYICON, 1084 "Drop: Host -> Guest", VBOX_DND_SHOWBALLOON_HEADER, 1085 15 * 1000 /* Time to display in msec */, NIIF_INFO); 1084 1086 1085 1087 if (m_lstFmtActive.size() >= 1) … … 1101 1103 if (RT_SUCCESS(rc)) 1102 1104 { 1103 LogRel(("DnD: Requesting data as '%s' ...\n", m_strFmtReq.c_str()));1105 VBoxTrayInfo("DnD: Requesting data as '%s' ...\n", m_strFmtReq.c_str()); 1104 1106 rc = VbglR3DnDHGSendReqData(&m_cmdCtx, m_strFmtReq.c_str()); 1105 1107 if (RT_FAILURE(rc)) … … 1109 1111 } 1110 1112 else /* Should never happen. */ 1111 LogRel(("DnD: Error: Host did not specify a data format for drop data\n"));1113 VBoxTrayError("DnD: Host did not specify a data format for drop data\n"); 1112 1114 } 1113 1115 … … 1120 1122 * to the guest after a "drop" event. 1121 1123 * 1122 * @return IPRTstatus code.1124 * @return VBox status code. 1123 1125 * @param pMeta Pointer to meta data received. 1124 1126 */ … … 1147 1149 case VBGLR3GUESTDNDMETADATATYPE_URI_LIST: 1148 1150 { 1149 LogRel2(("DnD: URI transfer root directory is '%s'\n", DnDTransferListGetRootPathAbs(&pMeta->u.URI.Transfer))); 1151 VBoxTrayVerbose(1, "DnD: URI transfer root directory is '%s'\n", 1152 DnDTransferListGetRootPathAbs(&pMeta->u.URI.Transfer)); 1150 1153 1151 1154 char *pszBuf; … … 1186 1189 * host -> guest operation. 1187 1190 * 1188 * @return IPRTstatus code.1191 * @return VBox status code. 1189 1192 */ 1190 1193 int VBoxDnDWnd::OnHgCancel(void) … … 1213 1216 * this class again. 1214 1217 * 1215 * @return IPRTstatus code.1218 * @return VBox status code. 1216 1219 */ 1217 1220 int VBoxDnDWnd::OnGhIsDnDPending(void) … … 1335 1338 case VERR_ACCESS_DENIED: 1336 1339 { 1337 rc = hlpShowBalloonTip(g_hInstance, g_hwndToolWindow, ID_TRAYICON,1338 szMsg, szTitle,1339 15 * 1000 /* Time to display in msec */, NIIF_INFO);1340 rc = VBoxTrayHlpShowBalloonTipEx(g_hInstance, g_hwndToolWindow, ID_TRAYICON, 1341 szMsg, szTitle, 1342 15 * 1000 /* Time to display in msec */, NIIF_INFO); 1340 1343 AssertRC(rc); 1341 1344 break; … … 1346 1349 } 1347 1350 1348 LogRel2(("DnD: Host refuses drag and drop operation from guest: %Rrc\n", rc2));1351 VBoxTrayVerbose(1, "DnD: Host refuses drag and drop operation from guest: %Rrc\n", rc2); 1349 1352 Reset(); 1350 1353 } … … 1363 1366 * to send data in a specific format the host requested. 1364 1367 * 1365 * @return IPRTstatus code.1368 * @return VBox status code. 1366 1369 * @param pszFormat Format the host requests the data in. 1367 1370 * @param cbFormat Size (in bytes) of format string. … … 1381 1384 strMsg += RTCStringFmt("Format: %s\n", strFormat.c_str()); 1382 1385 1383 hlpShowBalloonTip(g_hInstance, g_hwndToolWindow, ID_TRAYICON,1384 strMsg.c_str(), VBOX_DND_SHOWBALLOON_HEADER,1385 15 * 1000 /* Time to display in msec */, NIIF_INFO);1386 VBoxTrayHlpShowBalloonTipEx(g_hInstance, g_hwndToolWindow, ID_TRAYICON, 1387 strMsg.c_str(), VBOX_DND_SHOWBALLOON_HEADER, 1388 15 * 1000 /* Time to display in msec */, NIIF_INFO); 1386 1389 } 1387 1390 … … 1448 1451 * this class after processing. 1449 1452 * 1450 * @return IPRTstatus code.1453 * @return VBox status code. 1451 1454 * @param pEvent Event to inject. 1452 1455 */ … … 1464 1467 if (s_iBitchedAboutFailedDnDMessages++ < 32) 1465 1468 { 1466 LogRel(("DnD: Processing event %p failed with %ld (%Rrc), skipping\n",1467 pEvent, dwErr, RTErrConvertFromWin32(dwErr)));1469 VBoxTrayError("DnD: Processing event %p failed with %ld (%Rrc), skipping\n", 1470 pEvent, dwErr, RTErrConvertFromWin32(dwErr)); 1468 1471 } 1469 1472 … … 1483 1486 * and do a reconnect to the DnD HGCM service. 1484 1487 * 1485 * @returns IPRTstatus code.1488 * @returns VBox status code. 1486 1489 */ 1487 1490 int VBoxDnDWnd::checkForSessionChange(void) … … 1508 1511 * Hides the proxy window again. 1509 1512 * 1510 * @return IPRTstatus code.1513 * @return VBox status code. 1511 1514 */ 1512 1515 int VBoxDnDWnd::Hide(void) … … 1524 1527 * spawned across all active guest monitors. 1525 1528 * 1526 * @return IPRTstatus code.1529 * @return VBox status code. 1527 1530 */ 1528 1531 int VBoxDnDWnd::makeFullscreen(void) … … 1588 1591 { 1589 1592 DWORD dwErr = GetLastError(); 1590 LogRel(("DnD: Failed to set proxy window position, rc=%Rrc\n",1591 RTErrConvertFromWin32(dwErr)));1593 VBoxTrayError("DnD: Failed to set proxy window position, rc=%Rrc\n", 1594 RTErrConvertFromWin32(dwErr)); 1592 1595 } 1593 1596 } 1594 1597 else 1595 LogRel(("DnD: Failed to determine virtual screen size, rc=%Rrc\n", rc));1598 VBoxTrayError("DnD: Failed to determine virtual screen size, rc=%Rrc\n", rc); 1596 1599 1597 1600 LogFlowFuncLeaveRC(rc); … … 1602 1605 * Moves the guest mouse cursor to a specific position. 1603 1606 * 1604 * @return IPRTstatus code.1607 * @return VBox status code. 1605 1608 * @param x X position (in pixels) to move cursor to. 1606 1609 * @param y Y position (in pixels) to move cursor to. … … 1648 1651 * Releases a previously pressed left guest mouse button. 1649 1652 * 1650 * @return IPRTstatus code.1653 * @return VBox status code. 1651 1654 */ 1652 1655 int VBoxDnDWnd::mouseRelease(void) … … 1699 1702 * Sets the current operation mode of this proxy window. 1700 1703 * 1701 * @return IPRTstatus code.1704 * @return VBox status code. 1702 1705 * @param enmMode New mode to set. 1703 1706 */ … … 1751 1754 } 1752 1755 1753 /** 1754 * Initializes drag and drop. 1755 * 1756 * @return IPRT status code. 1757 * @param pEnv The DnD service's environment. 1758 * @param ppInstance The instance pointer which refer to this object. 1759 */ 1760 DECLCALLBACK(int) VBoxDnDInit(const PVBOXSERVICEENV pEnv, void **ppInstance) 1756 1757 /** 1758 * @interface_method_impl{VBOXSERVICEDESC,pfnPreInit} 1759 */ 1760 static DECLCALLBACK(int) vbtrDnDPreInit(void) 1761 { 1762 return VINF_SUCCESS; 1763 } 1764 1765 1766 /** 1767 * @interface_method_impl{VBOXSERVICEDESC,pfnOption} 1768 */ 1769 static DECLCALLBACK(int) vbtrDnDOption(const char **ppszShort, int argc, char **argv, int *pi) 1770 { 1771 RT_NOREF(ppszShort, argc, argv, pi); 1772 1773 return -1; 1774 } 1775 1776 /** 1777 * @interface_method_impl{VBOXSERVICEDESC,pfnInit} 1778 */ 1779 DECLCALLBACK(int) vbtrDnDInit(const PVBOXTRAYSVCENV pEnv, void **ppInstance) 1761 1780 { 1762 1781 AssertPtrReturn(pEnv, VERR_INVALID_POINTER); … … 1774 1793 { 1775 1794 /* Do not do drag and drop for remote sessions. */ 1776 LogRel(("DnD: Drag and drop has been disabled for a remote session\n"));1795 VBoxTrayInfo("DnD: Drag and drop has been disabled for a remote session\n"); 1777 1796 rc = VERR_NOT_SUPPORTED; 1778 1797 } … … 1791 1810 if (!fSupportedOS) 1792 1811 { 1793 LogRel(("DnD: Not supported Windows version, disabling drag and drop support\n"));1812 VBoxTrayInfo("DnD: Not supported Windows version, disabling drag and drop support\n"); 1794 1813 rc = VERR_NOT_SUPPORTED; 1795 1814 } … … 1842 1861 *ppInstance = pCtx; 1843 1862 1844 LogRel(("DnD: Drag and drop service successfully started\n"));1863 VBoxTrayInfo("DnD: Drag and drop service successfully started\n"); 1845 1864 } 1846 1865 else 1847 LogRel(("DnD: Initializing drag and drop service failed with rc=%Rrc\n", rc));1866 VBoxTrayError("DnD: Initializing drag and drop service failed with rc=%Rrc\n", rc); 1848 1867 1849 1868 LogFlowFuncLeaveRC(rc); … … 1851 1870 } 1852 1871 1853 DECLCALLBACK(int) VBoxDnDStop(void *pInstance) 1872 /** 1873 * @interface_method_impl{VBOXSERVICEDESC,pfnStop} 1874 */ 1875 DECLCALLBACK(int) vbtrDnDStop(void *pInstance) 1854 1876 { 1855 1877 AssertPtrReturn(pInstance, VERR_INVALID_POINTER); … … 1870 1892 } 1871 1893 1872 DECLCALLBACK(void) VBoxDnDDestroy(void *pInstance) 1894 /** 1895 * @interface_method_impl{VBOXSERVICEDESC,pfnInit} 1896 */ 1897 DECLCALLBACK(void) vbtrDnDDestroy(void *pInstance) 1873 1898 { 1874 1899 AssertPtrReturnVoid(pInstance); … … 1897 1922 } 1898 1923 1899 DECLCALLBACK(int) VBoxDnDWorker(void *pInstance, bool volatile *pfShutdown) 1924 /** 1925 * @interface_method_impl{VBOXSERVICEDESC,pfnWorker} 1926 */ 1927 DECLCALLBACK(int) vbtrDnDWorker(void *pInstance, bool volatile *pfShutdown) 1900 1928 { 1901 1929 AssertPtr(pInstance); … … 1918 1946 1919 1947 if (g_cVerbosity) 1920 hlpShowBalloonTip(g_hInstance, g_hwndToolWindow, ID_TRAYICON,1921 RTCStringFmt("Running (worker client ID %RU32)", pCtx->cmdCtx.uClientID).c_str(),1922 VBOX_DND_SHOWBALLOON_HEADER,1923 15 * 1000 /* Time to display in msec */, NIIF_INFO);1948 VBoxTrayHlpShowBalloonTipEx(g_hInstance, g_hwndToolWindow, ID_TRAYICON, 1949 RTCStringFmt("Running (worker client ID %RU32)", pCtx->cmdCtx.uClientID).c_str(), 1950 VBOX_DND_SHOWBALLOON_HEADER, 1951 15 * 1000 /* Time to display in msec */, NIIF_INFO); 1924 1952 1925 1953 /** @todo At the moment we only have one DnD proxy window. */ … … 1950 1978 cMsgSkippedInvalid = 0; /* Reset skipped messages count. */ 1951 1979 1952 LogRel2(("DnD: Received new event, type=%RU32, rc=%Rrc\n", pVbglR3Event->enmType, rc));1980 VBoxTrayVerbose(2, "DnD: Received new event, type=%RU32, rc=%Rrc\n", pVbglR3Event->enmType, rc); 1953 1981 1954 1982 /* pEvent now owns pVbglR3Event. */ … … 1963 1991 } 1964 1992 else 1965 LogRel(("DnD: Processing proxy window event %RU32 failed with %Rrc\n", pVbglR3Event->enmType, rc));1993 VBoxTrayInfo("DnD: Processing proxy window event %RU32 failed with %Rrc\n", pVbglR3Event->enmType, rc); 1966 1994 } 1967 1995 … … 1981 2009 if (cMsgSkippedInvalid++ > 32) 1982 2010 { 1983 LogRel(("DnD: Too many invalid/skipped messages from host, exiting ...\n"));2011 VBoxTrayInfo("DnD: Too many invalid/skipped messages from host, exiting ...\n"); 1984 2012 break; 1985 2013 } … … 2011 2039 VbglR3DnDDisconnect(&pCtx->cmdCtx); 2012 2040 2013 LogRel(("DnD: Ended\n"));2041 VBoxTrayInfo("DnD: Ended\n"); 2014 2042 2015 2043 LogFlowFuncLeaveRC(rc); … … 2020 2048 * The service description. 2021 2049 */ 2022 VBOX SERVICEDESC g_SvcDescDnD =2050 VBOXTRAYSVCDESC g_SvcDescDnD = 2023 2051 { 2024 2052 /* pszName. */ … … 2026 2054 /* pszDescription. */ 2027 2055 "Drag and Drop", 2056 /* pszUsage. */ 2057 NULL, 2058 /* pszOptions. */ 2059 NULL, 2028 2060 /* methods */ 2029 VBoxDnDInit, 2030 VBoxDnDWorker, 2031 VBoxDnDStop, 2032 VBoxDnDDestroy 2061 vbtrDnDPreInit, 2062 vbtrDnDOption, 2063 vbtrDnDInit, 2064 vbtrDnDWorker, 2065 vbtrDnDStop, 2066 vbtrDnDDestroy 2033 2067 }; 2034 2068 -
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxDnD.h
r106061 r106411 276 276 { 277 277 /** Pointer to the service environment. */ 278 const VBOX SERVICEENV *pEnv;278 const VBOXTRAYSVCENV *pEnv; 279 279 /** Started indicator. */ 280 280 bool fStarted; -
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxDnDDataObject.cpp
r106061 r106411 40 40 41 41 #include "VBoxTray.h" 42 #include "VBoxTrayInternal.h" 42 43 #include "VBoxHelpers.h" 43 44 #include "VBoxDnD.h" … … 129 130 if (m_enmStatus == Status_Dropping) 130 131 { 131 LogRel2(("DnD: Waiting for drop event ...\n"));132 VBoxTrayVerbose(2, "DnD: Waiting for drop event ...\n"); 132 133 int rc2 = RTSemEventWait(m_EvtDropped, RT_INDEFINITE_WAIT); 133 134 LogFlowFunc(("rc2=%Rrc, mStatus=%ld\n", rc2, m_enmStatus)); RT_NOREF(rc2); … … 136 137 if (m_enmStatus == Status_Dropped) 137 138 { 138 LogRel2(("DnD: Drop event received\n"));139 LogRel3(("DnD: cfFormat=%RI16, sFormat=%s, tyMed=%RU32, dwAspect=%RU32\n",140 pThisFormat->cfFormat, VBoxDnDDataObject::ClipboardFormatToString(pFormatEtc->cfFormat),141 pThisFormat->tymed, pThisFormat->dwAspect));142 LogRel3(("DnD: Got strFormat=%s, pvData=%p, cbData=%RU32\n",143 m_strFormat.c_str(), m_pvData, m_cbData));139 VBoxTrayVerbose(2, "DnD: Drop event received\n"); 140 VBoxTrayVerbose(3, "DnD: cfFormat=%RI16, sFormat=%s, tyMed=%RU32, dwAspect=%RU32\n", 141 pThisFormat->cfFormat, VBoxDnDDataObject::ClipboardFormatToString(pFormatEtc->cfFormat), 142 pThisFormat->tymed, pThisFormat->dwAspect); 143 VBoxTrayVerbose(3, "DnD: Got strFormat=%s, pvData=%p, cbData=%RU32\n", 144 m_strFormat.c_str(), m_pvData, m_cbData); 144 145 145 146 /* … … 160 161 && cFiles) 161 162 { 162 LogRel2(("DnD: Files (%zu)\n", cFiles));163 VBoxTrayVerbose(1, "DnD: Files (%zu)\n", cFiles); 163 164 for (size_t i = 0; i < cFiles; i++) 164 LogRel2(("\tDnD: File '%s'\n", papszFiles[i]));165 VBoxTrayVerbose(1, "\tDnD: File '%s'\n", papszFiles[i]); 165 166 166 167 #if 0 … … 636 637 && pFormatEtc->dwAspect == m_paFormatEtc[i].dwAspect) 637 638 { 638 LogRel3(("DnD: Format found: tyMed=%RI32, cfFormat=%RI16, sFormats=%s, dwAspect=%RI32, ulIndex=%RU32\n",639 pFormatEtc->tymed, pFormatEtc->cfFormat, VBoxDnDDataObject::ClipboardFormatToString(m_paFormatEtc[i].cfFormat),640 pFormatEtc->dwAspect, i));639 VBoxTrayVerbose(3, "DnD: Format found: tyMed=%RI32, cfFormat=%RI16, sFormats=%s, dwAspect=%RI32, ulIndex=%RU32\n", 640 pFormatEtc->tymed, pFormatEtc->cfFormat, VBoxDnDDataObject::ClipboardFormatToString(m_paFormatEtc[i].cfFormat), 641 pFormatEtc->dwAspect, i); 641 642 if (puIndex) 642 643 *puIndex = i; … … 645 646 } 646 647 647 LogRel3(("DnD: Format NOT found: tyMed=%RI32, cfFormat=%RI16, sFormats=%s, dwAspect=%RI32\n",648 pFormatEtc->tymed, pFormatEtc->cfFormat, VBoxDnDDataObject::ClipboardFormatToString(pFormatEtc->cfFormat),649 pFormatEtc->dwAspect));648 VBoxTrayVerbose(3, "DnD: Format NOT found: tyMed=%RI32, cfFormat=%RI16, sFormats=%s, dwAspect=%RI32\n", 649 pFormatEtc->tymed, pFormatEtc->cfFormat, VBoxDnDDataObject::ClipboardFormatToString(pFormatEtc->cfFormat), 650 pFormatEtc->dwAspect); 650 651 651 652 return false; … … 728 729 729 730 /* Signal in any case. */ 730 LogRel2(("DnD: Signalling drop event\n"));731 VBoxTrayVerbose(2, "DnD: Signalling drop event\n"); 731 732 732 733 int rc2 = RTSemEventSignal(m_EvtDropped); -
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxDnDDropTarget.cpp
r106061 r106411 34 34 35 35 #include "VBoxTray.h" 36 #include "VBoxTrayInternal.h" 36 37 #include "VBoxHelpers.h" 37 38 #include "VBoxDnD.h" … … 120 121 if (SUCCEEDED(hr2)) 121 122 { 122 LogRel(("DnD: The following formats were offered to us:\n"));123 VBoxTrayVerbose(1, "DnD: The following formats were offered to us:\n"); 123 124 124 125 FORMATETC curFormatEtc; … … 129 130 hr2 = GetClipboardFormatNameW(curFormatEtc.cfFormat, wszCfName, 130 131 sizeof(wszCfName) / sizeof(WCHAR)); 131 LogRel(("\tcfFormat=%RI16 (%s), tyMed=%RI32, dwAspect=%RI32, strCustomName=%ls, hr=%Rhrc\n",132 curFormatEtc.cfFormat,133 VBoxDnDDataObject::ClipboardFormatToString(curFormatEtc.cfFormat),134 curFormatEtc.tymed,135 curFormatEtc.dwAspect,136 wszCfName, hr2));132 VBoxTrayVerbose(1, "\tcfFormat=%RI16 (%s), tyMed=%RI32, dwAspect=%RI32, strCustomName=%ls, hr=%Rhrc\n", 133 curFormatEtc.cfFormat, 134 VBoxDnDDataObject::ClipboardFormatToString(curFormatEtc.cfFormat), 135 curFormatEtc.tymed, 136 curFormatEtc.dwAspect, 137 wszCfName, hr2); 137 138 } 138 139 … … 228 229 case ERROR_INVALID_FUNCTION: 229 230 { 230 LogRel(("DnD: Drag and drop format is not supported by VBoxTray\n"));231 VBoxTrayError("DnD: Drag and drop format is not supported by VBoxTray\n"); 231 232 VBoxDnDDropTarget::DumpFormats(pDataObject); 232 233 break; … … 353 354 size_t cbSize = GlobalSize(pvData); 354 355 355 LogRel(("DnD: Got %zu bytes of %s\n", cbSize,356 357 ? "ANSI text" : "Unicode text"));356 VBoxTrayVerbose(2, "DnD: Got %zu bytes of %s\n", cbSize, 357 m_FormatEtc.cfFormat == CF_TEXT 358 ? "ANSI text" : "Unicode text"); 358 359 if (cbSize) 359 360 { … … 409 410 UINT cFiles = DragQueryFile(hDrop, UINT32_MAX /* iFile */, NULL /* lpszFile */, 0 /* cchFile */); 410 411 411 LogRel(("DnD: Got %RU16 file(s), fUnicode=%RTbool\n", cFiles, fUnicode));412 VBoxTrayVerbose(1, "DnD: Got %RU16 file(s), fUnicode=%RTbool\n", cFiles, fUnicode); 412 413 413 414 for (UINT i = 0; i < cFiles; i++) … … 466 467 LogFlowFunc(("\tFile: %s (cchFile=%RU16)\n", pszFileUtf8, cchFileUtf8)); 467 468 468 LogRel(("DnD: Adding guest file '%s'\n", pszFileUtf8));469 VBoxTrayVerbose(1, "DnD: Adding guest file '%s'\n", pszFileUtf8); 469 470 470 471 if (RT_SUCCESS(rc)) … … 486 487 487 488 if (RT_FAILURE(rc)) 488 LogRel(("DnD: Error handling file entry #%u, rc=%Rrc\n", i, rc));489 VBoxTrayError("DnD: Error handling file entry #%u, rc=%Rrc\n", i, rc); 489 490 490 491 RTStrFree(pszFileUtf8); -
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxHelpers.cpp
r106061 r106411 30 30 #include <iprt/string.h> 31 31 #include <iprt/alloca.h> 32 #include <iprt/stream.h> 32 33 #include <iprt/system.h> 33 34 #include <iprt/utf16.h> … … 35 36 #include <VBox/VBoxGuestLib.h> 36 37 38 #include "VBoxTray.h" 39 #include "VBoxTrayInternal.h" 37 40 #include "VBoxHelpers.h" 38 41 39 42 40 int hlpReportStatus(VBoxGuestFacilityStatus statusCurrent) 41 { 43 44 static const char *vboxTrayGstFacilityStsToStr(VBoxGuestFacilityStatus faStatus, bool fShort) 45 { 46 switch (faStatus) 47 { 48 case VBoxGuestFacilityStatus_Inactive: 49 return fShort ? "inactive" : "not active"; 50 case VBoxGuestFacilityStatus_Paused: 51 return fShort ? "paused" : "paused"; 52 case VBoxGuestFacilityStatus_PreInit: 53 return fShort ? "preinit" : "pre-initializing"; 54 case VBoxGuestFacilityStatus_Init: 55 return fShort ? "init" : "initializing"; 56 case VBoxGuestFacilityStatus_Active: 57 return fShort ? "active" : "active/running"; 58 case VBoxGuestFacilityStatus_Terminating: 59 return fShort ? "terminating" : "terminating"; 60 case VBoxGuestFacilityStatus_Terminated: 61 return fShort ? "terminated" : "terminated"; 62 case VBoxGuestFacilityStatus_Failed: 63 return fShort ? "failed" : "failed"; 64 case VBoxGuestFacilityStatus_Unknown: 65 default: 66 break; 67 } 68 return "unknown"; 69 } 70 71 int VBoxTrayHlpReportStatus(VBoxGuestFacilityStatus statusCurrent) 72 { 73 if (g_cVerbosity) 74 VBoxTrayHlpShowBalloonTip(vboxTrayGstFacilityStsToStr(statusCurrent, false /* fShort */), 75 "Reporting status to host", RT_MS_5SEC); 76 42 77 int rc = VbglR3ReportAdditionsStatus(VBoxGuestFacilityType_VBoxTrayClient, 43 78 statusCurrent, 44 79 0 /* Flags */); 45 80 if (RT_FAILURE(rc)) 46 Log(("VBoxTray: Could not report VBoxTray status \"%ld\", rc=%Rrc\n", statusCurrent, rc)); 81 VBoxTrayError("Could not report VBoxTray status '%s' to host, rc=%Rrc\n", 82 vboxTrayGstFacilityStsToStr(statusCurrent, false /* fShort */), rc); 47 83 return rc; 48 84 } … … 279 315 } 280 316 281 int hlpShowBalloonTip(HINSTANCE hInst, HWND hWnd, UINT uID, 282 const char *pszMsg, const char *pszTitle, 283 UINT uTimeout, DWORD dwInfoFlags) 284 { 317 int VBoxTrayHlpShowBalloonTipEx(HINSTANCE hInst, HWND hWnd, UINT uID, 318 const char *pszMsg, const char *pszTitle, 319 UINT uTimeout, DWORD dwInfoFlags) 320 { 321 VBoxTrayVerbose(2, "Showing balloon tip \"%s\": %s\n", pszMsg, pszTitle); 322 285 323 NOTIFYICONDATA niData; 286 324 ZeroMemory(&niData, sizeof(NOTIFYICONDATA)); … … 299 337 niData.dwInfoFlags = dwInfoFlags; 300 338 301 /* Do we want to have */302 303 339 /* Is the current OS supported (at least WinXP) for displaying 304 340 * our own icon and do we actually *want* to display our own stuff? */ … … 336 372 if (!Shell_NotifyIcon(NIM_MODIFY, &niData)) 337 373 { 338 DWORD dwErr = GetLastError(); 339 return RTErrConvertFromWin32(dwErr); 340 } 374 VBoxTrayError("Could not show balloon tip (%#x)\n", GetLastError()); 375 return VERR_INVALID_HANDLE; 376 } 377 341 378 return VINF_SUCCESS; 379 } 380 381 int VBoxTrayHlpShowBalloonTip(const char *pszMsg, const char *pszTitle, 382 UINT uTimeout) 383 { 384 return VBoxTrayHlpShowBalloonTipEx(g_hInstance, g_hwndToolWindow, ID_TRAYICON, 385 pszMsg, pszTitle, uTimeout, NIIF_INFO); 342 386 } 343 387 … … 351 395 * @param ... Arguments for format string. 352 396 */ 353 void hlpShowMessageBox(const char *pszTitle, UINT uStyle, const char *pszFmt, ...)397 void VBoxTrayShowMsgBox(const char *pszTitle, UINT uStyle, const char *pszFmt, ...) 354 398 { 355 399 if (!uStyle) … … 363 407 if (rc >= 0) 364 408 { 365 PRTUTF16 pwszTitle; 366 rc = RTStrToUtf16(pszTitle, &pwszTitle); 367 if (RT_SUCCESS(rc)) 368 { 369 PRTUTF16 pwszMsg; 370 rc = RTStrToUtf16(pszMsg, &pwszMsg); 409 if (g_fHasConsole) 410 { 411 RTPrintf("%s", pszMsg); 412 } 413 else 414 { 415 PRTUTF16 pwszTitle; 416 rc = RTStrToUtf16(pszTitle, &pwszTitle); 371 417 if (RT_SUCCESS(rc)) 372 418 { 373 MessageBoxW(GetDesktopWindow(), pwszMsg, pwszTitle, uStyle); 374 RTUtf16Free(pwszMsg); 419 PRTUTF16 pwszMsg; 420 rc = RTStrToUtf16(pszMsg, &pwszMsg); 421 if (RT_SUCCESS(rc)) 422 { 423 MessageBoxW(GetDesktopWindow(), pwszMsg, pwszTitle, uStyle); 424 RTUtf16Free(pwszMsg); 425 } 426 else 427 MessageBoxA(GetDesktopWindow(), pszMsg, pszTitle, uStyle); 428 RTUtf16Free(pwszTitle); 375 429 } 376 else377 MessageBoxA(GetDesktopWindow(), pszMsg, pszTitle, uStyle);378 RTUtf16Free(pwszTitle);379 430 } 380 431 } … … 384 435 } 385 436 437 /** 438 * Logs a verbose message. 439 * 440 * @param pszFormat The message text. 441 * @param va Format arguments. 442 */ 443 static void vboxTrayLogV(const char *pszFormat, va_list va) 444 { 445 #ifdef DEBUG0 446 int rc = RTCritSectEnter(&g_csLog); 447 if (RT_SUCCESS(rc)) 448 { 449 #endif 450 char *psz = NULL; 451 RTStrAPrintfV(&psz, pszFormat, va); 452 453 AssertPtr(psz); 454 LogRel(("%s", psz)); 455 456 RTStrFree(psz); 457 #ifdef DEBUG0 458 RTCritSectLeave(&g_csLog); 459 } 460 #endif 461 } 462 463 /** 464 * Logs an information message. 465 * 466 * @param pszFormat The message text. 467 * @param ... Format arguments. 468 */ 469 void VBoxTrayInfo(const char *pszFormat, ...) 470 { 471 va_list va; 472 va_start(va, pszFormat); 473 vboxTrayLogV(pszFormat, va); 474 va_end(va); 475 } 476 477 /** 478 * Logs an error message. 479 * 480 * @returns RTEXITCODE_FAILURE. 481 * @param pszFormat The message text. 482 * @param ... Format arguments. 483 */ 484 RTEXITCODE VBoxTrayError(const char *pszFormat, ...) 485 { 486 va_list args; 487 va_start(args, pszFormat); 488 char *psz = NULL; 489 RTStrAPrintfV(&psz, pszFormat, args); 490 va_end(args); 491 492 AssertPtr(psz); 493 LogRel(("Error: %s", psz)); 494 495 RTStrFree(psz); 496 497 return RTEXITCODE_FAILURE; 498 } 499 500 /** 501 * Logs a verbose message based on the currently 502 * set global verbosity level. 503 * 504 * @param iLevel Minimum log level required to display this message. 505 * @param pszFormat The message text. 506 * @param ... Format arguments. 507 */ 508 void VBoxTrayVerbose(unsigned iLevel, const char *pszFormat, ...) 509 { 510 if (iLevel <= g_cVerbosity) 511 { 512 va_list va; 513 va_start(va, pszFormat); 514 vboxTrayLogV(pszFormat, va); 515 va_end(va); 516 } 517 } 518 519 /** 520 * Displays an error message. 521 * 522 * @returns RTEXITCODE_FAILURE. 523 * @param pszFormat The message text. 524 * @param ... Format arguments. 525 */ 526 RTEXITCODE VBoxTrayShowError(const char *pszFormat, ...) 527 { 528 va_list args; 529 va_start(args, pszFormat); 530 char *psz = NULL; 531 RTStrAPrintfV(&psz, pszFormat, args); 532 va_end(args); 533 534 AssertPtr(psz); 535 536 VBoxTrayError("%s", psz); 537 VBoxTrayShowMsgBox(VBOX_VBOXTRAY_TITLE " - Error", MB_OK | MB_ICONERROR, psz); 538 539 RTStrFree(psz); 540 541 return RTEXITCODE_FAILURE; 542 } 543 -
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxHelpers.h
r106061 r106411 32 32 #endif 33 33 34 extern int hlpReportStatus(VBoxGuestFacilityStatus statusCurrent);35 34 extern void hlpReloadCursor(void); 36 35 extern void hlpResizeRect(RECTL *paRects, unsigned nRects, unsigned uPrimary, unsigned uResized, int iNewWidth, int iNewHeight, int iNewPosX, int iNewPosY); 37 extern int hlpShowBalloonTip(HINSTANCE hInst, HWND hWnd, UINT uID, const char *pszMsg, const char *pszTitle, UINT uTimeout, DWORD dwInfoFlags); 38 extern void hlpShowMessageBox(const char *pszTitle, UINT uStyle, const char *pszFmt, ...); 36 37 extern int VBoxTrayHlpReportStatus(VBoxGuestFacilityStatus statusCurrent); 38 extern int VBoxTrayHlpShowBalloonTip(const char *pszMsg, const char *pszTitle, UINT uTimeout); 39 extern int VBoxTrayHlpShowBalloonTipEx(HINSTANCE hInst, HWND hWnd, UINT uID, const char *pszMsg, const char *pszTitle, UINT uTimeout, DWORD dwInfoFlags); 40 extern void VBoxTrayShowMsgBox(const char *pszTitle, UINT uStyle, const char *pszFmt, ...); 39 41 40 42 #endif /* !GA_INCLUDED_SRC_WINNT_VBoxTray_VBoxHelpers_h */ -
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxHostVersion.cpp
r106061 r106411 32 32 #include "VBoxHostVersion.h" 33 33 #include "VBoxTray.h" 34 #include "VBoxTrayInternal.h" 34 35 #include "VBoxHelpers.h" 35 36 36 37 37 … … 64 64 "install option from the Devices menu.", pszGuestVersion, pszHostVersion); 65 65 66 rc = hlpShowBalloonTip(g_hInstance, g_hwndToolWindow, ID_TRAYICON, 67 szMsg, szTitle, 68 5000 /* Time to display in msec */, NIIF_INFO); 69 if (RT_FAILURE(rc)) 70 LogFlowFunc(("Guest Additions update found; however: could not show version notifier balloon tooltip, rc=%Rrc\n", rc)); 66 rc = VBoxTrayHlpShowBalloonTip(szMsg, szTitle, RT_MS_5SEC); 67 68 VBoxTrayInfo("Guest Additions update found: %s -> %s\n", pszGuestVersion, pszHostVersion); 71 69 } 72 70 -
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxIPC.cpp
r106061 r106411 59 59 { 60 60 /** Pointer to the service environment. */ 61 const VBOX SERVICEENV *pEnv;61 const VBOXTRAYSVCENV *pEnv; 62 62 /** Handle for the local IPC server. */ 63 63 RTLOCALIPCSERVER hServer; … … 170 170 * Showing the balloon tooltip is not critical. 171 171 */ 172 int rc2 = hlpShowBalloonTip(g_hInstance, g_hwndToolWindow, ID_TRAYICON,172 VBoxTrayHlpShowBalloonTipEx(g_hInstance, g_hwndToolWindow, ID_TRAYICON, 173 173 pszMsg, pszTitle, Payload.s.cMsTimeout, Payload.s.uType); 174 LogFlowFunc(("Showing \"%s\" - \"%s\" (type %RU32, %RU32ms), rc=%Rrc\n",175 pszTitle, pszMsg, Payload.s.cMsTimeout, Payload.s.uType, rc2));176 RT_NOREF_PV(rc2);177 174 178 175 return VINF_SUCCESS; … … 207 204 208 205 /** 209 * Initializes the IPC communication. 210 * 211 * @return IPRT status code. 212 * @param pEnv The IPC service's environment. 213 * @param ppInstance The instance pointer which refers to this object. 214 */ 215 DECLCALLBACK(int) VBoxIPCInit(const PVBOXSERVICEENV pEnv, void **ppInstance) 206 * @interface_method_impl{VBOXSERVICEDESC,pfnPreInit} 207 */ 208 static DECLCALLBACK(int) vbtrIPCPreInit(void) 209 { 210 return VINF_SUCCESS; 211 } 212 213 214 /** 215 * @interface_method_impl{VBOXSERVICEDESC,pfnOption} 216 */ 217 static DECLCALLBACK(int) vbtrIPCOption(const char **ppszShort, int argc, char **argv, int *pi) 218 { 219 RT_NOREF(ppszShort, argc, argv, pi); 220 221 return -1; 222 } 223 224 /** 225 * @interface_method_impl{VBOXSERVICEDESC,pfnInit} 226 */ 227 DECLCALLBACK(int) vbtrIPCInit(const PVBOXTRAYSVCENV pEnv, void **ppInstance) 216 228 { 217 229 AssertPtrReturn(pEnv, VERR_INVALID_POINTER); … … 260 272 } 261 273 274 /** 275 * @interface_method_impl{VBOXSERVICEDESC,pfnStop} 276 */ 262 277 DECLCALLBACK(void) VBoxIPCStop(void *pInstance) 263 278 { … … 298 313 } 299 314 300 DECLCALLBACK(void) VBoxIPCDestroy(void *pInstance) 315 /** 316 * @interface_method_impl{VBOXSERVICEDESC,pfnDestroy} 317 */ 318 DECLCALLBACK(void) vbtrIPCDestroy(void *pInstance) 301 319 { 302 320 AssertPtrReturnVoid(pInstance); … … 552 570 * requests 553 571 */ 554 DECLCALLBACK(int) VBoxIPCWorker(void *pInstance, bool volatile *pfShutdown)572 DECLCALLBACK(int) vbtrIPCWorker(void *pInstance, bool volatile *pfShutdown) 555 573 { 556 574 AssertPtr(pInstance); … … 606 624 * The service description. 607 625 */ 608 VBOX SERVICEDESC g_SvcDescIPC =626 VBOXTRAYSVCDESC g_SvcDescIPC = 609 627 { 610 628 /* pszName. */ … … 612 630 /* pszDescription. */ 613 631 "Inter-Process Communication", 632 /* pszUsage. */ 633 NULL, 634 /* pszOptions. */ 635 NULL, 614 636 /* methods */ 615 VBoxIPCInit, 616 VBoxIPCWorker, 637 vbtrIPCPreInit, 638 vbtrIPCOption, 639 vbtrIPCInit, 640 vbtrIPCWorker, 617 641 NULL /* pfnStop */, 618 VBoxIPCDestroy642 vbtrIPCDestroy 619 643 }; 620 644 -
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxIPC.h
r106061 r106411 34 34 #endif 35 35 36 int VBoxIPCInit (const VBOXSERVICEENV *pEnv, void **ppInstance, bool *pfStartThread);37 unsigned __stdcall VBoxIPCWorker (void *pInstance);38 void VBoxIPCStop (const VBOX SERVICEENV *pEnv, void *pInstance);39 void VBoxIPCDestroy (const VBOXSERVICEENV *pEnv, void *pInstance);36 int vbtrIPCInit (const VBOXTRAYSVCENV *pEnv, void **ppInstance, bool *pfStartThread); 37 unsigned __stdcall vbtrIPCWorker (void *pInstance); 38 void VBoxIPCStop (const VBOXTRAYSVCENV *pEnv, void *pInstance); 39 void vbtrIPCDestroy (const VBOXTRAYSVCENV *pEnv, void *pInstance); 40 40 41 41 #endif /* !GA_INCLUDED_SRC_WINNT_VBoxTray_VBoxIPC_h */ -
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxLA.cpp
r106061 r106411 72 72 typedef struct _VBOXLACONTEXT 73 73 { 74 const VBOX SERVICEENV *pEnv;74 const VBOXTRAYSVCENV *pEnv; 75 75 76 76 bool fLogEnabled; … … 1209 1209 } 1210 1210 1211 DECLCALLBACK(int) VBoxLAInit(const PVBOXSERVICEENV pEnv, void **ppInstance) 1211 /** 1212 * @interface_method_impl{VBOXSERVICEDESC,pfnPreInit} 1213 */ 1214 static DECLCALLBACK(int) vbtrLAPreInit(void) 1215 { 1216 return VINF_SUCCESS; 1217 } 1218 1219 1220 /** 1221 * @interface_method_impl{VBOXSERVICEDESC,pfnOption} 1222 */ 1223 static DECLCALLBACK(int) vbtrLAOption(const char **ppszShort, int argc, char **argv, int *pi) 1224 { 1225 RT_NOREF(ppszShort, argc, argv, pi); 1226 1227 return -1; 1228 } 1229 1230 /** 1231 * @interface_method_impl{VBOXSERVICEDESC,pfnInit} 1232 */ 1233 DECLCALLBACK(int) vbtrLAInit(const PVBOXTRAYSVCENV pEnv, void **ppInstance) 1212 1234 { 1213 1235 AssertPtrReturn(pEnv, VERR_INVALID_POINTER); … … 1262 1284 } 1263 1285 1264 DECLCALLBACK(void) VBoxLADestroy(void *pInstance) 1286 /** 1287 * @interface_method_impl{VBOXSERVICEDESC,pfnDestroy} 1288 */ 1289 DECLCALLBACK(void) vbtrLADestroy(void *pInstance) 1265 1290 { 1266 1291 AssertPtrReturnVoid(pInstance); … … 1282 1307 } 1283 1308 1284 /* 1285 * Thread function to wait for and process property changes1309 /** 1310 * @interface_method_impl{VBOXSERVICEDESC,pfnWorker} 1286 1311 */ 1287 DECLCALLBACK(int) VBoxLAWorker(void *pInstance, bool volatile *pfShutdown)1312 DECLCALLBACK(int) vbtrLAWorker(void *pInstance, bool volatile *pfShutdown) 1288 1313 { 1289 1314 AssertPtr(pInstance); … … 1426 1451 * The service description. 1427 1452 */ 1428 VBOX SERVICEDESC g_SvcDescLA =1453 VBOXTRAYSVCDESC g_SvcDescLA = 1429 1454 { 1430 1455 /* pszName. */ … … 1432 1457 /* pszDescription. */ 1433 1458 "Location Awareness", 1459 /* pszUsage. */ 1460 NULL, 1461 /* pszOptions. */ 1462 NULL, 1434 1463 /* methods */ 1435 VBoxLAInit, 1436 VBoxLAWorker, 1464 vbtrLAPreInit, 1465 vbtrLAOption, 1466 vbtrLAInit, 1467 vbtrLAWorker, 1437 1468 NULL /* pfnStop */, 1438 VBoxLADestroy1469 vbtrLADestroy 1439 1470 }; 1440 1471 -
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxSeamless.cpp
r106061 r106411 52 52 typedef struct _VBOXSEAMLESSCONTEXT 53 53 { 54 const VBOX SERVICEENV *pEnv;54 const VBOXTRAYSVCENV *pEnv; 55 55 56 56 RTLDRMOD hModHook; … … 82 82 83 83 84 static DECLCALLBACK(int) VBoxSeamlessInit(const PVBOXSERVICEENV pEnv, void **ppInstance) 84 /** 85 * @interface_method_impl{VBOXSERVICEDESC,pfnPreInit} 86 */ 87 static DECLCALLBACK(int) vbtrSeamlessPreInit(void) 88 { 89 return VINF_SUCCESS; 90 } 91 92 /** 93 * @interface_method_impl{VBOXSERVICEDESC,pfnOption} 94 */ 95 static DECLCALLBACK(int) vbtrSeamlessOption(const char **ppszShort, int argc, char **argv, int *pi) 96 { 97 RT_NOREF(ppszShort, argc, argv, pi); 98 99 return -1; 100 } 101 102 /** 103 * @interface_method_impl{VBOXSERVICEDESC,pfnInit} 104 */ 105 static DECLCALLBACK(int) vbtrSeamlessInit(const PVBOXTRAYSVCENV pEnv, void **ppInstance) 85 106 { 86 107 LogFlowFuncEnter(); … … 135 156 } 136 157 158 /** 159 * @interface_method_impl{VBOXSERVICEDESC,pfnDestroy} 160 */ 137 161 static DECLCALLBACK(void) VBoxSeamlessDestroy(void *pInstance) 138 162 { … … 394 418 395 419 /** 396 * Thread function to wait for and process seamless mode change 397 * requests 398 */ 399 static DECLCALLBACK(int) VBoxSeamlessWorker(void *pvInstance, bool volatile *pfShutdown) 420 * @interface_method_impl{VBOXSERVICEDESC,pfnWorker} 421 */ 422 static DECLCALLBACK(int) vbtrSeamlessWorker(void *pvInstance, bool volatile *pfShutdown) 400 423 { 401 424 AssertPtrReturn(pvInstance, VERR_INVALID_POINTER); … … 519 542 * The service description. 520 543 */ 521 VBOX SERVICEDESC g_SvcDescSeamless =544 VBOXTRAYSVCDESC g_SvcDescSeamless = 522 545 { 523 546 /* pszName. */ … … 525 548 /* pszDescription. */ 526 549 "Seamless Windows", 550 /* pszUsage. */ 551 NULL, 552 /* pszOptions. */ 553 NULL, 527 554 /* methods */ 528 VBoxSeamlessInit, 529 VBoxSeamlessWorker, 555 vbtrSeamlessPreInit, 556 vbtrSeamlessOption, 557 vbtrSeamlessInit, 558 vbtrSeamlessWorker, 530 559 NULL /* pfnStop */, 531 560 VBoxSeamlessDestroy -
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxSessionTracking.cpp
r106061 r106411 37 37 38 38 #include "VBoxTray.h" 39 #include "VBoxTrayInternal.h" 39 40 40 41 … … 125 126 else 126 127 { 127 DWORD dwErr = GetLastError();128 LogRel(("WTSRegisterSessionNotification failed, error = %08X\n", dwErr));128 DWORD const dwErr = GetLastError(); 129 VBoxTrayInfo("WTSRegisterSessionNotification failed, error = %08X\n", dwErr); 129 130 if (dwErr == RPC_S_INVALID_BINDING) 130 131 { … … 144 145 else 145 146 { 146 LogRel(("WtsApi32.dll APIs are not available (%Rrc)\n", rc)); 147 VBoxTrayInfo("WtsApi32.dll APIs are not available (%Rrc)\n", rc); 148 147 149 gVBoxSt.pfnWTSRegisterSessionNotification = NULL; 148 150 gVBoxSt.pfnWTSUnRegisterSessionNotification = NULL; … … 153 155 gVBoxSt.fIsConsole = TRUE; 154 156 gVBoxSt.enmConnectState = WTSActive; 157 158 if (RT_FAILURE(rc)) 159 VBoxTrayError("Initializing sessiosn tracking failed with %Rrc\n", rc); 160 155 161 return rc; 156 162 } -
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxTray.cpp
r106246 r106411 53 53 #include <iprt/asm.h> 54 54 #include <iprt/buildconfig.h> 55 #include <iprt/file.h> 55 56 #include <iprt/getopt.h> 56 57 #include <iprt/ldr.h> … … 58 59 #include <iprt/path.h> 59 60 #include <iprt/process.h> 61 #include <iprt/stream.h> 60 62 #include <iprt/system.h> 61 63 #include <iprt/time.h> … … 80 82 * Global Variables * 81 83 *********************************************************************************************************************************/ 82 int g_cVerbosity = 0; 84 /** Mutex for checking if VBoxTray already is running. */ 85 HANDLE g_hMutexAppRunning = NULL; 86 /** Whether VBoxTray is connected to a (parent) console. */ 87 bool g_fHasConsole = false; 88 /** The current verbosity level. */ 89 unsigned g_cVerbosity = 0; 83 90 HANDLE g_hStopSem; 84 91 HANDLE g_hSeamlessWtNotifyEvent = 0; … … 90 97 uint32_t g_fGuestDisplaysChanged = 0; 91 98 92 static PRTLOGGER g_pLoggerRelease = NULL; /**< This is actually the debug logger in DEBUG builds! */ 93 static uint32_t g_cHistory = 10; /**< Enable log rotation, 10 files. */ 94 static uint32_t g_uHistoryFileTime = RT_SEC_1DAY; /**< Max 1 day per file. */ 95 static uint64_t g_uHistoryFileSize = 100 * _1M; /**< Max 100MB per file. */ 96 97 #ifdef DEBUG_andy 98 static VBOXSERVICEINFO g_aServices[] = 99 { 100 { &g_SvcDescClipboard, NIL_RTTHREAD, NULL, false, false, false, false, true } 101 }; 102 #else 99 103 100 /** 104 101 * The details of the services that has been compiled in. 105 102 */ 106 static VBOX SERVICEINFO g_aServices[] =103 static VBOXTRAYSVCINFO g_aServices[] = 107 104 { 108 105 { &g_SvcDescDisplay, NIL_RTTHREAD, NULL, false, false, false, false, true }, … … 118 115 #endif 119 116 }; 120 #endif 121 122 /* The global message table. */ 123 static VBOXGLOBALMESSAGE g_vboxGlobalMessageTable[] = 117 118 /** 119 * The global message table. 120 */ 121 static VBOXTRAYGLOBALMSG g_vboxGlobalMessageTable[] = 124 122 { 125 123 /* Windows specific stuff. */ … … 131 129 /* VBoxTray specific stuff. */ 132 130 /** @todo Add new messages here! */ 133 134 131 { 135 132 NULL … … 141 138 * get (re-)created. Nice to install our tray icon. 142 139 * 143 * @return IPRTstatus code.140 * @return VBox status code. 144 141 * @param wParam 145 142 * @param lParam … … 151 148 } 152 149 150 /** 151 * Creates VBoxTray's tray icon. 152 * 153 * @returns VBox status code. 154 */ 153 155 static int vboxTrayCreateTrayIcon(void) 154 156 { … … 156 158 if (hIcon == NULL) 157 159 { 158 DWORD dwErr = GetLastError();159 LogFunc(("Could not load tray icon, error %08X\n", dwErr));160 DWORD const dwErr = GetLastError(); 161 VBoxTrayError("Could not load tray icon (%#x)\n", dwErr); 160 162 return RTErrConvertFromWin32(dwErr); 161 163 } … … 176 178 if (!Shell_NotifyIcon(NIM_ADD, &g_NotifyIconData)) 177 179 { 178 DWORD dwErr = GetLastError();179 LogFunc(("Could not create tray icon, error=%ld\n", dwErr));180 DWORD const dwErr = GetLastError(); 181 VBoxTrayError("Could not create tray icon (%#x)\n", dwErr); 180 182 rc = RTErrConvertFromWin32(dwErr); 181 183 RT_ZERO(g_NotifyIconData); … … 187 189 } 188 190 191 /** 192 * Removes VBoxTray's tray icon. 193 * 194 * @returns VBox status code. 195 */ 189 196 static void vboxTrayRemoveTrayIcon(void) 190 197 { … … 213 220 static DECLCALLBACK(int) vboxTrayServiceThread(RTTHREAD ThreadSelf, void *pvUser) 214 221 { 215 PVBOX SERVICEINFO pSvc = (PVBOXSERVICEINFO)pvUser;222 PVBOXTRAYSVCINFO pSvc = (PVBOXTRAYSVCINFO)pvUser; 216 223 AssertPtr(pSvc); 217 224 … … 229 236 RTThreadUserSignal(ThreadSelf); 230 237 231 LogFunc(("Worker for '%s' ended with %Rrc\n", pSvc->pDesc->pszName, rc));238 VBoxTrayVerbose(1, "Thread for '%s' ended with %Rrc\n", pSvc->pDesc->pszName, rc); 232 239 return rc; 233 240 } 234 241 235 static int vboxTrayServicesStart(PVBOXSERVICEENV pEnv) 242 /** 243 * Lazily calls the pfnPreInit method on each service. 244 * 245 * @returns VBox status code, error message displayed. 246 */ 247 static int vboxTrayServicesLazyPreInit(void) 248 { 249 for (unsigned j = 0; j < RT_ELEMENTS(g_aServices); j++) 250 if (!g_aServices[j].fPreInited) 251 { 252 int rc = g_aServices[j].pDesc->pfnPreInit(); 253 if (RT_FAILURE(rc)) 254 return VBoxTrayError("Service '%s' failed pre-init: %Rrc\n", g_aServices[j].pDesc->pszName, rc); 255 g_aServices[j].fPreInited = true; 256 } 257 return VINF_SUCCESS; 258 } 259 260 /** 261 * Starts all services. 262 * 263 * @returns VBox status code. 264 * @param pEnv Service environment to use. 265 */ 266 static int vboxTrayServicesStart(PVBOXTRAYSVCENV pEnv) 236 267 { 237 268 AssertPtrReturn(pEnv, VERR_INVALID_POINTER); 238 269 239 LogRel(("Starting services ...\n"));270 VBoxTrayInfo("Starting services ...\n"); 240 271 241 272 int rc = VINF_SUCCESS; 242 273 274 size_t cServicesStarted = 0; 275 243 276 for (unsigned i = 0; i < RT_ELEMENTS(g_aServices); i++) 244 277 { 245 PVBOXSERVICEINFO pSvc = &g_aServices[i]; 246 LogRel(("Starting service '%s' ...\n", pSvc->pDesc->pszName)); 278 PVBOXTRAYSVCINFO pSvc = &g_aServices[i]; 279 280 if (!pSvc->fEnabled) 281 { 282 VBoxTrayInfo("Skipping starting service '%s' (disabled)\n", pSvc->pDesc->pszName); 283 continue; 284 } 285 286 VBoxTrayInfo("Starting service '%s' ...\n", pSvc->pDesc->pszName); 247 287 248 288 pSvc->hThread = NIL_RTTHREAD; … … 261 301 { 262 302 case VERR_NOT_SUPPORTED: 263 LogRel(("Service '%s' is not supported on this system\n", pSvc->pDesc->pszName));303 VBoxTrayInfo("Service '%s' is not supported on this system\n", pSvc->pDesc->pszName); 264 304 rc2 = VINF_SUCCESS; /* Keep going. */ 265 305 break; 266 306 267 307 case VERR_HGCM_SERVICE_NOT_FOUND: 268 LogRel(("Service '%s' is not available on the host\n", pSvc->pDesc->pszName));308 VBoxTrayInfo("Service '%s' is not available on the host\n", pSvc->pDesc->pszName); 269 309 rc2 = VINF_SUCCESS; /* Keep going. */ 270 310 break; 271 311 272 312 default: 273 LogRel(("Failed to initialize service '%s', rc=%Rrc\n", pSvc->pDesc->pszName, rc2));313 VBoxTrayError("Failed to initialize service '%s', rc=%Rrc\n", pSvc->pDesc->pszName, rc2); 274 314 break; 275 315 } … … 288 328 if (pSvc->fShutdown) 289 329 { 290 LogRel(("Service '%s' failed to start!\n", pSvc->pDesc->pszName));330 VBoxTrayError("Service '%s' failed to start!\n", pSvc->pDesc->pszName); 291 331 rc = VERR_GENERAL_FAILURE; 292 332 } 293 333 else 294 LogRel(("Service '%s' started\n", pSvc->pDesc->pszName)); 334 { 335 cServicesStarted++; 336 VBoxTrayInfo("Service '%s' started\n", pSvc->pDesc->pszName); 337 } 295 338 } 296 339 else 297 340 { 298 LogRel(("Failed to start thread for service '%s': %Rrc\n", rc2));341 VBoxTrayInfo("Failed to start thread for service '%s': %Rrc\n", rc2); 299 342 if (pSvc->pDesc->pfnDestroy) 300 343 pSvc->pDesc->pfnDestroy(pSvc->pInstance); … … 307 350 } 308 351 309 if (RT_SUCCESS(rc)) 310 LogRel(("All services started\n")); 311 else 312 LogRel(("Services started, but some with errors\n")); 352 VBoxTrayInfo("%zu/%zu service(s) started\n", cServicesStarted, RT_ELEMENTS(g_aServices)); 353 if (RT_FAILURE(rc)) 354 VBoxTrayInfo("Some service(s) reported errors when starting -- see log above\n"); 313 355 314 356 LogFlowFuncLeaveRC(rc); … … 316 358 } 317 359 318 static int vboxTrayServicesStop(VBOXSERVICEENV *pEnv) 360 /** 361 * Stops all services. 362 * 363 * @returns VBox status code. 364 * @param pEnv Service environment to use. 365 */ 366 static int vboxTrayServicesStop(VBOXTRAYSVCENV *pEnv) 319 367 { 320 368 AssertPtrReturn(pEnv, VERR_INVALID_POINTER); 321 369 322 LogRel2(("Stopping all services ...\n"));370 VBoxTrayVerbose(1, "Stopping all services ...\n"); 323 371 324 372 /* … … 333 381 for (unsigned i = 0; i < RT_ELEMENTS(g_aServices); i++) 334 382 { 335 PVBOX SERVICEINFO pSvc = &g_aServices[i];383 PVBOXTRAYSVCINFO pSvc = &g_aServices[i]; 336 384 if ( pSvc->fStarted 337 385 && pSvc->pDesc->pfnStop) 338 386 { 339 LogRel2(("Calling stop function for service '%s' ...\n", pSvc->pDesc->pszName));387 VBoxTrayVerbose(1, "Calling stop function for service '%s' ...\n", pSvc->pDesc->pszName); 340 388 int rc2 = pSvc->pDesc->pfnStop(pSvc->pInstance); 341 389 if (RT_FAILURE(rc2)) 342 LogRel(("Failed to stop service '%s': %Rrc\n", pSvc->pDesc->pszName, rc2));343 } 344 } 345 346 LogRel2(("All stop functions for services called\n"));390 VBoxTrayError("Failed to stop service '%s': %Rrc\n", pSvc->pDesc->pszName, rc2); 391 } 392 } 393 394 VBoxTrayVerbose(2, "All stop functions for services called\n"); 347 395 348 396 int rc = VINF_SUCCESS; … … 353 401 for (unsigned i = 0; i < RT_ELEMENTS(g_aServices); i++) 354 402 { 355 PVBOX SERVICEINFO pSvc = &g_aServices[i];403 PVBOXTRAYSVCINFO pSvc = &g_aServices[i]; 356 404 if (!pSvc->fEnabled) /* Only stop services which were started before. */ 357 405 continue; … … 359 407 if (pSvc->hThread != NIL_RTTHREAD) 360 408 { 361 LogRel2(("Waiting for service '%s' to stop ...\n", pSvc->pDesc->pszName));409 VBoxTrayVerbose(1, "Waiting for service '%s' to stop ...\n", pSvc->pDesc->pszName); 362 410 int rc2 = VINF_SUCCESS; 363 411 for (int j = 0; j < 30; j++) /* Wait 30 seconds in total */ … … 369 417 if (RT_FAILURE(rc2)) 370 418 { 371 LogRel(("Service '%s' failed to stop (%Rrc)\n", pSvc->pDesc->pszName, rc2));419 VBoxTrayError("Service '%s' failed to stop (%Rrc)\n", pSvc->pDesc->pszName, rc2); 372 420 if (RT_SUCCESS(rc)) 373 421 rc = rc2; … … 378 426 && pSvc->pInstance) /* pInstance might be NULL if initialization of a service failed. */ 379 427 { 380 LogRel2(("Terminating service '%s' ...\n", pSvc->pDesc->pszName));428 VBoxTrayVerbose(1, "Terminating service '%s' ...\n", pSvc->pDesc->pszName); 381 429 pSvc->pDesc->pfnDestroy(pSvc->pInstance); 382 430 } … … 384 432 385 433 if (RT_SUCCESS(rc)) 386 LogRel(("All services stopped\n"));434 VBoxTrayVerbose(1, "All services stopped\n"); 387 435 388 436 LogFlowFuncLeaveRC(rc); … … 390 438 } 391 439 392 static int vboxTrayRegisterGlobalMessages(PVBOXGLOBALMESSAGE pTable) 440 /** 441 * Registers all global window messages of a specific table. 442 * 443 * @returns VBox status code. 444 * @param pTable Table to register messages for. 445 */ 446 static int vboxTrayRegisterGlobalMessages(PVBOXTRAYGLOBALMSG pTable) 393 447 { 394 448 int rc = VINF_SUCCESS; … … 403 457 { 404 458 DWORD dwErr = GetLastError(); 405 Log(("Registering global message \"%s\" failed, error = %08X\n", dwErr));459 VBoxTrayError("Registering global message \"%s\" failed, error = %08X\n", pTable->pszName, dwErr); 406 460 rc = RTErrConvertFromWin32(dwErr); 407 461 } … … 413 467 } 414 468 415 static bool vboxTrayHandleGlobalMessages(PVBOXGLOBALMESSAGE pTable, UINT uMsg, 469 /** 470 * Handler for global (registered) window messages. 471 * 472 * @returns \c true if message got handeled, \c false if not. 473 * @param pTable Message table to look message up in. 474 * @param uMsg Message ID to handle. 475 * @param wParam WPARAM of the message. 476 * @param lParam LPARAM of the message. 477 */ 478 static bool vboxTrayHandleGlobalMessages(PVBOXTRAYGLOBALMSG pTable, UINT uMsg, 416 479 WPARAM wParam, LPARAM lParam) 417 480 { … … 434 497 435 498 /** 436 * Header/footer callback for the release logger. 437 * 438 * @param pLoggerRelease 439 * @param enmPhase 440 * @param pfnLog 441 */ 442 static DECLCALLBACK(void) vboxTrayLogHeaderFooter(PRTLOGGER pLoggerRelease, RTLOGPHASE enmPhase, PFNRTLOGPHASEMSG pfnLog) 443 { 444 /* Some introductory information. */ 445 static RTTIMESPEC s_TimeSpec; 446 char szTmp[256]; 447 if (enmPhase == RTLOGPHASE_BEGIN) 448 RTTimeNow(&s_TimeSpec); 449 RTTimeSpecToString(&s_TimeSpec, szTmp, sizeof(szTmp)); 450 451 switch (enmPhase) 452 { 453 case RTLOGPHASE_BEGIN: 454 { 455 pfnLog(pLoggerRelease, 456 "VBoxTray %s r%s %s (%s %s) release log\n" 457 "Log opened %s\n", 458 RTBldCfgVersion(), RTBldCfgRevisionStr(), VBOX_BUILD_TARGET, 459 __DATE__, __TIME__, szTmp); 460 461 int vrc = RTSystemQueryOSInfo(RTSYSOSINFO_PRODUCT, szTmp, sizeof(szTmp)); 462 if (RT_SUCCESS(vrc) || vrc == VERR_BUFFER_OVERFLOW) 463 pfnLog(pLoggerRelease, "OS Product: %s\n", szTmp); 464 vrc = RTSystemQueryOSInfo(RTSYSOSINFO_RELEASE, szTmp, sizeof(szTmp)); 465 if (RT_SUCCESS(vrc) || vrc == VERR_BUFFER_OVERFLOW) 466 pfnLog(pLoggerRelease, "OS Release: %s\n", szTmp); 467 vrc = RTSystemQueryOSInfo(RTSYSOSINFO_VERSION, szTmp, sizeof(szTmp)); 468 if (RT_SUCCESS(vrc) || vrc == VERR_BUFFER_OVERFLOW) 469 pfnLog(pLoggerRelease, "OS Version: %s\n", szTmp); 470 if (RT_SUCCESS(vrc) || vrc == VERR_BUFFER_OVERFLOW) 471 pfnLog(pLoggerRelease, "OS Service Pack: %s\n", szTmp); 472 473 /* the package type is interesting for Linux distributions */ 474 char szExecName[RTPATH_MAX]; 475 char *pszExecName = RTProcGetExecutablePath(szExecName, sizeof(szExecName)); 476 pfnLog(pLoggerRelease, 477 "Executable: %s\n" 478 "Process ID: %u\n" 479 "Package type: %s" 480 #ifdef VBOX_OSE 481 " (OSE)" 482 #endif 483 "\n", 484 pszExecName ? pszExecName : "unknown", 485 RTProcSelf(), 486 VBOX_PACKAGE_STRING); 487 break; 488 } 489 490 case RTLOGPHASE_PREROTATE: 491 pfnLog(pLoggerRelease, "Log rotated - Log started %s\n", szTmp); 492 break; 493 494 case RTLOGPHASE_POSTROTATE: 495 pfnLog(pLoggerRelease, "Log continuation - Log started %s\n", szTmp); 496 break; 497 498 case RTLOGPHASE_END: 499 pfnLog(pLoggerRelease, "End of log file - Log started %s\n", szTmp); 500 break; 501 502 default: 503 /* nothing */; 504 } 505 } 506 507 /** 508 * Creates the default release logger outputting to the specified file. 509 * 510 * @return IPRT status code. 511 * @param pszLogFile Path to log file to use. Can be NULL if not needed. 512 */ 513 static int vboxTrayLogCreate(const char *pszLogFile) 514 { 515 /* Create release (or debug) logger (stdout + file). */ 516 static const char * const s_apszGroups[] = VBOX_LOGGROUP_NAMES; 517 #ifdef DEBUG 518 static const char s_szEnvVarPfx[] = "VBOXTRAY_LOG"; 519 static const char s_szGroupSettings[] = "all.e.l.f"; 520 #else 521 static const char s_szEnvVarPfx[] = "VBOXTRAY_RELEASE_LOG"; 522 static const char s_szGroupSettings[] = "all"; 523 #endif 524 RTERRINFOSTATIC ErrInfo; 525 int rc = RTLogCreateEx(&g_pLoggerRelease, s_szEnvVarPfx, 526 RTLOGFLAGS_PREFIX_THREAD | RTLOGFLAGS_PREFIX_TIME_PROG | RTLOGFLAGS_USECRLF, 527 s_szGroupSettings, RT_ELEMENTS(s_apszGroups), s_apszGroups, UINT32_MAX, 528 0 /*cBufDescs*/, NULL /*paBufDescs*/, RTLOGDEST_STDOUT, 529 vboxTrayLogHeaderFooter, g_cHistory, g_uHistoryFileSize, g_uHistoryFileTime, 530 NULL /*pOutputIf*/, NULL /*pvOutputIfUser*/, 531 RTErrInfoInitStatic(&ErrInfo), "%s", pszLogFile ? pszLogFile : ""); 532 if (RT_SUCCESS(rc)) 533 { 534 #ifdef DEBUG 535 /* Register this logger as the _debug_ logger. */ 536 RTLogSetDefaultInstance(g_pLoggerRelease); 537 #else 538 /* Register this logger as the release logger. */ 539 RTLogRelSetDefaultInstance(g_pLoggerRelease); 540 #endif 541 /* If verbosity is explicitly set, make sure to increase the logging levels for 542 * the logging groups we offer functionality for in VBoxTray. */ 543 if (g_cVerbosity) 544 { 545 /* All groups we want to enable logging for VBoxTray. */ 546 #ifdef DEBUG 547 const char *apszGroups[] = { "guest_dnd", "shared_clipboard" }; 548 #else /* For release builds we always want all groups being logged in verbose mode. Don't change this! */ 549 const char *apszGroups[] = { "all" }; 550 #endif 551 char szGroupSettings[_1K]; 552 553 szGroupSettings[0] = '\0'; 554 555 for (size_t i = 0; i < RT_ELEMENTS(apszGroups); i++) 556 { 557 if (i > 0) 558 rc = RTStrCat(szGroupSettings, sizeof(szGroupSettings), "+"); 559 if (RT_SUCCESS(rc)) 560 rc = RTStrCat(szGroupSettings, sizeof(szGroupSettings), apszGroups[i]); 561 if (RT_FAILURE(rc)) 562 break; 563 564 switch (g_cVerbosity) 565 { 566 case 1: 567 rc = RTStrCat(szGroupSettings, sizeof(szGroupSettings), ".e.l.l2"); 568 break; 569 570 case 2: 571 rc = RTStrCat(szGroupSettings, sizeof(szGroupSettings), ".e.l.l2.l3"); 572 break; 573 574 case 3: 575 rc = RTStrCat(szGroupSettings, sizeof(szGroupSettings), ".e.l.l2.l3.l4"); 576 break; 577 578 case 4: 579 RT_FALL_THROUGH(); 580 default: 581 rc = RTStrCat(szGroupSettings, sizeof(szGroupSettings), ".e.l.l2.l3.l4.f"); 582 break; 583 } 584 585 if (RT_FAILURE(rc)) 586 break; 587 } 588 589 LogRel(("Verbose log settings are: %s\n", szGroupSettings)); 590 591 if (RT_SUCCESS(rc)) 592 rc = RTLogGroupSettings(g_pLoggerRelease, szGroupSettings); 593 if (RT_FAILURE(rc)) 594 RTMsgError("Setting log group settings failed, rc=%Rrc\n", rc); 595 } 596 597 /* Explicitly flush the log in case of VBOXTRAY_RELEASE_LOG=buffered. */ 598 RTLogFlush(g_pLoggerRelease); 599 } 600 else 601 VBoxTrayShowError(ErrInfo.szMsg); 602 603 return rc; 604 } 605 606 static void vboxTrayLogDestroy(void) 607 { 608 /* Only want to destroy the release logger before calling exit(). The debug 609 logger can be useful after that point... */ 610 RTLogDestroy(RTLogRelSetDefaultInstance(NULL)); 611 } 612 613 /** 614 * Displays an error message. 615 * 616 * @returns RTEXITCODE_FAILURE. 617 * @param pszFormat The message text. 618 * @param ... Format arguments. 619 */ 620 RTEXITCODE VBoxTrayShowError(const char *pszFormat, ...) 621 { 622 va_list args; 623 va_start(args, pszFormat); 624 char *psz = NULL; 625 RTStrAPrintfV(&psz, pszFormat, args); 626 va_end(args); 627 628 AssertPtr(psz); 629 LogRel(("Error: %s", psz)); 630 631 MessageBox(GetDesktopWindow(), psz, "VBoxTray - Error", MB_OK | MB_ICONERROR); 632 633 RTStrFree(psz); 634 635 return RTEXITCODE_FAILURE; 636 } 637 499 * Destroys the invisible tool window of VBoxTray. 500 */ 638 501 static void vboxTrayDestroyToolWindow(void) 639 502 { 640 503 if (g_hwndToolWindow) 641 504 { 642 Log(("Destroying tool window ...\n"));643 644 505 /* Destroy the tool window. */ 645 506 DestroyWindow(g_hwndToolWindow); … … 650 511 } 651 512 513 /** 514 * Creates the invisible tool window of VBoxTray. 515 * 516 * @returns VBox status code. 517 */ 652 518 static int vboxTrayCreateToolWindow(void) 653 519 { … … 666 532 { 667 533 dwErr = GetLastError(); 668 Log(("Registering invisible tool window failed, error = %08X\n", dwErr));534 VBoxTrayError("Registering invisible tool window failed, error = %08X\n", dwErr); 669 535 } 670 536 else … … 697 563 if (dwErr != ERROR_SUCCESS) 698 564 vboxTrayDestroyToolWindow(); 699 return RTErrConvertFromWin32(dwErr); 565 566 int const rc = RTErrConvertFromWin32(dwErr); 567 568 if (RT_FAILURE(rc)) 569 VBoxTrayError("Could not create tool window, rc=%Rrc\n", rc); 570 571 return rc; 700 572 } 701 573 … … 782 654 } 783 655 } 784 return RTErrConvertFromWin32(dwErr); 656 657 int const rc = RTErrConvertFromWin32(dwErr); 658 659 if (RT_FAILURE(rc)) 660 VBoxTrayError("Could not setup seamless, rc=%Rrc\n", rc); 661 662 return rc; 785 663 } 786 664 … … 800 678 } 801 679 680 /** 681 * Main routine for starting / stopping all internal services. 682 * 683 * @returns VBox status code. 684 */ 802 685 static int vboxTrayServiceMain(void) 803 686 { 804 687 int rc = VINF_SUCCESS; 805 LogFunc(("Entering vboxTrayServiceMain\n"));688 VBoxTrayVerbose(2, "Entering main loop\n"); 806 689 807 690 g_hStopSem = CreateEvent(NULL, TRUE, FALSE, NULL); … … 816 699 * Start services listed in the vboxServiceTable. 817 700 */ 818 VBOX SERVICEENV svcEnv;701 VBOXTRAYSVCENV svcEnv; 819 702 svcEnv.hInstance = g_hInstance; 820 703 821 704 /* Initializes disp-if to default (XPDM) mode. */ 822 705 VBoxDispIfInit(&svcEnv.dispIf); /* Cannot fail atm. */ 823 706 #ifdef VBOX_WITH_WDDM 824 707 /* 825 708 * For now the display mode will be adjusted to WDDM mode if needed 826 709 * on display service initialization when it detects the display driver type. 827 710 */ 828 #endif 711 #endif 712 VBoxTrayHlpReportStatus(VBoxGuestFacilityStatus_Init); 829 713 830 714 /* Finally start all the built-in services! */ 831 715 rc = vboxTrayServicesStart(&svcEnv); 832 if (RT_FAILURE(rc)) 833 { 834 /* Terminate service if something went wrong. */ 835 vboxTrayServicesStop(&svcEnv); 836 } 837 else 716 if (RT_SUCCESS(rc)) 838 717 { 839 718 uint64_t const uNtVersion = RTSystemGetNtVersion(); 840 rc = vboxTrayCreateTrayIcon();841 719 if ( RT_SUCCESS(rc) 842 720 && uNtVersion >= RTSYSTEM_MAKE_NT_VERSION(5, 0, 0)) /* Only for W2K and up ... */ … … 853 731 { 854 732 /* Report the host that we're up and running! */ 855 hlpReportStatus(VBoxGuestFacilityStatus_Active);733 VBoxTrayHlpReportStatus(VBoxGuestFacilityStatus_Active); 856 734 } 857 735 … … 957 835 LogFunc(("Returned from main loop, exiting ...\n")); 958 836 } 959 LogFunc(("Waiting for services to stop ...\n")); 960 vboxTrayServicesStop(&svcEnv); 837 961 838 } /* Services started */ 839 840 LogFunc(("Waiting for services to stop ...\n")); 841 842 VBoxTrayHlpReportStatus(VBoxGuestFacilityStatus_Terminating); 843 844 vboxTrayServicesStop(&svcEnv); 845 962 846 CloseHandle(g_hStopSem); 847 963 848 } /* Stop event created */ 964 849 965 vboxTrayRemoveTrayIcon(); 966 967 LogFunc(("Leaving with rc=%Rrc\n", rc)); 850 VBoxTrayVerbose(2, "Leaving main loop with %Rrc\n", rc); 968 851 return rc; 852 } 853 854 /** 855 * Attaches to a parent console (if any) or creates an own (dedicated) console window. 856 * 857 * @returns VBox status code. 858 */ 859 static int vboxTrayAttachConsole(void) 860 { 861 if (g_fHasConsole) /* Console already attached? Bail out. */ 862 return VINF_SUCCESS; 863 864 /* As we run with the WINDOWS subsystem, we need to either attach to or create an own console 865 * to get any stdout / stderr output. */ 866 bool fAllocConsole = false; 867 if (!AttachConsole(ATTACH_PARENT_PROCESS)) 868 fAllocConsole = true; 869 870 if (fAllocConsole) 871 { 872 if (!AllocConsole()) 873 VBoxTrayShowError("Unable to attach to or allocate a console!"); 874 /* Continue running. */ 875 } 876 877 RTFILE hStdIn; 878 RTFileFromNative(&hStdIn, (RTHCINTPTR)GetStdHandle(STD_INPUT_HANDLE)); 879 /** @todo Closing of standard handles not support via IPRT (yet). */ 880 RTStrmOpenFileHandle(hStdIn, "r", 0, &g_pStdIn); 881 882 RTFILE hStdOut; 883 RTFileFromNative(&hStdOut, (RTHCINTPTR)GetStdHandle(STD_OUTPUT_HANDLE)); 884 /** @todo Closing of standard handles not support via IPRT (yet). */ 885 RTStrmOpenFileHandle(hStdOut, "wt", 0, &g_pStdOut); 886 887 RTFILE hStdErr; 888 RTFileFromNative(&hStdErr, (RTHCINTPTR)GetStdHandle(STD_ERROR_HANDLE)); 889 RTStrmOpenFileHandle(hStdErr, "wt", 0, &g_pStdErr); 890 891 if (!fAllocConsole) /* When attaching to the parent console, make sure we start on a fresh line. */ 892 RTPrintf("\n"); 893 894 g_fHasConsole = true; 895 896 return VINF_SUCCESS; 897 } 898 899 /** 900 * Detaches from the (parent) console. 901 */ 902 static void vboxTrayDetachConsole() 903 { 904 g_fHasConsole = false; 905 } 906 907 /** 908 * Destroys VBoxTray. 909 * 910 * @returns RTEXITCODE_SUCCESS. 911 */ 912 static RTEXITCODE vboxTrayDestroy() 913 { 914 vboxTrayDetachConsole(); 915 916 /* Release instance mutex. */ 917 if (g_hMutexAppRunning != NULL) 918 { 919 CloseHandle(g_hMutexAppRunning); 920 g_hMutexAppRunning = NULL; 921 } 922 923 return RTEXITCODE_SUCCESS; 924 } 925 926 /** 927 * Prints the help to either a message box or a console (if attached). 928 * 929 * @returns RTEXITCODE_SYNTAX. 930 * @param cArgs Number of arguments given via argc. 931 * @param papszArgs Arguments given specified by \a cArgs. 932 */ 933 static RTEXITCODE vboxTrayPrintHelp(int cArgs, char **papszArgs) 934 { 935 RT_NOREF(cArgs); 936 937 char szServices[64] = { 0 }; 938 for (size_t i = 0; i < RT_ELEMENTS(g_aServices); i++) 939 { 940 char szName[RTTHREAD_NAME_LEN]; 941 int rc2 = RTStrCopy(szName, sizeof(szName), g_aServices[i].pDesc->pszName); 942 RTStrToLower(szName); /* To make it easier for users to recognize the service name via command line. */ 943 AssertRCBreak(rc2); 944 if (i > 0) 945 { 946 rc2 = RTStrCat(szServices, sizeof(szServices), ", "); 947 AssertRCBreak(rc2); 948 } 949 rc2 = RTStrCat(szServices, sizeof(szServices), szName); 950 AssertRCBreak(rc2); 951 } 952 953 VBoxTrayShowMsgBox(VBOX_PRODUCT " - " VBOX_VBOXTRAY_TITLE, 954 MB_ICONINFORMATION, 955 VBOX_PRODUCT " %s v%u.%u.%ur%u\n" 956 "Copyright (C) 2009-" VBOX_C_YEAR " " VBOX_VENDOR "\n\n" 957 "Command Line Parameters:\n\n" 958 "-d, --debug\n" 959 " Enables debugging mode\n" 960 "-f, --foreground\n" 961 " Enables running in foreground\n" 962 "-l, --logfile <file>\n" 963 " Enables logging to a file\n" 964 "-v, --verbose\n" 965 " Increases verbosity\n" 966 "-V, --version\n" 967 " Displays version number and exit\n" 968 "-?, -h, --help\n" 969 " Displays this help text and exit\n" 970 "\n" 971 "Service parameters:\n\n" 972 "--enable-<service-name>\n" 973 " Enables the given service\n" 974 "--disable-<service-name>\n" 975 " Disables the given service\n" 976 "--only-<service-name>\n" 977 " Only starts the given service\n" 978 "\n" 979 "Examples:\n" 980 " %s -vvv --logfile C:\\Temp\\VBoxTray.log\n" 981 " %s --foreground -vvvv --only-draganddrop\n" 982 "\n" 983 "Available services: %s\n\n", 984 VBOX_VBOXTRAY_TITLE, VBOX_VERSION_MAJOR, VBOX_VERSION_MINOR, VBOX_VERSION_BUILD, VBOX_SVN_REV, 985 papszArgs[0], papszArgs[0], szServices); 986 987 vboxTrayDestroy(); 988 989 return RTEXITCODE_SYNTAX; 969 990 } 970 991 … … 977 998 if (RT_FAILURE(rc)) 978 999 return RTMsgInitFailure(rc); 1000 1001 /* If a debugger is present, we always want to attach a console. */ 1002 if (IsDebuggerPresent()) 1003 vboxTrayAttachConsole(); 979 1004 980 1005 /* … … 983 1008 static const RTGETOPTDEF s_aOptions[] = 984 1009 { 1010 { "--debug", 'd', RTGETOPT_REQ_NOTHING }, 1011 { "/debug", 'd', RTGETOPT_REQ_NOTHING }, 1012 { "--foreground", 'f', RTGETOPT_REQ_NOTHING }, 1013 { "/foreground", 'f', RTGETOPT_REQ_NOTHING }, 985 1014 { "--help", 'h', RTGETOPT_REQ_NOTHING }, 986 1015 { "-help", 'h', RTGETOPT_REQ_NOTHING }, … … 1006 1035 { 1007 1036 case 'h': 1008 hlpShowMessageBox(VBOX_PRODUCT " - " VBOX_VBOXTRAY_TITLE, 1009 MB_ICONINFORMATION, 1010 "-- " VBOX_PRODUCT " %s v%u.%u.%ur%u --\n\n" 1011 "Copyright (C) 2009-" VBOX_C_YEAR " " VBOX_VENDOR "\n\n" 1012 "Command Line Parameters:\n\n" 1013 "-l, --logfile <file>\n" 1014 " Enables logging to a file\n" 1015 "-v, --verbose\n" 1016 " Increases verbosity\n" 1017 "-V, --version\n" 1018 " Displays version number and exit\n" 1019 "-?, -h, --help\n" 1020 " Displays this help text and exit\n" 1021 "\n" 1022 "Examples:\n" 1023 " %s -vvv\n", 1024 VBOX_VBOXTRAY_TITLE, VBOX_VERSION_MAJOR, VBOX_VERSION_MINOR, VBOX_VERSION_BUILD, VBOX_SVN_REV, 1025 papszArgs[0], papszArgs[0]); 1026 return RTEXITCODE_SUCCESS; 1037 return vboxTrayPrintHelp(cArgs, papszArgs); 1038 1039 case 'd': 1040 { 1041 /* ignore rc */ vboxTrayAttachConsole(); 1042 g_cVerbosity = 4; /* Set verbosity to level 4. */ 1043 break; 1044 } 1045 1046 case 'f': 1047 { 1048 /* ignore rc */ vboxTrayAttachConsole(); 1049 /* Don't increase verbosity automatically here. */ 1050 break; 1051 } 1027 1052 1028 1053 case 'l': 1054 { 1029 1055 if (*ValueUnion.psz == '\0') 1030 1056 szLogFile[0] = '\0'; … … 1033 1059 rc = RTPathAbs(ValueUnion.psz, szLogFile, sizeof(szLogFile)); 1034 1060 if (RT_FAILURE(rc)) 1035 return RTMsgErrorExit(RTEXITCODE_FAILURE, "RTPathAbs failed on log file path: %Rrc (%s)", 1036 rc, ValueUnion.psz); 1061 { 1062 int rcExit = RTMsgErrorExit(RTEXITCODE_FAILURE, "RTPathAbs failed on log file path: %Rrc (%s)", 1063 rc, ValueUnion.psz); 1064 vboxTrayDestroy(); 1065 return rcExit; 1066 } 1037 1067 } 1038 1068 break; 1069 } 1039 1070 1040 1071 case 'v': … … 1043 1074 1044 1075 case 'V': 1045 hlpShowMessageBox(VBOX_VBOXTRAY_TITLE, MB_ICONINFORMATION,1046 "Version: %u.%u.%ur%u",1047 VBOX_VERSION_MAJOR, VBOX_VERSION_MINOR, VBOX_VERSION_BUILD, VBOX_SVN_REV);1048 return RTEXITCODE_SUCCESS;1076 VBoxTrayShowMsgBox(VBOX_PRODUCT " - " VBOX_VBOXTRAY_TITLE, 1077 MB_ICONINFORMATION, 1078 "%u.%u.%ur%u", VBOX_VERSION_MAJOR, VBOX_VERSION_MINOR, VBOX_VERSION_BUILD, VBOX_SVN_REV); 1079 return vboxTrayDestroy(); 1049 1080 1050 1081 default: 1051 rc = RTGetOptPrintError(ch, &ValueUnion); 1052 break; 1053 } 1054 } 1055 1056 /* Note: Do not use a global namespace ("Global\\") for mutex name here, 1057 * will blow up NT4 compatibility! */ 1058 HANDLE hMutexAppRunning = CreateMutex(NULL, FALSE, VBOX_VBOXTRAY_TITLE); 1059 if ( hMutexAppRunning != NULL 1082 { 1083 const char *psz = ValueUnion.psz; 1084 size_t const cch = strlen(ValueUnion.psz); 1085 bool fFound = false; 1086 1087 if (cch > sizeof("--enable-") && !memcmp(psz, RT_STR_TUPLE("--enable-"))) 1088 for (unsigned j = 0; !fFound && j < RT_ELEMENTS(g_aServices); j++) 1089 if ((fFound = !RTStrICmp(psz + sizeof("--enable-") - 1, g_aServices[j].pDesc->pszName))) 1090 g_aServices[j].fEnabled = true; 1091 1092 if (cch > sizeof("--disable-") && !memcmp(psz, RT_STR_TUPLE("--disable-"))) 1093 for (unsigned j = 0; !fFound && j < RT_ELEMENTS(g_aServices); j++) 1094 if ((fFound = !RTStrICmp(psz + sizeof("--disable-") - 1, g_aServices[j].pDesc->pszName))) 1095 g_aServices[j].fEnabled = false; 1096 1097 if (cch > sizeof("--only-") && !memcmp(psz, RT_STR_TUPLE("--only-"))) 1098 for (unsigned j = 0; j < RT_ELEMENTS(g_aServices); j++) 1099 { 1100 g_aServices[j].fEnabled = !RTStrICmp(psz + sizeof("--only-") - 1, g_aServices[j].pDesc->pszName); 1101 if (g_aServices[j].fEnabled) 1102 fFound = true; 1103 } 1104 1105 if (!fFound) 1106 { 1107 rc = vboxTrayServicesLazyPreInit(); 1108 if (RT_FAILURE(rc)) 1109 break; 1110 for (unsigned j = 0; !fFound && j < RT_ELEMENTS(g_aServices); j++) 1111 { 1112 rc = g_aServices[j].pDesc->pfnOption(NULL, cArgs, papszArgs, NULL); 1113 fFound = rc == VINF_SUCCESS; 1114 if (fFound) 1115 break; 1116 if (rc != -1) /* Means not parsed. */ 1117 break; 1118 } 1119 } 1120 if (!fFound) 1121 { 1122 RTGetOptPrintError(ch, &ValueUnion); /* Only shown on console. */ 1123 return vboxTrayPrintHelp(cArgs, papszArgs); 1124 } 1125 1126 continue; 1127 } 1128 } 1129 } 1130 1131 if (RT_FAILURE(rc)) 1132 { 1133 vboxTrayDestroy(); 1134 return RTEXITCODE_FAILURE; 1135 } 1136 1137 /** 1138 * VBoxTray already running? Bail out. 1139 * 1140 * Note: Do not use a global namespace ("Global\\") for mutex name here, 1141 * will blow up NT4 compatibility! 1142 */ 1143 g_hMutexAppRunning = CreateMutex(NULL, FALSE, VBOX_VBOXTRAY_TITLE); 1144 if ( g_hMutexAppRunning != NULL 1060 1145 && GetLastError() == ERROR_ALREADY_EXISTS) 1061 1146 { 1062 /* VBoxTray already running? Bail out. */ 1063 CloseHandle (hMutexAppRunning); 1064 hMutexAppRunning = NULL; 1065 return RTEXITCODE_SUCCESS; 1066 } 1147 VBoxTrayError(VBOX_VBOXTRAY_TITLE " already running!\n"); 1148 return vboxTrayDestroy(); 1149 } 1150 1151 /* Set the instance handle. */ 1152 #ifdef IPRT_NO_CRT 1153 Assert(g_hInstance == NULL); /* Make sure this isn't set before by WinMain(). */ 1154 g_hInstance = GetModuleHandleW(NULL); 1155 #endif 1067 1156 1068 1157 rc = VbglR3Init(); 1069 1158 if (RT_SUCCESS(rc)) 1070 1159 { 1071 rc = vboxTrayLogCreate(szLogFile[0] ? szLogFile : NULL);1160 rc = VBoxTrayLogCreate(szLogFile[0] ? szLogFile : NULL); 1072 1161 if (RT_SUCCESS(rc)) 1073 1162 { 1074 LogRel(("Verbosity level: %d\n", g_cVerbosity)); 1075 1076 /* Log the major windows NT version: */ 1077 uint64_t const uNtVersion = RTSystemGetNtVersion(); 1078 LogRel(("Windows version %u.%u build %u (uNtVersion=%#RX64)\n", RTSYSTEM_NT_VERSION_GET_MAJOR(uNtVersion), 1079 RTSYSTEM_NT_VERSION_GET_MINOR(uNtVersion), RTSYSTEM_NT_VERSION_GET_BUILD(uNtVersion), uNtVersion )); 1080 1081 /* Set the instance handle. */ 1082 #ifdef IPRT_NO_CRT 1083 Assert(g_hInstance == NULL); /* Make sure this isn't set before by WinMain(). */ 1084 g_hInstance = GetModuleHandleW(NULL); 1085 #endif 1086 hlpReportStatus(VBoxGuestFacilityStatus_Init); 1163 VBoxTrayInfo("Verbosity level: %d\n", g_cVerbosity); 1164 1087 1165 rc = vboxTrayCreateToolWindow(); 1166 if (RT_SUCCESS(rc)) 1167 rc = vboxTrayCreateTrayIcon(); 1168 1169 VBoxTrayHlpReportStatus(VBoxGuestFacilityStatus_PreInit); 1170 1088 1171 if (RT_SUCCESS(rc)) 1089 1172 { … … 1101 1184 1102 1185 rc = vboxDtInit(); 1103 if ( !RT_SUCCESS(rc))1186 if (RT_FAILURE(rc)) 1104 1187 { 1105 LogFlowFunc(("vboxDtInit failed, rc=%Rrc\n", rc));1106 1188 /* ignore the Dt Init failure. this can happen for < XP win that do not support WTS API 1107 1189 * in that case the session is treated as active connected to the physical console … … 1110 1192 } 1111 1193 1112 rc = VBoxAcquireGuestCaps(VMMDEV_GUEST_SUPPORTS_SEAMLESS | VMMDEV_GUEST_SUPPORTS_GRAPHICS, 0, true); 1113 if (!RT_SUCCESS(rc)) 1114 LogFlowFunc(("VBoxAcquireGuestCaps failed with rc=%Rrc, ignoring ...\n", rc)); 1115 1116 rc = vboxTraySetupSeamless(); /** @todo r=andy Do we really want to be this critical for the whole application? */ 1117 if (RT_SUCCESS(rc)) 1118 { 1119 rc = vboxTrayServiceMain(); 1120 if (RT_SUCCESS(rc)) 1121 hlpReportStatus(VBoxGuestFacilityStatus_Terminating); 1122 vboxTrayShutdownSeamless(); 1123 } 1194 VBoxAcquireGuestCaps(VMMDEV_GUEST_SUPPORTS_SEAMLESS | VMMDEV_GUEST_SUPPORTS_GRAPHICS, 0, true); 1195 1196 vboxTraySetupSeamless(); 1197 1198 rc = vboxTrayServiceMain(); 1199 /* Note: Do *not* overwrite rc in the following code, as this acts as the exit code. */ 1200 1201 vboxTrayShutdownSeamless(); 1124 1202 1125 1203 /* it should be safe to call vboxDtTerm even if vboxStInit above failed */ … … 1130 1208 1131 1209 VBoxCapsTerm(); 1132 1133 vboxTrayDestroyToolWindow(); 1134 } 1210 } 1211 1212 vboxTrayRemoveTrayIcon(); 1213 vboxTrayDestroyToolWindow(); 1214 1135 1215 if (RT_SUCCESS(rc)) 1136 hlpReportStatus(VBoxGuestFacilityStatus_Terminated); 1216 1217 VBoxTrayHlpReportStatus(VBoxGuestFacilityStatus_Terminated); 1137 1218 else 1138 { 1139 LogRel(("Error while starting, rc=%Rrc\n", rc)); 1140 hlpReportStatus(VBoxGuestFacilityStatus_Failed); 1141 } 1142 1143 LogRel(("Ended\n")); 1144 1145 vboxTrayLogDestroy(); 1219 VBoxTrayHlpReportStatus(VBoxGuestFacilityStatus_Failed); 1220 1221 VBoxTrayInfo("VBoxTray terminated with %Rrc\n", rc); 1222 1223 VBoxTrayLogDestroy(); 1146 1224 } 1147 1225 … … 1151 1229 VBoxTrayShowError("VbglR3Init failed: %Rrc\n", rc); 1152 1230 1153 /* Release instance mutex. */ 1154 if (hMutexAppRunning != NULL) 1155 { 1156 CloseHandle(hMutexAppRunning); 1157 hMutexAppRunning = NULL; 1158 } 1231 vboxTrayDestroy(); 1159 1232 1160 1233 return RT_SUCCESS(rc) ? RTEXITCODE_SUCCESS : RTEXITCODE_FAILURE; … … 1213 1286 { 1214 1287 case TIMERID_VBOXTRAY_CHECK_HOSTVERSION: 1288 { 1215 1289 if (RT_SUCCESS(VBoxCheckHostVersion())) 1216 1290 { 1217 /* After successful run we don't need to check again. */1291 /* After a successful run we don't need to check again. */ 1218 1292 KillTimer(g_hwndToolWindow, TIMERID_VBOXTRAY_CHECK_HOSTVERSION); 1219 1293 } 1294 1220 1295 return 0; 1296 } 1221 1297 1222 1298 default: -
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxTray.h
r106061 r106411 78 78 79 79 /** 80 * The environment information for services.81 */ 82 typedef struct VBOX SERVICEENV80 * The environment information for a single VBoxTray service. 81 */ 82 typedef struct VBOXTRAYSVCENV 83 83 { 84 84 /** hInstance of VBoxTray. */ … … 88 88 * by the VBoxCaps facility. See #8037. */ 89 89 VBOXDISPIF dispIf; 90 } VBOX SERVICEENV;90 } VBOXTRAYSVCENV; 91 91 /** Pointer to a VBoxTray service env info structure. */ 92 typedef VBOX SERVICEENV *PVBOXSERVICEENV;92 typedef VBOXTRAYSVCENV *PVBOXTRAYSVCENV; 93 93 /** Pointer to a const VBoxTray service env info structure. */ 94 typedef VBOX SERVICEENV const *PCVBOXSERVICEENV;95 96 /** 97 * A service descriptor.98 */ 99 typedef struct VBOX SERVICEDESC94 typedef VBOXTRAYSVCENV const *PCVBOXTRAYSVCENV; 95 96 /** 97 * A VBoxTray service descriptor. 98 */ 99 typedef struct VBOXTRAYSVCDESC 100 100 { 101 101 /** The service's name. RTTHREAD_NAME_LEN maximum characters. */ … … 103 103 /** The service description. */ 104 104 const char *pszDesc; 105 /** The usage options stuff for the --help screen. */ 106 const char *pszUsage; 107 /** The option descriptions for the --help screen. */ 108 const char *pszOptions; 105 109 106 110 /** Callbacks. */ 111 112 /** 113 * Called before parsing arguments. 114 * @returns VBox status code. 115 */ 116 DECLCALLBACKMEMBER(int, pfnPreInit,(void)); 117 118 /** 119 * Tries to parse the given command line option. 120 * 121 * @returns 0 if we parsed, -1 if it didn't and anything else means exit. 122 * @param ppszShort If not NULL it points to the short option iterator. a short argument. 123 * If NULL examine argv[*pi]. 124 * @param argc The argument count. 125 * @param argv The argument vector. 126 * @param pi The argument vector index. Update if any value(s) are eaten. 127 */ 128 DECLCALLBACKMEMBER(int, pfnOption,(const char **ppszShort, int argc, char **argv, int *pi)); 107 129 108 130 /** … … 116 138 * @todo r=bird: The pEnv type is WRONG! Please check all your const pointers. 117 139 */ 118 DECLCALLBACKMEMBER(int, pfnInit,(const PVBOX SERVICEENV pEnv, void **ppInstance));140 DECLCALLBACKMEMBER(int, pfnInit,(const PVBOXTRAYSVCENV pEnv, void **ppInstance)); 119 141 120 142 /** Called from the worker thread. … … 139 161 */ 140 162 DECLCALLBACKMEMBER(void, pfnDestroy,(void *pInstance)); 141 } VBOXSERVICEDESC, *PVBOXSERVICEDESC; 142 143 144 /** 145 * The service initialization info and runtime variables. 146 */ 147 typedef struct VBOXSERVICEINFO 163 } VBOXTRAYSVCDESC; 164 /** Pointer to a VBoxTray service descriptor. */ 165 typedef VBOXTRAYSVCDESC *PVBOXTRAYSVCDESC; 166 167 /** 168 * VBoxTray service initialization info and runtime variables. 169 */ 170 typedef struct VBOXTRAYSVCINFO 148 171 { 149 172 /** Pointer to the service descriptor. */ 150 PVBOX SERVICEDESC pDesc;173 PVBOXTRAYSVCDESC pDesc; 151 174 /** Thread handle. */ 152 175 RTTHREAD hThread; … … 164 187 /** Whether the service is enabled or not. */ 165 188 bool fEnabled; 166 } VBOXSERVICEINFO, *PVBOXSERVICEINFO; 167 168 /** 169 * Globally unique (system wide) message registration. 170 */ 171 typedef struct VBOXGLOBALMESSAGE 189 } VBOXTRAYSVCINFO; 190 /** Pointer to a VBoxTray service' initialization and runtime variables. */ 191 typedef VBOXTRAYSVCINFO *PVBOXTRAYSVCINFO; 192 193 /** 194 * Structure for keeping a globally registered Windows message. 195 */ 196 typedef struct VBOXTRAYGLOBALMSG 172 197 { 173 198 /** Message name. */ … … 181 206 * to be filled in when registering the actual message. */ 182 207 UINT uMsgID; 183 } VBOXGLOBALMESSAGE, *PVBOXGLOBALMESSAGE; 184 208 } VBOXTRAYGLOBALMSG; 209 /** Pointer to a globally registered Windows message. */ 210 typedef VBOXTRAYGLOBALMSG *PVBOXTRAYGLOBALMSG; 185 211 186 212 /********************************************************************************************************************************* 187 213 * Externals * 188 214 *********************************************************************************************************************************/ 189 extern VBOX SERVICEDESC g_SvcDescDisplay;215 extern VBOXTRAYSVCDESC g_SvcDescDisplay; 190 216 #ifdef VBOX_WITH_SHARED_CLIPBOARD 191 extern VBOX SERVICEDESC g_SvcDescClipboard;217 extern VBOXTRAYSVCDESC g_SvcDescClipboard; 192 218 #endif 193 extern VBOX SERVICEDESC g_SvcDescSeamless;194 extern VBOX SERVICEDESC g_SvcDescVRDP;195 extern VBOX SERVICEDESC g_SvcDescIPC;196 extern VBOX SERVICEDESC g_SvcDescLA;219 extern VBOXTRAYSVCDESC g_SvcDescSeamless; 220 extern VBOXTRAYSVCDESC g_SvcDescVRDP; 221 extern VBOXTRAYSVCDESC g_SvcDescIPC; 222 extern VBOXTRAYSVCDESC g_SvcDescLA; 197 223 #ifdef VBOX_WITH_DRAG_AND_DROP 198 extern VBOX SERVICEDESC g_SvcDescDnD;224 extern VBOXTRAYSVCDESC g_SvcDescDnD; 199 225 #endif 200 226 201 extern int g_cVerbosity; 227 extern bool g_fHasConsole; 228 extern unsigned g_cVerbosity; 202 229 extern HINSTANCE g_hInstance; 203 230 extern HWND g_hwndToolWindow; 204 231 extern uint32_t g_fGuestDisplaysChanged; 205 232 206 RTEXITCODE VBoxTrayShowError(const char *pszFormat, ...);207 208 233 #endif /* !GA_INCLUDED_SRC_WINNT_VBoxTray_VBoxTray_h */ 209 234 -
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxTrayInternal.h
r106061 r106411 104 104 DWORD aBitsPerPixel, LONG aPosX, LONG aPosY, BOOL fEnabled, BOOL fExtDispSup); 105 105 106 int VBoxTrayLogCreate(const char *pszLogFile); 107 void VBoxTrayLogDestroy(void); 108 109 void VBoxTrayInfo(const char *pszFormat, ...); 110 RTEXITCODE VBoxTrayError(const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(1, 2); 111 void VBoxTrayVerbose(unsigned iLevel, const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(2, 3); 112 RTEXITCODE VBoxTrayShowError(const char *pszFormat, ...); 113 106 114 #endif /* !GA_INCLUDED_SRC_WINNT_VBoxTray_VBoxTrayInternal_h */ -
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxVRDP.cpp
r106061 r106411 79 79 typedef struct VBOXVRDPCONTEXT 80 80 { 81 const VBOX SERVICEENV *pEnv;81 const VBOXTRAYSVCENV *pEnv; 82 82 83 83 uint32_t level; … … 279 279 } 280 280 281 static DECLCALLBACK(int) VBoxVRDPInit(const PVBOXSERVICEENV pEnv, void **ppInstance) 281 /** 282 * @interface_method_impl{VBOXSERVICEDESC,pfnPreInit} 283 */ 284 static DECLCALLBACK(int) vbtrVRDPPreInit(void) 285 { 286 return VINF_SUCCESS; 287 } 288 289 /** 290 * @interface_method_impl{VBOXSERVICEDESC,pfnOption} 291 */ 292 static DECLCALLBACK(int) vbtrVRDPOption(const char **ppszShort, int argc, char **argv, int *pi) 293 { 294 RT_NOREF(ppszShort, argc, argv, pi); 295 296 return -1; 297 } 298 299 /** 300 * @interface_method_impl{VBOXSERVICEDESC,pfnInit} 301 */ 302 static DECLCALLBACK(int) vbtrVRDPInit(const PVBOXTRAYSVCENV pEnv, void **ppInstance) 282 303 { 283 304 AssertPtrReturn(pEnv, VERR_INVALID_POINTER); … … 316 337 } 317 338 339 /** 340 * @interface_method_impl{VBOXSERVICEDESC,pfnDestroy} 341 */ 318 342 static DECLCALLBACK(void) VBoxVRDPDestroy(void *pInstance) 319 343 { … … 335 359 336 360 /** 337 * Thread function to wait for and process mode change requests338 */ 339 static DECLCALLBACK(int) VBoxVRDPWorker(void *pvInstance, bool volatile *pfShutdown)361 * @interface_method_impl{VBOXSERVICEDESC,pfnWorker} 362 */ 363 static DECLCALLBACK(int) vbtrVRDPWorker(void *pvInstance, bool volatile *pfShutdown) 340 364 { 341 365 AssertPtrReturn(pvInstance, VERR_INVALID_POINTER); … … 450 474 * The service description. 451 475 */ 452 VBOX SERVICEDESC g_SvcDescVRDP =476 VBOXTRAYSVCDESC g_SvcDescVRDP = 453 477 { 454 478 /* pszName. */ … … 456 480 /* pszDescription. */ 457 481 "VRDP Connection Notification", 482 /* pszUsage. */ 483 NULL, 484 /* pszOptions. */ 485 NULL, 458 486 /* methods */ 459 VBoxVRDPInit, 460 VBoxVRDPWorker, 487 vbtrVRDPPreInit, 488 vbtrVRDPOption, 489 vbtrVRDPInit, 490 vbtrVRDPWorker, 461 491 NULL /* pfnStop */, 462 492 VBoxVRDPDestroy -
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxVRDP.h
r106061 r106411 33 33 34 34 /* The restore service prototypes. */ 35 int VBoxVRDPInit (const VBOX SERVICEENV *pEnv, void **ppInstance, bool *pfStartThread);35 int VBoxVRDPInit (const VBOXTRAYSVCENV *pEnv, void **ppInstance, bool *pfStartThread); 36 36 unsigned __stdcall VBoxVRDPThread (void *pInstance); 37 void VBoxVRDPDestroy (const VBOX SERVICEENV *pEnv, void *pInstance);37 void VBoxVRDPDestroy (const VBOXTRAYSVCENV *pEnv, void *pInstance); 38 38 39 39 #endif /* !GA_INCLUDED_SRC_WINNT_VBoxTray_VBoxVRDP_h */
Note:
See TracChangeset
for help on using the changeset viewer.