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.

262 lines
7.0 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1997 - 1999
  6. //
  7. // File: simprop2.cpp
  8. //
  9. //--------------------------------------------------------------------------
  10. // SimProp2.cpp
  11. #include "stdafx.h"
  12. #include "common.h"
  13. #include "helpids.h"
  14. #ifdef _DEBUG
  15. #define new DEBUG_NEW
  16. #undef THIS_FILE
  17. static char THIS_FILE[] = __FILE__;
  18. #endif
  19. ///////////////////////////////////////
  20. const TColumnHeaderItem rgzColumnHeader[] =
  21. {
  22. { IDS_SIM_KERBEROS_PRINCIPAL_NAME, 85 },
  23. { 0, 0 },
  24. };
  25. /////////////////////////////////////////////////////////////////////////////
  26. /////////////////////////////////////////////////////////////////////////////
  27. // CSimKerberosPropPage property page
  28. // IMPLEMENT_DYNCREATE(CSimKerberosPropPage, CSimPropPage)
  29. CSimKerberosPropPage::CSimKerberosPropPage() : CSimPropPage(CSimKerberosPropPage::IDD)
  30. {
  31. //{{AFX_DATA_INIT(CSimKerberosPropPage)
  32. // NOTE: the ClassWizard will add member initialization here
  33. //}}AFX_DATA_INIT
  34. m_prgzColumnHeader = rgzColumnHeader;
  35. }
  36. CSimKerberosPropPage::~CSimKerberosPropPage()
  37. {
  38. }
  39. void CSimKerberosPropPage::DoDataExchange(CDataExchange* pDX)
  40. {
  41. ASSERT(m_pData != NULL);
  42. CSimPropPage::DoDataExchange(pDX);
  43. //{{AFX_DATA_MAP(CSimKerberosPropPage)
  44. // NOTE: the ClassWizard will add DDX and DDV calls here
  45. //}}AFX_DATA_MAP
  46. if (!pDX->m_bSaveAndValidate)
  47. {
  48. // Fill in the listview
  49. ListView_DeleteAllItems(m_hwndListview);
  50. for (CSimEntry * pSimEntry = m_pData->m_pSimEntryList;
  51. pSimEntry != NULL;
  52. pSimEntry = pSimEntry->m_pNext)
  53. {
  54. if (pSimEntry->m_eDialogTarget != eKerberos)
  55. continue;
  56. LPCTSTR pszT = pSimEntry->PchGetString();
  57. pszT += cchKerberos;
  58. ListView_AddString(m_hwndListview, pszT, (LPARAM)pSimEntry);
  59. } // for
  60. ListView_SelectItem(m_hwndListview, 0);
  61. } // if
  62. } // CSimKerberosPropPage::DoDataExchange()
  63. BEGIN_MESSAGE_MAP(CSimKerberosPropPage, CSimPropPage)
  64. //{{AFX_MSG_MAP(CSimKerberosPropPage)
  65. ON_BN_CLICKED(IDC_BUTTON_ADD, OnButtonAdd)
  66. ON_BN_CLICKED(IDC_BUTTON_EDIT, OnButtonEdit)
  67. //}}AFX_MSG_MAP
  68. END_MESSAGE_MAP()
  69. void CSimKerberosPropPage::OnButtonAdd()
  70. {
  71. CThemeContextActivator activator;
  72. CSimAddKerberosDlg dlg;
  73. if (dlg.DoModal() != IDOK)
  74. return;
  75. CString str = dlg.m_strName;
  76. str.TrimLeft();
  77. str.TrimRight();
  78. int iItem = ListView_FindString(m_hwndListview, str);
  79. if (iItem >= 0)
  80. {
  81. ListView_SelectItem(m_hwndListview, iItem);
  82. ReportErrorEx (GetSafeHwnd(),IDS_SIM_ERR_KERBEROS_NAME_ALREADY_EXISTS,S_OK,
  83. MB_OK | MB_ICONINFORMATION, NULL, 0);
  84. return;
  85. }
  86. CString strTemp = szKerberos;
  87. strTemp += str;
  88. CSimEntry * pSimEntry = m_pData->PAddSimEntry(strTemp);
  89. UpdateData(FALSE);
  90. ListView_SelectLParam(m_hwndListview, (LPARAM)pSimEntry);
  91. SetDirty();
  92. } // OnButtonAdd()
  93. void CSimKerberosPropPage::OnButtonEdit()
  94. {
  95. CThemeContextActivator activator;
  96. int iItem;
  97. CSimEntry * pSimEntry = (CSimEntry *)ListView_GetItemLParam(m_hwndListview, -1, OUT &iItem);
  98. if (pSimEntry == NULL || iItem < 0)
  99. {
  100. // No item selected
  101. return;
  102. }
  103. CString str;
  104. ListView_GetItemString(m_hwndListview, iItem, 0, OUT str);
  105. // ASSERT(!str.IsEmpty());
  106. CSimAddKerberosDlg dlg;
  107. dlg.m_strName = str;
  108. if (dlg.DoModal() != IDOK)
  109. return;
  110. dlg.m_strName.TrimLeft();
  111. dlg.m_strName.TrimRight();
  112. if (str == dlg.m_strName)
  113. {
  114. // Strings are identical
  115. return;
  116. }
  117. int iItemT = ListView_FindString(m_hwndListview, dlg.m_strName);
  118. if (iItemT >= 0)
  119. {
  120. ListView_SelectItem(m_hwndListview, iItemT);
  121. ReportErrorEx (GetSafeHwnd(),IDS_SIM_ERR_KERBEROS_NAME_ALREADY_EXISTS,S_OK,
  122. MB_OK | MB_ICONINFORMATION, NULL, 0);
  123. return;
  124. }
  125. CString strTemp = szKerberos;
  126. strTemp += dlg.m_strName;
  127. pSimEntry->SetString(strTemp);
  128. UpdateData(FALSE);
  129. ListView_SelectLParam(m_hwndListview, (LPARAM)pSimEntry);
  130. SetDirty();
  131. } // OnButtonEdit()
  132. void CSimKerberosPropPage::DoContextHelp (HWND hWndControl)
  133. {
  134. TRACE0 ("Entering CSimKerberosPropPage::DoContextHelp\n");
  135. static const DWORD help_map[] =
  136. {
  137. IDC_EDIT_USER_ACCOUNT, IDH_EDIT_USER_ACCOUNT,
  138. IDC_LISTVIEW, IDH_LISTVIEW_KERBEROS,
  139. IDC_BUTTON_ADD, IDH_BUTTON_ADD,
  140. IDC_BUTTON_EDIT, IDH_BUTTON_EDIT,
  141. IDC_BUTTON_REMOVE, IDH_BUTTON_REMOVE,
  142. 0, 0
  143. };
  144. // Display context help for a control
  145. if ( !::WinHelp (
  146. hWndControl,
  147. DSADMIN_CONTEXT_HELP_FILE,
  148. HELP_WM_HELP,
  149. (DWORD_PTR) help_map) )
  150. {
  151. TRACE1 ("WinHelp () failed: 0x%x\n", GetLastError ());
  152. }
  153. TRACE0 ("Leaving CSimKerberosPropPage::DoContextHelp\n");
  154. }
  155. /////////////////////////////////////////////////////////////////////////////
  156. /////////////////////////////////////////////////////////////////////////////
  157. // CSimAddKerberosDlg dialog
  158. CSimAddKerberosDlg::CSimAddKerberosDlg(CWnd* pParent /*=NULL*/)
  159. : CDialog(CSimAddKerberosDlg::IDD, pParent)
  160. {
  161. //{{AFX_DATA_INIT(CSimAddKerberosDlg)
  162. //}}AFX_DATA_INIT
  163. }
  164. void CSimAddKerberosDlg::DoDataExchange(CDataExchange* pDX)
  165. {
  166. CDialog::DoDataExchange(pDX);
  167. //{{AFX_DATA_MAP(CSimAddKerberosDlg)
  168. DDX_Text(pDX, IDC_EDIT_KERBEROS_NAME, m_strName);
  169. //}}AFX_DATA_MAP
  170. }
  171. BEGIN_MESSAGE_MAP(CSimAddKerberosDlg, CDialog)
  172. //{{AFX_MSG_MAP(CSimAddKerberosDlg)
  173. ON_EN_CHANGE(IDC_EDIT_KERBEROS_NAME, OnChangeEditKerberosName)
  174. //}}AFX_MSG_MAP
  175. ON_MESSAGE(WM_HELP, OnHelp)
  176. END_MESSAGE_MAP()
  177. BOOL CSimAddKerberosDlg::OnInitDialog()
  178. {
  179. CDialog::OnInitDialog();
  180. if ( m_strName.IsEmpty() )
  181. {
  182. GetDlgItem (IDOK)->EnableWindow (FALSE);
  183. }
  184. else
  185. {
  186. // Change the caption
  187. CString str;
  188. VERIFY( str.LoadString(IDS_SIM_EDIT_KERBEROS_NAME) );
  189. SetWindowText(str);
  190. }
  191. return TRUE;
  192. }
  193. void CSimAddKerberosDlg::OnChangeEditKerberosName()
  194. {
  195. UpdateData (TRUE);
  196. m_strName.TrimLeft ();
  197. m_strName.TrimRight ();
  198. GetDlgItem (IDOK)->EnableWindow (!m_strName.IsEmpty ());
  199. }
  200. void CSimAddKerberosDlg::DoContextHelp (HWND hWndControl)
  201. {
  202. TRACE0 ("Entering CSimAddKerberosDlg::DoContextHelp\n");
  203. static const DWORD help_map[] =
  204. {
  205. IDC_EDIT_KERBEROS_NAME, IDH_EDIT_KERBEROS_NAME,
  206. 0, 0
  207. };
  208. // Display context help for a control
  209. if ( !::WinHelp (
  210. hWndControl,
  211. DSADMIN_CONTEXT_HELP_FILE,
  212. HELP_WM_HELP,
  213. (DWORD_PTR) help_map) )
  214. {
  215. TRACE1 ("WinHelp () failed: 0x%x\n", GetLastError ());
  216. }
  217. TRACE0 ("Leaving CSimAddKerberosDlg::DoContextHelp\n");
  218. }
  219. BOOL CSimAddKerberosDlg::OnHelp(WPARAM, LPARAM lParam)
  220. {
  221. TRACE0 ("Entering CSimAddKerberosDlg::OnHelp\n");
  222. const LPHELPINFO pHelpInfo = (LPHELPINFO)lParam;
  223. if (pHelpInfo && pHelpInfo->iContextType == HELPINFO_WINDOW)
  224. {
  225. DoContextHelp ((HWND) pHelpInfo->hItemHandle);
  226. }
  227. TRACE0 ("Leaving CSimAddKerberosDlg::OnHelp\n");
  228. return TRUE;
  229. }