mirror of
https://github.com/lubosz/overte.git
synced 2025-04-17 07:32:10 +02:00
Merge branch 'master' of https://github.com/highfidelity/hifi into yellow
This commit is contained in:
commit
579a27cfb9
3 changed files with 53 additions and 22 deletions
|
@ -234,14 +234,38 @@ const JSONCallbackParameters& AddressManager::apiCallbackParameters() {
|
|||
return callbackParams;
|
||||
}
|
||||
|
||||
bool AddressManager::handleUrl(const QUrl& lookupUrl, LookupTrigger trigger) {
|
||||
bool AddressManager::handleUrl(const QUrl& lookupUrlIn, LookupTrigger trigger) {
|
||||
static QString URL_TYPE_USER = "user";
|
||||
static QString URL_TYPE_DOMAIN_ID = "domain_id";
|
||||
static QString URL_TYPE_PLACE = "place";
|
||||
static QString URL_TYPE_NETWORK_ADDRESS = "network_address";
|
||||
if (lookupUrl.scheme() == URL_SCHEME_HIFI) {
|
||||
|
||||
qCDebug(networking) << "Trying to go to URL" << lookupUrl.toString();
|
||||
QUrl lookupUrl = lookupUrlIn;
|
||||
|
||||
qCDebug(networking) << "Trying to go to URL" << lookupUrl.toString();
|
||||
|
||||
if (lookupUrl.scheme().isEmpty() && !lookupUrl.path().startsWith("/")) {
|
||||
// 'urls' without schemes are taken as domain names, as opposed to
|
||||
// simply a path portion of a url, so we need to set the scheme
|
||||
lookupUrl.setScheme(URL_SCHEME_HIFI);
|
||||
}
|
||||
|
||||
static const QRegExp PORT_REGEX = QRegExp("\\d{1,5}(\\/.*)?");
|
||||
if(!lookupUrl.scheme().isEmpty() && lookupUrl.host().isEmpty() && PORT_REGEX.exactMatch(lookupUrl.path())) {
|
||||
// this is in the form somewhere:<port>, convert it to hifi://somewhere:<port>
|
||||
lookupUrl = QUrl(URL_SCHEME_HIFI + "://" + lookupUrl.toString());
|
||||
}
|
||||
// it should be noted that url's in the form
|
||||
// somewhere:<port> are not valid, as that
|
||||
// would indicate that the scheme is 'somewhere'
|
||||
// use hifi://somewhere:<port> instead
|
||||
|
||||
if (lookupUrl.scheme() == URL_SCHEME_HIFI) {
|
||||
if (lookupUrl.host().isEmpty()) {
|
||||
// this was in the form hifi:/somewhere or hifi:somewhere. Fix it by making it hifi://somewhere
|
||||
static const QRegExp HIFI_SCHEME_REGEX = QRegExp(URL_SCHEME_HIFI + ":\\/?", Qt::CaseInsensitive);
|
||||
lookupUrl = QUrl(lookupUrl.toString().replace(HIFI_SCHEME_REGEX, URL_SCHEME_HIFI + "://"));
|
||||
}
|
||||
|
||||
DependencyManager::get<NodeList>()->flagTimeForConnectionStep(LimitedNodeList::ConnectionStep::LookupAddress);
|
||||
|
||||
|
@ -379,25 +403,11 @@ bool isPossiblePlaceName(QString possiblePlaceName) {
|
|||
}
|
||||
|
||||
void AddressManager::handleLookupString(const QString& lookupString, bool fromSuggestions) {
|
||||
if (!lookupString.isEmpty()) {
|
||||
|
||||
QString sanitizedString = lookupString.trimmed();
|
||||
if (!sanitizedString.isEmpty()) {
|
||||
// make this a valid hifi URL and handle it off to handleUrl
|
||||
QString sanitizedString = lookupString.trimmed();
|
||||
QUrl lookupURL;
|
||||
|
||||
if (!lookupString.startsWith('/')) {
|
||||
// sometimes we need to handle lookupStrings like hifi:/somewhere
|
||||
const QRegExp HIFI_SCHEME_REGEX = QRegExp(URL_SCHEME_HIFI + ":\\/{1,2}", Qt::CaseInsensitive);
|
||||
sanitizedString = sanitizedString.remove(HIFI_SCHEME_REGEX);
|
||||
|
||||
lookupURL = QUrl(sanitizedString);
|
||||
if (lookupURL.scheme().isEmpty() || lookupURL.scheme().toLower() == LOCALHOST) {
|
||||
lookupURL = QUrl("hifi://" + sanitizedString);
|
||||
}
|
||||
} else {
|
||||
lookupURL = QUrl(sanitizedString);
|
||||
}
|
||||
|
||||
handleUrl(lookupURL, fromSuggestions ? Suggestions : UserInput);
|
||||
handleUrl(sanitizedString, fromSuggestions ? Suggestions : UserInput);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -29,6 +29,8 @@
|
|||
#include <shared/QtHelpers.h>
|
||||
#include <Gzip.h>
|
||||
|
||||
#include <future>
|
||||
|
||||
using Promise = MiniPromise::Promise;
|
||||
|
||||
AssetScriptingInterface::AssetScriptingInterface(QObject* parent) : BaseAssetScriptingInterface(parent) {
|
||||
|
@ -38,6 +40,25 @@ AssetScriptingInterface::AssetScriptingInterface(QObject* parent) : BaseAssetScr
|
|||
|
||||
#define JS_VERIFY(cond, error) { if (!this->jsVerify(cond, error)) { return; } }
|
||||
|
||||
bool AssetScriptingInterface::initializeCache() {
|
||||
if (!Parent::initializeCache()) {
|
||||
if (assetClient()) {
|
||||
std::promise<bool> cacheStatusResult;
|
||||
Promise assetClientPromise(makePromise(__func__));
|
||||
assetClientPromise->moveToThread(qApp->thread()); // To ensure the finally() is processed.
|
||||
|
||||
assetClient()->cacheInfoRequestAsync(assetClientPromise);
|
||||
assetClientPromise->finally([&](QString, QVariantMap result)
|
||||
{ cacheStatusResult.set_value(!result.isEmpty()); });
|
||||
return cacheStatusResult.get_future().get();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
void AssetScriptingInterface::uploadData(QString data, QScriptValue callback) {
|
||||
auto handler = jsBindCallback(thisObject(), callback);
|
||||
QByteArray dataByteArray = data.toUtf8();
|
||||
|
|
|
@ -356,7 +356,7 @@ public:
|
|||
* @function Assets.initializeCache
|
||||
* @returns {boolean} <code>true</code> if the cache is initialized, <code>false</code> if it isn't.
|
||||
*/
|
||||
Q_INVOKABLE bool initializeCache() { return Parent::initializeCache(); }
|
||||
Q_INVOKABLE bool initializeCache();
|
||||
|
||||
/**jsdoc
|
||||
* Checks whether the script can write to the cache.
|
||||
|
|
Loading…
Reference in a new issue