| 47 | */ |
| 48 | |
| 49 | void |
| 50 | cupsdAddEvent( |
| 51 | cupsd_eventmask_t event, /* I - Event */ |
| 52 | cupsd_printer_t *dest, /* I - Printer associated with event */ |
| 53 | cupsd_job_t *job, /* I - Job associated with event */ |
| 54 | const char *text, /* I - Notification text */ |
| 55 | ...) /* I - Additional arguments as needed */ |
| 56 | { |
| 57 | int i, /* Looping var */ |
| 58 | scount; /* Number of subscriptions */ |
| 59 | va_list ap; /* Pointer to additional arguments */ |
| 60 | char ftext[1024]; /* Formatted text buffer */ |
| 61 | ipp_attribute_t *attr; /* Printer/job attribute */ |
| 62 | cupsd_event_t *temp = NULL; /* New event pointer */ |
| 63 | cupsd_subscription_t *sub; /* Current subscription */ |
| 64 | |
| 65 | |
| 66 | cupsdLogMessage(CUPSD_LOG_DEBUG2, |
| 67 | "cupsdAddEvent(event=%s, dest=%p(%s), job=%p(%d), text=\"%s\", ...)", |
| 68 | cupsdEventName(event), dest, dest ? dest->name : "", |
| 69 | job, job ? job->id : 0, text); |
| 70 | |
| 71 | /* |
| 72 | * Keep track of events with any OS-supplied notification mechanisms... |
| 73 | */ |
| 74 | |
| 75 | LastEvent |= event; |
| 76 | |
| 77 | #ifdef HAVE_DBUS |
| 78 | cupsd_send_dbus(event, dest, job); |
| 79 | #endif /* HAVE_DBUS */ |
| 80 | |
| 81 | /* |
| 82 | * Return if we aren't keeping events... |
| 83 | */ |
| 84 | |
| 85 | if (MaxEvents <= 0) |
| 86 | { |
| 87 | cupsdLogMessage(CUPSD_LOG_WARN, |
| 88 | "cupsdAddEvent: Discarding %s event since MaxEvents is %d!", |
| 89 | cupsdEventName(event), MaxEvents); |
| 90 | return; |
| 91 | } |
| 92 | |
| 93 | /* |
| 94 | * Then loop through the subscriptions and add the event to the corresponding |
| 95 | * caches... |
| 96 | */ |
| 97 | |
| 98 | if (job && !dest) |
| 99 | dest = cupsdFindPrinter(job->dest); |
| 100 | |
| 101 | _cupsRWLockRead(&SubscriptionsLock); |
| 102 | |
| 103 | for (i = 0, scount = cupsArrayCount(Subscriptions); i < scount; i ++) |
| 104 | { |
| 105 | /* |
| 106 | * Check if this subscription requires this event... |
no test coverage detected