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.

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