libaccounts-qt
1.6
|
The Account class provides an interface to account settings. More...
#include <Accounts/Account>
Inherits QObject.
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 | |
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). | |
Manager * | manager () const |
Returns the Manager. | |
bool | supportsService (const QString &serviceType) const |
Checks whether the account supports the given service. | |
ServiceList | services (const QString &serviceType=NULL) const |
Returns a list of services supported by this account. More... | |
ServiceList | enabledServices () const |
Returns a list of enabled services supported by this account. More... | |
bool | enabled () const |
Checks whether the account or selected service is enabled. More... | |
void | setEnabled (bool) |
Enables/disables the account or selected service. More... | |
uint | credentialsId () |
Gets the account's credentials ID in Signon database. More... | |
void | setCredentialsId (const uint id) |
Sets the accounts credentials ID. More... | |
QString | displayName () const |
Returns the display name of the account. More... | |
void | setDisplayName (const QString &displayName) |
Changes the display name of the account. More... | |
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. More... | |
Service | selectedService () const |
QStringList | allKeys () const |
Returns all keys in the current group. More... | |
void | beginGroup (const QString &prefix) |
Enters a group. More... | |
QStringList | childGroups () const |
Returns all the groups which are direct children of the current group. More... | |
QStringList | childKeys () const |
Return all the keys which are direct children of the current group. More... | |
void | clear () |
Removes all the keys in the currently selected service. More... | |
bool | contains (const QString &key) const |
Checks whether the given key is in the current group. More... | |
void | endGroup () |
Exits a group. More... | |
QString | group () const |
Returns the name of the current group. More... | |
bool | isWritable () const |
Checks whether the account is writable. More... | |
void | remove (const QString &key) |
Removes the given key. More... | |
void | setValue (const QString &key, const QVariant &value) |
Changes the value of an account setting. More... | |
QVariant | value (const QString &key, const QVariant &defaultValue=QVariant(), SettingSource *source=0) const |
Retrieves the value of an account setting, as a QVariant. More... | |
SettingSource | value (const QString &key, QVariant &value) const |
Retrieves the value of an account setting, as a QVariant. More... | |
QString | valueAsString (const QString &key, QString default_value=QString::null, SettingSource *source=0) const |
Gets an account setting as a string. More... | |
int | valueAsInt (const QString &key, int default_value=0, SettingSource *source=0) const |
Gets an account setting as an integer. More... | |
quint64 | valueAsUInt64 (const QString &key, quint64 default_value=0, SettingSource *source=0) const |
Gets an account setting as an unsigned long integer. More... | |
bool | valueAsBool (const QString &key, bool default_value=false, SettingSource *source=0) const |
Gets an account setting as a boolean. More... | |
Watch * | watchKey (const QString &key=NULL) |
Installs a key or group watch. More... | |
void | sync () |
Stores all account settings into the database. More... | |
bool | syncAndBlock () |
Blocking version of the sync() method: execution of the current thread will block until the operation has completed. More... | |
void | remove () |
Marks the account for removal. More... | |
void | sign (const QString &key, const char *token) |
Creates signature of key with given aegis token. More... | |
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. More... | |
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. More... | |
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).
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
will disable the "myService" service.
All changes made on an account (including deletion) are not stored until sync() is called.
QStringList allKeys | ( | ) | const |
Returns all keys in the current group.
This method operates on the currently selected service.
Definition at line 377 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.
prefix | This method operates on the currently selected service. |
Definition at line 400 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 410 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 431 of file account.cpp.
References Account::allKeys().
Referenced by Account::contains().
void clear | ( | ) |
Removes all the keys in the currently selected service.
Definition at line 448 of file account.cpp.
bool contains | ( | const QString & | key | ) | const |
Checks whether the given key is in the current group.
key | The key name of the settings. |
This method operates on the currently selected service.
Definition at line 464 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 865 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 316 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.
Definition at line 294 of file account.cpp.
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 269 of file account.cpp.
void endGroup | ( | ) |
Exits a group.
This method operates on the currently selected service.
Definition at line 474 of file account.cpp.
QString group | ( | ) | const |
Returns the name of the current group.
This method operates on the currently selected service.
Definition at line 486 of file account.cpp.
Referenced by Account::childGroups().
bool isWritable | ( | ) | const |
Checks whether the account is writable.
This always returns true.
Definition at line 496 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.
key | The key name of the settings. |
This method operates on the currently selected service.
Definition at line 508 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 803 of file account.cpp.
Service selectedService | ( | ) | const |
Definition at line 366 of file account.cpp.
Referenced by Account::credentialsId().
Select the Service for the subsequent operations.
service | The Service to select. If this is invalid, the global account settings will be selected. |
Definition at line 352 of file account.cpp.
References Service::isValid().
Referenced by Account::credentialsId().
ServiceList services | ( | const QString & | serviceType = NULL | ) | 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 240 of file account.cpp.
|
inline |
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 325 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 306 of file account.cpp.
void setValue | ( | const QString & | key, |
const QVariant & | value | ||
) |
Changes the value of an account setting.
key | The key name of the setting. |
value | The new value. |
This method operates on the currently selected service.
Definition at line 535 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.
key | The key or the prefix of set of the keys to be signed. |
token | The aegis token to be used for signing the key. |
This method operates on the currently selected service.
Definition at line 817 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 769 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.
Definition at line 784 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.
key | The key whose value must be retrieved. |
defaultValue | Value returned if the key is unset. |
source | Indicates whether the value comes from the account, the service template or was unset. |
This method operates on the currently selected service.
Definition at line 582 of file account.cpp.
Referenced by 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.
key | The key whose value must be retrieved. |
value | A QVariant initialized to the expected type of the value. |
This method operates on the currently selected service.
Definition at line 616 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.
key | The key whose value must be retrieved. |
default_value | Value returned if the key is unset. |
source | Indicates whether the value comes from the account, the service template or was unset. |
This method operates on the currently selected service.
Definition at line 699 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.
key | The key whose value must be retrieved. |
default_value | Value returned if the key is unset. |
source | Indicates whether the value comes from the account, the service template or was unset. |
This method operates on the currently selected service.
Definition at line 659 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.
key | The key whose value must be retrieved. |
default_value | Value returned if the key is unset. |
source | Indicates whether the value comes from the account, the service template or was unset. |
This method operates on the currently selected service.
Definition at line 639 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.
key | The key of which value must be retrieved. |
default_value | Value returned if the key is unset. |
source | Indicates whether the value comes from the account, the service template or was unset. |
This method operates on the currently selected service.
Definition at line 679 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.
key | The name of the key or prefix of the keys to be verified. |
token | Aegis token to be retrieved. |
This method operates on the currently selected service.
Definition at line 833 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.
key | The name of the key or prefix of the keys to be verified. |
tokens | Array of aegis tokens. |
This method operates on the currently selected service.
Definition at line 850 of file account.cpp.
Watch * watchKey | ( | const QString & | key = NULL | ) |
Installs a key or group watch.
key | The key to watch; if NULL, watches the currently selected group. |
This method operates on the currently selected service.
Definition at line 728 of file account.cpp.