Changeset 80444 in vbox for trunk/src/VBox/Additions/WINNT/VBoxTray
- Timestamp:
- Aug 27, 2019 5:47:44 PM (5 years ago)
- Location:
- trunk/src/VBox/Additions/WINNT/VBoxTray
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/VBoxTray/Makefile.kmk
r80324 r80444 51 51 VBoxTray_SOURCES += \ 52 52 VBoxClipboard.cpp \ 53 $(PATH_ROOT)/src/VBox/GuestHost/SharedClipboard/clipboard-win.cpp 53 $(PATH_ROOT)/src/VBox/GuestHost/SharedClipboard/clipboard-win.cpp \ 54 $(PATH_ROOT)/src/VBox/GuestHost/SharedClipboard/clipboard-common.cpp 54 55 ifdef VBOX_WITH_SHARED_CLIPBOARD_URI_LIST 55 56 VBoxTray_DEFS += VBOX_WITH_SHARED_CLIPBOARD_GUEST … … 60 61 $(PATH_ROOT)/src/VBox/GuestHost/SharedClipboard/ClipboardPath.cpp \ 61 62 $(PATH_ROOT)/src/VBox/GuestHost/SharedClipboard/ClipboardStreamImpl-win.cpp \ 62 $(PATH_ROOT)/src/VBox/GuestHost/SharedClipboard/clipboard-common.cpp \63 63 $(PATH_ROOT)/src/VBox/GuestHost/SharedClipboard/clipboard-uri.cpp 64 64 endif -
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxClipboard.cpp
r80374 r80444 27 27 28 28 #include <iprt/asm.h> 29 #include <iprt/errcore.h> 30 #include <iprt/mem.h> 29 31 #include <iprt/ldr.h> 30 32 31 #include <iprt/errcore.h>32 33 33 34 #include <VBox/GuestHost/SharedClipboard.h> 35 #include <VBox/GuestHost/SharedClipboard-win.h> 36 #include <VBox/GuestHost/clipboard-helper.h> 34 37 #include <VBox/HostServices/VBoxClipboardSvc.h> /* Temp, remove. */ 35 #include <VBox/GuestHost/SharedClipboard-win.h>36 38 #ifdef VBOX_WITH_SHARED_CLIPBOARD_URI_LIST 37 39 # include <VBox/GuestHost/SharedClipboard-uri.h> … … 118 120 if (RT_SUCCESS(rc)) 119 121 { 120 rc = VbglR3ClipboardTransferSendStatus(&cmdCtx, SHAREDCLIPBOARDURITRANSFERSTATUS_RUNNING);122 rc = VbglR3ClipboardTransferSendStatus(&cmdCtx, pTransfer, SHAREDCLIPBOARDURITRANSFERSTATUS_RUNNING); 121 123 if (RT_SUCCESS(rc)) 122 124 { … … 127 129 { 128 130 PVBGLR3CLIPBOARDEVENT pEvent = NULL; 129 rc = VbglR3ClipboardEventGetNext(&cmdCtx, pTransfer,&pEvent);131 rc = VbglR3ClipboardEventGetNext(&cmdCtx, &pEvent); 130 132 if (RT_SUCCESS(rc)) 131 133 { … … 425 427 /* Clipboard was updated by another application. 426 428 * Report available formats to the host. */ 427 VBOXCLIPBOARDFORMATS fFormats;428 int rc = VBoxClipboardWinGetFormats(&pCtx->Win, & fFormats);429 SHAREDCLIPBOARDFORMATDATA Formats; 430 int rc = VBoxClipboardWinGetFormats(&pCtx->Win, &Formats); 429 431 if (RT_SUCCESS(rc)) 430 432 { 431 LogFunc(("WM_CLIPBOARDUPDATE: Reporting formats 0x%x\n", fFormats));432 rc = VbglR3Clipboard ReportFormats(pCtx->CmdCtx.uClientID, fFormats);433 LogFunc(("WM_CLIPBOARDUPDATE: Reporting formats 0x%x\n", Formats.uFormats)); 434 rc = VbglR3ClipboardFormatsSend(&pCtx->CmdCtx, &Formats); 433 435 } 434 436 } … … 452 454 /* Clipboard was updated by another application. */ 453 455 /* WM_DRAWCLIPBOARD always expects a return code of 0, so don't change "rc" here. */ 454 VBOXCLIPBOARDFORMATS fFormats;455 int rc = VBoxClipboardWinGetFormats(pWinCtx, & fFormats);456 SHAREDCLIPBOARDFORMATDATA Formats; 457 int rc = VBoxClipboardWinGetFormats(pWinCtx, &Formats); 456 458 if (RT_SUCCESS(rc)) 457 rc = VbglR3Clipboard ReportFormats(pCtx->CmdCtx.uClientID, fFormats);459 rc = VbglR3ClipboardFormatsSend(&pCtx->CmdCtx, &Formats); 458 460 } 459 461 … … 641 643 642 644 /* Announce available formats. Do not insert data -- will be inserted in WM_RENDERFORMAT. */ 643 VBOXCLIPBOARDFORMATS fFormats = (uint32_t)lParam; 645 PVBGLR3CLIPBOARDEVENT pEvent = (PVBGLR3CLIPBOARDEVENT)lParam; 646 AssertPtr(pEvent); 647 Assert(pEvent->enmType == VBGLR3CLIPBOARDEVENTTYPE_REPORT_FORMATS); 648 649 const VBOXCLIPBOARDFORMATS fFormats = pEvent->u.ReportFormats.uFormats; 650 644 651 if (fFormats != VBOX_SHARED_CLIPBOARD_FMT_NONE) /* Could arrive with some older GA versions. */ 645 652 { … … 687 694 { 688 695 /* Send data in the specified format to the host. */ 689 VBOXCLIPBOARDFORMAT uFormat = (uint32_t)lParam; 696 PVBGLR3CLIPBOARDEVENT pEvent = (PVBGLR3CLIPBOARDEVENT)lParam; 697 AssertPtr(pEvent); 698 Assert(pEvent->enmType == VBGLR3CLIPBOARDEVENTTYPE_READ_DATA); 699 700 const VBOXCLIPBOARDFORMAT uFormat = (uint32_t)pEvent->u.ReadData.uFmt; 701 690 702 HANDLE hClip = NULL; 691 703 … … 703 715 if (lp != NULL) 704 716 { 705 rc = VbglR3ClipboardWriteData(pCtx->CmdCtx.uClientID, VBOX_SHARED_CLIPBOARD_FMT_BITMAP, 706 lp, GlobalSize(hClip)); 717 SHAREDCLIPBOARDDATABLOCK dataBlock = { uFormat, lp, (uint32_t)GlobalSize(hClip) }; 718 719 rc = VbglR3ClipboardWriteDataEx(&pEvent->cmdCtx, &dataBlock); 720 707 721 GlobalUnlock(hClip); 708 722 } … … 721 735 if (uniString != NULL) 722 736 { 723 rc = VbglR3ClipboardWriteData(pCtx->CmdCtx.uClientID, VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT, 724 uniString, (lstrlenW(uniString) + 1) * 2); 737 SHAREDCLIPBOARDDATABLOCK dataBlock = { uFormat, uniString, ((uint32_t)lstrlenW(uniString) + 1) * 2 }; 738 739 rc = VbglR3ClipboardWriteDataEx(&pEvent->cmdCtx, &dataBlock); 740 725 741 GlobalUnlock(hClip); 726 742 } … … 743 759 if (lp != NULL) 744 760 { 745 rc = VbglR3ClipboardWriteData(pCtx->CmdCtx.uClientID, VBOX_SHARED_CLIPBOARD_FMT_HTML, 746 lp, GlobalSize(hClip)); 761 SHAREDCLIPBOARDDATABLOCK dataBlock = { uFormat, lp, (uint32_t)GlobalSize(hClip) }; 762 763 rc = VbglR3ClipboardWriteDataEx(&pEvent->cmdCtx, &dataBlock); 764 747 765 GlobalUnlock(hClip); 748 766 } … … 754 772 } 755 773 } 774 #ifdef VBOX_WITH_SHARED_CLIPBOARD_URI_LIST 775 else if (uFormat == VBOX_SHARED_CLIPBOARD_FMT_URI_LIST) 776 { 777 LogFunc(("cTransfersRunning=%RU32\n", SharedClipboardURICtxGetRunningTransfers(&pCtx->URI))); 778 779 int rc = VBoxClipboardWinOpen(hwnd); 780 if (RT_SUCCESS(rc)) 781 { 782 PSHAREDCLIPBOARDURITRANSFER pTransfer; 783 rc = SharedClipboardURITransferCreate(SHAREDCLIPBOARDURITRANSFERDIR_WRITE, 784 SHAREDCLIPBOARDSOURCE_LOCAL, 785 &pTransfer); 786 if (RT_SUCCESS(rc)) 787 { 788 rc = SharedClipboardURICtxTransferAdd(&pCtx->URI, pTransfer); 789 if (RT_SUCCESS(rc)) 790 { 791 /* The data data in CF_HDROP format, as the files are locally present and don't need to be 792 * presented as a IDataObject or IStream. */ 793 HANDLE hClip = hClip = GetClipboardData(CF_HDROP); 794 if (hClip) 795 { 796 HDROP hDrop = (HDROP)GlobalLock(hClip); 797 if (hDrop) 798 { 799 char *papszList; 800 uint32_t cbList; 801 rc = VBoxClipboardWinDropFilesToStringList((DROPFILES *)hDrop, &papszList, &cbList); 802 803 GlobalUnlock(hClip); 804 805 if (RT_SUCCESS(rc)) 806 { 807 rc = SharedClipboardURILTransferSetRoots(pTransfer, 808 papszList, cbList + 1 /* Include termination */); 809 if (RT_SUCCESS(rc)) 810 { 811 PVBOXCLIPBOARDURIWRITETHREADCTX pThreadCtx 812 = (PVBOXCLIPBOARDURIWRITETHREADCTX)RTMemAllocZ(sizeof(VBOXCLIPBOARDURIWRITETHREADCTX)); 813 if (pThreadCtx) 814 { 815 pThreadCtx->pClipboardCtx = pCtx; 816 pThreadCtx->pTransfer = pTransfer; 817 818 rc = SharedClipboardURITransferPrepare(pTransfer); 819 if (RT_SUCCESS(rc)) 820 { 821 rc = SharedClipboardURITransferRun(pTransfer, vboxClipboardURIWriteThread, 822 pThreadCtx /* pvUser */); 823 /* pThreadCtx now is owned by vboxClipboardURIWriteThread(). */ 824 } 825 } 826 else 827 rc = VERR_NO_MEMORY; 828 } 829 830 if (papszList) 831 RTStrFree(papszList); 832 } 833 } 834 else 835 { 836 hClip = NULL; 837 } 838 } 839 } 840 } 841 842 VBoxClipboardWinClose(); 843 } 844 845 if (RT_FAILURE(rc)) 846 LogFunc(("Failed with rc=%Rrc\n", rc)); 847 } 848 #endif 756 849 757 850 if (hClip == NULL) … … 771 864 } 772 865 773 #if def VBOX_WITH_SHARED_CLIPBOARD_URI_LIST866 #if 0 774 867 /* The host wants to read URI data. */ 775 868 case VBOX_CLIPBOARD_WM_URI_START_READ: … … 1055 1148 /* ignore rc */ VBoxClipboardWinCheckAndInitNewAPI(&pCtx->Win.newAPI); 1056 1149 1057 rc = VbglR3ClipboardConnect (&pCtx->CmdCtx.uClientID);1150 rc = VbglR3ClipboardConnectEx(&pCtx->CmdCtx); 1058 1151 if (RT_SUCCESS(rc)) 1059 1152 { 1060 pCtx->CmdCtx.uProtocol = 0;1061 1062 1153 rc = vboxClipboardCreateWindow(pCtx); 1063 1154 if (RT_SUCCESS(rc)) … … 1071 1162 else 1072 1163 { 1073 VbglR3ClipboardDisconnect (pCtx->CmdCtx.uClientID);1164 VbglR3ClipboardDisconnectEx(&pCtx->CmdCtx); 1074 1165 } 1075 1166 } … … 1098 1189 int rc; 1099 1190 1191 LogFlowFunc(("Using protocol %RU32\n", pCtx->CmdCtx.uProtocolVer)); 1192 1193 uint32_t uMsg; 1194 uint32_t uFormats; 1195 1100 1196 /* The thread waits for incoming messages from the host. */ 1101 1197 for (;;) 1102 1198 { 1103 LogFlowFunc(("Waiting for host message ...\n")); 1104 1105 uint32_t u32Msg; 1106 uint32_t u32Formats; 1107 rc = VbglR3ClipboardGetHostMsgOld(pCtx->CmdCtx.uClientID, &u32Msg, &u32Formats); 1199 PVBGLR3CLIPBOARDEVENT pEvent = NULL; 1200 1201 LogFlowFunc(("Waiting for host message (protocol v%RU32) ...\n", pCtx->CmdCtx.uProtocolVer)); 1202 1203 if (pCtx->CmdCtx.uProtocolVer == 0) /* Legacy protocol */ 1204 { 1205 rc = VbglR3ClipboardGetHostMsgOld(pCtx->CmdCtx.uClientID, &uMsg, &uFormats); 1206 if (RT_FAILURE(rc)) 1207 { 1208 if (rc == VERR_INTERRUPTED) 1209 break; 1210 1211 LogFunc(("Error getting host message, rc=%Rrc\n", rc)); 1212 } 1213 else 1214 { 1215 PVBGLR3CLIPBOARDEVENT pEvent = (PVBGLR3CLIPBOARDEVENT)RTMemAllocZ(sizeof(VBGLR3CLIPBOARDEVENT)); 1216 if (!pEvent) 1217 { 1218 rc = VERR_NO_MEMORY; 1219 break; 1220 } 1221 1222 switch (uMsg) 1223 { 1224 case VBOX_SHARED_CLIPBOARD_HOST_MSG_FORMATS_WRITE: 1225 { 1226 pEvent->enmType = VBGLR3CLIPBOARDEVENTTYPE_REPORT_FORMATS; 1227 pEvent->u.ReportFormats.uFormats = uFormats; 1228 break; 1229 } 1230 1231 case VBOX_SHARED_CLIPBOARD_HOST_MSG_READ_DATA: 1232 { 1233 pEvent->enmType = VBGLR3CLIPBOARDEVENTTYPE_READ_DATA; 1234 pEvent->u.ReadData.uFmt = uFormats; 1235 break; 1236 } 1237 1238 default: 1239 rc = VERR_NOT_SUPPORTED; 1240 break; 1241 } 1242 } 1243 } 1244 else /* Protocol >= v1. */ 1245 { 1246 rc = VbglR3ClipboardEventGetNext(&pCtx->CmdCtx, &pEvent); 1247 } 1248 1108 1249 if (RT_FAILURE(rc)) 1109 1250 { 1110 if (rc == VERR_INTERRUPTED)1111 break;1112 1113 LogFunc(("Error getting host message, rc=%Rrc\n", rc));1114 1115 1251 if (*pfShutdown) 1116 1252 break; … … 1122 1258 else 1123 1259 { 1124 LogFlowFunc(("u32Msg=%RU32, u32Formats=0x%x\n", u32Msg, u32Formats)); 1125 switch (u32Msg) 1260 AssertPtr(pEvent); 1261 LogFlowFunc(("Event uType=%RU32\n", pEvent->enmType)); 1262 1263 switch (pEvent->enmType) 1126 1264 { 1127 case VBOX_SHARED_CLIPBOARD_HOST_MSG_REPORT_FORMATS: 1128 { 1129 LogFlowFunc(("VBOX_SHARED_CLIPBOARD_HOST_MSG_REPORT_FORMATS\n")); 1130 1265 case VBGLR3CLIPBOARDEVENTTYPE_REPORT_FORMATS: 1266 { 1131 1267 /* The host has announced available clipboard formats. 1132 1268 * Forward the information to the window, so it can later 1133 1269 * respond to WM_RENDERFORMAT message. */ 1134 ::PostMessage(pWinCtx->hWnd, VBOX_CLIPBOARD_WM_REPORT_FORMATS, 0, u32Formats); 1270 ::PostMessage(pWinCtx->hWnd, VBOX_CLIPBOARD_WM_REPORT_FORMATS, 1271 0 /* wParam */, (LPARAM)pEvent /* lParam */); 1135 1272 break; 1136 1273 } 1137 1274 1138 case VBOX_SHARED_CLIPBOARD_HOST_MSG_READ_DATA: 1139 { 1140 LogFlowFunc(("VBOX_SHARED_CLIPBOARD_HOST_MSG_READ_DATA\n")); 1141 1275 case VBGLR3CLIPBOARDEVENTTYPE_READ_DATA: 1276 { 1142 1277 /* The host needs data in the specified format. */ 1143 ::PostMessage(pWinCtx->hWnd, VBOX_CLIPBOARD_WM_READ_DATA, 0, u32Formats); 1278 ::PostMessage(pWinCtx->hWnd, VBOX_CLIPBOARD_WM_READ_DATA, 1279 0 /* wParam */, (LPARAM)pEvent /* lParam */); 1144 1280 break; 1145 1281 } 1146 1147 #ifdef VBOX_WITH_SHARED_CLIPBOARD_URI_LIST 1282 #if 0 1148 1283 case VBOX_SHARED_CLIPBOARD_HOST_MSG_URI_TRANSFER_START: 1149 1284 { 1150 LogFlowFunc(("VBOX_SHARED_CLIPBOARD_HOST_MSG_URI_TRANSFER_START\n"));1151 1152 1285 const UINT uMsg = u32Formats == 0 ? 1153 1286 VBOX_CLIPBOARD_WM_URI_START_READ : VBOX_CLIPBOARD_WM_URI_START_WRITE; … … 1157 1290 } 1158 1291 #endif 1159 case VBOX_SHARED_CLIPBOARD_HOST_MSG_QUIT: 1160 { 1161 LogFlowFunc(("VBOX_SHARED_CLIPBOARD_HOST_MSG_QUIT\n")); 1162 1292 case VBGLR3CLIPBOARDEVENTTYPE_QUIT: 1293 { 1163 1294 /* The host is terminating. */ 1164 1295 LogRel(("Clipboard: Terminating ...\n")); … … 1169 1300 default: 1170 1301 { 1171 LogFlowFunc(("Unsupported message from host, message=%RU32\n", u32Msg));1172 1173 1302 /* Wait a bit before retrying. */ 1174 1303 RTThreadSleep(1000); … … 1176 1305 } 1177 1306 } 1307 1308 if (RT_FAILURE(rc)) 1309 VbglR3ClipboardEventFree(pEvent); 1178 1310 } 1179 1311
Note:
See TracChangeset
for help on using the changeset viewer.