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 <TelepathyQt4/ClientRegistrar>

Inherits Tp::Object.

List of all members.

Public Member Functions

Static Public Member Functions


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:

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-Qt4 channel subclasses, as appropriate, with no features ready.

Parameters:
busQDBusConnection 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:
accountFactoryThe account factory to use.
connectionFactoryThe connection factory to use.
channelFactoryThe channel factory to use.
contactFactoryThe 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:
busQDBusConnection to use.
accountFactoryThe account factory to use.
connectionFactoryThe connection factory to use.
channelFactoryThe channel factory to use.
contactFactoryThe 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:
managerThe 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:
clientThe client to register.
clientNameThe client name used to register.
uniqueWhether 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:
clientThe 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()


Copyright © 2008-2011 Collabora Ltd. and Nokia Corporation
Telepathy-Qt4 0.6.5