feat: enhance PrinterInfo object values (#21081)

This commit is contained in:
Shelley Vohr 2019-11-13 05:31:28 +00:00 committed by Cheng Zhao
parent 8320160fe2
commit b8ee8c4eee
2 changed files with 23 additions and 16 deletions

View file

@ -1,9 +1,13 @@
# PrinterInfo Object # PrinterInfo Object
* `name` String * `name` String - the name of the printer as understood by the OS.
* `description` String * `displayName` String - the name of the printer as shown in Print Preview.
* `status` Number * `description` String - a longer description of the printer's type.
* `isDefault` Boolean * `status` Number - the current status of the printer.
* `isDefault` Boolean - whether or not a given printer is set as the default printer on the OS.
* `options` Object - an object containing a variable number of platform-specific printer information.
The number represented by `status` means different things on different platforms: on Windows it's potential values can be found [here](https://docs.microsoft.com/en-us/windows/win32/printdocs/printer-info-2), and on Linux and macOS they can be found [here](https://www.cups.org/doc/cupspm.html).
## Example ## Example
@ -12,13 +16,14 @@ may be different on each platform.
```javascript ```javascript
{ {
name: 'Zebra_LP2844', name: 'Austin_4th_Floor_Printer___C02XK13BJHD4',
description: 'Zebra LP2844', displayName: 'Austin 4th Floor Printer @ C02XK13BJHD4',
description: 'TOSHIBA ColorMFP',
status: 3, status: 3,
isDefault: false, isDefault: false,
options: { options: {
copies: '1', copies: '1',
'device-uri': 'usb://Zebra/LP2844?location=14200000', 'device-uri': 'dnssd://Austin%204th%20Floor%20Printer%20%40%20C02XK13BJHD4._ipps._tcp.local./?uuid=71687f1e-1147-3274-6674-22de61b110bd',
finishings: '3', finishings: '3',
'job-cancel-after': '10800', 'job-cancel-after': '10800',
'job-hold-until': 'no-hold', 'job-hold-until': 'no-hold',
@ -26,18 +31,19 @@ may be different on each platform.
'job-sheets': 'none,none', 'job-sheets': 'none,none',
'marker-change-time': '0', 'marker-change-time': '0',
'number-up': '1', 'number-up': '1',
'printer-commands': 'none', 'printer-commands': 'ReportLevels,PrintSelfTestPage,com.toshiba.ColourProfiles.update,com.toshiba.EFiling.update,com.toshiba.EFiling.checkPassword',
'printer-info': 'Zebra LP2844', 'printer-info': 'Austin 4th Floor Printer @ C02XK13BJHD4',
'printer-is-accepting-jobs': 'true', 'printer-is-accepting-jobs': 'true',
'printer-is-shared': 'true', 'printer-is-shared': 'false',
'printer-is-temporary': 'false',
'printer-location': '', 'printer-location': '',
'printer-make-and-model': 'Zebra EPL2 Label Printer', 'printer-make-and-model': 'TOSHIBA ColorMFP',
'printer-state': '3', 'printer-state': '3',
'printer-state-change-time': '1484872644', 'printer-state-change-time': '1573472937',
'printer-state-reasons': 'offline-report', 'printer-state-reasons': 'offline-report,com.toshiba.snmp.failed',
'printer-type': '36932', 'printer-type': '10531038',
'printer-uri-supported': 'ipp://localhost/printers/Zebra_LP2844', 'printer-uri-supported': 'ipp://localhost/printers/Austin_4th_Floor_Printer___C02XK13BJHD4',
system_driverinfo: 'Z' system_driverinfo: 'T'
} }
} }
``` ```

View file

@ -131,6 +131,7 @@ struct Converter<printing::PrinterBasicInfo> {
const printing::PrinterBasicInfo& val) { const printing::PrinterBasicInfo& val) {
gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate); gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
dict.Set("name", val.printer_name); dict.Set("name", val.printer_name);
dict.Set("displayName", val.display_name);
dict.Set("description", val.printer_description); dict.Set("description", val.printer_description);
dict.Set("status", val.printer_status); dict.Set("status", val.printer_status);
dict.Set("isDefault", val.is_default ? true : false); dict.Set("isDefault", val.is_default ? true : false);