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.

738 lines
21 KiB

  1. /****************************************************************************
  2. *
  3. * ICWAPRTC.cpp
  4. *
  5. * Microsoft Confidential
  6. * Copyright (c) Microsoft Corporation 1992-1997
  7. * All rights reserved
  8. *
  9. * This module provides the implementation of the methods for
  10. * the CICWApprentice class.
  11. *
  12. * 5/1/97 jmazner Created
  13. *
  14. ***************************************************************************/
  15. #include "wizard.h"
  16. #include "icwextsn.h"
  17. #include "icwaprtc.h"
  18. #include "imnext.h"
  19. #include "pagefcns.h"
  20. #include "icwcfg.h"
  21. UINT g_uExternUIPrev, g_uExternUINext;
  22. IICWExtension *g_pExternalIICWExtension = NULL;
  23. BOOL g_fConnectionInfoValid = FALSE;
  24. //defined/allocated in propmgr.cpp
  25. extern PAGEINFO PageInfo[NUM_WIZARD_PAGES];
  26. extern INT_PTR CALLBACK GenDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam,
  27. LPARAM lParam);
  28. extern VOID InitWizardState(WIZARDSTATE * pWizardState, DWORD dwFlags);
  29. extern VOID InitUserInfo(USERINFO * pUserInfo);
  30. //define in rnacall.cpp
  31. extern void InitRasEntry(LPRASENTRY lpEntry);
  32. //defined in endui.cpp
  33. extern BOOL CommitConfigurationChanges(HWND hDlg);
  34. /*** Class definition, for reference only ***
  35. (actual definition is in icwaprtc.h)
  36. class CICWApprentice : public IICWApprentice
  37. {
  38. public:
  39. virtual HRESULT STDMETHODCALLTYPE Initialize(IICWExtension *pExt);
  40. virtual HRESULT STDMETHODCALLTYPE AddWizardPages(DWORD dwFlags);
  41. virtual HRESULT STDMETHODCALLTYPE GetConnectionInformation(CONNECTINFO *pInfo);
  42. virtual HRESULT STDMETHODCALLTYPE SetConnectionInformation(CONNECTINFO *pInfo);
  43. virtual HRESULT STDMETHODCALLTYPE Save(HWND hwnd, DWORD *pdwError);
  44. virtual HRESULT STDMETHODCALLTYPE SetPrevNextPage(UINT uPrevPageDlgID, UINT uNextPageDlgID);
  45. virtual HRESULT STDMETHODCALLTYPE QueryInterface( REFIID theGUID, void** retPtr );
  46. virtual ULONG STDMETHODCALLTYPE AddRef( void );
  47. virtual ULONG STDMETHODCALLTYPE Release( void );
  48. CICWApprentice( void );
  49. ~CICWApprentice( void );
  50. IICWExtension *m_pIICWExt;
  51. private:
  52. LONG m_lRefCount;
  53. };
  54. ****/
  55. //+----------------------------------------------------------------------------
  56. //
  57. // Function CICWApprentice::Initialize
  58. //
  59. // Synopsis Called by the main Wizard to initialize class members and
  60. // globals
  61. //
  62. // Arguments [in] pExt -- pointer the Wizard's IICWExtension interface, which
  63. // encapsulates the functionality needed to add wizard
  64. // pages.
  65. //
  66. // Returns E_OUTOFMEMORY -- unable to allocate global vars.
  67. // S_OK indicates success
  68. //
  69. // History 4/23/97 jmazner created
  70. //
  71. //-----------------------------------------------------------------------------
  72. HRESULT CICWApprentice::Initialize(IICWExtension *pExt)
  73. {
  74. DEBUGMSG("CICWApprentice::Initialize");
  75. ASSERT( pExt );
  76. m_pIICWExt = pExt;
  77. m_pIICWExt->AddRef();
  78. // various page OKProcs will need this pointer in order
  79. // to call SetFirstLastPage
  80. ASSERT( NULL == g_pExternalIICWExtension );
  81. g_pExternalIICWExtension = pExt;
  82. g_fConnectionInfoValid = FALSE;
  83. if( !gpWizardState)
  84. {
  85. gpWizardState = new WIZARDSTATE;
  86. }
  87. if( !gpUserInfo )
  88. {
  89. gpUserInfo = new USERINFO;
  90. }
  91. if( !gpRasEntry )
  92. {
  93. gdwRasEntrySize = sizeof(RASENTRY);
  94. gpRasEntry = (LPRASENTRY) GlobalAlloc(GPTR,gdwRasEntrySize);
  95. }
  96. if( !gpRasEntry || !gpWizardState || !gpUserInfo )
  97. {
  98. DEBUGMSG("CICWApprentice::Initialize couldn't initialize the globals!");
  99. return E_OUTOFMEMORY;
  100. }
  101. // stolen from RunSignupWizard in propmgr.cpp
  102. // initialize the rasentry structure
  103. InitRasEntry(gpRasEntry);
  104. // initialize the app state structure
  105. InitWizardState(gpWizardState, RSW_APPRENTICE);
  106. gpWizardState->dwRunFlags |= RSW_APPRENTICE;
  107. // initialize user data structure
  108. InitUserInfo(gpUserInfo);
  109. //
  110. // 6/2/97 jmazner Olympus #4542
  111. // default to CONNECT_RAS
  112. //
  113. gpUserInfo->uiConnectionType = CONNECT_RAS;
  114. return S_OK;
  115. }
  116. //+----------------------------------------------------------------------------
  117. //
  118. // Function CICWApprentice::AddWizardPages
  119. //
  120. // Synopsis Creates a series of Property Sheet pages, and adds them to the
  121. // main wizard via the m_pIICWExt interface pointer. Note that
  122. // we add every page in the global PageInfo struct, even though the
  123. // Apprentice may not use some pages (eg, CONNECTEDOK)
  124. //
  125. // Arguments [] dwFlags -- currently unused
  126. //
  127. // Returns S_OK indicates success
  128. // E_FAIL indicates failure. If for any reason all pages can not be
  129. // added, we will attempt to remove any pages that had been
  130. // added prior to the failure.
  131. //
  132. // History 4/23/97 jmazner created
  133. //
  134. //-----------------------------------------------------------------------------
  135. HRESULT CICWApprentice::AddWizardPages(DWORD dwFlags)
  136. {
  137. HPROPSHEETPAGE hWizPage[NUM_WIZARD_PAGES]; // array to hold handles to pages
  138. PROPSHEETPAGE psPage; // struct used to create prop sheet pages
  139. UINT nPageIndex;
  140. HRESULT hr = S_OK;
  141. unsigned long ulNumItems = 0;
  142. DEBUGMSG("CICWApprentice::AddWizardPages");
  143. gpWizardState->dwRunFlags |= RSW_APPRENTICE;
  144. ZeroMemory(&hWizPage,sizeof(hWizPage)); // hWizPage is an array
  145. ZeroMemory(&psPage,sizeof(PROPSHEETPAGE));
  146. if (dwFlags & WIZ_USE_WIZARD97)
  147. g_fIsExternalWizard97 = TRUE;
  148. // fill out common data property sheet page struct
  149. psPage.dwSize = sizeof(psPage);
  150. psPage.hInstance = ghInstance;
  151. psPage.pfnDlgProc = GenDlgProc;
  152. // create a property sheet page for each page in the wizard
  153. for (nPageIndex = 0; nPageIndex < NUM_WIZARD_PAGES; nPageIndex++)
  154. {
  155. UINT uDlgID;
  156. psPage.dwFlags = PSP_DEFAULT | PSP_HASHELP;
  157. if (g_fIsExternalWizard97)
  158. {
  159. psPage.dwFlags |= PSP_USETITLE;
  160. psPage.pszTitle= gpWizardState->cmnStateData.szWizTitle;
  161. uDlgID = PageInfo[nPageIndex].uDlgID97External;
  162. }
  163. else
  164. uDlgID = PageInfo[nPageIndex].uDlgID;
  165. psPage.pszTemplate = MAKEINTRESOURCE(uDlgID);
  166. // set a pointer to the PAGEINFO struct as the private data for this
  167. // page
  168. psPage.lParam = (LPARAM) &PageInfo[nPageIndex];
  169. if (g_fIsExternalWizard97 && PageInfo[nPageIndex].nIdTitle)
  170. {
  171. psPage.dwFlags |= PSP_USEHEADERTITLE | (PageInfo[nPageIndex].nIdSubTitle ? PSP_USEHEADERSUBTITLE : 0);
  172. psPage.pszHeaderTitle = MAKEINTRESOURCE(PageInfo[nPageIndex].nIdTitle);
  173. psPage.pszHeaderSubTitle = MAKEINTRESOURCE(PageInfo[nPageIndex].nIdSubTitle);
  174. }
  175. hWizPage[nPageIndex] = CreatePropertySheetPage(&psPage);
  176. if (!hWizPage[nPageIndex])
  177. {
  178. DEBUGTRAP("Failed to create property sheet page");
  179. MsgBox(NULL,IDS_ERROutOfMemory,MB_ICONEXCLAMATION,MB_OK);
  180. hr = E_FAIL;
  181. // creating page failed, free any pages already created and bail
  182. goto AddWizardPagesErrorExit;
  183. }
  184. hr = m_pIICWExt->AddExternalPage( hWizPage[nPageIndex], uDlgID);
  185. if( FAILED(hr) )
  186. {
  187. // free any pages already created and bail
  188. goto AddWizardPagesErrorExit;
  189. }
  190. }
  191. if (((dwFlags & WIZ_HOST_ICW_LAN) || (dwFlags & WIZ_HOST_ICW_PHONE)) ||
  192. (dwFlags & WIZ_HOST_ICW_MPHONE))
  193. {
  194. UINT uNextPage;
  195. BOOL bDummy;
  196. g_fIsICW = TRUE;
  197. if (!InitWizard(0))
  198. {
  199. hr = E_FAIL;
  200. DeinitWizard(RSW_NOREBOOT);
  201. }
  202. else
  203. {
  204. if (S_OK != ProcessCustomFlags(dwFlags))
  205. {
  206. DeinitWizard(RSW_NOREBOOT);
  207. hr = E_FAIL;
  208. }
  209. }
  210. }
  211. else
  212. {
  213. // of course, we have no idea what the last page will really be.
  214. // so make a guess here, and update it later when we know for sure.
  215. if (g_fIsExternalWizard97)
  216. m_pIICWExt->SetFirstLastPage( IDD_PAGE_HOWTOCONNECT97, IDD_PAGE_HOWTOCONNECT97 );
  217. else
  218. m_pIICWExt->SetFirstLastPage( IDD_PAGE_HOWTOCONNECT, IDD_PAGE_HOWTOCONNECT );
  219. }
  220. return hr;
  221. AddWizardPagesErrorExit:
  222. UINT nFreeIndex;
  223. for (nFreeIndex=0;nFreeIndex<nPageIndex;nFreeIndex++)
  224. {
  225. UINT uDlgID;
  226. if (g_fIsExternalWizard97)
  227. uDlgID = PageInfo[nPageIndex].uDlgID97External;
  228. else
  229. uDlgID = PageInfo[nPageIndex].uDlgID;
  230. DestroyPropertySheetPage(hWizPage[nFreeIndex]);
  231. m_pIICWExt->RemoveExternalPage( hWizPage[nFreeIndex], uDlgID );
  232. }
  233. return hr;
  234. }
  235. //+----------------------------------------------------------------------------
  236. //
  237. // Function CICWApprentice::GetConnectionInformation
  238. //
  239. // Synopsis Fills the passed in CONNECTINFO structure with the connection
  240. // information entered by the user.
  241. //
  242. // Arguments [in] pInfo -- pointer to a CONNECTINFO structure
  243. // [out] pInfo -- the indicated structure will contain the user's
  244. // connection information.
  245. //
  246. // Returns S_OK indicates success
  247. // E_POINTER -- the pInfo pointer is not valid
  248. // E_FAIL -- the user has not entered any connection info. This
  249. // error will occur if the function is called before
  250. // the user has completed the apprentice.
  251. //
  252. // History 4/23/97 jmazner created
  253. //
  254. //-----------------------------------------------------------------------------
  255. HRESULT CICWApprentice::GetConnectionInformation(CONNECTINFO *pInfo)
  256. {
  257. DEBUGMSG("CICWApprentice::GetConnectionInformation");
  258. ASSERTSZ(pInfo, "CONNECTINFO *pInfo is NULL!");
  259. if( !pInfo )
  260. {
  261. return E_POINTER;
  262. }
  263. if( !g_fConnectionInfoValid )
  264. {
  265. DEBUGMSG("CICWApprentice::GetConnectionInformation: haven't gathered any connection info yet!");
  266. return E_FAIL;
  267. }
  268. else
  269. {
  270. pInfo->cbSize = sizeof( CONNECTINFO );
  271. #ifdef UNICODE
  272. wcstombs(pInfo->szConnectoid, TEXT("Uninitialized\0"), MAX_PATH);
  273. #else
  274. lstrcpy( pInfo->szConnectoid, TEXT("Uninitialized\0"));
  275. #endif
  276. pInfo->type = gpUserInfo->uiConnectionType;
  277. if( CONNECT_RAS == pInfo->type )
  278. {
  279. #ifdef UNICODE
  280. wcstombs(pInfo->szConnectoid, gpUserInfo->szISPName, MAX_PATH);
  281. #else
  282. lstrcpy( pInfo->szConnectoid, gpUserInfo->szISPName);
  283. #endif
  284. }
  285. }
  286. return S_OK;
  287. }
  288. //+----------------------------------------------------------------------------
  289. //
  290. // Function CICWApprentice::SetConnectionInformation
  291. //
  292. // Synopsis Sets the default connectoin information for the Apprentice
  293. //
  294. // Arguments [in] pInfo -- pointer to a CONNECTINFO structure containing the
  295. // defaults to use.
  296. //
  297. // Returns S_OK indicates success
  298. // E_POINTER -- the pInfo pointer is not valid
  299. // E_INVALIDARG -- pInfo appears to point a different CONNECTINO
  300. // structure than the one we know about (based on
  301. // the cbSize member).
  302. //
  303. // History 4/23/97 jmazner created
  304. //
  305. //-----------------------------------------------------------------------------
  306. HRESULT CICWApprentice::SetConnectionInformation(CONNECTINFO *pInfo)
  307. {
  308. DEBUGMSG("CICWApprentice::SetConnectionInformation");
  309. ASSERTSZ(pInfo, "CONNECTINFO *pInfo is NULL!");
  310. if( !pInfo )
  311. {
  312. return E_POINTER;
  313. }
  314. if( !(sizeof( CONNECTINFO ) == pInfo->cbSize) )
  315. {
  316. DEBUGMSG("CICWApprentice::SetConnectionInformation pInfo->cbSize is unknown!");
  317. return E_INVALIDARG;
  318. }
  319. gpUserInfo->uiConnectionType = pInfo->type;
  320. if( CONNECT_RAS == pInfo->type )
  321. {
  322. #ifdef UNICODE
  323. mbstowcs(gpUserInfo->szISPName, pInfo->szConnectoid, MAX_PATH);
  324. #else
  325. lstrcpy( gpUserInfo->szISPName, pInfo->szConnectoid);
  326. #endif
  327. }
  328. return S_OK;
  329. }
  330. //+----------------------------------------------------------------------------
  331. //
  332. // Function CICWApprentice::Save
  333. //
  334. // Synopsis Called by the Wizard to commit changes
  335. //
  336. // Arguments [in] hwnd -- hwnd of Wizard window, used to display modal msgs
  337. // [out] pdwError -- implementation specfic error code. Not used.
  338. //
  339. // Returns S_OK indicates success
  340. // Otherwise, returns E_FAIL.
  341. //
  342. //
  343. // History 4/23/97 jmazner created
  344. //
  345. //-----------------------------------------------------------------------------
  346. HRESULT CICWApprentice::Save(HWND hwnd, DWORD *pdwError)
  347. {
  348. DEBUGMSG("CICWApprentice::Save");
  349. if( CommitConfigurationChanges(hwnd) )
  350. {
  351. return S_OK;
  352. }
  353. else
  354. {
  355. return E_FAIL;
  356. }
  357. }
  358. HRESULT CICWApprentice::SetDlgHwnd(HWND hDlg)
  359. {
  360. m_hwndDlg = hDlg;
  361. return S_OK;
  362. }
  363. //+----------------------------------------------------------------------------
  364. //
  365. // Function CICWApprentice::SetPrevNextPage
  366. //
  367. // Synopsis Lets the apprentice notify the wizard of the dialog IDs of the
  368. // first and last pages in the apprentice
  369. //
  370. //
  371. // Arguments uPrevPageDlgID -- DlgID of wizard page to back up to
  372. // uNextPageDlgID -- DlgID of wizard page to go forwards into
  373. //
  374. //
  375. // Returns FALSE if both parameters are 0
  376. // TRUE if the update succeeded.
  377. //
  378. // Notes: If either variable is set to 0, the function will not update
  379. // that information, i.e. a value of 0 means "ignore me". If both
  380. // variables are 0, the function immediately returns FALSE.
  381. //
  382. // History 4/23/97 jmazner created
  383. //
  384. //-----------------------------------------------------------------------------
  385. HRESULT CICWApprentice::SetPrevNextPage(UINT uPrevPageDlgID, UINT uNextPageDlgID)
  386. {
  387. DEBUGMSG("CICWApprentice::SetPrevNextPage: updating prev = %d, next = %d",
  388. uPrevPageDlgID, uNextPageDlgID);
  389. if( (0 == uPrevPageDlgID) && (0 == uNextPageDlgID) )
  390. {
  391. DEBUGMSG("SetFirstLastPage: both IDs are 0!");
  392. return( E_INVALIDARG );
  393. }
  394. if( 0 != uPrevPageDlgID )
  395. g_uExternUIPrev = uPrevPageDlgID;
  396. if( 0 != uNextPageDlgID )
  397. g_uExternUINext = uNextPageDlgID;
  398. return S_OK;
  399. }
  400. //+----------------------------------------------------------------------------
  401. //
  402. // Function CICWApprentice::ProcessCustomFlags
  403. //
  404. // Synopsis Lets the apprentice know that there is a special modification
  405. // to this set of apprentice pages after it is loaded
  406. //
  407. // Arguments dwFlags -- info needed to pass to the external pages
  408. //
  409. //
  410. // Returns FALSE if both parameters are 0
  411. // TRUE if the update succeeded.
  412. //
  413. // History 9/23/97 vyung created
  414. //
  415. //-----------------------------------------------------------------------------
  416. HRESULT CICWApprentice::ProcessCustomFlags(DWORD dwFlags)
  417. {
  418. UINT uNextPage;
  419. BOOL bDummy;
  420. HRESULT hr = S_OK;
  421. if (gpUserInfo)
  422. gpUserInfo->uiConnectionType = (dwFlags & WIZ_HOST_ICW_LAN) ? CONNECT_LAN : CONNECT_RAS;
  423. g_bSkipMultiModem = (BOOL) (dwFlags & WIZ_HOST_ICW_PHONE);
  424. if (gpWizardState)
  425. {
  426. gpWizardState->cmnStateData.dwFlags = 0;
  427. if (dwFlags & (WIZ_NO_MAIL_ACCT | WIZ_NO_NEWS_ACCT))
  428. {
  429. gpWizardState->dwRunFlags |= RSW_NOIMN;
  430. }
  431. }
  432. if (!HowToConnectOKProc(m_hwndDlg, TRUE, &uNextPage, &bDummy))
  433. {
  434. if (g_bReboot && gpWizardState && g_fIsICW)
  435. {
  436. // Set a registry value indicating that we messed with the desktop
  437. DWORD dwFlags = 0x00800000;//ICW_CFGFLAG_SMARTREBOOT_MANUAL;
  438. DWORD dwDisposition;
  439. HKEY hkey = 0;
  440. if (ERROR_SUCCESS == RegCreateKeyEx(HKEY_CURRENT_USER,
  441. ICW_REGPATHSETTINGS,
  442. 0,
  443. NULL,
  444. REG_OPTION_NON_VOLATILE,
  445. KEY_ALL_ACCESS,
  446. NULL,
  447. &hkey,
  448. &dwDisposition))
  449. {
  450. DWORD dwDesktopChanged = 1;
  451. RegSetValueEx(hkey,
  452. ICW_REGKEYERROR,
  453. 0,
  454. REG_DWORD,
  455. (LPBYTE)&dwFlags,
  456. sizeof(DWORD));
  457. RegCloseKey(hkey);
  458. }
  459. g_bRebootAtExit = FALSE;
  460. }
  461. hr = E_FAIL;
  462. }
  463. else
  464. {
  465. switch( uNextPage )
  466. {
  467. case ORD_PAGE_USEPROXY:
  468. m_pIICWExt->SetFirstLastPage( IDD_PAGE_USEPROXY97, IDD_PAGE_USEPROXY97 );
  469. break;
  470. case ORD_PAGE_SETUP_PROXY:
  471. m_pIICWExt->SetFirstLastPage( IDD_PAGE_SETUP_PROXY97, IDD_PAGE_SETUP_PROXY97 );
  472. break;
  473. case ORD_PAGE_CHOOSEMODEM:
  474. m_pIICWExt->SetFirstLastPage( IDD_PAGE_CHOOSEMODEM97, IDD_PAGE_CHOOSEMODEM97 );
  475. break;
  476. case ORD_PAGE_PHONENUMBER:
  477. case ORD_PAGE_CONNECTION:
  478. m_pIICWExt->SetFirstLastPage( IDD_PAGE_PHONENUMBER97, IDD_PAGE_PHONENUMBER97 );
  479. break;
  480. default:
  481. m_pIICWExt->SetFirstLastPage( 0, 0 );
  482. break;
  483. } // end of switch
  484. }
  485. return hr;
  486. }
  487. HRESULT CICWApprentice::SetStateDataFromExeToDll(LPCMNSTATEDATA lpData)
  488. {
  489. ASSERT(gpWizardState);
  490. memcpy(&gpWizardState->cmnStateData, lpData, sizeof(CMNSTATEDATA));
  491. return S_OK;
  492. }
  493. //converse of the previous function
  494. HRESULT CICWApprentice::SetStateDataFromDllToExe(LPCMNSTATEDATA lpData)
  495. {
  496. ASSERT(gpWizardState);
  497. memcpy(lpData, &gpWizardState->cmnStateData, sizeof(CMNSTATEDATA));
  498. return (S_OK);
  499. }
  500. //+----------------------------------------------------------------------------
  501. //
  502. // Function CICWApprentice::QueryInterface
  503. //
  504. // Synopsis This is the standard QI, with support for
  505. // IID_Unknown, IICW_Extension and IID_ICWApprentice
  506. // (stolen from Inside COM, chapter 7)
  507. //
  508. // History 4/23/97 jmazner created
  509. //
  510. //-----------------------------------------------------------------------------
  511. HRESULT CICWApprentice::QueryInterface( REFIID riid, void** ppv )
  512. {
  513. DEBUGMSG("CICWApprentice::QueryInterface");
  514. if (ppv == NULL)
  515. return(E_INVALIDARG);
  516. *ppv = NULL;
  517. // IID_IICWApprentice
  518. if (IID_IICWApprentice == riid)
  519. *ppv = (void *)(IICWApprentice *)this;
  520. // IID_IICWApprenticeEx
  521. else if (IID_IICWApprenticeEx == riid)
  522. *ppv = (void *)(IICWApprenticeEx *)this;
  523. // IID_IICWExtension
  524. else if (IID_IICWExtension == riid)
  525. *ppv = (void *)(IICWExtension *)this;
  526. // IID_IUnknown
  527. else if (IID_IUnknown == riid)
  528. *ppv = (void *)this;
  529. else
  530. return(E_NOINTERFACE);
  531. ((LPUNKNOWN)*ppv)->AddRef();
  532. return(S_OK);
  533. }
  534. //+----------------------------------------------------------------------------
  535. //
  536. // Function CICWApprentice::AddRef
  537. //
  538. // Synopsis This is the standard AddRef
  539. //
  540. // History 4/23/97 jmazner created
  541. //
  542. //-----------------------------------------------------------------------------
  543. ULONG CICWApprentice::AddRef( void )
  544. {
  545. DEBUGMSG("CICWApprentice::AddRef %d", m_lRefCount + 1);
  546. return InterlockedIncrement(&m_lRefCount) ;
  547. }
  548. //+----------------------------------------------------------------------------
  549. //
  550. // Function CICWApprentice::Release
  551. //
  552. // Synopsis This is the standard Release
  553. //
  554. // History 4/23/97 jmazner created
  555. //
  556. //-----------------------------------------------------------------------------
  557. ULONG CICWApprentice::Release( void )
  558. {
  559. ASSERT( m_lRefCount > 0 );
  560. InterlockedDecrement(&m_lRefCount);
  561. DEBUGMSG("CICWApprentice::Release %d", m_lRefCount);
  562. if( 0 == m_lRefCount )
  563. {
  564. m_pIICWExt->Release();
  565. m_pIICWExt = NULL;
  566. delete( this );
  567. return( 0 );
  568. }
  569. else
  570. {
  571. return( m_lRefCount );
  572. }
  573. }
  574. //+----------------------------------------------------------------------------
  575. //
  576. // Function CICWApprentice::CICWApprentice
  577. //
  578. // Synopsis This is the constructor, nothing fancy
  579. //
  580. // History 4/23/97 jmazner created
  581. //
  582. //-----------------------------------------------------------------------------
  583. CICWApprentice::CICWApprentice( void )
  584. {
  585. DEBUGMSG("CICWApprentice constructor called");
  586. m_lRefCount = 0;
  587. m_pIICWExt = NULL;
  588. }
  589. //+----------------------------------------------------------------------------
  590. //
  591. // Function CICWApprentice::~CICWApprentice
  592. //
  593. // Synopsis This is the destructor. We want to clean up all the memory
  594. // we allocated in ::Initialize
  595. //
  596. // History 4/23/97 jmazner created
  597. //
  598. //-----------------------------------------------------------------------------
  599. CICWApprentice::~CICWApprentice( void )
  600. {
  601. DEBUGMSG("CICWApprentice destructor called with ref count of %d", m_lRefCount);
  602. if (gpImnApprentice)
  603. {
  604. gpImnApprentice->Release(); // DeinitWizard is called in Release()
  605. gpImnApprentice = NULL;
  606. }
  607. if( g_fIsICW ) // if ICW, we need to clean up, otherwise, leave cleanup later
  608. DeinitWizard(0);
  609. if( m_pIICWExt )
  610. {
  611. m_pIICWExt->Release();
  612. m_pIICWExt = NULL;
  613. }
  614. g_pExternalIICWExtension = NULL;
  615. g_fConnectionInfoValid = FALSE;
  616. if( gpWizardState)
  617. {
  618. delete gpWizardState;
  619. gpWizardState = NULL;
  620. }
  621. if( gpUserInfo )
  622. {
  623. delete gpUserInfo;
  624. gpUserInfo = NULL;
  625. }
  626. if( gpRasEntry )
  627. {
  628. GlobalFree(gpRasEntry);
  629. gpRasEntry = NULL;
  630. }
  631. }