File indexing completed on 2024-05-12 05:25:41
0001 /* 0002 SPDX-FileCopyrightText: 2013-2024 Laurent Montel <montel@kde.org> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include "libsieveeditor_export.h" 0010 #include "libsieveeditor_private_export.h" 0011 #include <KSieveCore/SieveImapAccountSettings> 0012 #include <MailTransport/Transport> 0013 #include <QString> 0014 #include <QUrl> 0015 namespace SieveEditorUtil 0016 { 0017 struct LIBSIEVEEDITOR_EXPORT SieveAccountSettings { 0018 SieveAccountSettings() = default; 0019 0020 [[nodiscard]] bool operator==(const SieveAccountSettings &other) const; 0021 [[nodiscard]] bool isValid() const; 0022 QString serverName; 0023 QString userName; 0024 QString password; 0025 MailTransport::Transport::EnumAuthenticationType authenticationType = MailTransport::Transport::EnumAuthenticationType::PLAIN; 0026 int port = -1; 0027 }; 0028 0029 struct LIBSIEVEEDITOR_EXPORT SieveServerConfig { 0030 SieveServerConfig() = default; 0031 0032 [[nodiscard]] bool isValid() const; 0033 [[nodiscard]] QUrl url() const; 0034 SieveAccountSettings sieveSettings; 0035 KSieveCore::SieveImapAccountSettings sieveImapAccountSettings; 0036 bool operator==(const SieveServerConfig &other) const; 0037 bool enabled = true; 0038 bool useImapCustomServer = false; 0039 }; 0040 0041 void writeServerSieveConfig(const QList<SieveEditorUtil::SieveServerConfig> &lstConfig); 0042 void addServerSieveConfig(const SieveEditorUtil::SieveServerConfig &conf); 0043 void writeSieveSettings(const KSharedConfigPtr &cfg, const SieveEditorUtil::SieveServerConfig &conf, int index); 0044 [[nodiscard]] QString sievePasswordIdentifier(const QString &userName, const QString &serverName); 0045 [[nodiscard]] QString imapPasswordIdentifier(const QString &userName, const QString &serverName); 0046 [[nodiscard]] QString walletFolderName(); 0047 } 0048 Q_DECLARE_TYPEINFO(SieveEditorUtil::SieveServerConfig, Q_RELOCATABLE_TYPE); 0049 LIBSIEVEEDITOR_TESTS_EXPORT QDebug operator<<(QDebug d, const SieveEditorUtil::SieveAccountSettings &settings); 0050 LIBSIEVEEDITOR_TESTS_EXPORT QDebug operator<<(QDebug d, const SieveEditorUtil::SieveServerConfig &settings);