- Timestamp:
- Jan 20, 2014 2:05:02 PM (11 years ago)
- svn:sync-xref-src-repo-rev:
- 91661
- Location:
- trunk/src/VBox
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxHeadless/testcase/tstHeadless.cpp
r48244 r50117 6 6 7 7 /* 8 * Copyright (C) 2006-201 1Oracle Corporation8 * Copyright (C) 2006-2014 Oracle Corporation 9 9 * 10 10 * This file is part of VirtualBox Open Source Edition (OSE), as … … 22 22 #include <VBox/com/ErrorInfo.h> 23 23 #include <VBox/com/errorprint.h> 24 #include <VBox/com/EventQueue.h>25 24 26 25 #include <VBox/com/VirtualBox.h> … … 38 37 * Entry point. 39 38 */ 40 int main 39 int main(int argc, char **argv) 41 40 { 42 41 // initialize VBox Runtime … … 56 55 if (!name || !operation) 57 56 { 58 RTPrintf 59 60 57 RTPrintf("\nUsage:\n\n" 58 "%s <machine_name> [on|off|pause|resume]\n\n", 59 argv [0]); 61 60 return 0; 62 61 } 63 62 64 RTPrintf 65 RTPrintf 66 67 RTPrintf 68 69 63 RTPrintf("\n"); 64 RTPrintf("tstHeadless STARTED.\n"); 65 66 RTPrintf("VM name : {%s}\n" 67 "Operation : %s\n\n", 68 name, operation); 70 69 71 70 HRESULT rc; … … 83 82 ComPtr <ISession> session; 84 83 85 RTPrintf 86 rc = virtualBox.createLocalObject 84 RTPrintf("Creating VirtualBox object...\n"); 85 rc = virtualBox.createLocalObject(CLSID_VirtualBox); 87 86 if (FAILED(rc)) 88 87 RTPrintf("ERROR: failed to create the VirtualBox object!\n"); … … 94 93 } 95 94 96 if (FAILED 95 if (FAILED(rc)) 97 96 { 98 97 com::ErrorInfo info; … … 106 105 break; 107 106 } 108 109 // create the event queue110 // (here it is necessary only to process remaining XPCOM/IPC events111 // after the session is closed)112 EventQueue eventQ;113 107 114 108 ComPtr <IMachine> m; … … 121 115 { 122 116 ComPtr <IProgress> progress; 123 RTPrintf 124 CHECK_ERROR_BREAK 125 126 127 128 RTPrintf 129 CHECK_ERROR_BREAK (progress, WaitForCompletion(-1));117 RTPrintf("Opening a new (remote) session...\n"); 118 CHECK_ERROR_BREAK(m, 119 LaunchVMProcess(session, Bstr("vrdp").raw(), 120 NULL, progress.asOutParam())); 121 122 RTPrintf("Waiting for the remote session to open...\n"); 123 CHECK_ERROR_BREAK(progress, WaitForCompletion(-1)); 130 124 131 125 BOOL completed; 132 CHECK_ERROR_BREAK (progress, COMGETTER(Completed)(&completed));133 ASSERT 126 CHECK_ERROR_BREAK(progress, COMGETTER(Completed)(&completed)); 127 ASSERT(completed); 134 128 135 129 LONG resultCode; 136 CHECK_ERROR_BREAK (progress, COMGETTER(ResultCode)(&resultCode));137 if (FAILED 130 CHECK_ERROR_BREAK(progress, COMGETTER(ResultCode)(&resultCode)); 131 if (FAILED(resultCode)) 138 132 { 139 133 ProgressErrorInfo info(progress); … … 142 136 else 143 137 { 144 RTPrintf 138 RTPrintf("Remote session has been successfully opened.\n"); 145 139 } 146 140 } 147 141 else 148 142 { 149 RTPrintf 143 RTPrintf("Opening an existing session...\n"); 150 144 CHECK_ERROR_BREAK(m, LockMachine(session, LockType_Shared)); 151 145 … … 153 147 CHECK_ERROR_BREAK(session, COMGETTER(Console)(console.asOutParam())); 154 148 155 if (!strcmp 149 if (!strcmp(operation, "off")) 156 150 { 157 151 ComPtr <IProgress> progress; 158 RTPrintf 159 CHECK_ERROR_BREAK 160 161 RTPrintf 162 CHECK_ERROR_BREAK (progress, WaitForCompletion(-1));152 RTPrintf("Powering the VM off...\n"); 153 CHECK_ERROR_BREAK(console, PowerDown(progress.asOutParam())); 154 155 RTPrintf("Waiting for the VM to power down...\n"); 156 CHECK_ERROR_BREAK(progress, WaitForCompletion(-1)); 163 157 164 158 BOOL completed; 165 CHECK_ERROR_BREAK (progress, COMGETTER(Completed)(&completed));166 ASSERT 159 CHECK_ERROR_BREAK(progress, COMGETTER(Completed)(&completed)); 160 ASSERT(completed); 167 161 168 162 LONG resultCode; 169 CHECK_ERROR_BREAK (progress, COMGETTER(ResultCode)(&resultCode));170 if (FAILED 163 CHECK_ERROR_BREAK(progress, COMGETTER(ResultCode)(&resultCode)); 164 if (FAILED(resultCode)) 171 165 { 172 166 ProgressErrorInfo info(progress); … … 175 169 else 176 170 { 177 RTPrintf 171 RTPrintf("VM is powered down.\n"); 178 172 } 179 173 } 180 174 else 181 if (!strcmp 182 { 183 RTPrintf 184 CHECK_ERROR_BREAK 185 } 186 else 187 if (!strcmp 188 { 189 RTPrintf 190 CHECK_ERROR_BREAK 191 } 192 else 193 { 194 RTPrintf 175 if (!strcmp(operation, "pause")) 176 { 177 RTPrintf("Pausing the VM...\n"); 178 CHECK_ERROR_BREAK(console, Pause()); 179 } 180 else 181 if (!strcmp(operation, "resume")) 182 { 183 RTPrintf("Resuming the VM...\n"); 184 CHECK_ERROR_BREAK(console, Resume()); 185 } 186 else 187 { 188 RTPrintf("Invalid operation!\n"); 195 189 } 196 190 } … … 200 194 } 201 195 while (0); 202 RTPrintf 196 RTPrintf("\n"); 203 197 204 198 com::Shutdown(); 205 199 206 RTPrintf 200 RTPrintf("tstHeadless FINISHED.\n"); 207 201 208 202 return rc; -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageUSB.cpp
r47908 r50117 5 5 6 6 /* 7 * Copyright (C) 2006-201 3Oracle Corporation7 * Copyright (C) 2006-2014 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 27 27 28 28 #include <iprt/asm.h> 29 30 /* missing XPCOM <-> COM wrappers */31 #ifndef STDMETHOD_32 # define STDMETHOD_(ret, meth) NS_IMETHOD_(ret) meth33 #endif34 #ifndef NS_GET_IID35 # define NS_GET_IID(I) IID_##I36 #endif37 #ifndef RT_OS_WINDOWS38 #define IUnknown nsISupports39 #endif40 29 41 30 using namespace com; … … 71 60 { 72 61 Guid guid(iid); 73 if (guid == Guid( NS_GET_IID(IUnknown)))62 if (guid == Guid(COM_IIDOF(IUnknown))) 74 63 *ppvObject = (IUnknown *)this; 75 64 #ifdef RT_OS_WINDOWS 76 else if (guid == Guid( NS_GET_IID(IDispatch)))65 else if (guid == Guid(COM_IIDOF(IDispatch))) 77 66 *ppvObject = (IDispatch *)this; 78 67 #endif 79 else if (guid == Guid( NS_GET_IID(IUSBDevice)))68 else if (guid == Guid(COM_IIDOF(IUSBDevice))) 80 69 *ppvObject = (IUSBDevice *)this; 81 70 else -
trunk/src/VBox/Frontends/VirtualBox/src/globals/COMDefs.h
r44528 r50117 10 10 11 11 /* 12 * Copyright (C) 2006-201 2Oracle Corporation12 * Copyright (C) 2006-2014 Oracle Corporation 13 13 * 14 14 * This file is part of VirtualBox Open Source Edition (OSE), as … … 49 49 // ... 50 50 51 QVector <LONG> in(3);52 in 53 in 54 in 55 56 QVector 57 QVector 58 59 ret = component.TestArrays 51 QVector<LONG> in(3); 52 in[0] = -1; 53 in[1] = -2; 54 in[2] = -3; 55 56 QVector<LONG> out; 57 QVector<LONG> ret; 58 59 ret = component.TestArrays(in, out); 60 60 61 61 for (size_t i = 0; i < ret.size(); ++ i) 62 LogFlow (("*** ret[%u]=%d\n", i, ret[i]));62 LogFlow(("*** ret[%u]=%d\n", i, ret[i])); 63 63 64 64 * @endcode … … 88 88 */ 89 89 90 #if !defined 91 92 #else /* !defined 90 #if !defined(VBOX_WITH_XPCOM) 91 92 #else /* !defined(VBOX_WITH_XPCOM) */ 93 93 94 94 #include <nsXPCOM.h> … … 98 98 class XPCOMEventQSocketListener; 99 99 100 #endif /* !defined 100 #endif /* !defined(VBOX_WITH_XPCOM) */ 101 101 102 102 103 103 /* VirtualBox interfaces declarations */ 104 #if !defined 104 #if !defined(VBOX_WITH_XPCOM) 105 105 #include <VirtualBox.h> 106 #else /* !defined 106 #else /* !defined(VBOX_WITH_XPCOM) */ 107 107 #include <VirtualBox_XPCOM.h> 108 #endif /* !defined 108 #endif /* !defined(VBOX_WITH_XPCOM) */ 109 109 110 110 ///////////////////////////////////////////////////////////////////////////// … … 170 170 void fetchFromCurrentThread(IUnknown *callee, const GUID *calleeIID); 171 171 172 static QString getInterfaceNameFromIID 172 static QString getInterfaceNameFromIID(const QUuid &id); 173 173 174 174 bool mIsNull : 1; … … 210 210 HRESULT lastRC() const { return mRC; } 211 211 212 #if !defined 212 #if !defined(VBOX_WITH_XPCOM) 213 213 214 214 /** Converts a GUID value to QUuid */ 215 static QUuid ToQUuid 216 { 217 return QUuid 218 219 220 } 221 222 #else /* !defined 215 static QUuid ToQUuid(const GUID &id) 216 { 217 return QUuid(id.Data1, id.Data2, id.Data3, 218 id.Data4[0], id.Data4[1], id.Data4[2], id.Data4[3], 219 id.Data4[4], id.Data4[5], id.Data4[6], id.Data4[7]); 220 } 221 222 #else /* !defined(VBOX_WITH_XPCOM) */ 223 223 224 224 /** Converts a GUID value to QUuid */ 225 static QUuid ToQUuid 226 { 227 return QUuid 228 229 230 } 231 232 #endif /* !defined 225 static QUuid ToQUuid(const nsID &id) 226 { 227 return QUuid(id.m0, id.m1, id.m2, 228 id.m3[0], id.m3[1], id.m3[2], id.m3[3], 229 id.m3[4], id.m3[5], id.m3[6], id.m3[7]); 230 } 231 232 #endif /* !defined(VBOX_WITH_XPCOM) */ 233 233 234 234 /* Arrays of arbitrary types */ 235 235 236 236 template <typename QT, typename CT> 237 static void ToSafeArray (const QVector <QT> &aVec, com::SafeArray<CT> &aArr)238 { 239 aArr.reset 237 static void ToSafeArray(const QVector<QT> &aVec, com::SafeArray<CT> &aArr) 238 { 239 aArr.reset(aVec.size()); 240 240 for (int i = 0; i < aVec.size(); ++i) 241 aArr [i] = static_cast<CT> (aVec.at(i));241 aArr[i] = static_cast<CT>(aVec.at(i)); 242 242 } 243 243 244 244 template <typename CT, typename QT> 245 static void FromSafeArray (const com::SafeArray <CT> &aArr, QVector<QT> &aVec)246 { 247 aVec.resize (static_cast<int>(aArr.size()));245 static void FromSafeArray(const com::SafeArray<CT> &aArr, QVector<QT> &aVec) 246 { 247 aVec.resize(static_cast<int>(aArr.size())); 248 248 for (int i = 0; i < aVec.size(); ++i) 249 aVec [i] = static_cast<QT> (aArr[i]);249 aVec[i] = static_cast<QT>(aArr[i]); 250 250 } 251 251 252 252 template <typename QT, typename CT> 253 static void ToSafeArray (const QVector <QT *> &aVec, com::SafeArray<CT *> &aArr)254 { 255 Q_UNUSED 256 Q_UNUSED 257 AssertMsgFailedReturnVoid 253 static void ToSafeArray(const QVector<QT *> &aVec, com::SafeArray<CT *> &aArr) 254 { 255 Q_UNUSED(aVec); 256 Q_UNUSED(aArr); 257 AssertMsgFailedReturnVoid(("No conversion!\n")); 258 258 } 259 259 260 260 template <typename CT, typename QT> 261 static void FromSafeArray (const com::SafeArray <CT *> &aArr, QVector<QT *> &aVec)262 { 263 Q_UNUSED 264 Q_UNUSED 265 AssertMsgFailedReturnVoid 261 static void FromSafeArray(const com::SafeArray<CT *> &aArr, QVector<QT *> &aVec) 262 { 263 Q_UNUSED(aArr); 264 Q_UNUSED(aVec); 265 AssertMsgFailedReturnVoid(("No conversion!\n")); 266 266 } 267 267 … … 269 269 270 270 template <typename T> 271 static void ToSafeArray (const QVector <T> &aVec, com::SafeArray<T> &aArr)272 { 273 aArr.reset 271 static void ToSafeArray(const QVector<T> &aVec, com::SafeArray<T> &aArr) 272 { 273 aArr.reset(aVec.size()); 274 274 for (int i = 0; i < aVec.size(); ++i) 275 aArr [i] = aVec.at(i);275 aArr[i] = aVec.at(i); 276 276 } 277 277 278 278 template <typename T> 279 static void FromSafeArray (const com::SafeArray <T> &aArr, QVector<T> &aVec)280 { 281 aVec.resize (static_cast<int>(aArr.size()));279 static void FromSafeArray(const com::SafeArray<T> &aArr, QVector<T> &aVec) 280 { 281 aVec.resize(static_cast<int>(aArr.size())); 282 282 for (int i = 0; i < aVec.size(); ++i) 283 aVec [i] = aArr[i];283 aVec[i] = aArr[i]; 284 284 } 285 285 286 286 /* Arrays of strings */ 287 287 288 static void ToSafeArray (const QVector<QString> &aVec,289 com::SafeArray<BSTR> &aArr);290 static void FromSafeArray (const com::SafeArray<BSTR> &aArr,291 QVector<QString> &aVec);288 static void ToSafeArray(const QVector<QString> &aVec, 289 com::SafeArray<BSTR> &aArr); 290 static void FromSafeArray(const com::SafeArray<BSTR> &aArr, 291 QVector<QString> &aVec); 292 292 293 293 /* Arrays of GUID */ 294 294 295 static void ToSafeArray (const QVector<QUuid> &aVec,296 297 static void FromSafeArray 298 QVector<QUuid> &aVec);295 static void ToSafeArray(const QVector<QUuid> &aVec, 296 com::SafeGUIDArray &aArr); 297 static void FromSafeArray(const com::SafeGUIDArray &aArr, 298 QVector<QUuid> &aVec); 299 299 300 300 /* Arrays of enums. Does a cast similar to what ENUMOut does. */ 301 301 302 302 template <typename QE, typename CE> 303 static void ToSafeArray (const QVector<QE> &aVec,304 com::SafeIfaceArray<CE> &aArr)305 { 306 aArr.reset (static_cast <int>(aVec.size()));303 static void ToSafeArray(const QVector<QE> &aVec, 304 com::SafeIfaceArray<CE> &aArr) 305 { 306 aArr.reset(static_cast<int>(aVec.size())); 307 307 for (int i = 0; i < aVec.size(); ++i) 308 aArr [i] = static_cast <CE> (aVec.at(i));308 aArr[i] = static_cast<CE>(aVec.at(i)); 309 309 } 310 310 311 311 template <typename CE, typename QE> 312 static void FromSafeArray (const com::SafeIfaceArray<CE> &aArr,313 QVector<QE> &aVec)314 { 315 aVec.resize (static_cast <int>(aArr.size()));312 static void FromSafeArray(const com::SafeIfaceArray<CE> &aArr, 313 QVector<QE> &aVec) 314 { 315 aVec.resize(static_cast<int>(aArr.size())); 316 316 for (int i = 0; i < aVec.size(); ++i) 317 aVec [i] = static_cast <QE> (aArr[i]);317 aVec[i] = static_cast<QE>(aArr[i]); 318 318 } 319 319 320 320 /* Arrays of interface pointers. Note: we need a separate pair of names 321 321 * only because the MSVC8 template matching algorithm is poor and tries to 322 * instantiate a com::SafeIfaceArray 322 * instantiate a com::SafeIfaceArray<BSTR> (!!!) template otherwise for 323 323 * *no* reason and fails. Note that it's also not possible to choose the 324 324 * correct function by specifying template arguments explicitly because then 325 * it starts to try to instantiate the com::SafeArray 325 * it starts to try to instantiate the com::SafeArray<I> template for 326 326 * *no* reason again and fails too. Definitely, broken. Works in GCC like a 327 327 * charm. */ 328 328 329 329 template <class CI, class I> 330 static void ToSafeIfaceArray (const QVector<CI> &aVec,331 com::SafeIfaceArray<I> &aArr)332 { 333 aArr.reset (static_cast<int>(aVec.size()));330 static void ToSafeIfaceArray(const QVector<CI> &aVec, 331 com::SafeIfaceArray<I> &aArr) 332 { 333 aArr.reset(static_cast<int>(aVec.size())); 334 334 for (int i = 0; i < aVec.size(); ++i) 335 335 { 336 aArr [i] = aVec.at(i).raw();337 if (aArr 338 aArr 336 aArr[i] = aVec.at(i).raw(); 337 if (aArr[i]) 338 aArr[i]->AddRef(); 339 339 } 340 340 } 341 341 342 342 template <class I, class CI> 343 static void FromSafeIfaceArray (const com::SafeIfaceArray<I> &aArr,344 QVector<CI> &aVec)345 { 346 aVec.resize (static_cast<int>(aArr.size()));343 static void FromSafeIfaceArray(const com::SafeIfaceArray<I> &aArr, 344 QVector<CI> &aVec) 345 { 346 aVec.resize(static_cast<int>(aArr.size())); 347 347 for (int i = 0; i < aVec.size(); ++i) 348 aVec [i].attach (aArr[i]);348 aVec[i].attach(aArr[i]); 349 349 } 350 350 … … 352 352 353 353 /* no arbitrary instance creations */ 354 COMBase() : mRC 355 356 #if defined 354 COMBase() : mRC(S_OK) {} 355 356 #if defined(VBOX_WITH_XPCOM) 357 357 static XPCOMEventQSocketListener *sSocketListener; 358 358 #endif … … 363 363 public: 364 364 365 BSTRIn (const QString &s) : bstr (SysAllocString((const OLECHAR *)365 BSTRIn(const QString &s) : bstr(SysAllocString((const OLECHAR *) 366 366 (s.isNull() ? 0 : s.utf16()))) {} 367 367 … … 369 369 { 370 370 if (bstr) 371 SysFreeString 371 SysFreeString(bstr); 372 372 } 373 373 … … 384 384 public: 385 385 386 BSTROut (QString &s) : str (s), bstr(0) {}386 BSTROut(QString &s) : str(s), bstr(0) {} 387 387 388 388 ~BSTROut() 389 389 { 390 390 if (bstr) { 391 str = QString::fromUtf16 392 SysFreeString 391 str = QString::fromUtf16(bstr); 392 SysFreeString(bstr); 393 393 } 394 394 } … … 413 413 public: 414 414 415 ENUMOut (QE &e) : qe (e), ce ((CE)0) {}416 ~ENUMOut() { qe = (QE) 415 ENUMOut(QE &e) : qe(e), ce((CE)0) {} 416 ~ENUMOut() { qe = (QE)ce; } 417 417 operator CE *() { return &ce; } 418 418 … … 423 423 }; 424 424 425 #if !defined 425 #if !defined(VBOX_WITH_XPCOM) 426 426 427 427 /** Adapter to pass QUuid as input GUID params */ 428 static GUID GUIDIn 428 static GUID GUIDIn(const QUuid &uuid) { return uuid; } 429 429 430 430 /** Adapter to pass QUuid as output GUID params */ … … 433 433 public: 434 434 435 GUIDOut (QUuid &id) : uuid(id)436 { 437 ::memset (&guid, 0, sizeof(GUID));435 GUIDOut(QUuid &id) : uuid(id) 436 { 437 ::memset(&guid, 0, sizeof(GUID)); 438 438 } 439 439 440 440 ~GUIDOut() 441 441 { 442 uuid = QUuid 442 uuid = QUuid( 443 443 guid.Data1, guid.Data2, guid.Data3, 444 444 guid.Data4[0], guid.Data4[1], guid.Data4[2], guid.Data4[3], … … 454 454 }; 455 455 456 #else /* !defined 456 #else /* !defined(VBOX_WITH_XPCOM) */ 457 457 458 458 /** Adapter to pass QUuid as input GUID params */ 459 static const nsID &GUIDIn 459 static const nsID &GUIDIn(const QUuid &uuid) 460 460 { 461 461 return *(const nsID *) &uuid; … … 467 467 public: 468 468 469 GUIDOut (QUuid &id) : uuid (id), nsid(0) {}469 GUIDOut(QUuid &id) : uuid(id), nsid(0) {} 470 470 471 471 ~GUIDOut() … … 473 473 if (nsid) 474 474 { 475 uuid = QUuid 475 uuid = QUuid( 476 476 nsid->m0, nsid->m1, nsid->m2, 477 477 nsid->m3[0], nsid->m3[1], nsid->m3[2], nsid->m3[3], 478 478 nsid->m3[4], nsid->m3[5], nsid->m3[6], nsid->m3[7]); 479 nsMemory::Free 479 nsMemory::Free(nsid); 480 480 } 481 481 } … … 489 489 }; 490 490 491 #endif /* !defined 492 493 static void addref 494 static void release 491 #endif /* !defined(VBOX_WITH_XPCOM) */ 492 493 static void addref(IUnknown *aIface) { if (aIface) aIface->AddRef(); } 494 static void release(IUnknown *aIface) { if (aIface) aIface->Release(); } 495 495 496 496 protected: … … 523 523 524 524 /* no arbitrary instance creation */ 525 COMBaseWithEI() : COMBase 526 527 void setErrorInfo 528 529 void fetchErrorInfo 530 { 531 mErrInfo.fetchFromCurrentThread 525 COMBaseWithEI() : COMBase() {}; 526 527 void setErrorInfo(const COMErrorInfo &aErrInfo) { mErrInfo = aErrInfo; } 528 529 void fetchErrorInfo(IUnknown *aCallee, const GUID *aCalleeIID) const 530 { 531 mErrInfo.fetchFromCurrentThread(aCallee, aCalleeIID); 532 532 } 533 533 … … 544 544 public: 545 545 546 COMResult() : mRC 546 COMResult() : mRC(S_OK) {} 547 547 548 548 /** 549 549 * Queries the current result code from the given component. 550 550 */ 551 explicit COMResult 552 : mRC 551 explicit COMResult(const COMBase &aComponent) 552 : mRC(aComponent.lastRC()) {} 553 553 554 554 /** … … 563 563 * Queries the current result code from the given component. 564 564 */ 565 COMResult &operator= 565 COMResult &operator=(const COMBase &aComponent) 566 566 { 567 567 mRC = aComponent.lastRC(); … … 572 572 * Queries the current result code and error info from the given component. 573 573 */ 574 COMResult &operator= 574 COMResult &operator=(const COMBaseWithEI &aComponent) 575 575 { 576 576 mRC = aComponent.lastRC(); … … 585 585 * warnings). 586 586 */ 587 bool isOk() const { return SUCCEEDED 587 bool isOk() const { return SUCCEEDED(mRC); } 588 588 589 589 /** … … 591 591 * warnings. 592 592 */ 593 bool isWarning() const { return SUCCEEDED_WARNING 593 bool isWarning() const { return SUCCEEDED_WARNING(mRC); } 594 594 595 595 /** … … 635 635 } 636 636 637 CInterface (const CInterface &that) : B(that)637 CInterface(const CInterface &that) : B(that) 638 638 { 639 639 clear(); … … 642 642 } 643 643 644 CInterface 644 CInterface(I *aIface) 645 645 { 646 646 clear(); 647 setPtr 648 this->addref 647 setPtr(aIface); 648 this->addref(aIface); 649 649 } 650 650 … … 658 658 659 659 // utility methods 660 void createInstance 661 { 662 AssertMsg 660 void createInstance(const CLSID &aClsId) 661 { 662 AssertMsg(ptr() == NULL, ("Instance is already non-NULL\n")); 663 663 if (ptr() == NULL) 664 664 { 665 665 I* pObj = NULL; 666 #if !defined 667 B::mRC = CoCreateInstance 668 _ATL_IIDOF (I), (void **)&pObj);666 #if !defined(VBOX_WITH_XPCOM) 667 B::mRC = CoCreateInstance(aClsId, NULL, CLSCTX_ALL, 668 _ATL_IIDOF(I), (void **)&pObj); 669 669 #else 670 nsCOMPtr 671 B::mRC = NS_GetComponentManager (getter_AddRefs(manager));672 if (SUCCEEDED 673 B::mRC = manager->CreateInstance (aClsId, nsnull, NS_GET_IID(I),674 (void **)&pObj);675 #endif 676 677 if (SUCCEEDED 670 nsCOMPtr<nsIComponentManager> manager; 671 B::mRC = NS_GetComponentManager(getter_AddRefs(manager)); 672 if (SUCCEEDED(B::mRC)) 673 B::mRC = manager->CreateInstance(aClsId, nsnull, NS_GET_IID(I), 674 (void **)&pObj); 675 #endif 676 677 if (SUCCEEDED(B::mRC)) 678 678 setPtr(pObj); 679 679 else … … 683 683 * reasons can lead to an error (w/o providing error info), not only 684 684 * the instance initialization code (that should always provide it) */ 685 B::fetchErrorInfo 685 B::fetchErrorInfo(NULL, NULL); 686 686 } 687 687 } … … 692 692 */ 693 693 template <class OI> 694 void attach 694 void attach(OI *aIface) 695 695 { 696 696 #ifdef DEBUG … … 699 699 /* be aware of self assignment */ 700 700 I* amIface = ptr(); 701 this->addref 702 this->release 701 this->addref(aIface); 702 this->release(amIface); 703 703 if (aIface) 704 704 { 705 705 amIface = NULL; 706 B::mRC = aIface->QueryInterface (COM_IIDOF (I), (void **)&amIface);707 this->release 706 B::mRC = aIface->QueryInterface(COM_IIDOF(I), (void **)&amIface); 707 this->release(aIface); 708 708 setPtr(amIface); 709 709 } … … 716 716 717 717 /** Specialization of attach() for our own interface I. Never fails. */ 718 void attach 718 void attach(I *aIface) 719 719 { 720 720 #ifdef DEBUG … … 722 722 #endif 723 723 /* be aware of self assignment */ 724 this->addref 725 this->release 724 this->addref(aIface); 725 this->release(ptr()); 726 726 setPtr(aIface); 727 727 B::mRC = S_OK; … … 734 734 Assert(!mDead); 735 735 #endif 736 this->release 736 this->release(ptr()); 737 737 setPtr(NULL); 738 738 } … … 751 751 * warnings). 752 752 */ 753 bool isOk() const { return !isNull() && SUCCEEDED 753 bool isOk() const { return !isNull() && SUCCEEDED(B::mRC); } 754 754 755 755 /** … … 757 757 * warnings. 758 758 */ 759 bool isWarning() const { return !isNull() && SUCCEEDED_WARNING 759 bool isWarning() const { return !isNull() && SUCCEEDED_WARNING(B::mRC); } 760 760 761 761 /** … … 766 766 // utility operators 767 767 768 CInterface &operator= 769 { 770 attach 771 B::operator= 768 CInterface &operator=(const CInterface &that) 769 { 770 attach(that.ptr()); 771 B::operator=(that); 772 772 return *this; 773 773 } 774 774 775 CInterface &operator= 776 { 777 attach 775 CInterface &operator=(I *aIface) 776 { 777 attach(aIface); 778 778 return *this; 779 779 } … … 788 788 } 789 789 790 bool operator== 791 bool operator!= 790 bool operator==(const CInterface &that) const { return ptr() == that.ptr(); } 791 bool operator!=(const CInterface &that) const { return ptr() != that.ptr(); } 792 792 793 793 I* ptr() const … … 825 825 ///////////////////////////////////////////////////////////////////////////// 826 826 827 class CUnknown : public CInterface 827 class CUnknown : public CInterface<IUnknown, COMBaseWithEI> 828 828 { 829 829 public: 830 830 831 typedef CInterface 831 typedef CInterface<IUnknown, COMBaseWithEI> Base; 832 832 833 833 CUnknown() {} … … 835 835 /** Creates an instance given another CInterface-based instance. */ 836 836 template <class OI, class OB> 837 explicit CUnknown (const CInterface<OI, OB> &that)838 { 839 attach 840 if (SUCCEEDED 837 explicit CUnknown(const CInterface<OI, OB> &that) 838 { 839 attach(that.ptr()); 840 if (SUCCEEDED(mRC)) 841 841 { 842 842 /* preserve old error info if any */ 843 843 mRC = that.lastRC(); 844 setErrorInfo 844 setErrorInfo(that.errorInfo()); 845 845 } 846 846 } 847 847 848 848 /** Constructor specialization for IUnknown. */ 849 CUnknown (const CUnknown &that) : Base(that) {}849 CUnknown(const CUnknown &that) : Base(that) {} 850 850 851 851 /** Creates an instance given a foreign interface pointer. */ 852 852 template <class OI> 853 explicit CUnknown 854 { 855 attach 853 explicit CUnknown(OI *aIface) 854 { 855 attach(aIface); 856 856 } 857 857 858 858 /** Constructor specialization for IUnknown. */ 859 explicit CUnknown (IUnknown *aIface) : Base(aIface) {}859 explicit CUnknown(IUnknown *aIface) : Base(aIface) {} 860 860 861 861 /** Assigns from another CInterface-based instance. */ 862 862 template <class OI, class OB> 863 CUnknown &operator= (const CInterface<OI, OB> &that)864 { 865 attach 866 if (SUCCEEDED 863 CUnknown &operator=(const CInterface<OI, OB> &that) 864 { 865 attach(that.ptr()); 866 if (SUCCEEDED(mRC)) 867 867 { 868 868 /* preserve old error info if any */ 869 869 mRC = that.lastRC(); 870 setErrorInfo 870 setErrorInfo(that.errorInfo()); 871 871 } 872 872 return *this; … … 874 874 875 875 /** Assignment specialization for CUnknown. */ 876 CUnknown &operator= 877 { 878 Base::operator= 876 CUnknown &operator=(const CUnknown &that) 877 { 878 Base::operator=(that); 879 879 return *this; 880 880 } … … 882 882 /** Assigns from a foreign interface pointer. */ 883 883 template <class OI> 884 CUnknown &operator= 885 { 886 attach 884 CUnknown &operator=(OI *aIface) 885 { 886 attach(aIface); 887 887 return *this; 888 888 } 889 889 890 890 /** Assignment specialization for IUnknown. */ 891 CUnknown &operator= 892 { 893 Base::operator= 891 CUnknown &operator=(IUnknown *aIface) 892 { 893 Base::operator=(aIface); 894 894 return *this; 895 895 } -
trunk/src/VBox/Main/glue/initterm.cpp
r48282 r50117 6 6 7 7 /* 8 * Copyright (C) 2006-201 3Oracle Corporation8 * Copyright (C) 2006-2014 Oracle Corporation 9 9 * 10 10 * This file is part of VirtualBox Open Source Edition (OSE), as … … 21 21 # include <objbase.h> 22 22 23 #else /* !defined 23 #else /* !defined(VBOX_WITH_XPCOM) */ 24 24 25 25 # include <stdlib.h> … … 173 173 return rv; 174 174 175 return localFile->QueryInterface(NS_GET_IID 175 return localFile->QueryInterface(NS_GET_IID(nsIFile), (void **)aRetval); 176 176 } 177 177 … … 187 187 static unsigned int gXPCOMInitCount = 0; 188 188 189 #else /* !defined 189 #else /* !defined(VBOX_WITH_XPCOM) */ 190 190 191 191 /** … … 199 199 static uint32_t gCOMMainInitCount = 0; 200 200 201 #endif /* !defined 201 #endif /* !defined(VBOX_WITH_XPCOM) */ 202 202 203 203 … … 295 295 gCOMMainInitCount = 1; 296 296 297 #else /* !defined 297 #else /* !defined(VBOX_WITH_XPCOM) */ 298 298 299 299 /* Unused here */ … … 499 499 } 500 500 501 #endif /* !defined 501 #endif /* !defined(VBOX_WITH_XPCOM) */ 502 502 503 503 AssertComRCReturnRC(rc); … … 537 537 CoUninitialize(); 538 538 539 #else /* !defined 539 #else /* !defined(VBOX_WITH_XPCOM) */ 540 540 541 541 nsCOMPtr<nsIEventQueue> eventQ; -
trunk/src/VBox/Main/src-server/xpcom/server_module.cpp
r47117 r50117 5 5 6 6 /* 7 * Copyright (C) 2006-201 1Oracle Corporation7 * Copyright (C) 2006-2014 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 92 92 */ 93 93 94 NS_DECL_CLASSINFO 95 NS_IMPL_CI_INTERFACE_GETTER1 94 NS_DECL_CLASSINFO(VirtualBox) 95 NS_IMPL_CI_INTERFACE_GETTER1(VirtualBox, IVirtualBox) 96 96 97 97 static nsresult vboxsvcSpawnDaemon(void) … … 168 168 */ 169 169 static NS_IMETHODIMP 170 VirtualBoxConstructor 171 170 VirtualBoxConstructor(nsISupports *aOuter, REFNSIID aIID, 171 void **aResult) 172 172 { 173 173 LogFlowFuncEnter(); … … 189 189 /* Get the directory containing XPCOM components -- the VBoxSVC 190 190 * executable is expected in the parent directory. */ 191 nsCOMPtr <nsIProperties> dirServ = do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rc);191 nsCOMPtr<nsIProperties> dirServ = do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rc); 192 192 if (NS_SUCCEEDED(rc)) 193 193 { 194 nsCOMPtr 195 rc = dirServ->Get 196 NS_GET_IID (nsIFile), getter_AddRefs(componentDir));194 nsCOMPtr<nsIFile> componentDir; 195 rc = dirServ->Get(NS_XPCOM_COMPONENT_DIR, 196 NS_GET_IID(nsIFile), getter_AddRefs(componentDir)); 197 197 198 198 if (NS_SUCCEEDED(rc)) 199 199 { 200 200 nsCAutoString path; 201 componentDir->GetNativePath 202 203 LogFlowFunc 204 AssertBreakStmt (path.Length() + strlen(VBoxSVC_exe) < RTPATH_MAX,205 201 componentDir->GetNativePath(path); 202 203 LogFlowFunc(("component directory = \"%s\"\n", path.get())); 204 AssertBreakStmt(path.Length() + strlen(VBoxSVC_exe) < RTPATH_MAX, 205 rc = NS_ERROR_FAILURE); 206 206 207 207 #if defined(RT_OS_SOLARIS) && defined(VBOX_WITH_HARDENING) 208 208 char achKernArch[128]; 209 int cbKernArch = sysinfo 209 int cbKernArch = sysinfo(SI_ARCHITECTURE_K, achKernArch, sizeof(achKernArch)); 210 210 if (cbKernArch > 0) 211 211 { … … 216 216 rc = NS_ERROR_UNEXPECTED; 217 217 #else 218 strcpy 219 RTPathStripFilename 220 strcat 218 strcpy(VBoxSVCPath, path.get()); 219 RTPathStripFilename(VBoxSVCPath); 220 strcat(VBoxSVCPath, VBoxSVC_exe); 221 221 222 222 IsVBoxSVCPathSet = true; … … 228 228 } 229 229 230 nsCOMPtr <ipcIService> ipcServ = do_GetService(IPC_SERVICE_CONTRACTID, &rc);230 nsCOMPtr<ipcIService> ipcServ = do_GetService(IPC_SERVICE_CONTRACTID, &rc); 231 231 if (NS_FAILED(rc)) 232 232 break; … … 239 239 do 240 240 { 241 LogFlowFunc 241 LogFlowFunc(("Resolving server name \"%s\"...\n", VBOXSVC_IPC_NAME)); 242 242 243 243 PRUint32 serverID = 0; 244 rc = ipcServ->ResolveClientName 244 rc = ipcServ->ResolveClientName(VBOXSVC_IPC_NAME, &serverID); 245 245 if (NS_FAILED(rc)) 246 246 { 247 LogFlowFunc 247 LogFlowFunc(("Starting server \"%s\"...\n", VBoxSVCPath)); 248 248 249 249 startedOnce = true; … … 256 256 do 257 257 { 258 RTThreadSleep 259 rc = ipcServ->ResolveClientName 258 RTThreadSleep(VBoxSVC_WaitSlice); 259 rc = ipcServ->ResolveClientName(VBOXSVC_IPC_NAME, &serverID); 260 260 if (NS_SUCCEEDED(rc)) 261 261 break; … … 276 276 } 277 277 278 LogFlowFunc 279 280 nsCOMPtr 281 do_GetService 278 LogFlowFunc(("Connecting to server (ID=%d)...\n", serverID)); 279 280 nsCOMPtr<ipcIDConnectService> dconServ = 281 do_GetService(IPC_DCONNECTSERVICE_CONTRACTID, &rc); 282 282 if (NS_FAILED(rc)) 283 283 break; 284 284 285 rc = dconServ->CreateInstance 286 287 285 rc = dconServ->CreateInstance(serverID, 286 CLSID_VirtualBox, 287 aIID, aResult); 288 288 if (NS_SUCCEEDED(rc)) 289 289 break; 290 290 291 LogFlowFunc 291 LogFlowFunc(("Failed to connect (rc=%Rhrc (%#08x))\n", rc, rc)); 292 292 293 293 /* It's possible that the server gets shut down after we … … 298 298 { 299 299 nsresult rc2 = 300 ipcServ->ResolveClientName 300 ipcServ->ResolveClientName(VBOXSVC_IPC_NAME, &serverID); 301 301 if (NS_SUCCEEDED(rc2)) 302 302 break; 303 303 304 LogFlowFunc (("Server seems to have terminated before " 305 "receiving our request. Will try again.\n")); 304 LogFlowFunc(("Server seems to have terminated before receiving our request. Will try again.\n")); 306 305 } 307 306 else … … 312 311 while (0); 313 312 314 LogFlowFunc 313 LogFlowFunc(("rc=%Rhrc (%#08x), vrc=%Rrc\n", rc, rc, vrc)); 315 314 LogFlowFuncLeave(); 316 315 … … 331 330 */ 332 331 static NS_IMETHODIMP 333 VirtualBoxRegistration 334 335 336 337 332 VirtualBoxRegistration(nsIComponentManager *aCompMgr, 333 nsIFile *aPath, 334 const char *aLoaderStr, 335 const char *aType, 336 const nsModuleComponentInfo *aInfo) 338 337 { 339 338 nsCAutoString modulePath; 340 aPath->GetNativePath 339 aPath->GetNativePath(modulePath); 341 340 nsCAutoString moduleTarget; 342 aPath->GetNativeTarget 343 344 LogFlowFunc 345 341 aPath->GetNativeTarget(moduleTarget); 342 343 LogFlowFunc(("aPath=%s, aTarget=%s, aLoaderStr=%s, aType=%s\n", 344 modulePath.get(), moduleTarget.get(), aLoaderStr, aType)); 346 345 347 346 nsresult rc = NS_OK; … … 372 371 }; 373 372 374 NS_IMPL_NSGETMODULE 373 NS_IMPL_NSGETMODULE(VirtualBox_Server_Module, components) -
trunk/src/VBox/Main/testcase/tstAPI.cpp
r48955 r50117 5 5 6 6 /* 7 * Copyright (C) 2006-201 2Oracle Corporation7 * Copyright (C) 2006-2014 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 25 25 #include <VBox/com/ErrorInfo.h> 26 26 #include <VBox/com/errorprint.h> 27 #include <VBox/com/EventQueue.h>28 27 29 28 #include <VBox/com/VirtualBox.h> … … 369 368 } 370 369 #endif 371 372 // create the event queue373 // (here it is necessary only to process remaining XPCOM/IPC events374 // after the session is closed)375 EventQueue eventQ;376 370 377 371 #if 0 -
trunk/src/VBox/Main/testcase/tstOVF.cpp
r45068 r50117 6 6 7 7 /* 8 * Copyright (C) 2010-201 3Oracle Corporation8 * Copyright (C) 2010-2014 Oracle Corporation 9 9 * 10 10 * This file is part of VirtualBox Open Source Edition (OSE), as … … 24 24 #include <VBox/com/ErrorInfo.h> 25 25 #include <VBox/com/errorprint.h> 26 #include <VBox/com/EventQueue.h>27 26 28 27 #include <iprt/initterm.h> … … 306 305 if (FAILED(rc)) throw MyError(rc, "failed to create a session object!\n"); 307 306 308 // create the event queue309 // (here it is necessary only to process remaining XPCOM/IPC events after the session is closed)310 EventQueue eventQ;311 312 307 // for each testcase, we will copy the dummy VMDK image to the subdirectory with the OVF testcase 313 308 // so that the import will find the disks it expects; this is just for testing the import since -
trunk/src/VBox/Main/testcase/tstVBoxAPIXPCOM.cpp
r49452 r50117 8 8 9 9 /* 10 * Copyright (C) 2006-201 3Oracle Corporation10 * Copyright (C) 2006-2014 Oracle Corporation 11 11 * 12 12 * This file is part of VirtualBox Open Source Edition (OSE), as … … 80 80 #include <VBox/com/ErrorInfo.h> 81 81 #include <VBox/com/errorprint.h> 82 #include <VBox/com/EventQueue.h>83 82 84 83 #include <VBox/com/VirtualBox.h> -
trunk/src/VBox/Main/webservice/websrv-cpp.xsl
r47578 r50117 12 12 generated for the webservice. 13 13 14 Copyright (C) 2007-201 3Oracle Corporation14 Copyright (C) 2007-2014 Oracle Corporation 15 15 16 16 This file is part of VirtualBox Open Source Edition (OSE), as … … 66 66 #include <VBox/com/ErrorInfo.h> 67 67 #include <VBox/com/errorprint.h> 68 #include <VBox/com/EventQueue.h>69 68 #include <VBox/VBoxAuth.h> 70 69
Note:
See TracChangeset
for help on using the changeset viewer.