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.

365 lines
12 KiB

  1. /****************************************************************************
  2. *
  3. * ICWESTSN.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 CICWExtension class.
  11. *
  12. * 05/14/98 donaldm copied from INETCFG
  13. *
  14. ***************************************************************************/
  15. #include "pre.h"
  16. #include "icwconn.h"
  17. #include "icwextsn.h"
  18. //+----------------------------------------------------------------------------
  19. //
  20. // Function CICWExtension::AddExternalPage
  21. //
  22. // Synopsis Adds a page created via CreatePropertySheetPage to the main
  23. // property sheet/wizard.
  24. //
  25. //
  26. // Arguments hPage -- page handle returned from CreatePropertySheetPage
  27. // uDlgID -- the dialog ID of the page to be added, as defined
  28. // the resource file of the page's owner.
  29. //
  30. //
  31. // Returns FALSE is the dlgID is already in use in the Wizard
  32. // TRUE otherwise
  33. //
  34. // Notes: PropSheet_AddPage does not return a usefull error code. Thus
  35. // the assumption here is that every AddPage will succeed. But, even
  36. // though it is not enforced by PropSheet_AddPage, every page in the
  37. // PropSheet must have a unique dialog ID. Thus, if the uDlgID passed
  38. // in has previously been added to the PropSheet, we'll return FALSE.
  39. //
  40. // History 4/23/97 jmazner created
  41. //
  42. //-----------------------------------------------------------------------------
  43. BOOL CICWExtension::AddExternalPage( HPROPSHEETPAGE hPage, UINT uDlgID )
  44. {
  45. LRESULT lResult= 0;
  46. if ( (uDlgID < EXTERNAL_DIALOGID_MINIMUM) || (EXTERNAL_DIALOGID_MAXIMUM < uDlgID) )
  47. {
  48. TraceMsg(TF_ICWEXTSN, TEXT("ICWEXTSN: SetFirstLastPage: uDlgID %d is out of range!"), uDlgID);
  49. return( FALSE );
  50. }
  51. if( !DialogIDAlreadyInUse(uDlgID) )
  52. {
  53. SetDialogIDInUse( uDlgID, TRUE );
  54. lResult = PropSheet_AddPage(m_hWizardHWND, hPage);
  55. TraceMsg(TF_ICWEXTSN, TEXT("ICWEXTSN: PS_AddPage DlgID %d"), uDlgID);
  56. return(TRUE);
  57. }
  58. else
  59. {
  60. TraceMsg(TF_ICWEXTSN, TEXT("ICWEXTSN: AddExternalPage DlgID %d is already in use, rejecting this page!"), uDlgID);
  61. return(FALSE);
  62. }
  63. }
  64. //+----------------------------------------------------------------------------
  65. //
  66. // Function CICWExtension::RemoveExternalPage
  67. //
  68. // Synopsis Removes a page added via ::AddExternalPage to the main
  69. // property sheet/wizard.
  70. //
  71. //
  72. // Arguments hPage -- page handle returned from CreatePropertySheetPage
  73. // uDlgID -- the dialog ID of the page to be removed, as defined
  74. // the resource file of the page's owner.
  75. //
  76. //
  77. // Returns FALSE is the dlgID is not already in use in the Wizard
  78. // TRUE otherwise
  79. //
  80. // Notes: PropSheet_RemovePage does not return a usefull error code. Thus
  81. // the assumption here is that every RemovePage will succeed if that
  82. // dialog id is currently in the property sheet
  83. //
  84. // History 4/23/97 jmazner created
  85. //
  86. //-----------------------------------------------------------------------------
  87. BOOL CICWExtension::RemoveExternalPage( HPROPSHEETPAGE hPage, UINT uDlgID )
  88. {
  89. if ( (uDlgID < EXTERNAL_DIALOGID_MINIMUM) || (EXTERNAL_DIALOGID_MAXIMUM < uDlgID) )
  90. {
  91. TraceMsg(TF_ICWEXTSN, TEXT("ICWEXTSN: SetFirstLastPage: uDlgID %d is out of range!"), uDlgID);
  92. return( FALSE );
  93. }
  94. if( DialogIDAlreadyInUse(uDlgID) )
  95. {
  96. SetDialogIDInUse( uDlgID, FALSE );
  97. PropSheet_RemovePage(m_hWizardHWND, NULL, hPage);
  98. TraceMsg(TF_ICWEXTSN, TEXT("ICWEXTSN: propmgr: PS_RemovePage DlgID %d"), uDlgID);
  99. return(TRUE);
  100. }
  101. else
  102. {
  103. TraceMsg(TF_ICWEXTSN, TEXT("ICWEXTSN: RemoveExternalPage: DlgID %d was not marked as in use!"), uDlgID);
  104. return(FALSE);
  105. }
  106. }
  107. //+----------------------------------------------------------------------------
  108. //
  109. // Function CICWExtension::ExternalCancel
  110. //
  111. // Synopsis Notifies the wizard that the user has cancelled while in the
  112. // apprentice pages
  113. //
  114. //
  115. // Arguments uCancelType -- tells the wizard whether it should immediately
  116. // quit out, or whether it should show the confirmation
  117. // dialog (as though the user had hit Cancel within the
  118. // wizard itself.)
  119. //
  120. //
  121. // Returns TRUE if we're about to exit the wizard
  122. // FALSE if not.
  123. //
  124. //
  125. // History 4/23/97 jmazner created
  126. //
  127. //-----------------------------------------------------------------------------
  128. BOOL CICWExtension::ExternalCancel( CANCELTYPE uCancelType )
  129. {
  130. TraceMsg(TF_ICWEXTSN, TEXT("ICWEXTSN: propmgr.cpp: received ExternalCancel callback"));
  131. switch( uCancelType )
  132. {
  133. case CANCEL_PROMPT:
  134. gfUserCancelled = (MsgBox(m_hWizardHWND,
  135. IDS_QUERYCANCEL,
  136. MB_ICONQUESTION,MB_YESNO | MB_DEFBUTTON2) == IDYES);
  137. if( gfUserCancelled )
  138. {
  139. PropSheet_PressButton( m_hWizardHWND, PSBTN_CANCEL );
  140. gfQuitWizard = TRUE;
  141. return( TRUE );
  142. }
  143. else
  144. {
  145. return( FALSE );
  146. }
  147. break;
  148. case CANCEL_SILENT:
  149. PropSheet_PressButton( m_hWizardHWND, PSBTN_CANCEL );
  150. gfQuitWizard = TRUE;
  151. return( TRUE );
  152. break;
  153. case CANCEL_REBOOT:
  154. PropSheet_PressButton( m_hWizardHWND, PSBTN_CANCEL );
  155. gfQuitWizard = TRUE;
  156. gpWizardState->fNeedReboot = TRUE;
  157. return( TRUE );
  158. break;
  159. default:
  160. TraceMsg(TF_ICWEXTSN, TEXT("ICWEXTSN: ExternalCancel got an unkown CancelType!"));
  161. return( FALSE );
  162. }
  163. }
  164. //+----------------------------------------------------------------------------
  165. //
  166. // Function CICWExtension::SetFirstLastPage
  167. //
  168. // Synopsis Lets the apprentice notify the wizard of the dialog IDs of the
  169. // first and last pages in the apprentice
  170. //
  171. //
  172. // Arguments uFirstPageDlgID -- DlgID of first page in apprentice.
  173. // uLastPageDlgID -- DlgID of last page in apprentice
  174. //
  175. //
  176. // Returns FALSE if the parameters passed in are out of range
  177. // TRUE if the update succeeded.
  178. //
  179. // Notes: If either variable is set to 0, the function will not update
  180. // that information, i.e. a value of 0 means "ignore me". If both
  181. // variables are 0, the function immediately returns FALSE.
  182. //
  183. // History 4/23/97 jmazner created
  184. //
  185. //-----------------------------------------------------------------------------
  186. BOOL CICWExtension::SetFirstLastPage(UINT uFirstPageDlgID, UINT uLastPageDlgID)
  187. {
  188. // validation code galore!
  189. if( (0 == uFirstPageDlgID) && (0 == uLastPageDlgID) )
  190. {
  191. TraceMsg(TF_ICWEXTSN, TEXT("ICWEXTSN: SetFirstLastPage: both IDs are 0!"));
  192. return( FALSE );
  193. }
  194. if( (0 != uFirstPageDlgID) )
  195. {
  196. if ( (uFirstPageDlgID < EXTERNAL_DIALOGID_MINIMUM) || (EXTERNAL_DIALOGID_MAXIMUM < uFirstPageDlgID) )
  197. {
  198. TraceMsg(TF_ICWEXTSN, TEXT("ICWEXTSN: SetFirstLastPage: uFirstPageDlgID %d is out of range!"), uFirstPageDlgID);
  199. return( FALSE );
  200. }
  201. if( !DialogIDAlreadyInUse(uFirstPageDlgID) )
  202. {
  203. TraceMsg(TF_ICWEXTSN, TEXT("ICWEXTSN: SetFirstLastPage: uFirstPageDlgID %d not marked as in use!"), uFirstPageDlgID);
  204. return( FALSE );
  205. }
  206. }
  207. if( (0 != uLastPageDlgID) )
  208. {
  209. if ( (uLastPageDlgID < EXTERNAL_DIALOGID_MINIMUM) || (EXTERNAL_DIALOGID_MAXIMUM < uLastPageDlgID) )
  210. {
  211. TraceMsg(TF_ICWEXTSN, TEXT("ICWEXTSN: SetFirstLastPage: uLastPageDlgID %d is out of range!"), uFirstPageDlgID);
  212. return( FALSE );
  213. }
  214. if( !DialogIDAlreadyInUse(uLastPageDlgID) )
  215. {
  216. TraceMsg(TF_ICWEXTSN, TEXT("ICWEXTSN: SetFirstLastPage: uLastPageDlgID %d not marked as in use!"), uFirstPageDlgID);
  217. return( FALSE );
  218. }
  219. }
  220. if( 0 != uFirstPageDlgID )
  221. g_uICWCONNUIFirst = uFirstPageDlgID;
  222. if( 0 != uLastPageDlgID )
  223. g_uICWCONNUILast = uLastPageDlgID;
  224. TraceMsg(TF_ICWEXTSN, TEXT("ICWEXTSN: SetFirstLastPage: updating mail, first = %d, last = %d"),
  225. uFirstPageDlgID, uLastPageDlgID);
  226. return TRUE;
  227. }
  228. //+----------------------------------------------------------------------------
  229. //
  230. // Function CICWExtension::QueryInterface
  231. //
  232. // Synopsis This is the standard QI, with support for
  233. // IID_Unknown, IICW_Extension and IID_ICW50Apprentice
  234. // (Taken from Inside COM, chapter 7)
  235. //
  236. // History 4/23/97 jmazner created
  237. //
  238. //-----------------------------------------------------------------------------
  239. HRESULT CICWExtension::QueryInterface( REFIID riid, void** ppv )
  240. {
  241. if (ppv == NULL)
  242. return(E_INVALIDARG);
  243. *ppv = NULL;
  244. // IID_IICW50Apprentice
  245. if (IID_IICW50Apprentice == riid)
  246. *ppv = (void *)(IICW50Apprentice *)this;
  247. // IID_IICWExtension
  248. else if (IID_IICW50Extension == riid)
  249. *ppv = (void *)(IICW50Extension *)this;
  250. // IID_IUnknown
  251. else if (IID_IUnknown == riid)
  252. *ppv = (void *)this;
  253. else
  254. return(E_NOINTERFACE);
  255. ((LPUNKNOWN)*ppv)->AddRef();
  256. return(S_OK);
  257. }
  258. //+----------------------------------------------------------------------------
  259. //
  260. // Function CICWExtension::AddRef
  261. //
  262. // Synopsis This is the standard AddRef
  263. //
  264. // History 4/23/97 jmazner created
  265. //
  266. //-----------------------------------------------------------------------------
  267. ULONG CICWExtension::AddRef( void )
  268. {
  269. TraceMsg(TF_ICWEXTSN, TEXT("ICWEXTSN: CICWExtension::AddRef called %d"), m_lRefCount + 1);
  270. return InterlockedIncrement(&m_lRefCount) ;
  271. }
  272. //+----------------------------------------------------------------------------
  273. //
  274. // Function CICWExtension::Release
  275. //
  276. // Synopsis This is the standard Release
  277. //
  278. // History 4/23/97 jmazner created
  279. //
  280. //-----------------------------------------------------------------------------
  281. ULONG CICWExtension::Release( void )
  282. {
  283. ASSERT( m_lRefCount > 0 );
  284. InterlockedDecrement(&m_lRefCount);
  285. TraceMsg(TF_ICWEXTSN, TEXT("ICWEXTSN: CICWExtension::Release called %d"), m_lRefCount);
  286. if( 0 == m_lRefCount )
  287. {
  288. delete( this );
  289. return( 0 );
  290. }
  291. else
  292. {
  293. return( m_lRefCount );
  294. }
  295. }
  296. //+----------------------------------------------------------------------------
  297. //
  298. // Function CICWExtension::CICWExtension
  299. //
  300. // Synopsis The constructor. Initializes member variables to NULL.
  301. //
  302. // History 4/23/97 jmazner created
  303. //
  304. //-----------------------------------------------------------------------------
  305. CICWExtension::CICWExtension( void )
  306. {
  307. TraceMsg(TF_ICWEXTSN, TEXT("ICWEXTSN: CICWExtension constructor called"));
  308. m_lRefCount = 0;
  309. m_hWizardHWND = NULL;
  310. }
  311. //+----------------------------------------------------------------------------
  312. //
  313. // Function CICWExtension::CICWExtension
  314. //
  315. // Synopsis The constructor. Since there was no fancy initialization,
  316. // there's nothing to do here.
  317. //
  318. // History 4/23/97 jmazner created
  319. //
  320. //-----------------------------------------------------------------------------
  321. CICWExtension::~CICWExtension( void )
  322. {
  323. TraceMsg(TF_ICWEXTSN, TEXT("ICWEXTSN: CICWExtension destructor called with ref count of %d"), m_lRefCount);
  324. }