def handle_info_request(self, iq): request = iq.payload try: node = self._node_mounts[request.node] except KeyError: raise errors.XMPPModifyError( condition=(namespaces.stanzas, "item-not-found") ) response = disco_xso.InfoQuery() for category, type_, lang, name in node.iter_identities(): response.identities.append(disco_xso.Identity( category=category, type_=type_, lang=lang, name=name )) if not response.identities: raise errors.XMPPModifyError( condition=(namespaces.stanzas, "item-not-found"), ) response.features.update(node.iter_features()) return response
def handle_info_request(self, iq): request = iq.payload try: node = self._node_mounts[request.node] except KeyError: raise errors.XMPPModifyError( condition=errors.ErrorCondition.ITEM_NOT_FOUND) response = node.as_info_xso(iq) response.node = request.node if not response.identities: raise errors.XMPPModifyError( condition=errors.ErrorCondition.ITEM_NOT_FOUND, ) return response
def handle_info_request(self, iq): request = iq.payload try: node = self._node_mounts[request.node] except KeyError: raise errors.XMPPModifyError(condition=(namespaces.stanzas, "item-not-found")) response = node.as_info_xso(iq) response.node = request.node if not response.identities: raise errors.XMPPModifyError(condition=(namespaces.stanzas, "item-not-found"), ) return response
def handle_items_request(self, iq): request = iq.payload try: node = self._node_mounts[request.node] except KeyError: raise errors.XMPPModifyError( condition=errors.ErrorCondition.ITEM_NOT_FOUND) response = disco_xso.ItemsQuery() response.items.extend(node.iter_items(iq)) return response
def handle_items_request(self, iq): request = iq.payload try: node = self._node_mounts[request.node] except KeyError: raise errors.XMPPModifyError(condition=(namespaces.stanzas, "item-not-found")) response = disco_xso.ItemsQuery() response.items.extend(node.iter_items(iq)) return response
def _handle_open_request(self, iq): peer_jid = iq.from_ sid = iq.payload.sid block_size = iq.payload.block_size stanza_type = iq.payload.stanza if block_size > MAX_BLOCK_SIZE: raise errors.XMPPModifyError( condition=errors.ErrorCondition.RESOURCE_CONSTRAINT ) try: protocol_factory, expected_future = \ self._expected_sessions[sid, peer_jid] except KeyError: if len(self._sessions) >= self.session_limit: raise errors.XMPPCancelError( condition=errors.ErrorCondition.NOT_ACCEPTABLE ) expected_future = None protocol_factory = self.default_protocol_factory if (sid, peer_jid) in self._sessions: # disallow opening a session twice if expected_future is not None: # is this correct? expected_future.cancel() raise errors.XMPPCancelError( condition=errors.ErrorCondition.NOT_ACCEPTABLE ) handle = self._sessions[sid, peer_jid] = IBBTransport( self, peer_jid, sid, stanza_type, block_size ) protocol = protocol_factory() handle.set_protocol(protocol) if expected_future is None: self.on_session_accepted((handle, protocol)) else: expected_future.set_result((handle, protocol))