Changeset 933 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Feb 15, 2007 7:06:12 PM (18 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/include/COMDefs.h
r469 r933 231 231 * operation. 232 232 */ 233 HRESULT lastRC() const { return rc; }233 HRESULT lastRC() const { return mRC; } 234 234 235 235 /** … … 243 243 244 244 /* no arbitrary instance creations */ 245 COMBase() : rc(S_OK) {};245 COMBase() : mRC (S_OK) {}; 246 246 247 247 #if !defined (Q_OS_WIN32) 248 static nsIComponentManager * componentManager;249 static nsIEventQueue* eventQ;250 static ipcIDConnectService * dconnectService;251 static PRUint32 vboxServerID;252 253 static XPCOMEventQSocketListener * socketListener;248 static nsIComponentManager *gComponentManager; 249 static nsIEventQueue* gEventQ; 250 static ipcIDConnectService *gDConnectService; 251 static PRUint32 gVBoxServerID; 252 253 static XPCOMEventQSocketListener *gSocketListener; 254 254 #endif 255 255 … … 360 360 void fetchErrorInfo (IUnknown * /*callee*/, const GUID * /*calleeIID*/) const {} 361 361 362 mutable HRESULT rc;362 mutable HRESULT mRC; 363 363 364 364 friend class COMErrorInfo; … … 381 381 * represents a failure (i.e. CInterface::isOk() is false). 382 382 */ 383 COMErrorInfo errorInfo() const { return errInfo; }383 COMErrorInfo errorInfo() const { return mErrInfo; } 384 384 385 385 protected: … … 389 389 390 390 void fetchErrorInfo (IUnknown *callee, const GUID *calleeIID) const { 391 errInfo.fetchFromCurrentThread (callee, calleeIID);392 } 393 394 mutable COMErrorInfo errInfo;391 mErrInfo.fetchFromCurrentThread (callee, calleeIID); 392 } 393 394 mutable COMErrorInfo mErrInfo; 395 395 }; 396 396 … … 458 458 /* constructors & destructor */ 459 459 460 CInterface() : iface (NULL) {} 461 462 CInterface (const CInterface &that) : B (that), iface (that.iface) { 463 addref (iface); 460 CInterface() : mIface (NULL) {} 461 462 CInterface (const CInterface &that) : B (that), mIface (that.mIface) 463 { 464 addref (mIface); 464 465 } 465 466 466 467 CInterface (const CUnknown &that); 467 468 468 CInterface (I *i) : iface (i) { addref (iface); }469 470 virtual ~CInterface() { release ( iface); }469 CInterface (I *i) : mIface (i) { addref (mIface); } 470 471 virtual ~CInterface() { release (mIface); } 471 472 472 473 /* utility methods */ 473 474 474 void createInstance (const CLSID &clsid) { 475 AssertMsg (!iface, ("Instance is already non-NULL\n")); 476 if (!iface) 475 void createInstance (const CLSID &clsid) 476 { 477 AssertMsg (!mIface, ("Instance is already non-NULL\n")); 478 if (!mIface) 477 479 { 478 480 #if defined (Q_OS_WIN32) 479 B:: rc= CoCreateInstance (clsid, NULL, CLSCTX_ALL,480 _ATL_IIDOF (I), (void**) &iface);481 B::mRC = CoCreateInstance (clsid, NULL, CLSCTX_ALL, 482 _ATL_IIDOF (I), (void**) &mIface); 481 483 #else 482 484 /* first, try to create an instance within the in-proc server 483 485 * (for compatibility with Win32) */ 484 B:: rc = B::componentManager->CreateInstance (485 clsid, nsnull, NS_GET_IID (I), (void**) &iface486 );487 if (FAILED (B::rc) && B::dconnectService && B::vboxServerID){486 B::mRC = B::gComponentManager-> 487 CreateInstance (clsid, nsnull, NS_GET_IID (I), (void**) &mIface); 488 if (FAILED (B::mRC) && B::gDConnectService && B::gVBoxServerID) 489 { 488 490 /* now try the out-of-proc server if it exists */ 489 B::rc = B::dconnectService->CreateInstance ( 490 B::vboxServerID, clsid, 491 NS_GET_IID (I), (void**) &iface 492 ); 491 B::mRC = B::gDConnectService-> 492 CreateInstance (B::gVBoxServerID, clsid, 493 NS_GET_IID (I), (void**) &mIface); 493 494 } 494 495 #endif … … 500 501 } 501 502 502 void attach (I *i) { 503 void attach (I *i) 504 { 503 505 /* be aware of self (from COM point of view) assignment */ 504 I *old_iface = iface;505 iface = i;506 addref ( iface);506 I *old_iface = mIface; 507 mIface = i; 508 addref (mIface); 507 509 release (old_iface); 508 B:: rc= S_OK;510 B::mRC = S_OK; 509 511 }; 510 512 511 void attachUnknown (IUnknown *i) { 513 void attachUnknown (IUnknown *i) 514 { 512 515 /* be aware of self (from COM point of view) assignment */ 513 I *old_iface = iface;514 iface = NULL;515 B:: rc= S_OK;516 I *old_iface = mIface; 517 mIface = NULL; 518 B::mRC = S_OK; 516 519 if (i) 517 520 #if defined (Q_OS_WIN32) 518 B:: rc = i->QueryInterface (_ATL_IIDOF (I), (void**) &iface);519 #else 520 B:: rc = i->QueryInterface (NS_GET_IID (I), (void**) &iface);521 B::mRC = i->QueryInterface (_ATL_IIDOF (I), (void**) &mIface); 522 #else 523 B::mRC = i->QueryInterface (NS_GET_IID (I), (void**) &mIface); 521 524 #endif 522 525 release (old_iface); 523 526 }; 524 527 525 void detach() { release ( iface); iface = NULL; }526 527 bool isNull() const { return iface == NULL; }528 529 bool isOk() const { return !isNull() && SUCCEEDED (B:: rc); }528 void detach() { release (mIface); mIface = NULL; } 529 530 bool isNull() const { return mIface == NULL; } 531 532 bool isOk() const { return !isNull() && SUCCEEDED (B::mRC); } 530 533 531 534 /* utility operators */ 532 535 533 CInterface &operator= (const CInterface &that) { 534 attach (that.iface); 536 CInterface &operator= (const CInterface &that) 537 { 538 attach (that.mIface); 535 539 B::operator= (that); 536 540 return *this; 537 541 } 538 542 539 #ifdef VBOX_WITH_DEBUGGER_GUI 540 /** @todo bird: dmik, perhaps I missed something, but I didn't find anything equivalent 541 * to this. feel free to fix &/| remove this hack. */ 542 I *getInterface() { return iface; } 543 #endif 544 545 bool operator== (const CInterface &that) const { return iface == that.iface; } 546 bool operator!= (const CInterface &that) const { return iface != that.iface; } 543 I *iface() const { return mIface; } 544 545 bool operator== (const CInterface &that) const { return mIface == that.mIface; } 546 bool operator!= (const CInterface &that) const { return mIface != that.mIface; } 547 547 548 548 CInterface &operator= (const CUnknown &that); … … 553 553 static void release (I *i) { if (i) i->Release(); } 554 554 555 mutable I * iface;555 mutable I *mIface; 556 556 }; 557 557 … … 565 565 566 566 template <class C> 567 explicit CUnknown (const C &that) { 568 iface = NULL; 569 if (that.iface) 567 explicit CUnknown (const C &that) 568 { 569 mIface = NULL; 570 if (that.mIface) 570 571 #if defined (Q_OS_WIN32) 571 rc = that.iface->QueryInterface (_ATL_IIDOF (IUnknown), (void**) &iface);572 #else 573 rc = that.iface->QueryInterface (NS_GET_IID (IUnknown), (void**) &iface);574 #endif 575 if (SUCCEEDED ( rc)) {576 rc= that.lastRC();577 errInfo = that.errorInfo();572 mRC = that.mIface->QueryInterface (_ATL_IIDOF (IUnknown), (void**) &mIface); 573 #else 574 mRC = that.mIface->QueryInterface (NS_GET_IID (IUnknown), (void**) &mIface); 575 #endif 576 if (SUCCEEDED (mRC)) { 577 mRC = that.lastRC(); 578 mErrInfo = that.errorInfo(); 578 579 } 579 580 } 580 581 /* specialization for CUnknown */ 581 582 CUnknown (const CUnknown &that) : CInterface <IUnknown, COMBaseWithEI> () { 582 iface = that.iface;583 addref ( iface);583 mIface = that.mIface; 584 addref (mIface); 584 585 COMBaseWithEI::operator= (that); 585 586 } … … 588 589 CUnknown &operator= (const C &that) { 589 590 /* be aware of self (from COM point of view) assignment */ 590 IUnknown *old_iface = iface;591 iface = NULL;592 rc= S_OK;591 IUnknown *old_iface = mIface; 592 mIface = NULL; 593 mRC = S_OK; 593 594 #if defined (Q_OS_WIN32) 594 if (that. iface)595 rc = that.iface->QueryInterface (_ATL_IIDOF (IUnknown), (void**) &iface);596 #else 597 if (that. iface)598 rc = that.iface->QueryInterface (NS_GET_IID (IUnknown), (void**) &iface);599 #endif 600 if (SUCCEEDED ( rc)) {601 rc= that.lastRC();602 errInfo = that.errorInfo();595 if (that.mIface) 596 mRC = that.mIface->QueryInterface (_ATL_IIDOF (IUnknown), (void**) &mIface); 597 #else 598 if (that.mIface) 599 mRC = that.mIface->QueryInterface (NS_GET_IID (IUnknown), (void**) &mIface); 600 #endif 601 if (SUCCEEDED (mRC)) { 602 mRC = that.lastRC(); 603 mErrInfo = that.errorInfo(); 603 604 } 604 605 release (old_iface); … … 607 608 /* specialization for CUnknown */ 608 609 CUnknown &operator= (const CUnknown &that) { 609 attach (that. iface);610 attach (that.mIface); 610 611 COMBaseWithEI::operator= (that); 611 612 return *this; 612 613 } 613 614 614 IUnknown *&ifaceRef() { return iface; };615 IUnknown * ifaceRef() const { return iface; };615 /* @internal Used in wrappers. */ 616 IUnknown *&ifaceRef() { return mIface; }; 616 617 }; 617 618 … … 620 621 template <class I, class B> 621 622 inline CInterface <I, B>::CInterface (const CUnknown &that) 622 : iface (NULL)623 { 624 attachUnknown (that.iface Ref());625 if (SUCCEEDED (B:: rc))623 : mIface (NULL) 624 { 625 attachUnknown (that.iface()); 626 if (SUCCEEDED (B::mRC)) 626 627 B::operator= ((B &) that); 627 628 } … … 630 631 inline CInterface <I, B> &CInterface <I, B>::operator =(const CUnknown &that) 631 632 { 632 attachUnknown (that.iface Ref());633 if (SUCCEEDED (B:: rc))633 attachUnknown (that.iface()); 634 if (SUCCEEDED (B::mRC)) 634 635 B::operator= ((B &) that); 635 636 return *this; -
trunk/src/VBox/Frontends/VirtualBox/include/COMWrappers.xsl
r469 r933 465 465 <xsl:text>::GetCount () const {
</xsl:text> 466 466 <xsl:text> ULONG count = 0;
</xsl:text> 467 <xsl:text> Assert ( iface);
</xsl:text>468 <xsl:text> if (! iface)
 return count;
</xsl:text>469 <xsl:text> rc = iface->COMGETTER(Count) (&count);
</xsl:text>467 <xsl:text> Assert (mIface);
</xsl:text> 468 <xsl:text> if (!mIface)
 return count;
</xsl:text> 469 <xsl:text> mRC = mIface->COMGETTER(Count) (&count);
</xsl:text> 470 470 <xsl:call-template name="tryComposeFetchErrorInfo"/> 471 471 <xsl:text> return count;
</xsl:text> … … 479 479 <xsl:text> </xsl:text><xsl:apply-templates select="@type"/> 480 480 <xsl:text> item;
</xsl:text> 481 <xsl:text> Assert ( iface);
</xsl:text>482 <xsl:text> if (! iface)
 return item;
</xsl:text>483 <xsl:text> rc = iface->GetItemAt (index, &item.iface);
</xsl:text>481 <xsl:text> Assert (mIface);
</xsl:text> 482 <xsl:text> if (!mIface)
 return item;
</xsl:text> 483 <xsl:text> mRC = mIface->GetItemAt (index, &item.mIface);
</xsl:text> 484 484 <xsl:call-template name="tryComposeFetchErrorInfo"/> 485 485 <xsl:text> return item;
</xsl:text> … … 493 493 <xsl:text> </xsl:text><xsl:apply-templates select="@enumerator"/> 494 494 <xsl:text> enumerator;
</xsl:text> 495 <xsl:text> Assert ( iface);
</xsl:text>496 <xsl:text> if (! iface)
 return enumerator;
</xsl:text>497 <xsl:text> rc = iface->Enumerate (&enumerator.iface);
</xsl:text>495 <xsl:text> Assert (mIface);
</xsl:text> 496 <xsl:text> if (!mIface)
 return enumerator;
</xsl:text> 497 <xsl:text> mRC = mIface->Enumerate (&enumerator.mIface);
</xsl:text> 498 498 <xsl:call-template name="tryComposeFetchErrorInfo"/> 499 499 <xsl:text> return enumerator;
</xsl:text> … … 507 507 <xsl:text>::HasMore () const {
</xsl:text> 508 508 <xsl:text> BOOL more = FALSE;
</xsl:text> 509 <xsl:text> Assert ( iface);
</xsl:text>510 <xsl:text> if (! iface)
 return more;
</xsl:text>511 <xsl:text> rc = iface->HasMore (&more);
</xsl:text>509 <xsl:text> Assert (mIface);
</xsl:text> 510 <xsl:text> if (!mIface)
 return more;
</xsl:text> 511 <xsl:text> mRC = mIface->HasMore (&more);
</xsl:text> 512 512 <xsl:call-template name="tryComposeFetchErrorInfo"/> 513 513 <xsl:text> return more;
</xsl:text> … … 521 521 <xsl:text> </xsl:text><xsl:apply-templates select="@type"/> 522 522 <xsl:text> next;
</xsl:text> 523 <xsl:text> Assert ( iface);
</xsl:text>524 <xsl:text> if (! iface)
 return next;
</xsl:text>525 <xsl:text> rc = iface->GetNext (&next.iface);
</xsl:text>523 <xsl:text> Assert (mIface);
</xsl:text> 524 <xsl:text> if (!mIface)
 return next;
</xsl:text> 525 <xsl:text> mRC = mIface->GetNext (&next.mIface);
</xsl:text> 526 526 <xsl:call-template name="tryComposeFetchErrorInfo"/> 527 527 <xsl:text> return next;
</xsl:text> … … 622 622 <xsl:text> {
</xsl:text> 623 623 <!-- iface assertion --> 624 <xsl:text> Assert ( iface);
</xsl:text>625 <xsl:text> if (! iface)
 return;
</xsl:text>624 <xsl:text> Assert (mIface);
</xsl:text> 625 <xsl:text> if (!mIface)
 return;
</xsl:text> 626 626 <!-- method call --> 627 627 <xsl:call-template name="composeMethodCall"> … … 667 667 <xsl:text>;
</xsl:text> 668 668 <!-- iface assertion --> 669 <xsl:text> Assert ( iface);
</xsl:text>670 <xsl:text> if (! iface)
 return a_</xsl:text>669 <xsl:text> Assert (mIface);
</xsl:text> 670 <xsl:text> if (!mIface)
 return a_</xsl:text> 671 671 <!-- ### xsl:call-template name="capitalize"> 672 672 <xsl:with-param name="str" select="$return/@name"/> … … 762 762 <xsl:template name="composeMethodCall"> 763 763 <xsl:param name="isSetter" select="''"/> 764 <xsl:text> rc = iface-></xsl:text>764 <xsl:text> mRC = mIface-></xsl:text> 765 765 <xsl:choose> 766 766 <!-- attribute method call --> … … 850 850 <xsl:otherwise> 851 851 <xsl:if test="$supports='strict' or $supports='yes'"> 852 <xsl:text> if (FAILED ( rc)) {
</xsl:text>853 <xsl:text> fetchErrorInfo ( iface, &COM_IIDOF (Base::Iface));
</xsl:text>852 <xsl:text> if (FAILED (mRC)) {
</xsl:text> 853 <xsl:text> fetchErrorInfo (mIface, &COM_IIDOF (Base::Iface));
</xsl:text> 854 854 <xsl:if test="$supports='strict'"> 855 855 <xsl:text> AssertMsg (errInfo.isFullAvailable(), </xsl:text> 856 <xsl:text>("for RC=0x%08X\n", rc));
</xsl:text>856 <xsl:text>("for RC=0x%08X\n", mRC));
</xsl:text> 857 857 </xsl:if> 858 858 <xsl:text> }
</xsl:text> … … 962 962 <xsl:choose> 963 963 <xsl:when test="@type='$unknown'"> 964 <xsl:text>.iface Ref()</xsl:text>964 <xsl:text>.iface()</xsl:text> 965 965 </xsl:when> 966 966 <xsl:otherwise> 967 <xsl:text>. iface</xsl:text>967 <xsl:text>.mIface</xsl:text> 968 968 </xsl:otherwise> 969 969 </xsl:choose> … … 980 980 </xsl:when> 981 981 <xsl:otherwise> 982 <xsl:text>. iface</xsl:text>982 <xsl:text>.mIface</xsl:text> 983 983 </xsl:otherwise> 984 984 </xsl:choose> -
trunk/src/VBox/Frontends/VirtualBox/src/COMDefs.cpp
r675 r933 66 66 #include <VBox/com/assert.h> 67 67 68 nsIComponentManager *COMBase:: componentManager = nsnull;69 nsIEventQueue* COMBase:: eventQ = nsnull;70 ipcIDConnectService *COMBase:: dconnectService = nsnull;71 PRUint32 COMBase:: vboxServerID = 0;72 73 XPCOMEventQSocketListener *COMBase:: socketListener = 0;68 nsIComponentManager *COMBase::gComponentManager = nsnull; 69 nsIEventQueue* COMBase::gEventQ = nsnull; 70 ipcIDConnectService *COMBase::gDConnectService = nsnull; 71 PRUint32 COMBase::gVBoxServerID = 0; 72 73 XPCOMEventQSocketListener *COMBase::gSocketListener = 0; 74 74 75 75 /** … … 83 83 public: 84 84 85 XPCOMEventQSocketListener (nsIEventQueue *eq) { 86 eventQ = eq; 87 notifier = new QSocketNotifier ( 88 eventQ->GetEventQueueSelectFD(), QSocketNotifier::Read, 89 this, "XPCOMEventQSocketNotifier" 90 ); 91 QObject::connect( 92 notifier, SIGNAL( activated (int) ), 93 this, SLOT( processEvents() ) 94 ); 85 XPCOMEventQSocketListener (nsIEventQueue *eq) 86 { 87 mEventQ = eq; 88 mNotifier = new QSocketNotifier (mEventQ->GetEventQueueSelectFD(), 89 QSocketNotifier::Read, this, 90 "XPCOMEventQSocketNotifier"); 91 QObject::connect (mNotifier, SIGNAL (activated (int)), 92 this, SLOT (processEvents())); 95 93 } 96 94 97 95 public slots: 98 96 99 void processEvents() { 100 eventQ->ProcessPendingEvents(); 101 } 97 void processEvents() { mEventQ->ProcessPendingEvents(); } 102 98 103 99 private: 104 QSocketNotifier *notifier; 105 nsIEventQueue *eventQ; 100 101 QSocketNotifier *mNotifier; 102 nsIEventQueue *mEventQ; 106 103 }; 107 104 … … 129 126 #else 130 127 131 if ( componentManager)128 if (gComponentManager) 132 129 { 133 130 LogFlow (("COMBase::initializeCOM(): END\n")); … … 174 171 // get the component manager 175 172 rc = registrar->QueryInterface (NS_GET_IID (nsIComponentManager), 176 (void**) & componentManager);173 (void**) &gComponentManager); 177 174 if (SUCCEEDED (rc)) 178 175 { … … 180 177 // gets created upon XPCOM startup, so it will use the main (this) 181 178 // thread's event queue to receive IPC events) 182 rc = NS_GetMainEventQ (& eventQ);179 rc = NS_GetMainEventQ (&gEventQ); 183 180 #ifdef DEBUG 184 181 BOOL isNative = FALSE; 185 eventQ->IsQueueNative (&isNative);182 gEventQ->IsQueueNative (&isNative); 186 183 AssertMsg (isNative, ("The event queue must be native")); 187 184 #endif 188 socketListener = new XPCOMEventQSocketListener (eventQ);185 gSocketListener = new XPCOMEventQSocketListener (gEventQ); 189 186 190 187 // get the IPC service … … 195 192 // get the VirtualBox out-of-proc server ID 196 193 rc = ipcServ->ResolveClientName ("VirtualBoxServer", 197 & vboxServerID);194 &gVBoxServerID); 198 195 if (SUCCEEDED (rc)) 199 196 { 200 197 // get the DConnect service 201 rc = serviceManager->GetServiceByContractID ( 202 IPC_DCONNECTSERVICE_CONTRACTID, 203 NS_GET_IID (ipcIDConnectService), 204 (void **) &dconnectService 205 ); 198 rc = serviceManager-> 199 GetServiceByContractID (IPC_DCONNECTSERVICE_CONTRACTID, 200 NS_GET_IID (ipcIDConnectService), 201 (void **) &gDConnectService); 206 202 } 207 203 } … … 229 225 CoUninitialize(); 230 226 #else 231 if ( componentManager)227 if (gComponentManager) 232 228 { 233 229 PRBool isOnCurrentThread = true; 234 if ( eventQ)235 eventQ->IsOnCurrentThread (&isOnCurrentThread);230 if (gEventQ) 231 gEventQ->IsOnCurrentThread (&isOnCurrentThread); 236 232 237 233 if (isOnCurrentThread) 238 234 { 239 235 LogFlow (("COMBase::cleanupCOM(): doing cleanup...\n")); 240 if ( socketListener)241 delete socketListener;242 if ( dconnectService)243 dconnectService->Release();244 if ( eventQ)245 eventQ->Release();246 componentManager->Release();236 if (gSocketListener) 237 delete gSocketListener; 238 if (gDConnectService) 239 gDConnectService->Release(); 240 if (gEventQ) 241 gEventQ->Release(); 242 gComponentManager->Release(); 247 243 NS_ShutdownXPCOM (nsnull); 248 244 XPCOMGlueShutdown(); -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleWnd.cpp
r831 r933 2220 2220 if (dbg_gui) 2221 2221 return true; 2222 int rc = DBGGuiCreate (csession. getInterface(), &dbg_gui);2222 int rc = DBGGuiCreate (csession.iface(), &dbg_gui); 2223 2223 if (VBOX_SUCCESS (rc)) 2224 2224 {
Note:
See TracChangeset
for help on using the changeset viewer.