comparison src/plugins/plugin_xep_0060.py @ 745:812dc38c0094

plugins groupblog (xep-0060, xep-0277): added blog item modification/deletion
author souliane <souliane@mailoo.org>
date Tue, 10 Dec 2013 09:02:20 +0100
parents 3c304929af74
children bfabeedbf32e
comparison
equal deleted inserted replaced
744:312a2842b2b8 745:812dc38c0094
16 16
17 # You should have received a copy of the GNU Affero General Public License 17 # You should have received a copy of the GNU Affero General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. 18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 19
20 from logging import debug, info, error 20 from logging import debug, info, error
21 21 from wokkel.pubsub import PubSubRequest
22 from wokkel import disco, pubsub 22 from wokkel import disco, pubsub
23
24 from zope.interface import implements 23 from zope.interface import implements
25 24
26 PLUGIN_INFO = { 25 PLUGIN_INFO = {
27 "name": "Publish-Subscribe", 26 "name": "Publish-Subscribe",
28 "import_name": "XEP-0060", 27 "import_name": "XEP-0060",
117 116
118 def deleteNode(self, service, nodeIdentifier, profile_key='@DEFAULT@'): 117 def deleteNode(self, service, nodeIdentifier, profile_key='@DEFAULT@'):
119 profile, client = self.__getClientNProfile(profile_key, 'delete node') 118 profile, client = self.__getClientNProfile(profile_key, 'delete node')
120 return client.deleteNode(service, nodeIdentifier) 119 return client.deleteNode(service, nodeIdentifier)
121 120
121 def retractItems(self, service, nodeIdentifier, itemIdentifiers, profile_key='@DEFAULT@'):
122 profile, client = self.__getClientNProfile(profile_key, 'retract items')
123 return client.retractItems(service, nodeIdentifier, itemIdentifiers)
124
122 def subscribe(self, service, nodeIdentifier, sub_jid=None, options=None, profile_key='@DEFAULT@'): 125 def subscribe(self, service, nodeIdentifier, sub_jid=None, options=None, profile_key='@DEFAULT@'):
123 profile, client = self.__getClientNProfile(profile_key, 'subscribe node') 126 profile, client = self.__getClientNProfile(profile_key, 'subscribe node')
124 return client.subscribe(service, nodeIdentifier, sub_jid or client.parent.jid.userhostJID(), options=options) 127 return client.subscribe(service, nodeIdentifier, sub_jid or client.parent.jid.userhostJID(), options=options)
125 128
126 129
132 self.parent_plugin = parent_plugin 135 self.parent_plugin = parent_plugin
133 pubsub.PubSubClient.__init__(self) 136 pubsub.PubSubClient.__init__(self)
134 137
135 def connectionInitialized(self): 138 def connectionInitialized(self):
136 pubsub.PubSubClient.connectionInitialized(self) 139 pubsub.PubSubClient.connectionInitialized(self)
140
141 # XXX: this should be done in wokkel
142 def retractItems(self, service, nodeIdentifier, itemIdentifiers, sender=None):
143 """
144 Retract items from a publish subscribe node.
145
146 @param service: The publish subscribe service to delete the node from.
147 @type service: L{JID<twisted.words.protocols.jabber.jid.JID>}
148 @param nodeIdentifier: The identifier of the node.
149 @type nodeIdentifier: C{unicode}
150 @param itemIdentifiers: Identifiers of the items to be retracted.
151 @type itemIdentifiers: C{set}
152 """
153 request = PubSubRequest('retract')
154 request.recipient = service
155 request.nodeIdentifier = nodeIdentifier
156 request.itemIdentifiers = itemIdentifiers
157 request.sender = sender
158 return request.send(self.xmlstream)
137 159
138 def itemsReceived(self, event): 160 def itemsReceived(self, event):
139 if not self.host.trigger.point("PubSubItemsReceived", event, self.parent.profile): 161 if not self.host.trigger.point("PubSubItemsReceived", event, self.parent.profile):
140 return 162 return
141 for node in self.parent_plugin.managedNodes: 163 for node in self.parent_plugin.managedNodes: