Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

781 lines
23 KiB

  1. // --------------------------------------------------------------------------------
  2. // Factory.cpp
  3. // Copyright (c)1993-1995 Microsoft Corporation, All Rights Reserved
  4. // Steven J. Bailey
  5. // --------------------------------------------------------------------------------
  6. #include "pch.hxx"
  7. #include "dllmain.h"
  8. #include "factory.h"
  9. #include "ixppop3.h"
  10. #include "ixpsmtp.h"
  11. #include "ixpnntp.h"
  12. #include "ixphttpm.h"
  13. #include "ixpras.h"
  14. #include "imap4.h"
  15. #include "range.h"
  16. #include "olealloc.h"
  17. #include "smime.h"
  18. #include "vstream.h"
  19. #include "icoint.h"
  20. #include "internat.h"
  21. #include "partial.h"
  22. #include "docobj.h"
  23. #include "doc.h"
  24. #include "hash.h"
  25. #include "fontcash.h"
  26. #include "propfind.h"
  27. // --------------------------------------------------------------------------------
  28. // Pretty
  29. // --------------------------------------------------------------------------------
  30. #define OBJTYPE0 0
  31. #define OBJTYPE1 OIF_ALLOWAGGREGATION
  32. // --------------------------------------------------------------------------------
  33. // Global Object Info Table
  34. // --------------------------------------------------------------------------------
  35. static CClassFactory g_rgFactory[] = {
  36. CClassFactory(&CLSID_IMimePropertySet, OBJTYPE1, (PFCREATEINSTANCE)WebBookContentBody_CreateInstance),
  37. CClassFactory(&CLSID_IMimeBody, OBJTYPE1, (PFCREATEINSTANCE)WebBookContentBody_CreateInstance),
  38. CClassFactory(&CLSID_IMimeBodyW, OBJTYPE1, (PFCREATEINSTANCE)WebBookContentBody_CreateInstance),
  39. CClassFactory(&CLSID_IMimeMessageTree, OBJTYPE1, (PFCREATEINSTANCE)WebBookContentTree_CreateInstance),
  40. CClassFactory(&CLSID_IMimeMessage, OBJTYPE1, (PFCREATEINSTANCE)WebBookContentTree_CreateInstance),
  41. CClassFactory(&CLSID_IMimeMessageW, OBJTYPE1, (PFCREATEINSTANCE)WebBookContentTree_CreateInstance),
  42. CClassFactory(&CLSID_IMimeAllocator, OBJTYPE0, (PFCREATEINSTANCE)IMimeAllocator_CreateInstance),
  43. CClassFactory(&CLSID_IMimeSecurity, OBJTYPE0, (PFCREATEINSTANCE)IMimeSecurity_CreateInstance),
  44. CClassFactory(&CLSID_IMimeMessageParts, OBJTYPE0, (PFCREATEINSTANCE)IMimeMessageParts_CreateInstance),
  45. CClassFactory(&CLSID_IMimeInternational, OBJTYPE0, (PFCREATEINSTANCE)IMimeInternational_CreateInstance),
  46. CClassFactory(&CLSID_IMimeHeaderTable, OBJTYPE0, (PFCREATEINSTANCE)IMimeHeaderTable_CreateInstance),
  47. CClassFactory(&CLSID_IMimePropertySchema, OBJTYPE0, (PFCREATEINSTANCE)IMimePropertySchema_CreateInstance),
  48. CClassFactory(&CLSID_IVirtualStream, OBJTYPE0, (PFCREATEINSTANCE)IVirtualStream_CreateInstance),
  49. CClassFactory(&CLSID_IMimeHtmlProtocol, OBJTYPE1, (PFCREATEINSTANCE)IMimeHtmlProtocol_CreateInstance),
  50. CClassFactory(&CLSID_ISMTPTransport, OBJTYPE0, (PFCREATEINSTANCE)ISMTPTransport_CreateInstance),
  51. CClassFactory(&CLSID_IPOP3Transport, OBJTYPE0, (PFCREATEINSTANCE)IPOP3Transport_CreateInstance),
  52. CClassFactory(&CLSID_INNTPTransport, OBJTYPE0, (PFCREATEINSTANCE)INNTPTransport_CreateInstance),
  53. CClassFactory(&CLSID_IRASTransport, OBJTYPE0, (PFCREATEINSTANCE)IRASTransport_CreateInstance),
  54. CClassFactory(&CLSID_IIMAPTransport, OBJTYPE0, (PFCREATEINSTANCE)IIMAPTransport_CreateInstance),
  55. CClassFactory(&CLSID_IRangeList, OBJTYPE0, (PFCREATEINSTANCE)IRangeList_CreateInstance),
  56. CClassFactory(&CLSID_MimeEdit, OBJTYPE1, (PFCREATEINSTANCE)MimeEdit_CreateInstance),
  57. CClassFactory(&CLSID_IHashTable, OBJTYPE0, (PFCREATEINSTANCE)IHashTable_CreateInstance),
  58. CClassFactory(&CLSID_IFontCache, OBJTYPE1, (PFCREATEINSTANCE)CFontCache::CreateInstance),
  59. #ifndef NOHTTPMAIL
  60. CClassFactory(&CLSID_IHTTPMailTransport, OBJTYPE0, (PFCREATEINSTANCE)IHTTPMailTransport_CreateInstance),
  61. CClassFactory(&CLSID_IPropFindRequest, OBJTYPE0, (PFCREATEINSTANCE)IPropFindRequest_CreateInstance),
  62. CClassFactory(&CLSID_IPropPatchRequest, OBJTYPE0, (PFCREATEINSTANCE)IPropPatchRequest_CreateInstance),
  63. #endif
  64. };
  65. // --------------------------------------------------------------------------------
  66. // DllGetClassObject
  67. // --------------------------------------------------------------------------------
  68. STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
  69. {
  70. // Locals
  71. HRESULT hr=S_OK;
  72. ULONG i;
  73. // Bad param
  74. if (ppv == NULL)
  75. {
  76. hr = TrapError(E_INVALIDARG);
  77. goto exit;
  78. }
  79. // No memory allocator
  80. if (NULL == g_pMalloc)
  81. {
  82. hr = TrapError(E_OUTOFMEMORY);
  83. goto exit;
  84. }
  85. // Find Object Class
  86. for (i=0; i<ARRAYSIZE(g_rgFactory); i++)
  87. {
  88. // Compare for clsids
  89. if (IsEqualCLSID(rclsid, *g_rgFactory[i].m_pclsid))
  90. {
  91. // Delegate to the factory
  92. CHECKHR(hr = g_rgFactory[i].QueryInterface(riid, ppv));
  93. // Done
  94. goto exit;
  95. }
  96. }
  97. // Otherwise, no class
  98. hr = TrapError(CLASS_E_CLASSNOTAVAILABLE);
  99. exit:
  100. // Done
  101. return hr;
  102. }
  103. // --------------------------------------------------------------------------------
  104. // CClassFactory::CClassFactory
  105. // --------------------------------------------------------------------------------
  106. CClassFactory::CClassFactory(CLSID const *pclsid, DWORD dwFlags, PFCREATEINSTANCE pfCreateInstance)
  107. : m_pclsid(pclsid), m_dwFlags(dwFlags), m_pfCreateInstance(pfCreateInstance)
  108. {
  109. }
  110. // --------------------------------------------------------------------------------
  111. // CClassFactory::QueryInterface
  112. // --------------------------------------------------------------------------------
  113. STDMETHODIMP CClassFactory::QueryInterface(REFIID riid, void **ppvObj)
  114. {
  115. // Invalid Arg
  116. if (NULL == ppvObj)
  117. return TrapError(E_INVALIDARG);
  118. // IClassFactory or IUnknown
  119. if (!IsEqualIID(riid, IID_IClassFactory) && !IsEqualIID(riid, IID_IUnknown))
  120. return TrapError(E_NOINTERFACE);
  121. // Return the Class Facotry
  122. *ppvObj = (LPVOID)this;
  123. // Add Ref the dll
  124. DllAddRef();
  125. // Done
  126. return S_OK;
  127. }
  128. // --------------------------------------------------------------------------------
  129. // CClassFactory::AddRef
  130. // --------------------------------------------------------------------------------
  131. STDMETHODIMP_(ULONG) CClassFactory::AddRef(void)
  132. {
  133. DllAddRef();
  134. return 2;
  135. }
  136. // --------------------------------------------------------------------------------
  137. // CClassFactory::Release
  138. // --------------------------------------------------------------------------------
  139. STDMETHODIMP_(ULONG) CClassFactory::Release(void)
  140. {
  141. DllRelease();
  142. return 1;
  143. }
  144. // --------------------------------------------------------------------------------
  145. // CClassFactory::CreateInstance
  146. // --------------------------------------------------------------------------------
  147. STDMETHODIMP CClassFactory::CreateInstance(IUnknown *pUnkOuter, REFIID riid, void **ppvObj)
  148. {
  149. // Locals
  150. HRESULT hr=S_OK;
  151. IUnknown *pObject=NULL;
  152. // Bad param
  153. if (ppvObj == NULL)
  154. return TrapError(E_INVALIDARG);
  155. // Init
  156. *ppvObj = NULL;
  157. // Verify that a controlling unknown asks for IUnknown
  158. if (NULL != pUnkOuter && IID_IUnknown != riid)
  159. return TrapError(CLASS_E_NOAGGREGATION);
  160. // No memory allocator
  161. if (NULL == g_pMalloc)
  162. return TrapError(E_OUTOFMEMORY);
  163. // Can I do aggregaton
  164. if (pUnkOuter !=NULL && !(m_dwFlags & OIF_ALLOWAGGREGATION))
  165. return TrapError(CLASS_E_NOAGGREGATION);
  166. // Create the object...
  167. CHECKHR(hr = CreateObjectInstance(pUnkOuter, &pObject));
  168. // Aggregated, then we know we're looking for an IUnknown, return pObject, otherwise, QI
  169. if (pUnkOuter)
  170. {
  171. // Matches Release after Exit
  172. pObject->AddRef();
  173. // Return pObject::IUnknown
  174. *ppvObj = (LPVOID)pObject;
  175. }
  176. // Otherwise
  177. else
  178. {
  179. // Get the interface requested from pObj
  180. CHECKHR(hr = pObject->QueryInterface(riid, ppvObj));
  181. }
  182. exit:
  183. // Cleanup
  184. SafeRelease(pObject);
  185. // Done
  186. Assert(FAILED(hr) ? NULL == *ppvObj : TRUE);
  187. return hr;
  188. }
  189. // --------------------------------------------------------------------------------
  190. // CClassFactory::LockServer
  191. // --------------------------------------------------------------------------------
  192. STDMETHODIMP CClassFactory::LockServer(BOOL fLock)
  193. {
  194. if (fLock) InterlockedIncrement(&g_cLock);
  195. else InterlockedDecrement(&g_cLock);
  196. return NOERROR;
  197. }
  198. // --------------------------------------------------------------------------------
  199. // CreateRASTransport
  200. // --------------------------------------------------------------------------------
  201. IMNXPORTAPI CreateRASTransport(
  202. /* out */ IRASTransport **ppTransport)
  203. {
  204. // check params
  205. if (NULL == ppTransport)
  206. return TrapError(E_INVALIDARG);
  207. // Create the object
  208. *ppTransport = new CRASTransport();
  209. if (NULL == *ppTransport)
  210. return TrapError(E_OUTOFMEMORY);
  211. // Done
  212. return S_OK;
  213. }
  214. // --------------------------------------------------------------------------------
  215. // CreateNNTPTransport
  216. // --------------------------------------------------------------------------------
  217. IMNXPORTAPI CreateNNTPTransport(
  218. /* out */ INNTPTransport **ppTransport)
  219. {
  220. // check params
  221. if (NULL == ppTransport)
  222. return TrapError(E_INVALIDARG);
  223. // Create the object
  224. *ppTransport = new CNNTPTransport();
  225. if (NULL == *ppTransport)
  226. return TrapError(E_OUTOFMEMORY);
  227. // Done
  228. return S_OK;
  229. }
  230. // --------------------------------------------------------------------------------
  231. // CreateSMTPTransport
  232. // --------------------------------------------------------------------------------
  233. IMNXPORTAPI CreateSMTPTransport(
  234. /* out */ ISMTPTransport **ppTransport)
  235. {
  236. // check params
  237. if (NULL == ppTransport)
  238. return TrapError(E_INVALIDARG);
  239. // Create the object
  240. *ppTransport = new CSMTPTransport();
  241. if (NULL == *ppTransport)
  242. return TrapError(E_OUTOFMEMORY);
  243. // Done
  244. return S_OK;
  245. }
  246. // --------------------------------------------------------------------------------
  247. // CreatePOP3Transport
  248. // --------------------------------------------------------------------------------
  249. IMNXPORTAPI CreatePOP3Transport(
  250. /* out */ IPOP3Transport **ppTransport)
  251. {
  252. // check params
  253. if (NULL == ppTransport)
  254. return TrapError(E_INVALIDARG);
  255. // Create the object
  256. *ppTransport = new CPOP3Transport();
  257. if (NULL == *ppTransport)
  258. return TrapError(E_OUTOFMEMORY);
  259. // Done
  260. return S_OK;
  261. }
  262. // --------------------------------------------------------------------------------
  263. // CreateIMAPTransport
  264. // --------------------------------------------------------------------------------
  265. IMNXPORTAPI CreateIMAPTransport(
  266. /* out */ IIMAPTransport **ppTransport)
  267. {
  268. // check params
  269. if (NULL == ppTransport)
  270. return TrapError(E_INVALIDARG);
  271. // Create the object
  272. *ppTransport = (IIMAPTransport *) new CImap4Agent();
  273. if (NULL == *ppTransport)
  274. return TrapError(E_OUTOFMEMORY);
  275. // Done
  276. return S_OK;
  277. }
  278. // --------------------------------------------------------------------------------
  279. // CreateIMAPTransport2
  280. // --------------------------------------------------------------------------------
  281. IMNXPORTAPI CreateIMAPTransport2(
  282. /* out */ IIMAPTransport2 **ppTransport)
  283. {
  284. // check params
  285. if (NULL == ppTransport)
  286. return TrapError(E_INVALIDARG);
  287. // Create the object
  288. *ppTransport = (IIMAPTransport2 *) new CImap4Agent();
  289. if (NULL == *ppTransport)
  290. return TrapError(E_OUTOFMEMORY);
  291. // Done
  292. return S_OK;
  293. }
  294. // --------------------------------------------------------------------------------
  295. // CreateRangeList
  296. // --------------------------------------------------------------------------------
  297. IMNXPORTAPI CreateRangeList(
  298. /* out */ IRangeList **ppRangeList)
  299. {
  300. // check params
  301. if (NULL == ppRangeList)
  302. return TrapError(E_INVALIDARG);
  303. // Create the object
  304. *ppRangeList = (IRangeList *) new CRangeList();
  305. if (NULL == *ppRangeList)
  306. return TrapError(E_OUTOFMEMORY);
  307. // Done
  308. return S_OK;
  309. }
  310. // --------------------------------------------------------------------------------
  311. // IMimeAllocator_CreateInstance
  312. // --------------------------------------------------------------------------------
  313. HRESULT IMimeAllocator_CreateInstance(IUnknown* pUnkOuter, IUnknown** ppUnknown)
  314. {
  315. // Invalid Arg
  316. Assert(ppUnknown);
  317. // Initialize
  318. *ppUnknown = NULL;
  319. // Create me
  320. CMimeAllocator *pNew = new CMimeAllocator();
  321. if (NULL == pNew)
  322. return TrapError(E_OUTOFMEMORY);
  323. // Cast to unknown
  324. *ppUnknown = SAFECAST(pNew, IMimeAllocator *);
  325. // Done
  326. return S_OK;
  327. }
  328. // --------------------------------------------------------------------------------
  329. // IMimeSecurity_CreateInstance
  330. // --------------------------------------------------------------------------------
  331. HRESULT IMimeSecurity_CreateInstance(IUnknown* pUnkOuter, IUnknown** ppUnknown)
  332. {
  333. // Invalid Arg
  334. Assert(ppUnknown);
  335. // Initialize
  336. *ppUnknown = NULL;
  337. // Create me
  338. CSMime *pNew = new CSMime();
  339. if (NULL == pNew)
  340. return TrapError(E_OUTOFMEMORY);
  341. // Cast to unknown
  342. *ppUnknown = SAFECAST(pNew, IMimeSecurity *);
  343. // Done
  344. return S_OK;
  345. }
  346. // --------------------------------------------------------------------------------
  347. // IMimePropertySchema_CreateInstance
  348. // --------------------------------------------------------------------------------
  349. HRESULT IMimePropertySchema_CreateInstance(IUnknown* pUnkOuter, IUnknown** ppUnknown)
  350. {
  351. // Invalid Arg
  352. Assert(ppUnknown);
  353. // Initialize
  354. *ppUnknown = NULL;
  355. // Out of memory
  356. if (NULL == g_pSymCache)
  357. return TrapError(E_OUTOFMEMORY);
  358. // Create me
  359. *ppUnknown = ((IUnknown *)((IMimePropertySchema *)g_pSymCache));
  360. // Increase RefCount
  361. (*ppUnknown)->AddRef();
  362. // Done
  363. return S_OK;
  364. }
  365. // --------------------------------------------------------------------------------
  366. // IMimeInternational_CreateInstance
  367. // --------------------------------------------------------------------------------
  368. HRESULT IMimeInternational_CreateInstance(IUnknown* pUnkOuter, IUnknown** ppUnknown)
  369. {
  370. // Invalid Arg
  371. Assert(ppUnknown);
  372. // Initialize
  373. *ppUnknown = NULL;
  374. // Outof memory
  375. if (NULL == g_pInternat)
  376. return TrapError(E_OUTOFMEMORY);
  377. // Assign It
  378. *ppUnknown = ((IUnknown *)((IMimeInternational *)g_pInternat));
  379. // Increase RefCount
  380. (*ppUnknown)->AddRef();
  381. // Done
  382. return S_OK;
  383. }
  384. // --------------------------------------------------------------------------------
  385. // ISMTPTransport_CreateInstance
  386. // --------------------------------------------------------------------------------
  387. HRESULT ISMTPTransport_CreateInstance(IUnknown* pUnkOuter, IUnknown** ppUnknown)
  388. {
  389. // Invalid Arg
  390. Assert(ppUnknown);
  391. // Initialize
  392. *ppUnknown = NULL;
  393. // Create me
  394. CSMTPTransport *pNew = new CSMTPTransport();
  395. if (NULL == pNew)
  396. return TrapError(E_OUTOFMEMORY);
  397. // Cast to unknown
  398. *ppUnknown = SAFECAST(pNew, ISMTPTransport *);
  399. // Done
  400. return S_OK;
  401. }
  402. // --------------------------------------------------------------------------------
  403. // IPOP3Transport_CreateInstance
  404. // --------------------------------------------------------------------------------
  405. HRESULT IPOP3Transport_CreateInstance(IUnknown* pUnkOuter, IUnknown** ppUnknown)
  406. {
  407. // Invalid Arg
  408. Assert(ppUnknown);
  409. // Initialize
  410. *ppUnknown = NULL;
  411. // Create me
  412. CPOP3Transport *pNew = new CPOP3Transport();
  413. if (NULL == pNew)
  414. return TrapError(E_OUTOFMEMORY);
  415. // Cast to unknown
  416. *ppUnknown = SAFECAST(pNew, IPOP3Transport *);
  417. // Done
  418. return S_OK;
  419. }
  420. #ifndef NOHTTPMAIL
  421. // --------------------------------------------------------------------------------
  422. // IHTTPMailTransport_CreateInstance
  423. // --------------------------------------------------------------------------------
  424. HRESULT IHTTPMailTransport_CreateInstance(IUnknown* pUnkOuter, IUnknown** ppUnknown)
  425. {
  426. // Invalid Arg
  427. Assert(ppUnknown);
  428. // Initialize
  429. *ppUnknown = NULL;
  430. // Create me
  431. CHTTPMailTransport *pNew = new CHTTPMailTransport();
  432. if (NULL == pNew)
  433. return TrapError(E_OUTOFMEMORY);
  434. // Cast to unknown
  435. *ppUnknown = SAFECAST(pNew, IHTTPMailTransport *);
  436. // Done
  437. return S_OK;
  438. }
  439. // --------------------------------------------------------------------------------
  440. // IPropFindRequest_CreateInstance
  441. // --------------------------------------------------------------------------------
  442. HRESULT IPropFindRequest_CreateInstance(IUnknown* pUnkOuter, IUnknown** ppUnknown)
  443. {
  444. // Invalid Arg
  445. Assert(ppUnknown);
  446. // Initialize
  447. *ppUnknown = NULL;
  448. // Create me
  449. CPropFindRequest *pNew = new CPropFindRequest();
  450. if (NULL == pNew)
  451. return TrapError(E_OUTOFMEMORY);
  452. // Cast to unknown
  453. *ppUnknown = SAFECAST(pNew, IPropFindRequest *);
  454. // Done
  455. return S_OK;
  456. }
  457. // --------------------------------------------------------------------------------
  458. // IPropPatchRequest_CreateInstance
  459. // --------------------------------------------------------------------------------
  460. HRESULT IPropPatchRequest_CreateInstance(IUnknown* pUnkOuter, IUnknown** ppUnknown)
  461. {
  462. // Invalid Arg
  463. Assert(ppUnknown);
  464. // Initialize
  465. *ppUnknown = NULL;
  466. // Create me
  467. CPropPatchRequest *pNew = new CPropPatchRequest();
  468. if (NULL == pNew)
  469. return TrapError(E_OUTOFMEMORY);
  470. // Cast to unknown
  471. *ppUnknown = SAFECAST(pNew, IPropPatchRequest *);
  472. // Done
  473. return S_OK;
  474. }
  475. #endif
  476. // --------------------------------------------------------------------------------
  477. // INNTPTransport_CreateInstance
  478. // --------------------------------------------------------------------------------
  479. HRESULT INNTPTransport_CreateInstance(IUnknown* pUnkOuter, IUnknown** ppUnknown)
  480. {
  481. // Invalid Arg
  482. Assert(ppUnknown);
  483. // Initialize
  484. *ppUnknown = NULL;
  485. // Create me
  486. CNNTPTransport *pNew = new CNNTPTransport();
  487. if (NULL == pNew)
  488. return TrapError(E_OUTOFMEMORY);
  489. // Cast to unknown
  490. *ppUnknown = SAFECAST(pNew, INNTPTransport *);
  491. // Done
  492. return S_OK;
  493. }
  494. // --------------------------------------------------------------------------------
  495. // IRASTransport_CreateInstance
  496. // --------------------------------------------------------------------------------
  497. HRESULT IRASTransport_CreateInstance(IUnknown* pUnkOuter, IUnknown** ppUnknown)
  498. {
  499. // Invalid Arg
  500. Assert(ppUnknown);
  501. // Initialize
  502. *ppUnknown = NULL;
  503. // Create me
  504. CRASTransport *pNew = new CRASTransport();
  505. if (NULL == pNew)
  506. return TrapError(E_OUTOFMEMORY);
  507. // Cast to unknown
  508. *ppUnknown = SAFECAST(pNew, IRASTransport *);
  509. // Done
  510. return S_OK;
  511. }
  512. // --------------------------------------------------------------------------------
  513. // IIMAPTransport_CreateInstance
  514. // --------------------------------------------------------------------------------
  515. HRESULT IIMAPTransport_CreateInstance(IUnknown* pUnkOuter, IUnknown** ppUnknown)
  516. {
  517. // Invalid Arg
  518. Assert(ppUnknown);
  519. // Initialize
  520. *ppUnknown = NULL;
  521. // Create me
  522. CImap4Agent *pNew = new CImap4Agent();
  523. if (NULL == pNew)
  524. return TrapError(E_OUTOFMEMORY);
  525. // Cast to unknown
  526. *ppUnknown = SAFECAST(pNew, IIMAPTransport *);
  527. // Done
  528. return S_OK;
  529. }
  530. // --------------------------------------------------------------------------------
  531. // IRangeList_CreateInstance
  532. // --------------------------------------------------------------------------------
  533. HRESULT IRangeList_CreateInstance(IUnknown* pUnkOuter, IUnknown** ppUnknown)
  534. {
  535. // Invalid Arg
  536. Assert(ppUnknown);
  537. // Initialize
  538. *ppUnknown = NULL;
  539. // Create me
  540. CRangeList *pNew = new CRangeList();
  541. if (NULL == pNew)
  542. return TrapError(E_OUTOFMEMORY);
  543. // Cast to unknown
  544. *ppUnknown = SAFECAST(pNew, IRangeList *);
  545. // Done
  546. return S_OK;
  547. }
  548. // --------------------------------------------------------------------------------
  549. // IVirtualStream_CreateInstance
  550. // --------------------------------------------------------------------------------
  551. HRESULT IVirtualStream_CreateInstance(IUnknown* pUnkOuter, IUnknown** ppUnknown)
  552. {
  553. // Invalid Arg
  554. Assert(ppUnknown);
  555. // Initialize
  556. *ppUnknown = NULL;
  557. // Create me
  558. CVirtualStream *pNew = new CVirtualStream();
  559. if (NULL == pNew)
  560. return TrapError(E_OUTOFMEMORY);
  561. // Cast to unknown
  562. *ppUnknown = SAFECAST(pNew, IStream *);
  563. // Done
  564. return S_OK;
  565. }
  566. // --------------------------------------------------------------------------------
  567. // IMimeMessageParts_CreateInstance
  568. // --------------------------------------------------------------------------------
  569. HRESULT IMimeMessageParts_CreateInstance(IUnknown* pUnkOuter, IUnknown** ppUnknown)
  570. {
  571. // Invalid Arg
  572. Assert(ppUnknown);
  573. // Initialize
  574. *ppUnknown = NULL;
  575. // Create me
  576. CMimeMessageParts *pNew = new CMimeMessageParts();
  577. if (NULL == pNew)
  578. return TrapError(E_OUTOFMEMORY);
  579. // Cast to unknown
  580. *ppUnknown = SAFECAST(pNew, IMimeMessageParts *);
  581. // Done
  582. return S_OK;
  583. }
  584. // --------------------------------------------------------------------------------
  585. // IMimeHeaderTable_CreateInstance
  586. // --------------------------------------------------------------------------------
  587. HRESULT IMimeHeaderTable_CreateInstance(IUnknown* pUnkOuter, IUnknown** ppUnknown)
  588. {
  589. // Invalid Arg
  590. Assert(ppUnknown);
  591. // Initialize
  592. *ppUnknown = NULL;
  593. // Create me
  594. return TrapError(MimeOleCreateHeaderTable((IMimeHeaderTable **)ppUnknown));
  595. }
  596. // --------------------------------------------------------------------------------
  597. // MimeEdit_CreateInstance
  598. // --------------------------------------------------------------------------------
  599. HRESULT MimeEdit_CreateInstance(IUnknown* pUnkOuter, IUnknown** ppUnknown)
  600. {
  601. // Invalid Arg
  602. Assert(ppUnknown);
  603. // Initialize
  604. *ppUnknown = NULL;
  605. // Create me
  606. CDoc *pNew = new CDoc(pUnkOuter);
  607. if (NULL == pNew)
  608. return (E_OUTOFMEMORY);
  609. // Return the Innter
  610. *ppUnknown = pNew->GetInner();
  611. // Done
  612. return S_OK;
  613. }
  614. // --------------------------------------------------------------------------------
  615. // IHashTable_CreateInstance
  616. // --------------------------------------------------------------------------------
  617. HRESULT IHashTable_CreateInstance(IUnknown* pUnkOuter, IUnknown** ppUnknown)
  618. {
  619. // Invalid Arg
  620. Assert(ppUnknown);
  621. // Initialize
  622. *ppUnknown = NULL;
  623. // Create me
  624. CHash *pNew= new CHash(pUnkOuter);
  625. if (NULL == pNew)
  626. return (E_OUTOFMEMORY);
  627. // Return the Innter
  628. *ppUnknown = pNew->GetInner();
  629. // Done
  630. return S_OK;
  631. }