VirtualBox

Ignore:
Timestamp:
May 7, 2019 5:44:31 PM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
130440
Message:

Shared Clipboard/URI: Update.

Location:
trunk/src/VBox/Additions/WINNT/VBoxTray
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/WINNT/VBoxTray/Makefile.kmk

    r78307 r78440  
    5252        VBoxClipboard.cpp \
    5353        $(PATH_ROOT)/src/VBox/GuestHost/SharedClipboard/clipboard-win.cpp
     54 ifdef VBOX_WITH_SHARED_CLIPBOARD_URI_LIST
     55 VBoxTray_SOURCES  += \
     56        $(PATH_ROOT)/src/VBox/GuestHost/SharedClipboard/ClipboardURIList.cpp \
     57        $(PATH_ROOT)/src/VBox/GuestHost/SharedClipboard/ClipboardURIObject.cpp \
     58        $(PATH_ROOT)/src/VBox/GuestHost/SharedClipboard/ClipboardPath.cpp \
     59        $(PATH_ROOT)/src/VBox/GuestHost/SharedClipboard/ClipboardDataObjectImpl-win.cpp \
     60        $(PATH_ROOT)/src/VBox/GuestHost/SharedClipboard/ClipboardEnumFormatEtcImpl-win.cpp \
     61        $(PATH_ROOT)/src/VBox/GuestHost/SharedClipboard/ClipboardStreamImpl-win.cpp
     62 endif
    5463endif
    5564ifdef VBOX_WITH_DRAG_AND_DROP
  • trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxClipboard.cpp

    r78317 r78440  
    174174        {
    175175           /* Insert the requested clipboard format data into the clipboard. */
    176            uint32_t u32Format = 0;
    177            UINT format = (UINT)wParam;
    178 
    179            LogFlowFunc(("WM_RENDERFORMAT, format = %x\n", format));
    180            switch (format)
     176           uint32_t fFormat = VBOX_SHARED_CLIPBOARD_FMT_NONE;
     177
     178           const UINT cfFormat = (UINT)wParam;
     179           switch (cfFormat)
    181180           {
    182181              case CF_UNICODETEXT:
    183                   u32Format |= VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT;
     182                  fFormat = VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT;
    184183                  break;
    185184
    186185              case CF_DIB:
    187                   u32Format |= VBOX_SHARED_CLIPBOARD_FMT_BITMAP;
     186                  fFormat = VBOX_SHARED_CLIPBOARD_FMT_BITMAP;
    188187                  break;
    189188
     189#ifdef VBOX_WITH_SHARED_CLIPBOARD_URI_LIST
     190              case CF_HDROP:
     191                  fFormat = VBOX_SHARED_CLIPBOARD_FMT_URI_LIST;
     192                  break;
     193#endif
    190194              default:
    191                   if (format >= 0xC000)
     195                  if (cfFormat >= 0xC000) /** @todo r=andy Explain. */
    192196                  {
    193                       TCHAR szFormatName[256];
    194 
    195                       int cActual = GetClipboardFormatName(format, szFormatName, sizeof(szFormatName) / sizeof(TCHAR));
     197                      TCHAR szFormatName[256]; /** @todo r=andy Do we need Unicode support here as well? */
     198
     199                      int cActual = GetClipboardFormatName(cfFormat, szFormatName, sizeof(szFormatName) / sizeof(TCHAR));
    196200                      if (cActual)
    197201                      {
    198202                          if (strcmp(szFormatName, "HTML Format") == 0)
    199                           {
    200                               u32Format |= VBOX_SHARED_CLIPBOARD_FMT_HTML;
    201                           }
     203                              fFormat = VBOX_SHARED_CLIPBOARD_FMT_HTML;
    202204                      }
    203205                  }
     
    205207           }
    206208
    207            if (u32Format == 0)
     209           LogFunc(("WM_RENDERFORMAT: format=%u -> fFormat=0x%x\n", cfFormat, fFormat));
     210
     211           if (fFormat == VBOX_SHARED_CLIPBOARD_FMT_NONE)
    208212           {
    209213               /* Unsupported clipboard format is requested. */
    210                LogFlowFunc(("Unsupported clipboard format requested: %ld\n", u32Format));
     214               LogRel(("Clipboard: Unsupported clipboard format requested (0x%x)\n", fFormat));
    211215               VBoxClipboardWinClear();
    212216           }
     217#ifdef VBOX_WITH_SHARED_CLIPBOARD_URI_LIST
     218           else if (fFormat == VBOX_SHARED_CLIPBOARD_FMT_URI_LIST)
     219           {
     220
     221           }
     222#endif
    213223           else
    214224           {
    215                const uint32_t cbPrealloc = 4096; /** @todo r=andy Make it dynamic for supporting larger text buffers! */
     225               const uint32_t cbPrealloc = _4K;
    216226               uint32_t cb = 0;
    217227
     
    228238                   {
    229239                       /* Read the host data to the preallocated buffer. */
    230                        int vboxrc = VbglR3ClipboardReadData(pCtx->u32ClientID, u32Format, pMem, cbPrealloc, &cb);
     240                       int vboxrc = VbglR3ClipboardReadData(pCtx->u32ClientID, fFormat, pMem, cbPrealloc, &cb);
    231241                       LogFlowFunc(("VbglR3ClipboardReadData returned with rc = %Rrc\n",  vboxrc));
    232242
     
    259269                                       /* Read the host data to the preallocated buffer. */
    260270                                       uint32_t cbNew = 0;
    261                                        vboxrc = VbglR3ClipboardReadData(pCtx->u32ClientID, u32Format, pMem, cb, &cbNew);
     271                                       vboxrc = VbglR3ClipboardReadData(pCtx->u32ClientID, fFormat, pMem, cb, &cbNew);
    262272                                       LogFlowFunc(("VbglR3ClipboardReadData returned with rc = %Rrc, cb = %d, cbNew = %d\n", vboxrc, cb, cbNew));
    263273
     
    287297                                * must have the exact string size.
    288298                                */
    289                                if (u32Format == VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT)
     299                               if (fFormat == VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT)
    290300                               {
    291301                                   size_t cbActual = 0;
     
    319329                                   /* 'hMem' contains the host clipboard data.
    320330                                    * size is 'cb' and format is 'format'. */
    321                                    HANDLE hClip = SetClipboardData(format, hMem);
     331                                   HANDLE hClip = SetClipboardData(cfFormat, hMem);
    322332                                   LogFlowFunc(("WM_RENDERFORMAT hClip = %p\n", hClip));
    323333
     
    362372        {
    363373           /* Announce available formats. Do not insert data, they will be inserted in WM_RENDER*. */
    364            uint32_t u32Formats = (uint32_t)lParam;
    365 
    366            LogFlowFunc(("VBOX_WM_SHCLPB_SET_FORMATS: u32Formats=0x%x\n", u32Formats));
     374           VBOXCLIPBOARDFORMATS fFormats = (uint32_t)lParam;
     375
     376           LogFlowFunc(("VBOX_WM_SHCLPB_SET_FORMATS: fFormats=0x%x\n", fFormats));
    367377
    368378           int vboxrc = VBoxClipboardWinOpen(hwnd);
     
    373383               HANDLE hClip = NULL;
    374384
    375                if (u32Formats & VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT)
     385               if (fFormats & VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT)
    376386                   hClip = SetClipboardData(CF_UNICODETEXT, NULL);
    377387
    378                if (u32Formats & VBOX_SHARED_CLIPBOARD_FMT_BITMAP)
     388               if (fFormats & VBOX_SHARED_CLIPBOARD_FMT_BITMAP)
    379389                   hClip = SetClipboardData(CF_DIB, NULL);
    380390
    381                if (u32Formats & VBOX_SHARED_CLIPBOARD_FMT_HTML)
     391               if (fFormats & VBOX_SHARED_CLIPBOARD_FMT_HTML)
    382392               {
    383393                   UINT format = RegisterClipboardFormat("HTML Format");
     
    387397
    388398#ifdef VBOX_WITH_SHARED_CLIPBOARD_URI_LIST
    389                if (u32Formats & VBOX_SHARED_CLIPBOARD_FMT_URI_LIST)
     399               if (fFormats & VBOX_SHARED_CLIPBOARD_FMT_URI_LIST)
    390400                   hClip = SetClipboardData(CF_HDROP, NULL);
    391401#endif
     402
     403               /** @todo Implement more flexible clipboard precedence for supported formats. */
     404
     405               if (hClip == NULL)
     406                   LogRel(("Clipboard: Unsupported format(s) from host (0x%x), ignoring\n", fFormats));
     407
    392408               VBoxClipboardWinClose();
    393409
     
    479495                       if (hDrop)
    480496                       {
    481                            vboxrc = VbglR3ClipboardWriteData(pCtx->u32ClientID, VBOX_SHARED_CLIPBOARD_FMT_URI_LIST,
    482                                                              );
     497       /*                    vboxrc = VbglR3ClipboardWriteData(pCtx->u32ClientID, VBOX_SHARED_CLIPBOARD_FMT_URI_LIST,
     498                                                             );*/
    483499                           GlobalUnlock(hClip);
    484500                       }
     
    681697                break;
    682698
    683             LogFlowFunc(("Error getting host message, rc=%Rrc\n", rc));
     699            LogFunc(("Error getting host message, rc=%Rrc\n", rc));
    684700
    685701            if (*pfShutdown)
     
    701717                    * respond to WM_RENDERFORMAT message. */
    702718                   ::PostMessage(pWinCtx->hWnd, VBOX_CLIPBOARD_WM_SET_FORMATS, 0, u32Formats);
    703                }
    704719                   break;
     720               }
    705721
    706722               case VBOX_SHARED_CLIPBOARD_HOST_MSG_READ_DATA:
     
    708724                   /* The host needs data in the specified format. */
    709725                   ::PostMessage(pWinCtx->hWnd, VBOX_CLIPBOARD_WM_READ_DATA, 0, u32Formats);
    710                }
    711726                   break;
     727               }
    712728
    713729               case VBOX_SHARED_CLIPBOARD_HOST_MSG_QUIT:
     
    716732                   LogRel(("Clipboard: Terminating ...\n"));
    717733                   ASMAtomicXchgBool(pfShutdown, true);
    718                }
    719734                   break;
     735               }
    720736
    721737               default:
     
    725741                   /* Wait a bit before retrying. */
    726742                   RTThreadSleep(1000);
    727                }
    728743                   break;
     744               }
    729745            }
    730746        }
Note: See TracChangeset for help on using the changeset viewer.

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