Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(176)

Unified Diff: chrome/service/cloud_print/printer_info_cups.cc

Issue 2232002: Added CUPS options to the printer information. Options get uploaded to the cl... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 10 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/service/cloud_print/printer_info.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/service/cloud_print/printer_info_cups.cc
===================================================================
--- chrome/service/cloud_print/printer_info_cups.cc (revision 48213)
+++ chrome/service/cloud_print/printer_info_cups.cc (working copy)
@@ -32,30 +32,42 @@
cups_dest_t* destinations = NULL;
int num_dests = cupsGetDests(&destinations);
- for (int i = 0; i < num_dests; i++) {
+ for (int printer_index = 0; printer_index < num_dests; printer_index++) {
+ const cups_dest_t& printer = destinations[printer_index];
+
PrinterBasicInfo printer_info;
- printer_info.printer_name = destinations[i].name;
+ printer_info.printer_name = printer.name;
const char* info = cupsGetOption(kCUPSPrinterInfoOpt,
- destinations[i].num_options, destinations[i].options);
+ printer.num_options, printer.options);
if (info != NULL)
printer_info.printer_description = info;
const char* state = cupsGetOption(kCUPSPrinterStateOpt,
- destinations[i].num_options, destinations[i].options);
+ printer.num_options, printer.options);
if (state != NULL)
StringToInt(state, &printer_info.printer_status);
+ // Store printer options.
+ for (int opt_index = 0; opt_index < printer.num_options; opt_index++) {
+ printer_info.options[printer.options[opt_index].name] =
+ printer.options[opt_index].value;
+ }
+
printer_list->push_back(printer_info);
}
cupsFreeDests(num_dests, destinations);
+
+ DLOG(INFO) << "Enumerated " << printer_list->size() << " printers.";
}
bool GetPrinterCapsAndDefaults(const std::string& printer_name,
PrinterCapsAndDefaults* printer_info) {
DCHECK(printer_info);
+ DLOG(INFO) << "Getting Caps and Defaults for: " << printer_name;
+
static Lock ppd_lock;
// cupsGetPPD returns a filename stored in a static buffer in CUPS.
// Protect this code with lock.
@@ -126,6 +138,8 @@
PlatformJobId* job_id_ret) {
DCHECK(job_id_ret);
+ DLOG(INFO) << "Spooling print job for: " << printer_name;
+
// We need to store options as char* string for the duration of the
// cupsPrintFile call. We'll use map here to store options, since
// Dictionary value from JSON parser returns wchat_t.
@@ -159,6 +173,10 @@
PlatformJobId job_id,
PrintJobDetails *job_details) {
DCHECK(job_details);
+
+ DLOG(INFO) << "Getting job details for: " << printer_name <<
+ " job_id: " << job_id;
+
cups_job_t* jobs = NULL;
int num_jobs = cupsGetJobs(&jobs, printer_name.c_str(), 1, -1);
@@ -197,6 +215,8 @@
bool GetPrinterInfo(const std::string& printer_name, PrinterBasicInfo* info) {
DCHECK(info);
+ DLOG(INFO) << "Getting printer info for: " << printer_name;
+
// This is not very efficient way to get specific printer info. CUPS 1.4
// supports cupsGetNamedDest() function. However, CUPS 1.4 is not available
// everywhere (for example, it supported from Mac OS 10.6 only).
« no previous file with comments | « chrome/service/cloud_print/printer_info.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698