]> git.saurik.com Git - apple/mdnsresponder.git/blob - Clients/PrinterSetupWizard/ThirdPage.h
mDNSResponder-214.3.2.tar.gz
[apple/mdnsresponder.git] / Clients / PrinterSetupWizard / ThirdPage.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: ThirdPage.h,v $
20 Revision 1.10 2009/05/29 20:43:37 herscher
21 <rdar://problem/6928136> Printer Wizard doesn't work correctly in Windows 7 64 bit
22
23 Revision 1.9 2007/04/13 23:42:20 herscher
24 <rdar://problem/4580061> mDNS: Printers added using Bonjour should be set as the default printer.
25
26 Revision 1.8 2007/04/13 21:38:46 herscher
27 <rdar://problem/4528853> mDNS: When auto-highlighting items in lists, scroll list so highlighted item is in the middle
28
29 Revision 1.7 2007/04/13 20:18:30 herscher
30 <rdar://problem/4189721> mDNS: Epson shows up twice in the list
31
32 Revision 1.6 2006/08/14 23:24:09 cheshire
33 Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
34
35 Revision 1.5 2005/07/07 17:53:20 shersche
36 Fix problems associated with the CUPS printer workaround fix.
37
38 Revision 1.4 2005/02/08 21:45:06 shersche
39 <rdar://problem/3947490> Default to Generic PostScript or PCL if unable to match driver
40
41 Revision 1.3 2005/01/25 08:57:28 shersche
42 <rdar://problem/3911084> Add m_printerControl member for dynamic loading of icons from resource DLLs
43 Bug #: 3911084
44
45 Revision 1.2 2004/12/29 18:53:38 shersche
46 <rdar://problem/3725106>
47 <rdar://problem/3737413> Added support for LPR and IPP protocols as well as support for obtaining multiple text records. Reorganized and simplified codebase.
48 Bug #: 3725106, 3737413
49
50 Revision 1.1 2004/06/18 04:36:58 rpantos
51 First checked in
52
53
54 */
55
56 #pragma once
57 #include "afxcmn.h"
58 #include "UtilTypes.h"
59 #include <CommonServices.h>
60 #include <DebugServices.h>
61 #include <dns_sd.h>
62 #include <map>
63 #include "afxwin.h"
64
65
66 // CThirdPage dialog
67
68 class CThirdPage : public CPropertyPage
69 {
70 DECLARE_DYNAMIC(CThirdPage)
71
72 public:
73 CThirdPage();
74 virtual ~CThirdPage();
75
76 // Dialog Data
77 enum { IDD = IDD_THIRD_PAGE };
78
79 protected:
80 virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
81 virtual BOOL OnSetActive();
82 virtual BOOL OnKillActive();
83
84 DECLARE_MESSAGE_MAP()
85
86 private:
87
88 //
89 //<rdar://problem/4189721> mDNS: Epson shows up twice in the list. Use case insensitive compare
90 //
91 struct compare_func
92 {
93 bool operator()( const CString & s1, const CString & s2 ) const
94 {
95 return s1.CompareNoCase( s2 ) < 0;
96 }
97 };
98
99 typedef std::map<CString, Manufacturer*, compare_func> Manufacturers;
100
101 //
102 // LoadPrintDriverDefsFromFile
103 //
104 // Parses INF file and populates manufacturers
105 //
106 OSStatus LoadPrintDriverDefsFromFile(Manufacturers & manufacturers, const CString & filename, bool checkForDuplicateModels );
107
108 //
109 // LoadPrintDriverDefs
110 //
111 // Loads extant print driver definitions
112 //
113 OSStatus LoadPrintDriverDefs(Manufacturers & manufacturers);
114
115 //
116 // LoadGenericPrintDriversDefs
117 //
118 // Loads generic postscript and pcl print driver defs
119 //
120 OSStatus LoadGenericPrintDriverDefs( Manufacturers & manufacturers );
121
122 //
123 // PopulateUI
124 //
125 // Load print driver defs into UI for browsing/selection
126 //
127 OSStatus PopulateUI(Manufacturers & manufacturers);
128
129 //
130 // MatchPrinter
131 //
132 // Tries to match printer based on manufacturer and model
133 //
134 OSStatus MatchPrinter(Manufacturers & manufacturers, Printer * printer, Service * service, bool useCUPSWorkaround);
135
136 //
137 // OnInitPage
138 //
139 // Called first time page is activated.
140 OSStatus OnInitPage();
141
142 //
143 // these functions will tweak the names so that everything is
144 // consistent
145 //
146 CString ConvertToManufacturerName( const CString & name );
147 CString ConvertToModelName( const CString & name );
148 CString NormalizeManufacturerName( const CString & name );
149
150 Manufacturer * MatchManufacturer( Manufacturers & manufacturer, const CString & name );
151 Model * MatchModel( Manufacturer * manufacturer, const CString & name );
152 BOOL MatchGeneric( Manufacturers & manufacturers, Printer * printer, Service * service, Manufacturer ** manufacturer, Model ** model );
153 void SelectMatch(Printer * printer, Service * service, Manufacturer * manufacturer, Model * model);
154 void SelectMatch(Manufacturers & manufacturers, Printer * printer, Service * service, Manufacturer * manufacturer, Model * model);
155 void CopyPrinterSettings(Printer * printer, Service * service, Manufacturer * manufacturer, Model * model);
156 //
157 // <rdar://problem/4580061> mDNS: Printers added using Bonjour should be set as the default printer.
158 //
159 BOOL DefaultPrinterExists();
160 //
161 //<rdar://problem/4528853> mDNS: When auto-highlighting items in lists, scroll list so highlighted item is in the middle
162 //
163 void AutoScroll(CListCtrl & list, int nIndex);
164
165 Manufacturers m_manufacturers;
166
167 CListCtrl m_manufacturerListCtrl;
168 Manufacturer * m_manufacturerSelected;
169
170 CListCtrl m_modelListCtrl;
171 Model * m_modelSelected;
172
173 Model * m_genericPostscript;
174 Model * m_genericPCL;
175
176 bool m_initialized;
177
178 public:
179
180 afx_msg void OnLvnItemchangedManufacturer(NMHDR *pNMHDR, LRESULT *pResult);
181 CStatic m_printerName;
182 afx_msg void OnLvnItemchangedPrinterModel(NMHDR *pNMHDR, LRESULT *pResult);
183 afx_msg void OnBnClickedDefaultPrinter();
184 private:
185
186 void
187 Split( const CString & string, TCHAR ch, CStringList & components );
188
189 CButton m_defaultPrinterCtrl;
190
191 public:
192 CStatic m_printerSelectionText;
193 CStatic * m_printerImage;
194 afx_msg void OnBnClickedHaveDisk();
195 };