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

Public Member Functions | Static Public Member Functions
Tp::ClientRegistrar Class Reference

The ClientRegistrar class is responsible for registering Telepathy clients (Observer, Approver, Handler). More...

`#include <TelepathyQt/ClientRegistrar>`

Inherits Tp::Object.

List of all members.

## Public Member Functions

- ~ClientRegistrar ()
- QDBusConnection dbusConnection () const
- AccountFactoryConstPtr accountFactory () const
- ConnectionFactoryConstPtr connectionFactory () const
- ChannelFactoryConstPtr channelFactory () const
- ContactFactoryConstPtr contactFactory () const
- QList< AbstractClientPtr > registeredClients () const
- bool registerClient (const AbstractClientPtr &client, const QString &clientName, bool unique=false)
- bool unregisterClient (const AbstractClientPtr &client)
- void unregisterClients ()

## Static Public Member Functions

- static ClientRegistrarPtr create (const QDBusConnection &bus)
- static ClientRegistrarPtr create (const AccountFactoryConstPtr &accountFactory=AccountFactory::create(QDBusConnection::sessionBus()), const ConnectionFactoryConstPtr &connectionFactory=ConnectionFactory::create(QDBusConnection::sessionBus()), const ChannelFactoryConstPtr &channelFactory=ChannelFactory::create(QDBusConnection::sessionBus()), const ContactFactoryConstPtr &contactFactory=ContactFactory::create())
- static ClientRegistrarPtr create (const QDBusConnection &bus, const AccountFactoryConstPtr &accountFactory, const ConnectionFactoryConstPtr &connectionFactory, const ChannelFactoryConstPtr &channelFactory, const ContactFactoryConstPtr &contactFactory)
- static ClientRegistrarPtr create (const AccountManagerPtr &accountManager)

## Detailed Description

The ClientRegistrar class is responsible for registering Telepathy clients (Observer, Approver, Handler).

Clients should inherit AbstractClientObserver, AbstractClientApprover, AbstractClientHandler or some combination of these, by using multiple inheritance, and register themselves using registerClient().

See the individual classes descriptions for more details.

## Usage

### Creating a client registrar object

One way to create a ClientRegistrar object is to just call the create method. For example:

     ClientRegistrarPtr cr = ClientRegistrar::create();

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

     ClientRegistrarPtr cr = ClientRegistrar::create(QDBusConnection::systemBus());

### Registering a client

To register a client, just call registerClient() with a given AbstractClientPtr pointing to a valid AbstractClient instance.

     class MyClient : public AbstractClientObserver, public AbstractClientHandler
     {
         ...
     };

     ...

     ClientRegistrarPtr cr = ClientRegistrar::create();
     SharedPtr<MyClient> client = SharedPtr<MyClient>(new MyClient(...));
     cr->registerClient(AbstractClientPtr::dynamicCast(client), "myclient");

See also:
  AbstractClientObserver, AbstractClientApprover, AbstractClientHandler

See Asynchronous Object Model, Shared Pointer Usage

## Constructor & Destructor Documentation

Tp::ClientRegistrar::~ClientRegistrar | ( |  | ) |

Class destructor.

## Member Function Documentation

ClientRegistrarPtr Tp::ClientRegistrar::create | ( | const QDBusConnection & | bus | ) | `[static]`

Create a new client registrar object using the given bus.

The instance will use an account factory creating Tp::Account objects with no features ready, a connection factory creating Tp::Connection objects with no features ready, and a channel factory creating stock Telepathy-Qt channel subclasses, as appropriate, with no features ready.

Parameters:

  bus | QDBusConnection to use.

Returns:
  A ClientRegistrarPtr object pointing to the newly created ClientRegistrar object.

ClientRegistrarPtr Tp::ClientRegistrar::create | ( | const AccountFactoryConstPtr & | accountFactory = `AccountFactory::create(QDBusConnection::sessionBus())`,
|  | const ConnectionFactoryConstPtr & | connectionFactory = `ConnectionFactory::create(QDBusConnection::sessionBus())`,
|  | const ChannelFactoryConstPtr & | channelFactory = `ChannelFactory::create(QDBusConnection::sessionBus())`,
|  | const ContactFactoryConstPtr & | contactFactory = `ContactFactory::create()`
| ) |  | `[static]`

Create a new client registrar object using QDBusConnection::sessionBus() and the given factories.

Parameters:

  accountFactory | The account factory to use.
  connectionFactory | The connection factory to use.
  channelFactory | The channel factory to use.
  contactFactory | The contact factory to use.

Returns:
  A ClientRegistrarPtr object pointing to the newly created ClientRegistrar object.

ClientRegistrarPtr Tp::ClientRegistrar::create | ( | const QDBusConnection & | bus,
|  | const AccountFactoryConstPtr & | accountFactory,
|  | const ConnectionFactoryConstPtr & | connectionFactory,
|  | const ChannelFactoryConstPtr & | channelFactory,
|  | const ContactFactoryConstPtr & | contactFactory
| ) |  | `[static]`

Create a new client registrar object using the given bus and the given factories.

Parameters:

  bus | QDBusConnection to use.
  accountFactory | The account factory to use.
  connectionFactory | The connection factory to use.
  channelFactory | The channel factory to use.
  contactFactory | The contact factory to use.

Returns:
  A ClientRegistrarPtr object pointing to the newly created ClientRegistrar object.

ClientRegistrarPtr Tp::ClientRegistrar::create | ( | const AccountManagerPtr & | manager | ) | `[static]`

Create a new client registrar object using the bus and factories of the given Account manager.

Using this create method will enable (like any other way of passing the same factories to an AM and a registrar) getting the same Account/Connection etc. proxy instances from both AccountManager and AbstractClient implementations.

Parameters:

  manager | The AccountManager the bus and factories of which should be used.

Returns:
  A ClientRegistrarPtr object pointing to the newly ClientRegistrar object.

QDBusConnection Tp::ClientRegistrar::dbusConnection | ( |  | ) | const

Return the D-Bus connection being used by this client registrar.

Returns:
  A QDBusConnection object.

AccountFactoryConstPtr Tp::ClientRegistrar::accountFactory | ( |  | ) | const

Get the account factory used by this client registrar.

Only read access is provided. This allows constructing object instances and examining the object construction settings, but not changing settings. Allowing changes would lead to tricky situations where objects constructed at different times by the registrar would have unpredictably different construction settings (eg. subclass).

Returns:
  A read-only pointer to the AccountFactory object.

ConnectionFactoryConstPtr Tp::ClientRegistrar::connectionFactory | ( |  | ) | const

Get the connection factory used by this client registrar.

Only read access is provided. This allows constructing object instances and examining the object construction settings, but not changing settings. Allowing changes would lead to tricky situations where objects constructed at different times by the registrar would have unpredictably different construction settings (eg. subclass).

Returns:
  A read-only pointer to the ConnectionFactory object.

ChannelFactoryConstPtr Tp::ClientRegistrar::channelFactory | ( |  | ) | const

Get the channel factory used by this client registrar.

Only read access is provided. This allows constructing object instances and examining the object construction settings, but not changing settings. Allowing changes would lead to tricky situations where objects constructed at different times by the registrar would have unpredictably different construction settings (eg. subclass).

Returns:
  A read-only pointer to the ChannelFactory object.

ContactFactoryConstPtr Tp::ClientRegistrar::contactFactory | ( |  | ) | const

Get the contact factory used by this client registrar.

Only read access is provided. This allows constructing object instances and examining the object construction settings, but not changing settings. Allowing changes would lead to tricky situations where objects constructed at different times by the registrar would have unpredictably different construction settings (eg. subclass).

Returns:
  A read-only pointer to the ContactFactory object.

QList< AbstractClientPtr > Tp::ClientRegistrar::registeredClients | ( |  | ) | const

Return the list of clients registered using registerClient() on this client registrar.

Returns:
  A list of pointers to AbstractClient objects.

See also:
  registerClient(), unregisterClient()

bool Tp::ClientRegistrar::registerClient | ( | const AbstractClientPtr & | client,
|  | const QString & | clientName,
|  | bool | unique = `false`
| ) |  |

Register a client on D-Bus.

The client registrar will export the appropriate D-Bus interfaces, based on the abstract classes subclassed by

Parameters:

  client. | If each of a client instance should be able to manipulate channels separately, set unique to true.

The client name MUST be a non-empty string of ASCII digits, letters, dots and/or underscores, starting with a letter, and without sets of two consecutive dots or a dot followed by a digit.

This method will do nothing if the client is already registered, and `true` will be returned.

To unregister a client use unregisterClient().

Parameters:

  client | The client to register.
  clientName | The client name used to register.
  unique | Whether each of a client instance is able to manipulate channels separately.

Returns:
  `true` if client was successfully registered, `false` otherwise.

See also:
  registeredClients(), unregisterClient()

bool Tp::ClientRegistrar::unregisterClient | ( | const AbstractClientPtr & | client | ) |

Unregister a client registered using registerClient() on this client registrar.

If client was not registered previously, `false` will be returned.

Parameters:

  client | The client to unregister.

Returns:
  `true` if client was successfully unregistered, `false` otherwise.

See also:
  registeredClients(), registerClient()

void Tp::ClientRegistrar::unregisterClients | ( |  | ) |

Unregister all clients registered using registerClient() on this client registrar.

See also:
  registeredClients(), registerClient(), unregisterClient()