VirtualBox

Ignore:
Timestamp:
Nov 23, 2020 11:25:53 AM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
141479
Message:

Shared Clipboard: Convert VBox clipboard formats to strings to improve logging.

Location:
trunk/src/VBox/GuestHost/SharedClipboard
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/GuestHost/SharedClipboard/clipboard-common.cpp

    r86889 r86959  
    11281128    return "Unknown";
    11291129}
     1130
     1131/**
     1132 * Converts Shared Clipboard formats to a string.
     1133 *
     1134 * @returns Stringified Shared Clipboard formats, or NULL on failure. Must be free'd with RTStrFree().
     1135 * @param   fFormats            Shared Clipboard formats to convert.
     1136 *
     1137 */
     1138char *ShClFormatsToStrA(SHCLFORMATS fFormats)
     1139{
     1140#define APPEND_FMT_TO_STR(_aFmt)                \
     1141    if (fFormats & VBOX_SHCL_FMT_##_aFmt)       \
     1142    {                                           \
     1143        if (pszFmts)                            \
     1144        {                                       \
     1145            rc2 = RTStrAAppend(&pszFmts, ", "); \
     1146            if (RT_FAILURE(rc2))                \
     1147                break;                          \
     1148        }                                       \
     1149                                                \
     1150        rc2 = RTStrAAppend(&pszFmts, #_aFmt);   \
     1151        if (RT_FAILURE(rc2))                    \
     1152            break;                              \
     1153    }
     1154
     1155    char *pszFmts = NULL;
     1156    int rc2 = VINF_SUCCESS;
     1157
     1158    do
     1159    {
     1160        APPEND_FMT_TO_STR(UNICODETEXT);
     1161        APPEND_FMT_TO_STR(BITMAP);
     1162        APPEND_FMT_TO_STR(HTML);
     1163# ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS
     1164        APPEND_FMT_TO_STR(URI_LIST);
     1165# endif
     1166
     1167    } while (0);
     1168
     1169    if (!pszFmts)
     1170        rc2 = RTStrAAppend(&pszFmts, "NONE");
     1171
     1172    if (   RT_FAILURE(rc2)
     1173        && pszFmts)
     1174    {
     1175        RTStrFree(pszFmts);
     1176        pszFmts = NULL;
     1177    }
     1178
     1179#undef APPEND_FMT_TO_STR
     1180
     1181    return pszFmts;
     1182}
     1183
  • trunk/src/VBox/GuestHost/SharedClipboard/clipboard-x11.cpp

    r86737 r86959  
    4848#include <X11/StringDefs.h>
    4949
     50#include <iprt/assert.h>
    5051#include <iprt/types.h>
    5152#include <iprt/mem.h>
     
    444445    LogFlow((" -> vboxFmt=%#x\n", vboxFmt));
    445446
    446     LogRel2(("Shared Clipboard: X11 reported available VBox formats: %#x\n", vboxFmt));
     447#ifdef LOG_ENABLED
     448    char *pszFmts = ShClFormatsToStrA(vboxFmt);
     449    AssertPtrReturnVoid(pszFmts);
     450    LogRel2(("Shared Clipboard: X11 reported available VBox formats '%s'\n", pszFmts));
     451    RTStrFree(pszFmts);
     452#endif
    447453
    448454    ShClX11ReportFormatsCallback(pCtx->pFrontend, vboxFmt);
     
    15851591                 pCtx->vboxFormats, idxFmtX11, g_aFormats[idxFmtX11].pcszAtom, fmtX11));
    15861592
    1587     LogRel2(("Shared Clipboard: Converting VBox formats %#x to '%s' for X11\n",
    1588              pCtx->vboxFormats, g_aFormats[idxFmtX11].pcszAtom));
     1593#ifdef LOG_ENABLED
     1594    char *pszFmts = ShClFormatsToStrA(pCtx->vboxFormats);
     1595    AssertPtrReturn(pszFmts, VERR_NO_MEMORY);
     1596    LogRel2(("Shared Clipboard: Converting VBox formats '%s' to '%s' for X11\n",
     1597             pszFmts, g_aFormats[idxFmtX11].pcszAtom));
     1598    RTStrFree(pszFmts);
     1599#endif
    15891600
    15901601    if (   ((fmtX11 == SHCLX11FMT_UTF8) || (fmtX11 == SHCLX11FMT_TEXT))
     
    16961707
    16971708    if (RT_FAILURE(rc))
    1698         LogRel(("Shared Clipboard: Converting VBox formats %#x to '%s' for X11 (idxFmtX11=%u, fmtX11=%u) failed, rc=%Rrc\n",
    1699                 pCtx->vboxFormats, g_aFormats[idxFmtX11].pcszAtom, idxFmtX11, fmtX11, rc));
     1709    {
     1710        char *pszFmts2 = ShClFormatsToStrA(pCtx->vboxFormats);
     1711        AssertPtrReturn(pszFmts2, VERR_NO_MEMORY);
     1712        LogRel(("Shared Clipboard: Converting VBox formats '%s' to '%s' for X11 (idxFmtX11=%u, fmtX11=%u) failed, rc=%Rrc\n",
     1713                pszFmts2, g_aFormats[idxFmtX11].pcszAtom, idxFmtX11, fmtX11, rc));
     1714        RTStrFree(pszFmts2);
     1715    }
    17001716
    17011717    LogFlowFuncLeaveRC(rc);
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