2012-03-15 10:17:03 +04:00
|
|
|
/*
|
|
|
|
This file is part of the PhantomJS project from Ofi Labs.
|
|
|
|
|
|
|
|
Copyright (C) 2012 execjosh, http://execjosh.blogspot.com
|
2012-11-06 21:39:45 +04:00
|
|
|
Copyright (C) 2012 James M. Greene <james.m.greene@gmail.com>
|
2012-03-15 10:17:03 +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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SYSTEM_H
|
|
|
|
#define SYSTEM_H
|
|
|
|
|
2014-07-24 21:25:46 +04:00
|
|
|
#include <QApplication>
|
2012-03-15 10:17:03 +04:00
|
|
|
#include <QObject>
|
|
|
|
#include <QStringList>
|
2012-05-18 17:19:27 +04:00
|
|
|
#include <QMap>
|
|
|
|
#include <QVariant>
|
2012-03-15 10:17:03 +04:00
|
|
|
|
2012-12-15 15:01:36 +04:00
|
|
|
#include "filesystem.h"
|
2012-03-15 10:17:03 +04:00
|
|
|
|
|
|
|
// This class implements the CommonJS System/1.0 spec.
|
|
|
|
// See: http://wiki.commonjs.org/wiki/System/1.0
|
2012-12-29 20:23:10 +04:00
|
|
|
class System : public QObject
|
2012-03-15 10:17:03 +04:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
2012-11-06 21:39:45 +04:00
|
|
|
Q_PROPERTY(qint64 pid READ pid)
|
2012-03-15 11:40:49 +04:00
|
|
|
Q_PROPERTY(QStringList args READ args)
|
2012-03-15 12:19:23 +04:00
|
|
|
Q_PROPERTY(QVariant env READ env)
|
2012-05-18 17:19:27 +04:00
|
|
|
Q_PROPERTY(QVariant os READ os)
|
2012-09-03 17:50:34 +04:00
|
|
|
Q_PROPERTY(bool isSSLSupported READ isSSLSupported)
|
2014-08-22 18:56:40 +04:00
|
|
|
Q_PROPERTY(QObject *standardout READ _stdout)
|
|
|
|
Q_PROPERTY(QObject *standarderr READ _stderr)
|
|
|
|
Q_PROPERTY(QObject *standardin READ _stdin)
|
2012-03-15 10:17:03 +04:00
|
|
|
|
|
|
|
public:
|
|
|
|
explicit System(QObject *parent = 0);
|
2012-12-15 15:01:36 +04:00
|
|
|
virtual ~System();
|
2012-03-15 10:17:03 +04:00
|
|
|
|
2012-11-06 21:39:45 +04:00
|
|
|
qint64 pid() const;
|
|
|
|
|
2012-03-15 11:40:49 +04:00
|
|
|
void setArgs(const QStringList& args);
|
|
|
|
QStringList args() const;
|
|
|
|
|
2012-03-15 12:19:23 +04:00
|
|
|
QVariant env() const;
|
|
|
|
|
2012-05-18 17:19:27 +04:00
|
|
|
QVariant os() const;
|
|
|
|
|
2012-09-03 17:50:34 +04:00
|
|
|
bool isSSLSupported() const;
|
|
|
|
|
2012-12-15 15:01:36 +04:00
|
|
|
// system.stdout
|
|
|
|
QObject *_stdout();
|
|
|
|
|
|
|
|
// system.stderr
|
|
|
|
QObject *_stderr();
|
|
|
|
|
|
|
|
// system.stdin
|
|
|
|
QObject *_stdin();
|
|
|
|
|
2013-03-26 16:34:28 +04:00
|
|
|
private slots:
|
|
|
|
void _onTerminalEncodingChanged(const QString &encoding);
|
|
|
|
|
2012-03-15 10:17:03 +04:00
|
|
|
private:
|
2013-04-02 22:39:18 +04:00
|
|
|
File *createFileInstance(QFile *f);
|
|
|
|
|
2012-03-15 11:40:49 +04:00
|
|
|
QStringList m_args;
|
2012-05-18 17:19:27 +04:00
|
|
|
QVariant m_env;
|
|
|
|
QMap<QString, QVariant> m_os;
|
2012-12-15 15:01:36 +04:00
|
|
|
File *m_stdout;
|
|
|
|
File *m_stderr;
|
|
|
|
File *m_stdin;
|
2012-03-15 10:17:03 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // SYSTEM_H
|