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

Public Member Functions | Protected Member Functions
Tp::DBusProxyFactory Class Reference
Utililty classes

The DBusProxyFactory class is a base class for all D-Bus proxy factory classes. Handles proxy caching and making them ready as appropriate. More...

`#include <TelepathyQt/DBusProxyFactory>`

Inherits Tp::RefCounted.

Inherited by Tp::ChannelFactory, and Tp::FixedFeatureFactory.

List of all members.

## Public Member Functions

- virtual ~DBusProxyFactory ()
- const QDBusConnection & dbusConnection () const

## Protected Member Functions

- DBusProxyFactory (const QDBusConnection &bus)
- DBusProxyPtr cachedProxy (const QString &busName, const QString &objectPath) const
- PendingReady * nowHaveProxy (const DBusProxyPtr &proxy) const
- virtual QString finalBusNameFrom (const QString &uniqueOrWellKnown) const =0
- virtual PendingOperation * initialPrepare (const DBusProxyPtr &proxy) const
- virtual PendingOperation * readyPrepare (const DBusProxyPtr &proxy) const
- virtual Features featuresFor (const DBusProxyPtr &proxy) const =0

## Detailed Description

The DBusProxyFactory class is a base class for all D-Bus proxy factory classes. Handles proxy caching and making them ready as appropriate.

## Constructor & Destructor Documentation

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

Class destructor.

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

Construct a new DBusProxyFactory object.

The intention for storing the bus here is that it generally doesn't make sense to construct proxies for multiple buses in the same context. Allowing that would lead to more complex keying needs in the cache, as well.

Parameters:

  bus | The D-Bus bus connection for the objects constructed using this factory.

## Member Function Documentation

const QDBusConnection & Tp::DBusProxyFactory::dbusConnection | ( |  | ) | const

Return the D-Bus connection all of the proxies from this factory communicate with.

Returns:
  A QDBusConnection object.

DBusProxyPtr Tp::DBusProxyFactory::cachedProxy | ( | const QString & | busName,
|  | const QString & | objectPath
| ) |  | const`[protected]`

Return a cached proxy with the given busName and objectPath.

If a proxy has not been previously put into the cache by nowHaveProxy for those identifying attributes, or a previously cached proxy has since been invalidated and/or destroyed, a `Null` shared pointer is returned instead.

Parameters:

  busName | Bus name of the proxy to return.
  objectPath | Object path of the proxy to return.

Returns:
  A pointer to the DBusProxy object, if any.

PendingReady * Tp::DBusProxyFactory::nowHaveProxy | ( | const DBusProxyPtr & | proxy | ) | const`[protected]`

Should be called by subclasses when they have a proxy, be it a newly-constructed one or one from the cache.

This function will then do the rest of the factory work, including caching the proxy if it's not cached already, doing any initialPrepare()/readyPrepare() work if appropriate, and making the features from featuresFor() ready if they aren't already.

The returned PendingReady only finishes when the initialPrepare() and readyPrepare() operations for the proxy has completed, and the requested features have all been made ready (or found unable to be made ready). Note that this might have happened already before calling this function, if the proxy was not a newly created one, but was looked up from the cache. DBusProxyFactory handles the necessary subleties for this to work.

Access to the proxy instance is allowed as soon as this method returns through PendingReady::proxy(), if the proxy is needed in a context where it's not required to be ready.

Parameters:

  proxy | The proxy which the factory should now make sure is prepared and made ready.

Returns:
  A PendingReady operation which will emit PendingReady::finished when the proxy is usable.

QString Tp::DBusProxyFactory::finalBusNameFrom | ( | const QString & | uniqueOrWellKnown | ) | const`[protected, pure virtual]`

"Normalize" a bus name according to the rules for the proxy class to construct.

Should be implemented by subclasses to transform the application-specified name uniqueOrWellKnown to whatever the proxy constructed for that name would have in its DBusProxy::busName() in the end.

For StatelessDBusProxy sub-classes this should mostly be an identity transform, while for StatefulDBusProxy sub-classes StatefulDBusProxy::uniqueNameFrom() or an equivalent thereof should be used in most cases.

If this is not implemented correctly, caching won't work properly.

Parameters:

  uniqueOrWellKnown | Any valid D-Bus service name, either unique or well-known.

Returns:
  Whatever that name would turn to, when a proxy is constructed for it.

Implemented in Tp::ChannelFactory, Tp::AccountFactory, and Tp::ConnectionFactory.

PendingOperation * Tp::DBusProxyFactory::initialPrepare | ( | const DBusProxyPtr & | proxy | ) | const`[protected, virtual]`

Allows subclasses to do arbitrary manipulation on the proxy before it is attempted to be made ready.

If a non-`NULL` operation is returned, the completion of that operation is waited for before starting to make the object ready whenever nowHaveProxy() is called the first time around for a given proxy.

Todo:
  FIXME actually implement this... :) Currently just a vtable placeholder.

Parameters:

  proxy | The just-constructed proxy to be prepared.

Returns:
  `NULL` ie. nothing to do.

PendingOperation * Tp::DBusProxyFactory::readyPrepare | ( | const DBusProxyPtr & | proxy | ) | const`[protected, virtual]`

Allows subclasses to do arbitrary manipulation on the proxy after it has been made ready.

If a non-`NULL` operation is returned, the completion of that operation is waited for before signaling that the object is ready for use after ReadyObject::becomeReady() for it has finished whenever nowHaveProxy() is called the first time around for a given proxy.

Todo:
  FIXME actually implement this... :) Currently just a vtable placeholder.

Parameters:

  proxy | The just-readified proxy to be prepared.

Returns:
  `NULL` ie. nothing to do.

Features Tp::DBusProxyFactory::featuresFor | ( | const DBusProxyPtr & | proxy | ) | const`[protected, pure virtual]`

Return the features which should be made ready on a given proxy.

This can be used to implement instance-specific features based on arbitrary criteria. FixedFeatureFactory implements this as a fixed set of features independent of the instance, however.

It should be noted that if an empty set of features is returned, ReadyObject::becomeReady() is not called at all. In other words, any "core feature" is not automatically added to the requested features. This is to enable setting a factory to not make proxies ready at all, which is useful eg. in the case of account editing UIs which aren't interested in the state of Connection objects for the Account objects they're editing.

Parameters:

  proxy | The proxy on which the returned features will be made ready.

Returns:
  A list of Feature objects.

Implemented in Tp::ChannelFactory, and Tp::FixedFeatureFactory.