summaryrefslogtreecommitdiffstats
path: root/src/common/nokde/nokde_kprocess.cpp
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-02-24 18:42:24 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-02-24 18:42:24 +0000
commitf508189682b6fba62e08feeb1596f682bad5fff9 (patch)
tree28aeb0e6c19386c385c1ce5edf8a92c1bca15281 /src/common/nokde/nokde_kprocess.cpp
downloadpiklab-f508189682b6fba62e08feeb1596f682bad5fff9.tar.gz
piklab-f508189682b6fba62e08feeb1596f682bad5fff9.zip
Added KDE3 version of PikLab
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/piklab@1095639 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'src/common/nokde/nokde_kprocess.cpp')
-rw-r--r--src/common/nokde/nokde_kprocess.cpp100
1 files changed, 100 insertions, 0 deletions
diff --git a/src/common/nokde/nokde_kprocess.cpp b/src/common/nokde/nokde_kprocess.cpp
new file mode 100644
index 0000000..92c8968
--- /dev/null
+++ b/src/common/nokde/nokde_kprocess.cpp
@@ -0,0 +1,100 @@
+#include "nokde_kprocess.h"
+
+#if QT_VERSION<0x040000
+# include <qprocess.h>
+# define Q3Process QProcess
+#else
+# include <Qt3Support/Q3Process>
+#endif
+
+#if defined(Q_OS_UNIX)
+# include <signal.h>
+#endif
+
+KProcess::KProcess(QObject *parent, const char *name)
+ : QObject(parent, name)
+{
+ _process = new Q3Process(this);
+ connect(_process, SIGNAL(processExited()), SLOT(processExitedSlot()));
+ connect(_process, SIGNAL(readyReadStdout()), SLOT(readyReadStdoutSlot()));
+ connect(_process, SIGNAL(readyReadStderr()), SLOT(readyReadStderrSlot()));
+}
+
+bool KProcess::start()
+{
+ _process->setArguments(_arguments);
+ QStringList env;
+ if ( !_environment.isEmpty() ) {
+ for (uint i=0; environ[i]; i++) env += environ[i];
+ env += _environment;
+ }
+ return _process->start(env.isEmpty() ? 0 : &env);
+}
+
+void KProcess::processExitedSlot()
+{
+ readyReadStdoutSlot();
+ readyReadStderrSlot();
+ emit processExited(this);
+}
+
+void KProcess::readyReadStdoutSlot()
+{
+ QByteArray a = _process->readStdout();
+ emit receivedStdout(this, a.data(), a.count());
+}
+
+void KProcess::readyReadStderrSlot()
+{
+ QByteArray a = _process->readStderr();
+ emit receivedStderr(this, a.data(), a.count());
+}
+
+bool KProcess::writeStdin(const char *buffer, int len)
+{
+#if QT_VERSION<0x040000
+ QByteArray a;
+ a.assign(buffer, len);
+#else
+ QByteArray a(buffer, len);
+#endif
+ _process->writeToStdin(a);
+ return true;
+}
+
+bool KProcess::kill()
+{
+ _process->kill();
+ return true;
+}
+
+bool KProcess::kill(int n)
+{
+#if defined(Q_OS_UNIX)
+ return ( ::kill(_process->processIdentifier(), n)!=-1 );
+#elif defined(Q_OS_WIN)
+ // #### impossible to do ??
+ return false;
+#endif
+}
+
+int KProcess::exitStatus() const
+{
+ return _process->exitStatus();
+}
+
+bool KProcess::isRunning() const
+{
+ return _process->isRunning();
+}
+
+void KProcess::setWorkingDirectory(const QDir &dir)
+{
+ return _process->setWorkingDirectory(dir);
+}
+
+void KProcess::setUseShell(bool useShell)
+{
+ // ### TODO: just issue "/bin/sh" "-c" "command"
+ Q_ASSERT(false);
+}