Changeset 30156 in vbox
- Timestamp:
- Jun 10, 2010 5:54:11 PM (14 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 2 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/Makefile.kmk
r29859 r30156 338 338 win/svchlp.cpp \ 339 339 win/HostPowerWin.cpp \ 340 win/VBoxSVC.rc 340 win/VBoxSVC.rc \ 341 win/VBoxComEvents.cpp 341 342 342 343 VBoxSVC_SOURCES.linux = \ -
trunk/src/VBox/Main/VirtualBoxImpl.cpp
r30070 r30156 74 74 #ifdef RT_OS_WINDOWS 75 75 # include "win/svchlp.h" 76 # include "win/VBoxComEvents.h" 76 77 #endif 77 78 … … 203 204 204 205 virtual HRESULT handleCallback(const ComPtr<IVirtualBoxCallback> &aCallback) = 0; 206 #ifdef RT_OS_WINDOWS 207 virtual HRESULT prepareEventDesc(ComEventDesc& aEvDesc) = 0; 208 #endif 205 209 206 210 private: … … 348 352 EventQueue * const pAsyncEventQ; 349 353 354 #ifdef RT_OS_WINDOWS 355 ComEventsHelper aComEvHelper; 356 #endif 350 357 }; 351 358 … … 584 591 } 585 592 593 #ifdef RT_OS_WINDOWS 594 if (SUCCEEDED(rc)) 595 rc = m->aComEvHelper.init(IID_IVirtualBoxCallback); 596 #endif 597 586 598 /* Confirm a successful initialization when it's the case */ 587 599 if (SUCCEEDED(rc)) … … 2585 2597 } 2586 2598 } 2599 #ifdef RT_OS_WINDOWS 2600 HRESULT prepareEventDesc(ComEventDesc& aEvDesc) 2601 { 2602 switch (mWhat) 2603 { 2604 case VirtualBoxCallbackRegistration::kOnMachineDataChange: 2605 aEvDesc.init("OnMachineDataChange", 1); 2606 aEvDesc.add(id.toUtf16()); 2607 break; 2608 2609 case VirtualBoxCallbackRegistration::kOnMachineStateChange: 2610 aEvDesc.init("OnMachineStateChange", 2); 2611 aEvDesc.add(id.toUtf16()).add((int)state); 2612 break; 2613 2614 case VirtualBoxCallbackRegistration::kOnMachineRegistered: 2615 aEvDesc.init("OnMachineRegistered", 2); 2616 aEvDesc.add(id.toUtf16()).add((BOOL)registered); 2617 break; 2618 2619 default: 2620 AssertFailedReturn(S_OK); 2621 } 2622 return S_OK; 2623 } 2624 #endif 2587 2625 2588 2626 Guid id; … … 2681 2719 return aCallback->OnExtraDataChange(machineId.toUtf16(), key, val); 2682 2720 } 2721 #ifdef RT_OS_WINDOWS 2722 HRESULT prepareEventDesc(ComEventDesc& aEvDesc) 2723 { 2724 aEvDesc.init("OnExtraDataChange", 3); 2725 aEvDesc.add(machineId.toUtf16()).add(key).add(val); 2726 return S_OK; 2727 } 2728 #endif 2683 2729 2684 2730 Guid machineId; … … 2716 2762 return aCallback->OnSessionStateChange(machineId.toUtf16(), sessionState); 2717 2763 } 2764 2765 #ifdef RT_OS_WINDOWS 2766 HRESULT prepareEventDesc(ComEventDesc& aEvDesc) 2767 { 2768 aEvDesc.init("OnSessionStateChange", 2); 2769 aEvDesc.add(machineId.toUtf16()).add((int)sessionState); 2770 return S_OK; 2771 } 2772 #endif 2718 2773 2719 2774 Guid machineId; … … 2764 2819 } 2765 2820 } 2821 2822 #ifdef RT_OS_WINDOWS 2823 HRESULT prepareEventDesc(ComEventDesc& aEvDesc) 2824 { 2825 aEvDesc.init("OnSnapshotTaken", 2); 2826 aEvDesc.add(machineId.toUtf16()).add(snapshotId.toUtf16()); 2827 return S_OK; 2828 } 2829 #endif 2830 2766 2831 2767 2832 Guid machineId; … … 2814 2879 return aCallback->OnGuestPropertyChange(machineId.toUtf16(), name, value, flags); 2815 2880 } 2881 2882 #ifdef RT_OS_WINDOWS 2883 HRESULT prepareEventDesc(ComEventDesc& aEvDesc) 2884 { 2885 aEvDesc.init("OnGuestPropertyChange", 4); 2886 aEvDesc.add(machineId.toUtf16()).add(name).add(value).add(flags); 2887 return S_OK; 2888 } 2889 #endif 2816 2890 2817 2891 Guid machineId; … … 4508 4582 } 4509 4583 4510 #ifdef RT_OS_WINDOWS 4584 4585 #ifdef RT_OS_WINDOWS 4511 4586 #if 0 4512 4587 // WIP 4513 4514 LPTYPEINFO ptinfo; 4515 HRESULT hr; 4516 LPTYPELIB ptlib; 4517 DISPID dispid; 4518 4519 /* Real solution must cache all needed dispids once, ofc */ 4520 hr = ::LoadRegTypeLib(LIBID_VirtualBox, kTypeLibraryMajorVersion, kTypeLibraryMinorVersion, LOCALE_SYSTEM_DEFAULT, &ptlib); 4521 hr = ptlib->GetTypeInfoOfGuid(IID_IVirtualBoxCallback, &ptinfo); 4522 ptlib->Release(); 4523 4524 OLECHAR FAR* szMember = L"OnMachineStateChange"; 4525 4526 hr = ::DispGetIDsOfNames(ptinfo, &szMember, 1, &dispid); 4527 ptinfo->Release(); 4528 4529 int nConnections = mVirtualBox->m_vec.GetSize(); 4530 for (int i=0; i<nConnections; i++) 4531 { 4588 { 4589 ComEventDesc evDesc; 4590 4591 int nConnections = mVirtualBox->m_vec.GetSize(); 4592 /* Only prepare args if someone needs them */ 4593 if (nConnections) 4594 prepareEventDesc(evDesc); 4595 4596 for (int i=0; i<nConnections; i++) 4597 { 4532 4598 ComPtr<IUnknown> sp = mVirtualBox->m_vec.GetAt(i); 4533 4599 ComPtr<IVirtualBoxCallback> cbI; … … 4538 4604 4539 4605 /** 4540 * Would be like thisin ideal world, unfortunately our consumers want to be invoked via IDispatch,4606 * Would be just handleCallback(cbI) in ideal world, unfortunately our consumers want to be invoked via IDispatch, 4541 4607 * thus going the hard way. 4542 4608 */ 4543 #if 04544 if (cbI != NULL)4545 {4546 HRESULT hrc = handleCallback(cbI);4547 if (hrc == VBOX_E_DONT_CALL_AGAIN)4548 {4549 // need to handle that somehow, maybe just set element to 04550 }4551 }4552 #endif4553 4609 if (cbI != NULL && cbD != NULL) 4554 4610 { 4555 CComVariant varResult, arg1, arg2; 4556 4557 ::VariantClear(&varResult); 4558 ::VariantClear(&arg1); 4559 ::VariantClear(&arg2); 4560 4561 VARIANTARG args[] = {arg1, arg2}; 4562 DISPPARAMS disp = { args, NULL, sizeof(args)/sizeof(args[0]), 0}; 4563 4564 cbD->Invoke(dispid, IID_NULL, 4565 LOCALE_USER_DEFAULT, 4566 DISPATCH_METHOD, 4567 &disp, &varResult, 4568 NULL, NULL); 4569 } 4611 CComVariant varResult; 4612 mVirtualBox->m->aComEvHelper.fire(cbD, evDesc, &varResult); 4613 // what we gonna do with the result? 4614 } 4615 } 4570 4616 } 4571 4617 #endif
Note:
See TracChangeset
for help on using the changeset viewer.