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