]> git.saurik.com Git - apple/mdnsresponder.git/blob - Clients/PrinterSetupWizard/PrinterSetupWizardSheet.h
mDNSResponder-107.1.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.9 2005/04/13 17:46:22 shersche
27 <rdar://problem/4082122> Generic PCL not selected when printers advertise multiple text records
28
29 Revision 1.8 2005/02/08 18:53:33 shersche
30 Remove qtotalDefined parameter from ParseTextRecord()
31
32 Revision 1.7 2005/01/31 23:54:29 shersche
33 <rdar://problem/3947508> Start browsing when printer wizard starts. Move browsing logic from CSecondPage object to CPrinterSetupWizardSheet object.
34
35 Revision 1.6 2005/01/03 19:05:01 shersche
36 Store pointer to instance of wizard sheet so that print driver install thread sends a window message to the correct window
37
38 Revision 1.5 2004/12/29 18:53:38 shersche
39 <rdar://problem/3725106>
40 <rdar://problem/3737413> Added support for LPR and IPP protocols as well as support for obtaining multiple text records. Reorganized and simplified codebase.
41 Bug #: 3725106, 3737413
42
43 Revision 1.4 2004/07/13 21:24:23 rpantos
44 Fix for <rdar://problem/3701120>.
45
46 Revision 1.3 2004/06/28 00:51:47 shersche
47 Move call to EnumPrinters out of browse callback into standalone function
48
49 Revision 1.2 2004/06/24 20:12:07 shersche
50 Clean up source code
51 Submitted by: herscher
52
53 Revision 1.1 2004/06/18 04:36:57 rpantos
54 First checked in
55
56
57 */
58
59 #pragma once
60
61
62 #include "firstpage.h"
63 #include "secondpage.h"
64 #include "thirdpage.h"
65 #include "fourthpage.h"
66 #include "UtilTypes.h"
67 #include "dns_sd.h"
68 #include <stdexcept>
69 #include <map>
70
71 using namespace PrinterSetupWizard;
72
73 // CPrinterSetupWizardSheet
74
75 class CPrinterSetupWizardSheet : public CPropertySheet
76 {
77 DECLARE_DYNAMIC(CPrinterSetupWizardSheet)
78
79 public:
80
81 struct WizardException
82 {
83 CString text;
84 CString caption;
85 };
86
87 public:
88
89 CPrinterSetupWizardSheet(UINT nIDCaption, CWnd* pParentWnd = NULL, UINT iSelectPage = 0);
90 virtual ~CPrinterSetupWizardSheet();
91
92 void
93 SetSelectedPrinter(Printer * printer);
94
95 Printer*
96 GetSelectedPrinter();
97
98 OSStatus
99 LoadPrinterDriver(const CString & filename);
100
101 HCURSOR
102 GetCursor();
103
104 //
105 // handles end of process event
106 //
107 virtual LONG
108 OnProcessEvent(WPARAM inWParam, LPARAM inLParam);
109
110 virtual LONG
111 OnSocketEvent(WPARAM inWParam, LPARAM inLParam);
112
113 virtual BOOL
114 OnCommand(WPARAM wParam, LPARAM lParam);
115
116 virtual BOOL
117 OnInitDialog();
118
119 virtual BOOL
120 OnSetCursor(CWnd * pWnd, UINT nHitTest, UINT message);
121
122 virtual void
123 OnContextMenu(CWnd * pWnd, CPoint pos);
124
125 afx_msg void
126 OnOK();
127
128 OSStatus
129 StartResolve( Printer * printer );
130
131 OSStatus
132 StopResolve( Printer * printer );
133
134 Printers m_printers;
135
136 HCURSOR m_active;
137 HCURSOR m_arrow;
138 HCURSOR m_wait;
139
140 protected:
141 DECLARE_MESSAGE_MAP()
142 CFirstPage m_pgFirst;
143 CSecondPage m_pgSecond;
144 CThirdPage m_pgThird;
145 CFourthPage m_pgFourth;
146
147 void
148 OnServiceResolved(
149 Service * service);
150
151 void Init(void);
152
153 private:
154
155 static void DNSSD_API
156 OnBrowse(
157 DNSServiceRef inRef,
158 DNSServiceFlags inFlags,
159 uint32_t inInterfaceIndex,
160 DNSServiceErrorType inErrorCode,
161 const char * inName,
162 const char * inType,
163 const char * inDomain,
164 void * inContext );
165
166 static void DNSSD_API
167 OnResolve(
168 DNSServiceRef inRef,
169 DNSServiceFlags inFlags,
170 uint32_t inInterfaceIndex,
171 DNSServiceErrorType inErrorCode,
172 const char * inFullName,
173 const char * inHostName,
174 uint16_t inPort,
175 uint16_t inTXTSize,
176 const char * inTXT,
177 void * inContext );
178
179 static void DNSSD_API
180 OnQuery(
181 DNSServiceRef inRef,
182 DNSServiceFlags inFlags,
183 uint32_t inInterfaceIndex,
184 DNSServiceErrorType inErrorCode,
185 const char * inFullName,
186 uint16_t inRRType,
187 uint16_t inRRClass,
188 uint16_t inRDLen,
189 const void * inRData,
190 uint32_t inTTL,
191 void * inContext);
192
193 Printer*
194 OnAddPrinter(
195 uint32_t inInterfaceIndex,
196 const char * inName,
197 const char * inType,
198 const char * inDomain,
199 bool moreComing);
200
201 OSStatus
202 OnRemovePrinter(
203 Printer * printer,
204 bool moreComing);
205
206 OSStatus
207 OnAddService(
208 Printer * printer,
209 uint32_t inInterfaceIndex,
210 const char * inName,
211 const char * inType,
212 const char * inDomain);
213
214 OSStatus
215 OnRemoveService(
216 Service * service);
217
218 void
219 OnResolveService(
220 Service * service );
221
222 static bool
223 OrderServiceFunc( const Service * a, const Service * b );
224
225 static bool
226 OrderQueueFunc( const Queue * q1, const Queue * q2 );
227
228 OSStatus
229 StartOperation( DNSServiceRef ref );
230
231 OSStatus
232 StopOperation( DNSServiceRef & ref );
233
234 OSStatus
235 StartBrowse();
236
237 OSStatus
238 StopBrowse();
239
240 OSStatus
241 StartResolve( Service * service );
242
243 OSStatus
244 StopResolve( Service * service );
245
246 OSStatus
247 ParseTextRecord( Service * service, Queue * q, uint16_t inTXTSize, const char * inTXT );
248
249 OSStatus
250 LoadPrinterNames();
251
252 Printer*
253 Lookup( const char * name );
254
255 OSStatus
256 InstallPrinter(Printer * printer);
257
258 OSStatus
259 InstallPrinterPDLAndLPR(Printer * printer, Service * service, DWORD protocol);
260
261 OSStatus
262 InstallPrinterIPP(Printer * printer, Service * service);
263
264 static unsigned WINAPI
265 InstallDriverThread( LPVOID inParam );
266
267 typedef std::map<CString,CString> PrinterNameMap;
268 typedef std::list<DNSServiceRef> ServiceRefList;
269 static CPrinterSetupWizardSheet * m_self;
270 PrinterNameMap m_printerNames;
271 Printer * m_selectedPrinter;
272 bool m_driverThreadFinished;
273 DWORD m_driverThreadExitCode;
274 ServiceRefList m_serviceRefList;
275 DNSServiceRef m_pdlBrowser;
276 DNSServiceRef m_lprBrowser;
277 DNSServiceRef m_ippBrowser;
278 DNSServiceRef m_resolver;
279 };
280
281
282 inline Printer*
283 CPrinterSetupWizardSheet::GetSelectedPrinter()
284 {
285 return m_selectedPrinter;
286 }
287
288
289 inline HCURSOR
290 CPrinterSetupWizardSheet::GetCursor()
291 {
292 return m_active;
293 }
294
295
296 // Service Types
297
298 #define kPDLServiceType "_pdl-datastream._tcp."
299 #define kLPRServiceType "_printer._tcp."
300 #define kIPPServiceType "_ipp._tcp."