1 /* -*- Mode: C; tab-width: 4 -*-
3 * Copyright (c) 1997-2004 Apple Computer, Inc. All rights reserved.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 Change History (most recent first):
19 $Log: PrinterSetupWizardSheet.h,v $
20 Revision 1.12 2006/08/14 23:24:09 cheshire
21 Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
23 Revision 1.11 2005/10/05 17:32:51 herscher
24 <rdar://problem/4141221> Use a case insensitive compare operation to check whether a printer with the same name has already been installed.
26 Revision 1.10 2005/07/07 17:53:19 shersche
27 Fix problems associated with the CUPS printer workaround fix.
29 Revision 1.9 2005/04/13 17:46:22 shersche
30 <rdar://problem/4082122> Generic PCL not selected when printers advertise multiple text records
32 Revision 1.8 2005/02/08 18:53:33 shersche
33 Remove qtotalDefined parameter from ParseTextRecord()
35 Revision 1.7 2005/01/31 23:54:29 shersche
36 <rdar://problem/3947508> Start browsing when printer wizard starts. Move browsing logic from CSecondPage object to CPrinterSetupWizardSheet object.
38 Revision 1.6 2005/01/03 19:05:01 shersche
39 Store pointer to instance of wizard sheet so that print driver install thread sends a window message to the correct window
41 Revision 1.5 2004/12/29 18:53:38 shersche
42 <rdar://problem/3725106>
43 <rdar://problem/3737413> Added support for LPR and IPP protocols as well as support for obtaining multiple text records. Reorganized and simplified codebase.
44 Bug #: 3725106, 3737413
46 Revision 1.4 2004/07/13 21:24:23 rpantos
47 Fix for <rdar://problem/3701120>.
49 Revision 1.3 2004/06/28 00:51:47 shersche
50 Move call to EnumPrinters out of browse callback into standalone function
52 Revision 1.2 2004/06/24 20:12:07 shersche
54 Submitted by: herscher
56 Revision 1.1 2004/06/18 04:36:57 rpantos
65 #include "firstpage.h"
66 #include "secondpage.h"
67 #include "thirdpage.h"
68 #include "fourthpage.h"
69 #include "UtilTypes.h"
74 using namespace PrinterSetupWizard
;
76 // CPrinterSetupWizardSheet
78 class CPrinterSetupWizardSheet
: public CPropertySheet
80 DECLARE_DYNAMIC(CPrinterSetupWizardSheet
)
84 struct WizardException
92 CPrinterSetupWizardSheet(UINT nIDCaption
, CWnd
* pParentWnd
= NULL
, UINT iSelectPage
= 0);
93 virtual ~CPrinterSetupWizardSheet();
99 SetLastPage(CPropertyPage
* page
);
102 SetSelectedPrinter(Printer
* printer
);
105 GetSelectedPrinter();
108 LoadPrinterDriver(const CString
& filename
);
114 // handles end of process event
117 OnProcessEvent(WPARAM inWParam
, LPARAM inLParam
);
120 OnSocketEvent(WPARAM inWParam
, LPARAM inLParam
);
123 OnCommand(WPARAM wParam
, LPARAM lParam
);
129 OnSetCursor(CWnd
* pWnd
, UINT nHitTest
, UINT message
);
132 OnContextMenu(CWnd
* pWnd
, CPoint pos
);
138 StartResolve( Printer
* printer
);
141 StopResolve( Printer
* printer
);
150 DECLARE_MESSAGE_MAP()
151 CFirstPage m_pgFirst
;
152 CSecondPage m_pgSecond
;
153 CThirdPage m_pgThird
;
154 CFourthPage m_pgFourth
;
164 static void DNSSD_API
167 DNSServiceFlags inFlags
,
168 uint32_t inInterfaceIndex
,
169 DNSServiceErrorType inErrorCode
,
172 const char * inDomain
,
175 static void DNSSD_API
178 DNSServiceFlags inFlags
,
179 uint32_t inInterfaceIndex
,
180 DNSServiceErrorType inErrorCode
,
181 const char * inFullName
,
182 const char * inHostName
,
188 static void DNSSD_API
191 DNSServiceFlags inFlags
,
192 uint32_t inInterfaceIndex
,
193 DNSServiceErrorType inErrorCode
,
194 const char * inFullName
,
198 const void * inRData
,
204 uint32_t inInterfaceIndex
,
207 const char * inDomain
,
218 uint32_t inInterfaceIndex
,
221 const char * inDomain
);
232 OrderServiceFunc( const Service
* a
, const Service
* b
);
235 OrderQueueFunc( const Queue
* q1
, const Queue
* q2
);
238 StartOperation( DNSServiceRef ref
);
241 StopOperation( DNSServiceRef
& ref
);
250 StartResolve( Service
* service
);
253 StopResolve( Service
* service
);
256 ParseTextRecord( Service
* service
, Queue
* q
, uint16_t inTXTSize
, const char * inTXT
);
262 Lookup( const char * name
);
265 InstallPrinter(Printer
* printer
);
268 InstallPrinterPDLAndLPR(Printer
* printer
, Service
* service
, DWORD protocol
);
271 InstallPrinterIPP(Printer
* printer
, Service
* service
);
273 static unsigned WINAPI
274 InstallDriverThread( LPVOID inParam
);
276 typedef std::list
<CString
> PrinterNames
;
277 typedef std::list
<DNSServiceRef
> ServiceRefList
;
278 static CPrinterSetupWizardSheet
* m_self
;
279 PrinterNames m_printerNames
;
280 Printer
* m_selectedPrinter
;
281 bool m_driverThreadFinished
;
282 DWORD m_driverThreadExitCode
;
283 ServiceRefList m_serviceRefList
;
284 DNSServiceRef m_pdlBrowser
;
285 DNSServiceRef m_lprBrowser
;
286 DNSServiceRef m_ippBrowser
;
287 DNSServiceRef m_resolver
;
289 CPropertyPage
* m_lastPage
;
294 CPrinterSetupWizardSheet::GetSelectedPrinter()
296 return m_selectedPrinter
;
301 CPrinterSetupWizardSheet::GetCursor()
307 inline CPropertyPage
*
308 CPrinterSetupWizardSheet::GetLastPage()
315 CPrinterSetupWizardSheet::SetLastPage(CPropertyPage
* lastPage
)
317 m_lastPage
= lastPage
;
323 #define kPDLServiceType "_pdl-datastream._tcp."
324 #define kLPRServiceType "_printer._tcp."
325 #define kIPPServiceType "_ipp._tcp."