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.

794 lines
21 KiB

  1. // File: dlginfo.cpp
  2. #include "precomp.h"
  3. #include <windowsx.h>
  4. #include "resource.h"
  5. #include "help_ids.h"
  6. #include "nmhelp.h"
  7. #include "mrulist2.h"
  8. #include "dlginfo.h"
  9. #include "nmsysinfo.h"
  10. extern HINSTANCE g_hInst;
  11. const int MRU_MAX_ENTRIES = 15; // This MUST be the same as the constant in ui\conf\mrulist.h
  12. const int CCHMAXSZ = 256; // Maximum generic string length
  13. const int CCHMAXSZ_EMAIL = 128; // Maximum length of an email name
  14. const int CCHMAXSZ_FIRSTNAME = 128; // Maximum length of a first name
  15. const int CCHMAXSZ_LASTNAME = 128; // Maximum length of a last name
  16. const int CCHMAXSZ_NAME = 256; // Maximum user name, displayed (combined first+last name)
  17. const int CCHMAXSZ_LOCATION = 128; // Maximum length of a Location
  18. const int CCHMAXSZ_SERVER = 128; // Maximum length of an address
  19. ///////////////////////////////////////////////////////////////////////////
  20. // Local Data
  21. static const DWSTR _rgMruServer[] = {
  22. {1, DIR_MRU_KEY},
  23. {MRUTYPE_SZ, TEXT("Name")},
  24. };
  25. static const DWORD _mpIdHelpDlgInfo[] = {
  26. IDG_UI_MYINFO, IDH_MYINFO_MYINFO,
  27. IDE_UI_FIRSTNAME, IDH_MYINFO_FIRSTNAME,
  28. IDE_UI_LASTNAME, IDH_MYINFO_LASTNAME,
  29. IDE_UI_EMAIL, IDH_MYINFO_EMAIL,
  30. IDE_UI_LOCATION, IDH_MYINFO_LOCATION,
  31. IDG_UI_DIRECTORY, IDH_MYINFO_ULS_SERVER,
  32. IDE_UI_DIRECTORY, IDH_MYINFO_ULS_SERVER,
  33. 0, 0 // terminator
  34. };
  35. // Local functions
  36. VOID FillServerComboBox(HWND hwndCombo);
  37. BOOL FLegalEmailName(HWND hdlg, UINT id);
  38. BOOL FLegalEmailSz(PTSTR pszName);
  39. BOOL FLoadString(UINT id, LPTSTR lpsz, UINT cch);
  40. BOOL FGetDefaultServer(LPTSTR pszServer, UINT cchMax);
  41. UINT GetDlgItemTextTrimmed(HWND hdlg, int id, PTCHAR psz, int cchMax);
  42. BOOL FEmptyDlgItem(HWND hdlg, UINT id);
  43. VOID CombineNames(LPTSTR pszResult, int cchResult, LPCTSTR pcszFirst, LPCTSTR pcszLast);
  44. BOOL FGetPropertySz(NM_SYSPROP nmProp, LPTSTR psz, int cchMax);
  45. BOOL FSetPropertySz(NM_SYSPROP nmProp, LPCTSTR pcsz);
  46. CMRUList2 * GetMruListServer(void);
  47. /* C D L G I N F O */
  48. /*-------------------------------------------------------------------------
  49. %%Function: CDlgInfo
  50. -------------------------------------------------------------------------*/
  51. CDlgInfo::CDlgInfo():
  52. m_hwnd(NULL)
  53. {
  54. }
  55. CDlgInfo::~CDlgInfo(void)
  56. {
  57. }
  58. /* D O M O D A L */
  59. /*-------------------------------------------------------------------------
  60. %%Function: DoModal
  61. -------------------------------------------------------------------------*/
  62. INT_PTR CDlgInfo::DoModal(HWND hwndParent)
  63. {
  64. return DialogBoxParam(g_hInst, MAKEINTRESOURCE(IDD_USERINFO),
  65. hwndParent, CDlgInfo::DlgProc, (LPARAM) this);
  66. }
  67. /* I N I T C T R L */
  68. /*-------------------------------------------------------------------------
  69. %%Function: InitCtrl
  70. -------------------------------------------------------------------------*/
  71. VOID CDlgInfo::InitCtrl(NM_SYSPROP nmProp, HWND hwnd, int cchMax)
  72. {
  73. ::SendMessage(hwnd, WM_SETFONT, (WPARAM)(HFONT)::GetStockObject(DEFAULT_GUI_FONT), 0);
  74. Edit_LimitText(hwnd, cchMax);
  75. TCHAR sz[MAX_PATH];
  76. if (!FGetPropertySz(nmProp, sz, CCHMAX(sz)))
  77. return;
  78. ::SendMessage(hwnd, WM_SETTEXT, 0, (LPARAM) sz);
  79. }
  80. /* F S E T P R O P E R T Y */
  81. /*-------------------------------------------------------------------------
  82. %%Function: FSetProperty
  83. -------------------------------------------------------------------------*/
  84. BOOL CDlgInfo::FSetProperty(NM_SYSPROP nmProp, int id)
  85. {
  86. TCHAR sz[MAX_PATH];
  87. if (0 == GetDlgItemTextTrimmed(m_hwnd, id, sz, CCHMAX(sz)))
  88. return FALSE;
  89. return FSetPropertySz(nmProp, sz);
  90. }
  91. /* O N I N I T D I A L O G */
  92. /*-------------------------------------------------------------------------
  93. %%Function: OnInitDialog
  94. -------------------------------------------------------------------------*/
  95. VOID CDlgInfo::OnInitDialog(void)
  96. {
  97. InitCtrl(NM_SYSPROP_FIRST_NAME, GetDlgItem(m_hwnd, IDE_UI_FIRSTNAME), CCHMAXSZ_FIRSTNAME-1);
  98. InitCtrl(NM_SYSPROP_LAST_NAME, GetDlgItem(m_hwnd, IDE_UI_LASTNAME), CCHMAXSZ_LASTNAME-1);
  99. InitCtrl(NM_SYSPROP_EMAIL_NAME, GetDlgItem(m_hwnd, IDE_UI_EMAIL), CCHMAXSZ_EMAIL-1);
  100. InitCtrl(NM_SYSPROP_USER_CITY, GetDlgItem(m_hwnd, IDE_UI_LOCATION), CCHMAXSZ_LOCATION-1);
  101. m_hwndCombo = GetDlgItem(m_hwnd, IDE_UI_DIRECTORY);
  102. InitCtrl(NM_SYSPROP_SERVER_NAME, m_hwndCombo, CCHMAXSZ_SERVER-1);
  103. FillServerComboBox(m_hwndCombo);
  104. ComboBox_SetCurSel( m_hwndCombo, 0 );
  105. ValidateData();
  106. }
  107. /* D L G P R O C */
  108. /*-------------------------------------------------------------------------
  109. %%Function: DlgProc
  110. -------------------------------------------------------------------------*/
  111. INT_PTR CALLBACK CDlgInfo::DlgProc(HWND hdlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
  112. {
  113. switch (uMsg)
  114. {
  115. case WM_INITDIALOG:
  116. {
  117. ASSERT(NULL != lParam);
  118. ::SetWindowLongPtr(hdlg, DWLP_USER, lParam);
  119. CDlgInfo * pDlg = (CDlgInfo*) lParam;
  120. pDlg->m_hwnd = hdlg;
  121. pDlg->OnInitDialog();
  122. return TRUE; // default focus is ok
  123. }
  124. case WM_COMMAND:
  125. {
  126. CDlgInfo * pDlg = (CDlgInfo*) GetWindowLongPtr(hdlg, DWLP_USER);
  127. if (NULL != pDlg)
  128. {
  129. pDlg->OnCommand(wParam, lParam);
  130. }
  131. break;
  132. }
  133. case WM_HELP:
  134. DoHelp(lParam, _mpIdHelpDlgInfo);
  135. break;
  136. case WM_CONTEXTMENU:
  137. DoHelpWhatsThis(wParam, _mpIdHelpDlgInfo);
  138. break;
  139. default:
  140. break;
  141. }
  142. return FALSE;
  143. }
  144. /* O N C O M M A N D */
  145. /*-------------------------------------------------------------------------
  146. %%Function: OnCommand
  147. -------------------------------------------------------------------------*/
  148. BOOL CDlgInfo::OnCommand(WPARAM wParam, LPARAM lParam)
  149. {
  150. ASSERT(NULL != m_hwnd);
  151. WORD wCmd = GET_WM_COMMAND_ID(wParam, lParam);
  152. switch (wCmd)
  153. {
  154. case IDE_UI_FIRSTNAME:
  155. case IDE_UI_LASTNAME:
  156. case IDE_UI_EMAIL:
  157. {
  158. if (GET_WM_COMMAND_CMD(wParam,lParam) == EN_CHANGE)
  159. {
  160. ValidateData();
  161. }
  162. break;
  163. }
  164. case IDE_UI_DIRECTORY:
  165. {
  166. switch (GET_WM_COMMAND_CMD(wParam,lParam))
  167. {
  168. case CBN_SELCHANGE:
  169. // The data isn't available yet
  170. PostMessage(m_hwnd, WM_COMMAND, MAKELONG(IDE_UI_DIRECTORY, CBN_EDITCHANGE), lParam);
  171. break;
  172. case CBN_EDITCHANGE:
  173. ValidateData();
  174. default:
  175. break;
  176. }
  177. break;
  178. }
  179. case IDOK:
  180. {
  181. if (FSaveData())
  182. {
  183. ::EndDialog(m_hwnd, wCmd);
  184. }
  185. return TRUE;
  186. }
  187. case IDCANCEL:
  188. {
  189. ::EndDialog(m_hwnd, wCmd);
  190. return TRUE;
  191. }
  192. default:
  193. break;
  194. }
  195. return FALSE;
  196. }
  197. VOID CDlgInfo::ValidateData(void)
  198. {
  199. BOOL fOk = !FEmptyDlgItem(m_hwnd, IDE_UI_FIRSTNAME) &&
  200. !FEmptyDlgItem(m_hwnd, IDE_UI_LASTNAME) &&
  201. !FEmptyDlgItem(m_hwnd, IDE_UI_EMAIL);
  202. if (fOk)
  203. {
  204. TCHAR sz[CCHMAXSZ_EMAIL];
  205. GetDlgItemTextTrimmed(m_hwnd, IDE_UI_EMAIL, sz, CCHMAX(sz));
  206. fOk = FLegalEmailSz(sz);
  207. }
  208. if (fOk)
  209. {
  210. TCHAR sz[CCHMAXSZ_SERVER];
  211. fOk = (0 != ComboBox_GetText(m_hwndCombo, sz, CCHMAX(sz)));
  212. if (fOk)
  213. {
  214. fOk = 0 != TrimSz(sz);
  215. }
  216. }
  217. Button_Enable(GetDlgItem(m_hwnd, IDOK), fOk);
  218. }
  219. /* F S A V E D A T A */
  220. /*-------------------------------------------------------------------------
  221. %%Function: FSaveData
  222. -------------------------------------------------------------------------*/
  223. BOOL CDlgInfo::FSaveData(void)
  224. {
  225. if (!FSetProperty(NM_SYSPROP_FIRST_NAME, IDE_UI_FIRSTNAME) ||
  226. !FSetProperty(NM_SYSPROP_LAST_NAME, IDE_UI_LASTNAME) ||
  227. !FSetProperty(NM_SYSPROP_EMAIL_NAME, IDE_UI_EMAIL) ||
  228. !FSetProperty(NM_SYSPROP_SERVER_NAME, IDE_UI_DIRECTORY)
  229. )
  230. {
  231. return FALSE;
  232. }
  233. // The city name (can be blank)
  234. TCHAR sz[CCHMAXSZ];
  235. GetDlgItemTextTrimmed(m_hwnd, IDE_UI_LOCATION, sz, CCHMAX(sz));
  236. FSetPropertySz(NM_SYSPROP_USER_CITY, sz);
  237. // Full Name = First + Last
  238. TCHAR szFirst[CCHMAXSZ_FIRSTNAME];
  239. GetDlgItemTextTrimmed(m_hwnd, IDE_UI_FIRSTNAME, szFirst, CCHMAX(szFirst));
  240. TCHAR szLast[CCHMAXSZ_LASTNAME];
  241. GetDlgItemTextTrimmed(m_hwnd, IDE_UI_LASTNAME, szLast, CCHMAX(szLast));
  242. CombineNames(sz, CCHMAX(sz), szFirst, szLast);
  243. if (!FSetPropertySz(NM_SYSPROP_USER_NAME, sz))
  244. return FALSE;
  245. // Resolve Name = server / email
  246. UINT cch = GetDlgItemTextTrimmed(m_hwnd, IDE_UI_DIRECTORY, sz, CCHMAX(sz));
  247. GetDlgItemTextTrimmed(m_hwnd, IDE_UI_EMAIL, &sz[cch], CCHMAX(sz)-cch);
  248. return FSetPropertySz(NM_SYSPROP_RESOLVE_NAME, sz);
  249. }
  250. ///////////////////////////////////////////////////////////////////////////
  251. /* C O M B I N E N A M E S */
  252. /*-------------------------------------------------------------------------
  253. %%Function: CombineNames
  254. Combine the two names into one string.
  255. The result is a "First Last" (or Intl'd "Last First") string
  256. -------------------------------------------------------------------------*/
  257. VOID CombineNames(LPTSTR pszResult, int cchResult, LPCTSTR pcszFirst, LPCTSTR pcszLast)
  258. {
  259. ASSERT(pszResult);
  260. TCHAR szFmt[32]; // A small value: String is "%1 %2" or "%2 %1"
  261. TCHAR sz[CCHMAXSZ_NAME];
  262. LPCTSTR argw[2];
  263. argw[0] = pcszFirst;
  264. argw[1] = pcszLast;
  265. *pszResult = _T('\0');
  266. if (!FLoadString(IDS_NAME_ORDER, szFmt, CCHMAX(szFmt)))
  267. return;
  268. if (0 == FormatMessage(FORMAT_MESSAGE_ARGUMENT_ARRAY | FORMAT_MESSAGE_FROM_STRING,
  269. szFmt, 0, 0, sz, CCHMAX(sz), (va_list *)argw ))
  270. return;
  271. // REVIEW: Use STRCPYN or make this a utility function
  272. lstrcpyn(pszResult, sz, cchResult);
  273. #ifndef _UNICODE
  274. // lstrcpyn() can clip a DBCS character in half at the end of the string
  275. // we need to walk the string with ::CharNext() and replace the last byte
  276. // with a NULL if the last byte is half of a DBCS char.
  277. PTSTR pszSource = sz;
  278. while (*pszSource && (pszSource - sz < cchResult))
  279. {
  280. PTSTR pszPrev = pszSource;
  281. pszSource = ::CharNext(pszPrev);
  282. // If we've reached the first character that didn't get copied into
  283. // the destination buffer, and the previous character was a double
  284. // byte character...
  285. if (((pszSource - sz) == cchResult) && ::IsDBCSLeadByte(*pszPrev))
  286. {
  287. // Replace the destination buffer's last character with '\0'
  288. // NOTE: pszResult[cchResult - 1] is '\0' thanks to lstrcpyn()
  289. pszResult[cchResult - 2] = _T('\0');
  290. break;
  291. }
  292. }
  293. #endif // ! _UNICODE
  294. }
  295. /* F L E G A L E M A I L S Z */
  296. /*-------------------------------------------------------------------------
  297. %%Function: FLegalEmailSz
  298. A legal email name contains only ANSI characters.
  299. "a-z, A-Z, numbers 0-9 and some common symbols"
  300. It cannot include extended characters or < > ( ) /
  301. -------------------------------------------------------------------------*/
  302. BOOL FLegalEmailSz(PTSTR pszName)
  303. {
  304. if (IS_EMPTY_STRING(pszName))
  305. return FALSE;
  306. for ( ; ; )
  307. {
  308. UINT ch = (UINT) ((*pszName++) & 0x00FF);
  309. if (0 == ch)
  310. break;
  311. switch (ch)
  312. {
  313. default:
  314. if ((ch > (UINT) _T(' ')) && (ch <= (UINT) _T('~')) )
  315. break;
  316. // else fall thru to error code
  317. case '(': case ')':
  318. case '<': case '>':
  319. case '[': case ']':
  320. case '/': case '\\':
  321. case ':': case ';':
  322. case '+':
  323. case '=':
  324. case ',':
  325. case '\"':
  326. WARNING_OUT(("FLegalEmailSz: Invalid character '%s' (0x%02X)", &ch, ch));
  327. return FALSE;
  328. }
  329. }
  330. return TRUE;
  331. }
  332. /* F L E G A L E M A I L N A M E */
  333. /*-------------------------------------------------------------------------
  334. %%Function: FLegalEmailName
  335. -------------------------------------------------------------------------*/
  336. BOOL FLegalEmailName(HWND hdlg, UINT id)
  337. {
  338. TCHAR sz[MAX_PATH];
  339. GetDlgItemTextTrimmed(hdlg, id, sz, CCHMAX(sz));
  340. return FLegalEmailSz(sz);
  341. }
  342. #include "rend.h"
  343. TCHAR s_DomainDirectory[ MAX_PATH ] = TEXT( "" );
  344. HRESULT BSTR_to_LPTSTR(LPTSTR *ppsz, BSTR bstr);
  345. //--------------------------------------------------------------------------//
  346. // CDirectoryManager::get_DomainDirectory. //
  347. //--------------------------------------------------------------------------//
  348. const TCHAR * const
  349. get_DomainDirectory(void)
  350. {
  351. static bool bAccessAttempted = false; // only read this info once... if it fails once assume it's not available and don't retry until restarted...
  352. if( (!bAccessAttempted) && s_DomainDirectory[ 0 ] == '\0' )
  353. {
  354. bAccessAttempted = true;
  355. // Try to obtain the configured directory for this domain...
  356. ITRendezvous * pRendezvous;
  357. HRESULT hrResult;
  358. hrResult = ::CoCreateInstance( CLSID_Rendezvous, NULL, CLSCTX_ALL, IID_ITRendezvous, (void **) &pRendezvous );
  359. if( (hrResult == S_OK) && (pRendezvous != NULL) )
  360. {
  361. IEnumDirectory * pEnumDirectory;
  362. hrResult = pRendezvous->EnumerateDefaultDirectories( &pEnumDirectory );
  363. if( (hrResult == S_OK) && (pEnumDirectory != NULL) )
  364. {
  365. ITDirectory * pDirectory;
  366. bool bFoundILS = false;
  367. do
  368. {
  369. hrResult = pEnumDirectory->Next( 1, &pDirectory, NULL );
  370. if( (hrResult == S_OK) && (pDirectory != NULL) )
  371. {
  372. LPWSTR * ppServers;
  373. DIRECTORY_TYPE type;
  374. if( pDirectory->get_DirectoryType( &type ) == S_OK )
  375. {
  376. if( type == DT_ILS ) // Found an ILS server configured on the DS... retrieve the name and port...
  377. {
  378. bFoundILS = true;
  379. BSTR pName;
  380. if( pDirectory->get_DisplayName( &pName ) == S_OK )
  381. {
  382. LPTSTR szName;
  383. if (SUCCEEDED(BSTR_to_LPTSTR (&szName, pName)))
  384. {
  385. lstrcpy( s_DomainDirectory, szName );
  386. delete (szName);
  387. }
  388. SysFreeString( pName );
  389. }
  390. ITILSConfig * pITILSConfig;
  391. hrResult = pDirectory->QueryInterface( IID_ITILSConfig, (void **) &pITILSConfig );
  392. if( (hrResult == S_OK) && (pITILSConfig != NULL) )
  393. {
  394. long lPort;
  395. if( pITILSConfig->get_Port( &lPort ) == S_OK )
  396. {
  397. TCHAR pszPort[ 32 ];
  398. wsprintf( pszPort, TEXT( ":%d" ), lPort );
  399. lstrcat( s_DomainDirectory, pszPort );
  400. }
  401. pITILSConfig->Release();
  402. }
  403. }
  404. }
  405. pDirectory->Release();
  406. }
  407. }
  408. while( (!bFoundILS) && (hrResult == S_OK) && (pDirectory != NULL) );
  409. pEnumDirectory->Release();
  410. }
  411. pRendezvous->Release();
  412. }
  413. }
  414. return( (s_DomainDirectory[ 0 ] != '\0')? s_DomainDirectory: NULL );
  415. } // End of CDirectoryManager::get_DomainDirectory.
  416. /* F I L L S E R V E R C O M B O B O X */
  417. /*-------------------------------------------------------------------------
  418. %%Function: FillServerComboBox
  419. -------------------------------------------------------------------------*/
  420. VOID FillServerComboBox(HWND hwnd)
  421. {
  422. CMRUList2 * pMru = GetMruListServer();
  423. if (NULL == pMru)
  424. return;
  425. get_DomainDirectory();
  426. if(s_DomainDirectory[0]!='\0')
  427. {
  428. ComboBox_AddString(hwnd, s_DomainDirectory);
  429. }
  430. int cServers = pMru->GetNumEntries();
  431. for (int i = 0; i < cServers; i++)
  432. {
  433. int iPos = ComboBox_AddString(hwnd, pMru->PszEntry(i));
  434. if (iPos < 0)
  435. break;
  436. }
  437. delete pMru;
  438. }
  439. inline VOID DwToSz(DWORD dw, LPTSTR psz)
  440. {
  441. wsprintf(psz, TEXT("%d"), dw);
  442. }
  443. BOOL FGetPropertySz(NM_SYSPROP nmProp, LPTSTR psz, int cchMax)
  444. {
  445. HKEY hkey;
  446. LPTSTR pszSubKey;
  447. LPTSTR pszValue;
  448. bool fString;
  449. LONG lVal;
  450. if (!CNmSysInfoObj::GetKeyDataForProp(nmProp, &hkey, &pszSubKey, &pszValue, &fString))
  451. {
  452. return FALSE;
  453. }
  454. RegEntry re(pszSubKey, hkey);
  455. if (fString)
  456. {
  457. lstrcpyn(psz, re.GetString(pszValue), cchMax);
  458. }
  459. else
  460. {
  461. lVal = re.GetNumber(pszValue, 0);
  462. DwToSz(lVal, psz);
  463. ASSERT(lstrlen(psz) < cchMax);
  464. }
  465. return TRUE;
  466. }
  467. BOOL FSetPropertySz(NM_SYSPROP nmProp, LPCTSTR pcsz)
  468. {
  469. HKEY hkey;
  470. LPTSTR pszSubKey;
  471. LPTSTR pszValue;
  472. bool fString;
  473. if (!CNmSysInfoObj::GetKeyDataForProp(nmProp, &hkey, &pszSubKey, &pszValue, &fString))
  474. {
  475. return FALSE;
  476. }
  477. RegEntry re(pszSubKey, hkey);
  478. if (fString)
  479. {
  480. return (0 == re.SetValue(pszValue, pcsz));
  481. }
  482. DWORD dw = DecimalStringToUINT(pcsz);
  483. return (0 == re.SetValue(pszValue, dw));
  484. }
  485. CMRUList2 * GetMruListServer(void)
  486. {
  487. CMRUList2 * pMruList = new CMRUList2(&_rgMruServer[0], MRU_MAX_ENTRIES, TRUE /* fReverse */);
  488. if (NULL != pMruList)
  489. {
  490. TCHAR sz[MAX_PATH];
  491. if (FGetDefaultServer(sz, CCHMAX(sz)))
  492. {
  493. pMruList->AddEntry(sz);
  494. TCHAR ldapDirectory[ MAX_PATH ];
  495. if( FLoadString( IDS_MS_INTERNET_DIRECTORY, ldapDirectory, CCHMAX( ldapDirectory ) ) )
  496. {
  497. pMruList->DeleteEntry( ldapDirectory );
  498. }
  499. RegEntry re( CONFERENCING_KEY, HKEY_CURRENT_USER );
  500. TCHAR * webViewServer = re.GetString( REGVAL_WEBDIR_DISPLAY_NAME );
  501. if( lstrlen( webViewServer ) > 0 )
  502. {
  503. pMruList->DeleteEntry( webViewServer );
  504. }
  505. pMruList->SetDirty(FALSE);
  506. }
  507. }
  508. return pMruList;
  509. }
  510. ///////////////////////////////////////////////////////////////////////////
  511. /* F V A L I D U S E R I N F O */
  512. /*-------------------------------------------------------------------------
  513. %%Function: FValidUserInfo
  514. Return TRUE if all of the necessary user information is available.
  515. -------------------------------------------------------------------------*/
  516. BOOL FValidUserInfo(void)
  517. {
  518. { // Fail if not a valid installation directory
  519. TCHAR sz[MAX_PATH];
  520. if (!GetInstallDirectory(sz) || !FDirExists(sz))
  521. return FALSE;
  522. }
  523. { // Validate ULS entries
  524. RegEntry reUls(ISAPI_KEY "\\" REGKEY_USERDETAILS, HKEY_CURRENT_USER);
  525. if (FEmptySz(reUls.GetString(REGVAL_ULS_EMAIL_NAME)))
  526. return FALSE;
  527. if (FEmptySz(reUls.GetString(REGVAL_SERVERNAME)))
  528. return FALSE;
  529. if (FEmptySz(reUls.GetString(REGVAL_ULS_RES_NAME)))
  530. return FALSE;
  531. }
  532. #if 0
  533. { // Check Wizard key
  534. RegEntry reConf(CONFERENCING_KEY, HKEY_CURRENT_USER);
  535. // check to see if the wizard has been run in UI mode
  536. DWORD dwVersion = reConf.GetNumber(REGVAL_WIZARD_VERSION_UI, 0);
  537. BOOL fForceWizard = (VER_PRODUCTVERSION_DW != dwVersion);
  538. if (fForceWizard)
  539. {
  540. // the wizard has not been run in UI mode, check to see if its been run in NOUI mode
  541. dwVersion = reConf.GetNumber(REGVAL_WIZARD_VERSION_NOUI, 0);
  542. fForceWizard = (VER_PRODUCTVERSION_DW != dwVersion);
  543. }
  544. if (fForceWizard)
  545. return FALSE; // Wizard has never been run
  546. }
  547. #endif /* 0 */
  548. // Everything is properly installed and the Wizard will not run
  549. return TRUE;
  550. }
  551. ///////////////////////////////////////////////////////////////////////////
  552. /* F L O A D S T R I N G */
  553. /*----------------------------------------------------------------------------
  554. %%Function: FLoadString
  555. Load a resource string.
  556. Assumes the buffer is valid and can hold the resource.
  557. ----------------------------------------------------------------------------*/
  558. BOOL FLoadString(UINT id, LPTSTR lpsz, UINT cch)
  559. {
  560. ASSERT(NULL != _Module.GetModuleInstance());
  561. ASSERT(NULL != lpsz);
  562. if (0 == ::LoadString(g_hInst, id, lpsz, cch))
  563. {
  564. ERROR_OUT(("*** Resource %d does not exist", id));
  565. *lpsz = _T('\0');
  566. return FALSE;
  567. }
  568. return TRUE;
  569. }
  570. /* F G E T D E F A U L T S E R V E R */
  571. /*-------------------------------------------------------------------------
  572. %%Function: FGetDefaultServer
  573. -------------------------------------------------------------------------*/
  574. BOOL FGetDefaultServer(LPTSTR pszServer, UINT cchMax)
  575. {
  576. RegEntry ulsKey(ISAPI_CLIENT_KEY, HKEY_CURRENT_USER);
  577. LPTSTR psz = ulsKey.GetString(REGVAL_SERVERNAME);
  578. if (FEmptySz(psz))
  579. return FALSE;
  580. lstrcpyn(pszServer, psz, cchMax);
  581. return TRUE;
  582. }
  583. /* G E T D L G I T E M T E X T T R I M M E D */
  584. /*-------------------------------------------------------------------------
  585. %%Function: GetDlgItemTextTrimmed
  586. -------------------------------------------------------------------------*/
  587. UINT GetDlgItemTextTrimmed(HWND hdlg, int id, PTCHAR psz, int cchMax)
  588. {
  589. UINT cch = GetDlgItemText(hdlg, id, psz, cchMax);
  590. if (0 != cch)
  591. {
  592. cch = TrimSz(psz);
  593. }
  594. return cch;
  595. }
  596. /* F E M P T Y D L G I T E M */
  597. /*-------------------------------------------------------------------------
  598. %%Function: FEmptyDlgItem
  599. Return TRUE if the dialog control is empty
  600. -------------------------------------------------------------------------*/
  601. BOOL FEmptyDlgItem(HWND hdlg, UINT id)
  602. {
  603. TCHAR sz[MAX_PATH];
  604. return (0 == GetDlgItemTextTrimmed(hdlg, id, sz, CCHMAX(sz)) );
  605. }
  606. /* V E R I F Y U S E R I N F O */
  607. /*-------------------------------------------------------------------------
  608. %%Function: VerifyUserInfo
  609. Return S_OK if the data is valid or S_FALSE if it is not.
  610. -------------------------------------------------------------------------*/
  611. HRESULT WINAPI VerifyUserInfo(HWND hwnd, NM_VUI options)
  612. {
  613. BOOL fOk = FALSE;
  614. BOOL fShow = (options & NM_VUI_SHOW) || !FValidUserInfo();
  615. if (fShow)
  616. {
  617. CDlgInfo * pDlg = new CDlgInfo();
  618. if (NULL == pDlg)
  619. return E_OUTOFMEMORY;
  620. fOk = (IDOK == pDlg->DoModal(hwnd));
  621. delete pDlg;
  622. }
  623. if (!FValidUserInfo())
  624. {
  625. // The app should not continue with this.
  626. return S_FALSE;
  627. }
  628. return S_OK;
  629. }
  630.