| 1 | // Copyright (C) 2016 The Qt Company Ltd. |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 3 | |
| 4 | #ifndef QV4INCLUDE_P_H |
| 5 | #define QV4INCLUDE_P_H |
| 6 | |
| 7 | // |
| 8 | // W A R N I N G |
| 9 | // ------------- |
| 10 | // |
| 11 | // This file is not part of the Qt API. It exists purely as an |
| 12 | // implementation detail. This header file may change from version to |
| 13 | // version without notice, or even be removed. |
| 14 | // |
| 15 | // We mean it. |
| 16 | // |
| 17 | |
| 18 | #include <QtCore/qobject.h> |
| 19 | #include <QtCore/qurl.h> |
| 20 | #include <QtCore/qpointer.h> |
| 21 | |
| 22 | #include <private/qv4value_p.h> |
| 23 | #include <private/qv4context_p.h> |
| 24 | #include <private/qv4persistent_p.h> |
| 25 | |
| 26 | QT_BEGIN_NAMESPACE |
| 27 | |
| 28 | class QJSEngine; |
| 29 | class QJSValue; |
| 30 | #if QT_CONFIG(qml_network) |
| 31 | class QNetworkAccessManager; |
| 32 | #endif |
| 33 | class QNetworkReply; |
| 34 | class QV4Include : public QObject |
| 35 | { |
| 36 | Q_OBJECT |
| 37 | public: |
| 38 | enum Status { |
| 39 | Ok = 0, |
| 40 | Loading = 1, |
| 41 | NetworkError = 2, |
| 42 | Exception = 3 |
| 43 | }; |
| 44 | |
| 45 | static QJSValue method_include(QV4::ExecutionEngine *engine, const QUrl &url, |
| 46 | const QJSValue &callbackFunction); |
| 47 | |
| 48 | private Q_SLOTS: |
| 49 | void finished(); |
| 50 | |
| 51 | private: |
| 52 | QV4Include(const QUrl &url, QV4::ExecutionEngine *engine, QV4::QmlContext *qmlContext, |
| 53 | const QV4::Value &callback); |
| 54 | ~QV4Include(); |
| 55 | |
| 56 | QV4::ReturnedValue result(); |
| 57 | |
| 58 | static QV4::ReturnedValue resultValue(QV4::ExecutionEngine *v4, Status status = Loading, |
| 59 | const QString &statusText = QString()); |
| 60 | static void callback(const QV4::Value &callback, const QV4::Value &status); |
| 61 | |
| 62 | QV4::ExecutionEngine *v4; |
| 63 | QUrl m_url; |
| 64 | |
| 65 | #if QT_CONFIG(qml_network) |
| 66 | QNetworkAccessManager *m_network; |
| 67 | QPointer<QNetworkReply> m_reply; |
| 68 | #endif |
| 69 | |
| 70 | QV4::PersistentValue m_callbackFunction; |
| 71 | QV4::PersistentValue m_resultObject; |
| 72 | QV4::PersistentValue m_qmlContext; |
| 73 | }; |
| 74 | |
| 75 | QT_END_NAMESPACE |
| 76 | |
| 77 | #endif |
| 78 | |
| 79 | |