From b87d65df30c05114ce86dd0d59034f93d564c549 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Tue, 18 Feb 2014 13:23:53 -0800 Subject: [PATCH] re-set domain auth info if hostname changes --- libraries/shared/src/DomainInfo.cpp | 14 ++++++++++++-- libraries/shared/src/DomainInfo.h | 2 ++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/libraries/shared/src/DomainInfo.cpp b/libraries/shared/src/DomainInfo.cpp index 863edba9ae..f1831f240b 100644 --- a/libraries/shared/src/DomainInfo.cpp +++ b/libraries/shared/src/DomainInfo.cpp @@ -17,9 +17,20 @@ DomainInfo::DomainInfo() : } +void DomainInfo::reset() { + _hostname = QString(); + _sockAddr.setAddress(QHostAddress::Null); + _connectionSecret = QString(); + _registrationToken = QString(); + _rootAuthenticationURL = QUrl(); +} + void DomainInfo::setHostname(const QString& hostname) { if (hostname != _hostname) { + // re-set the domain info so that auth information is reloaded + reset(); + int colonIndex = hostname.indexOf(':'); if (colonIndex > 0) { @@ -40,9 +51,8 @@ void DomainInfo::setHostname(const QString& hostname) { } // re-set the sock addr to null and fire off a lookup of the IP address for this domain-server's hostname - _sockAddr.setAddress(QHostAddress::Null); qDebug("Looking up DS hostname %s.", _hostname.toLocal8Bit().constData()); - QHostInfo::lookupHost(_hostname, this, SLOT(completedHostnameLookup(const QHostInfo&))); + QHostInfo::lookupHost(_hostname, this, SLOT(completedHostnameLookup)); emit hostnameChanged(_hostname); } diff --git a/libraries/shared/src/DomainInfo.h b/libraries/shared/src/DomainInfo.h index 72e5a853e4..b42545f980 100644 --- a/libraries/shared/src/DomainInfo.h +++ b/libraries/shared/src/DomainInfo.h @@ -49,6 +49,8 @@ private slots: signals: void hostnameChanged(const QString& hostname); private: + void reset(); + QString _hostname; HifiSockAddr _sockAddr; QUuid _connectionSecret;