| 107 | */ |
| 108 | |
| 109 | void |
| 110 | cupsdSetBusyState(int working) /* I - Doing significant work? */ |
| 111 | { |
| 112 | int i; /* Looping var */ |
| 113 | cupsd_job_t *job; /* Current job */ |
| 114 | cupsd_printer_t *p; /* Current printer */ |
| 115 | int newbusy; /* New busy state */ |
| 116 | static int busy = 0; /* Current busy state */ |
| 117 | static const char * const busy_text[] = |
| 118 | { /* Text for busy states */ |
| 119 | "Not busy", |
| 120 | "Dirty files", |
| 121 | "Printing jobs", |
| 122 | "Printing jobs and dirty files", |
| 123 | "Active clients", |
| 124 | "Active clients and dirty files", |
| 125 | "Active clients and printing jobs", |
| 126 | "Active clients, printing jobs, and dirty files" |
| 127 | }; |
| 128 | #ifdef __APPLE__ |
| 129 | static IOPMAssertionID keep_awake = 0;/* Keep the system awake while printing */ |
| 130 | #endif /* __APPLE__ */ |
| 131 | |
| 132 | |
| 133 | /* |
| 134 | * Figure out how busy we are... |
| 135 | */ |
| 136 | |
| 137 | newbusy = (DirtyCleanTime ? 1 : 0) | |
| 138 | ((working || cupsArrayCount(ActiveClients) > 0) ? 4 : 0); |
| 139 | |
| 140 | for (job = (cupsd_job_t *)cupsArrayFirst(PrintingJobs); |
| 141 | job; |
| 142 | job = (cupsd_job_t *)cupsArrayNext(PrintingJobs)) |
| 143 | { |
| 144 | if ((p = job->printer) != NULL) |
| 145 | { |
| 146 | for (i = 0; i < p->num_reasons; i ++) |
| 147 | if (!strcmp(p->reasons[i], "connecting-to-device")) |
| 148 | break; |
| 149 | |
| 150 | if (!p->num_reasons || i >= p->num_reasons) |
| 151 | break; |
| 152 | } |
| 153 | } |
| 154 | |
| 155 | if (job) |
| 156 | newbusy |= 2; |
| 157 | |
| 158 | cupsdLogMessage(CUPSD_LOG_DEBUG, |
| 159 | "cupsdSetBusyState: newbusy=\"%s\", busy=\"%s\"", |
| 160 | busy_text[newbusy], busy_text[busy]); |
| 161 | |
| 162 | /* |
| 163 | * Manage state changes... |
| 164 | */ |
| 165 | |
| 166 | if (newbusy != busy) |
no test coverage detected