~x2go/x2go/x2goclient_master

« back to all changes in this revision

Viewing changes to src/sshprocess.h

  • Committer: Mihai Moldovan
  • Date: 2015-03-04 20:15:47 UTC
  • Revision ID: git-v1:b7398771a7abd84ddcff407063edb95dd0a205d3
general: move *.cpp and *.h files to src/ and *.ts files to src/i18n/.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**************************************************************************
 
2
*   Copyright (C) 2005-2015 by Oleksandr Shneyder                         *
 
3
*   o.shneyder@phoca-gmbh.de                                              *
 
4
*                                                                         *
 
5
*   This program is free software; you can redistribute it and/or modify  *
 
6
*   it under the terms of the GNU General Public License as published by  *
 
7
*   the Free Software Foundation; either version 2 of the License, or     *
 
8
*   (at your option) any later version.                                   *
 
9
*   This program is distributed in the hope that it will be useful,       *
 
10
*   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 
11
*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 
12
*   GNU General Public License for more details.                          *
 
13
*                                                                         *
 
14
*   You should have received a copy of the GNU General Public License     *
 
15
*   along with this program.  If not, see <http://www.gnu.org/licenses/>. *
 
16
***************************************************************************/
 
17
 
 
18
#ifndef SSHPROCESS_H
 
19
#define SSHPROCESS_H
 
20
 
 
21
#include <libssh/libssh.h>
 
22
#include <QObject>
 
23
#include <QProcess>
 
24
#ifndef Q_OS_WIN
 
25
#include <netinet/in.h>
 
26
#endif
 
27
 
 
28
#include "sshmasterconnection.h"
 
29
 
 
30
class SshProcess : public QObject
 
31
{
 
32
    Q_OBJECT
 
33
    friend class SshMasterConnection;
 
34
private:
 
35
 
 
36
    SshProcess(SshMasterConnection* master, int pid);
 
37
    ~SshProcess();
 
38
 
 
39
    void startNormal(const QString& cmd);
 
40
    void startTunnel(const QString& forwardHost, uint forwardPort, const QString& localHost,
 
41
                     uint localPort, bool reverse=false);
 
42
    void start_cp(QString src, QString dst);
 
43
    QString getSource()
 
44
    {
 
45
        return scpSource;
 
46
    }
 
47
 
 
48
    void tunnelLoop();
 
49
#ifdef Q_OS_WIN
 
50
    void    addPuttyReg(QString host, QString uuidStr);
 
51
    void    rmPuttyReg(QString uuidStr);
 
52
#endif
 
53
 
 
54
private:
 
55
    SshMasterConnection* masterCon;
 
56
    SshMasterConnection* tunnelConnection;
 
57
    int pid;
 
58
    QString forwardHost;
 
59
    QString localHost;
 
60
    QString command;
 
61
    QString scpSource;
 
62
    quint16 forwardPort;
 
63
    quint16 localPort;
 
64
    uint serverSocket;
 
65
    struct sockaddr_in address;
 
66
#ifndef  Q_OS_WIN
 
67
    socklen_t addrlen;
 
68
#else
 
69
    int addrlen;
 
70
#endif
 
71
    QString stdOutString;
 
72
    QString stdErrString;
 
73
    QString abortString;
 
74
    bool tunnel;
 
75
    bool normalExited;
 
76
//only to use with krb (until no GSSAPI support in libssh)
 
77
    QProcess* proc;
 
78
    QString procUuid;
 
79
    bool execProcess;
 
80
    bool tunnelOkEmited;
 
81
 
 
82
private slots:
 
83
    void slotCheckNewConnection();
 
84
    void slotStdErr(SshProcess* creator, QByteArray data);
 
85
    void slotStdOut(SshProcess* creator, QByteArray data);
 
86
    void slotIOerr(SshProcess* creator,QString message, QString sshSessionErr);
 
87
    void slotChannelClosed(SshProcess* creator, QString uuid);
 
88
    void slotReverseTunnelOk(SshProcess* creator);
 
89
    void slotReverseTunnelFailed(SshProcess* creator, QString error);
 
90
    void slotCopyOk(SshProcess* creator);
 
91
    void slotCopyErr(SshProcess* creator,QString message, QString sshSessionErr);
 
92
    //krb stuff
 
93
    void slotSshProcFinished( int exitCode, QProcess::ExitStatus exitStatus);
 
94
    void slotSshProcStdErr();
 
95
    void slotSshProcStdOut();
 
96
signals:
 
97
    void sshFinished ( bool result, QString output, int processId);
 
98
    void sshTunnelOk(int processId);
 
99
};
 
100
 
 
101
#endif // SSHPROCESS_H