Source code of Windows XP (NT5)
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.

133 lines
2.9 KiB

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