| Home · All Classes · All Namespaces · Modules · Functions · Files

# Tp::AccountManager Class Reference
[Account manager proxies]

The AccountManager class provides an object representing a Telepathy account manager. More...

`#include <TelepathyQt4/AccountManager>`

Inherits Tp::StatelessDBusProxy, OptionalInterfaceFactory< AccountManager >, Tp::ReadyObject, and Tp::RefCounted.

List of all members.

## Signals

- void accountCreated (const QString &path)
- void accountRemoved (const QString &path)
- void accountValidityChanged (const QString &path, bool valid)

## Public Member Functions

- virtual ~AccountManager ()
- QStringList validAccountPaths () const
- QStringList invalidAccountPaths () const
- QStringList allAccountPaths () const
- QList< AccountPtr > validAccounts ()
- QList< AccountPtr > invalidAccounts ()
- QList< AccountPtr > allAccounts ()
- AccountPtr accountForPath (const QString &path)
- QList< AccountPtr > accountsForPaths (const QStringList &paths)
- QStringList supportedAccountProperties () const
- PendingAccount * createAccount (const QString &connectionManager, const QString &protocol, const QString &displayName, const QVariantMap &parameters, const QVariantMap &properties=QVariantMap())
- Client::DBus::PropertiesInterface * propertiesInterface () const

## Static Public Member Functions

- static AccountManagerPtr create ()
- static AccountManagerPtr create (const QDBusConnection &bus)

## Static Public Attributes

- static const Feature FeatureCore

## Protected Member Functions

- AccountManager ()
- AccountManager (const QDBusConnection &bus)
- Client::AccountManagerInterface * baseInterface () const

## Detailed Description

The AccountManager class provides an object representing a Telepathy account manager.

AccountManager adds the following features compared to using Client::AccountManagerInterface directly:

- Account status tracking
- Getting the list of supported interfaces automatically
- Cache Account objects when they are requested the first time

The remote object accessor functions on this object (allAccountPaths(), allAccounts(), and so on) don't make any D-Bus calls; instead, they return/use values cached from a previous introspection run. The introspection process populates their values in the most efficient way possible based on what the service implements. Their return value is mostly undefined until the introspection process is completed, i.e. isReady() returns true. See the individual accessor descriptions for more details.

Signals are emitted to indicate that accounts are added/removed and when accounts validity changes. See accountCreated(), accountRemoved(), accountValidityChanged().

## Usage

### Creating an account manager object

One way to create an AccountManager object is to just call the create method. For example:

     AccountManagerPtr am = AccountManager::create();

An AccountManagerPtr object is returned, which will automatically keep track of object lifetime.

You can also provide a D-Bus connection as a QDBusConnection:

     AccountManagerPtr am = AccountManager::create(QDBusConnection::sessionBus());

### Making account manager ready to use

An AccountManager object needs to become ready before usage, meaning that the introspection process finished and the object accessors can be used.

To make the object ready, use becomeReady() and wait for the PendingOperation::finished() signal to be emitted.

     class MyClass : public QObject
     {
         QOBJECT

     public:
         MyClass(QObject *parent = 0);
         ~MyClass() { }

     private Q_SLOTS:
         void onAccountManagerReady(Tp::PendingOperation*);

     private:
         AccountManagerPtr am;
     };

     MyClass::MyClass(QObject *parent)
         : QObject(parent)
           am(AccountManager::create())
     {
         connect(am->becomeReady(),
                 SIGNAL(finished(Tp::PendingOperation*)),
                 SLOT(onAccountManagerReady(Tp::PendingOperation*)));
     }

     void MyClass::onAccountManagerReady(Tp::PendingOperation *op)
     {
         if (op->isError()) {
             qWarning() << "Account manager cannot become ready:" <<
                 op->errorName() << "-" << op->errorMessage();
             return;
         }

         // AccountManager is now ready
         qDebug() << "Valid accounts:";
         foreach (const QString &path, am->validAccountPaths()) {
             qDebug() << " path:" << path;
         }
     }

See Asynchronous Object Model, Shared Pointer Usage

## Constructor & Destructor Documentation

Tp::AccountManager::~AccountManager | ( |  | ) | `[virtual]`

Class destructor.

Tp::AccountManager::AccountManager | ( |  | ) | `[protected]`

Construct a new AccountManager object using QDBusConnection::sessionBus().

Tp::AccountManager::AccountManager | ( | const QDBusConnection & | bus | ) | `[protected]`

Construct a new AccountManager object using the given bus.

Parameters:

  | bus | QDBusConnection to use.

## Member Function Documentation

AccountManagerPtr Tp::AccountManager::create | ( |  | ) | `[static]`

Create a new AccountManager object using QDBusConnection::sessionBus().

Returns:
  An AccountManagerPtr object pointing to the newly created AccountManager object.

AccountManagerPtr Tp::AccountManager::create | ( | const QDBusConnection & | bus | ) | `[static]`

Create a new AccountManager object using the given bus.

Parameters:

  | bus | QDBusConnection to use.

Returns:
  An AccountManagerPtr object pointing to the newly created AccountManager object.

QStringList Tp::AccountManager::validAccountPaths | ( |  | ) | const

Return a list of object paths for all valid accounts.

Returns:
  A list of object paths.

QStringList Tp::AccountManager::invalidAccountPaths | ( |  | ) | const

Return a list of object paths for all invalid accounts.

Returns:
  A list of object paths.

QStringList Tp::AccountManager::allAccountPaths | ( |  | ) | const

Return a list of object paths for all accounts.

Returns:
  A list of object paths.

QList< AccountPtr > Tp::AccountManager::validAccounts | ( |  | ) |

Return a list of AccountPtr objects for all valid accounts.

Remember to call Account::becomeReady on the new accounts, to make sure they are ready before using them.

Returns:
  A list of AccountPtr objects.

See also:
  invalidAccounts(), allAccounts(), accountsForPaths()

QList< AccountPtr > Tp::AccountManager::invalidAccounts | ( |  | ) |

Return a list of AccountPtr objects for all invalid accounts.

Remember to call Account::becomeReady on the new accounts, to make sure they are ready before using them.

Returns:
  A list of AccountPtr objects.

See also:
  validAccounts(), allAccounts(), accountsForPaths()

QList< AccountPtr > Tp::AccountManager::allAccounts | ( |  | ) |

Return a list of AccountPtr objects for all accounts.

Remember to call Account::becomeReady on the new accounts, to make sure they are ready before using them.

Returns:
  A list of AccountPtr objects.

See also:
  validAccounts(), invalidAccounts(), accountsForPaths()

AccountPtr Tp::AccountManager::accountForPath | ( | const QString & | path | ) |

Return an AccountPtr object for the given path.

Remember to call Account::becomeReady on the new account, to make sure it is ready before using it.

Parameters:

  | path | The account object path.

Returns:
  An AccountPtr object pointing to the Account object for the given path, or a null AccountPtr if path is invalid.

See also:
  validAccounts(), invalidAccounts(), accountsForPaths()

QList< AccountPtr > Tp::AccountManager::accountsForPaths | ( | const QStringList & | paths | ) |

Return a list of AccountPtr objects for the given paths.

The returned list will have one AccountPtr object for each given path. If a given path is invalid the returned AccountPtr object will point to 0. AccountPtr::isNull() will return true.

Remember to call Account::becomeReady on the new accounts, to make sure they are ready before using them.

Parameters:

  | paths | List of accounts object paths.

Returns:
  A list of AccountPtr objects.

See also:
  validAccounts(), invalidAccounts(), allAccounts(), accountForPath()

QStringList Tp::AccountManager::supportedAccountProperties | ( |  | ) | const

Return a list of the fully qualified names of properties that can be set when calling createAccount().

Returns:
  A list of fully qualified D-Bus property names, such as "org.freedesktop.Telepathy.Account.Enabled"

See also:
  createAccount()

PendingAccount * Tp::AccountManager::createAccount | ( | const QString & | connectionManager,
|  | const QString & | protocol,
|  | const QString & | displayName,
|  | const QVariantMap & | parameters,
|  | const QVariantMap & | properties = `QVariantMap()` |
| ) |  |  |

Create an account with the given parameters.

The optional properties argument can be used to set any property listed in supportedAccountProperties() at the time the account is created.

Parameters:

  | connectionManager | Name of the connection manager to create the account for.
  | protocol | Name of the protocol to create the account for.
  | displayName | The account display name.
  | parameters | The account parameters.
  | properties | An optional map from fully qualified D-Bus property names such as "org.freedesktop.Telepathy.Account.Enabled" to their values.

Returns:
  A PendingAccount object which will emit PendingAccount::finished when the account has been created of failed its creation process.

See also:
  supportedAccountProperties()

Client::DBus::PropertiesInterface * Tp::AccountManager::propertiesInterface | ( |  | ) | const`[inline]`

Convenience function for getting a PropertiesInterface interface proxy object for this account manager. The AccountManager interface relies on properties, so this interface is always assumed to be present.

Returns:
  A pointer to the existing Client::DBus::PropertiesInterface object for this AccountManager object.

void Tp::AccountManager::accountCreated | ( | const QString & | path | ) | `[signal]`

This signal is emitted when a new account is created.

Parameters:

  | path | The object path of the newly created account.

See also:
  accountForPath()

void Tp::AccountManager::accountRemoved | ( | const QString & | path | ) | `[signal]`

This signal is emitted when an account gets removed.

Parameters:

  | path | The object path of the removed account.

See also:
  accountForPath()

void Tp::AccountManager::accountValidityChanged | ( | const QString & | path,
|  | bool | valid |
| ) |  |  | `[signal]`

This signal is emitted when an account validity changes.

Parameters:

  | path | The object path of the account in which the validity changed.
  | valid | Whether the account is valid or not.

See also:
  accountForPath()

Client::AccountManagerInterface * Tp::AccountManager::baseInterface | ( |  | ) | const`[protected]`

Return the Client::AccountManagerInterface interface proxy object for this account manager. This method is protected since the convenience methods provided by this class should generally be used instead of calling D-Bus methods directly.

Returns:
  A pointer to the existing Client::AccountManagerInterface object for this AccountManager object.

## Member Data Documentation

const Feature Tp::AccountManager::FeatureCore`[static]`

Feature representing the core that needs to become ready to make the AccountManager object usable.

Note that this feature must be enabled in order to use any AccountManager method.

When calling isReady(), becomeReady(), this feature is implicitly added to the requested features.