Mercurial > libervia-backend
comparison src/plugins/plugin_xep_0277.py @ 587:952322b1d490
Remove trailing whitespaces.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Fri, 18 Jan 2013 17:55:34 +0100 |
parents | ca13633d3b6b |
children | beaf6bec2fcd |
comparison
equal
deleted
inserted
replaced
586:6a718ede8be1 | 587:952322b1d490 |
---|---|
155 @param errback: used for the async answer | 155 @param errback: used for the async answer |
156 """ | 156 """ |
157 assert(callback) | 157 assert(callback) |
158 d = self.host.plugins["XEP-0060"].getItems(jid.JID(pub_jid), NS_MICROBLOG, max_items=max_items, profile_key=profile_key) | 158 d = self.host.plugins["XEP-0060"].getItems(jid.JID(pub_jid), NS_MICROBLOG, max_items=max_items, profile_key=profile_key) |
159 d.addCallback(lambda items: map(self.item2mbdata, items)) | 159 d.addCallback(lambda items: map(self.item2mbdata, items)) |
160 | 160 |
161 def setMicroblogAccess(self, access="presence", profile_key='@DEFAULT@'): | 161 def setMicroblogAccess(self, access="presence", profile_key='@DEFAULT@'): |
162 """Create a microblog node on PEP with given access | 162 """Create a microblog node on PEP with given access |
163 If the node already exists, it change options | 163 If the node already exists, it change options |
164 @param access: Node access model, according to xep-0060 #4.5 | 164 @param access: Node access model, according to xep-0060 #4.5 |
165 @param profile_key: profile key""" | 165 @param profile_key: profile key""" |
167 _jid, xmlstream = self.host.getJidNStream(profile_key) | 167 _jid, xmlstream = self.host.getJidNStream(profile_key) |
168 if not _jid: | 168 if not _jid: |
169 error(_("Can't find profile's jid")) | 169 error(_("Can't find profile's jid")) |
170 return | 170 return |
171 _options = {OPT_ACCESS_MODEL:access, OPT_PERSIST_ITEMS:1, OPT_MAX_ITEMS:-1, OPT_DELIVER_PAYLOADS:1, OPT_SEND_ITEM_SUBSCRIBE: 1} | 171 _options = {OPT_ACCESS_MODEL:access, OPT_PERSIST_ITEMS:1, OPT_MAX_ITEMS:-1, OPT_DELIVER_PAYLOADS:1, OPT_SEND_ITEM_SUBSCRIBE: 1} |
172 | 172 |
173 def cb(result): | 173 def cb(result): |
174 #Node is created with right permission | 174 #Node is created with right permission |
175 debug(_("Microblog node has now access %s") % access) | 175 debug(_("Microblog node has now access %s") % access) |
176 | 176 |
177 def fatal_err(s_error): | 177 def fatal_err(s_error): |
186 #d = self.host.plugins["XEP-0060"].deleteNode(_jid.userhostJID(), NS_MICROBLOG, profile_key=profile_key) | 186 #d = self.host.plugins["XEP-0060"].deleteNode(_jid.userhostJID(), NS_MICROBLOG, profile_key=profile_key) |
187 #d.addCallback(lambda x: create_node().addCallback(cb).addErrback(fatal_err)) | 187 #d.addCallback(lambda x: create_node().addCallback(cb).addErrback(fatal_err)) |
188 change_node_options().addCallback(cb).addErrback(fatal_err) | 188 change_node_options().addCallback(cb).addErrback(fatal_err) |
189 else: | 189 else: |
190 fatal_err(s_error) | 190 fatal_err(s_error) |
191 | 191 |
192 def create_node(): | 192 def create_node(): |
193 return self.host.plugins["XEP-0060"].createNode(_jid.userhostJID(), NS_MICROBLOG, _options, profile_key=profile_key) | 193 return self.host.plugins["XEP-0060"].createNode(_jid.userhostJID(), NS_MICROBLOG, _options, profile_key=profile_key) |
194 | 194 |
195 def change_node_options(): | 195 def change_node_options(): |
196 return self.host.plugins["XEP-0060"].setOptions(_jid.userhostJID(), NS_MICROBLOG, _jid.userhostJID(), _options, profile_key=profile_key) | 196 return self.host.plugins["XEP-0060"].setOptions(_jid.userhostJID(), NS_MICROBLOG, _jid.userhostJID(), _options, profile_key=profile_key) |
197 | 197 |
198 create_node().addCallback(cb).addErrback(err_cb) | 198 create_node().addCallback(cb).addErrback(err_cb) |
199 | 199 |
200 | 200 |
201 | 201 |