#include "ogurlhandler.h" #include #include #include void OGBrowserUrlHandlerCommand::requestStarted(QWebEngineUrlRequestJob *job) { qInfo() << "Command request: " << job->requestUrl(); QString cmd; if ( !baseCommand().isEmpty() ) { cmd = baseCommand(); //QString url = getScheme() + ":/" + cmd = cmd.replace("%u", job->requestUrl().toString()); // single URL cmd = cmd.replace("%U", job->requestUrl().toString()); // URL list } else { cmd = job->requestUrl().path(); } qDebug() << "Resulting command: " << cmd; emit command(cmd, askConfirmation(), returnOuput()); //job->redirect(QUrl()); job->fail(QWebEngineUrlRequestJob::NoError); return; /* // For all command with confirmation links, show a popup box if (askConfirmation()) { QMessageBox msgBox; msgBox.setWindowFlags(Qt::CustomizeWindowHint | Qt::WindowTitleHint); msgBox.setWindowTitle(tr(gettext("AVISO"))); msgBox.setIcon(QMessageBox::Question); msgBox.setTextFormat(Qt::RichText); msgBox.setText(tr(gettext("La siguiente acción puede modificar datos o tardar varios minutos. El equipo no podrá ser utilizado durante su ejecución."))); QPushButton *execButton = msgBox.addButton(tr(gettext("Ejecutar")), QMessageBox::ActionRole); msgBox.addButton(tr(gettext("Cancelar")), QMessageBox::RejectRole); msgBox.setDefaultButton(execButton); msgBox.exec(); // Continue if user press the execution button if (msgBox.clickedButton() == execButton) { // For command with confirmation and output link, show an output window to non-admin user if((urlScheme == COMMAND_CONFIRM_OUTPUT || urlScheme == COMMAND_OUTPUT_CONFIRM) && (! m_env.contains("ogactiveadmin") || m_env["ogactiveadmin"] != "true")) { int w=MainWindow::width(), h=MainWindow::height(); m_output->setWindowFlags(Qt::Window); m_output->move(100, 100); m_output->setFixedSize(w*0.8-100, h*0.8-100); m_output->show(); } } else { job->fail(QWebEngineUrlRequestJob::RequestDenied); return; } } // Execute the command executeCommand(urlString.remove(0, urlScheme.length()+1)); else if(urlScheme == COMMAND || urlScheme == COMMAND_OUTPUT) { // For command with output link, show an output window to non-admin user if(urlScheme == COMMAND_OUTPUT && (! m_env.contains("ogactiveadmin") || m_env["ogactiveadmin"] != "true")) { int w=MainWindow::width(), h=MainWindow::height(); m_output->setWindowFlags(Qt::Window); m_output->move(100, 100); m_output->setFixedSize(w*0.8-100, h*0.8-100); m_output->show(); } // Execute the command executeCommand(urlString.remove(0, urlScheme.length()+1)); } */ }