]> git.saurik.com Git - apple/mdnsresponder.git/blob - Clients/PrinterSetupWizard/SecondPage.h
mDNSResponder-98.tar.gz
[apple/mdnsresponder.git] / Clients / PrinterSetupWizard / SecondPage.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: SecondPage.h,v $
26 Revision 1.6 2005/01/04 21:09:14 shersche
27 Fix problems in parsing text records. Fix problems in remove event handling. Ensure that the same service can't be resolved more than once.
28
29 Revision 1.5 2004/12/31 07:25:27 shersche
30 Tidy up printer management, and fix memory leaks when hitting 'Cancel'
31
32 Revision 1.4 2004/12/30 01:02:46 shersche
33 <rdar://problem/3734478> Add Printer information box that displays description and location information when printer name is selected
34 Bug #: 3734478
35
36 Revision 1.3 2004/12/29 18:53:38 shersche
37 <rdar://problem/3725106>
38 <rdar://problem/3737413> Added support for LPR and IPP protocols as well as support for obtaining multiple text records. Reorganized and simplified codebase.
39 Bug #: 3725106, 3737413
40
41 Revision 1.2 2004/09/13 21:23:42 shersche
42 <rdar://problem/3796483> Add moreComing argument to OnAddPrinter and OnRemovePrinter callbacks
43 Bug #: 3796483
44
45 Revision 1.1 2004/06/18 04:36:57 rpantos
46 First checked in
47
48
49 */
50
51 #pragma once
52
53 #include "PrinterSetupWizardSheet.h"
54 #include "CommonServices.h"
55 #include "UtilTypes.h"
56 #include "afxcmn.h"
57 #include "dns_sd.h"
58 #include "afxwin.h"
59 #include <map>
60
61 using namespace PrinterSetupWizard;
62
63 // CSecondPage dialog
64
65 class CSecondPage : public CPropertyPage
66 {
67 DECLARE_DYNAMIC(CSecondPage)
68
69 public:
70 CSecondPage();
71 virtual ~CSecondPage();
72
73 // Dialog Data
74 enum { IDD = IDD_SECOND_PAGE };
75
76 static void DNSSD_API
77 OnBrowse(
78 DNSServiceRef inRef,
79 DNSServiceFlags inFlags,
80 uint32_t inInterfaceIndex,
81 DNSServiceErrorType inErrorCode,
82 const char * inName,
83 const char * inType,
84 const char * inDomain,
85 void * inContext );
86
87 static void DNSSD_API
88 OnResolve(
89 DNSServiceRef inRef,
90 DNSServiceFlags inFlags,
91 uint32_t inInterfaceIndex,
92 DNSServiceErrorType inErrorCode,
93 const char * inFullName,
94 const char * inHostName,
95 uint16_t inPort,
96 uint16_t inTXTSize,
97 const char * inTXT,
98 void * inContext );
99
100 static void DNSSD_API
101 OnQuery(
102 DNSServiceRef inRef,
103 DNSServiceFlags inFlags,
104 uint32_t inInterfaceIndex,
105 DNSServiceErrorType inErrorCode,
106 const char * inFullName,
107 uint16_t inRRType,
108 uint16_t inRRClass,
109 uint16_t inRDLen,
110 const void * inRData,
111 uint32_t inTTL,
112 void * inContext);
113
114 protected:
115
116 void InitBrowseList();
117 virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
118 afx_msg BOOL OnSetCursor(CWnd * pWnd, UINT nHitTest, UINT message);
119 virtual BOOL OnSetActive();
120 virtual BOOL OnKillActive();
121
122 DECLARE_MESSAGE_MAP()
123
124 public:
125
126 HTREEITEM m_emptyListItem;
127 bool m_selectOkay;
128 CTreeCtrl m_browseList;
129 DNSServiceRef m_resolver;
130 bool m_initialized;
131 bool m_waiting;
132
133 LONG OnServiceEvent(WPARAM inWParam, LPARAM inLParam);
134 afx_msg void OnTvnSelchangedBrowseList(NMHDR *pNMHDR, LRESULT *pResult);
135
136 private:
137
138 OSStatus
139 LoadPrinterNames();
140
141 Printer*
142 Lookup( const char * name );
143
144 OSStatus
145 StartOperation( DNSServiceRef ref );
146
147 OSStatus
148 StopOperation( DNSServiceRef & ref );
149
150 OSStatus
151 StartBrowse();
152
153 OSStatus
154 StopBrowse();
155
156 OSStatus
157 StartResolve( Printer * printer );
158
159 OSStatus
160 StartResolve( Service * service );
161
162 OSStatus
163 StopResolve( Printer * printer );
164
165 OSStatus
166 StopResolve( Service * service );
167
168 OSStatus
169 OnAddPrinter(
170 uint32_t inInterfaceIndex,
171 const char * inName,
172 const char * inType,
173 const char * inDomain,
174 bool moreComing);
175
176 OSStatus
177 OnRemovePrinter(
178 const char * inName,
179 const char * inType,
180 const char * inDomain,
181 bool moreComing);
182
183 void
184 OnResolveService( Service * service );
185
186 static bool
187 OrderServiceFunc( const Service * a, const Service * b );
188
189 static bool
190 OrderQueueFunc( const Queue * q1, const Queue * q2 );
191
192 void
193 LoadTextAndDisableWindow( CString & text );
194
195 void
196 SetPrinterInformationState( BOOL state );
197
198 OSStatus
199 ParseTextRecord( Service * service, uint16_t inTXTSize, const char * inTXT, bool & qtotalDefined, CString & qname, uint32_t & qpriority );
200
201 typedef std::map<CString,CString> PrinterNameMap;
202 typedef std::list<DNSServiceRef> ServiceRefList;
203 typedef std::list<Printer*> Printers;
204
205
206 PrinterNameMap m_printerNames;
207 Printers m_printers;
208 ServiceRefList m_serviceRefList;
209 DNSServiceRef m_pdlBrowser;
210 DNSServiceRef m_lprBrowser;
211 DNSServiceRef m_ippBrowser;
212
213 Printer * m_selected;
214 std::string m_selectedName;
215
216 private:
217
218 CStatic m_printerInformation;
219 CStatic m_descriptionLabel;
220 CStatic m_descriptionField;
221 CStatic m_locationLabel;
222 CStatic m_locationField;
223 };