File indexing completed on 2024-06-16 05:01:22

0001 /* Copyright (C) 2006 - 2014 Jan Kundrát <jkt@flaska.net>
0002 
0003    This file is part of the Trojita Qt IMAP e-mail client,
0004    http://trojita.flaska.net/
0005 
0006    This program is free software; you can redistribute it and/or
0007    modify it under the terms of the GNU General Public License as
0008    published by the Free Software Foundation; either version 2 of
0009    the License or (at your option) version 3 or any later version
0010    accepted by the membership of KDE e.V. (or its successor approved
0011    by the membership of KDE e.V.), which shall act as a proxy
0012    defined in Section 14 of version 3 of the license.
0013 
0014    This program is distributed in the hope that it will be useful,
0015    but WITHOUT ANY WARRANTY; without even the implied warranty of
0016    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0017    GNU General Public License for more details.
0018 
0019    You should have received a copy of the GNU General Public License
0020    along with this program.  If not, see <http://www.gnu.org/licenses/>.
0021 */
0022 
0023 #ifndef COMPOSER_RECIPIENTS_H
0024 #define COMPOSER_RECIPIENTS_H
0025 
0026 #include "Imap/Parser/MailAddress.h"
0027 
0028 class QModelIndex;
0029 
0030 namespace Composer {
0031 
0032 typedef enum {
0033     REPLY_PRIVATE, /**< @short Reply to "sender(s)" only */
0034     REPLY_ALL, /**< @short Reply to all recipients */
0035     REPLY_ALL_BUT_ME, /**< @short Reply to all recipients excluding any of my own identities */
0036     REPLY_LIST /**< @short Reply to the mailing list */
0037 } ReplyMode;
0038 
0039 enum class ForwardMode {
0040     FORWARD_AS_ATTACHMENT, /**< @short Forward the message as an attachment */
0041 };
0042 
0043 /** @short Recipients */
0044 typedef enum {
0045     ADDRESS_TO,
0046     ADDRESS_CC,
0047     ADDRESS_BCC,
0048     ADDRESS_FROM,
0049     ADDRESS_SENDER,
0050     ADDRESS_REPLY_TO,
0051     ADDRESS_RESENT_TO,
0052     ADDRESS_RESENT_CC,
0053     ADDRESS_RESENT_BCC,
0054     ADDRESS_RESENT_FROM,
0055     ADDRESS_RESENT_SENDER
0056 } RecipientKind;
0057 
0058 typedef QList<QPair<RecipientKind, Imap::Message::MailAddress> > RecipientList;
0059 
0060 class SenderIdentitiesModel;
0061 
0062 namespace Util {
0063 
0064 bool replyRecipientList(const ReplyMode mode, const SenderIdentitiesModel *senderIdetitiesModel,
0065                         const RecipientList &originalRecipients,
0066                         const QList<QUrl> &headerListPost, const bool headerListPostNo,
0067                         RecipientList &output);
0068 
0069 bool replyRecipientList(const ReplyMode mode, const SenderIdentitiesModel *senderIdetitiesModel,
0070                         const QModelIndex &message, RecipientList &output);
0071 
0072 bool chooseSenderIdentity(const SenderIdentitiesModel *senderIdetitiesModel,
0073         const QList<Imap::Message::MailAddress> &addresses, int &row);
0074 
0075 bool chooseSenderIdentityForReply(const SenderIdentitiesModel *senderIdetitiesModel, const QModelIndex &message, int &row);
0076 
0077 QList<Imap::Message::MailAddress> extractEmailAddresses(const RecipientList &list);
0078 QList<Imap::Message::MailAddress> extractEmailAddresses(const SenderIdentitiesModel *senderIdetitiesModel);
0079 }
0080 
0081 }
0082 
0083 #endif // COMPOSER_RECIPIENTS_H