gschecker.cpp00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "gschecker.h"
00021 #include "kpipeprocess.h"
00022
00023 #include <qfile.h>
00024 #include <qtextstream.h>
00025
00026 GsChecker::GsChecker(QObject *parent, const char *name)
00027 : QObject(parent,name)
00028 {
00029 }
00030
00031 bool GsChecker::checkGsDriver(const QString& name)
00032 {
00033 if (m_driverlist.count() == 0)
00034 loadDriverList();
00035 return m_driverlist.contains(name);
00036 }
00037
00038 void GsChecker::loadDriverList()
00039 {
00040 KPipeProcess proc;
00041 if (proc.open("gs -h",IO_ReadOnly))
00042 {
00043 QTextStream t(&proc);
00044 QString buffer, line;
00045 bool ok(false);
00046 while (!t.eof())
00047 {
00048 line = t.readLine().stripWhiteSpace();
00049 if (ok)
00050 {
00051 if (line.find(':') != -1)
00052 break;
00053 else
00054 buffer.append(line).append(" ");
00055 }
00056 else if (line.startsWith(QString::fromLatin1("Available devices:")))
00057 ok = true;
00058 }
00059 m_driverlist = QStringList::split(' ',buffer,false);
00060 }
00061 }
|