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.

131 lines
2.9 KiB

  1. #include "priv.h"
  2. #include "darpub.h"
  3. #include "darenum.h"
  4. #include "sccls.h"
  5. #include "util.h"
  6. /////////////////////////////////////////////////////////////////////////////
  7. // CDarwinAppPublisher
  8. // Very thin layer around the darwin CoGet* API's
  9. // constructor
  10. CDarwinAppPublisher::CDarwinAppPublisher() : _cRef(1)
  11. {
  12. DllAddRef();
  13. TraceAddRef(CDarwinAppPub, _cRef);
  14. }
  15. // destructor
  16. CDarwinAppPublisher::~CDarwinAppPublisher()
  17. {
  18. DllRelease();
  19. }
  20. // IAppPublisher::QueryInterface
  21. HRESULT CDarwinAppPublisher::QueryInterface(REFIID riid, LPVOID * ppvOut)
  22. {
  23. static const QITAB qit[] = {
  24. QITABENT(CDarwinAppPublisher, IAppPublisher), // IID_IAppPublisher
  25. { 0 },
  26. };
  27. return QISearch(this, qit, riid, ppvOut);
  28. }
  29. // IAppPublisher::AddRef
  30. ULONG CDarwinAppPublisher::AddRef()
  31. {
  32. _cRef++;
  33. TraceAddRef(CDarwinAppPub, _cRef);
  34. return _cRef;
  35. }
  36. // IAppPublisher::Release
  37. ULONG CDarwinAppPublisher::Release()
  38. {
  39. _cRef--;
  40. TraceRelease(CDarwinAppPub, _cRef);
  41. if (_cRef > 0)
  42. return _cRef;
  43. delete this;
  44. return 0;
  45. }
  46. // IAppPublisher::GetNumberOfCategories
  47. STDMETHODIMP CDarwinAppPublisher::GetNumberOfCategories(DWORD * pdwCat)
  48. {
  49. return E_NOTIMPL;
  50. }
  51. // IAppPublisher::GetCategories
  52. STDMETHODIMP CDarwinAppPublisher::GetCategories(APPCATEGORYINFOLIST * pAppCategoryList)
  53. {
  54. HRESULT hres = E_FAIL;
  55. DWORD dwStatus;
  56. RIP(pAppCategoryList);
  57. ZeroMemory(pAppCategoryList, SIZEOF(APPCATEGORYINFOLIST));
  58. APPCATEGORYINFOLIST acil = {0};
  59. dwStatus = GetManagedApplicationCategories(0, &acil);
  60. hres = HRESULT_FROM_WIN32( dwStatus );
  61. if (SUCCEEDED(hres) && (acil.cCategory > 0))
  62. {
  63. hres = _DuplicateCategoryList(&acil, pAppCategoryList);
  64. ReleaseAppCategoryInfoList(&acil);
  65. }
  66. return hres;
  67. }
  68. // IAppPublisher::GetNumberOfApps
  69. STDMETHODIMP CDarwinAppPublisher::GetNumberOfApps(DWORD * pdwApps)
  70. {
  71. return E_NOTIMPL;
  72. }
  73. // IAppPublisher::EnumApps
  74. STDMETHODIMP CDarwinAppPublisher::EnumApps(GUID * pAppCategoryId, IEnumPublishedApps ** ppepa)
  75. {
  76. HRESULT hres = E_FAIL;
  77. CDarwinEnumPublishedApps * pdepa = new CDarwinEnumPublishedApps(pAppCategoryId);
  78. if (pdepa)
  79. {
  80. *ppepa = SAFECAST(pdepa, IEnumPublishedApps *);
  81. hres = S_OK;
  82. }
  83. else
  84. hres = E_OUTOFMEMORY;
  85. return hres;
  86. }
  87. /*----------------------------------------------------------
  88. Purpose: Create-instance function for class factory
  89. */
  90. STDAPI CDarwinAppPublisher_CreateInstance(IUnknown* pUnkOuter, IUnknown** ppunk, LPCOBJECTINFO poi)
  91. {
  92. // aggregation checking is handled in class factory
  93. HRESULT hres = E_OUTOFMEMORY;
  94. CDarwinAppPublisher* pObj = new CDarwinAppPublisher();
  95. if (pObj)
  96. {
  97. *ppunk = SAFECAST(pObj, IAppPublisher *);
  98. hres = S_OK;
  99. }
  100. return hres;
  101. }