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.

1406 lines
44 KiB

  1. /****************************************************************************
  2. *
  3. * FILE: UlsCpl.cpp
  4. *
  5. * CREATED: Claus Giloi (ClausGi) 4-18-96
  6. *
  7. * CONTENTS: ULS-related control panel control data exchange functions
  8. *
  9. ****************************************************************************/
  10. #include "precomp.h"
  11. #include "help_ids.h"
  12. #include "ulswizrd.h"
  13. #include "confcpl.h"
  14. #include "NmLdap.h"
  15. #include "call.h"
  16. #include "statbar.h"
  17. #include "confpolicies.h"
  18. #include "conf.h"
  19. #include "callto.h"
  20. // Globals
  21. static CULSWizard* s_pUlsWizard = NULL;
  22. static ULS_CONF g_Old_ulsC;
  23. static BOOL g_fOld_ulsC_saved = FALSE;
  24. static bool s_fOldUseUlsServer;
  25. static bool s_fOldTaskbarSetting;
  26. static bool s_fOldAlwaysRunning;
  27. static HWND s_hDlgUserInfo = NULL;
  28. static DWORD aUserHelpIds[] =
  29. {
  30. // User information settings...
  31. IDC_MYINFO_GROUP, IDH_MYINFO_MYINFO,
  32. IDG_DIRECTMODE, IDH_MYINFO_MYINFO,
  33. IDC_STATIC_MYINFO, IDH_MYINFO_MYINFO,
  34. IDC_USER_NAME, IDH_MYINFO_FIRSTNAME,
  35. IDC_USER_LASTNAME, IDH_MYINFO_LASTNAME,
  36. IDC_USER_EMAIL, IDH_MYINFO_EMAIL,
  37. IDC_USER_LOCATION, IDH_MYINFO_LOCATION,
  38. IDC_USER_INTERESTS, IDH_MYINFO_COMMENTS,
  39. // ILS settings...
  40. IDC_USER_PUBLISH, IDH_MYINFO_PUBLISH,
  41. IDC_USEULS, IDH_MYINFO_DIRECTORY_AT_START,
  42. IDC_NAMESERVER, IDH_MYINFO_ULS_SERVER,
  43. IDC_STATIC_SERVER_NAME, IDH_MYINFO_ULS_SERVER,
  44. // General stuff
  45. IDC_SHOWONTASKBAR, IDH_GENERAL_SHOW_ON_TASKBAR,
  46. IDC_BANDWIDTH, IDH_CALLING_BANDWIDTH,
  47. IDC_ADVANCED_CALL_OPTS, IDH_CALLING_ADVANCED,
  48. // NULL terminator...
  49. 0, 0
  50. };
  51. static const DWORD _rgHelpIdsCalling[] =
  52. {
  53. // GateKeeper settings...
  54. IDC_CALLOPT_GK_USE, IDH_SERVERS_USE_GATEKEEPER,
  55. IDG_GKMODE, IDH_GENERAL_GENERAL,
  56. IDE_CALLOPT_GK_SERVER, IDH_SERVERS_GATEKEEPER_NAME,
  57. IDC_STATIC_GATEKEEPER_NAME, IDH_SERVERS_GATEKEEPER_NAME,
  58. IDC_CHECK_USE_ACCOUNT, IDH_ADVCALL_USE_ACCOUNT,
  59. IDS_STATIC_ACCOUNT, IDH_ADVCALL_ACCOUNT_NO,
  60. IDE_CALLOPT_GK_ACCOUNT, IDH_ADVCALL_ACCOUNT_NO,
  61. IDC_CHECK_USE_PHONE_NUMBERS, IDH_SERVERS_GATEKEEPER_PHONENO,
  62. IDC_STATIC_PHONE_NUMBER, IDH_MYINFO_PHONE,
  63. IDE_CALLOPT_GK_PHONE_NUMBER, IDH_MYINFO_PHONE,
  64. // Direct proxy settings...
  65. IDG_DIRECTMODE, IDH_GENERAL_GENERAL,
  66. IDC_CHECK_USE_PROXY, IDH_ADVCALL_USE_PROXY,
  67. IDC_STATIC_PROXY_NAME, IDH_ADVCALL_PROXY_NAME,
  68. IDE_CALLOPT_PROXY_SERVER, IDH_ADVCALL_PROXY_NAME,
  69. // Direct gateway settings...
  70. IDC_CHECK_USE_GATEWAY, IDH_AUDIO_USEGATEWAY,
  71. IDC_STATIC_GATEWAY_NAME, IDH_AUDIO_H323_GATEWAY,
  72. IDE_CALLOPT_GW_SERVER, IDH_AUDIO_H323_GATEWAY,
  73. // NULL terminator...
  74. 0, 0
  75. };
  76. VOID FixServerDropList(HWND hdlg, int id, LPTSTR pszServer, UINT cchMax);
  77. static void _SetLogOntoIlsButton( HWND hDlg, bool bLogOntoIlsWhenNmStarts );
  78. void InitGWInfo( HWND hDlg, CULSWizard* pWiz, bool& rbOldEnableGateway, LPTSTR szOldServerNameBuf, UINT cch );
  79. void InitProxyInfo( HWND hDlg, CULSWizard* pWiz, bool& rbOldEnableProxy, LPTSTR szOldServerNameBuf, UINT cch );
  80. // Functions
  81. inline bool FIsDlgButtonChecked(HWND hDlg, int nIDButton)
  82. {
  83. return ( BST_CHECKED == IsDlgButtonChecked(hDlg, nIDButton) );
  84. }
  85. static BOOL InitULSDll ( VOID )
  86. {
  87. delete s_pUlsWizard;
  88. return (NULL != (s_pUlsWizard = new CULSWizard()));
  89. }
  90. static BOOL DeInitULSDll ( VOID )
  91. {
  92. if( s_pUlsWizard )
  93. {
  94. delete s_pUlsWizard;
  95. s_pUlsWizard = NULL;
  96. }
  97. return TRUE;
  98. }
  99. // implemented in wizard.cpp
  100. extern UINT GetBandwidth();
  101. extern void SetBandwidth(UINT uBandwidth);
  102. // implemented in audiocpl.cpp
  103. extern VOID UpdateCodecSettings(UINT uBandWidth);
  104. static HRESULT InitULSControls(HWND hDlg, CULSWizard* pWiz,
  105. UINT ideditServerName,
  106. UINT ideditFirstName,
  107. UINT ideditLastName,
  108. UINT ideditEmailName,
  109. UINT ideditLocation,
  110. UINT ideditInterests,
  111. UINT idbtnDontPublish )
  112. {
  113. HRESULT hr = (pWiz == NULL) ? E_NOINTERFACE : S_OK;
  114. if (SUCCEEDED(hr))
  115. {
  116. // Build up the flags for the getconfiguration call
  117. ULS_CONF ulsC;
  118. ClearStruct(&ulsC);
  119. if ( ideditServerName )
  120. ulsC.dwFlags |= ULSCONF_F_SERVER_NAME;
  121. if ( ideditFirstName )
  122. ulsC.dwFlags |= ULSCONF_F_FIRST_NAME;
  123. if ( ideditLastName )
  124. ulsC.dwFlags |= ULSCONF_F_LAST_NAME;
  125. if ( ideditEmailName )
  126. ulsC.dwFlags |= ULSCONF_F_EMAIL_NAME;
  127. if ( ideditLocation )
  128. ulsC.dwFlags |= ULSCONF_F_LOCATION;
  129. if ( ideditInterests )
  130. ulsC.dwFlags |= ULSCONF_F_COMMENTS;
  131. if ( idbtnDontPublish )
  132. ulsC.dwFlags |= ULSCONF_F_PUBLISH;
  133. // Get the current data
  134. hr = s_pUlsWizard->GetConfig(&ulsC);
  135. if (SUCCEEDED(hr))
  136. {
  137. // Save a copy of the struct to detect changes later
  138. g_Old_ulsC = ulsC;
  139. g_fOld_ulsC_saved = TRUE;
  140. if ( ideditFirstName )
  141. SetDlgItemText ( hDlg, ideditFirstName, ulsC.szFirstName );
  142. if ( ideditLastName )
  143. SetDlgItemText ( hDlg, ideditLastName, ulsC.szLastName );
  144. if ( ideditEmailName )
  145. SetDlgItemText ( hDlg, ideditEmailName, ulsC.szEmailName );
  146. if ( ideditLocation )
  147. SetDlgItemText ( hDlg, ideditLocation, ulsC.szLocation );
  148. if ( ideditInterests )
  149. SetDlgItemText ( hDlg, ideditInterests, ulsC.szComments );
  150. if ( idbtnDontPublish )
  151. SendDlgItemMessage ( hDlg, idbtnDontPublish, BM_SETCHECK,
  152. ulsC.fDontPublish ? TRUE : FALSE, 0 );
  153. }
  154. }
  155. if (FAILED(hr))
  156. {
  157. // There was a problem - disable everything
  158. DisableControl(hDlg, ideditServerName);
  159. DisableControl(hDlg, ideditFirstName);
  160. DisableControl(hDlg, ideditLastName);
  161. DisableControl(hDlg, ideditEmailName);
  162. DisableControl(hDlg, ideditLocation);
  163. DisableControl(hDlg, ideditInterests);
  164. DisableControl(hDlg, idbtnDontPublish);
  165. }
  166. return hr;
  167. }
  168. static BOOL IsULSEqual ( ULS_CONF * u1, ULS_CONF *u2, DWORD dwFlags )
  169. {
  170. if ( lstrcmp ( u1->szServerName, u2->szServerName ) &&
  171. ( dwFlags & ULSCONF_F_SERVER_NAME ) ||
  172. lstrcmp ( u1->szFirstName, u2->szFirstName ) &&
  173. ( dwFlags & ULSCONF_F_FIRST_NAME ) ||
  174. lstrcmp ( u1->szLastName, u2->szLastName ) &&
  175. ( dwFlags & ULSCONF_F_LAST_NAME ) ||
  176. lstrcmp ( u1->szEmailName, u2->szEmailName ) &&
  177. ( dwFlags & ULSCONF_F_EMAIL_NAME ) ||
  178. lstrcmp ( u1->szLocation, u2->szLocation ) &&
  179. ( dwFlags & ULSCONF_F_LOCATION ) ||
  180. lstrcmp ( u1->szComments, u2->szComments ) &&
  181. ( dwFlags & ULSCONF_F_COMMENTS ) ||
  182. u1->fDontPublish != u2->fDontPublish &&
  183. ( dwFlags & ULSCONF_F_PUBLISH ) )
  184. return FALSE;
  185. return TRUE;
  186. }
  187. static HRESULT SaveULSControls ( HWND hDlg,
  188. UINT ideditServerName,
  189. UINT ideditFirstName,
  190. UINT ideditLastName,
  191. UINT ideditEmailName,
  192. UINT ideditLocation,
  193. UINT ideditInterests,
  194. UINT idbtnDontPublish,
  195. BOOL bServerNameChanged
  196. )
  197. {
  198. // Check to see if the ULS is initialized
  199. if ( s_pUlsWizard == NULL ) {
  200. return E_NOINTERFACE;
  201. }
  202. // Now build up the flags for the setconfiguration call
  203. ULS_CONF ulsC;
  204. ulsC.dwFlags = 0;
  205. if ( ideditServerName )
  206. ulsC.dwFlags |= ULSCONF_F_SERVER_NAME;
  207. if ( ideditFirstName )
  208. ulsC.dwFlags |= ULSCONF_F_FIRST_NAME;
  209. if ( ideditLastName )
  210. ulsC.dwFlags |= ULSCONF_F_LAST_NAME;
  211. if ( ideditEmailName )
  212. ulsC.dwFlags |= ULSCONF_F_EMAIL_NAME;
  213. if ( ideditLocation )
  214. ulsC.dwFlags |= ULSCONF_F_LOCATION;
  215. if ( ideditInterests )
  216. ulsC.dwFlags |= ULSCONF_F_COMMENTS;
  217. if ( idbtnDontPublish )
  218. ulsC.dwFlags |= ULSCONF_F_PUBLISH;
  219. // Initialize the structure from the controls
  220. if ( ideditServerName )
  221. {
  222. GetDlgItemText( hDlg, ideditServerName, ulsC.szServerName, sizeof ( ulsC.szServerName ) );
  223. lstrcpyn( ulsC.szServerName, CDirectoryManager::get_dnsName( ulsC.szServerName ), sizeof ( ulsC.szServerName ) );
  224. }
  225. if ( ideditFirstName )
  226. GetDlgItemText ( hDlg, ideditFirstName, ulsC.szFirstName,
  227. sizeof( ulsC.szFirstName ) );
  228. if ( ideditLastName )
  229. GetDlgItemText ( hDlg, ideditLastName, ulsC.szLastName,
  230. sizeof( ulsC.szLastName ) );
  231. if ( ideditEmailName )
  232. GetDlgItemText ( hDlg, ideditEmailName, ulsC.szEmailName,
  233. sizeof( ulsC.szEmailName ) );
  234. if ( ideditLocation )
  235. GetDlgItemText ( hDlg, ideditLocation, ulsC.szLocation,
  236. sizeof( ulsC.szLocation ) );
  237. if ( ideditInterests )
  238. GetDlgItemText ( hDlg, ideditInterests, ulsC.szComments,
  239. sizeof( ulsC.szComments ) );
  240. if ( idbtnDontPublish )
  241. ulsC.fDontPublish =
  242. (BOOL)SendDlgItemMessage ( hDlg, idbtnDontPublish, BM_GETCHECK, 0, 0 );
  243. // Make the call
  244. HRESULT hRes = s_pUlsWizard->SetConfig( &ulsC );
  245. if ( hRes != S_OK) {
  246. ERROR_OUT(("ULSSetConfig call failed: %lx", hRes ));
  247. return hRes;
  248. }
  249. // Now check for changed ULS settings
  250. if ( g_fOld_ulsC_saved || bServerNameChanged) {
  251. if ( bServerNameChanged || !IsULSEqual ( &ulsC , &g_Old_ulsC, ulsC.dwFlags ))
  252. {
  253. g_dwChangedSettings |= CSETTING_L_ULSSETTINGS;
  254. if(ConfPolicies::GetCallingMode() == ConfPolicies::CallingMode_Direct)
  255. {
  256. BOOL bLogonToILSServer = TRUE;
  257. if(!g_pLDAP || !g_pLDAP->IsLoggedOn())
  258. {
  259. TCHAR res1[RES_CH_MAX];
  260. USES_RES2T
  261. RES2T(IDS_ULS_CHANGED_PROMPT);
  262. COPY_RES2T(res1);
  263. // Ask the user if they want to logon
  264. int iRet = ::MessageBox(hDlg,
  265. res1,
  266. RES2T(IDS_MSGBOX_TITLE),
  267. MB_SETFOREGROUND | MB_YESNO | MB_ICONQUESTION);
  268. if(IDNO == iRet)
  269. {
  270. bLogonToILSServer = FALSE;
  271. }
  272. }
  273. if(bLogonToILSServer)
  274. {
  275. if(NULL == g_pLDAP)
  276. {
  277. InitNmLdapAndLogon();
  278. }
  279. else
  280. {
  281. g_pLDAP->LogonAsync();
  282. }
  283. }
  284. }
  285. }
  286. }
  287. return S_OK;
  288. }
  289. /* _ I N I T U S E R D L G P R O C */
  290. /*-------------------------------------------------------------------------
  291. %%Function: _InitUserDlgProc
  292. Initialize the conferencing name fields
  293. -------------------------------------------------------------------------*/
  294. static void _InitUserDlgProc(HWND hdlg, PROPSHEETPAGE * ps, LPTSTR szOldServerNameBuf, UINT cch )
  295. {
  296. RegEntry reCU( CONFERENCING_KEY, HKEY_CURRENT_USER);
  297. s_fOldAlwaysRunning = (0 != reCU.GetNumber(
  298. REGVAL_CONF_ALWAYS_RUNNING, ALWAYS_RUNNING_DEFAULT ));
  299. CheckDlgButton( hdlg, IDC_ALWAYS_RUNNING, s_fOldAlwaysRunning ? BST_CHECKED : BST_UNCHECKED );
  300. #ifndef TASKBARBKGNDONLY
  301. ///////////////////////////////////////////////////////////
  302. //
  303. // Taskbar Icon Settings
  304. //
  305. // Initialize the icon-on-taskbar settings
  306. // Check the right button for taskbar icon use
  307. s_fOldTaskbarSetting = reCU.GetNumber(
  308. REGVAL_TASKBAR_ICON, TASKBARICON_DEFAULT )
  309. == TASKBARICON_ALWAYS;
  310. SendDlgItemMessage ( hdlg, IDC_SHOWONTASKBAR,
  311. BM_SETCHECK,
  312. s_fOldTaskbarSetting ? BST_CHECKED : BST_UNCHECKED,
  313. 0L );
  314. #endif // ! TASKBARBKGNDONLY
  315. #if USE_GAL
  316. if( ConfPolicies::IsGetMyInfoFromGALEnabled() && ConfPolicies::GetMyInfoFromGALSucceeded())
  317. {
  318. EnableWindow( GetDlgItem( hdlg, IDC_USER_NAME), FALSE );
  319. EnableWindow( GetDlgItem( hdlg, IDC_USER_LASTNAME), FALSE );
  320. EnableWindow( GetDlgItem( hdlg, IDC_USER_EMAIL), FALSE );
  321. EnableWindow( GetDlgItem( hdlg, IDC_USER_LOCATION), FALSE );
  322. EnableWindow( GetDlgItem( hdlg, IDC_USER_INTERESTS), FALSE );
  323. TCHAR szBuffer[ MAX_PATH ];
  324. FLoadString( IDS_MYINFO_CAPTION_DISABLED, szBuffer, CCHMAX( szBuffer ) );
  325. SetWindowText( GetDlgItem( hdlg, IDC_STATIC_MYINFO ), szBuffer );
  326. }
  327. else
  328. {
  329. TCHAR szBuffer[ MAX_PATH ];
  330. FLoadString( IDS_MYINFO_CAPTION_ENABLED, szBuffer, CCHMAX( szBuffer ) );
  331. SetWindowText( GetDlgItem( hdlg, IDC_STATIC_MYINFO ), szBuffer );
  332. }
  333. #endif // USE_GAL
  334. if( ConfPolicies::GetCallingMode() == ConfPolicies::CallingMode_GateKeeper)
  335. {
  336. // Disable the ILS-related stuff
  337. EnableWindow( GetDlgItem( hdlg, IDC_NAMESERVER), FALSE );
  338. EnableWindow( GetDlgItem( hdlg, IDC_USER_PUBLISH), FALSE );
  339. EnableWindow( GetDlgItem( hdlg, IDC_USEULS), FALSE );
  340. EnableWindow( GetDlgItem( hdlg, IDC_STATIC_SERVER_NAME), FALSE );
  341. }
  342. EnableWindow( GetDlgItem( hdlg, IDC_ADVANCED_CALL_OPTS),
  343. ConfPolicies::IsAdvancedCallingAllowed());
  344. // Set the font
  345. SendDlgItemMessage(hdlg, IDC_USER_NAME, WM_SETFONT, (WPARAM) g_hfontDlg, 0);
  346. SendDlgItemMessage(hdlg, IDC_USER_LASTNAME, WM_SETFONT, (WPARAM) g_hfontDlg, 0);
  347. SendDlgItemMessage(hdlg, IDC_USER_LOCATION, WM_SETFONT, (WPARAM) g_hfontDlg, 0);
  348. SendDlgItemMessage(hdlg, IDC_USER_INTERESTS, WM_SETFONT, (WPARAM) g_hfontDlg, 0);
  349. // Limit the edit control
  350. SendDlgItemMessage(hdlg, IDC_USER_NAME, EM_LIMITTEXT, MAX_FIRST_NAME_LENGTH-1, 0);
  351. SendDlgItemMessage(hdlg, IDC_USER_LASTNAME, EM_LIMITTEXT, MAX_LAST_NAME_LENGTH-1, 0);
  352. SendDlgItemMessage(hdlg, IDC_USER_EMAIL, EM_LIMITTEXT, MAX_EMAIL_NAME_LENGTH-1, 0);
  353. SendDlgItemMessage(hdlg, IDC_USER_LOCATION, EM_LIMITTEXT, MAX_LOCATION_NAME_LENGTH-1, 0);
  354. SendDlgItemMessage(hdlg, IDC_USER_INTERESTS,EM_LIMITTEXT, UI_COMMENTS_LENGTH-1, 0);
  355. InitULSDll();
  356. RegEntry reConf(CONFERENCING_KEY, HKEY_CURRENT_USER);
  357. // Init the server combobox... can we skip this stuff if we are not using ILS????
  358. FixServerDropList(hdlg, IDC_NAMESERVER, szOldServerNameBuf, cch );
  359. InitULSControls(hdlg, s_pUlsWizard,
  360. IDC_NAMESERVER,
  361. IDC_USER_NAME, IDC_USER_LASTNAME, IDC_USER_EMAIL,
  362. IDC_USER_LOCATION, IDC_USER_INTERESTS,
  363. IDC_USER_PUBLISH);
  364. // First the log onto directory servers stuff...
  365. s_fOldUseUlsServer = ConfPolicies::LogOntoIlsWhenNetMeetingStartsIfInDirectCallingMode();
  366. _SetLogOntoIlsButton( hdlg, s_fOldUseUlsServer);
  367. if (!SysPol::AllowDirectoryServices())
  368. {
  369. // Disable all items in this group
  370. DisableControl(hdlg, IDC_USEULS);
  371. DisableControl(hdlg, IDC_NAMESERVER);
  372. DisableControl(hdlg, IDC_USER_PUBLISH);
  373. DisableControl(hdlg, IDC_STATIC_SERVER_NAME);
  374. }
  375. s_hDlgUserInfo = hdlg;
  376. }
  377. static void General_OnCommand(HWND hDlg, int id, HWND hwndCtl, UINT codeNotify, UINT *puBandwidth)
  378. {
  379. INT_PTR CALLBACK BandwidthDlg( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
  380. switch(id)
  381. {
  382. case IDC_ADVANCED_CALL_OPTS:
  383. {
  384. DialogBox( GetInstanceHandle(), MAKEINTRESOURCE( IDD_CALLOPT ), hDlg, CallOptDlgProc );
  385. BOOL bEnable = (ConfPolicies::GetCallingMode() == ConfPolicies::CallingMode_Direct);
  386. // Disable/Enable the ILS-related stuff
  387. EnableWindow( GetDlgItem( hDlg, IDC_NAMESERVER), bEnable );
  388. EnableWindow( GetDlgItem( hDlg, IDC_USER_PUBLISH), bEnable );
  389. EnableWindow( GetDlgItem( hDlg, IDC_USEULS), bEnable );
  390. EnableWindow( GetDlgItem( hDlg, IDC_STATIC_SERVER_NAME), bEnable );
  391. // We are now in Gatekeeper mode, we should log off the ILS server
  392. if(!bEnable && g_pLDAP && g_pLDAP->IsLoggedOn())
  393. {
  394. g_pLDAP->Logoff();
  395. }
  396. break;
  397. }
  398. case IDC_BANDWIDTH:
  399. int nRet;
  400. nRet = (int)DialogBoxParam(_Module.GetModuleInstance(), MAKEINTRESOURCE(IDD_BANDWIDTH), hDlg, BandwidthDlg, *puBandwidth);
  401. if (nRet != 0)
  402. {
  403. *puBandwidth = nRet;
  404. }
  405. break;
  406. case IDC_ALWAYS_RUNNING:
  407. if (FIsDlgButtonChecked( hDlg, IDC_ALWAYS_RUNNING ))
  408. {
  409. VOID EnableRDS(BOOL fEnabledRDS);
  410. RegEntry reLM( REMOTECONTROL_KEY, HKEY_LOCAL_MACHINE);
  411. BOOL bRDSRunning = reLM.GetNumber(REMOTE_REG_RUNSERVICE, DEFAULT_REMOTE_RUNSERVICE);
  412. if (bRDSRunning)
  413. {
  414. TCHAR szMsg[2*RES_CH_MAX];
  415. USES_RES2T
  416. if (IDYES != MessageBox(hDlg,
  417. Res2THelper(IDS_RDSWARNING, szMsg, ARRAY_ELEMENTS(szMsg)), RES2T(IDS_MSGBOX_TITLE),
  418. MB_YESNO|MB_ICONHAND))
  419. {
  420. CheckDlgButton(hDlg, IDC_ALWAYS_RUNNING, BST_UNCHECKED);
  421. break;
  422. }
  423. EnableRDS(FALSE);
  424. }
  425. }
  426. break;
  427. default:
  428. break;
  429. }
  430. }
  431. /* U S E R D L G P R O C */
  432. /*-------------------------------------------------------------------------
  433. %%Function: UserDlgProc
  434. -------------------------------------------------------------------------*/
  435. INT_PTR APIENTRY UserDlgProc( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  436. {
  437. static PROPSHEETPAGE * ps;
  438. static TCHAR s_szOldServerNameBuf[MAX_PATH];
  439. static UINT uOldBandwidth=0;
  440. static UINT uNewBandwidth=0;
  441. switch (message)
  442. {
  443. case WM_INITDIALOG:
  444. {
  445. // Save the PROPSHEETPAGE information.
  446. ps = (PROPSHEETPAGE *)lParam;
  447. _InitUserDlgProc(hDlg, ps, s_szOldServerNameBuf, CCHMAX(s_szOldServerNameBuf) );
  448. uNewBandwidth = uOldBandwidth = GetBandwidth();
  449. return TRUE;
  450. }
  451. case WM_COMMAND:
  452. General_OnCommand(hDlg, LOWORD(wParam), (HWND)lParam, HIWORD(wParam), &uNewBandwidth);
  453. break;
  454. case WM_NOTIFY:
  455. switch (((NMHDR FAR *) lParam)->code) {
  456. case PSN_KILLACTIVE:
  457. {
  458. int _IdFocus = 0;
  459. TCHAR szName[MAX_FIRST_NAME_LENGTH];
  460. TCHAR szLastName[MAX_LAST_NAME_LENGTH];
  461. TCHAR szEMail[MAX_EMAIL_NAME_LENGTH];
  462. // Check for no data in user name
  463. if (0 == GetDlgItemTextTrimmed(hDlg, IDC_USER_NAME, szName, CCHMAX(szName) ))
  464. {
  465. ConfMsgBox(hDlg, (LPCTSTR)IDS_NEEDUSERNAME);
  466. _IdFocus = IDC_USER_NAME;
  467. }
  468. // Check for no data in user name
  469. else if( 0 == GetDlgItemTextTrimmed(hDlg, IDC_USER_LASTNAME, szLastName, CCHMAX(szLastName)))
  470. {
  471. ConfMsgBox(hDlg, (LPCTSTR)IDS_NEEDUSERNAME);
  472. _IdFocus = IDC_USER_LASTNAME;
  473. }
  474. else if( (!GetDlgItemText(hDlg, IDC_USER_EMAIL, szEMail, CCHMAX(szEMail)) || !FLegalEmailSz(szEMail)))
  475. {
  476. ConfMsgBox(hDlg, (LPCTSTR)IDS_ILLEGALEMAILNAME);
  477. _IdFocus = IDC_USER_EMAIL;
  478. }
  479. TCHAR szServerNameBuf[ MAX_PATH ];
  480. if( (!_IdFocus) &&
  481. FIsDlgButtonChecked( hDlg, IDC_USEULS ) &&
  482. (GetDlgItemTextTrimmed( hDlg, IDC_NAMESERVER, szServerNameBuf, CCHMAX( szServerNameBuf ) ) == 0) )
  483. {
  484. // They specified logon to ILS at startup but didn't specify an ILS...
  485. ConfMsgBox( hDlg, (LPCTSTR) IDS_NO_ILS_SERVER );
  486. _IdFocus = IDC_NAMESERVER;
  487. }
  488. if( _IdFocus )
  489. {
  490. SetFocus(GetDlgItem(hDlg, _IdFocus));
  491. SendDlgItemMessage(hDlg, _IdFocus, EM_SETSEL, (WPARAM) 0, (LPARAM) -1);
  492. SetWindowLongPtr(hDlg, DWLP_MSGRESULT, TRUE );
  493. return TRUE;
  494. }
  495. }
  496. break;
  497. case PSN_APPLY:
  498. {
  499. RegEntry reConf( CONFERENCING_KEY, HKEY_CURRENT_USER );
  500. bool fAlwaysRunning;
  501. fAlwaysRunning = FIsDlgButtonChecked( hDlg, IDC_ALWAYS_RUNNING );
  502. // if ( fAlwaysRunning != s_fOldAlwaysRunning )
  503. {
  504. reConf.SetValue(REGVAL_CONF_ALWAYS_RUNNING, fAlwaysRunning);
  505. RegEntry reRun(WINDOWS_RUN_KEY, HKEY_CURRENT_USER);
  506. if (fAlwaysRunning)
  507. {
  508. TCHAR szRunTask[MAX_PATH*2];
  509. TCHAR szInstallDir[MAX_PATH];
  510. if (GetInstallDirectory(szInstallDir))
  511. {
  512. RegEntry reConfLM(CONFERENCING_KEY, HKEY_LOCAL_MACHINE);
  513. wsprintf(szRunTask, _TEXT("\"%s%s\" -%s"),
  514. szInstallDir,
  515. reConfLM.GetString(REGVAL_NC_NAME),
  516. g_cszBackgroundSwitch);
  517. reRun.SetValue(REGVAL_RUN_TASKNAME, szRunTask);
  518. }
  519. }
  520. else
  521. {
  522. reRun.DeleteValue(REGVAL_RUN_TASKNAME);
  523. }
  524. }
  525. #ifndef TASKBARBKGNDONLY
  526. ///////////////////////////////////////////////////////////
  527. //
  528. // Taskbar Icon Settings
  529. //
  530. // Save taskbar icon state
  531. bool fTaskbarSetting;
  532. fTaskbarSetting = FIsDlgButtonChecked( hDlg,
  533. IDC_SHOWONTASKBAR );
  534. if ( fTaskbarSetting != s_fOldTaskbarSetting )
  535. {
  536. reConf.SetValue( REGVAL_TASKBAR_ICON,
  537. fTaskbarSetting? TASKBARICON_ALWAYS :
  538. TASKBARICON_NEVER );
  539. g_dwChangedSettings |= CSETTING_L_SHOWTASKBAR;
  540. }
  541. #endif // ! TASKBARBKGNDONLY
  542. // Process "use uls server" setting...
  543. bool fUseUlsServer = FIsDlgButtonChecked( hDlg, IDC_USEULS ) ? true : false;
  544. if( fUseUlsServer != s_fOldUseUlsServer )
  545. {
  546. reConf.SetValue( REGVAL_DONT_LOGON_ULS, !fUseUlsServer );
  547. g_dwChangedSettings |= CSETTING_L_USEULSSERVER;
  548. }
  549. TCHAR szServerNameBuf[MAX_PATH];
  550. GetDlgItemTextTrimmed( hDlg, IDC_NAMESERVER, szServerNameBuf, CCHMAX( szServerNameBuf ) );
  551. if( lstrcmpi( szServerNameBuf, s_szOldServerNameBuf ) != 0 )
  552. {
  553. g_dwChangedSettings |= CSETTING_L_ULSSETTINGS;
  554. }
  555. ///////////////////////////////////////////////////////////
  556. //
  557. // Conferencing Name Settings
  558. //
  559. // Just clean the rest
  560. TrimDlgItemText(hDlg, IDC_USER_LOCATION);
  561. TrimDlgItemText(hDlg, IDC_USER_INTERESTS);
  562. BOOL bServerNameChanged = g_dwChangedSettings & CSETTING_L_USEULSSERVER;
  563. HRESULT hRes = SaveULSControls( hDlg,
  564. ((g_dwChangedSettings & CSETTING_L_ULSSETTINGS) != 0)? IDC_NAMESERVER: 0,
  565. IDC_USER_NAME,
  566. IDC_USER_LASTNAME,
  567. IDC_USER_EMAIL,
  568. IDC_USER_LOCATION,
  569. IDC_USER_INTERESTS,
  570. IDC_USER_PUBLISH,
  571. bServerNameChanged);
  572. if( (g_dwChangedSettings & CSETTING_L_ULSSETTINGS) != 0 )
  573. {
  574. g_pCCallto->SetIlsServerName( CDirectoryManager::get_dnsName( szServerNameBuf ) );
  575. }
  576. ASSERT(S_OK == hRes);
  577. if (uNewBandwidth != uOldBandwidth)
  578. {
  579. g_dwChangedSettings |= CSETTING_L_BANDWIDTH;
  580. SetBandwidth(uNewBandwidth);
  581. UpdateCodecSettings(uNewBandwidth);
  582. }
  583. break;
  584. }
  585. case PSN_RESET:
  586. break;
  587. }
  588. break;
  589. case WM_CONTEXTMENU:
  590. DoHelpWhatsThis(wParam, aUserHelpIds);
  591. break;
  592. case WM_HELP:
  593. DoHelp(lParam, aUserHelpIds);
  594. break;
  595. case WM_DESTROY:
  596. {
  597. DeInitULSDll();
  598. break;
  599. }
  600. }
  601. return (FALSE);
  602. }
  603. VOID FixServerDropList(HWND hdlg, int id, LPTSTR pszServer, UINT cchMax)
  604. {
  605. HWND hwndCtrl = GetDlgItem(hdlg, id);
  606. ASSERT(NULL != hwndCtrl);
  607. BOOL fComboBox = SysPol::AllowAddingServers();
  608. if (fComboBox)
  609. {
  610. // Limit the text in the edit control
  611. ComboBox_LimitText(GetDlgItem(hdlg, id), MAX_SERVER_NAME_LENGTH - 1);
  612. }
  613. else
  614. {
  615. // System policy does not allow adding new servers
  616. // Replace the combo list with a simple drop list
  617. RECT rc;
  618. GetWindowRect(hwndCtrl, &rc);
  619. LONG xpTop = rc.top;
  620. ComboBox_GetDroppedControlRect(hwndCtrl, &rc);
  621. rc.top = xpTop;
  622. ::MapWindowPoints(NULL, hdlg, (LPPOINT) &rc, 2);
  623. DWORD dwStyle = GetWindowLong(hwndCtrl, GWL_STYLE);
  624. DWORD dwStyleEx = GetWindowLong(hwndCtrl, GWL_EXSTYLE);
  625. INT_PTR id2 = GetWindowLong(hwndCtrl, GWL_ID);
  626. HFONT hFont = (HFONT) ::SendMessage(hwndCtrl, WM_GETFONT, 0, 0);
  627. HWND hwndPrev = ::GetNextWindow(hwndCtrl, GW_HWNDPREV);
  628. DestroyWindow(hwndCtrl);
  629. dwStyle = CBS_DROPDOWNLIST | (dwStyle & ~CBS_DROPDOWN);
  630. hwndCtrl = ::CreateWindowEx(dwStyleEx, TEXT("COMBOBOX"), g_szEmpty, dwStyle,
  631. rc.left, rc.top, RectWidth(rc), RectHeight(rc),
  632. hdlg, (HMENU) id2, ::GetInstanceHandle(), 0);
  633. ::SendMessage(hwndCtrl, WM_SETFONT, (WPARAM) hFont, 0);
  634. // Maintain the tab order
  635. ::SetWindowPos(hwndCtrl, hwndPrev, 0, 0, 0, 0,
  636. SWP_NOMOVE | SWP_NOSIZE | SWP_NOOWNERZORDER | SWP_NOREDRAW);
  637. }
  638. FillServerComboBox(hwndCtrl);
  639. // Find the item in the list
  640. int index = (int)::SendMessage( hwndCtrl, CB_FINDSTRINGEXACT, -1, (LPARAM) CDirectoryManager::get_displayName( pszServer ) );
  641. ComboBox_SetCurSel( hwndCtrl, (index == CB_ERR)? 0: index );
  642. }
  643. static void _SetCallingMode( HWND hDlg, ConfPolicies::eCallingMode eMode )
  644. {
  645. switch( eMode )
  646. {
  647. case ConfPolicies::CallingMode_Direct:
  648. CheckDlgButton( hDlg, IDC_CALLOPT_GK_USE, BST_UNCHECKED );
  649. SendMessage( hDlg, WM_COMMAND, MAKEWPARAM(IDC_CALLOPT_GK_USE,0 ), 0 );
  650. break;
  651. case ConfPolicies::CallingMode_GateKeeper:
  652. CheckDlgButton( hDlg, IDC_CALLOPT_GK_USE, BST_CHECKED );
  653. SendMessage( hDlg, WM_COMMAND, MAKEWPARAM(IDC_CALLOPT_GK_USE,0 ), 0 );
  654. break;
  655. default:
  656. ERROR_OUT(("Invalid return val"));
  657. break;
  658. }
  659. }
  660. static void _SetLogOntoIlsButton( HWND hDlg, bool bLogOntoIlsWhenNmStarts )
  661. {
  662. if( bLogOntoIlsWhenNmStarts )
  663. {
  664. CheckDlgButton( hDlg, IDC_USEULS, bLogOntoIlsWhenNmStarts ? BST_CHECKED : BST_UNCHECKED );
  665. SendMessage( hDlg, WM_COMMAND, MAKEWPARAM(IDC_USEULS, 0 ), 0 );
  666. }
  667. }
  668. // NOTE: This function is shared by the wizard page IDD_PAGE_SERVER
  669. void InitDirectoryServicesDlgInfo( HWND hDlg, CULSWizard* pWiz, bool& rbOldEnableGateway, LPTSTR szOldServerNameBuf, UINT cch )
  670. {
  671. RegEntry reConf(CONFERENCING_KEY, HKEY_CURRENT_USER);
  672. // Init the server combobox... can we skip this stuff if we are not using ILS????
  673. FixServerDropList(hDlg, IDC_NAMESERVER, szOldServerNameBuf, cch );
  674. InitULSControls(hDlg, pWiz,
  675. IDC_NAMESERVER,
  676. 0, 0, 0,
  677. 0, 0,
  678. IDC_USER_PUBLISH);
  679. // First the log onto directory servers stuff...
  680. s_fOldUseUlsServer = ConfPolicies::LogOntoIlsWhenNetMeetingStartsIfInDirectCallingMode();
  681. _SetLogOntoIlsButton( hDlg, s_fOldUseUlsServer);
  682. if (!SysPol::AllowDirectoryServices())
  683. {
  684. // Disable all items in this group
  685. DisableControl(hDlg, IDC_USEULS);
  686. DisableControl(hDlg, IDC_NAMESERVER);
  687. DisableControl(hDlg, IDC_USER_PUBLISH);
  688. }
  689. }
  690. void InitProxyInfo( HWND hDlg, CULSWizard* pWiz, bool& rbOldEnableProxy, LPTSTR szOldProxyNameBuf, UINT cch )
  691. {
  692. RegEntry reConf(CONFERENCING_KEY, HKEY_CURRENT_USER);
  693. // proxy settings...
  694. HWND hEditProxyServer = GetDlgItem( hDlg, IDE_CALLOPT_PROXY_SERVER );
  695. if( hEditProxyServer )
  696. {
  697. SetWindowText( hEditProxyServer, reConf.GetString( REGVAL_PROXY ) );
  698. SendMessage( hEditProxyServer, EM_LIMITTEXT, CCHMAXSZ_SERVER - 1, 0 );
  699. rbOldEnableProxy = reConf.GetNumber( REGVAL_USE_PROXY )? true: false;
  700. if( rbOldEnableProxy )
  701. {
  702. CheckDlgButton( hDlg, IDC_CHECK_USE_PROXY, BST_CHECKED );
  703. }
  704. else
  705. {
  706. EnableWindow( hEditProxyServer, FALSE );
  707. DisableControl( hDlg, IDC_STATIC_PROXY_NAME );
  708. }
  709. }
  710. }
  711. void InitGWInfo( HWND hDlg, CULSWizard* pWiz, bool& rbOldEnableGateway, LPTSTR szOldServerNameBuf, UINT cch )
  712. {
  713. RegEntry reConf(CONFERENCING_KEY, HKEY_CURRENT_USER);
  714. // H.323 gateway settings
  715. HWND hEditGwServer = GetDlgItem( hDlg, IDE_CALLOPT_GW_SERVER );
  716. if( hEditGwServer )
  717. {
  718. SetWindowText( hEditGwServer, reConf.GetString( REGVAL_H323_GATEWAY ) );
  719. SendMessage( hEditGwServer, EM_LIMITTEXT, CCHMAXSZ_SERVER - 1, 0 );
  720. rbOldEnableGateway = reConf.GetNumber( REGVAL_USE_H323_GATEWAY )? true: false;
  721. if( rbOldEnableGateway )
  722. {
  723. CheckDlgButton( hDlg, IDC_CHECK_USE_GATEWAY, BST_CHECKED );
  724. }
  725. else
  726. {
  727. EnableWindow( hEditGwServer, FALSE );
  728. DisableControl( hDlg, IDC_STATIC_GATEWAY_NAME );
  729. }
  730. }
  731. }
  732. // NOTE: This function is shared by the wizard page IDD_WIZPG_GKMODE_SETTINGS
  733. void InitGatekeeperDlgInfo( HWND hDlg, HWND hDlgUserInfo, CULSWizard* pWiz)
  734. {
  735. //////////////////////////////////////////
  736. // Set the gatekeeper data
  737. // First the server name
  738. TCHAR buffer[CCHMAXSZ_SERVER];
  739. ConfPolicies::GetGKServerName( buffer, CCHMAX( buffer ) );
  740. SendDlgItemMessage(hDlg, IDE_CALLOPT_GK_SERVER, WM_SETFONT, (WPARAM) g_hfontDlg, 0);
  741. SendDlgItemMessage(hDlg, IDE_CALLOPT_GK_SERVER, EM_LIMITTEXT, CCHMAXSZ_SERVER-1, 0);
  742. SetDlgItemText(hDlg, IDE_CALLOPT_GK_SERVER, buffer );
  743. ConfPolicies::GetGKAccountName( buffer, CCHMAX( buffer ) );
  744. SendDlgItemMessage(hDlg, IDE_CALLOPT_GK_ACCOUNT, WM_SETFONT, (WPARAM) g_hfontDlg, 0);
  745. SendDlgItemMessage(hDlg, IDE_CALLOPT_GK_ACCOUNT, EM_LIMITTEXT, CCHMAXSZ_SERVER-1, 0);
  746. SetDlgItemText(hDlg, IDE_CALLOPT_GK_ACCOUNT, buffer );
  747. ConfPolicies::eGKAddressingMode addressingMode = ConfPolicies::GetGKAddressingMode();
  748. bool bUsePhoneNumbers = ((addressingMode == ConfPolicies::GKAddressing_PhoneNum) || (addressingMode == ConfPolicies::GKAddressing_Both));
  749. bool bUseAccount = ((addressingMode == ConfPolicies::GKAddressing_Account) || (addressingMode == ConfPolicies::GKAddressing_Both));
  750. RegEntry reULS(ISAPI_CLIENT_KEY, HKEY_CURRENT_USER);
  751. SendDlgItemMessage(hDlg, IDE_CALLOPT_GK_PHONE_NUMBER, WM_SETFONT, (WPARAM) g_hfontDlg, 0);
  752. SendDlgItemMessage(hDlg, IDE_CALLOPT_GK_PHONE_NUMBER, EM_LIMITTEXT, MAX_PHONENUM_LENGTH-1, 0);
  753. SetDlgItemText(hDlg, IDE_CALLOPT_GK_PHONE_NUMBER, reULS.GetString( REGVAL_ULS_PHONENUM_NAME ));
  754. if( bUsePhoneNumbers )
  755. {
  756. CheckDlgButton( hDlg, IDC_CHECK_USE_PHONE_NUMBERS, BST_CHECKED );
  757. }
  758. if( bUseAccount )
  759. {
  760. CheckDlgButton( hDlg, IDC_CHECK_USE_ACCOUNT, BST_CHECKED );
  761. }
  762. EnableWindow( GetDlgItem( hDlg, IDC_STATIC_PHONE_NUMBER ), bUsePhoneNumbers );
  763. EnableWindow( GetDlgItem( hDlg, IDE_CALLOPT_GK_PHONE_NUMBER ), bUsePhoneNumbers );
  764. EnableWindow( GetDlgItem( hDlg, IDS_STATIC_ACCOUNT ), bUseAccount );
  765. EnableWindow( GetDlgItem( hDlg, IDE_CALLOPT_GK_ACCOUNT ), bUseAccount );
  766. }
  767. /* C A L L O P T D L G P R O C */
  768. /*-------------------------------------------------------------------------
  769. %%Function: CallOptDlgProc
  770. -------------------------------------------------------------------------*/
  771. INT_PTR APIENTRY CallOptDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  772. {
  773. static PROPSHEETPAGE * ps;
  774. static bool s_fEnableGk;
  775. static bool s_fEnableGw;
  776. static bool s_fEnableProxy;
  777. static bool s_fCantChangeCallMode;
  778. static bool s_InitialbUsingPhoneNum;
  779. static bool s_InitialbUsingAccount;
  780. static TCHAR s_szOldGatewayNameBuf[MAX_PATH];
  781. static TCHAR s_szOldProxyNameBuf[MAX_PATH];
  782. switch (message)
  783. {
  784. case WM_INITDIALOG:
  785. {
  786. s_fCantChangeCallMode = !ConfPolicies::UserCanChangeCallMode();
  787. InitProxyInfo( hDlg, s_pUlsWizard, s_fEnableProxy, s_szOldProxyNameBuf, CCHMAX( s_szOldProxyNameBuf ) );
  788. InitGWInfo( hDlg, s_pUlsWizard, s_fEnableGw, s_szOldGatewayNameBuf, CCHMAX( s_szOldGatewayNameBuf ) );
  789. InitGatekeeperDlgInfo( hDlg, s_hDlgUserInfo, s_pUlsWizard);
  790. s_InitialbUsingPhoneNum = FIsDlgButtonChecked( hDlg, IDC_CHECK_USE_PHONE_NUMBERS );
  791. s_InitialbUsingAccount = FIsDlgButtonChecked( hDlg, IDC_CHECK_USE_ACCOUNT );
  792. s_fEnableGk = ( ConfPolicies::CallingMode_GateKeeper == ConfPolicies::GetCallingMode() );
  793. ///////////////////////////////////////////
  794. // Set the calling mode
  795. _SetCallingMode( hDlg, ConfPolicies::GetCallingMode() );
  796. return TRUE;
  797. }
  798. break;
  799. case WM_COMMAND:
  800. switch (LOWORD(wParam))
  801. {
  802. case IDC_WARNME:
  803. EnableWindow(GetDlgItem(hDlg, IDC_WARNCOUNT),
  804. FIsDlgButtonChecked(hDlg, IDC_WARNME));
  805. break;
  806. case IDC_CALLOPT_GK_USE:
  807. {
  808. if( FIsDlgButtonChecked( hDlg, IDC_CALLOPT_GK_USE ) )
  809. {
  810. BOOL fUsePhone = FIsDlgButtonChecked( hDlg, IDC_CHECK_USE_PHONE_NUMBERS );
  811. BOOL fUseAccount = FIsDlgButtonChecked( hDlg, IDC_CHECK_USE_ACCOUNT );
  812. #if defined( PROXY_SUPPORTED )
  813. // disable the non-gatekeeper items
  814. EnableWindow( GetDlgItem( hDlg, IDC_CHECK_USE_PROXY ), FALSE );
  815. EnableWindow( GetDlgItem( hDlg, IDC_STATIC_PROXY_NAME ), FALSE );
  816. EnableWindow( GetDlgItem( hDlg, IDE_CALLOPT_PROXY_SERVER ), FALSE );
  817. #endif // defined( PROXY_SUPPORTED )
  818. EnableWindow( GetDlgItem( hDlg, IDC_CHECK_USE_GATEWAY ), FALSE );
  819. EnableWindow( GetDlgItem( hDlg, IDC_STATIC_GATEWAY_NAME ), FALSE );
  820. EnableWindow( GetDlgItem( hDlg, IDE_CALLOPT_GW_SERVER ), FALSE );
  821. // Enable the gatekeeper options
  822. EnableWindow( GetDlgItem( hDlg, IDC_CALLOPT_GK_USE ), !s_fCantChangeCallMode);
  823. EnableWindow( GetDlgItem( hDlg, IDE_CALLOPT_GK_SERVER ), !s_fCantChangeCallMode);
  824. EnableWindow( GetDlgItem( hDlg, IDC_STATIC_GATEKEEPER_NAME ), !s_fCantChangeCallMode);
  825. EnableWindow( GetDlgItem( hDlg, IDC_CHECK_USE_PHONE_NUMBERS ), !s_fCantChangeCallMode);
  826. EnableWindow( GetDlgItem( hDlg, IDC_STATIC_PHONE_NUMBER ), fUsePhone);
  827. EnableWindow( GetDlgItem( hDlg, IDE_CALLOPT_GK_PHONE_NUMBER ), fUsePhone);
  828. EnableWindow( GetDlgItem( hDlg, IDC_CHECK_USE_ACCOUNT ), !s_fCantChangeCallMode );
  829. EnableWindow( GetDlgItem( hDlg, IDS_STATIC_ACCOUNT ), fUseAccount );
  830. EnableWindow( GetDlgItem( hDlg, IDE_CALLOPT_GK_ACCOUNT ), fUseAccount );
  831. if (!s_fCantChangeCallMode)
  832. {
  833. SetFocus( GetDlgItem( hDlg, IDE_CALLOPT_GK_SERVER ) );
  834. SendDlgItemMessage( hDlg, IDE_CALLOPT_GK_SERVER, EM_SETSEL, 0, -1 );
  835. }
  836. else
  837. {
  838. if (fUsePhone)
  839. {
  840. SetFocus( GetDlgItem( hDlg, IDE_CALLOPT_GK_PHONE_NUMBER ) );
  841. SendDlgItemMessage( hDlg, IDE_CALLOPT_GK_PHONE_NUMBER, EM_SETSEL, 0, -1 );
  842. }
  843. else if (fUseAccount)
  844. {
  845. SetFocus( GetDlgItem( hDlg, IDE_CALLOPT_GK_ACCOUNT ) );
  846. SendDlgItemMessage( hDlg, IDE_CALLOPT_GK_ACCOUNT, EM_SETSEL, 0, -1 );
  847. }
  848. }
  849. }
  850. else
  851. {
  852. #if defined( PROXY_SUPPORTED )
  853. // Enable the direct use options
  854. EnableWindow( GetDlgItem( hDlg, IDC_CHECK_USE_PROXY ), TRUE );
  855. EnableWindow( GetDlgItem( hDlg, IDC_STATIC_PROXY_NAME ), FIsDlgButtonChecked( hDlg, IDC_CHECK_USE_PROXY ) );
  856. EnableWindow( GetDlgItem( hDlg, IDE_CALLOPT_PROXY_SERVER ), FIsDlgButtonChecked( hDlg, IDC_CHECK_USE_PROXY ) );
  857. #endif // defined( PROXY_SUPPORTED )
  858. EnableWindow( GetDlgItem( hDlg, IDC_CHECK_USE_GATEWAY ), !s_fCantChangeCallMode );
  859. EnableWindow( GetDlgItem( hDlg, IDC_STATIC_GATEWAY_NAME ), !s_fCantChangeCallMode && FIsDlgButtonChecked( hDlg, IDC_CHECK_USE_GATEWAY ) );
  860. EnableWindow( GetDlgItem( hDlg, IDE_CALLOPT_GW_SERVER ), !s_fCantChangeCallMode && FIsDlgButtonChecked( hDlg, IDC_CHECK_USE_GATEWAY ) );
  861. // Disable the gatekeeper options
  862. EnableWindow( GetDlgItem( hDlg, IDC_CALLOPT_GK_USE ), !s_fCantChangeCallMode);
  863. EnableWindow( GetDlgItem( hDlg, IDE_CALLOPT_GK_SERVER ), FALSE );
  864. EnableWindow( GetDlgItem( hDlg, IDC_STATIC_GATEKEEPER_NAME ), FALSE );
  865. EnableWindow( GetDlgItem( hDlg, IDC_CHECK_USE_PHONE_NUMBERS ), FALSE );
  866. EnableWindow( GetDlgItem( hDlg, IDC_STATIC_PHONE_NUMBER ), FALSE);
  867. EnableWindow( GetDlgItem( hDlg, IDE_CALLOPT_GK_PHONE_NUMBER ), FALSE );
  868. EnableWindow( GetDlgItem( hDlg, IDC_CHECK_USE_ACCOUNT ), FALSE );
  869. EnableWindow( GetDlgItem( hDlg, IDS_STATIC_ACCOUNT ), FALSE);
  870. EnableWindow( GetDlgItem( hDlg, IDE_CALLOPT_GK_ACCOUNT ), FALSE );
  871. }
  872. break;
  873. }
  874. case IDC_CHECK_USE_ACCOUNT:
  875. {
  876. if( FIsDlgButtonChecked( hDlg, IDC_CHECK_USE_ACCOUNT ) )
  877. {
  878. EnableWindow(GetDlgItem( hDlg, IDS_STATIC_ACCOUNT ), TRUE);
  879. EnableWindow(GetDlgItem( hDlg, IDE_CALLOPT_GK_ACCOUNT ), TRUE);
  880. SetFocus( GetDlgItem( hDlg, IDE_CALLOPT_GK_ACCOUNT ) );
  881. SendDlgItemMessage( hDlg, IDE_CALLOPT_GK_ACCOUNT, EM_SETSEL, 0, -1 );
  882. }
  883. else
  884. {
  885. EnableWindow(GetDlgItem( hDlg, IDS_STATIC_ACCOUNT ), FALSE);
  886. EnableWindow(GetDlgItem( hDlg, IDE_CALLOPT_GK_ACCOUNT ), FALSE);
  887. }
  888. break;
  889. }
  890. case IDC_CHECK_USE_PHONE_NUMBERS:
  891. {
  892. if( FIsDlgButtonChecked( hDlg, IDC_CHECK_USE_PHONE_NUMBERS ) )
  893. {
  894. EnableWindow(GetDlgItem( hDlg, IDC_STATIC_PHONE_NUMBER ), TRUE);
  895. EnableWindow(GetDlgItem( hDlg, IDE_CALLOPT_GK_PHONE_NUMBER ), TRUE);
  896. SetFocus( GetDlgItem( hDlg, IDE_CALLOPT_GK_PHONE_NUMBER ) );
  897. SendDlgItemMessage( hDlg, IDE_CALLOPT_GK_PHONE_NUMBER, EM_SETSEL, 0, -1 );
  898. }
  899. else
  900. {
  901. EnableWindow(GetDlgItem( hDlg, IDE_CALLOPT_GK_PHONE_NUMBER ), FALSE);
  902. EnableWindow(GetDlgItem( hDlg, IDC_STATIC_PHONE_NUMBER ), FALSE);
  903. }
  904. break;
  905. }
  906. case IDC_CHECK_USE_PROXY:
  907. {
  908. if( FIsDlgButtonChecked( hDlg, IDC_CHECK_USE_PROXY ) != FALSE )
  909. {
  910. EnableWindow(GetDlgItem( hDlg, IDC_STATIC_PROXY_NAME ), TRUE );
  911. EnableWindow(GetDlgItem( hDlg, IDE_CALLOPT_PROXY_SERVER ), TRUE );
  912. SetFocus( GetDlgItem( hDlg, IDE_CALLOPT_PROXY_SERVER ) );
  913. SendDlgItemMessage( hDlg, IDE_CALLOPT_PROXY_SERVER, EM_SETSEL, 0, -1 );
  914. }
  915. else
  916. {
  917. EnableWindow(GetDlgItem( hDlg, IDC_STATIC_PROXY_NAME ), FALSE );
  918. EnableWindow(GetDlgItem( hDlg, IDE_CALLOPT_PROXY_SERVER ), FALSE );
  919. }
  920. }
  921. break;
  922. case IDC_CHECK_USE_GATEWAY:
  923. {
  924. if( FIsDlgButtonChecked( hDlg, IDC_CHECK_USE_GATEWAY ) != FALSE )
  925. {
  926. EnableWindow(GetDlgItem( hDlg, IDC_STATIC_GATEWAY_NAME ), TRUE );
  927. EnableWindow(GetDlgItem( hDlg, IDE_CALLOPT_GW_SERVER ), TRUE );
  928. SetFocus( GetDlgItem( hDlg, IDE_CALLOPT_GW_SERVER ) );
  929. SendDlgItemMessage( hDlg, IDE_CALLOPT_GW_SERVER, EM_SETSEL, 0, -1 );
  930. }
  931. else
  932. {
  933. EnableWindow(GetDlgItem( hDlg, IDE_CALLOPT_GW_SERVER ), FALSE );
  934. EnableWindow(GetDlgItem( hDlg, IDC_STATIC_GATEWAY_NAME ), FALSE );
  935. }
  936. }
  937. break;
  938. case IDOK:
  939. {
  940. ////////////////////////////////////////////////////////////////////
  941. // First we check to see that we have valid data
  942. int _IdFocus = 0;
  943. // Check to see if we are in gatekeeper mode...
  944. if( FIsDlgButtonChecked( hDlg, IDC_CALLOPT_GK_USE ) )
  945. {
  946. // Verify the gatekeeper settings
  947. TCHAR szServer[CCHMAXSZ_SERVER];
  948. if (!GetDlgItemText(hDlg, IDE_CALLOPT_GK_SERVER, szServer, CCHMAX(szServer)) ||
  949. !IsLegalGateKeeperServerSz(szServer))
  950. {
  951. ConfMsgBox(hDlg, (LPCTSTR)IDS_ILLEGAL_GATEKEEPERSERVER_NAME);
  952. _IdFocus = IDE_CALLOPT_GK_SERVER;
  953. }
  954. if( (!_IdFocus) && (!FIsDlgButtonChecked( hDlg, IDC_CHECK_USE_PHONE_NUMBERS )) &&
  955. (!FIsDlgButtonChecked( hDlg, IDC_CHECK_USE_ACCOUNT )) )
  956. {
  957. // must check either account or phone number...
  958. ConfMsgBox(hDlg, (LPCTSTR)IDS_ILLEGAL_GK_MODE);
  959. _IdFocus = IDC_CHECK_USE_PHONE_NUMBERS;
  960. }
  961. if( (!_IdFocus) && FIsDlgButtonChecked( hDlg, IDC_CHECK_USE_PHONE_NUMBERS ) )
  962. {
  963. // Verify the phone number
  964. TCHAR szPhone[MAX_PHONENUM_LENGTH];
  965. if (!GetDlgItemText(hDlg, IDE_CALLOPT_GK_PHONE_NUMBER, szPhone, CCHMAX(szPhone)) ||
  966. !IsLegalE164Number(szPhone))
  967. {
  968. ConfMsgBox(hDlg, (LPCTSTR)IDS_ILLEGAL_PHONE_NUMBER);
  969. _IdFocus = IDE_CALLOPT_GK_PHONE_NUMBER;
  970. }
  971. }
  972. if( (!_IdFocus) && FIsDlgButtonChecked( hDlg, IDC_CHECK_USE_ACCOUNT ) )
  973. {
  974. // Verify the account
  975. TCHAR account[MAX_PATH];
  976. if (!GetDlgItemText(hDlg, IDE_CALLOPT_GK_ACCOUNT, account, CCHMAX(account)) )
  977. {
  978. ConfMsgBox(hDlg, (LPCTSTR)IDS_ILLEGAL_ACCOUNT);
  979. _IdFocus = IDE_CALLOPT_GK_ACCOUNT;
  980. }
  981. }
  982. }
  983. #if defined( PROXY_SUPPORTED )
  984. // Verify the proxy settings...
  985. if( (!_IdFocus) && FIsDlgButtonChecked( hDlg, IDC_CHECK_USE_PROXY ) && (!FIsDlgButtonChecked( hDlg, IDC_CALLOPT_GK_USE )) )
  986. {
  987. TCHAR szServer[CCHMAXSZ_SERVER];
  988. if (!GetDlgItemText(hDlg, IDE_CALLOPT_PROXY_SERVER, szServer, CCHMAX(szServer)) ||
  989. !IsLegalGatewaySz(szServer))
  990. {
  991. ConfMsgBox(hDlg, (LPCTSTR) IDS_ILLEGAL_PROXY_NAME);
  992. _IdFocus = IDE_CALLOPT_PROXY_SERVER;
  993. }
  994. }
  995. #endif // defined( PROXY_SUPPORTED )
  996. // Verify the gateway settings...
  997. if( (!_IdFocus) && FIsDlgButtonChecked( hDlg, IDC_CHECK_USE_GATEWAY ) && (!FIsDlgButtonChecked( hDlg, IDC_CALLOPT_GK_USE )) )
  998. {
  999. TCHAR szServer[CCHMAXSZ_SERVER];
  1000. if (!GetDlgItemText(hDlg, IDE_CALLOPT_GW_SERVER, szServer, CCHMAX(szServer)) ||
  1001. !IsLegalGatewaySz(szServer))
  1002. {
  1003. ConfMsgBox(hDlg, (LPCTSTR)IDS_ILLEGAL_GATEWAY_NAME);
  1004. _IdFocus = IDE_CALLOPT_GW_SERVER;
  1005. }
  1006. }
  1007. if( _IdFocus )
  1008. {
  1009. SetFocus(GetDlgItem(hDlg, _IdFocus));
  1010. SendDlgItemMessage(hDlg, _IdFocus, EM_SETSEL, (WPARAM) 0, (LPARAM) -1);
  1011. SetWindowLongPtr(hDlg, DWLP_MSGRESULT, TRUE );
  1012. }
  1013. else
  1014. {
  1015. RegEntry reConf(CONFERENCING_KEY, HKEY_CURRENT_USER);
  1016. // Handle the H323 Gateway setting:
  1017. TCHAR buffer[CCHMAXSZ_SERVER];
  1018. GetDlgItemText(hDlg, IDE_CALLOPT_GW_SERVER, buffer, CCHMAX(buffer));
  1019. reConf.SetValue(REGVAL_H323_GATEWAY, buffer);
  1020. g_pCCallto->SetGatewayName( buffer );
  1021. bool fEnable = FIsDlgButtonChecked(hDlg, IDC_CHECK_USE_GATEWAY) ? true : false;
  1022. if (fEnable != s_fEnableGw)
  1023. {
  1024. reConf.SetValue(REGVAL_USE_H323_GATEWAY, fEnable);
  1025. }
  1026. g_pCCallto->SetGatewayEnabled( fEnable );
  1027. #if defined( PROXY_SUPPORTED )
  1028. reConf.SetValue( REGVAL_USE_PROXY, FIsDlgButtonChecked( hDlg, IDC_CHECK_USE_PROXY ) );
  1029. GetDlgItemText( hDlg, IDE_CALLOPT_PROXY_SERVER, buffer, CCHMAX( buffer ) );
  1030. reConf.SetValue( REGVAL_PROXY, buffer );
  1031. #endif // defined( PROXY_SUPPORTED )
  1032. bool relogonRequired = false;
  1033. // Gatekeeper / alias settings
  1034. {
  1035. TCHAR szServer[CCHMAXSZ_SERVER];
  1036. GetDlgItemTextTrimmed(hDlg, IDE_CALLOPT_GK_SERVER, szServer, CCHMAX(szServer));
  1037. if (0 != lstrcmp(szServer, reConf.GetString(REGVAL_GK_SERVER)))
  1038. {
  1039. reConf.SetValue(REGVAL_GK_SERVER, szServer);
  1040. relogonRequired = true;
  1041. }
  1042. fEnable = FIsDlgButtonChecked(hDlg, IDC_CALLOPT_GK_USE) ? true : false;
  1043. if( fEnable != s_fEnableGk )
  1044. {
  1045. // Set the calling mode
  1046. reConf.SetValue(REGVAL_CALLING_MODE, fEnable ? CALLING_MODE_GATEKEEPER : CALLING_MODE_DIRECT );
  1047. relogonRequired = true;
  1048. }
  1049. bool bUsingPhoneNum = FIsDlgButtonChecked( hDlg, IDC_CHECK_USE_PHONE_NUMBERS );
  1050. bool bUsingAccount = FIsDlgButtonChecked( hDlg, IDC_CHECK_USE_ACCOUNT );
  1051. ConfPolicies::eGKAddressingMode addressingMode;
  1052. if( bUsingPhoneNum && bUsingAccount )
  1053. {
  1054. addressingMode = ConfPolicies::GKAddressing_Both;
  1055. }
  1056. else if( bUsingPhoneNum )
  1057. {
  1058. addressingMode = ConfPolicies::GKAddressing_PhoneNum;
  1059. }
  1060. else if( bUsingAccount )
  1061. {
  1062. addressingMode = ConfPolicies::GKAddressing_Account;
  1063. }
  1064. else
  1065. {
  1066. addressingMode = ConfPolicies::GKAddressing_Invalid;
  1067. }
  1068. if( (s_InitialbUsingPhoneNum != bUsingPhoneNum) ||
  1069. (s_InitialbUsingAccount != bUsingAccount) )
  1070. {
  1071. // Set the calling mode
  1072. reConf.SetValue(REGVAL_GK_METHOD, addressingMode );
  1073. relogonRequired = true;
  1074. }
  1075. RegEntry reULS(ISAPI_CLIENT_KEY, HKEY_CURRENT_USER);
  1076. GetDlgItemTextTrimmed( hDlg, IDE_CALLOPT_GK_PHONE_NUMBER, buffer, CCHMAX( buffer ) );
  1077. if( lstrcmp( buffer, reULS.GetString( REGVAL_ULS_PHONENUM_NAME ) ) != 0 )
  1078. {
  1079. reULS.SetValue( REGVAL_ULS_PHONENUM_NAME, buffer );
  1080. relogonRequired = true;
  1081. }
  1082. GetDlgItemTextTrimmed( hDlg, IDE_CALLOPT_GK_ACCOUNT, buffer, CCHMAX( buffer ) );
  1083. if( lstrcmp( buffer, reULS.GetString( REGVAL_ULS_GK_ACCOUNT ) ) != 0 )
  1084. {
  1085. reULS.SetValue( REGVAL_ULS_GK_ACCOUNT, buffer );
  1086. relogonRequired = true;
  1087. }
  1088. }
  1089. if( relogonRequired )
  1090. {
  1091. // This means that we need to log on to the gatekeeper with this new changed info...
  1092. reConf.FlushKey();
  1093. if( fEnable )
  1094. {
  1095. if( s_fEnableGk )
  1096. {
  1097. // We are already logged on to the gatekeeper so we must log off first...
  1098. GkLogoff();
  1099. }
  1100. GkLogon();
  1101. }
  1102. else
  1103. {
  1104. // We are now in direct mode, we should log off the GateKeeper....
  1105. GkLogoff();
  1106. SetGkLogonState( NM_GK_NOT_IN_GK_MODE );
  1107. }
  1108. // Update the status Bar...
  1109. CConfStatusBar* pStatusBar = CConfStatusBar::GetInstance();
  1110. if( pStatusBar )
  1111. {
  1112. pStatusBar->Update();
  1113. }
  1114. }
  1115. EndDialog( hDlg, IDOK );
  1116. }
  1117. }
  1118. break;
  1119. case IDCANCEL:
  1120. {
  1121. EndDialog( hDlg, IDCANCEL );
  1122. }
  1123. break;
  1124. default:
  1125. break;
  1126. }
  1127. break;
  1128. case WM_CONTEXTMENU:
  1129. DoHelpWhatsThis(wParam, _rgHelpIdsCalling);
  1130. break;
  1131. case WM_HELP:
  1132. DoHelp(lParam, _rgHelpIdsCalling);
  1133. break;
  1134. case WM_DESTROY:
  1135. s_hDlgUserInfo = NULL;
  1136. break;
  1137. default:
  1138. break;
  1139. }
  1140. return FALSE;
  1141. }
  1142.