From da8aeccd35f99749814fd12ec47159d3307447bd Mon Sep 17 00:00:00 2001 From: Tristan Dunn Date: Thu, 26 Jan 2012 21:40:36 -0600 Subject: [PATCH] Merge in upstream changes for requested URL command and more. --- src/CommandFactory.cpp | 1 + src/RequestedUrl.cpp | 15 +++++++++++++++ src/RequestedUrl.h | 12 ++++++++++++ src/Visit.cpp | 2 +- src/find_command.h | 3 ++- src/webkit_server.js | 6 +++--- src/webkit_server.pro | 3 +++ 7 files changed, 37 insertions(+), 5 deletions(-) create mode 100644 src/RequestedUrl.cpp create mode 100644 src/RequestedUrl.h diff --git a/src/CommandFactory.cpp b/src/CommandFactory.cpp index ed4782a..c81c2c0 100644 --- a/src/CommandFactory.cpp +++ b/src/CommandFactory.cpp @@ -19,6 +19,7 @@ #include "GetCookies.h" #include "SetProxy.h" #include "ConsoleMessages.h" +#include "RequestedUrl.h" CommandFactory::CommandFactory(WebPage *page, QObject *parent) : QObject(parent) { m_page = page; diff --git a/src/RequestedUrl.cpp b/src/RequestedUrl.cpp new file mode 100644 index 0000000..4f7bf93 --- /dev/null +++ b/src/RequestedUrl.cpp @@ -0,0 +1,15 @@ +#include "RequestedUrl.h" +#include "WebPage.h" + +RequestedUrl::RequestedUrl(WebPage *page, QObject *parent) : Command(page, parent) { +} + +void RequestedUrl::start(QStringList &arguments) { + Q_UNUSED(arguments); + + QUrl humanUrl = page()->currentFrame()->requestedUrl(); + QByteArray encodedBytes = humanUrl.toEncoded(); + QString urlString = QString(encodedBytes); + emit finished(new Response(true, urlString)); +} + diff --git a/src/RequestedUrl.h b/src/RequestedUrl.h new file mode 100644 index 0000000..e90a1dc --- /dev/null +++ b/src/RequestedUrl.h @@ -0,0 +1,12 @@ +#include "Command.h" + +class WebPage; + +class RequestedUrl : public Command { + Q_OBJECT + + public: + RequestedUrl(WebPage *page, QObject *parent = 0); + virtual void start(QStringList &arguments); +}; + diff --git a/src/Visit.cpp b/src/Visit.cpp index a50e3f4..2e819f3 100644 --- a/src/Visit.cpp +++ b/src/Visit.cpp @@ -7,7 +7,7 @@ Visit::Visit(WebPage *page, QObject *parent) : Command(page, parent) { } void Visit::start(QStringList &arguments) { - QUrl requestedUrl = QUrl(arguments[0]); + QUrl requestedUrl = QUrl::fromEncoded(arguments[0].toUtf8(), QUrl::StrictMode); page()->currentFrame()->load(QUrl(requestedUrl)); } diff --git a/src/find_command.h b/src/find_command.h index 23681ca..152c2fa 100644 --- a/src/find_command.h +++ b/src/find_command.h @@ -22,4 +22,5 @@ CHECK_COMMAND(ClearCookies) CHECK_COMMAND(GetCookies) CHECK_COMMAND(Headers) CHECK_COMMAND(SetProxy) -CHECK_COMMAND(ConsoleMessages) \ No newline at end of file +CHECK_COMMAND(ConsoleMessages) +CHECK_COMMAND(RequestedUrl) diff --git a/src/webkit_server.js b/src/webkit_server.js index 61709be..a8f5acc 100644 --- a/src/webkit_server.js +++ b/src/webkit_server.js @@ -103,7 +103,7 @@ window.WebKitServer = { set: function(index, value) { var node = this.nodes[index], type = (node.type || node.tagName).toLowerCase(), - textTypes = ["email", "password", "search", "text", "textarea", "url"]; + textTypes = ["email", "number", "password", "search", "tel", "text", "textarea", "url"]; if (textTypes.indexOf(type) !== -1) { this.trigger(index, "focus"); @@ -127,12 +127,12 @@ window.WebKitServer = { this.trigger(index, "change"); this.trigger(index, "blur"); - } else if (type == "checkbox" || type == "radio") { + } else if (type === "checkbox" || type === "radio") { node.checked = (value == "true"); this.trigger(index, "click"); this.trigger(index, "change"); - } else if (type == "file") { + } else if (type === "file") { this.lastAttachedFile = value; this.trigger(index, "click"); } else { diff --git a/src/webkit_server.pro b/src/webkit_server.pro index c863ab9..3e31143 100644 --- a/src/webkit_server.pro +++ b/src/webkit_server.pro @@ -2,6 +2,7 @@ TEMPLATE = app TARGET = webkit_server DESTDIR = . HEADERS = \ + RequestedUrl.h \ ConsoleMessages.h \ WebPage.h \ Server.h \ @@ -34,6 +35,7 @@ HEADERS = \ SetProxy.h \ SOURCES = \ + RequestedUrl.cpp \ ConsoleMessages.cpp \ main.cpp \ WebPage.cpp \ @@ -70,3 +72,4 @@ RESOURCES = webkit_server.qrc QT += network webkit CONFIG += console CONFIG -= app_bundle +