Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Pass command arguments to the constructor

  • Loading branch information...
commit 85dcc729ddf04800b7efe6433ca1cca3d0d6e605 1 parent b3b1adf
@jferris jferris authored
Showing with 119 additions and 137 deletions.
  1. +2 −2 src/Body.h
  2. +2 −5 src/ClearCookies.cpp
  3. +2 −2 src/ClearCookies.h
  4. +7 −3 src/Command.cpp
  5. +4 −2 src/Command.h
  6. +1 −1  src/CommandFactory.cpp
  7. +1 −1  src/CommandFactory.h
  8. +2 −2 src/Connection.cpp
  9. +2 −3 src/ConsoleMessages.cpp
  10. +2 −2 src/ConsoleMessages.h
  11. +2 −4 src/CurrentUrl.cpp
  12. +2 −2 src/CurrentUrl.h
  13. +3 −3 src/Evaluate.cpp
  14. +2 −2 src/Evaluate.h
  15. +3 −3 src/Execute.cpp
  16. +2 −2 src/Execute.h
  17. +3 −3 src/Find.cpp
  18. +2 −2 src/Find.h
  19. +5 −5 src/FrameFocus.cpp
  20. +2 −2 src/FrameFocus.h
  21. +2 −4 src/GetCookies.cpp
  22. +2 −2 src/GetCookies.h
  23. +4 −4 src/Header.cpp
  24. +2 −2 src/Header.h
  25. +2 −3 src/Headers.cpp
  26. +2 −2 src/Headers.h
  27. +3 −3 src/Node.cpp
  28. +2 −2 src/Node.h
  29. +5 −6 src/Render.cpp
  30. +2 −2 src/Render.h
  31. +2 −4 src/RequestedUrl.cpp
  32. +2 −2 src/RequestedUrl.h
  33. +2 −4 src/Reset.cpp
  34. +2 −2 src/Reset.h
  35. +3 −5 src/SetCookie.cpp
  36. +2 −2 src/SetCookie.h
  37. +7 −9 src/SetProxy.cpp
  38. +2 −2 src/SetProxy.h
  39. +2 −4 src/Source.cpp
  40. +2 −2 src/Source.h
  41. +2 −3 src/Status.cpp
  42. +2 −2 src/Status.h
  43. +2 −4 src/Url.cpp
  44. +2 −2 src/Url.h
  45. +3 −3 src/Visit.cpp
  46. +2 −2 src/Visit.h
  47. +2 −3 src/body.cpp
  48. +1 −1  src/find_command.h
View
4 src/Body.h
@@ -6,7 +6,7 @@ class Body : public Command {
Q_OBJECT
public:
- Body(WebPage *page, QObject *parent = 0);
- virtual void start(QStringList &arguments);
+ Body(WebPage *page, QStringList &arguments, QObject *parent = 0);
+ virtual void start();
};
View
7 src/ClearCookies.cpp
@@ -3,13 +3,10 @@
#include "NetworkCookieJar.h"
#include <QNetworkCookie>
-ClearCookies::ClearCookies(WebPage *page, QObject *parent)
- : Command(page, parent)
-{ }
+ClearCookies::ClearCookies(WebPage *page, QStringList &arguments, QObject *parent) : Command(page, arguments, parent) {}
-void ClearCookies::start(QStringList &arguments)
+void ClearCookies::start()
{
- Q_UNUSED(arguments);
NetworkCookieJar *jar = qobject_cast<NetworkCookieJar*>(page()
->networkAccessManager()
->cookieJar());
View
4 src/ClearCookies.h
@@ -6,6 +6,6 @@ class ClearCookies : public Command {
Q_OBJECT;
public:
- ClearCookies(WebPage *page, QObject *parent = 0);
- virtual void start(QStringList &arguments);
+ ClearCookies(WebPage *page, QStringList &arguments, QObject *parent = 0);
+ virtual void start();
};
View
10 src/Command.cpp
@@ -1,15 +1,19 @@
#include "Command.h"
#include "WebPage.h"
-Command::Command(WebPage *page, QObject *parent) : QObject(parent) {
+Command::Command(WebPage *page, QStringList &arguments, QObject *parent) : QObject(parent) {
m_page = page;
+ m_arguments = arguments;
}
-void Command::start(QStringList &arguments) {
- Q_UNUSED(arguments);
+void Command::start() {
}
WebPage *Command::page() {
return m_page;
}
+QStringList &Command::arguments() {
+ return m_arguments;
+}
+
View
6 src/Command.h
@@ -11,17 +11,19 @@ class Command : public QObject {
Q_OBJECT
public:
- Command(WebPage *page, QObject *parent = 0);
- virtual void start(QStringList &arguments);
+ Command(WebPage *page, QStringList &arguments, QObject *parent = 0);
+ virtual void start();
signals:
void finished(Response *response);
protected:
WebPage *page();
+ QStringList &arguments();
private:
WebPage *m_page;
+ QStringList m_arguments;
};
View
2  src/CommandFactory.cpp
@@ -26,7 +26,7 @@ CommandFactory::CommandFactory(WebPage *page, QObject *parent) : QObject(parent)
m_page = page;
}
-Command *CommandFactory::createCommand(const char *name) {
+Command *CommandFactory::createCommand(const char *name, QStringList &arguments) {
#include "find_command.h"
return NULL;
}
View
2  src/CommandFactory.h
@@ -8,7 +8,7 @@ class CommandFactory : public QObject {
public:
CommandFactory(WebPage *page, QObject *parent = 0);
- Command *createCommand(const char *name);
+ Command *createCommand(const char *name, QStringList &arguments);
private:
WebPage *m_page;
View
4 src/Connection.cpp
@@ -38,14 +38,14 @@ void Connection::commandReady(QString commandName, QStringList arguments) {
void Connection::startCommand() {
m_commandWaiting = false;
if (m_pageSuccess) {
- m_command = m_commandFactory->createCommand(m_commandName.toAscii().constData());
+ m_command = m_commandFactory->createCommand(m_commandName.toAscii().constData(), m_arguments);
if (m_command) {
connect(m_page, SIGNAL(loadStarted()), this, SLOT(pageLoadingFromCommand()));
connect(m_command,
SIGNAL(finished(Response *)),
this,
SLOT(finishCommand(Response *)));
- m_command->start(m_arguments);
+ m_command->start();
} else {
QString failure = QString("[Capybara WebKit] Unknown command: ") + m_commandName + "\n";
writeResponse(new Response(false, failure));
View
5 src/ConsoleMessages.cpp
@@ -1,11 +1,10 @@
#include "ConsoleMessages.h"
#include "WebPage.h"
-ConsoleMessages::ConsoleMessages(WebPage *page, QObject *parent) : Command(page, parent) {
+ConsoleMessages::ConsoleMessages(WebPage *page, QStringList &arguments, QObject *parent) : Command(page, arguments, parent) {
}
-void ConsoleMessages::start(QStringList &arguments) {
- Q_UNUSED(arguments);
+void ConsoleMessages::start() {
emit finished(new Response(true, page()->consoleMessages()));
}
View
4 src/ConsoleMessages.h
@@ -6,7 +6,7 @@ class ConsoleMessages : public Command {
Q_OBJECT
public:
- ConsoleMessages(WebPage *page, QObject *parent = 0);
- virtual void start(QStringList &arguments);
+ ConsoleMessages(WebPage *page, QStringList &arguments, QObject *parent = 0);
+ virtual void start();
};
View
6 src/CurrentUrl.cpp
@@ -1,7 +1,7 @@
#include "CurrentUrl.h"
#include "WebPage.h"
-CurrentUrl::CurrentUrl(WebPage *page, QObject *parent) : Command(page, parent) {
+CurrentUrl::CurrentUrl(WebPage *page, QStringList &arguments, QObject *parent) : Command(page, arguments, parent) {
}
/*
@@ -51,9 +51,7 @@ CurrentUrl::CurrentUrl(WebPage *page, QObject *parent) : Command(page, parent) {
* redirect w/o pushState, in which case QWebFrame->url() will have the correct
* current_url value. In all other cases QWebFrame->requestedUrl() is correct.
*/
-void CurrentUrl::start(QStringList &arguments) {
- Q_UNUSED(arguments);
-
+void CurrentUrl::start() {
QUrl humanUrl = wasRedirectedAndNotModifiedByJavascript() ?
page()->currentFrame()->url() : page()->currentFrame()->requestedUrl();
QByteArray encodedBytes = humanUrl.toEncoded();
View
4 src/CurrentUrl.h
@@ -6,8 +6,8 @@ class CurrentUrl : public Command {
Q_OBJECT
public:
- CurrentUrl(WebPage *page, QObject *parent = 0);
- virtual void start(QStringList &arguments);
+ CurrentUrl(WebPage *page, QStringList &arguments, QObject *parent = 0);
+ virtual void start();
private:
bool wasRegularLoad();
View
6 src/Evaluate.cpp
@@ -2,12 +2,12 @@
#include "WebPage.h"
#include <iostream>
-Evaluate::Evaluate(WebPage *page, QObject *parent) : Command(page, parent) {
+Evaluate::Evaluate(WebPage *page, QStringList &arguments, QObject *parent) : Command(page, arguments, parent) {
m_buffer = "";
}
-void Evaluate::start(QStringList &arguments) {
- QVariant result = page()->currentFrame()->evaluateJavaScript(arguments[0]);
+void Evaluate::start() {
+ QVariant result = page()->currentFrame()->evaluateJavaScript(arguments()[0]);
addVariant(result);
emit finished(new Response(true, m_buffer));
}
View
4 src/Evaluate.h
@@ -8,8 +8,8 @@ class Evaluate : public Command {
Q_OBJECT
public:
- Evaluate(WebPage *page, QObject *parent = 0);
- virtual void start(QStringList &arguments);
+ Evaluate(WebPage *page, QStringList &arguments, QObject *parent = 0);
+ virtual void start();
private:
void addVariant(QVariant &object);
View
6 src/Execute.cpp
@@ -1,11 +1,11 @@
#include "Execute.h"
#include "WebPage.h"
-Execute::Execute(WebPage *page, QObject *parent) : Command(page, parent) {
+Execute::Execute(WebPage *page, QStringList &arguments, QObject *parent) : Command(page, arguments, parent) {
}
-void Execute::start(QStringList &arguments) {
- QString script = arguments[0] + QString("; 'success'");
+void Execute::start() {
+ QString script = arguments()[0] + QString("; 'success'");
QVariant result = page()->currentFrame()->evaluateJavaScript(script);
if (result.isValid()) {
emit finished(new Response(true));
View
4 src/Execute.h
@@ -6,7 +6,7 @@ class Execute : public Command {
Q_OBJECT
public:
- Execute(WebPage *page, QObject *parent = 0);
- virtual void start(QStringList &arguments);
+ Execute(WebPage *page, QStringList &arguments, QObject *parent = 0);
+ virtual void start();
};
View
6 src/Find.cpp
@@ -2,12 +2,12 @@
#include "Command.h"
#include "WebPage.h"
-Find::Find(WebPage *page, QObject *parent) : Command(page, parent) {
+Find::Find(WebPage *page, QStringList &arguments, QObject *parent) : Command(page, arguments, parent) {
}
-void Find::start(QStringList &arguments) {
+void Find::start() {
QString message;
- QVariant result = page()->invokeCapybaraFunction("find", arguments);
+ QVariant result = page()->invokeCapybaraFunction("find", arguments());
if (result.isValid()) {
message = result.toString();
View
4 src/Find.h
@@ -6,8 +6,8 @@ class Find : public Command {
Q_OBJECT
public:
- Find(WebPage *page, QObject *parent = 0);
- virtual void start(QStringList &arguments);
+ Find(WebPage *page, QStringList &arguments, QObject *parent = 0);
+ virtual void start();
};
View
10 src/FrameFocus.cpp
@@ -2,17 +2,17 @@
#include "Command.h"
#include "WebPage.h"
-FrameFocus::FrameFocus(WebPage *page, QObject *parent) : Command(page, parent) {
+FrameFocus::FrameFocus(WebPage *page, QStringList &arguments, QObject *parent) : Command(page, arguments, parent) {
}
-void FrameFocus::start(QStringList &arguments) {
+void FrameFocus::start() {
findFrames();
- switch(arguments.length()) {
+ switch(arguments().length()) {
case 1:
- focusId(arguments[0]);
+ focusId(arguments()[0]);
break;
case 2:
- focusIndex(arguments[1].toInt());
+ focusIndex(arguments()[1].toInt());
break;
default:
focusParent();
View
4 src/FrameFocus.h
@@ -7,8 +7,8 @@ class FrameFocus : public Command {
Q_OBJECT
public:
- FrameFocus(WebPage *page, QObject *parent = 0);
- virtual void start(QStringList &arguments);
+ FrameFocus(WebPage *page, QStringList &arguments, QObject *parent = 0);
+ virtual void start();
private:
void findFrames();
View
6 src/GetCookies.cpp
@@ -2,15 +2,13 @@
#include "WebPage.h"
#include "NetworkCookieJar.h"
-GetCookies::GetCookies(WebPage *page, QObject *parent)
- : Command(page, parent)
+GetCookies::GetCookies(WebPage *page, QStringList &arguments, QObject *parent) : Command(page, arguments, parent)
{
m_buffer = "";
}
-void GetCookies::start(QStringList &arguments)
+void GetCookies::start()
{
- Q_UNUSED(arguments);
NetworkCookieJar *jar = qobject_cast<NetworkCookieJar*>(page()
->networkAccessManager()
->cookieJar());
View
4 src/GetCookies.h
@@ -6,8 +6,8 @@ class GetCookies : public Command {
Q_OBJECT;
public:
- GetCookies(WebPage *page, QObject *parent = 0);
- virtual void start(QStringList &arguments);
+ GetCookies(WebPage *page, QStringList &arguments, QObject *parent = 0);
+ virtual void start();
private:
QString m_buffer;
View
8 src/Header.cpp
@@ -2,12 +2,12 @@
#include "WebPage.h"
#include "NetworkAccessManager.h"
-Header::Header(WebPage *page, QObject *parent) : Command(page, parent) {
+Header::Header(WebPage *page, QStringList &arguments, QObject *parent) : Command(page, arguments, parent) {
}
-void Header::start(QStringList &arguments) {
- QString key = arguments[0];
- QString value = arguments[1];
+void Header::start() {
+ QString key = arguments()[0];
+ QString value = arguments()[1];
NetworkAccessManager* networkAccessManager = qobject_cast<NetworkAccessManager*>(page()->networkAccessManager());
if (key.toLower().replace("-", "_") == "user_agent") {
page()->setUserAgent(value);
View
4 src/Header.h
@@ -6,6 +6,6 @@ class Header : public Command {
Q_OBJECT
public:
- Header(WebPage *page, QObject *parent = 0);
- virtual void start(QStringList &arguments);
+ Header(WebPage *page, QStringList &arguments, QObject *parent = 0);
+ virtual void start();
};
View
5 src/Headers.cpp
@@ -1,11 +1,10 @@
#include "Headers.h"
#include "WebPage.h"
-Headers::Headers(WebPage *page, QObject *parent) : Command(page, parent) {
+Headers::Headers(WebPage *page, QStringList &arguments, QObject *parent) : Command(page, arguments, parent) {
}
-void Headers::start(QStringList &arguments) {
- Q_UNUSED(arguments);
+void Headers::start() {
emit finished(new Response(true, page()->pageHeaders()));
}
View
4 src/Headers.h
@@ -6,7 +6,7 @@ class Headers : public Command {
Q_OBJECT
public:
- Headers(WebPage *page, QObject *parent = 0);
- virtual void start(QStringList &arguments);
+ Headers(WebPage *page, QStringList &arguments, QObject *parent = 0);
+ virtual void start();
};
View
6 src/Node.cpp
@@ -1,11 +1,11 @@
#include "Node.h"
#include "WebPage.h"
-Node::Node(WebPage *page, QObject *parent) : Command(page, parent) {
+Node::Node(WebPage *page, QStringList &arguments, QObject *parent) : Command(page, arguments, parent) {
}
-void Node::start(QStringList &arguments) {
- QStringList functionArguments(arguments);
+void Node::start() {
+ QStringList functionArguments(arguments());
QString functionName = functionArguments.takeFirst();
QVariant result = page()->invokeCapybaraFunction(functionName, functionArguments);
QString attributeValue = result.toString();
View
4 src/Node.h
@@ -7,7 +7,7 @@ class Node : public Command {
Q_OBJECT
public:
- Node(WebPage *page, QObject *parent = 0);
- virtual void start(QStringList &arguments);
+ Node(WebPage *page, QStringList &arguments, QObject *parent = 0);
+ virtual void start();
};
View
11 src/Render.cpp
@@ -1,14 +1,13 @@
#include "Render.h"
#include "WebPage.h"
-Render::Render(WebPage *page, QObject *parent) : Command(page, parent) {
+Render::Render(WebPage *page, QStringList &arguments, QObject *parent) : Command(page, arguments, parent) {
}
-void Render::start(QStringList &arguments) {
- QStringList functionArguments(arguments);
- QString imagePath = functionArguments.takeFirst();
- int width = functionArguments.takeFirst().toInt();
- int height = functionArguments.takeFirst().toInt();
+void Render::start() {
+ QString imagePath = arguments()[0];
+ int width = arguments()[1].toInt();
+ int height = arguments()[2].toInt();
QSize size(width, height);
page()->setViewportSize(size);
View
4 src/Render.h
@@ -7,6 +7,6 @@ class Render : public Command {
Q_OBJECT
public:
- Render(WebPage *page, QObject *parent = 0);
- virtual void start(QStringList &arguments);
+ Render(WebPage *page, QStringList &arguments, QObject *parent = 0);
+ virtual void start();
};
View
6 src/RequestedUrl.cpp
@@ -1,12 +1,10 @@
#include "RequestedUrl.h"
#include "WebPage.h"
-RequestedUrl::RequestedUrl(WebPage *page, QObject *parent) : Command(page, parent) {
+RequestedUrl::RequestedUrl(WebPage *page, QStringList &arguments, QObject *parent) : Command(page, arguments, parent) {
}
-void RequestedUrl::start(QStringList &arguments) {
- Q_UNUSED(arguments);
-
+void RequestedUrl::start() {
QUrl humanUrl = page()->currentFrame()->requestedUrl();
QByteArray encodedBytes = humanUrl.toEncoded();
QString urlString = QString(encodedBytes);
View
4 src/RequestedUrl.h
@@ -6,7 +6,7 @@ class RequestedUrl : public Command {
Q_OBJECT
public:
- RequestedUrl(WebPage *page, QObject *parent = 0);
- virtual void start(QStringList &arguments);
+ RequestedUrl(WebPage *page, QStringList &arguments, QObject *parent = 0);
+ virtual void start();
};
View
6 src/Reset.cpp
@@ -3,12 +3,10 @@
#include "NetworkAccessManager.h"
#include "NetworkCookieJar.h"
-Reset::Reset(WebPage *page, QObject *parent) : Command(page, parent) {
+Reset::Reset(WebPage *page, QStringList &arguments, QObject *parent) : Command(page, arguments, parent) {
}
-void Reset::start(QStringList &arguments) {
- Q_UNUSED(arguments);
-
+void Reset::start() {
page()->triggerAction(QWebPage::Stop);
page()->networkAccessManager()->setCookieJar(new NetworkCookieJar());
page()->setCustomNetworkAccessManager();
View
4 src/Reset.h
@@ -6,8 +6,8 @@ class Reset : public Command {
Q_OBJECT
public:
- Reset(WebPage *page, QObject *parent = 0);
- virtual void start(QStringList &arguments);
+ Reset(WebPage *page, QStringList &arguments, QObject *parent = 0);
+ virtual void start();
private:
void resetHistory();
View
8 src/SetCookie.cpp
@@ -3,13 +3,11 @@
#include "NetworkCookieJar.h"
#include <QNetworkCookie>
-SetCookie::SetCookie(WebPage *page, QObject *parent)
- : Command(page, parent)
-{ }
+SetCookie::SetCookie(WebPage *page, QStringList &arguments, QObject *parent) : Command(page, arguments, parent) {}
-void SetCookie::start(QStringList &arguments)
+void SetCookie::start()
{
- QList<QNetworkCookie> cookies = QNetworkCookie::parseCookies(arguments[0].toAscii());
+ QList<QNetworkCookie> cookies = QNetworkCookie::parseCookies(arguments()[0].toAscii());
NetworkCookieJar *jar = qobject_cast<NetworkCookieJar*>(page()
->networkAccessManager()
->cookieJar());
View
4 src/SetCookie.h
@@ -6,6 +6,6 @@ class SetCookie : public Command {
Q_OBJECT;
public:
- SetCookie(WebPage *page, QObject *parent = 0);
- virtual void start(QStringList &arguments);
+ SetCookie(WebPage *page, QStringList &arguments, QObject *parent = 0);
+ virtual void start();
};
View
16 src/SetProxy.cpp
@@ -3,21 +3,19 @@
#include <QNetworkAccessManager>
#include <QNetworkProxy>
-SetProxy::SetProxy(WebPage *page, QObject *parent)
- : Command(page, parent)
-{ }
+SetProxy::SetProxy(WebPage *page, QStringList &arguments, QObject *parent) : Command(page, arguments, parent) {}
-void SetProxy::start(QStringList &arguments)
+void SetProxy::start()
{
// default to empty proxy
QNetworkProxy proxy;
- if (arguments.size() > 0)
+ if (arguments().size() > 0)
proxy = QNetworkProxy(QNetworkProxy::HttpProxy,
- arguments[0],
- (quint16)(arguments[1].toInt()),
- arguments[2],
- arguments[3]);
+ arguments()[0],
+ (quint16)(arguments()[1].toInt()),
+ arguments()[2],
+ arguments()[3]);
page()->networkAccessManager()->setProxy(proxy);
emit finished(new Response(true));
View
4 src/SetProxy.h
@@ -6,6 +6,6 @@ class SetProxy : public Command {
Q_OBJECT;
public:
- SetProxy(WebPage *page, QObject *parent = 0);
- virtual void start(QStringList &arguments);
+ SetProxy(WebPage *page, QStringList &arguments, QObject *parent = 0);
+ virtual void start();
};
View
6 src/Source.cpp
@@ -1,12 +1,10 @@
#include "Source.h"
#include "WebPage.h"
-Source::Source(WebPage *page, QObject *parent) : Command(page, parent) {
+Source::Source(WebPage *page, QStringList &arguments, QObject *parent) : Command(page, arguments, parent) {
}
-void Source::start(QStringList &arguments) {
- Q_UNUSED(arguments)
-
+void Source::start() {
QNetworkAccessManager* accessManager = page()->networkAccessManager();
QNetworkRequest request(page()->currentFrame()->url());
reply = accessManager->get(request);
View
4 src/Source.h
@@ -7,8 +7,8 @@ class Source : public Command {
Q_OBJECT
public:
- Source(WebPage *page, QObject *parent = 0);
- virtual void start(QStringList &arguments);
+ Source(WebPage *page, QStringList &arguments, QObject *parent = 0);
+ virtual void start();
public slots:
void sourceLoaded();
View
5 src/Status.cpp
@@ -2,11 +2,10 @@
#include "WebPage.h"
#include <sstream>
-Status::Status(WebPage *page, QObject *parent) : Command(page, parent) {
+Status::Status(WebPage *page, QStringList &arguments, QObject *parent) : Command(page, arguments, parent) {
}
-void Status::start(QStringList &arguments) {
- Q_UNUSED(arguments);
+void Status::start() {
int status = page()->getLastStatus();
emit finished(new Response(true, QString::number(status)));
}
View
4 src/Status.h
@@ -6,7 +6,7 @@ class Status : public Command {
Q_OBJECT
public:
- Status(WebPage *page, QObject *parent = 0);
- virtual void start(QStringList &arguments);
+ Status(WebPage *page, QStringList &arguments, QObject *parent = 0);
+ virtual void start();
};
View
6 src/Url.cpp
@@ -1,12 +1,10 @@
#include "Url.h"
#include "WebPage.h"
-Url::Url(WebPage *page, QObject *parent) : Command(page, parent) {
+Url::Url(WebPage *page, QStringList &arguments, QObject *parent) : Command(page, arguments, parent) {
}
-void Url::start(QStringList &argments) {
- Q_UNUSED(argments);
-
+void Url::start() {
QUrl humanUrl = page()->currentFrame()->url();
QByteArray encodedBytes = humanUrl.toEncoded();
QString urlString = QString(encodedBytes);
View
4 src/Url.h
@@ -6,7 +6,7 @@ class Url : public Command {
Q_OBJECT
public:
- Url(WebPage *page, QObject *parent = 0);
- virtual void start(QStringList &argments);
+ Url(WebPage *page, QStringList &arguments, QObject *parent = 0);
+ virtual void start();
};
View
6 src/Visit.cpp
@@ -2,11 +2,11 @@
#include "Command.h"
#include "WebPage.h"
-Visit::Visit(WebPage *page, QObject *parent) : Command(page, parent) {
+Visit::Visit(WebPage *page, QStringList &arguments, QObject *parent) : Command(page, arguments, parent) {
}
-void Visit::start(QStringList &arguments) {
- QUrl requestedUrl = QUrl::fromEncoded(arguments[0].toUtf8(), QUrl::StrictMode);
+void Visit::start() {
+ QUrl requestedUrl = QUrl::fromEncoded(arguments()[0].toUtf8(), QUrl::StrictMode);
page()->currentFrame()->load(QUrl(requestedUrl));
emit finished(new Response(true));
}
View
4 src/Visit.h
@@ -6,7 +6,7 @@ class Visit : public Command {
Q_OBJECT
public:
- Visit(WebPage *page, QObject *parent = 0);
- virtual void start(QStringList &arguments);
+ Visit(WebPage *page, QStringList &arguments, QObject *parent = 0);
+ virtual void start();
};
View
5 src/body.cpp
@@ -1,11 +1,10 @@
#include "Body.h"
#include "WebPage.h"
-Body::Body(WebPage *page, QObject *parent) : Command(page, parent) {
+Body::Body(WebPage *page, QStringList &arguments, QObject *parent) : Command(page, arguments, parent) {
}
-void Body::start(QStringList &arguments) {
- Q_UNUSED(arguments);
+void Body::start() {
QString result = page()->currentFrame()->toHtml();
emit finished(new Response(true, result));
}
View
2  src/find_command.h
@@ -1,6 +1,6 @@
#define CHECK_COMMAND(expectedName) \
if (strcmp(#expectedName, name) == 0) { \
- return new expectedName(m_page, this); \
+ return new expectedName(m_page, arguments, this); \
}
CHECK_COMMAND(Visit)
Please sign in to comment.
Something went wrong with that request. Please try again.