Changeset 3142 in vbox for trunk/src/VBox/Additions/linux/xclient
- Timestamp:
- Jun 18, 2007 2:36:56 PM (18 years ago)
- svn:sync-xref-src-repo-rev:
- 22047
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/linux/xclient/clipboard.cpp
r3126 r3142 1365 1365 void vboxClipboardDisconnect (void) 1366 1366 { 1367 #if 0 1367 1368 VMMDevHGCMDisconnect request; 1369 #endif 1368 1370 LogFlowFunc(("\n")); 1369 1371 1370 1372 AssertReturn(g_ctx.client != 0, (void) 0); 1373 #if 0 1374 /* Currently, disconnecting is not needed, as the new "connect clipboard" 1375 ioctl in the Guest Additions kernel module disconnects the last 1376 connection made automatically. The reason for this change was that 1377 currently only one clipboard connection is allowed, and that if the 1378 client holding that connection was terminated too abruptly, the 1379 information needed to disconnect that connection was lost. If the 1380 subsystem is ever changed to allow several connections, this will have 1381 to be rethought. */ 1371 1382 vmmdevInitRequest((VMMDevRequestHeader*)&request, VMMDevReq_HGCMDisconnect); 1372 1383 request.u32ClientID = g_ctx.client; 1373 1384 ioctl(g_ctx.sendDevice, IOCTL_VBOXGUEST_VMMREQUEST, (void*)&request); 1385 #endif 1374 1386 LogFlowFunc(("returning\n")); 1375 1387 } … … 1403 1415 } 1404 1416 1405 void vboxClipboardSignalHandler(int number)1406 {1407 LogFlowFunc(("number: %d\n", number));1408 vboxClipboardDisconnect();1409 if (g_ctx.daemonise == 0)1410 {1411 cout << "Received signal " << number << ". Aborting" << endl;1412 }1413 LogFlowFunc(("exiting\n"));1414 exit(1);1415 }1416 1417 1417 1418 /** … … 1422 1423 int vboxClipboardConnect (void) 1423 1424 { 1424 VMMDevHGCMConnect request;1425 struct sigaction sSigAction;1426 1427 1425 LogFlowFunc(("\n")); 1428 memset(&request, 0, sizeof(request)); 1429 request.u32ClientID = 0; 1426 int rc; 1430 1427 /* Only one client is supported for now */ 1431 1428 AssertReturn(g_ctx.client == 0, VERR_NOT_SUPPORTED); 1432 1429 1433 vmmdevInitRequest((VMMDevRequestHeader*)&request, VMMDevReq_HGCMConnect); 1434 request.loc.type = VMMDevHGCMLoc_LocalHost_Existing; 1435 strcpy (request.loc.u.host.achName, "VBoxSharedClipboard"); 1436 if (ioctl(g_ctx.sendDevice, IOCTL_VBOXGUEST_VMMREQUEST, (void*)&request) >= 0) 1437 { 1438 if (VBOX_SUCCESS(request.header.header.rc)) 1439 { 1440 if (request.u32ClientID == 0) 1441 { 1442 cout << "We got an invalid client ID of 0!" << endl; 1443 return VERR_NOT_SUPPORTED; 1444 } 1445 g_ctx.client = request.u32ClientID; 1446 g_ctx.eOwner = HOST; 1447 } 1448 else 1449 { 1450 Log(("Error connecting to host. header.rc = %Vrc\n", request.header.header.rc)); 1451 cout << "Unable to connect to the host system." << endl; 1452 LogFlowFunc(("returned VERR_NOT_SUPPORTED\n")); 1430 rc = ioctl(g_ctx.sendDevice, IOCTL_VBOXGUEST_CLIPBOARD_CONNECT, (void*)&g_ctx.client); 1431 if (rc >= 0) 1432 { 1433 if (g_ctx.client == 0) 1434 { 1435 cout << "We got an invalid client ID of 0!" << endl; 1453 1436 return VERR_NOT_SUPPORTED; 1454 1437 } 1455 1438 g_ctx.eOwner = HOST; 1456 1439 } 1457 1440 else 1458 1441 { 1459 Log(("Error performing VMM request ioctl. errno = %d\n", errno));1460 cout << " The VirtualBox device in the guest is not responding correctly." << endl;1442 Log(("Error connecting to host. rc = %d (%s)\n", rc, strerror(-rc))); 1443 cout << "Unable to connect to the host system." << endl; 1461 1444 LogFlowFunc(("returned VERR_NOT_SUPPORTED\n")); 1462 1445 return VERR_NOT_SUPPORTED; 1463 1446 } 1464 /* If the programme exits without disconnecting from the shared clipboard service, we 1465 will need to reboot the guest in order to use it again. So we set handlers for as 1466 many fatal conditions as possible which disconnect and exit the programme. */ 1447 /* Set an X11 error handler, so that we don't die when we get BadAtom errors. */ 1467 1448 XSetErrorHandler(vboxClipboardXLibErrorHandler); 1468 sSigAction.sa_handler = vboxClipboardSignalHandler;1469 sigemptyset(&sSigAction.sa_mask);1470 sSigAction.sa_flags = 0;1471 sigaction(SIGSEGV, &sSigAction, 0);1472 sigaction(SIGBUS, &sSigAction, 0);1473 sigaction(SIGUSR1, &sSigAction, 0);1474 sigaction(SIGINT, &sSigAction, 0);1475 sigaction(SIGQUIT, &sSigAction, 0);1476 sigaction(SIGTERM, &sSigAction, 0);1477 sigaction(SIGTRAP, &sSigAction, 0);1478 1449 LogFlowFunc(("returned VINF_SUCCESS\n")); 1479 1450 return VINF_SUCCESS;
Note:
See TracChangeset
for help on using the changeset viewer.