[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdelibs/kdeprint
From: Oswald Buddenhagen <ossi () kde ! org>
Date: 2007-06-11 16:33:37
Message-ID: 1181579617.279779.20837.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 674059 by ossi:
k3process--
kpipeprocess--
(calling process where library call is sufficient)--
M +5 -19 cups/kmcupsmanager.cpp
M +3 -3 foomatic/kmfoomaticmanager.cpp
M +4 -3 kdeprintd.cpp
M +3 -2 kprinterimpl.cpp
M +2 -2 kxmlcommand.cpp
M +11 -25 lpd/kmlpdmanager.cpp
M +11 -12 lpr/lpchelper.cpp
M +2 -2 lpr/lpqhelper.cpp
M +9 -23 lpr/matichandler.cpp
M +11 -9 management/smbview.cpp
--- trunk/KDE/kdelibs/kdeprint/cups/kmcupsmanager.cpp #674058:674059
@@ -26,7 +26,6 @@
#include "kmdbentry.h"
#include "cupsaddsmb2.h"
#include "ippreportdlg.h"
-#include "kpipeprocess.h"
#include "util.h"
#include "foomatic2loader.h"
#include "ppdloader.h"
@@ -40,6 +39,7 @@
#include <QtCore/QDate>
#include <QtNetwork/QTcpSocket>
+#include <kprocess.h>
#include <kdebug.h>
#include <krandom.h>
#include <kicon.h>
@@ -546,25 +546,11 @@
return NULL;
}
- KPipeProcess in;
- QFile out(tmpFile);
- QString cmd = KShell::quoteArg(exe);
- cmd += " -t cups -d ";
- cmd += KShell::quoteArg(comps[2]);
- cmd += " -p ";
- cmd += KShell::quoteArg(comps[1]);
- if (in.open(cmd) && out.open(QIODevice::WriteOnly))
+ KProcess proc;
+ proc << exe << "-t" << "cups" << "-d" << comps[2] << "-p" << comps[1];
+ proc.setStandardOutputFile(tmpFile);
+ if (!proc.execute())
{
- QTextStream tin(&in), tout(&out);
- QString line;
- while (!tin.atEnd())
- {
- line = tin.readLine();
- tout << line << endl;
- }
- in.close();
- out.close();
-
DrMain *driver = loadDriverFile(tmpFile);
if (driver)
{
--- trunk/KDE/kdelibs/kdeprint/foomatic/kmfoomaticmanager.cpp #674058:674059
@@ -24,7 +24,7 @@
#include <Qt/qdom.h>
#include <klocale.h>
#include <kdebug.h>
-#include <k3process.h>
+#include <kshell.h>
#include <unistd.h>
@@ -77,9 +77,9 @@
}
QString cmd = "foomatic-combo-xml -p ";
- cmd += K3Process::quote(printer->option("printer"));
+ cmd += KShell::quoteArg(printer->option("printer"));
cmd += " -d ";
- cmd += K3Process::quote(printer->option("driver"));
+ cmd += KShell::quoteArg(printer->option("driver"));
KPipeProcess proc(cmd);
QDomDocument doc;
doc.setContent(&proc);
--- trunk/KDE/kdelibs/kdeprint/kdeprintd.cpp #674058:674059
@@ -33,6 +33,7 @@
#include <kstandarddirs.h>
#include <kwindowsystem.h>
#include <krandom.h>
+#include <kshell.h>
#include <QtGui/QLayout>
#include <QtCore/QTimer>
#include <QtCore/QRegExp>
@@ -130,12 +131,12 @@
if ( !url.isLocalFile() )
{
QString tmpFilename = KStandardDirs::locateLocal( "tmp", "kdeprint_" + \
KRandom::randomString( 8 ) );
- command.replace( re, K3Process::quote( tmpFilename ) );
+ command.replace( re, KShell::quoteArg( tmpFilename ) );
proc->setOutput( re.cap( 1 ) );
proc->setTempOutput( tmpFilename );
}
else
- command.replace( re, K3Process::quote( re.cap( 1 ) ) );
+ command.replace( re, KShell::quoteArg( re.cap( 1 ) ) );
}
if ( checkFiles( command, files ) )
@@ -190,7 +191,7 @@
KGuiItem(i18n("Enter the root password")), KStandardGuiItem::cancel(),
"provideRootsPassword") == KMessageBox::Continue)
{
- cmd = ("kdesu -c " + K3Process::quote(cmd));
+ cmd = ("kdesu -c " + KShell::quoteArg(cmd));
break;
}
else
--- trunk/KDE/kdelibs/kdeprint/kprinterimpl.cpp #674058:674059
@@ -39,12 +39,13 @@
#include <kdebug.h>
#include <kmimetype.h>
#include <kmessagebox.h>
-#include <k3process.h>
+#include <kshell.h>
#include <QtCore/Q_PID>
#include <kconfig.h>
#include <kapplication.h>
#include <stdlib.h>
+#include <unistd.h>
void dumpOptions(const QMap<QString,QString>&);
void initEditPrinter(KMPrinter *p)
@@ -543,7 +544,7 @@
}
QString KPrinterImpl::quote(const QString& s)
-{ return K3Process::quote(s); }
+{ return KShell::quoteArg(s); }
void KPrinterImpl::saveOptions(const QMap<QString,QString>& opts)
{
--- trunk/KDE/kdelibs/kdeprint/kxmlcommand.cpp #674058:674059
@@ -37,7 +37,7 @@
#include <kconfig.h>
#include <kdialog.h>
#include <kdebug.h>
-#include <k3process.h>
+#include <kshell.h>
#include <klibloader.h>
#include <kmessagebox.h>
@@ -396,7 +396,7 @@
}
else
{
- format.replace( re, K3Process::quote( dopt->valueText() ) );
+ format.replace( re, KShell::quoteArg( dopt->valueText() ) );
}
str.append(format).append(" ");
}
--- trunk/KDE/kdelibs/kdeprint/lpd/kmlpdmanager.cpp #674058:674059
@@ -186,11 +186,9 @@
}
// 4) change permissions of spool directory
- QByteArray cmd = "chmod -R o-rwx,g+rwX ";
- cmd += QFile::encodeName(K3Process::quote(ent->arg("sd")));
- cmd += "&& chown -R lp.lp ";
- cmd += QFile::encodeName(K3Process::quote(ent->arg("sd")));
- if (system(cmd.data()) != 0)
+ // XXX do this in-process with posix calls
+ if (KProcess::execute("chmod", QStringList() << "-R" << "o-rwx,g+rwX" << \
ent->arg("sd")) != 0 || + KProcess::execute("chown", QStringList() << "-R" << \
"lp.lp" << ent->arg("sd")) != 0) {
setErrorMsg(i18n("Unable to set correct permissions on spool directory %1 for \
printer <b>%2</b>.", ent->arg("sd"), ent->m_name)); return false;
@@ -210,9 +208,8 @@
m_entries.insert(ent->m_name,ent);
return false;
}
- QByteArray cmd = "rm -rf ";
- cmd += QFile::encodeName(K3Process::quote(ent->arg("sd")));
- system(cmd.data());
+ // XXX don't we have a library call for this?
+ KProcess::execute("rm", QStringList() << "-rf" << ent->arg("sd"));
delete ent;
return true;
}
@@ -222,19 +219,12 @@
bool KMLpdManager::enablePrinter(KMPrinter *printer, bool state)
{
- KPipeProcess proc;
- QString cmd = programName(0);
- cmd += ' ';
- cmd += state ? "up" : "down";
- cmd += ' ';
- cmd += K3Process::quote(printer->printerName());
- if (proc.open(cmd))
+ KProcess proc;
+ proc << programName(0) << (state ? "up" : "down") << printer->printerName();
+ proc.setOutputChannelMode(KProcess::OnlyStdoutChannel);
+ if (!proc.execute())
{
- QTextStream t(&proc);
- QString buffer;
- while (!t.atEnd())
- buffer.append(t.readLine());
- if (buffer.startsWith("?Privilege"))
+ if (proc.readAll().startsWith("?Privilege"))
{
setErrorMsg(i18n("Permission denied: you must be root."));
return false;
@@ -554,11 +544,7 @@
if (!writePrinters())
return false;
// write various driver files using templates
- QByteArray cmd = "cp ";
- cmd += QFile::encodeName(K3Process::quote(driverDirectory()+"/master-filter"));
- cmd += ' ';
- cmd += QFile::encodeName(K3Process::quote(spooldir + "/filter"));
- if (system(cmd.data()) == 0 &&
+ if (QFile::copy(driverDirectory()+"/master-filter", spooldir+"/filter") &&
savePrinttoolCfgFile(driverDirectory()+"/general.cfg.in",spooldir,options) &&
savePrinttoolCfgFile(driverDirectory()+"/postscript.cfg.in",spooldir,options) \
&&
savePrinttoolCfgFile(driverDirectory()+"/textonly.cfg.in",spooldir,options))
--- trunk/KDE/kdelibs/kdeprint/lpr/lpchelper.cpp #674058:674059
@@ -27,21 +27,20 @@
#include <QtCore/QRegExp>
#include <kdebug.h>
#include <klocale.h>
-#include <k3process.h>
+#include <kprocess.h>
#include <stdlib.h>
-static QString execute(const QString& cmd)
+static QString execute(const QStringList& cmd)
{
- KPipeProcess proc;
- QString output;
- if (proc.open(cmd))
+ KProcess proc;
+ proc.setProgram(cmd);
+ proc.setOutputChannelMode(KProcess::OnlyStdoutChannel);
+ if (!proc.execute())
{
QTextStream t(&proc);
- while (!t.atEnd())
- output.append(t.readLine()).append("\n");
- proc.close();
+ return t.readAll();
}
- return output;
+ return QString();
}
LpcHelper::LpcHelper(QObject *parent)
@@ -235,7 +234,7 @@
msg = i18n("The executable %1 could not be found in your PATH.", QString("lpc"));
return false;
}
- QString result = execute(m_exepath + ' ' + op + ' ' + K3Process::quote(printer));
+ QString result = execute(QStringList() << m_exepath << op << printer);
int status;
switch (LprSettings::self()->mode())
@@ -273,7 +272,7 @@
msg = i18n("The executable %1 could not be found in your PATH.", QString("lprm"));
return false;
}
- QString result = execute(m_lprmpath + " -P " + K3Process::quote(job->printer()) + ' \
' + QString::number(job->id())); + QString result = execute(QStringList() << \
m_lprmpath << "-P" << job->printer() << QString::number(job->id())); if \
(result.indexOf("dequeued") != -1) return true;
else if (result.indexOf("Permission denied") != -1 || result.indexOf("no \
permissions") != -1) @@ -291,7 +290,7 @@
msg = i18n("The executable %1 could not be found in your PATH.", QString("lpc"));
return false;
}
- QString result = execute(m_exepath + (state == KMJob::Held ? " hold " : " release \
") + K3Process::quote(job->printer()) + ' ' + QString::number(job->id())); \
+ QString result = execute(QStringList() << m_exepath << (state == KMJob::Held ? \
"hold" : "release") << job->printer() << QString::number(job->id())); QString answer \
= lprngAnswer(result, job->printer()); if (answer == "no")
{
--- trunk/KDE/kdelibs/kdeprint/lpr/lpqhelper.cpp #674058:674059
@@ -23,7 +23,7 @@
#include "lprsettings.h"
#include <kstandarddirs.h>
-#include <k3process.h>
+#include <kshell.h>
#include <kdebug.h>
#include <QtCore/QTextStream>
@@ -84,7 +84,7 @@
void LpqHelper::listJobs(QList<KMJob*>& jobs, const QString& prname, int limit)
{
KPipeProcess proc;
- if (!m_exepath.isEmpty() && proc.open(m_exepath + " -P " + \
K3Process::quote(prname))) + if (!m_exepath.isEmpty() && proc.open(m_exepath + " -P " \
+ KShell::quoteArg(prname))) {
QTextStream t(&proc);
QString line;
--- trunk/KDE/kdelibs/kdeprint/lpr/matichandler.cpp #674058:674059
@@ -33,7 +33,7 @@
#include <kstandarddirs.h>
#include <krandom.h>
#include <kdebug.h>
-#include <k3process.h>
+#include <kprocess.h>
#include <QtCore/Q_PID>
#include <QtCore/QFile>
#include <QtCore/QTextStream>
@@ -257,25 +257,11 @@
return NULL;
}
- KPipeProcess in;
- QFile out(tmpFile);
- QString cmd = K3Process::quote(exe);
- cmd += " -t lpd -d ";
- cmd += K3Process::quote(comps[2]);
- cmd += " -p ";
- cmd += K3Process::quote(comps[1]);
- if (in.open(cmd) && out.open(QIODevice::WriteOnly))
+ KProcess proc;
+ proc << exe << "-t" << "lpd" << "-d" << comps[2] << "-p" << comps[1];
+ proc.setStandardOutputFile(tmpFile);
+ if (!proc.execute())
{
- QTextStream tin(&in), tout(&out);
- QString line;
- while (!tin.atEnd())
- {
- line = tin.readLine();
- tout << line << endl;
- }
- in.close();
- out.close();
-
DrMain *driver = Foomatic2Loader::loadDriver(tmpFile);
if (driver)
{
@@ -330,10 +316,10 @@
inFile.close();
tmpFile.close();
- QString cmd = "mv " + K3Process::quote(tmpFile.fileName()) + ' ' + \
K3Process::quote(outFile);
- int status = ::system(QFile::encodeName(cmd).data());
- QFile::remove(tmpFile.fileName());
- result = (status != -1 && WEXITSTATUS(status) == 0);
+ QFile::remove(outFile);
+ result = QFile::rename(tmpFile.fileName(), outFile);
+ if (!result)
+ QFile::remove(tmpFile.fileName());
}
if (!result)
--- trunk/KDE/kdelibs/kdeprint/management/smbview.cpp #674058:674059
@@ -19,8 +19,6 @@
#include "smbview.h"
-#include <k3process.h>
-#include <ktemporaryfile.h>
#include <Qt3Support/Q3Header>
#include <QtGui/QApplication>
#include <QtCore/QTextStream>
@@ -30,6 +28,9 @@
#include <kdebug.h>
#include <kmessagebox.h>
#include <kcursor.h>
+#include <kshell.h>
+#include <k3process.h>
+#include <ktemporaryfile.h>
#include <QtCore/QFile>
#include <cstdlib>
@@ -172,15 +173,16 @@
{
if (on && item->childCount() == 0)
{
+ // XXX should use KProcessGroup once it is there
if (item->depth() == 0)
{ // opening group
m_current = item;
*m_proc << "nmblookup"+m_wins_server+"-M ";
- *m_proc << K3Process::quote(item->text(0));
+ *m_proc << KShell::quoteArg(item->text(0));
*m_proc << " -S | grep '<20>' | sed -e 's/^[[:space:]]*//' \
-e 's/[[:space:]]*<20>.*//' | xargs -iserv_name smbclient -N -L \
'serv_name' -W ";
- *m_proc << K3Process::quote(item->text(0));
+ *m_proc << KShell::quoteArg(item->text(0));
*m_proc << " -A ";
- *m_proc << K3Process::quote(m_passwdFile->fileName());
+ *m_proc << KShell::quoteArg(m_passwdFile->fileName());
startProcess(ServerListing);
}
else if (item->depth() == 1)
@@ -195,15 +197,15 @@
{
*m_proc << "smbclient -N -L ";
}
- *m_proc << K3Process::quote (item->text (0));
+ *m_proc << KShell::quoteArg(item->text (0));
*m_proc << " -W ";
- *m_proc << K3Process::quote (item->parent ()->
+ *m_proc << KShell::quoteArg(item->parent ()->
text (0));
if (!krb5ccname)
{
*m_proc << " -A ";
- *m_proc << K3Process::
- quote (m_passwdFile->fileName ());
+ *m_proc << KShell::
+ quoteArg (m_passwdFile->fileName ());
}
startProcess(ShareListing);
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic