annotate src/plugins/plugin_xep_0060.py @ 609:84a6e83157c2

fixed licences in docstrings (they are now in comments)
author Goffi <goffi@goffi.org>
date Fri, 08 Mar 2013 00:36:22 +0100
parents e629371a28d3
children 6f4c31192c7c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
609
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 594
diff changeset
4 # SAT plugin for Publish-Subscribe (xep-0060)
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 594
diff changeset
5 # Copyright (C) 2009, 2010, 2011, 2012, 2013 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
6
609
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 594
diff changeset
7 # This program is free software: you can redistribute it and/or modify
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 594
diff changeset
8 # it under the terms of the GNU Affero General Public License as published by
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 594
diff changeset
9 # the Free Software Foundation, either version 3 of the License, or
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 594
diff changeset
10 # (at your option) any later version.
283
68cd30d982a5 core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff changeset
11
609
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 594
diff changeset
12 # This program is distributed in the hope that it will be useful,
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 594
diff changeset
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 594
diff changeset
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 594
diff changeset
15 # 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
16
609
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 594
diff changeset
17 # You should have received a copy of the GNU Affero General Public License
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 594
diff changeset
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
283
68cd30d982a5 core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff changeset
19
68cd30d982a5 core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff changeset
20 from logging import debug, info, error
68cd30d982a5 core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff changeset
21 from twisted.internet import protocol
68cd30d982a5 core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff changeset
22 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
23 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
24 import twisted.internet.error
68cd30d982a5 core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff changeset
25
68cd30d982a5 core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff changeset
26 from wokkel import disco, iwokkel, pubsub
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 zope.interface import implements
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 PLUGIN_INFO = {
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
31 "name": "Publish-Subscribe",
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
32 "import_name": "XEP-0060",
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
33 "type": "XEP",
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
34 "protocols": ["XEP-0060"],
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
35 "dependencies": [],
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
36 "main": "XEP_0060",
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
37 "handler": "yes",
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
38 "description": _("""Implementation of PubSub Protocol""")
283
68cd30d982a5 core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff changeset
39 }
68cd30d982a5 core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff changeset
40
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
41
588
beaf6bec2fcd Remove every old-style class.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 587
diff changeset
42 class XEP_0060(object):
283
68cd30d982a5 core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff changeset
43
68cd30d982a5 core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff changeset
44 def __init__(self, host):
68cd30d982a5 core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff changeset
45 info(_("PubSub plugin initialization"))
68cd30d982a5 core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff changeset
46 self.host = host
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
47 self.managedNodes = []
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
48 self.clients = {}
372
f964dcec1611 core: plugins refactored according to bridge + updatedValue now use profile
Goffi <goffi@goffi.org>
parents: 310
diff changeset
49 """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
50 async = True,
e33b3a777f10 plugin xep-0060: added getEntry method
Goffi <goffi@goffi.org>
parents: 291
diff changeset
51 doc = { 'summary':'retrieve items',
e33b3a777f10 plugin xep-0060: added getEntry method
Goffi <goffi@goffi.org>
parents: 291
diff changeset
52 'param_0':'service: pubsub service',
e33b3a777f10 plugin xep-0060: added getEntry method
Goffi <goffi@goffi.org>
parents: 291
diff changeset
53 'param_1':'node: node identifier',
e33b3a777f10 plugin xep-0060: added getEntry method
Goffi <goffi@goffi.org>
parents: 291
diff changeset
54 'param_2':'\n'.join(['options: can be:',
e33b3a777f10 plugin xep-0060: added getEntry method
Goffi <goffi@goffi.org>
parents: 291
diff changeset
55 '- max_items: see XEP-0060 #6.5.7',
e33b3a777f10 plugin xep-0060: added getEntry method
Goffi <goffi@goffi.org>
parents: 291
diff changeset
56 '- 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
57 'param_3':'%(doc_profile)s',
e33b3a777f10 plugin xep-0060: added getEntry method
Goffi <goffi@goffi.org>
parents: 291
diff changeset
58 'return':'array of raw XML (content of the items)'
e33b3a777f10 plugin xep-0060: added getEntry method
Goffi <goffi@goffi.org>
parents: 291
diff changeset
59 })"""
283
68cd30d982a5 core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff changeset
60
68cd30d982a5 core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff changeset
61 def getHandler(self, profile):
68cd30d982a5 core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff changeset
62 self.clients[profile] = SatPubSubClient(self.host, self)
68cd30d982a5 core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff changeset
63 return self.clients[profile]
68cd30d982a5 core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff changeset
64
68cd30d982a5 core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff changeset
65 def addManagedNode(self, node_name, callback):
68cd30d982a5 core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff changeset
66 """Add a handler for a namespace
68cd30d982a5 core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff changeset
67 @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
68 @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
69 @param profile: profile which manage this handler"""
68cd30d982a5 core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff changeset
70 self.managedNodes.append((node_name, callback))
68cd30d982a5 core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff changeset
71
303
2b52a5da0978 plugin XEP_0277: microblog access model can now be changed
Goffi <goffi@goffi.org>
parents: 301
diff changeset
72 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
73 """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
74 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
75 @param profile_key: as usual :)
2b52a5da0978 plugin XEP_0277: microblog access model can now be changed
Goffi <goffi@goffi.org>
parents: 301
diff changeset
76 @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
77 profile = self.host.memory.getProfileName(profile_key)
3b382fa0ac28 plugin xep-0163: added mood publishing
Goffi <goffi@goffi.org>
parents: 283
diff changeset
78 if not profile:
303
2b52a5da0978 plugin XEP_0277: microblog access model can now be changed
Goffi <goffi@goffi.org>
parents: 301
diff changeset
79 err_mess = _('Trying to %(action)s with an unknown profile key [%(profile_key)s]') % {
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
80 'action': action,
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
81 'profile_key': profile_key}
286
3b382fa0ac28 plugin xep-0163: added mood publishing
Goffi <goffi@goffi.org>
parents: 283
diff changeset
82 error(err_mess)
3b382fa0ac28 plugin xep-0163: added mood publishing
Goffi <goffi@goffi.org>
parents: 283
diff changeset
83 raise Exception(err_mess)
3b382fa0ac28 plugin xep-0163: added mood publishing
Goffi <goffi@goffi.org>
parents: 283
diff changeset
84 try:
3b382fa0ac28 plugin xep-0163: added mood publishing
Goffi <goffi@goffi.org>
parents: 283
diff changeset
85 client = self.clients[profile]
3b382fa0ac28 plugin xep-0163: added mood publishing
Goffi <goffi@goffi.org>
parents: 283
diff changeset
86 except KeyError:
3b382fa0ac28 plugin xep-0163: added mood publishing
Goffi <goffi@goffi.org>
parents: 283
diff changeset
87 err_mess = _('INTERNAL ERROR: no handler for required profile')
3b382fa0ac28 plugin xep-0163: added mood publishing
Goffi <goffi@goffi.org>
parents: 283
diff changeset
88 error(err_mess)
3b382fa0ac28 plugin xep-0163: added mood publishing
Goffi <goffi@goffi.org>
parents: 283
diff changeset
89 raise Exception(err_mess)
303
2b52a5da0978 plugin XEP_0277: microblog access model can now be changed
Goffi <goffi@goffi.org>
parents: 301
diff changeset
90 return profile, client
2b52a5da0978 plugin XEP_0277: microblog access model can now be changed
Goffi <goffi@goffi.org>
parents: 301
diff changeset
91
2b52a5da0978 plugin XEP_0277: microblog access model can now be changed
Goffi <goffi@goffi.org>
parents: 301
diff changeset
92 def publish(self, service, nodeIdentifier, items=None, profile_key='@DEFAULT@'):
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
93 profile, client = self.__getClientNProfile(profile_key, 'publish item')
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 572
diff changeset
94 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
95
301
e33b3a777f10 plugin xep-0060: added getEntry method
Goffi <goffi@goffi.org>
parents: 291
diff changeset
96 def getItems(self, service, node, max_items=None, sub_id=None, profile_key='@DEFAULT@'):
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
97 profile, client = self.__getClientNProfile(profile_key, 'get items')
301
e33b3a777f10 plugin xep-0060: added getEntry method
Goffi <goffi@goffi.org>
parents: 291
diff changeset
98 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
99
2b52a5da0978 plugin XEP_0277: microblog access model can now be changed
Goffi <goffi@goffi.org>
parents: 301
diff changeset
100 def getOptions(self, service, nodeIdentifier, subscriber, subscriptionIdentifier=None, profile_key='@DEFAULT@'):
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
101 profile, client = self.__getClientNProfile(profile_key, 'get options')
303
2b52a5da0978 plugin XEP_0277: microblog access model can now be changed
Goffi <goffi@goffi.org>
parents: 301
diff changeset
102 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
103
2b52a5da0978 plugin XEP_0277: microblog access model can now be changed
Goffi <goffi@goffi.org>
parents: 301
diff changeset
104 def setOptions(self, service, nodeIdentifier, subscriber, options, subscriptionIdentifier=None, profile_key='@DEFAULT@'):
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
105 profile, client = self.__getClientNProfile(profile_key, 'set options')
303
2b52a5da0978 plugin XEP_0277: microblog access model can now be changed
Goffi <goffi@goffi.org>
parents: 301
diff changeset
106 return client.setOptions(service, nodeIdentifier, subscriber, options, subscriptionIdentifier)
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 572
diff changeset
107
303
2b52a5da0978 plugin XEP_0277: microblog access model can now be changed
Goffi <goffi@goffi.org>
parents: 301
diff changeset
108 def createNode(self, service, nodeIdentifier, options, profile_key='@DEFAULT@'):
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
109 profile, client = self.__getClientNProfile(profile_key, 'create node')
303
2b52a5da0978 plugin XEP_0277: microblog access model can now be changed
Goffi <goffi@goffi.org>
parents: 301
diff changeset
110 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
111
2b52a5da0978 plugin XEP_0277: microblog access model can now be changed
Goffi <goffi@goffi.org>
parents: 301
diff changeset
112 def deleteNode(self, service, nodeIdentifier, profile_key='@DEFAULT@'):
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
113 profile, client = self.__getClientNProfile(profile_key, 'delete node')
303
2b52a5da0978 plugin XEP_0277: microblog access model can now be changed
Goffi <goffi@goffi.org>
parents: 301
diff changeset
114 return client.deleteNode(service, nodeIdentifier)
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 572
diff changeset
115
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
116 def subscribe(self, service, nodeIdentifier, sub_jid=None, options=None, profile_key='@DEFAULT@'):
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
117 profile, client = self.__getClientNProfile(profile_key, 'subscribe node')
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 572
diff changeset
118 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
119
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 572
diff changeset
120
283
68cd30d982a5 core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff changeset
121 class SatPubSubClient(pubsub.PubSubClient):
68cd30d982a5 core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff changeset
122 implements(disco.IDisco)
68cd30d982a5 core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff changeset
123
68cd30d982a5 core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff changeset
124 def __init__(self, host, parent_plugin):
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
125 self.host = host
283
68cd30d982a5 core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff changeset
126 self.parent_plugin = parent_plugin
68cd30d982a5 core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff changeset
127 pubsub.PubSubClient.__init__(self)
68cd30d982a5 core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff changeset
128
68cd30d982a5 core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff changeset
129 def connectionInitialized(self):
68cd30d982a5 core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff changeset
130 pubsub.PubSubClient.connectionInitialized(self)
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 572
diff changeset
131
283
68cd30d982a5 core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff changeset
132 def itemsReceived(self, event):
477
031b0e0aaab8 plugin groupblog: subscriptions/notifications
Goffi <goffi@goffi.org>
parents: 459
diff changeset
133 if not self.host.trigger.point("PubSubItemsReceived", event, self.parent.profile):
031b0e0aaab8 plugin groupblog: subscriptions/notifications
Goffi <goffi@goffi.org>
parents: 459
diff changeset
134 return
283
68cd30d982a5 core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff changeset
135 for node in self.parent_plugin.managedNodes:
68cd30d982a5 core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff changeset
136 if event.nodeIdentifier == node[0]:
68cd30d982a5 core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff changeset
137 return node[1](event, self.parent.profile)
68cd30d982a5 core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff changeset
138
68cd30d982a5 core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff changeset
139 def deleteReceived(self, event):
303
2b52a5da0978 plugin XEP_0277: microblog access model can now be changed
Goffi <goffi@goffi.org>
parents: 301
diff changeset
140 #TODO: manage delete event
2b52a5da0978 plugin XEP_0277: microblog access model can now be changed
Goffi <goffi@goffi.org>
parents: 301
diff changeset
141 debug(_("Publish node deleted"))
283
68cd30d982a5 core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff changeset
142
68cd30d982a5 core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff changeset
143 def purgeReceived(self, event):
68cd30d982a5 core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff changeset
144 import pdb
68cd30d982a5 core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff changeset
145 pdb.set_trace()
68cd30d982a5 core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff changeset
146
68cd30d982a5 core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff changeset
147 def getDiscoInfo(self, requestor, target, nodeIdentifier=''):
68cd30d982a5 core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff changeset
148 _disco_info = []
68cd30d982a5 core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff changeset
149 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
150 return _disco_info
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 572
diff changeset
151
283
68cd30d982a5 core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff changeset
152 def getDiscoItems(self, requestor, target, nodeIdentifier=''):
68cd30d982a5 core: added plugins for PubSub et PEP (first drafts)
Goffi <goffi@goffi.org>
parents:
diff changeset
153 return []