1 # -*- coding: utf-8 -*-
2 # Generated from the Telepathy spec
3 """Copyright © 2008-2009 Collabora Ltd.
4 Copyright © 2008-2009 Nokia Corporation
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with this library; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
26 class ChannelDispatchOperation(dbus.service.Object):
28 A channel dispatch operation is an object in the ChannelDispatcher
29 representing a batch of unrequested channels being announced to
34 These objects can result from new incoming channels or channels
35 which are automatically created for some reason, but cannot result
36 from outgoing requests for channels.
38 More specifically, whenever the
39 Connection.Interface.Requests.NewChannels
40 signal contains channels whose
42 property is false, or whenever the
44 signal contains a channel with suppress_handler false,
45 one or more ChannelDispatchOperation objects are created for those
48 (If some channels in a NewChannels signal are in different bundles,
49 this is an error. The channel dispatcher SHOULD recover by treating
50 the NewChannels signal as if it had been several NewChannels signals
51 each containing one channel.)
53 First, the channel dispatcher SHOULD construct a list of all the
55 that could handle all the channels (based on their HandlerChannelFilter
57 priority in some implementation-dependent way. If there are handlers
58 which could handle all the channels, one channel dispatch operation
59 SHOULD be created for all the channels. If there are not, one channel
60 dispatch operation SHOULD be created for each channel, each with
61 a list of channel handlers that could handle that channel.
63 If no handler at all can handle a channel, the channel dispatcher
64 SHOULD terminate that channel instead of creating a channel dispatcher
65 for it. It is RECOMMENDED that the channel dispatcher closes
66 the channels using Channel.Interface.Destroyable.Destroy
67 if supported, or Channel.Close
68 otherwise. As a special case, the channel dispatcher SHOULD NOT close
70 channels, and if Close fails, the channel dispatcher SHOULD ignore
74 ContactList channels are strange. We hope to replace them with
75 something better, such as an interface on the Connection, in a
76 future version of this specification.
79 When listing channel handlers, priority SHOULD be given to
80 channel handlers that are already handling channels from the same
83 If a handler with BypassApproval
84 = True could handle all of the channels in the dispatch
85 operation, then the channel dispatcher SHOULD call HandleChannels
86 on that handler, and (assuming the call succeeds) emit
87 Finished and stop processing those
88 channels without involving any approvers.
91 Some channel types can be picked up "quietly" by an existing
92 channel handler. If a Text
93 channel is added to an existing bundle containing a StreamedMedia
94 channel, there shouldn't be
95 any approvers, flashing icons or notification bubbles, if the
96 the UI for the StreamedMedia channel can just add a text box
97 and display the message.
100 Otherwise, the channel dispatcher SHOULD send the channel dispatch
101 operation to all relevant approvers (in parallel) and wait for an
102 approver to claim the channels or request that they are handled.
105 for more details on this.
107 Finally, if the approver requested it, the channel dispatcher SHOULD
108 send the channels to a handler.
111 @dbus.service.method('org.freedesktop.Telepathy.ChannelDispatchOperation', in_signature='s', out_signature='')
112 def HandleWith(self, Handler):
114 Called by an approver to accept a channel bundle and request that
115 the given handler be used to handle it.
117 If successful, this method will cause the ChannelDispatchOperation
118 object to disappear, emitting
121 However, this method may fail because the dispatch has already been
122 completed and the object has already gone. If this occurs, it
123 indicates that another approver has asked for the bundle to be
124 handled by a particular handler. The approver MUST NOT attempt
125 to interact with the channels further in this case, unless it is
126 separately invoked as the handler.
128 Approvers which are also channel handlers SHOULD use
130 of HandleWith to request that they can handle a channel bundle
133 (FIXME: list some possible errors)
135 If the channel handler raises an error from HandleChannels,
137 MAY respond by raising that same error, even if it is not
138 specifically documented here.
141 raise NotImplementedError
143 @dbus.service.method('org.freedesktop.Telepathy.ChannelDispatchOperation', in_signature='', out_signature='')
146 Called by an approver to claim channels for handling
147 internally. If this method is called successfully, the process
148 calling this method becomes the handler for the channel, but
149 does not have the HandleChannels
152 Clients that call Claim on channels but do not immediately
153 close them SHOULD implement the Handler interface and its
157 Approvers wishing to reject channels MUST call this method to
158 claim ownership of them, and MUST NOT call
160 on the channels unless/until this method returns successfully.
163 The channel dispatcher can't know how best to close arbitrary
164 channel types, so it leaves it up to the approver to do so.
165 For instance, for Text channels it is necessary
166 to acknowledge any messages that have already been displayed to
167 the user first - ideally, the approver would display and then
168 acknowledge the messages - or to call Channel.Interface.Destroyable.Destroy
169 if the destructive behaviour of that method is desired.
171 Similarly, an Approver for StreamedMedia channels can close the
172 channel with a reason (e.g. "busy") if desired. The channel
173 dispatcher, which is designed to have no specific knowledge
174 of particular channel types, can't do that.
177 If successful, this method will cause the ChannelDispatchOperation
178 object to disappear, emitting
179 Finished, in the same way as for
182 This method may fail because the dispatch operation has already
183 been completed. Again, see HandleWith for more details. The approver
184 MUST NOT attempt to interact with the channels further in this
187 (FIXME: list some other possible errors)
190 raise NotImplementedError
192 @dbus.service.signal('org.freedesktop.Telepathy.ChannelDispatchOperation', signature='oss')
193 def ChannelLost(self, Channel, Error, Message):
195 A channel has closed before it could be claimed or handled. If
196 this is emitted for the last remaining channel in a channel
197 dispatch operation, it MUST immediately be followed by
200 This signal MUST NOT be emitted until all Approvers that were
201 invoked have returned (successfully or with an error) from
202 their AddDispatchOperation
206 This means that Approvers can connect to the ChannelLost signal
207 in a race-free way. Non-approver processes that discover
208 a channel dispatch operation in some way (such as observers)
209 will have to follow the usual "connect to signals then recover
210 state" model - first connect to ChannelLost and
212 then download Channels (and
213 on error, perhaps assume that the operation has already
220 @dbus.service.signal('org.freedesktop.Telepathy.ChannelDispatchOperation', signature='')
223 Emitted when this dispatch operation finishes. The dispatch
224 operation is no longer present and further methods must not be
227 Approvers that have a user interface SHOULD stop notifying the user
228 about the channels in response to this signal; they MAY assume that
229 on errors, they would have received
232 Its object path SHOULD NOT be reused for a subsequent dispatch
233 operation; the ChannelDispatcher MUST choose object paths
234 in a way that avoids immediate re-use.
237 Otherwise, clients might accidentally call
239 Claim on a new dispatch operation
240 instead of the one they intended to handle.
243 This signal MUST NOT be emitted until all Approvers that were
244 invoked have returned (successfully or with an error) from
245 their AddDispatchOperation
249 This means that Approvers can connect to the ChannelLost signal
250 in a race-free way. Non-approver processes that discover
251 a channel dispatch operation in some way (such as observers)
252 will have to follow the usual "connect to signals then recover
253 state" model - first connect to
255 Finished, then download Channels
256 (and on error, perhaps assume that the operation has already