File indexing completed on 2025-01-05 04:54:57
0001 /* 0002 Copyright (c) 2016 Christian Mollekopf <mollekopf@kolabsys.com> 0003 0004 This library is free software; you can redistribute it and/or modify it 0005 under the terms of the GNU Library General Public License as published by 0006 the Free Software Foundation; either version 2 of the License, or (at your 0007 option) any later version. 0008 0009 This library is distributed in the hope that it will be useful, but WITHOUT 0010 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0011 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 0012 License for more details. 0013 0014 You should have received a copy of the GNU Library General Public License 0015 along with this library; see the file COPYING.LIB. If not, write to the 0016 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 0017 02110-1301, USA. 0018 */ 0019 #pragma once 0020 0021 #include "kube_export.h" 0022 #include <QObject> 0023 #include <QValidator> 0024 0025 class KUBE_EXPORT AccountSettings : public QObject 0026 { 0027 Q_OBJECT 0028 Q_PROPERTY(QByteArray accountType READ accountType WRITE setAccountType) 0029 Q_PROPERTY(QByteArray accountIdentifier READ accountIdentifier WRITE setAccountIdentifier NOTIFY changed) 0030 Q_PROPERTY(QString icon MEMBER mIcon NOTIFY changed) 0031 Q_PROPERTY(QString accountName MEMBER mName NOTIFY changed) 0032 0033 Q_PROPERTY(QString userName MEMBER mUsername NOTIFY identityChanged) 0034 Q_PROPERTY(QString emailAddress MEMBER mEmailAddress NOTIFY identityChanged) 0035 0036 Q_PROPERTY(QString imapServer MEMBER mImapServer NOTIFY imapResourceChanged) 0037 Q_PROPERTY(QValidator* imapServerValidator READ imapServerValidator CONSTANT) 0038 Q_PROPERTY(QString imapUsername MEMBER mImapUsername NOTIFY imapResourceChanged) 0039 Q_PROPERTY(bool imapStarttls MEMBER mImapStarttls NOTIFY imapResourceChanged) 0040 Q_PROPERTY(QString imapAuthenticationMode MEMBER mImapAuthenticationMode NOTIFY imapResourceChanged) 0041 0042 Q_PROPERTY(QString smtpServer MEMBER mSmtpServer NOTIFY smtpResourceChanged) 0043 Q_PROPERTY(QValidator* smtpServerValidator READ smtpServerValidator CONSTANT) 0044 Q_PROPERTY(QString smtpUsername MEMBER mSmtpUsername NOTIFY smtpResourceChanged) 0045 0046 Q_PROPERTY(QString carddavServer MEMBER mCardDavServer NOTIFY cardDavResourceChanged) 0047 Q_PROPERTY(QString carddavUsername MEMBER mCardDavUsername NOTIFY cardDavResourceChanged) 0048 0049 Q_PROPERTY(QString caldavServer MEMBER mCalDavServer NOTIFY calDavResourceChanged) 0050 Q_PROPERTY(QString caldavUsername MEMBER mCalDavUsername NOTIFY calDavResourceChanged) 0051 0052 Q_PROPERTY(QUrl path READ path WRITE setPath NOTIFY pathChanged) 0053 Q_PROPERTY(QValidator* pathValidator READ pathValidator CONSTANT) 0054 0055 public: 0056 AccountSettings(QObject *parent = 0); 0057 0058 void setAccountIdentifier(const QByteArray &); 0059 QByteArray accountIdentifier() const; 0060 0061 void setAccountType(const QByteArray &); 0062 QByteArray accountType() const; 0063 0064 void setPath(const QUrl &); 0065 QUrl path() const; 0066 0067 virtual QValidator *imapServerValidator() const; 0068 virtual QValidator *smtpServerValidator() const; 0069 virtual QValidator *pathValidator() const; 0070 0071 Q_INVOKABLE virtual void load(); 0072 Q_INVOKABLE virtual void save(); 0073 Q_INVOKABLE virtual void remove(); 0074 Q_INVOKABLE void login(const QVariantMap &secrets); 0075 0076 signals: 0077 void imapResourceChanged(); 0078 void smtpResourceChanged(); 0079 void identityChanged(); 0080 void pathChanged(); 0081 void changed(); 0082 void cardDavResourceChanged(); 0083 void calDavResourceChanged(); 0084 0085 protected: 0086 void saveAccount(); 0087 void saveImapResource(); 0088 void saveMaildirResource(); 0089 void saveMailtransportResource(); 0090 void saveIdentity(); 0091 void saveCardDavResource(); 0092 void saveCalDavResource(); 0093 0094 void loadAccount(); 0095 void loadImapResource(); 0096 void loadMaildirResource(); 0097 void loadMailtransportResource(); 0098 void loadIdentity(); 0099 void loadCardDavResource(); 0100 void loadCalDavResource(); 0101 0102 void removeAccount(); 0103 void removeResource(const QByteArray &identifier); 0104 0105 void removeIdentity(); 0106 0107 QByteArray mAccountIdentifier; 0108 QByteArray mAccountType; 0109 QString mIcon; 0110 QString mName; 0111 0112 QByteArray mImapIdentifier; 0113 QString mImapServer; 0114 QString mImapUsername; 0115 QString mImapAuthenticationMode; 0116 bool mImapStarttls; 0117 0118 QByteArray mMaildirIdentifier; 0119 QString mPath; 0120 0121 QByteArray mMailtransportIdentifier; 0122 QString mSmtpServer; 0123 QString mSmtpUsername; 0124 0125 QByteArray mIdentityIdentifier; 0126 QString mUsername; 0127 QString mEmailAddress; 0128 0129 QByteArray mCardDavIdentifier; 0130 QString mCardDavServer; 0131 QString mCardDavUsername; 0132 0133 QByteArray mCalDavIdentifier; 0134 QString mCalDavServer; 0135 QString mCalDavUsername; 0136 }; 0137