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.

1397 lines
42 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 ) {
  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. // Ask the user if they want to logon
  260. int iRet = ::MessageBox(hDlg,
  261. RES2T(IDS_ULS_CHANGED_PROMPT),
  262. RES2T(IDS_MSGBOX_TITLE),
  263. MB_SETFOREGROUND | MB_YESNO | MB_ICONQUESTION);
  264. if(IDNO == iRet)
  265. {
  266. bLogonToILSServer = FALSE;
  267. }
  268. }
  269. if(bLogonToILSServer)
  270. {
  271. if(NULL == g_pLDAP)
  272. {
  273. InitNmLdapAndLogon();
  274. }
  275. else
  276. {
  277. g_pLDAP->LogonAsync();
  278. }
  279. }
  280. }
  281. }
  282. }
  283. return S_OK;
  284. }
  285. /* _ I N I T U S E R D L G P R O C */
  286. /*-------------------------------------------------------------------------
  287. %%Function: _InitUserDlgProc
  288. Initialize the conferencing name fields
  289. -------------------------------------------------------------------------*/
  290. static void _InitUserDlgProc(HWND hdlg, PROPSHEETPAGE * ps, LPTSTR szOldServerNameBuf, UINT cch )
  291. {
  292. RegEntry reCU( CONFERENCING_KEY, HKEY_CURRENT_USER);
  293. s_fOldAlwaysRunning = (0 != reCU.GetNumber(
  294. REGVAL_CONF_ALWAYS_RUNNING, ALWAYS_RUNNING_DEFAULT ));
  295. CheckDlgButton( hdlg, IDC_ALWAYS_RUNNING, s_fOldAlwaysRunning ? BST_CHECKED : BST_UNCHECKED );
  296. #ifndef TASKBARBKGNDONLY
  297. ///////////////////////////////////////////////////////////
  298. //
  299. // Taskbar Icon Settings
  300. //
  301. // Initialize the icon-on-taskbar settings
  302. // Check the right button for taskbar icon use
  303. s_fOldTaskbarSetting = reCU.GetNumber(
  304. REGVAL_TASKBAR_ICON, TASKBARICON_DEFAULT )
  305. == TASKBARICON_ALWAYS;
  306. SendDlgItemMessage ( hdlg, IDC_SHOWONTASKBAR,
  307. BM_SETCHECK,
  308. s_fOldTaskbarSetting ? BST_CHECKED : BST_UNCHECKED,
  309. 0L );
  310. #endif // ! TASKBARBKGNDONLY
  311. #if USE_GAL
  312. if( ConfPolicies::IsGetMyInfoFromGALEnabled() && ConfPolicies::GetMyInfoFromGALSucceeded())
  313. {
  314. EnableWindow( GetDlgItem( hdlg, IDC_USER_NAME), FALSE );
  315. EnableWindow( GetDlgItem( hdlg, IDC_USER_LASTNAME), FALSE );
  316. EnableWindow( GetDlgItem( hdlg, IDC_USER_EMAIL), FALSE );
  317. EnableWindow( GetDlgItem( hdlg, IDC_USER_LOCATION), FALSE );
  318. EnableWindow( GetDlgItem( hdlg, IDC_USER_INTERESTS), FALSE );
  319. TCHAR szBuffer[ MAX_PATH ];
  320. FLoadString( IDS_MYINFO_CAPTION_DISABLED, szBuffer, CCHMAX( szBuffer ) );
  321. SetWindowText( GetDlgItem( hdlg, IDC_STATIC_MYINFO ), szBuffer );
  322. }
  323. else
  324. {
  325. TCHAR szBuffer[ MAX_PATH ];
  326. FLoadString( IDS_MYINFO_CAPTION_ENABLED, szBuffer, CCHMAX( szBuffer ) );
  327. SetWindowText( GetDlgItem( hdlg, IDC_STATIC_MYINFO ), szBuffer );
  328. }
  329. #endif // USE_GAL
  330. if( ConfPolicies::GetCallingMode() == ConfPolicies::CallingMode_GateKeeper)
  331. {
  332. // Disable the ILS-related stuff
  333. EnableWindow( GetDlgItem( hdlg, IDC_NAMESERVER), FALSE );
  334. EnableWindow( GetDlgItem( hdlg, IDC_USER_PUBLISH), FALSE );
  335. EnableWindow( GetDlgItem( hdlg, IDC_USEULS), FALSE );
  336. EnableWindow( GetDlgItem( hdlg, IDC_STATIC_SERVER_NAME), FALSE );
  337. }
  338. EnableWindow( GetDlgItem( hdlg, IDC_ADVANCED_CALL_OPTS),
  339. ConfPolicies::IsAdvancedCallingAllowed());
  340. // Set the font
  341. SendDlgItemMessage(hdlg, IDC_USER_NAME, WM_SETFONT, (WPARAM) g_hfontDlg, 0);
  342. SendDlgItemMessage(hdlg, IDC_USER_LASTNAME, WM_SETFONT, (WPARAM) g_hfontDlg, 0);
  343. SendDlgItemMessage(hdlg, IDC_USER_LOCATION, WM_SETFONT, (WPARAM) g_hfontDlg, 0);
  344. SendDlgItemMessage(hdlg, IDC_USER_INTERESTS, WM_SETFONT, (WPARAM) g_hfontDlg, 0);
  345. // Limit the edit control
  346. SendDlgItemMessage(hdlg, IDC_USER_NAME, EM_LIMITTEXT, MAX_FIRST_NAME_LENGTH-1, 0);
  347. SendDlgItemMessage(hdlg, IDC_USER_LASTNAME, EM_LIMITTEXT, MAX_LAST_NAME_LENGTH-1, 0);
  348. SendDlgItemMessage(hdlg, IDC_USER_EMAIL, EM_LIMITTEXT, MAX_EMAIL_NAME_LENGTH-1, 0);
  349. SendDlgItemMessage(hdlg, IDC_USER_LOCATION, EM_LIMITTEXT, MAX_LOCATION_NAME_LENGTH-1, 0);
  350. SendDlgItemMessage(hdlg, IDC_USER_INTERESTS,EM_LIMITTEXT, UI_COMMENTS_LENGTH-1, 0);
  351. InitULSDll();
  352. RegEntry reConf(CONFERENCING_KEY, HKEY_CURRENT_USER);
  353. // Init the server combobox... can we skip this stuff if we are not using ILS????
  354. FixServerDropList(hdlg, IDC_NAMESERVER, szOldServerNameBuf, cch );
  355. InitULSControls(hdlg, s_pUlsWizard,
  356. IDC_NAMESERVER,
  357. IDC_USER_NAME, IDC_USER_LASTNAME, IDC_USER_EMAIL,
  358. IDC_USER_LOCATION, IDC_USER_INTERESTS,
  359. IDC_USER_PUBLISH);
  360. // First the log onto directory servers stuff...
  361. s_fOldUseUlsServer = ConfPolicies::LogOntoIlsWhenNetMeetingStartsIfInDirectCallingMode();
  362. _SetLogOntoIlsButton( hdlg, s_fOldUseUlsServer);
  363. if (!SysPol::AllowDirectoryServices())
  364. {
  365. // Disable all items in this group
  366. DisableControl(hdlg, IDC_USEULS);
  367. DisableControl(hdlg, IDC_NAMESERVER);
  368. DisableControl(hdlg, IDC_USER_PUBLISH);
  369. DisableControl(hdlg, IDC_STATIC_SERVER_NAME);
  370. }
  371. s_hDlgUserInfo = hdlg;
  372. }
  373. static void General_OnCommand(HWND hDlg, int id, HWND hwndCtl, UINT codeNotify, UINT *puBandwidth)
  374. {
  375. INT_PTR CALLBACK BandwidthDlg( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
  376. switch(id)
  377. {
  378. case IDC_ADVANCED_CALL_OPTS:
  379. {
  380. DialogBox( GetInstanceHandle(), MAKEINTRESOURCE( IDD_CALLOPT ), hDlg, CallOptDlgProc );
  381. BOOL bEnable = (ConfPolicies::GetCallingMode() == ConfPolicies::CallingMode_Direct);
  382. // Disable/Enable the ILS-related stuff
  383. EnableWindow( GetDlgItem( hDlg, IDC_NAMESERVER), bEnable );
  384. EnableWindow( GetDlgItem( hDlg, IDC_USER_PUBLISH), bEnable );
  385. EnableWindow( GetDlgItem( hDlg, IDC_USEULS), bEnable );
  386. EnableWindow( GetDlgItem( hDlg, IDC_STATIC_SERVER_NAME), bEnable );
  387. // We are now in Gatekeeper mode, we should log off the ILS server
  388. if(!bEnable && g_pLDAP && g_pLDAP->IsLoggedOn())
  389. {
  390. g_pLDAP->Logoff();
  391. }
  392. break;
  393. }
  394. case IDC_BANDWIDTH:
  395. int nRet;
  396. nRet = (int)DialogBoxParam(_Module.GetModuleInstance(), MAKEINTRESOURCE(IDD_BANDWIDTH), hDlg, BandwidthDlg, *puBandwidth);
  397. if (nRet != 0)
  398. {
  399. *puBandwidth = nRet;
  400. }
  401. break;
  402. case IDC_ALWAYS_RUNNING:
  403. if (FIsDlgButtonChecked( hDlg, IDC_ALWAYS_RUNNING ))
  404. {
  405. VOID EnableRDS(BOOL fEnabledRDS);
  406. RegEntry reLM( REMOTECONTROL_KEY, HKEY_LOCAL_MACHINE);
  407. BOOL bRDSRunning = reLM.GetNumber(REMOTE_REG_RUNSERVICE, DEFAULT_REMOTE_RUNSERVICE);
  408. if (bRDSRunning)
  409. {
  410. TCHAR szMsg[2*RES_CH_MAX];
  411. if (IDYES != MessageBox(hDlg,
  412. Res2THelper(IDS_RDSWARNING, szMsg, ARRAY_ELEMENTS(szMsg)), RES2T(IDS_MSGBOX_TITLE),
  413. MB_YESNO|MB_ICONHAND))
  414. {
  415. CheckDlgButton(hDlg, IDC_ALWAYS_RUNNING, BST_UNCHECKED);
  416. break;
  417. }
  418. EnableRDS(FALSE);
  419. }
  420. }
  421. break;
  422. default:
  423. break;
  424. }
  425. }
  426. /* U S E R D L G P R O C */
  427. /*-------------------------------------------------------------------------
  428. %%Function: UserDlgProc
  429. -------------------------------------------------------------------------*/
  430. INT_PTR APIENTRY UserDlgProc( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  431. {
  432. static PROPSHEETPAGE * ps;
  433. static TCHAR s_szOldServerNameBuf[MAX_PATH];
  434. static UINT uOldBandwidth=0;
  435. static UINT uNewBandwidth=0;
  436. switch (message)
  437. {
  438. case WM_INITDIALOG:
  439. {
  440. // Save the PROPSHEETPAGE information.
  441. ps = (PROPSHEETPAGE *)lParam;
  442. _InitUserDlgProc(hDlg, ps, s_szOldServerNameBuf, CCHMAX(s_szOldServerNameBuf) );
  443. uNewBandwidth = uOldBandwidth = GetBandwidth();
  444. return TRUE;
  445. }
  446. case WM_COMMAND:
  447. General_OnCommand(hDlg, LOWORD(wParam), (HWND)lParam, HIWORD(wParam), &uNewBandwidth);
  448. break;
  449. case WM_NOTIFY:
  450. switch (((NMHDR FAR *) lParam)->code) {
  451. case PSN_KILLACTIVE:
  452. {
  453. int _IdFocus = 0;
  454. TCHAR szName[MAX_FIRST_NAME_LENGTH];
  455. TCHAR szLastName[MAX_LAST_NAME_LENGTH];
  456. TCHAR szEMail[MAX_EMAIL_NAME_LENGTH];
  457. // Check for no data in user name
  458. if (0 == GetDlgItemTextTrimmed(hDlg, IDC_USER_NAME, szName, CCHMAX(szName) ))
  459. {
  460. ConfMsgBox(hDlg, (LPCTSTR)IDS_NEEDUSERNAME);
  461. _IdFocus = IDC_USER_NAME;
  462. }
  463. // Check for no data in user name
  464. else if( 0 == GetDlgItemTextTrimmed(hDlg, IDC_USER_LASTNAME, szLastName, CCHMAX(szLastName)))
  465. {
  466. ConfMsgBox(hDlg, (LPCTSTR)IDS_NEEDUSERNAME);
  467. _IdFocus = IDC_USER_LASTNAME;
  468. }
  469. else if( (!GetDlgItemText(hDlg, IDC_USER_EMAIL, szEMail, CCHMAX(szEMail)) || !FLegalEmailSz(szEMail)))
  470. {
  471. ConfMsgBox(hDlg, (LPCTSTR)IDS_ILLEGALEMAILNAME);
  472. _IdFocus = IDC_USER_EMAIL;
  473. }
  474. TCHAR szServerNameBuf[ MAX_PATH ];
  475. if( (!_IdFocus) &&
  476. FIsDlgButtonChecked( hDlg, IDC_USEULS ) &&
  477. (GetDlgItemTextTrimmed( hDlg, IDC_NAMESERVER, szServerNameBuf, CCHMAX( szServerNameBuf ) ) == 0) )
  478. {
  479. // They specified logon to ILS at startup but didn't specify an ILS...
  480. ConfMsgBox( hDlg, (LPCTSTR) IDS_NO_ILS_SERVER );
  481. _IdFocus = IDC_NAMESERVER;
  482. }
  483. if( _IdFocus )
  484. {
  485. SetFocus(GetDlgItem(hDlg, _IdFocus));
  486. SendDlgItemMessage(hDlg, _IdFocus, EM_SETSEL, (WPARAM) 0, (LPARAM) -1);
  487. SetWindowLongPtr(hDlg, DWLP_MSGRESULT, TRUE );
  488. return TRUE;
  489. }
  490. }
  491. break;
  492. case PSN_APPLY:
  493. {
  494. RegEntry reConf( CONFERENCING_KEY, HKEY_CURRENT_USER );
  495. bool fAlwaysRunning;
  496. fAlwaysRunning = FIsDlgButtonChecked( hDlg, IDC_ALWAYS_RUNNING );
  497. // if ( fAlwaysRunning != s_fOldAlwaysRunning )
  498. {
  499. reConf.SetValue(REGVAL_CONF_ALWAYS_RUNNING, fAlwaysRunning);
  500. RegEntry reRun(WINDOWS_RUN_KEY, HKEY_CURRENT_USER);
  501. if (fAlwaysRunning)
  502. {
  503. TCHAR szRunTask[MAX_PATH*2];
  504. TCHAR szInstallDir[MAX_PATH];
  505. if (GetInstallDirectory(szInstallDir))
  506. {
  507. RegEntry reConfLM(CONFERENCING_KEY, HKEY_LOCAL_MACHINE);
  508. wsprintf(szRunTask, _TEXT("\"%s%s\" -%s"),
  509. szInstallDir,
  510. reConfLM.GetString(REGVAL_NC_NAME),
  511. g_cszBackgroundSwitch);
  512. reRun.SetValue(REGVAL_RUN_TASKNAME, szRunTask);
  513. }
  514. }
  515. else
  516. {
  517. reRun.DeleteValue(REGVAL_RUN_TASKNAME);
  518. }
  519. }
  520. #ifndef TASKBARBKGNDONLY
  521. ///////////////////////////////////////////////////////////
  522. //
  523. // Taskbar Icon Settings
  524. //
  525. // Save taskbar icon state
  526. bool fTaskbarSetting;
  527. fTaskbarSetting = FIsDlgButtonChecked( hDlg,
  528. IDC_SHOWONTASKBAR );
  529. if ( fTaskbarSetting != s_fOldTaskbarSetting )
  530. {
  531. reConf.SetValue( REGVAL_TASKBAR_ICON,
  532. fTaskbarSetting? TASKBARICON_ALWAYS :
  533. TASKBARICON_NEVER );
  534. g_dwChangedSettings |= CSETTING_L_SHOWTASKBAR;
  535. }
  536. #endif // ! TASKBARBKGNDONLY
  537. // Process "use uls server" setting...
  538. bool fUseUlsServer = FIsDlgButtonChecked( hDlg, IDC_USEULS ) ? true : false;
  539. if( fUseUlsServer != s_fOldUseUlsServer )
  540. {
  541. reConf.SetValue( REGVAL_DONT_LOGON_ULS, !fUseUlsServer );
  542. g_dwChangedSettings |= CSETTING_L_USEULSSERVER;
  543. }
  544. TCHAR szServerNameBuf[MAX_PATH];
  545. GetDlgItemTextTrimmed( hDlg, IDC_NAMESERVER, szServerNameBuf, CCHMAX( szServerNameBuf ) );
  546. if( lstrcmpi( szServerNameBuf, s_szOldServerNameBuf ) != 0 )
  547. {
  548. g_dwChangedSettings |= CSETTING_L_ULSSETTINGS;
  549. }
  550. ///////////////////////////////////////////////////////////
  551. //
  552. // Conferencing Name Settings
  553. //
  554. // Just clean the rest
  555. TrimDlgItemText(hDlg, IDC_USER_LOCATION);
  556. TrimDlgItemText(hDlg, IDC_USER_INTERESTS);
  557. BOOL bServerNameChanged = g_dwChangedSettings & CSETTING_L_USEULSSERVER;
  558. HRESULT hRes = SaveULSControls( hDlg,
  559. ((g_dwChangedSettings & CSETTING_L_ULSSETTINGS) != 0)? IDC_NAMESERVER: 0,
  560. IDC_USER_NAME,
  561. IDC_USER_LASTNAME,
  562. IDC_USER_EMAIL,
  563. IDC_USER_LOCATION,
  564. IDC_USER_INTERESTS,
  565. IDC_USER_PUBLISH,
  566. bServerNameChanged);
  567. if( (g_dwChangedSettings & CSETTING_L_ULSSETTINGS) != 0 )
  568. {
  569. g_pCCallto->SetIlsServerName( CDirectoryManager::get_dnsName( szServerNameBuf ) );
  570. }
  571. ASSERT(S_OK == hRes);
  572. if (uNewBandwidth != uOldBandwidth)
  573. {
  574. g_dwChangedSettings |= CSETTING_L_BANDWIDTH;
  575. SetBandwidth(uNewBandwidth);
  576. UpdateCodecSettings(uNewBandwidth);
  577. }
  578. break;
  579. }
  580. case PSN_RESET:
  581. break;
  582. }
  583. break;
  584. case WM_CONTEXTMENU:
  585. DoHelpWhatsThis(wParam, aUserHelpIds);
  586. break;
  587. case WM_HELP:
  588. DoHelp(lParam, aUserHelpIds);
  589. break;
  590. case WM_DESTROY:
  591. {
  592. DeInitULSDll();
  593. break;
  594. }
  595. }
  596. return (FALSE);
  597. }
  598. VOID FixServerDropList(HWND hdlg, int id, LPTSTR pszServer, UINT cchMax)
  599. {
  600. HWND hwndCtrl = GetDlgItem(hdlg, id);
  601. ASSERT(NULL != hwndCtrl);
  602. BOOL fComboBox = SysPol::AllowAddingServers();
  603. if (fComboBox)
  604. {
  605. // Limit the text in the edit control
  606. ComboBox_LimitText(GetDlgItem(hdlg, id), MAX_SERVER_NAME_LENGTH - 1);
  607. }
  608. else
  609. {
  610. // System policy does not allow adding new servers
  611. // Replace the combo list with a simple drop list
  612. RECT rc;
  613. GetWindowRect(hwndCtrl, &rc);
  614. LONG xpTop = rc.top;
  615. ComboBox_GetDroppedControlRect(hwndCtrl, &rc);
  616. rc.top = xpTop;
  617. ::MapWindowPoints(NULL, hdlg, (LPPOINT) &rc, 2);
  618. DWORD dwStyle = GetWindowLong(hwndCtrl, GWL_STYLE);
  619. DWORD dwStyleEx = GetWindowLong(hwndCtrl, GWL_EXSTYLE);
  620. INT_PTR id = GetWindowLong(hwndCtrl, GWL_ID);
  621. HFONT hFont = (HFONT) ::SendMessage(hwndCtrl, WM_GETFONT, 0, 0);
  622. HWND hwndPrev = ::GetNextWindow(hwndCtrl, GW_HWNDPREV);
  623. DestroyWindow(hwndCtrl);
  624. dwStyle = CBS_DROPDOWNLIST | (dwStyle & ~CBS_DROPDOWN);
  625. hwndCtrl = ::CreateWindowEx(dwStyleEx, TEXT("COMBOBOX"), g_szEmpty, dwStyle,
  626. rc.left, rc.top, RectWidth(rc), RectHeight(rc),
  627. hdlg, (HMENU) id, ::GetInstanceHandle(), 0);
  628. ::SendMessage(hwndCtrl, WM_SETFONT, (WPARAM) hFont, 0);
  629. // Maintain the tab order
  630. ::SetWindowPos(hwndCtrl, hwndPrev, 0, 0, 0, 0,
  631. SWP_NOMOVE | SWP_NOSIZE | SWP_NOOWNERZORDER | SWP_NOREDRAW);
  632. }
  633. FillServerComboBox(hwndCtrl);
  634. // Find the item in the list
  635. int index = (int)::SendMessage( hwndCtrl, CB_FINDSTRINGEXACT, -1, (LPARAM) CDirectoryManager::get_displayName( pszServer ) );
  636. ComboBox_SetCurSel( hwndCtrl, (index == CB_ERR)? 0: index );
  637. }
  638. static void _SetCallingMode( HWND hDlg, ConfPolicies::eCallingMode eMode )
  639. {
  640. switch( eMode )
  641. {
  642. case ConfPolicies::CallingMode_Direct:
  643. CheckDlgButton( hDlg, IDC_CALLOPT_GK_USE, BST_UNCHECKED );
  644. SendMessage( hDlg, WM_COMMAND, MAKEWPARAM(IDC_CALLOPT_GK_USE,0 ), 0 );
  645. break;
  646. case ConfPolicies::CallingMode_GateKeeper:
  647. CheckDlgButton( hDlg, IDC_CALLOPT_GK_USE, BST_CHECKED );
  648. SendMessage( hDlg, WM_COMMAND, MAKEWPARAM(IDC_CALLOPT_GK_USE,0 ), 0 );
  649. break;
  650. default:
  651. ERROR_OUT(("Invalid return val"));
  652. break;
  653. }
  654. }
  655. static void _SetLogOntoIlsButton( HWND hDlg, bool bLogOntoIlsWhenNmStarts )
  656. {
  657. if( bLogOntoIlsWhenNmStarts )
  658. {
  659. CheckDlgButton( hDlg, IDC_USEULS, bLogOntoIlsWhenNmStarts ? BST_CHECKED : BST_UNCHECKED );
  660. SendMessage( hDlg, WM_COMMAND, MAKEWPARAM(IDC_USEULS, 0 ), 0 );
  661. }
  662. }
  663. // NOTE: This function is shared by the wizard page IDD_PAGE_SERVER
  664. void InitDirectoryServicesDlgInfo( HWND hDlg, CULSWizard* pWiz, bool& rbOldEnableGateway, LPTSTR szOldServerNameBuf, UINT cch )
  665. {
  666. RegEntry reConf(CONFERENCING_KEY, HKEY_CURRENT_USER);
  667. // Init the server combobox... can we skip this stuff if we are not using ILS????
  668. FixServerDropList(hDlg, IDC_NAMESERVER, szOldServerNameBuf, cch );
  669. InitULSControls(hDlg, pWiz,
  670. IDC_NAMESERVER,
  671. 0, 0, 0,
  672. 0, 0,
  673. IDC_USER_PUBLISH);
  674. // First the log onto directory servers stuff...
  675. s_fOldUseUlsServer = ConfPolicies::LogOntoIlsWhenNetMeetingStartsIfInDirectCallingMode();
  676. _SetLogOntoIlsButton( hDlg, s_fOldUseUlsServer);
  677. if (!SysPol::AllowDirectoryServices())
  678. {
  679. // Disable all items in this group
  680. DisableControl(hDlg, IDC_USEULS);
  681. DisableControl(hDlg, IDC_NAMESERVER);
  682. DisableControl(hDlg, IDC_USER_PUBLISH);
  683. }
  684. }
  685. void InitProxyInfo( HWND hDlg, CULSWizard* pWiz, bool& rbOldEnableProxy, LPTSTR szOldProxyNameBuf, UINT cch )
  686. {
  687. RegEntry reConf(CONFERENCING_KEY, HKEY_CURRENT_USER);
  688. // proxy settings...
  689. HWND hEditProxyServer = GetDlgItem( hDlg, IDE_CALLOPT_PROXY_SERVER );
  690. if( hEditProxyServer )
  691. {
  692. SetWindowText( hEditProxyServer, reConf.GetString( REGVAL_PROXY ) );
  693. SendMessage( hEditProxyServer, EM_LIMITTEXT, CCHMAXSZ_SERVER - 1, 0 );
  694. rbOldEnableProxy = reConf.GetNumber( REGVAL_USE_PROXY )? true: false;
  695. if( rbOldEnableProxy )
  696. {
  697. CheckDlgButton( hDlg, IDC_CHECK_USE_PROXY, BST_CHECKED );
  698. }
  699. else
  700. {
  701. EnableWindow( hEditProxyServer, FALSE );
  702. DisableControl( hDlg, IDC_STATIC_PROXY_NAME );
  703. }
  704. }
  705. }
  706. void InitGWInfo( HWND hDlg, CULSWizard* pWiz, bool& rbOldEnableGateway, LPTSTR szOldServerNameBuf, UINT cch )
  707. {
  708. RegEntry reConf(CONFERENCING_KEY, HKEY_CURRENT_USER);
  709. // H.323 gateway settings
  710. HWND hEditGwServer = GetDlgItem( hDlg, IDE_CALLOPT_GW_SERVER );
  711. if( hEditGwServer )
  712. {
  713. SetWindowText( hEditGwServer, reConf.GetString( REGVAL_H323_GATEWAY ) );
  714. SendMessage( hEditGwServer, EM_LIMITTEXT, CCHMAXSZ_SERVER - 1, 0 );
  715. rbOldEnableGateway = reConf.GetNumber( REGVAL_USE_H323_GATEWAY )? true: false;
  716. if( rbOldEnableGateway )
  717. {
  718. CheckDlgButton( hDlg, IDC_CHECK_USE_GATEWAY, BST_CHECKED );
  719. }
  720. else
  721. {
  722. EnableWindow( hEditGwServer, FALSE );
  723. DisableControl( hDlg, IDC_STATIC_GATEWAY_NAME );
  724. }
  725. }
  726. }
  727. // NOTE: This function is shared by the wizard page IDD_WIZPG_GKMODE_SETTINGS
  728. void InitGatekeeperDlgInfo( HWND hDlg, HWND hDlgUserInfo, CULSWizard* pWiz)
  729. {
  730. //////////////////////////////////////////
  731. // Set the gatekeeper data
  732. // First the server name
  733. TCHAR buffer[CCHMAXSZ_SERVER];
  734. ConfPolicies::GetGKServerName( buffer, CCHMAX( buffer ) );
  735. SendDlgItemMessage(hDlg, IDE_CALLOPT_GK_SERVER, WM_SETFONT, (WPARAM) g_hfontDlg, 0);
  736. SendDlgItemMessage(hDlg, IDE_CALLOPT_GK_SERVER, EM_LIMITTEXT, CCHMAXSZ_SERVER-1, 0);
  737. SetDlgItemText(hDlg, IDE_CALLOPT_GK_SERVER, buffer );
  738. ConfPolicies::GetGKAccountName( buffer, CCHMAX( buffer ) );
  739. SendDlgItemMessage(hDlg, IDE_CALLOPT_GK_ACCOUNT, WM_SETFONT, (WPARAM) g_hfontDlg, 0);
  740. SendDlgItemMessage(hDlg, IDE_CALLOPT_GK_ACCOUNT, EM_LIMITTEXT, CCHMAXSZ_SERVER-1, 0);
  741. SetDlgItemText(hDlg, IDE_CALLOPT_GK_ACCOUNT, buffer );
  742. ConfPolicies::eGKAddressingMode addressingMode = ConfPolicies::GetGKAddressingMode();
  743. bool bUsePhoneNumbers = ((addressingMode == ConfPolicies::GKAddressing_PhoneNum) || (addressingMode == ConfPolicies::GKAddressing_Both));
  744. bool bUseAccount = ((addressingMode == ConfPolicies::GKAddressing_Account) || (addressingMode == ConfPolicies::GKAddressing_Both));
  745. RegEntry reULS(ISAPI_CLIENT_KEY, HKEY_CURRENT_USER);
  746. SendDlgItemMessage(hDlg, IDE_CALLOPT_GK_PHONE_NUMBER, WM_SETFONT, (WPARAM) g_hfontDlg, 0);
  747. SendDlgItemMessage(hDlg, IDE_CALLOPT_GK_PHONE_NUMBER, EM_LIMITTEXT, MAX_PHONENUM_LENGTH-1, 0);
  748. SetDlgItemText(hDlg, IDE_CALLOPT_GK_PHONE_NUMBER, reULS.GetString( REGVAL_ULS_PHONENUM_NAME ));
  749. if( bUsePhoneNumbers )
  750. {
  751. CheckDlgButton( hDlg, IDC_CHECK_USE_PHONE_NUMBERS, BST_CHECKED );
  752. }
  753. if( bUseAccount )
  754. {
  755. CheckDlgButton( hDlg, IDC_CHECK_USE_ACCOUNT, BST_CHECKED );
  756. }
  757. EnableWindow( GetDlgItem( hDlg, IDC_STATIC_PHONE_NUMBER ), bUsePhoneNumbers );
  758. EnableWindow( GetDlgItem( hDlg, IDE_CALLOPT_GK_PHONE_NUMBER ), bUsePhoneNumbers );
  759. EnableWindow( GetDlgItem( hDlg, IDS_STATIC_ACCOUNT ), bUseAccount );
  760. EnableWindow( GetDlgItem( hDlg, IDE_CALLOPT_GK_ACCOUNT ), bUseAccount );
  761. }
  762. /* C A L L O P T D L G P R O C */
  763. /*-------------------------------------------------------------------------
  764. %%Function: CallOptDlgProc
  765. -------------------------------------------------------------------------*/
  766. INT_PTR APIENTRY CallOptDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  767. {
  768. static PROPSHEETPAGE * ps;
  769. static bool s_fEnableGk;
  770. static bool s_fEnableGw;
  771. static bool s_fEnableProxy;
  772. static bool s_fCantChangeCallMode;
  773. static bool s_InitialbUsingPhoneNum;
  774. static bool s_InitialbUsingAccount;
  775. static TCHAR s_szOldGatewayNameBuf[MAX_PATH];
  776. static TCHAR s_szOldProxyNameBuf[MAX_PATH];
  777. switch (message)
  778. {
  779. case WM_INITDIALOG:
  780. {
  781. s_fCantChangeCallMode = !ConfPolicies::UserCanChangeCallMode();
  782. InitProxyInfo( hDlg, s_pUlsWizard, s_fEnableProxy, s_szOldProxyNameBuf, CCHMAX( s_szOldProxyNameBuf ) );
  783. InitGWInfo( hDlg, s_pUlsWizard, s_fEnableGw, s_szOldGatewayNameBuf, CCHMAX( s_szOldGatewayNameBuf ) );
  784. InitGatekeeperDlgInfo( hDlg, s_hDlgUserInfo, s_pUlsWizard);
  785. s_InitialbUsingPhoneNum = FIsDlgButtonChecked( hDlg, IDC_CHECK_USE_PHONE_NUMBERS );
  786. s_InitialbUsingAccount = FIsDlgButtonChecked( hDlg, IDC_CHECK_USE_ACCOUNT );
  787. s_fEnableGk = ( ConfPolicies::CallingMode_GateKeeper == ConfPolicies::GetCallingMode() );
  788. ///////////////////////////////////////////
  789. // Set the calling mode
  790. _SetCallingMode( hDlg, ConfPolicies::GetCallingMode() );
  791. return TRUE;
  792. }
  793. break;
  794. case WM_COMMAND:
  795. switch (LOWORD(wParam))
  796. {
  797. case IDC_WARNME:
  798. EnableWindow(GetDlgItem(hDlg, IDC_WARNCOUNT),
  799. FIsDlgButtonChecked(hDlg, IDC_WARNME));
  800. break;
  801. case IDC_CALLOPT_GK_USE:
  802. {
  803. if( FIsDlgButtonChecked( hDlg, IDC_CALLOPT_GK_USE ) )
  804. {
  805. BOOL fUsePhone = FIsDlgButtonChecked( hDlg, IDC_CHECK_USE_PHONE_NUMBERS );
  806. BOOL fUseAccount = FIsDlgButtonChecked( hDlg, IDC_CHECK_USE_ACCOUNT );
  807. #if defined( PROXY_SUPPORTED )
  808. // disable the non-gatekeeper items
  809. EnableWindow( GetDlgItem( hDlg, IDC_CHECK_USE_PROXY ), FALSE );
  810. EnableWindow( GetDlgItem( hDlg, IDC_STATIC_PROXY_NAME ), FALSE );
  811. EnableWindow( GetDlgItem( hDlg, IDE_CALLOPT_PROXY_SERVER ), FALSE );
  812. #endif // defined( PROXY_SUPPORTED )
  813. EnableWindow( GetDlgItem( hDlg, IDC_CHECK_USE_GATEWAY ), FALSE );
  814. EnableWindow( GetDlgItem( hDlg, IDC_STATIC_GATEWAY_NAME ), FALSE );
  815. EnableWindow( GetDlgItem( hDlg, IDE_CALLOPT_GW_SERVER ), FALSE );
  816. // Enable the gatekeeper options
  817. EnableWindow( GetDlgItem( hDlg, IDC_CALLOPT_GK_USE ), !s_fCantChangeCallMode);
  818. EnableWindow( GetDlgItem( hDlg, IDE_CALLOPT_GK_SERVER ), !s_fCantChangeCallMode);
  819. EnableWindow( GetDlgItem( hDlg, IDC_STATIC_GATEKEEPER_NAME ), !s_fCantChangeCallMode);
  820. EnableWindow( GetDlgItem( hDlg, IDC_CHECK_USE_PHONE_NUMBERS ), !s_fCantChangeCallMode);
  821. EnableWindow( GetDlgItem( hDlg, IDC_STATIC_PHONE_NUMBER ), fUsePhone);
  822. EnableWindow( GetDlgItem( hDlg, IDE_CALLOPT_GK_PHONE_NUMBER ), fUsePhone);
  823. EnableWindow( GetDlgItem( hDlg, IDC_CHECK_USE_ACCOUNT ), !s_fCantChangeCallMode );
  824. EnableWindow( GetDlgItem( hDlg, IDS_STATIC_ACCOUNT ), fUseAccount );
  825. EnableWindow( GetDlgItem( hDlg, IDE_CALLOPT_GK_ACCOUNT ), fUseAccount );
  826. if (!s_fCantChangeCallMode)
  827. {
  828. SetFocus( GetDlgItem( hDlg, IDE_CALLOPT_GK_SERVER ) );
  829. SendDlgItemMessage( hDlg, IDE_CALLOPT_GK_SERVER, EM_SETSEL, 0, -1 );
  830. }
  831. else
  832. {
  833. if (fUsePhone)
  834. {
  835. SetFocus( GetDlgItem( hDlg, IDE_CALLOPT_GK_PHONE_NUMBER ) );
  836. SendDlgItemMessage( hDlg, IDE_CALLOPT_GK_PHONE_NUMBER, EM_SETSEL, 0, -1 );
  837. }
  838. else if (fUseAccount)
  839. {
  840. SetFocus( GetDlgItem( hDlg, IDE_CALLOPT_GK_ACCOUNT ) );
  841. SendDlgItemMessage( hDlg, IDE_CALLOPT_GK_ACCOUNT, EM_SETSEL, 0, -1 );
  842. }
  843. }
  844. }
  845. else
  846. {
  847. #if defined( PROXY_SUPPORTED )
  848. // Enable the direct use options
  849. EnableWindow( GetDlgItem( hDlg, IDC_CHECK_USE_PROXY ), TRUE );
  850. EnableWindow( GetDlgItem( hDlg, IDC_STATIC_PROXY_NAME ), FIsDlgButtonChecked( hDlg, IDC_CHECK_USE_PROXY ) );
  851. EnableWindow( GetDlgItem( hDlg, IDE_CALLOPT_PROXY_SERVER ), FIsDlgButtonChecked( hDlg, IDC_CHECK_USE_PROXY ) );
  852. #endif // defined( PROXY_SUPPORTED )
  853. EnableWindow( GetDlgItem( hDlg, IDC_CHECK_USE_GATEWAY ), !s_fCantChangeCallMode );
  854. EnableWindow( GetDlgItem( hDlg, IDC_STATIC_GATEWAY_NAME ), !s_fCantChangeCallMode && FIsDlgButtonChecked( hDlg, IDC_CHECK_USE_GATEWAY ) );
  855. EnableWindow( GetDlgItem( hDlg, IDE_CALLOPT_GW_SERVER ), !s_fCantChangeCallMode && FIsDlgButtonChecked( hDlg, IDC_CHECK_USE_GATEWAY ) );
  856. // Disable the gatekeeper options
  857. EnableWindow( GetDlgItem( hDlg, IDC_CALLOPT_GK_USE ), !s_fCantChangeCallMode);
  858. EnableWindow( GetDlgItem( hDlg, IDE_CALLOPT_GK_SERVER ), FALSE );
  859. EnableWindow( GetDlgItem( hDlg, IDC_STATIC_GATEKEEPER_NAME ), FALSE );
  860. EnableWindow( GetDlgItem( hDlg, IDC_CHECK_USE_PHONE_NUMBERS ), FALSE );
  861. EnableWindow( GetDlgItem( hDlg, IDC_STATIC_PHONE_NUMBER ), FALSE);
  862. EnableWindow( GetDlgItem( hDlg, IDE_CALLOPT_GK_PHONE_NUMBER ), FALSE );
  863. EnableWindow( GetDlgItem( hDlg, IDC_CHECK_USE_ACCOUNT ), FALSE );
  864. EnableWindow( GetDlgItem( hDlg, IDS_STATIC_ACCOUNT ), FALSE);
  865. EnableWindow( GetDlgItem( hDlg, IDE_CALLOPT_GK_ACCOUNT ), FALSE );
  866. }
  867. break;
  868. }
  869. case IDC_CHECK_USE_ACCOUNT:
  870. {
  871. if( FIsDlgButtonChecked( hDlg, IDC_CHECK_USE_ACCOUNT ) )
  872. {
  873. EnableWindow(GetDlgItem( hDlg, IDS_STATIC_ACCOUNT ), TRUE);
  874. EnableWindow(GetDlgItem( hDlg, IDE_CALLOPT_GK_ACCOUNT ), TRUE);
  875. SetFocus( GetDlgItem( hDlg, IDE_CALLOPT_GK_ACCOUNT ) );
  876. SendDlgItemMessage( hDlg, IDE_CALLOPT_GK_ACCOUNT, EM_SETSEL, 0, -1 );
  877. }
  878. else
  879. {
  880. EnableWindow(GetDlgItem( hDlg, IDS_STATIC_ACCOUNT ), FALSE);
  881. EnableWindow(GetDlgItem( hDlg, IDE_CALLOPT_GK_ACCOUNT ), FALSE);
  882. }
  883. break;
  884. }
  885. case IDC_CHECK_USE_PHONE_NUMBERS:
  886. {
  887. if( FIsDlgButtonChecked( hDlg, IDC_CHECK_USE_PHONE_NUMBERS ) )
  888. {
  889. EnableWindow(GetDlgItem( hDlg, IDC_STATIC_PHONE_NUMBER ), TRUE);
  890. EnableWindow(GetDlgItem( hDlg, IDE_CALLOPT_GK_PHONE_NUMBER ), TRUE);
  891. SetFocus( GetDlgItem( hDlg, IDE_CALLOPT_GK_PHONE_NUMBER ) );
  892. SendDlgItemMessage( hDlg, IDE_CALLOPT_GK_PHONE_NUMBER, EM_SETSEL, 0, -1 );
  893. }
  894. else
  895. {
  896. EnableWindow(GetDlgItem( hDlg, IDE_CALLOPT_GK_PHONE_NUMBER ), FALSE);
  897. EnableWindow(GetDlgItem( hDlg, IDC_STATIC_PHONE_NUMBER ), FALSE);
  898. }
  899. break;
  900. }
  901. case IDC_CHECK_USE_PROXY:
  902. {
  903. if( FIsDlgButtonChecked( hDlg, IDC_CHECK_USE_PROXY ) != FALSE )
  904. {
  905. EnableWindow(GetDlgItem( hDlg, IDC_STATIC_PROXY_NAME ), TRUE );
  906. EnableWindow(GetDlgItem( hDlg, IDE_CALLOPT_PROXY_SERVER ), TRUE );
  907. SetFocus( GetDlgItem( hDlg, IDE_CALLOPT_PROXY_SERVER ) );
  908. SendDlgItemMessage( hDlg, IDE_CALLOPT_PROXY_SERVER, EM_SETSEL, 0, -1 );
  909. }
  910. else
  911. {
  912. EnableWindow(GetDlgItem( hDlg, IDC_STATIC_PROXY_NAME ), FALSE );
  913. EnableWindow(GetDlgItem( hDlg, IDE_CALLOPT_PROXY_SERVER ), FALSE );
  914. }
  915. }
  916. break;
  917. case IDC_CHECK_USE_GATEWAY:
  918. {
  919. if( FIsDlgButtonChecked( hDlg, IDC_CHECK_USE_GATEWAY ) != FALSE )
  920. {
  921. EnableWindow(GetDlgItem( hDlg, IDC_STATIC_GATEWAY_NAME ), TRUE );
  922. EnableWindow(GetDlgItem( hDlg, IDE_CALLOPT_GW_SERVER ), TRUE );
  923. SetFocus( GetDlgItem( hDlg, IDE_CALLOPT_GW_SERVER ) );
  924. SendDlgItemMessage( hDlg, IDE_CALLOPT_GW_SERVER, EM_SETSEL, 0, -1 );
  925. }
  926. else
  927. {
  928. EnableWindow(GetDlgItem( hDlg, IDE_CALLOPT_GW_SERVER ), FALSE );
  929. EnableWindow(GetDlgItem( hDlg, IDC_STATIC_GATEWAY_NAME ), FALSE );
  930. }
  931. }
  932. break;
  933. case IDOK:
  934. {
  935. ////////////////////////////////////////////////////////////////////
  936. // First we check to see that we have valid data
  937. int _IdFocus = 0;
  938. // Check to see if we are in gatekeeper mode...
  939. if( FIsDlgButtonChecked( hDlg, IDC_CALLOPT_GK_USE ) )
  940. {
  941. // Verify the gatekeeper settings
  942. TCHAR szServer[CCHMAXSZ_SERVER];
  943. if (!GetDlgItemText(hDlg, IDE_CALLOPT_GK_SERVER, szServer, CCHMAX(szServer)) ||
  944. !IsLegalGateKeeperServerSz(szServer))
  945. {
  946. ConfMsgBox(hDlg, (LPCTSTR)IDS_ILLEGAL_GATEKEEPERSERVER_NAME);
  947. _IdFocus = IDE_CALLOPT_GK_SERVER;
  948. }
  949. if( (!_IdFocus) && (!FIsDlgButtonChecked( hDlg, IDC_CHECK_USE_PHONE_NUMBERS )) &&
  950. (!FIsDlgButtonChecked( hDlg, IDC_CHECK_USE_ACCOUNT )) )
  951. {
  952. // must check either account or phone number...
  953. ConfMsgBox(hDlg, (LPCTSTR)IDS_ILLEGAL_GK_MODE);
  954. _IdFocus = IDC_CHECK_USE_PHONE_NUMBERS;
  955. }
  956. if( (!_IdFocus) && FIsDlgButtonChecked( hDlg, IDC_CHECK_USE_PHONE_NUMBERS ) )
  957. {
  958. // Verify the phone number
  959. TCHAR szPhone[MAX_PHONENUM_LENGTH];
  960. if (!GetDlgItemText(hDlg, IDE_CALLOPT_GK_PHONE_NUMBER, szPhone, CCHMAX(szPhone)) ||
  961. !IsLegalE164Number(szPhone))
  962. {
  963. ConfMsgBox(hDlg, (LPCTSTR)IDS_ILLEGAL_PHONE_NUMBER);
  964. _IdFocus = IDE_CALLOPT_GK_PHONE_NUMBER;
  965. }
  966. }
  967. if( (!_IdFocus) && FIsDlgButtonChecked( hDlg, IDC_CHECK_USE_ACCOUNT ) )
  968. {
  969. // Verify the account
  970. TCHAR account[MAX_PATH];
  971. if (!GetDlgItemText(hDlg, IDE_CALLOPT_GK_ACCOUNT, account, CCHMAX(account)) )
  972. {
  973. ConfMsgBox(hDlg, (LPCTSTR)IDS_ILLEGAL_ACCOUNT);
  974. _IdFocus = IDE_CALLOPT_GK_ACCOUNT;
  975. }
  976. }
  977. }
  978. #if defined( PROXY_SUPPORTED )
  979. // Verify the proxy settings...
  980. if( (!_IdFocus) && FIsDlgButtonChecked( hDlg, IDC_CHECK_USE_PROXY ) && (!FIsDlgButtonChecked( hDlg, IDC_CALLOPT_GK_USE )) )
  981. {
  982. TCHAR szServer[CCHMAXSZ_SERVER];
  983. if (!GetDlgItemText(hDlg, IDE_CALLOPT_PROXY_SERVER, szServer, CCHMAX(szServer)) ||
  984. !IsLegalGatewaySz(szServer))
  985. {
  986. ConfMsgBox(hDlg, (LPCTSTR) IDS_ILLEGAL_PROXY_NAME);
  987. _IdFocus = IDE_CALLOPT_PROXY_SERVER;
  988. }
  989. }
  990. #endif // defined( PROXY_SUPPORTED )
  991. // Verify the gateway settings...
  992. if( (!_IdFocus) && FIsDlgButtonChecked( hDlg, IDC_CHECK_USE_GATEWAY ) && (!FIsDlgButtonChecked( hDlg, IDC_CALLOPT_GK_USE )) )
  993. {
  994. TCHAR szServer[CCHMAXSZ_SERVER];
  995. if (!GetDlgItemText(hDlg, IDE_CALLOPT_GW_SERVER, szServer, CCHMAX(szServer)) ||
  996. !IsLegalGatewaySz(szServer))
  997. {
  998. ConfMsgBox(hDlg, (LPCTSTR)IDS_ILLEGAL_GATEWAY_NAME);
  999. _IdFocus = IDE_CALLOPT_GW_SERVER;
  1000. }
  1001. }
  1002. if( _IdFocus )
  1003. {
  1004. SetFocus(GetDlgItem(hDlg, _IdFocus));
  1005. SendDlgItemMessage(hDlg, _IdFocus, EM_SETSEL, (WPARAM) 0, (LPARAM) -1);
  1006. SetWindowLongPtr(hDlg, DWLP_MSGRESULT, TRUE );
  1007. }
  1008. else
  1009. {
  1010. RegEntry reConf(CONFERENCING_KEY, HKEY_CURRENT_USER);
  1011. // Handle the H323 Gateway setting:
  1012. TCHAR buffer[CCHMAXSZ_SERVER];
  1013. GetDlgItemText(hDlg, IDE_CALLOPT_GW_SERVER, buffer, CCHMAX(buffer));
  1014. reConf.SetValue(REGVAL_H323_GATEWAY, buffer);
  1015. g_pCCallto->SetGatewayName( buffer );
  1016. bool fEnable = FIsDlgButtonChecked(hDlg, IDC_CHECK_USE_GATEWAY) ? true : false;
  1017. if (fEnable != s_fEnableGw)
  1018. {
  1019. reConf.SetValue(REGVAL_USE_H323_GATEWAY, fEnable);
  1020. }
  1021. g_pCCallto->SetGatewayEnabled( fEnable );
  1022. #if defined( PROXY_SUPPORTED )
  1023. reConf.SetValue( REGVAL_USE_PROXY, FIsDlgButtonChecked( hDlg, IDC_CHECK_USE_PROXY ) );
  1024. GetDlgItemText( hDlg, IDE_CALLOPT_PROXY_SERVER, buffer, CCHMAX( buffer ) );
  1025. reConf.SetValue( REGVAL_PROXY, buffer );
  1026. #endif // defined( PROXY_SUPPORTED )
  1027. bool relogonRequired = false;
  1028. // Gatekeeper / alias settings
  1029. {
  1030. TCHAR szServer[CCHMAXSZ_SERVER];
  1031. GetDlgItemTextTrimmed(hDlg, IDE_CALLOPT_GK_SERVER, szServer, CCHMAX(szServer));
  1032. if (0 != lstrcmp(szServer, reConf.GetString(REGVAL_GK_SERVER)))
  1033. {
  1034. reConf.SetValue(REGVAL_GK_SERVER, szServer);
  1035. relogonRequired = true;
  1036. }
  1037. fEnable = FIsDlgButtonChecked(hDlg, IDC_CALLOPT_GK_USE) ? true : false;
  1038. if( fEnable != s_fEnableGk )
  1039. {
  1040. // Set the calling mode
  1041. reConf.SetValue(REGVAL_CALLING_MODE, fEnable ? CALLING_MODE_GATEKEEPER : CALLING_MODE_DIRECT );
  1042. relogonRequired = true;
  1043. }
  1044. bool bUsingPhoneNum = FIsDlgButtonChecked( hDlg, IDC_CHECK_USE_PHONE_NUMBERS );
  1045. bool bUsingAccount = FIsDlgButtonChecked( hDlg, IDC_CHECK_USE_ACCOUNT );
  1046. ConfPolicies::eGKAddressingMode addressingMode;
  1047. if( bUsingPhoneNum && bUsingAccount )
  1048. {
  1049. addressingMode = ConfPolicies::GKAddressing_Both;
  1050. }
  1051. else if( bUsingPhoneNum )
  1052. {
  1053. addressingMode = ConfPolicies::GKAddressing_PhoneNum;
  1054. }
  1055. else if( bUsingAccount )
  1056. {
  1057. addressingMode = ConfPolicies::GKAddressing_Account;
  1058. }
  1059. else
  1060. {
  1061. addressingMode = ConfPolicies::GKAddressing_Invalid;
  1062. }
  1063. if( (s_InitialbUsingPhoneNum != bUsingPhoneNum) ||
  1064. (s_InitialbUsingAccount != bUsingAccount) )
  1065. {
  1066. // Set the calling mode
  1067. reConf.SetValue(REGVAL_GK_METHOD, addressingMode );
  1068. relogonRequired = true;
  1069. }
  1070. RegEntry reULS(ISAPI_CLIENT_KEY, HKEY_CURRENT_USER);
  1071. GetDlgItemTextTrimmed( hDlg, IDE_CALLOPT_GK_PHONE_NUMBER, buffer, CCHMAX( buffer ) );
  1072. if( lstrcmp( buffer, reULS.GetString( REGVAL_ULS_PHONENUM_NAME ) ) != 0 )
  1073. {
  1074. reULS.SetValue( REGVAL_ULS_PHONENUM_NAME, buffer );
  1075. relogonRequired = true;
  1076. }
  1077. GetDlgItemTextTrimmed( hDlg, IDE_CALLOPT_GK_ACCOUNT, buffer, CCHMAX( buffer ) );
  1078. if( lstrcmp( buffer, reULS.GetString( REGVAL_ULS_GK_ACCOUNT ) ) != 0 )
  1079. {
  1080. reULS.SetValue( REGVAL_ULS_GK_ACCOUNT, buffer );
  1081. relogonRequired = true;
  1082. }
  1083. }
  1084. if( relogonRequired )
  1085. {
  1086. // This means that we need to log on to the gatekeeper with this new changed info...
  1087. reConf.FlushKey();
  1088. if( fEnable )
  1089. {
  1090. if( s_fEnableGk )
  1091. {
  1092. // We are already logged on to the gatekeeper so we must log off first...
  1093. GkLogoff();
  1094. }
  1095. GkLogon();
  1096. }
  1097. else
  1098. {
  1099. // We are now in direct mode, we should log off the GateKeeper....
  1100. GkLogoff();
  1101. SetGkLogonState( NM_GK_NOT_IN_GK_MODE );
  1102. }
  1103. // Update the status Bar...
  1104. CConfStatusBar* pStatusBar = CConfStatusBar::GetInstance();
  1105. if( pStatusBar )
  1106. {
  1107. pStatusBar->Update();
  1108. }
  1109. }
  1110. EndDialog( hDlg, IDOK );
  1111. }
  1112. }
  1113. break;
  1114. case IDCANCEL:
  1115. {
  1116. EndDialog( hDlg, IDCANCEL );
  1117. }
  1118. break;
  1119. default:
  1120. break;
  1121. }
  1122. break;
  1123. case WM_CONTEXTMENU:
  1124. DoHelpWhatsThis(wParam, _rgHelpIdsCalling);
  1125. break;
  1126. case WM_HELP:
  1127. DoHelp(lParam, _rgHelpIdsCalling);
  1128. break;
  1129. case WM_DESTROY:
  1130. s_hDlgUserInfo = NULL;
  1131. break;
  1132. default:
  1133. break;
  1134. }
  1135. return FALSE;
  1136. }
  1137.