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