Mercurial > libervia-backend
annotate src/plugins/plugin_xep_0060.py @ 559:bdcd8c6c4ed4
core: renamed badly named ConnectedProfileError
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 16 Dec 2012 18:02:43 +0100 |
parents | 2a072735e459 |
children | ca13633d3b6b |
rev | line source |
---|---|
283
68cd30d982a5
core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
1 #!/usr/bin/python |
68cd30d982a5
core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
2 # -*- coding: utf-8 -*- |
68cd30d982a5
core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
3 |
68cd30d982a5
core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
4 """ |
68cd30d982a5
core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
5 SAT plugin for Publish-Subscribe (xep-0060) |
459 | 6 Copyright (C) 2009, 2010, 2011, 2012 Jérôme Poisson (goffi@goffi.org) |
283
68cd30d982a5
core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
7 |
68cd30d982a5
core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
8 This program is free software: you can redistribute it and/or modify |
480
2a072735e459
Licence modification: the full project is now under AGPL v3+ instead of GPL v3+
Goffi <goffi@goffi.org>
parents:
477
diff
changeset
|
9 it under the terms of the GNU Affero General Public License as published by |
283
68cd30d982a5
core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
10 the Free Software Foundation, either version 3 of the License, or |
68cd30d982a5
core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
11 (at your option) any later version. |
68cd30d982a5
core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
12 |
68cd30d982a5
core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
13 This program is distributed in the hope that it will be useful, |
68cd30d982a5
core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
14 but WITHOUT ANY WARRANTY; without even the implied warranty of |
68cd30d982a5
core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
480
2a072735e459
Licence modification: the full project is now under AGPL v3+ instead of GPL v3+
Goffi <goffi@goffi.org>
parents:
477
diff
changeset
|
16 GNU Affero General Public License for more details. |
283
68cd30d982a5
core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
17 |
480
2a072735e459
Licence modification: the full project is now under AGPL v3+ instead of GPL v3+
Goffi <goffi@goffi.org>
parents:
477
diff
changeset
|
18 You should have received a copy of the GNU Affero General Public License |
283
68cd30d982a5
core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
19 along with this program. If not, see <http://www.gnu.org/licenses/>. |
68cd30d982a5
core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
20 """ |
68cd30d982a5
core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
21 |
68cd30d982a5
core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
22 from logging import debug, info, error |
68cd30d982a5
core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
23 from twisted.internet import protocol |
68cd30d982a5
core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
24 from twisted.words.protocols.jabber import client, jid |
68cd30d982a5
core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
25 from twisted.words.protocols.jabber import error as jab_error |
68cd30d982a5
core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
26 import twisted.internet.error |
68cd30d982a5
core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
27 |
68cd30d982a5
core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
28 from wokkel import disco, iwokkel, pubsub |
68cd30d982a5
core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
29 |
68cd30d982a5
core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
30 from zope.interface import implements |
68cd30d982a5
core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
31 |
68cd30d982a5
core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
32 PLUGIN_INFO = { |
68cd30d982a5
core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
33 "name": "Publish-Subscribe", |
291 | 34 "import_name": "XEP-0060", |
283
68cd30d982a5
core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
35 "type": "XEP", |
68cd30d982a5
core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
36 "protocols": ["XEP-0060"], |
68cd30d982a5
core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
37 "dependencies": [], |
68cd30d982a5
core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
38 "main": "XEP_0060", |
68cd30d982a5
core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
39 "handler": "yes", |
68cd30d982a5
core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
40 "description": _("""Implementation of PubSub Protocol""") |
68cd30d982a5
core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
41 } |
68cd30d982a5
core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
42 |
68cd30d982a5
core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
43 class XEP_0060(): |
68cd30d982a5
core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
44 |
68cd30d982a5
core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
45 def __init__(self, host): |
68cd30d982a5
core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
46 info(_("PubSub plugin initialization")) |
68cd30d982a5
core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
47 self.host = host |
68cd30d982a5
core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
48 self.managedNodes=[] |
68cd30d982a5
core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
49 self.clients={} |
372
f964dcec1611
core: plugins refactored according to bridge + updatedValue now use profile
Goffi <goffi@goffi.org>
parents:
310
diff
changeset
|
50 """host.bridge.addMethod("getItems", ".plugin", in_sign='ssa{ss}s', out_sign='as', method=self.getItems, |
301
e33b3a777f10
plugin xep-0060: added getEntry method
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
51 async = True, |
e33b3a777f10
plugin xep-0060: added getEntry method
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
52 doc = { 'summary':'retrieve items', |
e33b3a777f10
plugin xep-0060: added getEntry method
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
53 'param_0':'service: pubsub service', |
e33b3a777f10
plugin xep-0060: added getEntry method
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
54 'param_1':'node: node identifier', |
e33b3a777f10
plugin xep-0060: added getEntry method
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
55 'param_2':'\n'.join(['options: can be:', |
e33b3a777f10
plugin xep-0060: added getEntry method
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
56 '- max_items: see XEP-0060 #6.5.7', |
e33b3a777f10
plugin xep-0060: added getEntry method
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
57 '- sub_id: subscription identifier, see XEP-0060 #7.2.2.2']), |
e33b3a777f10
plugin xep-0060: added getEntry method
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
58 'param_3':'%(doc_profile)s', |
e33b3a777f10
plugin xep-0060: added getEntry method
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
59 'return':'array of raw XML (content of the items)' |
e33b3a777f10
plugin xep-0060: added getEntry method
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
60 })""" |
283
68cd30d982a5
core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
61 |
68cd30d982a5
core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
62 def getHandler(self, profile): |
68cd30d982a5
core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
63 self.clients[profile] = SatPubSubClient(self.host, self) |
68cd30d982a5
core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
64 return self.clients[profile] |
68cd30d982a5
core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
65 |
68cd30d982a5
core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
66 def addManagedNode(self, node_name, callback): |
68cd30d982a5
core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
67 """Add a handler for a namespace |
68cd30d982a5
core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
68 @param namespace: NS of the handler (will appear in disco info) |
68cd30d982a5
core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
69 @param callback: method to call when the handler is found |
68cd30d982a5
core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
70 @param profile: profile which manage this handler""" |
68cd30d982a5
core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
71 self.managedNodes.append((node_name, callback)) |
68cd30d982a5
core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
72 |
303
2b52a5da0978
plugin XEP_0277: microblog access model can now be changed
Goffi <goffi@goffi.org>
parents:
301
diff
changeset
|
73 def __getClientNProfile(self, profile_key, action='do pusbsub'): |
2b52a5da0978
plugin XEP_0277: microblog access model can now be changed
Goffi <goffi@goffi.org>
parents:
301
diff
changeset
|
74 """Return a tuple of (client, profile) |
2b52a5da0978
plugin XEP_0277: microblog access model can now be changed
Goffi <goffi@goffi.org>
parents:
301
diff
changeset
|
75 raise error when the profile doesn't exists |
2b52a5da0978
plugin XEP_0277: microblog access model can now be changed
Goffi <goffi@goffi.org>
parents:
301
diff
changeset
|
76 @param profile_key: as usual :) |
2b52a5da0978
plugin XEP_0277: microblog access model can now be changed
Goffi <goffi@goffi.org>
parents:
301
diff
changeset
|
77 @param action: text of action to show in case of error""" |
286
3b382fa0ac28
plugin xep-0163: added mood publishing
Goffi <goffi@goffi.org>
parents:
283
diff
changeset
|
78 profile = self.host.memory.getProfileName(profile_key) |
3b382fa0ac28
plugin xep-0163: added mood publishing
Goffi <goffi@goffi.org>
parents:
283
diff
changeset
|
79 if not profile: |
303
2b52a5da0978
plugin XEP_0277: microblog access model can now be changed
Goffi <goffi@goffi.org>
parents:
301
diff
changeset
|
80 err_mess = _('Trying to %(action)s with an unknown profile key [%(profile_key)s]') % { |
2b52a5da0978
plugin XEP_0277: microblog access model can now be changed
Goffi <goffi@goffi.org>
parents:
301
diff
changeset
|
81 'action':action, |
2b52a5da0978
plugin XEP_0277: microblog access model can now be changed
Goffi <goffi@goffi.org>
parents:
301
diff
changeset
|
82 'profile_key':profile_key} |
286
3b382fa0ac28
plugin xep-0163: added mood publishing
Goffi <goffi@goffi.org>
parents:
283
diff
changeset
|
83 error(err_mess) |
3b382fa0ac28
plugin xep-0163: added mood publishing
Goffi <goffi@goffi.org>
parents:
283
diff
changeset
|
84 raise Exception(err_mess) |
3b382fa0ac28
plugin xep-0163: added mood publishing
Goffi <goffi@goffi.org>
parents:
283
diff
changeset
|
85 try: |
3b382fa0ac28
plugin xep-0163: added mood publishing
Goffi <goffi@goffi.org>
parents:
283
diff
changeset
|
86 client = self.clients[profile] |
3b382fa0ac28
plugin xep-0163: added mood publishing
Goffi <goffi@goffi.org>
parents:
283
diff
changeset
|
87 except KeyError: |
3b382fa0ac28
plugin xep-0163: added mood publishing
Goffi <goffi@goffi.org>
parents:
283
diff
changeset
|
88 err_mess = _('INTERNAL ERROR: no handler for required profile') |
3b382fa0ac28
plugin xep-0163: added mood publishing
Goffi <goffi@goffi.org>
parents:
283
diff
changeset
|
89 error(err_mess) |
3b382fa0ac28
plugin xep-0163: added mood publishing
Goffi <goffi@goffi.org>
parents:
283
diff
changeset
|
90 raise Exception(err_mess) |
303
2b52a5da0978
plugin XEP_0277: microblog access model can now be changed
Goffi <goffi@goffi.org>
parents:
301
diff
changeset
|
91 return profile, client |
2b52a5da0978
plugin XEP_0277: microblog access model can now be changed
Goffi <goffi@goffi.org>
parents:
301
diff
changeset
|
92 |
2b52a5da0978
plugin XEP_0277: microblog access model can now be changed
Goffi <goffi@goffi.org>
parents:
301
diff
changeset
|
93 def publish(self, service, nodeIdentifier, items=None, profile_key='@DEFAULT@'): |
2b52a5da0978
plugin XEP_0277: microblog access model can now be changed
Goffi <goffi@goffi.org>
parents:
301
diff
changeset
|
94 profile,client = self.__getClientNProfile(profile_key, 'publish item') |
2b52a5da0978
plugin XEP_0277: microblog access model can now be changed
Goffi <goffi@goffi.org>
parents:
301
diff
changeset
|
95 return client.publish(service, nodeIdentifier, items, client.parent.jid) |
286
3b382fa0ac28
plugin xep-0163: added mood publishing
Goffi <goffi@goffi.org>
parents:
283
diff
changeset
|
96 |
301
e33b3a777f10
plugin xep-0060: added getEntry method
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
97 def getItems(self, service, node, max_items=None, sub_id=None, profile_key='@DEFAULT@'): |
303
2b52a5da0978
plugin XEP_0277: microblog access model can now be changed
Goffi <goffi@goffi.org>
parents:
301
diff
changeset
|
98 profile,client = self.__getClientNProfile(profile_key, 'get items') |
301
e33b3a777f10
plugin xep-0060: added getEntry method
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
99 return client.items(service, node, max_items, sub_id, client.parent.jid) |
303
2b52a5da0978
plugin XEP_0277: microblog access model can now be changed
Goffi <goffi@goffi.org>
parents:
301
diff
changeset
|
100 |
2b52a5da0978
plugin XEP_0277: microblog access model can now be changed
Goffi <goffi@goffi.org>
parents:
301
diff
changeset
|
101 def getOptions(self, service, nodeIdentifier, subscriber, subscriptionIdentifier=None, profile_key='@DEFAULT@'): |
2b52a5da0978
plugin XEP_0277: microblog access model can now be changed
Goffi <goffi@goffi.org>
parents:
301
diff
changeset
|
102 profile,client = self.__getClientNProfile(profile_key, 'get options') |
2b52a5da0978
plugin XEP_0277: microblog access model can now be changed
Goffi <goffi@goffi.org>
parents:
301
diff
changeset
|
103 return client.getOptions(service, nodeIdentifier, subscriber, subscriptionIdentifier) |
2b52a5da0978
plugin XEP_0277: microblog access model can now be changed
Goffi <goffi@goffi.org>
parents:
301
diff
changeset
|
104 |
2b52a5da0978
plugin XEP_0277: microblog access model can now be changed
Goffi <goffi@goffi.org>
parents:
301
diff
changeset
|
105 def setOptions(self, service, nodeIdentifier, subscriber, options, subscriptionIdentifier=None, profile_key='@DEFAULT@'): |
2b52a5da0978
plugin XEP_0277: microblog access model can now be changed
Goffi <goffi@goffi.org>
parents:
301
diff
changeset
|
106 profile,client = self.__getClientNProfile(profile_key, 'set options') |
2b52a5da0978
plugin XEP_0277: microblog access model can now be changed
Goffi <goffi@goffi.org>
parents:
301
diff
changeset
|
107 return client.setOptions(service, nodeIdentifier, subscriber, options, subscriptionIdentifier) |
2b52a5da0978
plugin XEP_0277: microblog access model can now be changed
Goffi <goffi@goffi.org>
parents:
301
diff
changeset
|
108 |
2b52a5da0978
plugin XEP_0277: microblog access model can now be changed
Goffi <goffi@goffi.org>
parents:
301
diff
changeset
|
109 def createNode(self, service, nodeIdentifier, options, profile_key='@DEFAULT@'): |
2b52a5da0978
plugin XEP_0277: microblog access model can now be changed
Goffi <goffi@goffi.org>
parents:
301
diff
changeset
|
110 profile,client = self.__getClientNProfile(profile_key, 'create node') |
2b52a5da0978
plugin XEP_0277: microblog access model can now be changed
Goffi <goffi@goffi.org>
parents:
301
diff
changeset
|
111 return client.createNode(service, nodeIdentifier, options) |
2b52a5da0978
plugin XEP_0277: microblog access model can now be changed
Goffi <goffi@goffi.org>
parents:
301
diff
changeset
|
112 |
2b52a5da0978
plugin XEP_0277: microblog access model can now be changed
Goffi <goffi@goffi.org>
parents:
301
diff
changeset
|
113 def deleteNode(self, service, nodeIdentifier, profile_key='@DEFAULT@'): |
2b52a5da0978
plugin XEP_0277: microblog access model can now be changed
Goffi <goffi@goffi.org>
parents:
301
diff
changeset
|
114 profile,client = self.__getClientNProfile(profile_key, 'delete node') |
2b52a5da0978
plugin XEP_0277: microblog access model can now be changed
Goffi <goffi@goffi.org>
parents:
301
diff
changeset
|
115 return client.deleteNode(service, nodeIdentifier) |
310
53adec87d1d7
plugin group blog: group blog subscription
Goffi <goffi@goffi.org>
parents:
303
diff
changeset
|
116 |
53adec87d1d7
plugin group blog: group blog subscription
Goffi <goffi@goffi.org>
parents:
303
diff
changeset
|
117 def subscribe(self, service, nodeIdentifier, sub_jid = None, options=None, profile_key='@DEFAULT@'): |
53adec87d1d7
plugin group blog: group blog subscription
Goffi <goffi@goffi.org>
parents:
303
diff
changeset
|
118 profile,client = self.__getClientNProfile(profile_key, 'subscribe node') |
53adec87d1d7
plugin group blog: group blog subscription
Goffi <goffi@goffi.org>
parents:
303
diff
changeset
|
119 return client.subscribe(service, nodeIdentifier, sub_jid or client.parent.jid.userhostJID(), options=options) |
303
2b52a5da0978
plugin XEP_0277: microblog access model can now be changed
Goffi <goffi@goffi.org>
parents:
301
diff
changeset
|
120 |
301
e33b3a777f10
plugin xep-0060: added getEntry method
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
121 |
283
68cd30d982a5
core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
122 class SatPubSubClient(pubsub.PubSubClient): |
68cd30d982a5
core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
123 implements(disco.IDisco) |
68cd30d982a5
core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
124 |
68cd30d982a5
core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
125 def __init__(self, host, parent_plugin): |
68cd30d982a5
core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
126 self.host=host |
68cd30d982a5
core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
127 self.parent_plugin = parent_plugin |
68cd30d982a5
core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
128 pubsub.PubSubClient.__init__(self) |
68cd30d982a5
core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
129 |
68cd30d982a5
core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
130 def connectionInitialized(self): |
68cd30d982a5
core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
131 pubsub.PubSubClient.connectionInitialized(self) |
68cd30d982a5
core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
132 |
68cd30d982a5
core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
133 def itemsReceived(self, event): |
477
031b0e0aaab8
plugin groupblog: subscriptions/notifications
Goffi <goffi@goffi.org>
parents:
459
diff
changeset
|
134 if not self.host.trigger.point("PubSubItemsReceived", event, self.parent.profile): |
031b0e0aaab8
plugin groupblog: subscriptions/notifications
Goffi <goffi@goffi.org>
parents:
459
diff
changeset
|
135 return |
283
68cd30d982a5
core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
136 for node in self.parent_plugin.managedNodes: |
68cd30d982a5
core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
137 if event.nodeIdentifier == node[0]: |
68cd30d982a5
core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
138 return node[1](event, self.parent.profile) |
68cd30d982a5
core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
139 |
68cd30d982a5
core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
140 def deleteReceived(self, event): |
303
2b52a5da0978
plugin XEP_0277: microblog access model can now be changed
Goffi <goffi@goffi.org>
parents:
301
diff
changeset
|
141 #TODO: manage delete event |
2b52a5da0978
plugin XEP_0277: microblog access model can now be changed
Goffi <goffi@goffi.org>
parents:
301
diff
changeset
|
142 debug(_("Publish node deleted")) |
283
68cd30d982a5
core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
143 |
68cd30d982a5
core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
144 def purgeReceived(self, event): |
68cd30d982a5
core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
145 import pdb |
68cd30d982a5
core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
146 pdb.set_trace() |
68cd30d982a5
core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
147 |
68cd30d982a5
core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
148 def getDiscoInfo(self, requestor, target, nodeIdentifier=''): |
68cd30d982a5
core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
149 _disco_info = [] |
68cd30d982a5
core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
150 self.host.trigger.point("PubSub Disco Info", _disco_info, self.parent.profile) |
68cd30d982a5
core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
151 return _disco_info |
68cd30d982a5
core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
152 |
68cd30d982a5
core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
153 def getDiscoItems(self, requestor, target, nodeIdentifier=''): |
68cd30d982a5
core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
154 return [] |
68cd30d982a5
core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
155 |