History

expose account details via AccountScriptingInterface

Stojce Slavkovski committed 12 years ago

Commit 8de2bdf1 parent 39c1dac4 files · +85 −9Browse files

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

Unified · Split

interface/src/scripting/AccountScriptingInterface.cpp+37−0
@@ -0,0 +1,37 @@
1+//
2+// AccountScriptingInterface.cpp
3+// interface/src/scripting
4+//
5+// Created by Stojce Slavkovski on 6/07/14.
6+// Copyright 2014 High Fidelity, Inc.
7+//
8+// Distributed under the Apache License, Version 2.0.
9+// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
10+//
11+
12+#include "AccountScriptingInterface.h"
13+
14+AccountScriptingInterface::AccountScriptingInterface() {
15+ AccountManager& accountManager = AccountManager::getInstance();
16+ connect(&accountManager, &AccountManager::balanceChanged, this,
17+ &AccountScriptingInterface::updateBalance);
18+}
19+
20+AccountScriptingInterface* AccountScriptingInterface::getInstance() {
21+ static AccountScriptingInterface sharedInstance;
22+ return &sharedInstance;
23+}
24+
25+qint64 AccountScriptingInterface::getBalance() {
26+ AccountManager& accountManager = AccountManager::getInstance();
27+ return accountManager.getAccountInfo().getBalance();
28+}
29+
30+bool AccountScriptingInterface::isLoggedIn() {
31+ AccountManager& accountManager = AccountManager::getInstance();
32+ return accountManager.isLoggedIn();
33+}
34+
35+void AccountScriptingInterface::updateBalance(qint16 newBalance) {
36+ emit balanceChanged(newBalance);
37+}