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
18#include <DomainHandler.h>18#include <DomainHandler.h>
19#include <AddressManager.h>19#include <AddressManager.h>
20#include <NodeList.h>20#include <NodeList.h>
21#include <SettingHandle.h>
21 22
22// Because the connection monitor is created at startup, the time we wait on initial load23// Because the connection monitor is created at startup, the time we wait on initial load
23// should be longer to allow the application to initialize.24// should be longer to allow the application to initialize.
24static const int ON_INITIAL_LOAD_REDIRECT_AFTER_DISCONNECTED_FOR_X_MS = 10000;25static const int ON_INITIAL_LOAD_REDIRECT_AFTER_DISCONNECTED_FOR_X_MS = 10000;
25static const int REDIRECT_AFTER_DISCONNECTED_FOR_X_MS = 5000;26static const int REDIRECT_AFTER_DISCONNECTED_FOR_X_MS = 5000;
27static const int ON_INITIAL_LOAD_DISPLAY_AFTER_DISCONNECTED_FOR_X_MS = 10000;
28static const int DISPLAY_AFTER_DISCONNECTED_FOR_X_MS = 5000;
29Setting::Handle<bool> enableInterstitialMode{ "enableInterstitialMode", false };
26 30
27void ConnectionMonitor::init() {31void ConnectionMonitor::init() {
28 // Connect to domain disconnected message32 // Connect to domain disconnected message
@@ -37,20 +41,36 @@ void ConnectionMonitor::init() { · 8 unmodified lines
37 41
38 _timer.setSingleShot(true);42 _timer.setSingleShot(true);
39 if (!domainHandler.isConnected()) {43 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 }
41 }49 }
42 50
43 connect(&_timer, &QTimer::timeout, this, [this]() {51 connect(&_timer, &QTimer::timeout, this, [this]() {
44 qDebug() << "ConnectionMonitor: Redirecting to 404 error domain";
45 // set in a timeout error52 // 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 }
47 });60 });
48}61}
49 62
50void ConnectionMonitor::startTimer() {63void 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 }
52}69}
53 70
54void ConnectionMonitor::stopTimer() {71void ConnectionMonitor::stopTimer() {
55 _timer.stop();72 _timer.stop();
73 if (!enableInterstitialMode.get()) {
74 DependencyManager::get<DialogsManager>()->setDomainConnectionFailureVisibility(false);
75 }
56}76}