accounts-qt: Manager Class Reference

accounts-qt 1.17

Public Types | Signals | Public Member Functions | List of all members
Manager Class Reference

Manager of accounts, services and providers. More...

`#include <Accounts/Manager>`

Inherits QObject.

## Public Types
enum | Option { DisableNotifications = 0x1 }
| Specifies options for the object. More...

## Signals
void | accountCreated (Accounts::AccountId id)
| The signal is emitted when new account is created.
void | accountRemoved (Accounts::AccountId id)
| The signal is emitted when existing account is removed.
void | accountUpdated (Accounts::AccountId id)
| The signal is emitted when any account property for a particular service is updated.
void | enabledEvent (Accounts::AccountId id)
| If the manager has been created with serviceType, this signal will be emitted when an account (identified by AccountId) has been modified in such a way that the application might be interested to start/stop using it: the "enabled" flag on the account or in some service supported by the account and matching the AgManager::serviceType have changed.

## Public Member Functions
| Manager (QObject *parent=nullptr)
| Constructor.
| Manager (const QString &serviceType, QObject *parent=nullptr)
| Constructs a manager initialized with service type.
| Manager (Options options, QObject *parent=nullptr)
| Constructor, allowing option flags to be specified.
| ~Manager ()
| Destructor.
Account * | account (const AccountId &id) const
| Loads an account from the database.
AccountIdList | accountList (const QString &serviceType=QString()) const
| Lists the accounts which support the requested service.
AccountIdList | accountListEnabled (const QString &serviceType=QString()) const
| Lists the enabled accounts which support the requested service that also must be enabled.
Account * | createAccount (const QString &providerName)
| Creates a new account.
Service | service (const QString &serviceName) const
| Gets an object representing a service.
ServiceList | serviceList (const QString &serviceType=QString()) const
| Gets the service list.
ServiceList | serviceList (const Application &application) const
| Get the list of services supported by the given application.
Provider | provider (const QString &providerName) const
| Gets an object representing a provider.
ProviderList | providerList () const
| Gets a provider list.
ServiceType | serviceType (const QString &name) const
| Gets an object representing a service type.
Application | application (const QString &applicationName) const
| Get an object representing an application.
ApplicationList | applicationList (const Service &service) const
| List the registered applications which support the given service.
QString | serviceType () const
| Gets the service type if given in manager constructor.
void | setTimeout (quint32 timeout)
| Sets the timeout for database operations.
quint32 | timeout ()
| Gets the database timeout.
void | setAbortOnTimeout (bool abort)
| Sets whether to abort the application when a database timeout occurs.
bool | abortOnTimeout () const
Options | options () const
Error | lastError () const
| Gets the last error.

## Detailed Description

Manager of accounts, services and providers.

The Manager offers ways to create accounts, list accounts, services and providers. It also emits signals when accounts are created and removed.

Definition at line 51 of file manager.h.

## Member Enumeration Documentation

## ◆ Option

enum Option

Specifies options for the object.

Enumerator
DisableNotifications | Disable all inter-process notifications

Definition at line 60 of file manager.h.

## Constructor & Destructor Documentation

## ◆ Manager() [1/3]

Manager | ( | QObject * | parent = `nullptr` | ) |

Constructor.

Users should check for manager->lastError() to check if manager construction was fully succesful.

Definition at line 146 of file manager.cpp.

References Error::DatabaseLocked.

## ◆ Manager() [2/3]

Manager | ( | const QString & | serviceType,
|  | QObject * | parent = `nullptr`
| ) |  |

Constructs a manager initialized with service type.

This constructor should be used when there is an interest for just one service type. Such a manager has influence on some class methods. When listing the accounts and services only the ones supporting the given service type will be returned. Also the creating account with this manager will affect the acccount class method for listing services in same manner. The signal enabledEvent() will be emitted only when manager is created with this constructor. Users should check for manager->lastError() to check if manager construction was fully succesful.

Definition at line 173 of file manager.cpp.

References Error::DatabaseLocked, and Manager::serviceType().

## ◆ Manager() [3/3]

Manager | ( | Options | options,
|  | QObject * | parent = `nullptr`
| ) |  |

Constructor, allowing option flags to be specified.

Users should check for lastError() to check if manager construction was fully succesful.

Definition at line 194 of file manager.cpp.

References Manager::DisableNotifications, and Manager::options().

## ◆ ~Manager()

~Manager | ( |  | ) |

Destructor.

Definition at line 217 of file manager.cpp.

## Member Function Documentation

## ◆ abortOnTimeout()

bool abortOnTimeout | ( |  | ) | const

Returns
  Whether the application will be aborted when a database timeout occurs.

Definition at line 552 of file manager.cpp.

## ◆ account()

Account * account | ( | const AccountId & | id | ) | const

Loads an account from the database.

Parameters

  id | Id of the account to be retrieved.

Returns
  Requested account or 0 if not found. If 0 is returned, call lastError() to find out why.

Attention
  The objects returned by this method are shared, meaning that calling this method twice with the same id will return the same object. It is recommended that clients do not destroy the objects returned by this method, if there's the possibility that they are still being used in other parts of the application.

Definition at line 245 of file manager.cpp.

References Manager::account().

Referenced by Manager::account().

## ◆ accountCreated

accountCreated | ( | Accounts::AccountId | id | ) |
| signal

The signal is emitted when new account is created.

Parameters

  id | Identifier of the Account

## ◆ accountList()

AccountIdList accountList | ( | const QString & | serviceType = `QString()` | ) | const

Lists the accounts which support the requested service.

Parameters

  serviceType | Type of service that returned accounts must support. If not given and the manager is not constructed with service type, all accounts are returned.

Returns
  List of account IDs.

Definition at line 266 of file manager.cpp.

References Manager::serviceType().

## ◆ accountListEnabled()

AccountIdList accountListEnabled | ( | const QString & | serviceType = `QString()` | ) | const

Lists the enabled accounts which support the requested service that also must be enabled.

Parameters

  serviceType | Type of service that returned accounts must support. If not given and the manager is not constructed with service type, all enabled accounts are returned.

Returns
  List of account IDs.

Definition at line 301 of file manager.cpp.

References Manager::serviceType().

## ◆ accountRemoved

accountRemoved | ( | Accounts::AccountId | id | ) |
| signal

The signal is emitted when existing account is removed.

Parameters

  id | Identifier of the Account

## ◆ accountUpdated

accountUpdated | ( | Accounts::AccountId | id | ) |
| signal

The signal is emitted when any account property for a particular service is updated.

To receive this notification user has to create accounts manager using Manager(const QString &serviceType, QObject *parent) constructor. Update notification is only emitted when manager is created for particular type of service.

Parameters

  id | Identifier of the Account

## ◆ application()

Application application | ( | const QString & | applicationName | ) | const

Get an object representing an application.

Parameters

  applicationName | Name of the application to load.

Returns
  The requested Application, or an invalid Application object if not found.

Definition at line 477 of file manager.cpp.

References Manager::application().

Referenced by Manager::application(), Manager::applicationList(), and Manager::serviceList().

## ◆ applicationList()

ApplicationList applicationList | ( | const Service & | service | ) | const

List the registered applications which support the given service.

Parameters

  service | The service to be supported.

Returns
  A list of Application objects.

Definition at line 491 of file manager.cpp.

References Manager::application(), and Manager::service().

## ◆ createAccount()

Account * createAccount | ( | const QString & | providerName | ) |

Creates a new account.

Parameters

  providerName | Name of account provider.

Returns
  Created account or NULL if some error occurs.

Definition at line 331 of file manager.cpp.

## ◆ enabledEvent

enabledEvent | ( | Accounts::AccountId | id | ) |
| signal

If the manager has been created with serviceType, this signal will be emitted when an account (identified by AccountId) has been modified in such a way that the application might be interested to start/stop using it: the "enabled" flag on the account or in some service supported by the account and matching the AgManager::serviceType have changed.

Note
  In practice, this signal might be emitted more often than when strictly needed; applications must call Account::enabledServices() to get the current state.

Parameters

  id | identifier of the Account

## ◆ lastError()

Error lastError | ( |  | ) | const

Gets the last error.

Not all operations set/reset the error; see the individual methods' documentation to see if they set the last error or not. Call this method right after an account operation has failed; if no error occurred, the result of this method are undefined.

Returns
  The last error.

Definition at line 583 of file manager.cpp.

## ◆ options()

Manager::Options options | ( |  | ) | const

Returns
  Configuration options for this object.

Definition at line 560 of file manager.cpp.

References Manager::DisableNotifications.

Referenced by Manager::Manager().

## ◆ provider()

Provider provider | ( | const QString & | providerName | ) | const

Gets an object representing a provider.

Parameters

  providerName | Name of provider to get.

Returns
  Requested provider or NULL if not found.

Definition at line 421 of file manager.cpp.

References Manager::provider().

Referenced by Manager::provider(), and Manager::providerList().

## ◆ providerList()

ProviderList providerList | ( |  | ) | const

Gets a provider list.

Returns
  List of registered providers.

Definition at line 435 of file manager.cpp.

References Manager::provider().

## ◆ service()

Service service | ( | const QString & | serviceName | ) | const

Gets an object representing a service.

Parameters

  serviceName | Name of service to get.

Returns
  The requested service or an invalid service if not found.

Definition at line 342 of file manager.cpp.

References Manager::service().

Referenced by Manager::applicationList(), Manager::service(), and Manager::serviceList().

## ◆ serviceList() [1/2]

ServiceList serviceList | ( | const Application & | application | ) | const

Get the list of services supported by the given application.

Parameters

  application | Application whose services are to be retrieved.

Returns
  List of Service objects.

Definition at line 393 of file manager.cpp.

References Manager::application(), and Manager::service().

## ◆ serviceList() [2/2]

ServiceList serviceList | ( | const QString & | serviceType = `QString()` | ) | const

Gets the service list.

If the manager is constructed with given service type only the services which supports the service type will be returned.

Parameters

  serviceType | Type of services to be listed. If not given and the manager is not constructed with service type, all services are listed.

Returns
  List of Service objects.

Definition at line 360 of file manager.cpp.

References Manager::service(), and Manager::serviceType().

## ◆ serviceType() [1/2]

QString serviceType | ( |  | ) | const

Gets the service type if given in manager constructor.

Returns
  Service type or NULL if not given.

Definition at line 511 of file manager.cpp.

Referenced by Manager::accountList(), Manager::accountListEnabled(), Manager::Manager(), and Manager::serviceList().

## ◆ serviceType() [2/2]

ServiceType serviceType | ( | const QString & | name | ) | const

Gets an object representing a service type.

Parameters

  name | Name of service type to load.

Returns
  Requested service type or NULL if not found.

Definition at line 462 of file manager.cpp.

## ◆ setAbortOnTimeout()

void setAbortOnTimeout | ( | bool | abort | ) |

Sets whether to abort the application when a database timeout occurs.

By default the library does not abort the application.

Definition at line 543 of file manager.cpp.

## ◆ setTimeout()

void setTimeout | ( | quint32 | timeout | ) |

Sets the timeout for database operations.

Parameters

  timeout | The new timeout in milliseconds.

This tells the library how long it is allowed to block while waiting for a locked DB to become accessible. Higher values mean a higher chance of successful reads, but also mean that the execution might be blocked for a longer time. The default is 5 seconds.

Definition at line 525 of file manager.cpp.

References Manager::timeout().

## ◆ timeout()

quint32 timeout | ( |  | ) |

Gets the database timeout.

Returns
  The timeout (in milliseconds) for database operations.

Definition at line 534 of file manager.cpp.

Referenced by Manager::setTimeout().

The documentation for this class was generated from the following files:

- Accounts/manager.h
- Accounts/manager.cpp