History

adding 404 redirect toggle with interstitial

Wayne Chen committed 8 years ago

Commit 795580f1 parent 8b3fff13 files · +45 −24Browse files

Showing the changes to interface/src/ConnectionMonitor.cpp (1 of 3 files). Show all

Unified · Split

interface/src/ConnectionMonitor.cpp+24−4
@@ -18,11 +18,15 @@ · 17 unmodified lines
1818 #include <DomainHandler.h>
1919 #include <AddressManager.h>
2020 #include <NodeList.h>
21+#include <SettingHandle.h>
2122
2223 // Because the connection monitor is created at startup, the time we wait on initial load
2324 // should be longer to allow the application to initialize.
2425 static const int ON_INITIAL_LOAD_REDIRECT_AFTER_DISCONNECTED_FOR_X_MS = 10000;
2526 static const int REDIRECT_AFTER_DISCONNECTED_FOR_X_MS = 5000;
27+static const int ON_INITIAL_LOAD_DISPLAY_AFTER_DISCONNECTED_FOR_X_MS = 10000;
28+static const int DISPLAY_AFTER_DISCONNECTED_FOR_X_MS = 5000;
29+Setting::Handle<bool> enableInterstitialMode{ "enableInterstitialMode", false };
2630
2731 void ConnectionMonitor::init() {
2832 // Connect to domain disconnected message
@@ -37,20 +41,36 @@ void ConnectionMonitor::init() { · 8 unmodified lines
3741
3842 _timer.setSingleShot(true);
3943 if (!domainHandler.isConnected()) {
40− _timer.start(ON_INITIAL_LOAD_REDIRECT_AFTER_DISCONNECTED_FOR_X_MS);
44+ if (enableInterstitialMode.get()) {
45+ _timer.start(ON_INITIAL_LOAD_REDIRECT_AFTER_DISCONNECTED_FOR_X_MS);
46+ } else {
47+ _timer.start(ON_INITIAL_LOAD_DISPLAY_AFTER_DISCONNECTED_FOR_X_MS);
48+ }
4149 }
4250
4351 connect(&_timer, &QTimer::timeout, this, [this]() {
44− qDebug() << "ConnectionMonitor: Redirecting to 404 error domain";
4552 // set in a timeout error
46− emit setRedirectErrorState(REDIRECT_HIFI_ADDRESS, 5);
53+ if (enableInterstitialMode.get()) {
54+ qDebug() << "ConnectionMonitor: Redirecting to 404 error domain";
55+ emit setRedirectErrorState(REDIRECT_HIFI_ADDRESS, 5);
56+ } else {
57+ qDebug() << "ConnectionMonitor: Showing connection failure window";
58+ DependencyManager::get<DialogsManager>()->setDomainConnectionFailureVisibility(true);
59+ }
4760 });
4861 }
4962
5063 void ConnectionMonitor::startTimer() {
51− _timer.start(REDIRECT_AFTER_DISCONNECTED_FOR_X_MS);
64+ if (enableInterstitialMode.get()) {
65+ _timer.start(REDIRECT_AFTER_DISCONNECTED_FOR_X_MS);
66+ } else {
67+ _timer.start(DISPLAY_AFTER_DISCONNECTED_FOR_X_MS);
68+ }
5269 }
5370
5471 void ConnectionMonitor::stopTimer() {
5572 _timer.stop();
73+ if (!enableInterstitialMode.get()) {
74+ DependencyManager::get<DialogsManager>()->setDomainConnectionFailureVisibility(false);
75+ }
5676 }