source: ogBrowser-Git/src/ogurlhandler.cpp

jenkins
Last change on this file was 476581b, checked in by Vadim Troshchinskiy Shmelev <vtroshchinskiy@…>, 16 months ago

Add desktop file parser

  • Property mode set to 100644
File size: 3.2 KB
Line 
1
2
3#include "ogurlhandler.h"
4#include <QWebEngineUrlRequestJob>
5#include <QMessageBox>
6#include <QDebug>
7
8
9void OGBrowserUrlHandlerCommand::requestStarted(QWebEngineUrlRequestJob *job) {
10
11    qInfo() << "Command request: " << job->requestUrl();
12
13
14    QString cmd;
15    if ( !baseCommand().isEmpty() ) {
16        cmd = baseCommand();
17
18        //QString url = getScheme() + ":/" +
19        cmd = cmd.replace("%u", job->requestUrl().toString()); // single URL
20        cmd = cmd.replace("%U", job->requestUrl().toString()); // URL list
21    } else {
22        cmd = job->requestUrl().path();
23    }
24
25    qDebug() << "Resulting command: " << cmd;
26    emit command(cmd, askConfirmation(), returnOuput());
27
28    //job->redirect(QUrl());
29    job->fail(QWebEngineUrlRequestJob::NoError);
30
31    return;
32    /*
33        // For all command with confirmation links, show a popup box
34        if (askConfirmation()) {
35            QMessageBox msgBox;
36            msgBox.setWindowFlags(Qt::CustomizeWindowHint | Qt::WindowTitleHint);
37            msgBox.setWindowTitle(tr(gettext("AVISO")));
38            msgBox.setIcon(QMessageBox::Question);
39            msgBox.setTextFormat(Qt::RichText);
40            msgBox.setText(tr(gettext("La siguiente acci&oacute;n puede modificar datos o tardar varios minutos. El equipo no podr&aacute; ser utilizado durante su ejecuci&oacute;n.")));
41            QPushButton *execButton = msgBox.addButton(tr(gettext("Ejecutar")), QMessageBox::ActionRole);
42            msgBox.addButton(tr(gettext("Cancelar")), QMessageBox::RejectRole);
43            msgBox.setDefaultButton(execButton);
44            msgBox.exec();
45            // Continue if user press the execution button
46            if (msgBox.clickedButton() == execButton)
47            {
48                // For command with confirmation and output link, show an output window to non-admin user
49                if((urlScheme == COMMAND_CONFIRM_OUTPUT || urlScheme == COMMAND_OUTPUT_CONFIRM) &&
50                (! m_env.contains("ogactiveadmin") || m_env["ogactiveadmin"] != "true"))
51                {
52                    int w=MainWindow::width(), h=MainWindow::height();
53                    m_output->setWindowFlags(Qt::Window);
54                    m_output->move(100, 100);
55                    m_output->setFixedSize(w*0.8-100, h*0.8-100);
56                    m_output->show();
57                }
58            } else {
59                job->fail(QWebEngineUrlRequestJob::RequestDenied);
60                return;
61            }
62        }
63
64        // Execute the command
65        executeCommand(urlString.remove(0, urlScheme.length()+1));
66
67
68
69
70        else if(urlScheme == COMMAND || urlScheme == COMMAND_OUTPUT)
71        {
72            // For command with output link, show an output window to non-admin user
73            if(urlScheme == COMMAND_OUTPUT &&
74            (! m_env.contains("ogactiveadmin") || m_env["ogactiveadmin"] != "true"))
75            {
76                int w=MainWindow::width(), h=MainWindow::height();
77                m_output->setWindowFlags(Qt::Window);
78                m_output->move(100, 100);
79                m_output->setFixedSize(w*0.8-100, h*0.8-100);
80                m_output->show();
81            }
82            // Execute the command
83            executeCommand(urlString.remove(0, urlScheme.length()+1));
84        } */
85}
Note: See TracBrowser for help on using the repository browser.