KDECore
kprocess.h
Go to the documentation of this file.
00001 /* 00002 This file is part of the KDE libraries 00003 00004 Copyright (C) 2007 Oswald Buddenhagen <ossi@kde.org> 00005 00006 This library is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU Library General Public 00008 License as published by the Free Software Foundation; either 00009 version 2 of the License, or (at your option) any later version. 00010 00011 This library is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 Library General Public License for more details. 00015 00016 You should have received a copy of the GNU Library General Public License 00017 along with this library; see the file COPYING.LIB. If not, write to 00018 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00019 Boston, MA 02110-1301, USA. 00020 */ 00021 00022 #ifndef KPROCESS_H 00023 #define KPROCESS_H 00024 00025 #include <kdecore_export.h> 00026 00027 #include <QtCore/QProcess> 00028 00029 class KProcessPrivate; 00030 00044 class KDECORE_EXPORT KProcess : public QProcess 00045 { 00046 Q_OBJECT 00047 Q_DECLARE_PRIVATE(KProcess) 00048 00049 public: 00050 00054 enum OutputChannelMode { 00055 SeparateChannels = QProcess::SeparateChannels, 00058 MergedChannels = QProcess::MergedChannels, 00061 ForwardedChannels = QProcess::ForwardedChannels, 00064 OnlyStdoutChannel, 00066 OnlyStderrChannel 00067 }; 00068 00072 explicit KProcess(QObject *parent = 0); 00073 00077 virtual ~KProcess(); 00078 00090 void setOutputChannelMode(OutputChannelMode mode); 00091 00097 OutputChannelMode outputChannelMode() const; 00098 00108 void setNextOpenMode(QIODevice::OpenMode mode); 00109 00120 void setEnv(const QString &name, const QString &value, bool overwrite = true); 00121 00129 void unsetEnv(const QString &name); 00130 00139 void clearEnvironment(); 00140 00150 void setProgram(const QString &exe, const QStringList &args = QStringList()); 00151 00158 void setProgram(const QStringList &argv); 00159 00177 KProcess &operator<<(const QString& arg); 00178 00185 KProcess &operator<<(const QStringList& args); 00186 00190 void clearProgram(); 00191 00212 void setShellCommand(const QString &cmd); 00213 00220 QStringList program() const; 00221 00227 void start(); 00228 00246 int execute(int msecs = -1); 00247 00258 static int execute(const QString &exe, const QStringList &args = QStringList(), int msecs = -1); 00259 00269 static int execute(const QStringList &argv, int msecs = -1); 00270 00285 int startDetached(); 00286 00295 static int startDetached(const QString &exe, const QStringList &args = QStringList()); 00296 00304 static int startDetached(const QStringList &argv); 00305 00316 int pid() const; 00317 00318 protected: 00322 KProcess(KProcessPrivate *d, QObject *parent); 00323 00327 KProcessPrivate * const d_ptr; 00328 00329 private: 00330 // hide those 00331 using QProcess::setReadChannelMode; 00332 using QProcess::readChannelMode; 00333 using QProcess::setProcessChannelMode; 00334 using QProcess::processChannelMode; 00335 00336 Q_PRIVATE_SLOT(d_func(), void _k_forwardStdout()) 00337 Q_PRIVATE_SLOT(d_func(), void _k_forwardStderr()) 00338 }; 00339 00340 #endif 00341
KDE 4.6 API Reference