001/** 002 * 003 * Copyright the original author or authors 004 * 005 * Licensed under the Apache License, Version 2.0 (the "License"); 006 * you may not use this file except in compliance with the License. 007 * You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.jivesoftware.smackx.bytestreams; 018 019import org.jivesoftware.smack.SmackException.NotConnectedException; 020import org.jivesoftware.smack.XMPPException.XMPPErrorException; 021 022import org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamRequest; 023import org.jivesoftware.smackx.bytestreams.socks5.Socks5BytestreamRequest; 024import org.jivesoftware.smackx.bytestreams.socks5.Socks5Exception.CouldNotConnectToAnyProvidedSocks5Host; 025import org.jivesoftware.smackx.bytestreams.socks5.Socks5Exception.NoSocks5StreamHostsProvided; 026 027import org.jxmpp.jid.Jid; 028 029/** 030 * BytestreamRequest provides an interface to handle incoming bytestream requests. 031 * <p> 032 * There are two implementations of the interface. See {@link Socks5BytestreamRequest} and 033 * {@link InBandBytestreamRequest}. 034 * 035 * @author Henning Staib 036 */ 037public interface BytestreamRequest { 038 039 /** 040 * Returns the sender of the bytestream open request. 041 * 042 * @return the sender of the bytestream open request 043 */ 044 Jid getFrom(); 045 046 /** 047 * Returns the session ID of the bytestream open request. 048 * 049 * @return the session ID of the bytestream open request 050 */ 051 String getSessionID(); 052 053 /** 054 * Accepts the bytestream open request and returns the session to send/receive data. 055 * 056 * @return the session to send/receive data 057 * @throws XMPPErrorException if an error occurred while accepting the bytestream request 058 * @throws InterruptedException if the thread was interrupted while waiting in a blocking 059 * operation 060 * @throws NotConnectedException if the XMPP connection is not connected. 061 * @throws CouldNotConnectToAnyProvidedSocks5Host if no connection to any provided stream host could be established 062 * @throws NoSocks5StreamHostsProvided if no stream host was provided. 063 */ 064 BytestreamSession accept() throws InterruptedException, XMPPErrorException, CouldNotConnectToAnyProvidedSocks5Host, 065 NotConnectedException, NoSocks5StreamHostsProvided; 066 067 /** 068 * Rejects the bytestream request by sending a reject error to the initiator. 069 * @throws NotConnectedException if the XMPP connection is not connected. 070 * @throws InterruptedException if the calling thread was interrupted. 071 */ 072 void reject() throws NotConnectedException, InterruptedException; 073 074}