| 1 | /************************************************************************** |
| 2 | Copyright (C) 2016 Dan Chapman <[email protected]> |
| 3 | |
| 4 | This file is part of Dekko email client for Ubuntu devices |
| 5 | |
| 6 | This program is free software; you can redistribute it and/or |
| 7 | modify it under the terms of the GNU General Public License as |
| 8 | published by the Free Software Foundation; either version 2 of |
| 9 | the License or (at your option) version 3 |
| 10 | |
| 11 | This program is distributed in the hope that it will be useful, |
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | GNU General Public License for more details. |
| 15 | |
| 16 | You should have received a copy of the GNU General Public License |
| 17 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 18 | **************************************************************************/ |
| 19 | #ifndef POLICYMANAGER_H |
| 20 | #define POLICYMANAGER_H |
| 21 | |
| 22 | #include <QObject> |
| 23 | #include <QQmlEngine> |
| 24 | #include <QJSEngine> |
| 25 | #include <QPointer> |
| 26 | #include "SettingsPolicies.h" |
| 27 | /** |
| 28 | * @brief The PolicyManager class |
| 29 | */ |
| 30 | class PolicyManager : public QObject |
| 31 | { |
| 32 | Q_OBJECT |
| 33 | Q_PROPERTY(PrivacyPolicy *privacy READ privacyPolicy CONSTANT) |
| 34 | Q_PROPERTY(ViewPolicy *views READ viewPolicy CONSTANT) |
| 35 | public: |
| 36 | explicit PolicyManager(QObject *parent = 0); |
| 37 | |
| 38 | /** |
| 39 | * @brief Singleton accessor for the PolicyManager |
| 40 | * @return PolicyManager instance |
| 41 | */ |
| 42 | static PolicyManager *instance(); |
| 43 | /** |
| 44 | * @brief factory for accessiong singleton in QML |
| 45 | * @param engine |
| 46 | * @param scriptEngine |
| 47 | * @return PolicyManager instance |
| 48 | */ |
| 49 | static QObject *factory(QQmlEngine *engine, QJSEngine *scriptEngine); |
| 50 | |
| 51 | /** |
| 52 | * @brief Retrieve the MailPolicy for \param accountId |
| 53 | * @param QMailAccountId::toULongLong() |
| 54 | * @return MailPolicy |
| 55 | */ |
| 56 | Q_INVOKABLE MailPolicy *mailPolicy(const int &accountId); |
| 57 | /** |
| 58 | * @brief Retrieve the MailPolicy for \param accountId |
| 59 | * @param QMailAccountId |
| 60 | * @return MailPolicy |
| 61 | */ |
| 62 | MailPolicy *mailPolicy(const QMailAccountId &accountId); |
| 63 | |
| 64 | /** |
| 65 | * @brief Retrieve the PrivacyPolicy for this user |
| 66 | * @return PrivacyPolicy |
| 67 | */ |
| 68 | PrivacyPolicy *privacyPolicy(); |
| 69 | |
| 70 | /** |
| 71 | * @brief Retrieve the ViewPolicy for this user |
| 72 | * @return ViewPolicy |
| 73 | */ |
| 74 | ViewPolicy *viewPolicy(); |
| 75 | |
| 76 | /** |
| 77 | * @brief Set the default policies for \param accountId |
| 78 | * @param QMailAccountId::toULongLong() |
| 79 | */ |
| 80 | Q_INVOKABLE void setDefaultPolicies(const int &accountId); |
| 81 | /** |
| 82 | * @brief Set the default policies for \param accountId |
| 83 | * @param QMailAccountId |
| 84 | */ |
| 85 | void setDefaultPolicies(const QMailAccountId &accountId); |
| 86 | |
| 87 | Q_INVOKABLE bool idValid(const int &id); |
| 88 | |
| 89 | private: |
| 90 | QPointer<PrivacyPolicy> m_privacy; |
| 91 | QPointer<ViewPolicy> m_view; |
| 92 | }; |
| 93 | |
| 94 | #endif // POLICYMANAGER_H |