OSDN Git Service

Update license.
[qt-creator-jp/qt-creator-jp.git] / src / libs / utils / ssh / sshremoteprocess.h
1 /**************************************************************************
2 **
3 ** This file is part of Qt Creator
4 **
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
6 **
7 ** Contact: Nokia Corporation (info@qt.nokia.com)
8 **
9 **
10 ** GNU Lesser General Public License Usage
11 **
12 ** This file may be used under the terms of the GNU Lesser General Public
13 ** License version 2.1 as published by the Free Software Foundation and
14 ** appearing in the file LICENSE.LGPL included in the packaging of this file.
15 ** Please review the following information to ensure the GNU Lesser General
16 ** Public License version 2.1 requirements will be met:
17 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
18 **
19 ** In addition, as a special exception, Nokia gives you certain additional
20 ** rights. These rights are described in the Nokia Qt LGPL Exception
21 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
22 **
23 ** Other Usage
24 **
25 ** Alternatively, this file may be used in accordance with the terms and
26 ** conditions contained in a signed written agreement between you and Nokia.
27 **
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
30 **
31 **************************************************************************/
32
33 #ifndef SSHREMOTECOMMAND_H
34 #define SSHREMOTECOMMAND_H
35
36 #include <utils/utils_global.h>
37
38 #include <QtCore/QObject>
39 #include <QtCore/QSharedPointer>
40
41 QT_BEGIN_NAMESPACE
42 class QByteArray;
43 QT_END_NAMESPACE
44
45 namespace Utils {
46 namespace Internal {
47 class SshChannelManager;
48 class SshRemoteProcessPrivate;
49 class SshSendFacility;
50 } // namespace Internal
51
52 class QTCREATOR_UTILS_EXPORT SshRemoteProcess : public QObject
53 {
54     Q_OBJECT
55     Q_DISABLE_COPY(SshRemoteProcess)
56
57     friend class Internal::SshChannelManager;
58     friend class Internal::SshRemoteProcessPrivate;
59
60 public:
61     typedef QSharedPointer<SshRemoteProcess> Ptr;
62     enum ExitStatus { FailedToStart, KilledBySignal, ExitedNormally };
63
64     static const QByteArray AbrtSignal;
65     static const QByteArray AlrmSignal;
66     static const QByteArray FpeSignal;
67     static const QByteArray HupSignal;
68     static const QByteArray IllSignal;
69     static const QByteArray IntSignal;
70     static const QByteArray KillSignal;
71     static const QByteArray PipeSignal;
72     static const QByteArray QuitSignal;
73     static const QByteArray SegvSignal;
74     static const QByteArray TermSignal;
75     static const QByteArray Usr1Signal;
76     static const QByteArray Usr2Signal;
77
78     ~SshRemoteProcess();
79
80     /*
81      * Note that this is of limited value in practice, because servers are
82      * usually configured to ignore such requests for security reasons.
83      */
84     void addToEnvironment(const QByteArray &var, const QByteArray &value);
85
86     void start();
87     void closeChannel();
88
89     bool isRunning() const;
90     QString errorString() const;
91     int exitCode() const;
92     QByteArray exitSignal() const;
93
94     // Note: This is ignored by the OpenSSH server.
95     void sendSignal(const QByteArray &signal);
96     void kill() { sendSignal(KillSignal); }
97
98     void sendInput(const QByteArray &data); // Should usually have a trailing newline.
99
100 signals:
101     void started();
102     void outputAvailable(const QByteArray &output);
103     void errorOutputAvailable(const QByteArray &output);
104
105     /*
106      * Parameter is of type ExitStatus, but we use int because of
107      * signal/slot awkwardness (full namespace required).
108      */
109     void closed(int exitStatus);
110
111 private:
112     SshRemoteProcess(const QByteArray &command, quint32 channelId,
113         Internal::SshSendFacility &sendFacility);
114
115     Internal::SshRemoteProcessPrivate *d;
116 };
117
118 } // namespace Utils
119
120 #endif // SSHREMOTECOMMAND_H