Signals | Public Member Functions

Accounts::Account Class Reference

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

#include <account.h>

List of all members.

Signals

void displayNameChanged (const QString &displayName)
void enabledChanged (const QString &serviceName, bool enabled)
void error (Accounts::ErrorCode errorCode)
void synced ()
void removed ()

Public Member Functions

virtual ~Account ()
 Destroy 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=NULL) const
 Return a list of services supported by this account.
ServiceList enabledServices () const
 Return a list of enabled services supported by this account.
bool enabled () const
 Checks whether the account is enabled.
void setEnabled (bool)
 Enables/disables the account.
qint32 credentialsId ()
 Get the account's credentials id in signon DB.
void setCredentialsId (const qint32 id)
 set the accounts credentials id The change will be written only when sync() is called.
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.
void selectService (const Service *service=0)
 Selects the Service for the subsequent operations.
ServiceselectedService () const
 Returns the currently selected service.
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
 Check 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)
 Remove the given key.
void setValue (const QString &key, const QVariant &value)
 Changes the value of an account setting.
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.
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 usigned long 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=NULL)
 Install a key/group watch.
void remove ()
 Marks the account for removal.
void sign (const QString &key, const char *token)
 Creates signature of key with given token.
bool verify (const QString &key, const char **token)
 Verify if the key is signed and the signature matches the value and provides the token which was used for signing the key.
bool verifyWithTokens (const QString &key, QList< const char * > tokens)
 Verify if the key is signed with any of the tokens and the signature is valid.

Detailed Description

The Account class provides an interface to account settings.

The Account class is used to access 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 138 of file account.h.


Constructor & Destructor Documentation

Account::~Account (  )  [virtual]

Destroy current account object and free all resources.

Definition at line 120 of file account.cpp.


Member Function Documentation

QStringList Account::allKeys (  )  const

Returns all keys in the current group.

This method operates on the currently selected service.

Definition at line 260 of file account.cpp.

Referenced by childGroups(), childKeys(), main(), and remove().

void Account::beginGroup ( const QString &  prefix  ) 

Enters a group.

This method never fails.

Parameters:
prefix This method operates on the currently selected service.

Definition at line 277 of file account.cpp.

QStringList Account::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 282 of file account.cpp.

References allKeys(), and group().

QStringList Account::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 298 of file account.cpp.

References allKeys().

Referenced by contains().

void Account::clear (  ) 

Removes all the keys in the currently selected service.

See also:
remove(const QString &key)

Definition at line 311 of file account.cpp.

bool Account::contains ( const QString &  key  )  const

Check whether the given key is in the current group.

Parameters:
key The key name of the settings.

This method operates on the currently selected service.

Definition at line 321 of file account.cpp.

References childKeys().

qint32 Account::credentialsId (  ) 

Get the account's credentials id in signon DB.

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

Definition at line 629 of file account.cpp.

References Accounts::NONE, selectedService(), selectService(), and value().

QString Account::displayName (  )  const

Returns the display name of the account.

This method operates on the currently selected service.

Definition at line 220 of file account.cpp.

void Accounts::Account::displayNameChanged ( const QString &  displayName  )  [signal]
bool Account::enabled (  )  const

Checks whether the account is enabled.

Definition at line 210 of file account.cpp.

void Accounts::Account::enabledChanged ( const QString &  serviceName,
bool  enabled 
) [signal]
ServiceList Account::enabledServices (  )  const

Return 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 189 of file account.cpp.

References manager().

void Account::endGroup (  ) 

Exits a group.

This method operates on the currently selected service.

Definition at line 326 of file account.cpp.

void Accounts::Account::error ( Accounts::ErrorCode  errorCode  )  [signal]

Referenced by syncAndBlock().

QString Account::group (  )  const

Returns the name of the current group.

This method operates on the currently selected service.

Definition at line 333 of file account.cpp.

Referenced by childGroups().

AccountId Account::id (  )  const

Returns the AccountId of this account (0 if the account has not yet been stored into the database).

Definition at line 143 of file account.cpp.

bool Account::isWritable (  )  const

Checks whether the account is writable.

This always returns true.

Definition at line 340 of file account.cpp.

Manager * Account::manager (  )  const

Returns the Manager.

Definition at line 148 of file account.cpp.

Referenced by enabledServices(), selectedService(), and services().

QString Account::providerName (  )  const

Returns the name of the provider of the account.

Definition at line 231 of file account.cpp.

void Account::remove (  ) 

Marks the account for removal.

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

Definition at line 598 of file account.cpp.

void Account::remove ( const QString &  key  ) 

Remove the given key.

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

Parameters:
key The key name of the settings.

This method operates on the currently selected service.

Definition at line 345 of file account.cpp.

References allKeys().

void Accounts::Account::removed (  )  [signal]
Service * Account::selectedService (  )  const

Returns the currently selected service.

Definition at line 247 of file account.cpp.

References manager().

Referenced by credentialsId().

void Account::selectService ( const Service service = 0  ) 

Selects the Service for the subsequent operations.

Parameters:
service The Service to select. If this is NULL, the global account settings will be selected.

Definition at line 236 of file account.cpp.

Referenced by credentialsId().

ServiceList Account::services ( const QString &  serviceType = NULL  )  const

Return 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 161 of file account.cpp.

References manager().

void Accounts::Account::setCredentialsId ( const qint32  id  )  [inline]

set 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 211 of file account.h.

References ACCOUNTS_KEY_CREDENTIALS_ID.

void Account::setDisplayName ( const QString &  displayName  ) 

Changes the display name of the account.

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

Definition at line 225 of file account.cpp.

void Account::setEnabled ( bool  enabled  ) 

Enables/disables the account.

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

This method operates on the currently selected service.

Definition at line 215 of file account.cpp.

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

Changes the value of an account setting.

Parameters:
key The key name of the setting.
value The new value.

This method operates on the currently selected service.

Definition at line 365 of file account.cpp.

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

Creates signature of key with given token.

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

This method operates on the currently selected service.

Definition at line 604 of file account.cpp.

bool Account::supportsService ( const QString &  serviceType  )  const

Checks whether the account supports the given service.

Definition at line 153 of file account.cpp.

void Account::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 423 of file account.cpp.

bool Account::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 432 of file account.cpp.

References error().

void Accounts::Account::synced (  )  [signal]
SettingSource Account::value ( const QString &  key,
QVariant &  value 
) const

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

Parameters:
key The key whose value must be retrieved.
value A 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.

Definition at line 449 of file account.cpp.

References Accounts::ACCOUNT.

Referenced by credentialsId(), valueAsBool(), valueAsInt(), valueAsString(), and valueAsUInt64().

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

Gets an account setting as a boolean.

Parameters:
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 550 of file account.cpp.

References value().

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

Gets an account setting as an integer.

Parameters:
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 528 of file account.cpp.

References value().

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

Gets an account setting as a string.

Parameters:
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 517 of file account.cpp.

References value().

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

Gets an account setting as an usigned long long integer.

Parameters:
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 539 of file account.cpp.

References value().

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

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

Parameters:
key The name of the key or prefix of the keys to be verified.
token 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 609 of file account.cpp.

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

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

Parameters:
key The name of the key or prefix of the keys to be verified.
tokens Array of the tokens.
Returns:
true if the key is signed with any of the token and the signature is valid.

This method operates on the currently selected service.

Definition at line 614 of file account.cpp.

Watch * Account::watchKey ( const QString &  key = NULL  ) 

Install a key/group watch.

Parameters:
key The 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 569 of file account.cpp.


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