]> git.saurik.com Git - apple/mdnsresponder.git/blob - Clients/PrinterSetupWizard/ThirdPage.h
mDNSResponder-1310.80.1.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
18 #pragma once
19 #include "afxcmn.h"
20 #include "UtilTypes.h"
21 #include <CommonServices.h>
22 #include <DebugServices.h>
23 #include <dns_sd.h>
24 #include <map>
25 #include "afxwin.h"
26
27
28 // CThirdPage dialog
29
30 class CThirdPage : public CPropertyPage
31 {
32 DECLARE_DYNAMIC(CThirdPage)
33
34 public:
35 CThirdPage();
36 virtual ~CThirdPage();
37
38 // Dialog Data
39 enum { IDD = IDD_THIRD_PAGE };
40
41 protected:
42 virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
43 virtual BOOL OnSetActive();
44 virtual BOOL OnKillActive();
45
46 DECLARE_MESSAGE_MAP()
47
48 private:
49
50 //
51 //<rdar://problem/4189721> mDNS: Epson shows up twice in the list. Use case insensitive compare
52 //
53 struct compare_func
54 {
55 bool operator()( const CString & s1, const CString & s2 ) const
56 {
57 return s1.CompareNoCase( s2 ) < 0;
58 }
59 };
60
61 typedef std::map<CString, Manufacturer*, compare_func> Manufacturers;
62
63 //
64 // LoadPrintDriverDefsFromFile
65 //
66 // Parses INF file and populates manufacturers
67 //
68 OSStatus LoadPrintDriverDefsFromFile(Manufacturers & manufacturers, const CString & filename, bool checkForDuplicateModels );
69
70 //
71 // LoadPrintDriverDefs
72 //
73 // Loads extant print driver definitions
74 //
75 OSStatus LoadPrintDriverDefs(Manufacturers & manufacturers);
76
77 //
78 // LoadGenericPrintDriversDefs
79 //
80 // Loads generic postscript and pcl print driver defs
81 //
82 OSStatus LoadGenericPrintDriverDefs( Manufacturers & manufacturers );
83
84 //
85 // PopulateUI
86 //
87 // Load print driver defs into UI for browsing/selection
88 //
89 OSStatus PopulateUI(Manufacturers & manufacturers);
90
91 //
92 // MatchPrinter
93 //
94 // Tries to match printer based on manufacturer and model
95 //
96 OSStatus MatchPrinter(Manufacturers & manufacturers, Printer * printer, Service * service, bool useCUPSWorkaround);
97
98 //
99 // OnInitPage
100 //
101 // Called first time page is activated.
102 OSStatus OnInitPage();
103
104 //
105 // these functions will tweak the names so that everything is
106 // consistent
107 //
108 CString ConvertToManufacturerName( const CString & name );
109 CString ConvertToModelName( const CString & name );
110 CString NormalizeManufacturerName( const CString & name );
111
112 Manufacturer * MatchManufacturer( Manufacturers & manufacturer, const CString & name );
113 Model * MatchModel( Manufacturer * manufacturer, const CString & name );
114 BOOL MatchGeneric( Manufacturers & manufacturers, Printer * printer, Service * service, Manufacturer ** manufacturer, Model ** model );
115 void SelectMatch(Printer * printer, Service * service, Manufacturer * manufacturer, Model * model);
116 void SelectMatch(Manufacturers & manufacturers, Printer * printer, Service * service, Manufacturer * manufacturer, Model * model);
117 void CopyPrinterSettings(Printer * printer, Service * service, Manufacturer * manufacturer, Model * model);
118 //
119 // <rdar://problem/4580061> mDNS: Printers added using Bonjour should be set as the default printer.
120 //
121 BOOL DefaultPrinterExists();
122 //
123 //<rdar://problem/4528853> mDNS: When auto-highlighting items in lists, scroll list so highlighted item is in the middle
124 //
125 void AutoScroll(CListCtrl & list, int nIndex);
126
127 void FreeManufacturers( Manufacturers & manufacturers );
128
129 Manufacturers m_manufacturers;
130
131 CListCtrl m_manufacturerListCtrl;
132 Manufacturer * m_manufacturerSelected;
133
134 CListCtrl m_modelListCtrl;
135 Model * m_modelSelected;
136
137 Model * m_genericPostscript;
138 Model * m_genericPCL;
139
140 bool m_initialized;
141
142 public:
143
144 afx_msg void OnLvnItemchangedManufacturer(NMHDR *pNMHDR, LRESULT *pResult);
145 CStatic m_printerName;
146 afx_msg void OnLvnItemchangedPrinterModel(NMHDR *pNMHDR, LRESULT *pResult);
147 afx_msg void OnBnClickedDefaultPrinter();
148 private:
149
150 void
151 Split( const CString & string, TCHAR ch, CStringList & components );
152
153 CButton m_defaultPrinterCtrl;
154
155 public:
156 CStatic m_printerSelectionText;
157 CStatic * m_printerImage;
158 afx_msg void OnBnClickedHaveDisk();
159 };