Copyright © 2008-2009 Collabora Ltd. Copyright © 2008-2009 Nokia Corporation

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

(as a stable interface)

Handlers are the user interface for a channel. They turn an abstract Telepathy channel into something the user wants to see, like a text message stream or an audio and/or video call.

For its entire lifetime, each channel on a connection known to the channel dispatcher is either being processed by the channel dispatcher, or being handled by precisely one Handler.

Because each channel is only handled by one Handler, handlers may perform actions that only make sense to do once, such as acknowledging Text messages, doing the actual streaming for Call1 channels, or transferring the file in FileTransfer1 channels.

When a new incoming channel (one with Requested = FALSE) is offered to Approvers by the channel dispatcher, it also offers the Approvers a list of all the running or activatable handlers whose HandlerChannelFilter property (possibly as cached in the .client file) indicates that they are able to handle the channel. The Approvers can choose one of those channel handlers to handle the channel.

When a new outgoing channel (one with Requested = TRUE) appears, the channel dispatcher passes it to an appropriate channel handler automatically.

A specification of the channels that this channel handler can deal with.

This property works in exactly the same way as the Client.Observer.ObserverChannelFilter property. In particular, it cannot change while the handler process continues to own the corresponding Client bus name.

In the .client file, it is represented in the same way as ObserverChannelFilter, but the group has the same name as this interface and the keys start with HandlerChannelFilter instead of ObserverChannelFilter.

If true, channels destined for this handler are automatically handled, without invoking approvers.

For service-activatable handlers, this property should be specified in the handler's .client file as follows:

[im.telepathy.v1.Client.Handler]
BypassApproval=true
A DBus_Interface, followed by a slash '/' character and an identifier for a capability defined by that interface. The capability identifier SHOULD be in lower case. If an interface references an external specification which is case-insensitive (such as MIME), then names from that specification MUST be normalized to lower-case before providing them to this Telepathy API, so that implementations can safely rely on simple byte-by-byte comparison. These aren't D-Bus core Properties, and we want them to look visibly different.

So far, all client capabilities are defined by the Call1 interface.

The set of additional capabilities supported by this handler. This describes things like support for streamed media codecs and NAT traversal mechanisms: see the Contact Capabilities interface for more details.

For handlers that have a .client file, the channel dispatcher may discover this property from the im.telepathy.v1.Client.Handler.Capabilities group; for each capability, that group contains a key whose name is the capability, with value true. Keys with other values SHOULD NOT appear in this group.

For instance, the .client file for a streamed media handler that supports ICE-UDP NAT traversal, Speex audio, and Theora and H264 video might contain this group:

[im.telepathy.v1.Client.Handler.Capabilities]
im.telepathy.v1.Channel.Interface.MediaSignalling/ice-udp=true
im.telepathy.v1.Channel.Interface.MediaSignalling/audio/speex=true
im.telepathy.v1.Channel.Interface.MediaSignalling/video/theora=true
im.telepathy.v1.Channel.Interface.MediaSignalling/video/h264=true

Like the HandlerChannelFilter property, this property cannot change while the Handler owns its Client bus name. However, the .client file, if any, can change (due to upgrades or installation of pluggable codecs), and the capabilities really supported by the handler might not exactly match what is cached in the .client file.

The client file is installed statically and is intended to list codecs etc. that the handler guarantees it can support (e.g. by having a hard dependency on them), whereas the running handler process might be able to find additional codecs.

Called by the channel dispatcher when this client should handle this channel, or when this client should present a channel that it is already handling to the user (e.g. bring it into the foreground).

Clients are expected to know what channels they're already handling, and which channel object path corresponds to which window or tab. This can easily be done using a hash table keyed by channels' object paths.

This method can raise any D-Bus error. If it does, the handler is assumed to have failed or crashed, and the channel dispatcher MUST recover in an implementation-specific way; it MAY attempt to dispatch the channel to another handler, or close the channel.

If closing the channel, it is RECOMMENDED that the channel dispatcher attempts to use Channel.Close, but resorts to calling Channel.Interface.Destroyable1.Destroy (if available) or ignoring the channel (if not) if the same handler repeatedly fails to handle a channel.

After HandleChannel returns successfully, the client process is considered to be responsible for the channel until it its unique name disappears from the bus.

If a process has multiple Client bus names - some temporary and some long-lived - and drops one of the temporary bus names in order to reduce the set of channels that it will handle, any channels that it is already handling should remain unaffected.

The Account with which the channel is associated. The well-known bus name to use is that of the AccountManager. The Connection with which the channel is associated. The well-known bus name to use can be derived from this object path by removing the leading '/' and replacing all subsequent '/' by '.'.

The Channel object. Its well-known bus name is the same as that of the Connection.

Properties of the channel, equivalent to the properties in Channel_Details.

The requests satisfied by this channel.

If the handler implements Requests, this tells it that this channel matches previous AddRequest calls that it may have received.

There can be more than one, if they were EnsureChannel requests.

The time at which user action occurred, or 0 if this channel is to be handled for some reason not involving user action. Handlers SHOULD use this for focus-stealing prevention, if applicable.

Additional information about this channel. Currently defined keys are:

request-properties - a{oa{sv}}
A map from ChannelRequest paths listed in Requests_Satisfied to Qualified_Property_Value_Maps containing namespaced immutable properties of each request.

When more keys are defined for this dictionary, all will be optional; handlers MAY safely ignore any entry in this dictionary.

A list of the channels that this process is currently handling.

There is no change notification.

This property exists for state recovery - it makes it possible for channel handling to survive a ChannelDispatcher crash.

If the channel dispatcher is automatically replaced, the replacement can discover all Handlers by looking for the Client well-known bus names, and discover which channels they are currently handling. Once this has been done, all unhandled channels can be re-dispatched, and the only issue visible to the user is that unhandled channels that they have already approved might be sent back to Approvers.

The value of this property SHOULD be the same for all Client instances that share a unique bus name, and SHOULD include all channels that are being handled, even if they were conceptually handled by a different Client instance.

Otherwise, when a process released a temporary Client name, channels that it handled because of that Client name would no longer be state-recoverable.