mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 10:14:28 +02:00
changes per CR feedback; additional jsdoc
This commit is contained in:
parent
76cbc4ee55
commit
c2ee13931e
3 changed files with 18 additions and 7 deletions
|
@ -92,7 +92,7 @@ MiniPromise::Promise AssetClient::cacheInfoRequestAsync(MiniPromise::Promise def
|
||||||
if (QThread::currentThread() != thread()) {
|
if (QThread::currentThread() != thread()) {
|
||||||
QMetaObject::invokeMethod(this, "cacheInfoRequestAsync", Q_ARG(MiniPromise::Promise, deferred));
|
QMetaObject::invokeMethod(this, "cacheInfoRequestAsync", Q_ARG(MiniPromise::Promise, deferred));
|
||||||
} else {
|
} else {
|
||||||
auto* cache = qobject_cast<QNetworkDiskCache*>(NetworkAccessManager::getInstance().cache());
|
auto cache = qobject_cast<QNetworkDiskCache*>(NetworkAccessManager::getInstance().cache());
|
||||||
if (cache) {
|
if (cache) {
|
||||||
deferred->resolve({
|
deferred->resolve({
|
||||||
{ "cacheDirectory", cache->cacheDirectory() },
|
{ "cacheDirectory", cache->cacheDirectory() },
|
||||||
|
|
|
@ -21,9 +21,6 @@
|
||||||
#include "NetworkAccessManager.h"
|
#include "NetworkAccessManager.h"
|
||||||
#include <QtNetwork/QNetworkDiskCache>
|
#include <QtNetwork/QNetworkDiskCache>
|
||||||
|
|
||||||
/**jsdoc
|
|
||||||
* @namespace Assets
|
|
||||||
*/
|
|
||||||
class BaseAssetScriptingInterface : public QObject {
|
class BaseAssetScriptingInterface : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -215,6 +215,21 @@ void AssetScriptingInterface::deleteAsset(QScriptValue options, QScriptValue sco
|
||||||
jsVerify(false, "TODO: deleteAsset API");
|
jsVerify(false, "TODO: deleteAsset API");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**jsdoc
|
||||||
|
* @typedef {string} Assets.GetOptions.ResponseType
|
||||||
|
* <p>Available <code>responseType</code> values for use with @{link Assets.getAsset} and @{link Assets.loadFromCache} configuration option. </p>
|
||||||
|
* <table>
|
||||||
|
* <thead>
|
||||||
|
* <tr><th>responseType</th><th>typeof response value</th></tr>
|
||||||
|
* </thead>
|
||||||
|
* <tbody>
|
||||||
|
* <tr><td><code>"text"</code></td><td>contents returned as utf-8 decoded <code>String</code> value</td></tr>
|
||||||
|
* <tr><td><code>"arraybuffer"</code></td><td>contents as a binary <code>ArrayBuffer</code> object</td></tr>
|
||||||
|
* <tr><td><code>"json"</code></td><td>contents as a parsed <code>JSON</code> object</td></tr>
|
||||||
|
* </tbody>
|
||||||
|
* </table>
|
||||||
|
*/
|
||||||
|
|
||||||
void AssetScriptingInterface::getAsset(QScriptValue options, QScriptValue scope, QScriptValue callback) {
|
void AssetScriptingInterface::getAsset(QScriptValue options, QScriptValue scope, QScriptValue callback) {
|
||||||
JS_VERIFY(options.isObject() || options.isString(), "expected request options Object or URL as first parameter");
|
JS_VERIFY(options.isObject() || options.isString(), "expected request options Object or URL as first parameter");
|
||||||
|
|
||||||
|
@ -224,7 +239,7 @@ void AssetScriptingInterface::getAsset(QScriptValue options, QScriptValue scope,
|
||||||
if (options.isString()) {
|
if (options.isString()) {
|
||||||
url = options.toString();
|
url = options.toString();
|
||||||
}
|
}
|
||||||
if (responseType.isEmpty() || responseType == "string") {
|
if (responseType.isEmpty()) {
|
||||||
responseType = "text";
|
responseType = "text";
|
||||||
}
|
}
|
||||||
auto asset = AssetUtils::getATPUrl(url).path();
|
auto asset = AssetUtils::getATPUrl(url).path();
|
||||||
|
@ -389,8 +404,7 @@ bool AssetScriptingInterface::canWriteCacheValue(const QUrl& url) {
|
||||||
// allow cache writes only from Client, EntityServer and Agent scripts
|
// allow cache writes only from Client, EntityServer and Agent scripts
|
||||||
bool isAllowedContext = (
|
bool isAllowedContext = (
|
||||||
scriptEngine->isClientScript() ||
|
scriptEngine->isClientScript() ||
|
||||||
scriptEngine->isAgentScript() ||
|
scriptEngine->isAgentScript()
|
||||||
scriptEngine->isEntityServerScript()
|
|
||||||
);
|
);
|
||||||
if (!isAllowedContext) {
|
if (!isAllowedContext) {
|
||||||
qCDebug(scriptengine) << __FUNCTION__ << "invalid context" << scriptEngine->getContext() << url;
|
qCDebug(scriptengine) << __FUNCTION__ << "invalid context" << scriptEngine->getContext() << url;
|
||||||
|
|
Loading…
Reference in a new issue