add new address accessor for 'public' addresses, use it for snapshot and stream

This commit is contained in:
Seth Alves 2018-04-05 13:39:51 -07:00
parent 148007435e
commit 8de545acdf
4 changed files with 26 additions and 9 deletions

View file

@ -129,7 +129,7 @@ void DiscoverabilityManager::updateLocation() {
// Update Steam // Update Steam
if (auto steamClient = PluginManager::getInstance()->getSteamClientPlugin()) { if (auto steamClient = PluginManager::getInstance()->getSteamClientPlugin()) {
steamClient->updateLocation(domainHandler.getHostname(), addressManager->currentFacingShareableAddress()); steamClient->updateLocation(domainHandler.getHostname(), addressManager->currentFacingPublicAddress());
} }
} }

View file

@ -95,7 +95,7 @@ QTemporaryFile* Snapshot::saveTempSnapshot(QImage image) {
QFile* Snapshot::savedFileForSnapshot(QImage & shot, bool isTemporary, const QString& userSelectedFilename) { QFile* Snapshot::savedFileForSnapshot(QImage & shot, bool isTemporary, const QString& userSelectedFilename) {
// adding URL to snapshot // adding URL to snapshot
QUrl currentURL = DependencyManager::get<AddressManager>()->currentShareableAddress(); QUrl currentURL = DependencyManager::get<AddressManager>()->currentPublicAddress();
shot.setText(URL, currentURL.toString()); shot.setText(URL, currentURL.toString());
QString username = DependencyManager::get<AccountManager>()->getAccountInfo().getUsername(); QString username = DependencyManager::get<AccountManager>()->getAccountInfo().getUsername();

View file

@ -60,7 +60,6 @@ QUrl AddressManager::currentFacingAddress() const {
} }
QUrl AddressManager::currentShareableAddress(bool domainOnly) const { QUrl AddressManager::currentShareableAddress(bool domainOnly) const {
QUrl shareableAddress;
if (!_shareablePlaceName.isEmpty()) { if (!_shareablePlaceName.isEmpty()) {
// if we have a shareable place name use that instead of whatever the current host is // if we have a shareable place name use that instead of whatever the current host is
QUrl hifiURL; QUrl hifiURL;
@ -72,18 +71,23 @@ QUrl AddressManager::currentShareableAddress(bool domainOnly) const {
hifiURL.setPath(currentPath()); hifiURL.setPath(currentPath());
} }
shareableAddress = hifiURL; return hifiURL;
} else { } else {
shareableAddress = currentAddress(domainOnly); return currentAddress(domainOnly);
} }
}
QUrl AddressManager::currentPublicAddress(bool domainOnly) const {
// return an address that can be used by others to visit this client's current location. If
// in a serverless domain (which can't be visited) return an empty URL.
QUrl shareableAddress = currentShareableAddress(domainOnly);
if (shareableAddress.scheme() != URL_SCHEME_HIFI) { if (shareableAddress.scheme() != URL_SCHEME_HIFI) {
return QUrl(); // file: urls aren't shareable return QUrl(); // file: urls aren't public
} }
return shareableAddress; return shareableAddress;
} }
QUrl AddressManager::currentFacingShareableAddress() const { QUrl AddressManager::currentFacingShareableAddress() const {
auto hifiURL = currentShareableAddress(); auto hifiURL = currentShareableAddress();
if (hifiURL.scheme() == URL_SCHEME_HIFI) { if (hifiURL.scheme() == URL_SCHEME_HIFI) {
@ -93,6 +97,17 @@ QUrl AddressManager::currentFacingShareableAddress() const {
return hifiURL; return hifiURL;
} }
QUrl AddressManager::currentFacingPublicAddress() const {
// return an address that can be used by others to visit this client's current location. If
// in a serverless domain (which can't be visited) return an empty URL.
QUrl shareableAddress = currentFacingShareableAddress();
if (shareableAddress.scheme() != URL_SCHEME_HIFI) {
return QUrl(); // file: urls aren't public
}
return shareableAddress;
}
void AddressManager::loadSettings(const QString& lookupString) { void AddressManager::loadSettings(const QString& lookupString) {
#if defined(USE_GLES) && defined(Q_OS_WIN) #if defined(USE_GLES) && defined(Q_OS_WIN)
handleUrl(QUrl("hifi://127.0.0.0"), LookupTrigger::StartupFromSettings); handleUrl(QUrl("hifi://127.0.0.0"), LookupTrigger::StartupFromSettings);
@ -825,8 +840,8 @@ void AddressManager::copyAddress() {
return; return;
} }
// currentShareableAddress will be blank for serverless domains, so use currentFacingAddress here // assume that the address is being copied because the user wants a shareable address
QGuiApplication::clipboard()->setText(currentFacingAddress().toString()); QGuiApplication::clipboard()->setText(currentShareableAddress().toString());
} }
void AddressManager::copyPath() { void AddressManager::copyPath() {

View file

@ -150,7 +150,9 @@ public:
QUrl currentAddress(bool domainOnly = false) const; QUrl currentAddress(bool domainOnly = false) const;
QUrl currentFacingAddress() const; QUrl currentFacingAddress() const;
QUrl currentShareableAddress(bool domainOnly = false) const; QUrl currentShareableAddress(bool domainOnly = false) const;
QUrl currentPublicAddress(bool domainOnly = false) const;
QUrl currentFacingShareableAddress() const; QUrl currentFacingShareableAddress() const;
QUrl currentFacingPublicAddress() const;
QString currentPath(bool withOrientation = true) const; QString currentPath(bool withOrientation = true) const;
QString currentFacingPath() const; QString currentFacingPath() const;