|
IntroductionStarting with Mac OS X 10.4, IP printers can detect printer supply levels by using the built-in command line tool /System/Library/Printers/Libraries/snmpInk <queue_id> This tool will return XML formatted data obtained using SNMP which is then used to create a supply level Print Dialog Extension (PDE), which can be displayed to the user to indicate ink levels. Here is an example of a "Supply Levels" pane in the Print Dialog: Custom Supply ToolsA printer driver can provide a custom tool that can detect printer supply levels. This tool will override the default If you have a CUPS driver and you would like to override the default tool with your custom tool, you must add the * *APPrinterLowInkTool: "/Library/Printers/Foo/Utility/MySupplyTool" If you have a Tioga driver (10.0 -10.1 based driver), you must include the When executed, the tool should write to stdout the XML form of a CF or Your tool should also be able to end gracefully when receiving the TERM signal. The TERM signal is sent to your tool if a user were to switch printers in the print dialog. Therefore, your tool may need a signal handler to gracefully shutdown its dialog with the printer. Required KeysCurrently, there is a single defined key for the top-level dictionary. This key is When creating your custom tool, you must support four keys. Table 1: Required Keys
IMPORTANT: It is important to note that your custom tool should return localized CFStrings for the prtMarkerSuppliesDescription key. Therefore, your tool would most likely be contained in an application bundle with localized resources. Optional KeysTable 2: Optional Keys
Testing your toolWhen you are testing your custom supply tool, you can run your tool on the command line and retrieve output in the console. <tool> <queue_id> Note: When developing a custom tool you must enable verbose output by modifying your printing preferences to get the output returned by your tool. Enable verbose output with the following command: defaults write com.apple.print verboseInk 'YES' Sample SNMP QueryHere is sample output for a color laser printer. This sample was generated via SNMP queries of the printer. Listing 1: Sample SNMP Query <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>prtMarkerSuppliesTable</key> <array> <dict> <key>prtMarkerSuppliesClass</key> <integer>3</integer> <key>prtMarkerSuppliesDescription</key> <string>Black Print Cartridge</string> <key>prtMarkerSuppliesLevel</key> <integer>20500</integer> <key>prtMarkerSuppliesMaxCapacity</key> <integer>25000</integer> <key>prtMarkerSuppliesSupplyUnit</key> <integer>7</integer> <key>prtMarkerSuppliesType</key> <integer>3</integer> <key>prtMarkerPartNumber</key> <string>HP C8550A</string> </dict> <dict> <key>prtMarkerSuppliesClass</key> <integer>3</integer> <key>prtMarkerSuppliesDescription</key> <string>Cyan Print Cartridge</string> <key>prtMarkerSuppliesLevel</key> <integer>11750</integer> <key>prtMarkerSuppliesMaxCapacity</key> <integer>25000</integer> <key>prtMarkerSuppliesSupplyUnit</key> <integer>7</integer> <key>prtMarkerSuppliesType</key> <integer>3</integer> <key>prtMarkerPartNumber</key> <string>HP C8551A</string> </dict> <dict> <key>prtMarkerSuppliesClass</key> <integer>3</integer> <key>prtMarkerSuppliesDescription</key> <string>Magenta Print Cartridge</string> <key>prtMarkerSuppliesLevel</key> <integer>12500</integer> <key>prtMarkerSuppliesMaxCapacity</key> <integer>25000</integer> <key>prtMarkerSuppliesSupplyUnit</key> <integer>7</integer> <key>prtMarkerSuppliesType</key> <integer>3</integer> <key>prtMarkerPartNumber</key> <string>HP C8553A</string> </dict> <dict> <key>prtMarkerSuppliesClass</key> <integer>3</integer> <key>prtMarkerSuppliesDescription</key> <string>Yellow Print Cartridge</string> <key>prtMarkerSuppliesLevel</key> <integer>11500</integer> <key>prtMarkerSuppliesMaxCapacity</key> <integer>25000</integer> <key>prtMarkerSuppliesSupplyUnit</key> <integer>7</integer> <key>prtMarkerSuppliesType</key> <integer>3</integer> <key>prtMarkerPartNumber</key> <string>HP C8552A</string> </dict> <dict> <key>prtMarkerSuppliesClass</key> <integer>3</integer> <key>prtMarkerSuppliesDescription</key> <string>Black Image Drum</string> <key>prtMarkerSuppliesLevel</key> <integer>38800</integer> <key>prtMarkerSuppliesMaxCapacity</key> <integer>40000</integer> <key>prtMarkerSuppliesSupplyUnit</key> <integer>7</integer> <key>prtMarkerSuppliesType</key> <integer>9</integer> <key>prtMarkerPartNumber</key> <string>HP C8560A</string> </dict> <dict> <key>prtMarkerSuppliesClass</key> <integer>3</integer> <key>prtMarkerSuppliesDescription</key> <string>Cyan Image Drum</string> <key>prtMarkerSuppliesLevel</key> <integer>14400</integer> <key>prtMarkerSuppliesMaxCapacity</key> <integer>40000</integer> <key>prtMarkerSuppliesSupplyUnit</key> <integer>7</integer> <key>prtMarkerSuppliesType</key> <integer>9</integer> <key>prtMarkerPartNumber</key> <string>HP C8561A</string> </dict> <dict> <key>prtMarkerSuppliesClass</key> <integer>3</integer> <key>prtMarkerSuppliesDescription</key> <string>Magenta Image Drum</string> <key>prtMarkerSuppliesLevel</key> <integer>14800</integer> <key>prtMarkerSuppliesMaxCapacity</key> <integer>40000</integer> <key>prtMarkerSuppliesSupplyUnit</key> <integer>7</integer> <key>prtMarkerSuppliesType</key> <integer>9</integer> <key>prtMarkerPartNumber</key> <string>HP C8563A</string> </dict> <dict> <key>prtMarkerSuppliesClass</key> <integer>3</integer> <key>prtMarkerSuppliesDescription</key> <string>Yellow Image Drum</string> <key>prtMarkerSuppliesLevel</key> <integer>14800</integer> <key>prtMarkerSuppliesMaxCapacity</key> <integer>40000</integer> <key>prtMarkerSuppliesSupplyUnit</key> <integer>7</integer> <key>prtMarkerSuppliesType</key> <integer>9</integer> <key>prtMarkerPartNumber</key> <string>HP C8562A</string> </dict> <dict> <key>prtMarkerSuppliesClass</key> <integer>3</integer> <key>prtMarkerSuppliesDescription</key> <string>Image Transfer Kit</string> <key>prtMarkerSuppliesLevel</key> <integer>162822</integer> <key>prtMarkerSuppliesMaxCapacity</key> <integer>200000</integer> <key>prtMarkerSuppliesSupplyUnit</key> <integer>7</integer> <key>prtMarkerSuppliesType</key> <integer>20</integer> <key>prtMarkerPartNumber</key> <string>HP C8555A</string> </dict> <dict> <key>prtMarkerSuppliesClass</key> <integer>3</integer> <key>prtMarkerSuppliesDescription</key> <string>Image Cleaning Kit</string> <key>prtMarkerSuppliesLevel</key> <integer>45388</integer> <key>prtMarkerSuppliesMaxCapacity</key> <integer>50000</integer> <key>prtMarkerSuppliesSupplyUnit</key> <integer>7</integer> <key>prtMarkerSuppliesType</key> <integer>18</integer> <key>prtMarkerPartNumber</key> <string>HP C8554A</string> </dict> <dict> <key>prtMarkerSuppliesClass</key> <integer>3</integer> <key>prtMarkerSuppliesDescription</key> <string>Image Fuser Kit</string> <key>prtMarkerSuppliesLevel</key> <integer>62819</integer> <key>prtMarkerSuppliesMaxCapacity</key> <integer>100000</integer> <key>prtMarkerSuppliesSupplyUnit</key> <integer>7</integer> <key>prtMarkerSuppliesType</key> <integer>15</integer> <key>prtMarkerPartNumber</key> <string>HP C8556A </string> </dict> </array> </dict> </plist> Communication with your printerTo communicate with your printer, you will need to determine your printers connection type. You can use the Listing 2: Determine your printers connection type from the queue ID //argv[1] = Queue name CFStringRef queueID = CFStringCreateWithCString(kCFAllocatorDefault,argv[1],kCFStringEncodingUTF8); PMPrinter printer = PMPrinterCreateFromPrinterID(queueID); CFURLRef deviceURI; PMPrinterCopyDeviceURI(printer, (CFURLRef *)&deviceURI); //connection type : ipp, lpd ... CFURLRef scheme = CFURLCopyScheme(deviceURI); Document Revision History
Posted: 2005-06-29 |
|