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.

1502 lines
40 KiB

  1. /*-----------------------------------------------------------------------------
  2. dialerr.cpp
  3. Handle Could Not Connect dialog
  4. Copyright (C) 1996 Microsoft Corporation
  5. All rights reserved.
  6. Authors:
  7. ChrisK ChrisKauffman
  8. History:
  9. 7/22/96 ChrisK Cleaned and formatted
  10. -----------------------------------------------------------------------------*/
  11. #include "pch.hpp"
  12. #include "resource.h"
  13. TCHAR szBuf256[256];
  14. #define VALID_INIT (m_pcRNA && m_hLineApp && m_pszPhoneNumber)
  15. TCHAR szValidPhoneCharacters[] = {TEXT("0123456789AaBbCcDdPpTtWw!@$ -.()+*#,&\0")};
  16. #ifndef WIN16
  17. int g_iMyMaxPhone = 0;
  18. #endif
  19. //+---------------------------------------------------------------------------
  20. //
  21. // Function: ProcessDBCS
  22. //
  23. // Synopsis: Converts control to use DBCS compatible font
  24. // Use this at the beginning of the dialog procedure
  25. //
  26. // Note that this is required due to a bug in Win95-J that prevents
  27. // it from properly mapping MS Shell Dlg. This hack is not needed
  28. // under winNT.
  29. //
  30. // Arguments: hwnd - Window handle of the dialog
  31. // cltID - ID of the control you want changed.
  32. //
  33. // Returns: ERROR_SUCCESS
  34. //
  35. // History: 4/31/97 a-frankh Created
  36. // 5/13/97 jmazner Stole from CM to use here
  37. //----------------------------------------------------------------------------
  38. void ProcessDBCS(HWND hDlg, int ctlID)
  39. {
  40. #if defined(WIN16)
  41. return;
  42. #else
  43. HFONT hFont = NULL;
  44. if( IsNT() )
  45. {
  46. return;
  47. }
  48. hFont = (HFONT) GetStockObject(DEFAULT_GUI_FONT);
  49. if (hFont == NULL)
  50. hFont = (HFONT) GetStockObject(SYSTEM_FONT);
  51. if (hFont != NULL)
  52. SendMessage(GetDlgItem(hDlg,ctlID), WM_SETFONT, (WPARAM) hFont, MAKELPARAM(TRUE, 0));
  53. #endif
  54. }
  55. //+---------------------------------------------------------------------------
  56. //
  57. // Function: IsSBCSString
  58. //
  59. // Synopsis: Walks through a string looking for DBCS characters
  60. //
  61. // Arguments: sz -- the string to check
  62. //
  63. // Returns: TRUE if no DBCS characters are found
  64. // FALSE otherwise
  65. //
  66. // History: 5/17/97 jmazner Stole from conn1 to use here
  67. // (Olympus #137)
  68. //----------------------------------------------------------------------------
  69. #if !defined(WIN16)
  70. BOOL IsSBCSString( LPCTSTR sz )
  71. {
  72. Assert(sz);
  73. #ifdef UNICODE
  74. // Check if the string contains only ASCII chars.
  75. int attrib = IS_TEXT_UNICODE_ASCII16 | IS_TEXT_UNICODE_CONTROLS;
  76. return (BOOL)IsTextUnicode((CONST LPVOID)sz, lstrlen(sz), &attrib);
  77. #else
  78. while( NULL != *sz )
  79. {
  80. if (IsDBCSLeadByte(*sz)) return FALSE;
  81. sz++;
  82. }
  83. return TRUE;
  84. #endif
  85. }
  86. #endif
  87. //+----------------------------------------------------------------------------
  88. //
  89. // Function: DialingErrorDialog
  90. //
  91. // Synopsis: Display and handle dialing error dialog, or as it is known
  92. // the "Could Not Connect" dialog
  93. //
  94. // Arguemtns: pED - pointer to error dialog data structure
  95. //
  96. // Returns: ERROR_USERNEXT - user hit redial
  97. // ERROR_USERCANCEL - user selected cancel
  98. // otherwise the function returns the appropriate error code
  99. //
  100. // History: 7/2/96 ChrisK Created
  101. //
  102. //-----------------------------------------------------------------------------
  103. HRESULT WINAPI DialingErrorDialog(PERRORDLGDATA pED)
  104. {
  105. HRESULT hr = ERROR_SUCCESS;
  106. CDialingErrorDlg *pcDEDlg = NULL;
  107. //
  108. // Validate parameters
  109. //
  110. if (!pED)
  111. {
  112. hr = ERROR_INVALID_PARAMETER;
  113. goto DialingErrorDialogExit;
  114. }
  115. if (pED->dwSize < sizeof(ERRORDLGDATA))
  116. {
  117. hr = ERROR_BUFFER_TOO_SMALL;
  118. goto DialingErrorDialogExit;
  119. }
  120. //
  121. // Initialize dialog
  122. //
  123. pcDEDlg = new CDialingErrorDlg;
  124. if (!pcDEDlg)
  125. {
  126. hr = ERROR_NOT_ENOUGH_MEMORY;
  127. goto DialingErrorDialogExit;
  128. }
  129. #ifndef WIN16
  130. if( IsNT() )
  131. {
  132. g_iMyMaxPhone = MAXPHONE_NT;
  133. }
  134. else
  135. {
  136. g_iMyMaxPhone = MAXPHONE_95;
  137. }
  138. #endif
  139. AssertMsg( (RAS_MaxPhoneNumber >= g_iMyMaxPhone), "RAS_MaxPhone < g_iMyMaxPhone" );
  140. //
  141. // Copy in data
  142. //
  143. pcDEDlg->m_hInst = pED->hInst;
  144. pcDEDlg->m_hwnd = pED->hParentHwnd;
  145. if (ERROR_SUCCESS != (hr = pcDEDlg->Init()))
  146. goto DialingErrorDialogExit;
  147. StrDup(&pcDEDlg->m_pszConnectoid,pED->pszRasEntryName);
  148. StrDup(&pcDEDlg->m_pszMessage,pED->pszMessage);
  149. StrDup(&pcDEDlg->m_pszDunFile,pED->pszDunFile);
  150. pcDEDlg->m_dwPhoneBook = pED->dwPhonebook;
  151. if (0 != pED->dwPhonebook)
  152. {
  153. if (pED->pdwCountryID) pcDEDlg->m_dwCountryID = *(pED->pdwCountryID);
  154. if (pED->pwStateID) pcDEDlg->m_wState = *(pED->pwStateID);
  155. pcDEDlg->m_bType = pED->bType;
  156. pcDEDlg->m_bMask = pED->bMask;
  157. }
  158. //
  159. // Help information, if one was not specified use the default trouble shooter
  160. //
  161. if (pcDEDlg->m_pszHelpFile)
  162. {
  163. StrDup(&pcDEDlg->m_pszHelpFile,pED->pszHelpFile);
  164. pcDEDlg->m_dwHelpID = pED->dwHelpID;
  165. }
  166. else
  167. {
  168. StrDup(&pcDEDlg->m_pszHelpFile,AUTODIAL_HELPFILE);
  169. pcDEDlg->m_dwHelpID = icw_trb;
  170. }
  171. //
  172. // Display dialog
  173. //
  174. hr = (HRESULT)DialogBoxParam(GetModuleHandle(TEXT("ICWDIAL")),MAKEINTRESOURCE(IDD_DIALERR),
  175. pED->hParentHwnd,GenericDlgProc,(LPARAM)pcDEDlg);
  176. //
  177. // Copy out data
  178. //
  179. if (pED->pszDunFile)
  180. GlobalFree(pED->pszDunFile);
  181. pED->pszDunFile = NULL;
  182. StrDup(&pED->pszDunFile,pcDEDlg->m_pszDunFile);
  183. DialingErrorDialogExit:
  184. if (pcDEDlg) delete pcDEDlg;
  185. pcDEDlg = NULL;
  186. return hr;
  187. }
  188. //+----------------------------------------------------------------------------
  189. //
  190. // Function: CDialingErrorDlg (constructor)
  191. //
  192. // Synopsis: initializes CDialingErrorDlg data members
  193. //
  194. // Arguements: none
  195. //
  196. // Returns: none
  197. //
  198. // History: 7/2/96 ChrisK Created
  199. //
  200. //-----------------------------------------------------------------------------
  201. CDialingErrorDlg::CDialingErrorDlg()
  202. {
  203. m_hInst = NULL;
  204. m_hwnd = NULL;
  205. m_pszConnectoid = NULL;
  206. m_pszDisplayable = NULL;
  207. m_pszPhoneNumber = NULL;
  208. m_pszMessage = NULL;
  209. m_pszDunFile = NULL;
  210. m_dwPhoneBook = 0;
  211. m_hLineApp = NULL;
  212. m_dwTapiDev = 0;
  213. m_dwAPIVersion = 0;
  214. m_pcRNA = NULL;
  215. m_lpRasDevInfo = NULL;
  216. m_dwNumDev = 0;
  217. m_pszHelpFile = NULL;
  218. m_dwHelpID = 0;
  219. m_dwCountryID = 0;
  220. m_wState = 0;
  221. m_bType = 0;
  222. m_bMask = 0;
  223. // Normandy 10612 - ChrisK
  224. // The dial error dialog will handle its own prompt to exit. The generic
  225. // dialog proc should not ask about this.
  226. m_bShouldAsk = FALSE;
  227. }
  228. //+----------------------------------------------------------------------------
  229. //
  230. // Function: ~CDialingErrorDlg (destructor)
  231. //
  232. // Synopsis: deallocated and cleans up data members
  233. //
  234. // Arguements: none
  235. //
  236. // Returns: none
  237. //
  238. // History: 7/2/96 ChrisK Created
  239. //
  240. //-----------------------------------------------------------------------------
  241. CDialingErrorDlg::~CDialingErrorDlg()
  242. {
  243. m_hInst = NULL;
  244. m_hwnd = NULL;
  245. if (m_pszConnectoid) GlobalFree(m_pszConnectoid);
  246. m_pszConnectoid = NULL;
  247. if (m_pszDisplayable) GlobalFree(m_pszDisplayable);
  248. m_pszDisplayable = NULL;
  249. if (m_pszPhoneNumber) GlobalFree(m_pszPhoneNumber);
  250. m_pszPhoneNumber = NULL;
  251. if (m_pszMessage) GlobalFree(m_pszMessage);
  252. m_pszMessage = NULL;
  253. if (m_pszDunFile) GlobalFree(m_pszDunFile);
  254. m_pszDunFile = NULL;
  255. m_dwPhoneBook = 0;
  256. if (m_hLineApp) lineShutdown(m_hLineApp);
  257. m_hLineApp = NULL;
  258. if (m_pszHelpFile) GlobalFree(m_pszHelpFile);
  259. m_pszHelpFile = NULL;
  260. m_dwHelpID = 0;
  261. m_dwNumDev = 0;
  262. m_dwTapiDev = 0;
  263. m_dwAPIVersion = 0;
  264. m_pcRNA = NULL;
  265. m_dwCountryID = 0;
  266. m_wState = 0;
  267. m_bType = 0;
  268. m_bMask = 0;
  269. }
  270. //+----------------------------------------------------------------------------
  271. //
  272. // Function: CDialingErrorDlg::Init
  273. //
  274. // Synopsis: Intialize data members that may fail. We need to return an
  275. // code for these cases and C++ constructors don't support this
  276. //
  277. // Arguments: none
  278. //
  279. // Returns: ERROR_SUCCESS - success
  280. // anything else indicates a failure
  281. //
  282. // History: 7/2/96 ChrisK Created
  283. //
  284. //-----------------------------------------------------------------------------
  285. HRESULT CDialingErrorDlg::Init()
  286. {
  287. HRESULT hr = ERROR_SUCCESS;
  288. LPLINEEXTENSIONID lpExtensionID = NULL;
  289. // Initialize RAS/RNA
  290. //
  291. m_pcRNA = new RNAAPI;
  292. if (!m_pcRNA)
  293. {
  294. hr = ERROR_NOT_ENOUGH_MEMORY;
  295. goto InitExit;
  296. }
  297. //
  298. // Initialize TAPI
  299. //
  300. hr = lineInitialize(&m_hLineApp,m_hInst,LineCallback,NULL,&m_dwNumDev);
  301. if (hr) goto InitExit;
  302. lpExtensionID = (LPLINEEXTENSIONID)GlobalAlloc(LPTR,sizeof(LINEEXTENSIONID));
  303. if (!lpExtensionID)
  304. {
  305. hr = ERROR_NOT_ENOUGH_MEMORY;
  306. goto InitExit;
  307. }
  308. hr = lineNegotiateAPIVersion(m_hLineApp, m_dwTapiDev, 0x00010004, 0x00010004,
  309. &m_dwAPIVersion, lpExtensionID);
  310. // 4/2/97 ChrisK Olypmus 2745
  311. while (ERROR_SUCCESS != hr && m_dwTapiDev < (m_dwNumDev - 1))
  312. {
  313. m_dwTapiDev++;
  314. hr = lineNegotiateAPIVersion(m_hLineApp, m_dwTapiDev, 0x00010004, 0x00010004,
  315. &m_dwAPIVersion, lpExtensionID);
  316. }
  317. if (hr != ERROR_SUCCESS)
  318. goto InitExit;
  319. // Initialize strings
  320. //
  321. //
  322. // 6/3/97 jmazner Olympus #4868
  323. // allocate enough space to hold maximum length phone numbers.
  324. //
  325. //m_pszPhoneNumber = (LPTSTR)GlobalAlloc(LPTR,MAX_CANONICAL_NUMBER);
  326. m_pszPhoneNumber = (LPTSTR)GlobalAlloc(GPTR,
  327. sizeof(TCHAR)*(MAX_CANONICAL_NUMBER>g_iMyMaxPhone?MAX_CANONICAL_NUMBER:g_iMyMaxPhone + 1));
  328. if (!m_pszPhoneNumber)
  329. {
  330. hr = ERROR_NOT_ENOUGH_MEMORY;
  331. goto InitExit;
  332. }
  333. InitExit:
  334. if (lpExtensionID) GlobalFree(lpExtensionID);
  335. return hr;
  336. }
  337. //+----------------------------------------------------------------------------
  338. //
  339. // Function: CDialingErrorDlg::DlgProc
  340. //
  341. // Synopsis: Handle messages sent to the dial error dialog
  342. //
  343. // Arguments: See Windows documentation for DialogProc's
  344. //
  345. // Returns: See Windows documentation for DialogProc's
  346. //
  347. // History: 7/8/96 ChrisK Created
  348. //
  349. //-----------------------------------------------------------------------------
  350. LRESULT CDialingErrorDlg::DlgProc(HWND hwnd, UINT uMsg, WPARAM wparam, LPARAM lparam, LRESULT lres)
  351. {
  352. LRESULT lRes = TRUE;
  353. HRESULT hr;
  354. // Normandy 11745
  355. // WORD wIDS;
  356. FARPROC fp = NULL;
  357. LPTSTR *ppPhoneNumbers;
  358. LPTSTR pszPhoneNumber;
  359. LPTSTR *ppDunFiles;
  360. LPTSTR pszDunFile = NULL;
  361. WORD wNumber;
  362. DWORD dwSize;
  363. LPRASENTRY lpRasEntry = NULL;
  364. LPRASDEVINFO lpRasDevInfo = NULL;
  365. DWORD dwRasEntrySize = 0;
  366. DWORD dwRasDevInfoSize = 0;
  367. LRESULT idx = 0;
  368. HINSTANCE hPHBKDll = NULL;
  369. LPTSTR lpszDialNumber = NULL;
  370. static BOOL bCheckDisplayable = FALSE;
  371. static BOOL bInitComplete = FALSE; //shows dialog init is complete - MKarki
  372. static BOOL bDlgPropEnabled = TRUE; //this flags holds state of Dialing Properties PushButton MKarki - (5/3/97/) Fix for Bug#3393
  373. //CSupport objSupportNum;
  374. //CHAR szSupportNumber[256];
  375. //CHAR szSupportMsg[256];
  376. static BOOL fUserEditedNumber = FALSE;
  377. Assert(NULL == m_hwnd || hwnd == m_hwnd);
  378. switch(uMsg)
  379. {
  380. case WM_INITDIALOG:
  381. Assert(VALID_INIT);
  382. //
  383. // This GOTO has been added to
  384. // display dialog again when phone numbers are
  385. // not valid - MKarki (4/21/97) Fix for Bug#2868 and 3461
  386. //
  387. ShowErrDlgAgain:
  388. m_hwnd = hwnd;
  389. // Set limit on phone number length
  390. //
  391. //
  392. // ChrisK Olympus 4851 6/9/97
  393. // The maximum length of this string needs to include space for a terminating
  394. // NULL
  395. //
  396. SendDlgItemMessage(hwnd,IDC_TEXTNUMBER,EM_SETLIMITTEXT,g_iMyMaxPhone - 1 ,0);
  397. #if 0
  398. //
  399. // Get the PSS Support Number now
  400. // MKarki (5/9/97) - Fix for Bug#267
  401. //
  402. if ((objSupportNum.GetSupportInfo(szSupportNumber)) == TRUE)
  403. {
  404. //
  405. // show the info
  406. //
  407. lstrcpy (szSupportMsg, GetSz (IDS_SUPPORTMSG));
  408. lstrcat (szSupportMsg, szSupportNumber);
  409. SetDlgItemText(hwnd,IDC_LBSUPPORTMSG, szSupportMsg);
  410. }
  411. #endif
  412. // Show the phone number
  413. //
  414. hr = GetDisplayableNumber();
  415. if (hr != ERROR_SUCCESS)
  416. {
  417. bCheckDisplayable = FALSE;
  418. SetDlgItemText(hwnd,IDC_TEXTNUMBER,m_pszPhoneNumber);
  419. } else {
  420. bCheckDisplayable = TRUE;
  421. SetDlgItemText(hwnd,IDC_TEXTNUMBER,m_pszDisplayable);
  422. }
  423. // Bug Normandy 5920
  424. // ChrisK, turns out we are calling MakeBold twice
  425. // MakeBold(GetDlgItem(m_hwnd,IDC_LBLTITLE),TRUE,FW_BOLD);
  426. // Fill in error message
  427. //
  428. if (m_pszMessage)
  429. SetDlgItemText(m_hwnd,IDC_LBLERRMSG,m_pszMessage);
  430. FillModems();
  431. //
  432. // Enable DBCS on win95-J systems
  433. //
  434. ProcessDBCS(m_hwnd, IDC_CMBMODEMS);
  435. ProcessDBCS(m_hwnd, IDC_TEXTNUMBER);
  436. // Set the focus to the Modems selection list
  437. //
  438. SetFocus(GetDlgItem(m_hwnd,IDC_CMBMODEMS));
  439. lRes = FALSE;
  440. SetForegroundWindow(m_hwnd);
  441. if (0 == m_dwPhoneBook)
  442. {
  443. //
  444. // 8/1/97 jmazner Olympus #11118
  445. // This ISP phonebook code is totally messed up, but we never use this
  446. // functionality anyways. Just make sure that the phonebook button is gone
  447. // unless someone explicitly asks for it.
  448. //
  449. //if (g_szISPFile[0] == '\0') // BUG: this condition should go away eventually.
  450. // see the comments with the phone book button code below.
  451. //{
  452. ShowWindow(GetDlgItem(hwnd,IDC_LBLPHONE),SW_HIDE);
  453. ShowWindow(GetDlgItem(hwnd,IDC_CMDPHONEBOOK),SW_HIDE);
  454. //}
  455. }
  456. //
  457. // we should disable the Dialing Properites PushButton
  458. // if we have changed the phone number once
  459. // MKarki (5/3/97) - Fix for Bug#3393
  460. //
  461. if (FALSE == bDlgPropEnabled)
  462. {
  463. EnableWindow (
  464. GetDlgItem (hwnd, IDC_CMDDIALPROP),
  465. FALSE
  466. );
  467. }
  468. //
  469. // This shows the INIT for the error dialog is complete
  470. // and we can start processing changes to Ph No. TEXTBOX
  471. // MKarki (4/24/97) - Fix for Bug#3511
  472. //
  473. bInitComplete = TRUE;
  474. break;
  475. case WM_CLOSE:
  476. if (MessageBox(m_hwnd,GetSz(IDS_WANTTOEXIT),GetSz(IDS_TITLE),
  477. MB_APPLMODAL | MB_ICONQUESTION | MB_YESNO | MB_DEFBUTTON2) == IDYES)
  478. EndDialog(m_hwnd,ERROR_USERCANCEL);
  479. break;
  480. case WM_DESTROY:
  481. ReleaseBold(GetDlgItem(m_hwnd,IDC_LBLTITLE));
  482. break;
  483. case WM_HELP:
  484. //
  485. // Chrisk Olympus 5130 5/27/97
  486. // Added support for F1 Help Key
  487. //
  488. if (m_pszHelpFile && *m_pszHelpFile)
  489. WinHelp(m_hwnd,m_pszHelpFile,HELP_CONTEXT,m_dwHelpID);
  490. break;
  491. case WM_COMMAND:
  492. switch(LOWORD(wparam))
  493. {
  494. //
  495. // We now processes changes to ph no. EDIT BOX
  496. // If there is anychange in the phone number we
  497. // disable to Dialing Properties Push Button
  498. // MKarki (3/22/97) - Fix for Bug #3511
  499. //
  500. case IDC_TEXTNUMBER:
  501. TCHAR lpszTempNumber[RAS_MaxPhoneNumber + 1];
  502. if ((HIWORD (wparam) == EN_CHANGE) && (bInitComplete == TRUE))
  503. {
  504. if ((GetDlgItemText (
  505. hwnd,
  506. IDC_TEXTNUMBER,
  507. lpszTempNumber,
  508. RAS_MaxPhoneNumber + 1
  509. )) &&
  510. (0 != lstrcmp(
  511. lpszTempNumber,
  512. bCheckDisplayable ? m_pszDisplayable : m_pszPhoneNumber)))
  513. {
  514. //
  515. // number has been modified by the user
  516. // hide the Dialing Properties Push Button
  517. //
  518. EnableWindow (
  519. GetDlgItem (hwnd, IDC_CMDDIALPROP),
  520. FALSE
  521. );
  522. //
  523. // save the state of the Dialing Properties PushButton
  524. // MKarki (5/3/97) - Fix for Bug#3393
  525. //
  526. bDlgPropEnabled = FALSE;
  527. //
  528. // 7/17/97 jmazner Olympus #8234
  529. //
  530. fUserEditedNumber = TRUE;
  531. }
  532. }
  533. break;
  534. case IDC_CMBMODEMS:
  535. if (HIWORD(wparam) == CBN_SELCHANGE)
  536. {
  537. idx = SendDlgItemMessage(m_hwnd,IDC_CMBMODEMS,CB_GETCURSEL,0,0);
  538. //
  539. // ChrisK Olympus 245 5/25/97
  540. // Get index of modem
  541. //
  542. idx = SendDlgItemMessage(m_hwnd,IDC_CMBMODEMS,CB_GETITEMDATA,idx,0);
  543. if (idx == CB_ERR) break;
  544. //
  545. // Get the connectoid
  546. //
  547. hr = ICWGetRasEntry(&lpRasEntry, &dwRasEntrySize, &lpRasDevInfo, &dwRasDevInfoSize, m_pszConnectoid);
  548. // UNDONE: Error Message
  549. //
  550. // Replace the device with a new one
  551. //
  552. lstrcpyn(lpRasEntry->szDeviceType,m_lpRasDevInfo[idx].szDeviceType,RAS_MaxDeviceType+1);
  553. lstrcpyn(lpRasEntry->szDeviceName,m_lpRasDevInfo[idx].szDeviceName,RAS_MaxDeviceName+1);
  554. if (lpRasDevInfo) GlobalFree(lpRasDevInfo);
  555. //
  556. // ChrisK Olympus 2461 5/30/97
  557. // Ras will take the modem settings from the RasEntry structure. If these are
  558. // not zeroed out, then they will corrupt the entry.
  559. //
  560. lpRasDevInfo = 0;
  561. dwRasDevInfoSize = 0;
  562. hr = m_pcRNA->RasSetEntryProperties(NULL,m_pszConnectoid,(LPBYTE)lpRasEntry,dwRasEntrySize,(LPBYTE)lpRasDevInfo,dwRasDevInfoSize);
  563. lpRasDevInfo = NULL; // Set back to NULL so we don't try and free later
  564. if (lpRasEntry) GlobalFree(lpRasEntry);
  565. lpRasEntry = NULL;
  566. // DO NOT FREE DEVINFO struct!!
  567. lpRasDevInfo = NULL;
  568. dwRasEntrySize = 0;
  569. dwRasDevInfoSize = 0;
  570. }
  571. break;
  572. case IDC_CMDNEXT:
  573. //
  574. // Redial button
  575. //
  576. // NOTE: This button is actually labeled "Redial"
  577. //
  578. lpszDialNumber = (LPTSTR)GlobalAlloc(GPTR, sizeof(TCHAR)*(g_iMyMaxPhone + 2));
  579. if (NULL == lpszDialNumber)
  580. {
  581. MsgBox(IDS_OUTOFMEMORY,MB_MYERROR);
  582. break;
  583. }
  584. // If the user has altered the phone number, make sure it can be used
  585. //
  586. if (fUserEditedNumber &&
  587. (GetDlgItemText(hwnd, IDC_TEXTNUMBER, lpszDialNumber, g_iMyMaxPhone + 1)) &&
  588. (0 != lstrcmp(lpszDialNumber, bCheckDisplayable ? m_pszDisplayable : m_pszPhoneNumber)))
  589. {
  590. //
  591. // return failure if we do not have a valid
  592. // phone number - MKarki 4/21/97 Bug# 2868 & 3461
  593. //
  594. hr = CreateDialAsIsConnectoid(lpszDialNumber);
  595. lRes = (hr == ERROR_SUCCESS);
  596. }
  597. if (lpszDialNumber)
  598. GlobalFree(lpszDialNumber);
  599. //
  600. // only end this dialog, if we have a valid
  601. // phone number, else refresh the same dialog
  602. // MKarki (4/21/97) Fix for Bug#2868 & 3461
  603. //
  604. if (lRes == TRUE)
  605. EndDialog(m_hwnd,ERROR_USERNEXT);
  606. else
  607. goto ShowErrDlgAgain;
  608. break;
  609. case IDC_CMDHELP:
  610. //
  611. // Help Button
  612. //
  613. if (m_pszHelpFile && *m_pszHelpFile)
  614. WinHelp(m_hwnd,m_pszHelpFile,HELP_CONTEXT,m_dwHelpID);
  615. break;
  616. case IDC_CMDCANCEL:
  617. //
  618. // Cancel button
  619. //
  620. if (MessageBox(m_hwnd,GetSz(IDS_WANTTOEXIT),GetSz(IDS_TITLE),
  621. MB_APPLMODAL | MB_ICONQUESTION | MB_YESNO | MB_DEFBUTTON2) == IDYES)
  622. EndDialog(m_hwnd,ERROR_USERCANCEL);
  623. break;
  624. case IDC_CMDDIALPROP:
  625. //
  626. // Dialing properties
  627. //
  628. // If the user has altered the phone number, make sure it can be used
  629. //
  630. lpszDialNumber = (LPTSTR)GlobalAlloc(GPTR, sizeof(TCHAR)*(g_iMyMaxPhone + 2));
  631. if (NULL == lpszDialNumber)
  632. {
  633. MsgBox(IDS_OUTOFMEMORY,MB_MYERROR);
  634. break;
  635. }
  636. if (fUserEditedNumber &&
  637. (GetDlgItemText(hwnd, IDC_TEXTNUMBER, lpszDialNumber, g_iMyMaxPhone + 1)) &&
  638. (0 != lstrcmp(lpszDialNumber, bCheckDisplayable ? m_pszDisplayable : m_pszPhoneNumber)))
  639. {
  640. hr = CreateDialAsIsConnectoid(lpszDialNumber);
  641. lRes = (hr == ERROR_SUCCESS);
  642. lstrcpy(m_pszPhoneNumber,lpszDialNumber);
  643. }
  644. // 11/25/96 jmazner Normandy #10294
  645. //ShowWindow(m_hwnd,SW_HIDE);
  646. EnableWindow(m_hwnd, FALSE);
  647. hr = lineTranslateDialog(m_hLineApp,m_dwTapiDev,m_dwAPIVersion,m_hwnd,m_pszPhoneNumber);
  648. hr = GetDisplayableNumber();
  649. if (hr != ERROR_SUCCESS)
  650. {
  651. bCheckDisplayable = FALSE;
  652. SetDlgItemText(hwnd,IDC_TEXTNUMBER,m_pszPhoneNumber);
  653. } else {
  654. bCheckDisplayable = TRUE;
  655. SetDlgItemText(hwnd,IDC_TEXTNUMBER,m_pszDisplayable);
  656. }
  657. if (lpszDialNumber)
  658. GlobalFree(lpszDialNumber);
  659. #if 0
  660. //
  661. // See if support number has changed
  662. // MKarki (5/9/97) - Fix for Bug#267
  663. //
  664. if ((objSupportNum.GetSupportInfo(szSupportNumber)) == TRUE)
  665. {
  666. //
  667. // show the info
  668. //
  669. lstrcpy (szSupportMsg, GetSz (IDS_SUPPORTMSG));
  670. lstrcat (szSupportMsg, szSupportNumber);
  671. SetDlgItemText(hwnd,IDC_LBSUPPORTMSG, szSupportMsg);
  672. }
  673. else
  674. {
  675. //
  676. // need to clear what is being displayed now
  677. //
  678. ZeroMemory ( szSupportMsg, sizeof (szSupportMsg));
  679. SetDlgItemText(hwnd,IDC_LBSUPPORTMSG, szSupportMsg);
  680. }
  681. #endif
  682. //ShowWindow(m_hwnd,SW_SHOW);
  683. EnableWindow(m_hwnd, TRUE);
  684. SetForegroundWindow(m_hwnd);
  685. //
  686. // 6/6/97 jmazner Olympus #4759
  687. //
  688. SetFocus(GetDlgItem(hwnd,IDC_CMDNEXT));
  689. break;
  690. case IDC_CMDPHONEBOOK:
  691. // BUG: This code will not work with the restructured dialer DLL.
  692. // The problem is the restructure DLL expects the call to have already
  693. // opened and load the phone book and just pass in the dwPhoneBook ID.
  694. // This code actually loads the phone book from the global ISP file.
  695. PhoneBookClick:
  696. if (!hPHBKDll)
  697. hPHBKDll = LoadLibrary(PHONEBOOK_LIBRARY);
  698. if (!hPHBKDll)
  699. {
  700. wsprintf(szBuf256,GetSz(IDS_CANTLOADINETCFG),PHONEBOOK_LIBRARY);
  701. MessageBox(m_hwnd,szBuf256,GetSz(IDS_TITLE),MB_MYERROR);
  702. } else {
  703. fp = GetProcAddress(hPHBKDll,PHBK_LOADAPI);
  704. if (!fp)
  705. MsgBox(IDS_CANTLOADPHBKAPI,MB_MYERROR);
  706. else
  707. {
  708. hr = ((PFNPHONEBOOKLOAD)fp)(GetISPFile(),&m_dwPhoneBook);
  709. if (hr != ERROR_SUCCESS)
  710. MsgBox(IDS_CANTINITPHONEBOOK,MB_MYERROR);
  711. else
  712. {
  713. fp = GetProcAddress(hPHBKDll,PHBK_DISPLAYAPI);
  714. if (!fp)
  715. MsgBox(IDS_CANTLOADPHBKAPI,MB_MYERROR);
  716. else {
  717. ppPhoneNumbers = &pszPhoneNumber;
  718. pszPhoneNumber = m_pszPhoneNumber;
  719. ppDunFiles = &pszDunFile;
  720. pszDunFile = (LPTSTR)GlobalAlloc(GPTR,sizeof(TCHAR)*(256));
  721. // BUGBUG: ignoring error condition
  722. Assert(pszDunFile);
  723. wNumber = 1;
  724. if (pszDunFile && pszPhoneNumber)
  725. {
  726. ShowWindow(m_hwnd,SW_HIDE);
  727. hr = ((PFNPHONEDISPLAY)fp)
  728. (m_dwPhoneBook,
  729. ppPhoneNumbers,
  730. ppDunFiles,
  731. &wNumber,
  732. &m_dwCountryID,
  733. &m_wState,
  734. m_bType,
  735. m_bMask,
  736. NULL,8);
  737. ShowWindow(m_hwnd,SW_SHOW);
  738. SetForegroundWindow(m_hwnd);
  739. if (hr == ERROR_SUCCESS)
  740. {
  741. m_pcRNA->RasDeleteEntry(NULL,m_pszConnectoid);
  742. // Make a new connectoid
  743. //
  744. hr = CreateEntryFromDUNFile(pszDunFile);
  745. if (hr != ERROR_SUCCESS)
  746. {
  747. MsgBox(IDS_INVALIDPN,MB_MYERROR);
  748. goto PhoneBookClick;
  749. break;
  750. }
  751. // Get the name of the connectoid
  752. //
  753. dwSize = sizeof(TCHAR)*RAS_MaxEntryName;
  754. hr = ReadSignUpReg((LPBYTE)m_pszConnectoid, &dwSize, REG_SZ, RASENTRYVALUENAME);
  755. if (hr != ERROR_SUCCESS)
  756. {
  757. MsgBox(IDS_CANTREADKEY,MB_MYERROR);
  758. break;
  759. }
  760. // Get the connectoid
  761. //
  762. hr = ICWGetRasEntry(&lpRasEntry, &dwRasEntrySize, &lpRasDevInfo, &dwRasDevInfoSize, m_pszConnectoid);
  763. // UNDONE: ERROR MESSAGE
  764. // Break up phone number
  765. //
  766. if (!BreakUpPhoneNumber(lpRasEntry, m_pszPhoneNumber))
  767. {
  768. MsgBox(IDS_INVALIDPN,MB_MYERROR);
  769. goto PhoneBookClick;
  770. break;
  771. }
  772. // Set Country ID
  773. //
  774. lpRasEntry->dwCountryID=m_dwCountryID;
  775. // Set connectoid with new phone number
  776. //
  777. hr = m_pcRNA->RasSetEntryProperties(NULL,m_pszConnectoid,
  778. (LPBYTE)lpRasEntry,dwRasEntrySize,
  779. (LPBYTE)lpRasDevInfo,dwRasDevInfoSize);
  780. // UNDONE: ERROR MESSAGE
  781. // Update display
  782. //
  783. hr = GetDisplayableNumber();
  784. if (hr != ERROR_SUCCESS)
  785. {
  786. bCheckDisplayable = FALSE;
  787. SetDlgItemText(hwnd,IDC_TEXTNUMBER,m_pszPhoneNumber);
  788. //
  789. // Now we can show the Dialing Properties Push Button again
  790. // MKarki (4/24/97) - Fix for Bug#3511
  791. //
  792. EnableWindow (GetDlgItem (hwnd, IDC_CMDDIALPROP), TRUE);
  793. //
  794. // save the state of the Dialing Properties PushButton
  795. // MKarki (5/3/97) - Fix for Bug#3393
  796. //
  797. bDlgPropEnabled = TRUE;
  798. } else {
  799. bCheckDisplayable = TRUE;
  800. SetDlgItemText(hwnd,IDC_TEXTNUMBER,m_pszDisplayable);
  801. }
  802. fUserEditedNumber = FALSE;
  803. }
  804. } else {
  805. MsgBox(IDS_OUTOFMEMORY,MB_MYERROR);
  806. }
  807. Assert(pszDunFile);
  808. GlobalFree(pszDunFile);
  809. pszDunFile = NULL;
  810. }
  811. }
  812. }
  813. }
  814. break;
  815. }
  816. break;
  817. default:
  818. lRes = FALSE;
  819. break;
  820. }
  821. return lRes;
  822. }
  823. // ############################################################################
  824. HRESULT CDialingErrorDlg::FillModems()
  825. {
  826. HRESULT hr = ERROR_SUCCESS;
  827. DWORD dwSize;
  828. DWORD idx;
  829. DWORD dwRasEntrySize = 0;
  830. DWORD dwRasDevInfoSize = 0;
  831. LPRASENTRY lpRasEntry=NULL;
  832. LPRASDEVINFO lpRasDevInfo=NULL;
  833. LRESULT lLast = 0;
  834. LPLINEDEVCAPS lpLineDevCaps = NULL;
  835. //
  836. // Get the connectoid
  837. //
  838. hr = ICWGetRasEntry(&lpRasEntry,&dwRasEntrySize, &lpRasDevInfo, &dwRasDevInfoSize, m_pszConnectoid);
  839. if (hr) goto FillModemExit;
  840. //
  841. // Get devices from RAS
  842. //
  843. m_lpRasDevInfo = (LPRASDEVINFO)GlobalAlloc(LPTR,sizeof(RASDEVINFO));
  844. if (!m_lpRasDevInfo)
  845. {
  846. hr = ERROR_NOT_ENOUGH_MEMORY;
  847. goto FillModemExit;
  848. }
  849. m_dwNumDev = 0;
  850. m_lpRasDevInfo->dwSize = sizeof(RASDEVINFO);
  851. dwSize = sizeof(RASDEVINFO);
  852. hr = m_pcRNA->RasEnumDevices(m_lpRasDevInfo,&dwSize,&m_dwNumDev);
  853. if (hr == ERROR_BUFFER_TOO_SMALL)
  854. {
  855. GlobalFree(m_lpRasDevInfo);
  856. // 3/20/97 jmazner Olympus #1768
  857. m_lpRasDevInfo = NULL;
  858. m_lpRasDevInfo = (LPRASDEVINFO)GlobalAlloc(LPTR,dwSize);
  859. if (!m_lpRasDevInfo)
  860. {
  861. hr = ERROR_NOT_ENOUGH_MEMORY;
  862. goto FillModemExit;
  863. }
  864. m_lpRasDevInfo->dwSize = sizeof(RASDEVINFO);
  865. m_dwNumDev = 0;
  866. hr = m_pcRNA->RasEnumDevices(m_lpRasDevInfo,&dwSize,&m_dwNumDev);
  867. }
  868. if (hr)
  869. goto FillModemExit;
  870. for (idx=0;idx < m_dwNumDev;idx++)
  871. {
  872. //
  873. // Add string to combo box
  874. //
  875. //
  876. // ChrisK Olympus 4560 do not add VPN's to list of modems
  877. //
  878. if (0 != lstrcmpi(TEXT("VPN"),m_lpRasDevInfo[idx].szDeviceType))
  879. {
  880. lLast = SendDlgItemMessage(m_hwnd,IDC_CMBMODEMS,CB_ADDSTRING,0,(LPARAM)m_lpRasDevInfo[idx].szDeviceName);
  881. //
  882. // ChrisK Olympus 245 5/25/97
  883. // Save index of modem
  884. //
  885. SendDlgItemMessage(m_hwnd,IDC_CMBMODEMS,CB_SETITEMDATA,(WPARAM)lLast,(LPARAM)idx);
  886. if (lstrcmp(m_lpRasDevInfo[idx].szDeviceName,lpRasEntry->szDeviceName) == 0)
  887. SendDlgItemMessage(m_hwnd,IDC_CMBMODEMS,CB_SETCURSEL,(WPARAM)lLast,0);
  888. }
  889. }
  890. if (m_dwNumDev == 1)
  891. SendDlgItemMessage(m_hwnd,IDC_CMBMODEMS,CB_SETCURSEL,0,0);
  892. FillModemExit:
  893. if (lpRasEntry) GlobalFree(lpRasEntry);
  894. lpRasEntry = NULL;
  895. if (lpRasDevInfo) GlobalFree(lpRasDevInfo);
  896. lpRasDevInfo = NULL;
  897. return hr;
  898. }
  899. // ############################################################################
  900. // UNDONE: Collapse this function with the one in dialdlg.cpp
  901. HRESULT CDialingErrorDlg::GetDisplayableNumber()
  902. {
  903. HRESULT hr;
  904. LPRASENTRY lpRasEntry = NULL;
  905. LPRASDEVINFO lpRasDevInfo = NULL;
  906. LPLINETRANSLATEOUTPUT lpOutput1;
  907. LPLINETRANSLATEOUTPUT lpOutput2;
  908. HINSTANCE hRasDll = NULL;
  909. // Normandy 11745
  910. // FARPROC fp = NULL;
  911. DWORD dwRasEntrySize = 0;
  912. DWORD dwRasDevInfoSize = 0;
  913. Assert(VALID_INIT);
  914. // Format the phone number
  915. //
  916. lpOutput1 = (LPLINETRANSLATEOUTPUT)GlobalAlloc(LPTR,sizeof(LINETRANSLATEOUTPUT));
  917. if (!lpOutput1)
  918. {
  919. hr = ERROR_NOT_ENOUGH_MEMORY;
  920. goto GetDisplayableNumberExit;
  921. }
  922. lpOutput1->dwTotalSize = sizeof(LINETRANSLATEOUTPUT);
  923. // Get phone number from connectoid
  924. //
  925. hr = ICWGetRasEntry(&lpRasEntry, &dwRasEntrySize, &lpRasDevInfo, &dwRasDevInfoSize, m_pszConnectoid);
  926. if (hr != ERROR_SUCCESS)
  927. {
  928. goto GetDisplayableNumberExit;
  929. }
  930. //
  931. // If this is a dial as is number, just get it from the structure
  932. //
  933. if (!(lpRasEntry->dwfOptions & RASEO_UseCountryAndAreaCodes))
  934. {
  935. if (m_pszDisplayable) GlobalFree(m_pszDisplayable);
  936. m_pszDisplayable = (LPTSTR)GlobalAlloc(GPTR, sizeof(TCHAR)*(lstrlen(lpRasEntry->szLocalPhoneNumber)+1));
  937. if (!m_pszDisplayable)
  938. {
  939. hr = ERROR_NOT_ENOUGH_MEMORY;
  940. goto GetDisplayableNumberExit;
  941. }
  942. lstrcpy(m_pszPhoneNumber, lpRasEntry->szLocalPhoneNumber);
  943. lstrcpy(m_pszDisplayable, lpRasEntry->szLocalPhoneNumber);
  944. }
  945. else
  946. {
  947. //
  948. // If there is no area code, don't use parentheses
  949. //
  950. if (lpRasEntry->szAreaCode[0])
  951. wsprintf(m_pszPhoneNumber,TEXT("+%d (%s) %s\0"),lpRasEntry->dwCountryCode,lpRasEntry->szAreaCode,lpRasEntry->szLocalPhoneNumber);
  952. else
  953. wsprintf(m_pszPhoneNumber,TEXT("+%lu %s\0"),lpRasEntry->dwCountryCode,
  954. lpRasEntry->szLocalPhoneNumber);
  955. // Turn the canonical form into the "displayable" form
  956. //
  957. hr = lineTranslateAddress(m_hLineApp,m_dwTapiDev,m_dwAPIVersion,m_pszPhoneNumber,
  958. 0,LINETRANSLATEOPTION_CANCELCALLWAITING,lpOutput1);
  959. if (hr != ERROR_SUCCESS || (lpOutput1->dwNeededSize != lpOutput1->dwTotalSize))
  960. {
  961. lpOutput2 = (LPLINETRANSLATEOUTPUT)GlobalAlloc(LPTR,lpOutput1->dwNeededSize);
  962. if (!lpOutput2)
  963. {
  964. hr = ERROR_NOT_ENOUGH_MEMORY;
  965. goto GetDisplayableNumberExit;
  966. }
  967. lpOutput2->dwTotalSize = lpOutput1->dwNeededSize;
  968. GlobalFree(lpOutput1);
  969. lpOutput1 = lpOutput2;
  970. lpOutput2 = NULL;
  971. hr = lineTranslateAddress(m_hLineApp,m_dwTapiDev,m_dwAPIVersion,m_pszPhoneNumber,
  972. 0,LINETRANSLATEOPTION_CANCELCALLWAITING,lpOutput1);
  973. }
  974. if (hr != ERROR_SUCCESS)
  975. {
  976. goto GetDisplayableNumberExit;
  977. }
  978. StrDup(&m_pszDisplayable,(LPTSTR)&((LPBYTE)lpOutput1)[lpOutput1->dwDisplayableStringOffset]);
  979. }
  980. GetDisplayableNumberExit:
  981. if (lpRasEntry) GlobalFree(lpRasEntry);
  982. lpRasEntry = NULL;
  983. if (lpRasDevInfo) GlobalFree(lpRasDevInfo);
  984. lpRasDevInfo = NULL;
  985. if (lpOutput1) GlobalFree(lpOutput1);
  986. lpOutput1 = NULL;
  987. return hr;
  988. }
  989. /**
  990. // ############################################################################
  991. HRESULT ShowDialErrDialog(HRESULT hrErr, LPTSTR pszConnectoid, HINSTANCE hInst, HWND hwnd)
  992. {
  993. int iRC;
  994. // CDialErrDlg *pcDED = NULL;
  995. g_pcDialErr = (PDIALERR)GlobalAlloc(LPTR,sizeof(DIALERR));
  996. if (!g_pcDialErr)
  997. {
  998. MessageBox(hwnd,GetSz(IDS_OUTOFMEMORY),GetSz(IDS_TITLE),MB_APPLMODAL | MB_ICONERROR);
  999. iRC = ERROR_NOT_ENOUGH_MEMORY;
  1000. goto ShowDialErrDialogExit;
  1001. }
  1002. g_pcDialErr->m_pszConnectoid = (LPTSTR)GlobalAlloc(LPTR,RAS_MaxEntryName);
  1003. if (!g_pcDialErr->m_pszConnectoid)
  1004. {
  1005. iRC = ERROR_NOT_ENOUGH_MEMORY;
  1006. goto ShowDialErrDialogExit;
  1007. }
  1008. lstrcpyn(g_pcDialErr->m_pszConnectoid,pszConnectoid,RAS_MaxEntryName);
  1009. g_pcDialErr->m_hrError = hrErr;
  1010. g_pcDialErr->m_hInst = hInst;
  1011. iRC = DialogBoxParam(g_pcDialErr->m_hInst,MAKEINTRESOURCE(IDD_DIALERR),hwnd,DialErrDlgProc,(LPARAM)g_pcDialErr);
  1012. lstrcpyn(pszConnectoid,g_pcDialErr->m_pszConnectoid,RAS_MaxEntryName);
  1013. ShowDialErrDialogExit:
  1014. if (g_pcDialErr->m_lprasdevinfo) GlobalFree(g_pcDialErr->m_lprasdevinfo);
  1015. if (g_pcDialErr) GlobalFree(g_pcDialErr);
  1016. return iRC;
  1017. }
  1018. **/
  1019. /**
  1020. // ############################################################################
  1021. HRESULT CDialingErrorDlg::DialErrGetDisplayableNumber()
  1022. {
  1023. DWORD dwNumDev;
  1024. HRESULT hr;
  1025. LPRASENTRY lpRasEntry;
  1026. LPRASDEVINFO lpRasDevInfo;
  1027. DWORD dwRasEntrySize;
  1028. DWORD dwRasDevInfoSize;
  1029. LPLINETRANSLATEOUTPUT lpOutput1;
  1030. LPLINETRANSLATEOUTPUT lpOutput2;
  1031. LPLINEEXTENSIONID lpExtensionID = NULL;
  1032. HINSTANCE hRasDll = NULL;
  1033. FARPROC fp = NULL;
  1034. //RNAAPI * pcRNA;
  1035. // Initialize TAPIness
  1036. //
  1037. dwNumDev = 0;
  1038. hr = lineInitialize(&g_pcDialErr->m_hLineApp,g_pcDialErr->m_hInst,LineCallback,NULL,&dwNumDev);
  1039. if (hr != ERROR_SUCCESS)
  1040. goto GetDisplayableNumberExit;
  1041. if (g_pdevice->dwTapiDev == 0xFFFFFFFF)
  1042. {
  1043. // if (dwNumDev == 1)
  1044. g_pdevice->dwTapiDev = 0;
  1045. //else
  1046. // UNDONE: Tell the user to select a modem
  1047. // DO NOT EXIT UNTIL THEY PICK ONE
  1048. }
  1049. lpExtensionID = (LPLINEEXTENSIONID )GlobalAlloc(LPTR,sizeof(LINEEXTENSIONID));
  1050. if (!lpExtensionID)
  1051. {
  1052. hr = ERROR_NOT_ENOUGH_MEMORY;
  1053. goto GetDisplayableNumberExit;
  1054. }
  1055. hr = lineNegotiateAPIVersion(g_pcDialErr->m_hLineApp, g_pdevice->dwTapiDev, 0x00010004, 0x00010004,
  1056. &g_pcDialErr->m_dwAPIVersion, lpExtensionID);
  1057. // ditch it since we don't use it
  1058. //
  1059. if (lpExtensionID) GlobalFree(lpExtensionID);
  1060. lpExtensionID = NULL;
  1061. if (hr != ERROR_SUCCESS)
  1062. goto GetDisplayableNumberExit;
  1063. // Format the phone number
  1064. //
  1065. lpOutput1 = (LPLINETRANSLATEOUTPUT)GlobalAlloc(LPTR,sizeof(LINETRANSLATEOUTPUT));
  1066. if (!lpOutput1)
  1067. {
  1068. hr = ERROR_NOT_ENOUGH_MEMORY;
  1069. goto GetDisplayableNumberExit;
  1070. }
  1071. lpOutput1->dwTotalSize = sizeof(LINETRANSLATEOUTPUT);
  1072. // Get phone number from connectoid
  1073. //
  1074. lpRasEntry = (LPRASENTRY)GlobalAlloc(LPTR,sizeof(RASENTRY));
  1075. if (!lpRasEntry)
  1076. {
  1077. hr = ERROR_NOT_ENOUGH_MEMORY;
  1078. goto GetDisplayableNumberExit;
  1079. }
  1080. lpRasDevInfo = (LPRASDEVINFO)GlobalAlloc(LPTR,sizeof(RASDEVINFO));
  1081. if (!lpRasDevInfo)
  1082. {
  1083. hr = ERROR_NOT_ENOUGH_MEMORY;
  1084. goto GetDisplayableNumberExit;
  1085. }
  1086. dwRasEntrySize = sizeof(RASENTRY);
  1087. dwRasDevInfoSize = sizeof(RASDEVINFO);
  1088. lpRasEntry->dwSize = dwRasEntrySize;
  1089. lpRasDevInfo->dwSize = dwRasDevInfoSize;
  1090. hRasDll = LoadLibrary(TEXT("RASAPI32.DLL"));
  1091. if (!hRasDll)
  1092. {
  1093. hr = GetLastError();
  1094. goto GetDisplayableNumberExit;
  1095. }
  1096. fp =GetProcAddress(hRasDll,"RasGetEntryPropertiesA");
  1097. if (!fp)
  1098. {
  1099. FreeLibrary(hRasDll);
  1100. hRasDll = LoadLibrary(TEXT("RNAPH.DLL"));
  1101. if (!hRasDll)
  1102. {
  1103. hr = GetLastError();
  1104. goto GetDisplayableNumberExit;
  1105. }
  1106. fp = GetProcAddress(hRasDll,"RasGetEntryPropertiesA");
  1107. if (!fp)
  1108. {
  1109. hr = GetLastError();
  1110. goto GetDisplayableNumberExit;
  1111. }
  1112. }
  1113. hr = ((PFNRASGETENTRYPROPERTIES)fp)(NULL,g_pcDialErr->m_pszConnectoid,(LPBYTE)lpRasEntry,&dwRasEntrySize,(LPBYTE)lpRasDevInfo,&dwRasDevInfoSize);
  1114. if (hr != ERROR_SUCCESS)
  1115. {
  1116. goto GetDisplayableNumberExit;
  1117. }
  1118. FreeLibrary(hRasDll);
  1119. wsprintf(g_pcDialErr->m_szPhoneNumber,TEXT("+%d (%s) %s\0"),lpRasEntry->dwCountryCode,lpRasEntry->szAreaCode,lpRasEntry->szLocalPhoneNumber);
  1120. // Turn the canonical form into the "displayable" form
  1121. //
  1122. hr = lineTranslateAddress(g_pcDialErr->m_hLineApp,g_pdevice->dwTapiDev,
  1123. g_pcDialErr->m_dwAPIVersion,
  1124. g_pcDialErr->m_szPhoneNumber,0,
  1125. LINETRANSLATEOPTION_CANCELCALLWAITING,
  1126. lpOutput1);
  1127. if (hr != ERROR_SUCCESS || (lpOutput1->dwNeededSize != lpOutput1->dwTotalSize))
  1128. {
  1129. lpOutput2 = (LPLINETRANSLATEOUTPUT)GlobalAlloc(LPTR,lpOutput1->dwNeededSize);
  1130. if (!lpOutput2)
  1131. {
  1132. hr = ERROR_NOT_ENOUGH_MEMORY;
  1133. goto GetDisplayableNumberExit;
  1134. }
  1135. lpOutput2->dwTotalSize = lpOutput1->dwNeededSize;
  1136. GlobalFree(lpOutput1);
  1137. lpOutput1 = lpOutput2;
  1138. lpOutput2 = NULL;
  1139. hr = lineTranslateAddress(g_pcDialErr->m_hLineApp,g_pdevice->dwTapiDev,
  1140. g_pcDialErr->m_dwAPIVersion,
  1141. g_pcDialErr->m_szPhoneNumber,0,
  1142. LINETRANSLATEOPTION_CANCELCALLWAITING,
  1143. lpOutput1);
  1144. }
  1145. if (hr != ERROR_SUCCESS)
  1146. {
  1147. goto GetDisplayableNumberExit;
  1148. }
  1149. g_pcDialErr->m_pszDisplayable = (LPTSTR)GlobalAlloc(LPTR,lpOutput1->dwDisplayableStringSize+1);
  1150. if (!g_pcDialErr->m_pszDisplayable)
  1151. {
  1152. hr = ERROR_NOT_ENOUGH_MEMORY;
  1153. goto GetDisplayableNumberExit;
  1154. }
  1155. lstrcpyn(g_pcDialErr->m_pszDisplayable,(LPTSTR)&((LPBYTE)lpOutput1)[lpOutput1->dwDisplayableStringOffset],lpOutput1->dwDisplayableStringSize);
  1156. GetDisplayableNumberExit:
  1157. if (g_pcDialErr->m_hLineApp)
  1158. {
  1159. lineShutdown(g_pcDialErr->m_hLineApp);
  1160. g_pcDialErr->m_hLineApp = NULL;
  1161. }
  1162. return hr;
  1163. }
  1164. **/
  1165. //+----------------------------------------------------------------------------
  1166. //
  1167. // Function: CDialingErrorDlg::CreateDialAsIsConnectoid
  1168. //
  1169. // Synopsis: Using the string in the editable text box create a dia-as-is
  1170. // connectoid
  1171. //
  1172. // Arguemnts: lpszDialNumber string containing the to-be-dailed number
  1173. //
  1174. // Returns: Error value (ERROR_SUCCESS == success)
  1175. //
  1176. // History: 8/29/96 Chrisk Created
  1177. //
  1178. //-----------------------------------------------------------------------------
  1179. HRESULT CDialingErrorDlg::CreateDialAsIsConnectoid(LPCTSTR lpszDialNumber)
  1180. {
  1181. HRESULT hr = ERROR_SUCCESS;
  1182. LPRASENTRY lpRasEntry=NULL;
  1183. LPRASDEVINFO lpRasDevInfo=NULL;
  1184. RNAAPI *pcRNA = NULL;
  1185. LPCTSTR p, p2;
  1186. DWORD dwRasEntrySize = 0;
  1187. DWORD dwRasDevInfoSize = 0;
  1188. Assert(lpszDialNumber);
  1189. // Check that the phone number only contains valid characters
  1190. //
  1191. //
  1192. // 5/17/97 jmazner Olympus #137
  1193. // check for DBCS characters
  1194. //
  1195. #ifndef WIN16
  1196. if( !IsSBCSString( lpszDialNumber) )
  1197. {
  1198. MsgBox(IDS_SBCSONLY,MB_MYERROR);
  1199. SetFocus(GetDlgItem(m_hwnd,IDC_TEXTNUMBER));
  1200. SendMessage(GetDlgItem(m_hwnd, IDC_TEXTNUMBER),
  1201. EM_SETSEL,
  1202. (WPARAM) 0,
  1203. (LPARAM) -1);
  1204. hr = ERROR_INVALID_PARAMETER;
  1205. goto CreateDialAsIsConnectoidExit;
  1206. }
  1207. #endif
  1208. for (p = lpszDialNumber;*p;p++)
  1209. {
  1210. for(p2 = szValidPhoneCharacters;*p2;p2++)
  1211. {
  1212. if (*p == *p2)
  1213. break; // p2 for loop
  1214. }
  1215. if (!*p2) break; // p for loop
  1216. }
  1217. if (*p)
  1218. {
  1219. MsgBox(IDS_INVALIDPHONE,MB_MYERROR);
  1220. //
  1221. // Set the focus back to the phone number field
  1222. //
  1223. SetFocus(GetDlgItem(m_hwnd,IDC_TEXTNUMBER));
  1224. {
  1225. hr = ERROR_INVALID_PARAMETER;
  1226. goto CreateDialAsIsConnectoidExit;
  1227. }
  1228. }
  1229. //hr = ICWGetRasEntry(&lpRasEntry,&lpRasDevInfo,m_pszConnectoid);
  1230. hr = ICWGetRasEntry(&lpRasEntry, &dwRasEntrySize, &lpRasDevInfo, &dwRasDevInfoSize, m_pszConnectoid);
  1231. if (ERROR_SUCCESS != hr)
  1232. goto CreateDialAsIsConnectoidExit;
  1233. // Replace the phone number with the new one
  1234. //
  1235. lstrcpy(lpRasEntry->szLocalPhoneNumber, lpszDialNumber);
  1236. //
  1237. // This is dummy information and will not effect the dialed string
  1238. // This information is required due to bugs in RAS apis.
  1239. //
  1240. lpRasEntry->dwCountryID = 1;
  1241. lpRasEntry->dwCountryCode = 1;
  1242. lpRasEntry->szAreaCode[0] = '8';
  1243. lpRasEntry->szAreaCode[1] = '\0';
  1244. // Set to dial as is
  1245. //
  1246. lpRasEntry->dwfOptions &= ~RASEO_UseCountryAndAreaCodes;
  1247. if (!pcRNA) pcRNA = new RNAAPI;
  1248. if (!pcRNA)
  1249. {
  1250. hr = ERROR_NOT_ENOUGH_MEMORY;
  1251. goto CreateDialAsIsConnectoidExit;
  1252. }
  1253. // jmazner 10/10/96 Normandy #9066
  1254. // Don't assume that sizeof lpRasEntry and lpRasDevInfo buffers is that of their
  1255. // respective structs; RasGetEntryProperties sometimes needs these buffers to be
  1256. // larger than just the struct!
  1257. // hr = pcRNA->RasSetEntryProperties(NULL,m_pszConnectoid,(LPBYTE)lpRasEntry,
  1258. // sizeof(RASENTRY),(LPBYTE)lpRasDevInfo,sizeof(RASDEVINFO));
  1259. hr = pcRNA->RasSetEntryProperties(NULL,m_pszConnectoid,(LPBYTE)lpRasEntry,
  1260. dwRasEntrySize,(LPBYTE)lpRasDevInfo,dwRasDevInfoSize);
  1261. if (hr != ERROR_SUCCESS)
  1262. {
  1263. MsgBox(IDS_CANTSAVEKEY,MB_MYERROR);
  1264. goto CreateDialAsIsConnectoidExit;
  1265. }
  1266. CreateDialAsIsConnectoidExit:
  1267. if (lpRasEntry)
  1268. GlobalFree(lpRasEntry);
  1269. lpRasEntry = NULL;
  1270. if (lpRasDevInfo)
  1271. GlobalFree(lpRasDevInfo);
  1272. lpRasDevInfo = NULL;
  1273. if (pcRNA)
  1274. delete pcRNA;
  1275. pcRNA = NULL;
  1276. return hr;
  1277. }