]> git.saurik.com Git - apple/mdnsresponder.git/blobdiff - Clients/PrinterSetupWizard/PrinterSetupWizardSheet.cpp
mDNSResponder-176.3.tar.gz
[apple/mdnsresponder.git] / Clients / PrinterSetupWizard / PrinterSetupWizardSheet.cpp
index 378e56ce06071ee487f8049e20551c54ac1d0e24..e912716b3a2e0284a0f2976ac8c7ec086c415e3b 100644 (file)
@@ -1,28 +1,37 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 1997-2004 Apple Computer, Inc. All rights reserved.
  *
  * Copyright (c) 1997-2004 Apple Computer, Inc. All rights reserved.
  *
- * @APPLE_LICENSE_HEADER_START@
+ * 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
  * 
  * 
- * This file contains Original Code and/or Modifications of Original Code
- * as defined in and that are subject to the Apple Public Source License
- * Version 2.0 (the 'License'). You may not use this file except in
- * compliance with the License. Please obtain a copy of the License at
- * http://www.opensource.apple.com/apsl/ and read it before using this
- * file.
+ *     http://www.apache.org/licenses/LICENSE-2.0
  * 
  * 
- * The Original Code and all software distributed under the License are
- * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
- * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
- * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
- * Please see the License for the specific language governing rights and
+ * 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.
  * limitations under the License.
- * 
- * @APPLE_LICENSE_HEADER_END@
 
     Change History (most recent first):
     
 $Log: PrinterSetupWizardSheet.cpp,v $
 
     Change History (most recent first):
     
 $Log: PrinterSetupWizardSheet.cpp,v $
+Revision 1.35  2006/08/14 23:24:09  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
+Revision 1.34  2005/10/05 17:32:51  herscher
+<rdar://problem/4141221> Use a case insensitive compare operation to check whether a printer with the same name has already been installed.
+
+Revision 1.33  2005/07/11 20:17:15  shersche
+<rdar://problem/4124524> UI fixes associated with CUPS printer workaround fix.
+
+Revision 1.32  2005/07/07 17:53:20  shersche
+Fix problems associated with the CUPS printer workaround fix.
+
+Revision 1.31  2005/06/30 18:02:54  shersche
+<rdar://problem/4124524> Workaround for Mac OS X Printer Sharing bug
+
 Revision 1.30  2005/04/13 17:46:22  shersche
 <rdar://problem/4082122> Generic PCL not selected when printers advertise multiple text records
 
 Revision 1.30  2005/04/13 17:46:22  shersche
 <rdar://problem/4082122> Generic PCL not selected when printers advertise multiple text records
 
@@ -166,7 +175,8 @@ CPrinterSetupWizardSheet::CPrinterSetupWizardSheet(UINT nIDCaption, CWnd* pParen
        m_driverThreadFinished( false ),
        m_pdlBrowser( NULL ),
        m_ippBrowser( NULL ),
        m_driverThreadFinished( false ),
        m_pdlBrowser( NULL ),
        m_ippBrowser( NULL ),
-       m_lprBrowser( NULL )
+       m_lprBrowser( NULL ),
+       m_lastPage( NULL )
 {
        m_arrow         =       LoadCursor(0, IDC_ARROW);
        m_wait          =       LoadCursor(0, IDC_APPSTARTING);
 {
        m_arrow         =       LoadCursor(0, IDC_ARROW);
        m_wait          =       LoadCursor(0, IDC_APPSTARTING);
@@ -248,7 +258,7 @@ CPrinterSetupWizardSheet::LoadPrinterNames()
                {
                        PRINTER_INFO_4 * lppi4 = (PRINTER_INFO_4*) (buffer + index * sizeof(PRINTER_INFO_4));
 
                {
                        PRINTER_INFO_4 * lppi4 = (PRINTER_INFO_4*) (buffer + index * sizeof(PRINTER_INFO_4));
 
-                       m_printerNames[lppi4->pPrinterName] = lppi4->pPrinterName;
+                       m_printerNames.push_back( lppi4->pPrinterName );
                }
        }
 
                }
        }
 
@@ -292,6 +302,7 @@ CPrinterSetupWizardSheet::InstallPrinter(Printer * printer)
        //
        // if the driver isn't installed, then install it
        //
        //
        // if the driver isn't installed, then install it
        //
+
        if ( !printer->driverInstalled )
        {
                DWORD           dwResult;
        if ( !printer->driverInstalled )
        {
                DWORD           dwResult;
@@ -401,7 +412,7 @@ CPrinterSetupWizardSheet::InstallPrinterPDLAndLPR(Printer * printer, Service * s
        ok = OpenPrinter(L",XcvMonitor Standard TCP/IP Port", &hXcv, &printerDefaults);
        err = translate_errno( ok, errno_compat(), kUnknownErr );
        require_noerr( err, exit );
        ok = OpenPrinter(L",XcvMonitor Standard TCP/IP Port", &hXcv, &printerDefaults);
        err = translate_errno( ok, errno_compat(), kUnknownErr );
        require_noerr( err, exit );
-       
+
        //
        // BUGBUG: MSDN said this is not required, but my experience shows it is required
        //
        //
        // BUGBUG: MSDN said this is not required, but my experience shows it is required
        //
@@ -432,7 +443,7 @@ CPrinterSetupWizardSheet::InstallPrinterPDLAndLPR(Printer * printer, Service * s
        wcscpy(portData.sztQueue, q->name);
        wcscpy(portData.sztIPAddress, service->hostname); 
        wcscpy(portData.sztHostAddress, service->hostname);
        wcscpy(portData.sztQueue, q->name);
        wcscpy(portData.sztIPAddress, service->hostname); 
        wcscpy(portData.sztHostAddress, service->hostname);
-               
+
        ok = XcvData(hXcv, L"AddPort", (PBYTE) &portData, sizeof(PORT_DATA_1), pOutputData, cbInputData,  &cbOutputNeeded, &dwStatus);
        err = translate_errno( ok, errno_compat(), kUnknownErr );
        require_noerr( err, exit );
        ok = XcvData(hXcv, L"AddPort", (PBYTE) &portData, sizeof(PORT_DATA_1), pOutputData, cbInputData,  &cbOutputNeeded, &dwStatus);
        err = translate_errno( ok, errno_compat(), kUnknownErr );
        require_noerr( err, exit );
@@ -1121,9 +1132,18 @@ CPrinterSetupWizardSheet::OnAddPrinter(
 
        for (;;)
        {
 
        for (;;)
        {
-               CPrinterSetupWizardSheet::PrinterNameMap::iterator it;
+               CPrinterSetupWizardSheet::PrinterNames::iterator it;
+
+               // <rdar://problem/4141221> Don't use find to do comparisons because we need to
+               // do a case insensitive string comparison
 
 
-               it = m_printerNames.find(printer->actualName);
+               for ( it = m_printerNames.begin(); it != m_printerNames.end(); it++ )
+               {
+                       if ( (*it).CompareNoCase( printer->actualName ) == 0 )
+                       {
+                               break;
+                       }
+               }
 
                if (it != m_printerNames.end())
                {
 
                if (it != m_printerNames.end())
                {
@@ -1267,7 +1287,7 @@ CPrinterSetupWizardSheet::OnResolveService( Service * service )
 {
        // Make sure that the active page is page 2
 
 {
        // Make sure that the active page is page 2
 
-       check( GetActivePage() == &m_pgSecond );
+       require_quiet( GetActivePage() == &m_pgSecond, exit );
 
        if ( !--service->printer->resolving )
        {
 
        if ( !--service->printer->resolving )
        {
@@ -1289,6 +1309,10 @@ CPrinterSetupWizardSheet::OnResolveService( Service * service )
 
                m_pgSecond.OnResolveService( service );
        }               
 
                m_pgSecond.OnResolveService( service );
        }               
+
+exit:
+
+       return;
 }
 
 
 }
 
 
@@ -1633,6 +1657,13 @@ CPrinterSetupWizardSheet::ParseTextRecord( Service * service, Queue * q, uint16_
                q->priority = atoi( buf );
        }
 
                q->priority = atoi( buf );
        }
 
+       // <rdar://problem/4124524> Was this printer discovered via OS X Printer Sharing?
+
+       if ( TXTRecordContainsKey( inTXTSize, inTXT, "printer-state" ) || TXTRecordContainsKey( inTXTSize, inTXT, "printer-type" ) )
+       {
+               service->printer->isSharedFromOSX = true;
+       }
+
 exit:
 
        // The following code is to fix a problem with older HP 
 exit:
 
        // The following code is to fix a problem with older HP