diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-02-22 14:19:43 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-02-22 15:57:44 +0100 |
commit | cb2b1a35e14031f15155243aee12fc862cb65ebf (patch) | |
tree | cc6a28ef675953d41b9eeb98b21325d9a7b030b4 /framework/domain/settings/accountsettings.cpp | |
parent | b08e78c52a0b6a3c725ce58e0c3fb0bfcdf2bc55 (diff) | |
download | kube-cb2b1a35e14031f15155243aee12fc862cb65ebf.tar.gz kube-cb2b1a35e14031f15155243aee12fc862cb65ebf.zip |
Fixed kolabnow account setup page.
The account plugin supplies the configuration UI, the application
supplies the scaffolding. That way we ensure the application doens't
contain any account specific code and account configurations are free to
offer specialized UI's that work best for them.
We're not currently using a standardized controller, but if we did those
controllers would have to live with the plugin, not the framework or the
components.
Diffstat (limited to 'framework/domain/settings/accountsettings.cpp')
-rw-r--r-- | framework/domain/settings/accountsettings.cpp | 48 |
1 files changed, 36 insertions, 12 deletions
diff --git a/framework/domain/settings/accountsettings.cpp b/framework/domain/settings/accountsettings.cpp index d7c8c1c0..16791a7f 100644 --- a/framework/domain/settings/accountsettings.cpp +++ b/framework/domain/settings/accountsettings.cpp | |||
@@ -34,6 +34,15 @@ AccountSettings::AccountSettings(QObject *parent) | |||
34 | { | 34 | { |
35 | } | 35 | } |
36 | 36 | ||
37 | void AccountSettings::setAccountType(const QByteArray &type) | ||
38 | { | ||
39 | mAccountType = type; | ||
40 | } | ||
41 | |||
42 | QByteArray AccountSettings::accountType() const | ||
43 | { | ||
44 | return mAccountType; | ||
45 | } | ||
37 | 46 | ||
38 | void AccountSettings::setAccountIdentifier(const QByteArray &id) | 47 | void AccountSettings::setAccountIdentifier(const QByteArray &id) |
39 | { | 48 | { |
@@ -134,18 +143,32 @@ QValidator *AccountSettings::smtpServerValidator() const | |||
134 | 143 | ||
135 | void AccountSettings::saveAccount() | 144 | void AccountSettings::saveAccount() |
136 | { | 145 | { |
137 | qDebug() << "Saving account " << mAccountIdentifier << mMailtransportIdentifier; | 146 | if (mAccountIdentifier.isEmpty()) { |
138 | Q_ASSERT(!mAccountIdentifier.isEmpty()); | 147 | auto account = ApplicationDomainType::createEntity<SinkAccount>(); |
139 | SinkAccount account(mAccountIdentifier); | 148 | mAccountIdentifier = account.identifier(); |
140 | account.setAccountType("imap"); | 149 | Q_ASSERT(!mAccountType.isEmpty()); |
141 | account.setName(mName); | 150 | account.setAccountType(mAccountType); |
142 | account.setIcon(mIcon); | 151 | account.setName(mName); |
143 | Q_ASSERT(!account.identifier().isEmpty()); | 152 | account.setIcon(mIcon); |
144 | Store::modify(account) | 153 | Store::create(account) |
145 | .onError([](const KAsync::Error &error) { | 154 | .onError([](const KAsync::Error &error) { |
146 | qWarning() << "Error while creating account: " << error.errorMessage;; | 155 | qWarning() << "Error while creating account: " << error.errorMessage;; |
147 | }) | 156 | }) |
148 | .exec(); | 157 | .exec(); |
158 | } else { | ||
159 | qDebug() << "Saving account " << mAccountIdentifier << mMailtransportIdentifier; | ||
160 | Q_ASSERT(!mAccountIdentifier.isEmpty()); | ||
161 | SinkAccount account(mAccountIdentifier); | ||
162 | account.setAccountType(mAccountType); | ||
163 | account.setName(mName); | ||
164 | account.setIcon(mIcon); | ||
165 | Q_ASSERT(!account.identifier().isEmpty()); | ||
166 | Store::modify(account) | ||
167 | .onError([](const KAsync::Error &error) { | ||
168 | qWarning() << "Error while creating account: " << error.errorMessage;; | ||
169 | }) | ||
170 | .exec(); | ||
171 | } | ||
149 | } | 172 | } |
150 | 173 | ||
151 | void AccountSettings::loadAccount() | 174 | void AccountSettings::loadAccount() |
@@ -153,6 +176,7 @@ void AccountSettings::loadAccount() | |||
153 | Q_ASSERT(!mAccountIdentifier.isEmpty()); | 176 | Q_ASSERT(!mAccountIdentifier.isEmpty()); |
154 | Store::fetchOne<SinkAccount>(Query().filter(mAccountIdentifier)) | 177 | Store::fetchOne<SinkAccount>(Query().filter(mAccountIdentifier)) |
155 | .then([this](const SinkAccount &account) { | 178 | .then([this](const SinkAccount &account) { |
179 | mAccountType = account.getAccountType().toLatin1(); | ||
156 | mIcon = account.getIcon(); | 180 | mIcon = account.getIcon(); |
157 | mName = account.getName(); | 181 | mName = account.getName(); |
158 | emit changed(); | 182 | emit changed(); |