File indexing completed on 2024-06-23 05:15:12

0001 /*
0002     SPDX-FileCopyrightText: 2009 Constantin Berzan <exit3219@gmail.com>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include "mailtransport_export.h"
0010 #include "transport.h"
0011 
0012 #include <QString>
0013 
0014 namespace MailTransport
0015 {
0016 class AddTransportDialog;
0017 class TransportManager;
0018 class TransportTypePrivate;
0019 
0020 /**
0021   @short A representation of a transport type.
0022 
0023   Represents an available transport type.  SMTP is available
0024 
0025   All available transport types can be retrieved via TransportManager::types().
0026 
0027   @author Constantin Berzan <exit3219@gmail.com>
0028   @since 4.4
0029 */
0030 class MAILTRANSPORT_EXPORT TransportType
0031 {
0032     Q_GADGET
0033 
0034     /// This property holds whether the transport type is valid.
0035     Q_PROPERTY(bool isValid READ isValid CONSTANT)
0036 
0037     /// This property holds the i18n'ed name of the transport type.
0038     Q_PROPERTY(QString name READ name CONSTANT)
0039 
0040     /// This property holds the transport type.
0041     Q_PROPERTY(QString description READ description CONSTANT)
0042 
0043     /// This property holds the plugin identifier.
0044     Q_PROPERTY(QString identifier READ identifier CONSTANT)
0045 
0046     /// This property holds whether this transport is an akonadi resource.
0047     Q_PROPERTY(bool isAkonadiResource READ isAkonadiResource CONSTANT)
0048 
0049     friend class AddTransportDialog;
0050     friend class Transport;
0051     friend class TransportManager;
0052     friend class TransportManagerPrivate;
0053 
0054 public:
0055     /**
0056       Describes a list of transport types.
0057     */
0058     using List = QList<TransportType>;
0059 
0060     /**
0061       Constructs a new TransportType.
0062     */
0063     TransportType();
0064 
0065     /**
0066       Creates a copy of the @p other TransportType.
0067     */
0068     TransportType(const TransportType &other);
0069 
0070     /**
0071       Destroys the TransportType.
0072     */
0073     ~TransportType();
0074 
0075     /**
0076      * Replaces the transport type by the @p other.
0077      */
0078     TransportType &operator=(const TransportType &other);
0079 
0080     /**
0081      * Compares the transport type with the @p other.
0082      */
0083     [[nodiscard]] bool operator==(const TransportType &other) const;
0084 
0085     /**
0086       Returns whether the transport type is valid.
0087     */
0088     [[nodiscard]] bool isValid() const;
0089 
0090     /**
0091       Returns the i18n'ed name of the transport type.
0092     */
0093     [[nodiscard]] QString name() const;
0094 
0095     /**
0096       Returns a description of the transport type.
0097     */
0098     [[nodiscard]] QString description() const;
0099 
0100     /**
0101      * Returns a plugin identifier
0102      */
0103     [[nodiscard]] QString identifier() const;
0104 
0105     /// Returns whether this transport is an akonadi resource.
0106     [[nodiscard]] bool isAkonadiResource() const;
0107 
0108 private:
0109     //@cond PRIVATE
0110     QSharedDataPointer<TransportTypePrivate> d;
0111     //@endcond
0112 };
0113 } // namespace MailTransport
0114 
0115 Q_DECLARE_TYPEINFO(MailTransport::TransportType, Q_RELOCATABLE_TYPE);