summaryrefslogtreecommitdiffstats
path: root/framework/domain/accountfactory.cpp
diff options
context:
space:
mode:
authorMichael Bohlender <michael.bohlender@kdemail.net>2017-01-05 15:17:04 +0100
committerMichael Bohlender <michael.bohlender@kdemail.net>2017-01-05 15:17:04 +0100
commita2fda0ad4fc013e4f9dd7d68ce2ec5385c1717ce (patch)
tree3ca0df1d96c01baef1575b4d961365ed227531e1 /framework/domain/accountfactory.cpp
parentbc7879eca0d242934ec2051af93fd58b66845461 (diff)
downloadkube-a2fda0ad4fc013e4f9dd7d68ce2ec5385c1717ce.tar.gz
kube-a2fda0ad4fc013e4f9dd7d68ce2ec5385c1717ce.zip
move accounts related files to seperate folder
Diffstat (limited to 'framework/domain/accountfactory.cpp')
-rw-r--r--framework/domain/accountfactory.cpp65
1 files changed, 0 insertions, 65 deletions
diff --git a/framework/domain/accountfactory.cpp b/framework/domain/accountfactory.cpp
deleted file mode 100644
index 182a0a1d..00000000
--- a/framework/domain/accountfactory.cpp
+++ /dev/null
@@ -1,65 +0,0 @@
1/*
2 Copyright (c) 2016 Christian Mollekopf <mollekopf@kolabsystems.com>
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#include "accountfactory.h"
20
21#include <QDebug>
22
23#include <KPackage/PackageLoader>
24#include <KPackage/Package>
25#include <KPluginMetaData>
26
27#include "settings/settings.h"
28#include <sink/store.h>
29
30AccountFactory::AccountFactory(QObject *parent)
31 : QObject(parent)
32{
33}
34
35QString AccountFactory::name() const
36{
37 if (mName.isEmpty()) {
38 return tr("Account");
39 }
40 return mName;
41}
42
43void AccountFactory::setAccountId(const QString &accountId)
44{
45 mAccountId = accountId;
46 Sink::Store::fetchOne<Sink::ApplicationDomain::SinkAccount>(Sink::Query().filter(accountId.toUtf8()))
47 .syncThen<void, Sink::ApplicationDomain::SinkAccount>([this](const Sink::ApplicationDomain::SinkAccount &account) {
48 mAccountType = account.getProperty("type").toByteArray();
49 loadPackage();
50 }).exec();
51}
52
53void AccountFactory::loadPackage()
54{
55 auto package = KPackage::PackageLoader::self()->loadPackage("KPackage/GenericQML", "org.kube.accounts." + mAccountType);
56 if (!package.isValid()) {
57 qWarning() << "Failed to load account package: " << "org.kube.accounts." + mAccountType;
58 return;
59 }
60 Q_ASSERT(package.isValid());
61 mUiPath = package.filePath("mainscript");
62 mName = package.metadata().name();
63 mIcon = package.metadata().iconName();
64 emit accountLoaded();
65}