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.

787 lines
27 KiB

  1. /******************************************************
  2. IMNEXT.CPP
  3. Contains definitions for global variables and
  4. functions used for Internet Mail and News setup.
  5. * Microsoft Confidential
  6. * Copyright (c) Microsoft Corporation 1992-1996
  7. * All rights reserved
  8. 9/30/96 valdonb Created
  9. ******************************************************/
  10. #include "wizard.h"
  11. #include "initguid.h" // Make DEFINE_GUID declare an instance of each GUID
  12. #include "icwextsn.h"
  13. #include "imnext.h"
  14. #include "inetcfg.h"
  15. #include <icwcfg.h>
  16. IICWApprentice *gpImnApprentice = NULL; // Mail/News account manager object
  17. //+----------------------------------------------------------------------------
  18. //
  19. // Function LoadAcctMgrUI
  20. //
  21. // Synopsis Loads in the Account Manager's apprentice pages for configuring
  22. // accounts (mail, news, directory service/LDAP).
  23. //
  24. // If the UI has previously been loaded, the function will simply
  25. // update the Next and Back pages for the apprentice.
  26. //
  27. // Uses global variable g_fAcctMgrUILoaded.
  28. //
  29. //
  30. // Arguments hWizHWND -- HWND of main property sheet
  31. // uPrevDlgID -- Dialog ID apprentice should go to when user leaves
  32. // apprentice by clicking Back
  33. // uNextDlgID -- Dialog ID apprentice should go to when user leaves
  34. // apprentice by clicking Next
  35. // dwFlags -- Flags variable that should be passed to
  36. // IICWApprentice::AddWizardPages
  37. //
  38. //
  39. // Returns TRUE if all went well
  40. // FALSE otherwise
  41. //
  42. // History 4/23/97 jmazner created
  43. //
  44. //-----------------------------------------------------------------------------
  45. BOOL LoadAcctMgrUI( HWND hWizHWND, UINT uPrevDlgID, UINT uNextDlgID, DWORD dwFlags )
  46. {
  47. HRESULT hResult = E_NOTIMPL;
  48. // If we should not run Internet Mail and New setup, then just return FALSE
  49. if (gpWizardState->dwRunFlags & RSW_NOIMN)
  50. return FALSE;
  51. if( g_fAcctMgrUILoaded )
  52. {
  53. ASSERT( g_pCICWExtension );
  54. ASSERT( gpImnApprentice );
  55. DEBUGMSG("LoadAcctMgrUI: UI already loaded, just reset first (%d) and last (%d) pages",
  56. uPrevDlgID, uNextDlgID);
  57. // If We are ICW, the Mail account manager is our last page.
  58. if (g_fIsICW)
  59. uNextDlgID = g_uExternUINext;
  60. hResult = gpImnApprentice->SetPrevNextPage( uPrevDlgID, uNextDlgID );
  61. goto LoadAcctMgrUIExit;
  62. }
  63. if( !hWizHWND )
  64. {
  65. DEBUGMSG("LoadAcctMgrUI got a NULL hWizHWND!");
  66. return FALSE;
  67. }
  68. if( gpImnApprentice )
  69. {
  70. if( NULL == g_pCICWExtension )
  71. {
  72. DEBUGMSG("Instantiating ICWExtension and using it to initialize Acct Mgr's IICWApprentice");
  73. g_pCICWExtension = new( CICWExtension );
  74. g_pCICWExtension->AddRef();
  75. g_pCICWExtension->m_hWizardHWND = hWizHWND;
  76. gpImnApprentice->Initialize( g_pCICWExtension );
  77. }
  78. hResult = gpImnApprentice->AddWizardPages(dwFlags);
  79. if( !SUCCEEDED(hResult) )
  80. {
  81. goto LoadAcctMgrUIExit;
  82. }
  83. // If We are ICW, the Mail account manager is our last page.
  84. if (g_fIsICW)
  85. uNextDlgID = g_uExternUINext;
  86. hResult = gpImnApprentice->SetPrevNextPage( uPrevDlgID, uNextDlgID );
  87. }
  88. LoadAcctMgrUIExit:
  89. if( SUCCEEDED(hResult) )
  90. {
  91. g_fAcctMgrUILoaded = TRUE;
  92. return TRUE;
  93. }
  94. else
  95. {
  96. DEBUGMSG("LoadAcctMgrUI failed with (hex) hresult %x", hResult);
  97. return FALSE;
  98. }
  99. }
  100. /****
  101. *
  102. * The rest of the functions in this file are no longer used since switching to
  103. * the apprentice/wizard model
  104. *
  105. * 4/23/97 jmazner Olympus #3136
  106. /*****************************************************************
  107. NAME: InitAccountList
  108. SYNOPSIS: Fills a list box with the account names in the account list.
  109. PARAMETERS:
  110. hLB HWND to the list box to be filled
  111. pEnumAccts Pointer the the account list
  112. accttype Type of accounts in the account list
  113. RETURN: none
  114. *****************************************************************/
  115. /**
  116. VOID InitAccountList(HWND hLB, IImnEnumAccounts *pEnumAccts, ACCTTYPE accttype)
  117. {
  118. IImnAccount *pAcct = NULL;
  119. CHAR szDefAcct[CCHMAX_ACCOUNT_NAME+1];
  120. CHAR szBuf[CCHMAX_ACCOUNT_NAME+1];
  121. HRESULT hr;
  122. DWORD index;
  123. BOOL fSelected = FALSE;
  124. ListBox_ResetContent(hLB);
  125. if (NULL == pEnumAccts)
  126. return;
  127. szDefAcct[0] = '\0';
  128. // Get the default so we can highlight it in the list
  129. gpImnAcctMgr->GetDefaultAccountName(accttype,szDefAcct,CCHMAX_ACCOUNT_NAME);
  130. // 2/20/97 jmazner Olympus #262
  131. // Reset back to the first acct. so that when we walk through the GetNext loop,
  132. // we're sure to get every account
  133. pEnumAccts->Reset();
  134. // Populate the account list box
  135. while (SUCCEEDED(pEnumAccts->GetNext(&pAcct)))
  136. {
  137. hr = pAcct->GetPropSz(AP_ACCOUNT_NAME,szBuf,sizeof(szBuf));
  138. if (SUCCEEDED(hr))
  139. {
  140. index = ListBox_AddString(hLB,szBuf);
  141. if (!lstrcmp(szBuf,szDefAcct))
  142. {
  143. fSelected = TRUE;
  144. ListBox_SetCurSel(hLB, index);
  145. }
  146. }
  147. pAcct->Release();
  148. pAcct = NULL;
  149. }
  150. // If nothing was selected as the default,
  151. // select the first in the list
  152. if (!fSelected)
  153. // oops, SetSel is for multiple choice list boxes
  154. // we want SetCurSel
  155. //ListBox_SetSel(hLB, TRUE, 0);
  156. ListBox_SetCurSel(hLB, 0);
  157. }
  158. **/
  159. /*****************************************************************
  160. NAME: GetAccount
  161. SYNOPSIS: Gets a mail or news account by name and sets the
  162. property information structure.
  163. PARAMETERS:
  164. szAcctName Name of the account to load
  165. accttype Type of account to load
  166. RETURN: BOOL TRUE if account was found and loaded
  167. FALSE if not found
  168. *****************************************************************/
  169. /**
  170. BOOL GetAccount(LPSTR szAcctName, ACCTTYPE accttype)
  171. {
  172. IImnAccount *pAcct = NULL;
  173. HRESULT hr;
  174. DWORD dwTemp = 0;
  175. DWORD dwServerTypes = 0;
  176. BOOL fRet = TRUE;
  177. if (NULL == gpImnAcctMgr)
  178. return FALSE;
  179. // Get the account information and move it into our
  180. // structure.
  181. hr = gpImnAcctMgr->FindAccount(AP_ACCOUNT_NAME,szAcctName,
  182. &pAcct);
  183. if (FAILED(hr) || !pAcct)
  184. return FALSE;
  185. // 12/3/96 jmazner Normandy #8504
  186. // 2/7/96 jmazner Athena changed things around a bit
  187. //pAcct->GetPropDw(AP_SERVER_TYPES, &dwServerTypes);
  188. pAcct->GetServerTypes( &dwServerTypes );
  189. // 2/17/96 jmazner Olympus #1063
  190. // need to clearAccount before loading new stuff
  191. ClearUserInfo( gpUserInfo, accttype);
  192. switch( accttype )
  193. {
  194. case ACCT_NEWS:
  195. // 12/16/96 jmazner This is not a valid assert; sometimes we'll load
  196. // in an account for mail, and later check whether it also has news
  197. // Also, the macro causes a GPF in retail builds...
  198. //ASSERT( dwServerTypes & SRV_NNTP );
  199. // 2/12/97 jmazner Athena changed things around in their build 0511;
  200. // one of the changes is that now an account can only
  201. // hold one ACCT type (see Normandy #13710)
  202. if( !(SRV_NNTP & dwServerTypes) )
  203. {
  204. fRet = FALSE;
  205. goto GetAccountExit;
  206. }
  207. pAcct->GetPropSz(AP_NNTP_DISPLAY_NAME, gpUserInfo->inc.szNNTPName, MAX_EMAIL_NAME);
  208. pAcct->GetPropSz(AP_NNTP_EMAIL_ADDRESS, gpUserInfo->inc.szNNTPAddress, MAX_EMAIL_ADDRESS);
  209. pAcct->GetPropSz(AP_NNTP_USERNAME, gpUserInfo->inc.szNNTPLogonName, MAX_LOGON_NAME);
  210. pAcct->GetPropSz(AP_NNTP_PASSWORD, gpUserInfo->inc.szNNTPLogonPassword, MAX_LOGON_PASSWORD);
  211. pAcct->GetPropSz(AP_NNTP_SERVER, gpUserInfo->inc.szNNTPServer, MAX_SERVER_NAME);
  212. // 12/17/96 jmazner Normandy 12871
  213. //pAcct->GetPropDw(AP_NNTP_USE_SICILY, &dwTemp);
  214. //gpUserInfo->fNewsAccount = !(BOOL)dwTemp;
  215. pAcct->GetPropDw(AP_NNTP_USE_SICILY, (DWORD *)&(gpUserInfo->inc.fNewsLogonSPA));
  216. gpUserInfo->fNewsLogon = (gpUserInfo->inc.fNewsLogonSPA || gpUserInfo->inc.szNNTPLogonName[0]);
  217. break;
  218. case ACCT_MAIL:
  219. if( !( (SRV_SMTP & dwServerTypes) ||
  220. (SRV_POP3 & dwServerTypes) ||
  221. (SRV_IMAP & dwServerTypes) ))
  222. {
  223. fRet = FALSE;
  224. goto GetAccountExit;
  225. }
  226. pAcct->GetPropSz(AP_SMTP_SERVER, gpUserInfo->inc.szSMTPServer, MAX_SERVER_NAME);
  227. pAcct->GetPropSz(AP_SMTP_DISPLAY_NAME, gpUserInfo->inc.szEMailName, MAX_EMAIL_NAME);
  228. pAcct->GetPropSz(AP_SMTP_EMAIL_ADDRESS, gpUserInfo->inc.szEMailAddress, MAX_EMAIL_ADDRESS);
  229. if( dwServerTypes & SRV_POP3 )
  230. {
  231. pAcct->GetPropSz(AP_POP3_USERNAME, gpUserInfo->inc.szIncomingMailLogonName, MAX_LOGON_NAME);
  232. pAcct->GetPropSz(AP_POP3_PASSWORD, gpUserInfo->inc.szIncomingMailLogonPassword, MAX_LOGON_PASSWORD);
  233. pAcct->GetPropSz(AP_POP3_SERVER, gpUserInfo->inc.szIncomingMailServer, MAX_SERVER_NAME);
  234. pAcct->GetPropDw(AP_POP3_USE_SICILY, (DWORD *)&(gpUserInfo->inc.fMailLogonSPA));
  235. gpUserInfo->inc.iIncomingProtocol = SRV_POP3;
  236. }
  237. else
  238. {
  239. pAcct->GetPropSz(AP_IMAP_USERNAME, gpUserInfo->inc.szIncomingMailLogonName, MAX_LOGON_NAME);
  240. pAcct->GetPropSz(AP_IMAP_PASSWORD, gpUserInfo->inc.szIncomingMailLogonPassword, MAX_LOGON_PASSWORD);
  241. pAcct->GetPropSz(AP_IMAP_SERVER, gpUserInfo->inc.szIncomingMailServer, MAX_SERVER_NAME);
  242. pAcct->GetPropDw(AP_IMAP_USE_SICILY, (DWORD *)&(gpUserInfo->inc.fMailLogonSPA));
  243. gpUserInfo->inc.iIncomingProtocol = SRV_IMAP;
  244. }
  245. break;
  246. case ACCT_DIR_SERV:
  247. if( !(SRV_LDAP & dwServerTypes) )
  248. {
  249. fRet = FALSE;
  250. goto GetAccountExit;
  251. }
  252. {
  253. DWORD dwLDAPAuth = 0;
  254. pAcct->GetPropDw(AP_LDAP_AUTHENTICATION, &dwLDAPAuth);
  255. switch( dwLDAPAuth )
  256. {
  257. case LDAP_AUTH_ANONYMOUS:
  258. gpUserInfo->inc.fLDAPLogonSPA = FALSE;
  259. gpUserInfo->fLDAPLogon = FALSE;
  260. break;
  261. case LDAP_AUTH_MEMBER_SYSTEM:
  262. gpUserInfo->inc.fLDAPLogonSPA = TRUE;
  263. gpUserInfo->fLDAPLogon = TRUE;
  264. break;
  265. case LDAP_AUTH_PASSWORD:
  266. gpUserInfo->inc.fLDAPLogonSPA = FALSE;
  267. gpUserInfo->fLDAPLogon = TRUE;
  268. pAcct->GetPropSz(AP_LDAP_USERNAME, gpUserInfo->inc.szLDAPLogonName, MAX_LOGON_NAME);
  269. pAcct->GetPropSz(AP_LDAP_PASSWORD, gpUserInfo->inc.szLDAPLogonPassword, MAX_LOGON_PASSWORD);
  270. break;
  271. }
  272. }
  273. pAcct->GetPropSz(AP_LDAP_SERVER, gpUserInfo->inc.szLDAPServer, MAX_SERVER_NAME);
  274. pAcct->GetPropDw(AP_LDAP_RESOLVE_FLAG, (DWORD *)&(gpUserInfo->inc.fLDAPResolve));
  275. break;
  276. default:
  277. fRet = FALSE;
  278. break;
  279. }
  280. GetAccountExit:
  281. pAcct->Release();
  282. pAcct = NULL;
  283. return fRet;
  284. }
  285. **/
  286. /*****************************************************************
  287. NAME: ValidateAccountName
  288. SYNOPSIS: Validates that a string can be used as an account
  289. name. It will also check if the account exists and
  290. load the information by calling GetAccount.
  291. PARAMETERS:
  292. szAcctName String to use for the name of the account
  293. accttype Type of account
  294. RETURN: DWORD 0 if successful
  295. Resource id of error string if an error
  296. occurs.
  297. *****************************************************************/
  298. /**
  299. DWORD ValidateAccountName(LPSTR szAcctName, ACCTTYPE accttype)
  300. {
  301. LPSTR sz = szAcctName;
  302. BOOL fBlank = TRUE;
  303. // Make sure the name is not blank and
  304. // does not contain a backslash
  305. while (*sz && '\\' != *sz)
  306. {
  307. if (' ' != *sz)
  308. fBlank = FALSE;
  309. sz++;
  310. }
  311. // 12/17/96 jmazner Normandy #12851
  312. // check for backslash first to correctly handle the string "\"
  313. if ('\\' == *sz)
  314. return IDS_ERRInvalidAcctName;
  315. if (fBlank)
  316. return IDS_NEED_ACCTNAME;
  317. // Check if this account already exists
  318. // 2/10/97 jmazner Normandy #13710
  319. // If the account already exists, notify the user and force a new acct name.
  320. if ( AccountNameExists(szAcctName) )
  321. {
  322. return IDS_DUP_ACCTNAME;
  323. }
  324. return ERROR_SUCCESS;
  325. }
  326. **/
  327. /*******************************************************************
  328. NAME: SaveAccount
  329. SYNOPSIS: Save the changes to the mail or news account.
  330. PARAMETERS:
  331. accttype Type of account to save (ACCT_SMTP or ACCT_NNTP)
  332. bSetAsDefault Set this account to be the default
  333. RETURN: BOOL TRUE if changes saved
  334. FALSE if an error occured
  335. ********************************************************************/
  336. /**
  337. BOOL SaveAccount(ACCTTYPE accttype, BOOL fSetAsDefault)
  338. {
  339. IImnAccount *pAcct = NULL;
  340. LPSTR lpszAcctName = NULL;
  341. DWORD dwConnectionType;
  342. BOOL fRet = FALSE;
  343. HRESULT hr;
  344. ASSERT (gpImnAcctMgr);
  345. if (NULL == gpImnAcctMgr)
  346. goto CommitAccountExit;
  347. dwConnectionType = gpUserInfo->fConnectOverLAN ? 0L : 2L;
  348. switch( accttype )
  349. {
  350. case ACCT_NEWS:
  351. lpszAcctName = gpUserInfo->szNewsAcctName;
  352. break;
  353. case ACCT_MAIL:
  354. lpszAcctName = gpUserInfo->szMailAcctName;
  355. break;
  356. case ACCT_DIR_SERV:
  357. lpszAcctName = gpUserInfo->szDirServiceName;
  358. break;
  359. }
  360. // lpszAcctName = gpUserInfo->szNewsAcctName;
  361. //else
  362. // lpszAcctName = gpUserInfo->szMailAcctName;
  363. // First try and get existing account info to change
  364. hr = gpImnAcctMgr->FindAccount(AP_ACCOUNT_NAME,
  365. lpszAcctName,
  366. &pAcct);
  367. if (FAILED(hr) || !pAcct)
  368. {
  369. // Create a new account
  370. hr = gpImnAcctMgr->CreateAccountObject(accttype, &pAcct);
  371. if (FAILED(hr) || !pAcct)
  372. goto CommitAccountExit;
  373. }
  374. // Fill in the account information that we have
  375. pAcct->SetPropSz(AP_ACCOUNT_NAME, lpszAcctName);
  376. //pAcct->SetPropSz(AP_RAS_CONNECTOID, gpUserInfo->szISPName);
  377. //pAcct->SetPropDw(AP_RAS_CONNECTION_TYPE, dwConnectionType);
  378. switch( accttype )
  379. {
  380. case ACCT_NEWS:
  381. pAcct->SetPropSz(AP_RAS_CONNECTOID, gpUserInfo->szISPName);
  382. pAcct->SetPropDw(AP_RAS_CONNECTION_TYPE, dwConnectionType);
  383. pAcct->SetPropSz(AP_NNTP_DISPLAY_NAME, gpUserInfo->inc.szNNTPName);
  384. pAcct->SetPropSz(AP_NNTP_EMAIL_ADDRESS, gpUserInfo->inc.szNNTPAddress);
  385. // 12/17/96 jmazner Normandy #12871
  386. //pAcct->SetPropDw(AP_NNTP_USE_SICILY, gpUserInfo->fNewsLogon && !gpUserInfo->fNewsAccount);
  387. pAcct->SetPropDw(AP_NNTP_USE_SICILY, gpUserInfo->inc.fNewsLogonSPA);
  388. if (gpUserInfo->fNewsLogon && !gpUserInfo->inc.fNewsLogonSPA)
  389. {
  390. pAcct->SetPropSz(AP_NNTP_USERNAME, gpUserInfo->inc.szNNTPLogonName);
  391. pAcct->SetPropSz(AP_NNTP_PASSWORD, gpUserInfo->inc.szNNTPLogonPassword);
  392. }
  393. else
  394. {
  395. // 1/15/96 jmazner Normandy #13162
  396. // clear out logon name and password, so that if we load in this account
  397. // in the future, we won't be confused about whether to set fNewsLogon
  398. pAcct->SetProp(AP_NNTP_USERNAME, NULL, 0);
  399. pAcct->SetProp(AP_NNTP_PASSWORD, NULL, 0);
  400. }
  401. pAcct->SetPropSz(AP_NNTP_SERVER, gpUserInfo->inc.szNNTPServer);
  402. break;
  403. case ACCT_MAIL:
  404. pAcct->SetPropSz(AP_RAS_CONNECTOID, gpUserInfo->szISPName);
  405. pAcct->SetPropDw(AP_RAS_CONNECTION_TYPE, dwConnectionType);
  406. pAcct->SetPropSz(AP_SMTP_SERVER, gpUserInfo->inc.szSMTPServer);
  407. pAcct->SetPropSz(AP_SMTP_DISPLAY_NAME, gpUserInfo->inc.szEMailName);
  408. pAcct->SetPropSz(AP_SMTP_EMAIL_ADDRESS, gpUserInfo->inc.szEMailAddress);
  409. // 12/3/96 jmazner Normandy #8504
  410. if( SRV_POP3 == gpUserInfo->inc.iIncomingProtocol )
  411. {
  412. pAcct->SetPropSz(AP_POP3_SERVER, gpUserInfo->inc.szIncomingMailServer);
  413. // 12/17/96 jmazner Normandy #12871
  414. pAcct->SetPropDw(AP_POP3_USE_SICILY, gpUserInfo->inc.fMailLogonSPA);
  415. if( !gpUserInfo->inc.fMailLogonSPA )
  416. {
  417. pAcct->SetPropSz(AP_POP3_USERNAME, gpUserInfo->inc.szIncomingMailLogonName);
  418. pAcct->SetPropSz(AP_POP3_PASSWORD, gpUserInfo->inc.szIncomingMailLogonPassword);
  419. }
  420. pAcct->SetProp(AP_IMAP_USERNAME, NULL, 0);
  421. pAcct->SetProp(AP_IMAP_SERVER, NULL, 0);
  422. pAcct->SetProp(AP_IMAP_PASSWORD, NULL, 0);
  423. }
  424. else
  425. {
  426. pAcct->SetPropSz(AP_IMAP_SERVER, gpUserInfo->inc.szIncomingMailServer);
  427. // 12/17/96 jmazner Normandy #12871
  428. pAcct->SetPropDw(AP_IMAP_USE_SICILY, gpUserInfo->inc.fMailLogonSPA);
  429. if( !gpUserInfo->inc.fMailLogonSPA )
  430. {
  431. pAcct->SetPropSz(AP_IMAP_USERNAME, gpUserInfo->inc.szIncomingMailLogonName);
  432. pAcct->SetPropSz(AP_IMAP_PASSWORD, gpUserInfo->inc.szIncomingMailLogonPassword);
  433. }
  434. pAcct->SetProp(AP_POP3_USERNAME, NULL, 0);
  435. pAcct->SetProp(AP_POP3_SERVER, NULL, 0);
  436. pAcct->SetProp(AP_POP3_PASSWORD, NULL, 0);
  437. }
  438. break;
  439. case ACCT_DIR_SERV:
  440. pAcct->SetPropSz(AP_LDAP_SERVER, gpUserInfo->inc.szLDAPServer);
  441. pAcct->SetPropDw(AP_LDAP_RESOLVE_FLAG, gpUserInfo->inc.fLDAPResolve);
  442. if( gpUserInfo->inc.szLDAPLogonName[0] && gpUserInfo->fLDAPLogon )
  443. {
  444. // if we have a user name, then we're using
  445. // LDAP_AUTH_PASSWORD
  446. ASSERT( !gpUserInfo->inc.fLDAPLogonSPA );
  447. pAcct->SetPropSz(AP_LDAP_USERNAME, gpUserInfo->inc.szLDAPLogonName);
  448. pAcct->SetPropSz(AP_LDAP_PASSWORD, gpUserInfo->inc.szLDAPLogonPassword);
  449. pAcct->SetPropDw(AP_LDAP_AUTHENTICATION, LDAP_AUTH_PASSWORD);
  450. }
  451. else
  452. {
  453. //we know there's no username/password, so clear out those fields
  454. pAcct->SetProp(AP_LDAP_USERNAME, NULL, 0);
  455. pAcct->SetProp(AP_LDAP_PASSWORD, NULL, 0);
  456. //now determine whether there's no logon required, or if we're using SPA
  457. if( gpUserInfo->inc.fLDAPLogonSPA )
  458. {
  459. pAcct->SetPropDw(AP_LDAP_AUTHENTICATION, LDAP_AUTH_MEMBER_SYSTEM);
  460. }
  461. else
  462. {
  463. pAcct->SetPropDw(AP_LDAP_AUTHENTICATION, LDAP_AUTH_ANONYMOUS);
  464. }
  465. }
  466. break;
  467. }
  468. // Save the changes
  469. hr = pAcct->SaveChanges();
  470. if (FAILED(hr))
  471. goto CommitAccountExit;
  472. if (fSetAsDefault)
  473. {
  474. // Set this account as the default
  475. // Ignore failure since it isn't fatal
  476. pAcct->SetAsDefault();
  477. }
  478. // If we need to return the settings, put them in the global struct
  479. if (gpMailNewsInfo && ( (ACCT_MAIL==accttype) || (ACCT_NEWS==accttype) ) )
  480. {
  481. ASSERT(sizeof(*gpMailNewsInfo) == gpMailNewsInfo->dwSize);
  482. if (ACCT_NEWS == accttype)
  483. {
  484. lstrcpy(gpMailNewsInfo->szAccountName, gpUserInfo->szNewsAcctName);
  485. lstrcpy(gpMailNewsInfo->szUserName, gpUserInfo->inc.szNNTPLogonName);
  486. lstrcpy(gpMailNewsInfo->szPassword, gpUserInfo->inc.szNNTPLogonPassword);
  487. lstrcpy(gpMailNewsInfo->szNNTPServer, gpUserInfo->inc.szNNTPServer);
  488. lstrcpy(gpMailNewsInfo->szDisplayName, gpUserInfo->inc.szNNTPName);
  489. lstrcpy(gpMailNewsInfo->szEmailAddress, gpUserInfo->inc.szNNTPAddress);
  490. // 12/17/96 jmazner Normandy #12871
  491. // fNewsLogon and fNewsAccount flags have been superceeded by fNewsLogonSPA
  492. //gpMailNewsInfo->fUseSicily = (gpUserInfo->fNewsLogon && !gpUserInfo->fNewsAccount);
  493. gpMailNewsInfo->fUseSicily = (gpUserInfo->inc.fNewsLogonSPA);
  494. }
  495. else
  496. {
  497. lstrcpy(gpMailNewsInfo->szAccountName, gpUserInfo->szMailAcctName);
  498. lstrcpy(gpMailNewsInfo->szUserName, gpUserInfo->inc.szIncomingMailLogonName);
  499. lstrcpy(gpMailNewsInfo->szPassword, gpUserInfo->inc.szIncomingMailLogonPassword);
  500. lstrcpy(gpMailNewsInfo->szSMTPServer, gpUserInfo->inc.szSMTPServer);
  501. if( SRV_POP3 == gpUserInfo->inc.iIncomingProtocol )
  502. lstrcpy(gpMailNewsInfo->szPOP3Server, gpUserInfo->inc.szIncomingMailServer);
  503. else
  504. lstrcpy(gpMailNewsInfo->szIMAPServer, gpUserInfo->inc.szIncomingMailServer);
  505. lstrcpy(gpMailNewsInfo->szDisplayName, gpUserInfo->inc.szEMailName);
  506. lstrcpy(gpMailNewsInfo->szEmailAddress, gpUserInfo->inc.szEMailAddress);
  507. gpMailNewsInfo->fUseSicily = (gpUserInfo->inc.fMailLogonSPA);
  508. }
  509. gpMailNewsInfo->dwConnectionType = dwConnectionType;
  510. lstrcpy(gpMailNewsInfo->szConnectoid, gpUserInfo->szISPName);
  511. }
  512. else if( gpDirServiceInfo && (ACCT_DIR_SERV == accttype) )
  513. {
  514. ASSERT(sizeof(*gpDirServiceInfo) == gpDirServiceInfo->dwSize);
  515. lstrcpy(gpDirServiceInfo->szServiceName, gpUserInfo->szDirServiceName);
  516. lstrcpy(gpDirServiceInfo->szUserName, gpUserInfo->inc.szLDAPLogonName);
  517. lstrcpy(gpDirServiceInfo->szPassword, gpUserInfo->inc.szLDAPLogonPassword);
  518. lstrcpy(gpDirServiceInfo->szLDAPServer, gpUserInfo->inc.szLDAPServer);
  519. gpDirServiceInfo->fUseSicily = (gpUserInfo->inc.fMailLogonSPA);
  520. gpDirServiceInfo->fLDAPResolve = (gpUserInfo->inc.fLDAPResolve);
  521. }
  522. fRet = TRUE;
  523. CommitAccountExit:
  524. if (pAcct)
  525. {
  526. pAcct->Release();
  527. pAcct = NULL;
  528. }
  529. return fRet;
  530. }
  531. **/
  532. /*****************************************************************
  533. NAME: IsStringWhiteSpaceOnly
  534. SYNOPSIS: Checks whether a string has non space characters
  535. PARAMETERS:
  536. szString String to check
  537. RETURN: BOOL TRUE if no characters other than ' '
  538. FALSE otherwise
  539. *****************************************************************/
  540. /**
  541. BOOL IsStringWhiteSpaceOnly(LPSTR szString)
  542. {
  543. LPSTR sz = szString;
  544. while (*sz)
  545. {
  546. if (' ' != *sz)
  547. return FALSE;
  548. sz++;
  549. }
  550. return TRUE;
  551. }
  552. **/
  553. /*****************************************************************
  554. NAME: AccountNameExists
  555. SYNOPSIS: Checks whether a given string is currently in use as
  556. an Account Manager (inetcomm) account name
  557. PARAMETERS:
  558. szAcctName Name of the account to load
  559. RETURN: BOOL TRUE if account name is in use
  560. FALSE if not
  561. HISTORY: 2/10/96 jmazner Created
  562. *****************************************************************/
  563. /**
  564. BOOL AccountNameExists(LPSTR szAcctName)
  565. {
  566. IImnAccount *pAcct = NULL;
  567. HRESULT hr;
  568. if (NULL == gpImnAcctMgr)
  569. return FALSE;
  570. if (NULL == szAcctName)
  571. return FALSE;
  572. hr = gpImnAcctMgr->FindAccount(AP_ACCOUNT_NAME,szAcctName,
  573. &pAcct);
  574. if (FAILED(hr) || !pAcct)
  575. {
  576. return FALSE;
  577. }
  578. else
  579. {
  580. pAcct->Release();
  581. pAcct = NULL;
  582. return TRUE;
  583. }
  584. }
  585. **/
  586. //+----------------------------------------------------------------------------
  587. //
  588. // Function ClearUserInfo
  589. //
  590. // Synopsis Sets the fields in a USERINFO struct to NULL.
  591. //
  592. // Arguments lpUserinfo - the struct to clear out.
  593. // accttype - determines whether Mail or News fields are cleared out
  594. //
  595. // Returns TRUE if all went well
  596. // FALSE otherwise
  597. //
  598. // History 1/21/96 jmazner created
  599. //
  600. //-----------------------------------------------------------------------------
  601. /**
  602. BOOL ClearUserInfo( USERINFO *lpUserInfo, ACCTTYPE accttype )
  603. {
  604. if( NULL == lpUserInfo )
  605. return FALSE;
  606. switch( accttype ){
  607. case ACCT_NEWS:
  608. //lpUserInfo->szNewsAcctName[0] = '\0';
  609. lpUserInfo->inc.szNNTPLogonName[0] = '\0';
  610. lpUserInfo->inc.szNNTPLogonPassword[0] = '\0';
  611. lpUserInfo->inc.szNNTPServer[0] = '\0';
  612. lpUserInfo->inc.szNNTPName[0] = '\0';
  613. lpUserInfo->inc.szNNTPAddress[0] = '\0';
  614. lpUserInfo->inc.fNewsLogonSPA = FALSE;
  615. lpUserInfo->fNewsLogon = FALSE;
  616. return TRUE;
  617. break;
  618. case ACCT_MAIL:
  619. //lpUserInfo->szMailAcctName[0] = '\0';
  620. lpUserInfo->inc.szIncomingMailLogonName[0] = '\0';
  621. lpUserInfo->inc.szIncomingMailLogonPassword[0] = '\0';
  622. lpUserInfo->inc.szSMTPServer[0] = '\0';
  623. lpUserInfo->inc.iIncomingProtocol = SRV_POP3;
  624. lpUserInfo->inc.szIncomingMailServer[0] = '\0';
  625. lpUserInfo->inc.szEMailName[0] = '\0';
  626. lpUserInfo->inc.szEMailAddress[0] = '\0';
  627. lpUserInfo->inc.fMailLogonSPA = FALSE;
  628. return TRUE;
  629. break;
  630. case ACCT_DIR_SERV:
  631. //lpUserInfo->szDirServiceName[0] = '\0';
  632. lpUserInfo->inc.szLDAPLogonName[0] = '\0';
  633. lpUserInfo->inc.szLDAPLogonPassword[0] = '\0';
  634. lpUserInfo->inc.szLDAPServer[0] = '\0';
  635. lpUserInfo->inc.fLDAPResolve = FALSE;
  636. lpUserInfo->inc.fLDAPLogonSPA = FALSE;
  637. lpUserInfo->fLDAPLogon = FALSE;
  638. default:
  639. return FALSE;
  640. break;
  641. }
  642. }
  643. **/