From 2f22c0cd962b3193e92d59a75b341e7dad1f112f Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Mon, 9 Mar 2015 16:28:01 -0700 Subject: [PATCH 01/10] cleanup username API from GlobalServicesScriptingInterface --- .../oculus/virtualKeyboardTextEntityExample.js | 2 +- .../GlobalServicesScriptingInterface.cpp | 4 ---- .../scripting/GlobalServicesScriptingInterface.h | 16 +++++++++------- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/examples/controllers/oculus/virtualKeyboardTextEntityExample.js b/examples/controllers/oculus/virtualKeyboardTextEntityExample.js index cf36fdbffb..15025831e7 100644 --- a/examples/controllers/oculus/virtualKeyboardTextEntityExample.js +++ b/examples/controllers/oculus/virtualKeyboardTextEntityExample.js @@ -86,7 +86,7 @@ keyboard.onKeyRelease = function(event) { var textLines = textText.split("\n"); var maxLineWidth = Overlays.textSize(textSizeMeasureOverlay, textText).width; - var usernameLine = "--" + GlobalServices.myUsername; + var usernameLine = "--" + GlobalServices.username; var usernameWidth = Overlays.textSize(textSizeMeasureOverlay, usernameLine).width; if (maxLineWidth < usernameWidth) { maxLineWidth = usernameWidth; diff --git a/interface/src/scripting/GlobalServicesScriptingInterface.cpp b/interface/src/scripting/GlobalServicesScriptingInterface.cpp index 478b708e53..37367fe40c 100644 --- a/interface/src/scripting/GlobalServicesScriptingInterface.cpp +++ b/interface/src/scripting/GlobalServicesScriptingInterface.cpp @@ -36,10 +36,6 @@ GlobalServicesScriptingInterface* GlobalServicesScriptingInterface::getInstance( return &sharedInstance; } -QString GlobalServicesScriptingInterface::getMyUsername() { - return AccountManager::getInstance().getAccountInfo().getUsername(); -} - void GlobalServicesScriptingInterface::loggedOut() { emit GlobalServicesScriptingInterface::disconnected(QString("logout")); } diff --git a/interface/src/scripting/GlobalServicesScriptingInterface.h b/interface/src/scripting/GlobalServicesScriptingInterface.h index a71446a970..bf49df15ad 100644 --- a/interface/src/scripting/GlobalServicesScriptingInterface.h +++ b/interface/src/scripting/GlobalServicesScriptingInterface.h @@ -31,20 +31,21 @@ Q_DECLARE_METATYPE(DownloadInfoResult) QScriptValue DownloadInfoResultToScriptValue(QScriptEngine* engine, const DownloadInfoResult& result); void DownloadInfoResultFromScriptValue(const QScriptValue& object, DownloadInfoResult& result); - class GlobalServicesScriptingInterface : public QObject { Q_OBJECT - Q_PROPERTY(QString myUsername READ getMyUsername) - GlobalServicesScriptingInterface(); - ~GlobalServicesScriptingInterface(); + + Q_PROPERTY(QString username READ getUsername) + public: static GlobalServicesScriptingInterface* getInstance(); - QString getMyUsername(); + const QString& getUsername() const { return AccountManager::getInstance().getAccountInfo().getUsername(); } public slots: DownloadInfoResult getDownloadInfo(); void updateDownloadInfo(); + + void setDiscoverability(const QString& discoverability); private slots: void loggedOut(); @@ -53,12 +54,13 @@ private slots: signals: void connected(); void disconnected(const QString& reason); - void incomingMessage(const QString& username, const QString& message); - void onlineUsersChanged(const QStringList& usernames); void myUsernameChanged(const QString& username); void downloadInfoChanged(DownloadInfoResult info); private: + GlobalServicesScriptingInterface(); + ~GlobalServicesScriptingInterface(); + bool _downloading; }; From f81ae309181f2d1b72fc86fe5b86891a4c967a66 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Mon, 9 Mar 2015 16:32:09 -0700 Subject: [PATCH 02/10] fix getUsername for AccountManager include in implementation --- interface/src/scripting/GlobalServicesScriptingInterface.cpp | 4 ++++ interface/src/scripting/GlobalServicesScriptingInterface.h | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/interface/src/scripting/GlobalServicesScriptingInterface.cpp b/interface/src/scripting/GlobalServicesScriptingInterface.cpp index 37367fe40c..1b03fcd5e6 100644 --- a/interface/src/scripting/GlobalServicesScriptingInterface.cpp +++ b/interface/src/scripting/GlobalServicesScriptingInterface.cpp @@ -36,6 +36,10 @@ GlobalServicesScriptingInterface* GlobalServicesScriptingInterface::getInstance( return &sharedInstance; } +const QString& GlobalServicesScriptingInterface::getUsername() const { + return AccountManager::getInstance().getAccountInfo().getUsername(); +} + void GlobalServicesScriptingInterface::loggedOut() { emit GlobalServicesScriptingInterface::disconnected(QString("logout")); } diff --git a/interface/src/scripting/GlobalServicesScriptingInterface.h b/interface/src/scripting/GlobalServicesScriptingInterface.h index bf49df15ad..58d7259b6e 100644 --- a/interface/src/scripting/GlobalServicesScriptingInterface.h +++ b/interface/src/scripting/GlobalServicesScriptingInterface.h @@ -39,7 +39,7 @@ class GlobalServicesScriptingInterface : public QObject { public: static GlobalServicesScriptingInterface* getInstance(); - const QString& getUsername() const { return AccountManager::getInstance().getAccountInfo().getUsername(); } + const QString& getUsername() const; public slots: DownloadInfoResult getDownloadInfo(); From 77a60a3d72eb8aaaf6c1540551ce647f0705ac72 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Mon, 9 Mar 2015 16:34:00 -0700 Subject: [PATCH 03/10] remove discoverability setter until API ready --- interface/src/scripting/GlobalServicesScriptingInterface.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/interface/src/scripting/GlobalServicesScriptingInterface.h b/interface/src/scripting/GlobalServicesScriptingInterface.h index 58d7259b6e..ad19a9496c 100644 --- a/interface/src/scripting/GlobalServicesScriptingInterface.h +++ b/interface/src/scripting/GlobalServicesScriptingInterface.h @@ -44,8 +44,6 @@ public: public slots: DownloadInfoResult getDownloadInfo(); void updateDownloadInfo(); - - void setDiscoverability(const QString& discoverability); private slots: void loggedOut(); From 0658b54263d5c9b4ebf4a2ac118b08832504f474 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Mon, 9 Mar 2015 16:48:39 -0700 Subject: [PATCH 04/10] move location update to DiscoverabilityManager --- interface/src/Application.cpp | 45 ++-------------- interface/src/Application.h | 1 - interface/src/DiscoverabilityManager.cpp | 65 ++++++++++++++++++++++++ interface/src/DiscoverabilityManager.h | 26 ++++++++++ 4 files changed, 95 insertions(+), 42 deletions(-) create mode 100644 interface/src/DiscoverabilityManager.cpp create mode 100644 interface/src/DiscoverabilityManager.h diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 7addc27b3b..f393587006 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -87,6 +87,7 @@ #include "Application.h" #include "AudioClient.h" +#include "DiscoverabilityManager.h" #include "InterfaceVersion.h" #include "LODManager.h" #include "Menu.h" @@ -367,11 +368,12 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : connect(&domainHandler, &DomainHandler::hostnameChanged, DependencyManager::get().data(), &AddressManager::storeCurrentAddress); - // update our location every 5 seconds in the data-server, assuming that we are authenticated with one + // update our location every 5 seconds in the metaverse server, assuming that we are authenticated with one const qint64 DATA_SERVER_LOCATION_CHANGE_UPDATE_MSECS = 5 * 1000; locationUpdateTimer = new QTimer(this); - connect(locationUpdateTimer, &QTimer::timeout, this, &Application::updateLocationInServer); + auto discoverabilityManager = DependencyManager::get(); + connect(locationUpdateTimer, &QTimer::timeout, discoverabilityManager.data(), &DiscoverabilityManager::updateLocation); locationUpdateTimer->start(DATA_SERVER_LOCATION_CHANGE_UPDATE_MSECS); connect(nodeList.data(), &NodeList::nodeAdded, this, &Application::nodeAdded); @@ -3187,45 +3189,6 @@ void Application::updateWindowTitle(){ _window->setWindowTitle(title); } -void Application::updateLocationInServer() { - - AccountManager& accountManager = AccountManager::getInstance(); - auto addressManager = DependencyManager::get(); - DomainHandler& domainHandler = DependencyManager::get()->getDomainHandler(); - - if (accountManager.isLoggedIn() && domainHandler.isConnected() - && (!addressManager->getRootPlaceID().isNull() || !domainHandler.getUUID().isNull())) { - - // construct a QJsonObject given the user's current address information - QJsonObject rootObject; - - QJsonObject locationObject; - - QString pathString = addressManager->currentPath(); - - const QString LOCATION_KEY_IN_ROOT = "location"; - - const QString PATH_KEY_IN_LOCATION = "path"; - locationObject.insert(PATH_KEY_IN_LOCATION, pathString); - - if (!addressManager->getRootPlaceID().isNull()) { - const QString PLACE_ID_KEY_IN_LOCATION = "place_id"; - locationObject.insert(PLACE_ID_KEY_IN_LOCATION, - uuidStringWithoutCurlyBraces(addressManager->getRootPlaceID())); - - } else { - const QString DOMAIN_ID_KEY_IN_LOCATION = "domain_id"; - locationObject.insert(DOMAIN_ID_KEY_IN_LOCATION, - uuidStringWithoutCurlyBraces(domainHandler.getUUID())); - } - - rootObject.insert(LOCATION_KEY_IN_ROOT, locationObject); - - accountManager.authenticatedRequest("/api/v1/user/location", QNetworkAccessManager::PutOperation, - JSONCallbackParameters(), QJsonDocument(rootObject).toJson()); - } -} - void Application::clearDomainOctreeDetails() { qDebug() << "Clearing domain octree details..."; // reset the environment so that we don't erroneously end up with multiple diff --git a/interface/src/Application.h b/interface/src/Application.h index ce4bae45b9..1da5f430b6 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -318,7 +318,6 @@ signals: public slots: void domainChanged(const QString& domainHostname); void updateWindowTitle(); - void updateLocationInServer(); void nodeAdded(SharedNodePointer node); void nodeKilled(SharedNodePointer node); void packetSent(quint64 length); diff --git a/interface/src/DiscoverabilityManager.cpp b/interface/src/DiscoverabilityManager.cpp new file mode 100644 index 0000000000..e2fa011ed8 --- /dev/null +++ b/interface/src/DiscoverabilityManager.cpp @@ -0,0 +1,65 @@ +// +// DiscoverabilityManager.cpp +// interface/src +// +// Created by Stephen Birarda on 2015-03-09. +// Copyright 2015 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#include + +#include +#include +#include +#include +#include + +#include "DiscoverabilityManager.h" + +const QString API_USER_LOCATION_PATH = "/api/v1/user/location"; + +void DiscoverabilityManager::updateLocation() { + AccountManager& accountManager = AccountManager::getInstance(); + auto addressManager = DependencyManager::get(); + DomainHandler& domainHandler = DependencyManager::get()->getDomainHandler(); + + if (accountManager.isLoggedIn() && domainHandler.isConnected() + && (!addressManager->getRootPlaceID().isNull() || !domainHandler.getUUID().isNull())) { + + // construct a QJsonObject given the user's current address information + QJsonObject rootObject; + + QJsonObject locationObject; + + QString pathString = addressManager->currentPath(); + + const QString LOCATION_KEY_IN_ROOT = "location"; + + const QString PATH_KEY_IN_LOCATION = "path"; + locationObject.insert(PATH_KEY_IN_LOCATION, pathString); + + if (!addressManager->getRootPlaceID().isNull()) { + const QString PLACE_ID_KEY_IN_LOCATION = "place_id"; + locationObject.insert(PLACE_ID_KEY_IN_LOCATION, + uuidStringWithoutCurlyBraces(addressManager->getRootPlaceID())); + + } else { + const QString DOMAIN_ID_KEY_IN_LOCATION = "domain_id"; + locationObject.insert(DOMAIN_ID_KEY_IN_LOCATION, + uuidStringWithoutCurlyBraces(domainHandler.getUUID())); + } + + rootObject.insert(LOCATION_KEY_IN_ROOT, locationObject); + + accountManager.authenticatedRequest(API_USER_LOCATION_PATH, QNetworkAccessManager::PutOperation, + JSONCallbackParameters(), QJsonDocument(rootObject).toJson()); + } +} + +void DiscoverabilityManager::removeLocation() { + AccountManager& accountManager = AccountManager::getInstance(); + accountManager.authenticatedRequest(API_USER_LOCATION_PATH, QNetworkAccessManager::DeleteOperation); +} \ No newline at end of file diff --git a/interface/src/DiscoverabilityManager.h b/interface/src/DiscoverabilityManager.h new file mode 100644 index 0000000000..a9533b5efe --- /dev/null +++ b/interface/src/DiscoverabilityManager.h @@ -0,0 +1,26 @@ +// +// DiscoverabilityManager.h +// interface/src +// +// Created by Stephen Birarda on 2015-03-09. +// Copyright 2015 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#ifndef hifi_DiscoverabilityManager_h +#define hifi_DiscoverabilityManager_h + +#include + +class DiscoverabilityManager : public QObject, public Dependency { + Q_OBJECT + SINGLETON_DEPENDENCY + +public slots: + void updateLocation(); + void removeLocation(); +}; + +#endif // hifi_DiscoverabilityManager_h \ No newline at end of file From 6d900d5a40d72c7a78b37f0b52957e8f02152844 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Mon, 9 Mar 2015 17:05:57 -0700 Subject: [PATCH 05/10] handle discoverability change in DiscoverabilityManager --- interface/src/Application.cpp | 1 + interface/src/DiscoverabilityManager.cpp | 87 +++++++++++++++--------- interface/src/DiscoverabilityManager.h | 20 +++++- 3 files changed, 76 insertions(+), 32 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index f393587006..b30be206df 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -247,6 +247,7 @@ bool setupEssentials(int& argc, char** argv) { #if defined(Q_OS_MAC) || defined(Q_OS_WIN) auto speechRecognizer = DependencyManager::set(); #endif + auto discoverabilityManager = DependencyManager::set(); return true; } diff --git a/interface/src/DiscoverabilityManager.cpp b/interface/src/DiscoverabilityManager.cpp index e2fa011ed8..3c27e90152 100644 --- a/interface/src/DiscoverabilityManager.cpp +++ b/interface/src/DiscoverabilityManager.cpp @@ -19,47 +19,72 @@ #include "DiscoverabilityManager.h" +const Discoverability::Mode DEFAULT_DISCOVERABILITY_MODE = Discoverability::None; + +DiscoverabilityManager::DiscoverabilityManager() : + _mode("discoverabilityMode", DEFAULT_DISCOVERABILITY_MODE) +{ + +} + const QString API_USER_LOCATION_PATH = "/api/v1/user/location"; void DiscoverabilityManager::updateLocation() { - AccountManager& accountManager = AccountManager::getInstance(); - auto addressManager = DependencyManager::get(); - DomainHandler& domainHandler = DependencyManager::get()->getDomainHandler(); - - if (accountManager.isLoggedIn() && domainHandler.isConnected() - && (!addressManager->getRootPlaceID().isNull() || !domainHandler.getUUID().isNull())) { + if (_mode.get() != Discoverability::None) { + AccountManager& accountManager = AccountManager::getInstance(); + auto addressManager = DependencyManager::get(); + DomainHandler& domainHandler = DependencyManager::get()->getDomainHandler(); - // construct a QJsonObject given the user's current address information - QJsonObject rootObject; - - QJsonObject locationObject; - - QString pathString = addressManager->currentPath(); - - const QString LOCATION_KEY_IN_ROOT = "location"; - - const QString PATH_KEY_IN_LOCATION = "path"; - locationObject.insert(PATH_KEY_IN_LOCATION, pathString); - - if (!addressManager->getRootPlaceID().isNull()) { - const QString PLACE_ID_KEY_IN_LOCATION = "place_id"; - locationObject.insert(PLACE_ID_KEY_IN_LOCATION, - uuidStringWithoutCurlyBraces(addressManager->getRootPlaceID())); + if (accountManager.isLoggedIn() && domainHandler.isConnected() + && (!addressManager->getRootPlaceID().isNull() || !domainHandler.getUUID().isNull())) { - } else { - const QString DOMAIN_ID_KEY_IN_LOCATION = "domain_id"; - locationObject.insert(DOMAIN_ID_KEY_IN_LOCATION, - uuidStringWithoutCurlyBraces(domainHandler.getUUID())); + // construct a QJsonObject given the user's current address information + QJsonObject rootObject; + + QJsonObject locationObject; + + QString pathString = addressManager->currentPath(); + + const QString LOCATION_KEY_IN_ROOT = "location"; + + const QString PATH_KEY_IN_LOCATION = "path"; + locationObject.insert(PATH_KEY_IN_LOCATION, pathString); + + if (!addressManager->getRootPlaceID().isNull()) { + const QString PLACE_ID_KEY_IN_LOCATION = "place_id"; + locationObject.insert(PLACE_ID_KEY_IN_LOCATION, + uuidStringWithoutCurlyBraces(addressManager->getRootPlaceID())); + + } else { + const QString DOMAIN_ID_KEY_IN_LOCATION = "domain_id"; + locationObject.insert(DOMAIN_ID_KEY_IN_LOCATION, + uuidStringWithoutCurlyBraces(domainHandler.getUUID())); + } + + rootObject.insert(LOCATION_KEY_IN_ROOT, locationObject); + + accountManager.authenticatedRequest(API_USER_LOCATION_PATH, QNetworkAccessManager::PutOperation, + JSONCallbackParameters(), QJsonDocument(rootObject).toJson()); } - - rootObject.insert(LOCATION_KEY_IN_ROOT, locationObject); - - accountManager.authenticatedRequest(API_USER_LOCATION_PATH, QNetworkAccessManager::PutOperation, - JSONCallbackParameters(), QJsonDocument(rootObject).toJson()); + } else { + qDebug() << "not updating discoverability since it is currently set to none!"; } } void DiscoverabilityManager::removeLocation() { AccountManager& accountManager = AccountManager::getInstance(); accountManager.authenticatedRequest(API_USER_LOCATION_PATH, QNetworkAccessManager::DeleteOperation); +} + +void DiscoverabilityManager::setDiscoverability(Discoverability::Mode discoverabilityMode) { + if (_mode.get() != discoverabilityMode) { + + // update the setting to the new value + _mode.set(discoverabilityMode); + + if (_mode.get() == Discoverability::None) { + // if we just got set to no discoverability, make sure that we delete our location in DB + removeLocation(); + } + } } \ No newline at end of file diff --git a/interface/src/DiscoverabilityManager.h b/interface/src/DiscoverabilityManager.h index a9533b5efe..cb7791e82f 100644 --- a/interface/src/DiscoverabilityManager.h +++ b/interface/src/DiscoverabilityManager.h @@ -13,6 +13,17 @@ #define hifi_DiscoverabilityManager_h #include +#include + +namespace Discoverability { + enum Mode { + None, + Friends, + All + }; +} + +Q_DECLARE_METATYPE(Discoverability::Mode); class DiscoverabilityManager : public QObject, public Dependency { Q_OBJECT @@ -20,7 +31,14 @@ class DiscoverabilityManager : public QObject, public Dependency { public slots: void updateLocation(); - void removeLocation(); + void removeLocation(); + + void setDiscoverability(Discoverability::Mode discoverabilityMode); + +private: + DiscoverabilityManager(); + + Setting::Handle _mode; }; #endif // hifi_DiscoverabilityManager_h \ No newline at end of file From cd382eeea5dc10aa8b06b8364c648aa2f08d043f Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Mon, 9 Mar 2015 17:20:09 -0700 Subject: [PATCH 06/10] expose discoverability changes to js --- interface/src/DiscoverabilityManager.cpp | 4 +-- interface/src/DiscoverabilityManager.h | 3 ++- .../GlobalServicesScriptingInterface.cpp | 27 +++++++++++++++++++ .../GlobalServicesScriptingInterface.h | 4 +++ 4 files changed, 34 insertions(+), 4 deletions(-) diff --git a/interface/src/DiscoverabilityManager.cpp b/interface/src/DiscoverabilityManager.cpp index 3c27e90152..7dca8c399a 100644 --- a/interface/src/DiscoverabilityManager.cpp +++ b/interface/src/DiscoverabilityManager.cpp @@ -66,8 +66,6 @@ void DiscoverabilityManager::updateLocation() { accountManager.authenticatedRequest(API_USER_LOCATION_PATH, QNetworkAccessManager::PutOperation, JSONCallbackParameters(), QJsonDocument(rootObject).toJson()); } - } else { - qDebug() << "not updating discoverability since it is currently set to none!"; } } @@ -76,7 +74,7 @@ void DiscoverabilityManager::removeLocation() { accountManager.authenticatedRequest(API_USER_LOCATION_PATH, QNetworkAccessManager::DeleteOperation); } -void DiscoverabilityManager::setDiscoverability(Discoverability::Mode discoverabilityMode) { +void DiscoverabilityManager::setDiscoverabilityMode(Discoverability::Mode discoverabilityMode) { if (_mode.get() != discoverabilityMode) { // update the setting to the new value diff --git a/interface/src/DiscoverabilityManager.h b/interface/src/DiscoverabilityManager.h index cb7791e82f..6d9f912928 100644 --- a/interface/src/DiscoverabilityManager.h +++ b/interface/src/DiscoverabilityManager.h @@ -33,7 +33,8 @@ public slots: void updateLocation(); void removeLocation(); - void setDiscoverability(Discoverability::Mode discoverabilityMode); + Discoverability::Mode getDiscoverabilityMode() { return _mode.get(); } + void setDiscoverabilityMode(Discoverability::Mode discoverabilityMode); private: DiscoverabilityManager(); diff --git a/interface/src/scripting/GlobalServicesScriptingInterface.cpp b/interface/src/scripting/GlobalServicesScriptingInterface.cpp index 1b03fcd5e6..d39da47e78 100644 --- a/interface/src/scripting/GlobalServicesScriptingInterface.cpp +++ b/interface/src/scripting/GlobalServicesScriptingInterface.cpp @@ -11,6 +11,7 @@ #include "AccountManager.h" #include "Application.h" +#include "DiscoverabilityManager.h" #include "ResourceCache.h" #include "GlobalServicesScriptingInterface.h" @@ -44,6 +45,32 @@ void GlobalServicesScriptingInterface::loggedOut() { emit GlobalServicesScriptingInterface::disconnected(QString("logout")); } +QString GlobalServicesScriptingInterface::getFindableBy() const { + auto discoverabilityManager = DependencyManager::get(); + + if (discoverabilityManager->getDiscoverabilityMode() == Discoverability::None) { + return "none"; + } else if (discoverabilityManager->getDiscoverabilityMode() == Discoverability::Friends) { + return "friends"; + } else { + return "all"; + } +} + +void GlobalServicesScriptingInterface::setFindableBy(const QString& discoverabilityMode) { + auto discoverabilityManager = DependencyManager::get(); + + if (discoverabilityMode.toLower() == "none") { + discoverabilityManager->setDiscoverabilityMode(Discoverability::None); + } else if (discoverabilityMode.toLower() == "friends") { + discoverabilityManager->setDiscoverabilityMode(Discoverability::Friends); + } else if (discoverabilityMode.toLower() == "all") { + discoverabilityManager->setDiscoverabilityMode(Discoverability::All); + } else { + qDebug() << "GlobalServices setFindableBy called with an unrecognized value. Did not change discoverability."; + } +} + DownloadInfoResult::DownloadInfoResult() : downloading(QList()), pending(0.0f) diff --git a/interface/src/scripting/GlobalServicesScriptingInterface.h b/interface/src/scripting/GlobalServicesScriptingInterface.h index ad19a9496c..a39219ba40 100644 --- a/interface/src/scripting/GlobalServicesScriptingInterface.h +++ b/interface/src/scripting/GlobalServicesScriptingInterface.h @@ -35,6 +35,7 @@ class GlobalServicesScriptingInterface : public QObject { Q_OBJECT Q_PROPERTY(QString username READ getUsername) + Q_PROPERTY(QString findableBy READ getFindableBy WRITE setFindableBy) public: static GlobalServicesScriptingInterface* getInstance(); @@ -48,6 +49,9 @@ public slots: private slots: void loggedOut(); void checkDownloadInfo(); + + QString getFindableBy() const; + void setFindableBy(const QString& discoverabilityMode); signals: void connected(); From c6afa131d9a219d39e8e03c935fde19641095c0e Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Mon, 9 Mar 2015 17:26:56 -0700 Subject: [PATCH 07/10] store discoverability mode as an int --- interface/src/DiscoverabilityManager.cpp | 6 +++--- interface/src/DiscoverabilityManager.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/interface/src/DiscoverabilityManager.cpp b/interface/src/DiscoverabilityManager.cpp index 7dca8c399a..0d0139e1db 100644 --- a/interface/src/DiscoverabilityManager.cpp +++ b/interface/src/DiscoverabilityManager.cpp @@ -75,12 +75,12 @@ void DiscoverabilityManager::removeLocation() { } void DiscoverabilityManager::setDiscoverabilityMode(Discoverability::Mode discoverabilityMode) { - if (_mode.get() != discoverabilityMode) { + if (static_cast(_mode.get()) != discoverabilityMode) { // update the setting to the new value - _mode.set(discoverabilityMode); + _mode.set(static_cast(discoverabilityMode)); - if (_mode.get() == Discoverability::None) { + if (static_cast(_mode.get()) == Discoverability::None) { // if we just got set to no discoverability, make sure that we delete our location in DB removeLocation(); } diff --git a/interface/src/DiscoverabilityManager.h b/interface/src/DiscoverabilityManager.h index 6d9f912928..1dac7d63eb 100644 --- a/interface/src/DiscoverabilityManager.h +++ b/interface/src/DiscoverabilityManager.h @@ -33,13 +33,13 @@ public slots: void updateLocation(); void removeLocation(); - Discoverability::Mode getDiscoverabilityMode() { return _mode.get(); } + Discoverability::Mode getDiscoverabilityMode() { return static_cast(_mode.get()); } void setDiscoverabilityMode(Discoverability::Mode discoverabilityMode); private: DiscoverabilityManager(); - Setting::Handle _mode; + Setting::Handle _mode; }; #endif // hifi_DiscoverabilityManager_h \ No newline at end of file From de38221cf6a38e71eee63504bde83ed43175d23a Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Mon, 9 Mar 2015 17:28:44 -0700 Subject: [PATCH 08/10] default to All discoverability until UI is present --- interface/src/DiscoverabilityManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/src/DiscoverabilityManager.cpp b/interface/src/DiscoverabilityManager.cpp index 0d0139e1db..49850e4ef6 100644 --- a/interface/src/DiscoverabilityManager.cpp +++ b/interface/src/DiscoverabilityManager.cpp @@ -19,7 +19,7 @@ #include "DiscoverabilityManager.h" -const Discoverability::Mode DEFAULT_DISCOVERABILITY_MODE = Discoverability::None; +const Discoverability::Mode DEFAULT_DISCOVERABILITY_MODE = Discoverability::All; DiscoverabilityManager::DiscoverabilityManager() : _mode("discoverabilityMode", DEFAULT_DISCOVERABILITY_MODE) From 292354e180a0d37926fcf68419ac5ce80b0f906d Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Tue, 10 Mar 2015 11:33:49 -0700 Subject: [PATCH 09/10] manually call delete on GLCanvas in Application dtor --- interface/src/Application.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 6945e88949..aa5d0bfb88 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -602,7 +602,9 @@ Application::~Application() { _myAvatar = NULL; - ModelEntityItem::cleanupLoadedAnimations() ; + ModelEntityItem::cleanupLoadedAnimations(); + + delete _glWidget; DependencyManager::destroy(); DependencyManager::destroy(); @@ -614,7 +616,7 @@ Application::~Application() { } void Application::initializeGL() { - qDebug( "Created Display Window."); + qDebug() << "Created Display Window."; // initialize glut for shape drawing; Qt apparently initializes it on OS X #ifndef __APPLE__ @@ -629,7 +631,7 @@ void Application::initializeGL() { #ifdef WIN32 GLenum err = glewInit(); if (GLEW_OK != err) { - /* Problem: glewInit failed, something is seriously wrong. */ + /* Problem: glewInit fa iled, something is seriously wrong. */ qDebug("Error: %s\n", glewGetErrorString(err)); } qDebug("Status: Using GLEW %s\n", glewGetString(GLEW_VERSION)); From a8046b8316bf477073fa37910fdf942f43146fcb Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Tue, 10 Mar 2015 11:47:35 -0700 Subject: [PATCH 10/10] fix a typo in comment, NULL glWidget pointer --- interface/src/Application.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index aa5d0bfb88..0182e6e195 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -605,6 +605,7 @@ Application::~Application() { ModelEntityItem::cleanupLoadedAnimations(); delete _glWidget; + _glWidget = NULL; DependencyManager::destroy(); DependencyManager::destroy(); @@ -631,7 +632,7 @@ void Application::initializeGL() { #ifdef WIN32 GLenum err = glewInit(); if (GLEW_OK != err) { - /* Problem: glewInit fa iled, something is seriously wrong. */ + /* Problem: glewInit failed, something is seriously wrong. */ qDebug("Error: %s\n", glewGetErrorString(err)); } qDebug("Status: Using GLEW %s\n", glewGetString(GLEW_VERSION));