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