mirror of
https://github.com/thoughtbot/capybara-webkit
synced 2023-03-27 23:22:28 -04:00
Split Command into more abstract Command and concrete SocketCommand
This commit is contained in:
parent
d9b18985e1
commit
95732ad796
71 changed files with 162 additions and 140 deletions
|
@ -2,7 +2,7 @@
|
|||
#include "WebPage.h"
|
||||
#include "NetworkAccessManager.h"
|
||||
|
||||
Authenticate::Authenticate(WebPageManager *manager, QStringList &arguments, QObject *parent) : Command(manager, arguments, parent) {
|
||||
Authenticate::Authenticate(WebPageManager *manager, QStringList &arguments, QObject *parent) : SocketCommand(manager, arguments, parent) {
|
||||
}
|
||||
|
||||
void Authenticate::start() {
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#include "Command.h"
|
||||
#include "SocketCommand.h"
|
||||
|
||||
class WebPage;
|
||||
|
||||
class Authenticate : public Command {
|
||||
class Authenticate : public SocketCommand {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "Command.h"
|
||||
#include "SocketCommand.h"
|
||||
|
||||
class Body : public Command {
|
||||
class Body : public SocketCommand {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include "NetworkCookieJar.h"
|
||||
#include <QNetworkCookie>
|
||||
|
||||
ClearCookies::ClearCookies(WebPageManager *manager, QStringList &arguments, QObject *parent) : Command(manager, arguments, parent) {}
|
||||
ClearCookies::ClearCookies(WebPageManager *manager, QStringList &arguments, QObject *parent) : SocketCommand(manager, arguments, parent) {}
|
||||
|
||||
void ClearCookies::start()
|
||||
{
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "Command.h"
|
||||
#include "SocketCommand.h"
|
||||
|
||||
class ClearCookies : public Command {
|
||||
class ClearCookies : public SocketCommand {
|
||||
Q_OBJECT;
|
||||
|
||||
public:
|
||||
|
|
|
@ -1,27 +1,8 @@
|
|||
#include "Command.h"
|
||||
#include "WebPage.h"
|
||||
#include "WebPageManager.h"
|
||||
#include "SocketCommand.h"
|
||||
|
||||
Command::Command(WebPageManager *manager, QStringList &arguments, QObject *parent) : QObject(parent) {
|
||||
m_manager = manager;
|
||||
m_arguments = arguments;
|
||||
}
|
||||
|
||||
void Command::start() {
|
||||
Command::Command(QObject *parent) : QObject(parent) {
|
||||
}
|
||||
|
||||
QString Command::toString() const {
|
||||
return metaObject()->className();
|
||||
}
|
||||
|
||||
WebPage *Command::page() const {
|
||||
return m_manager->currentPage();
|
||||
}
|
||||
|
||||
const QStringList &Command::arguments() const {
|
||||
return m_arguments;
|
||||
}
|
||||
|
||||
WebPageManager *Command::manager() const {
|
||||
return m_manager;
|
||||
}
|
||||
|
|
|
@ -2,32 +2,18 @@
|
|||
#define COMMAND_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QStringList>
|
||||
#include "Response.h"
|
||||
|
||||
class WebPage;
|
||||
class WebPageManager;
|
||||
|
||||
class Command : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Command(WebPageManager *, QStringList &arguments, QObject *parent = 0);
|
||||
virtual void start();
|
||||
Command(QObject *parent = 0);
|
||||
virtual void start() = 0;
|
||||
virtual QString toString() const;
|
||||
|
||||
signals:
|
||||
void finished(Response *response);
|
||||
|
||||
protected:
|
||||
WebPage *page() const;
|
||||
const QStringList &arguments() const;
|
||||
WebPageManager *manager() const;
|
||||
|
||||
private:
|
||||
QStringList m_arguments;
|
||||
WebPageManager *m_manager;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#include "CommandFactory.h"
|
||||
#include "NullCommand.h"
|
||||
#include "SocketCommand.h"
|
||||
#include "Visit.h"
|
||||
#include "Find.h"
|
||||
#include "Command.h"
|
||||
#include "Reset.h"
|
||||
#include "Node.h"
|
||||
#include "Url.h"
|
||||
|
@ -38,7 +38,5 @@ CommandFactory::CommandFactory(WebPageManager *manager, QObject *parent) : QObje
|
|||
|
||||
Command *CommandFactory::createCommand(const char *name, QStringList &arguments) {
|
||||
#include "find_command.h"
|
||||
arguments.clear();
|
||||
arguments.append(QString(name));
|
||||
return new NullCommand(m_manager, arguments);
|
||||
return new NullCommand(QString(name));
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "CommandParser.h"
|
||||
#include "CommandFactory.h"
|
||||
#include "Command.h"
|
||||
#include "SocketCommand.h"
|
||||
|
||||
#include <QIODevice>
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include "CommandParser.h"
|
||||
#include "CommandFactory.h"
|
||||
#include "PageLoadingCommand.h"
|
||||
#include "Command.h"
|
||||
#include "SocketCommand.h"
|
||||
|
||||
#include <QTcpSocket>
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#include "WebPage.h"
|
||||
#include "WebPageManager.h"
|
||||
|
||||
ConsoleMessages::ConsoleMessages(WebPageManager *manager, QStringList &arguments, QObject *parent) : Command(manager, arguments, parent) {
|
||||
ConsoleMessages::ConsoleMessages(WebPageManager *manager, QStringList &arguments, QObject *parent) : SocketCommand(manager, arguments, parent) {
|
||||
}
|
||||
|
||||
void ConsoleMessages::start() {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "Command.h"
|
||||
#include "SocketCommand.h"
|
||||
|
||||
class ConsoleMessages : public Command {
|
||||
class ConsoleMessages : public SocketCommand {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#include "WebPage.h"
|
||||
#include "WebPageManager.h"
|
||||
|
||||
CurrentUrl::CurrentUrl(WebPageManager *manager, QStringList &arguments, QObject *parent) : Command(manager, arguments, parent) {
|
||||
CurrentUrl::CurrentUrl(WebPageManager *manager, QStringList &arguments, QObject *parent) : SocketCommand(manager, arguments, parent) {
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "Command.h"
|
||||
#include "SocketCommand.h"
|
||||
|
||||
class CurrentUrl : public Command {
|
||||
class CurrentUrl : public SocketCommand {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "EnableLogging.h"
|
||||
#include "WebPageManager.h"
|
||||
|
||||
EnableLogging::EnableLogging(WebPageManager *manager, QStringList &arguments, QObject *parent) : Command(manager, arguments, parent) {
|
||||
EnableLogging::EnableLogging(WebPageManager *manager, QStringList &arguments, QObject *parent) : SocketCommand(manager, arguments, parent) {
|
||||
}
|
||||
|
||||
void EnableLogging::start() {
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#include "Command.h"
|
||||
#include "SocketCommand.h"
|
||||
|
||||
class WebPageManager;
|
||||
|
||||
class EnableLogging : public Command {
|
||||
class EnableLogging : public SocketCommand {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#include "WebPageManager.h"
|
||||
#include <iostream>
|
||||
|
||||
Evaluate::Evaluate(WebPageManager *manager, QStringList &arguments, QObject *parent) : Command(manager, arguments, parent) {
|
||||
Evaluate::Evaluate(WebPageManager *manager, QStringList &arguments, QObject *parent) : SocketCommand(manager, arguments, parent) {
|
||||
m_buffer = "";
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#include "Command.h"
|
||||
#include "SocketCommand.h"
|
||||
|
||||
#include <QVariantList>
|
||||
|
||||
class Evaluate : public Command {
|
||||
class Evaluate : public SocketCommand {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#include "WebPage.h"
|
||||
#include "WebPageManager.h"
|
||||
|
||||
Execute::Execute(WebPageManager *manager, QStringList &arguments, QObject *parent) : Command(manager, arguments, parent) {
|
||||
Execute::Execute(WebPageManager *manager, QStringList &arguments, QObject *parent) : SocketCommand(manager, arguments, parent) {
|
||||
}
|
||||
|
||||
void Execute::start() {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "Command.h"
|
||||
#include "SocketCommand.h"
|
||||
|
||||
class Execute : public Command {
|
||||
class Execute : public SocketCommand {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#include "Find.h"
|
||||
#include "Command.h"
|
||||
#include "SocketCommand.h"
|
||||
#include "WebPage.h"
|
||||
#include "WebPageManager.h"
|
||||
|
||||
Find::Find(WebPageManager *manager, QStringList &arguments, QObject *parent) : Command(manager, arguments, parent) {
|
||||
Find::Find(WebPageManager *manager, QStringList &arguments, QObject *parent) : SocketCommand(manager, arguments, parent) {
|
||||
}
|
||||
|
||||
void Find::start() {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "Command.h"
|
||||
#include "SocketCommand.h"
|
||||
|
||||
class Find : public Command {
|
||||
class Find : public SocketCommand {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#include "FrameFocus.h"
|
||||
#include "Command.h"
|
||||
#include "SocketCommand.h"
|
||||
#include "WebPage.h"
|
||||
#include "WebPageManager.h"
|
||||
|
||||
FrameFocus::FrameFocus(WebPageManager *manager, QStringList &arguments, QObject *parent) : Command(manager, arguments, parent) {
|
||||
FrameFocus::FrameFocus(WebPageManager *manager, QStringList &arguments, QObject *parent) : SocketCommand(manager, arguments, parent) {
|
||||
}
|
||||
|
||||
void FrameFocus::start() {
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#include "Command.h"
|
||||
#include "SocketCommand.h"
|
||||
|
||||
class QWebFrame;
|
||||
|
||||
class FrameFocus : public Command {
|
||||
class FrameFocus : public SocketCommand {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#include "WebPageManager.h"
|
||||
#include "NetworkCookieJar.h"
|
||||
|
||||
GetCookies::GetCookies(WebPageManager *manager, QStringList &arguments, QObject *parent) : Command(manager, arguments, parent)
|
||||
GetCookies::GetCookies(WebPageManager *manager, QStringList &arguments, QObject *parent) : SocketCommand(manager, arguments, parent)
|
||||
{
|
||||
m_buffer = "";
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "Command.h"
|
||||
#include "SocketCommand.h"
|
||||
|
||||
class GetCookies : public Command {
|
||||
class GetCookies : public SocketCommand {
|
||||
Q_OBJECT;
|
||||
|
||||
public:
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#include "WebPageManager.h"
|
||||
#include <QStringList>
|
||||
|
||||
GetWindowHandle::GetWindowHandle(WebPageManager *manager, QStringList &arguments, QObject *parent) : Command(manager, arguments, parent) {
|
||||
GetWindowHandle::GetWindowHandle(WebPageManager *manager, QStringList &arguments, QObject *parent) : SocketCommand(manager, arguments, parent) {
|
||||
}
|
||||
|
||||
void GetWindowHandle::start() {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "Command.h"
|
||||
#include "SocketCommand.h"
|
||||
|
||||
class GetWindowHandle : public Command {
|
||||
class GetWindowHandle : public SocketCommand {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include "WebPage.h"
|
||||
#include <QStringList>
|
||||
|
||||
GetWindowHandles::GetWindowHandles(WebPageManager *manager, QStringList &arguments, QObject *parent) : Command(manager, arguments, parent) {
|
||||
GetWindowHandles::GetWindowHandles(WebPageManager *manager, QStringList &arguments, QObject *parent) : SocketCommand(manager, arguments, parent) {
|
||||
}
|
||||
|
||||
void GetWindowHandles::start() {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "Command.h"
|
||||
#include "SocketCommand.h"
|
||||
|
||||
class GetWindowHandles : public Command {
|
||||
class GetWindowHandles : public SocketCommand {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#include "WebPageManager.h"
|
||||
#include "NetworkAccessManager.h"
|
||||
|
||||
Header::Header(WebPageManager *manager, QStringList &arguments, QObject *parent) : Command(manager, arguments, parent) {
|
||||
Header::Header(WebPageManager *manager, QStringList &arguments, QObject *parent) : SocketCommand(manager, arguments, parent) {
|
||||
}
|
||||
|
||||
void Header::start() {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "Command.h"
|
||||
#include "SocketCommand.h"
|
||||
|
||||
class Header : public Command {
|
||||
class Header : public SocketCommand {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#include "WebPage.h"
|
||||
#include "WebPageManager.h"
|
||||
|
||||
Headers::Headers(WebPageManager *manager, QStringList &arguments, QObject *parent) : Command(manager, arguments, parent) {
|
||||
Headers::Headers(WebPageManager *manager, QStringList &arguments, QObject *parent) : SocketCommand(manager, arguments, parent) {
|
||||
}
|
||||
|
||||
void Headers::start() {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "Command.h"
|
||||
#include "SocketCommand.h"
|
||||
|
||||
class Headers : public Command {
|
||||
class Headers : public SocketCommand {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#include "WebPageManager.h"
|
||||
|
||||
IgnoreSslErrors::IgnoreSslErrors(WebPageManager *manager, QStringList &arguments, QObject *parent) :
|
||||
Command(manager, arguments, parent) {
|
||||
SocketCommand(manager, arguments, parent) {
|
||||
}
|
||||
|
||||
void IgnoreSslErrors::start() {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "Command.h"
|
||||
#include "SocketCommand.h"
|
||||
|
||||
class IgnoreSslErrors : public Command {
|
||||
class IgnoreSslErrors : public SocketCommand {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#include "WebPage.h"
|
||||
#include "WebPageManager.h"
|
||||
|
||||
Node::Node(WebPageManager *manager, QStringList &arguments, QObject *parent) : Command(manager, arguments, parent) {
|
||||
Node::Node(WebPageManager *manager, QStringList &arguments, QObject *parent) : SocketCommand(manager, arguments, parent) {
|
||||
}
|
||||
|
||||
void Node::start() {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "Command.h"
|
||||
#include "SocketCommand.h"
|
||||
#include <QStringList>
|
||||
|
||||
class Node : public Command {
|
||||
class Node : public SocketCommand {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
|
|
@ -2,10 +2,12 @@
|
|||
#include "WebPage.h"
|
||||
#include "WebPageManager.h"
|
||||
|
||||
NullCommand::NullCommand(WebPageManager *manager, QStringList &arguments, QObject *parent) : Command(manager, arguments, parent) {}
|
||||
NullCommand::NullCommand(QString name, QObject *parent) : Command(parent) {
|
||||
m_name = name;
|
||||
}
|
||||
|
||||
void NullCommand::start() {
|
||||
QString failure = QString("[Capybara WebKit] Unknown command: ") + arguments()[0] + "\n";
|
||||
QString failure = QString("[Capybara WebKit] Unknown command: ") + m_name + "\n";
|
||||
emit finished(new Response(false, failure));
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,9 @@ class NullCommand : public Command {
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
NullCommand(WebPageManager *, QStringList &arguments, QObject *parent = 0);
|
||||
NullCommand(QString name, QObject *parent = 0);
|
||||
virtual void start();
|
||||
|
||||
private:
|
||||
QString m_name;
|
||||
};
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "PageLoadingCommand.h"
|
||||
#include "Command.h"
|
||||
#include "SocketCommand.h"
|
||||
#include "WebPage.h"
|
||||
#include "WebPageManager.h"
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#include "WebPage.h"
|
||||
#include "WebPageManager.h"
|
||||
|
||||
Render::Render(WebPageManager *manager, QStringList &arguments, QObject *parent) : Command(manager, arguments, parent) {
|
||||
Render::Render(WebPageManager *manager, QStringList &arguments, QObject *parent) : SocketCommand(manager, arguments, parent) {
|
||||
}
|
||||
|
||||
void Render::start() {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "Command.h"
|
||||
#include "SocketCommand.h"
|
||||
#include <QStringList>
|
||||
|
||||
class Render : public Command {
|
||||
class Render : public SocketCommand {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#include "WebPage.h"
|
||||
#include "WebPageManager.h"
|
||||
|
||||
RequestedUrl::RequestedUrl(WebPageManager *manager, QStringList &arguments, QObject *parent) : Command(manager, arguments, parent) {
|
||||
RequestedUrl::RequestedUrl(WebPageManager *manager, QStringList &arguments, QObject *parent) : SocketCommand(manager, arguments, parent) {
|
||||
}
|
||||
|
||||
void RequestedUrl::start() {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "Command.h"
|
||||
#include "SocketCommand.h"
|
||||
|
||||
class RequestedUrl : public Command {
|
||||
class RequestedUrl : public SocketCommand {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#include "WebPage.h"
|
||||
#include "WebPageManager.h"
|
||||
|
||||
Reset::Reset(WebPageManager *manager, QStringList &arguments, QObject *parent) : Command(manager, arguments, parent) {
|
||||
Reset::Reset(WebPageManager *manager, QStringList &arguments, QObject *parent) : SocketCommand(manager, arguments, parent) {
|
||||
}
|
||||
|
||||
void Reset::start() {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "Command.h"
|
||||
#include "SocketCommand.h"
|
||||
|
||||
class Reset : public Command {
|
||||
class Reset : public SocketCommand {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#include "WebPage.h"
|
||||
#include "WebPageManager.h"
|
||||
|
||||
ResizeWindow::ResizeWindow(WebPageManager *manager, QStringList &arguments, QObject *parent) : Command(manager, arguments, parent) {
|
||||
ResizeWindow::ResizeWindow(WebPageManager *manager, QStringList &arguments, QObject *parent) : SocketCommand(manager, arguments, parent) {
|
||||
}
|
||||
|
||||
void ResizeWindow::start() {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "Command.h"
|
||||
#include "SocketCommand.h"
|
||||
|
||||
class ResizeWindow : public Command {
|
||||
class ResizeWindow : public SocketCommand {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include "NetworkCookieJar.h"
|
||||
#include <QNetworkCookie>
|
||||
|
||||
SetCookie::SetCookie(WebPageManager *manager, QStringList &arguments, QObject *parent) : Command(manager, arguments, parent) {}
|
||||
SetCookie::SetCookie(WebPageManager *manager, QStringList &arguments, QObject *parent) : SocketCommand(manager, arguments, parent) {}
|
||||
|
||||
void SetCookie::start()
|
||||
{
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "Command.h"
|
||||
#include "SocketCommand.h"
|
||||
|
||||
class SetCookie : public Command {
|
||||
class SetCookie : public SocketCommand {
|
||||
Q_OBJECT;
|
||||
|
||||
public:
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include <QNetworkAccessManager>
|
||||
#include <QNetworkProxy>
|
||||
|
||||
SetProxy::SetProxy(WebPageManager *manager, QStringList &arguments, QObject *parent) : Command(manager, arguments, parent) {}
|
||||
SetProxy::SetProxy(WebPageManager *manager, QStringList &arguments, QObject *parent) : SocketCommand(manager, arguments, parent) {}
|
||||
|
||||
void SetProxy::start()
|
||||
{
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "Command.h"
|
||||
#include "SocketCommand.h"
|
||||
|
||||
class SetProxy : public Command {
|
||||
class SetProxy : public SocketCommand {
|
||||
Q_OBJECT;
|
||||
|
||||
public:
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#include "WebPageManager.h"
|
||||
|
||||
SetSkipImageLoading::SetSkipImageLoading(WebPageManager *manager, QStringList &arguments, QObject *parent) :
|
||||
Command(manager, arguments, parent) {
|
||||
SocketCommand(manager, arguments, parent) {
|
||||
}
|
||||
|
||||
void SetSkipImageLoading::start() {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "Command.h"
|
||||
#include "SocketCommand.h"
|
||||
|
||||
class SetSkipImageLoading : public Command {
|
||||
class SetSkipImageLoading : public SocketCommand {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
|
21
src/SocketCommand.cpp
Normal file
21
src/SocketCommand.cpp
Normal file
|
@ -0,0 +1,21 @@
|
|||
#include "SocketCommand.h"
|
||||
#include "WebPage.h"
|
||||
#include "WebPageManager.h"
|
||||
|
||||
SocketCommand::SocketCommand(WebPageManager *manager, QStringList &arguments, QObject *parent) : Command(parent) {
|
||||
m_manager = manager;
|
||||
m_arguments = arguments;
|
||||
}
|
||||
|
||||
WebPage *SocketCommand::page() const {
|
||||
return m_manager->currentPage();
|
||||
}
|
||||
|
||||
const QStringList &SocketCommand::arguments() const {
|
||||
return m_arguments;
|
||||
}
|
||||
|
||||
WebPageManager *SocketCommand::manager() const {
|
||||
return m_manager;
|
||||
}
|
||||
|
29
src/SocketCommand.h
Normal file
29
src/SocketCommand.h
Normal file
|
@ -0,0 +1,29 @@
|
|||
#ifndef SOCKET_COMMAND_H
|
||||
#define SOCKET_COMMAND_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QStringList>
|
||||
#include "Command.h"
|
||||
|
||||
class WebPage;
|
||||
class WebPageManager;
|
||||
class Response;
|
||||
|
||||
class SocketCommand : public Command {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
SocketCommand(WebPageManager *, QStringList &arguments, QObject *parent = 0);
|
||||
|
||||
protected:
|
||||
WebPage *page() const;
|
||||
const QStringList &arguments() const;
|
||||
WebPageManager *manager() const;
|
||||
|
||||
private:
|
||||
QStringList m_arguments;
|
||||
WebPageManager *m_manager;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
|
@ -2,7 +2,7 @@
|
|||
#include "WebPage.h"
|
||||
#include "WebPageManager.h"
|
||||
|
||||
Source::Source(WebPageManager *manager, QStringList &arguments, QObject *parent) : Command(manager, arguments, parent) {
|
||||
Source::Source(WebPageManager *manager, QStringList &arguments, QObject *parent) : SocketCommand(manager, arguments, parent) {
|
||||
}
|
||||
|
||||
void Source::start() {
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#include "Command.h"
|
||||
#include "SocketCommand.h"
|
||||
|
||||
class QNetworkReply;
|
||||
|
||||
class Source : public Command {
|
||||
class Source : public SocketCommand {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#include "WebPageManager.h"
|
||||
#include <sstream>
|
||||
|
||||
Status::Status(WebPageManager *manager, QStringList &arguments, QObject *parent) : Command(manager, arguments, parent) {
|
||||
Status::Status(WebPageManager *manager, QStringList &arguments, QObject *parent) : SocketCommand(manager, arguments, parent) {
|
||||
}
|
||||
|
||||
void Status::start() {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "Command.h"
|
||||
#include "SocketCommand.h"
|
||||
|
||||
class Status : public Command {
|
||||
class Status : public SocketCommand {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#include "WebPage.h"
|
||||
#include "WebPageManager.h"
|
||||
|
||||
Url::Url(WebPageManager *manager, QStringList &arguments, QObject *parent) : Command(manager, arguments, parent) {
|
||||
Url::Url(WebPageManager *manager, QStringList &arguments, QObject *parent) : SocketCommand(manager, arguments, parent) {
|
||||
}
|
||||
|
||||
void Url::start() {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "Command.h"
|
||||
#include "SocketCommand.h"
|
||||
|
||||
class Url : public Command {
|
||||
class Url : public SocketCommand {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#include "Visit.h"
|
||||
#include "Command.h"
|
||||
#include "SocketCommand.h"
|
||||
#include "WebPage.h"
|
||||
#include "WebPageManager.h"
|
||||
|
||||
Visit::Visit(WebPageManager *manager, QStringList &arguments, QObject *parent) : Command(manager, arguments, parent) {
|
||||
Visit::Visit(WebPageManager *manager, QStringList &arguments, QObject *parent) : SocketCommand(manager, arguments, parent) {
|
||||
}
|
||||
|
||||
void Visit::start() {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "Command.h"
|
||||
#include "SocketCommand.h"
|
||||
|
||||
class Visit : public Command {
|
||||
class Visit : public SocketCommand {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
#include "WindowFocus.h"
|
||||
#include "Command.h"
|
||||
#include "SocketCommand.h"
|
||||
#include "WebPage.h"
|
||||
#include "CommandFactory.h"
|
||||
#include "WebPageManager.h"
|
||||
|
||||
WindowFocus::WindowFocus(WebPageManager *manager, QStringList &arguments, QObject *parent) : Command(manager, arguments, parent) {
|
||||
WindowFocus::WindowFocus(WebPageManager *manager, QStringList &arguments, QObject *parent) : SocketCommand(manager, arguments, parent) {
|
||||
}
|
||||
|
||||
void WindowFocus::start() {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "Command.h"
|
||||
#include "SocketCommand.h"
|
||||
|
||||
class WindowFocus : public Command {
|
||||
class WindowFocus : public SocketCommand {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#include "WebPage.h"
|
||||
#include "WebPageManager.h"
|
||||
|
||||
Body::Body(WebPageManager *manager, QStringList &arguments, QObject *parent) : Command(manager, arguments, parent) {
|
||||
Body::Body(WebPageManager *manager, QStringList &arguments, QObject *parent) : SocketCommand(manager, arguments, parent) {
|
||||
}
|
||||
|
||||
void Body::start() {
|
||||
|
|
|
@ -13,6 +13,7 @@ HEADERS = \
|
|||
Server.h \
|
||||
Connection.h \
|
||||
Command.h \
|
||||
SocketCommand.h \
|
||||
Visit.h \
|
||||
Find.h \
|
||||
Reset.h \
|
||||
|
@ -59,6 +60,7 @@ SOURCES = \
|
|||
Server.cpp \
|
||||
Connection.cpp \
|
||||
Command.cpp \
|
||||
SocketCommand.cpp \
|
||||
Visit.cpp \
|
||||
Find.cpp \
|
||||
Reset.cpp \
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "NAME.h"
|
||||
#include "WebPage.h"
|
||||
|
||||
NAME::NAME(WebPageManager *manager, QStringList &arguments, QObject *parent) : Command(manager, arguments, parent) {
|
||||
NAME::NAME(WebPageManager *manager, QStringList &arguments, QObject *parent) : SocketCommand(manager, arguments, parent) {
|
||||
}
|
||||
|
||||
void NAME::start() {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
class WebPage;
|
||||
|
||||
class NAME : public Command {
|
||||
class NAME : public SocketCommand {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
|
Loading…
Reference in a new issue