API Documentation
Documentation for developing SailfishOS applicationsEmailAccountProvisioner Class
(Sailfish::Mdm::Accounts::EmailAccountProvisioner)The EmailAccountProvisioner class allows clients to create email accounts. More...
Header: | #include <mdm-accounts.h> |
Inherits: | Provisioner |
Public Types
enum | Authentication { NoAuthentication, Login, Plain, CramMd5 } |
enum | ConnectionEncryption { NoEncryption, SSL, StartTLS } |
enum | IncomingProtocol { NoIncomingProtocol, Imap4, Pop3 } |
enum | OutgoingProtocol { NoOutgoingProtocol, Smtp } |
Properties
|
|
- 9 properties inherited from Sailfish::Mdm::Accounts::Provisioner
Public Functions
EmailAccountProvisioner(QObject *parent = nullptr) | |
QString | defaultServiceName() const |
QString | emailAddress() const |
bool | incomingAcceptUntrustedCertificates() const |
Sailfish::Mdm::Accounts::EmailAccountProvisioner::ConnectionEncryption | incomingConnectionEncryption() const |
QString | incomingPassword() const |
int | incomingPort() const |
Sailfish::Mdm::Accounts::EmailAccountProvisioner::IncomingProtocol | incomingProtocol() const |
QString | incomingServer() const |
QString | incomingUsername() const |
bool | outgoingAcceptUntrustedCertificates() const |
Sailfish::Mdm::Accounts::EmailAccountProvisioner::Authentication | outgoingAuthentication() const |
Sailfish::Mdm::Accounts::EmailAccountProvisioner::ConnectionEncryption | outgoingConnectionEncryption() const |
QString | outgoingPassword() const |
int | outgoingPort() const |
Sailfish::Mdm::Accounts::EmailAccountProvisioner::OutgoingProtocol | outgoingProtocol() const |
QString | outgoingServer() const |
QString | outgoingUsername() const |
void | setDefaultServiceName(const QString &servicename) |
void | setEmailAddress(const QString &emailaddress) |
void | setIncomingAcceptUntrustedCertificates(bool accept) |
void | setIncomingConnectionEncryption(Sailfish::Mdm::Accounts::EmailAccountProvisioner::ConnectionEncryption enc) |
void | setIncomingPassword(const QString &password) |
void | setIncomingPort(int port) |
void | setIncomingProtocol(Sailfish::Mdm::Accounts::EmailAccountProvisioner::IncomingProtocol protocol) |
void | setIncomingServer(const QString &server) |
void | setIncomingUsername(const QString &username) |
void | setOutgoingAcceptUntrustedCertificates(bool accept) |
void | setOutgoingAuthentication(Sailfish::Mdm::Accounts::EmailAccountProvisioner::Authentication requiresAuth) |
void | setOutgoingConnectionEncryption(Sailfish::Mdm::Accounts::EmailAccountProvisioner::ConnectionEncryption enc) |
void | setOutgoingPassword(const QString &password) |
void | setOutgoingPort(int port) |
void | setOutgoingProtocol(Sailfish::Mdm::Accounts::EmailAccountProvisioner::OutgoingProtocol protocol) |
void | setOutgoingServer(const QString &server) |
void | setOutgoingUsername(const QString &username) |
Reimplemented Public Functions
virtual bool | commitChanges() |
virtual bool | createAccount() |
virtual bool | selectAccount(quint64 accountId) |
- 23 public functions inherited from Sailfish::Mdm::Accounts::Provisioner
Signals
void | defaultServiceNameChanged() |
void | emailAddressChanged() |
void | incomingAcceptUntrustedCertificatesChanged() |
void | incomingConnectionEncryptionChanged() |
void | incomingPasswordChanged() |
void | incomingPortChanged() |
void | incomingProtocolChanged() |
void | incomingServerChanged() |
void | incomingUsernameChanged() |
void | outgoingAcceptUntrustedCertificatesChanged() |
void | outgoingAuthenticationChanged() |
void | outgoingConnectionEncryptionChanged() |
void | outgoingPasswordChanged() |
void | outgoingPortChanged() |
void | outgoingProtocolChanged() |
void | outgoingServerChanged() |
void | outgoingUsernameChanged() |
- 9 signals inherited from Sailfish::Mdm::Accounts::Provisioner
Detailed Description
The EmailAccountProvisioner class allows clients to create email accounts.
It provides a simple API which allows an MDM client to provision a device with an email account with specific settings.
While there are many specific settings which can be provided, in some cases these settings can be discovered automatically (based on the per-service configurations shipped with the device). The only settings which cannot be discovered (assuming that the per-service configurations contains settings for the required email account provider) are:
Also, if you wish to allow the device to accept untrusted certificates, that must be explicitly specified, otherwise they will be disallowed by default.
To use this class, clients must add the following to their qmake project:
CONFIG += link_pkgconfig PKGCONFIG += sailfishmdm
and then #include <mdm-accounts.h>
.
Example of usage:
#include <mdm-accounts.h> void createEmailAccount(const QString &emailAddress, const QString &password) { Sailfish::Mdm::Accounts::EmailAccountProvisioner eap; eap.setProviderName(QStringLiteral("email")); eap.setEmailAddress(emailAddress); eap.setIncomingPassword(password); if (!eap.createAccount()) { qWarning() << "Account creation failed:" << eap.errorMessage(); } }
Or to modify an existing account
#include <mdm-accounts.h> void setAccountServerAddress(quint64 accountId, const QString &defaultServiceName, const QString &serverAddress) { Sailfish::Mdm::Accounts::EmailAccountProvisioner eap; if (eap.selectAccount(accountId)) { eap.setDefaultServiceName(defaultServiceName); eap.setServerAddress(serverAddress); if (!eap.commitChanges()) { qWarning() << "Account modification failed:" << activeSyncAccount.errorMessage(); } } else { qWarning() << "No such account" } }
Member Type Documentation
enum EmailAccountProvisioner::Authentication
The authentication method to use when connecting to a mail server.
Constant | Value | Description |
---|---|---|
Sailfish::Mdm::Accounts::EmailAccountProvisioner::NoAuthentication | 0 | No authentication in use. |
Sailfish::Mdm::Accounts::EmailAccountProvisioner::Login | 1 | Use LOGIN authentication. |
Sailfish::Mdm::Accounts::EmailAccountProvisioner::Plain | 2 | Use PLAIN authentication. |
Sailfish::Mdm::Accounts::EmailAccountProvisioner::CramMd5 | 3 | Use CRAM-MD5 authentication. |
enum EmailAccountProvisioner::ConnectionEncryption
The connection encryption to use when connecting to a mail server.
Constant | Value | Description |
---|---|---|
Sailfish::Mdm::Accounts::EmailAccountProvisioner::NoEncryption | 0 | No encryption in use. |
Sailfish::Mdm::Accounts::EmailAccountProvisioner::SSL | 1 | SSL encryption. |
Sailfish::Mdm::Accounts::EmailAccountProvisioner::StartTLS | 2 | StartTLS encryption. |
enum EmailAccountProvisioner::IncomingProtocol
The protocol types supported for incoming mail servers.
Constant | Value | Description |
---|---|---|
Sailfish::Mdm::Accounts::EmailAccountProvisioner::NoIncomingProtocol | 0 | An invalid/default protocol value. |
Sailfish::Mdm::Accounts::EmailAccountProvisioner::Imap4 | 1 | IMAP4 protocol. |
Sailfish::Mdm::Accounts::EmailAccountProvisioner::Pop3 | 2 | POP3 protocol. |
enum EmailAccountProvisioner::OutgoingProtocol
The protocol types supported for outgoing mail servers.
Constant | Value | Description |
---|---|---|
Sailfish::Mdm::Accounts::EmailAccountProvisioner::NoOutgoingProtocol | 0 | An invalid/default protocol value. |
Sailfish::Mdm::Accounts::EmailAccountProvisioner::Smtp | 1 | SMTP protocol. |
Property Documentation
defaultServiceName : QString
This property holds the default account service name associated with the account.
The service definition will contain settings which are used by the email middleware (QMF) during email synchronisation.
If no default service name is set prior to account creation, an attempt will be made to autodiscover an appropriate email service from the Sailfish::Mdm::Accounts::Provisioner::providerName().
Access functions:
QString | defaultServiceName() const |
void | setDefaultServiceName(const QString &servicename) |
Notifier signal:
void | defaultServiceNameChanged() |
emailAddress : QString
This property holds the email address associated with the account.
Note that the email address may also be used as the username when connecting to the incoming server (to receive emails) and/or the outgoing server (to send emails), if no incoming username or outgoing username is set, respectively.
Access functions:
QString | emailAddress() const |
void | setEmailAddress(const QString &emailaddress) |
Notifier signal:
void | emailAddressChanged() |
incomingAcceptUntrustedCertificates : bool
This property holds true if the device should accept untrusted certificates from the incoming mail (e.g. POP/IMAP) server.
The default value is false
.
Access functions:
bool | incomingAcceptUntrustedCertificates() const |
void | setIncomingAcceptUntrustedCertificates(bool accept) |
Notifier signal:
void | incomingAcceptUntrustedCertificatesChanged() |
incomingConnectionEncryption : Sailfish::Mdm::Accounts::EmailAccountProvisioner::ConnectionEncryption
This property holds the type of connection encryption which should be used when communicating with the incoming mail (e.g. POP/IMAP) server.
If no encryption type is set prior to account creation, it may be automatically discovered if a valid configuration exists for the provider.
Access functions:
Sailfish::Mdm::Accounts::EmailAccountProvisioner::ConnectionEncryption | incomingConnectionEncryption() const |
void | setIncomingConnectionEncryption(Sailfish::Mdm::Accounts::EmailAccountProvisioner::ConnectionEncryption enc) |
Notifier signal:
void | incomingConnectionEncryptionChanged() |
incomingPassword : QString
This property holds the password to use with the incoming mail (e.g. POP/IMAP) server.
This is the password which will be used in conjunction with the incoming username in order to authenticate with the incoming server.
Note that if no outgoing password is set prior to account creation, the incoming password will be used as the outgoing password also.
Access functions:
QString | incomingPassword() const |
void | setIncomingPassword(const QString &password) |
Notifier signal:
void | incomingPasswordChanged() |
incomingPort : int
This property holds the port to which to connect to communicate with the incoming mail (e.g. POP/IMAP) server.
This is the port of the remote incoming server which the device will connect to in order to receive incoming emails.
If no incoming port is set prior to account creation, it may be automatically discovered if a valid configuration exists for the provider.
Access functions:
int | incomingPort() const |
void | setIncomingPort(int port) |
Notifier signal:
void | incomingPortChanged() |
incomingProtocol : Sailfish::Mdm::Accounts::EmailAccountProvisioner::IncomingProtocol
This property holds the protocol supported by the incoming mail server (e.g. POP3/IMAP4).
If no incoming protocol is set prior to account creation, it may be automatically discovered if a valid configuration exists for the provider.
Currently, only the IMAP4 and POP3 protocols are supported.
Access functions:
Sailfish::Mdm::Accounts::EmailAccountProvisioner::IncomingProtocol | incomingProtocol() const |
void | setIncomingProtocol(Sailfish::Mdm::Accounts::EmailAccountProvisioner::IncomingProtocol protocol) |
Notifier signal:
void | incomingProtocolChanged() |
incomingServer : QString
This property holds the internet address or URL of the incoming mail (e.g. POP/IMAP) server.
This is the server to which the device will connect to in order to receive incoming emails.
If no incoming server address is set prior to account creation, it may be automatically discovered if a valid configuration exists for the provider.
Access functions:
QString | incomingServer() const |
void | setIncomingServer(const QString &server) |
Notifier signal:
void | incomingServerChanged() |
incomingUsername : QString
This property holds the username to use with the incoming mail (e.g. POP/IMAP) server.
If no incoming username is set prior to account creation, it is assumed to be identical to the email address.
Note that if no outgoing username is set prior to account creation, it is assumed to be identical to this incoming username, or to the email address if no incoming username is set.
Access functions:
QString | incomingUsername() const |
void | setIncomingUsername(const QString &username) |
Notifier signal:
void | incomingUsernameChanged() |
outgoingAcceptUntrustedCertificates : bool
This property holds true if the device should accept untrusted certificates from the remote outgoing mail (e.g. SMTP) server.
The default value is false
.
Access functions:
bool | outgoingAcceptUntrustedCertificates() const |
void | setOutgoingAcceptUntrustedCertificates(bool accept) |
Notifier signal:
void | outgoingAcceptUntrustedCertificatesChanged() |
outgoingAuthentication : Sailfish::Mdm::Accounts::EmailAccountProvisioner::Authentication
This property holds the type of authentication required by the remote outgoing mail (e.g. SMTP) server.
If no authentication type is set prior to account creation, it may be automatically discovered if a valid configuration exists for the provider.
Access functions:
Sailfish::Mdm::Accounts::EmailAccountProvisioner::Authentication | outgoingAuthentication() const |
void | setOutgoingAuthentication(Sailfish::Mdm::Accounts::EmailAccountProvisioner::Authentication requiresAuth) |
Notifier signal:
void | outgoingAuthenticationChanged() |
outgoingConnectionEncryption : Sailfish::Mdm::Accounts::EmailAccountProvisioner::ConnectionEncryption
This property holds the type of connection encryption to use when communicating with the remote outgoing mail (e.g. SMTP) server.
If no encryption type is set prior to account creation, it may be automatically discovered if a valid configuration exists for the provider.
Access functions:
Sailfish::Mdm::Accounts::EmailAccountProvisioner::ConnectionEncryption | outgoingConnectionEncryption() const |
void | setOutgoingConnectionEncryption(Sailfish::Mdm::Accounts::EmailAccountProvisioner::ConnectionEncryption enc) |
Notifier signal:
void | outgoingConnectionEncryptionChanged() |
outgoingPassword : QString
This property holds the password to use with the remote outgoing mail (e.g. SMTP) server.
If no outgoing password is set prior to account creation, it will be assumed to be identical to the incoming password.
Access functions:
QString | outgoingPassword() const |
void | setOutgoingPassword(const QString &password) |
Notifier signal:
void | outgoingPasswordChanged() |
outgoingPort : int
This property holds the port to which to connect to communicate with the remote outgoing mail (e.g. SMTP) server.
If no outgoing port is set prior to account creation, it may be automatically discovered if a valid configuration exists for the provider.
Access functions:
int | outgoingPort() const |
void | setOutgoingPort(int port) |
Notifier signal:
void | outgoingPortChanged() |
outgoingProtocol : Sailfish::Mdm::Accounts::EmailAccountProvisioner::OutgoingProtocol
This property holds the protocol supported by the remote outgoing mail server (usually SMTP).
If no outgoing protocol is set prior to account creation, it is assumed to be Sailfish::Mdm::Accounts::EmailAccountProvisioner::Smtp.
Currently, only the SMTP protocol is supported.
Access functions:
Sailfish::Mdm::Accounts::EmailAccountProvisioner::OutgoingProtocol | outgoingProtocol() const |
void | setOutgoingProtocol(Sailfish::Mdm::Accounts::EmailAccountProvisioner::OutgoingProtocol protocol) |
Notifier signal:
void | outgoingProtocolChanged() |
outgoingServer : QString
This property holds the internet address or URL of the remote outgoing mail (e.g. SMTP) server.
If no outgoing server address is set prior to account creation, it may be automatically discovered if a valid configuration exists for the provider.
Access functions:
QString | outgoingServer() const |
void | setOutgoingServer(const QString &server) |
Notifier signal:
void | outgoingServerChanged() |
outgoingUsername : QString
This property holds the username to use with the remote outgoing mail (e.g. SMTP) server.
If no outgoing username is set prior to account creation, it is assumed to be identical to the incoming username, or (if no incoming username is set) the email address.
Access functions:
QString | outgoingUsername() const |
void | setOutgoingUsername(const QString &username) |
Notifier signal:
void | outgoingUsernameChanged() |
Member Function Documentation
EmailAccountProvisioner::EmailAccountProvisioner(QObject *parent = nullptr)
Constructs an email account provisioner with the given parent.
[virtual]
bool EmailAccountProvisioner::commitChanges()
[virtual]
bool EmailAccountProvisioner::createAccount()
Reimplemented from Provisioner::createAccount().