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-08-31 19:29:40 +04:00
|
|
|
Copyright (C) 2011 Ivan De Marino <ivan.de.marino@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-06-14 14:28:51 +04:00
|
|
|
#include "filesystem.h"
|
2011-08-16 22:53:56 +04:00
|
|
|
#include "encoding.h"
|
2011-08-28 16:05:34 +04:00
|
|
|
#include "config.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-18 07:17:58 +04:00
|
|
|
Q_PROPERTY(QString libraryPath READ libraryPath WRITE setLibraryPath)
|
2011-08-16 23:17:42 +04:00
|
|
|
Q_PROPERTY(QString outputEncoding READ outputEncoding WRITE setOutputEncoding)
|
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-08-16 23:17:42 +04:00
|
|
|
QString outputEncoding() const;
|
|
|
|
void setOutputEncoding(const QString &encoding);
|
2011-08-16 22:18:52 +04:00
|
|
|
|
2011-04-08 17:30:50 +04:00
|
|
|
bool execute();
|
|
|
|
int returnValue() const;
|
|
|
|
|
2011-06-18 07:17:58 +04:00
|
|
|
QString libraryPath() const;
|
|
|
|
void setLibraryPath(const QString &libraryPath);
|
2011-06-13 01:38:34 +04:00
|
|
|
|
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-09-08 20:55:50 +04:00
|
|
|
QObject *createFilesystem();
|
2011-06-10 19:50:49 +04:00
|
|
|
bool injectJs(const QString &jsFilePath);
|
2011-06-20 21:14:08 +04:00
|
|
|
void exit(int code = 0);
|
2011-04-08 17:30:50 +04:00
|
|
|
|
2011-05-29 08:16:18 +04:00
|
|
|
private slots:
|
2011-06-20 08:06:27 +04:00
|
|
|
void printConsoleMessage(const QString &msg, int lineNumber, const QString &source);
|
2011-05-29 08:16:18 +04:00
|
|
|
|
2011-04-08 17:30:50 +04:00
|
|
|
private:
|
2011-08-16 22:53:56 +04:00
|
|
|
Encoding m_scriptFileEnc;
|
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;
|
2011-04-08 20:55:10 +04:00
|
|
|
NetworkAccessManager *m_netAccessMan;
|
2011-05-28 07:37:36 +04:00
|
|
|
QVariantMap m_defaultPageSettings;
|
2011-06-14 14:28:51 +04:00
|
|
|
FileSystem m_filesystem;
|
2011-08-24 05:53:53 +04:00
|
|
|
QList<QPointer<WebPage> > m_pages;
|
2011-08-28 16:05:34 +04:00
|
|
|
Config m_config;
|
2011-04-08 17:30:50 +04:00
|
|
|
};
|
2011-04-09 22:49:22 +04:00
|
|
|
|
|
|
|
#endif // PHANTOM_H
|