File indexing completed on 2025-03-09 04:54:32
0001 /* SPDX-FileCopyrightText: 2012-2024 Laurent Montel <montel@kde.org> 0002 * 0003 * SPDX-License-Identifier: LGPL-2.0-or-later 0004 */ 0005 0006 #pragma once 0007 0008 #include "interfaces/bodypart.h" 0009 #include "messageviewer/viewer.h" 0010 0011 #include <KContacts/Addressee> 0012 #include <KContacts/Picture> 0013 0014 #include <QObject> 0015 #include <QPointer> 0016 0017 class KJob; 0018 namespace Gravatar 0019 { 0020 class GravatarResolvUrlJob; 0021 } 0022 0023 namespace Akonadi 0024 { 0025 class ContactSearchJob; 0026 } 0027 namespace MessageViewer 0028 { 0029 class ContactDisplayMessageMemento : public QObject, public MimeTreeParser::Interface::BodyPartMemento 0030 { 0031 Q_OBJECT 0032 public: 0033 explicit ContactDisplayMessageMemento(const QString &emailAddress); 0034 ~ContactDisplayMessageMemento() override; 0035 void processAddress(const KContacts::Addressee &addressee); 0036 [[nodiscard]] KContacts::Picture photo() const; 0037 0038 [[nodiscard]] bool finished() const; 0039 0040 void detach() override; 0041 0042 [[nodiscard]] QPixmap gravatarPixmap() const; 0043 0044 [[nodiscard]] QImage imageFromUrl() const; 0045 0046 Q_SIGNALS: 0047 // TODO: Factor our update and detach into base class 0048 void update(MimeTreeParser::UpdateMode); 0049 void changeDisplayMail(Viewer::DisplayFormatMessage displayAsHtml, bool remoteContent); 0050 0051 private Q_SLOTS: 0052 void slotSearchJobFinished(KJob *job); 0053 0054 void slotGravatarResolvUrlFinished(Gravatar::GravatarResolvUrlJob *); 0055 0056 private: 0057 [[nodiscard]] bool searchPhoto(const KContacts::AddresseeList &list); 0058 KContacts::Picture mPhoto; 0059 QPixmap mGravatarPixmap; 0060 QImage mImageFromUrl; 0061 const QString mEmailAddress; 0062 bool mFinished = false; 0063 QPointer<Akonadi::ContactSearchJob> mSearchJob; 0064 }; 0065 }