Showing the changes to libraries/script-engine/src/AssetScriptingInterface.cpp (1 of 503 files). Show all
Unified · Split
| @@ -19,7 +19,6 @@ · 18 unmodified lines | |||
| 19 | #include <AssetUpload.h> | 19 | #include <AssetUpload.h> |
| 20 | #include <AssetUtils.h> | 20 | #include <AssetUtils.h> |
| 21 | #include <MappingRequest.h> | 21 | #include <MappingRequest.h> |
| 22 | #include <NetworkLogging.h> | ||
| 23 | #include <NodeList.h> | 22 | #include <NodeList.h> |
| 24 | 23 | ||
| 25 | #include <RegisteredMetaTypes.h> | 24 | #include <RegisteredMetaTypes.h> |
| @@ -79,6 +78,27 @@ void AssetScriptingInterface::setMapping(QString path, QString hash, QScriptValu · 53 unmodified lines | |||
| 79 | setMappingRequest->start(); | 78 | setMappingRequest->start(); |
| 80 | } | 79 | } |
| 81 | 80 | ||
| 81 | void AssetScriptingInterface::getMapping(QString path, QScriptValue callback) { | ||
| 82 | auto request = DependencyManager::get<AssetClient>()->createGetMappingRequest(path); | ||
| 83 | QObject::connect(request, &GetMappingRequest::finished, this, [=](GetMappingRequest* request) mutable { | ||
| 84 | auto result = request->getError(); | ||
| 85 | if (callback.isFunction()) { | ||
| 86 | if (result == GetMappingRequest::NotFound) { | ||
| 87 | QScriptValueList args { "", true }; | ||
| 88 | callback.call(_engine->currentContext()->thisObject(), args); | ||
| 89 | } else if (result == GetMappingRequest::NoError) { | ||
| 90 | QScriptValueList args { request->getHash(), true }; | ||
| 91 | callback.call(_engine->currentContext()->thisObject(), args); | ||
| 92 | } else { | ||
| 93 | qCDebug(scriptengine) << "error -- " << request->getError() << " -- " << request->getErrorString(); | ||
| 94 | QScriptValueList args { "", false }; | ||
| 95 | callback.call(_engine->currentContext()->thisObject(), args); | ||
| 96 | } | ||
| 97 | request->deleteLater(); | ||
| 98 | } | ||
| 99 | }); | ||
| 100 | request->start(); | ||
| 101 | } | ||
| 82 | 102 | ||
| 83 | void AssetScriptingInterface::downloadData(QString urlString, QScriptValue callback) { | 103 | void AssetScriptingInterface::downloadData(QString urlString, QScriptValue callback) { |
| 84 | // FIXME: historically this API method failed silently when given a non-atp prefixed | 104 | // FIXME: historically this API method failed silently when given a non-atp prefixed |