| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
#ifndef SETTINGSPOLICIES_H |
| 20 |
#define SETTINGSPOLICIES_H |
| 21 |
|
| 22 |
#include <QObject> |
| 23 |
#include <qmailaccount.h> |
| 24 |
#include <qmailstore.h> |
| 25 |
#include "SettingsObjectBase.h" |
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
class PolicyInterface |
| 35 |
{ |
| 36 |
public: |
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
virtual QString readPolicy(const QString &policy) = 0; |
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
virtual void setPolicy(const QString &policy, const QString &value) = 0; |
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
virtual void setDefaults() = 0; |
| 53 |
}; |
| 54 |
Q_DECLARE_INTERFACE(PolicyInterface, "PolicyInterface") |
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
class GlobalPolicy : public SettingsObjectBase, public PolicyInterface |
| 69 |
{ |
| 70 |
Q_OBJECT |
| 71 |
Q_INTERFACES(PolicyInterface) |
| 72 |
public: |
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
explicit GlobalPolicy(QObject *parent) : SettingsObjectBase(parent) {} |
| 78 |
|
| 79 |
|
| 80 |
public: |
| 81 |
virtual QString readPolicy(const QString &policy) override { |
| 82 |
return read(policy, QString()).toString(); |
| 83 |
} |
| 84 |
virtual void setPolicy(const QString &policy, const QString &value) override { |
| 85 |
write(policy, value); |
| 86 |
} |
| 87 |
virtual void setDefaults() override {} |
| 88 |
|
| 89 |
|
| 90 |
protected: |
| 91 |
virtual void createDefaultsIfNotExist() override {} |
| 92 |
}; |
| 93 |
|
| 94 |
class PrivacyPolicy : public GlobalPolicy |
| 95 |
{ |
| 96 |
Q_OBJECT |
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
Q_PROPERTY(bool allowRemoteContent READ allowRemoteContent WRITE setAllowRemoteContent NOTIFY policyChanged) |
| 102 |
public: |
| 103 |
explicit PrivacyPolicy(QObject *parent = 0); |
| 104 |
|
| 105 |
bool allowRemoteContent(); |
| 106 |
void setAllowRemoteContent(const bool allowed); |
| 107 |
|
| 108 |
|
| 109 |
public: |
| 110 |
virtual void setDefaults() override; |
| 111 |
|
| 112 |
signals: |
| 113 |
void policyChanged(); |
| 114 |
|
| 115 |
|
| 116 |
protected: |
| 117 |
virtual void createDefaultsIfNotExist() override; |
| 118 |
}; |
| 119 |
|
| 120 |
class ViewPolicy : public GlobalPolicy |
| 121 |
{ |
| 122 |
Q_OBJECT |
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
Q_PROPERTY(bool unifiedInboxExpanded READ unifiedInboxExpanded WRITE setUnifiedInboxExpanded NOTIFY policyChanged) |
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
|
| 132 |
Q_PROPERTY(bool favouritesExpanded READ favouritesExpanded WRITE setFavouritesExpanded NOTIFY policyChanged) |
| 133 |
Q_PROPERTY(bool favouritesVisible READ favouritesVisible WRITE setFavouritesVisible NOTIFY policyChanged) |
| 134 |
Q_PROPERTY(bool smartFoldersExpanded READ smartFoldersExpanded WRITE setSmartFoldersExpanded NOTIFY policyChanged) |
| 135 |
Q_PROPERTY(bool smartFoldersVisible READ smartFoldersVisible WRITE setSmartFoldersVisible NOTIFY policyChanged) |
| 136 |
Q_PROPERTY(bool accountsExpanded READ accountsExpanded WRITE setAccountsExpanded NOTIFY policyChanged) |
| 137 |
Q_PROPERTY(bool accountsVisible READ accountsVisible WRITE setAccountsVisible NOTIFY policyChanged) |
| 138 |
Q_PROPERTY(bool gravatarEnabled READ gravatarEnabled WRITE setGravatarEnabled NOTIFY policyChanged) |
| 139 |
Q_PROPERTY(bool hideMarkedDeleted READ hideMarkedDeleted WRITE setHideMarkedDeleted NOTIFY policyChanged) |
| 140 |
Q_PROPERTY(bool preferPlainText READ preferPlainText WRITE setPreferPlainText NOTIFY policyChanged) |
| 141 |
Q_PROPERTY(int previewLines READ previewLines WRITE setPreviewLines NOTIFY policyChanged) |
| 142 |
Q_PROPERTY(bool threadViewEnabled READ threadViewEnabled WRITE setThreadViewEnabled NOTIFY policyChanged) |
| 143 |
Q_PROPERTY(bool showToasts READ showToasts WRITE setShowToasts NOTIFY policyChanged) |
| 144 |
public: |
| 145 |
explicit ViewPolicy(QObject *parent = 0); |
| 146 |
|
| 147 |
bool unifiedInboxExpanded(); |
| 148 |
void setUnifiedInboxExpanded(const bool expanded); |
| 149 |
|
| 150 |
bool favouritesExpanded(); |
| 151 |
void setFavouritesExpanded(const bool expanded); |
| 152 |
|
| 153 |
bool favouritesVisible(); |
| 154 |
void setFavouritesVisible(const bool visible); |
| 155 |
|
| 156 |
bool smartFoldersExpanded(); |
| 157 |
void setSmartFoldersExpanded(const bool expanded); |
| 158 |
|
| 159 |
bool smartFoldersVisible(); |
| 160 |
void setSmartFoldersVisible(const bool visible); |
| 161 |
|
| 162 |
bool accountsExpanded(); |
| 163 |
void setAccountsExpanded(const bool expanded); |
| 164 |
|
| 165 |
bool accountsVisible(); |
| 166 |
void setAccountsVisible(const bool visible); |
| 167 |
|
| 168 |
bool gravatarEnabled(); |
| 169 |
void setGravatarEnabled(const bool enabled); |
| 170 |
|
| 171 |
bool hideMarkedDeleted(); |
| 172 |
void setHideMarkedDeleted(const bool hide); |
| 173 |
|
| 174 |
bool preferPlainText(); |
| 175 |
void setPreferPlainText(const bool prefer); |
| 176 |
|
| 177 |
int previewLines(); |
| 178 |
void setPreviewLines(const int &lines); |
| 179 |
|
| 180 |
bool threadViewEnabled(); |
| 181 |
void setThreadViewEnabled(const bool enabled); |
| 182 |
|
| 183 |
bool showToasts(); |
| 184 |
void setShowToasts(const bool show); |
| 185 |
signals: |
| 186 |
void policyChanged(); |
| 187 |
|
| 188 |
public: |
| 189 |
virtual void setDefaults() override; |
| 190 |
|
| 191 |
|
| 192 |
protected: |
| 193 |
virtual void createDefaultsIfNotExist() override { |
| 194 |
setDefaults(); |
| 195 |
} |
| 196 |
}; |
| 197 |
|
| 198 |
|
| 199 |
|
| 200 |
|
| 201 |
class AccountPolicy : public QObject, public PolicyInterface |
| 202 |
{ |
| 203 |
Q_OBJECT |
| 204 |
Q_INTERFACES(PolicyInterface) |
| 205 |
|
| 206 |
|
| 207 |
|
| 208 |
|
| 209 |
Q_PROPERTY(int accountId READ accountId WRITE setAccountId NOTIFY accountIdChanged) |
| 210 |
|
| 211 |
public: |
| 212 |
explicit AccountPolicy(QObject *parent = 0) : QObject(parent) {} |
| 213 |
AccountPolicy(QObject *parent, const QMailAccountId &id): QObject(parent), m_accountId(id) {} |
| 214 |
AccountPolicy(QObject *parent, const int &id): QObject(parent), m_accountId(QMailAccountId(id)) {} |
| 215 |
|
| 216 |
int accountId() const; |
| 217 |
void setAccountId(const int &id); |
| 218 |
void setAccountId(const QMailAccountId &id); |
| 219 |
|
| 220 |
Q_INVOKABLE virtual void setPolicy(const QString &policy, const QString &value) override; |
| 221 |
Q_INVOKABLE virtual QString readPolicy(const QString &policy) override; |
| 222 |
virtual void setDefaults() {} |
| 223 |
|
| 224 |
signals: |
| 225 |
void accountIdChanged(); |
| 226 |
void accountUpdated(); |
| 227 |
|
| 228 |
protected: |
| 229 |
bool idValid() { return QMailAccountId(m_accountId).isValid(); } |
| 230 |
|
| 231 |
private: |
| 232 |
QMailAccountId m_accountId; |
| 233 |
}; |
| 234 |
|
| 235 |
|
| 236 |
|
| 237 |
|
| 238 |
class MailPolicy : public AccountPolicy |
| 239 |
{ |
| 240 |
Q_OBJECT |
| 241 |
|
| 242 |
|
| 243 |
|
| 244 |
|
| 245 |
Q_PROPERTY(int markAsReadInterval READ markInterval WRITE setMarkInterval NOTIFY policyChanged) |
| 246 |
|
| 247 |
|
| 248 |
|
| 249 |
|
| 250 |
Q_PROPERTY(MarkReadMode markRead READ markRead WRITE setMarkRead NOTIFY policyChanged) |
| 251 |
Q_PROPERTY(QString ccIncludes READ ccIncludes WRITE setCCIncludes NOTIFY policyChanged) |
| 252 |
Q_PROPERTY(QString bccIncludes READ bccIncludes WRITE setBCCIncludes NOTIFY policyChanged) |
| 253 |
Q_ENUMS(MarkReadMode) |
| 254 |
|
| 255 |
public: |
| 256 |
explicit MailPolicy(QObject *parent = 0); |
| 257 |
MailPolicy(QObject *parent, const int &id); |
| 258 |
MailPolicy(QObject *parent, const QMailAccountId &id); |
| 259 |
|
| 260 |
|
| 261 |
|
| 262 |
|
| 263 |
|
| 264 |
|
| 265 |
|
| 266 |
|
| 267 |
enum MarkReadMode { |
| 268 |
Never, |
| 269 |
AfterInterval, |
| 270 |
Immediately |
| 271 |
}; |
| 272 |
|
| 273 |
|
| 274 |
int markInterval(); |
| 275 |
|
| 276 |
void setMarkInterval(const int &interval); |
| 277 |
|
| 278 |
MarkReadMode markRead(); |
| 279 |
|
| 280 |
void setMarkRead(const MarkReadMode mode); |
| 281 |
|
| 282 |
QString ccIncludes(); |
| 283 |
void setCCIncludes(const QString &includes); |
| 284 |
QString bccIncludes(); |
| 285 |
void setBCCIncludes(const QString &includes); |
| 286 |
|
| 287 |
virtual void setDefaults() override; |
| 288 |
|
| 289 |
signals: |
| 290 |
void policyChanged(); |
| 291 |
|
| 292 |
}; |
| 293 |
|
| 294 |
#endif |