summaryrefslogtreecommitdiffstats
path: root/mDNSResponder/Clients/PrinterSetupWizard/ThirdPage.h
blob: 476e233783553bcd3c39bff04c85243cf722a17c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
/* -*- Mode: C; tab-width: 4 -*-
 *
 * Copyright (c) 1997-2004 Apple Computer, Inc. All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#pragma once
#include "afxcmn.h"
#include "UtilTypes.h"
#include <CommonServices.h>
#include <DebugServices.h>
#include <dns_sd.h>
#include <map>
#include "afxwin.h"


// CThirdPage dialog

class CThirdPage : public CPropertyPage
{
DECLARE_DYNAMIC(CThirdPage)

public:
CThirdPage();
virtual ~CThirdPage();

// Dialog Data
enum { IDD = IDD_THIRD_PAGE };

protected:
virtual void DoDataExchange(CDataExchange* pDX);        // DDX/DDV support
virtual BOOL OnSetActive();
virtual BOOL OnKillActive();

DECLARE_MESSAGE_MAP()

private:

//
//<rdar://problem/4189721> mDNS: Epson shows up twice in the list.  Use case insensitive compare
//
struct compare_func
{
    bool operator()( const CString & s1, const CString & s2 ) const
    {
        return s1.CompareNoCase( s2 ) < 0;
    }
};

typedef std::map<CString, Manufacturer*, compare_func> Manufacturers;

//
// LoadPrintDriverDefsFromFile
//
// Parses INF file and populates manufacturers
//
OSStatus LoadPrintDriverDefsFromFile(Manufacturers & manufacturers, const CString & filename, bool checkForDuplicateModels );

//
// LoadPrintDriverDefs
//
// Loads extant print driver definitions
//
OSStatus LoadPrintDriverDefs(Manufacturers & manufacturers);

//
// LoadGenericPrintDriversDefs
//
// Loads generic postscript and pcl print driver defs
//
OSStatus LoadGenericPrintDriverDefs( Manufacturers & manufacturers );

//
// PopulateUI
//
// Load print driver defs into UI for browsing/selection
//
OSStatus PopulateUI(Manufacturers & manufacturers);

//
// MatchPrinter
//
// Tries to match printer based on manufacturer and model
//
OSStatus MatchPrinter(Manufacturers & manufacturers, Printer * printer, Service * service, bool useCUPSWorkaround);

//
// OnInitPage
//
// Called first time page is activated.
OSStatus OnInitPage();

//
// these functions will tweak the names so that everything is
// consistent
//
CString             ConvertToManufacturerName( const CString & name );
CString             ConvertToModelName( const CString & name );
CString             NormalizeManufacturerName( const CString & name );

Manufacturer    *   MatchManufacturer( Manufacturers & manufacturer, const CString & name );
Model           *   MatchModel( Manufacturer * manufacturer, const CString & name );
BOOL                MatchGeneric( Manufacturers & manufacturers, Printer * printer, Service * service, Manufacturer ** manufacturer, Model ** model );
void                SelectMatch(Printer * printer, Service * service, Manufacturer * manufacturer, Model * model);
void                SelectMatch(Manufacturers & manufacturers, Printer * printer, Service * service, Manufacturer * manufacturer, Model * model);
void                CopyPrinterSettings(Printer * printer, Service * service, Manufacturer * manufacturer, Model * model);
//
// <rdar://problem/4580061> mDNS: Printers added using Bonjour should be set as the default printer.
//
BOOL                DefaultPrinterExists();
//
//<rdar://problem/4528853> mDNS: When auto-highlighting items in lists, scroll list so highlighted item is in the middle
//
void                AutoScroll(CListCtrl & list, int nIndex);

void                FreeManufacturers( Manufacturers & manufacturers );

Manufacturers m_manufacturers;

CListCtrl m_manufacturerListCtrl;
Manufacturer    *   m_manufacturerSelected;

CListCtrl m_modelListCtrl;
Model           *   m_modelSelected;

Model           *   m_genericPostscript;
Model           *   m_genericPCL;

bool m_initialized;

public:

afx_msg void OnLvnItemchangedManufacturer(NMHDR *pNMHDR, LRESULT *pResult);
CStatic m_printerName;
afx_msg void OnLvnItemchangedPrinterModel(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnBnClickedDefaultPrinter();
private:

void
Split( const CString & string, TCHAR ch, CStringList & components );

CButton m_defaultPrinterCtrl;

public:
CStatic m_printerSelectionText;
CStatic *   m_printerImage;
afx_msg void OnBnClickedHaveDisk();
};