diff options
Diffstat (limited to 'framework/domain/accountscontroller.cpp')
-rw-r--r-- | framework/domain/accountscontroller.cpp | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/framework/domain/accountscontroller.cpp b/framework/domain/accountscontroller.cpp new file mode 100644 index 00000000..1be03ba9 --- /dev/null +++ b/framework/domain/accountscontroller.cpp | |||
@@ -0,0 +1,54 @@ | |||
1 | /* | ||
2 | Copyright (c) 2016 Michael Bohlender <michael.bohlender@kdemail.net> | ||
3 | |||
4 | This library is free software; you can redistribute it and/or modify it | ||
5 | under the terms of the GNU Library General Public License as published by | ||
6 | the Free Software Foundation; either version 2 of the License, or (at your | ||
7 | option) any later version. | ||
8 | |||
9 | This library is distributed in the hope that it will be useful, but WITHOUT | ||
10 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
11 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public | ||
12 | License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU Library General Public License | ||
15 | along with this library; see the file COPYING.LIB. If not, write to the | ||
16 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | ||
17 | 02110-1301, USA. | ||
18 | */ | ||
19 | |||
20 | |||
21 | #include "accountscontroller.h" | ||
22 | |||
23 | #include <settings/settings.h> | ||
24 | |||
25 | #include <QVariant> | ||
26 | #include <QUuid> | ||
27 | #include <QDebug> | ||
28 | |||
29 | AccountsController::AccountsController(QObject *parent) : QObject(parent) | ||
30 | { | ||
31 | Kube::Settings settings("accounts"); | ||
32 | mAccounts = settings.property("accounts").toStringList(); | ||
33 | qWarning() << "Loaded accounts" << mAccounts; | ||
34 | } | ||
35 | |||
36 | void AccountsController::createAccount(const QString &accountType) | ||
37 | { | ||
38 | auto identifier = QUuid::createUuid().toByteArray(); | ||
39 | Kube::Account accountSettings(identifier); | ||
40 | accountSettings.setProperty("type", accountType); | ||
41 | accountSettings.save(); | ||
42 | |||
43 | Kube::Settings settings("accounts"); | ||
44 | auto accounts = settings.property("accounts").toStringList(); | ||
45 | accounts.append(identifier); | ||
46 | settings.setProperty("accounts", accounts); | ||
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 | } | ||