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.
Observers monitor the creation of new channels. This functionality can be used for things like message logging. All observers are notified simultaneously.
Observers SHOULD NOT modify the state of a channel except via user interaction.
We want Observer UIs for file transfer channels (a progress bar for the transfer) to be able to have a Cancel button.
Observers MUST NOT carry out actions that exactly one process must take responsibility for (e.g. acknowledging Text messages, or carrying out the actual transfer in a file transfer channel).
Since arbitrarily many observers can be activated for
each channel, it would not make sense for observers to do things
that can only be done by one process (acknowledging
Handlers MAY, of course, delegate responsibility for these tasks to other processes (including those run as observers), but this MUST be done explicitly via a request from the Handler to the Observer.
Whenever a collection of new channels is signalled, the channel
dispatcher will notify all running or activatable observers whose
Observers are activated for all channels in which they have
registered an interest - incoming, outgoing or automatically created -
although of course the ObserverChannelFilter property can be set
to filter on the
Because it might take time for an observer to become ready (for
instance, a Text logger needs to wait until pending messages have been
downloaded), the channel dispatcher must wait (up to some timeout) for
all observers to return from
Non-interactive approvers (for instance, to shoot down spam IM channels before the tray icon blinks at the user, or to grab a SASL channel before the user is prompted for a password) can be implemented as observers by following these steps:
Non-interactive approvers implemented as observers SHOULD
also set
A specification of the channels in which this observer is
interested. The
Only certain D-Bus types have useful semantics for matching like this, so only certain types are allowed:
This property never changes while the observer process owns its Client bus name. For activatable processes, the filter can change due to an upgrade - the channel dispatcher SHOULD observe changes to .client files using a mechanism like inotify.
Not allowing this property to change is a simplification, particularly for activatable processes (we reject the possibility that a process with a .client file, when activated, has a filter that differs from what its .client file said).
If an Observer wants to add extra channels to its list of interests at runtime, it can register an additional Client bus name (for instance, the org.freedesktop.Telepathy.Client.Empathy process with unique name :1.42 could additionally register org.freedesktop.Telepathy.Client.Empathy._1_42) with additional filters. To remove those filters, it can release the bus name; it could even re-claim the bus name immediately, with different filters.
The same principle is applied to Approvers and Handlers.
For observers that have a .client file, the channel dispatcher
may discover this property from keys of the form
"propertyname type
",
in groups in the .client file whose name is the name of this
interface followed by .ObserverChannelFilter
,
a space and an ASCII decimal number starting from 0.
Values in the .client file are encoded in exactly the same way as
the default-p
keys in .manager files, as
described in the
For instance, a .client file for an observer that is only interested in Text channels, with CONTACT or ROOM handles, that were requested by a local client:
[org.freedesktop.Telepathy.Client] Interfaces=org.freedesktop.Telepathy.Client.Observer; [org.freedesktop.Telepathy.Client.Observer.ObserverChannelFilter 0] org.freedesktop.Telepathy.Channel.ChannelType s=org.freedesktop.Telepathy.Channel.Type.Text org.freedesktop.Telepathy.Channel.TargetHandleType u=1 org.freedesktop.Telepathy.Channel.Requested b=true [org.freedesktop.Telepathy.Client.Observer.ObserverChannelFilter 1] org.freedesktop.Telepathy.Channel.ChannelType s=org.freedesktop.Telepathy.Channel.Type.Text org.freedesktop.Telepathy.Channel.TargetHandleType u=2 org.freedesktop.Telepathy.Channel.Requested b=true
If true, upon the startup of this observer,
When an activatable client having this property disappears from the bus and there are channels matching its ObserverChannelFilter, ObserveChannels will be called immediately to reactivate it again. Such clients should specify this property in their .client file as follows:
[org.freedesktop.Telepathy.Client.Observer] Recover=true
This means that if an activatable Observer crashes, it will
be restarted as soon as possible; while there is an unavoidable
possibility that it will miss some events during this process
(particularly
Non-activatable observers can't take advantage of this mechanism, but setting this property on a non-activatable observer does allow it to "catch up" on channels that are currently active at the time that it starts up.
When the ObserveChannels method is called due to observer recovery,
the Observer_Info dictionary will contain one extra item
mapping the key "recovering"
to True
.
Called by the channel dispatcher when channels in which the
observer has registered an interest are announced in a
If the same NewChannels signal announces some channels that match the filter, and some that do not, then only a subset of the channels (those that do match the filter) are passed to this method.
If the channel dispatcher will split up the channels from a single NewChannels signal and dispatch them separately (for instance because no installed Handler can handle all of them), it will call ObserveChannels several times.
The observer MUST NOT return from this method call until it is ready for a handler for the channel to run (which may change the channel's state).
The channel dispatcher must wait for observers to start up,
to avoid the following race: text channel logger (observer) gets
ObserveChannels, text channel handler gets
The channel dispatcher SHOULD NOT change its behaviour based on whether this method succeeds or fails: there are no defined D-Bus errors for this method, and if it fails, this only indicates that an Observer is somehow broken.
The expected error response in the channel dispatcher is to log a warning, and otherwise continue as though this method had succeeded.
The path to the
If the Observer calls
This allows an Observer to
Additional information about these channels. Currently defined keys are:
recovering
- bTrue
if ObserveChannels was called for an existing
channel (due to the True
); False
or omitted
otherwise.
request-properties
- a{oa{sv}}All defined keys for this dictionary are optional; observers MAY safely ignore any entry in this dictionary.
If true, the channel dispatcher will wait for
This property SHOULD be false unless there is a reason
why a channel should not be given to approvers. An example
of this is if an Observer is also a Handler and wants to
Observers and Approvers should be called at the same time in normal operation (with this property set to false) to improve responsiveness. For example, if an incoming call appears, the approver should get the channel as fast as possible to show a dialog, but if an approver has to make round-trips to set itself up, then the approval of the channel is delayed. As a result, it is recommended for this property to remain false unless absolutely necessary.
For service-activatable clients, this property should be specified in the observer's .client file as follows:
If this property is not implemented (telepathy-mission-control 5.7.5 and older), the channel dispatcher SHOULD consider it as being false.
[org.freedesktop.Telepathy.Client.Observer] DelayApprovers=true