1 /* -*- Mode: C; tab-width: 4 -*-
3 * Copyright (c) 1997-2004 Apple Computer, Inc. All rights reserved.
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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
21 #include "secondpage.h"
22 #include "thirdpage.h"
23 #include "fourthpage.h"
24 #include "UtilTypes.h"
30 using namespace PrinterSetupWizard
;
32 // CPrinterSetupWizardSheet
34 class CPrinterSetupWizardSheet
: public CPropertySheet
36 DECLARE_DYNAMIC(CPrinterSetupWizardSheet
)
40 struct WizardException
48 CPrinterSetupWizardSheet(UINT nIDCaption
, CWnd
* pParentWnd
= NULL
, UINT iSelectPage
= 0);
49 virtual ~CPrinterSetupWizardSheet();
55 SetLastPage(CPropertyPage
* page
);
58 SetSelectedPrinter(Printer
* printer
);
64 LoadPrinterDriver(const CString
& filename
);
70 // handles end of process event
73 OnProcessEvent(WPARAM inWParam
, LPARAM inLParam
);
76 OnSocketEvent(WPARAM inWParam
, LPARAM inLParam
);
79 OnCommand(WPARAM wParam
, LPARAM lParam
);
85 OnSetCursor(CWnd
* pWnd
, UINT nHitTest
, UINT message
);
88 OnContextMenu(CWnd
* pWnd
, CPoint pos
);
94 StartResolve( Printer
* printer
);
97 StopResolve( Printer
* printer
);
106 DECLARE_MESSAGE_MAP()
107 CSecondPage m_pgSecond
;
108 CThirdPage m_pgThird
;
109 CFourthPage m_pgFourth
;
119 // This is from <cups/http.h>
120 typedef enum http_encryption_e
/**** HTTP encryption values ****/
122 HTTP_ENCRYPT_IF_REQUESTED
, /* Encrypt if requested (TLS upgrade) */
123 HTTP_ENCRYPT_NEVER
, /* Never encrypt */
124 HTTP_ENCRYPT_REQUIRED
, /* Encryption is required (TLS upgrade) */
125 HTTP_ENCRYPT_ALWAYS
/* Always encrypt (SSL) */
128 typedef void* ( *httpConnectEncryptFunc
)( const char* host
, int port
, http_encryption_t encryption
);
129 typedef http_encryption_t ( *cupsEncryptionFunc
)( void );
130 typedef void ( *cupsSetEncryptionFunc
)( http_encryption_t e
);
131 typedef char* ( *cupsAdminCreateWindowsPPDFunc
)( void * http
, const char *dest
, char *buffer
, int bufsize
);
139 httpConnectEncrypt( NULL
),
140 cupsEncryption( NULL
),
141 cupsSetEncryption( NULL
),
142 cupsAdminCreateWindowsPPD( NULL
),
145 #if defined( LIBCUPS_ENABLED )
146 if ( ( library
= LoadLibrary( TEXT( "libcups2.dll" ) ) ) != NULL
)
148 httpConnectEncrypt
= ( httpConnectEncryptFunc
) GetProcAddress( library
, "httpConnectEncrypt" );
149 cupsEncryption
= ( cupsEncryptionFunc
) GetProcAddress( library
, "cupsEncryption" );
150 cupsSetEncryption
= ( cupsSetEncryptionFunc
) GetProcAddress( library
, "cupsSetEncryption" );
151 cupsAdminCreateWindowsPPD
= ( cupsAdminCreateWindowsPPDFunc
) GetProcAddress( library
, "cupsAdminCreateWindowsPPD" );
160 FreeLibrary( library
);
168 return ( ( httpConnectEncrypt
!= NULL
) && ( cupsEncryption
!= NULL
) && ( cupsSetEncryption
!= NULL
) && ( cupsAdminCreateWindowsPPD
!= NULL
) );
171 httpConnectEncryptFunc httpConnectEncrypt
;
172 cupsEncryptionFunc cupsEncryption
;
173 cupsSetEncryptionFunc cupsSetEncryption
;
174 cupsAdminCreateWindowsPPDFunc cupsAdminCreateWindowsPPD
;
182 static void DNSSD_API
185 DNSServiceFlags inFlags
,
186 uint32_t inInterfaceIndex
,
187 DNSServiceErrorType inErrorCode
,
190 const char * inDomain
,
193 static void DNSSD_API
196 DNSServiceFlags inFlags
,
197 uint32_t inInterfaceIndex
,
198 DNSServiceErrorType inErrorCode
,
199 const char * inFullName
,
200 const char * inHostName
,
206 static void DNSSD_API
209 DNSServiceFlags inFlags
,
210 uint32_t inInterfaceIndex
,
211 DNSServiceErrorType inErrorCode
,
212 const char * inFullName
,
216 const void * inRData
,
222 uint32_t inInterfaceIndex
,
225 const char * inDomain
,
236 uint32_t inInterfaceIndex
,
239 const char * inDomain
);
250 OrderServiceFunc( const Service
* a
, const Service
* b
);
253 OrderQueueFunc( const Queue
* q1
, const Queue
* q2
);
256 StartOperation( DNSServiceRef ref
);
259 StopOperation( DNSServiceRef
& ref
);
268 StartResolve( Service
* service
);
271 StopResolve( Service
* service
);
274 ParseTextRecord( Service
* service
, Queue
* q
, uint16_t inTXTSize
, const char * inTXT
);
280 Lookup( const char * name
);
283 InstallPrinter(Printer
* printer
);
286 InstallPrinterPort( Printer
* printer
, Service
* service
, DWORD protocol
, Logger
& log
);
289 InstallPrinterPDLAndLPR(Printer
* printer
, Service
* service
, Logger
& log
);
292 InstallPrinterIPP(Printer
* printer
, Service
* service
, Logger
& log
);
295 InstallPrinterCUPS( Printer
* printer
, Service
* service
, CUPSLibrary
& cupsLib
);
298 InstallPrinterCUPS(Printer
* printer
, Service
* service
, CUPSLibrary
& cupsLib
, TCHAR
* env
);
300 static unsigned WINAPI
301 InstallDriverThread( LPVOID inParam
);
303 typedef std::list
<CString
> PrinterNames
;
304 typedef std::list
<DNSServiceRef
> ServiceRefList
;
305 static CPrinterSetupWizardSheet
* m_self
;
306 PrinterNames m_printerNames
;
307 Printer
* m_selectedPrinter
;
308 bool m_driverThreadFinished
;
309 DWORD m_driverThreadExitCode
;
310 ServiceRefList m_serviceRefList
;
311 DNSServiceRef m_pdlBrowser
;
312 DNSServiceRef m_lprBrowser
;
313 DNSServiceRef m_ippBrowser
;
314 DNSServiceRef m_resolver
;
316 CPropertyPage
* m_lastPage
;
321 CPrinterSetupWizardSheet::GetSelectedPrinter()
323 return m_selectedPrinter
;
328 CPrinterSetupWizardSheet::GetCursor()
334 inline CPropertyPage
*
335 CPrinterSetupWizardSheet::GetLastPage()
342 CPrinterSetupWizardSheet::SetLastPage(CPropertyPage
* lastPage
)
344 m_lastPage
= lastPage
;
350 #define kPDLServiceType "_pdl-datastream._tcp."
351 #define kLPRServiceType "_printer._tcp."
352 #define kIPPServiceType "_ipp._tcp."