MailTransport

transport.h
1/*
2 SPDX-FileCopyrightText: 2006-2007 Volker Krause <vkrause@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#pragma once
8
9#include "mailtransport_export.h"
10#include "transportbase.h"
11#include "transporttype.h"
12
13#include <memory>
14
15class TransportPrivate;
16namespace QKeychain
17{
18class Job;
19}
20namespace MailTransport
21{
22class TransportType;
23
24/**
25 Represents the settings of a specific mail transport.
26
27 To create a new empty Transport object, use TransportManager::createTransport().
28
29 Initialize an empty Transport object by calling the set...() methods defined in
30 kcfg-generated TransportBase, and in this class.
31*/
32class MAILTRANSPORT_EXPORT Transport : public TransportBase
33{
34 Q_OBJECT
35
36 Q_PROPERTY(QString password READ password WRITE setPassword NOTIFY passwordChanged)
37 Q_PROPERTY(TransportType transportType READ transportType NOTIFY transportTypeChanged)
38
39 friend class TransportManager;
40 friend class TransportManagerPrivate;
41
42public:
43 /**
44 Destructor
45 */
46 ~Transport() override;
47
49 using Id = int;
50
51 /**
52 Returns true if this transport is valid, ie. has all necessary data set.
53 */
54 [[nodiscard]] Q_INVOKABLE bool isValid() const;
55
56 /**
57 Returns the password of this transport.
58 */
59 [[nodiscard]] QString password() const;
60
61 /**
62 Sets the password of this transport.
63 @param passwd The new password.
64 */
65 void setPassword(const QString &passwd);
66
67 /**
68 Makes sure the transport has a unique name. Adds #1, #2, #3 etc. if
69 necessary.
70 @since 4.4
71 */
72 void forceUniqueName();
73
74 /**
75 This function synchronizes the password of this transport with the
76 password of the transport with the same ID that is managed by the
77 transport manager. This is only useful for cloned transports, since
78 their passwords don't automatically get updated when calling
79 TransportManager::loadPasswordsAsync() or TransportManager::loadPasswords().
80
81 @sa clone()
82 @since 4.2
83 */
84 void updatePasswordState();
85
86 /**
87 Returns true if all settings have been loaded.
88 This is the way to find out if the password has already been loaded
89 from the wallet.
90 */
91 [[nodiscard]] bool isComplete() const;
92
93 /**
94 Returns a string representation of the authentication type.
95 */
96 [[nodiscard]] QString authenticationTypeString() const;
97
98 /**
99 Returns a string representation of the authentication type.
100 Convenience function when there isn't a Transport object
101 instantiated.
102
103 @since 4.5
104 */
105 [[nodiscard]] static QString authenticationTypeString(int type);
106
107 /**
108 Returns a deep copy of this Transport object which will no longer be
109 automatically updated. Use this if you need to store a Transport object
110 over a longer time. However it is recommended to store transport identifiers
111 instead if possible.
112
113 @sa updatePasswordState()
114 */
115 Transport *clone() const;
116
117 /**
118 Returns the type of this transport.
119 @see TransportType.
120 @since 4.4
121 */
122 [[nodiscard]] TransportType transportType() const;
123
124protected:
125 /**
126 Creates a Transport object. Should only be used by TransportManager.
127 @param cfgGroup The KConfig group to read its data from.
128 */
129 explicit Transport(const QString &cfgGroup);
130
131 void usrRead() override;
132 bool usrSave() override;
133
134 /**
135 Returns true if the password was not stored in the wallet.
136 */
137 [[nodiscard]] bool needsWalletMigration() const;
138
139 /**
140 Try to migrate the password from the config file to the wallet.
141 */
142 void migrateToWallet();
143
144private Q_SLOTS:
145
146 // Used by our friend, TransportManager
147 void readPassword();
148
149Q_SIGNALS:
150 /**
151 Emitted when passwords have been loaded from QKeyChain.
152 */
154 /**
155 * Emitted when the password is changed
156 */
158 /**
159 * Emitted when the transport type is changed
160 */
162
163private:
164 void readTransportPasswordFinished(QKeychain::Job *baseJob);
165 void loadPassword();
166
167private:
168 std::unique_ptr<TransportPrivate> const d;
169};
170} // namespace MailTransport
Central transport management interface.
A representation of a transport type.
Represents the settings of a specific mail transport.
Definition transport.h:33
void passwordLoaded()
Emitted when passwords have been loaded from QKeyChain.
void passwordChanged()
Emitted when the password is changed.
void transportTypeChanged()
Emitted when the transport type is changed.
~Transport() override
Destructor.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 22 2024 12:07:33 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.