Debian Codegraph @

tx_xmpp/itx_xmpp.py

raw
1 # -*- test-case-name: tx_xmpp.test.test.test_itx_xmpp -*-
2 #
3 # Copyright (c) Ralph Meijer.
4 # See LICENSE for details.
5
6 """
7 Wokkel interfaces.
8 """
9
10 from zope.interface import Interface
11
12
13 class IDisco(Interface):
14 """
15 Interface for XMPP service discovery.
16 """
17
18 def getDiscoInfo(requestor, target, nodeIdentifier=""):
19 """
20 Get identity and features from this entity, node.
21
22 @param requestor: The entity the request originated from.
23 @type requestor: L{JID<twisted.words.protocols.jabber.jid.JID>}
24 @param target: The target entity to which the request is made.
25 @type target: L{JID<twisted.words.protocols.jabber.jid.JID>}
26 @param nodeIdentifier: The optional identifier of the node at this
27 entity to retrieve the identify and features of. The default is
28 C{''}, meaning the root node.
29 @type nodeIdentifier: L{str}
30 """
31
32 def getDiscoItems(requestor, target, nodeIdentifier=""):
33 """
34 Get contained items for this entity, node.
35
36 @param requestor: The entity the request originated from.
37 @type requestor: L{JID<twisted.words.protocols.jabber.jid.JID>}
38 @param target: The target entity to which the request is made.
39 @type target: L{JID<twisted.words.protocols.jabber.jid.JID>}
40 @param nodeIdentifier: The optional identifier of the node at this
41 entity to retrieve the identify and features of.
42 The default is C{''}, meaning the root node.
43 @type nodeIdentifier: L{str}
44 """
45
46
47 class IPubSubClient(Interface):
48
49 def itemsReceived(event):
50 """
51 Called when an items notification has been received for a node.
52
53 An item can be an element named C{item} or C{retract}. Respectively,
54 they signal an item being published or retracted, optionally
55 accompanied with an item identifier in the C{id} attribute.
56
57 @param event: The items event.
58 @type event: L{ItemsEvent<tx_xmpp.pubsub.ItemsEvent>}
59 """
60
61 def deleteReceived(event):
62 """
63 Called when a deletion notification has been received for a node.
64
65 @param event: The items event.
66 @type event: L{ItemsEvent<tx_xmpp.pubsub.DeleteEvent>}
67 """
68
69 def purgeReceived(event):
70 """
71 Called when a purge notification has been received for a node.
72
73 Upon receiving this notification all items associated should be
74 considered retracted.
75
76 @param event: The items event.
77 @type event: L{ItemsEvent<tx_xmpp.pubsub.PurgeEvent>}
78 """
79
80 def createNode(service, nodeIdentifier=None):
81 """
82 Create a new publish subscribe node.
83
84 @param service: The publish-subscribe service entity.
85 @type service: L{JID<twisted.words.protocols.jabber.jid.JID>}
86 @param nodeIdentifier: Optional suggestion for the new node's
87 identifier. If omitted, the creation of an
88 instant node will be attempted.
89 @type nodeIdentifier: L{str}
90 @return: a deferred that fires with the identifier of the newly created
91 node. Note that this can differ from the suggested identifier
92 if the publish subscribe service chooses to modify or ignore
93 the suggested identifier.
94 @rtype: L{Deferred<twisted.internet.defer.Deferred>}
95 """
96
97 def deleteNode(service, nodeIdentifier):
98 """
99 Delete a node.
100
101 @param service: The publish-subscribe service entity.
102 @type service: L{JID<twisted.words.protocols.jabber.jid.JID>}
103 @param nodeIdentifier: Identifier of the node to be deleted.
104 @type nodeIdentifier: L{str}
105 @rtype: L{Deferred<twisted.internet.defer.Deferred>}
106 """
107
108 def subscribe(service, nodeIdentifier, subscriber):
109 """
110 Subscribe to a node with a given JID.
111
112 @param service: The publish-subscribe service entity.
113 @type service: L{JID<twisted.words.protocols.jabber.jid.JID>}
114 @param nodeIdentifier: Identifier of the node to subscribe to.
115 @type nodeIdentifier: L{str}
116 @param subscriber: JID to subscribe to the node.
117 @type subscriber: L{JID<twisted.words.protocols.jabber.jid.JID>}
118 @rtype: L{Deferred<twisted.internet.defer.Deferred>}
119 """
120
121 def unsubscribe(service, nodeIdentifier, subscriber):
122 """
123 Unsubscribe from a node with a given JID.
124
125 @param service: The publish-subscribe service entity.
126 @type service: L{JID<twisted.words.protocols.jabber.jid.JID>}
127 @param nodeIdentifier: Identifier of the node to unsubscribe from.
128 @type nodeIdentifier: L{str}
129 @param subscriber: JID to unsubscribe from the node.
130 @type subscriber: L{JID<twisted.words.protocols.jabber.jid.JID>}
131 @rtype: L{Deferred<twisted.internet.defer.Deferred>}
132 """
133
134 def publish(service, nodeIdentifier, items=[]):
135 """
136 Publish to a node.
137
138 Node that the C{items} parameter is optional, because so-called
139 transient, notification-only nodes do not use items and publish
140 actions only signify a change in some resource.
141
142 @param service: The publish-subscribe service entity.
143 @type service: L{JID<twisted.words.protocols.jabber.jid.JID>}
144 @param nodeIdentifier: Identifier of the node to publish to.
145 @type nodeIdentifier: L{str}
146 @param items: List of item elements.
147 @type items: L{list} of L{Item}
148 @rtype: L{Deferred<twisted.internet.defer.Deferred>}
149 """
150
151
152 class IPubSubService(Interface):
153 """
154 Interface for an XMPP Publish Subscribe Service.
155
156 All methods that are called as the result of an XMPP request are to
157 return a deferred that fires when the requested action has been performed.
158 Alternatively, exceptions maybe raised directly or by calling C{errback}
159 on the returned deferred.
160 """
161
162 def notifyPublish(service, nodeIdentifier, notifications):
163 """
164 Send out notifications for a publish event.
165
166 @param service: The entity the notifications will originate from.
167 @type service: L{JID<twisted.words.protocols.jabber.jid.JID>}
168 @param nodeIdentifier: The identifier of the node that was published
169 to.
170 @type nodeIdentifier: L{str}
171 @param notifications: The notifications as tuples of subscriber, the
172 list of subscriptions and the list of items to be notified.
173 @type notifications: L{list} of
174 (L{JID<twisted.words.protocols.jabber.jid.JID>}, L{list} of
175 L{Subscription<tx_xmpp.pubsub.Subscription>}, L{list} of
176 L{Element<twisted.words.xish.domish.Element>})
177 """
178
179 def notifyRetract(service, nodeIdentifier, notifications):
180 """
181 Send out items retraction notifications.
182
183 @param service: The entity the notifications will originate from.
184 @type service: L{JID<twisted.words.protocols.jabber.jid.JID>}
185 @param nodeIdentifier: The identifier of the node that was retracted
186 from.
187 @type nodeIdentifier: C{unicode}
188 @param notifications: The notifications as tuples of subscriber, the
189 list of subscriptions and the list of items to be notified.
190 @type notifications: C{list} of
191 (L{JID<twisted.words.protocols.jabber.jid.JID>}, C{list} of
192 L{Subscription<tx_xmpp.pubsub.Subscription>}, C{list} of
193 L{Element<twisted.words.xish.domish.Element>})
194 """
195
196 def notifyDelete(service, nodeIdentifier, subscribers, redirectURI=None):
197 """
198 Send out node deletion notifications.
199
200 @param service: The entity the notifications will originate from.
201 @type service: L{JID<twisted.words.protocols.jabber.jid.JID>}
202 @param nodeIdentifier: The identifier of the node that was deleted.
203 @type nodeIdentifier: L{str}
204 @param subscribers: The subscribers for which a notification should be
205 sent out.
206 @type subscribers: L{list} of
207 L{JID<twisted.words.protocols.jabber.jid.JID>}
208 @param redirectURI: Optional XMPP URI of another node that subscribers
209 are redirected to.
210 @type redirectURI: L{str}
211 """
212
213 def publish(requestor, service, nodeIdentifier, items):
214 """
215 Called when a publish request has been received.
216
217 @param requestor: The entity the request originated from.
218 @type requestor: L{JID<twisted.words.protocols.jabber.jid.JID>}
219 @param service: The entity the request was addressed to.
220 @type service: L{JID<twisted.words.protocols.jabber.jid.JID>}
221 @param nodeIdentifier: The identifier of the node to publish to.
222 @type nodeIdentifier: L{str}
223 @param items: The items to be published as elements.
224 @type items: L{list} of C{Element<twisted.words.xish.domish.Element>}
225 @return: deferred that fires on success.
226 @rtype: L{Deferred<twisted.internet.defer.Deferred>}
227 """
228
229 def subscribe(requestor, service, nodeIdentifier, subscriber):
230 """
231 Called when a subscribe request has been received.
232
233 @param requestor: The entity the request originated from.
234 @type requestor: L{JID<twisted.words.protocols.jabber.jid.JID>}
235 @param service: The entity the request was addressed to.
236 @type service: L{JID<twisted.words.protocols.jabber.jid.JID>}
237 @param nodeIdentifier: The identifier of the node to subscribe to.
238 @type nodeIdentifier: L{str}
239 @param subscriber: The entity to be subscribed.
240 @type subscriber: L{JID<twisted.words.protocols.jabber.jid.JID>}
241 @return: A deferred that fires with a
242 L{Subscription<tx_xmpp.pubsub.Subscription>}.
243 @rtype: L{Deferred<twisted.internet.defer.Deferred>}
244 """
245
246 def unsubscribe(requestor, service, nodeIdentifier, subscriber):
247 """
248 Called when a subscribe request has been received.
249
250 @param requestor: The entity the request originated from.
251 @type requestor: L{JID<twisted.words.protocols.jabber.jid.JID>}
252 @param service: The entity the request was addressed to.
253 @type service: L{JID<twisted.words.protocols.jabber.jid.JID>}
254 @param nodeIdentifier: The identifier of the node to unsubscribe from.
255 @type nodeIdentifier: L{str}
256 @param subscriber: The entity to be unsubscribed.
257 @type subscriber: L{JID<twisted.words.protocols.jabber.jid.JID>}
258 @return: A deferred that fires with C{None} when unsubscription has
259 succeeded.
260 @rtype: L{Deferred<twisted.internet.defer.Deferred>}
261 """
262
263 def subscriptions(requestor, service):
264 """
265 Called when a subscriptions retrieval request has been received.
266
267 @param requestor: The entity the request originated from.
268 @type requestor: L{JID<twisted.words.protocols.jabber.jid.JID>}
269 @param service: The entity the request was addressed to.
270 @type service: L{JID<twisted.words.protocols.jabber.jid.JID>}
271 @return: A deferred that fires with a L{list} of subscriptions as
272 L{Subscription<tx_xmpp.pubsub.Subscription>}.
273 @rtype: L{Deferred<twisted.internet.defer.Deferred>}
274 """
275
276 def affiliations(requestor, service):
277 """
278 Called when a affiliations retrieval request has been received.
279
280 @param requestor: The entity the request originated from.
281 @type requestor: L{JID<twisted.words.protocols.jabber.jid.JID>}
282 @param service: The entity the request was addressed to.
283 @type service: L{JID<twisted.words.protocols.jabber.jid.JID>}
284 @return: A deferred that fires with a L{list} of affiliations as
285 C{tuple}s of (node identifier as L{str}, affiliation state as
286 L{str}). The affiliation can be C{'owner'}, C{'publisher'}, or
287 C{'outcast'}.
288 @rtype: L{Deferred<twisted.internet.defer.Deferred>}
289 """
290
291 def create(requestor, service, nodeIdentifier):
292 """
293 Called when a node creation request has been received.
294
295 @param requestor: The entity the request originated from.
296 @type requestor: L{JID<twisted.words.protocols.jabber.jid.JID>}
297 @param service: The entity the request was addressed to.
298 @type service: L{JID<twisted.words.protocols.jabber.jid.JID>}
299 @param nodeIdentifier: The suggestion for the identifier of the node
300 to be created. If the request did not include a suggestion for the
301 node identifier, the value is C{None}.
302 @type nodeIdentifier: L{str} or C{NoneType}
303 @return: A deferred that fires with a L{str} that represents
304 the identifier of the new node.
305 @rtype: L{Deferred<twisted.internet.defer.Deferred>}
306 """
307
308 def getConfigurationOptions():
309 """
310 Retrieve all known node configuration options.
311
312 The returned dictionary holds the possible node configuration options
313 by option name. The value of each entry represents the specifics for
314 that option in a dictionary:
315
316 - C{'type'} (L{str}): The option's type (see
317 L{Field<tx_xmpp.data_form.Field>}'s doc string for possible values).
318 - C{'label'} (L{str}): A human readable label for this option.
319 - C{'options'} (L{dict}): Optional list of possible values for this
320 option.
321
322 Example::
323
324 {
325 "pubsub#persist_items":
326 {"type": "boolean",
327 "label": "Persist items to storage"},
328 "pubsub#deliver_payloads":
329 {"type": "boolean",
330 "label": "Deliver payloads with event notifications"},
331 "pubsub#send_last_published_item":
332 {"type": "list-single",
333 "label": "When to send the last published item",
334 "options": {
335 "never": "Never",
336 "on_sub": "When a new subscription is processed"}
337 }
338 }
339
340 @rtype: L{dict}.
341 """
342
343 def getDefaultConfiguration(requestor, service, nodeType):
344 """
345 Called when a default node configuration request has been received.
346
347 @param requestor: The entity the request originated from.
348 @type requestor: L{JID<twisted.words.protocols.jabber.jid.JID>}
349 @param service: The entity the request was addressed to.
350 @type service: L{JID<twisted.words.protocols.jabber.jid.JID>}
351 @param nodeType: The type of node for which the configuration is
352 retrieved, C{'leaf'} or C{'collection'}.
353 @type nodeType: L{str}
354 @return: A deferred that fires with a L{dict} representing the default
355 node configuration. Keys are L{str}s that represent the
356 field name. Values can be of types L{str}, L{int} or
357 L{bool}.
358 @rtype: L{Deferred<twisted.internet.defer.Deferred>}
359 """
360
361 def getConfiguration(requestor, service, nodeIdentifier):
362 """
363 Called when a node configuration retrieval request has been received.
364
365 @param requestor: The entity the request originated from.
366 @type requestor: L{JID<twisted.words.protocols.jabber.jid.JID>}
367 @param service: The entity the request was addressed to.
368 @type service: L{JID<twisted.words.protocols.jabber.jid.JID>}
369 @param nodeIdentifier: The identifier of the node to retrieve the
370 configuration from.
371 @type nodeIdentifier: L{str}
372 @return: A deferred that fires with a L{dict} representing the node
373 configuration. Keys are L{str}s that represent the field name.
374 Values can be of types L{str}, L{int} or L{bool}.
375 @rtype: L{Deferred<twisted.internet.defer.Deferred>}
376 """
377
378 def setConfiguration(requestor, service, nodeIdentifier, options):
379 """
380 Called when a node configuration change request has been received.
381
382 @param requestor: The entity the request originated from.
383 @type requestor: L{JID<twisted.words.protocols.jabber.jid.JID>}
384 @param service: The entity the request was addressed to.
385 @type service: L{JID<twisted.words.protocols.jabber.jid.JID>}
386 @param nodeIdentifier: The identifier of the node to change the
387 configuration of.
388 @type nodeIdentifier: L{str}
389 @return: A deferred that fires with C{None} when the node's
390 configuration has been changed.
391 @rtype: L{Deferred<twisted.internet.defer.Deferred>}
392 """
393
394 def items(requestor, service, nodeIdentifier, maxItems, itemIdentifiers):
395 """
396 Called when a items retrieval request has been received.
397
398 @param requestor: The entity the request originated from.
399 @type requestor: L{JID<twisted.words.protocols.jabber.jid.JID>}
400 @param service: The entity the request was addressed to.
401 @type service: L{JID<twisted.words.protocols.jabber.jid.JID>}
402 @param nodeIdentifier: The identifier of the node to retrieve items
403 from.
404 @type nodeIdentifier: L{str}
405 """
406
407 def retract(requestor, service, nodeIdentifier, itemIdentifiers):
408 """
409 Called when a item retraction request has been received.
410
411 @param requestor: The entity the request originated from.
412 @type requestor: L{JID<twisted.words.protocols.jabber.jid.JID>}
413 @param service: The entity the request was addressed to.
414 @type service: L{JID<twisted.words.protocols.jabber.jid.JID>}
415 @param nodeIdentifier: The identifier of the node to retract items
416 from.
417 @type nodeIdentifier: L{str}
418 """
419
420 def purge(requestor, service, nodeIdentifier):
421 """
422 Called when a node purge request has been received.
423
424 @param requestor: The entity the request originated from.
425 @type requestor: L{JID<twisted.words.protocols.jabber.jid.JID>}
426 @param service: The entity the request was addressed to.
427 @type service: L{JID<twisted.words.protocols.jabber.jid.JID>}
428 @param nodeIdentifier: The identifier of the node to be purged.
429 @type nodeIdentifier: L{str}
430 """
431
432 def delete(requestor, service, nodeIdentifier):
433 """
434 Called when a node deletion request has been received.
435
436 @param requestor: The entity the request originated from.
437 @type requestor: L{JID<twisted.words.protocols.jabber.jid.JID>}
438 @param service: The entity the request was addressed to.
439 @type service: L{JID<twisted.words.protocols.jabber.jid.JID>}
440 @param nodeIdentifier: The identifier of the node to be delete.
441 @type nodeIdentifier: L{str}
442 """
443
444
445 class IPubSubResource(Interface):
446
447 def locateResource(request):
448 """
449 Locate a resource that will handle the request.
450
451 @param request: The publish-subscribe request.
452 @type request: L{tx_xmpp.pubsub.PubSubRequest}
453 """
454
455 def getInfo(requestor, service, nodeIdentifier):
456 """
457 Get node type and meta data.
458
459 @param requestor: The entity the request originated from.
460 @type requestor: L{JID<twisted.words.protocols.jabber.jid.JID>}
461 @param service: The publish-subscribe service entity.
462 @type service: L{JID<twisted.words.protocols.jabber.jid.JID>}
463 @param nodeIdentifier: Identifier of the node to request the info for.
464 @type nodeIdentifier: L{str}
465 @return: A deferred that fires with a dictionary. If not empty,
466 it must have the keys C{'type'} and C{'meta-data'} to keep
467 respectively the node type and a dictionary with the meta
468 data for that node.
469 @rtype: L{Deferred<twisted.internet.defer.Deferred>}
470 """
471
472 def getNodes(requestor, service, nodeIdentifier):
473 """
474 Get all nodes contained by this node.
475
476 @param requestor: The entity the request originated from.
477 @type requestor: L{JID<twisted.words.protocols.jabber.jid.JID>}
478 @param service: The publish-subscribe service entity.
479 @type service: L{JID<twisted.words.protocols.jabber.jid.JID>}
480 @param nodeIdentifier: Identifier of the node to request the childs
481 for.
482 @type nodeIdentifier: L{str}
483 @return: A deferred that fires with a list of child node identifiers.
484 @rtype: L{Deferred<twisted.internet.defer.Deferred>}
485 """
486
487 def getConfigurationOptions():
488 """
489 Retrieve all known node configuration options.
490
491 The returned dictionary holds the possible node configuration options
492 by option name. The value of each entry represents the specifics for
493 that option in a dictionary:
494
495 - C{'type'} (L{str}): The option's type (see
496 L{Field<tx_xmpp.data_form.Field>}'s doc string for possible values).
497 - C{'label'} (L{str}): A human readable label for this option.
498 - C{'options'} (L{dict}): Optional list of possible values for this
499 option.
500
501 Example::
502
503 {
504 "pubsub#persist_items":
505 {"type": "boolean",
506 "label": "Persist items to storage"},
507 "pubsub#deliver_payloads":
508 {"type": "boolean",
509 "label": "Deliver payloads with event notifications"},
510 "pubsub#send_last_published_item":
511 {"type": "list-single",
512 "label": "When to send the last published item",
513 "options": {
514 "never": "Never",
515 "on_sub": "When a new subscription is processed"}
516 }
517 }
518
519 @rtype: L{dict}.
520 """
521
522 def publish(request):
523 """
524 Called when a publish request has been received.
525
526 @param request: The publish-subscribe request.
527 @type request: L{tx_xmpp.pubsub.PubSubRequest}
528 @return: deferred that fires on success.
529 @rtype: L{Deferred<twisted.internet.defer.Deferred>}
530 """
531
532 def subscribe(request):
533 """
534 Called when a subscribe request has been received.
535
536 @param request: The publish-subscribe request.
537 @type request: L{tx_xmpp.pubsub.PubSubRequest}
538 @return: A deferred that fires with a
539 L{Subscription<tx_xmpp.pubsub.Subscription>}.
540 @rtype: L{Deferred<twisted.internet.defer.Deferred>}
541 """
542
543 def unsubscribe(request):
544 """
545 Called when a subscribe request has been received.
546
547 @param request: The publish-subscribe request.
548 @type request: L{tx_xmpp.pubsub.PubSubRequest}
549 @return: A deferred that fires with C{None} when unsubscription has
550 succeeded.
551 @rtype: L{Deferred<twisted.internet.defer.Deferred>}
552 """
553
554 def subscriptions(request):
555 """
556 Called when a subscriptions retrieval request has been received.
557
558 @param request: The publish-subscribe request.
559 @type request: L{tx_xmpp.pubsub.PubSubRequest}
560 @return: A deferred that fires with a L{list} of subscriptions as
561 L{Subscription<tx_xmpp.pubsub.Subscription>}.
562 @rtype: L{Deferred<twisted.internet.defer.Deferred>}
563 """
564
565 def affiliations(request):
566 """
567 Called when a affiliations retrieval request has been received.
568
569 @param request: The publish-subscribe request.
570 @type request: L{tx_xmpp.pubsub.PubSubRequest}
571 @return: A deferred that fires with a L{list} of affiliations as
572 C{tuple}s of (node identifier as L{str}, affiliation state as
573 L{str}). The affiliation can be C{'owner'}, C{'publisher'}, or
574 C{'outcast'}.
575 @rtype: L{Deferred<twisted.internet.defer.Deferred>}
576 """
577
578 def create(request):
579 """
580 Called when a node creation request has been received.
581
582 @param request: The publish-subscribe request.
583 @type request: L{tx_xmpp.pubsub.PubSubRequest}
584 @return: A deferred that fires with a L{str} that represents
585 the identifier of the new node.
586 @rtype: L{Deferred<twisted.internet.defer.Deferred>}
587 """
588
589 def default(request):
590 """
591 Called when a default node configuration request has been received.
592
593 @param request: The publish-subscribe request.
594 @type request: L{tx_xmpp.pubsub.PubSubRequest}
595 @return: A deferred that fires with a L{dict} representing the default
596 node configuration. Keys are L{str}s that represent the
597 field name. Values can be of types L{str}, L{int} or
598 L{bool}.
599 @rtype: L{Deferred<twisted.internet.defer.Deferred>}
600 """
601
602 def configureGet(request):
603 """
604 Called when a node configuration retrieval request has been received.
605
606 @param request: The publish-subscribe request.
607 @type request: L{tx_xmpp.pubsub.PubSubRequest}
608 @return: A deferred that fires with a L{dict} representing the node
609 configuration. Keys are L{str}s that represent the field name.
610 Values can be of types L{str}, L{int} or L{bool}.
611 @rtype: L{Deferred<twisted.internet.defer.Deferred>}
612 """
613
614 def configureSet(request):
615 """
616 Called when a node configuration change request has been received.
617
618 @param request: The publish-subscribe request.
619 @type request: L{tx_xmpp.pubsub.PubSubRequest}
620 @return: A deferred that fires with C{None} when the node's
621 configuration has been changed.
622 @rtype: L{Deferred<twisted.internet.defer.Deferred>}
623 """
624
625 def items(request):
626 """
627 Called when a items retrieval request has been received.
628
629 @param request: The publish-subscribe request.
630 @type request: L{tx_xmpp.pubsub.PubSubRequest}
631 @return: A deferred that fires with:
632 - A L{list} of L{pubsub.Item} (L{domish.Element}) for basic implementations.
633 - A C{tuple} of (L{list} of items, L{tx_xmpp.rsm.RSMResponse}) when using
634 RSM (Result Set Management) support.
635 @rtype: L{Deferred<twisted.internet.defer.Deferred>}
636 """
637
638 def retract(request):
639 """
640 Called when a item retraction request has been received.
641
642 @param request: The publish-subscribe request.
643 @type request: L{tx_xmpp.pubsub.PubSubRequest}
644 @return: A deferred that fires with C{None} when the given items have
645 been retracted.
646 @rtype: L{Deferred<twisted.internet.defer.Deferred>}
647 """
648
649 def purge(request):
650 """
651 Called when a node purge request has been received.
652
653 @param request: The publish-subscribe request.
654 @type request: L{tx_xmpp.pubsub.PubSubRequest}
655 @return: A deferred that fires with C{None} when the node has been
656 purged.
657 @rtype: L{Deferred<twisted.internet.defer.Deferred>}
658 """
659
660 def delete(request):
661 """
662 Called when a node deletion request has been received.
663
664 @param request: The publish-subscribe request.
665 @type request: L{tx_xmpp.pubsub.PubSubRequest}
666 @return: A deferred that fires with C{None} when the node has been
667 deleted.
668 @rtype: L{Deferred<twisted.internet.defer.Deferred>}
669 """
670
671 def affiliationsGet(request):
672 """
673 Called when an owner affiliations retrieval request been received.
674
675 @param request: The publish-subscribe request.
676 @type request: L{tx_xmpp.pubsub.PubSubRequest}
677 @return: A deferred that fires with a L{dict} of affiliations with the
678 entity as key (L{JID<twisted.words.protocols.jabber.jid.JID>}) and
679 the affiliation state as value (L{str}). The affiliation can
680 be C{u'owner'}, C{u'publisher'}, or C{u'outcast'}.
681 @rtype: L{Deferred<twisted.internet.defer.Deferred>}
682
683 @note: Affiliations are always on the bare JID. An implementation of
684 this method MUST NOT return JIDs with a resource part.
685 """
686
687 def affiliationsSet(request):
688 """
689 Called when a affiliations modify request has been received.
690
691 @param request: The publish-subscribe request.
692 @type request: L{tx_xmpp.pubsub.PubSubRequest}
693
694 @return: A deferred that fires with C{None} when the affiliation
695 changes were succesfully processed..
696 @rtype: L{Deferred<twisted.internet.defer.Deferred>}
697
698 @note: Affiliations are always on the bare JID. The JIDs in
699 L{tx_xmpp.pubsub.PubSubRequest}'s C{affiliations} attribute are
700 already stripped of any resource.
701 """
702
703
704 class IMUCClient(Interface):
705 """
706 Multi-User Chat Client.
707
708 A client interface to XEP-045 : http://xmpp.org/extensions/xep-0045.html
709 """
710
711 def receivedSubject(room, user, subject):
712 """
713 The room subject has been received.
714
715 A subject is received when you join a room and when the subject is
716 changed.
717
718 @param room: The room the subject was accepted for.
719 @type room: L{muc.Room}
720
721 @param user: The user that set the subject.
722 @type user: L{muc.User}
723
724 @param subject: The subject of the given room.
725 @type subject: L{str}
726 """
727
728 def receivedHistory(room, user, message):
729 """
730 Past messages from a chat room have been received.
731
732 This occurs when you join a room.
733 """
734
735 def configure(roomJID, options):
736 """
737 Configure a room.
738
739 @param roomJID: The room to configure.
740 @type roomJID: L{JID<twisted.words.protocols.jabber.jid.JID>}
741
742 @param options: A mapping of field names to values, or C{None} to
743 cancel.
744 @type options: L{dict}
745 """
746
747 def getConfiguration(roomJID):
748 """
749 Grab the configuration from the room.
750
751 This sends an iq request to the room.
752
753 @param roomJID: The bare JID of the room.
754 @type roomJID: L{JID<twisted.words.protocols.jabber.jid.JID>}
755
756 @return: A deferred that fires with the room's configuration form as
757 a L{data_form.Form} or C{None} if there are no configuration
758 options available.
759 """
760
761 def join(roomJID, nick, historyOptions=None, password=None):
762 """
763 Join a MUC room by sending presence to it.
764
765 @param roomJID: The JID of the room the entity is joining.
766 @type roomJID: L{JID<twisted.words.protocols.jabber.jid.JID>}
767
768 @param nick: The nick name for the entitity joining the room.
769 @type nick: L{str}
770
771 @param historyOptions: Options for conversation history sent by the
772 room upon joining.
773 @type historyOptions: L{HistoryOptions}
774
775 @param password: Optional password for the room.
776 @type password: L{str}
777
778 @return: A deferred that fires when the entity is in the room or an
779 error has occurred.
780 """
781
782 def nick(roomJID, nick):
783 """
784 Change an entity's nick name in a MUC room.
785
786 See: http://xmpp.org/extensions/xep-0045.html#changenick
787
788 @param roomJID: The JID of the room, i.e. without a resource.
789 @type roomJID: L{JID<twisted.words.protocols.jabber.jid.JID>}
790
791 @param nick: The new nick name within the room.
792 @type nick: L{str}
793 """
794
795 def leave(roomJID):
796 """
797 Leave a MUC room.
798
799 See: http://xmpp.org/extensions/xep-0045.html#exit
800
801 @param roomJID: The Room JID of the room to leave.
802 @type roomJID: L{JID<twisted.words.protocols.jabber.jid.JID>}
803 """
804
805 def userJoinedRoom(room, user):
806 """
807 User has joined a MUC room.
808
809 This method will need to be modified inorder for clients to
810 do something when this event occurs.
811
812 @param room: The room the user joined.
813 @type room: L{muc.Room}
814
815 @param user: The user that joined the room.
816 @type user: L{muc.User}
817 """
818
819 def groupChat(roomJID, body):
820 """
821 Send a groupchat message.
822 """
823
824 def chat(occupantJID, body):
825 """
826 Send a private chat message to a user in a MUC room.
827
828 See: http://xmpp.org/extensions/xep-0045.html#privatemessage
829
830 @param occupantJID: The Room JID of the other user.
831 @type occupantJID: L{JID<twisted.words.protocols.jabber.jid.JID>}
832 """
833
834 def register(roomJID, options):
835 """
836 Send a request to register for a room.
837
838 @param roomJID: The bare JID of the room.
839 @type roomJID: L{JID<twisted.words.protocols.jabber.jid.JID>}
840
841 @param options: A mapping of field names to values, or C{None} to
842 cancel.
843 @type options: L{dict}
844 """
845
846 def subject(roomJID, subject):
847 """
848 Change the subject of a MUC room.
849
850 See: http://xmpp.org/extensions/xep-0045.html#subject-mod
851
852 @param roomJID: The bare JID of the room.
853 @type roomJID: L{JID<twisted.words.protocols.jabber.jid.JID>}
854
855 @param subject: The subject you want to set.
856 @type subject: L{str}
857 """
858
859 def voice(roomJID):
860 """
861 Request voice for a moderated room.
862
863 @param roomJID: The room jabber/xmpp entity id.
864 @type roomJID: L{JID<twisted.words.protocols.jabber.jid.JID>}
865 """
866
867 def history(roomJID, messages):
868 """
869 Send history to create a MUC based on a one on one chat.
870
871 See: http://xmpp.org/extensions/xep-0045.html#continue
872
873 @param roomJID: The room jabber/xmpp entity id.
874 @type roomJID: L{JID<twisted.words.protocols.jabber.jid.JID>}
875
876 @param messages: The history to send to the room as an ordered list of
877 message, represented by a dictionary with the keys C{'stanza'},
878 holding the original stanza a
879 L{Element<twisted.words.xish.domish.Element>}, and C{'timestamp'}
880 with the timestamp.
881 @type messages: L{list} of
882 L{Element<twisted.words.xish.domish.Element>}
883 """
884
885 def ban(roomJID, entity, reason=None, sender=None):
886 """
887 Ban a user from a MUC room.
888
889 @param roomJID: The bare JID of the room.
890 @type roomJID: L{JID<twisted.words.protocols.jabber.jid.JID>}
891
892 @param entity: The bare JID of the entity to be banned.
893 @type entity: L{JID<twisted.words.protocols.jabber.jid.JID>}
894
895 @param reason: The reason for banning the entity.
896 @type reason: L{str}
897
898 @param sender: The entity sending the request.
899 @type sender: L{JID<twisted.words.protocols.jabber.jid.JID>}
900 """
901
902 def kick(roomJID, nick, reason=None, sender=None):
903 """
904 Kick a user from a MUC room.
905
906 @param roomJID: The bare JID of the room.
907 @type roomJID: L{JID<twisted.words.protocols.jabber.jid.JID>}
908
909 @param nick: The occupant to be banned.
910 @type nick: L{JID<twisted.words.protocols.jabber.jid.JID>} or
911 L{str}
912
913 @param reason: The reason given for the kick.
914 @type reason: L{str}
915
916 @param sender: The entity sending the request.
917 @type sender: L{JID<twisted.words.protocols.jabber.jid.JID>}
918 """
919
920
921 class IMUCStatuses(Interface):
922 """
923 Interface for a container of Multi-User Chat status conditions.
924 """
925
926 def __contains__(key):
927 """
928 Return if a status exists in the container.
929 """
930
931 def __iter__():
932 """
933 Return an iterator over the status codes.
934 """
935
936 def __len__():
937 """
938 Return the number of status conditions.
939 """
940
941
942 __all__ = [
943 "IPubSubClient",
944 "IPubSubService",
945 "IPubSubResource",
946 "IMUCClient",
947 "IMUCStatuses",
948 ]