Changeset 748
- Timestamp:
- 07/28/08 15:13:17 (4 months ago)
- Files:
-
- oss/headstock/headstock/api/discovery.py (modified) (3 diffs)
- oss/headstock/headstock/protocol/extension/discovery.py (modified) (7 diffs)
- oss/headstock/headstock/protocol/extension/pubsub.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
oss/headstock/headstock/api/discovery.py
r746 r748 118 118 elif i.xml_ns == XMPP_DATA_FORM_NS: 119 119 disco.data_form = Data.from_element(i) 120 elif c.xml_ns == XMPP_CLIENT_NS and c.xml_name == 'error': 121 disco.error = Error.from_element(c) 120 122 121 123 return disco … … 251 253 def __init__(self, from_jid, to_jid, node_name=None, type=u'get', stanza_id=None): 252 254 Entity.__init__(self, from_jid, to_jid, type, stanza_id) 255 self.data_form = None 253 256 self.node_name = node_name 257 self.identities = [] 258 self.features = [] 259 self.items = [] 254 260 255 261 @staticmethod … … 265 271 def from_element(e): 266 272 disco = InformationDiscovery(JID.parse(e.get_attribute_value('from')), 267 JID.parse(e.get_attribute_value('to')), 268 type=e.get_attribute_value('type'), 269 stanza_id=e.get_attribute_value('id')) 270 271 return disco 273 JID.parse(e.get_attribute_value('to')), 274 type=e.get_attribute_value('type'), 275 stanza_id=e.get_attribute_value('id')) 276 277 for c in e.xml_children: 278 if not isinstance(c, E): 279 continue 280 281 if c.xml_ns in [XMPP_DISCO_INFO_NS, XMPP_DISCO_ITEMS_NS]: 282 disco.node_name = c.get_attribute_value('node') 283 for i in c.xml_children: 284 if i.xml_ns in [XMPP_DISCO_INFO_NS, XMPP_DISCO_ITEMS_NS]: 285 if i.xml_name == 'identity': 286 ident = Identity(i.get_attribute_value('name'), 287 i.get_attribute_value('category'), 288 i.get_attribute_value('type')) 289 disco.identities.append(ident) 290 elif i.xml_name == 'feature': 291 feat = Feature(i.get_attribute_value('var')) 292 disco.features.append(feat) 293 elif i.xml_name == 'item': 294 jid = JID.parse(unicode(i.get_attribute_value('jid'))) 295 item = Item(jid, i.get_attribute_value('action'), 296 i.get_attribute_value('name'), 297 i.get_attribute_value('node')) 298 disco.items.append(item) 299 elif i.xml_ns == XMPP_DATA_FORM_NS: 300 disco.data_form = Data.from_element(i) 301 elif c.xml_ns == XMPP_CLIENT_NS and c.xml_name == 'error': 302 disco.error = Error.from_element(c) 303 return disco oss/headstock/headstock/protocol/extension/discovery.py
r746 r748 9 9 from Axon.Component import component 10 10 from Axon.Ipc import shutdownMicroprocess, producerFinished 11 from Kamaelia.Util.Fanout import Fanout 11 12 12 13 … … 51 52 handled = False 52 53 a = self.recv("inbox") 53 e = a.xml_parent 54 self.send(('INCOMING', e), "log") 55 56 msg_type = e.get_attribute_value(u'type') or u'get' 57 key = 'xmpp.%s' % unicode(msg_type) 58 59 if key in self.outboxes: 60 self.send(FeaturesDiscovery.from_element(e), key) 61 handled = True 62 63 if not handled: 64 self.send(e, "unknown") 54 if a.get_attribute_value(u'node') == None: 55 e = a.xml_parent 56 self.send(('INCOMING', e), "log") 57 58 msg_type = e.get_attribute_value(u'type') or u'get' 59 key = 'xmpp.%s' % unicode(msg_type) 60 61 62 if key in self.outboxes: 63 self.send(FeaturesDiscovery.from_element(e), key) 64 handled = True 65 66 if not handled: 67 self.send(e, "unknown") 65 68 66 69 if not self.anyReady(): … … 269 272 handled = False 270 273 s = self.recv("inbox") 271 e = s.xml_parent.xml_parent272 self.send(('INCOMING', e), "log")273 274 msg_type = e.get_attribute_value(u'type') or u'get' 275 key = 'xmpp.%s' % unicode(msg_type)276 277 if key in self.outboxes:278 self.send(InformationDiscovery.from_element(e), key)279 handled = True280 281 if not handled:282 self.send(e, "unknown")274 if s.get_attribute_value(u'node') != None: 275 e = s.xml_parent 276 self.send(('INCOMING', e), "log") 277 278 msg_type = e.get_attribute_value(u'type') or u'get' 279 key = 'xmpp.%s' % unicode(msg_type) 280 if key in self.outboxes: 281 self.send(InformationDiscovery.from_element(e), key) 282 handled = True 283 284 if not handled: 285 self.send(e, "unknown") 283 286 284 287 if not self.anyReady(): … … 361 364 super(DiscoveryDispatcher, self).__init__() 362 365 363 def initComponents(self): 366 def initComponents(self): 367 fanout = Fanout(["features", "info"]) 368 self.link((self, 'inbox'), (fanout, 'inbox'), passthrough=1) 369 self.addChildren(fanout) 370 fanout.activate() 371 364 372 subdisp = SubscriptionsDiscoveryDispatcher() 365 373 self.link((self, 'subscription.inbox'), (subdisp, 'inbox'), passthrough=1) … … 397 405 398 406 featdisp = FeaturesDiscoveryDispatcher() 407 self.link((fanout, 'features'), (featdisp, 'inbox')) 399 408 self.link((self, 'features.inbox'), (featdisp, 'inbox'), passthrough=1) 400 409 self.link((self, 'features.forward'), (featdisp, 'forward'), passthrough=1) … … 431 440 432 441 infodisp = InformationDiscoveryDispatcher() 442 self.link((fanout, 'info'), (infodisp, 'inbox')) 433 443 self.link((self, 'info.inbox'), (infodisp, 'inbox'), passthrough=1) 434 444 self.link((self, 'info.forward'), (infodisp, 'forward'), passthrough=1) … … 456 466 mes = self.recv("control") 457 467 458 if isinstance(mes, shutdownMicroprocess) or isinstance(mes, producerFinished): 468 if isinstance(mes, shutdownMicroprocess) or \ 469 isinstance(mes, producerFinished): 459 470 self.send(producerFinished(), "signal") 460 471 break oss/headstock/headstock/protocol/extension/pubsub.py
r739 r748 788 788 mes = self.recv("control") 789 789 790 if isinstance(mes, shutdownMicroprocess) or isinstance(mes, producerFinished): 791 self.send(producerFinished(), "signal") 792 break 793 794 if not self.anyReady(): 795 self.pause() 796 797 yield 1 798 799 yield 1 790 if isinstance(mes, shutdownMicroprocess) or \ 791 isinstance(mes, producerFinished): 792 self.send(producerFinished(), "signal") 793 break 794 795 if not self.anyReady(): 796 self.pause() 797 798 yield 1 799 800 yield 1
