]> git.saurik.com Git - apple/mdnsresponder.git/blob - Clients/PrinterSetupWizard/PrinterSetupWizardSheet.h
mDNSResponder-212.1.tar.gz
[apple/mdnsresponder.git] / Clients / PrinterSetupWizard / PrinterSetupWizardSheet.h
1 /* -*- Mode: C; tab-width: 4 -*-
2 *
3 * Copyright (c) 1997-2004 Apple Computer, Inc. All rights reserved.
4 *
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
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
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.
16
17 Change History (most recent first):
18
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.
22
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
26
27 Revision 1.12 2006/08/14 23:24:09 cheshire
28 Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
29
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.
32
33 Revision 1.10 2005/07/07 17:53:19 shersche
34 Fix problems associated with the CUPS printer workaround fix.
35
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
38
39 Revision 1.8 2005/02/08 18:53:33 shersche
40 Remove qtotalDefined parameter from ParseTextRecord()
41
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.
44
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
47
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
52
53 Revision 1.4 2004/07/13 21:24:23 rpantos
54 Fix for <rdar://problem/3701120>.
55
56 Revision 1.3 2004/06/28 00:51:47 shersche
57 Move call to EnumPrinters out of browse callback into standalone function
58
59 Revision 1.2 2004/06/24 20:12:07 shersche
60 Clean up source code
61 Submitted by: herscher
62
63 Revision 1.1 2004/06/18 04:36:57 rpantos
64 First checked in
65
66
67 */
68
69 #pragma once
70
71
72 #include "firstpage.h"
73 #include "secondpage.h"
74 #include "thirdpage.h"
75 #include "fourthpage.h"
76 #include "UtilTypes.h"
77 #include "Logger.h"
78 #include "dns_sd.h"
79 #include <stdexcept>
80 #include <map>
81
82 using namespace PrinterSetupWizard;
83
84 // CPrinterSetupWizardSheet
85
86 class CPrinterSetupWizardSheet : public CPropertySheet
87 {
88 DECLARE_DYNAMIC(CPrinterSetupWizardSheet)
89
90 public:
91
92 struct WizardException
93 {
94 CString text;
95 CString caption;
96 };
97
98 public:
99
100 CPrinterSetupWizardSheet(UINT nIDCaption, CWnd* pParentWnd = NULL, UINT iSelectPage = 0);
101 virtual ~CPrinterSetupWizardSheet();
102
103 CPropertyPage*
104 GetLastPage();
105
106 void
107 SetLastPage(CPropertyPage * page );
108
109 void
110 SetSelectedPrinter(Printer * printer);
111
112 Printer*
113 GetSelectedPrinter();
114
115 OSStatus
116 LoadPrinterDriver(const CString & filename);
117
118 HCURSOR
119 GetCursor();
120
121 //
122 // handles end of process event
123 //
124 virtual LRESULT
125 OnProcessEvent(WPARAM inWParam, LPARAM inLParam);
126
127 virtual LRESULT
128 OnSocketEvent(WPARAM inWParam, LPARAM inLParam);
129
130 virtual BOOL
131 OnCommand(WPARAM wParam, LPARAM lParam);
132
133 virtual BOOL
134 OnInitDialog();
135
136 virtual BOOL
137 OnSetCursor(CWnd * pWnd, UINT nHitTest, UINT message);
138
139 virtual void
140 OnContextMenu(CWnd * pWnd, CPoint pos);
141
142 afx_msg void
143 OnOK();
144
145 OSStatus
146 StartResolve( Printer * printer );
147
148 OSStatus
149 StopResolve( Printer * printer );
150
151 Printers m_printers;
152
153 HCURSOR m_active;
154 HCURSOR m_arrow;
155 HCURSOR m_wait;
156
157 protected:
158 DECLARE_MESSAGE_MAP()
159 CFirstPage m_pgFirst;
160 CSecondPage m_pgSecond;
161 CThirdPage m_pgThird;
162 CFourthPage m_pgFourth;
163
164 void
165 OnServiceResolved(
166 Service * service);
167
168 void Init(void);
169
170 private:
171
172 static void DNSSD_API
173 OnBrowse(
174 DNSServiceRef inRef,
175 DNSServiceFlags inFlags,
176 uint32_t inInterfaceIndex,
177 DNSServiceErrorType inErrorCode,
178 const char * inName,
179 const char * inType,
180 const char * inDomain,
181 void * inContext );
182
183 static void DNSSD_API
184 OnResolve(
185 DNSServiceRef inRef,
186 DNSServiceFlags inFlags,
187 uint32_t inInterfaceIndex,
188 DNSServiceErrorType inErrorCode,
189 const char * inFullName,
190 const char * inHostName,
191 uint16_t inPort,
192 uint16_t inTXTSize,
193 const char * inTXT,
194 void * inContext );
195
196 static void DNSSD_API
197 OnQuery(
198 DNSServiceRef inRef,
199 DNSServiceFlags inFlags,
200 uint32_t inInterfaceIndex,
201 DNSServiceErrorType inErrorCode,
202 const char * inFullName,
203 uint16_t inRRType,
204 uint16_t inRRClass,
205 uint16_t inRDLen,
206 const void * inRData,
207 uint32_t inTTL,
208 void * inContext);
209
210 Printer*
211 OnAddPrinter(
212 uint32_t inInterfaceIndex,
213 const char * inName,
214 const char * inType,
215 const char * inDomain,
216 bool moreComing);
217
218 OSStatus
219 OnRemovePrinter(
220 Printer * printer,
221 bool moreComing);
222
223 OSStatus
224 OnAddService(
225 Printer * printer,
226 uint32_t inInterfaceIndex,
227 const char * inName,
228 const char * inType,
229 const char * inDomain);
230
231 OSStatus
232 OnRemoveService(
233 Service * service);
234
235 void
236 OnResolveService(
237 Service * service );
238
239 static bool
240 OrderServiceFunc( const Service * a, const Service * b );
241
242 static bool
243 OrderQueueFunc( const Queue * q1, const Queue * q2 );
244
245 OSStatus
246 StartOperation( DNSServiceRef ref );
247
248 OSStatus
249 StopOperation( DNSServiceRef & ref );
250
251 OSStatus
252 StartBrowse();
253
254 OSStatus
255 StopBrowse();
256
257 OSStatus
258 StartResolve( Service * service );
259
260 OSStatus
261 StopResolve( Service * service );
262
263 OSStatus
264 ParseTextRecord( Service * service, Queue * q, uint16_t inTXTSize, const char * inTXT );
265
266 OSStatus
267 LoadPrinterNames();
268
269 Printer*
270 Lookup( const char * name );
271
272 OSStatus
273 InstallPrinter(Printer * printer);
274
275 OSStatus
276 InstallPrinterPDLAndLPR(Printer * printer, Service * service, DWORD protocol, Logger & log);
277
278 OSStatus
279 InstallPrinterIPP(Printer * printer, Service * service, Logger & log);
280
281 static unsigned WINAPI
282 InstallDriverThread( LPVOID inParam );
283
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;
296
297 CPropertyPage * m_lastPage;
298 };
299
300
301 inline Printer*
302 CPrinterSetupWizardSheet::GetSelectedPrinter()
303 {
304 return m_selectedPrinter;
305 }
306
307
308 inline HCURSOR
309 CPrinterSetupWizardSheet::GetCursor()
310 {
311 return m_active;
312 }
313
314
315 inline CPropertyPage*
316 CPrinterSetupWizardSheet::GetLastPage()
317 {
318 return m_lastPage;
319 }
320
321
322 inline void
323 CPrinterSetupWizardSheet::SetLastPage(CPropertyPage * lastPage)
324 {
325 m_lastPage = lastPage;
326 }
327
328
329 // Service Types
330
331 #define kPDLServiceType "_pdl-datastream._tcp."
332 #define kLPRServiceType "_printer._tcp."
333 #define kIPPServiceType "_ipp._tcp."