#include "qplatformdefs.h"
#include "private/qabstractprintdialog_p.h"
#include <QtGui/qapplication.h>
#include <QtGui/qcheckbox.h>
#include <QtCore/qlibrary.h>
#include <QtCore/qlist.h>
#include <QtGui/qprinter.h>
#include <QtGui/qtreeview.h>
#include <QtGui/qlistview.h>
#include <QtGui/qevent.h>
#include <QtGui/qmessagebox.h>
#include "qprintdialog.h"
#include "qfiledialog.h"
#include <QtCore/qdebug.h>
#include <QtCore/qobject.h>
#include <QtGui/qabstractprintdialog.h>
#include <QtGui/qitemdelegate.h>
#include "qprintengine.h"
#include "ui_qprintdialog.h"
#include "ui_qprintpropertiesdialog.h"
#include <private/qcups_p.h>
#include <cups/cups.h>
#include <private/qpdf_p.h>
#include <rpcsvc/ypclnt.h>
#include <rpcsvc/yp_prot.h>
#include <ctype.h>
#include "moc_qprintdialog.cpp"
#include "qprintdialog_unix.moc"
Include dependency graph for qprintdialog_unix.cpp:

Go to the source code of this file.
| #define skipSpaces | ( | ) |
| anonymous enum |
| anonymous enum |
| static int getLprPrinters | ( | QList< QPrinterDescription > & | printers | ) | [static] |
Definition at line 815 of file qprintdialog_unix.cpp.
References QList< T >::at(), QRegExp::cap(), QPrinterDescription::comment, constData(), QByteArray::data(), QString::fromLocal8Bit(), i, QRegExp::indexIn(), QFileInfo::isDir(), QByteArray::isEmpty(), isEmpty(), QString::isEmpty(), QFileInfo::isFile(), QPrinterDescription::name, name, QFile::open(), parseEtcLpMember(), parseEtcLpPrinters(), parseNsswitchConf(), parsePrintcap(), parsePrintersConf(), parseQconfig(), parseSpoolInterface(), perhapsAddPrinter(), qgetenv(), quality, QIODevice::readLine(), QIODevice::ReadOnly, QByteArray::resize(), QFileInfo::setFile(), QList< T >::size(), and QString::toAscii().
Referenced by QPrintDialogPrivate::init().
00816 { 00817 QByteArray etcLpDefault; 00818 parsePrintcap(&printers, QLatin1String("/etc/printcap")); 00819 parseEtcLpMember(&printers); 00820 parseSpoolInterface(&printers); 00821 parseQconfig(&printers); 00822 00823 QFileInfo f; 00824 f.setFile(QLatin1String("/etc/lp/printers")); 00825 if (f.isDir()) { 00826 parseEtcLpPrinters(&printers); 00827 QFile def(QLatin1String("/etc/lp/default")); 00828 if (def.open(QIODevice::ReadOnly)) { 00829 etcLpDefault.resize(1025); 00830 if (def.readLine(etcLpDefault.data(), 1024) > 0) { 00831 QRegExp rx("^(\\S+)"); 00832 if (rx.indexIn(etcLpDefault) != -1) 00833 etcLpDefault = rx.cap(1).toAscii(); 00834 } 00835 } 00836 } 00837 00838 char *def = 0; 00839 f.setFile(QLatin1String("/etc/nsswitch.conf")); 00840 if (f.isFile()) { 00841 def = parseNsswitchConf(&printers); 00842 } else { 00843 f.setFile(QLatin1String("/etc/printers.conf")); 00844 if (f.isFile()) 00845 def = parsePrintersConf(&printers); 00846 } 00847 00848 if (def) { 00849 etcLpDefault = def; 00850 delete [] def; 00851 } 00852 00853 // all printers hopefully known. try to find a good default 00854 QString dollarPrinter; 00855 { 00856 if (!qgetenv("PRINTER").isEmpty()) 00857 dollarPrinter = QString::fromLocal8Bit(qgetenv("LPDEST").constData()); 00858 if (!dollarPrinter.isEmpty()) 00859 perhapsAddPrinter(&printers, dollarPrinter, 00860 QPrintDialog::tr("unknown"), 00861 QLatin1String("")); 00862 } 00863 00864 int quality = 0; 00865 int best = 0; 00866 for (int i = 0; i < printers.size(); ++i) { 00867 QRegExp ps(QLatin1String("[^a-z]ps(?:[^a-z]|$)")); 00868 QRegExp lp(QLatin1String("[^a-z]lp(?:[^a-z]|$)")); 00869 00870 QString name = printers.at(i).name; 00871 QString comment = printers.at(i).comment; 00872 if (quality < 4 && name == dollarPrinter) { 00873 best = i; 00874 quality = 4; 00875 } else if (quality < 3 && !etcLpDefault.isEmpty() && 00876 name == QLatin1String(etcLpDefault)) { 00877 best = i; 00878 quality = 3; 00879 } else if (quality < 2 && 00880 (name == QLatin1String("ps") || 00881 ps.indexIn(comment) != -1)) { 00882 best = i; 00883 quality = 2; 00884 } else if (quality < 1 && 00885 (name == QLatin1String("lp") || 00886 lp.indexIn(comment) > -1)) { 00887 best = i; 00888 quality = 1; 00889 } 00890 } 00891 00892 return best; 00893 }
Here is the call graph for this function:

| static void parseEtcLpMember | ( | QList< QPrinterDescription > * | printers | ) | [static] |
Definition at line 618 of file qprintdialog_unix.cpp.
References QList< T >::at(), QDir::entryInfoList(), QDir::exists(), i, QList< T >::isEmpty(), perhapsAddPrinter(), and QList< T >::size().
Referenced by getLprPrinters().
00619 { 00620 QDir lp(QLatin1String("/etc/lp/member")); 00621 if (!lp.exists()) 00622 return; 00623 QFileInfoList dirs = lp.entryInfoList(); 00624 if (dirs.isEmpty()) 00625 return; 00626 00627 QString tmp; 00628 for (int i = 0; i < dirs.size(); ++i) { 00629 QFileInfo printer = dirs.at(i); 00630 // I haven't found any real documentation, so I'm guessing that 00631 // since lpstat uses /etc/lp/member rather than one of the 00632 // other directories, it's the one to use. I did not find a 00633 // decent way to locate aliases and remote printers. 00634 if (printer.isFile()) 00635 perhapsAddPrinter(printers, printer.fileName(), 00636 QPrintDialog::tr("unknown"), 00637 QLatin1String("")); 00638 } 00639 }
Here is the call graph for this function:

| static void parseEtcLpPrinters | ( | QList< QPrinterDescription > * | printers | ) | [static] |
Definition at line 283 of file qprintdialog_unix.cpp.
References QList< T >::at(), QFile::atEnd(), QDir::entryInfoList(), QString::fromLatin1(), QString::fromLocal8Bit(), i, QList< T >::isEmpty(), QFile::open(), p, perhapsAddPrinter(), QByteArray::qstrcmp(), QIODevice::readLine(), QIODevice::ReadOnly, s, QString::simplified(), QList< T >::size(), and QString::sprintf().
Referenced by getLprPrinters().
00284 { 00285 QDir lp(QLatin1String("/etc/lp/printers")); 00286 QFileInfoList dirs = lp.entryInfoList(); 00287 if (dirs.isEmpty()) 00288 return; 00289 00290 QString tmp; 00291 for (int i = 0; i < dirs.size(); ++i) { 00292 QFileInfo printer = dirs.at(i); 00293 if (printer.isDir()) { 00294 tmp.sprintf("/etc/lp/printers/%s/configuration", 00295 printer.fileName().toAscii().data()); 00296 QFile configuration(tmp); 00297 char *line = new char[1025]; 00298 QString remote(QLatin1String("Remote:")); 00299 QString contentType(QLatin1String("Content types:")); 00300 QString printerHost; 00301 bool canPrintPostscript = false; 00302 if (configuration.open(QIODevice::ReadOnly)) { 00303 while (!configuration.atEnd() && 00304 configuration.readLine(line, 1024) > 0) { 00305 if (QString::fromLatin1(line).startsWith(remote)) { 00306 const char *p = line; 00307 while (*p != ':') 00308 p++; 00309 p++; 00310 while (isspace((uchar) *p)) 00311 p++; 00312 printerHost = QString::fromLocal8Bit(p); 00313 printerHost = printerHost.simplified(); 00314 } else if (QString::fromLatin1(line).startsWith(contentType)) { 00315 char *p = line; 00316 while (*p != ':') 00317 p++; 00318 p++; 00319 char *e; 00320 while (*p) { 00321 while (isspace((uchar) *p)) 00322 p++; 00323 if (*p) { 00324 char s; 00325 e = p; 00326 while (isalnum((uchar) *e)) 00327 e++; 00328 s = *e; 00329 *e = '\0'; 00330 if (!qstrcmp(p, "postscript") || 00331 !qstrcmp(p, "any")) 00332 canPrintPostscript = true; 00333 *e = s; 00334 if (s == ',') 00335 e++; 00336 p = e; 00337 } 00338 } 00339 } 00340 } 00341 if (canPrintPostscript) 00342 perhapsAddPrinter(printers, printer.fileName(), 00343 printerHost, QLatin1String("")); 00344 } 00345 delete[] line; 00346 } 00347 } 00348 }
Here is the call graph for this function:

| static char* parseNsswitchConf | ( | QList< QPrinterDescription > * | printers | ) | [static] |
Definition at line 591 of file qprintdialog_unix.cpp.
References QFile::atEnd(), QFile::open(), parseNsswitchPrintersEntry(), QByteArray::qstrncmp(), QIODevice::readLine(), and QIODevice::ReadOnly.
Referenced by getLprPrinters().
00592 { 00593 QFile nc(QLatin1String("/etc/nsswitch.conf")); 00594 if (!nc.open(QIODevice::ReadOnly)) 00595 return 0; 00596 00597 char *defaultPrinter = 0; 00598 00599 char *line = new char[1025]; 00600 line[1024] = '\0'; 00601 00602 while (!nc.atEnd() && 00603 nc.readLine(line, 1024) > 0) { 00604 if (qstrncmp(line, "printers", 8) == 0) { 00605 defaultPrinter = parseNsswitchPrintersEntry(printers, line); 00606 delete[] line; 00607 return defaultPrinter; 00608 } 00609 } 00610 00611 strcpy(line, "printers: user files nis nisplus xfn"); 00612 defaultPrinter = parseNsswitchPrintersEntry(printers, line); 00613 delete[] line; 00614 return defaultPrinter; 00615 }
Here is the call graph for this function:

| static char* parseNsswitchPrintersEntry | ( | QList< QPrinterDescription > * | printers, | |
| char * | line | |||
| ) | [static] |
Definition at line 512 of file qprintdialog_unix.cpp.
References QDir::homePath(), NotFound, parsePrintcap(), parsePrintersConf(), retrieveNisPrinters(), Return, skipSpaces, and Success.
Referenced by parseNsswitchConf().
00513 { 00514 #define skipSpaces() \ 00515 while (isspace((uchar) line[k])) \ 00516 k++ 00517 00518 char *defaultPrinter = 0; 00519 bool stop = false; 00520 int lastStatus = NotFound; 00521 00522 int k = 8; 00523 skipSpaces(); 00524 if (line[k] != ':') 00525 return 0; 00526 k++; 00527 00528 char *cp = strchr(line, '#'); 00529 if (cp != 0) 00530 *cp = '\0'; 00531 00532 while (line[k] != '\0') { 00533 if (isspace((uchar) line[k])) { 00534 k++; 00535 } else if (line[k] == '[') { 00536 k++; 00537 skipSpaces(); 00538 while (line[k] != '\0') { 00539 char status = tolower(line[k]); 00540 char action = '?'; 00541 00542 while (line[k] != '=' && line[k] != ']' && line[k] != '\0') 00543 k++; 00544 if (line[k] == '=') { 00545 k++; 00546 skipSpaces(); 00547 action = tolower(line[k]); 00548 while (line[k] != '\0' && !isspace((uchar) line[k]) && line[k] != ']') 00549 k++; 00550 } else if (line[k] == ']') { 00551 k++; 00552 break; 00553 } 00554 skipSpaces(); 00555 00556 if (lastStatus == status) 00557 stop = (action == (char) Return); 00558 } 00559 } else { 00560 if (stop) 00561 break; 00562 00563 QByteArray source; 00564 while (!isspace((uchar) line[k]) && line[k] != '[') { 00565 source += line[k]; 00566 k++; 00567 } 00568 00569 if (source == "user") { 00570 lastStatus = parsePrintcap(printers, 00571 QDir::homePath() + QLatin1String("/.printers")); 00572 } else if (source == "files") { 00573 bool found; 00574 defaultPrinter = parsePrintersConf(printers, &found); 00575 if (found) 00576 lastStatus = Success; 00577 #ifndef QT_NO_NIS 00578 } else if (source == "nis") { 00579 lastStatus = retrieveNisPrinters(printers); 00580 #endif 00581 } else { 00582 // nisplus, dns, etc., are not implemented yet 00583 lastStatus = NotFound; 00584 } 00585 stop = (lastStatus == Success); 00586 } 00587 } 00588 return defaultPrinter; 00589 }
Here is the call graph for this function:

| static int parsePrintcap | ( | QList< QPrinterDescription > * | printers, | |
| const QString & | fileName | |||
| ) | [static] |
Definition at line 244 of file qprintdialog_unix.cpp.
References QFile::atEnd(), QString::chop(), QString::fromLocal8Bit(), int, QString::length(), NotFound, QFile::open(), parsePrinterDesc(), QIODevice::readLine(), QIODevice::ReadOnly, Success, and QString::trimmed().
Referenced by getLprPrinters(), and parseNsswitchPrintersEntry().
00245 { 00246 QFile printcap(fileName); 00247 if (!printcap.open(QIODevice::ReadOnly)) 00248 return NotFound; 00249 00250 char *line_ascii = new char[1025]; 00251 line_ascii[1024] = '\0'; 00252 00253 QString printerDesc; 00254 bool atEnd = false; 00255 00256 while (!atEnd) { 00257 if (printcap.atEnd() || printcap.readLine(line_ascii, 1024) <= 0) 00258 atEnd = true; 00259 QString line = QString::fromLocal8Bit(line_ascii); 00260 line = line.trimmed(); 00261 if (line.length() >= 1 && line[int(line.length()) - 1] == QLatin1Char('\\')) 00262 line.chop(1); 00263 if (line[0] == QLatin1Char('#')) { 00264 if (!atEnd) 00265 continue; 00266 } else if (line[0] == QLatin1Char('|') || line[0] == QLatin1Char(':')) { 00267 printerDesc += line; 00268 if (!atEnd) 00269 continue; 00270 } 00271 00272 parsePrinterDesc(printerDesc, printers); 00273 00274 // add the first line of the new printer definition 00275 printerDesc = line; 00276 } 00277 delete[] line_ascii; 00278 return Success; 00279 }
Here is the call graph for this function:

| static void parsePrinterDesc | ( | QString | printerDesc, | |
| QList< QPrinterDescription > * | printers | |||
| ) | [static] |
Definition at line 197 of file qprintdialog_unix.cpp.
References aliases, QString::arg(), i, QString::indexOf(), QUnicodeTables::isSpace(), j, QString::left(), QString::length(), QString::mid(), perhapsAddPrinter(), QString::simplified(), and QString::split().
Referenced by parsePrintcap(), and pd_foreach().
00198 { 00199 if (printerDesc.length() < 1) 00200 return; 00201 00202 printerDesc = printerDesc.simplified(); 00203 int i = printerDesc.indexOf(QLatin1Char(':')); 00204 QString printerName, printerComment, printerHost; 00205 QStringList aliases; 00206 00207 if (i >= 0) { 00208 // have ':' want '|' 00209 int j = printerDesc.indexOf(QLatin1Char('|')); 00210 if (j > 0 && j < i) { 00211 printerName = printerDesc.left(j); 00212 aliases = printerDesc.mid(j + 1, i - j - 1).split(QLatin1Char('|')); 00213 // try extracting a comment from the aliases 00214 printerComment = QPrintDialog::tr("Aliases: %1") 00215 .arg(aliases.join(QLatin1String(", "))); 00216 } else { 00217 printerName = printerDesc.left(i); 00218 } 00219 // look for lprng pseudo all printers entry 00220 i = printerDesc.indexOf(QRegExp(QLatin1String(": *all *="))); 00221 if (i >= 0) 00222 printerName = QString(); 00223 // look for signs of this being a remote printer 00224 i = printerDesc.indexOf(QRegExp(QLatin1String(": *rm *="))); 00225 if (i >= 0) { 00226 // point k at the end of remote host name 00227 while (printerDesc[i] != QLatin1Char('=')) 00228 i++; 00229 while (printerDesc[i] == QLatin1Char('=') || printerDesc[i].isSpace()) 00230 i++; 00231 j = i; 00232 while (j < (int)printerDesc.length() && printerDesc[j] != QLatin1Char(':')) 00233 j++; 00234 00235 // and stuff that into the string 00236 printerHost = printerDesc.mid(i, j - i); 00237 } 00238 } 00239 if (printerName.length()) 00240 perhapsAddPrinter(printers, printerName, printerHost, printerComment, 00241 aliases); 00242 }
Here is the call graph for this function:

| static char* parsePrintersConf | ( | QList< QPrinterDescription > * | printers, | |
| bool * | found = 0 | |||
| ) | [static] |
Definition at line 352 of file qprintdialog_unix.cpp.
References aliases, QString::arg(), QFile::atEnd(), QByteArray::data(), QString::fromLocal8Bit(), i, QString::indexOf(), QUnicodeTables::isSpace(), j, QString::length(), QString::mid(), QFile::open(), perhapsAddPrinter(), QByteArray::qstrdup(), QIODevice::readLine(), QIODevice::ReadOnly, QString::simplified(), QString::split(), and QString::toAscii().
Referenced by getLprPrinters(), and parseNsswitchPrintersEntry().
00353 { 00354 QFile pc(QLatin1String("/etc/printers.conf")); 00355 if (!pc.open(QIODevice::ReadOnly)) { 00356 if (found) 00357 *found = false; 00358 return 0; 00359 } 00360 if (found) 00361 *found = true; 00362 00363 char *line = new char[1025]; 00364 line[1024] = '\0'; 00365 00366 QString printerDesc; 00367 int lineLength = 0; 00368 00369 char *defaultPrinter = 0; 00370 00371 while (!pc.atEnd() && 00372 (lineLength=pc.readLine(line, 1024)) > 0) { 00373 if (*line == '#') { 00374 *line = '\0'; 00375 lineLength = 0; 00376 } 00377 if (lineLength >= 2 && line[lineLength-2] == '\\') { 00378 line[lineLength-2] = '\0'; 00379 printerDesc += QString::fromLocal8Bit(line); 00380 } else { 00381 printerDesc += QString::fromLocal8Bit(line); 00382 printerDesc = printerDesc.simplified(); 00383 int i = printerDesc.indexOf(QLatin1Char(':')); 00384 QString printerName, printerHost, printerComment; 00385 QStringList aliases; 00386 if (i >= 0) { 00387 // have : want | 00388 int j = printerDesc.indexOf(QLatin1Char('|')); 00389 if (j >= i) 00390 j = -1; 00391 printerName = printerDesc.mid(0, j < 0 ? i : j); 00392 if (printerName == QLatin1String("_default")) { 00393 i = printerDesc.indexOf( 00394 QRegExp(QLatin1String(": *use *="))); 00395 while (printerDesc[i] != QLatin1Char('=')) 00396 i++; 00397 while (printerDesc[i] == QLatin1Char('=') || printerDesc[i].isSpace()) 00398 i++; 00399 j = i; 00400 while (j < (int)printerDesc.length() && 00401 printerDesc[j] != QLatin1Char(':') && printerDesc[j] != QLatin1Char(',')) 00402 j++; 00403 // that's our default printer 00404 defaultPrinter = 00405 qstrdup(printerDesc.mid(i, j-i).toAscii().data()); 00406 printerName = QString(); 00407 printerDesc = QString(); 00408 } else if (printerName == QLatin1String("_all")) { 00409 // skip it.. any other cases we want to skip? 00410 printerName = QString(); 00411 printerDesc = QString(); 00412 } 00413 00414 if (j > 0) { 00415 // try extracting a comment from the aliases 00416 aliases = printerDesc.mid(j + 1, i - j - 1).split(QLatin1Char('|')); 00417 printerComment = QPrintDialog::tr("Aliases: %1") 00418 .arg(aliases.join(QLatin1String(", "))); 00419 } 00420 // look for signs of this being a remote printer 00421 i = printerDesc.indexOf( 00422 QRegExp(QLatin1String(": *bsdaddr *="))); 00423 if (i >= 0) { 00424 // point k at the end of remote host name 00425 while (printerDesc[i] != QLatin1Char('=')) 00426 i++; 00427 while (printerDesc[i] == QLatin1Char('=') || printerDesc[i].isSpace()) 00428 i++; 00429 j = i; 00430 while (j < (int)printerDesc.length() && 00431 printerDesc[j] != QLatin1Char(':') && printerDesc[j] != QLatin1Char(',')) 00432 j++; 00433 // and stuff that into the string 00434 printerHost = printerDesc.mid(i, j-i); 00435 // maybe stick the remote printer name into the comment 00436 if (printerDesc[j] == QLatin1Char(',')) { 00437 i = ++j; 00438 while (printerDesc[i].isSpace()) 00439 i++; 00440 j = i; 00441 while (j < (int)printerDesc.length() && 00442 printerDesc[j] != QLatin1Char(':') && printerDesc[j] != QLatin1Char(',')) 00443 j++; 00444 if (printerName != printerDesc.mid(i, j-i)) { 00445 printerComment = 00446 QLatin1String("Remote name: "); 00447 printerComment += printerDesc.mid(i, j-i); 00448 } 00449 } 00450 } 00451 } 00452 if (printerComment == QLatin1String(":")) 00453 printerComment = QString(); // for cups 00454 if (printerName.length()) 00455 perhapsAddPrinter(printers, printerName, printerHost, 00456 printerComment, aliases); 00457 // chop away the line, for processing the next one 00458 printerDesc = QString(); 00459 } 00460 } 00461 delete[] line; 00462 return defaultPrinter; 00463 }
Here is the call graph for this function:

| static void parseQconfig | ( | QList< QPrinterDescription > * | printers | ) | [static] |
Definition at line 718 of file qprintdialog_unix.cpp.
References QTextStream::atEnd(), QString::chop(), QString::clear(), QString::contains(), i, QString::indexOf(), QString::left(), QString::length(), QString::mid(), QFile::open(), perhapsAddPrinter(), QTextStream::readLine(), QIODevice::ReadOnly, QString::simplified(), and value.
Referenced by getLprPrinters().
00719 { 00720 QFile qconfig(QLatin1String("/etc/qconfig")); 00721 if (!qconfig.open(QIODevice::ReadOnly)) 00722 return; 00723 00724 QTextStream ts(&qconfig); 00725 QString line; 00726 00727 QString stanzaName; // either a queue or a device name 00728 bool up = true; // queue up? default true, can be false 00729 QString remoteHost; // null if local 00730 QString deviceName; // null if remote 00731 00732 QRegExp newStanza(QLatin1String("^[0-z\\-]*:$")); 00733 00734 // our basic strategy here is to process each line, detecting new 00735 // stanzas. each time we see a new stanza, we check if the 00736 // previous stanza was a valid queue for a) a remote printer or b) 00737 // a local printer. if it wasn't, we assume that what we see is 00738 // the start of the first stanza, or that the previous stanza was 00739 // a device stanza, or that there is some syntax error (we don't 00740 // report those). 00741 00742 do { 00743 line = ts.readLine(); 00744 bool indented = line[0].isSpace(); 00745 line = line.simplified(); 00746 00747 int i = line.indexOf(QLatin1Char('=')); 00748 if (indented && i != -1) { // line in stanza 00749 QString variable = line.left(i).simplified(); 00750 QString value=line.mid(i+1, line.length()).simplified(); 00751 if (variable == QLatin1String("device")) 00752 deviceName = value; 00753 else if (variable == QLatin1String("host")) 00754 remoteHost = value; 00755 else if (variable == QLatin1String("up")) 00756 up = !(value.toLower() == QLatin1String("false")); 00757 } else if (line[0] == QLatin1Char('*')) { // comment 00758 // nothing to do 00759 } else if (ts.atEnd() || // end of file, or beginning of new stanza 00760 (!indented && line.contains(newStanza))) { 00761 if (up && stanzaName.length() > 0 && stanzaName.length() < 21) { 00762 if (remoteHost.length()) // remote printer 00763 perhapsAddPrinter(printers, stanzaName, remoteHost, 00764 QString()); 00765 else if (deviceName.length()) // local printer 00766 perhapsAddPrinter(printers, stanzaName, QString(), 00767 QString()); 00768 } 00769 line.chop(1); 00770 if (line.length() >= 1 && line.length() <= 20) 00771 stanzaName = line; 00772 up = true; 00773 remoteHost.clear(); 00774 deviceName.clear(); 00775 } else { 00776 // syntax error? ignore. 00777 } 00778 } while (!ts.atEnd()); 00779 }
Here is the call graph for this function:

| static void parseSpoolInterface | ( | QList< QPrinterDescription > * | printers | ) | [static] |
Definition at line 642 of file qprintdialog_unix.cpp.
References QList< T >::at(), Qt::CaseInsensitive, QByteArray::data(), QDir::entryInfoList(), QDir::exists(), QString::fromLocal8Bit(), i, QString::indexOf(), QList< T >::isEmpty(), QString::isEmpty(), QString::length(), QString::mid(), perhapsAddPrinter(), QIODevice::ReadOnly, QString::remove(), QByteArray::resize(), QString::simplified(), QList< T >::size(), and QString::trimmed().
Referenced by getLprPrinters().
00643 { 00644 QDir lp(QLatin1String("/usr/spool/lp/interface")); 00645 if (!lp.exists()) 00646 return; 00647 QFileInfoList files = lp.entryInfoList(); 00648 if(files.isEmpty()) 00649 return; 00650 00651 for (int i = 0; i < files.size(); ++i) { 00652 QFileInfo printer = files.at(i); 00653 00654 if (!printer.isFile()) 00655 continue; 00656 00657 // parse out some information 00658 QFile configFile(printer.filePath()); 00659 if (!configFile.open(QIODevice::ReadOnly)) 00660 continue; 00661 00662 QByteArray line; 00663 line.resize(1025); 00664 QString namePrinter; 00665 QString hostName; 00666 QString hostPrinter; 00667 QString printerType; 00668 00669 QString nameKey(QLatin1String("NAME=")); 00670 QString typeKey(QLatin1String("TYPE=")); 00671 QString hostKey(QLatin1String("HOSTNAME=")); 00672 QString hostPrinterKey(QLatin1String("HOSTPRINTER=")); 00673 00674 while (!configFile.atEnd() && 00675 (configFile.readLine(line.data(), 1024)) > 0) { 00676 QString uline = QString::fromLocal8Bit(line); 00677 if (uline.startsWith(typeKey) ) { 00678 printerType = uline.mid(nameKey.length()); 00679 printerType = printerType.simplified(); 00680 } else if (uline.startsWith(hostKey)) { 00681 hostName = uline.mid(hostKey.length()); 00682 hostName = hostName.simplified(); 00683 } else if (uline.startsWith(hostPrinterKey)) { 00684 hostPrinter = uline.mid(hostPrinterKey.length()); 00685 hostPrinter = hostPrinter.simplified(); 00686 } else if (uline.startsWith(nameKey)) { 00687 namePrinter = uline.mid(nameKey.length()); 00688 namePrinter = namePrinter.simplified(); 00689 } 00690 } 00691 configFile.close(); 00692 00693 printerType = printerType.trimmed(); 00694 if (printerType.indexOf(QLatin1String("postscript"), 0, Qt::CaseInsensitive) < 0) 00695 continue; 00696 00697 int ii = 0; 00698 while ((ii = namePrinter.indexOf(QLatin1Char('"'), ii)) >= 0) 00699 namePrinter.remove(ii, 1); 00700 00701 if (hostName.isEmpty() || hostPrinter.isEmpty()) { 00702 perhapsAddPrinter(printers, printer.fileName(), 00703 QLatin1String(""), namePrinter); 00704 } else { 00705 QString comment; 00706 comment = namePrinter; 00707 comment += QLatin1String(" ("); 00708 comment += hostPrinter; 00709 comment += QLatin1Char(')'); 00710 perhapsAddPrinter(printers, printer.fileName(), 00711 hostName, comment); 00712 } 00713 } 00714 }
Here is the call graph for this function:

| static int pd_foreach | ( | int | , | |
| char * | , | |||
| int | , | |||
| char * | val, | |||
| int | valLen, | |||
| char * | data | |||
| ) | [static] |
Definition at line 471 of file qprintdialog_unix.cpp.
References QString::fromLatin1(), and parsePrinterDesc().
Referenced by retrieveNisPrinters().
00473 { 00474 parsePrinterDesc(QString::fromLatin1(val, valLen), (QList<QPrinterDescription> *)data); 00475 return 0; 00476 }
Here is the call graph for this function:

| static void perhapsAddPrinter | ( | QList< QPrinterDescription > * | printers, | |
| const QString & | name, | |||
| QString | host, | |||
| QString | comment, | |||
| QStringList | aliases = QStringList() | |||
| ) | [static] |
Definition at line 184 of file qprintdialog_unix.cpp.
References aliases, QList< T >::append(), QList< T >::at(), i, QString::isEmpty(), name, QPrinterDescription::samePrinter(), QString::simplified(), and QList< T >::size().
Referenced by getLprPrinters(), parseEtcLpMember(), parseEtcLpPrinters(), parsePrinterDesc(), parsePrintersConf(), parseQconfig(), and parseSpoolInterface().
00187 { 00188 for (int i = 0; i < printers->size(); ++i) 00189 if (printers->at(i).samePrinter(name)) 00190 return; 00191 00192 if (host.isEmpty()) 00193 host = QPrintDialog::tr("locally connected"); 00194 printers->append(QPrinterDescription(name.simplified(), host.simplified(), comment.simplified(), aliases)); 00195 }
Here is the call graph for this function:

| static void populatePaperSizes | ( | QComboBox * | cb | ) | [static] |
Definition at line 781 of file qprintdialog_unix.cpp.
References QPrinter::A0, QPrinter::A1, QPrinter::A2, QPrinter::A3, QPrinter::A4, QPrinter::A5, QPrinter::A6, QPrinter::A7, QPrinter::A8, QPrinter::A9, QComboBox::addItem(), QPrinter::B0, QPrinter::B1, QPrinter::B10, QPrinter::B2, QPrinter::B3, QPrinter::B4, QPrinter::B5, QPrinter::B6, QPrinter::B7, QPrinter::B8, QPrinter::B9, QPrinter::C5E, QPrinter::Comm10E, QPrinter::DLE, QPrinter::Executive, QPrinter::Folio, QPrinter::Ledger, QPrinter::Legal, QPrinter::Letter, and QPrinter::Tabloid.
Referenced by QPrintDialogPrivate::refreshPageSizes().
00782 { 00783 cb->addItem(QPrintDialog::tr("A0 (841 x 1189 mm)"), QPrinter::A0); 00784 cb->addItem(QPrintDialog::tr("A1 (594 x 841 mm)"), QPrinter::A1); 00785 cb->addItem(QPrintDialog::tr("A2 (420 x 594 mm)"), QPrinter::A2); 00786 cb->addItem(QPrintDialog::tr("A3 (297 x 420 mm)"), QPrinter::A3); 00787 cb->addItem(QPrintDialog::tr("A4 (210 x 297 mm, 8.26 x 11.7 inches)"), QPrinter::A4); 00788 cb->addItem(QPrintDialog::tr("A5 (148 x 210 mm)"), QPrinter::A5); 00789 cb->addItem(QPrintDialog::tr("A6 (105 x 148 mm)"), QPrinter::A6); 00790 cb->addItem(QPrintDialog::tr("A7 (74 x 105 mm)"), QPrinter::A7); 00791 cb->addItem(QPrintDialog::tr("A8 (52 x 74 mm)"), QPrinter::A8); 00792 cb->addItem(QPrintDialog::tr("A9 (37 x 52 mm)"), QPrinter::A9); 00793 cb->addItem(QPrintDialog::tr("B0 (1000 x 1414 mm)"), QPrinter::B0); 00794 cb->addItem(QPrintDialog::tr("B1 (707 x 1000 mm)"), QPrinter::B1); 00795 cb->addItem(QPrintDialog::tr("B2 (500 x 707 mm)"), QPrinter::B2); 00796 cb->addItem(QPrintDialog::tr("B3 (353 x 500 mm)"), QPrinter::B3); 00797 cb->addItem(QPrintDialog::tr("B4 (250 x 353 mm)"), QPrinter::B4); 00798 cb->addItem(QPrintDialog::tr("B5 (176 x 250 mm, 6.93 x 9.84 inches)"), QPrinter::B5); 00799 cb->addItem(QPrintDialog::tr("B6 (125 x 176 mm)"), QPrinter::B6); 00800 cb->addItem(QPrintDialog::tr("B7 (88 x 125 mm)"), QPrinter::B7); 00801 cb->addItem(QPrintDialog::tr("B8 (62 x 88 mm)"), QPrinter::B8); 00802 cb->addItem(QPrintDialog::tr("B9 (44 x 62 mm)"), QPrinter::B9); 00803 cb->addItem(QPrintDialog::tr("B10 (31 x 44 mm)"), QPrinter::B10); 00804 cb->addItem(QPrintDialog::tr("C5E (163 x 229 mm)"), QPrinter::C5E); 00805 cb->addItem(QPrintDialog::tr("DLE (110 x 220 mm)"), QPrinter::DLE); 00806 cb->addItem(QPrintDialog::tr("Executive (7.5 x 10 inches, 191 x 254 mm)"), QPrinter::Executive); 00807 cb->addItem(QPrintDialog::tr("Folio (210 x 330 mm)"), QPrinter::Folio); 00808 cb->addItem(QPrintDialog::tr("Ledger (432 x 279 mm)"), QPrinter::Ledger); 00809 cb->addItem(QPrintDialog::tr("Legal (8.5 x 14 inches, 216 x 356 mm)"), QPrinter::Legal); 00810 cb->addItem(QPrintDialog::tr("Letter (8.5 x 11 inches, 216 x 279 mm)"), QPrinter::Letter); 00811 cb->addItem(QPrintDialog::tr("Tabloid (279 x 432 mm)"), QPrinter::Tabloid); 00812 cb->addItem(QPrintDialog::tr("US Common #10 Envelope (105 x 241 mm)"), QPrinter::Comm10E); 00813 }
Here is the call graph for this function:

| static int retrieveNisPrinters | ( | QList< QPrinterDescription > * | printers | ) | [static] |
Definition at line 482 of file qprintdialog_unix.cpp.
References int, pd_foreach(), QLibrary::resolve(), Success, and Unavail.
Referenced by parseNsswitchPrintersEntry().
00483 { 00484 typedef int (*WildCast)(int, char *, int, char *, int, char *); 00485 char printersConfByname[] = "printers.conf.byname"; 00486 char *domain; 00487 int err; 00488 00489 QLibrary lib(QLatin1String("nsl")); 00490 typedef int (*ypGetDefaultDomain)(char **); 00491 ypGetDefaultDomain _ypGetDefaultDomain = (ypGetDefaultDomain)lib.resolve("yp_get_default_domain"); 00492 typedef int (*ypAll)(const char *, const char *, const struct ypall_callback *); 00493 ypAll _ypAll = (ypAll)lib.resolve("yp_all"); 00494 00495 if (_ypGetDefaultDomain && _ypAll) { 00496 err = _ypGetDefaultDomain(&domain); 00497 if (err == 0) { 00498 ypall_callback cb; 00499 // wild cast to support K&R-style system headers 00500 (WildCast &) cb.foreach = (WildCast) pd_foreach; 00501 cb.data = (char *) printers; 00502 err = _ypAll(domain, printersConfByname, &cb); 00503 } 00504 if (!err) 00505 return Success; 00506 } 00507 return Unavail; 00508 }
Here is the call graph for this function:

1.5.1