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

AccountManager Class Reference
[Account 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

Public Member Functions

Static Public Member Functions

Static Public Attributes

Protected Member Functions


Detailed Description

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

AccountManager is a high-level class representing a Telepathy account manager.

It adds the following features compared to using AccountManagerInterface directly:

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; 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 keeps 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::finish() 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

~AccountManager (  )  [virtual]

Class destructor.

AccountManager (  )  [protected]

Construct a new account manager object using QDBusConnection::sessionBus().

AccountManager ( const QDBusConnection &  bus  )  [protected]

Construct a new account manager object using the given bus.

Parameters:
bus QDBusConnection to use.


Member Function Documentation

AccountManagerPtr create (  )  [static]

Create a new account manager object using QDBusConnection::sessionBus().

Returns:
An AccountManagerPtr pointing to the newly created AccountManager.

AccountManagerPtr create ( const QDBusConnection &  bus  )  [static]

Create a new account manager object using the given bus.

Parameters:
bus QDBusConnection to use.
Returns:
An AccountManagerPtr pointing to the newly created AccountManager.

QStringList validAccountPaths (  )  const

Return a list of object paths for all valid accounts.

Returns:
A list of object paths.

QStringList invalidAccountPaths (  )  const

Return a list of object paths for all invalid accounts.

Returns:
A list of object paths.

QStringList allAccountPaths (  )  const

Return a list of object paths for all accounts.

Returns:
A list of object paths.

QList< AccountPtr > 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 > 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 > 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 accountForPath ( const QString &  path  ) 

Return an AccountPtr object for the given path.

If path is invalid the returned AccountPtr object will point to 0. AccountPtr::isNull() will return true.

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.
See also:
validAccounts(), invalidAccounts(), accountsForPaths()

QList< AccountPtr > 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 supportedAccountProperties (  )  const

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

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

PendingAccount * createAccount ( const QString &  connectionManager,
const QString &  protocol,
const QString &  displayName,
const QVariantMap &  parameters,
const QVariantMap &  properties = QVariantMap() 
)

Create an account with the given parameters.

Return a pending operation representing the Account object which will succeed when the account has been created or fail if an error occurred.

The optional properties argument can be used to set any property listed in AccountManager::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.

DBus::PropertiesInterface * propertiesInterface (  )  const [inline]

Return the properties interface proxy object for this account manager. The AccountManager interface relies on properties, so this interface is always assumed to be present.

Returns:
DBus::PropertiesInterface proxy object.

void accountCreated ( const QString &  path  )  [signal]

Signal emitted when a new account is created.

Parameters:
path The object path of the newly created account.
See also:
accountForPath()

void accountRemoved ( const QString &  path  )  [signal]

Signal emitted when an account gets removed.

Parameters:
path The object path of the removed account.
See also:
accountForPath()

void accountValidityChanged ( const QString &  path,
bool  valid 
) [signal]

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

Client::AccountManagerInterface * baseInterface (  )  const [protected]

Get the AccountManagerInterface for this AccountManager. 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 AccountManagerInterface for this AccountManager.


Member Data Documentation

const Feature 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.


Copyright © 2009 Collabora Ltd. and Nokia Corporation
Telepathy-Qt4 0.1.10