accounts-qt
1.2
|
Account settings for a specific service. More...
#include <Accounts/AccountService>
Signals | |
void | enabled (bool isEnabled) |
Emitted when the enabledness state of the account service has changed. | |
void | changed () |
Emitted when some setting has changed on the account service. |
Public Member Functions | |
AccountService (Account *account, const Service &service) | |
Constructor. | |
virtual | ~AccountService () |
Destructor. | |
Account * | account () const |
Return the Account. | |
Service | service () const |
Return the Service. | |
bool | enabled () const |
Check whether the account service is enabled. | |
QStringList | allKeys () const |
Return all the keys in the current group. | |
void | beginGroup (const QString &prefix) |
Enter a group. | |
QStringList | childGroups () const |
Return 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 () |
Remove all the keys. | |
bool | contains (const QString &key) const |
Check whether the given key is in the current group. | |
void | endGroup () |
Exit a group. | |
QString | group () const |
Return the name of the current group. | |
void | remove (const QString &key) |
Remove the given key. | |
void | setValue (const char *key, const QVariant &value) |
void | setValue (const QString &key, const QVariant &value) |
Change the value of an account setting. | |
QVariant | value (const QString &key, SettingSource *source=0) const |
Retrieves the value of an account setting. | |
QVariant | value (const char *key, SettingSource *source=0) const |
QStringList | changedFields () const |
This method should be called only in the context of a handler of the AccountService::changed() signal, and can be used to retrieve the set of changes. | |
AuthData | authData () const |
Read the authentication data stored in the account (merging the service-specific settings with the global account settings). |
Account settings for a specific service.
The AccountService class provides access to the account settings for a specific service type. It is meant to be easier to use than the Account class because it hides the complexity of the account structure and gives access to only the limited subset of account settings which are relevant to a service.
To get an AccountService one can use the Manager methods accountServices() or enabledAccountServices(), which both return a QList of account services. Note that if the Manager was instantiated for a specific service type, these lists will contain only those account services matching that service type. The AccountService can also be instantiated with its AccountService(Account *account, Service *service) constructor: this is useful if one already has an Account instance.
This is intended to be a convenient wrapper over the accounts settings specific for a service; as such, it doesn't offer all the editing possibilities offered by the Account class, such as enabling the service itself: these operations should ideally not be performed by consumer applications, but by the account editing UI only.
Example code:
Definition at line 39 of file account-service.h.
|
explicit |
Constructor.
Definition at line 177 of file account-service.cpp.
Account * account | ( | ) | const |
Return the Account.
Do not delete this object explicitly.
Definition at line 193 of file account-service.cpp.
AuthData authData | ( | ) | const |
Read the authentication data stored in the account (merging the service-specific settings with the global account settings).
The method and mechanism are read from the "auth/method" and "auth/mechanism" keys, respectively. The authentication parameters are found under the "auth/<method>/<mechanism>/" group.
Definition at line 468 of file account-service.cpp.
void beginGroup | ( | const QString & | prefix | ) |
Enter a group.
This method never fails.
prefix |
Definition at line 247 of file account-service.cpp.
|
signal |
Emitted when some setting has changed on the account service.
You can use the changedFields() method to retrieve the list of the settings which have changed.
QStringList changedFields | ( | ) | const |
This method should be called only in the context of a handler of the AccountService::changed() signal, and can be used to retrieve the set of changes.
Definition at line 438 of file account-service.cpp.
void clear | ( | ) |
Remove all the keys.
Definition at line 292 of file account-service.cpp.
bool contains | ( | const QString & | key | ) | const |
Check whether the given key is in the current group.
key | The key name of the setting. |
Definition at line 307 of file account-service.cpp.
References AccountService::childKeys().
void remove | ( | const QString & | key | ) |
Remove the given key.
If the key is the empty string, all keys in the current group are removed.
key | The key name of the setting. |
Definition at line 339 of file account-service.cpp.
References AccountService::allKeys().
Service service | ( | ) | const |
Return the Service.
Do not delete this object explicitly.
Definition at line 205 of file account-service.cpp.
void setValue | ( | const QString & | key, |
const QVariant & | value | ||
) |
Change the value of an account setting.
key | The name of the setting. |
value | The new value of the setting. |
Definition at line 367 of file account-service.cpp.
QVariant value | ( | const QString & | key, |
SettingSource * | source = 0 |
||
) | const |
Retrieves the value of an account setting.
key | The key whose value must be retrieved |
source | Indicates whether the value comes from the account, the service template or was unset. |
Returns the value of the setting, or an invalid QVariant if unset.
Definition at line 398 of file account-service.cpp.