mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-25 16:55:07 +02:00
Fix ConnectionHandler not handling connected-but-need-auth condition
This commit is contained in:
parent
84bcefc147
commit
5b58e8ae97
7 changed files with 36 additions and 6 deletions
|
@ -27,8 +27,10 @@ void ConnectionMonitor::init() {
|
|||
// Connect to domain disconnected message
|
||||
auto nodeList = DependencyManager::get<NodeList>();
|
||||
const DomainHandler& domainHandler = nodeList->getDomainHandler();
|
||||
connect(&domainHandler, &DomainHandler::disconnectedFromDomain, this, &ConnectionMonitor::disconnectedFromDomain);
|
||||
connect(&domainHandler, &DomainHandler::connectedToDomain, this, &ConnectionMonitor::connectedToDomain);
|
||||
connect(&domainHandler, &DomainHandler::resetting, this, &ConnectionMonitor::startTimer);
|
||||
connect(&domainHandler, &DomainHandler::disconnectedFromDomain, this, &ConnectionMonitor::startTimer);
|
||||
connect(&domainHandler, &DomainHandler::connectedToDomain, this, &ConnectionMonitor::stopTimer);
|
||||
connect(&domainHandler, &DomainHandler::authRequired, this, &ConnectionMonitor::stopTimer);
|
||||
|
||||
_timer.setSingleShot(true);
|
||||
_timer.setInterval(ON_INITIAL_LOAD_DISPLAY_AFTER_DISCONNECTED_FOR_X_MS);
|
||||
|
@ -36,8 +38,10 @@ void ConnectionMonitor::init() {
|
|||
_timer.start();
|
||||
}
|
||||
|
||||
auto dialogsManager = DependencyManager::get<DialogsManager>();
|
||||
connect(&_timer, &QTimer::timeout, dialogsManager.data(), &DialogsManager::indicateDomainConnectionFailure);
|
||||
connect(&_timer, &QTimer::timeout, this, []() {
|
||||
qDebug() << "ConnectionMonitor: Showing connection failure window";
|
||||
DependencyManager::get<DialogsManager>()->setDomainConnectionFailureVisibility(true);
|
||||
});
|
||||
}
|
||||
|
||||
void ConnectionMonitor::startTimer() {
|
||||
|
@ -49,4 +53,5 @@ void ConnectionMonitor::startTimer() {
|
|||
void ConnectionMonitor::stopTimer() {
|
||||
qDebug() << "ConnectionMonitor: Stopping timer";
|
||||
_timer.stop();
|
||||
DependencyManager::get<DialogsManager>()->setDomainConnectionFailureVisibility(false);
|
||||
}
|
||||
|
|
|
@ -23,8 +23,8 @@ public:
|
|||
void init();
|
||||
|
||||
private slots:
|
||||
void disconnectedFromDomain();
|
||||
void connectedToDomain(const QString& name);
|
||||
void startTimer();
|
||||
void stopTimer();
|
||||
|
||||
private:
|
||||
QTimer _timer;
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "AddressBarDialog.h"
|
||||
#include "BandwidthDialog.h"
|
||||
#include "CachesSizeDialog.h"
|
||||
#include "ConnectionFailureDialog.h"
|
||||
#include "DiskCacheEditor.h"
|
||||
#include "DomainConnectionDialog.h"
|
||||
#include "HMDToolsDialog.h"
|
||||
|
@ -63,6 +64,14 @@ void DialogsManager::indicateDomainConnectionFailure() {
|
|||
OffscreenUi::information("No Connection", "Unable to connect to this domain. Click the 'GO TO' button on the toolbar to visit another domain.");
|
||||
}
|
||||
|
||||
void DialogsManager::setDomainConnectionFailureVisibility(bool visible) {
|
||||
if (visible) {
|
||||
ConnectionFailureDialog::show();
|
||||
} else {
|
||||
ConnectionFailureDialog::hide();
|
||||
}
|
||||
}
|
||||
|
||||
void DialogsManager::toggleDiskCacheEditor() {
|
||||
maybeCreateDialog(_diskCacheEditor);
|
||||
_diskCacheEditor->toggle();
|
||||
|
|
|
@ -45,6 +45,7 @@ public slots:
|
|||
void showAddressBar();
|
||||
void showFeed();
|
||||
void indicateDomainConnectionFailure();
|
||||
void setDomainConnectionFailureVisibility(bool visible);
|
||||
void toggleDiskCacheEditor();
|
||||
void toggleLoginDialog();
|
||||
void showLoginDialog();
|
||||
|
|
|
@ -425,6 +425,7 @@ void DomainHandler::processDomainServerConnectionDeniedPacket(QSharedPointer<Rec
|
|||
if (!_hasCheckedForAccessToken) {
|
||||
accountManager->checkAndSignalForAccessToken();
|
||||
_hasCheckedForAccessToken = true;
|
||||
emit authRequired();
|
||||
}
|
||||
|
||||
static const int CONNECTION_DENIALS_FOR_KEYPAIR_REGEN = 3;
|
||||
|
|
|
@ -117,6 +117,8 @@ signals:
|
|||
void connectedToDomain(const QString& hostname);
|
||||
void disconnectedFromDomain();
|
||||
|
||||
void authRequired();
|
||||
|
||||
void iceSocketAndIDReceived();
|
||||
void icePeerSocketsReceived();
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ private: \
|
|||
public: \
|
||||
static void registerType(); \
|
||||
static void show(std::function<void(QQmlContext*, QObject*)> f = [](QQmlContext*, QObject*) {}); \
|
||||
static void hide(); \
|
||||
static void toggle(std::function<void(QQmlContext*, QObject*)> f = [](QQmlContext*, QObject*) {}); \
|
||||
static void load(std::function<void(QQmlContext*, QObject*)> f = [](QQmlContext*, QObject*) {}); \
|
||||
private:
|
||||
|
@ -33,6 +34,7 @@ protected: \
|
|||
public: \
|
||||
static void registerType(); \
|
||||
static void show(); \
|
||||
static void hide(); \
|
||||
static void toggle(); \
|
||||
static void load(); \
|
||||
private:
|
||||
|
@ -50,6 +52,11 @@ private:
|
|||
offscreenUi->show(QML, NAME, f); \
|
||||
} \
|
||||
\
|
||||
void x::hide() { \
|
||||
auto offscreenUi = DependencyManager::get<OffscreenUi>(); \
|
||||
offscreenUi->hide(NAME); \
|
||||
} \
|
||||
\
|
||||
void x::toggle(std::function<void(QQmlContext*, QObject*)> f) { \
|
||||
auto offscreenUi = DependencyManager::get<OffscreenUi>(); \
|
||||
offscreenUi->toggle(QML, NAME, f); \
|
||||
|
@ -70,6 +77,11 @@ private:
|
|||
auto offscreenUi = DependencyManager::get<OffscreenUi>(); \
|
||||
offscreenUi->show(QML, NAME, f); \
|
||||
} \
|
||||
void x::hide() { \
|
||||
auto offscreenUi = DependencyManager::get<OffscreenUi>(); \
|
||||
offscreenUi->hide(NAME); \
|
||||
} \
|
||||
\
|
||||
void x::toggle() { \
|
||||
auto offscreenUi = DependencyManager::get<OffscreenUi>(); \
|
||||
offscreenUi->toggle(QML, NAME, f); \
|
||||
|
|
Loading…
Reference in a new issue