Showing the changes to interface/src/scripting/GlobalServicesScriptingInterface.cpp (1 of 4 files). Show all
Unified · Split
| @@ -18,7 +18,7 @@ · 17 unmodified lines | ||
| 18 | 18 | |
| 19 | 19 | GlobalServicesScriptingInterface::GlobalServicesScriptingInterface() { |
| 20 | 20 | auto accountManager = DependencyManager::get<AccountManager>(); |
| 21 | − connect(accountManager.data(), &AccountManager::usernameChanged, this, &GlobalServicesScriptingInterface::myUsernameChanged); | |
| 21 | + connect(accountManager.data(), &AccountManager::usernameChanged, this, &GlobalServicesScriptingInterface::onUsernameChanged); | |
| 22 | 22 | connect(accountManager.data(), &AccountManager::logoutComplete, this, &GlobalServicesScriptingInterface::loggedOut); |
| 23 | 23 | connect(accountManager.data(), &AccountManager::loginComplete, this, &GlobalServicesScriptingInterface::connected); |
| 24 | 24 | |
| @@ -31,11 +31,14 @@ GlobalServicesScriptingInterface::GlobalServicesScriptingInterface() { · 6 unmodified lines | ||
| 31 | 31 | auto discoverabilityManager = DependencyManager::get<DiscoverabilityManager>(); |
| 32 | 32 | connect(discoverabilityManager.data(), &DiscoverabilityManager::discoverabilityModeChanged, |
| 33 | 33 | this, &GlobalServicesScriptingInterface::discoverabilityModeChanged); |
| 34 | + | |
| 35 | + _loggedIn = isLoggedIn(); | |
| 36 | + emit loggedInChanged(_loggedIn); | |
| 34 | 37 | } |
| 35 | 38 | |
| 36 | 39 | GlobalServicesScriptingInterface::~GlobalServicesScriptingInterface() { |
| 37 | 40 | auto accountManager = DependencyManager::get<AccountManager>(); |
| 38 | − disconnect(accountManager.data(), &AccountManager::usernameChanged, this, &GlobalServicesScriptingInterface::myUsernameChanged); | |
| 41 | + disconnect(accountManager.data(), &AccountManager::usernameChanged, this, &GlobalServicesScriptingInterface::onUsernameChanged); | |
| 39 | 42 | disconnect(accountManager.data(), &AccountManager::logoutComplete, this, &GlobalServicesScriptingInterface::loggedOut); |
| 40 | 43 | disconnect(accountManager.data(), &AccountManager::loginComplete, this, &GlobalServicesScriptingInterface::connected); |
| 41 | 44 | } |
| @@ -49,6 +52,21 @@ const QString& GlobalServicesScriptingInterface::getUsername() const { · 7 unmodified lines | ||
| 49 | 52 | return DependencyManager::get<AccountManager>()->getAccountInfo().getUsername(); |
| 50 | 53 | } |
| 51 | 54 | |
| 55 | +bool GlobalServicesScriptingInterface::isLoggedIn() { | |
| 56 | + auto accountManager = DependencyManager::get<AccountManager>(); | |
| 57 | + return accountManager->isLoggedIn(); | |
| 58 | +} | |
| 59 | + | |
| 60 | +bool GlobalServicesScriptingInterface::checkAndSignalForAccessToken() { | |
| 61 | + auto accountManager = DependencyManager::get<AccountManager>(); | |
| 62 | + return accountManager->checkAndSignalForAccessToken(); | |
| 63 | +} | |
| 64 | + | |
| 65 | +void GlobalServicesScriptingInterface::logOut() { | |
| 66 | + auto accountManager = DependencyManager::get<AccountManager>(); | |
| 67 | + return accountManager->logout(); | |
| 68 | +} | |
| 69 | + | |
| 52 | 70 | void GlobalServicesScriptingInterface::loggedOut() { |
| 53 | 71 | emit GlobalServicesScriptingInterface::disconnected(QString("logout")); |
| 54 | 72 | } |
| @@ -77,6 +95,12 @@ void GlobalServicesScriptingInterface::discoverabilityModeChanged(Discoverabilit · 22 unmodified lines | ||
| 77 | 95 | emit findableByChanged(DiscoverabilityManager::findableByString(discoverabilityMode)); |
| 78 | 96 | } |
| 79 | 97 | |
| 98 | +void GlobalServicesScriptingInterface::onUsernameChanged(QString username) { | |
| 99 | + _loggedIn = (username != QString()); | |
| 100 | + emit myUsernameChanged(username); | |
| 101 | + emit loggedInChanged(_loggedIn); | |
| 102 | +} | |
| 103 | + | |
| 80 | 104 | DownloadInfoResult::DownloadInfoResult() : |
| 81 | 105 | downloading(QList<float>()), |
| 82 | 106 | pending(0.0f) |