From cb2b1a35e14031f15155243aee12fc862cb65ebf Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Wed, 22 Feb 2017 14:19:43 +0100 Subject: 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. --- framework/domain/settings/accountsettings.cpp | 48 ++++++++++++++++++++------- 1 file changed, 36 insertions(+), 12 deletions(-) (limited to 'framework/domain/settings/accountsettings.cpp') 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) { } +void AccountSettings::setAccountType(const QByteArray &type) +{ + mAccountType = type; +} + +QByteArray AccountSettings::accountType() const +{ + return mAccountType; +} void AccountSettings::setAccountIdentifier(const QByteArray &id) { @@ -134,18 +143,32 @@ QValidator *AccountSettings::smtpServerValidator() const void AccountSettings::saveAccount() { - qDebug() << "Saving account " << mAccountIdentifier << mMailtransportIdentifier; - Q_ASSERT(!mAccountIdentifier.isEmpty()); - SinkAccount account(mAccountIdentifier); - account.setAccountType("imap"); - account.setName(mName); - account.setIcon(mIcon); - Q_ASSERT(!account.identifier().isEmpty()); - Store::modify(account) - .onError([](const KAsync::Error &error) { - qWarning() << "Error while creating account: " << error.errorMessage;; - }) - .exec(); + if (mAccountIdentifier.isEmpty()) { + auto account = ApplicationDomainType::createEntity(); + mAccountIdentifier = account.identifier(); + Q_ASSERT(!mAccountType.isEmpty()); + account.setAccountType(mAccountType); + account.setName(mName); + account.setIcon(mIcon); + Store::create(account) + .onError([](const KAsync::Error &error) { + qWarning() << "Error while creating account: " << error.errorMessage;; + }) + .exec(); + } else { + qDebug() << "Saving account " << mAccountIdentifier << mMailtransportIdentifier; + Q_ASSERT(!mAccountIdentifier.isEmpty()); + SinkAccount account(mAccountIdentifier); + account.setAccountType(mAccountType); + account.setName(mName); + account.setIcon(mIcon); + Q_ASSERT(!account.identifier().isEmpty()); + Store::modify(account) + .onError([](const KAsync::Error &error) { + qWarning() << "Error while creating account: " << error.errorMessage;; + }) + .exec(); + } } void AccountSettings::loadAccount() @@ -153,6 +176,7 @@ void AccountSettings::loadAccount() Q_ASSERT(!mAccountIdentifier.isEmpty()); Store::fetchOne(Query().filter(mAccountIdentifier)) .then([this](const SinkAccount &account) { + mAccountType = account.getAccountType().toLatin1(); mIcon = account.getIcon(); mName = account.getName(); emit changed(); -- cgit v1.2.3