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.

372 lines
9.1 KiB

  1. // File: cmd.cpp
  2. //
  3. // General UI-type commands
  4. #include "precomp.h"
  5. #include "cmd.h"
  6. #include "ConfPolicies.h"
  7. #include <version.h>
  8. #include "conf.h"
  9. #include "confwnd.h"
  10. #include "dshowdlg.h"
  11. #include "dlghost.h"
  12. #include "confroom.h"
  13. #include "taskbar.h" // for RefreshTaskbarIcon()
  14. #include "getip.h"
  15. // static strings
  16. static const TCHAR g_cszRelNotesFileName[] = TEXT("netmeet.htm");
  17. static BOOL g_fDoNotDisturb = 0;
  18. BOOL FLaunchPsz(LPCTSTR pszPath)
  19. {
  20. HINSTANCE hInst = ::ShellExecute(::GetMainWindow(),
  21. NULL, pszPath, NULL, NULL, SW_SHOWNORMAL);
  22. if ((INT_PTR)hInst <= 32)
  23. {
  24. ERROR_OUT(("ShellExecute() failed, rc=%d", (int)((INT_PTR) hInst)));
  25. return FALSE;
  26. }
  27. return TRUE;
  28. }
  29. static VOID LaunchWebPage(LPCTSTR pcszPage)
  30. {
  31. FLaunchPsz(pcszPage);
  32. }
  33. BOOL IsIEClientInstalled(LPCTSTR pszClient)
  34. {
  35. RegEntry re(pszClient, HKEY_LOCAL_MACHINE);
  36. LPTSTR pszDefault = re.GetString(NULL);
  37. return !FEmptySz(pszDefault);
  38. }
  39. BOOL FEnableCmdGoNews(void)
  40. {
  41. return IsIEClientInstalled(REGVAL_IE_CLIENTS_NEWS);
  42. }
  43. /* F D O N O T D I S T U R B */
  44. /*-------------------------------------------------------------------------
  45. %%Function: FDoNotDisturb
  46. -------------------------------------------------------------------------*/
  47. BOOL FDoNotDisturb(void)
  48. {
  49. return g_fDoNotDisturb;
  50. }
  51. /* S E T D O N O T D I S T U R B */
  52. /*-------------------------------------------------------------------------
  53. %%Function: SetDoNotDisturb
  54. -------------------------------------------------------------------------*/
  55. VOID SetDoNotDisturb(BOOL fSet)
  56. {
  57. g_fDoNotDisturb = fSet;
  58. }
  59. /* C M D D O N O T D I S T U R B */
  60. /*-------------------------------------------------------------------------
  61. %%Function: CmdDoNotDisturb
  62. -------------------------------------------------------------------------*/
  63. VOID CmdDoNotDisturb(HWND hwnd)
  64. {
  65. // Retrieve the "do not disturb" state:
  66. BOOL fCallsBlocked = FDoNotDisturb();
  67. CDontShowDlg dlgDNDWarn(IDS_DO_NOT_DISTURB_WARNING,
  68. REGVAL_DS_DO_NOT_DISTURB_WARNING, MB_OKCANCEL);
  69. if ((TRUE == fCallsBlocked) || (IDOK == dlgDNDWarn.DoModal(hwnd)))
  70. {
  71. // Toggle the DoNotDisturb state and refresh the UI
  72. SetDoNotDisturb(!fCallsBlocked);
  73. RefreshTaskbarIcon(::GetHiddenWindow());
  74. }
  75. }
  76. /* C M D H O S T C O N F E R E N C E */
  77. /*-------------------------------------------------------------------------
  78. %%Function: CmdHostConference
  79. -------------------------------------------------------------------------*/
  80. VOID CmdHostConference(HWND hwnd)
  81. {
  82. CDlgHost dlgHost;
  83. if (IDOK != dlgHost.DoModal(hwnd))
  84. return;
  85. HRESULT hr = ::GetConfRoom()->HostConference(dlgHost.PszName(), dlgHost.PszPassword(), dlgHost.IsSecure(),
  86. dlgHost.AttendeePermissions(), dlgHost.MaxParticipants());
  87. if (FAILED(hr))
  88. {
  89. DisplayErrMsg(IDS_ERRMSG_HOST);
  90. }
  91. }
  92. void FormatURL(LPTSTR szURL)
  93. {
  94. LPTSTR pszFormat = new TCHAR[lstrlen(szURL)+1];
  95. if (NULL != pszFormat)
  96. {
  97. lstrcpy(pszFormat, szURL);
  98. wsprintf(szURL, pszFormat,
  99. ::GetVersionInfo()->dwMajorVersion,
  100. ::GetVersionInfo()->dwMinorVersion,
  101. ::GetSystemDefaultLCID(),
  102. ::GetUserDefaultLCID());
  103. delete[] pszFormat;
  104. }
  105. }
  106. /* L A U N C H R E D I R W E B P A G E */
  107. /*-------------------------------------------------------------------------
  108. %%Function: LaunchRedirWebPage
  109. Launch a redirector web page. Used by CmdLaunchWebHelp.
  110. Note: pcszPage can be a resource ID that is associated with a
  111. format string that contains the URL and fields for 4 local ID's.
  112. -------------------------------------------------------------------------*/
  113. VOID LaunchRedirWebPage(LPCTSTR pcszPage, bool bForceFormat)
  114. {
  115. TCHAR szWebPageFormat[1024]; // BUGBUG: MAX_URL??
  116. ASSERT(NULL != pcszPage);
  117. if (((UINT_PTR)pcszPage >> 16) == 0)
  118. {
  119. // pcszPage is a resource ID
  120. if (0 == ::LoadString(::GetInstanceHandle(), (UINT)((UINT_PTR) pcszPage),
  121. szWebPageFormat, CCHMAX(szWebPageFormat)))
  122. {
  123. ERROR_OUT(("LaunchRedirWebPage: Unable to find IDS=%08X", (UINT)((UINT_PTR)pcszPage)));
  124. return;
  125. }
  126. pcszPage = szWebPageFormat;
  127. bForceFormat = true;
  128. }
  129. if (bForceFormat)
  130. {
  131. lstrcpy(szWebPageFormat, pcszPage);
  132. FormatURL(szWebPageFormat);
  133. ASSERT(lstrlen(szWebPageFormat) < CCHMAX(szWebPageFormat));
  134. pcszPage = szWebPageFormat;
  135. }
  136. LaunchWebPage(pcszPage);
  137. }
  138. /* C M D L A U N C H W E B P A G E */
  139. /*-------------------------------------------------------------------------
  140. %%Function: CmdLaunchWebPage
  141. Display a web page, based on the command id.
  142. -------------------------------------------------------------------------*/
  143. VOID CmdLaunchWebPage(WPARAM wCmd)
  144. {
  145. LPTSTR psz;
  146. switch (wCmd)
  147. {
  148. default:
  149. {
  150. ERROR_OUT(("CmdLaunchWebHelp: Unknown command id=%08X", wCmd));
  151. // fall through
  152. }
  153. case ID_HELP_WEB_FREE:
  154. case ID_HELP_WEB_FAQ:
  155. case ID_HELP_WEB_FEEDBACK:
  156. case ID_HELP_WEB_MSHOME:
  157. {
  158. // NOTE: this requires that the format strings are in the same order
  159. // as the menu command ID's
  160. LaunchRedirWebPage((LPCTSTR) wCmd - (ID_HELP_WEB_FREE - IDS_WEB_PAGE_FORMAT_FREE));
  161. break;
  162. }
  163. case ID_HELP_WEB_SUPPORT:
  164. {
  165. TCHAR sz[ MAX_PATH ];
  166. bool bForcePrintf = ConfPolicies::GetIntranetSupportURL(sz, CCHMAX(sz));
  167. LaunchRedirWebPage( sz, bForcePrintf );
  168. break;
  169. }
  170. case ID_HELP_WEB_NEWS:
  171. {
  172. RegEntry re(CONFERENCING_KEY, HKEY_CURRENT_USER);
  173. psz = re.GetString(REGVAL_HOME_PAGE);
  174. if (FEmptySz(psz))
  175. {
  176. psz = (LPTSTR) IDS_WEB_PAGE_FORMAT_NEWS;
  177. }
  178. LaunchRedirWebPage(psz);
  179. break;
  180. }
  181. case IDM_VIDEO_GETACAMERA:
  182. {
  183. LaunchRedirWebPage(MAKEINTRESOURCE(IDS_WEB_PAGE_FORMAT_GETCAMERA));
  184. break;
  185. }
  186. } /* switch (wCommand) */
  187. }
  188. /* C M D S H O W R E L E A S E N O T E S */
  189. /*-------------------------------------------------------------------------
  190. %%Function: CmdShowReleaseNotes
  191. -------------------------------------------------------------------------*/
  192. VOID CmdShowReleaseNotes(void)
  193. {
  194. if (!FLaunchPsz(g_cszRelNotesFileName))
  195. {
  196. ::PostConfMsgBox(IDS_RELEASE_NOTES_MISSING);
  197. }
  198. }
  199. /* A B O U T B O X D L G P R O C */
  200. /*-------------------------------------------------------------------------
  201. %%Function: AboutBoxDlgProc
  202. -------------------------------------------------------------------------*/
  203. INT_PTR CALLBACK AboutBoxDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
  204. {
  205. switch (uMsg)
  206. {
  207. case WM_INITDIALOG:
  208. {
  209. TCHAR sz[700]; // really large for copyright message
  210. TCHAR *szIPList[] = {sz, sz+20, sz+40, sz+80};
  211. TCHAR *szIPDisplay = sz+200;
  212. int nListSize = sizeof(szIPList)/sizeof(TCHAR*);
  213. int nCount, nIndex;
  214. if (0 != ::GetDlgItemText(hDlg, IDC_ABOUT_VERSION_STATIC, sz, CCHMAX(sz)))
  215. {
  216. // Retrieved the format buffer from the dialog:
  217. TCHAR szVisibleText[MAX_PATH];
  218. wsprintf(szVisibleText, sz, VER_PRODUCTVERSION_STR);
  219. // Replace the text with text that contains the version number:
  220. ::SetDlgItemText(hDlg, IDC_ABOUT_VERSION_STATIC, szVisibleText);
  221. }
  222. // The about box copyright is > 255 characters.
  223. if (FLoadString(IDS_ABOUT_COPYRIGHT, sz, CCHMAX(sz)))
  224. {
  225. ::SetDlgItemText(hDlg, IDC_ABOUT_COPYRIGHT, sz);
  226. }
  227. // go fetch our IP address and display it to the user
  228. // we can only display up to 4
  229. nCount = GetIPAddresses(szIPList, nListSize);
  230. if (nCount >= 1)
  231. {
  232. lstrcpy(szIPDisplay, szIPList[0]);
  233. for (nIndex = 1; nIndex < nCount; nIndex++)
  234. {
  235. lstrcat(szIPDisplay, ", ");
  236. lstrcat(szIPDisplay, szIPList[nIndex]);
  237. }
  238. ::SetDlgItemText(hDlg, IDC_IP_ADDRESS, szIPDisplay);
  239. }
  240. else
  241. {
  242. // on error, don't show anything about IP addresses
  243. ShowWindow(GetDlgItem(hDlg, IDC_IP_ADDRESS), SW_HIDE);
  244. ShowWindow(GetDlgItem(hDlg, IDC_IPADDR_STATIC), SW_HIDE);
  245. }
  246. break;
  247. }
  248. case WM_COMMAND:
  249. {
  250. ::EndDialog(hDlg, LOWORD(wParam));
  251. break;
  252. }
  253. default:
  254. {
  255. return FALSE;
  256. }
  257. } /* switch (uMsg) */
  258. return TRUE;
  259. }
  260. /* C M D S H O W A B O U T */
  261. /*-------------------------------------------------------------------------
  262. %%Function: CmdShowAbout
  263. -------------------------------------------------------------------------*/
  264. VOID CmdShowAbout(HWND hwnd)
  265. {
  266. ::DialogBox(::GetInstanceHandle(), MAKEINTRESOURCE(IDD_ABOUT_BOX),
  267. hwnd, AboutBoxDlgProc);
  268. }
  269. /* F E N A B L E A U D I O W I Z A R D */
  270. /*-------------------------------------------------------------------------
  271. %%Function: FEnableAudioWizard
  272. -------------------------------------------------------------------------*/
  273. BOOL FEnableAudioWizard(void)
  274. {
  275. return FIsAudioAllowed() && (NULL == GetActiveConference());
  276. }
  277. ///////////////////////////////////////////////////////////////////////////
  278. // Application Sharing commands
  279. BOOL FEnableCmdShare(void)
  280. {
  281. CConfRoom * pcr = ::GetConfRoom();
  282. if (NULL == pcr)
  283. return FALSE;
  284. return pcr->FCanShare();
  285. }
  286. ///////////////////////////////////////////////////////////////////////////
  287. BOOL FEnableCmdHangup(void)
  288. {
  289. return ::FIsConferenceActive();
  290. }