From d0716c36927275fbfe0a0a9ab8e1726cbddb35c0 Mon Sep 17 00:00:00 2001 From: Michael Bohlender Date: Thu, 5 Jan 2017 17:46:56 +0100 Subject: add remove, modify and load to maildircontroller --- framework/accounts/maildircontroller.cpp | 59 ++++++++++++++++++++++---------- framework/accounts/maildircontroller.h | 7 ++++ 2 files changed, 48 insertions(+), 18 deletions(-) (limited to 'framework/accounts') diff --git a/framework/accounts/maildircontroller.cpp b/framework/accounts/maildircontroller.cpp index daafccb6..481d43d8 100644 --- a/framework/accounts/maildircontroller.cpp +++ b/framework/accounts/maildircontroller.cpp @@ -1,20 +1,20 @@ /* - Copyright (C) 2017 Michael Bohlender, - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ + * Copyright (C) 2017 Michael Bohlender, + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ #include "maildircontroller.h" @@ -44,12 +44,35 @@ void MaildirController::create() { resource.setProperty("path", getPath().path()); Store::create(resource).exec().waitForFinished(); - - clear(); } void MaildirController::modify() { + SinkResource resource(m_resourceId); + resource.setProperty("path", getPath().path()); + Store::modify(resource).exec(); } void MaildirController::remove() { + SinkAccount account(m_accountId); + Store::remove(account).exec(); + + clear(); +} + +void MaildirController::load(const QByteArray &id) { + + m_accountId = id; + clear(); + + Store::fetchOne(Query().filter(m_accountId)) + .syncThen([this](const SinkAccount &account) { + setIcon(account.getIcon()); + setName(account.getName()); + }).exec(); + + Store::fetchOne(Query().filter(m_accountId).containsFilter(ResourceCapabilities::Mail::storage)) + .syncThen([this](const SinkResource &resource) { + m_resourceId = resource.identifier(); + setPath(resource.getProperty("path").toString()); + }).exec(); } diff --git a/framework/accounts/maildircontroller.h b/framework/accounts/maildircontroller.h index da2a3a62..5965f118 100644 --- a/framework/accounts/maildircontroller.h +++ b/framework/accounts/maildircontroller.h @@ -41,4 +41,11 @@ class MaildirController : public Kube::Controller public: explicit MaildirController(); + +public slots: + void load(const QByteArray &id); + +private: + QByteArray m_accountId; + QByteArray m_resourceId; }; -- cgit v1.2.3