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