API Documentation
Documentation for developing SailfishOS applicationsProvisioner Class
(Sailfish::Mdm::Accounts::Provisioner)Base account provisioner type. More...
Header: | #include <mdm-accounts.h> |
Inherited By: | Sailfish::Mdm::Accounts::ActiveSyncAccountProvisioner, Sailfish::Mdm::Accounts::EmailAccountProvisioner, and Sailfish::Mdm::Accounts::GenericAccountProvisioner |
Public Types
class | AccountInfo |
Properties
|
|
Public Functions
Provisioner(QObject *parent = nullptr) | |
virtual | ~Provisioner() |
QVariantMap | accountConfiguration() const |
QString | accountDisplayName() const |
bool | accountLimited() const |
bool | accountReadOnly() const |
bool | canCreateAccount() const |
virtual bool | commitChanges() |
virtual bool | createAccount() = 0 |
virtual bool | deleteAccount(quint64 accountId) |
int | error() const |
QString | errorMessage() const |
QString | lastTransactionUuid() const |
virtual QList<Sailfish::Mdm::Accounts::Provisioner::AccountInfo> | listAccounts() |
QString | providerName() const |
bool | queuedTransactionUsed() const |
virtual bool | selectAccount(quint64 accountId) |
void | setAccountConfiguration(const QVariantMap &config) |
void | setAccountDisplayName(const QString &displayName) |
void | setAccountLimited(bool limited) |
void | setAccountReadOnly(bool readOnly) |
void | setProviderName(const QString &providername) |
void | setResultHandler(const QString &service, const QString &path, const QString &interface, const QString &method) |
void | setUser(int user) |
int | user() const |
Signals
void | accountConfigurationChanged() |
void | accountDisplayNameChanged() |
void | accountLimitedChanged() |
void | accountReadOnlyChanged() |
void | canCreateAccountChanged() |
void | lastTransactionUuidChanged() |
void | providerNameChanged() |
void | queuedTransactionUsedChanged() |
void | userChanged() |
Detailed Description
Base account provisioner type.
Clients should not use this type directly, but should instead use one of the derived types, such as the Sailfish::Mdm::Accounts::EmailAccountProvisioner.
Property Documentation
accountConfiguration : QVariantMap
This property holds the account configuration settings which will be associated with the account to be created.
The configuration consists of a map of service names to settings map. The global account configuration settings are associated with the empty service name.
For example, to add some new keys to the current configuration:
// Get the current account configuration QVariantMap config = accountProvisioner.accountConfiguration(); // Amend the current global configuration QVariantMap globalConfig = config.value(QString()).toMap(); // global configuration is identified by an empty service name globalConfig.insert(QStringLiteral("created_by_mdm"), true); config.insert(QString(), globalConfig); // Amend the current email configuration QVariantMap emailConfig = config.value(QStringLiteral("email").toMap(); emailConfig.insert(QStringLiteral("signature"), QStringLiteral("Sent by my Sailfish OS device")); config.insert(QStringLiteral("email"), emailConfig); // Update the account configuration accountProvisioner.setAccountConfiguration(config);
Access functions:
QVariantMap | accountConfiguration() const |
void | setAccountConfiguration(const QVariantMap &config) |
Notifier signal:
void | accountConfigurationChanged() |
accountDisplayName : QString
This property holds the display name of the account to be provisioned.
Access functions:
QString | accountDisplayName() const |
void | setAccountDisplayName(const QString &displayName) |
Notifier signal:
void | accountDisplayNameChanged() |
accountLimited : bool
This property holds true if the account is in limited mode.
Only the password of such accounts can be set outside MDM API.
The default value of this setting for accounts is false
.
Access functions:
bool | accountLimited() const |
void | setAccountLimited(bool limited) |
Notifier signal:
void | accountLimitedChanged() |
accountReadOnly : bool
This property holds true if the account is in read-only mode.
Such accounts may only be edited or deleted via MDM API.
The default value of this setting is false
.
Access functions:
bool | accountReadOnly() const |
void | setAccountReadOnly(bool readOnly) |
Notifier signal:
void | accountReadOnlyChanged() |
canCreateAccount : const bool
This property holds true if enough settings have been provided for account creation to succeed.
Access functions:
bool | canCreateAccount() const |
Notifier signal:
void | canCreateAccountChanged() |
lastTransactionUuid : const QString
This property holds the UUID of the last queued transaction or an empty string.
When queued transaction is made (i.e. user is not 0
and they are not logged in), this contains universally unique identifier (UUID) of that transaction. It is valid until the next queued transaction happens. If queued transaction fails or none has been made, this is an empty string.
Access functions:
QString | lastTransactionUuid() const |
Notifier signal:
void | lastTransactionUuidChanged() |
providerName : QString
This property holds name of the provider of the account to be provisioned.
Every account is provided by a specific provider, which is identified by the provider name. In order to create an account, a valid provider name must be set.
Providers are installed by accounts framework extension plugins.
Access functions:
QString | providerName() const |
void | setProviderName(const QString &providername) |
Notifier signal:
void | providerNameChanged() |
queuedTransactionUsed : const bool
This property holds whether last operation used queued transaction.
This is true
if the last operation stored queued transaction. It must be checked if user is not 0
and the operation supports queued transactions. The value is valid until next operation.
This is true
even if queued transaction failed and nothing was stored.
Access functions:
bool | queuedTransactionUsed() const |
Notifier signal:
void | queuedTransactionUsedChanged() |
user : int
This property holds user's UID or 0 if not specified.
When account change is directed to Unix user on device, this must be used to specify user identifier (UID). If the user is not currently logged in, the transaction is queued and run once user logs in next time. Note that this is not available on all interfaces.
This does not check if the user exists. It is caller's responsibility to check which users exist on device. It can be also used for users that have not been created yet.
Access functions:
int | user() const |
void | setUser(int user) |
Notifier signal:
void | userChanged() |
Member Function Documentation
Provisioner::Provisioner(QObject *parent = nullptr)
Constructs a new account provisioner with the given parent.
[virtual]
Provisioner::~Provisioner()
Destroys the account provisioner.
[virtual]
bool Provisioner::commitChanges()
Attempts to set the changes properties to an existing account.
[pure virtual]
bool Provisioner::createAccount()
Attempts to create an account with the settings specified in the provisioner. This operation supports queued transactions.
When queued transactions are used, callback's details argument has fields accountId
(unsigned long long), error
(int) and errorMessage
(string).
Returns true
if the account was created successfully or transaction was queued, otherwise returns false
.
[virtual]
bool Provisioner::deleteAccount(quint64 accountId)
Deletes the account with the specified accountId. This operation supports queued transactions.
When queued transactions are used, callback's details argument has fields success
(bool), error
(int) and errorMessage
(string).
Returns true
if the account was deleted successfully or transaction was queued, otherwise returns false
.
int Provisioner::error() const
Returns an error code associated with a failed attempt to create an account.
The value of the code will depend on the provisioner.
QString Provisioner::errorMessage() const
Returns an error message associated with a failed attempt to create or modify an account.
The message is not user-friendly and should not be shown in any UI, but should instead be logged. It should provide details as to why the failure occurred.
[virtual]
QList<Sailfish::Mdm::Accounts::Provisioner::AccountInfo> Provisioner::listAccounts()
Returns a list of the account id, provider name, and remote identifier (e.g. email address) of each account.
[virtual]
bool Provisioner::selectAccount(quint64 accountId)
Prepares the provisioner for modification / introspection of selected account. Note, only provisioned accounts can be selected.
void Provisioner::setResultHandler(const QString &service, const QString &path, const QString &interface, const QString &method)
Set handler for queued transaction callback.
When queued transactions are used this can be used to set D-Bus callback that gets called once the transaction is made.
Arguments service, path, interface and method define the D-Bus method to call once the transaction has been completed. It must have arguments (ssa{sv}) for transaction uuid, error and details respectively. Details array values are operation dependent but in case of an error it contains just one key errorMessage
with string value for the received error message.
Callback is unset if an empty string is provided.