Skip to content

Commit 45d9e1d

Browse files
committed
Perl debugger GUI update
1 parent 995b102 commit 45d9e1d

File tree

11 files changed

+51
-50
lines changed

11 files changed

+51
-50
lines changed

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Perl Executing Browser
66
[![Build Status](https://travis-ci.org/ddmitov/perl-executing-browser.svg?branch=master)](https://travis-ci.org/ddmitov/perl-executing-browser)
77
[![Build Status](https://ci.appveyor.com/api/projects/status/github/ddmitov/perl-executing-browser?branch=master&svg=true)](https://ci.appveyor.com/project/ddmitov/perl-executing-browser)
88

9-
Perl Executing Browser (PEB) is an HTML GUI for [Perl 5](https://www.perl.org/) desktop applications. It runs local Perl 5 scripts without server and with no timeout and is implemented as a C++ compiled executable based on [Qt 5](https://www.qt.io/) and [QtWebKit](https://trac.webkit.org/wiki/QtWebKit) libraries. PEB Perl scripts are fed from HTML forms using GET or POST requests to a built-in pseudo-domain. HTML interface for the [default Perl debugger](http://perldoc.perl.org/perldebug.html) is also available.
9+
Perl Executing Browser (PEB) is an HTML user interface for [Perl 5](https://www.perl.org/) desktop applications. It runs local Perl 5 scripts without server and with no timeout and is implemented as a C++ compiled executable based on [Qt 5](https://www.qt.io/) and [QtWebKit](https://trac.webkit.org/wiki/QtWebKit) libraries. PEB Perl scripts are fed from HTML forms using GET or POST requests to a built-in pseudo-domain. HTML interface for the [default Perl debugger](http://perldoc.perl.org/perldebug.html) is also available.
1010

1111
Inspired by [NW.js](http://nwjs.io/) and [Electron](http://electron.atom.io/), PEB is another reuse of web technologies in desktop applications with Perl doing the heavy lifting. In contrast to [NW.js](http://nwjs.io/) and [Electron](http://electron.atom.io/), PEB enforces strict separation between trusted and untrusted content in different browser windows.
1212

@@ -87,16 +87,16 @@ Inspired by [NW.js](http://nwjs.io/) and [Electron](http://electron.atom.io/), P
8787
* [Any icon can be displayed on windows and message boxes.](#icon)
8888

8989
**Development goodies:**
90-
* [PEB can interact with the Perl 5 debugger in graphical mode.](#html-interface-for-the-perl-debugger)
90+
* [PEB can interact with the Perl 5 debugger in graphical mode.](#perl-debugger-gui)
9191
* ``QWebInspector`` window can be invoked using <kbd>Ctrl</kbd> + <kbd>I</kbd> keyboard shortcut.
9292
* [Optional logging of all browser actions](#log-files)
9393

9494
## Compile-time Requirements
95-
GCC compiler and Qt 5.1 - 5.5 headers (including ``QtWebkit`` headers).
96-
The ``QtWebkit`` set of classes is deprecated and removed from all later versions of Qt.
97-
Compiling ``QtWebKit`` for a recent Qt version is possible, but this approach is resource-intensive and is not tested with the PEB sources.
95+
GCC compiler and Qt 5.1 - 5.5 headers (including ``QtWebKit`` headers).
96+
The ``QtWebKit`` set of classes is deprecated and removed from all later versions of Qt.
97+
Compiling ``QtWebKit`` for a recent Qt version is possible, but this approach is not tested with the PEB sources.
9898

99-
The most important Qt dependency of PEB is not ``QtWebkit``, but ``QNetworkAccessManager`` which is subclassed to implement the local pseudo-domain of PEB and all requests to local content. Unfortunately ``QNetworkAccessManager`` is incompatible with the ecosystem of ``QtWebEngine`` - the new Blink-based web engine of Qt. The transition to ``QtWebEngine`` is impractical because local POST requests and calling local Perl scripts from JavaScript can not be supported. If you want to render the HTML GUI of your Perl desktop application using the Blink web engine, you may use [Electron](http://electron.atom.io/) or [NW.js](http://nwjs.io/) and [camel-harness](https://github.com/ddmitov/camel-harness).
99+
The most important Qt dependency of PEB is not ``QtWebKit``, but ``QNetworkAccessManager`` which is used to implement the local pseudo-domain and most of the requests to local content. Unfortunately ``QNetworkAccessManager`` is incompatible with ``QtWebEngine`` - the new Blink-based web engine of Qt. The transition to ``QtWebEngine`` is impractical because local POST requests and calling local Perl scripts from JavaScript can not be supported. If you want to render the HTML user interface of your Perl desktop application using the Blink web engine, you may use [Electron](http://electron.atom.io/) or [NW.js](http://nwjs.io/) combined with [camel-harness](https://github.com/ddmitov/camel-harness).
100100

101101
Compiled and tested successfully using:
102102
* [Qt Creator 2.8.1 and Qt 5.1.1](http://download.qt.io/official_releases/qt/5.1/5.1.1/) on 32-bit Debian Linux,
@@ -385,7 +385,7 @@ They have two functions:
385385
```
386386

387387
## Security
388-
Being a GUI for Perl 5 desktop applications, PEB executes with normal user privileges only local Perl scripts in its application directory. Reasonable security restrictions are implemented in C++ code, but they do not constitute a sandbox for Perl scripts.
388+
Being a GUI for Perl 5 desktop applications, PEB executes with normal user privileges only local Perl scripts in its application directory. Reasonable security restrictions are implemented, but they do not constitute a sandbox for Perl scripts.
389389

390390
**PEB security principles:**
391391
* Users have full access to their local data using PEB.
@@ -485,9 +485,9 @@ PEB-based Perl debugger GUI is an idea proposed by Valcho Nedelchev and provoked
485485

486486
Syntax highlighting is achieved using [Syntax::Highlight::Engine::Kate](https://metacpan.org/release/Syntax-Highlight-Engine-Kate) CPAN module by Hans Jeuken and Gábor Szabó.
487487

488-
``{PEB_binary_directory}/perl5dbgui`` is home of the Perl debugger GUI script and the [Syntax::Highlight::Engine::Kate](https://metacpan.org/release/Syntax-Highlight-Engine-Kate) module. This folder and all files inside it should not be removed or renamed for the proper operation of the Perl debugger GUI.
488+
``{PEB_binary_directory}/resources/app/perl5dbgui`` is home of the Perl debugger GUI script and the [Syntax::Highlight::Engine::Kate](https://metacpan.org/release/Syntax-Highlight-Engine-Kate) module. This folder and all files inside it should not be removed or renamed for the proper operation of the Perl debugger GUI.
489489

490-
**Windows caveat:** The [default Perl debugger](http://perldoc.perl.org/perldebug.html) can not work inside PEB on Windows without a small, one-line modification, which makes the ``$console`` variable undefined. Tests proved that this is a minor change and it does not affect the normal operation of the debugger. This alteration is necessary because the ``Qprocess`` Qt class, which is used to handle the Perl debugger, doesn't use any console from the underlying operating system to start processes. Without the modification the debugger is unable to find a console and hangs. You could easily patch your Windows version of ``perl5db.pl`` manually by replacing ``$console = "con";`` with ``undef $console;`` or by using ``{PEB_binary_directory}/perl5dbgui/perl5db-win32.patch``.
490+
**Windows caveat:** The [default Perl debugger](http://perldoc.perl.org/perldebug.html) can not work with PEB on Windows without a small, one-line modification, which makes the ``$console`` variable undefined. Tests proved that this is a minor change and it does not affect the normal operation of the debugger. This alteration is necessary because the ``Qprocess`` class, which is used to handle the Perl debugger, does not use any console from the underlying operating system. Without the modification the debugger is unable to find a console and hangs. You could easily patch your Windows version of ``perl5db.pl`` manually by replacing ``$console = "con";`` with ``undef $console;`` or by using ``{PEB_binary_directory}/resources/app/perl5dbgui/perl5db-win32.patch``.
491491

492492
![PEB Perl Debugger GUI](https://github.com/ddmitov/perl-executing-browser/raw/master/screenshots/peb-perl-debugger.png "PEB HTML Interface for the Perl Debugger")
493493

File renamed without changes.
File renamed without changes.

src/page.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ QPage::QPage()
6060
// No download of files:
6161
setForwardUnsupportedContent(false);
6262

63+
// All links are handled by the application itself:
64+
setLinkDelegationPolicy(QWebPage::DontDelegateLinks);
65+
6366
// Disabled cache:
6467
QWebSettings::setMaximumPagesInCache(0);
6568
QWebSettings::setObjectCacheCapacities(0, 0, 0);

src/page.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -600,12 +600,13 @@ public slots:
600600
// Perl Debugger GUI:
601601
// Implementation of an idea proposed by Valcho Nedelchev
602602
// ==============================
603-
#if PERL_DEBUGGER_GUI == 1
603+
604604
if ((navigationType == QWebPage::NavigationTypeLinkClicked or
605605
navigationType ==
606606
QWebPage::NavigationTypeFormSubmitted) and
607607
request.url().fileName() == "perl-debugger.function") {
608608

609+
#if PERL_DEBUGGER_GUI == 1
609610
if (request.url().toString()
610611
.contains("action=select-file")) {
611612
debuggerHandler = new QPerlDebuggerHandler();
@@ -621,10 +622,11 @@ public slots:
621622
}
622623

623624
debuggerHandler->qHandleDebuggerSlot(request.url());
625+
#endif
624626

625627
return false;
626628
}
627-
#endif
629+
628630
}
629631

630632
if (pageStatus == "untrusted") {
@@ -799,7 +801,9 @@ public slots:
799801
QString yesLabel;
800802
QString noLabel;
801803

804+
#if PERL_DEBUGGER_GUI == 1
802805
QPerlDebuggerHandler *debuggerHandler;
806+
#endif
803807

804808
public:
805809
QPage();

src/perl-debugger-handler.h

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -84,20 +84,21 @@ public slots:
8484
// Formatting of Perl debugger output is started only after
8585
// the final command prompt comes out of the debugger:
8686
if (debuggerAccumulatedOutput.contains(QRegExp ("DB\\<\\d{1,5}\\>"))) {
87-
QUrl debuggerOutputFormatterUrl =
88-
QUrl::fromLocalFile(
89-
QDir::toNativeSeparators(
90-
QApplication::applicationDirPath()) +
91-
"/perl5dbgui/perl5dbgui.pl");
87+
88+
QString debuggerOutputFormatterFilePath =
89+
"http://" +
90+
QString(qApp->property("pseudoDomain").toString()) +
91+
"/perl5dbgui/perl5dbgui.pl";
9292

9393
QByteArray debuggerOutputArray;
9494
debuggerOutputArray.append(debuggerAccumulatedOutput.toLatin1());
9595

96-
// Clean any previous debugger output:
97-
debuggerAccumulatedOutput = "";
9896

99-
startDebuggerFormatterSignal(debuggerOutputFormatterUrl,
97+
startDebuggerFormatterSignal(QUrl(debuggerOutputFormatterFilePath),
10098
debuggerOutputArray);
99+
100+
// Clean any previous debugger output:
101+
debuggerAccumulatedOutput = "";
101102
}
102103
}
103104
private:

0 commit comments

Comments
 (0)