Messagelib

contactpreference.cpp
1 /*
2  SPDX-FileCopyrightText: 2022 Sandro KnauƟ <[email protected]>
3 
4  SPDX-License-Identifier: GPL-2.0-or-later
5 */
6 
7 #include "contactpreference.h"
8 
9 #include <KContacts/Addressee>
10 
11 using namespace MessageComposer;
12 
13 ContactPreference::ContactPreference() = default;
14 
15 void ContactPreference::fillFromAddressee(const KContacts::Addressee &contact)
16 {
17  const QString encryptPref = contact.custom(QStringLiteral("KADDRESSBOOK"), QStringLiteral("CRYPTOENCRYPTPREF"));
18  encryptionPreference = Kleo::stringToEncryptionPreference(encryptPref);
19  const QString signPref = contact.custom(QStringLiteral("KADDRESSBOOK"), QStringLiteral("CRYPTOSIGNPREF"));
20  signingPreference = Kleo::stringToSigningPreference(signPref);
21  const QString cryptoFormats = contact.custom(QStringLiteral("KADDRESSBOOK"), QStringLiteral("CRYPTOPROTOPREF"));
22  cryptoMessageFormat = Kleo::stringToCryptoMessageFormat(cryptoFormats);
23  pgpKeyFingerprints = contact.custom(QStringLiteral("KADDRESSBOOK"), QStringLiteral("OPENPGPFP")).split(QLatin1Char(','), Qt::SkipEmptyParts);
24  smimeCertFingerprints = contact.custom(QStringLiteral("KADDRESSBOOK"), QStringLiteral("SMIMEFP")).split(QLatin1Char(','), Qt::SkipEmptyParts);
25 }
26 
27 void ContactPreference::fillAddressee(KContacts::Addressee &contact) const
28 {
29  contact.insertCustom(QStringLiteral("KADDRESSBOOK"),
30  QStringLiteral("CRYPTOENCRYPTPREF"),
31  QLatin1String(Kleo::encryptionPreferenceToString(encryptionPreference)));
32  contact.insertCustom(QStringLiteral("KADDRESSBOOK"), QStringLiteral("CRYPTOSIGNPREF"), QLatin1String(Kleo::signingPreferenceToString(signingPreference)));
33  contact.insertCustom(QStringLiteral("KADDRESSBOOK"), QStringLiteral("CRYPTOPROTOPREF"), QLatin1String(cryptoMessageFormatToString(cryptoMessageFormat)));
34  contact.insertCustom(QStringLiteral("KADDRESSBOOK"), QStringLiteral("OPENPGPFP"), pgpKeyFingerprints.join(QLatin1Char(',')));
35  contact.insertCustom(QStringLiteral("KADDRESSBOOK"), QStringLiteral("SMIMEFP"), smimeCertFingerprints.join(QLatin1Char(',')));
36 }
Simple interface that both EncryptJob and SignEncryptJob implement so the composer can extract some e...
QString custom(const QString &app, const QString &name) const
QStringList split(const QString &sep, QString::SplitBehavior behavior, Qt::CaseSensitivity cs) const const
SkipEmptyParts
void insertCustom(const QString &app, const QString &name, const QString &value)
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sat Apr 1 2023 04:01:56 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.