History

remove unused AccountScriptingInterface functions and merge/wrap the rest into GlobalServicesScriptingInterface

David Back committed 9 years ago

Commit b60bf4f1 parent ea38b324 files · +49 −54Browse files

Showing the changes to interface/src/scripting/AccountScriptingInterface.cpp (1 of 4 files). Show all

Unified · Split

interface/src/scripting/AccountScriptingInterface.cpp+6−28
@@ -12,47 +12,25 @@ · 11 unmodified lines
1212 #include "AccountManager.h"
1313
1414 #include "AccountScriptingInterface.h"
15+#include "GlobalServicesScriptingInterface.h"
1516
1617 AccountScriptingInterface* AccountScriptingInterface::getInstance() {
1718 static AccountScriptingInterface sharedInstance;
18− auto accountManager = DependencyManager::get<AccountManager>();
19− QObject::connect(accountManager.data(), &AccountManager::profileChanged,
20− &sharedInstance, &AccountScriptingInterface::usernameChanged);
21− QObject::connect(accountManager.data(), &AccountManager::usernameChanged,
22− &sharedInstance, &AccountScriptingInterface::onUsernameChanged);
2319 return &sharedInstance;
2420 }
2521
2622 bool AccountScriptingInterface::isLoggedIn() {
27− auto accountManager = DependencyManager::get<AccountManager>();
28− return accountManager->isLoggedIn();
29−}
30−
31−bool AccountScriptingInterface::checkAndSignalForAccessToken() {
32− auto accountManager = DependencyManager::get<AccountManager>();
33− return accountManager->checkAndSignalForAccessToken();
23+ return GlobalServicesScriptingInterface::getInstance()->isLoggedIn();
3424 }
3525
3626 void AccountScriptingInterface::logOut() {
37− auto accountManager = DependencyManager::get<AccountManager>();
38− return accountManager->logout();
39−}
40−
41−AccountScriptingInterface::AccountScriptingInterface(QObject *parent): QObject(parent) {
42− m_loggedIn = isLoggedIn();
43− emit loggedInChanged(m_loggedIn);
27+ GlobalServicesScriptingInterface::getInstance()->logOut();
4428 }
4529
46−void AccountScriptingInterface::onUsernameChanged(QString username) {
47− m_loggedIn = (username != QString());
48− emit loggedInChanged(m_loggedIn);
30+bool AccountScriptingInterface::loggedIn() const {
31+ return GlobalServicesScriptingInterface::getInstance()->loggedIn();
4932 }
5033
5134 QString AccountScriptingInterface::getUsername() {
52− auto accountManager = DependencyManager::get<AccountManager>();
53− if (accountManager->isLoggedIn()) {
54− return accountManager->getAccountInfo().getUsername();
55− } else {
56− return "Unknown user";
57− }
35+ return GlobalServicesScriptingInterface::getInstance()->getUsername();
5836 }