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.

184 lines
4.6 KiB

  1. //---------------------------------------------------------------------------
  2. //
  3. // Copyright (c) Microsoft Corporation
  4. //
  5. // File: instapp.cpp
  6. //
  7. // Installed applications
  8. //
  9. // History:
  10. // 1-18-97 by dli
  11. //------------------------------------------------------------------------
  12. #include "priv.h"
  13. // Do not build this file if on Win9X or NT4
  14. #ifndef DOWNLEVEL_PLATFORM
  15. #include "darapp.h"
  16. #include "util.h"
  17. #include "appwizid.h"
  18. // constructor
  19. CDarwinPublishedApp::CDarwinPublishedApp(MANAGEDAPPLICATION * pma) : _cRef(1)
  20. {
  21. DllAddRef();
  22. TraceAddRef(CDarwinPublishedApp, _cRef);
  23. hmemcpy(&_ma, pma, SIZEOF(_ma));
  24. _dwAction |= APPACTION_INSTALL;
  25. }
  26. // destructor
  27. CDarwinPublishedApp::~CDarwinPublishedApp()
  28. {
  29. ClearManagedApplication(&_ma);
  30. DllRelease();
  31. }
  32. // IShellApps::GetAppInfo
  33. STDMETHODIMP CDarwinPublishedApp::GetAppInfo(PAPPINFODATA pai)
  34. {
  35. if (pai->cbSize != SIZEOF(APPINFODATA))
  36. return E_FAIL;
  37. DWORD dwInfoFlags = pai->dwMask;
  38. pai->dwMask = 0;
  39. if (dwInfoFlags & AIM_DISPLAYNAME)
  40. {
  41. if (SUCCEEDED(SHStrDupW(_ma.pszPackageName, &pai->pszDisplayName)))
  42. pai->dwMask |= AIM_DISPLAYNAME;
  43. }
  44. if ((dwInfoFlags & AIM_PUBLISHER) && _ma.pszPublisher && _ma.pszPublisher[0])
  45. {
  46. if (SUCCEEDED(SHStrDupW(_ma.pszPublisher, &pai->pszPublisher)))
  47. pai->dwMask |= AIM_PUBLISHER;
  48. }
  49. if ((dwInfoFlags & AIM_SUPPORTURL) && _ma.pszSupportUrl && _ma.pszSupportUrl[0])
  50. {
  51. if (SUCCEEDED(SHStrDupW(_ma.pszSupportUrl, &pai->pszSupportUrl)))
  52. pai->dwMask |= AIM_SUPPORTURL;
  53. }
  54. if ((dwInfoFlags & AIM_VERSION) && (_ma.dwVersionHi != 0))
  55. {
  56. pai->pszVersion = (LPWSTR)SHAlloc(SIZEOF(WCHAR) * MAX_PATH);
  57. wsprintf(pai->pszVersion, L"%d.%d.%d.%d", HIWORD(_ma.dwVersionHi), LOWORD(_ma.dwVersionHi), HIWORD(_ma.dwVersionLo), LOWORD(_ma.dwVersionLo));
  58. pai->dwMask |= AIM_VERSION;
  59. }
  60. // REARCHITECT: get more info for Darwin apps
  61. // original comment: don't know how to retrieve other infomation, need to talk to the Darwin guys about it
  62. TraceMsg(TF_GENERAL, "(DarPubApp) GetAppInfo with %x but got %x", dwInfoFlags, pai->dwMask);
  63. return S_OK;
  64. }
  65. // IShellApps::GetPossibleActions
  66. STDMETHODIMP CDarwinPublishedApp::GetPossibleActions(DWORD * pdwActions)
  67. {
  68. ASSERT(pdwActions);
  69. *pdwActions = _dwAction;
  70. return S_OK;
  71. }
  72. // IShellApps::GetSlowAppInfo
  73. STDMETHODIMP CDarwinPublishedApp::GetSlowAppInfo(PSLOWAPPINFO psai)
  74. {
  75. return E_NOTIMPL;
  76. }
  77. // IShellApps::GetSlowAppInfo
  78. STDMETHODIMP CDarwinPublishedApp::GetCachedSlowAppInfo(PSLOWAPPINFO psai)
  79. {
  80. return E_NOTIMPL;
  81. }
  82. // IShellApps::IsInstalled
  83. STDMETHODIMP CDarwinPublishedApp::IsInstalled()
  84. {
  85. return _ma.bInstalled ? S_OK : S_FALSE;
  86. }
  87. // IPublishedApps::Install
  88. STDMETHODIMP CDarwinPublishedApp::Install(LPSYSTEMTIME pftInstall)
  89. {
  90. INSTALLDATA id;
  91. id.Type = APPNAME;
  92. id.Spec.AppName.Name = _ma.pszPackageName;
  93. id.Spec.AppName.GPOId = _ma.GpoId;
  94. LONG lRet = InstallApplication(&id);
  95. HRESULT hres = HRESULT_FROM_WIN32(lRet);
  96. // Tell the users what is wrong with this install.
  97. if (FAILED(hres))
  98. _ARPErrorMessageBox(lRet);
  99. else
  100. _ma.bInstalled = TRUE;
  101. return hres;
  102. }
  103. // IPublishedApps::GetPublishedTime
  104. STDMETHODIMP CDarwinPublishedApp::GetPublishedAppInfo(PPUBAPPINFO ppai)
  105. {
  106. if (ppai->cbSize != SIZEOF(PUBAPPINFO))
  107. return E_FAIL;
  108. DWORD dwInfoFlags = ppai->dwMask;
  109. ppai->dwMask = 0;
  110. if ((dwInfoFlags & PAI_SOURCE) && _ma.pszPolicyName && _ma.pszPolicyName[0])
  111. {
  112. if (SUCCEEDED(SHStrDupW(_ma.pszPolicyName, &ppai->pszSource)))
  113. ppai->dwMask |= PAI_SOURCE;
  114. }
  115. return S_OK;
  116. }
  117. // IPublishedApps::GetAssignedTime
  118. STDMETHODIMP CDarwinPublishedApp::Unschedule(void)
  119. {
  120. return E_NOTIMPL;
  121. }
  122. // IPublishedApp::QueryInterface
  123. HRESULT CDarwinPublishedApp::QueryInterface(REFIID riid, LPVOID * ppvOut)
  124. {
  125. static const QITAB qit[] = {
  126. QITABENT(CDarwinPublishedApp, IPublishedApp), // IID_IPublishedApp
  127. QITABENTMULTI(CDarwinPublishedApp, IShellApp, IPublishedApp), // IID_IShellApp
  128. { 0 },
  129. };
  130. return QISearch(this, qit, riid, ppvOut);
  131. }
  132. // IPublishedApp::AddRef
  133. ULONG CDarwinPublishedApp::AddRef()
  134. {
  135. InterlockedIncrement(&_cRef);
  136. TraceAddRef(CDarwinPublishedApp, _cRef);
  137. return _cRef;
  138. }
  139. // IPublishedApp::Release
  140. ULONG CDarwinPublishedApp::Release()
  141. {
  142. InterlockedDecrement(&_cRef);
  143. TraceRelease(CDarwinPublishedApp, _cRef);
  144. if (_cRef > 0)
  145. return _cRef;
  146. delete this;
  147. return 0;
  148. }
  149. #endif //DOWNLEVEL_PLATFORM