Skip to content
This repository
Browse code

Pass command arguments to the constructor

  • Loading branch information...
commit 85dcc729ddf04800b7efe6433ca1cca3d0d6e605 1 parent b3b1adf
Joe Ferris authored

Showing 48 changed files with 119 additions and 137 deletions. Show diff stats Hide diff stats

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

0 notes on commit 85dcc72

Please sign in to comment.
Something went wrong with that request. Please try again.