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
12#include "AccountManager.h"12#include "AccountManager.h"
13 13
14#include "AccountScriptingInterface.h"14#include "AccountScriptingInterface.h"
15#include "GlobalServicesScriptingInterface.h"
15 16
16AccountScriptingInterface* AccountScriptingInterface::getInstance() {17AccountScriptingInterface* AccountScriptingInterface::getInstance() {
17 static AccountScriptingInterface sharedInstance;18 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);
23 return &sharedInstance;19 return &sharedInstance;
24}20}
25 21
26bool AccountScriptingInterface::isLoggedIn() {22bool AccountScriptingInterface::isLoggedIn() {
27 auto accountManager = DependencyManager::get<AccountManager>();23 return GlobalServicesScriptingInterface::getInstance()->isLoggedIn();
28 return accountManager->isLoggedIn();
29}
30
31bool AccountScriptingInterface::checkAndSignalForAccessToken() {
32 auto accountManager = DependencyManager::get<AccountManager>();
33 return accountManager->checkAndSignalForAccessToken();
34}24}
35 25
36void AccountScriptingInterface::logOut() {26void AccountScriptingInterface::logOut() {
37 auto accountManager = DependencyManager::get<AccountManager>();27 GlobalServicesScriptingInterface::getInstance()->logOut();
38 return accountManager->logout();
39}
40
41AccountScriptingInterface::AccountScriptingInterface(QObject *parent): QObject(parent) {
42 m_loggedIn = isLoggedIn();
43 emit loggedInChanged(m_loggedIn);
44}28}
45 29
46void AccountScriptingInterface::onUsernameChanged(QString username) {30bool AccountScriptingInterface::loggedIn() const {
47 m_loggedIn = (username != QString());31 return GlobalServicesScriptingInterface::getInstance()->loggedIn();
48 emit loggedInChanged(m_loggedIn);
49}32}
50 33
51QString AccountScriptingInterface::getUsername() {34QString AccountScriptingInterface::getUsername() {
52 auto accountManager = DependencyManager::get<AccountManager>();35 return GlobalServicesScriptingInterface::getInstance()->getUsername();
53 if (accountManager->isLoggedIn()) {
54 return accountManager->getAccountInfo().getUsername();
55 } else {
56 return "Unknown user";
57 }
58}36}