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.

241 lines
6.4 KiB

  1. // Deploy.cpp : implementation file
  2. //
  3. #include "precomp.hxx"
  4. #ifdef _DEBUG
  5. #define new DEBUG_NEW
  6. #undef THIS_FILE
  7. static char THIS_FILE[] = __FILE__;
  8. #endif
  9. /////////////////////////////////////////////////////////////////////////////
  10. // CDeploy property page
  11. IMPLEMENT_DYNCREATE(CDeploy, CPropertyPage)
  12. CDeploy::CDeploy() : CPropertyPage(CDeploy::IDD)
  13. {
  14. //{{AFX_DATA_INIT(CDeploy)
  15. m_fAutoInst = FALSE;
  16. m_iDeployment = -1;
  17. m_hConsoleHandle = NULL;
  18. m_iUI = -1;
  19. //}}AFX_DATA_INIT
  20. }
  21. CDeploy::~CDeploy()
  22. {
  23. *m_ppThis = NULL;
  24. MMCFreeNotifyHandle(m_hConsoleHandle);
  25. }
  26. void CDeploy::DoDataExchange(CDataExchange* pDX)
  27. {
  28. CPropertyPage::DoDataExchange(pDX);
  29. //{{AFX_DATA_MAP(CDeploy)
  30. DDX_Check(pDX, IDC_CHECK2, m_fAutoInst);
  31. DDX_Radio(pDX, IDC_RADIO6, m_iDeployment);
  32. DDX_Radio(pDX, IDC_RADIO3, m_iUI);
  33. //}}AFX_DATA_MAP
  34. }
  35. BEGIN_MESSAGE_MAP(CDeploy, CPropertyPage)
  36. //{{AFX_MSG_MAP(CDeploy)
  37. ON_BN_CLICKED(IDC_RADIO6, OnDisable)
  38. ON_BN_CLICKED(IDC_RADIO2, OnPublished)
  39. ON_BN_CLICKED(IDC_RADIO1, OnAssigned)
  40. ON_BN_CLICKED(IDC_CHECK2, OnAutoInstall)
  41. ON_BN_CLICKED(IDC_RADIO3, OnBasic)
  42. ON_BN_CLICKED(IDC_RADIO4, OnMax)
  43. ON_BN_CLICKED(IDC_RADIO5, OnDefault)
  44. ON_BN_CLICKED(IDC_BUTTON1, OnAdvanced)
  45. ON_WM_DESTROY()
  46. //}}AFX_MSG_MAP
  47. END_MESSAGE_MAP()
  48. /////////////////////////////////////////////////////////////////////////////
  49. // CDeploy message handlers
  50. BOOL CDeploy::OnApply()
  51. {
  52. DWORD dwActFlags = m_pData->pDetails->pInstallInfo->dwActFlags;
  53. dwActFlags &= ~(ACTFLG_Assigned | ACTFLG_Published | ACTFLG_OnDemandInstall | ACTFLG_UserInstall);
  54. switch (m_iDeployment)
  55. {
  56. case 0:
  57. // Disabled
  58. dwActFlags |= ACTFLG_Published;
  59. break;
  60. case 1:
  61. // Published
  62. dwActFlags |= ACTFLG_Published | ACTFLG_UserInstall;
  63. if (m_fAutoInst)
  64. {
  65. dwActFlags |= ACTFLG_OnDemandInstall;
  66. }
  67. break;
  68. case 2:
  69. // Assigned
  70. dwActFlags |= (ACTFLG_Assigned | ACTFLG_OnDemandInstall);
  71. break;
  72. default:
  73. break;
  74. }
  75. HRESULT hr = m_pIClassAdmin->ChangePackageProperties(m_pData->pDetails->pszPackageName,
  76. NULL,
  77. &dwActFlags,
  78. NULL,
  79. NULL,
  80. NULL);
  81. if (SUCCEEDED(hr))
  82. {
  83. m_pData->pDetails->pInstallInfo->dwActFlags = dwActFlags;
  84. #if UGLY_SUBDIRECTORY_HACK
  85. {
  86. CString sz = m_szGPTRoot;
  87. sz += L"\\";
  88. sz += m_pData->pDetails->pInstallInfo->pszScriptPath;
  89. // copy to subdirectories
  90. CString szRoot;
  91. CString szFile;
  92. int i = sz.ReverseFind(L'\\');
  93. szRoot = sz.Left(i);
  94. szFile = sz.Mid(i+1);
  95. CString szTemp;
  96. if (0 != (m_pData->pDetails->pInstallInfo->dwActFlags & ACTFLG_Assigned))
  97. {
  98. for (i = m_pData->pDetails->pPlatformInfo->cPlatforms; i--;)
  99. {
  100. if (PROCESSOR_ARCHITECTURE_INTEL == m_pData->pDetails->pPlatformInfo->prgPlatform[i].dwProcessorArch)
  101. {
  102. szTemp = szRoot;
  103. szTemp += L"\\assigned\\x86\\";
  104. szTemp += szFile;
  105. CopyFile(sz, szTemp, FALSE);
  106. }
  107. if (PROCESSOR_ARCHITECTURE_ALPHA == m_pData->pDetails->pPlatformInfo->prgPlatform[i].dwProcessorArch)
  108. {
  109. szTemp = szRoot;
  110. szTemp += L"\\assigned\\alpha\\";
  111. szTemp += szFile;
  112. CopyFile(sz, szTemp, FALSE);
  113. }
  114. }
  115. }
  116. else
  117. {
  118. szTemp = szRoot;
  119. szTemp += L"\\assigned\\x86\\";
  120. szTemp += szFile;
  121. DeleteFile(szTemp);
  122. szTemp = szRoot;
  123. szTemp += L"\\assigned\\alpha\\";
  124. szTemp += szFile;
  125. DeleteFile(szTemp);
  126. }
  127. }
  128. #endif
  129. MMCPropertyChangeNotify(m_hConsoleHandle, (long) m_cookie);
  130. }
  131. return CPropertyPage::OnApply();
  132. }
  133. BOOL CDeploy::OnInitDialog()
  134. {
  135. RefreshData();
  136. CPropertyPage::OnInitDialog();
  137. // unmarshal the IClassAdmin interface
  138. HRESULT hr = CoGetInterfaceAndReleaseStream(m_pIStream, IID_IClassAdmin, (void **) &m_pIClassAdmin);
  139. return TRUE; // return TRUE unless you set the focus to a control
  140. // EXCEPTION: OCX Property Pages should return FALSE
  141. }
  142. void CDeploy::OnDisable()
  143. {
  144. SetModified();
  145. m_fAutoInst = FALSE;
  146. GetDlgItem(IDC_CHECK2)->EnableWindow(FALSE);
  147. }
  148. void CDeploy::OnPublished()
  149. {
  150. SetModified();
  151. GetDlgItem(IDC_CHECK2)->EnableWindow(TRUE);
  152. }
  153. void CDeploy::OnAssigned()
  154. {
  155. SetModified();
  156. m_fAutoInst = TRUE;
  157. GetDlgItem(IDC_CHECK2)->EnableWindow(FALSE);
  158. }
  159. void CDeploy::OnAutoInstall()
  160. {
  161. SetModified();
  162. }
  163. void CDeploy::OnBasic()
  164. {
  165. SetModified();
  166. }
  167. void CDeploy::OnMax()
  168. {
  169. SetModified();
  170. }
  171. void CDeploy::OnDefault()
  172. {
  173. SetModified();
  174. }
  175. void CDeploy::OnAdvanced()
  176. {
  177. // TODO: Add your control notification handler code here
  178. }
  179. LRESULT CDeploy::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
  180. {
  181. switch (message)
  182. {
  183. case WM_USER_REFRESH:
  184. RefreshData();
  185. UpdateData(FALSE);
  186. return 0;
  187. case WM_USER_CLOSE:
  188. return GetOwner()->SendMessage(WM_CLOSE);
  189. default:
  190. return CPropertyPage::WindowProc(message, wParam, lParam);
  191. }
  192. }
  193. void CDeploy::RefreshData(void)
  194. {
  195. DWORD dwActFlags = m_pData->pDetails->pInstallInfo->dwActFlags;
  196. m_fAutoInst = (0 != (dwActFlags & ACTFLG_OnDemandInstall));
  197. if (dwActFlags & ACTFLG_Assigned)
  198. {
  199. m_iDeployment = 2;
  200. GetDlgItem(IDC_CHECK2)->EnableWindow(FALSE);
  201. }
  202. else if (dwActFlags & (ACTFLG_OnDemandInstall | ACTFLG_UserInstall))
  203. {
  204. m_iDeployment = 1;
  205. GetDlgItem(IDC_CHECK2)->EnableWindow(TRUE);
  206. }
  207. else
  208. {
  209. m_iDeployment = 0;
  210. GetDlgItem(IDC_CHECK2)->EnableWindow(FALSE);
  211. }
  212. SetModified(FALSE);
  213. }