summaryrefslogtreecommitdiffstats
path: root/framework/domain/accountscontroller.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'framework/domain/accountscontroller.cpp')
-rw-r--r--framework/domain/accountscontroller.cpp29
1 files changed, 10 insertions, 19 deletions
diff --git a/framework/domain/accountscontroller.cpp b/framework/domain/accountscontroller.cpp
index 1be03ba9..b5e7e9ca 100644
--- a/framework/domain/accountscontroller.cpp
+++ b/framework/domain/accountscontroller.cpp
@@ -21,6 +21,7 @@
21#include "accountscontroller.h" 21#include "accountscontroller.h"
22 22
23#include <settings/settings.h> 23#include <settings/settings.h>
24#include <sink/store.h>
24 25
25#include <QVariant> 26#include <QVariant>
26#include <QUuid> 27#include <QUuid>
@@ -28,27 +29,17 @@
28 29
29AccountsController::AccountsController(QObject *parent) : QObject(parent) 30AccountsController::AccountsController(QObject *parent) : QObject(parent)
30{ 31{
31 Kube::Settings settings("accounts");
32 mAccounts = settings.property("accounts").toStringList();
33 qWarning() << "Loaded accounts" << mAccounts;
34} 32}
35 33
36void AccountsController::createAccount(const QString &accountType) 34void AccountsController::createAccount(const QString &accountType)
37{ 35{
38 auto identifier = QUuid::createUuid().toByteArray(); 36 const auto identifier = QUuid::createUuid().toByteArray();
39 Kube::Account accountSettings(identifier); 37 Sink::ApplicationDomain::SinkAccount account;
40 accountSettings.setProperty("type", accountType); 38 account.setProperty("identifier", identifier);
41 accountSettings.save(); 39 account.setProperty("type", accountType);
42 40 Sink::Store::create(account).then<void>([]() {},
43 Kube::Settings settings("accounts"); 41 [](int errorCode, const QString &errorMessage) {
44 auto accounts = settings.property("accounts").toStringList(); 42 qWarning() << "Error while creating account: " << errorMessage;
45 accounts.append(identifier); 43 })
46 settings.setProperty("accounts", accounts); 44 .exec();
47 settings.save();
48
49 //TODO setup sink resources etc via plugin
50
51 qWarning() << "Created account " << identifier;
52 mAccounts.append(identifier);
53 emit accountsChanged();
54} 45}