儲存庫 vbox 的更動 62770
- 時間撮記:
- 2016-7-31 下午05:10:35 (8 年 以前)
- 位置:
- trunk/src/VBox/Main/cbinding
- 檔案:
-
- 修改 3 筆資料
圖例:
- 未更動
- 新增
- 刪除
-
trunk/src/VBox/Main/cbinding/VBoxCAPI.cpp
r60063 r62770 69 69 VBoxUtf8ToUtf16(const char *pszString, BSTR *ppwszString) 70 70 { 71 *ppwszString = NULL; 71 72 if (!pszString) 72 {73 *ppwszString = NULL;74 73 return VINF_SUCCESS; 75 }76 74 #ifdef VBOX_WITH_XPCOM 77 75 return RTStrToUtf16(pszString, ppwszString); … … 79 77 PRTUTF16 pwsz; 80 78 int vrc = RTStrToUtf16(pszString, &pwsz); 81 *ppwszString = ::SysAllocString(pwsz); 82 RTUtf16Free(pwsz); 79 if (RT_SUCCESS(vrc)) 80 { 81 *ppwszString = ::SysAllocString(pwsz); 82 if (!*ppwszString) 83 vrc = VERR_NO_STR_MEMORY; 84 RTUtf16Free(pwsz); 85 } 83 86 return vrc; 84 87 #endif /* !VBOX_WITH_XPCOM */ … … 102 105 #ifdef VBOX_WITH_XPCOM 103 106 RTUtf16Free(pwszString); 104 #else /* !VBOX_WITH_XPCOM */107 #else 105 108 ::SysFreeString(pwszString); 106 #endif /* !VBOX_WITH_XPCOM */109 #endif 107 110 } 108 111 … … 120 123 #ifdef VBOX_WITH_XPCOM 121 124 nsMemory::Free(pwsz); 122 #else /* !VBOX_WITH_XPCOM */125 #else 123 126 ::SysFreeString(pwsz); 124 #endif /* !VBOX_WITH_XPCOM */127 #endif 125 128 } 126 129 } … … 254 257 #ifndef VBOX_WITH_XPCOM 255 258 SafeArrayUnaccessData(psa); 256 #endif /* !VBOX_WITH_XPCOM */259 #endif 257 260 return S_OK; 258 261 } … … 317 320 #ifndef VBOX_WITH_XPCOM 318 321 SafeArrayUnaccessData(psa); 319 #endif /* !VBOX_WITH_XPCOM */322 #endif 320 323 return S_OK; 321 324 } -
trunk/src/VBox/Main/cbinding/capiidl.xsl
r62486 r62770 96 96 97 97 #ifdef _WIN32 98 # pragma warning(push) 99 # pragma warning(disable:4668 4255) /* -Wall and windows.h */ 98 100 # undef COBJMACROS 99 101 # define COBJMACROS 100 102 # include "Windows.h" 103 # pragma warning(pop) 101 104 #endif /* _WIN32 */ 102 105 -
trunk/src/VBox/Main/cbinding/tstCAPIGlue.c
r62485 r62770 32 32 # include <unistd.h> 33 33 # include <sys/poll.h> 34 #endif 35 #ifdef ___iprt_cdefs_h 36 # error "not supposed to involve any IPRT or VBox headers here." 34 37 #endif 35 38 … … 432 435 * @param virtualBox ptr to IVirtualBox object 433 436 * @param session ptr to ISession object 434 * @param id identifies the machine to start435 437 */ 436 static void registerActiveEventListener(IVirtualBox *virtualBox, ISession *session , BSTR machineId)438 static void registerActiveEventListener(IVirtualBox *virtualBox, ISession *session) 437 439 { 438 440 IConsole *console = NULL; … … 446 448 if (SUCCEEDED(rc) && es) 447 449 { 448 static const ULONG interestingEvents[] =449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 450 static const ULONG s_auInterestingEvents[] = 451 { 452 VBoxEventType_OnMousePointerShapeChanged, 453 VBoxEventType_OnMouseCapabilityChanged, 454 VBoxEventType_OnKeyboardLedsChanged, 455 VBoxEventType_OnStateChanged, 456 VBoxEventType_OnAdditionsStateChanged, 457 VBoxEventType_OnNetworkAdapterChanged, 458 VBoxEventType_OnSerialPortChanged, 459 VBoxEventType_OnParallelPortChanged, 460 VBoxEventType_OnStorageControllerChanged, 461 VBoxEventType_OnMediumChanged, 462 VBoxEventType_OnVRDEServerChanged, 463 VBoxEventType_OnUSBControllerChanged, 464 VBoxEventType_OnUSBDeviceStateChanged, 465 VBoxEventType_OnSharedFolderChanged, 466 VBoxEventType_OnRuntimeError, 467 VBoxEventType_OnCanShowWindow, 468 VBoxEventType_OnShowWindow 469 }; 468 470 SAFEARRAY *interestingEventsSA = NULL; 469 471 IEventListenerDemo *consoleListener = NULL; … … 471 473 /* The VirtualBox API expects enum values as VT_I4, which in the 472 474 * future can be hopefully relaxed. */ 473 interestingEventsSA = g_pVBoxFuncs->pfnSafeArrayCreateVector(VT_I4, 0, sizeof(interestingEvents) / sizeof(interestingEvents[0])); 474 g_pVBoxFuncs->pfnSafeArrayCopyInParamHelper(interestingEventsSA, &interestingEvents, sizeof(interestingEvents)); 475 interestingEventsSA = g_pVBoxFuncs->pfnSafeArrayCreateVector(VT_I4, 0, 476 sizeof(s_auInterestingEvents) 477 / sizeof(s_auInterestingEvents[0])); 478 g_pVBoxFuncs->pfnSafeArrayCopyInParamHelper(interestingEventsSA, &s_auInterestingEvents, 479 sizeof(s_auInterestingEvents)); 475 480 476 481 consoleListener = calloc(1, sizeof(IEventListenerDemo)); … … 499 504 500 505 while (!g_fStop) 501 {502 506 g_pVBoxFuncs->pfnProcessEventQueue(250); 503 }504 507 505 508 #ifdef WIN32 … … 510 513 } 511 514 else 512 {513 515 printf("Failed to register event listener.\n"); 514 }515 516 IEventSource_UnregisterListener(es, (IEventListener *)consoleListener); 516 517 #ifdef WIN32 … … 521 522 } 522 523 else 523 {524 524 printf("Failed while allocating memory for console event listener.\n"); 525 }526 525 g_pVBoxFuncs->pfnSafeArrayDestroy(interestingEventsSA); 527 526 IEventSource_Release(es); 528 527 } 529 528 else 530 {531 529 printf("Failed to get the event source instance.\n"); 532 }533 530 IConsole_Release(console); 534 531 } … … 542 539 * @param virtualBox ptr to IVirtualBox object 543 540 * @param session ptr to ISession object 544 * @param id identifies the machine to start545 541 */ 546 static void registerPassiveEventListener(I VirtualBox *virtualBox, ISession *session, BSTR machineId)542 static void registerPassiveEventListener(ISession *session) 547 543 { 548 544 IConsole *console = NULL; … … 550 546 551 547 rc = ISession_get_Console(session, &console); 552 if ( (SUCCEEDED(rc)) && console)548 if (SUCCEEDED(rc) && console) 553 549 { 554 550 IEventSource *es = NULL; … … 556 552 if (SUCCEEDED(rc) && es) 557 553 { 558 static const ULONG interestingEvents[] =559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 554 static const ULONG s_auInterestingEvents[] = 555 { 556 VBoxEventType_OnMousePointerShapeChanged, 557 VBoxEventType_OnMouseCapabilityChanged, 558 VBoxEventType_OnKeyboardLedsChanged, 559 VBoxEventType_OnStateChanged, 560 VBoxEventType_OnAdditionsStateChanged, 561 VBoxEventType_OnNetworkAdapterChanged, 562 VBoxEventType_OnSerialPortChanged, 563 VBoxEventType_OnParallelPortChanged, 564 VBoxEventType_OnStorageControllerChanged, 565 VBoxEventType_OnMediumChanged, 566 VBoxEventType_OnVRDEServerChanged, 567 VBoxEventType_OnUSBControllerChanged, 568 VBoxEventType_OnUSBDeviceStateChanged, 569 VBoxEventType_OnSharedFolderChanged, 570 VBoxEventType_OnRuntimeError, 571 VBoxEventType_OnCanShowWindow, 572 VBoxEventType_OnShowWindow 573 }; 578 574 SAFEARRAY *interestingEventsSA = NULL; 579 575 IEventListener *consoleListener = NULL; … … 581 577 /* The VirtualBox API expects enum values as VT_I4, which in the 582 578 * future can be hopefully relaxed. */ 583 interestingEventsSA = g_pVBoxFuncs->pfnSafeArrayCreateVector(VT_I4, 0, sizeof(interestingEvents) / sizeof(interestingEvents[0])); 584 g_pVBoxFuncs->pfnSafeArrayCopyInParamHelper(interestingEventsSA, &interestingEvents, sizeof(interestingEvents)); 579 interestingEventsSA = g_pVBoxFuncs->pfnSafeArrayCreateVector(VT_I4, 0, 580 sizeof(s_auInterestingEvents) 581 / sizeof(s_auInterestingEvents[0])); 582 g_pVBoxFuncs->pfnSafeArrayCopyInParamHelper(interestingEventsSA, &s_auInterestingEvents, 583 sizeof(s_auInterestingEvents)); 585 584 586 585 rc = IEventSource_CreateListener(es, &consoleListener); … … 643 642 } 644 643 else 645 {646 644 printf("Failed to register event listener.\n"); 647 }648 645 IEventSource_UnregisterListener(es, (IEventListener *)consoleListener); 649 646 IEventListener_Release(consoleListener); 650 647 } 651 648 else 652 {653 649 printf("Failed to create an event listener instance.\n"); 654 }655 650 g_pVBoxFuncs->pfnSafeArrayDestroy(interestingEventsSA); 656 651 IEventSource_Release(es); 657 652 } 658 653 else 659 {660 654 printf("Failed to get the event source instance.\n"); 661 }662 655 IConsole_Release(console); 663 656 } … … 675 668 { 676 669 IErrorInfo *ex; 677 HRESULT rc2 = S_OK;670 HRESULT rc2; 678 671 fprintf(stderr, "%s: %s (rc=%#010x)\n", pszExecutable, pszErrorMsg, (unsigned)rc); 679 672 rc2 = g_pVBoxFuncs->pfnGetException(&ex); … … 682 675 IVirtualBoxErrorInfo *ei; 683 676 rc2 = IErrorInfo_QueryInterface(ex, &IID_IVirtualBoxErrorInfo, (void **)&ei); 684 if (FAILED(rc2)) 685 ei = NULL; 686 if (ei) 677 if (SUCCEEDED(rc2) && ei != NULL) 687 678 { 688 679 /* got extended error info, maybe multiple infos */ … … 717 708 IVirtualBoxErrorInfo_Release(ei); 718 709 ei = ei_next; 719 } 720 while (ei); 710 } while (ei); 721 711 } 722 712 … … 813 803 * Ignore it if you need a more basic sample. */ 814 804 #ifdef USE_ACTIVE_EVENT_LISTENER 815 registerActiveEventListener(virtualBox, session , id);816 #else /* !USE_ACTIVE_EVENT_LISTENER */817 registerPassiveEventListener( virtualBox, session, id);818 #endif /* !USE_ACTIVE_EVENT_LISTENER */805 registerActiveEventListener(virtualBox, session); 806 #else 807 registerPassiveEventListener(session); 808 #endif 819 809 } 820 810 IProgress_Release(progress); … … 872 862 * Iterate through the collection. 873 863 */ 874 875 864 for (i = 0; i < machineCnt; ++i) 876 865 { … … 900 889 } 901 890 else 902 {903 891 printf("\tName: <inaccessible>\n"); 904 }905 892 906 893 { … … 958 945 * Let the user chose a machine to start. 959 946 */ 960 961 947 printf("Type Machine# to start (0 - %u) or 'quit' to do nothing: ", 962 (unsigned)(machineCnt - 1));948 (unsigned)(machineCnt - 1)); 963 949 fflush(stdout); 964 950 … … 980 966 * Don't forget to release the objects in the array. 981 967 */ 982 983 968 for (i = 0; i < machineCnt; ++i) 984 969 { … … 986 971 987 972 if (machine) 988 {989 973 IMachine_Release(machine); 990 }991 974 } 992 975 g_pVBoxFuncs->pfnArrayOutFree(machines); … … 1003 986 BSTR versionUtf16 = NULL; 1004 987 BSTR homefolderUtf16 = NULL; 1005 HRESULT rc; /* Result code of various function (method) calls. */ 988 HRESULT rc; /* Result code of various function (method) calls. */ 989 (void)argc; 1006 990 1007 991 printf("Starting main()\n"); … … 1061 1045 1062 1046 /* 1. Revision */ 1063 1064 1047 rc = IVirtualBox_get_Revision(vbox, &revision); 1065 1048 if (SUCCEEDED(rc)) … … 1069 1052 1070 1053 /* 2. Version */ 1071 1072 1054 rc = IVirtualBox_get_Version(vbox, &versionUtf16); 1073 1055 if (SUCCEEDED(rc)) … … 1083 1065 1084 1066 /* 3. Home Folder */ 1085 1086 1067 rc = IVirtualBox_get_HomeFolder(vbox, &homefolderUtf16); 1087 1068 if (SUCCEEDED(rc)) … … 1104 1085 * Do as mom told us: always clean up after yourself. 1105 1086 */ 1106 1107 1087 #ifdef USE_ACTIVE_EVENT_LISTENER 1108 1088 # ifdef WIN32
注意:
瀏覽 TracChangeset
來幫助您使用更動檢視器