39 #include "tdeprintcheck.h"
41 #include <kstandarddirs.h>
47 static const char*
const config_stddirs[] = {
56 bool KdeprintChecker::check(TDEConfig *conf,
const TQString& group)
59 conf->setGroup(group);
60 TQStringList uris = conf->readListEntry(
"Require");
64 bool KdeprintChecker::check(
const TQStringList& uris)
67 for (TQStringList::ConstIterator it=uris.begin(); it!=uris.end() && state; ++it)
69 state = (state && checkURL(KURL(*it)));
75 bool KdeprintChecker::checkURL(
const KURL& url)
77 TQString prot(url.protocol());
79 return checkConfig(url);
80 else if (prot ==
"exec")
81 return checkExec(url);
82 else if (prot ==
"file" || prot ==
"dir")
83 return TDEStandardDirs::exists(url.url());
84 else if (prot ==
"service")
85 return checkService(url);
89 bool KdeprintChecker::checkConfig(
const KURL& url)
92 TQString f(url.path().mid(1));
96 if (!locate(
"config",f).isEmpty())
101 const char*
const *p = config_stddirs;
105 if ( TQFile::exists( TQString::fromLatin1( *p ) + f ) )
117 bool KdeprintChecker::checkExec(
const KURL& url)
119 TQString execname(url.path().mid(1));
120 return !(TDEStandardDirs::findExe(execname).isEmpty());
123 bool KdeprintChecker::checkService(
const KURL& url)
125 TQString serv(url.path().mid(1));
126 KExtendedSocket sock;
129 int port = serv.toInt(&ok);
131 if (ok) sock.setAddress(
"localhost", port);
132 else sock.setAddress(
"localhost", serv);
133 return (sock.connect() == 0);