mirror of
https://github.com/overte-org/overte.git
synced 2025-04-19 16:23:39 +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 };
|
||||
if (addressLookupString.isEmpty() && firstRun.get()) {
|
||||
qDebug() << "First run and no URL passed... attempting to Go Home...";
|
||||
DependencyManager::get<AddressManager>()->goHomeOrElsewhere();
|
||||
qDebug() << "First run and no URL passed... attempting to go to Home or Entry...";
|
||||
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 {
|
||||
qDebug() << "Not first run... going to" << qPrintable(addressLookupString.isEmpty() ? QString("previous location") : 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();
|
||||
QNetworkRequest sandboxStatus(QString("http://localhost:60332/status"));
|
||||
QNetworkRequest sandboxStatus(SANDBOX_STATUS_URL);
|
||||
sandboxStatus.setHeader(QNetworkRequest::UserAgentHeader, HIGH_FIDELITY_USER_AGENT);
|
||||
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 statusJson = QJsonDocument::fromJson(statusData);
|
||||
if (!statusJson.isEmpty()) {
|
||||
|
@ -647,14 +649,12 @@ void AddressManager::goHomeOrElsewhere(QString elsewhere, LookupTrigger trigger)
|
|||
auto serversCount = serversObject.size();
|
||||
const int MINIMUM_EXPECTED_SERVER_COUNT = 5;
|
||||
if (serversCount >= MINIMUM_EXPECTED_SERVER_COUNT) {
|
||||
qDebug() << "Home sandbox is running, going to " << SANDBOX_HIFI_ADDRESS;
|
||||
handleUrl(SANDBOX_HIFI_ADDRESS, trigger);
|
||||
localSandboxRunningDoThis();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
qDebug() << "Home sandbox was not running, going to " << elsewhere << "instead.";
|
||||
handleUrl(elsewhere, trigger);
|
||||
localSandboxNotRunningDoThat();
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
const QString HIFI_URL_SCHEME = "hifi";
|
||||
const QString DEFAULT_HIFI_ADDRESS = "hifi://entry";
|
||||
const QString SANDBOX_HIFI_ADDRESS = "hifi://localhost";
|
||||
const QString SANDBOX_STATUS_URL = "http://localhost:60332/status";
|
||||
const QString INDEX_PATH = "/";
|
||||
|
||||
const QString GET_PLACE = "/api/v1/places/%1";
|
||||
|
@ -66,8 +67,10 @@ public:
|
|||
const QStack<QUrl>& getBackStack() const { return _backStack; }
|
||||
const QStack<QUrl>& getForwardStack() const { return _forwardStack; }
|
||||
|
||||
void goHomeOrElsewhere(QString elsewhere = DEFAULT_HIFI_ADDRESS,
|
||||
LookupTrigger trigger = LookupTrigger::StartupFromSettings);
|
||||
/// determines if the local sandbox is likely running. It does not account for custom setups but is only
|
||||
/// intended to detect the standard sandbox install.
|
||||
void ifLocalSandboxRunningElse(std::function<void()> localSandboxRunningDoThis,
|
||||
std::function<void()> localSandboxNotRunningDoThat);
|
||||
|
||||
public slots:
|
||||
void handleLookupString(const QString& lookupString);
|
||||
|
@ -78,6 +81,8 @@ public slots:
|
|||
|
||||
void goBack();
|
||||
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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue