source: ogBrowser-Git/src/mainwindow.h

jenkins
Last change on this file was 068539c, checked in by Vadim Troshchinskiy Shmelev <vtroshchinskiy@…>, 2 months ago

Add ability to ignore SSL errors

  • Property mode set to 100644
File size: 3.2 KB
Line 
1#ifndef MAINWINDOW_H
2#define MAINWINDOW_H
3
4#define COMMAND "command"
5#define COMMAND_CONFIRM "command+confirm"
6#define COMMAND_WITH_CONFIRMATION "commandwithconfirmation"  // Backwards compatibility
7#define COMMAND_OUTPUT "command+output"
8#define COMMAND_CONFIRM_OUTPUT "command+confirm+output"
9#define COMMAND_OUTPUT_CONFIRM "command+output+confirm"
10#define ENVIRONMENT "OGLOGFILE,ogactiveadmin,DEFAULTSPEED"
11
12
13#include <QWidget>
14#include <QProcess>
15#include <QMap>
16#include <QMainWindow>
17#include <QNetworkReply>
18#include <QSslError>
19#include <QProgressBar>
20#include <QLabel>
21#include <QLineEdit>
22#include <QTextEdit>
23#include <QFile>
24#include <QWebEngineView>
25#include <QVector>
26
27
28#include "digitalclock.h"
29
30
31
32struct PendingCommand {
33    QString command = "";
34    bool confirm = false;
35    bool returnOutput = false;
36
37    QProcess *process = nullptr;
38
39    bool operator==(const PendingCommand &other) {
40        return other.process == process;
41    }
42};
43
44
45class MainWindow : public QMainWindow
46{
47    Q_OBJECT
48
49    public:
50        MainWindow(QWidget *parent = 0);
51        void closeEvent(QCloseEvent *event) override;
52
53        ~MainWindow();
54
55    public slots:
56        // Funcion que maneja los links
57        void slotWebLoadStarted();
58        void slotWebLoadFinished(bool ok);
59        void slotWebLoadProgress(int progress);
60        void slotSslErrors(QNetworkReply* reply);
61        void slotCertificateErrors(const QWebEngineCertificateError &certificateError);
62
63
64        // Funciones que manejan cada vez que el proceso hace algo
65        void slotProcessStarted();
66        void slotProcessFinished(int code,QProcess::ExitStatus status);
67        void slotProcessError(QProcess::ProcessError error);
68        void slotProcessOutput();
69        void slotProcessErrorOutput();
70
71        // Funcion para crear terminales
72        void slotCreateTerminal();
73        void slotDeleteTerminal();
74
75        // Funcion para el webar
76        void slotUrlChanged(const QUrl &url);
77
78        void commandQueued(const QString &command, bool confirm, bool returnOutput);
79
80
81    private:
82        bool isAdmin() const { return m_is_admin; }
83        bool isKioskMode() const { return m_kiosk_mode; }
84        void registerScheme(const QString &name);
85        void registerHandler(const QString &name, bool confirm, bool output, const QString baseCommand = "");
86
87        bool m_is_admin{false};
88        bool m_kiosk_mode{false};
89
90
91    //Functions
92    protected:
93        int readEnvironmentValues();
94        void print(QString s);
95        void write(QString s);
96        void captureOutputForStatusBar(QString output);
97        void startProgressBar();
98        void finishProgressBar();
99        void executeCommand(QString &string);
100        QString readSpeed();
101        void showErrorMessage(QString string);
102
103    protected:
104        QWebEngineView *m_web;
105        QTextEdit *m_output;
106        QLabel *m_logo;
107        QProgressBar *m_progressBar;
108        QLabel *m_speedInfo;
109        DigitalClock *m_clock;
110        QTabWidget *m_tabs;
111        QLineEdit *m_webBar;
112
113        //QProcess *m_process;
114
115        QMap<QString,QString> m_env;
116        QFile *m_logfile;
117        QTextStream *m_logstream;
118
119        PendingCommand m_command;
120        //QVector<PendingCommand> m_commands;
121
122
123        int m_numberTerminal;
124};
125
126#endif // MAINWINDOW_H
Note: See TracBrowser for help on using the repository browser.