Lines Matching refs:jq
244 _job_queue_t *jq = _get_job_desc(job_handle); in _stream_dbg_end_job() local
245 if (jq && (jq->job_debug_fd >= 0)) { in _stream_dbg_end_job()
246 close(jq->job_debug_fd); in _stream_dbg_end_job()
247 jq->job_debug_fd = -1; in _stream_dbg_end_job()
253 _job_queue_t *jq = _get_job_desc(job_handle); in _stream_dbg_start_job() local
254 if (jq && jq->debug_path[0]) { in _stream_dbg_start_job()
256 snprintf(filename, MAX_PATHNAME_LENGTH, "%s/jobstream.%s", jq->debug_path, ext); in _stream_dbg_start_job()
258 jq->job_debug_fd = open(filename, O_CREAT | O_TRUNC | O_WRONLY, 0600); in _stream_dbg_start_job()
264 _job_queue_t *jq = _get_job_desc(job_handle); in _stream_dbg_job_data() local
266 if (jq && (jq->job_debug_fd >= 0)) { in _stream_dbg_job_data()
268 bytes_written = write(jq->job_debug_fd, buff, nbytes); in _stream_dbg_job_data()
279 _job_queue_t *jq = _get_job_desc(job_handle); in _stream_dbg_end_page() local
280 if (jq && (jq->page_debug_fd >= 0)) { in _stream_dbg_end_page()
281 close(jq->page_debug_fd); in _stream_dbg_end_page()
282 jq->page_debug_fd = -1; in _stream_dbg_end_page()
288 _job_queue_t *jq = _get_job_desc(job_handle); in _stream_dbg_page_data() local
290 if (jq && (jq->page_debug_fd >= 0)) { in _stream_dbg_page_data()
292 bytes_written = write(jq->page_debug_fd, buff, nbytes); in _stream_dbg_page_data()
307 _job_queue_t *jq = _get_job_desc(job_handle); in _stream_dbg_start_page() local
308 if (jq && jq->debug_path[0]) { in _stream_dbg_start_page()
313 snprintf(buff.filename, MAX_PATHNAME_LENGTH, "%s/page%4.4d.ppm", jq->debug_path, in _stream_dbg_start_page()
316 jq->page_debug_fd = open(buff.filename, O_CREAT | O_TRUNC | O_WRONLY, 0600); in _stream_dbg_start_page()
337 _job_queue_t *jq = _get_job_desc(handle); in getDebugStreamIfc() local
338 if (jq) { in getDebugStreamIfc()
339 return (jq->debug_path[0] == 0) ? NULL : &_debug_stream_ifc; in getDebugStreamIfc()
458 _job_queue_t *jq = _get_job_desc(job_handle); in _recycle_handle() local
460 if (jq == NULL) { in _recycle_handle()
462 } else if ((jq->job_state == JOB_STATE_CANCELLED) || (jq->job_state == JOB_STATE_ERROR) || in _recycle_handle()
463 (jq->job_state == JOB_STATE_CORRUPTED) || (jq->job_state == JOB_STATE_COMPLETED)) { in _recycle_handle()
464 if (jq->print_ifc != NULL) { in _recycle_handle()
465 jq->print_ifc->destroy(jq->print_ifc); in _recycle_handle()
468 jq->print_ifc = NULL; in _recycle_handle()
469 if (jq->status_ifc != NULL) { in _recycle_handle()
470 jq->status_ifc->destroy(jq->status_ifc); in _recycle_handle()
472 jq->status_ifc = NULL; in _recycle_handle()
473 if (jq->job_params.useragent != NULL) { in _recycle_handle()
474 free((void *) jq->job_params.useragent); in _recycle_handle()
476 if (jq->job_params.certificate != NULL) { in _recycle_handle()
477 free((void *) jq->job_params.certificate); in _recycle_handle()
479 free(jq->printer_addr); in _recycle_handle()
480 jq->job_state = JOB_STATE_FREE; in _recycle_handle()
481 if (jq->job_debug_fd != -1) { in _recycle_handle()
482 close(jq->job_debug_fd); in _recycle_handle()
484 jq->job_debug_fd = -1; in _recycle_handle()
485 if (jq->page_debug_fd != -1) { in _recycle_handle()
486 close(jq->page_debug_fd); in _recycle_handle()
488 jq->page_debug_fd = -1; in _recycle_handle()
489 jq->debug_path[0] = 0; in _recycle_handle()
490 if (jq->certificate) { in _recycle_handle()
491 free(jq->certificate); in _recycle_handle()
492 jq->certificate = NULL; in _recycle_handle()
503 static int _stop_status_thread(_job_queue_t *jq) { in _stop_status_thread() argument
504 if (!pthread_equal(_job_status_tid, pthread_self()) && (jq && jq->status_ifc)) { in _stop_status_thread()
505 (jq->status_ifc->stop)(jq->status_ifc); in _stop_status_thread()
523 _job_queue_t *jq = (_job_queue_t *) param; in _job_status_callback() local
529 cb_param.certificate = jq->certificate; in _job_status_callback()
530 cb_param.certificate_len = jq->certificate_len; in _job_status_callback()
550 && ((jq->print_ifc != NULL) && (jq->print_ifc->enable_timeout != NULL))) { in _job_status_callback()
551 jq->print_ifc->enable_timeout(jq->print_ifc, 1); in _job_status_callback()
560 if (jq->is_dir && !jq->last_page_seen) { in _job_status_callback()
561 wprintPage(jq->job_handle, jq->num_pages + 1, NULL, true, false, 0, 0, 0, 0); in _job_status_callback()
569 if ((jq->print_ifc != NULL) && (jq->print_ifc->enable_timeout != NULL)) { in _job_status_callback()
570 jq->print_ifc->enable_timeout(jq->print_ifc, 1); in _job_status_callback()
577 if ((jq->print_ifc != NULL) && (jq->print_ifc->enable_timeout != NULL)) { in _job_status_callback()
578 jq->print_ifc->enable_timeout(jq->print_ifc, 1); in _job_status_callback()
582 jq->job_params.cancelled = true; in _job_status_callback()
594 if ((jq->job_state != JOB_STATE_RUNNING) || (jq->blocked_reasons != blocked_reasons)) { in _job_status_callback()
595 jq->job_state = JOB_STATE_RUNNING; in _job_status_callback()
596 jq->blocked_reasons = blocked_reasons; in _job_status_callback()
597 if (jq->cb_fn) { in _job_status_callback()
599 cb_param.blocked_reasons = jq->blocked_reasons; in _job_status_callback()
602 jq->cb_fn(jq->job_handle, (void *) &cb_param); in _job_status_callback()
611 _stop_status_thread(jq); in _job_status_callback()
613 jq->blocked_reasons = blocked_reasons; in _job_status_callback()
614 jq->job_params.cancelled = true; in _job_status_callback()
615 jq->job_state = JOB_STATE_ERROR; in _job_status_callback()
616 if (jq->cb_fn) { in _job_status_callback()
621 jq->cb_fn(jq->job_handle, (void *) &cb_param); in _job_status_callback()
624 if (jq->print_ifc != NULL) { in _job_status_callback()
625 jq->print_ifc->destroy(jq->print_ifc); in _job_status_callback()
626 jq->print_ifc = NULL; in _job_status_callback()
629 if (jq->status_ifc != NULL) { in _job_status_callback()
630 jq->status_ifc->destroy(jq->status_ifc); in _job_status_callback()
631 jq->status_ifc = NULL; in _job_status_callback()
643 if ((jq->job_state != JOB_STATE_BLOCKED) || (jq->blocked_reasons != blocked_reasons)) { in _job_status_callback()
644 jq->job_state = JOB_STATE_BLOCKED; in _job_status_callback()
645 jq->blocked_reasons = blocked_reasons; in _job_status_callback()
646 if (jq->cb_fn) { in _job_status_callback()
651 jq->cb_fn(jq->job_handle, (void *) &cb_param); in _job_status_callback()
660 _job_queue_t *jq = (_job_queue_t *) param; in _job_status_thread() local
661 (jq->status_ifc->start)(jq->status_ifc, _job_status_callback, param); in _job_status_thread()
665 static int _start_status_thread(_job_queue_t *jq) { in _start_status_thread() argument
669 if ((jq == NULL) || (jq->status_ifc == NULL)) { in _start_status_thread()
681 result = pthread_create(&_job_status_tid, 0, _job_status_thread, jq); in _start_status_thread()
706 static bool _is_certificate_allowed(_job_queue_t *jq) { in _is_certificate_allowed() argument
710 if (jq->job_params.certificate && jq->certificate) { in _is_certificate_allowed()
711 if (jq->job_params.certificate_len != jq->certificate_len) { in _is_certificate_allowed()
713 jq->job_params.certificate_len, jq->certificate_len); in _is_certificate_allowed()
715 } else if (0 != memcmp(jq->job_params.certificate, jq->certificate, jq->certificate_len)) { in _is_certificate_allowed()
720 jq->job_params.certificate_len); in _is_certificate_allowed()
731 _job_queue_t *jq = connect_info->user; in _validate_certificate() local
734 connect_info->uri_path, data_len, jq->job_handle); in _validate_certificate()
737 if (jq->certificate) { in _validate_certificate()
738 free(jq->certificate); in _validate_certificate()
739 jq->certificate = NULL; in _validate_certificate()
741 jq->certificate = (uint8 *)malloc(data_len); in _validate_certificate()
743 if (jq->certificate == NULL) { in _validate_certificate()
747 memcpy(jq->certificate, data, data_len); in _validate_certificate()
748 jq->certificate_len = data_len; in _validate_certificate()
749 if (!_is_certificate_allowed(jq)) { in _validate_certificate()
760 static void _initialize_status_ifc(_job_queue_t *jq) { in _initialize_status_ifc() argument
762 connect_info.printer_addr = jq->printer_addr; in _initialize_status_ifc()
763 connect_info.uri_path = jq->printer_uri; in _initialize_status_ifc()
764 connect_info.port_num = jq->port_num; in _initialize_status_ifc()
765 if (jq->use_secure_uri) { in _initialize_status_ifc()
767 connect_info.user = jq; in _initialize_status_ifc()
776 jq->status_ifc->init(jq->status_ifc, &connect_info); in _initialize_status_ifc()
786 _job_queue_t *jq; in _job_thread() local
808 jq = _get_job_desc(job_handle); in _job_thread()
811 if (jq) { in _job_thread()
812 if (jq->job_state != JOB_STATE_QUEUED) { in _job_thread()
818 jq->job_params.plugin_data = NULL; in _job_thread()
827 if (jq->status_ifc != NULL) { in _job_thread()
828 _initialize_status_ifc(jq); in _job_thread()
831 if ((jq->status_ifc != NULL) && (jq->status_ifc->get_status != NULL)) { in _job_thread()
837 jq->status_ifc->get_status(jq->status_ifc, &printer_state); in _job_thread()
841 cb_param.certificate = jq->certificate; in _job_thread()
842 cb_param.certificate_len = jq->certificate_len; in _job_thread()
848 jq->blocked_reasons = 0; in _job_thread()
856 if (_is_certificate_allowed(jq)) { in _job_thread()
858 jq->blocked_reasons = BLOCKED_REASON_UNABLE_TO_CONNECT; in _job_thread()
861 jq->blocked_reasons = BLOCKED_REASON_BAD_CERTIFICATE; in _job_thread()
868 jq->blocked_reasons |= BLOCKED_REASONS_PRINTER_BUSY; in _job_thread()
869 } else if (!jq->job_params.cancelled) { in _job_thread()
883 if ((jq->job_state != JOB_STATE_BLOCKED) in _job_thread()
884 || (jq->blocked_reasons != blocked_reasons)) { in _job_thread()
885 jq->job_state = JOB_STATE_BLOCKED; in _job_thread()
886 jq->blocked_reasons = blocked_reasons; in _job_thread()
887 if (jq->cb_fn) { in _job_thread()
892 jq->cb_fn(jq->job_handle, (void *) &cb_param); in _job_thread()
902 if (jq->job_params.cancelled) { in _job_thread()
912 if (jq->print_ifc) { in _job_thread()
913 job_result = jq->print_ifc->init(jq->print_ifc, jq->printer_addr, in _job_thread()
914 jq->port_num, jq->printer_uri, jq->use_secure_uri); in _job_thread()
916 jq->blocked_reasons = BLOCKED_REASON_UNABLE_TO_CONNECT; in _job_thread()
921 _start_status_thread(jq); in _job_thread()
927 if ((job_result == OK) && jq->cb_fn) { in _job_thread()
932 jq->cb_fn(job_handle, (void *) &cb_param); in _job_thread()
935 jq->job_params.page_num = -1; in _job_thread()
937 if (jq->print_ifc != NULL) { in _job_thread()
939 if (jq->print_ifc->validate_job != NULL) { in _job_thread()
940 job_result = jq->print_ifc->validate_job(jq->print_ifc, &jq->job_params); in _job_thread()
948 if ((job_result == OK) && (jq->print_ifc->start_job != NULL) && in _job_thread()
949 (strcmp(jq->job_params.print_format, PRINT_FORMAT_PDF) != 0)) { in _job_thread()
950 jq->print_ifc->start_job(jq->print_ifc, &jq->job_params); in _job_thread()
955 if (job_result == OK && jq->plugin->start_job != NULL) { in _job_thread()
956 job_result = jq->plugin->start_job(job_handle, (void *) &_wprint_ifc, in _job_thread()
957 (void *) jq->print_ifc, &(jq->job_params)); in _job_thread()
962 jq->job_params.page_num = 0; in _job_thread()
966 if (jq->is_dir && (job_result == OK)) { in _job_thread()
968 for (i = 0; (i < jq->job_params.num_copies) && in _job_thread()
970 (!jq->job_params.cancelled); i++) { in _job_thread()
972 jq->job_params.copies_supported && in _job_thread()
973 (strcmp(jq->job_params.print_format, PRINT_FORMAT_PDF) == 0)) { in _job_thread()
978 if (jq->print_ifc->start_job != NULL && in _job_thread()
979 (strcmp(jq->job_params.print_format, PRINT_FORMAT_PDF) == 0)) { in _job_thread()
980 jq->print_ifc->start_job(jq->print_ifc, &jq->job_params); in _job_thread()
984 jq->job_state = JOB_STATE_RUNNING; in _job_thread()
989 while (OK == msgQReceive(jq->pageQ, (char *) &page, sizeof(page), in _job_thread()
994 if (jq->print_ifc->check_status) { in _job_thread()
995 if (jq->print_ifc->check_status(jq->print_ifc) == ERROR) { in _job_thread()
1006 if (page.last_page && ((i == jq->job_params.num_copies - 1) || in _job_thread()
1007 (jq->job_params.copies_supported && in _job_thread()
1008 strcmp(jq->job_params.print_format, in _job_thread()
1010 jq->job_params.last_page = page.last_page; in _job_thread()
1012 jq->job_params.last_page = false; in _job_thread()
1018 jq->job_params.page_num++; in _job_thread()
1021 jq->job_params.page_num = page.page_num; in _job_thread()
1023 jq->job_params.page_num = per_copy_page_num; in _job_thread()
1027 jq->job_params.print_top_margin += page.top_margin; in _job_thread()
1028 jq->job_params.print_left_margin += page.left_margin; in _job_thread()
1029 jq->job_params.print_right_margin += page.right_margin; in _job_thread()
1030 jq->job_params.print_bottom_margin += page.bottom_margin; in _job_thread()
1032 jq->job_params.copy_num = (i + 1); in _job_thread()
1033 jq->job_params.copy_page_num = page.page_num; in _job_thread()
1034 jq->job_params.page_backside = !(per_copy_page_num & 0x1); in _job_thread()
1035 jq->job_params.page_corrupted = (page.corrupted ? 1 : 0); in _job_thread()
1036 jq->job_params.page_printing = true; in _job_thread()
1042 if (strcmp(jq->job_params.print_format, PRINT_FORMAT_PDF) != 0) { in _job_thread()
1043 job_result = jq->plugin->print_page(&(jq->job_params), in _job_thread()
1044 jq->mime_type, in _job_thread()
1049 job_result = jq->plugin->print_page(&(jq->job_params), in _job_thread()
1050 jq->mime_type, in _job_thread()
1058 if ((jq->job_params.duplex != DUPLEX_MODE_NONE) && in _job_thread()
1059 (jq->plugin->print_blank_page != NULL)) { in _job_thread()
1060 jq->plugin->print_blank_page(job_handle, &(jq->job_params)); in _job_thread()
1065 jq->job_params.print_top_margin -= page.top_margin; in _job_thread()
1066 jq->job_params.print_left_margin -= page.left_margin; in _job_thread()
1067 jq->job_params.print_right_margin -= page.right_margin; in _job_thread()
1068 jq->job_params.print_bottom_margin -= page.bottom_margin; in _job_thread()
1069 jq->job_params.page_printing = false; in _job_thread()
1079 if (page.last_page && (jq->job_params.duplex != DUPLEX_MODE_NONE) in _job_thread()
1080 && !(jq->job_params.page_backside) in _job_thread()
1081 && (jq->plugin->print_blank_page != NULL)) { in _job_thread()
1083 jq->plugin->print_blank_page(job_handle, &(jq->job_params)); in _job_thread()
1088 if (jq->saveQ && !jq->job_params.cancelled && (job_result != ERROR)) { in _job_thread()
1089 job_result = msgQSend(jq->saveQ, (char *) &page, in _job_thread()
1093 if (page.last_page && !jq->job_params.last_page) { in _job_thread()
1094 msg_q_id tmpQ = jq->pageQ; in _job_thread()
1095 jq->pageQ = jq->saveQ; in _job_thread()
1096 jq->saveQ = tmpQ; in _job_thread()
1107 if (page.last_page || jq->job_params.cancelled) { in _job_thread()
1116 if ((strcmp(jq->job_params.print_format, PRINT_FORMAT_PDF) == 0) && in _job_thread()
1117 (jq->print_ifc->end_job)) { in _job_thread()
1118 int end_job_result = jq->print_ifc->end_job(jq->print_ifc); in _job_thread()
1130 for (i = 0; ((i < jq->job_params.num_copies) && (job_result == OK)); i++) { in _job_thread()
1131 if ((i > 0) && jq->job_params.copies_supported && in _job_thread()
1132 (strcmp(jq->job_params.print_format, PRINT_FORMAT_PDF) == 0)) { in _job_thread()
1138 if ((jq->print_ifc != NULL) && (jq->print_ifc->check_status)) { in _job_thread()
1139 if (jq->print_ifc->check_status(jq->print_ifc) == ERROR) { in _job_thread()
1145 jq->job_state = JOB_STATE_RUNNING; in _job_thread()
1146 jq->job_params.page_num++; in _job_thread()
1147 jq->job_params.last_page = (i == (jq->job_params.num_copies - 1)); in _job_thread()
1148 jq->job_params.copy_num = (i + 1); in _job_thread()
1149 jq->job_params.copy_page_num = 1; in _job_thread()
1150 jq->job_params.page_corrupted = (job_result == CORRUPT); in _job_thread()
1151 jq->job_params.page_printing = true; in _job_thread()
1154 job_result = jq->plugin->print_page(&(jq->job_params), jq->mime_type, in _job_thread()
1155 jq->pathname); in _job_thread()
1157 if ((jq->job_params.duplex != DUPLEX_MODE_NONE) in _job_thread()
1158 && (jq->plugin->print_blank_page != NULL)) { in _job_thread()
1159 jq->plugin->print_blank_page(job_handle, in _job_thread()
1160 &(jq->job_params)); in _job_thread()
1164 jq->job_params.page_printing = false; in _job_thread()
1171 if (jq->job_params.page_num >= 0) { in _job_thread()
1173 if ((jq->job_params.page_num == 0) in _job_thread()
1174 && (jq->plugin->print_blank_page != NULL)) { in _job_thread()
1175 jq->plugin->print_blank_page(job_handle, &(jq->job_params)); in _job_thread()
1177 if (jq->plugin->end_job != NULL) { in _job_thread()
1178 jq->plugin->end_job(&(jq->job_params)); in _job_thread()
1180 if ((jq->print_ifc != NULL) && (jq->print_ifc->end_job) && in _job_thread()
1181 (strcmp(jq->job_params.print_format, PRINT_FORMAT_PDF) != 0)) { in _job_thread()
1182 int end_job_result = jq->print_ifc->end_job(jq->print_ifc); in _job_thread()
1194 if ((jq->job_params.page_num > 0) && (jq->status_ifc != NULL)) { in _job_thread()
1211 if (jq->job_params.cancelled && !jq->cancel_ok) { in _job_thread()
1223 if (!jq->job_params.cancelled && in _job_thread()
1224 (jq->blocked_reasons in _job_thread()
1242 jq->job_params.page_num = MAX(0, jq->job_params.page_num); in _job_thread()
1243 _stop_status_thread(jq); in _job_thread()
1249 LOGI("job_thread(): with job_state value: %d ", jq->job_state); in _job_thread()
1250 if ((jq->job_state == JOB_STATE_COMPLETED) || (jq->job_state == JOB_STATE_ERROR) in _job_thread()
1251 || (jq->job_state == JOB_STATE_CANCELLED) in _job_thread()
1252 || (jq->job_state == JOB_STATE_CORRUPTED) in _job_thread()
1253 || (jq->job_state == JOB_STATE_FREE)) { in _job_thread()
1258 if (!jq->job_params.cancelled) { in _job_thread()
1259 jq->job_state = JOB_STATE_COMPLETED; in _job_thread()
1260 jq->blocked_reasons = 0; in _job_thread()
1266 jq->job_state = JOB_STATE_CANCELLED; in _job_thread()
1267 jq->blocked_reasons = BLOCKED_REASONS_CANCELLED; in _job_thread()
1268 if (!jq->cancel_ok) { in _job_thread()
1269 jq->blocked_reasons |= BLOCKED_REASON_PARTIAL_CANCEL; in _job_thread()
1274 jq->job_state = JOB_STATE_CORRUPTED; in _job_thread()
1275 jq->blocked_reasons = 0; in _job_thread()
1280 jq->mime_type, jq->job_params.print_format); in _job_thread()
1282 jq->job_state = JOB_STATE_ERROR; in _job_thread()
1287 if (jq->cb_fn) { in _job_thread()
1289 cb_param.blocked_reasons = jq->blocked_reasons; in _job_thread()
1292 jq->cb_fn(job_handle, (void *) &cb_param); in _job_thread()
1295 if (jq->print_ifc != NULL) { in _job_thread()
1296 jq->print_ifc->destroy(jq->print_ifc); in _job_thread()
1297 jq->print_ifc = NULL; in _job_thread()
1300 if (jq->status_ifc != NULL) { in _job_thread()
1301 jq->status_ifc->destroy(jq->status_ifc); in _job_thread()
1302 jq->status_ifc = NULL; in _job_thread()
1827 _job_queue_t *jq; in wprintStartJob() local
1876 jq = _get_job_desc(job_handle); in wprintStartJob()
1877 if (jq == NULL) { in wprintStartJob()
1885 strncpy(jq->debug_path, debugDir, MAX_PATHNAME_LENGTH); in wprintStartJob()
1886 jq->debug_path[MAX_PATHNAME_LENGTH] = 0; in wprintStartJob()
1889 strncpy(jq->printer_addr, printer_addr, MAX_PRINTER_ADDR_LENGTH); in wprintStartJob()
1890 strncpy(jq->mime_type, mime_type, MAX_MIME_LENGTH); in wprintStartJob()
1891 strncpy(jq->pathname, pathname, MAX_PATHNAME_LENGTH); in wprintStartJob()
1893 jq->port_num = port_num; in wprintStartJob()
1894 jq->cb_fn = cb_fn; in wprintStartJob()
1895 jq->print_ifc = print_ifc; in wprintStartJob()
1896 jq->cancel_ok = true; // assume cancel is ok in wprintStartJob()
1897 jq->plugin = plugin; in wprintStartJob()
1898 memcpy(jq->printer_uri, printer_cap->httpResource, in wprintStartJob()
1899 MIN(ARRAY_SIZE(printer_cap->httpResource), ARRAY_SIZE(jq->printer_uri))); in wprintStartJob()
1901 jq->status_ifc = _get_status_ifc(((port_num == 0) ? PORT_FILE : PORT_IPP)); in wprintStartJob()
1903 memcpy((char *) &(jq->job_params), job_params, sizeof(wprint_job_params_t)); in wprintStartJob()
1905 jq->use_secure_uri = (strstr(scheme, IPPS_PREFIX) != NULL); in wprintStartJob()
1907 size_t useragent_len = strlen(USERAGENT_PREFIX) + strlen(jq->job_params.docCategory) + 1; in wprintStartJob()
1910 snprintf(useragent, useragent_len, USERAGENT_PREFIX "%s", jq->job_params.docCategory); in wprintStartJob()
1911 jq->job_params.useragent = useragent; in wprintStartJob()
1916 jq->job_params.certificate = malloc(job_params->certificate_len); in wprintStartJob()
1917 if (jq->job_params.certificate) { in wprintStartJob()
1918 memcpy(jq->job_params.certificate, job_params->certificate, in wprintStartJob()
1923 jq->job_params.page_num = 0; in wprintStartJob()
1924 jq->job_params.print_format = print_format; in wprintStartJob()
1927 jq->job_params.pcl_type = PCLm; in wprintStartJob()
1929 jq->job_params.pcl_type = PCLNONE; in wprintStartJob()
1935 jq->job_params.pcl_type = PCLPWG; in wprintStartJob()
1937 jq->job_params.pcl_type = PCLNONE; in wprintStartJob()
1943 jq->is_dir = true; in wprintStartJob()
1944 jq->num_pages = 0; in wprintStartJob()
1947 jq->pageQ = msgQCreate(_MAX_PAGES_PER_JOB, sizeof(_page_t)); in wprintStartJob()
1950 if (jq->job_params.num_copies > 1) { in wprintStartJob()
1951 jq->saveQ = msgQCreate(_MAX_PAGES_PER_JOB, sizeof(_page_t)); in wprintStartJob()
1954 jq->num_pages = 1; in wprintStartJob()
1977 jq->job_state = JOB_STATE_ERROR; in wprintStartJob()
1988 _job_queue_t *jq; in wprintEndJob() local
1992 jq = _get_job_desc(job_handle); in wprintEndJob()
1994 if (jq) { in wprintEndJob()
1996 if ((jq->job_state == JOB_STATE_CANCELLED) || (jq->job_state == JOB_STATE_ERROR) || in wprintEndJob()
1997 (jq->job_state == JOB_STATE_CORRUPTED) || (jq->job_state == JOB_STATE_COMPLETED)) { in wprintEndJob()
1999 if (jq->pageQ) { in wprintEndJob()
2000 while ((msgQNumMsgs(jq->pageQ) > 0) in wprintEndJob()
2001 && (msgQReceive(jq->pageQ, (char *) &page, sizeof(page), in wprintEndJob()
2004 result |= msgQDelete(jq->pageQ); in wprintEndJob()
2005 jq->pageQ = NULL; in wprintEndJob()
2008 if (jq->saveQ) { in wprintEndJob()
2009 while ((msgQNumMsgs(jq->saveQ) > 0) in wprintEndJob()
2010 && (msgQReceive(jq->saveQ, (char *) &page, sizeof(page), in wprintEndJob()
2013 result |= msgQDelete(jq->saveQ); in wprintEndJob()
2014 jq->saveQ = NULL; in wprintEndJob()
2018 LOGE("job %ld cannot be ended from state %d", job_handle, jq->job_state); in wprintEndJob()
2031 _job_queue_t *jq; in wprintPage() local
2037 jq = _get_job_desc(job_handle); in wprintPage()
2054 if (jq && jq->is_dir && !(jq->last_page_seen) && (((strlen(filename) < MAX_PATHNAME_LENGTH)) || in wprintPage()
2055 (jq && (strcmp(filename, "") == 0) && last_page))) { in wprintPage()
2071 snprintf(page.filename, MAX_PATHNAME_LENGTH, "%s/%s", jq->pathname, filename); in wprintPage()
2075 jq->last_page_seen = true; in wprintPage()
2078 result = msgQSend(jq->pageQ, (char *) &page, sizeof(page), NO_WAIT, MSG_Q_FIFO); in wprintPage()
2084 jq->num_pages++; in wprintPage()
2095 _job_queue_t *jq; in wprintCancelJob() local
2100 jq = _get_job_desc(job_handle); in wprintCancelJob()
2102 if (jq) { in wprintCancelJob()
2105 if ((jq->job_state == JOB_STATE_RUNNING) || (jq->job_state == JOB_STATE_BLOCKED)) { in wprintCancelJob()
2107 jq->cancel_ok = true; in wprintCancelJob()
2108 jq->job_params.cancelled = true; in wprintCancelJob()
2109 wprintPage(job_handle, jq->num_pages + 1, NULL, true, false, 0, 0, 0, 0); in wprintCancelJob()
2110 if (jq->status_ifc) { in wprintCancelJob()
2112 if ((jq->job_state != JOB_STATE_BLOCKED) || (jq->job_params.page_num != 0)) { in wprintCancelJob()
2114 jq->cancel_ok = ((jq->status_ifc->cancel)(jq->status_ifc, in wprintCancelJob()
2115 jq->job_params.job_originating_user_name) == 0); in wprintCancelJob()
2116 if ((jq->cancel_ok == true) && (errno != OK)) { in wprintCancelJob()
2121 if (!jq->cancel_ok) { in wprintCancelJob()
2125 if (enableTimeout && (jq->print_ifc != NULL) && in wprintCancelJob()
2126 (jq->print_ifc->enable_timeout != NULL)) { in wprintCancelJob()
2127 jq->print_ifc->enable_timeout(jq->print_ifc, 1); in wprintCancelJob()
2130 errno = (jq->cancel_ok ? OK : ENOTSUP); in wprintCancelJob()
2131 jq->job_state = JOB_STATE_CANCEL_REQUEST; in wprintCancelJob()
2133 } else if ((jq->job_state == JOB_STATE_CANCEL_REQUEST) || in wprintCancelJob()
2134 (jq->job_state == JOB_STATE_CANCELLED)) { in wprintCancelJob()
2136 errno = (jq->cancel_ok ? OK : ENOTSUP); in wprintCancelJob()
2137 } else if (jq->job_state == JOB_STATE_QUEUED) { in wprintCancelJob()
2138 jq->job_params.cancelled = true; in wprintCancelJob()
2139 jq->job_state = JOB_STATE_CANCELLED; in wprintCancelJob()
2141 if (jq->cb_fn) { in wprintCancelJob()
2146 cb_param.certificate = jq->certificate; in wprintCancelJob()
2147 cb_param.certificate_len = jq->certificate_len; in wprintCancelJob()
2149 jq->cb_fn(job_handle, (void *) &cb_param); in wprintCancelJob()