~ubuntu-branches/ubuntu/hoary/kvirc/hoary

« back to all changes in this revision

Viewing changes to src/kvilib/kde/kvi_process_kde.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Robin Verduijn
  • Date: 2004-12-14 15:32:19 UTC
  • mfrom: (0.2.1 upstream) (1.1.1 warty)
  • Revision ID: james.westby@ubuntu.com-20041214153219-fdink3gyp2s20b6g
Tags: 2:2.1.3.1-2
* Change Recommends on xmms to a Suggests.
* Rebuild against KDE 3.3.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// =============================================================================
 
2
//
 
3
//      --- kvi_process_kde.cpp ---
 
4
//
 
5
//   This file is part of the KVIrc IRC client distribution
 
6
//   Copyright (C) 2003 Robin Verduijn <robin@debian.org>
 
7
//
 
8
//   This program is FREE software. You can redistribute it and/or
 
9
//   modify it under the terms of the GNU General Public License
 
10
//   as published by the Free Software Foundation; either version 2
 
11
//   of the License, or (at your opinion) any later version.
 
12
//
 
13
//   This program is distributed in the HOPE that it will be USEFUL,
 
14
//   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
16
//   See the GNU General Public License for more details.
 
17
//
 
18
//   You should have received a copy of the GNU General Public License
 
19
//   along with this program. If not, write to the Free Software Foundation,
 
20
//   Inc, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
21
//
 
22
// =============================================================================
 
23
 
 
24
#include <stdlib.h>
 
25
 
 
26
#include <qfileinfo.h>
 
27
#include <qstringlist.h>
 
28
 
 
29
#include "kvi_process_kde.h"
 
30
 
 
31
QString KviProcess::m_szShellName("");
 
32
 
 
33
KviProcess::KviProcess()
 
34
        : KProcess()
 
35
{
 
36
        connect(this, SIGNAL( processExited(KProcess *)),              this, SLOT( processExited(KProcess *)));
 
37
        connect(this, SIGNAL(receivedStdout(KProcess *, char *, int)), this, SLOT(receivedStdout(KProcess *, char *, int)));
 
38
        connect(this, SIGNAL(receivedStderr(KProcess *, char *, int)), this, SLOT(receivedStderr(KProcess *, char *, int)));
 
39
}
 
40
 
 
41
KviProcess::~KviProcess()
 
42
{
 
43
        // Nothing here
 
44
}
 
45
 
 
46
// TODO: kill-on-close parameter is ignored for now
 
47
bool KviProcess::run(const char *commandline, bool bCommunicate, bool /* ignored */, bool bExecInSubshell)
 
48
{
 
49
        QStringList args = QStringList::split(' ', commandline);
 
50
    for( QStringList::Iterator iter = args.begin(); iter != args.end(); ++iter )
 
51
                (*this) << *iter;
 
52
        setUseShell(bExecInSubshell);
 
53
 
 
54
        return start(NotifyOnExit, bCommunicate ? All : NoCommunication);
 
55
}
 
56
 
 
57
const QString KviProcess::findShell()
 
58
{
 
59
        if( !m_szShellName.isEmpty() )
 
60
                return m_szShellName;
 
61
 
 
62
        QString tmp = getenv("SHELL");
 
63
        if( !tmp.isEmpty() ) {
 
64
                QFileInfo f(tmp);
 
65
                if( f.isExecutable() ) {
 
66
                        m_szShellName = tmp;
 
67
                        return m_szShellName;
 
68
                }
 
69
        }
 
70
        m_szShellName = "/bin/sh";
 
71
        return m_szShellName;
 
72
}
 
73
 
 
74
void KviProcess::processExited(KProcess *proc)
 
75
{
 
76
        emit processExited((KviProcess *) proc);
 
77
}
 
78
 
 
79
void KviProcess::receivedStdout(KProcess *proc, char *buffer, int len)
 
80
{
 
81
        emit receivedStdout((KviProcess *) proc, buffer, len);
 
82
}
 
83
 
 
84
void KviProcess::receivedStderr(KProcess *proc, char *buffer, int len)
 
85
{
 
86
        emit receivedStderr((KviProcess *) proc, buffer, len);
 
87
}
 
88
 
 
89
#include "m_kvi_process_kde.moc"