diff --git a/lib/Pty.cpp b/lib/Pty.cpp index 821517a3..60ccb782 100644 --- a/lib/Pty.cpp +++ b/lib/Pty.cpp @@ -211,7 +211,7 @@ int Pty::start(const QString& program, pty()->setWinSize(_windowLines, _windowColumns); - KProcess::start(); + KTermProcess::start(); if (!waitForStarted()) return -1; diff --git a/lib/Session.cpp b/lib/Session.cpp index bf255ee3..72b351b3 100644 --- a/lib/Session.cpp +++ b/lib/Session.cpp @@ -118,7 +118,6 @@ Session::Session(QObject* parent) : connect( _emulation,SIGNAL(useUtf8Request(bool)),_shellProcess,SLOT(setUtf8Mode(bool)) ); connect( _shellProcess,SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(done(int)) ); - // not in kprocess anymore connect( _shellProcess,SIGNAL(done(int)), this, SLOT(done(int)) ); //setup timer for monitoring session activity _monitorTimer = new QTimer(this); @@ -790,123 +789,12 @@ void Session::setFlowControlEnabled(bool enabled) emit flowControlEnabledChanged(enabled); } + bool Session::flowControlEnabled() const { return _flowControl; } -//void Session::fireZModemDetected() -//{ -// if (!_zmodemBusy) -// { -// QTimer::singleShot(10, this, SIGNAL(zmodemDetected())); -// _zmodemBusy = true; -// } -//} - -//void Session::cancelZModem() -//{ -// _shellProcess->sendData("\030\030\030\030", 4); // Abort -// _zmodemBusy = false; -//} - -//void Session::startZModem(const QString &zmodem, const QString &dir, const QStringList &list) -//{ -// _zmodemBusy = true; -// _zmodemProc = new KProcess(); -// _zmodemProc->setOutputChannelMode( KProcess::SeparateChannels ); -// -// *_zmodemProc << zmodem << "-v" << list; -// -// if (!dir.isEmpty()) -// _zmodemProc->setWorkingDirectory(dir); -// -// _zmodemProc->start(); -// -// connect(_zmodemProc,SIGNAL (readyReadStandardOutput()), -// this, SLOT(zmodemReadAndSendBlock())); -// connect(_zmodemProc,SIGNAL (readyReadStandardError()), -// this, SLOT(zmodemReadStatus())); -// connect(_zmodemProc,SIGNAL (finished(int,QProcess::ExitStatus)), -// this, SLOT(zmodemFinished())); -// -// disconnect( _shellProcess,SIGNAL(block_in(const char*,int)), this, SLOT(onReceiveBlock(const char*,int)) ); -// connect( _shellProcess,SIGNAL(block_in(const char*,int)), this, SLOT(zmodemRcvBlock(const char*,int)) ); -// -// _zmodemProgress = new ZModemDialog(QApplication::activeWindow(), false, -// i18n("ZModem Progress")); -// -// connect(_zmodemProgress, SIGNAL(user1Clicked()), -// this, SLOT(zmodemDone())); -// -// _zmodemProgress->show(); -//} - -/*void Session::zmodemReadAndSendBlock() -{ - _zmodemProc->setReadChannel( QProcess::StandardOutput ); - QByteArray data = _zmodemProc->readAll(); - - if ( data.count() == 0 ) - return; - - _shellProcess->sendData(data.constData(),data.count()); -} -*/ -/* -void Session::zmodemReadStatus() -{ - _zmodemProc->setReadChannel( QProcess::StandardError ); - QByteArray msg = _zmodemProc->readAll(); - while(!msg.isEmpty()) - { - int i = msg.indexOf('\015'); - int j = msg.indexOf('\012'); - QByteArray txt; - if ((i != -1) && ((j == -1) || (i < j))) - { - msg = msg.mid(i+1); - } - else if (j != -1) - { - txt = msg.left(j); - msg = msg.mid(j+1); - } - else - { - txt = msg; - msg.truncate(0); - } - if (!txt.isEmpty()) - _zmodemProgress->addProgressText(QString::fromLocal8Bit(txt)); - } -} -*/ -/* -void Session::zmodemRcvBlock(const char *data, int len) -{ - QByteArray ba( data, len ); - _zmodemProc->write( ba ); -} -*/ -/* -void Session::zmodemFinished() -{ - if (_zmodemProc) - { - delete _zmodemProc; - _zmodemProc = 0; - _zmodemBusy = false; - - disconnect( _shellProcess,SIGNAL(block_in(const char*,int)), this ,SLOT(zmodemRcvBlock(const char*,int)) ); - connect( _shellProcess,SIGNAL(block_in(const char*,int)), this, SLOT(onReceiveBlock(const char*,int)) ); - - _shellProcess->sendData("\030\030\030\030", 4); // Abort - _shellProcess->sendData("\001\013\n", 3); // Try to get prompt back - _zmodemProgress->transferDone(); - } -} -*/ void Session::onReceiveBlock( const char * buf, int len ) { _emulation->receiveData( buf, len ); diff --git a/lib/Session.h b/lib/Session.h index 79f2f941..62f479ae 100644 --- a/lib/Session.h +++ b/lib/Session.h @@ -32,7 +32,6 @@ #include "History.h" #include "ProcessInfo.h" -class KProcess; namespace Konsole { @@ -565,11 +564,6 @@ private slots: QString _initialWorkingDir; - // ZModem -// bool _zmodemBusy; -// KProcess* _zmodemProc; -// ZModemDialog* _zmodemProgress; - // Color/Font Changes by ESC Sequences QColor _modifiedBackground; // as set by: echo -en '\033]11;Color\007 diff --git a/lib/kprocess.cpp b/lib/kprocess.cpp index 904e1bbf..83614204 100644 --- a/lib/kprocess.cpp +++ b/lib/kprocess.cpp @@ -47,7 +47,7 @@ #include #endif -void KProcessPrivate::writeAll(const QByteArray &buf, int fd) +void KTermProcessPrivate::writeAll(const QByteArray &buf, int fd) { #ifdef Q_OS_WIN #ifndef _WIN32_WCE @@ -73,9 +73,9 @@ void KProcessPrivate::writeAll(const QByteArray &buf, int fd) #endif } -void KProcessPrivate::forwardStd(KProcess::ProcessChannel good, int fd) +void KTermProcessPrivate::forwardStd(KTermProcess::ProcessChannel good, int fd) { - Q_Q(KProcess); + Q_Q(KTermProcess); QProcess::ProcessChannel oc = q->readChannel(); q->setReadChannel(good); @@ -83,21 +83,21 @@ void KProcessPrivate::forwardStd(KProcess::ProcessChannel good, int fd) q->setReadChannel(oc); } -void KProcessPrivate::_k_forwardStdout() +void KTermProcessPrivate::_k_forwardStdout() { #ifndef _WIN32_WCE - forwardStd(KProcess::StandardOutput, STD_OUTPUT_HANDLE); + forwardStd(KTermProcess::StandardOutput, STD_OUTPUT_HANDLE); #else - forwardStd(KProcess::StandardOutput, (int)stdout); + forwardStd(KTermProcess::StandardOutput, (int)stdout); #endif } -void KProcessPrivate::_k_forwardStderr() +void KTermProcessPrivate::_k_forwardStderr() { #ifndef _WIN32_WCE - forwardStd(KProcess::StandardError, STD_ERROR_HANDLE); + forwardStd(KTermProcess::StandardError, STD_ERROR_HANDLE); #else - forwardStd(KProcess::StandardError, (int)stderr); + forwardStd(KTermProcess::StandardError, (int)stderr); #endif } @@ -105,15 +105,15 @@ void KProcessPrivate::_k_forwardStderr() // public member functions // ///////////////////////////// -KProcess::KProcess(QObject *parent) : +KTermProcess::KTermProcess(QObject *parent) : QProcess(parent), - d_ptr(new KProcessPrivate) + d_ptr(new KTermProcessPrivate) { d_ptr->q_ptr = this; setOutputChannelMode(ForwardedChannels); } -KProcess::KProcess(KProcessPrivate *d, QObject *parent) : +KTermProcess::KTermProcess(KTermProcessPrivate *d, QObject *parent) : QProcess(parent), d_ptr(d) { @@ -121,14 +121,14 @@ KProcess::KProcess(KProcessPrivate *d, QObject *parent) : setOutputChannelMode(ForwardedChannels); } -KProcess::~KProcess() +KTermProcess::~KTermProcess() { delete d_ptr; } -void KProcess::setOutputChannelMode(OutputChannelMode mode) +void KTermProcess::setOutputChannelMode(OutputChannelMode mode) { - Q_D(KProcess); + Q_D(KTermProcess); d->outputChannelMode = mode; disconnect(this, SIGNAL(readyReadStandardOutput())); @@ -147,28 +147,28 @@ void KProcess::setOutputChannelMode(OutputChannelMode mode) QProcess::setProcessChannelMode(QProcess::SeparateChannels); } -KProcess::OutputChannelMode KProcess::outputChannelMode() const +KTermProcess::OutputChannelMode KTermProcess::outputChannelMode() const { - Q_D(const KProcess); + Q_D(const KTermProcess); return d->outputChannelMode; } -void KProcess::setNextOpenMode(QIODevice::OpenMode mode) +void KTermProcess::setNextOpenMode(QIODevice::OpenMode mode) { - Q_D(KProcess); + Q_D(KTermProcess); d->openMode = mode; } #define DUMMYENV "_KPROCESS_DUMMY_=" -void KProcess::clearEnvironment() +void KTermProcess::clearEnvironment() { setEnvironment(QStringList() << QString::fromLatin1(DUMMYENV)); } -void KProcess::setEnv(const QString &name, const QString &value, bool overwrite) +void KTermProcess::setEnv(const QString &name, const QString &value, bool overwrite) { QStringList env = environment(); if (env.isEmpty()) { @@ -189,7 +189,7 @@ void KProcess::setEnv(const QString &name, const QString &value, bool overwrite) setEnvironment(env); } -void KProcess::unsetEnv(const QString &name) +void KTermProcess::unsetEnv(const QString &name) { QStringList env = environment(); if (env.isEmpty()) { @@ -208,9 +208,9 @@ void KProcess::unsetEnv(const QString &name) } } -void KProcess::setProgram(const QString &exe, const QStringList &args) +void KTermProcess::setProgram(const QString &exe, const QStringList &args) { - Q_D(KProcess); + Q_D(KTermProcess); d->prog = exe; d->args = args; @@ -219,9 +219,9 @@ void KProcess::setProgram(const QString &exe, const QStringList &args) #endif } -void KProcess::setProgram(const QStringList &argv) +void KTermProcess::setProgram(const QStringList &argv) { - Q_D(KProcess); + Q_D(KTermProcess); Q_ASSERT( !argv.isEmpty() ); d->args = argv; @@ -231,9 +231,9 @@ void KProcess::setProgram(const QStringList &argv) #endif } -KProcess &KProcess::operator<<(const QString &arg) +KTermProcess &KTermProcess::operator<<(const QString &arg) { - Q_D(KProcess); + Q_D(KTermProcess); if (d->prog.isEmpty()) d->prog = arg; @@ -242,9 +242,9 @@ KProcess &KProcess::operator<<(const QString &arg) return *this; } -KProcess &KProcess::operator<<(const QStringList &args) +KTermProcess &KTermProcess::operator<<(const QStringList &args) { - Q_D(KProcess); + Q_D(KTermProcess); if (d->prog.isEmpty()) setProgram(args); @@ -253,9 +253,9 @@ KProcess &KProcess::operator<<(const QStringList &args) return *this; } -void KProcess::clearProgram() +void KTermProcess::clearProgram() { - Q_D(KProcess); + Q_D(KTermProcess); d->prog.clear(); d->args.clear(); @@ -265,9 +265,9 @@ void KProcess::clearProgram() } #if 0 -void KProcess::setShellCommand(const QString &cmd) +void KTermProcess::setShellCommand(const QString &cmd) { - Q_D(KProcess); + Q_D(KTermProcess); KShell::Errors err; d->args = KShell::splitArgs( @@ -331,23 +331,23 @@ void KProcess::setShellCommand(const QString &cmd) #endif } #endif -QStringList KProcess::program() const +QStringList KTermProcess::program() const { - Q_D(const KProcess); + Q_D(const KTermProcess); QStringList argv = d->args; argv.prepend(d->prog); return argv; } -void KProcess::start() +void KTermProcess::start() { - Q_D(KProcess); + Q_D(KTermProcess); QProcess::start(d->prog, d->args, d->openMode); } -int KProcess::execute(int msecs) +int KTermProcess::execute(int msecs) { start(); if (!waitForFinished(msecs)) { @@ -359,24 +359,24 @@ int KProcess::execute(int msecs) } // static -int KProcess::execute(const QString &exe, const QStringList &args, int msecs) +int KTermProcess::execute(const QString &exe, const QStringList &args, int msecs) { - KProcess p; + KTermProcess p; p.setProgram(exe, args); return p.execute(msecs); } // static -int KProcess::execute(const QStringList &argv, int msecs) +int KTermProcess::execute(const QStringList &argv, int msecs) { - KProcess p; + KTermProcess p; p.setProgram(argv); return p.execute(msecs); } -int KProcess::startDetached() +int KTermProcess::startDetached() { - Q_D(KProcess); + Q_D(KTermProcess); qint64 pid; if (!QProcess::startDetached(d->prog, d->args, workingDirectory(), &pid)) @@ -385,7 +385,7 @@ int KProcess::startDetached() } // static -int KProcess::startDetached(const QString &exe, const QStringList &args) +int KTermProcess::startDetached(const QString &exe, const QStringList &args) { qint64 pid; if (!QProcess::startDetached(exe, args, QString(), &pid)) @@ -394,7 +394,7 @@ int KProcess::startDetached(const QString &exe, const QStringList &args) } // static -int KProcess::startDetached(const QStringList &argv) +int KTermProcess::startDetached(const QStringList &argv) { QStringList args = argv; QString prog = args.takeFirst(); diff --git a/lib/kprocess.h b/lib/kprocess.h index ad2f05ec..20e4d035 100644 --- a/lib/kprocess.h +++ b/lib/kprocess.h @@ -30,14 +30,12 @@ #ifndef KPROCESS_H #define KPROCESS_H -//#include - #include -class KProcessPrivate; +class KTermProcessPrivate; /** - * \class KProcess kprocess.h + * \class KTermProcess KTermProcess.h * * Child process invocation, monitoring and control. * @@ -49,10 +47,10 @@ class KProcessPrivate; * * @author Oswald Buddenhagen **/ -class KProcess : public QProcess +class KTermProcess : public QProcess { Q_OBJECT - Q_DECLARE_PRIVATE(KProcess) + Q_DECLARE_PRIVATE(KTermProcess) public: @@ -61,10 +59,10 @@ class KProcess : public QProcess */ enum OutputChannelMode { SeparateChannels = QProcess::SeparateChannels, - /**< Standard output and standard error are handled by KProcess + /**< Standard output and standard error are handled by KTermProcess as separate channels */ MergedChannels = QProcess::MergedChannels, - /**< Standard output and standard error are handled by KProcess + /**< Standard output and standard error are handled by KTermProcess as one channel */ ForwardedChannels = QProcess::ForwardedChannels, /**< Both standard output and standard error are forwarded @@ -77,12 +75,12 @@ class KProcess : public QProcess /** * Constructor */ - explicit KProcess(QObject *parent = nullptr); + explicit KTermProcess(QObject *parent = nullptr); /** * Destructor */ - ~KProcess() override; + ~KTermProcess() override; /** * Set how to handle the output channels of the child process. @@ -172,7 +170,7 @@ class KProcess : public QProcess * * For example, doing an "ls -l /usr/local/bin" can be achieved by: * \code - * KProcess p; + * KTermProcess p; * p << "ls" << "-l" << "/usr/local/bin"; * ... * \endcode @@ -180,17 +178,17 @@ class KProcess : public QProcess * This function must be called before starting the process, obviously. * * @param arg the argument to add - * @return a reference to this KProcess + * @return a reference to this KTermProcess */ - KProcess &operator<<(const QString& arg); + KTermProcess &operator<<(const QString& arg); /** * @overload * * @param args the arguments to add - * @return a reference to this KProcess + * @return a reference to this KTermProcess */ - KProcess &operator<<(const QStringList& args); + KTermProcess &operator<<(const QStringList& args); /** * Clear the program and command line argument list. @@ -206,7 +204,7 @@ class KProcess : public QProcess * Redirections including pipes, etc. are better handled by the * respective functions provided by QProcess. * - * If KProcess determines that the command does not really need a + * If KTermProcess determines that the command does not really need a * shell, it will trasparently execute it without one for performance * reasons. * @@ -285,7 +283,7 @@ class KProcess : public QProcess * @note Currently, only the setProgram()/setShellCommand() and * setWorkingDirectory() parametrizations are supported. * - * The KProcess object may be re-used immediately after calling this + * The KTermProcess object may be re-used immediately after calling this * function. * * @return the PID of the started process or 0 on error @@ -315,12 +313,12 @@ class KProcess : public QProcess /** * @internal */ - KProcess(KProcessPrivate *d, QObject *parent); + KTermProcess(KTermProcessPrivate *d, QObject *parent); /** * @internal */ - KProcessPrivate * const d_ptr; + KTermProcessPrivate * const d_ptr; private: // hide those @@ -334,29 +332,29 @@ class KProcess : public QProcess }; /* ----------- kprocess_p.h ---------------- */ -class KProcessPrivate { +class KTermProcessPrivate { - Q_DECLARE_PUBLIC(KProcess) + Q_DECLARE_PUBLIC(KTermProcess) protected: - KProcessPrivate() : + KTermProcessPrivate() : openMode(QIODevice::ReadWrite) { } - virtual ~KProcessPrivate() + virtual ~KTermProcessPrivate() { } void writeAll(const QByteArray &buf, int fd); - void forwardStd(KProcess::ProcessChannel good, int fd); + void forwardStd(KTermProcess::ProcessChannel good, int fd); void _k_forwardStdout(); void _k_forwardStderr(); QString prog; QStringList args; - KProcess::OutputChannelMode outputChannelMode; + KTermProcess::OutputChannelMode outputChannelMode; QIODevice::OpenMode openMode; - KProcess *q_ptr; + KTermProcess *q_ptr; }; /* ------------------------------------------- */ #endif diff --git a/lib/kptyprocess.cpp b/lib/kptyprocess.cpp index 5c829fd1..c2abfbc2 100644 --- a/lib/kptyprocess.cpp +++ b/lib/kptyprocess.cpp @@ -38,7 +38,7 @@ #include KPtyProcess::KPtyProcess(QObject *parent) : - KProcess(new KPtyProcessPrivate, parent) + KTermProcess(new KPtyProcessPrivate, parent) { Q_D(KPtyProcess); @@ -49,7 +49,7 @@ KPtyProcess::KPtyProcess(QObject *parent) : } KPtyProcess::KPtyProcess(int ptyMasterFd, QObject *parent) : - KProcess(new KPtyProcessPrivate, parent) + KTermProcess(new KPtyProcessPrivate, parent) { Q_D(KPtyProcess); @@ -138,7 +138,7 @@ void KPtyProcess::setupChildProcess() if (d->ptyChannels & StderrChannel) dup2(d->pty->slaveFd(), 2); - KProcess::setupChildProcess(); + KTermProcess::setupChildProcess(); } //#include "kptyprocess.moc" diff --git a/lib/kptyprocess.h b/lib/kptyprocess.h index 3491b352..5588fd08 100644 --- a/lib/kptyprocess.h +++ b/lib/kptyprocess.h @@ -40,7 +40,7 @@ class KPtyDevice; class KPtyProcessPrivate; /** - * This class extends KProcess by support for PTYs (pseudo TTYs). + * This class extends KTermProcess by support for PTYs (pseudo TTYs). * * The PTY is opened as soon as the class is instantiated. Verify that * it was opened successfully by checking that pty()->masterFd() is not -1. @@ -54,7 +54,7 @@ class KPtyProcessPrivate; * * @author Oswald Buddenhagen */ -class KPtyProcess : public KProcess +class KPtyProcess : public KTermProcess { Q_OBJECT Q_DECLARE_PRIVATE(KPtyProcess) @@ -155,7 +155,7 @@ class KPtyProcess : public KProcess // private data // ////////////////// -class KPtyProcessPrivate : public KProcessPrivate { +class KPtyProcessPrivate : public KTermProcessPrivate { public: KPtyProcessPrivate() : ptyChannels(KPtyProcess::NoChannels),