patching fix for previous commits

This commit is contained in:
Wayne Chen 2018-09-24 15:22:46 -07:00
parent ac5814a1f8
commit 69d5299362
8 changed files with 61 additions and 44 deletions

View file

@ -3498,13 +3498,14 @@ bool Application::isServerlessMode() const {
} }
void Application::setIsInterstitialMode(bool interstitialMode) { void Application::setIsInterstitialMode(bool interstitialMode) {
Settings settings; bool enableInterstitial = DependencyManager::get<NodeList>()->getDomainHandler().getInterstitialModeEnabled();
bool enableInterstitial = settings.value("enableIntersitialMode", false).toBool(); if (enableInterstitial) {
if (_interstitialMode != interstitialMode && enableInterstitial) { if (_interstitialMode != interstitialMode) {
_interstitialMode = interstitialMode; _interstitialMode = interstitialMode;
DependencyManager::get<AudioClient>()->setAudioPaused(_interstitialMode); DependencyManager::get<AudioClient>()->setAudioPaused(_interstitialMode);
DependencyManager::get<AvatarManager>()->setMyAvatarDataPacketsPaused(_interstitialMode); DependencyManager::get<AvatarManager>()->setMyAvatarDataPacketsPaused(_interstitialMode);
}
} }
} }

View file

@ -432,7 +432,7 @@ public slots:
void setIsServerlessMode(bool serverlessDomain); void setIsServerlessMode(bool serverlessDomain);
void loadServerlessDomain(QUrl domainURL, bool errorDomain = false); void loadServerlessDomain(QUrl domainURL, bool errorDomain = false);
void setIsInterstitialMode(bool interstialMode); void setIsInterstitialMode(bool interstitialMode);
void updateVerboseLogging(); void updateVerboseLogging();

View file

@ -23,8 +23,6 @@
// should be longer to allow the application to initialize. // should be longer to allow the application to initialize.
static const int ON_INITIAL_LOAD_REDIRECT_AFTER_DISCONNECTED_FOR_X_MS = 10000; static const int ON_INITIAL_LOAD_REDIRECT_AFTER_DISCONNECTED_FOR_X_MS = 10000;
static const int REDIRECT_AFTER_DISCONNECTED_FOR_X_MS = 5000; static const int REDIRECT_AFTER_DISCONNECTED_FOR_X_MS = 5000;
static const int ON_INITIAL_LOAD_DISPLAY_AFTER_DISCONNECTED_FOR_X_MS = 10000;
static const int DISPLAY_AFTER_DISCONNECTED_FOR_X_MS = 5000;
void ConnectionMonitor::init() { void ConnectionMonitor::init() {
// Connect to domain disconnected message // Connect to domain disconnected message
@ -39,18 +37,15 @@ void ConnectionMonitor::init() {
_timer.setSingleShot(true); _timer.setSingleShot(true);
if (!domainHandler.isConnected()) { if (!domainHandler.isConnected()) {
if (_enableInterstitialMode.get()) { _timer.start(ON_INITIAL_LOAD_REDIRECT_AFTER_DISCONNECTED_FOR_X_MS);
_timer.start(ON_INITIAL_LOAD_REDIRECT_AFTER_DISCONNECTED_FOR_X_MS);
} else {
_timer.start(ON_INITIAL_LOAD_DISPLAY_AFTER_DISCONNECTED_FOR_X_MS);
}
} }
connect(&_timer, &QTimer::timeout, this, [this]() { connect(&_timer, &QTimer::timeout, this, [this]() {
// set in a timeout error // set in a timeout error
if (_enableInterstitialMode.get()) { bool enableInterstitial = DependencyManager::get<NodeList>()->getDomainHandler().getInterstitialModeEnabled();
if (enableInterstitial) {
qDebug() << "ConnectionMonitor: Redirecting to 404 error domain"; qDebug() << "ConnectionMonitor: Redirecting to 404 error domain";
emit setRedirectErrorState(REDIRECT_HIFI_ADDRESS, 5); emit setRedirectErrorState(REDIRECT_HIFI_ADDRESS, "", 5);
} else { } else {
qDebug() << "ConnectionMonitor: Showing connection failure window"; qDebug() << "ConnectionMonitor: Showing connection failure window";
DependencyManager::get<DialogsManager>()->setDomainConnectionFailureVisibility(true); DependencyManager::get<DialogsManager>()->setDomainConnectionFailureVisibility(true);
@ -59,16 +54,13 @@ void ConnectionMonitor::init() {
} }
void ConnectionMonitor::startTimer() { void ConnectionMonitor::startTimer() {
if (_enableInterstitialMode.get()) { _timer.start(REDIRECT_AFTER_DISCONNECTED_FOR_X_MS);
_timer.start(REDIRECT_AFTER_DISCONNECTED_FOR_X_MS);
} else {
_timer.start(DISPLAY_AFTER_DISCONNECTED_FOR_X_MS);
}
} }
void ConnectionMonitor::stopTimer() { void ConnectionMonitor::stopTimer() {
_timer.stop(); _timer.stop();
if (!_enableInterstitialMode.get()) { bool enableInterstitial = DependencyManager::get<NodeList>()->getDomainHandler().getInterstitialModeEnabled();
if (!enableInterstitial) {
DependencyManager::get<DialogsManager>()->setDomainConnectionFailureVisibility(false); DependencyManager::get<DialogsManager>()->setDomainConnectionFailureVisibility(false);
} }
} }

View file

@ -15,8 +15,6 @@
#include <QObject> #include <QObject>
#include <QTimer> #include <QTimer>
#include <SettingHandle.h>
class QUrl; class QUrl;
class QString; class QString;
@ -26,7 +24,7 @@ public:
void init(); void init();
signals: signals:
void setRedirectErrorState(QUrl errorURL, int reasonCode); void setRedirectErrorState(QUrl errorURL, QString reasonMessage = "", int reasonCode = -1, const QString& extraInfo = "");
private slots: private slots:
void startTimer(); void startTimer();
@ -34,7 +32,6 @@ private slots:
private: private:
QTimer _timer; QTimer _timer;
Setting::Handle<bool> _enableInterstitialMode{ "enableInterstitialMode", false };
}; };
#endif // hifi_ConnectionMonitor_h #endif // hifi_ConnectionMonitor_h

View file

@ -180,6 +180,14 @@ void WindowScriptingInterface::setPreviousBrowseAssetLocation(const QString& loc
Setting::Handle<QVariant>(LAST_BROWSE_ASSETS_LOCATION_SETTING).set(location); Setting::Handle<QVariant>(LAST_BROWSE_ASSETS_LOCATION_SETTING).set(location);
} }
bool WindowScriptingInterface::getInterstitialModeEnabled() const {
return DependencyManager::get<NodeList>()->getDomainHandler().getInterstitialModeEnabled();
}
void WindowScriptingInterface::setInterstitialModeEnabled(bool enableInterstitialMode) {
DependencyManager::get<NodeList>()->getDomainHandler().setInterstitialModeEnabled(enableInterstitialMode);
}
bool WindowScriptingInterface::isPointOnDesktopWindow(QVariant point) { bool WindowScriptingInterface::isPointOnDesktopWindow(QVariant point) {
auto offscreenUi = DependencyManager::get<OffscreenUi>(); auto offscreenUi = DependencyManager::get<OffscreenUi>();
return offscreenUi->isPointOnDesktopWindow(point); return offscreenUi->isPointOnDesktopWindow(point);

View file

@ -49,6 +49,7 @@ class WindowScriptingInterface : public QObject, public Dependency {
Q_PROPERTY(int innerHeight READ getInnerHeight) Q_PROPERTY(int innerHeight READ getInnerHeight)
Q_PROPERTY(int x READ getX) Q_PROPERTY(int x READ getX)
Q_PROPERTY(int y READ getY) Q_PROPERTY(int y READ getY)
Q_PROPERTY(bool interstitialModeEnabled READ getInterstitialModeEnabled WRITE setInterstitialModeEnabled)
public: public:
WindowScriptingInterface(); WindowScriptingInterface();
@ -758,6 +759,9 @@ private:
QString getPreviousBrowseAssetLocation() const; QString getPreviousBrowseAssetLocation() const;
void setPreviousBrowseAssetLocation(const QString& location); void setPreviousBrowseAssetLocation(const QString& location);
bool getInterstitialModeEnabled() const;
void setInterstitialModeEnabled(bool enableInterstitialMode);
void ensureReticleVisible() const; void ensureReticleVisible() const;
int createMessageBox(QString title, QString text, int buttons, int defaultButton); int createMessageBox(QString title, QString text, int buttons, int defaultButton);

View file

@ -15,6 +15,10 @@
#include <PathUtils.h> #include <PathUtils.h>
#include <shared/QtHelpers.h>
#include <QThread>
#include <QtCore/QJsonDocument> #include <QtCore/QJsonDocument>
#include <QtCore/QDataStream> #include <QtCore/QDataStream>
@ -134,6 +138,18 @@ void DomainHandler::hardReset() {
_pendingPath.clear(); _pendingPath.clear();
} }
bool DomainHandler::getInterstitialModeEnabled() const {
return _interstitialModeSettingLock.resultWithReadLock<bool>([&] {
return _enableInterstitialMode.get();
});
}
void DomainHandler::setInterstitialModeEnabled(bool enableInterstitialMode) {
_interstitialModeSettingLock.withWriteLock([&] {
_enableInterstitialMode.set(enableInterstitialMode);
});
}
void DomainHandler::setErrorDomainURL(const QUrl& url) { void DomainHandler::setErrorDomainURL(const QUrl& url) {
_errorDomainURL = url; _errorDomainURL = url;
return; return;
@ -340,11 +356,15 @@ void DomainHandler::loadedErrorDomain(std::map<QString, QString> namedPaths) {
DependencyManager::get<AddressManager>()->goToViewpointForPath(viewpoint, QString()); DependencyManager::get<AddressManager>()->goToViewpointForPath(viewpoint, QString());
} }
void DomainHandler::setRedirectErrorState(QUrl errorUrl, int reasonCode) { void DomainHandler::setRedirectErrorState(QUrl errorUrl, QString reasonMessage, int reasonCode, const QString& extraInfo) {
_errorDomainURL = errorUrl;
_lastDomainConnectionError = reasonCode; _lastDomainConnectionError = reasonCode;
_isInErrorState = true; if (getInterstitialModeEnabled()) {
emit redirectToErrorDomainURL(_errorDomainURL); _errorDomainURL = errorUrl;
_isInErrorState = true;
emit redirectToErrorDomainURL(_errorDomainURL);
} else {
emit domainConnectionRefused(reasonMessage, reasonCode, extraInfo);
}
} }
void DomainHandler::requestDomainSettings() { void DomainHandler::requestDomainSettings() {
@ -486,18 +506,9 @@ void DomainHandler::processDomainServerConnectionDeniedPacket(QSharedPointer<Rec
emit domainConnectionRefused(reasonMessage, (int)reasonCode, extraInfo); emit domainConnectionRefused(reasonMessage, (int)reasonCode, extraInfo);
#else #else
if (_enableInterstitialMode.get()) { // ingest the error - this is a "hard" connection refusal.
if (reasonCode == ConnectionRefusedReason::ProtocolMismatch || reasonCode == ConnectionRefusedReason::NotAuthorized) { setRedirectErrorState(_errorDomainURL, reasonMessage, (int)reasonCode, extraInfo);
// ingest the error - this is a "hard" connection refusal. #endif
setRedirectErrorState(_errorDomainURL, (int)reasonCode);
} else {
emit domainConnectionRefused(reasonMessage, (int)reasonCode, extraInfo);
}
_lastDomainConnectionError = (int)reasonCode;
} else {
emit domainConnectionRefused(reasonMessage, (int)reasonCode, extraInfo);
}
#endif
} }
auto accountManager = DependencyManager::get<AccountManager>(); auto accountManager = DependencyManager::get<AccountManager>();

View file

@ -19,6 +19,7 @@
#include <QtCore/QUrl> #include <QtCore/QUrl>
#include <QtNetwork/QHostInfo> #include <QtNetwork/QHostInfo>
#include <shared/ReadWriteLockable.h>
#include <SettingHandle.h> #include <SettingHandle.h>
#include "HifiSockAddr.h" #include "HifiSockAddr.h"
@ -85,6 +86,8 @@ public:
bool isConnected() const { return _isConnected; } bool isConnected() const { return _isConnected; }
void setIsConnected(bool isConnected); void setIsConnected(bool isConnected);
bool isServerless() const { return _domainURL.scheme() != URL_SCHEME_HIFI; } bool isServerless() const { return _domainURL.scheme() != URL_SCHEME_HIFI; }
bool getInterstitialModeEnabled() const;
void setInterstitialModeEnabled(bool enableInterstitialMode);
void connectedToServerless(std::map<QString, QString> namedPaths); void connectedToServerless(std::map<QString, QString> namedPaths);
@ -173,7 +176,7 @@ public slots:
void processDomainServerConnectionDeniedPacket(QSharedPointer<ReceivedMessage> message); void processDomainServerConnectionDeniedPacket(QSharedPointer<ReceivedMessage> message);
// sets domain handler in error state. // sets domain handler in error state.
void setRedirectErrorState(QUrl errorUrl, int reasonCode); void setRedirectErrorState(QUrl errorUrl, QString reasonMessage = "", int reason = -1, const QString& extraInfo = "");
bool isInErrorState() { return _isInErrorState; } bool isInErrorState() { return _isInErrorState; }
@ -223,10 +226,11 @@ private:
NetworkPeer _icePeer; NetworkPeer _icePeer;
bool _isConnected { false }; bool _isConnected { false };
bool _isInErrorState { false }; bool _isInErrorState { false };
Setting::Handle<bool> _enableInterstitialMode{ "enableInterstitialMode", false };
QJsonObject _settingsObject; QJsonObject _settingsObject;
QString _pendingPath; QString _pendingPath;
QTimer _settingsTimer; QTimer _settingsTimer;
mutable ReadWriteLockable _interstitialModeSettingLock;
Setting::Handle<bool> _enableInterstitialMode{ "enableInterstitialMode", false };
QSet<QString> _domainConnectionRefusals; QSet<QString> _domainConnectionRefusals;
bool _hasCheckedForAccessToken { false }; bool _hasCheckedForAccessToken { false };