MCPcopy Create free account
hub / github.com/OpenPrinting/cups / cupsdSetBusyState

Function cupsdSetBusyState

scheduler/sysman.c:109–185  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

107 */
108
109void
110cupsdSetBusyState(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)

Callers 9

cupsdAcceptClientFunction · 0.85
cupsdCloseClientFunction · 0.85
cupsdReadClientFunction · 0.85
cupsdWriteClientFunction · 0.85
cupsdCleanDirtyFunction · 0.85
cupsdMarkDirtyFunction · 0.85
cupsdStartServerFunction · 0.85
cupsdSetJobStateFunction · 0.85
mainFunction · 0.85

Calls 4

cupsArrayCountFunction · 0.85
cupsArrayFirstFunction · 0.85
cupsArrayNextFunction · 0.85
cupsdLogMessageFunction · 0.85

Tested by

no test coverage detected