23 #include "kmprinter.h"
26 #include <tdelocale.h>
29 #include <tqlineedit.h>
30 #include <tdemessagebox.h>
33 static bool checkLpdQueue(
const char *host,
const char *queue);
37 KMWLpd::KMWLpd(TQWidget *parent,
const char *name)
38 : KMWInfoBase(2,parent,name)
41 m_title = i18n(
"LPD Queue Information");
42 m_nextpage = KMWizard::Driver;
44 setInfo(i18n(
"<p>Enter the information concerning the remote LPD queue; "
45 "this wizard will check it before continuing.</p>"));
46 setLabel(0,i18n(
"Host:"));
47 setLabel(1,i18n(
"Queue:"));
50 bool KMWLpd::isValid(TQString& msg)
52 if (text(0).isEmpty() || text(1).isEmpty())
54 msg = i18n(
"Some information is missing.");
59 if (!checkLpdQueue(text(0).latin1(),text(1).latin1()))
61 if (KMessageBox::warningContinueCancel(
this, i18n(
"Cannot find queue %1 on server %2; do you want to continue anyway?").arg(text(1)).arg(text(0))) == KMessageBox::Cancel)
67 void KMWLpd::updatePrinter(KMPrinter *p)
69 TQString dev = TQString::fromLatin1(
"lpd://%1/%2").arg(text(0)).arg(text(1));
75 bool checkLpdQueue(
const char *host,
const char *queue)
77 KExtendedSocket sock(host,
"printer", KExtendedSocket::streamSocket);
78 sock.setBlockingMode(
true);
79 if (sock.connect() != 0)
83 snprintf(res,64,
"%c%s\n",(
char)4,queue);
84 if (sock.writeBlock(res, strlen(res)) != (TQ_LONG)(strlen(res)))
89 while ((n = sock.readBlock(res, 63)) > 0)
99 if (strlen(buf) == 0 || strstr(buf,
"unknown printer") != NULL)