]> git.saurik.com Git - apple/mdnsresponder.git/blob - Clients/PrinterSetupWizard/PrinterSetupWizardSheet.h
mDNSResponder-107.5.tar.gz
[apple/mdnsresponder.git] / Clients / PrinterSetupWizard / PrinterSetupWizardSheet.h
1 /*
2 * Copyright (c) 1997-2004 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22
23 Change History (most recent first):
24
25 $Log: PrinterSetupWizardSheet.h,v $
26 Revision 1.11 2005/10/05 17:32:51 herscher
27 <rdar://problem/4141221> Use a case insensitive compare operation to check whether a printer with the same name has already been installed.
28
29 Revision 1.10 2005/07/07 17:53:19 shersche
30 Fix problems associated with the CUPS printer workaround fix.
31
32 Revision 1.9 2005/04/13 17:46:22 shersche
33 <rdar://problem/4082122> Generic PCL not selected when printers advertise multiple text records
34
35 Revision 1.8 2005/02/08 18:53:33 shersche
36 Remove qtotalDefined parameter from ParseTextRecord()
37
38 Revision 1.7 2005/01/31 23:54:29 shersche
39 <rdar://problem/3947508> Start browsing when printer wizard starts. Move browsing logic from CSecondPage object to CPrinterSetupWizardSheet object.
40
41 Revision 1.6 2005/01/03 19:05:01 shersche
42 Store pointer to instance of wizard sheet so that print driver install thread sends a window message to the correct window
43
44 Revision 1.5 2004/12/29 18:53:38 shersche
45 <rdar://problem/3725106>
46 <rdar://problem/3737413> Added support for LPR and IPP protocols as well as support for obtaining multiple text records. Reorganized and simplified codebase.
47 Bug #: 3725106, 3737413
48
49 Revision 1.4 2004/07/13 21:24:23 rpantos
50 Fix for <rdar://problem/3701120>.
51
52 Revision 1.3 2004/06/28 00:51:47 shersche
53 Move call to EnumPrinters out of browse callback into standalone function
54
55 Revision 1.2 2004/06/24 20:12:07 shersche
56 Clean up source code
57 Submitted by: herscher
58
59 Revision 1.1 2004/06/18 04:36:57 rpantos
60 First checked in
61
62
63 */
64
65 #pragma once
66
67
68 #include "firstpage.h"
69 #include "secondpage.h"
70 #include "thirdpage.h"
71 #include "fourthpage.h"
72 #include "UtilTypes.h"
73 #include "dns_sd.h"
74 #include <stdexcept>
75 #include <map>
76
77 using namespace PrinterSetupWizard;
78
79 // CPrinterSetupWizardSheet
80
81 class CPrinterSetupWizardSheet : public CPropertySheet
82 {
83 DECLARE_DYNAMIC(CPrinterSetupWizardSheet)
84
85 public:
86
87 struct WizardException
88 {
89 CString text;
90 CString caption;
91 };
92
93 public:
94
95 CPrinterSetupWizardSheet(UINT nIDCaption, CWnd* pParentWnd = NULL, UINT iSelectPage = 0);
96 virtual ~CPrinterSetupWizardSheet();
97
98 CPropertyPage*
99 GetLastPage();
100
101 void
102 SetLastPage(CPropertyPage * page );
103
104 void
105 SetSelectedPrinter(Printer * printer);
106
107 Printer*
108 GetSelectedPrinter();
109
110 OSStatus
111 LoadPrinterDriver(const CString & filename);
112
113 HCURSOR
114 GetCursor();
115
116 //
117 // handles end of process event
118 //
119 virtual LONG
120 OnProcessEvent(WPARAM inWParam, LPARAM inLParam);
121
122 virtual LONG
123 OnSocketEvent(WPARAM inWParam, LPARAM inLParam);
124
125 virtual BOOL
126 OnCommand(WPARAM wParam, LPARAM lParam);
127
128 virtual BOOL
129 OnInitDialog();
130
131 virtual BOOL
132 OnSetCursor(CWnd * pWnd, UINT nHitTest, UINT message);
133
134 virtual void
135 OnContextMenu(CWnd * pWnd, CPoint pos);
136
137 afx_msg void
138 OnOK();
139
140 OSStatus
141 StartResolve( Printer * printer );
142
143 OSStatus
144 StopResolve( Printer * printer );
145
146 Printers m_printers;
147
148 HCURSOR m_active;
149 HCURSOR m_arrow;
150 HCURSOR m_wait;
151
152 protected:
153 DECLARE_MESSAGE_MAP()
154 CFirstPage m_pgFirst;
155 CSecondPage m_pgSecond;
156 CThirdPage m_pgThird;
157 CFourthPage m_pgFourth;
158
159 void
160 OnServiceResolved(
161 Service * service);
162
163 void Init(void);
164
165 private:
166
167 static void DNSSD_API
168 OnBrowse(
169 DNSServiceRef inRef,
170 DNSServiceFlags inFlags,
171 uint32_t inInterfaceIndex,
172 DNSServiceErrorType inErrorCode,
173 const char * inName,
174 const char * inType,
175 const char * inDomain,
176 void * inContext );
177
178 static void DNSSD_API
179 OnResolve(
180 DNSServiceRef inRef,
181 DNSServiceFlags inFlags,
182 uint32_t inInterfaceIndex,
183 DNSServiceErrorType inErrorCode,
184 const char * inFullName,
185 const char * inHostName,
186 uint16_t inPort,
187 uint16_t inTXTSize,
188 const char * inTXT,
189 void * inContext );
190
191 static void DNSSD_API
192 OnQuery(
193 DNSServiceRef inRef,
194 DNSServiceFlags inFlags,
195 uint32_t inInterfaceIndex,
196 DNSServiceErrorType inErrorCode,
197 const char * inFullName,
198 uint16_t inRRType,
199 uint16_t inRRClass,
200 uint16_t inRDLen,
201 const void * inRData,
202 uint32_t inTTL,
203 void * inContext);
204
205 Printer*
206 OnAddPrinter(
207 uint32_t inInterfaceIndex,
208 const char * inName,
209 const char * inType,
210 const char * inDomain,
211 bool moreComing);
212
213 OSStatus
214 OnRemovePrinter(
215 Printer * printer,
216 bool moreComing);
217
218 OSStatus
219 OnAddService(
220 Printer * printer,
221 uint32_t inInterfaceIndex,
222 const char * inName,
223 const char * inType,
224 const char * inDomain);
225
226 OSStatus
227 OnRemoveService(
228 Service * service);
229
230 void
231 OnResolveService(
232 Service * service );
233
234 static bool
235 OrderServiceFunc( const Service * a, const Service * b );
236
237 static bool
238 OrderQueueFunc( const Queue * q1, const Queue * q2 );
239
240 OSStatus
241 StartOperation( DNSServiceRef ref );
242
243 OSStatus
244 StopOperation( DNSServiceRef & ref );
245
246 OSStatus
247 StartBrowse();
248
249 OSStatus
250 StopBrowse();
251
252 OSStatus
253 StartResolve( Service * service );
254
255 OSStatus
256 StopResolve( Service * service );
257
258 OSStatus
259 ParseTextRecord( Service * service, Queue * q, uint16_t inTXTSize, const char * inTXT );
260
261 OSStatus
262 LoadPrinterNames();
263
264 Printer*
265 Lookup( const char * name );
266
267 OSStatus
268 InstallPrinter(Printer * printer);
269
270 OSStatus
271 InstallPrinterPDLAndLPR(Printer * printer, Service * service, DWORD protocol);
272
273 OSStatus
274 InstallPrinterIPP(Printer * printer, Service * service);
275
276 static unsigned WINAPI
277 InstallDriverThread( LPVOID inParam );
278
279 typedef std::list<CString> PrinterNames;
280 typedef std::list<DNSServiceRef> ServiceRefList;
281 static CPrinterSetupWizardSheet * m_self;
282 PrinterNames m_printerNames;
283 Printer * m_selectedPrinter;
284 bool m_driverThreadFinished;
285 DWORD m_driverThreadExitCode;
286 ServiceRefList m_serviceRefList;
287 DNSServiceRef m_pdlBrowser;
288 DNSServiceRef m_lprBrowser;
289 DNSServiceRef m_ippBrowser;
290 DNSServiceRef m_resolver;
291
292 CPropertyPage * m_lastPage;
293 };
294
295
296 inline Printer*
297 CPrinterSetupWizardSheet::GetSelectedPrinter()
298 {
299 return m_selectedPrinter;
300 }
301
302
303 inline HCURSOR
304 CPrinterSetupWizardSheet::GetCursor()
305 {
306 return m_active;
307 }
308
309
310 inline CPropertyPage*
311 CPrinterSetupWizardSheet::GetLastPage()
312 {
313 return m_lastPage;
314 }
315
316
317 inline void
318 CPrinterSetupWizardSheet::SetLastPage(CPropertyPage * lastPage)
319 {
320 m_lastPage = lastPage;
321 }
322
323
324 // Service Types
325
326 #define kPDLServiceType "_pdl-datastream._tcp."
327 #define kLPRServiceType "_printer._tcp."
328 #define kIPPServiceType "_ipp._tcp."