accounts-qt  1.15
Account Class Reference

The Account class provides an interface to account settings. More...

#include <Accounts/Account>

List of all members.

Signals

void displayNameChanged (const QString &displayName)
void enabledChanged (const QString &serviceName, bool enabled)
void error (Accounts::Error error)
 Emitted when an error occurs.
void synced ()
void removed ()

Public Member Functions

 Account (Manager *manager, const QString &provider, QObject *parent=0)
 Constructs a new Account.
virtual ~Account ()
 Destroys the current account object and free all resources.
AccountId id () const
 Returns the AccountId of this account (0 if the account has not yet been stored into the database).
Managermanager () const
 Returns the Manager.
bool supportsService (const QString &serviceType) const
 Checks whether the account supports the given service.
ServiceList services (const QString &serviceType=QString()) const
 Returns a list of services supported by this account.
ServiceList enabledServices () const
 Returns a list of enabled services supported by this account.
bool enabled () const
 Checks whether the account or selected service is enabled.
bool isEnabled () const
 Checks whether the account or selected service is enabled.
void setEnabled (bool)
 Enables/disables the account or selected service.
uint credentialsId ()
 Gets the account's credentials ID in Signon database.
void setCredentialsId (const uint id)
 Sets the accounts credentials ID.
QString displayName () const
 Returns the display name of the account.
void setDisplayName (const QString &displayName)
 Changes the display name of the account.
QString providerName () const
 Returns the name of the provider of the account.
Provider provider () const
 Returns the provider of the account.
void selectService (const Service &service=Service())
 Select the Service for the subsequent operations.
Service selectedService () const
QStringList allKeys () const
 Returns all keys in the current group.
void beginGroup (const QString &prefix)
 Enters a group.
QStringList childGroups () const
 Returns all the groups which are direct children of the current group.
QStringList childKeys () const
 Return all the keys which are direct children of the current group.
void clear ()
 Removes all the keys in the currently selected service.
bool contains (const QString &key) const
 Checks whether the given key is in the current group.
void endGroup ()
 Exits a group.
QString group () const
 Returns the name of the current group.
bool isWritable () const
 Checks whether the account is writable.
void remove (const QString &key)
 Removes the given key.
void setValue (const QString &key, const QVariant &value)
 Changes the value of an account setting.
QVariant value (const QString &key, const QVariant &defaultValue=QVariant(), SettingSource *source=0) const
 Retrieves the value of an account setting, as a QVariant.
SettingSource value (const QString &key, QVariant &value) const
 Retrieves the value of an account setting, as a QVariant.
QString valueAsString (const QString &key, QString default_value=QString::null, SettingSource *source=0) const
 Gets an account setting as a string.
int valueAsInt (const QString &key, int default_value=0, SettingSource *source=0) const
 Gets an account setting as an integer.
quint64 valueAsUInt64 (const QString &key, quint64 default_value=0, SettingSource *source=0) const
 Gets an account setting as an unsigned long integer.
bool valueAsBool (const QString &key, bool default_value=false, SettingSource *source=0) const
 Gets an account setting as a boolean.
WatchwatchKey (const QString &key=QString())
 Installs a key or group watch.
void sync ()
 Stores all account settings into the database.
bool syncAndBlock ()
 Blocking version of the sync() method: execution of the current thread will block until the operation has completed.
void remove ()
 Marks the account for removal.
void sign (const QString &key, const char *token)
 Creates signature of key with given aegis token.
bool verify (const QString &key, const char **token)
 Verifies if the key is signed and the signature matches the value and provides the aegis token which was used for signing the key.
bool verifyWithTokens (const QString &key, QList< const char * > tokens)
 Verifies if the key is signed with any of the aegis tokens and the signature is valid.

Static Public Member Functions

static AccountfromId (Manager *manager, AccountId id, QObject *parent=0)
 Constructs an Account object representing an account stored in the database.

Detailed Description

The Account class provides an interface to account settings.

The Account class is used to access the account and service settings. This class has no constructor, therefore to instantiate one Account object one has to either use the Manager::createAccount method (to create a new empty account) or Manager::account (to load an existing account).

Attention:
Do not call setParent() on an account object; the Account class assumes that the parent is always the Manager, and changing it will have unpredictable results.

Most of the methods in the Account class act on the selected service: for example, calling setEnabled(false) on the NULL service (this is the service to be used for changing settings globally on the account) will disable the account, while the code

 account->selectService(myService);
 account->setEnabled(false);

will disable the "myService" service.

All changes made on an account (including deletion) are not stored until sync() is called.

Definition at line 95 of file account.h.


Constructor & Destructor Documentation

Account ( Manager manager,
const QString &  providerName,
QObject *  parent = 0 
)

Constructs a new Account.

The account exists only in memory and is not visible to other applications (or Manager instances) until sync() has been called.

Parameters:
managerThe account manager. Do not destroy it while the account object is in use.
providerNameName of the provider for the account.
parentParent object.

Definition at line 202 of file account.cpp.

Referenced by Account::fromId().


Member Function Documentation

QStringList allKeys ( ) const

Returns all keys in the current group.

This method operates on the currently selected service.

Definition at line 450 of file account.cpp.

Referenced by Account::childGroups(), Account::childKeys(), and Account::remove().

void beginGroup ( const QString &  prefix)

Enters a group.

This method never fails.

Parameters:
prefixThis method operates on the currently selected service.

Definition at line 473 of file account.cpp.

QStringList childGroups ( ) const

Returns all the groups which are direct children of the current group.

This method operates on the currently selected service.

Definition at line 483 of file account.cpp.

References Account::allKeys(), and Account::group().

QStringList childKeys ( ) const

Return all the keys which are direct children of the current group.

This method operates on the currently selected service.

Definition at line 504 of file account.cpp.

References Account::allKeys().

Referenced by Account::contains().

void clear ( )

Removes all the keys in the currently selected service.

See also:
remove(const QString &key)

Definition at line 521 of file account.cpp.

bool contains ( const QString &  key) const

Checks whether the given key is in the current group.

Parameters:
keyThe key name of the settings.

This method operates on the currently selected service.

Definition at line 537 of file account.cpp.

References Account::childKeys().

uint credentialsId ( )

Gets the account's credentials ID in Signon database.

The credentials ID is first read from the currently selected service; if it is not found, then it is ready from the global account settings. In any case, the currently selected service is not altered.

Definition at line 935 of file account.cpp.

References Account::id(), Service::isValid(), Account::selectedService(), Account::selectService(), and Account::value().

QString displayName ( ) const

Returns the display name of the account.

This method operates on the currently selected service.

Definition at line 389 of file account.cpp.

bool enabled ( ) const

Checks whether the account or selected service is enabled.

This method operates on the currently selected service or globally, if none selected.

Note:
this is just a wrapper of isEnabled
See also:
isEnabled()
Deprecated:
use isEnabled instead

Definition at line 356 of file account.cpp.

References Account::isEnabled().

ServiceList enabledServices ( ) const

Returns a list of enabled services supported by this account.

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

Definition at line 327 of file account.cpp.

void endGroup ( )

Exits a group.

This method operates on the currently selected service.

Definition at line 547 of file account.cpp.

Account * fromId ( Manager manager,
AccountId  id,
QObject *  parent = 0 
) [static]

Constructs an Account object representing an account stored in the database.

Parameters:
managerThe account manager. Do not destroy it while the account object is in use.
idThe numeric identifier of the account.
parentParent object.
Returns:
A new account object, or 0 if an error occurred.

Definition at line 225 of file account.cpp.

References Account::Account(), Account::error(), and Manager::lastError().

Referenced by Manager::account().

QString group ( ) const

Returns the name of the current group.

This method operates on the currently selected service.

Definition at line 559 of file account.cpp.

Referenced by Account::childGroups().

bool isEnabled ( ) const

Checks whether the account or selected service is enabled.

This method operates on the currently selected service or globally, if none selected.

Definition at line 367 of file account.cpp.

Referenced by Account::enabled().

bool isWritable ( ) const

Checks whether the account is writable.

This always returns true.

Definition at line 569 of file account.cpp.

void remove ( const QString &  key)

Removes the given key.

If the key is the empty string, all keys in the current group are removed.

Parameters:
keyThe key name of the settings.

This method operates on the currently selected service.

Definition at line 581 of file account.cpp.

References Account::allKeys().

void remove ( )

Marks the account for removal.

The account will be deleted only when the sync() method is called.

Definition at line 873 of file account.cpp.

Returns:
The currently selected service.

Definition at line 439 of file account.cpp.

Referenced by Account::credentialsId().

void selectService ( const Service service = Service())

Select the Service for the subsequent operations.

Parameters:
serviceThe Service to select. If this is invalid, the global account settings will be selected.

Definition at line 425 of file account.cpp.

References Service::isValid().

Referenced by Account::credentialsId().

ServiceList services ( const QString &  serviceType = QString()) const

Returns a list of services supported by this account.

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

This is currently computed by returning all services having the same provider as the account.

Definition at line 298 of file account.cpp.

void setCredentialsId ( const uint  id) [inline]

Sets the accounts credentials ID.

The change will be written only when sync() is called.

This method operates on the currently selected service.

Definition at line 134 of file account.h.

void setDisplayName ( const QString &  displayName)

Changes the display name of the account.

The change will be written only when sync() is called.

Definition at line 398 of file account.cpp.

void setEnabled ( bool  enabled)

Enables/disables the account or selected service.

The change will be written only when sync() is called.

This method operates on the currently selected service or globally, if none selected.

Definition at line 379 of file account.cpp.

void setValue ( const QString &  key,
const QVariant &  value 
)

Changes the value of an account setting.

Parameters:
keyThe key name of the setting.
valueThe new value.

This method operates on the currently selected service.

Definition at line 608 of file account.cpp.

void sign ( const QString &  key,
const char *  token 
)

Creates signature of key with given aegis token.

The calling application must possess (request) the given aegis token. The account needs to be stored prior to executing this method.

Parameters:
keyThe key or the prefix of set of the keys to be signed.
tokenThe aegis token to be used for signing the key.

This method operates on the currently selected service.

Definition at line 887 of file account.cpp.

void sync ( )

Stores all account settings into the database.

The signal synced() will be emitted in case of success, or error() in case of failure. No assumption must be made about when these signals will be emitted: if the database is locked, the signals might be emitted asynchronously, whereas if the operation can happen synchronously then the signals can be emitted before this method returns. If for some reason one would want to process the signals asynchronously from the event loop, one can use the Qt::QueuedConnection connection type as last parameter of the QObject::connect call.

Definition at line 839 of file account.cpp.

bool syncAndBlock ( )

Blocking version of the sync() method: execution of the current thread will block until the operation has completed.

Usage of this method is discouraged, especially for UI applications.

Returns:
True on success, false otherwise.

Definition at line 854 of file account.cpp.

QVariant value ( const QString &  key,
const QVariant &  defaultValue = QVariant(),
SettingSource *  source = 0 
) const

Retrieves the value of an account setting, as a QVariant.

Parameters:
keyThe key whose value must be retrieved.
defaultValueValue returned if the key is unset.
sourceIndicates whether the value comes from the account, the service template or was unset.
See also:
valueAsString
valueAsInt
valueAsBool
Returns:
The value associated to key.

This method operates on the currently selected service.

Definition at line 652 of file account.cpp.

Referenced by Manager::account(), Account::credentialsId(), Account::value(), Account::valueAsBool(), Account::valueAsInt(), Account::valueAsString(), and Account::valueAsUInt64().

SettingSource value ( const QString &  key,
QVariant &  value 
) const

Retrieves the value of an account setting, as a QVariant.

Parameters:
keyThe key whose value must be retrieved.
valueA QVariant initialized to the expected type of the value.
See also:
valueAsString
valueAsInt
valueAsBool
Returns:
Whether the value comes from the account, the service template or was unset.

This method operates on the currently selected service.

Deprecated:
Use value(const QString &key, const QVariant &defaultValue, SettingSource *source) const instead.

Definition at line 686 of file account.cpp.

References Account::value().

bool valueAsBool ( const QString &  key,
bool  default_value = false,
SettingSource *  source = 0 
) const

Gets an account setting as a boolean.

Parameters:
keyThe key whose value must be retrieved.
default_valueValue returned if the key is unset.
sourceIndicates whether the value comes from the account, the service template or was unset.

This method operates on the currently selected service.

Definition at line 769 of file account.cpp.

References Account::value().

int valueAsInt ( const QString &  key,
int  default_value = 0,
SettingSource *  source = 0 
) const

Gets an account setting as an integer.

Parameters:
keyThe key whose value must be retrieved.
default_valueValue returned if the key is unset.
sourceIndicates whether the value comes from the account, the service template or was unset.

This method operates on the currently selected service.

Definition at line 729 of file account.cpp.

References Account::value().

QString valueAsString ( const QString &  key,
QString  default_value = QString::null,
SettingSource *  source = 0 
) const

Gets an account setting as a string.

Parameters:
keyThe key whose value must be retrieved.
default_valueValue returned if the key is unset.
sourceIndicates whether the value comes from the account, the service template or was unset.

This method operates on the currently selected service.

Definition at line 709 of file account.cpp.

References Account::value().

quint64 valueAsUInt64 ( const QString &  key,
quint64  default_value = 0,
SettingSource *  source = 0 
) const

Gets an account setting as an unsigned long integer.

Parameters:
keyThe key of which value must be retrieved.
default_valueValue returned if the key is unset.
sourceIndicates whether the value comes from the account, the service template or was unset.

This method operates on the currently selected service.

Definition at line 749 of file account.cpp.

References Account::value().

bool verify ( const QString &  key,
const char **  token 
)

Verifies if the key is signed and the signature matches the value and provides the aegis token which was used for signing the key.

Parameters:
keyThe name of the key or prefix of the keys to be verified.
tokenAegis token to be retrieved.
Returns:
True if the key is signed and the signature matches the value.

This method operates on the currently selected service.

Definition at line 903 of file account.cpp.

bool verifyWithTokens ( const QString &  key,
QList< const char * >  tokens 
)

Verifies if the key is signed with any of the aegis tokens and the signature is valid.

Parameters:
keyThe name of the key or prefix of the keys to be verified.
tokensArray of aegis tokens.
Returns:
True if the key is signed with any of the aegis tokens and the signature is valid.

This method operates on the currently selected service.

Definition at line 920 of file account.cpp.

Watch * watchKey ( const QString &  key = QString())

Installs a key or group watch.

Parameters:
keyThe key to watch; if NULL, watches the currently selected group.
Returns:
A watch object.

This method operates on the currently selected service.

Definition at line 798 of file account.cpp.


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