File indexing completed on 2025-02-02 05:08:35

0001 /*
0002     SPDX-FileCopyrightText: 2010-2024 Laurent Montel <montel@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 #include "libaccountwizard_export.h"
0009 #include <QObject>
0010 #include <gpgme++/global.h>
0011 
0012 namespace KIdentityManagementCore
0013 {
0014 class Identity;
0015 }
0016 
0017 namespace MailTransport
0018 {
0019 class Transport;
0020 }
0021 
0022 /// QObject-wrapper around a KIdentityManagement
0023 ///
0024 /// Allow to configure an account
0025 class LIBACCOUNTWIZARD_EXPORT IdentityBase : public QObject
0026 {
0027     Q_OBJECT
0028 
0029     /// This property holds the identity name
0030     Q_PROPERTY(QString identityName READ identityName WRITE setIdentityName NOTIFY identityNameChanged)
0031 
0032     /// This property holds the real name of the user.
0033     Q_PROPERTY(QString fullName READ fullName WRITE setFullName NOTIFY fullNameChanged)
0034 
0035     /// This property holds the email of the user.
0036     Q_PROPERTY(QString email READ email WRITE setEmail NOTIFY emailChanged)
0037 
0038     /// This property holds the organization of the user.
0039     Q_PROPERTY(QString organization READ organization WRITE setOrganization NOTIFY organizationChanged)
0040 
0041     /// This property holds the signature of the user.
0042     Q_PROPERTY(QString signature READ signature WRITE setSignature NOTIFY signatureChanged)
0043 
0044 public:
0045     explicit IdentityBase(QObject *parent = nullptr);
0046 
0047     void create();
0048     void destroy();
0049 
0050     [[nodiscard]] QString identityName() const;
0051     void setIdentityName(const QString &name);
0052 
0053     [[nodiscard]] QString fullName() const;
0054     void setFullName(const QString &name);
0055 
0056     [[nodiscard]] QString email() const;
0057     void setEmail(const QString &email);
0058 
0059     [[nodiscard]] QString organization() const;
0060     void setOrganization(const QString &org);
0061 
0062     [[nodiscard]] QString signature() const;
0063     void setSignature(const QString &sig);
0064 
0065     [[nodiscard]] uint uoid() const;
0066     void setTransport(MailTransport::Transport *transport);
0067     void setPreferredCryptoMessageFormat(const QString &format);
0068     void setXFace(const QString &xface);
0069     void setPgpAutoSign(bool autosign);
0070     void setPgpAutoEncrypt(bool autoencrypt);
0071     void setKey(GpgME::Protocol protocol, const QByteArray &fingerprint);
0072 
0073 Q_SIGNALS:
0074     void info(const QString &message);
0075     void finished(const QString &message);
0076     void identityNameChanged();
0077     void fullNameChanged();
0078     void emailChanged();
0079     void organizationChanged();
0080     void signatureChanged();
0081 
0082 protected:
0083     virtual void createNewIdentity();
0084     QString mIdentityName;
0085     KIdentityManagementCore::Identity *mIdentity = nullptr;
0086 };