]> git.saurik.com Git - apple/mdnsresponder.git/blob - Clients/PrinterSetupWizard/PrinterSetupWizardSheet.h
mDNSResponder-87.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.4 2004/07/13 21:24:23 rpantos
27 Fix for <rdar://problem/3701120>.
28
29 Revision 1.3 2004/06/28 00:51:47 shersche
30 Move call to EnumPrinters out of browse callback into standalone function
31
32 Revision 1.2 2004/06/24 20:12:07 shersche
33 Clean up source code
34 Submitted by: herscher
35
36 Revision 1.1 2004/06/18 04:36:57 rpantos
37 First checked in
38
39
40 */
41
42 #pragma once
43
44
45 #include "firstpage.h"
46 #include "secondpage.h"
47 #include "thirdpage.h"
48 #include "fourthpage.h"
49 #include "UtilTypes.h"
50 #include "dns_sd.h"
51 #include <stdexcept>
52 #include <map>
53
54 using namespace PrinterSetupWizard;
55
56 // CPrinterSetupWizardSheet
57
58 class CPrinterSetupWizardSheet : public CPropertySheet
59 {
60 DECLARE_DYNAMIC(CPrinterSetupWizardSheet)
61
62 public:
63
64 struct WizardException
65 {
66 CString text;
67 CString caption;
68 };
69
70 public:
71
72 CPrinterSetupWizardSheet(UINT nIDCaption, CWnd* pParentWnd = NULL, UINT iSelectPage = 0);
73 virtual ~CPrinterSetupWizardSheet();
74
75 int
76 InstallEventHandler(EventHandler * handler);
77
78 int
79 RemoveEventHandler(EventHandler * handler);
80
81 OSStatus
82 SetSelectedPrinter(Printer * printer);
83
84 Printer*
85 GetSelectedPrinter();
86
87 OSStatus
88 LoadPrinterDriver(const CString & filename);
89
90 HCURSOR
91 GetCursor();
92
93 //
94 // handles socket events for DNSService operations
95 //
96 virtual LONG
97 OnServiceEvent(WPARAM inWParam, LPARAM inLParam);
98
99 //
100 // handles end of process event
101 //
102 virtual LONG
103 OnProcessEvent(WPARAM inWParam, LPARAM inLParam);
104
105 virtual BOOL
106 OnCommand(WPARAM wParam, LPARAM lParam);
107
108 virtual BOOL
109 OnInitDialog();
110
111 virtual BOOL
112 OnSetCursor(CWnd * pWnd, UINT nHitTest, UINT message);
113
114 virtual void
115 OnContextMenu(CWnd * pWnd, CPoint pos);
116
117 afx_msg void
118 OnOK();
119
120 protected:
121 DECLARE_MESSAGE_MAP()
122 CFirstPage m_pgFirst;
123 CSecondPage m_pgSecond;
124 CThirdPage m_pgThird;
125 CFourthPage m_pgFourth;
126
127 static void DNSSD_API
128 OnBrowse(
129 DNSServiceRef inRef,
130 DNSServiceFlags inFlags,
131 uint32_t inInterfaceIndex,
132 DNSServiceErrorType inErrorCode,
133 const char * inName,
134 const char * inType,
135 const char * inDomain,
136 void * inContext );
137
138 static void DNSSD_API
139 OnResolve(
140 DNSServiceRef inRef,
141 DNSServiceFlags inFlags,
142 uint32_t inInterfaceIndex,
143 DNSServiceErrorType inErrorCode,
144 const char * inFullName,
145 const char * inHostName,
146 uint16_t inPort,
147 uint16_t inTXTSize,
148 const char * inTXT,
149 void * inContext );
150
151 void Init(void);
152
153 private:
154
155 OSStatus
156 LoadPrinterNames();
157
158 OSStatus
159 StartResolve(Printer * printer);
160
161 OSStatus
162 StopResolve(Printer * printer);
163
164 Printer*
165 LookUp(const char * inName);
166
167 OSStatus
168 InstallPrinter(Printer * printer);
169
170 static unsigned WINAPI
171 InstallPrinterThread( LPVOID inParam );
172
173
174 typedef std::list<Printer*> PrinterList;
175 typedef std::list<EventHandler*> EventHandlerList;
176 typedef std::list<DNSServiceRef> ServiceRefList;
177 typedef std::map<CString,CString> PrinterNameMap;
178
179 Printer * m_selectedPrinter;
180
181 PrinterNameMap m_printerNames;
182 PrinterList m_printerList;
183 EventHandlerList m_eventHandlerList;
184 ServiceRefList m_serviceRefList;
185
186 bool m_processFinished;
187
188 HCURSOR m_active;
189 HCURSOR m_arrow;
190 HCURSOR m_wait;
191
192 DNSServiceRef m_pdlBrowser;
193 };
194
195
196 inline Printer*
197 CPrinterSetupWizardSheet::GetSelectedPrinter()
198 {
199 return m_selectedPrinter;
200 }
201
202
203 inline HCURSOR
204 CPrinterSetupWizardSheet::GetCursor()
205 {
206 return m_active;
207 }