//
//     Copyright 2006 Jim Bublitz <jbublitz@nwinternet.com>
//     Earlier copyrights 1998 - 2005 Jim Bublitz and/or Phil Thompson
//     may also apply


//                 Generated by preSip
//            module tdecore  version KDE 3.5.3


// This software is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; either version 2 of
// the License, or (at your option) any later version.
//
// This software is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public
// License along with this library; see the file COPYING.
// If not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.


class TDEProcess : TQObject
{
%TypeHeaderCode
#include <kprocess.h>
%End


public:

%If ( KDE_3_5_2 -  )

    enum Communication
    {
        NoCommunication, 
        Stdin, 
        Stdout, 
        Stderr, 
        AllOutput, 
        All, 
        NoRead, 
        CTtyOnly, 
        MergedStderr
    };

%End


%If ( KDE_3_2_0 -  )

    enum RunMode
    {
        DontCare, 
        NotifyOnExit, 
        Block, 
        OwnGroup
    };

                         TDEProcess (TQObject* /TransferThis/, const char* = 0);
%End

                         TDEProcess ();
    bool                 setExecutable (const TQString&);

%If ( KDE_3_1_4 -  )
    TDEProcess&            operator << (const TQString&);
    TDEProcess&            operator << (const char*);
    TDEProcess&            operator << (const TQCString&);
    TDEProcess&            operator << (const TQStringList&);
%End

    void                 clearArguments ();
    virtual bool         start (TDEProcess::RunMode = NotifyOnExit , TDEProcess::Communication = NoCommunication );
    virtual bool         kill (int = SIGTERM );
    bool                 isRunning () const;
    pid_t                pid () const;
    pid_t                getPid () const;
    void                 suspend ();
    void                 resume ();

%If ( KDE_3_2_0 -  )
    bool                 wait (int = -1);
%End

    bool                 normalExit () const;

%If ( KDE_3_2_0 -  )
    bool                 signalled () const;
    bool                 coreDumped () const;
%End

    int                  exitStatus () const;

%If ( KDE_3_2_0 -  )
    int                  exitSignal () const;
%End

    bool                 writeStdin (const char*, int);
    bool                 closeStdin ();
    bool                 closeStdout ();
    bool                 closeStderr ();

%If ( KDE_3_2_0 -  )
    bool                 closePty ();
    void                 closeAll ();
%End

    const TQValueList<TQCString>& args ();
    void                 setRunPrivileged (bool);
    bool                 runPrivileged () const;
    void                 setEnvironment (const TQString&, const TQString&);
    void                 setWorkingDirectory (const TQString&);

%If ( KDE_3_1_0 -  )
    void                 setUseShell (bool, const char* = 0);
    static TQString       quote (const TQString&);
%End

    void                 detach ();

%If ( KDE_3_2_0 -  )

    enum 
    {
        PrioLowest, 
        PrioLow, 
        PrioLower, 
        PrioNormal, 
        PrioHigher, 
        PrioHigh, 
        PrioHighest
    };

    bool                 setPriority (int);
%End


signals:
    void                 processExited (TDEProcess*);
    void                 receivedStdout (TDEProcess*, char*, int);
//ig     void                 receivedStdout (int, int&);
    void                 receivedStderr (TDEProcess*, char*, int);
    void                 wroteStdin (TDEProcess*);

protected slots:
    void                 slotChildOutput (int);
    void                 slotChildError (int);
    void                 slotSendData (int);

protected:
    void                 setupEnvironment ();
    virtual int          setupCommunication (TDEProcess::Communication);
    virtual int          commSetupDoneP ();
    virtual int          commSetupDoneC ();
    virtual void         processHasExited (int);
    virtual void         commClose ();

%If ( KDE_3_2_0 -  )
    void                 setBinaryExecutable (const char*);
%End

    int                  childOutput (int);
    int                  childError (int);

protected:
//igx     virtual void         virtual_hook (int, void*);

public:

%If (  - KDE_3_5_2 )

    enum Communication
    {
        NoCommunication, 
        Stdin, 
        Stdout, 
        Stderr, 
        AllOutput, 
        All, 
        NoRead
    };

%End


public:

%If ( KDE_3_2_0 - KDE_3_4_0 )
    void                 setUsePty (TDEProcess::Communication, bool);
    KPty*                pty () const;
%End


public:

%If (  - KDE_3_2_0 )

    enum RunMode
    {
        DontCare, 
        NotifyOnExit, 
        Block
    };

%End


%If (  - KDE_3_2_0 )

private:
                         TDEProcess (const TDEProcess&);
%End


public:
//force
    void                 setArguments (SIP_PYLIST) [void (char**)];
%MethodCode
//takes arglist | (a Python list of strings)
//doc
// setArguments is the PyKDE equivalent of the stream operator methods (<<)
// in KDE's TDEProcess class - provide with a list of strings representing
// the arguments to the executable program set with setExecutable (PyKDE
// will continue to provide setExecutable even though it's deprecated in
// KDE (to also be replaced with stream operators)
//end

    PyObject *elem;

    for (int i = 0; i < PyList_Size (a0); i++)
    {
        elem = PyList_GET_ITEM (a0, i);
        *sipCpp << sipBytes_AsString (elem);
    }


%End

//end

};  // class TDEProcess


class KShellProcess : TDEProcess
{
%TypeHeaderCode
#include <kprocess.h>
%End


public:
                         KShellProcess (const char* = 0);
    virtual bool         start (RunMode = NotifyOnExit , Communication = NoCommunication );
    static TQString       quote (const TQString&);

protected:
//igx     virtual void         virtual_hook (int, void*);

%If (  - KDE_3_2_0 )

private:
                         KShellProcess (const KShellProcess&);
%End


};  // class KShellProcess

