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.14 2009/06/11 22:27:16 herscher
21 <rdar://problem/4458913> Add comprehensive logging during printer installation process.
23 Revision 1.13 2009/03/30 19:18:49 herscher
24 <rdar://problem/5925472> Current Bonjour code does not compile on Windows
25 <rdar://problem/5187308> Move build train to Visual Studio 2005
27 Revision 1.12 2006/08/14 23:24:09 cheshire
28 Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
30 Revision 1.11 2005/10/05 17:32:51 herscher
31 <rdar://problem/4141221> Use a case insensitive compare operation to check whether a printer with the same name has already been installed.
33 Revision 1.10 2005/07/07 17:53:19 shersche
34 Fix problems associated with the CUPS printer workaround fix.
36 Revision 1.9 2005/04/13 17:46:22 shersche
37 <rdar://problem/4082122> Generic PCL not selected when printers advertise multiple text records
39 Revision 1.8 2005/02/08 18:53:33 shersche
40 Remove qtotalDefined parameter from ParseTextRecord()
42 Revision 1.7 2005/01/31 23:54:29 shersche
43 <rdar://problem/3947508> Start browsing when printer wizard starts. Move browsing logic from CSecondPage object to CPrinterSetupWizardSheet object.
45 Revision 1.6 2005/01/03 19:05:01 shersche
46 Store pointer to instance of wizard sheet so that print driver install thread sends a window message to the correct window
48 Revision 1.5 2004/12/29 18:53:38 shersche
49 <rdar://problem/3725106>
50 <rdar://problem/3737413> Added support for LPR and IPP protocols as well as support for obtaining multiple text records. Reorganized and simplified codebase.
51 Bug #: 3725106, 3737413
53 Revision 1.4 2004/07/13 21:24:23 rpantos
54 Fix for <rdar://problem/3701120>.
56 Revision 1.3 2004/06/28 00:51:47 shersche
57 Move call to EnumPrinters out of browse callback into standalone function
59 Revision 1.2 2004/06/24 20:12:07 shersche
61 Submitted by: herscher
63 Revision 1.1 2004/06/18 04:36:57 rpantos
72 #include "firstpage.h"
73 #include "secondpage.h"
74 #include "thirdpage.h"
75 #include "fourthpage.h"
76 #include "UtilTypes.h"
82 using namespace PrinterSetupWizard
;
84 // CPrinterSetupWizardSheet
86 class CPrinterSetupWizardSheet
: public CPropertySheet
88 DECLARE_DYNAMIC(CPrinterSetupWizardSheet
)
92 struct WizardException
100 CPrinterSetupWizardSheet(UINT nIDCaption
, CWnd
* pParentWnd
= NULL
, UINT iSelectPage
= 0);
101 virtual ~CPrinterSetupWizardSheet();
107 SetLastPage(CPropertyPage
* page
);
110 SetSelectedPrinter(Printer
* printer
);
113 GetSelectedPrinter();
116 LoadPrinterDriver(const CString
& filename
);
122 // handles end of process event
125 OnProcessEvent(WPARAM inWParam
, LPARAM inLParam
);
128 OnSocketEvent(WPARAM inWParam
, LPARAM inLParam
);
131 OnCommand(WPARAM wParam
, LPARAM lParam
);
137 OnSetCursor(CWnd
* pWnd
, UINT nHitTest
, UINT message
);
140 OnContextMenu(CWnd
* pWnd
, CPoint pos
);
146 StartResolve( Printer
* printer
);
149 StopResolve( Printer
* printer
);
158 DECLARE_MESSAGE_MAP()
159 CFirstPage m_pgFirst
;
160 CSecondPage m_pgSecond
;
161 CThirdPage m_pgThird
;
162 CFourthPage m_pgFourth
;
172 static void DNSSD_API
175 DNSServiceFlags inFlags
,
176 uint32_t inInterfaceIndex
,
177 DNSServiceErrorType inErrorCode
,
180 const char * inDomain
,
183 static void DNSSD_API
186 DNSServiceFlags inFlags
,
187 uint32_t inInterfaceIndex
,
188 DNSServiceErrorType inErrorCode
,
189 const char * inFullName
,
190 const char * inHostName
,
196 static void DNSSD_API
199 DNSServiceFlags inFlags
,
200 uint32_t inInterfaceIndex
,
201 DNSServiceErrorType inErrorCode
,
202 const char * inFullName
,
206 const void * inRData
,
212 uint32_t inInterfaceIndex
,
215 const char * inDomain
,
226 uint32_t inInterfaceIndex
,
229 const char * inDomain
);
240 OrderServiceFunc( const Service
* a
, const Service
* b
);
243 OrderQueueFunc( const Queue
* q1
, const Queue
* q2
);
246 StartOperation( DNSServiceRef ref
);
249 StopOperation( DNSServiceRef
& ref
);
258 StartResolve( Service
* service
);
261 StopResolve( Service
* service
);
264 ParseTextRecord( Service
* service
, Queue
* q
, uint16_t inTXTSize
, const char * inTXT
);
270 Lookup( const char * name
);
273 InstallPrinter(Printer
* printer
);
276 InstallPrinterPDLAndLPR(Printer
* printer
, Service
* service
, DWORD protocol
, Logger
& log
);
279 InstallPrinterIPP(Printer
* printer
, Service
* service
, Logger
& log
);
281 static unsigned WINAPI
282 InstallDriverThread( LPVOID inParam
);
284 typedef std::list
<CString
> PrinterNames
;
285 typedef std::list
<DNSServiceRef
> ServiceRefList
;
286 static CPrinterSetupWizardSheet
* m_self
;
287 PrinterNames m_printerNames
;
288 Printer
* m_selectedPrinter
;
289 bool m_driverThreadFinished
;
290 DWORD m_driverThreadExitCode
;
291 ServiceRefList m_serviceRefList
;
292 DNSServiceRef m_pdlBrowser
;
293 DNSServiceRef m_lprBrowser
;
294 DNSServiceRef m_ippBrowser
;
295 DNSServiceRef m_resolver
;
297 CPropertyPage
* m_lastPage
;
302 CPrinterSetupWizardSheet::GetSelectedPrinter()
304 return m_selectedPrinter
;
309 CPrinterSetupWizardSheet::GetCursor()
315 inline CPropertyPage
*
316 CPrinterSetupWizardSheet::GetLastPage()
323 CPrinterSetupWizardSheet::SetLastPage(CPropertyPage
* lastPage
)
325 m_lastPage
= lastPage
;
331 #define kPDLServiceType "_pdl-datastream._tcp."
332 #define kLPRServiceType "_printer._tcp."
333 #define kIPPServiceType "_ipp._tcp."