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.

447 lines
11 KiB

  1. // File: dlghost.cpp
  2. #include "precomp.h"
  3. #include "resource.h"
  4. #include "dlghost.h"
  5. #include "ConfPolicies.h"
  6. #include <help_ids.h>
  7. // Dialog ID to Help ID mapping
  8. static const DWORD rgHelpIdsHostMeeting[] = {
  9. IDE_HOST_GENERAL, IDH_HOST_GENERAL,
  10. IDE_HOST_SETTINGS, IDH_HOST_SETTINGS,
  11. IDE_HOST_NAME, IDH_HOST_NAME,
  12. IDE_HOST_PASSWORD, IDH_HOST_PASSWORD,
  13. IDE_HOST_SECURE, IDH_HOST_SECURE,
  14. IDE_HOST_YOUACCEPT, IDH_HOST_ACCEPT_PEOPLE,
  15. IDE_HOST_YOUINVITE, IDH_HOST_INVITE_PEOPLE,
  16. IDE_HOST_TOOLS, IDH_HOST_TOOLS,
  17. IDE_HOST_TOOLS2, IDH_HOST_TOOLS,
  18. IDE_HOST_YOUSHARE, IDH_HOST_SHARE,
  19. IDE_HOST_YOUWB, IDH_HOST_WHITEBD,
  20. IDE_HOST_YOUCHAT, IDH_HOST_CHAT,
  21. IDE_HOST_YOUFT, IDH_HOST_XFER,
  22. IDE_HOST_YOUAUDIO, IDH_HOST_AUDIO,
  23. IDE_HOST_YOUVIDEO, IDH_HOST_VIDEO,
  24. 0, 0 // terminator
  25. };
  26. static HWND s_hwndSettings = NULL;
  27. /* C D L G H O S T */
  28. /*-------------------------------------------------------------------------
  29. %%Function: CDlgHost
  30. -------------------------------------------------------------------------*/
  31. CDlgHost::CDlgHost(void):
  32. m_hwnd(NULL),
  33. m_pszName(NULL),
  34. m_pszPassword(NULL),
  35. m_attendeePermissions(NM_PERMIT_ALL),
  36. m_maxParticipants(-1)
  37. {
  38. }
  39. CDlgHost::~CDlgHost(void)
  40. {
  41. delete m_pszName;
  42. delete m_pszPassword;
  43. }
  44. INT_PTR CDlgHost::DoModal(HWND hwnd)
  45. {
  46. return DialogBoxParam(::GetInstanceHandle(), MAKEINTRESOURCE(IDD_HOST),
  47. hwnd, CDlgHost::DlgProcHost, (LPARAM) this);
  48. }
  49. /* D L G P R O C H O S T */
  50. /*-------------------------------------------------------------------------
  51. %%Function: DlgProcHost
  52. -------------------------------------------------------------------------*/
  53. INT_PTR CALLBACK CDlgHost::DlgProcHost(HWND hdlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
  54. {
  55. switch (uMsg)
  56. {
  57. case WM_INITDIALOG:
  58. {
  59. ASSERT(NULL != lParam);
  60. ::SetWindowLongPtr(hdlg, DWLP_USER, lParam);
  61. CDlgHost * pDlg = (CDlgHost*) lParam;
  62. pDlg->m_hwnd = hdlg;
  63. pDlg->OnInitDialog();
  64. return TRUE; // default focus is ok
  65. }
  66. case WM_COMMAND:
  67. {
  68. CDlgHost * pDlg = (CDlgHost*) GetWindowLongPtr(hdlg, DWLP_USER);
  69. if (NULL != pDlg)
  70. {
  71. pDlg->OnCommand(wParam, lParam);
  72. }
  73. break;
  74. }
  75. case WM_CONTEXTMENU:
  76. DoHelpWhatsThis(wParam, rgHelpIdsHostMeeting);
  77. break;
  78. case WM_HELP:
  79. DoHelp(lParam, rgHelpIdsHostMeeting);
  80. break;
  81. default:
  82. break;
  83. }
  84. return FALSE;
  85. }
  86. /* O N C O M M A N D */
  87. /*-------------------------------------------------------------------------
  88. %%Function: OnCommand
  89. -------------------------------------------------------------------------*/
  90. BOOL CDlgHost::OnCommand(WPARAM wParam, LPARAM lParam)
  91. {
  92. TCHAR szName[MAX_PATH];
  93. TCHAR szPassword[MAX_PATH];
  94. UINT wCmd = GET_WM_COMMAND_ID(wParam, lParam);
  95. switch (wCmd)
  96. {
  97. case IDOK:
  98. {
  99. TCHAR sz[MAX_PATH];
  100. if (0 != GetDlgItemText(m_hwnd, IDE_HOST_NAME, sz, CCHMAX(sz)))
  101. {
  102. m_pszName = PszAlloc(sz);
  103. }
  104. if (0 != GetDlgItemText(m_hwnd, IDE_HOST_PASSWORD, sz, CCHMAX(sz)))
  105. {
  106. m_pszPassword = PszAlloc(sz);
  107. }
  108. m_fSecure = ::IsDlgButtonChecked(m_hwnd, IDE_HOST_SECURE);
  109. //
  110. // Permissions
  111. //
  112. if (::IsDlgButtonChecked(m_hwnd, IDE_HOST_YOUACCEPT))
  113. {
  114. m_attendeePermissions &= ~NM_PERMIT_INCOMINGCALLS;
  115. }
  116. if (::IsDlgButtonChecked(m_hwnd, IDE_HOST_YOUINVITE))
  117. {
  118. m_attendeePermissions &= ~NM_PERMIT_OUTGOINGCALLS;
  119. }
  120. if (::IsDlgButtonChecked(m_hwnd, IDE_HOST_YOUSHARE))
  121. {
  122. m_attendeePermissions &= ~NM_PERMIT_SHARE;
  123. }
  124. if (::IsDlgButtonChecked(m_hwnd, IDE_HOST_YOUWB))
  125. {
  126. m_attendeePermissions &= ~(NM_PERMIT_STARTOLDWB | NM_PERMIT_STARTWB);
  127. }
  128. if (::IsDlgButtonChecked(m_hwnd, IDE_HOST_YOUCHAT))
  129. {
  130. m_attendeePermissions &= ~NM_PERMIT_STARTCHAT;
  131. }
  132. if (::IsDlgButtonChecked(m_hwnd, IDE_HOST_YOUFT))
  133. {
  134. m_attendeePermissions &= ~NM_PERMIT_SENDFILES;
  135. }
  136. // fall thru to IDCANCEL
  137. }
  138. case IDCANCEL:
  139. {
  140. ::EndDialog(m_hwnd, wCmd);
  141. return TRUE;
  142. }
  143. case IDE_HOST_NAME:
  144. case IDE_HOST_PASSWORD:
  145. {
  146. switch (GET_WM_COMMAND_CMD(wParam, lParam))
  147. {
  148. case EN_CHANGE:
  149. {
  150. BOOL fOkName;
  151. BOOL fOkPassword;
  152. //
  153. // Look at the name
  154. //
  155. GetDlgItemText(m_hwnd, IDE_HOST_NAME, szName, CCHMAX(szName));
  156. if (!szName[0])
  157. {
  158. fOkName = FALSE;
  159. }
  160. else if (!FAnsiSz(szName))
  161. {
  162. fOkName = FALSE;
  163. if (GET_WM_COMMAND_ID(wParam, lParam) == IDE_HOST_NAME)
  164. {
  165. // User typed bogus char in name field
  166. MessageBeep(0);
  167. }
  168. }
  169. else
  170. {
  171. fOkName = TRUE;
  172. }
  173. //
  174. // Look at the password, it CAN be empty
  175. //
  176. GetDlgItemText(m_hwnd, IDE_HOST_PASSWORD, szPassword, CCHMAX(szPassword));
  177. if (!szPassword[0])
  178. {
  179. fOkPassword = TRUE;
  180. }
  181. else if (FAnsiSz(szPassword))
  182. {
  183. fOkPassword = TRUE;
  184. }
  185. else
  186. {
  187. fOkPassword = FALSE;
  188. if (GET_WM_COMMAND_ID(wParam, lParam) == IDE_HOST_PASSWORD)
  189. {
  190. // User typed bogus char in password field
  191. MessageBeep(0);
  192. }
  193. }
  194. EnableWindow(GetDlgItem(m_hwnd, IDOK), fOkName && fOkPassword);
  195. break;
  196. }
  197. }
  198. break;
  199. }
  200. default:
  201. break;
  202. }
  203. return FALSE;
  204. }
  205. /* O N I N I T D I A L O G */
  206. /*-------------------------------------------------------------------------
  207. %%Function: OnInitDialog
  208. -------------------------------------------------------------------------*/
  209. VOID CDlgHost::OnInitDialog(void)
  210. {
  211. TCHAR sz[MAX_PATH];
  212. BOOL fSecureAlterable;
  213. BOOL fSecureOn;
  214. switch (ConfPolicies::GetSecurityLevel())
  215. {
  216. case DISABLED_POL_SECURITY:
  217. fSecureOn = FALSE;
  218. fSecureAlterable = FALSE;
  219. break;
  220. case REQUIRED_POL_SECURITY:
  221. fSecureOn = TRUE;
  222. fSecureAlterable = FALSE;
  223. break;
  224. default:
  225. fSecureOn = ConfPolicies::OutgoingSecurityPreferred();
  226. fSecureAlterable = TRUE;
  227. break;
  228. }
  229. ::CheckDlgButton(m_hwnd, IDE_HOST_SECURE, fSecureOn);
  230. ::EnableWindow(::GetDlgItem(m_hwnd, IDE_HOST_SECURE), fSecureAlterable);
  231. if (FLoadString(IDS_DEFAULT_CONF_NAME, sz, CCHMAX(sz)))
  232. {
  233. SetDlgItemText(m_hwnd, IDE_HOST_NAME, sz);
  234. }
  235. Edit_LimitText(GetDlgItem(m_hwnd, IDE_HOST_NAME), CCHMAXSZ_NAME - 1);
  236. Edit_LimitText(GetDlgItem(m_hwnd, IDE_HOST_PASSWORD), CCHMAXSZ_NAME - 1);
  237. }
  238. //
  239. // C D L G H O S T S E T T I N G S
  240. //
  241. // This is a simple description of what restrictions there are in this
  242. // meeting. Users see this when
  243. // (a) They join a restricted meeting
  244. // (b) They or the host chooses the Meeting Properties menu item under Call
  245. //
  246. CDlgHostSettings::CDlgHostSettings
  247. (
  248. BOOL fHost,
  249. LPTSTR szName,
  250. DWORD caps,
  251. NM30_MTG_PERMISSIONS permissions
  252. )
  253. {
  254. m_hwnd = NULL;
  255. m_fHost = fHost;
  256. m_pszName = szName;
  257. m_caps = caps;
  258. m_permissions = permissions;
  259. }
  260. CDlgHostSettings::~CDlgHostSettings(void)
  261. {
  262. }
  263. void CDlgHostSettings::KillHostSettings(void)
  264. {
  265. if (s_hwndSettings)
  266. {
  267. // Kill current one.
  268. WARNING_OUT(("Killing previous meeting settings dialog"));
  269. SendMessage(s_hwndSettings, WM_COMMAND, IDCANCEL, 0);
  270. ASSERT(!s_hwndSettings);
  271. }
  272. }
  273. INT_PTR CDlgHostSettings::DoModal(HWND hwnd)
  274. {
  275. CDlgHostSettings::KillHostSettings();
  276. return DialogBoxParam(::GetInstanceHandle(), MAKEINTRESOURCE(IDD_HOST_SETTINGS),
  277. hwnd, CDlgHostSettings::DlgProc, (LPARAM)this);
  278. }
  279. //
  280. // CDlgHostSettings::DlgProc()
  281. //
  282. INT_PTR CALLBACK CDlgHostSettings::DlgProc(HWND hdlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
  283. {
  284. switch (uMsg)
  285. {
  286. case WM_INITDIALOG:
  287. {
  288. ASSERT(lParam != NULL);
  289. SetWindowLongPtr(hdlg, DWLP_USER, lParam);
  290. CDlgHostSettings * pDlg = (CDlgHostSettings *) lParam;
  291. ASSERT(!s_hwndSettings);
  292. s_hwndSettings = hdlg;
  293. pDlg->m_hwnd = hdlg;
  294. pDlg->OnInitDialog();
  295. return TRUE;
  296. }
  297. case WM_COMMAND:
  298. {
  299. switch (GET_WM_COMMAND_ID(wParam, lParam))
  300. {
  301. case IDOK:
  302. case IDCANCEL:
  303. if (s_hwndSettings == hdlg)
  304. {
  305. s_hwndSettings = NULL;
  306. }
  307. ::EndDialog(hdlg, GET_WM_COMMAND_ID(wParam, lParam));
  308. return TRUE;
  309. }
  310. break;
  311. }
  312. case WM_CONTEXTMENU:
  313. {
  314. DoHelpWhatsThis(wParam, rgHelpIdsHostMeeting);
  315. break;
  316. }
  317. case WM_HELP:
  318. {
  319. DoHelp(lParam, rgHelpIdsHostMeeting);
  320. break;
  321. }
  322. default:
  323. break;
  324. }
  325. return FALSE;
  326. }
  327. //
  328. // CDlgHostSettings::OnInitDialog()
  329. //
  330. void CDlgHostSettings::OnInitDialog(void)
  331. {
  332. TCHAR szText[256];
  333. TCHAR szRestrict[128];
  334. TCHAR szResult[384];
  335. USES_RES2T
  336. ::SetDlgItemText(m_hwnd, IDE_HOST_NAME, m_pszName);
  337. EnableWindow(GetDlgItem(m_hwnd, IDE_HOST_SECURE), ((m_caps & NMCH_SECURE) != 0));
  338. //
  339. // Meeting settings
  340. //
  341. if (!m_fHost)
  342. {
  343. SetDlgItemText(m_hwnd, IDE_HOST_YOUACCEPT, RES2T(IDS_NONHOST_YOUACCEPT));
  344. }
  345. EnableWindow(GetDlgItem(m_hwnd, IDE_HOST_YOUACCEPT),
  346. !(m_permissions & NM_PERMIT_INCOMINGCALLS));
  347. if (!m_fHost)
  348. {
  349. SetDlgItemText(m_hwnd, IDE_HOST_YOUINVITE, RES2T(IDS_NONHOST_YOUINVITE));
  350. }
  351. EnableWindow(GetDlgItem(m_hwnd, IDE_HOST_YOUINVITE),
  352. !(m_permissions & NM_PERMIT_OUTGOINGCALLS));
  353. //
  354. // Meeting tools
  355. //
  356. if (!m_fHost)
  357. {
  358. SetDlgItemText(m_hwnd, IDE_HOST_TOOLS, RES2T(IDS_NONHOST_TOOLS));
  359. }
  360. EnableWindow(GetDlgItem(m_hwnd, IDE_HOST_YOUSHARE),
  361. !(m_permissions & NM_PERMIT_SHARE));
  362. EnableWindow(GetDlgItem(m_hwnd, IDE_HOST_YOUWB),
  363. !(m_permissions & (NM_PERMIT_STARTWB | NM_PERMIT_STARTOLDWB)));
  364. EnableWindow(GetDlgItem(m_hwnd, IDE_HOST_YOUCHAT),
  365. !(m_permissions & NM_PERMIT_STARTCHAT));
  366. EnableWindow(GetDlgItem(m_hwnd, IDE_HOST_YOUFT),
  367. !(m_permissions & NM_PERMIT_SENDFILES));
  368. }