annotate src/tmp/wokkel/pubsub.py @ 1422:be1fccf4854d

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