2011-04-09 21:34:04 +04:00
|
|
|
/*
|
|
|
|
This file is part of the PhantomJS project from Ofi Labs.
|
|
|
|
|
|
|
|
Copyright (C) 2011 Ariya Hidayat <ariya.hidayat@gmail.com>
|
2011-04-10 09:37:06 +04:00
|
|
|
Copyright (C) 2010 Ariya Hidayat <ariya.hidayat@gmail.com>
|
2011-04-09 21:34:04 +04:00
|
|
|
|
|
|
|
Redistribution and use in source and binary forms, with or without
|
|
|
|
modification, are permitted provided that the following conditions are met:
|
|
|
|
|
|
|
|
* Redistributions of source code must retain the above copyright
|
|
|
|
notice, this list of conditions and the following disclaimer.
|
|
|
|
* Redistributions in binary form must reproduce the above copyright
|
|
|
|
notice, this list of conditions and the following disclaimer in the
|
|
|
|
documentation and/or other materials provided with the distribution.
|
|
|
|
* Neither the name of the <organization> nor the
|
|
|
|
names of its contributors may be used to endorse or promote products
|
|
|
|
derived from this software without specific prior written permission.
|
|
|
|
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
|
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
|
|
|
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
|
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
|
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
|
|
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
2011-04-09 22:49:22 +04:00
|
|
|
#ifndef PHANTOM_H
|
|
|
|
#define PHANTOM_H
|
|
|
|
|
2011-04-08 17:30:50 +04:00
|
|
|
#include <QtGui>
|
|
|
|
|
2011-05-26 01:00:20 +04:00
|
|
|
class WebPage;
|
2011-04-08 17:30:50 +04:00
|
|
|
#include "csconverter.h"
|
2011-04-08 20:55:10 +04:00
|
|
|
#include "networkaccessmanager.h"
|
2011-04-08 17:30:50 +04:00
|
|
|
|
|
|
|
class Phantom: public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
Q_PROPERTY(QStringList args READ args)
|
2011-05-28 09:36:34 +04:00
|
|
|
Q_PROPERTY(QVariantMap defaultPageSettings READ defaultPageSettings)
|
2011-06-13 01:38:34 +04:00
|
|
|
Q_PROPERTY(QString scriptLookupDir READ scriptLookupDir WRITE setScriptLookupDir)
|
2011-06-16 01:30:31 +04:00
|
|
|
Q_PROPERTY(QString scriptName READ scriptName)
|
2011-04-08 17:30:50 +04:00
|
|
|
Q_PROPERTY(QVariantMap version READ version)
|
|
|
|
|
|
|
|
public:
|
|
|
|
Phantom(QObject *parent = 0);
|
|
|
|
|
|
|
|
QStringList args() const;
|
|
|
|
|
2011-05-28 09:36:34 +04:00
|
|
|
QVariantMap defaultPageSettings() const;
|
|
|
|
|
2011-04-08 17:30:50 +04:00
|
|
|
bool execute();
|
|
|
|
int returnValue() const;
|
|
|
|
|
2011-06-13 01:38:34 +04:00
|
|
|
QString scriptLookupDir() const;
|
|
|
|
void setScriptLookupDir(const QString &dirPath);
|
|
|
|
|
2011-06-16 01:30:31 +04:00
|
|
|
QString scriptName() const;
|
|
|
|
|
2011-04-08 17:30:50 +04:00
|
|
|
QVariantMap version() const;
|
|
|
|
|
|
|
|
public slots:
|
2011-05-25 21:46:51 +04:00
|
|
|
QObject *createWebPage();
|
2011-06-10 19:50:49 +04:00
|
|
|
bool injectJs(const QString &jsFilePath);
|
2011-04-08 17:30:50 +04:00
|
|
|
void exit(int code = 0);
|
|
|
|
|
2011-05-29 08:16:18 +04:00
|
|
|
private slots:
|
|
|
|
void printConsoleMessage(const QString &msg);
|
|
|
|
|
2011-04-08 17:30:50 +04:00
|
|
|
private:
|
|
|
|
QString m_scriptFile;
|
|
|
|
QStringList m_args;
|
2011-05-26 01:00:20 +04:00
|
|
|
WebPage *m_page;
|
2011-05-29 11:20:56 +04:00
|
|
|
bool m_terminated;
|
2011-04-08 17:30:50 +04:00
|
|
|
int m_returnValue;
|
|
|
|
QString m_script;
|
|
|
|
CSConverter *m_converter;
|
2011-04-08 20:55:10 +04:00
|
|
|
NetworkAccessManager *m_netAccessMan;
|
2011-05-28 07:37:36 +04:00
|
|
|
QVariantMap m_defaultPageSettings;
|
2011-04-08 17:30:50 +04:00
|
|
|
};
|
2011-04-09 22:49:22 +04:00
|
|
|
|
|
|
|
#endif // PHANTOM_H
|