Skip to content

Commit 7765ca9

Browse files
committed
Send printer-added/modified events after creating and installing IPP Everywhere PPDs (Issue #1244)
1 parent 2406cba commit 7765ca9

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

scheduler/ipp.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5105,6 +5105,7 @@ create_local_bg_thread(
51055105
*response = NULL; /* Response from printer */
51065106
ipp_attribute_t *attr; /* Attribute in response */
51075107
ipp_status_t status; /* Status code */
5108+
cupsd_eventmask_t event; /* Event (CUPSD_EVENT_PRINTER_ADDED or CUPSD_EVENT_PRINTER_MODIFIED) */
51085109
static const char * const pattrs[] = /* Printer attributes we need */
51095110
{
51105111
"all",
@@ -5280,6 +5281,10 @@ create_local_bg_thread(
52805281

52815282
cupsRWUnlock(&printer->lock);
52825283

5284+
/*
5285+
* Try opening the created PPD file...
5286+
*/
5287+
52835288
if ((from = cupsFileOpen(fromppd, "r")) == NULL)
52845289
{
52855290
cupsdLogPrinter(printer, CUPSD_LOG_ERROR, "Unable to read generated PPD: %s", strerror(errno));
@@ -5294,7 +5299,17 @@ create_local_bg_thread(
52945299
goto finish_response;
52955300
}
52965301

5302+
/*
5303+
* Then the destination PPD for the queue...
5304+
*/
5305+
52975306
snprintf(toppd, sizeof(toppd), "%s/ppd/%s.ppd", ServerRoot, printer->name);
5307+
5308+
if (access(toppd, 0)) /* Determine whether to log an "added" or "modified" event */
5309+
event = CUPSD_EVENT_PRINTER_ADDED;
5310+
else
5311+
event = CUPSD_EVENT_PRINTER_MODIFIED;
5312+
52985313
if ((to = cupsdCreateConfFile(toppd, ConfigFilePerm)) == NULL)
52995314
{
53005315
cupsdLogPrinter(printer, CUPSD_LOG_ERROR, "Unable to create PPD for printer: %s", strerror(errno));
@@ -5310,6 +5325,10 @@ create_local_bg_thread(
53105325
goto finish_response;
53115326
}
53125327

5328+
/*
5329+
* Copy the PPD file over...
5330+
*/
5331+
53135332
while (cupsFileGets(from, line, sizeof(line)))
53145333
cupsFilePrintf(to, "%s\n", line);
53155334

@@ -5330,6 +5349,7 @@ create_local_bg_thread(
53305349

53315350
cupsdSetPrinterAttrs(printer);
53325351

5352+
cupsdAddEvent(event, printer, NULL, "Printer \"%s\" was %s.", printer->name, event == CUPSD_EVENT_PRINTER_ADDED ? "added" : "modified");
53335353
cupsdAddEvent(CUPSD_EVENT_PRINTER_CONFIG, printer, NULL, "Printer \"%s\" is now available.", printer->name);
53345354
cupsdLogClient(con, CUPSD_LOG_INFO, "Printer \"%s\" is now available.", printer->name);
53355355
}

0 commit comments

Comments
 (0)