Source code of Windows XP (NT5)
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.

1827 lines
34 KiB

  1. /*++
  2. Copyright (C) Microsoft Corporation, 1995 - 1999
  3. All rights reserved.
  4. Module Name:
  5. setup.hxx
  6. Abstract:
  7. Holds install headers.
  8. Author:
  9. Albert Ting (AlbertT) 17-Sept-1995
  10. Revision History:
  11. --*/
  12. #ifndef _SETUP_HXX
  13. #define _SETUP_HXX
  14. /********************************************************************
  15. Class forward refrences
  16. ********************************************************************/
  17. class TFindLocDlg;
  18. /********************************************************************
  19. Defines a copy constructor and an assignment operator.
  20. Use this macro in the private section of your class if you
  21. do not support copying and assignment.
  22. ********************************************************************/
  23. #define DEFINE_COPY_ASSIGNMENT( Type ) \
  24. Type( const Type & ); \
  25. Type & operator =( const Type & )
  26. /********************************************************************
  27. Defines a function to return the specified wizard page id.
  28. ********************************************************************/
  29. #define DEFINE_PAGE_IDENTIFIER( PageId ) \
  30. protected: \
  31. UINT \
  32. uGetPageId( \
  33. VOID \
  34. ) const \
  35. { \
  36. return PageId; \
  37. }
  38. /********************************************************************
  39. Constants
  40. ********************************************************************/
  41. const BOOL kDefaultShareState = FALSE;
  42. const BOOL kDefaultPublishState = TRUE;
  43. const DWORD kDefaultAdditionalDrivers = TArchLV::kDriverWIN95 |
  44. TArchLV::kDriverX86_2 |
  45. TArchLV::kDriverX86_3 |
  46. TArchLV::kDriverALPHA_2 |
  47. TArchLV::kDriverALPHA_3;
  48. /********************************************************************
  49. Printer setup wizard class.
  50. ********************************************************************/
  51. class TWizard: public CSimpleWndSubclass<TWizard> {
  52. SIGNATURE( 'prwz' )
  53. DEFINE_COPY_ASSIGNMENT( TWizard );
  54. public:
  55. enum PROP_PAGES {
  56. kPropPreIntro,
  57. kPropIntro,
  58. kPropType,
  59. kPropAutodetect,
  60. kPropPort,
  61. kPropPreSelectDevice,
  62. kPropDriver,
  63. kPropPostSelectDevice,
  64. kPropDriverExists,
  65. kPropName,
  66. kPropShare,
  67. kPropComment,
  68. kPropTestPage,
  69. kPropNet,
  70. kPropLocate,
  71. kPropFinish,
  72. kPropBrowse,
  73. kPropMax
  74. };
  75. enum DRIVER_EXISTS {
  76. kUninitialized = 0,
  77. kExists = 1,
  78. kDoesNotExist = 2
  79. };
  80. enum PNP_CONSTANTS {
  81. kPnPInstall = 1000,
  82. kDriverInstall = 1001,
  83. kPrinterInstall = 1002,
  84. kPrinterInstallModeless = 1003,
  85. };
  86. enum {
  87. kSelectDriverPage = -1,
  88. kSelectPrinterPage = -2,
  89. kInitialStackSize = kPropMax,
  90. };
  91. //
  92. // Some global constants
  93. //
  94. enum {
  95. //
  96. // This is the max number we try to generate a friendly printer name
  97. // in the form "Driver Name (Copy %d)". This number should be reasonably
  98. // small because we don't want performance hit on hydra.
  99. //
  100. kAddPrinterMaxRetry = 5,
  101. };
  102. enum ELocateType {
  103. kSearch,
  104. kBrowseNET,
  105. kBrowseURL,
  106. };
  107. enum EDsStatus {
  108. kDsStatusUnknown,
  109. kDsStatusUnavailable,
  110. kDsStatusAvailable,
  111. };
  112. //
  113. // Add printer attribute values.
  114. //
  115. enum EAddPrinterAttributes
  116. {
  117. kAttributesNone,
  118. kAttributesMasq,
  119. };
  120. struct Page {
  121. MGenericProp *pPage;
  122. INT iDialog;
  123. INT iTitle;
  124. INT iSubTitle;
  125. };
  126. struct AddInfo {
  127. LPCTSTR pszServerName;
  128. LPCTSTR pszPrinterName;
  129. LPCTSTR pszShareName;
  130. LPCTSTR pszPrintProcessor;
  131. DWORD dwAttributes;
  132. BOOL bShared;
  133. BOOL bPublish;
  134. EAddPrinterAttributes eFlags;
  135. EDsStatus eIsDsAvailable;
  136. };
  137. struct DriverTypes {
  138. UINT uBit;
  139. DWORD dwEncode;
  140. LPCTSTR pName;
  141. };
  142. Page _aPages[kPropMax];
  143. VAR( BOOL, bValid );
  144. VAR( UINT, uAction );
  145. VAR( HWND, hwnd );
  146. VAR( TString, strPrinterName );
  147. VAR( TStack<UINT>, Stack );
  148. VAR( BOOL, bNoPageChange );
  149. VAR( BOOL, bPreDir );
  150. VAR( BOOL, bPostDir );
  151. VAR( BOOL, bIsPrinterFolderEmpty );
  152. //
  153. // If pszServerName is NULL, this indicates it's the local machine.
  154. // If it's non-NULL, then it's a remote server.
  155. //
  156. VAR( LPCTSTR, pszServerName );
  157. VAR( TString, strServerName );
  158. VAR( TString, strPortName );
  159. VAR( TString, strShareName );
  160. VAR( TString, strDriverName );
  161. VAR( TString, strTitle );
  162. VAR( TString, strSetupPageTitle );
  163. VAR( TString, strSetupPageSubTitle );
  164. VAR( TString, strSetupPageDescription );
  165. VAR( TString, strInfFileName );
  166. VAR( TString, strLocation );
  167. VAR( TString, strComment );
  168. VAR( BOOL, bUseNewDriver );
  169. VAR( UINT, uDriverExists );
  170. VAR( BOOL, bNet );
  171. VAR( BOOL, bDefaultPrinter );
  172. VAR( BOOL, bShared );
  173. VAR( BOOL, bTestPage );
  174. VAR( BOOL, bSetDefault );
  175. VAR( BOOL, bShowSetDefault );
  176. VAR( BOOL, bPrinterCreated );
  177. VAR( BOOL, bConnected );
  178. VAR( BOOL, bErrorSaving );
  179. VAR( BOOL, bDriverChanged );
  180. VAR( BOOL, bRefreshPrinterName );
  181. VAR( BOOL, bWizardCanceled );
  182. VAR( BOOL, bUseNewDriverSticky );
  183. VAR( TPrinterDriverInstallation, Di );
  184. VAR( EDsStatus, eIsDsAvailablePerMachine );
  185. VAR( EDsStatus, eIsDsAvailablePerUser );
  186. VAR( BOOL, bNetworkInstalled);
  187. VAR( TArchLV, ArchLV );
  188. VAR( TDriverTransfer *, pDriverTransfer );
  189. VAR( BOOL, bIsCodeDownLoadAvailable );
  190. VAR( BOOL, bUseWeb );
  191. VAR( BOOL, bSkipArchSelection );
  192. VAR( BOOL, bPersistSettings );
  193. VAR( BOOL, bPublish );
  194. VAR( DWORD, dwDefaultAttributes );
  195. VAR( INT, LocateType );
  196. VAR( TDirectoryService, Ds );
  197. VAR( BOOL, bDownlevelBrowse );
  198. VAR( DWORD, dwAdditionalDrivers );
  199. VAR( BOOL, bAdditionalDrivers );
  200. VAR( BOOL, bIsNTServer );
  201. VAR( UINT, nDriverInstallCount );
  202. VAR( HFONT, hBigBoldFont );
  203. //
  204. // Browse for printer property page vars ...
  205. //
  206. VAR( BOOL, bAdminPrivilege );
  207. VAR( TString, strPrintersPageURL );
  208. VAR( UINT, nBrowsePageID );
  209. VAR( IPageSwitch*, pPageSwitchController );
  210. VAR( BOOL, bStylePatched );
  211. VAR( BOOL, bPrinterAutoDetected );
  212. VAR( BOOL, bPnPAutodetect );
  213. VAR( BOOL, bRunDetection );
  214. VAR( COleComInitializer, COM );
  215. VAR( BOOL, bRestartableFromLastPage );
  216. VAR( BOOL, bRestartAgain );
  217. VAR( BOOL, bIsSharingEnabled );
  218. VAR( int, iPosX );
  219. VAR( int, iPosY );
  220. TWizard(
  221. HWND hwnd,
  222. UINT uAction,
  223. LPCTSTR pszPrinterName,
  224. LPCTSTR pszServerName
  225. );
  226. ~TWizard(
  227. VOID
  228. );
  229. BOOL
  230. bPropPages(
  231. VOID
  232. );
  233. BOOL
  234. bAddPages(
  235. IN OUT PSP_INSTALLWIZARD_DATA pWizardData
  236. );
  237. VOID
  238. vTerminate(
  239. IN HWND hDlg
  240. );
  241. BOOL
  242. bCreatePrinter(
  243. IN HWND hwnd = NULL
  244. );
  245. BOOL
  246. bParseDriver(
  247. IN HWND hDlg
  248. );
  249. BOOL
  250. bDriverExists(
  251. VOID
  252. );
  253. static
  254. BOOL
  255. bInstallPrinter(
  256. IN LPCTSTR pszServerName,
  257. IN LPCTSTR pszPrinterName,
  258. IN LPCTSTR pszShareName,
  259. IN LPCTSTR pszPortName,
  260. IN LPCTSTR pszDriverName,
  261. IN LPCTSTR pszPrintProcessor,
  262. IN LPCTSTR pszLocation,
  263. IN LPCTSTR pszComment,
  264. IN BOOL bShared,
  265. IN BOOL bPublish,
  266. IN EAddPrinterAttributes eAttributeFlags,
  267. IN EDsStatus eIsDsAvailable,
  268. IN DWORD dwAttributes,
  269. IN PSECURITY_DESCRIPTOR pSecurityDescriptor
  270. );
  271. BOOL
  272. bPrintTestPage(
  273. VOID
  274. );
  275. UINT
  276. MapPageID(
  277. UINT uPageID
  278. ) const;
  279. VOID
  280. OnWizardInitro(
  281. HWND hDlgIntroPage
  282. );
  283. VOID
  284. OnWizardFinish(
  285. HWND hDlgFinishPage
  286. );
  287. BOOL
  288. bShouldRestart(
  289. VOID
  290. );
  291. // implement CSimpleWndSubclass<...>
  292. LRESULT
  293. WindowProc(
  294. IN HWND hwnd,
  295. IN UINT uMsg,
  296. IN WPARAM wParam,
  297. IN LPARAM lParam
  298. );
  299. private:
  300. static
  301. INT CALLBACK
  302. iSetupDlgCallback(
  303. IN HWND hwndDlg,
  304. IN UINT uMsg,
  305. IN LPARAM lParam
  306. );
  307. static
  308. BOOL
  309. bPreAddPrinter(
  310. IN AddInfo &Info
  311. );
  312. static
  313. BOOL
  314. bPostAddPrinter(
  315. IN AddInfo &Info,
  316. IN HANDLE hPrinter
  317. );
  318. BOOL
  319. bCreatePages(
  320. VOID
  321. );
  322. VOID
  323. vReadRegistrySettingDefaults(
  324. VOID
  325. );
  326. VOID
  327. vWriteRegistrySettingDefaults(
  328. VOID
  329. );
  330. BOOL
  331. bAddAdditionalDrivers(
  332. IN HWND hwnd = NULL
  333. );
  334. BOOL
  335. bCreatePropPages(
  336. IN UINT *pnPageHandles,
  337. IN UINT nPageHandles,
  338. IN HPROPSHEETPAGE *pPageHandles,
  339. IN UINT nPages,
  340. IN Page *pPages
  341. );
  342. VOID
  343. SetupFonts(
  344. IN HINSTANCE hInstance,
  345. IN HWND hwnd,
  346. IN HFONT *hBigBoldFont
  347. );
  348. BOOL
  349. bInsertPage(
  350. IN OUT UINT &Index,
  351. IN MGenericProp *pWizPage,
  352. IN UINT uDlgId,
  353. IN UINT uTitleId = IDS_WIZ_TITLE,
  354. IN UINT uSubTitleId = IDS_WIZ_SUBTITLE
  355. );
  356. HRESULT
  357. ServerAccessCheck(
  358. LPCTSTR pszServer,
  359. BOOL *pbFullAccess
  360. );
  361. };
  362. /********************************************************************
  363. Page switch controller class (implements IPageSwitch)
  364. ********************************************************************/
  365. class TPageSwitch: public IPageSwitch
  366. {
  367. SIGNATURE( 'pwps' )
  368. //
  369. // Do not allow this class to be copied
  370. //
  371. DEFINE_COPY_ASSIGNMENT( TPageSwitch );
  372. public:
  373. TPageSwitch(
  374. TWizard *pWizard
  375. );
  376. ~TPageSwitch(
  377. VOID
  378. );
  379. //
  380. // Implementation of INotifyReflect methods
  381. //
  382. STDMETHOD(GetPrevPageID)( THIS_ UINT *puPageID ) ;
  383. STDMETHOD(GetNextPageID)( THIS_ UINT *puPageID ) ;
  384. STDMETHOD(SetPrinterInfo)( THIS_ LPCTSTR pszPrinterName, LPCTSTR pszComment, LPCTSTR pszLocation, LPCTSTR pszShareName ) ;
  385. STDMETHOD(QueryCancel)( THIS_ ) ;
  386. private:
  387. VAR( TWizard*, pWizard );
  388. };
  389. /********************************************************************
  390. Mixin Wizard property sheet class.
  391. ********************************************************************/
  392. class MWizardProp : public MGenericProp {
  393. SIGNATURE( 'wizp' )
  394. DEFINE_COPY_ASSIGNMENT( MWizardProp );
  395. public:
  396. MWizardProp(
  397. IN TWizard *pWizard
  398. );
  399. virtual
  400. ~MWizardProp(
  401. VOID
  402. );
  403. protected:
  404. VAR(TWizard*, pWizard);
  405. virtual
  406. BOOL
  407. bHandle_InitDialog(
  408. VOID
  409. );
  410. virtual
  411. BOOL
  412. bHandle_Command(
  413. IN WORD wId,
  414. IN WORD wNotifyId,
  415. IN HWND hwnd
  416. );
  417. VOID
  418. SetControlFont(
  419. IN HFONT hFont,
  420. IN HWND hwnd,
  421. IN INT nId
  422. );
  423. virtual
  424. BOOL
  425. bHandle_Notify(
  426. IN WPARAM wIdCtrl,
  427. IN LPNMHDR pnmh
  428. );
  429. virtual
  430. BOOL
  431. bHandle_SetActive(
  432. VOID
  433. );
  434. virtual
  435. BOOL
  436. bHandle_KillActive(
  437. VOID
  438. );
  439. virtual
  440. BOOL
  441. bHandle_WizBack(
  442. VOID
  443. );
  444. virtual
  445. BOOL
  446. bHandle_WizNext(
  447. VOID
  448. );
  449. virtual
  450. BOOL
  451. bHandle_WizFinish(
  452. VOID
  453. );
  454. virtual
  455. BOOL
  456. bHandle_Cancel(
  457. VOID
  458. );
  459. virtual
  460. BOOL
  461. bHandle_Timer(
  462. IN WPARAM wIdTimer,
  463. IN TIMERPROC *tmProc
  464. );
  465. virtual
  466. UINT
  467. uGetPageId(
  468. VOID
  469. ) const = 0;
  470. private:
  471. enum {
  472. kFalse = FALSE,
  473. kTrue = TRUE,
  474. kDontCare = -1,
  475. kPush = -2,
  476. kPop = -3,
  477. kNone = -4,
  478. kEnd = -5,
  479. kSetButtonState = -6,
  480. kNoPage = -7,
  481. kSkipPage = -8,
  482. };
  483. struct DriverWizPageEntry {
  484. INT uMessage;
  485. INT uCurrentPage;
  486. INT uSkipArchPage;
  487. INT uPreDir;
  488. INT uPostDir;
  489. INT Result;
  490. INT Action;
  491. };
  492. struct PrinterWizPageEntry {
  493. INT uMessage;
  494. INT uCurrentPage;
  495. INT uSharingEnabled;
  496. INT uAutodetect;
  497. INT uPrinterDetected;
  498. INT uPnPInstall;
  499. INT uKeepExisting;
  500. INT uDriverExists;
  501. INT uSharing;
  502. INT uNetwork;
  503. INT bIsRemoteServer;
  504. INT uDirectoryService;
  505. INT uPreDir;
  506. INT uPostDir;
  507. INT uSetDefault;
  508. INT uShared;
  509. INT bAdminPrivilege;
  510. INT nLocateType;
  511. INT nDownlevelBrowse;
  512. INT uConnected;
  513. INT Result;
  514. INT Action;
  515. };
  516. BOOL
  517. bHandle_PageChange(
  518. BOOL bReturn,
  519. UINT uMsg,
  520. WPARAM wParam,
  521. LPARAM lParam
  522. );
  523. BOOL
  524. bDriverWizardPageChange(
  525. IN UINT uMsg
  526. );
  527. BOOL
  528. bAddPrinterWizardPageChange(
  529. IN UINT uMsg
  530. );
  531. BOOL
  532. bHandleMessage(
  533. IN UINT uMsg,
  534. IN WPARAM wParam,
  535. IN LPARAM lParam
  536. );
  537. VOID
  538. vCheckToPatchStyles(
  539. VOID
  540. );
  541. };
  542. class TWizPreIntro : public MWizardProp {
  543. DEFINE_COPY_ASSIGNMENT( TWizPreIntro );
  544. DEFINE_PAGE_IDENTIFIER( DLG_WIZ_PRE_INTRO );
  545. public:
  546. TWizPreIntro(
  547. TWizard* pWizard
  548. );
  549. private:
  550. //
  551. // Virtual override for MWizardProp.
  552. //
  553. BOOL
  554. bHandle_SetActive(
  555. VOID
  556. );
  557. };
  558. class TWizIntro : public MWizardProp {
  559. DEFINE_COPY_ASSIGNMENT( TWizIntro );
  560. DEFINE_PAGE_IDENTIFIER( DLG_WIZ_INTRO );
  561. public:
  562. TWizIntro(
  563. TWizard* pWizard
  564. );
  565. private:
  566. //
  567. // Virtual override for MWizardProp.
  568. //
  569. BOOL
  570. bHandle_InitDialog(
  571. VOID
  572. );
  573. };
  574. class TWizFinish : public MWizardProp {
  575. DEFINE_COPY_ASSIGNMENT( TWizFinish );
  576. DEFINE_PAGE_IDENTIFIER( DLG_WIZ_FINISH );
  577. public:
  578. TWizFinish(
  579. TWizard* pWizard
  580. );
  581. private:
  582. //
  583. // Virtual override for MWizardProp.
  584. //
  585. BOOL
  586. bHandle_InitDialog(
  587. VOID
  588. );
  589. BOOL
  590. bHandle_WizFinish(
  591. VOID
  592. );
  593. BOOL
  594. bHandle_SetActive(
  595. VOID
  596. );
  597. };
  598. class TWizType : public MWizardProp {
  599. DEFINE_COPY_ASSIGNMENT( TWizType );
  600. DEFINE_PAGE_IDENTIFIER( DLG_WIZ_TYPE );
  601. public:
  602. TWizType(
  603. TWizard* pWizard
  604. );
  605. static
  606. BOOL
  607. bConnectToPrinter(
  608. IN HWND hDlg,
  609. IN TString &strPrinterName,
  610. IN TString *pstrComment = NULL,
  611. IN TString *pstrLocation = NULL,
  612. IN TString *pstrShareName = NULL
  613. );
  614. private:
  615. //
  616. // Virtual override for MWizardProp.
  617. //
  618. VOID
  619. vReadUI(
  620. VOID
  621. );
  622. BOOL
  623. bHandle_InitDialog(
  624. VOID
  625. );
  626. BOOL
  627. bHandle_SetActive(
  628. VOID
  629. );
  630. BOOL
  631. bHandle_WizNext(
  632. VOID
  633. );
  634. BOOL
  635. bHandle_Command(
  636. IN WORD wId,
  637. IN WORD wNotifyId,
  638. IN HWND hwnd
  639. );
  640. };
  641. class TWizDetect : public MWizardProp {
  642. DEFINE_COPY_ASSIGNMENT( TWizDetect );
  643. DEFINE_PAGE_IDENTIFIER( DLG_WIZ_DETECT );
  644. public:
  645. TWizDetect(
  646. TWizard* pWizard
  647. );
  648. private:
  649. //
  650. // Virtual override for MWizardProp.
  651. //
  652. VOID
  653. vReadUI(
  654. VOID
  655. );
  656. BOOL
  657. bHandle_InitDialog(
  658. VOID
  659. );
  660. BOOL
  661. bHandle_SetActive(
  662. VOID
  663. );
  664. BOOL
  665. bHandle_WizNext(
  666. VOID
  667. );
  668. BOOL
  669. bHandle_Cancel(
  670. VOID
  671. );
  672. BOOL
  673. bHandle_Timer(
  674. IN WPARAM wIdTimer,
  675. IN TIMERPROC *tmProc
  676. );
  677. VOID
  678. vToggleTestPageControls(
  679. int nCmdShow
  680. );
  681. VOID
  682. vStartAnimation(
  683. BOOL bStart = TRUE
  684. );
  685. //
  686. // Some private constants
  687. //
  688. enum
  689. {
  690. POLLING_TIMER_ID = 1, // The polling timer ID
  691. POLLING_TIMER_INTERVAL = 200 // Polling timer interval
  692. };
  693. VAR( TPnPDetect, pnpPrinterDetector );
  694. };
  695. class TWizDriverExists : public MWizardProp {
  696. DEFINE_COPY_ASSIGNMENT( TWizDriverExists );
  697. DEFINE_PAGE_IDENTIFIER( DLG_WIZ_DRIVEREXISTS );
  698. public:
  699. TWizDriverExists(
  700. TWizard* pWizard
  701. );
  702. private:
  703. //
  704. // Virtual override for MWizardProp.
  705. //
  706. BOOL
  707. bHandle_SetActive(
  708. VOID
  709. );
  710. BOOL
  711. bHandle_InitDialog(
  712. VOID
  713. );
  714. BOOL
  715. TWizDriverExists::
  716. bHandle_WizNext(
  717. VOID
  718. );
  719. VOID
  720. vReadUI(
  721. VOID
  722. );
  723. };
  724. class TWizPort : public MWizardProp {
  725. DEFINE_COPY_ASSIGNMENT( TWizPort );
  726. DEFINE_PAGE_IDENTIFIER( DLG_WIZ_PORT );
  727. public:
  728. TWizPort(
  729. TWizard* pWizard
  730. );
  731. BOOL
  732. bValid(
  733. VOID
  734. );
  735. private:
  736. TPortsLV _PortsLV;
  737. HWND _hMonitorList;
  738. //
  739. // Virtual override for MWizardProp.
  740. //
  741. BOOL
  742. bHandle_Command(
  743. IN WORD wId,
  744. IN WORD wNotifyId,
  745. IN HWND hwnd
  746. );
  747. BOOL
  748. bHandle_InitDialog(
  749. VOID
  750. );
  751. BOOL
  752. bHandle_WizNext(
  753. VOID
  754. );
  755. BOOL
  756. bHandle_Notify(
  757. IN WPARAM wIdCtrl,
  758. IN LPNMHDR pnmh
  759. );
  760. BOOL
  761. bHandle_SetActive(
  762. VOID
  763. );
  764. VOID
  765. vSelectionPort(
  766. VOID
  767. );
  768. BOOL
  769. bInitializeMonitorList(
  770. VOID
  771. );
  772. BOOL
  773. bGetSelectedMonitor(
  774. IN TString &strMonitor
  775. );
  776. VOID
  777. vEnableMonitorList(
  778. VOID
  779. );
  780. VOID
  781. vDisableMonitorList(
  782. VOID
  783. );
  784. VOID
  785. vSetFocusMonitorList(
  786. VOID
  787. );
  788. VOID
  789. vSelectionMonitor(
  790. VOID
  791. );
  792. BOOL
  793. bIsRemoteableMonitor(
  794. IN LPCTSTR pszMonitorName
  795. );
  796. };
  797. class TWizPortNew: public MWizardProp
  798. {
  799. DEFINE_COPY_ASSIGNMENT(TWizPortNew);
  800. DEFINE_PAGE_IDENTIFIER(DLG_WIZ_PORT_NEW);
  801. public:
  802. // construction/destruction
  803. TWizPortNew(
  804. TWizard* pWizard
  805. );
  806. // port types in order of importance
  807. enum
  808. {
  809. PORT_TYPE_LPT1, // LPT1 is the recommended printer port (pri 0)
  810. PORT_TYPE_LPTX, // LPTX the rest paralell ports (pri 1)
  811. PORT_TYPE_COMX, // COMX the serial ports (pri 2)
  812. PORT_TYPE_FILE, // the print to file ports (pri 3)
  813. PORT_TYPE_OTHER, // other port type - local, internet ports, TS ports, etc... (pri 4)
  814. PORT_TYPE_LAST
  815. };
  816. private:
  817. struct PortInfo
  818. {
  819. int iType; // port type - see above
  820. LPCTSTR pszName; // port name
  821. LPCTSTR pszDesc; // port decription
  822. };
  823. // overrides & private members
  824. BOOL
  825. bHandle_Command(
  826. IN WORD wId,
  827. IN WORD wNotifyId,
  828. IN HWND hwnd
  829. );
  830. BOOL
  831. bHandle_InitDialog(
  832. VOID
  833. );
  834. BOOL
  835. bHandle_SetActive(
  836. VOID
  837. );
  838. BOOL
  839. bHandle_WizNext(
  840. VOID
  841. );
  842. VOID
  843. vSelectionPort(
  844. VOID
  845. );
  846. VOID
  847. vSelectionMonitor(
  848. VOID
  849. );
  850. BOOL
  851. bInitializePortsList(
  852. OUT int *piNewlyAdded
  853. );
  854. BOOL
  855. bInitializeMonitorsList(
  856. VOID
  857. );
  858. BOOL
  859. bIsRemoteableMonitor(
  860. IN LPCTSTR pszMonitorName
  861. );
  862. VOID
  863. vSelectPortsRadio(
  864. VOID
  865. );
  866. HRESULT
  867. hGetPorts(
  868. OUT int *piNewlyAdded
  869. );
  870. static int
  871. iGetPortType(
  872. IN LPCTSTR pszPortName
  873. );
  874. static BOOL
  875. bFormatPortName(
  876. IN const PortInfo &pi,
  877. OUT TString *pstrFriendlyName
  878. );
  879. class CPortsAdaptor: public Alg::CDefaultAdaptor<PortInfo>
  880. {
  881. public:
  882. // special comparition based on type & name
  883. static int Compare(const PortInfo &i1, const PortInfo &i2)
  884. {
  885. return (i1.iType == i2.iType ?
  886. // if the types are the same then compare the names
  887. lstrcmp(i1.pszName, i2.pszName) :
  888. // ... else compare the types
  889. Alg::CDefaultAdaptor<int>::Compare(i1.iType, i2.iType));
  890. }
  891. };
  892. typedef CSortedArray<PortInfo, PortInfo, CPortsAdaptor> CPortsArray;
  893. // data members
  894. HWND m_hwndCB_Ports;
  895. HWND m_hwndCB_Monitors;
  896. CAutoHandleBitmap m_hBmp;
  897. CAutoPtrSpl<BYTE> m_spBuffer;
  898. CAutoPtr<CPortsArray> m_spPorts;
  899. };
  900. class TWizName : public MWizardProp {
  901. DEFINE_COPY_ASSIGNMENT( TWizName );
  902. DEFINE_PAGE_IDENTIFIER( DLG_WIZ_NAME );
  903. public:
  904. TWizName(
  905. TWizard* pWizard
  906. );
  907. private:
  908. TString _strGeneratedPrinterName;
  909. //
  910. // Virtual override for MWizardProp.
  911. //
  912. BOOL
  913. bHandle_InitDialog(
  914. VOID
  915. );
  916. VOID
  917. vReadUI(
  918. VOID
  919. );
  920. BOOL
  921. bHandle_SetActive(
  922. VOID
  923. );
  924. BOOL
  925. bHandle_WizNext(
  926. VOID
  927. );
  928. VOID
  929. vUpdateName(
  930. VOID
  931. );
  932. };
  933. class TWizTestPage : public MWizardProp {
  934. DEFINE_COPY_ASSIGNMENT( TWizTestPage );
  935. DEFINE_PAGE_IDENTIFIER( DLG_WIZ_TEST_PAGE );
  936. public:
  937. TWizTestPage(
  938. TWizard* pWizard
  939. );
  940. private:
  941. //
  942. // Virtual override for MWizardProp.
  943. //
  944. BOOL
  945. bHandle_InitDialog(
  946. VOID
  947. );
  948. VOID
  949. vReadUI(
  950. VOID
  951. );
  952. BOOL
  953. bHandle_SetActive(
  954. VOID
  955. );
  956. BOOL
  957. bHandle_WizNext(
  958. VOID
  959. );
  960. };
  961. class TWizShare : public MWizardProp {
  962. DEFINE_COPY_ASSIGNMENT( TWizShare );
  963. DEFINE_PAGE_IDENTIFIER( DLG_WIZ_SHARE );
  964. public:
  965. TWizShare(
  966. TWizard* pWizard
  967. );
  968. ~TWizShare(
  969. VOID
  970. );
  971. private:
  972. TPrtShare *_pPrtShare;
  973. TString _strGeneratedShareName;
  974. BOOL
  975. bRefreshUI(
  976. IN BOOL bDriverChanged
  977. );
  978. VOID
  979. vSharePrinter(
  980. VOID
  981. );
  982. VOID
  983. vUnsharePrinter(
  984. VOID
  985. );
  986. VOID
  987. vSetDefaultShareName(
  988. VOID
  989. );
  990. //
  991. // Virtual override for MWizardProp.
  992. //
  993. BOOL
  994. bHandle_InitDialog(
  995. VOID
  996. );
  997. VOID
  998. vReadUI(
  999. VOID
  1000. );
  1001. BOOL
  1002. bHandle_SetActive(
  1003. VOID
  1004. );
  1005. BOOL
  1006. bHandle_WizNext(
  1007. VOID
  1008. );
  1009. BOOL
  1010. bHandle_Command(
  1011. IN WORD wId,
  1012. IN WORD wNotifyId,
  1013. IN HWND hwnd
  1014. );
  1015. };
  1016. class TWizComment : public MWizardProp {
  1017. DEFINE_COPY_ASSIGNMENT( TWizComment );
  1018. DEFINE_PAGE_IDENTIFIER( DLG_WIZ_COMMENT );
  1019. public:
  1020. TWizComment(
  1021. TWizard* pWizard
  1022. );
  1023. ~TWizComment(
  1024. VOID
  1025. );
  1026. BOOL
  1027. bHandle_InitDialog(
  1028. VOID
  1029. );
  1030. BOOL
  1031. bHandle_WizNext(
  1032. VOID
  1033. );
  1034. private:
  1035. BOOL
  1036. bHandle_Command(
  1037. IN WORD wId,
  1038. IN WORD wNotifyId,
  1039. IN HWND hwnd
  1040. );
  1041. TFindLocDlg* _pLocDlg;
  1042. CMultilineEditBug m_wndComment;
  1043. };
  1044. class TWizNet : public MWizardProp {
  1045. DEFINE_COPY_ASSIGNMENT( TWizNet );
  1046. DEFINE_PAGE_IDENTIFIER( DLG_WIZ_NET );
  1047. public:
  1048. TWizNet(
  1049. TWizard* pWizard
  1050. );
  1051. private:
  1052. //
  1053. // Virtual override for MWizardProp.
  1054. //
  1055. BOOL
  1056. bHandle_InitDialog(
  1057. VOID
  1058. );
  1059. BOOL
  1060. bHandle_WizNext(
  1061. VOID
  1062. );
  1063. };
  1064. class TWizLocate : public MWizardProp {
  1065. DEFINE_COPY_ASSIGNMENT( TWizLocate );
  1066. DEFINE_PAGE_IDENTIFIER( DLG_WIZ_LOCATE );
  1067. public:
  1068. TWizLocate(
  1069. TWizard* pWizard
  1070. );
  1071. private:
  1072. //
  1073. // Handle printer connection when downlevel browse is disabled
  1074. //
  1075. BOOL
  1076. Handle_ConnectToPrinterName(
  1077. VOID
  1078. );
  1079. //
  1080. // Handle clicking at URL browse
  1081. //
  1082. BOOL
  1083. Handle_URLBrowseClick(
  1084. VOID
  1085. );
  1086. //
  1087. // Reads the UI into class members
  1088. //
  1089. VOID
  1090. vReadUI(
  1091. VOID
  1092. );
  1093. //
  1094. // Search for printer in the directory
  1095. //
  1096. VOID
  1097. vSearch(
  1098. VOID
  1099. );
  1100. //
  1101. // Virtual override for MWizardProp.
  1102. //
  1103. BOOL
  1104. bHandle_WizNext(
  1105. VOID
  1106. );
  1107. BOOL
  1108. bHandle_WizBack(
  1109. VOID
  1110. );
  1111. BOOL
  1112. bHandle_InitDialog(
  1113. VOID
  1114. );
  1115. BOOL
  1116. bHandle_SetActive(
  1117. VOID
  1118. );
  1119. BOOL
  1120. bHandle_Command(
  1121. IN WORD wId,
  1122. IN WORD wNotifyId,
  1123. IN HWND hwnd
  1124. );
  1125. BOOL
  1126. bHandle_Notify(
  1127. IN WPARAM wIdCtrl,
  1128. IN LPNMHDR pnmh
  1129. );
  1130. VAR( TString, strConnectToURL );
  1131. VAR( TString, strConnectToNET );
  1132. };
  1133. class TWizDriverIntro : public MWizardProp {
  1134. DEFINE_COPY_ASSIGNMENT( TWizDriverIntro );
  1135. DEFINE_PAGE_IDENTIFIER( DLG_WIZ_DRIVER_INTRO );
  1136. public:
  1137. TWizDriverIntro(
  1138. TWizard* pWizard
  1139. );
  1140. private:
  1141. //
  1142. // Virtual override for MWizardProp.
  1143. //
  1144. BOOL
  1145. bHandle_InitDialog(
  1146. VOID
  1147. );
  1148. BOOL
  1149. bHandle_SetActive(
  1150. VOID
  1151. );
  1152. };
  1153. class TWizArchitecture : public MWizardProp {
  1154. DEFINE_COPY_ASSIGNMENT( TWizArchitecture );
  1155. DEFINE_PAGE_IDENTIFIER( DLG_WIZ_DRIVER_ARCHITECTURE );
  1156. public:
  1157. TWizArchitecture(
  1158. TWizard* pWizard
  1159. );
  1160. private:
  1161. //
  1162. // Virtual override for MWizardProp.
  1163. //
  1164. BOOL
  1165. bHandle_InitDialog(
  1166. VOID
  1167. );
  1168. BOOL
  1169. bHandle_SetActive(
  1170. VOID
  1171. );
  1172. BOOL
  1173. bHandle_Notify(
  1174. IN WPARAM wParam,
  1175. IN LPNMHDR pnmh
  1176. );
  1177. BOOL
  1178. bHandle_WizNext(
  1179. VOID
  1180. );
  1181. };
  1182. class TWizDriverEnd : public MWizardProp {
  1183. DEFINE_COPY_ASSIGNMENT( TWizDriverEnd );
  1184. DEFINE_PAGE_IDENTIFIER( DLG_WIZ_DRIVER_END );
  1185. public:
  1186. TWizDriverEnd(
  1187. TWizard* pWizard
  1188. );
  1189. static
  1190. BOOL
  1191. bInstallDriver(
  1192. IN HWND hwnd,
  1193. IN DWORD dwEncode,
  1194. IN TPrinterDriverInstallation &Di,
  1195. IN BOOL bFromWeb,
  1196. IN DWORD dwDriverFlags,
  1197. OUT TString *pstrDriverName
  1198. );
  1199. private:
  1200. //
  1201. // Virtual override for MWizardProp.
  1202. //
  1203. BOOL
  1204. bHandle_InitDialog(
  1205. VOID
  1206. );
  1207. BOOL
  1208. bHandle_WizFinish(
  1209. VOID
  1210. );
  1211. BOOL
  1212. bHandle_SetActive(
  1213. VOID
  1214. );
  1215. BOOL
  1216. bInstallNativeDriver(
  1217. OUT DWORD *pdwEncode
  1218. );
  1219. BOOL
  1220. bInstallSelectedDrivers(
  1221. OUT DWORD *pdwEncode
  1222. );
  1223. VOID
  1224. vDisplaySelectedDrivers(
  1225. VOID
  1226. );
  1227. };
  1228. class TWizPreSelectDriver : public MWizardProp {
  1229. DEFINE_COPY_ASSIGNMENT( TWizPreSelectDriver );
  1230. DEFINE_PAGE_IDENTIFIER( DLG_WIZ_PRE_SELECT_DEVICE );
  1231. public:
  1232. TWizPreSelectDriver(
  1233. TWizard* pWizard
  1234. );
  1235. private:
  1236. //
  1237. // Virtual override for MWizardProp.
  1238. //
  1239. BOOL
  1240. bHandle_SetActive(
  1241. VOID
  1242. );
  1243. };
  1244. class TWizPostSelectDriver : public MWizardProp {
  1245. DEFINE_COPY_ASSIGNMENT( TWizPostSelectDriver );
  1246. DEFINE_PAGE_IDENTIFIER( DLG_WIZ_POST_SELECT_DEVICE );
  1247. public:
  1248. TWizPostSelectDriver(
  1249. TWizard* pWizard
  1250. );
  1251. private:
  1252. //
  1253. // Virtual override for MWizardProp.
  1254. //
  1255. BOOL
  1256. bHandle_SetActive(
  1257. VOID
  1258. );
  1259. };
  1260. /********************************************************************
  1261. Printer setup data
  1262. ********************************************************************/
  1263. class TPrinterSetupData : public MSingletonWin {
  1264. DEFINE_COPY_ASSIGNMENT( TPrinterSetupData );
  1265. public:
  1266. TPrinterSetupData::
  1267. TPrinterSetupData(
  1268. IN HWND hwnd,
  1269. IN UINT uAction,
  1270. IN UINT cchPrinterName,
  1271. IN OUT LPTSTR pszPrinterName,
  1272. OUT UINT* pcchPrinterName,
  1273. IN LPCTSTR pszServerName,
  1274. IN LPCTSTR pszWindowName,
  1275. IN LPCTSTR pszInfName,
  1276. IN BOOL bModal,
  1277. IN BOOL bRestartableFromLastPage
  1278. );
  1279. TPrinterSetupData::
  1280. ~TPrinterSetupData(
  1281. VOID
  1282. );
  1283. BOOL
  1284. TPrinterSetupData::
  1285. bValid(
  1286. VOID
  1287. );
  1288. static
  1289. INT
  1290. TPrinterSetupData::
  1291. iPrinterSetupProc(
  1292. IN TPrinterSetupData *pSetupData ADOPT
  1293. );
  1294. private:
  1295. UINT _uAction;
  1296. UINT _cchPrinterName;
  1297. UINT* _pcchPrinterName;
  1298. LPTSTR _pszPrinterName;
  1299. LPCTSTR _pszServerName;
  1300. TString _strPrinterName;
  1301. TString _strServerName;
  1302. TString _strInfFileName;
  1303. BOOL _bValid;
  1304. BOOL _bRestartableFromLastPage;
  1305. };
  1306. /********************************************************************
  1307. Global definitions.
  1308. ********************************************************************/
  1309. //
  1310. // New printer driver wizard action flags.
  1311. //
  1312. enum ENewPrinterDriverFlags
  1313. {
  1314. kDriverWizardDefault = 0,
  1315. kSkipArchSelection = 1 << 1,
  1316. };
  1317. BOOL
  1318. bPrinterInstall(
  1319. IN LPCTSTR pszServerName,
  1320. IN LPCTSTR pszDriverName,
  1321. IN LPCTSTR pszPortName,
  1322. IN OUT LPTSTR pszPrinterNameBuffer,
  1323. IN UINT cchPrinterName,
  1324. IN DWORD dwFlags,
  1325. IN DWORD dwAttributes,
  1326. IN PSECURITY_DESCRIPTOR pSecurityDescriptor,
  1327. OUT PDWORD pdwError
  1328. );
  1329. BOOL
  1330. bPrinterSetup(
  1331. IN HWND hwnd,
  1332. IN UINT uAction,
  1333. IN UINT cchPrinterName,
  1334. IN OUT LPTSTR pszPrinterName,
  1335. OUT UINT *pcchPrinterName,
  1336. IN LPCTSTR pszServerName
  1337. );
  1338. BOOL
  1339. bPrinterSetupNew(
  1340. IN HWND hwnd,
  1341. IN UINT uAction,
  1342. IN UINT cchPrinterName,
  1343. IN OUT LPTSTR pszPrinterName,
  1344. OUT UINT *pcchPrinterName,
  1345. IN LPCTSTR pszServerName,
  1346. IN LPCTSTR pszInfFileName,
  1347. IN BOOL bRestartableFromLastPage
  1348. );
  1349. BOOL
  1350. bDriverSetupNew(
  1351. IN HWND hwnd,
  1352. IN UINT uAction,
  1353. IN UINT cchPrinterName,
  1354. IN OUT LPTSTR pszPrinterName,
  1355. OUT UINT* pcchPrinterName,
  1356. IN LPCTSTR pszServerName,
  1357. IN INT Flags,
  1358. IN BOOL bRestartableFromLastPage
  1359. );
  1360. BOOL
  1361. bRemovePrinter(
  1362. IN HWND hwnd,
  1363. IN LPCTSTR pszPrinterName,
  1364. IN LPCTSTR pszServerName,
  1365. IN BOOL bQuiet
  1366. );
  1367. BOOL
  1368. bPrinterNetInstall(
  1369. IN HWND hwnd,
  1370. IN LPCTSTR pszPrinterName
  1371. );
  1372. bPrinterNetRemove(
  1373. IN HWND hwnd,
  1374. IN LPCTSTR pszPrinterName,
  1375. IN BOOL bQuiet
  1376. );
  1377. BOOL
  1378. bInstallWizard(
  1379. IN LPCTSTR pszServerName,
  1380. IN OUT PSP_INSTALLWIZARD_DATA pWizardData,
  1381. IN OUT PVOID * pRefrenceData,
  1382. OUT PDWORD pdwError
  1383. );
  1384. BOOL
  1385. bDestroyWizard(
  1386. IN LPCTSTR pszServerName,
  1387. IN OUT PSP_INSTALLWIZARD_DATA pWizardData,
  1388. IN OUT PVOID pRefrenceData,
  1389. OUT PDWORD pdwError
  1390. );
  1391. BOOL
  1392. bInfInstall(
  1393. IN LPCTSTR pszServerName,
  1394. IN LPCTSTR pszInfName,
  1395. IN LPCTSTR pszModelName,
  1396. IN LPCTSTR pszPortName,
  1397. IN OUT LPTSTR pszPrinterNameBuffer,
  1398. IN UINT cchPrinterName,
  1399. IN LPCTSTR pszSourcePath,
  1400. IN DWORD dwFlags,
  1401. IN DWORD dwAttributes,
  1402. IN PSECURITY_DESCRIPTOR pSecurityDescriptor,
  1403. IN OUT PDWORD pdwOutFlags,
  1404. OUT PDWORD pdwError
  1405. );
  1406. BOOL
  1407. bInstallNewPrinterDriver(
  1408. IN HWND hwnd,
  1409. IN UINT uAction,
  1410. IN LPCTSTR pszServerName,
  1411. IN OUT TString &strDriverName,
  1412. OUT TDriverTransfer *pDriverTransfer,
  1413. IN INT Flags,
  1414. OUT PBOOL pbCanceled,
  1415. IN BOOL bRestartableFromLastPage,
  1416. IN PUINT pnDriverInstallCount = NULL
  1417. );
  1418. BOOL
  1419. bInstallPrinterDriver(
  1420. IN LPCTSTR pszServerName,
  1421. IN LPCTSTR pszDriverName,
  1422. IN LPCTSTR pszArchitecture,
  1423. IN LPCTSTR pszVersion,
  1424. IN LPCTSTR pszInfName,
  1425. IN LPCTSTR pszSourcePath,
  1426. IN DWORD dwFlags,
  1427. IN HWND hwnd,
  1428. IN DWORD *pdwLastError
  1429. );
  1430. BOOL
  1431. bRemovePrinterDriver(
  1432. IN LPCTSTR pszServerName,
  1433. IN LPCTSTR pszDriverName,
  1434. IN LPCTSTR pszArchitecture,
  1435. IN LPCTSTR pszVersion,
  1436. IN DWORD dwFlags,
  1437. IN DWORD *pdwError
  1438. );
  1439. BOOL
  1440. bFindPrinter(
  1441. IN HWND hwnd,
  1442. IN LPTSTR pszBuffer,
  1443. IN UINT *puSize
  1444. );
  1445. BOOL
  1446. bPromptForUnknownDriver(
  1447. IN TPrinterDriverInstallation &Di,
  1448. IN TString &strDriverName,
  1449. IN DWORD dwFlags
  1450. );
  1451. BOOL
  1452. GetOrUseInfName(
  1453. IN OUT TString &strInfName
  1454. );
  1455. #endif // ndef _SETUP_HXX