annotate wokkel/pubsub.py @ 40:03224edb88af

tmp (wokkel/pubsub): subscriptions improvments: - added "none" state to Subscription, it is needed to remove existing subscription - implemented subscriptionsGet and subscriptionsSet - replaced "nodeOrEmpty" by "node" for affiliationsGet, affiliationsSet and subscriptionsGet as node is mandatory for these commands
author Goffi <goffi@goffi.org>
date Sun, 20 Aug 2017 10:29:26 +0200
parents 2cc92af0e13a
children f9d14d3d0835
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8
a07bf3fb4b54 core (tests): test fixes
Goffi <goffi@goffi.org>
parents: 6
diff changeset
1 # -*- coding: utf-8 -*-
0
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2 # -*- test-case-name: wokkel.test.test_pubsub -*-
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3 #
6
dc3a3f454f39 tmp (wokkel): licenses fixes:
Goffi <goffi@goffi.org>
parents: 0
diff changeset
4 # SàT adaptation for wokkel.pubsub
dc3a3f454f39 tmp (wokkel): licenses fixes:
Goffi <goffi@goffi.org>
parents: 0
diff changeset
5 # Copyright (C) 2015 Adien Cossa (souliane@mailoo.org)
dc3a3f454f39 tmp (wokkel): licenses fixes:
Goffi <goffi@goffi.org>
parents: 0
diff changeset
6 # Copyright (c) 2003-2012 Ralph Meijer.
dc3a3f454f39 tmp (wokkel): licenses fixes:
Goffi <goffi@goffi.org>
parents: 0
diff changeset
7
dc3a3f454f39 tmp (wokkel): licenses fixes:
Goffi <goffi@goffi.org>
parents: 0
diff changeset
8 # This program is free software: you can redistribute it and/or modify
dc3a3f454f39 tmp (wokkel): licenses fixes:
Goffi <goffi@goffi.org>
parents: 0
diff changeset
9 # it under the terms of the GNU Affero General Public License as published by
dc3a3f454f39 tmp (wokkel): licenses fixes:
Goffi <goffi@goffi.org>
parents: 0
diff changeset
10 # the Free Software Foundation, either version 3 of the License, or
dc3a3f454f39 tmp (wokkel): licenses fixes:
Goffi <goffi@goffi.org>
parents: 0
diff changeset
11 # (at your option) any later version.
dc3a3f454f39 tmp (wokkel): licenses fixes:
Goffi <goffi@goffi.org>
parents: 0
diff changeset
12
dc3a3f454f39 tmp (wokkel): licenses fixes:
Goffi <goffi@goffi.org>
parents: 0
diff changeset
13 # This program is distributed in the hope that it will be useful,
dc3a3f454f39 tmp (wokkel): licenses fixes:
Goffi <goffi@goffi.org>
parents: 0
diff changeset
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
dc3a3f454f39 tmp (wokkel): licenses fixes:
Goffi <goffi@goffi.org>
parents: 0
diff changeset
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
dc3a3f454f39 tmp (wokkel): licenses fixes:
Goffi <goffi@goffi.org>
parents: 0
diff changeset
16 # GNU Affero General Public License for more details.
dc3a3f454f39 tmp (wokkel): licenses fixes:
Goffi <goffi@goffi.org>
parents: 0
diff changeset
17
dc3a3f454f39 tmp (wokkel): licenses fixes:
Goffi <goffi@goffi.org>
parents: 0
diff changeset
18 # You should have received a copy of the GNU Affero General Public License
dc3a3f454f39 tmp (wokkel): licenses fixes:
Goffi <goffi@goffi.org>
parents: 0
diff changeset
19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
dc3a3f454f39 tmp (wokkel): licenses fixes:
Goffi <goffi@goffi.org>
parents: 0
diff changeset
20 # --
dc3a3f454f39 tmp (wokkel): licenses fixes:
Goffi <goffi@goffi.org>
parents: 0
diff changeset
21
dc3a3f454f39 tmp (wokkel): licenses fixes:
Goffi <goffi@goffi.org>
parents: 0
diff changeset
22 # This program is based on wokkel (https://wokkel.ik.nu/),
dc3a3f454f39 tmp (wokkel): licenses fixes:
Goffi <goffi@goffi.org>
parents: 0
diff changeset
23 # originaly written by Ralph Meijer
dc3a3f454f39 tmp (wokkel): licenses fixes:
Goffi <goffi@goffi.org>
parents: 0
diff changeset
24 # It is sublicensed under AGPL v3 (or any later version) as allowed by the original
dc3a3f454f39 tmp (wokkel): licenses fixes:
Goffi <goffi@goffi.org>
parents: 0
diff changeset
25 # license.
dc3a3f454f39 tmp (wokkel): licenses fixes:
Goffi <goffi@goffi.org>
parents: 0
diff changeset
26
dc3a3f454f39 tmp (wokkel): licenses fixes:
Goffi <goffi@goffi.org>
parents: 0
diff changeset
27 # --
dc3a3f454f39 tmp (wokkel): licenses fixes:
Goffi <goffi@goffi.org>
parents: 0
diff changeset
28
dc3a3f454f39 tmp (wokkel): licenses fixes:
Goffi <goffi@goffi.org>
parents: 0
diff changeset
29 # Here is a copy of the original license:
dc3a3f454f39 tmp (wokkel): licenses fixes:
Goffi <goffi@goffi.org>
parents: 0
diff changeset
30
dc3a3f454f39 tmp (wokkel): licenses fixes:
Goffi <goffi@goffi.org>
parents: 0
diff changeset
31 # Copyright (c) 2003-2012 Ralph Meijer.
dc3a3f454f39 tmp (wokkel): licenses fixes:
Goffi <goffi@goffi.org>
parents: 0
diff changeset
32 #
dc3a3f454f39 tmp (wokkel): licenses fixes:
Goffi <goffi@goffi.org>
parents: 0
diff changeset
33 # Permission is hereby granted, free of charge, to any person obtaining
dc3a3f454f39 tmp (wokkel): licenses fixes:
Goffi <goffi@goffi.org>
parents: 0
diff changeset
34 # a copy of this software and associated documentation files (the
dc3a3f454f39 tmp (wokkel): licenses fixes:
Goffi <goffi@goffi.org>
parents: 0
diff changeset
35 # "Software"), to deal in the Software without restriction, including
dc3a3f454f39 tmp (wokkel): licenses fixes:
Goffi <goffi@goffi.org>
parents: 0
diff changeset
36 # without limitation the rights to use, copy, modify, merge, publish,
dc3a3f454f39 tmp (wokkel): licenses fixes:
Goffi <goffi@goffi.org>
parents: 0
diff changeset
37 # distribute, sublicense, and/or sell copies of the Software, and to
dc3a3f454f39 tmp (wokkel): licenses fixes:
Goffi <goffi@goffi.org>
parents: 0
diff changeset
38 # permit persons to whom the Software is furnished to do so, subject to
dc3a3f454f39 tmp (wokkel): licenses fixes:
Goffi <goffi@goffi.org>
parents: 0
diff changeset
39 # the following conditions:
dc3a3f454f39 tmp (wokkel): licenses fixes:
Goffi <goffi@goffi.org>
parents: 0
diff changeset
40 #
dc3a3f454f39 tmp (wokkel): licenses fixes:
Goffi <goffi@goffi.org>
parents: 0
diff changeset
41 # The above copyright notice and this permission notice shall be
dc3a3f454f39 tmp (wokkel): licenses fixes:
Goffi <goffi@goffi.org>
parents: 0
diff changeset
42 # included in all copies or substantial portions of the Software.
dc3a3f454f39 tmp (wokkel): licenses fixes:
Goffi <goffi@goffi.org>
parents: 0
diff changeset
43 #
dc3a3f454f39 tmp (wokkel): licenses fixes:
Goffi <goffi@goffi.org>
parents: 0
diff changeset
44 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
dc3a3f454f39 tmp (wokkel): licenses fixes:
Goffi <goffi@goffi.org>
parents: 0
diff changeset
45 # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
dc3a3f454f39 tmp (wokkel): licenses fixes:
Goffi <goffi@goffi.org>
parents: 0
diff changeset
46 # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
dc3a3f454f39 tmp (wokkel): licenses fixes:
Goffi <goffi@goffi.org>
parents: 0
diff changeset
47 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
dc3a3f454f39 tmp (wokkel): licenses fixes:
Goffi <goffi@goffi.org>
parents: 0
diff changeset
48 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
dc3a3f454f39 tmp (wokkel): licenses fixes:
Goffi <goffi@goffi.org>
parents: 0
diff changeset
49 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
dc3a3f454f39 tmp (wokkel): licenses fixes:
Goffi <goffi@goffi.org>
parents: 0
diff changeset
50 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
0
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
51
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
52 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
53 XMPP publish-subscribe protocol.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
54
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
55 This protocol is specified in
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
56 U{XEP-0060<http://xmpp.org/extensions/xep-0060.html>}.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
57 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
58
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
59 from zope.interface import implements
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
60
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
61 from twisted.internet import defer
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
62 from twisted.python import log
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
63 from twisted.words.protocols.jabber import jid, error
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
64 from twisted.words.xish import domish
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
65
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
66 from wokkel import disco, data_form, generic, shim
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
67 from wokkel.compat import IQ
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
68 from wokkel.subprotocols import IQHandlerMixin, XMPPHandler
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
69 from wokkel.iwokkel import IPubSubClient, IPubSubService, IPubSubResource
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
70
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
71 # Iq get and set XPath queries
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
72 IQ_GET = '/iq[@type="get"]'
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
73 IQ_SET = '/iq[@type="set"]'
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
74
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
75 # Publish-subscribe namespaces
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
76 NS_PUBSUB = 'http://jabber.org/protocol/pubsub'
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
77 NS_PUBSUB_EVENT = NS_PUBSUB + '#event'
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
78 NS_PUBSUB_ERRORS = NS_PUBSUB + '#errors'
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
79 NS_PUBSUB_OWNER = NS_PUBSUB + "#owner"
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
80 NS_PUBSUB_NODE_CONFIG = NS_PUBSUB + "#node_config"
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
81 NS_PUBSUB_META_DATA = NS_PUBSUB + "#meta-data"
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
82 NS_PUBSUB_SUBSCRIBE_OPTIONS = NS_PUBSUB + "#subscribe_options"
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
83
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
84 # XPath to match pubsub requests
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
85 PUBSUB_REQUEST = '/iq[@type="get" or @type="set"]/' + \
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
86 'pubsub[@xmlns="' + NS_PUBSUB + '" or ' + \
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
87 '@xmlns="' + NS_PUBSUB_OWNER + '"]'
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
88
13
22f0cb2fa793 tmp(pubsub): added retract "notify" attribute management
Goffi <goffi@goffi.org>
parents: 8
diff changeset
89 BOOL_TRUE = ('1','true')
22f0cb2fa793 tmp(pubsub): added retract "notify" attribute management
Goffi <goffi@goffi.org>
parents: 8
diff changeset
90 BOOL_FALSE = ('0','false')
22f0cb2fa793 tmp(pubsub): added retract "notify" attribute management
Goffi <goffi@goffi.org>
parents: 8
diff changeset
91
0
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
92 class SubscriptionPending(Exception):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
93 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
94 Raised when the requested subscription is pending acceptance.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
95 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
96
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
97
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
98
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
99 class SubscriptionUnconfigured(Exception):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
100 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
101 Raised when the requested subscription needs to be configured before
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
102 becoming active.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
103 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
104
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
105
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
106
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
107 class PubSubError(error.StanzaError):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
108 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
109 Exception with publish-subscribe specific condition.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
110 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
111 def __init__(self, condition, pubsubCondition, feature=None, text=None):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
112 appCondition = domish.Element((NS_PUBSUB_ERRORS, pubsubCondition))
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
113 if feature:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
114 appCondition['feature'] = feature
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
115 error.StanzaError.__init__(self, condition,
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
116 text=text,
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
117 appCondition=appCondition)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
118
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
119
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
120
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
121 class BadRequest(error.StanzaError):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
122 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
123 Bad request stanza error.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
124 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
125 def __init__(self, pubsubCondition=None, text=None):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
126 if pubsubCondition:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
127 appCondition = domish.Element((NS_PUBSUB_ERRORS, pubsubCondition))
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
128 else:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
129 appCondition = None
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
130 error.StanzaError.__init__(self, 'bad-request',
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
131 text=text,
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
132 appCondition=appCondition)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
133
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
134
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
135
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
136 class Unsupported(PubSubError):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
137 def __init__(self, feature, text=None):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
138 self.feature = feature
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
139 PubSubError.__init__(self, 'feature-not-implemented',
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
140 'unsupported',
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
141 feature,
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
142 text)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
143
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
144 def __str__(self):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
145 message = PubSubError.__str__(self)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
146 message += ', feature %r' % self.feature
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
147 return message
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
148
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
149
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
150 class Subscription(object):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
151 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
152 A subscription to a node.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
153
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
154 @ivar nodeIdentifier: The identifier of the node subscribed to. The root
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
155 node is denoted by C{None}.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
156 @type nodeIdentifier: C{unicode}
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
157
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
158 @ivar subscriber: The subscribing entity.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
159 @type subscriber: L{jid.JID}
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
160
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
161 @ivar state: The subscription state. One of C{'subscribed'}, C{'pending'},
40
03224edb88af tmp (wokkel/pubsub): subscriptions improvments:
Goffi <goffi@goffi.org>
parents: 39
diff changeset
162 C{'unconfigured'}, C{'none'}.
0
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
163 @type state: C{unicode}
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
164
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
165 @ivar options: Optional list of subscription options.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
166 @type options: C{dict}
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
167
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
168 @ivar subscriptionIdentifier: Optional subscription identifier.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
169 @type subscriptionIdentifier: C{unicode}
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
170 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
171
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
172 def __init__(self, nodeIdentifier, subscriber, state, options=None,
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
173 subscriptionIdentifier=None):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
174 self.nodeIdentifier = nodeIdentifier
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
175 self.subscriber = subscriber
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
176 self.state = state
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
177 self.options = options or {}
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
178 self.subscriptionIdentifier = subscriptionIdentifier
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
179
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
180
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
181 @staticmethod
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
182 def fromElement(element):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
183 return Subscription(
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
184 element.getAttribute('node'),
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
185 jid.JID(element.getAttribute('jid')),
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
186 element.getAttribute('subscription'),
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
187 subscriptionIdentifier=element.getAttribute('subid'))
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
188
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
189
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
190 def toElement(self, defaultUri=None):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
191 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
192 Return the DOM representation of this subscription.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
193
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
194 @rtype: L{domish.Element}
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
195 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
196 element = domish.Element((defaultUri, 'subscription'))
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
197 if self.nodeIdentifier:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
198 element['node'] = self.nodeIdentifier
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
199 element['jid'] = unicode(self.subscriber)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
200 element['subscription'] = self.state
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
201 if self.subscriptionIdentifier:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
202 element['subid'] = self.subscriptionIdentifier
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
203 return element
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
204
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
205
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
206
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
207 class Item(domish.Element):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
208 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
209 Publish subscribe item.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
210
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
211 This behaves like an object providing L{domish.IElement}.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
212
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
213 Item payload can be added using C{addChild} or C{addRawXml}, or using the
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
214 C{payload} keyword argument to C{__init__}.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
215 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
216
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
217 def __init__(self, id=None, payload=None):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
218 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
219 @param id: optional item identifier
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
220 @type id: C{unicode}
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
221 @param payload: optional item payload. Either as a domish element, or
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
222 as serialized XML.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
223 @type payload: object providing L{domish.IElement} or C{unicode}.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
224 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
225
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
226 domish.Element.__init__(self, (None, 'item'))
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
227 if id is not None:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
228 self['id'] = id
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
229 if payload is not None:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
230 if isinstance(payload, basestring):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
231 self.addRawXml(payload)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
232 else:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
233 self.addChild(payload)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
234
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
235
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
236
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
237 class PubSubRequest(generic.Stanza):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
238 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
239 A publish-subscribe request.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
240
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
241 The set of instance variables used depends on the type of request. If
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
242 a variable is not applicable or not passed in the request, its value is
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
243 C{None}.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
244
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
245 @ivar verb: The type of publish-subscribe request. See C{_requestVerbMap}.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
246 @type verb: C{str}.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
247
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
248 @ivar affiliations: Affiliations to be modified.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
249 @type affiliations: C{set}
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
250
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
251 @ivar items: The items to be published, as L{domish.Element}s.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
252 @type items: C{list}
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
253
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
254 @ivar itemIdentifiers: Identifiers of the items to be retrieved or
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
255 retracted.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
256 @type itemIdentifiers: C{set}
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
257
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
258 @ivar maxItems: Maximum number of items to retrieve.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
259 @type maxItems: C{int}.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
260
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
261 @ivar nodeIdentifier: Identifier of the node the request is about.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
262 @type nodeIdentifier: C{unicode}
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
263
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
264 @ivar nodeType: The type of node that should be created, or for which the
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
265 configuration is retrieved. C{'leaf'} or C{'collection'}.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
266 @type nodeType: C{str}
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
267
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
268 @ivar options: Configurations options for nodes, subscriptions and publish
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
269 requests.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
270 @type options: L{data_form.Form}
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
271
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
272 @ivar subscriber: The subscribing entity.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
273 @type subscriber: L{JID<twisted.words.protocols.jabber.jid.JID>}
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
274
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
275 @ivar subscriptionIdentifier: Identifier for a specific subscription.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
276 @type subscriptionIdentifier: C{unicode}
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
277
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
278 @ivar subscriptions: Subscriptions to be modified, as a set of
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
279 L{Subscription}.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
280 @type subscriptions: C{set}
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
281
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
282 @ivar affiliations: Affiliations to be modified, as a dictionary of entity
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
283 (L{JID<twisted.words.protocols.jabber.jid.JID>} to affiliation
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
284 (C{unicode}).
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
285 @type affiliations: C{dict}
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
286 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
287
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
288 verb = None
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
289
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
290 items = None
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
291 itemIdentifiers = None
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
292 maxItems = None
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
293 nodeIdentifier = None
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
294 nodeType = None
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
295 options = None
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
296 subscriber = None
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
297 subscriptionIdentifier = None
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
298 subscriptions = None
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
299 affiliations = None
13
22f0cb2fa793 tmp(pubsub): added retract "notify" attribute management
Goffi <goffi@goffi.org>
parents: 8
diff changeset
300 notify = None
0
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
301
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
302 # Map request iq type and subelement name to request verb
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
303 _requestVerbMap = {
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
304 ('set', NS_PUBSUB, 'publish'): 'publish',
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
305 ('set', NS_PUBSUB, 'subscribe'): 'subscribe',
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
306 ('set', NS_PUBSUB, 'unsubscribe'): 'unsubscribe',
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
307 ('get', NS_PUBSUB, 'options'): 'optionsGet',
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
308 ('set', NS_PUBSUB, 'options'): 'optionsSet',
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
309 ('get', NS_PUBSUB, 'subscriptions'): 'subscriptions',
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
310 ('get', NS_PUBSUB, 'affiliations'): 'affiliations',
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
311 ('set', NS_PUBSUB, 'create'): 'create',
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
312 ('get', NS_PUBSUB_OWNER, 'default'): 'default',
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
313 ('get', NS_PUBSUB_OWNER, 'configure'): 'configureGet',
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
314 ('set', NS_PUBSUB_OWNER, 'configure'): 'configureSet',
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
315 ('get', NS_PUBSUB, 'items'): 'items',
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
316 ('set', NS_PUBSUB, 'retract'): 'retract',
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
317 ('set', NS_PUBSUB_OWNER, 'purge'): 'purge',
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
318 ('set', NS_PUBSUB_OWNER, 'delete'): 'delete',
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
319 ('get', NS_PUBSUB_OWNER, 'affiliations'): 'affiliationsGet',
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
320 ('set', NS_PUBSUB_OWNER, 'affiliations'): 'affiliationsSet',
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
321 ('get', NS_PUBSUB_OWNER, 'subscriptions'): 'subscriptionsGet',
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
322 ('set', NS_PUBSUB_OWNER, 'subscriptions'): 'subscriptionsSet',
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
323 }
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
324
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
325 # Map request verb to request iq type and subelement name
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
326 _verbRequestMap = dict(((v, k) for k, v in _requestVerbMap.iteritems()))
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
327
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
328 # Map request verb to parameter handler names
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
329 _parameters = {
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
330 'publish': ['node', 'items'],
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
331 'subscribe': ['nodeOrEmpty', 'jid', 'optionsWithSubscribe'],
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
332 'unsubscribe': ['nodeOrEmpty', 'jid', 'subidOrNone'],
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
333 'optionsGet': ['nodeOrEmpty', 'jid', 'subidOrNone'],
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
334 'optionsSet': ['nodeOrEmpty', 'jid', 'options', 'subidOrNone'],
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
335 'subscriptions': [],
37
e8296d7bfeb1 tmp (wokkel/pubsub): fixed affiliations (normal entity) handling
Goffi <goffi@goffi.org>
parents: 36
diff changeset
336 'affiliations': ['nodeOrNone'],
0
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
337 'create': ['nodeOrNone', 'configureOrNone'],
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
338 'default': ['default'],
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
339 'configureGet': ['nodeOrEmpty'],
35
79e36496994a plugin XEP-0060: added setConfiguration/psNodeConfigurationSet + fix in tmp.wokkel.pubsub
Goffi <goffi@goffi.org>
parents: 22
diff changeset
340 'configureSet': ['nodeOrEmpty', 'configureOrNone'],
0
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
341 'items': ['node', 'maxItems', 'itemIdentifiers', 'subidOrNone'],
13
22f0cb2fa793 tmp(pubsub): added retract "notify" attribute management
Goffi <goffi@goffi.org>
parents: 8
diff changeset
342 'retract': ['node', 'notify', 'itemIdentifiers'],
0
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
343 'purge': ['node'],
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
344 'delete': ['node'],
40
03224edb88af tmp (wokkel/pubsub): subscriptions improvments:
Goffi <goffi@goffi.org>
parents: 39
diff changeset
345 'affiliationsGet': ['node'],
03224edb88af tmp (wokkel/pubsub): subscriptions improvments:
Goffi <goffi@goffi.org>
parents: 39
diff changeset
346 'affiliationsSet': ['node', 'affiliations'],
03224edb88af tmp (wokkel/pubsub): subscriptions improvments:
Goffi <goffi@goffi.org>
parents: 39
diff changeset
347 'subscriptionsGet': ['node'],
03224edb88af tmp (wokkel/pubsub): subscriptions improvments:
Goffi <goffi@goffi.org>
parents: 39
diff changeset
348 'subscriptionsSet': ['node', 'subscriptions'],
0
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
349 }
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
350
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
351 def __init__(self, verb=None):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
352 self.verb = verb
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
353
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
354
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
355 def _parse_node(self, verbElement):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
356 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
357 Parse the required node identifier out of the verbElement.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
358 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
359 try:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
360 self.nodeIdentifier = verbElement["node"]
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
361 except KeyError:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
362 raise BadRequest('nodeid-required')
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
363
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
364
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
365 def _render_node(self, verbElement):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
366 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
367 Render the required node identifier on the verbElement.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
368 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
369 if not self.nodeIdentifier:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
370 raise Exception("Node identifier is required")
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
371
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
372 verbElement['node'] = self.nodeIdentifier
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
373
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
374
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
375 def _parse_nodeOrEmpty(self, verbElement):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
376 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
377 Parse the node identifier out of the verbElement. May be empty.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
378 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
379 self.nodeIdentifier = verbElement.getAttribute("node", '')
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
380
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
381
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
382 def _render_nodeOrEmpty(self, verbElement):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
383 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
384 Render the node identifier on the verbElement. May be empty.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
385 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
386 if self.nodeIdentifier:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
387 verbElement['node'] = self.nodeIdentifier
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
388
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
389
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
390 def _parse_nodeOrNone(self, verbElement):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
391 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
392 Parse the optional node identifier out of the verbElement.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
393 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
394 self.nodeIdentifier = verbElement.getAttribute("node")
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
395
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
396
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
397 def _render_nodeOrNone(self, verbElement):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
398 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
399 Render the optional node identifier on the verbElement.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
400 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
401 if self.nodeIdentifier:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
402 verbElement['node'] = self.nodeIdentifier
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
403
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
404
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
405 def _parse_items(self, verbElement):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
406 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
407 Parse items out of the verbElement for publish requests.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
408 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
409 self.items = []
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
410 for element in verbElement.elements():
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
411 if element.uri == NS_PUBSUB and element.name == 'item':
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
412 self.items.append(element)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
413
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
414
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
415 def _render_items(self, verbElement):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
416 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
417 Render items into the verbElement for publish requests.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
418 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
419 if self.items:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
420 for item in self.items:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
421 item.uri = NS_PUBSUB
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
422 verbElement.addChild(item)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
423
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
424
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
425 def _parse_jid(self, verbElement):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
426 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
427 Parse subscriber out of the verbElement for un-/subscribe requests.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
428 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
429 try:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
430 self.subscriber = jid.internJID(verbElement["jid"])
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
431 except KeyError:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
432 raise BadRequest('jid-required')
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
433
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
434
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
435 def _render_jid(self, verbElement):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
436 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
437 Render subscriber into the verbElement for un-/subscribe requests.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
438 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
439 verbElement['jid'] = self.subscriber.full()
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
440
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
441
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
442 def _parse_default(self, verbElement):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
443 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
444 Parse node type out of a request for the default node configuration.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
445 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
446 form = data_form.findForm(verbElement, NS_PUBSUB_NODE_CONFIG)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
447 if form is not None and form.formType == 'submit':
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
448 values = form.getValues()
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
449 self.nodeType = values.get('pubsub#node_type', 'leaf')
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
450 else:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
451 self.nodeType = 'leaf'
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
452
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
453
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
454 def _parse_configure(self, verbElement):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
455 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
456 Parse options out of a request for setting the node configuration.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
457 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
458 form = data_form.findForm(verbElement, NS_PUBSUB_NODE_CONFIG)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
459 if form is not None:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
460 if form.formType in ('submit', 'cancel'):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
461 self.options = form
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
462 else:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
463 raise BadRequest(text=u"Unexpected form type '%s'" % form.formType)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
464 else:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
465 raise BadRequest(text="Missing configuration form")
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
466
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
467
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
468 def _parse_configureOrNone(self, verbElement):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
469 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
470 Parse optional node configuration form in create request.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
471 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
472 for element in verbElement.parent.elements():
39
2cc92af0e13a tmp(wokkel/pubsub): fixed configuration parsing
Goffi <goffi@goffi.org>
parents: 38
diff changeset
473 if element.uri in (NS_PUBSUB, NS_PUBSUB_OWNER) and element.name == 'configure':
0
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
474 form = data_form.findForm(element, NS_PUBSUB_NODE_CONFIG)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
475 if form is not None:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
476 if form.formType != 'submit':
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
477 raise BadRequest(text=u"Unexpected form type '%s'" %
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
478 form.formType)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
479 else:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
480 form = data_form.Form('submit',
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
481 formNamespace=NS_PUBSUB_NODE_CONFIG)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
482 self.options = form
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
483
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
484
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
485 def _render_configureOrNone(self, verbElement):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
486 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
487 Render optional node configuration form in create request.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
488 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
489 if self.options is not None:
36
a67d9617b4ef tmp (wokkel/pubsub): fixed configuration setting
Goffi <goffi@goffi.org>
parents: 35
diff changeset
490 if verbElement.name == 'configure':
a67d9617b4ef tmp (wokkel/pubsub): fixed configuration setting
Goffi <goffi@goffi.org>
parents: 35
diff changeset
491 configure = verbElement
a67d9617b4ef tmp (wokkel/pubsub): fixed configuration setting
Goffi <goffi@goffi.org>
parents: 35
diff changeset
492 else:
a67d9617b4ef tmp (wokkel/pubsub): fixed configuration setting
Goffi <goffi@goffi.org>
parents: 35
diff changeset
493 configure = verbElement.parent.addElement('configure')
0
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
494 configure.addChild(self.options.toElement())
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
495
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
496
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
497 def _parse_itemIdentifiers(self, verbElement):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
498 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
499 Parse item identifiers out of items and retract requests.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
500 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
501 self.itemIdentifiers = []
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
502 for element in verbElement.elements():
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
503 if element.uri == NS_PUBSUB and element.name == 'item':
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
504 try:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
505 self.itemIdentifiers.append(element["id"])
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
506 except KeyError:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
507 raise BadRequest()
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
508
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
509
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
510 def _render_itemIdentifiers(self, verbElement):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
511 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
512 Render item identifiers into items and retract requests.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
513 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
514 if self.itemIdentifiers:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
515 for itemIdentifier in self.itemIdentifiers:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
516 item = verbElement.addElement('item')
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
517 item['id'] = itemIdentifier
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
518
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
519
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
520 def _parse_maxItems(self, verbElement):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
521 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
522 Parse maximum items out of an items request.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
523 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
524 value = verbElement.getAttribute('max_items')
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
525
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
526 if value:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
527 try:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
528 self.maxItems = int(value)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
529 except ValueError:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
530 raise BadRequest(text="Field max_items requires a positive " +
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
531 "integer value")
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
532
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
533
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
534 def _render_maxItems(self, verbElement):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
535 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
536 Render maximum items into an items request.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
537 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
538 if self.maxItems:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
539 verbElement['max_items'] = unicode(self.maxItems)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
540
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
541
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
542 def _parse_subidOrNone(self, verbElement):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
543 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
544 Parse subscription identifier out of a request.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
545 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
546 self.subscriptionIdentifier = verbElement.getAttribute("subid")
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
547
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
548
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
549 def _render_subidOrNone(self, verbElement):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
550 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
551 Render subscription identifier into a request.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
552 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
553 if self.subscriptionIdentifier:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
554 verbElement['subid'] = self.subscriptionIdentifier
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
555
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
556
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
557 def _parse_options(self, verbElement):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
558 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
559 Parse options form out of a subscription options request.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
560 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
561 form = data_form.findForm(verbElement, NS_PUBSUB_SUBSCRIBE_OPTIONS)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
562 if form is not None:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
563 if form.formType in ('submit', 'cancel'):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
564 self.options = form
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
565 else:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
566 raise BadRequest(text=u"Unexpected form type '%s'" % form.formType)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
567 else:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
568 raise BadRequest(text="Missing options form")
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
569
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
570
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
571 def _render_options(self, verbElement):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
572 verbElement.addChild(self.options.toElement())
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
573
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
574
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
575 def _parse_optionsWithSubscribe(self, verbElement):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
576 for element in verbElement.parent.elements():
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
577 if element.name == 'options' and element.uri == NS_PUBSUB:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
578 form = data_form.findForm(element,
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
579 NS_PUBSUB_SUBSCRIBE_OPTIONS)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
580 if form is not None:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
581 if form.formType != 'submit':
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
582 raise BadRequest(text=u"Unexpected form type '%s'" %
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
583 form.formType)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
584 else:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
585 form = data_form.Form('submit',
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
586 formNamespace=NS_PUBSUB_SUBSCRIBE_OPTIONS)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
587 self.options = form
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
588
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
589
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
590 def _render_optionsWithSubscribe(self, verbElement):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
591 if self.options is not None:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
592 optionsElement = verbElement.parent.addElement('options')
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
593 self._render_options(optionsElement)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
594
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
595
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
596 def _parse_affiliations(self, verbElement):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
597 self.affiliations = {}
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
598 for element in verbElement.elements():
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
599 if (element.uri == NS_PUBSUB_OWNER and
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
600 element.name == 'affiliation'):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
601 try:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
602 entity = jid.internJID(element['jid']).userhostJID()
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
603 except KeyError:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
604 raise BadRequest(text='Missing jid attribute')
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
605
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
606 if entity in self.affiliations:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
607 raise BadRequest(text='Multiple affiliations for an entity')
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
608
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
609 try:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
610 affiliation = element['affiliation']
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
611 except KeyError:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
612 raise BadRequest(text='Missing affiliation attribute')
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
613
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
614 self.affiliations[entity] = affiliation
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
615
40
03224edb88af tmp (wokkel/pubsub): subscriptions improvments:
Goffi <goffi@goffi.org>
parents: 39
diff changeset
616
38
e3e02ead6bde tmp(wokkel/pubsub): removed affiliations attribute which was there twice + added missing _render_affiliations
Goffi <goffi@goffi.org>
parents: 37
diff changeset
617 def _render_affiliations(self, verbElement):
e3e02ead6bde tmp(wokkel/pubsub): removed affiliations attribute which was there twice + added missing _render_affiliations
Goffi <goffi@goffi.org>
parents: 37
diff changeset
618 for entity, affiliation in self.affiliations.iteritems():
e3e02ead6bde tmp(wokkel/pubsub): removed affiliations attribute which was there twice + added missing _render_affiliations
Goffi <goffi@goffi.org>
parents: 37
diff changeset
619 affiliationElement = verbElement.addElement((NS_PUBSUB_OWNER, 'affiliation'))
e3e02ead6bde tmp(wokkel/pubsub): removed affiliations attribute which was there twice + added missing _render_affiliations
Goffi <goffi@goffi.org>
parents: 37
diff changeset
620 affiliationElement['jid'] = entity.full()
e3e02ead6bde tmp(wokkel/pubsub): removed affiliations attribute which was there twice + added missing _render_affiliations
Goffi <goffi@goffi.org>
parents: 37
diff changeset
621 affiliationElement['affiliation'] = affiliation
0
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
622
40
03224edb88af tmp (wokkel/pubsub): subscriptions improvments:
Goffi <goffi@goffi.org>
parents: 39
diff changeset
623
03224edb88af tmp (wokkel/pubsub): subscriptions improvments:
Goffi <goffi@goffi.org>
parents: 39
diff changeset
624 def _parse_subscriptions(self, verbElement):
03224edb88af tmp (wokkel/pubsub): subscriptions improvments:
Goffi <goffi@goffi.org>
parents: 39
diff changeset
625 self.subscriptions = set()
03224edb88af tmp (wokkel/pubsub): subscriptions improvments:
Goffi <goffi@goffi.org>
parents: 39
diff changeset
626 seen_entities = set()
03224edb88af tmp (wokkel/pubsub): subscriptions improvments:
Goffi <goffi@goffi.org>
parents: 39
diff changeset
627 for element in verbElement.elements():
03224edb88af tmp (wokkel/pubsub): subscriptions improvments:
Goffi <goffi@goffi.org>
parents: 39
diff changeset
628 if (element.uri == NS_PUBSUB_OWNER and
03224edb88af tmp (wokkel/pubsub): subscriptions improvments:
Goffi <goffi@goffi.org>
parents: 39
diff changeset
629 element.name == 'subscription'):
03224edb88af tmp (wokkel/pubsub): subscriptions improvments:
Goffi <goffi@goffi.org>
parents: 39
diff changeset
630 try:
03224edb88af tmp (wokkel/pubsub): subscriptions improvments:
Goffi <goffi@goffi.org>
parents: 39
diff changeset
631 subscriber = jid.internJID(element['jid']).userhostJID()
03224edb88af tmp (wokkel/pubsub): subscriptions improvments:
Goffi <goffi@goffi.org>
parents: 39
diff changeset
632 except KeyError:
03224edb88af tmp (wokkel/pubsub): subscriptions improvments:
Goffi <goffi@goffi.org>
parents: 39
diff changeset
633 raise BadRequest(text='Missing jid attribute')
03224edb88af tmp (wokkel/pubsub): subscriptions improvments:
Goffi <goffi@goffi.org>
parents: 39
diff changeset
634
03224edb88af tmp (wokkel/pubsub): subscriptions improvments:
Goffi <goffi@goffi.org>
parents: 39
diff changeset
635 if subscriber in seen_entities:
03224edb88af tmp (wokkel/pubsub): subscriptions improvments:
Goffi <goffi@goffi.org>
parents: 39
diff changeset
636 raise BadRequest(text='Multiple subscriptions for an subscriber')
03224edb88af tmp (wokkel/pubsub): subscriptions improvments:
Goffi <goffi@goffi.org>
parents: 39
diff changeset
637 seen_entities.add(subscriber)
03224edb88af tmp (wokkel/pubsub): subscriptions improvments:
Goffi <goffi@goffi.org>
parents: 39
diff changeset
638
03224edb88af tmp (wokkel/pubsub): subscriptions improvments:
Goffi <goffi@goffi.org>
parents: 39
diff changeset
639 try:
03224edb88af tmp (wokkel/pubsub): subscriptions improvments:
Goffi <goffi@goffi.org>
parents: 39
diff changeset
640 state = element['subscription']
03224edb88af tmp (wokkel/pubsub): subscriptions improvments:
Goffi <goffi@goffi.org>
parents: 39
diff changeset
641 except KeyError:
03224edb88af tmp (wokkel/pubsub): subscriptions improvments:
Goffi <goffi@goffi.org>
parents: 39
diff changeset
642 # §8.8.2.1 says that value MUST NOT be changed
03224edb88af tmp (wokkel/pubsub): subscriptions improvments:
Goffi <goffi@goffi.org>
parents: 39
diff changeset
643 # if subscription is missing
03224edb88af tmp (wokkel/pubsub): subscriptions improvments:
Goffi <goffi@goffi.org>
parents: 39
diff changeset
644 continue
03224edb88af tmp (wokkel/pubsub): subscriptions improvments:
Goffi <goffi@goffi.org>
parents: 39
diff changeset
645
03224edb88af tmp (wokkel/pubsub): subscriptions improvments:
Goffi <goffi@goffi.org>
parents: 39
diff changeset
646 self.subscriptions.add(Subscription(self.nodeIdentifier,
03224edb88af tmp (wokkel/pubsub): subscriptions improvments:
Goffi <goffi@goffi.org>
parents: 39
diff changeset
647 subscriber,
03224edb88af tmp (wokkel/pubsub): subscriptions improvments:
Goffi <goffi@goffi.org>
parents: 39
diff changeset
648 state))
03224edb88af tmp (wokkel/pubsub): subscriptions improvments:
Goffi <goffi@goffi.org>
parents: 39
diff changeset
649
03224edb88af tmp (wokkel/pubsub): subscriptions improvments:
Goffi <goffi@goffi.org>
parents: 39
diff changeset
650
03224edb88af tmp (wokkel/pubsub): subscriptions improvments:
Goffi <goffi@goffi.org>
parents: 39
diff changeset
651 def _render_subscriptions(self, verbElement):
03224edb88af tmp (wokkel/pubsub): subscriptions improvments:
Goffi <goffi@goffi.org>
parents: 39
diff changeset
652 for subscription in self.subscriptions:
03224edb88af tmp (wokkel/pubsub): subscriptions improvments:
Goffi <goffi@goffi.org>
parents: 39
diff changeset
653 subscriptionElement = verbElement.addElement((NS_PUBSUB_OWNER, 'subscription'))
03224edb88af tmp (wokkel/pubsub): subscriptions improvments:
Goffi <goffi@goffi.org>
parents: 39
diff changeset
654 subscriptionElement['jid'] = subscription.subscriber.full()
03224edb88af tmp (wokkel/pubsub): subscriptions improvments:
Goffi <goffi@goffi.org>
parents: 39
diff changeset
655 subscriptionElement['subscription'] = subscription.state
03224edb88af tmp (wokkel/pubsub): subscriptions improvments:
Goffi <goffi@goffi.org>
parents: 39
diff changeset
656
03224edb88af tmp (wokkel/pubsub): subscriptions improvments:
Goffi <goffi@goffi.org>
parents: 39
diff changeset
657
13
22f0cb2fa793 tmp(pubsub): added retract "notify" attribute management
Goffi <goffi@goffi.org>
parents: 8
diff changeset
658 def _parse_notify(self, verbElement):
22f0cb2fa793 tmp(pubsub): added retract "notify" attribute management
Goffi <goffi@goffi.org>
parents: 8
diff changeset
659 value = verbElement.getAttribute('notify')
22f0cb2fa793 tmp(pubsub): added retract "notify" attribute management
Goffi <goffi@goffi.org>
parents: 8
diff changeset
660
22f0cb2fa793 tmp(pubsub): added retract "notify" attribute management
Goffi <goffi@goffi.org>
parents: 8
diff changeset
661 if value:
22f0cb2fa793 tmp(pubsub): added retract "notify" attribute management
Goffi <goffi@goffi.org>
parents: 8
diff changeset
662 if value in BOOL_TRUE:
22f0cb2fa793 tmp(pubsub): added retract "notify" attribute management
Goffi <goffi@goffi.org>
parents: 8
diff changeset
663 self.notify = True
22f0cb2fa793 tmp(pubsub): added retract "notify" attribute management
Goffi <goffi@goffi.org>
parents: 8
diff changeset
664 elif value in BOOL_FALSE:
22f0cb2fa793 tmp(pubsub): added retract "notify" attribute management
Goffi <goffi@goffi.org>
parents: 8
diff changeset
665 self.notify = False
22f0cb2fa793 tmp(pubsub): added retract "notify" attribute management
Goffi <goffi@goffi.org>
parents: 8
diff changeset
666 else:
22f0cb2fa793 tmp(pubsub): added retract "notify" attribute management
Goffi <goffi@goffi.org>
parents: 8
diff changeset
667 raise BadRequest(text="Field notify must be a boolean value")
22f0cb2fa793 tmp(pubsub): added retract "notify" attribute management
Goffi <goffi@goffi.org>
parents: 8
diff changeset
668
22f0cb2fa793 tmp(pubsub): added retract "notify" attribute management
Goffi <goffi@goffi.org>
parents: 8
diff changeset
669
22f0cb2fa793 tmp(pubsub): added retract "notify" attribute management
Goffi <goffi@goffi.org>
parents: 8
diff changeset
670 def _render_notify(self, verbElement):
22f0cb2fa793 tmp(pubsub): added retract "notify" attribute management
Goffi <goffi@goffi.org>
parents: 8
diff changeset
671 if self.notify is not None:
22f0cb2fa793 tmp(pubsub): added retract "notify" attribute management
Goffi <goffi@goffi.org>
parents: 8
diff changeset
672 verbElement['notify'] = "true" if self.notify else "false"
22f0cb2fa793 tmp(pubsub): added retract "notify" attribute management
Goffi <goffi@goffi.org>
parents: 8
diff changeset
673
22f0cb2fa793 tmp(pubsub): added retract "notify" attribute management
Goffi <goffi@goffi.org>
parents: 8
diff changeset
674
0
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
675 def parseElement(self, element):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
676 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
677 Parse the publish-subscribe verb and parameters out of a request.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
678 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
679 generic.Stanza.parseElement(self, element)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
680
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
681 verbs = []
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
682 verbElements = []
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
683 for child in element.pubsub.elements():
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
684 key = (self.stanzaType, child.uri, child.name)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
685 try:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
686 verb = self._requestVerbMap[key]
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
687 except KeyError:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
688 continue
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
689
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
690 verbs.append(verb)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
691 verbElements.append(child)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
692
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
693 if not verbs:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
694 raise NotImplementedError()
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
695
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
696 if len(verbs) > 1:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
697 if 'optionsSet' in verbs and 'subscribe' in verbs:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
698 self.verb = 'subscribe'
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
699 verbElement = verbElements[verbs.index('subscribe')]
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
700 else:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
701 raise NotImplementedError()
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
702 else:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
703 self.verb = verbs[0]
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
704 verbElement = verbElements[0]
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
705
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
706 for parameter in self._parameters[self.verb]:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
707 getattr(self, '_parse_%s' % parameter)(verbElement)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
708
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
709
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
710
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
711 def send(self, xs):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
712 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
713 Send this request to its recipient.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
714
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
715 This renders all of the relevant parameters for this specific
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
716 requests into an L{IQ}, and invoke its C{send} method.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
717 This returns a deferred that fires upon reception of a response. See
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
718 L{IQ} for details.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
719
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
720 @param xs: The XML stream to send the request on.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
721 @type xs: L{twisted.words.protocols.jabber.xmlstream.XmlStream}
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
722 @rtype: L{defer.Deferred}.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
723 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
724
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
725 try:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
726 (self.stanzaType,
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
727 childURI,
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
728 childName) = self._verbRequestMap[self.verb]
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
729 except KeyError:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
730 raise NotImplementedError()
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
731
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
732 iq = IQ(xs, self.stanzaType)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
733 iq.addElement((childURI, 'pubsub'))
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
734 verbElement = iq.pubsub.addElement(childName)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
735
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
736 if self.sender:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
737 iq['from'] = self.sender.full()
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
738 if self.recipient:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
739 iq['to'] = self.recipient.full()
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
740
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
741 for parameter in self._parameters[self.verb]:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
742 getattr(self, '_render_%s' % parameter)(verbElement)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
743
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
744 return iq.send()
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
745
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
746
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
747
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
748 class PubSubEvent(object):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
749 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
750 A publish subscribe event.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
751
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
752 @param sender: The entity from which the notification was received.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
753 @type sender: L{jid.JID}
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
754 @param recipient: The entity to which the notification was sent.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
755 @type recipient: L{wokkel.pubsub.ItemsEvent}
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
756 @param nodeIdentifier: Identifier of the node the event pertains to.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
757 @type nodeIdentifier: C{unicode}
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
758 @param headers: SHIM headers, see L{wokkel.shim.extractHeaders}.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
759 @type headers: C{dict}
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
760 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
761
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
762 def __init__(self, sender, recipient, nodeIdentifier, headers):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
763 self.sender = sender
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
764 self.recipient = recipient
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
765 self.nodeIdentifier = nodeIdentifier
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
766 self.headers = headers
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
767
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
768
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
769
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
770 class ItemsEvent(PubSubEvent):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
771 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
772 A publish-subscribe event that signifies new, updated and retracted items.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
773
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
774 @param items: List of received items as domish elements.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
775 @type items: C{list} of L{domish.Element}
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
776 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
777
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
778 def __init__(self, sender, recipient, nodeIdentifier, items, headers):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
779 PubSubEvent.__init__(self, sender, recipient, nodeIdentifier, headers)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
780 self.items = items
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
781
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
782
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
783
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
784 class DeleteEvent(PubSubEvent):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
785 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
786 A publish-subscribe event that signifies the deletion of a node.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
787 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
788
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
789 redirectURI = None
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
790
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
791
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
792
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
793 class PurgeEvent(PubSubEvent):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
794 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
795 A publish-subscribe event that signifies the purging of a node.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
796 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
797
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
798
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
799
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
800 class PubSubClient(XMPPHandler):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
801 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
802 Publish subscribe client protocol.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
803 """
22
5246a9186b91 tmp (wokkel.pubsub): PubSubRequest class can be overriden everywhere, including PubSubClient
Goffi <goffi@goffi.org>
parents: 21
diff changeset
804 implements(IPubSubClient)
0
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
805
22
5246a9186b91 tmp (wokkel.pubsub): PubSubRequest class can be overriden everywhere, including PubSubClient
Goffi <goffi@goffi.org>
parents: 21
diff changeset
806 _request_class = PubSubRequest
0
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
807
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
808 def connectionInitialized(self):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
809 self.xmlstream.addObserver('/message/event[@xmlns="%s"]' %
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
810 NS_PUBSUB_EVENT, self._onEvent)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
811
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
812
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
813 def _onEvent(self, message):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
814 if message.getAttribute('type') == 'error':
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
815 return
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
816
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
817 try:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
818 sender = jid.JID(message["from"])
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
819 recipient = jid.JID(message["to"])
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
820 except KeyError:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
821 return
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
822
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
823 actionElement = None
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
824 for element in message.event.elements():
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
825 if element.uri == NS_PUBSUB_EVENT:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
826 actionElement = element
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
827
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
828 if not actionElement:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
829 return
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
830
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
831 eventHandler = getattr(self, "_onEvent_%s" % actionElement.name, None)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
832
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
833 if eventHandler:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
834 headers = shim.extractHeaders(message)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
835 eventHandler(sender, recipient, actionElement, headers)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
836 message.handled = True
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
837
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
838
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
839 def _onEvent_items(self, sender, recipient, action, headers):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
840 nodeIdentifier = action["node"]
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
841
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
842 items = [element for element in action.elements()
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
843 if element.name in ('item', 'retract')]
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
844
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
845 event = ItemsEvent(sender, recipient, nodeIdentifier, items, headers)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
846 self.itemsReceived(event)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
847
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
848
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
849 def _onEvent_delete(self, sender, recipient, action, headers):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
850 nodeIdentifier = action["node"]
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
851 event = DeleteEvent(sender, recipient, nodeIdentifier, headers)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
852 if action.redirect:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
853 event.redirectURI = action.redirect.getAttribute('uri')
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
854 self.deleteReceived(event)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
855
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
856
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
857 def _onEvent_purge(self, sender, recipient, action, headers):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
858 nodeIdentifier = action["node"]
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
859 event = PurgeEvent(sender, recipient, nodeIdentifier, headers)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
860 self.purgeReceived(event)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
861
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
862
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
863 def itemsReceived(self, event):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
864 pass
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
865
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
866
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
867 def deleteReceived(self, event):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
868 pass
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
869
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
870
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
871 def purgeReceived(self, event):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
872 pass
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
873
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
874
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
875 def createNode(self, service, nodeIdentifier=None, options=None,
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
876 sender=None):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
877 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
878 Create a publish subscribe node.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
879
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
880 @param service: The publish subscribe service to create the node at.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
881 @type service: L{JID<twisted.words.protocols.jabber.jid.JID>}
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
882 @param nodeIdentifier: Optional suggestion for the id of the node.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
883 @type nodeIdentifier: C{unicode}
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
884 @param options: Optional node configuration options.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
885 @type options: C{dict}
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
886 """
22
5246a9186b91 tmp (wokkel.pubsub): PubSubRequest class can be overriden everywhere, including PubSubClient
Goffi <goffi@goffi.org>
parents: 21
diff changeset
887 request = self._request_class('create')
0
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
888 request.recipient = service
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
889 request.nodeIdentifier = nodeIdentifier
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
890 request.sender = sender
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
891
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
892 if options:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
893 form = data_form.Form(formType='submit',
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
894 formNamespace=NS_PUBSUB_NODE_CONFIG)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
895 form.makeFields(options)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
896 request.options = form
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
897
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
898 def cb(iq):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
899 try:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
900 new_node = iq.pubsub.create["node"]
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
901 except AttributeError:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
902 # the suggested node identifier was accepted
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
903 new_node = nodeIdentifier
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
904 return new_node
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
905
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
906 d = request.send(self.xmlstream)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
907 d.addCallback(cb)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
908 return d
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
909
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
910
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
911 def deleteNode(self, service, nodeIdentifier, sender=None):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
912 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
913 Delete a publish subscribe node.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
914
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
915 @param service: The publish subscribe service to delete the node from.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
916 @type service: L{JID<twisted.words.protocols.jabber.jid.JID>}
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
917 @param nodeIdentifier: The identifier of the node.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
918 @type nodeIdentifier: C{unicode}
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
919 """
22
5246a9186b91 tmp (wokkel.pubsub): PubSubRequest class can be overriden everywhere, including PubSubClient
Goffi <goffi@goffi.org>
parents: 21
diff changeset
920 request = self._request_class('delete')
0
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
921 request.recipient = service
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
922 request.nodeIdentifier = nodeIdentifier
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
923 request.sender = sender
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
924 return request.send(self.xmlstream)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
925
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
926
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
927 def subscribe(self, service, nodeIdentifier, subscriber,
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
928 options=None, sender=None):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
929 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
930 Subscribe to a publish subscribe node.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
931
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
932 @param service: The publish subscribe service that keeps the node.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
933 @type service: L{JID<twisted.words.protocols.jabber.jid.JID>}
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
934
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
935 @param nodeIdentifier: The identifier of the node.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
936 @type nodeIdentifier: C{unicode}
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
937
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
938 @param subscriber: The entity to subscribe to the node. This entity
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
939 will get notifications of new published items.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
940 @type subscriber: L{JID<twisted.words.protocols.jabber.jid.JID>}
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
941
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
942 @param options: Subscription options.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
943 @type options: C{dict}
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
944
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
945 @return: Deferred that fires with L{Subscription} or errbacks with
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
946 L{SubscriptionPending} or L{SubscriptionUnconfigured}.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
947 @rtype: L{defer.Deferred}
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
948 """
22
5246a9186b91 tmp (wokkel.pubsub): PubSubRequest class can be overriden everywhere, including PubSubClient
Goffi <goffi@goffi.org>
parents: 21
diff changeset
949 request = self._request_class('subscribe')
0
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
950 request.recipient = service
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
951 request.nodeIdentifier = nodeIdentifier
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
952 request.subscriber = subscriber
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
953 request.sender = sender
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
954
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
955 if options:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
956 form = data_form.Form(formType='submit',
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
957 formNamespace=NS_PUBSUB_SUBSCRIBE_OPTIONS)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
958 form.makeFields(options)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
959 request.options = form
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
960
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
961 def cb(iq):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
962 subscription = Subscription.fromElement(iq.pubsub.subscription)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
963
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
964 if subscription.state == 'pending':
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
965 raise SubscriptionPending()
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
966 elif subscription.state == 'unconfigured':
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
967 raise SubscriptionUnconfigured()
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
968 else:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
969 # we assume subscription == 'subscribed'
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
970 # any other value would be invalid, but that should have
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
971 # yielded a stanza error.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
972 return subscription
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
973
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
974 d = request.send(self.xmlstream)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
975 d.addCallback(cb)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
976 return d
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
977
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
978
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
979 def unsubscribe(self, service, nodeIdentifier, subscriber,
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
980 subscriptionIdentifier=None, sender=None):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
981 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
982 Unsubscribe from a publish subscribe node.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
983
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
984 @param service: The publish subscribe service that keeps the node.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
985 @type service: L{JID<twisted.words.protocols.jabber.jid.JID>}
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
986
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
987 @param nodeIdentifier: The identifier of the node.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
988 @type nodeIdentifier: C{unicode}
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
989
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
990 @param subscriber: The entity to unsubscribe from the node.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
991 @type subscriber: L{JID<twisted.words.protocols.jabber.jid.JID>}
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
992
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
993 @param subscriptionIdentifier: Optional subscription identifier.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
994 @type subscriptionIdentifier: C{unicode}
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
995 """
22
5246a9186b91 tmp (wokkel.pubsub): PubSubRequest class can be overriden everywhere, including PubSubClient
Goffi <goffi@goffi.org>
parents: 21
diff changeset
996 request = self._request_class('unsubscribe')
0
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
997 request.recipient = service
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
998 request.nodeIdentifier = nodeIdentifier
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
999 request.subscriber = subscriber
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1000 request.subscriptionIdentifier = subscriptionIdentifier
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1001 request.sender = sender
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1002 return request.send(self.xmlstream)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1003
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1004
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1005 def publish(self, service, nodeIdentifier, items=None, sender=None):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1006 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1007 Publish to a publish subscribe node.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1008
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1009 @param service: The publish subscribe service that keeps the node.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1010 @type service: L{JID<twisted.words.protocols.jabber.jid.JID>}
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1011 @param nodeIdentifier: The identifier of the node.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1012 @type nodeIdentifier: C{unicode}
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1013 @param items: Optional list of L{Item}s to publish.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1014 @type items: C{list}
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1015 """
22
5246a9186b91 tmp (wokkel.pubsub): PubSubRequest class can be overriden everywhere, including PubSubClient
Goffi <goffi@goffi.org>
parents: 21
diff changeset
1016 request = self._request_class('publish')
0
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1017 request.recipient = service
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1018 request.nodeIdentifier = nodeIdentifier
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1019 request.items = items
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1020 request.sender = sender
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1021 return request.send(self.xmlstream)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1022
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1023
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1024 def items(self, service, nodeIdentifier, maxItems=None, itemIdentifiers=None,
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1025 subscriptionIdentifier=None, sender=None):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1026 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1027 Retrieve previously published items from a publish subscribe node.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1028
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1029 @param service: The publish subscribe service that keeps the node.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1030 @type service: L{JID<twisted.words.protocols.jabber.jid.JID>}
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1031
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1032 @param nodeIdentifier: The identifier of the node.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1033 @type nodeIdentifier: C{unicode}
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1034
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1035 @param maxItems: Optional limit on the number of retrieved items.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1036 @type maxItems: C{int}
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1037
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1038 @param itemIdentifiers: Identifiers of the items to be retrieved.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1039 @type itemIdentifiers: C{set}
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1040
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1041 @param subscriptionIdentifier: Optional subscription identifier. In
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1042 case the node has been subscribed to multiple times, this narrows
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1043 the results to the specific subscription.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1044 @type subscriptionIdentifier: C{unicode}
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1045 """
22
5246a9186b91 tmp (wokkel.pubsub): PubSubRequest class can be overriden everywhere, including PubSubClient
Goffi <goffi@goffi.org>
parents: 21
diff changeset
1046 request = self._request_class('items')
0
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1047 request.recipient = service
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1048 request.nodeIdentifier = nodeIdentifier
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1049 if maxItems:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1050 request.maxItems = str(int(maxItems))
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1051 request.subscriptionIdentifier = subscriptionIdentifier
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1052 request.sender = sender
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1053 request.itemIdentifiers = itemIdentifiers
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1054
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1055 def cb(iq):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1056 items = []
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1057 for element in iq.pubsub.items.elements():
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1058 if element.uri == NS_PUBSUB and element.name == 'item':
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1059 items.append(element)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1060 return items
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1061
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1062 d = request.send(self.xmlstream)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1063 d.addCallback(cb)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1064 return d
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1065
13
22f0cb2fa793 tmp(pubsub): added retract "notify" attribute management
Goffi <goffi@goffi.org>
parents: 8
diff changeset
1066 def retractItems(self, service, nodeIdentifier, itemIdentifiers, notify=None, sender=None):
0
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1067 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1068 Retract items from a publish subscribe node.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1069
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1070 @param service: The publish subscribe service to delete the node from.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1071 @type service: L{JID<twisted.words.protocols.jabber.jid.JID>}
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1072 @param nodeIdentifier: The identifier of the node.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1073 @type nodeIdentifier: C{unicode}
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1074 @param itemIdentifiers: Identifiers of the items to be retracted.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1075 @type itemIdentifiers: C{set}
13
22f0cb2fa793 tmp(pubsub): added retract "notify" attribute management
Goffi <goffi@goffi.org>
parents: 8
diff changeset
1076 @param notify: True if notification is required
22f0cb2fa793 tmp(pubsub): added retract "notify" attribute management
Goffi <goffi@goffi.org>
parents: 8
diff changeset
1077 @type notify: C{unicode}
0
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1078 """
22
5246a9186b91 tmp (wokkel.pubsub): PubSubRequest class can be overriden everywhere, including PubSubClient
Goffi <goffi@goffi.org>
parents: 21
diff changeset
1079 request = self._request_class('retract')
0
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1080 request.recipient = service
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1081 request.nodeIdentifier = nodeIdentifier
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1082 request.itemIdentifiers = itemIdentifiers
13
22f0cb2fa793 tmp(pubsub): added retract "notify" attribute management
Goffi <goffi@goffi.org>
parents: 8
diff changeset
1083 request.notify = notify
0
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1084 request.sender = sender
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1085 return request.send(self.xmlstream)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1086
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1087 def getOptions(self, service, nodeIdentifier, subscriber,
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1088 subscriptionIdentifier=None, sender=None):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1089 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1090 Get subscription options.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1091
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1092 @param service: The publish subscribe service that keeps the node.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1093 @type service: L{JID<twisted.words.protocols.jabber.jid.JID>}
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1094
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1095 @param nodeIdentifier: The identifier of the node.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1096 @type nodeIdentifier: C{unicode}
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1097
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1098 @param subscriber: The entity subscribed to the node.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1099 @type subscriber: L{JID<twisted.words.protocols.jabber.jid.JID>}
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1100
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1101 @param subscriptionIdentifier: Optional subscription identifier.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1102 @type subscriptionIdentifier: C{unicode}
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1103
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1104 @rtype: L{data_form.Form}
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1105 """
22
5246a9186b91 tmp (wokkel.pubsub): PubSubRequest class can be overriden everywhere, including PubSubClient
Goffi <goffi@goffi.org>
parents: 21
diff changeset
1106 request = self._request_class('optionsGet')
0
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1107 request.recipient = service
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1108 request.nodeIdentifier = nodeIdentifier
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1109 request.subscriber = subscriber
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1110 request.subscriptionIdentifier = subscriptionIdentifier
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1111 request.sender = sender
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1112
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1113 def cb(iq):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1114 form = data_form.findForm(iq.pubsub.options,
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1115 NS_PUBSUB_SUBSCRIBE_OPTIONS)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1116 form.typeCheck()
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1117 return form
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1118
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1119 d = request.send(self.xmlstream)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1120 d.addCallback(cb)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1121 return d
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1122
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1123
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1124 def setOptions(self, service, nodeIdentifier, subscriber,
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1125 options, subscriptionIdentifier=None, sender=None):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1126 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1127 Set subscription options.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1128
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1129 @param service: The publish subscribe service that keeps the node.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1130 @type service: L{JID<twisted.words.protocols.jabber.jid.JID>}
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1131
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1132 @param nodeIdentifier: The identifier of the node.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1133 @type nodeIdentifier: C{unicode}
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1134
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1135 @param subscriber: The entity subscribed to the node.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1136 @type subscriber: L{JID<twisted.words.protocols.jabber.jid.JID>}
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1137
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1138 @param options: Subscription options.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1139 @type options: C{dict}.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1140
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1141 @param subscriptionIdentifier: Optional subscription identifier.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1142 @type subscriptionIdentifier: C{unicode}
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1143 """
22
5246a9186b91 tmp (wokkel.pubsub): PubSubRequest class can be overriden everywhere, including PubSubClient
Goffi <goffi@goffi.org>
parents: 21
diff changeset
1144 request = self._request_class('optionsSet')
0
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1145 request.recipient = service
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1146 request.nodeIdentifier = nodeIdentifier
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1147 request.subscriber = subscriber
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1148 request.subscriptionIdentifier = subscriptionIdentifier
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1149 request.sender = sender
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1150
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1151 form = data_form.Form(formType='submit',
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1152 formNamespace=NS_PUBSUB_SUBSCRIBE_OPTIONS)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1153 form.makeFields(options)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1154 request.options = form
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1155
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1156 d = request.send(self.xmlstream)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1157 return d
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1158
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1159
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1160
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1161 class PubSubService(XMPPHandler, IQHandlerMixin):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1162 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1163 Protocol implementation for a XMPP Publish Subscribe Service.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1164
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1165 The word Service here is used as taken from the Publish Subscribe
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1166 specification. It is the party responsible for keeping nodes and their
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1167 subscriptions, and sending out notifications.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1168
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1169 Methods from the L{IPubSubService} interface that are called as a result
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1170 of an XMPP request may raise exceptions. Alternatively the deferred
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1171 returned by these methods may have their errback called. These are handled
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1172 as follows:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1173
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1174 - If the exception is an instance of L{error.StanzaError}, an error
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1175 response iq is returned.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1176 - Any other exception is reported using L{log.msg}. An error response
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1177 with the condition C{internal-server-error} is returned.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1178
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1179 The default implementation of said methods raises an L{Unsupported}
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1180 exception and are meant to be overridden.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1181
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1182 @ivar discoIdentity: Service discovery identity as a dictionary with
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1183 keys C{'category'}, C{'type'} and C{'name'}.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1184 @ivar pubSubFeatures: List of supported publish-subscribe features for
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1185 service discovery, as C{str}.
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1186 @type pubSubFeatures: C{list} or C{None}
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1187 """
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1188
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1189 implements(IPubSubService, disco.IDisco)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1190
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1191 iqHandlers = {
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1192 '/*': '_onPubSubRequest',
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1193 }
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1194
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1195 _legacyHandlers = {
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1196 'publish': ('publish', ['sender', 'recipient',
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1197 'nodeIdentifier', 'items']),
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1198 'subscribe': ('subscribe', ['sender', 'recipient',
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1199 'nodeIdentifier', 'subscriber']),
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1200 'unsubscribe': ('unsubscribe', ['sender', 'recipient',
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1201 'nodeIdentifier', 'subscriber']),
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1202 'subscriptions': ('subscriptions', ['sender', 'recipient']),
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1203 'affiliations': ('affiliations', ['sender', 'recipient']),
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1204 'create': ('create', ['sender', 'recipient', 'nodeIdentifier']),
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1205 'getConfigurationOptions': ('getConfigurationOptions', []),
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1206 'default': ('getDefaultConfiguration',
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1207 ['sender', 'recipient', 'nodeType']),
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1208 'configureGet': ('getConfiguration', ['sender', 'recipient',
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1209 'nodeIdentifier']),
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1210 'configureSet': ('setConfiguration', ['sender', 'recipient',
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1211 'nodeIdentifier', 'options']),
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1212 'items': ('items', ['sender', 'recipient', 'nodeIdentifier',
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1213 'maxItems', 'itemIdentifiers']),
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1214 'retract': ('retract', ['sender', 'recipient', 'nodeIdentifier',
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1215 'itemIdentifiers']),
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1216 'purge': ('purge', ['sender', 'recipient', 'nodeIdentifier']),
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1217 'delete': ('delete', ['sender', 'recipient', 'nodeIdentifier']),
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1218 }
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1219
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1220 _request_class = PubSubRequest
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1221
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1222 hideNodes = False
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1223
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1224 def __init__(self, resource=None):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1225 self.resource = resource
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1226 self.discoIdentity = {'category': 'pubsub',
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1227 'type': 'service',
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1228 'name': 'Generic Publish-Subscribe Service'}
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1229
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1230 self.pubSubFeatures = []
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1231
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1232
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1233 def connectionMade(self):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1234 self.xmlstream.addObserver(PUBSUB_REQUEST, self.handleRequest)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1235
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1236
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1237 def getDiscoInfo(self, requestor, target, nodeIdentifier=''):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1238 def toInfo(nodeInfo):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1239 if not nodeInfo:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1240 return
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1241
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1242 (nodeType, metaData) = nodeInfo['type'], nodeInfo['meta-data']
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1243 info.append(disco.DiscoIdentity('pubsub', nodeType))
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1244 if metaData:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1245 form = data_form.Form(formType="result",
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1246 formNamespace=NS_PUBSUB_META_DATA)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1247 form.addField(
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1248 data_form.Field(
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1249 var='pubsub#node_type',
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1250 value=nodeType,
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1251 label='The type of node (collection or leaf)'
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1252 )
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1253 )
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1254
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1255 for metaDatum in metaData:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1256 form.addField(data_form.Field.fromDict(metaDatum))
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1257
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1258 info.append(form)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1259
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1260 return
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1261
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1262 info = []
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1263
22
5246a9186b91 tmp (wokkel.pubsub): PubSubRequest class can be overriden everywhere, including PubSubClient
Goffi <goffi@goffi.org>
parents: 21
diff changeset
1264 request = self._request_class('discoInfo')
0
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1265
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1266 if self.resource is not None:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1267 resource = self.resource.locateResource(request)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1268 identity = resource.discoIdentity
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1269 features = resource.features
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1270 getInfo = resource.getInfo
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1271 else:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1272 category = self.discoIdentity['category']
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1273 idType = self.discoIdentity['type']
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1274 name = self.discoIdentity['name']
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1275 identity = disco.DiscoIdentity(category, idType, name)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1276 features = self.pubSubFeatures
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1277 getInfo = self.getNodeInfo
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1278
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1279 if not nodeIdentifier:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1280 info.append(identity)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1281 info.append(disco.DiscoFeature(disco.NS_DISCO_ITEMS))
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1282 info.extend([disco.DiscoFeature("%s#%s" % (NS_PUBSUB, feature))
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1283 for feature in features])
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1284
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1285 d = defer.maybeDeferred(getInfo, requestor, target, nodeIdentifier or '')
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1286 d.addCallback(toInfo)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1287 d.addErrback(log.err)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1288 d.addCallback(lambda _: info)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1289 return d
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1290
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1291
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1292 def getDiscoItems(self, requestor, target, nodeIdentifier=''):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1293 if self.hideNodes:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1294 d = defer.succeed([])
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1295 elif self.resource is not None:
22
5246a9186b91 tmp (wokkel.pubsub): PubSubRequest class can be overriden everywhere, including PubSubClient
Goffi <goffi@goffi.org>
parents: 21
diff changeset
1296 request = self._request_class('discoInfo')
0
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1297 resource = self.resource.locateResource(request)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1298 d = resource.getNodes(requestor, target, nodeIdentifier)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1299 elif nodeIdentifier:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1300 d = self.getNodes(requestor, target)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1301 else:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1302 d = defer.succeed([])
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1303
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1304 d.addCallback(lambda nodes: [disco.DiscoItem(target, node)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1305 for node in nodes])
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1306 return d
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1307
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1308
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1309 def _onPubSubRequest(self, iq):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1310 request = self._request_class.fromElement(iq)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1311 if self.resource is not None:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1312 resource = self.resource.locateResource(request)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1313 else:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1314 resource = self
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1315
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1316 # Preprocess the request, knowing the handling resource
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1317 try:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1318 preProcessor = getattr(self, '_preProcess_%s' % request.verb)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1319 except AttributeError:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1320 pass
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1321 else:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1322 request = preProcessor(resource, request)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1323 if request is None:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1324 return defer.succeed(None)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1325
8
a07bf3fb4b54 core (tests): test fixes
Goffi <goffi@goffi.org>
parents: 6
diff changeset
1326 # Process the request itself,
0
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1327 if resource is not self:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1328 try:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1329 handler = getattr(resource, request.verb)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1330 except AttributeError:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1331 text = "Request verb: %s" % request.verb
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1332 return defer.fail(Unsupported('', text))
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1333
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1334 d = handler(request)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1335 else:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1336 try:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1337 handlerName, argNames = self._legacyHandlers[request.verb]
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1338 except KeyError:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1339 text = "Request verb: %s" % request.verb
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1340 return defer.fail(Unsupported('', text))
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1341
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1342 handler = getattr(self, handlerName)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1343 args = [getattr(request, arg) for arg in argNames]
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1344 d = handler(*args)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1345
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1346 # If needed, translate the result into a response
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1347 try:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1348 cb = getattr(self, '_toResponse_%s' % request.verb)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1349 except AttributeError:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1350 pass
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1351 else:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1352 d.addCallback(cb, resource, request)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1353
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1354 return d
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1355
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1356
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1357 def _toResponse_subscribe(self, result, resource, request):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1358 response = domish.Element((NS_PUBSUB, "pubsub"))
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1359 response.addChild(result.toElement(NS_PUBSUB))
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1360 return response
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1361
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1362
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1363 def _toResponse_subscriptions(self, result, resource, request):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1364 response = domish.Element((NS_PUBSUB, 'pubsub'))
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1365 subscriptions = response.addElement('subscriptions')
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1366 for subscription in result:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1367 subscriptions.addChild(subscription.toElement(NS_PUBSUB))
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1368 return response
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1369
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1370
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1371 def _toResponse_affiliations(self, result, resource, request):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1372 response = domish.Element((NS_PUBSUB, 'pubsub'))
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1373 affiliations = response.addElement('affiliations')
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1374
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1375 for nodeIdentifier, affiliation in result:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1376 item = affiliations.addElement('affiliation')
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1377 item['node'] = nodeIdentifier
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1378 item['affiliation'] = affiliation
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1379
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1380 return response
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1381
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1382
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1383 def _toResponse_create(self, result, resource, request):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1384 if not request.nodeIdentifier or request.nodeIdentifier != result:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1385 response = domish.Element((NS_PUBSUB, 'pubsub'))
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1386 create = response.addElement('create')
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1387 create['node'] = result
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1388 return response
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1389 else:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1390 return None
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1391
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1392
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1393 def _formFromConfiguration(self, resource, values):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1394 fieldDefs = resource.getConfigurationOptions()
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1395 form = data_form.Form(formType="form",
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1396 formNamespace=NS_PUBSUB_NODE_CONFIG)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1397 form.makeFields(values, fieldDefs)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1398 return form
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1399
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1400
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1401 def _checkConfiguration(self, resource, form):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1402 fieldDefs = resource.getConfigurationOptions()
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1403 form.typeCheck(fieldDefs, filterUnknown=True)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1404
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1405
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1406 def _preProcess_create(self, resource, request):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1407 if request.options:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1408 self._checkConfiguration(resource, request.options)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1409 return request
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1410
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1411
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1412 def _preProcess_default(self, resource, request):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1413 if request.nodeType not in ('leaf', 'collection'):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1414 raise error.StanzaError('not-acceptable')
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1415 else:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1416 return request
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1417
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1418
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1419 def _toResponse_default(self, options, resource, request):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1420 response = domish.Element((NS_PUBSUB_OWNER, "pubsub"))
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1421 default = response.addElement("default")
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1422 form = self._formFromConfiguration(resource, options)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1423 default.addChild(form.toElement())
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1424 return response
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1425
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1426
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1427 def _toResponse_configureGet(self, options, resource, request):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1428 response = domish.Element((NS_PUBSUB_OWNER, "pubsub"))
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1429 configure = response.addElement("configure")
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1430 form = self._formFromConfiguration(resource, options)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1431 configure.addChild(form.toElement())
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1432
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1433 if request.nodeIdentifier:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1434 configure["node"] = request.nodeIdentifier
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1435
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1436 return response
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1437
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1438
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1439 def _preProcess_configureSet(self, resource, request):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1440 if request.options.formType == 'cancel':
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1441 return None
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1442 else:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1443 self._checkConfiguration(resource, request.options)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1444 return request
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1445
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1446
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1447 def _toResponse_items(self, result, resource, request):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1448 response = domish.Element((NS_PUBSUB, 'pubsub'))
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1449 items = response.addElement('items')
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1450 items["node"] = request.nodeIdentifier
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1451
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1452 for item in result:
21
54f834e40341 tmp (wokkel/rsm): various improvments:
Goffi <goffi@goffi.org>
parents: 17
diff changeset
1453 item.uri = NS_PUBSUB
54f834e40341 tmp (wokkel/rsm): various improvments:
Goffi <goffi@goffi.org>
parents: 17
diff changeset
1454 items.addChild(item)
0
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1455
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1456 return response
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1457
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1458
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1459 def _createNotification(self, eventType, service, nodeIdentifier,
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1460 subscriber, subscriptions=None):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1461 headers = []
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1462
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1463 if subscriptions:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1464 for subscription in subscriptions:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1465 if nodeIdentifier != subscription.nodeIdentifier:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1466 headers.append(('Collection', subscription.nodeIdentifier))
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1467
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1468 message = domish.Element((None, "message"))
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1469 message["from"] = service.full()
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1470 message["to"] = subscriber.full()
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1471 event = message.addElement((NS_PUBSUB_EVENT, "event"))
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1472
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1473 element = event.addElement(eventType)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1474 element["node"] = nodeIdentifier
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1475
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1476 if headers:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1477 message.addChild(shim.Headers(headers))
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1478
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1479 return message
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1480
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1481
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1482 def _toResponse_affiliationsGet(self, result, resource, request):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1483 response = domish.Element((NS_PUBSUB_OWNER, 'pubsub'))
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1484 affiliations = response.addElement('affiliations')
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1485
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1486 if request.nodeIdentifier:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1487 affiliations['node'] = request.nodeIdentifier
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1488
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1489 for entity, affiliation in result.iteritems():
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1490 item = affiliations.addElement('affiliation')
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1491 item['jid'] = entity.full()
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1492 item['affiliation'] = affiliation
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1493
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1494 return response
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1495
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1496
40
03224edb88af tmp (wokkel/pubsub): subscriptions improvments:
Goffi <goffi@goffi.org>
parents: 39
diff changeset
1497 def _toResponse_subscriptionsGet(self, result, resource, request):
03224edb88af tmp (wokkel/pubsub): subscriptions improvments:
Goffi <goffi@goffi.org>
parents: 39
diff changeset
1498 response = domish.Element((NS_PUBSUB, 'pubsub'))
03224edb88af tmp (wokkel/pubsub): subscriptions improvments:
Goffi <goffi@goffi.org>
parents: 39
diff changeset
1499 subscriptions = response.addElement('subscriptions')
03224edb88af tmp (wokkel/pubsub): subscriptions improvments:
Goffi <goffi@goffi.org>
parents: 39
diff changeset
1500 subscriptions['node'] = request.nodeIdentifier
03224edb88af tmp (wokkel/pubsub): subscriptions improvments:
Goffi <goffi@goffi.org>
parents: 39
diff changeset
1501 for subscription in result:
03224edb88af tmp (wokkel/pubsub): subscriptions improvments:
Goffi <goffi@goffi.org>
parents: 39
diff changeset
1502 subscription_element = subscription.toElement(NS_PUBSUB)
03224edb88af tmp (wokkel/pubsub): subscriptions improvments:
Goffi <goffi@goffi.org>
parents: 39
diff changeset
1503 del subscription_element['node']
03224edb88af tmp (wokkel/pubsub): subscriptions improvments:
Goffi <goffi@goffi.org>
parents: 39
diff changeset
1504 subscriptions.addChild(subscription_element)
03224edb88af tmp (wokkel/pubsub): subscriptions improvments:
Goffi <goffi@goffi.org>
parents: 39
diff changeset
1505 return response
03224edb88af tmp (wokkel/pubsub): subscriptions improvments:
Goffi <goffi@goffi.org>
parents: 39
diff changeset
1506
03224edb88af tmp (wokkel/pubsub): subscriptions improvments:
Goffi <goffi@goffi.org>
parents: 39
diff changeset
1507
0
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1508 # public methods
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1509
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1510 def notifyPublish(self, service, nodeIdentifier, notifications):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1511 for subscriber, subscriptions, items in notifications:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1512 message = self._createNotification('items', service,
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1513 nodeIdentifier, subscriber,
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1514 subscriptions)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1515 for item in items:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1516 item.uri = NS_PUBSUB_EVENT
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1517 message.event.items.addChild(item)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1518 self.send(message)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1519
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1520
17
fd6957dfa8c6 tmp (wokkel.pubsub): implemented missing notifyRetract
Goffi <goffi@goffi.org>
parents: 14
diff changeset
1521 def notifyRetract(self, service, nodeIdentifier, notifications):
fd6957dfa8c6 tmp (wokkel.pubsub): implemented missing notifyRetract
Goffi <goffi@goffi.org>
parents: 14
diff changeset
1522 for subscriber, subscriptions, items in notifications:
fd6957dfa8c6 tmp (wokkel.pubsub): implemented missing notifyRetract
Goffi <goffi@goffi.org>
parents: 14
diff changeset
1523 message = self._createNotification('items', service,
fd6957dfa8c6 tmp (wokkel.pubsub): implemented missing notifyRetract
Goffi <goffi@goffi.org>
parents: 14
diff changeset
1524 nodeIdentifier, subscriber,
fd6957dfa8c6 tmp (wokkel.pubsub): implemented missing notifyRetract
Goffi <goffi@goffi.org>
parents: 14
diff changeset
1525 subscriptions)
fd6957dfa8c6 tmp (wokkel.pubsub): implemented missing notifyRetract
Goffi <goffi@goffi.org>
parents: 14
diff changeset
1526 for item in items:
fd6957dfa8c6 tmp (wokkel.pubsub): implemented missing notifyRetract
Goffi <goffi@goffi.org>
parents: 14
diff changeset
1527 retract = domish.Element((None, "retract"))
fd6957dfa8c6 tmp (wokkel.pubsub): implemented missing notifyRetract
Goffi <goffi@goffi.org>
parents: 14
diff changeset
1528 retract['id'] = item['id']
fd6957dfa8c6 tmp (wokkel.pubsub): implemented missing notifyRetract
Goffi <goffi@goffi.org>
parents: 14
diff changeset
1529 message.event.items.addChild(retract)
fd6957dfa8c6 tmp (wokkel.pubsub): implemented missing notifyRetract
Goffi <goffi@goffi.org>
parents: 14
diff changeset
1530 self.send(message)
fd6957dfa8c6 tmp (wokkel.pubsub): implemented missing notifyRetract
Goffi <goffi@goffi.org>
parents: 14
diff changeset
1531
fd6957dfa8c6 tmp (wokkel.pubsub): implemented missing notifyRetract
Goffi <goffi@goffi.org>
parents: 14
diff changeset
1532
0
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1533 def notifyDelete(self, service, nodeIdentifier, subscribers,
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1534 redirectURI=None):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1535 for subscriber in subscribers:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1536 message = self._createNotification('delete', service,
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1537 nodeIdentifier,
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1538 subscriber)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1539 if redirectURI:
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1540 redirect = message.event.delete.addElement('redirect')
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1541 redirect['uri'] = redirectURI
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1542 self.send(message)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1543
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1544
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1545 def getNodeInfo(self, requestor, service, nodeIdentifier):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1546 return None
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1547
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1548
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1549 def getNodes(self, requestor, service):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1550 return []
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1551
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1552
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1553 def publish(self, requestor, service, nodeIdentifier, items):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1554 raise Unsupported('publish')
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1555
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1556
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1557 def subscribe(self, requestor, service, nodeIdentifier, subscriber):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1558 raise Unsupported('subscribe')
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1559
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1560
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1561 def unsubscribe(self, requestor, service, nodeIdentifier, subscriber):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1562 raise Unsupported('subscribe')
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1563
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1564
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1565 def subscriptions(self, requestor, service):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1566 raise Unsupported('retrieve-subscriptions')
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1567
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1568
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1569 def affiliations(self, requestor, service):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1570 raise Unsupported('retrieve-affiliations')
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1571
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1572
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1573 def create(self, requestor, service, nodeIdentifier):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1574 raise Unsupported('create-nodes')
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1575
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1576
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1577 def getConfigurationOptions(self):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1578 return {}
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1579
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1580
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1581 def getDefaultConfiguration(self, requestor, service, nodeType):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1582 raise Unsupported('retrieve-default')
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1583
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1584
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1585 def getConfiguration(self, requestor, service, nodeIdentifier):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1586 raise Unsupported('config-node')
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1587
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1588
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1589 def setConfiguration(self, requestor, service, nodeIdentifier, options):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1590 raise Unsupported('config-node')
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1591
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1592
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1593 def items(self, requestor, service, nodeIdentifier, maxItems,
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1594 itemIdentifiers):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1595 raise Unsupported('retrieve-items')
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1596
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1597
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1598 def retract(self, requestor, service, nodeIdentifier, itemIdentifiers):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1599 raise Unsupported('retract-items')
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1600
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1601
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1602 def purge(self, requestor, service, nodeIdentifier):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1603 raise Unsupported('purge-nodes')
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1604
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1605
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1606 def delete(self, requestor, service, nodeIdentifier):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1607 raise Unsupported('delete-nodes')
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1608
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1609
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1610
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1611 class PubSubResource(object):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1612
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1613 implements(IPubSubResource)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1614
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1615 features = []
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1616 discoIdentity = disco.DiscoIdentity('pubsub',
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1617 'service',
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1618 'Publish-Subscribe Service')
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1619
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1620
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1621 def locateResource(self, request):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1622 return self
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1623
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1624
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1625 def getInfo(self, requestor, service, nodeIdentifier):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1626 return defer.succeed(None)
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1627
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1628
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1629 def getNodes(self, requestor, service, nodeIdentifier):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1630 return defer.succeed([])
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1631
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1632
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1633 def getConfigurationOptions(self):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1634 return {}
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1635
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1636
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1637 def publish(self, request):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1638 return defer.fail(Unsupported('publish'))
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1639
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1640
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1641 def subscribe(self, request):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1642 return defer.fail(Unsupported('subscribe'))
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1643
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1644
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1645 def unsubscribe(self, request):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1646 return defer.fail(Unsupported('subscribe'))
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1647
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1648
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1649 def subscriptions(self, request):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1650 return defer.fail(Unsupported('retrieve-subscriptions'))
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1651
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1652
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1653 def affiliations(self, request):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1654 return defer.fail(Unsupported('retrieve-affiliations'))
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1655
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1656
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1657 def create(self, request):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1658 return defer.fail(Unsupported('create-nodes'))
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1659
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1660
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1661 def default(self, request):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1662 return defer.fail(Unsupported('retrieve-default'))
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1663
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1664
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1665 def configureGet(self, request):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1666 return defer.fail(Unsupported('config-node'))
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1667
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1668
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1669 def configureSet(self, request):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1670 return defer.fail(Unsupported('config-node'))
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1671
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1672
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1673 def items(self, request):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1674 return defer.fail(Unsupported('retrieve-items'))
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1675
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1676
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1677 def retract(self, request):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1678 return defer.fail(Unsupported('retract-items'))
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1679
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1680
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1681 def purge(self, request):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1682 return defer.fail(Unsupported('purge-nodes'))
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1683
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1684
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1685 def delete(self, request):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1686 return defer.fail(Unsupported('delete-nodes'))
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1687
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1688
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1689 def affiliationsGet(self, request):
37
e8296d7bfeb1 tmp (wokkel/pubsub): fixed affiliations (normal entity) handling
Goffi <goffi@goffi.org>
parents: 36
diff changeset
1690 return defer.fail(Unsupported('retrieve-affiliations'))
0
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1691
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1692
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1693 def affiliationsSet(self, request):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1694 return defer.fail(Unsupported('modify-affiliations'))
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1695
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1696
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1697 def subscriptionsGet(self, request):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1698 return defer.fail(Unsupported('manage-subscriptions'))
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1699
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1700
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1701 def subscriptionsSet(self, request):
09e7c32a6a00 use sat.tmp.wokkel as a buffer module until the changes are integrated to wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1702 return defer.fail(Unsupported('manage-subscriptions'))