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

Signals | Public Member Functions | Properties | List of all members
Tp::AccountSet Class Reference
Client-side proxies » Account proxies

The AccountSet class represents a set of Telepathy accounts filtered by a given criteria. More...

`#include <TelepathyQt/AccountSet>`

Inheritance diagram for Tp::AccountSet:
[legend]

## Signals

void | accountAdded (const Tp::AccountPtr &account)
void | accountRemoved (const Tp::AccountPtr &account)
Signals inherited from Tp::Object
void | propertyChanged (const QString &propertyName)

## Public Member Functions

| AccountSet (const AccountManagerPtr &accountManager, const AccountFilterConstPtr &filter)
| AccountSet (const AccountManagerPtr &accountManager, const QVariantMap &filter)
virtual | ~AccountSet ()
AccountManagerPtr | accountManager () const
AccountFilterConstPtr | filter () const
QList< AccountPtr > | accounts () const
Public Member Functions inherited from Tp::Object
virtual | ~Object ()
Public Member Functions inherited from QObject
| QObject (QObject *parent)
virtual | ~QObject ()
virtual bool | event (QEvent *e)
virtual bool | eventFilter (QObject *watched, QEvent *event)
virtual const QMetaObject * | metaObject () const
QString | objectName () const
void | setObjectName (const QString &name)
bool | isWidgetType () const
bool | signalsBlocked () const
bool | blockSignals (bool block)
QThread * | thread () const
void | moveToThread (QThread *targetThread)
int | startTimer (int interval)
void | killTimer (int id)
T | findChild (const QString &name) const
QList< T > | findChildren (const QString &name) const
QList< T > | findChildren (const QRegExp &regExp) const
QObject * | child (const char *objName, const char *inheritsClass, bool recursiveSearch) const
const QObjectList & | children () const
void | setParent (QObject *parent)
void | installEventFilter (QObject *filterObj)
void | removeEventFilter (QObject *obj)
bool | connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const
bool | disconnect (const char *signal, const QObject *receiver, const char *method)
bool | disconnect (const QObject *receiver, const char *method)
void | dumpObjectTree ()
void | dumpObjectInfo ()
bool | setProperty (const char *name, const QVariant &value)
QVariant | property (const char *name) const
QList< QByteArray > | dynamicPropertyNames () const
void | destroyed (QObject *obj)
QObject * | parent () const
bool | inherits (const char *className) const
void | deleteLater ()
| QObject (QObject *parent, const char *name)
void | insertChild (QObject *object)
void | removeChild (QObject *object)
bool | isA (const char *className) const
const char * | className () const
const char * | name () const
const char * | name (const char *defaultName) const
void | setName (const char *name)
Public Member Functions inherited from Tp::RefCounted
| RefCounted ()
virtual | ~RefCounted ()

## Properties

AccountManagerPtr | accountManager
AccountFilterConstPtr | filter
QList< AccountPtr > | accounts
Properties inherited from QObject
| objectName

## Additional Inherited Members

Static Public Member Functions inherited from QObject
QString | tr (const char *sourceText, const char *disambiguation, int n)
QString | trUtf8 (const char *sourceText, const char *disambiguation, int n)
bool | connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
bool | connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
bool | disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
bool | disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
Protected Member Functions inherited from Tp::Object
| Object ()
void | notify (const char *propertyName)
Protected Member Functions inherited from QObject
QObject * | sender () const
int | senderSignalIndex () const
int | receivers (const char *signal) const
virtual void | timerEvent (QTimerEvent *event)
virtual void | childEvent (QChildEvent *event)
virtual void | customEvent (QEvent *event)
virtual void | connectNotify (const char *signal)
virtual void | disconnectNotify (const char *signal)
bool | checkConnectArgs (const char *signal, const QObject *object, const char *method)
Static Protected Member Functions inherited from QObject
QByteArray | normalizeSignalSlot (const char *signalSlot)

## Detailed Description

The AccountSet class represents a set of Telepathy accounts filtered by a given criteria.

AccountSet is automatically updated whenever accounts that match the given criteria are added, removed or updated.

# Usage

## Creating an AccountSet object

The easiest way to create AccountSet objects is through AccountManager. One can just use the AccountManager convenience methods such as AccountManager::validAccounts() to get a set of account objects representing valid accounts.

For example:

class MyClass : public QObject
{
QOBJECT
public:
MyClass(QObject *parent = 0);
~MyClass() { }
private Q_SLOTS:
void onAccountManagerReady(Tp::PendingOperation *);
void onValidAccountAdded(const Tp::AccountPtr &);
void onValidAccountRemoved(const Tp::AccountPtr &);
private:
AccountManagerPtr am;
AccountSetPtr validAccountsSet;
};
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;
}
validAccountsSet = am->validAccounts();
connect(validAccountsSet.data(),
SIGNAL(accountAdded(const Tp::AccountPtr &)),
SLOT(onValidAccountAdded(const Tp::AccountPtr &)));
connect(validAccountsSet.data(),
SIGNAL(accountRemoved(const Tp::AccountPtr &)),
SLOT(onValidAccountRemoved(const Tp::AccountPtr &)));
QList<AccountPtr> accounts = validAccountsSet->accounts();
// do something with accounts
}
void MyClass::onValidAccountAdded(const Tp::AccountPtr &account)
{
// do something with account
}
void MyClass::onValidAccountRemoved(const Tp::AccountPtr &account)
{
// do something with account
}

You can also define your own filter using AccountManager::filterAccounts:

void MyClass::onAccountManagerReady(Tp::PendingOperation *op)
{
...
AccountPropertyFilterPtr filter = AccountPropertyFilter::create();
filter->addProperty(QLatin1String("protocolName"), QLatin1String("jabber"));
filter->addProperty(QLatin1String("enabled"), true);
AccountSetPtr filteredAccountSet = am->filterAccounts(filter);
// connect to AccountSet::accountAdded/accountRemoved signals
QList<AccountPtr> accounts = filteredAccountSet->accounts();
// do something with accounts
....
}

Note that for AccountSet to property work with AccountCapabilityFilter objects, the feature Account::FeatureCapabilities need to be enabled in all accounts return by the AccountManager passed as param in the constructor. The easiest way to do this is to enable AccountManager feature AccountManager::FeatureFilterByCapabilities.

AccountSet can also be instantiated directly, but when doing it, the AccountManager object passed as param in the constructor must be ready for AccountSet properly work.

## Constructor & Destructor Documentation

## § AccountSet() [1/2]

Tp::AccountSet::AccountSet | ( | const AccountManagerPtr & | accountManager,
|  | const AccountFilterConstPtr & | filter
| ) |  |

Construct a new AccountSet object.

Parameters

  accountManager | An account manager object used to filter accounts. The account manager object must be ready.
  filter | The desired filter.

## § AccountSet() [2/2]

Tp::AccountSet::AccountSet | ( | const AccountManagerPtr & | accountManager,
|  | const QVariantMap & | filter
| ) |  |

Construct a new AccountSet object.

The filter must contain Account property names and values as map items.

Parameters

  accountManager | An account manager object used to filter accounts. The account manager object must be ready.
  filter | The desired filter.

## § ~AccountSet()

Tp::AccountSet::~AccountSet | ( |  | ) |

virtual

Class destructor.

## Member Function Documentation

## § accountManager()

AccountManagerPtr Tp::AccountSet::accountManager | ( |  | ) | const

## § filter()

AccountFilterConstPtr Tp::AccountSet::filter | ( |  | ) | const

## § accounts()

QList<AccountPtr> Tp::AccountSet::accounts | ( |  | ) | const

## § accountAdded

void Tp::AccountSet::accountAdded | ( | const Tp::AccountPtr & | account | ) |

signal

Emitted whenever an account that matches filter is added to this set.

Parameters

  account | The account that was added to this set.

See also
  accounts()

## § accountRemoved

void Tp::AccountSet::accountRemoved | ( | const Tp::AccountPtr & | account | ) |

signal

Emitted whenever an account that matches filter is removed from this set.

Parameters

  account | The account that was removed from this set.

See also
  accounts()

## Property Documentation

## § accountManager

AccountManagerPtr Tp::AccountSet::accountManager

read

Return the account manager object used to filter accounts.

Returns
  A pointer to the AccountManager object.

## § filter

AccountFilterConstPtr Tp::AccountSet::filter

read

Return the filter used to filter accounts.

Returns
  A read-only pointer the AccountFilter object.

## § accounts

QList< AccountPtr > Tp::AccountSet::accounts

read

Return a list of account objects that match filter.

Change notification is via the accountAdded() and accountRemoved() signals.

Returns
  A list of pointers to Account objects.

See also
  accountAdded(), accountRemoved()