• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • kdepim
  • Sitemap
  • Contact Us
 

kalarm/lib

shellprocess.h

Go to the documentation of this file.
00001 /*
00002  *  shellprocess.h  -  execute a process through the shell
00003  *  Program:  kalarm
00004  *  Copyright © 2004-2008 by David Jarvie <software@astrojar.org.uk>
00005  *
00006  *  This program is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License as published by
00008  *  the Free Software Foundation; either version 2 of the License, or
00009  *  (at your option) any later version.
00010  *
00011  *  This program 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
00014  *  GNU General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU General Public License along
00017  *  with this program; if not, write to the Free Software Foundation, Inc.,
00018  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00019  */
00020 
00021 #ifndef SHELLPROCESS_H
00022 #define SHELLPROCESS_H
00023 
00026 #include <QQueue>
00027 #include <QByteArray>
00028 #include <kprocess.h>
00029 
00030 
00052 class ShellProcess : public KProcess
00053 {
00054         Q_OBJECT
00055     public:
00065         enum Status {
00066             INACTIVE,     // start() has not yet been called to run the command
00067             RUNNING,      // command is currently running
00068             SUCCESS,      // command appears to have exited successfully
00069             UNAUTHORISED, // shell commands are not authorised for this user
00070             DIED,         // command didn't exit cleanly, i.e. was killed or died
00071             NOT_FOUND,    // command either not found or not executable
00072             START_FAIL    // command couldn't be started for other reasons
00073         };
00077         explicit ShellProcess(const QString& command);
00081         bool            start(OpenMode = ReadWrite);
00083         Status          status() const       { return mStatus; }
00085         int             exitCode() const     { return mExitCode; }
00089         bool            normalExit() const   { return mStatus == SUCCESS; }
00091         const QString&  command() const      { return mCommand; }
00096         QString         errorMessage() const;
00098         void            writeStdin(const char* buffer, int bufflen);
00100         void            stdinExit();
00104         static bool     authorised();
00108         static const QByteArray& shellName()   { shellPath();  return mShellName; }
00112         static const QByteArray& shellPath();
00113 
00114     signals:
00118         void  shellExited(ShellProcess*);
00120         void  receivedStdout(ShellProcess*);
00122         void  receivedStderr(ShellProcess*);
00123 
00124     private slots:
00125         void  writtenStdin(qint64 bytes);
00126         void  stdoutReady()         { emit receivedStdout(this); }
00127         void  stderrReady()         { emit receivedStderr(this); }
00128         void  slotExited(int exitCode, QProcess::ExitStatus);
00129 
00130     private:
00131         // Prohibit the following inherited methods
00132         ShellProcess&  operator<<(const QString&);
00133         ShellProcess&  operator<<(const QStringList&);
00134 
00135         static QByteArray  mShellName;    // name of shell to be used
00136         static QByteArray  mShellPath;    // path of shell to be used
00137         static bool        mInitialised;  // true once static data has been initialised
00138         static bool        mAuthorised;   // true if shell commands are authorised
00139         QString            mCommand;      // copy of command to be executed
00140         QQueue<QByteArray> mStdinQueue;   // queued strings to send to STDIN
00141         qint64             mStdinBytes;   // bytes still to be written from first queued string
00142         int                mExitCode;     // shell exit value (if mStatus == SUCCESS or NOT_FOUND)
00143         Status             mStatus;       // current execution status
00144         bool               mStdinExit;    // exit once STDIN queue has been written
00145 };
00146 
00147 #endif // SHELLPROCESS_H

kalarm/lib

Skip menu "kalarm/lib"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members

kdepim

Skip menu "kdepim"
  • akonadi
  •   clients
  •   kabc
  •   kcal
  •   kcm
  • akregator
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt
  • kdgantt1
  • kjots
  • kleopatra
  • kmail
  • kmobiletools
  • knode
  • knotes
  • kontact
  • kontactinterfaces
  • korganizer
  •   korgac
  • kpilot
  • ktimetracker
  • libkdepim
  • libkholidays
  • libkleo
  • libkpgp
  • maildir
Generated for kdepim by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal