From bdb1b502083e00fe5929f9ca4204bfaa87f15263 Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Sun, 1 Dec 2024 22:25:19 +0900 Subject: Rename kprocess.{h,cpp} to tdeprocess.{h.cpp}. Add temporary kprocess.h to keep things building. Signed-off-by: Michele Calgaro --- tdecore/tests/CMakeLists.txt | 2 +- tdecore/tests/Makefile.am | 6 +- tdecore/tests/kprocesstest.cpp | 116 --------------------------------------- tdecore/tests/kprocesstest.h | 50 ----------------- tdecore/tests/kprociotest.cpp | 2 +- tdecore/tests/tdeprocesstest.cpp | 116 +++++++++++++++++++++++++++++++++++++++ tdecore/tests/tdeprocesstest.h | 48 ++++++++++++++++ 7 files changed, 169 insertions(+), 171 deletions(-) delete mode 100644 tdecore/tests/kprocesstest.cpp delete mode 100644 tdecore/tests/kprocesstest.h create mode 100644 tdecore/tests/tdeprocesstest.cpp create mode 100644 tdecore/tests/tdeprocesstest.h (limited to 'tdecore/tests') diff --git a/tdecore/tests/CMakeLists.txt b/tdecore/tests/CMakeLists.txt index f3e0aae45..fa14f6357 100644 --- a/tdecore/tests/CMakeLists.txt +++ b/tdecore/tests/CMakeLists.txt @@ -31,7 +31,7 @@ tde_add_library( tdeconfigtest SHARED AUTOMOC ) set( CHECKS - tdeconfigtestgui klocaletest kprocesstest ksimpleconfigtest kstddirstest + tdeconfigtestgui klocaletest tdeprocesstest ksimpleconfigtest kstddirstest tdeuniqueapptest ktempfiletest krandomsequencetest kdebugtest ksocktest kstringhandlertest kcmdlineargstest kapptest kmemtest dcopkonqtest kipctest cplusplustest kiconloadertest kresolvertest diff --git a/tdecore/tests/Makefile.am b/tdecore/tests/Makefile.am index 9398716eb..19787c4df 100644 --- a/tdecore/tests/Makefile.am +++ b/tdecore/tests/Makefile.am @@ -21,7 +21,7 @@ INCLUDES = -I$(top_srcdir)/tdecore $(all_includes) AM_LDFLAGS = $(QT_LDFLAGS) $(X_LDFLAGS) $(KDE_RPATH) -check_PROGRAMS = tdeconfigtestgui klocaletest kprocesstest ksimpleconfigtest \ +check_PROGRAMS = tdeconfigtestgui klocaletest tdeprocesstest ksimpleconfigtest \ kstddirstest kurltest tdeuniqueapptest ktempfiletest krandomsequencetest \ kdebugtest ksocktest kstringhandlertest kcmdlineargstest kapptest \ kmemtest kidlservertest kidlclienttest dcopkonqtest kipctest \ @@ -32,7 +32,7 @@ check_PROGRAMS = tdeconfigtestgui klocaletest kprocesstest ksimpleconfigtest \ TESTS = kurltest tdestdacceltest -noinst_HEADERS = klocaletest.h kprocesstest.h KIDLTest.h \ +noinst_HEADERS = klocaletest.h tdeprocesstest.h KIDLTest.h \ kipctest.h kprociotest.h METASOURCES = AUTO @@ -46,7 +46,7 @@ klocaletest_SOURCES = klocaletest.cpp ksimpleconfigtest_SOURCES = ksimpleconfigtest.cpp kurltest_SOURCES = kurltest.cpp kstddirstest_SOURCES = kstddirstest.cpp -kprocesstest_SOURCES = kprocesstest.cpp +tdeprocesstest_SOURCES = tdeprocesstest.cpp tdeuniqueapptest_SOURCES = tdeuniqueapptest.cpp kapptest_SOURCES = kapptest.cpp ksocktest_SOURCES = ksocktest.cpp diff --git a/tdecore/tests/kprocesstest.cpp b/tdecore/tests/kprocesstest.cpp deleted file mode 100644 index b7908ec6e..000000000 --- a/tdecore/tests/kprocesstest.cpp +++ /dev/null @@ -1,116 +0,0 @@ -// -// MAIN -- a little demo of the capabilities of the "TDEProcess" class -// -// version 0.2, Aug 2nd 1997 -// $Id$ -// -// (C) Christian Czezatke -// e9025461@student.tuwien.ac.at -// - - -#include "kprocess.h" - -#include -#include -#include - -#include - -#include "kprocesstest.h" - -#define PROCNO 10 - - -// -// A nice input for "sort"... ;- ) -// -static const char txt[] = "hat\nder\nalte\nhexenmeister\nsich\ndoch\neinmal\nwegbegeben\n\ -und\nnun\nsollen\nseine\ngeister\nsich\nnach\nmeinem\nwillen\nregen\nseine\nwort\nund\n\ -werke\nmerkt\nich\nund\nden\nbrauch\nund\nmit\ngeistesstaerke\ntu\nich\nwunder\nauch\n"; - - -int main(int argc, char *argv[]) -{ - TDEProcess p1, p2, p3, p4; - Dummy dummy; - TDEApplication app(argc, argv, TQCString("kprocesstest")); - - - printf("Welcome to the TDEProcess Demo Application!\n"); - - // - // The kghostview demo -- Starts a kghostview instance blocking. -- After - // kghostview has exited, kghostview is restarted non-blocking. When the process exits, - // the signal "processExited" will be emitted. - // - - p1 << "kghostview"; - TQObject::connect(&p1, TQ_SIGNAL(processExited(TDEProcess *)), &dummy, TQ_SLOT(printMessage(TDEProcess *))); - - printf("starting kghostview blocking (close to continue)\n"); - p1.start(TDEProcess::Block); - printf("restarting kghostview non blocking\n"); - p1.start(); - - - // - // A konsole with tcsh to demonstrate how to pass command line options to a process - // with "TDEProcess" (is run blocking) - // - - printf("Starting konsole with /bin/tcsh as shell (close to continue)\n"); - p2 << "konsole" << "-e" << "/bin/tcsh"; - p2.setWorkingDirectory("/tmp"); - TQObject::connect(&p2, TQ_SIGNAL(processExited(TDEProcess *)), &dummy, TQ_SLOT(printMessage(TDEProcess *))); - p2.start(TDEProcess::Block); - - // - // Getting the output from a process. "ls" with parameter "-l" is called and it output is captured - // - - p3 << "ls" << "-l"; - TQObject::connect(&p3, TQ_SIGNAL(processExited(TDEProcess *)), - &dummy, TQ_SLOT(printMessage(TDEProcess *))); - - TQObject::connect(&p3, TQ_SIGNAL(receivedStdout(TDEProcess *, char *, int)), - &dummy, TQ_SLOT(gotOutput(TDEProcess *, char *, int))); - TQObject::connect(&p3, TQ_SIGNAL(receivedStderr(TDEProcess *, char *, int)), - &dummy, TQ_SLOT(gotOutput(TDEProcess *, char *, int))); - - p3.start(TDEProcess::NotifyOnExit, TDEProcess::AllOutput); - - - // - // An even more advanced example of communicating with a child proces. -- A "sort" command - // is started. After it has been started a list of words (as stored in "txt") is written - // to its stdin. When the sort command has absorbed all its input it will emit the signal - // "inputSent". -- This signal is connected to "outputDone" in the Dummy object. - // - // "OutputDone" will do a "sendEof" to p4. -- This will cause "sort" to perform its task. - // The output of sort is then captured once more by connecting to the signal "outputWaiting" - // - // - - p4 << "sort"; - TQObject::connect(&p4, TQ_SIGNAL(processExited(TDEProcess *)), - &dummy, TQ_SLOT(printMessage(TDEProcess *))); - - TQObject::connect(&p4, TQ_SIGNAL(receivedStdout(TDEProcess *, char *, int)), - &dummy, TQ_SLOT(gotOutput(TDEProcess *, char *, int))); - TQObject::connect(&p4, TQ_SIGNAL(receivedStderr(TDEProcess *, char *, int)), - &dummy, TQ_SLOT(gotOutput(TDEProcess *, char *, int))); - - TQObject::connect(&p4, TQ_SIGNAL(wroteStdin(TDEProcess *)), - &dummy, TQ_SLOT(outputDone(TDEProcess *))); - - p4.start(TDEProcess::NotifyOnExit, TDEProcess::All); - printf("after p4.start"); - p4.writeStdin(txt, strlen(txt)); - - printf("Entering man Qt event loop -- press to abort\n"); - app.exec(); - - return 0; -} -#include "kprocesstest.moc" diff --git a/tdecore/tests/kprocesstest.h b/tdecore/tests/kprocesstest.h deleted file mode 100644 index 4bd4ab71e..000000000 --- a/tdecore/tests/kprocesstest.h +++ /dev/null @@ -1,50 +0,0 @@ -// -// DUMMY -- A dummy class with a slot to demonstrate TDEProcess signals -// -// version 0.2, Aug 2nd 1997 -// -// (C) Christian Czezatke -// e9025461@student.tuwien.ac.at -// - - -#ifndef __DUMMY_H__ -#define __DUMMY_H__ - -#include -#include -#include "kprocess.h" - -class Dummy : public TQObject -{ - TQ_OBJECT - - public slots: - void printMessage(TDEProcess *proc) - { - printf("Process %d exited!\n", (int)proc->getPid()); - } - - void gotOutput(TDEProcess*, char *buffer, int len) - { - char result[1025]; // this is ugly since it relys on the internal buffer size of TDEProcess, - memcpy(result, buffer, len); // NEVER do that in your own application... ;-) - result[len] = '\0'; - printf("OUTPUT>>%s", result); - } - - void outputDone(TDEProcess *proc) - /* - Slot Procedure for the "sort" example. -- If it is indicated that the "sort" command has - absorbed all its input, we send an "EOF" to it to indicate that there is no more - data to be processed. - */ - { - proc->closeStdin(); - } - -}; - -#endif - - diff --git a/tdecore/tests/kprociotest.cpp b/tdecore/tests/kprociotest.cpp index e7165092c..81522f394 100644 --- a/tdecore/tests/kprociotest.cpp +++ b/tdecore/tests/kprociotest.cpp @@ -9,7 +9,7 @@ // -#include "kprocess.h" +#include "tdeprocess.h" #include #include diff --git a/tdecore/tests/tdeprocesstest.cpp b/tdecore/tests/tdeprocesstest.cpp new file mode 100644 index 000000000..0d27f69fa --- /dev/null +++ b/tdecore/tests/tdeprocesstest.cpp @@ -0,0 +1,116 @@ +// +// MAIN -- a little demo of the capabilities of the "TDEProcess" class +// +// version 0.2, Aug 2nd 1997 +// $Id$ +// +// (C) Christian Czezatke +// e9025461@student.tuwien.ac.at +// + + +#include "tdeprocess.h" + +#include +#include +#include + +#include + +#include "tdeprocesstest.h" + +#define PROCNO 10 + + +// +// A nice input for "sort"... ;- ) +// +static const char txt[] = "hat\nder\nalte\nhexenmeister\nsich\ndoch\neinmal\nwegbegeben\n\ +und\nnun\nsollen\nseine\ngeister\nsich\nnach\nmeinem\nwillen\nregen\nseine\nwort\nund\n\ +werke\nmerkt\nich\nund\nden\nbrauch\nund\nmit\ngeistesstaerke\ntu\nich\nwunder\nauch\n"; + + +int main(int argc, char *argv[]) +{ + TDEProcess p1, p2, p3, p4; + Dummy dummy; + TDEApplication app(argc, argv, TQCString("tdeprocesstest")); + + + printf("Welcome to the TDEProcess Demo Application!\n"); + + // + // The kghostview demo -- Starts a kghostview instance blocking. -- After + // kghostview has exited, kghostview is restarted non-blocking. When the process exits, + // the signal "processExited" will be emitted. + // + + p1 << "kghostview"; + TQObject::connect(&p1, TQ_SIGNAL(processExited(TDEProcess *)), &dummy, TQ_SLOT(printMessage(TDEProcess *))); + + printf("starting kghostview blocking (close to continue)\n"); + p1.start(TDEProcess::Block); + printf("restarting kghostview non blocking\n"); + p1.start(); + + + // + // A konsole with tcsh to demonstrate how to pass command line options to a process + // with "TDEProcess" (is run blocking) + // + + printf("Starting konsole with /bin/tcsh as shell (close to continue)\n"); + p2 << "konsole" << "-e" << "/bin/tcsh"; + p2.setWorkingDirectory("/tmp"); + TQObject::connect(&p2, TQ_SIGNAL(processExited(TDEProcess *)), &dummy, TQ_SLOT(printMessage(TDEProcess *))); + p2.start(TDEProcess::Block); + + // + // Getting the output from a process. "ls" with parameter "-l" is called and it output is captured + // + + p3 << "ls" << "-l"; + TQObject::connect(&p3, TQ_SIGNAL(processExited(TDEProcess *)), + &dummy, TQ_SLOT(printMessage(TDEProcess *))); + + TQObject::connect(&p3, TQ_SIGNAL(receivedStdout(TDEProcess *, char *, int)), + &dummy, TQ_SLOT(gotOutput(TDEProcess *, char *, int))); + TQObject::connect(&p3, TQ_SIGNAL(receivedStderr(TDEProcess *, char *, int)), + &dummy, TQ_SLOT(gotOutput(TDEProcess *, char *, int))); + + p3.start(TDEProcess::NotifyOnExit, TDEProcess::AllOutput); + + + // + // An even more advanced example of communicating with a child proces. -- A "sort" command + // is started. After it has been started a list of words (as stored in "txt") is written + // to its stdin. When the sort command has absorbed all its input it will emit the signal + // "inputSent". -- This signal is connected to "outputDone" in the Dummy object. + // + // "OutputDone" will do a "sendEof" to p4. -- This will cause "sort" to perform its task. + // The output of sort is then captured once more by connecting to the signal "outputWaiting" + // + // + + p4 << "sort"; + TQObject::connect(&p4, TQ_SIGNAL(processExited(TDEProcess *)), + &dummy, TQ_SLOT(printMessage(TDEProcess *))); + + TQObject::connect(&p4, TQ_SIGNAL(receivedStdout(TDEProcess *, char *, int)), + &dummy, TQ_SLOT(gotOutput(TDEProcess *, char *, int))); + TQObject::connect(&p4, TQ_SIGNAL(receivedStderr(TDEProcess *, char *, int)), + &dummy, TQ_SLOT(gotOutput(TDEProcess *, char *, int))); + + TQObject::connect(&p4, TQ_SIGNAL(wroteStdin(TDEProcess *)), + &dummy, TQ_SLOT(outputDone(TDEProcess *))); + + p4.start(TDEProcess::NotifyOnExit, TDEProcess::All); + printf("after p4.start"); + p4.writeStdin(txt, strlen(txt)); + + printf("Entering man Qt event loop -- press to abort\n"); + app.exec(); + + return 0; +} +#include "tdeprocesstest.moc" diff --git a/tdecore/tests/tdeprocesstest.h b/tdecore/tests/tdeprocesstest.h new file mode 100644 index 000000000..32a559157 --- /dev/null +++ b/tdecore/tests/tdeprocesstest.h @@ -0,0 +1,48 @@ +// +// DUMMY -- A dummy class with a slot to demonstrate TDEProcess signals +// +// version 0.2, Aug 2nd 1997 +// +// (C) Christian Czezatke +// e9025461@student.tuwien.ac.at +// + + +#ifndef __DUMMY_H__ +#define __DUMMY_H__ + +#include +#include +#include "tdeprocess.h" + +class Dummy : public TQObject +{ + TQ_OBJECT + + public slots: + void printMessage(TDEProcess *proc) + { + printf("Process %d exited!\n", (int)proc->getPid()); + } + + void gotOutput(TDEProcess*, char *buffer, int len) + { + char result[1025]; // this is ugly since it relys on the internal buffer size of TDEProcess, + memcpy(result, buffer, len); // NEVER do that in your own application... ;-) + result[len] = '\0'; + printf("OUTPUT>>%s", result); + } + + void outputDone(TDEProcess *proc) + /* + Slot Procedure for the "sort" example. -- If it is indicated that the "sort" command has + absorbed all its input, we send an "EOF" to it to indicate that there is no more + data to be processed. + */ + { + proc->closeStdin(); + } + +}; + +#endif -- cgit v1.2.1