Skip to content

Commit

Permalink
Bug 1657874 - Remove CUPSPrinterList. r=jwatt
Browse files Browse the repository at this point in the history
Now that we share the list code between GTK and Mac, there's no reason
for this. This also avoids work when getting the default printer name.

Differential Revision: https://phabricator.services.mozilla.com/D86345
  • Loading branch information
emilio committed Aug 7, 2020
1 parent 63ad134 commit cf0578d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 110 deletions.
41 changes: 0 additions & 41 deletions widget/CUPSPrinterList.cpp

This file was deleted.

58 changes: 0 additions & 58 deletions widget/CUPSPrinterList.h

This file was deleted.

1 change: 0 additions & 1 deletion widget/moz.build
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,6 @@ if CONFIG['MOZ_XUL'] and CONFIG['NS_PRINTING']:

if toolkit in ('cocoa', 'gtk'):
UNIFIED_SOURCES += [
'CUPSPrinterList.cpp',
'nsCUPSShim.cpp',
'nsPrinterCUPS.cpp',
'nsPrinterListCUPS.cpp',
Expand Down
22 changes: 12 additions & 10 deletions widget/nsPrinterListCUPS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@

#include "nsPrinterListCUPS.h"

#include "CUPSPrinterList.h"
#include "mozilla/IntegerRange.h"
#include "nsCUPSShim.h"
#include "nsPrinterCUPS.h"
#include "nsString.h"
#include "prenv.h"

static nsCUPSShim sCupsShim;
Expand All @@ -17,12 +18,12 @@ nsPrinterListCUPS::GetPrinters(nsTArray<RefPtr<nsIPrinter>>& aPrinters) {
return NS_ERROR_FAILURE;
}

mozilla::CUPSPrinterList cupsPrinterList(sCupsShim);
cupsPrinterList.Initialize();
aPrinters.SetCapacity(cupsPrinterList.NumPrinters());
cups_dest_t* printers = nullptr;
auto numPrinters = sCupsShim.cupsGetDests(&printers);
aPrinters.SetCapacity(numPrinters);

for (int i = 0; i < cupsPrinterList.NumPrinters(); i++) {
cups_dest_t* const dest = cupsPrinterList.GetPrinter(i);
for (auto i : mozilla::IntegerRange(0, numPrinters)) {
cups_dest_t* dest = printers + i;

nsString displayName;
GetDisplayNameForPrinter(*dest, displayName);
Expand All @@ -32,6 +33,7 @@ nsPrinterListCUPS::GetPrinters(nsTArray<RefPtr<nsIPrinter>>& aPrinters) {
aPrinters.AppendElement(cupsPrinter);
}

sCupsShim.cupsFreeDests(numPrinters, printers);
return NS_OK;
}

Expand All @@ -41,10 +43,10 @@ nsPrinterListCUPS::GetSystemDefaultPrinterName(nsAString& aName) {
return NS_ERROR_FAILURE;
}

mozilla::CUPSPrinterList cupsPrinterList(sCupsShim);
cupsPrinterList.Initialize();

cups_dest_t* const dest = cupsPrinterList.GetDefaultPrinter();
// Passing in nullptr for the name will return the default, if any.
const cups_dest_t* dest =
sCupsShim.cupsGetNamedDest(CUPS_HTTP_DEFAULT, /* name */ nullptr,
/* instance */ nullptr);
if (!dest) {
return NS_ERROR_GFX_PRINTER_NO_PRINTER_AVAILABLE;
}
Expand Down

0 comments on commit cf0578d

Please sign in to comment.