~x2go/x2go/x2goclient_master

« back to all changes in this revision

Viewing changes to src/httpbrokerclient.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 HTTPBROKERCLIENT_H
 
19
#define HTTPBROKERCLIENT_H
 
20
#include "x2goclientconfig.h"
 
21
#include <QNetworkAccessManager>
 
22
#include <QUrl>
 
23
#include <QNetworkRequest>
 
24
#include <QNetworkReply>
 
25
#include <QSslError>
 
26
#include <QBuffer>
 
27
#include <QObject>
 
28
#include <QDateTime>
 
29
#include <QSslSocket>
 
30
#include "sshmasterconnection.h"
 
31
/**
 
32
        @author Oleksandr Shneyder <oleksandr.shneyder@obviously-nice.de>
 
33
*/
 
34
class QNetworkAccessManager;
 
35
struct ConfigFile;
 
36
class ONMainWindow;
 
37
 
 
38
class HttpBrokerClient: public QObject
 
39
{
 
40
    Q_OBJECT
 
41
public:
 
42
    HttpBrokerClient ( ONMainWindow* wnd, ConfigFile* cfg );
 
43
    ~HttpBrokerClient();
 
44
    void selectUserSession(const QString& session );
 
45
    void changePassword(QString newPass);
 
46
    void testConnection();
 
47
private:
 
48
    QNetworkAccessManager* http;
 
49
    QNetworkRequest* netRequest;
 
50
    QSslSocket* sslSocket;
 
51
    QNetworkReply* sessionsRequest;
 
52
    QNetworkReply* selSessRequest;
 
53
    QNetworkReply* chPassRequest;
 
54
    QNetworkReply* testConRequest;
 
55
    QString nextAuthId;
 
56
    QString newBrokerPass;
 
57
    ConfigFile* config;
 
58
    ONMainWindow* mainWindow;
 
59
    QTime requestTime;
 
60
    bool sshBroker;
 
61
    SshMasterConnection* sshConnection;
 
62
private:
 
63
    void createIniFile(const QString& raw_content);
 
64
    void parseSession(QString sInfo);
 
65
    void createSshConnection();
 
66
    bool checkAccess(QString answer);
 
67
 
 
68
private slots:
 
69
    void slotRequestFinished ( QNetworkReply*  reply );
 
70
    void slotSslErrors ( QNetworkReply* netReply, const QList<QSslError> & errors ) ;
 
71
    QString getHexVal ( const QByteArray& ba );
 
72
    void slotSshConnectionError ( QString message, QString lastSessionError );
 
73
    void slotSshServerAuthError ( int error, QString sshMessage, SshMasterConnection* connection );
 
74
    void slotSshServerAuthPassphrase ( SshMasterConnection* connection, bool verificationCode=false );
 
75
    void slotSshUserAuthError ( QString error );
 
76
    void slotSshConnectionOk();
 
77
    void slotListSessions ( bool success, QString answer, int pid);
 
78
    void slotSelectSession ( bool success, QString answer, int pid);
 
79
    void slotPassChanged ( bool success, QString answer, int pid);
 
80
    void slotConnectionTest( bool success, QString answer, int pid);
 
81
 
 
82
public slots:
 
83
    void getUserSessions();
 
84
 
 
85
signals:
 
86
    void haveSshKey ( QString );
 
87
    void fatalHttpError();
 
88
    void authFailed();
 
89
    void sessionsLoaded();
 
90
    void sessionSelected( );
 
91
    void passwordChanged( QString );
 
92
    void connectionTime(int, int);
 
93
};
 
94
 
 
95
#endif