File indexing completed on 2024-11-24 04:39:33

0001 /*
0002   SPDX-FileCopyrightText: 2010 Tobias Koenig <tokoe@kde.org>
0003 
0004   SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include "akonadi-contact-widgets_export.h"
0010 #include <Akonadi/Item>
0011 #include <KJob>
0012 
0013 #include <memory>
0014 
0015 namespace Akonadi
0016 {
0017 class Item;
0018 class AddEmailAddressJobPrivate;
0019 
0020 /**
0021  * @short A job to add a new contact with a given email address to Akonadi.
0022  *
0023  * The job will check whether a contact with the given email address already
0024  * exists in Akonadi and inform the user about it, if it does not exist yet,
0025  * a new contact is added.
0026  */
0027 class AKONADI_CONTACT_WIDGETS_EXPORT AddEmailAddressJob : public KJob
0028 {
0029     Q_OBJECT
0030 
0031 public:
0032     /**
0033      * Creates a new add email address job.
0034      *
0035      * @param email The email address.
0036      * @param parentWidget The widget that will be used as parent for dialog.
0037      * @param parent The parent object.
0038      */
0039     explicit AddEmailAddressJob(const QString &email, QWidget *parentWidget, QObject *parent = nullptr);
0040 
0041     /**
0042      * Destroys the add email address job.
0043      */
0044     ~AddEmailAddressJob() override;
0045 
0046     /**
0047      * Starts the job.
0048      */
0049     void start() override;
0050 
0051     /**
0052      * Returns the item that represents the new contact.
0053      */
0054     [[nodiscard]] Akonadi::Item contact() const;
0055 
0056     void setInteractive(bool b);
0057 Q_SIGNALS:
0058     void successMessage(const QString &message);
0059 
0060 private:
0061     //@cond PRIVATE
0062     friend class AddEmailAddressJobPrivate;
0063     std::unique_ptr<AddEmailAddressJobPrivate> const d;
0064     //@endcond
0065 };
0066 }