mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 09:29:02 +02:00
rename functions
This commit is contained in:
parent
0eb2388f69
commit
a17acc6f6b
3 changed files with 23 additions and 11 deletions
|
@ -2957,8 +2957,15 @@ void Application::init() {
|
||||||
|
|
||||||
Setting::Handle<bool> firstRun { Settings::firstRun, true };
|
Setting::Handle<bool> firstRun { Settings::firstRun, true };
|
||||||
if (addressLookupString.isEmpty() && firstRun.get()) {
|
if (addressLookupString.isEmpty() && firstRun.get()) {
|
||||||
qDebug() << "First run and no URL passed... attempting to Go Home...";
|
qDebug() << "First run and no URL passed... attempting to go to Home or Entry...";
|
||||||
DependencyManager::get<AddressManager>()->goHomeOrElsewhere();
|
DependencyManager::get<AddressManager>()->ifLocalSandboxRunningElse([](){
|
||||||
|
qDebug() << "Home sandbox appears to be running, going to Home.";
|
||||||
|
DependencyManager::get<AddressManager>()->goToLocalSandbox();
|
||||||
|
},
|
||||||
|
[](){
|
||||||
|
qDebug() << "Home sandbox does not appear to be running, going to Entry.";
|
||||||
|
DependencyManager::get<AddressManager>()->goToEntry();
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
qDebug() << "Not first run... going to" << qPrintable(addressLookupString.isEmpty() ? QString("previous location") : addressLookupString);
|
qDebug() << "Not first run... going to" << qPrintable(addressLookupString.isEmpty() ? QString("previous location") : addressLookupString);
|
||||||
DependencyManager::get<AddressManager>()->loadSettings(addressLookupString);
|
DependencyManager::get<AddressManager>()->loadSettings(addressLookupString);
|
||||||
|
|
|
@ -630,13 +630,15 @@ void AddressManager::addCurrentAddressToHistory(LookupTrigger trigger) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddressManager::goHomeOrElsewhere(QString elsewhere, LookupTrigger trigger) {
|
void AddressManager::ifLocalSandboxRunningElse(std::function<void()> localSandboxRunningDoThis,
|
||||||
|
std::function<void()> localSandboxNotRunningDoThat) {
|
||||||
|
|
||||||
QNetworkAccessManager& networkAccessManager = NetworkAccessManager::getInstance();
|
QNetworkAccessManager& networkAccessManager = NetworkAccessManager::getInstance();
|
||||||
QNetworkRequest sandboxStatus(QString("http://localhost:60332/status"));
|
QNetworkRequest sandboxStatus(SANDBOX_STATUS_URL);
|
||||||
sandboxStatus.setHeader(QNetworkRequest::UserAgentHeader, HIGH_FIDELITY_USER_AGENT);
|
sandboxStatus.setHeader(QNetworkRequest::UserAgentHeader, HIGH_FIDELITY_USER_AGENT);
|
||||||
QNetworkReply* reply = networkAccessManager.get(sandboxStatus);
|
QNetworkReply* reply = networkAccessManager.get(sandboxStatus);
|
||||||
|
|
||||||
connect(reply, &QNetworkReply::finished, this, [this, elsewhere, reply, trigger]() {
|
connect(reply, &QNetworkReply::finished, this, [reply, localSandboxRunningDoThis, localSandboxNotRunningDoThat]() {
|
||||||
auto statusData = reply->readAll();
|
auto statusData = reply->readAll();
|
||||||
auto statusJson = QJsonDocument::fromJson(statusData);
|
auto statusJson = QJsonDocument::fromJson(statusData);
|
||||||
if (!statusJson.isEmpty()) {
|
if (!statusJson.isEmpty()) {
|
||||||
|
@ -647,14 +649,12 @@ void AddressManager::goHomeOrElsewhere(QString elsewhere, LookupTrigger trigger)
|
||||||
auto serversCount = serversObject.size();
|
auto serversCount = serversObject.size();
|
||||||
const int MINIMUM_EXPECTED_SERVER_COUNT = 5;
|
const int MINIMUM_EXPECTED_SERVER_COUNT = 5;
|
||||||
if (serversCount >= MINIMUM_EXPECTED_SERVER_COUNT) {
|
if (serversCount >= MINIMUM_EXPECTED_SERVER_COUNT) {
|
||||||
qDebug() << "Home sandbox is running, going to " << SANDBOX_HIFI_ADDRESS;
|
localSandboxRunningDoThis();
|
||||||
handleUrl(SANDBOX_HIFI_ADDRESS, trigger);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
qDebug() << "Home sandbox was not running, going to " << elsewhere << "instead.";
|
localSandboxNotRunningDoThat();
|
||||||
handleUrl(elsewhere, trigger);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
const QString HIFI_URL_SCHEME = "hifi";
|
const QString HIFI_URL_SCHEME = "hifi";
|
||||||
const QString DEFAULT_HIFI_ADDRESS = "hifi://entry";
|
const QString DEFAULT_HIFI_ADDRESS = "hifi://entry";
|
||||||
const QString SANDBOX_HIFI_ADDRESS = "hifi://localhost";
|
const QString SANDBOX_HIFI_ADDRESS = "hifi://localhost";
|
||||||
|
const QString SANDBOX_STATUS_URL = "http://localhost:60332/status";
|
||||||
const QString INDEX_PATH = "/";
|
const QString INDEX_PATH = "/";
|
||||||
|
|
||||||
const QString GET_PLACE = "/api/v1/places/%1";
|
const QString GET_PLACE = "/api/v1/places/%1";
|
||||||
|
@ -66,8 +67,10 @@ public:
|
||||||
const QStack<QUrl>& getBackStack() const { return _backStack; }
|
const QStack<QUrl>& getBackStack() const { return _backStack; }
|
||||||
const QStack<QUrl>& getForwardStack() const { return _forwardStack; }
|
const QStack<QUrl>& getForwardStack() const { return _forwardStack; }
|
||||||
|
|
||||||
void goHomeOrElsewhere(QString elsewhere = DEFAULT_HIFI_ADDRESS,
|
/// determines if the local sandbox is likely running. It does not account for custom setups but is only
|
||||||
LookupTrigger trigger = LookupTrigger::StartupFromSettings);
|
/// intended to detect the standard sandbox install.
|
||||||
|
void ifLocalSandboxRunningElse(std::function<void()> localSandboxRunningDoThis,
|
||||||
|
std::function<void()> localSandboxNotRunningDoThat);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void handleLookupString(const QString& lookupString);
|
void handleLookupString(const QString& lookupString);
|
||||||
|
@ -78,6 +81,8 @@ public slots:
|
||||||
|
|
||||||
void goBack();
|
void goBack();
|
||||||
void goForward();
|
void goForward();
|
||||||
|
void goToLocalSandbox(LookupTrigger trigger = LookupTrigger::StartupFromSettings) { handleUrl(SANDBOX_HIFI_ADDRESS, trigger); }
|
||||||
|
void goToEntry(LookupTrigger trigger = LookupTrigger::StartupFromSettings) { handleUrl(DEFAULT_HIFI_ADDRESS, trigger); }
|
||||||
|
|
||||||
void goToUser(const QString& username);
|
void goToUser(const QString& username);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue