VirtualBox

Changeset 3895 in vbox


Ignore:
Timestamp:
Jul 27, 2007 7:17:56 AM (17 years ago)
Author:
vboxsync
Message:

Removed support for Latin1 from the Linux clipboard code, except as a fallback for bad Utf8. Plain text now means Utf8.

Location:
trunk/src/VBox
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/linux/xclient/clipboard.cpp

    r3332 r3895  
    2626#define USE_UTF8
    2727#define USE_CTEXT
    28 #define USE_LATIN1
    2928
    3029#define LOG_GROUP LOG_GROUP_HGCM
     
    8180    INVALID = 0,
    8281    TARGETS,
    83     LATIN1,
    8482    CTEXT,
    8583    UTF8,
     
    660658        break;
    661659    case UTF8:
    662     case LATIN1:
    663660    {
    664661        /* If we are given broken Utf-8, we treat it as Latin1.  Is this acceptable? */
     
    12421239    *pcLenReturn = property.nitems;
    12431240    *piFormatReturn = property.format;
    1244     LogFlowFunc(("rc = true\n"));
    1245     return true;
    1246 }
    1247 
    1248 /**
    1249  * Satisfy a request from the guest to convert the clipboard text to Latin1.
    1250  *
    1251  * @returns true if we successfully convert the data to the format requested, false otherwise.
    1252  *
    1253  * @param atomTypeReturn The type of the data we are returning
    1254  * @param pValReturn     A pointer to the data we are returning.  This should be to memory
    1255  *                       allocated by XtMalloc, which will be freed by the toolkit later
    1256  * @param pcLenReturn    The length of the data we are returning
    1257  * @param piFormatReturn The format (8bit, 16bit, 32bit) of the data we are returning
    1258  */
    1259 static Boolean vboxClipboardConvertLatin1(Atom *atomTypeReturn, XtPointer *pValReturn,
    1260                                           unsigned long *pcLenReturn, int *piFormatReturn)
    1261 {
    1262     enum { LINEFEED = 0xa, CARRIAGERETURN = 0xd };
    1263     PRTUTF16 pu16HostText;
    1264     unsigned cbHostText, cwHostText, cbGuestPos = 0, cbGuestText;
    1265     unsigned char *pcGuestText;
    1266     int rc;
    1267 
    1268     LogFlowFunc(("\n"));
    1269     /* Get the host UTF16 data */
    1270     rc = vboxClipboardReadHostData(VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT,
    1271                                    reinterpret_cast<void **>(&pu16HostText), &cbHostText);
    1272     if ((rc != VINF_SUCCESS) || cbHostText == 0)
    1273     {
    1274         Log (("vboxClipboardConvertUtf16: vboxClipboardReadHostData returned %Vrc, %d bytes of data\n", rc, cbGuestText));
    1275         g_ctx.hostFormats = 0;
    1276         LogFlowFunc(("rc = false\n"));
    1277         return false;
    1278     }
    1279     cwHostText = cbHostText / 2;
    1280     cbGuestText = cwHostText;
    1281     pcGuestText = reinterpret_cast<unsigned char *>(XtMalloc(cbGuestText));
    1282     if (pcGuestText == 0)
    1283     {
    1284         RTMemFree(reinterpret_cast<void *>(pu16HostText));
    1285         LogFlowFunc(("rc = false\n"));
    1286         return false;
    1287     }
    1288     for (unsigned i = 0; i < cwHostText; ++i, ++cbGuestPos)
    1289     {
    1290         if (   (i + 1 < cwHostText)
    1291             && (pu16HostText[i] == CARRIAGERETURN)
    1292             && (pu16HostText[i + 1] == LINEFEED))
    1293             ++i;
    1294         if (pu16HostText[i] < 256)
    1295             pcGuestText[cbGuestPos] = pu16HostText[i];
    1296         else
    1297             /* Any better ideas as to how to do this? */
    1298             pcGuestText[cbGuestPos] = '.';
    1299     }
    1300     Log (("vboxClipboardConvertLatin1: returning Latin-1, original text is %.*ls\n", cwHostText,
    1301           pu16HostText));
    1302     Log (("vboxClipboardConvertLatin1: converted text is %.*s\n", cbGuestPos,
    1303           pcGuestText));
    1304     RTMemFree(reinterpret_cast<void *>(pu16HostText));
    1305     *atomTypeReturn = XA_STRING;
    1306     *pValReturn = reinterpret_cast<XtPointer>(pcGuestText);
    1307     *pcLenReturn = cbGuestPos;
    1308     *piFormatReturn = 8;
    13091241    LogFlowFunc(("rc = true\n"));
    13101242    return true;
     
    13801312    case CTEXT:
    13811313        rc = vboxClipboardConvertCText(atomTypeReturn, pValReturn, pcLenReturn, piFormatReturn);
    1382         LogFlowFunc(("rc=%d\n", rc));
    1383         return rc;
    1384     case LATIN1:
    1385         rc = vboxClipboardConvertLatin1(atomTypeReturn, pValReturn, pcLenReturn, piFormatReturn);
    13861314        LogFlowFunc(("rc=%d\n", rc));
    13871315        return rc;
     
    17201648    vboxClipboardAddFormat("text/plain;charset=utf-8", UTF8,
    17211649                           VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT);
     1650    vboxClipboardAddFormat("STRING", UTF8,
     1651                           VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT);
     1652    vboxClipboardAddFormat("TEXT", UTF8,
     1653                           VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT);
     1654    vboxClipboardAddFormat("text/plain", UTF8,
     1655                           VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT);
    17221656#endif
    17231657#ifdef USE_CTEXT
    17241658    vboxClipboardAddFormat("COMPOUND_TEXT", CTEXT,
    1725                            VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT);
    1726 #endif
    1727 #ifdef USE_LATIN1
    1728     vboxClipboardAddFormat("STRING", LATIN1,
    1729                            VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT);
    1730     vboxClipboardAddFormat("TEXT", LATIN1,
    1731                            VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT);
    1732     vboxClipboardAddFormat("text/plain", LATIN1,
    17331659                           VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT);
    17341660#endif
  • trunk/src/VBox/HostServices/SharedClipboard/linux.cpp

    r3338 r3895  
    2424#define USE_UTF8
    2525#define USE_CTEXT
    26 #define USE_LATIN1
    2726
    2827#include <vector>
     
    5049#include <X11/Xproto.h>
    5150
    52 #define USE_UTF16
    53 #define USE_UTF8
    54 #define USE_CTEXT
    55 #define USE_LATIN1
    56 
    5751/** The different clipboard formats which we support. */
    5852enum g_eClipboardFormats
     
    6054    INVALID = 0,
    6155    TARGETS,
    62     LATIN1,
    6356    CTEXT,
    6457    UTF8,
     
    798791        break;
    799792    case UTF8:
    800     case LATIN1:
    801793    {
    802794        /* If we are given broken Utf-8, we treat it as Latin1.  Is this acceptable? */
     
    1007999    vboxClipboardAddFormat("text/plain;charset=utf-8", UTF8,
    10081000                           VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT);
     1001    vboxClipboardAddFormat("STRING", UTF8,
     1002                           VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT);
     1003    vboxClipboardAddFormat("TEXT", UTF8,
     1004                           VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT);
     1005    vboxClipboardAddFormat("text/plain", UTF8,
     1006                           VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT);
    10091007#endif
    10101008#ifdef USE_CTEXT
    10111009    vboxClipboardAddFormat("COMPOUND_TEXT", CTEXT,
    1012                            VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT);
    1013 #endif
    1014 #ifdef USE_LATIN1
    1015     vboxClipboardAddFormat("STRING", LATIN1,
    1016                            VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT);
    1017     vboxClipboardAddFormat("TEXT", LATIN1,
    1018                            VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT);
    1019     vboxClipboardAddFormat("text/plain", LATIN1,
    10201010                           VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT);
    10211011#endif
     
    13751365    if ((rc != VINF_SUCCESS) || (g_ctx.pClient->data.cb == 0))
    13761366    {
    1377         LogRel (("vboxClipboardConvertUtf8: vboxClipboardReadDataFromClient returned %Vrc, %d bytes of data\n", rc, g_ctx.pClient->data.cb));
     1367        LogRel (("vboxClipboardConvertCText: vboxClipboardReadDataFromClient returned %Vrc, %d bytes of data\n", rc, g_ctx.pClient->data.cb));
    13781368        vboxClipboardEmptyGuestBuffer();
    13791369        return false;
     
    14531443    *pcLenReturn = property.nitems;
    14541444    *piFormatReturn = property.format;
    1455     return true;
    1456 }
    1457 
    1458 
    1459 /**
    1460  * Satisfy a request from the host to convert the clipboard text to Latin1.
    1461  *
    1462  * @returns true if we successfully convert the data to the format requested, false otherwise.
    1463  *
    1464  * @param atomTypeReturn The type of the data we are returning
    1465  * @param pValReturn     A pointer to the data we are returning.  This should be to memory
    1466  *                       allocated by XtMalloc, which will be freed by the toolkit later
    1467  * @param pcLenReturn    The length of the data we are returning
    1468  * @param piFormatReturn The format (8bit, 16bit, 32bit) of the data we are returning
    1469  */
    1470 static Boolean vboxClipboardConvertLatin1(Atom *atomTypeReturn, XtPointer *pValReturn,
    1471                                           unsigned long *pcLenReturn, int *piFormatReturn)
    1472 {
    1473     PRTUTF16 pu16GuestText;
    1474     size_t cwGuestText, cbHostPos = 0;
    1475     unsigned char *pcHostText;
    1476     int rc;
    1477 
    1478     LogFlow (("vboxClipboardConvertLatin1 called\n"));
    1479     rc = vboxClipboardReadDataFromClient(&g_ctx, VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT);
    1480     if (RT_FAILURE(rc) || (g_ctx.pClient->data.cb == 0))
    1481     {
    1482         Log (("vboxClipboardConvertLatin1: vboxClipboardReadDataFromClient returned %Vrc, %d bytes of data\n", rc, g_ctx.pClient->data.cb));
    1483         vboxClipboardEmptyGuestBuffer();
    1484         return false;
    1485     }
    1486     pu16GuestText = reinterpret_cast<PRTUTF16>(g_ctx.pClient->data.pv);
    1487     cwGuestText = g_ctx.pClient->data.cb / 2;
    1488     pcHostText = reinterpret_cast<unsigned char *>(XtMalloc(cwGuestText));
    1489     if (pcHostText == 0)
    1490     {
    1491         vboxClipboardEmptyGuestBuffer();
    1492         return false;
    1493     }
    1494     for (unsigned i = 0; i < cwGuestText; ++i, ++cbHostPos)
    1495     {
    1496         if (   (i + 1 < cwGuestText)
    1497             && (pu16GuestText[i] == CARRIAGERETURN)
    1498             && (pu16GuestText[i + 1] == LINEFEED))
    1499             ++i;
    1500         if (pu16GuestText[i] < 256)
    1501             pcHostText[cbHostPos] = pu16GuestText[i];
    1502         else
    1503             /* Any better ideas as to how to do this? */
    1504             pcHostText[cbHostPos] = '.';
    1505     }
    1506     Log (("vboxClipboardConvertLatin1: returning Latin-1, original text is %.*ls\n", cwGuestText,
    1507           pu16GuestText));
    1508     Log (("vboxClipboardConvertLatin1: converted text is %.*s\n", cbHostPos,
    1509           pcHostText));
    1510     vboxClipboardEmptyGuestBuffer();
    1511     *atomTypeReturn = XA_STRING;
    1512     *pValReturn = reinterpret_cast<XtPointer>(pcHostText);
    1513     *pcLenReturn = cbHostPos;
    1514     *piFormatReturn = 8;
    15151445    return true;
    15161446}
     
    15821512        return vboxClipboardConvertCText(atomTypeReturn, pValReturn, pcLenReturn,
    15831513                                         piFormatReturn);
    1584     case LATIN1:
    1585         return vboxClipboardConvertLatin1(atomTypeReturn, pValReturn, pcLenReturn,
    1586                                           piFormatReturn);
    15871514    default:
    15881515        Log(("vboxClipboardConvertProc: bad format\n"));
Note: See TracChangeset for help on using the changeset viewer.

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