static int check_json_tree_printer_pretty() { JT::TreeBuilder tree_builder; auto created = tree_builder.build(json_data2,sizeof(json_data2)); JT::Node *root = created.first; assert(root); check_json_tree_from_json_data2(root); JT::SerializerOptions printerOption(true); char buffer[4096]; memset(buffer,'\0', 4096); JT::TreeSerializer serializer(buffer,4096); assert(serializer.serialize(root->asObjectNode())); size_t actual_size = strlen(buffer); size_t reported_used = serializer.buffers().front().used; assert(actual_size == reported_used); delete root; created = tree_builder.build(buffer,actual_size); root = created.first; check_json_tree_from_json_data2(root); return 0; }
QPrint::DeviceState QPpdPrintDevice::state() const { // 3 = idle, 4 = printing, 5 = stopped // More details available from printer-state-message and printer-state-reasons int state = printerOption(QStringLiteral("printer-state")).toInt(); if (state == 3) return QPrint::Idle; else if (state == 4) return QPrint::Active; else return QPrint::Error; }
QPpdPrintDevice::QPpdPrintDevice(const QString &id) : QPlatformPrintDevice(id), m_cupsDest(0), m_ppd(0) { if (!id.isEmpty()) { // TODO For now each dest is an individual device QStringList parts = id.split(QLatin1Char('/')); m_cupsName = parts.at(0).toUtf8(); if (parts.size() > 1) m_cupsInstance = parts.at(1).toUtf8(); loadPrinter(); if (m_cupsDest && m_ppd) { m_name = printerOption("printer-info"); m_location = printerOption("printer-location"); m_makeAndModel = printerOption("printer-make-and-model"); cups_ptype_e type = printerTypeFlags(); m_isRemote = type & CUPS_PRINTER_REMOTE; // Note this is if the hardware does multiple copies, not if Cups can m_supportsMultipleCopies = type & CUPS_PRINTER_COPIES; // Note this is if the hardware does collation, not if Cups can m_supportsCollateCopies = type & CUPS_PRINTER_COLLATE; // Custom Page Size support // Cups cups_ptype_e CUPS_PRINTER_VARIABLE // Cups ppd_file_t variable_sizes custom_min custom_max // PPD MaxMediaWidth MaxMediaHeight m_supportsCustomPageSizes = type & CUPS_PRINTER_VARIABLE; m_minimumPhysicalPageSize = QSize(m_ppd->custom_min[0], m_ppd->custom_min[1]); m_maximumPhysicalPageSize = QSize(m_ppd->custom_max[0], m_ppd->custom_max[1]); m_customMargins = QMarginsF(m_ppd->custom_margins[0], m_ppd->custom_margins[3], m_ppd->custom_margins[2], m_ppd->custom_margins[1]); } } }