MeeGo 1.2 Harmattan Developer Documentation Develop for the Nokia N9

Accounts::Account Class Reference

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

Inheritance diagram for Accounts::Account:
Inheritance graph
[legend]

List of all members.

Signals

void  displayNameChanged (const QString &displayName)
void  enabledChanged (const QString &serviceName, bool enabled)
void  error (Accounts::ErrorCode errorCode)
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.
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.
void  setEnabled (bool)
  Enables/disables the account or selected service.
qint32  credentialsId ()
  Gets the account's credentials ID in Signon database.
void  setCredentialsId (const qint32 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.
void  selectService (const Service *service=0)
  Selects the Service for the subsequent operations.
Service selectedService () 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
  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.
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 unsigned long integer.
bool  valueAsBool (const QString &key, bool default_value=false, SettingSource *source=0) const
  Gets an account setting as a boolean.
Watch watchKey (const QString &key=NULL)
  Installs a key or group watch.
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.

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.


Constructor & Destructor Documentation

virtual Accounts::Account::~Account (  )  [virtual]

Destroys the current account object and free all resources.


Member Function Documentation

QStringList Accounts::Account::allKeys (  )  const

Returns all keys in the current group.

This method operates on the currently selected service.

void Accounts::Account::beginGroup ( const QString prefix  ) 

Enters a group.

This method never fails.

Parameters:
prefix  This method operates on the currently selected service.
QStringList Accounts::Account::childGroups (  )  const

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

This method operates on the currently selected service.

QStringList Accounts::Account::childKeys (  )  const

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

This method operates on the currently selected service.

void Accounts::Account::clear (  ) 

Removes all the keys in the currently selected service.

See also:
remove(const QString &key)
bool Accounts::Account::contains ( const QString key  )  const

Checks 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.

qint32 Accounts::Account::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.

QString Accounts::Account::displayName (  )  const

Returns the display name of the account.

This method operates on the currently selected service.

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

Checks whether the account or selected service is enabled.

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

void Accounts::Account::enabledChanged ( const QString serviceName,
bool  enabled  
) [signal]
ServiceList Accounts::Account::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.

void Accounts::Account::endGroup (  ) 

Exits a group.

This method operates on the currently selected service.

void Accounts::Account::error ( Accounts::Error  error  )  [signal]

Emitted when an error occurs.

void Accounts::Account::error ( Accounts::ErrorCode  errorCode  )  [signal]
Deprecated:
This signal is deprecated and will eventually be removed.
See also:
error(Account::Error)
QString Accounts::Account::group (  )  const

Returns the name of the current group.

This method operates on the currently selected service.

AccountId Accounts::Account::id (  )  const

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

bool Accounts::Account::isWritable (  )  const

Checks whether the account is writable.

This always returns true.

Manager* Accounts::Account::manager (  )  const

Returns the Manager.

QString Accounts::Account::providerName (  )  const

Returns the name of the provider of the account.

void Accounts::Account::remove (  ) 

Marks the account for removal.

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

void Accounts::Account::remove ( const QString key  ) 

Removes 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.

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

Returns the currently selected service.

void Accounts::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.
ServiceList Accounts::Account::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.

void Accounts::Account::setCredentialsId ( const qint32  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.

void Accounts::Account::setDisplayName ( const QString displayName  ) 

Changes the display name of the account.

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

void Accounts::Account::setEnabled ( bool   ) 

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.

void Accounts::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.

void Accounts::Account::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:
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.

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

Checks whether the account supports the given service.

void Accounts::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.

bool Accounts::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.
void Accounts::Account::synced (  )  [signal]
SettingSource Accounts::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.

bool Accounts::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.

int Accounts::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.

QString Accounts::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.

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

Gets an account setting as an unsigned long integer.

Parameters:
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.

bool Accounts::Account::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:
key  The name of the key or prefix of the keys to be verified.
token  Aegis 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.

bool Accounts::Account::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:
key  The name of the key or prefix of the keys to be verified.
tokens  Array 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.

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

Installs a key or 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.


Copyright (C) 2009-2011 Nokia Corporation.
LGPL
MeeGo 1.2 Harmattan API