selector[PPD_MAX_NAME];
/* Profile selection string */
ppd_file_t *ppd; /* PPD file */
- ppd_attr_t *attr, /* cupsICCProfile attributes */
- *profileid_attr;/* cupsProfileID attribute */
+ ppd_attr_t *attr, /* Profile attributes */
+ *profileid_attr,/* cupsProfileID attribute */
+ *q1_attr, /* ColorModel (or other) qualifier */
+ *q2_attr, /* MediaType (or other) qualifier */
+ *q3_attr; /* Resolution (or other) qualifier */
+ char q_keyword[PPD_MAX_NAME];
+ /* Qualifier keyword */
+ const char *q1_choice, /* ColorModel (or other) choice */
+ *q2_choice, /* MediaType (or other) choice */
+ *q3_choice; /* Resolution (or other) choice */
const char *profile_key; /* Profile keyword */
ppd_option_t *cm_option; /* Color model option */
- ppd_choice_t *cm_choice, /* Color model choice */
- *q1_choice, /* ColorModel (or other) qualifier */
- *q2_choice, /* MediaType (or other) qualifier */
- *q3_choice; /* Resolution (or other) qualifier */
+ ppd_choice_t *cm_choice; /* Color model choice */
int num_profiles; /* Number of profiles */
CMError error; /* Last error */
unsigned device_id, /* Printer device ID */
if ((ppd = ppdOpenFile(ppdfile)) == NULL)
return;
- ppdMarkDefaults(ppd);
-
/*
* See if we have any profiles...
*/
if (num_profiles > 0)
{
- /*
- * Figure out the default profile selectors...
- */
+ if (profile_key[0] == 'A')
+ {
+ /*
+ * For Tioga PPDs, get the default profile using the DefaultAPTiogaProfile
+ * attribute...
+ */
- if ((attr = ppdFindAttr(ppd, "cupsICCQualifier1", NULL)) != NULL &&
- attr->value && attr->value[0])
- q1_choice = ppdFindMarkedChoice(ppd, attr->value);
- else
- q1_choice = ppdFindMarkedChoice(ppd, "ColorModel");
+ if ((attr = ppdFindAttr(ppd, "DefaultAPTiogaProfile", NULL)) != NULL &&
+ attr->value)
+ default_profile_id = atoi(attr->value);
- if ((attr = ppdFindAttr(ppd, "cupsICCQualifier2", NULL)) != NULL &&
- attr->value && attr->value[0])
- q2_choice = ppdFindMarkedChoice(ppd, attr->value);
+ q1_choice = q2_choice = q3_choice = NULL;
+ }
else
- q2_choice = ppdFindMarkedChoice(ppd, "MediaType");
+ {
+ /*
+ * For CUPS PPDs, figure out the default profile selector values...
+ */
- if ((attr = ppdFindAttr(ppd, "cupsICCQualifier3", NULL)) != NULL &&
- attr->value && attr->value[0])
- q3_choice = ppdFindMarkedChoice(ppd, attr->value);
- else
- q3_choice = ppdFindMarkedChoice(ppd, "Resolution");
+ if ((attr = ppdFindAttr(ppd, "cupsICCQualifier1", NULL)) != NULL &&
+ attr->value && attr->value[0])
+ {
+ snprintf(q_keyword, sizeof(q_keyword), "Default%s", attr->value);
+ q1_attr = ppdFindAttr(ppd, q_keyword, NULL);
+ }
+ else if ((q1_attr = ppdFindAttr(ppd, "DefaultColorModel", NULL)) == NULL)
+ q1_attr = ppdFindAttr(ppd, "DefaultColorSpace", NULL);
+
+ if (q1_attr && q1_attr->value && q1_attr->value[0])
+ q1_choice = q1_attr->value;
+ else
+ q1_choice = "";
+
+ if ((attr = ppdFindAttr(ppd, "cupsICCQualifier2", NULL)) != NULL &&
+ attr->value && attr->value[0])
+ {
+ snprintf(q_keyword, sizeof(q_keyword), "Default%s", attr->value);
+ q2_attr = ppdFindAttr(ppd, q_keyword, NULL);
+ }
+ else
+ q2_attr = ppdFindAttr(ppd, "DefaultMediaType", NULL);
+
+ if (q2_attr && q2_attr->value && q2_attr->value[0])
+ q2_choice = q2_attr->value;
+ else
+ q2_choice = NULL;
+
+ if ((attr = ppdFindAttr(ppd, "cupsICCQualifier3", NULL)) != NULL &&
+ attr->value && attr->value[0])
+ {
+ snprintf(q_keyword, sizeof(q_keyword), "Default%s", attr->value);
+ q3_attr = ppdFindAttr(ppd, q_keyword, NULL);
+ }
+ else
+ q3_attr = ppdFindAttr(ppd, "DefaultResolution", NULL);
+
+ if (q3_attr && q3_attr->value && q3_attr->value[0])
+ q3_choice = q3_attr->value;
+ else
+ q3_choice = NULL;
+ }
/*
* Build the array of profiles...
* See if this is the default profile...
*/
- if (!default_profile_id && q1_choice)
+ if (!default_profile_id)
{
if (q2_choice)
{
if (q3_choice)
{
snprintf(selector, sizeof(selector), "%s.%s.%s",
- q1_choice->choice, q2_choice->choice, q3_choice->choice);
+ q1_choice, q2_choice, q3_choice);
if (!strcmp(selector, attr->spec))
default_profile_id = profile_id;
}
if (!default_profile_id)
{
- snprintf(selector, sizeof(selector), "%s.%s.", q1_choice->choice,
- q2_choice->choice);
+ snprintf(selector, sizeof(selector), "%s.%s.", q1_choice,
+ q2_choice);
if (!strcmp(selector, attr->spec))
default_profile_id = profile_id;
}
if (!default_profile_id && q3_choice)
{
- snprintf(selector, sizeof(selector), "%s..%s", q1_choice->choice,
- q3_choice->choice);
+ snprintf(selector, sizeof(selector), "%s..%s", q1_choice,
+ q3_choice);
if (!strcmp(selector, attr->spec))
default_profile_id = profile_id;
}
if (!default_profile_id)
{
- snprintf(selector, sizeof(selector), "%s..", q1_choice->choice);
+ snprintf(selector, sizeof(selector), "%s..", q1_choice);
if (!strcmp(selector, attr->spec))
default_profile_id = profile_id;
}
cupsArrayAdd(ra, "pdl-override-supported");
cupsArrayAdd(ra, "printer-alert");
cupsArrayAdd(ra, "printer-alert-description");
+ cupsArrayAdd(ra, "printer-commands");
cupsArrayAdd(ra, "printer-current-time");
cupsArrayAdd(ra, "printer-driver-installer");
+ cupsArrayAdd(ra, "printer-dns-sd-name");
cupsArrayAdd(ra, "printer-info");
cupsArrayAdd(ra, "printer-is-accepting-jobs");
cupsArrayAdd(ra, "printer-location");
cupsArrayAdd(ra, "printer-state");
cupsArrayAdd(ra, "printer-state-message");
cupsArrayAdd(ra, "printer-state-reasons");
+ cupsArrayAdd(ra, "printer-type");
cupsArrayAdd(ra, "printer-up-time");
cupsArrayAdd(ra, "printer-uri-supported");
cupsArrayAdd(ra, "queued-job-count");
cupsdHoldJob(job);
- cupsdAddEvent(CUPSD_EVENT_JOB_STATE, job->printer, job,
+ cupsdAddEvent(CUPSD_EVENT_JOB_STATE, cupsdFindDest(job->dest), job,
"Job held by user.");
if ((newattr = ippFindAttribute(con->request, "job-hold-until",
cupsdSetJobHoldUntil(job, attr->values[0].string.text);
- cupsdAddEvent(CUPSD_EVENT_JOB_CONFIG_CHANGED, job->printer, job,
+ cupsdAddEvent(CUPSD_EVENT_JOB_CONFIG_CHANGED, cupsdFindDest(job->dest), job,
"Job job-hold-until value changed by user.");
}
attr->value_tag = IPP_TAG_KEYWORD;
attr->values[0].string.text = _cupsStrAlloc("no-hold");
- cupsdAddEvent(CUPSD_EVENT_JOB_CONFIG_CHANGED, job->printer, job,
+ cupsdAddEvent(CUPSD_EVENT_JOB_CONFIG_CHANGED, cupsdFindDest(job->dest), job,
"Job job-hold-until value changed by user.");
}
cupsdReleaseJob(job);
- cupsdAddEvent(CUPSD_EVENT_JOB_STATE, job->printer, job,
+ cupsdAddEvent(CUPSD_EVENT_JOB_STATE, cupsdFindDest(job->dest), job,
"Job released by user.");
cupsdLogMessage(CUPSD_LOG_INFO, "[Job %d] Released by \"%s\".", jobid,
*/
if (event & CUPSD_EVENT_PRINTER_QUEUE_ORDER_CHANGED)
- cupsdAddEvent(CUPSD_EVENT_PRINTER_QUEUE_ORDER_CHANGED, job->printer, job,
+ cupsdAddEvent(CUPSD_EVENT_PRINTER_QUEUE_ORDER_CHANGED,
+ cupsdFindDest(job->dest), job,
"Job priority changed by user.");
if (event & CUPSD_EVENT_JOB_STATE)
- cupsdAddEvent(CUPSD_EVENT_JOB_STATE, job->printer, job,
+ cupsdAddEvent(CUPSD_EVENT_JOB_STATE, cupsdFindDest(job->dest), job,
job->state_value == IPP_JOB_HELD ?
"Job held by user." : "Job restarted by user.");
if (event & CUPSD_EVENT_JOB_CONFIG_CHANGED)
- cupsdAddEvent(CUPSD_EVENT_JOB_CONFIG_CHANGED, job->printer, job,
+ cupsdAddEvent(CUPSD_EVENT_JOB_CONFIG_CHANGED, cupsdFindDest(job->dest), job,
"Job options changed by user.");
/*