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;
020import org.jivesoftware.smack.SmackException.NoResponseException;
021import org.jivesoftware.smack.SmackException.NotConnectedException;
022import org.jivesoftware.smack.XMPPException.XMPPErrorException;
023import org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamRequest;
024import org.jivesoftware.smackx.bytestreams.socks5.Socks5BytestreamRequest;
025
026/**
027 * BytestreamRequest provides an interface to handle incoming bytestream requests.
028 * <p>
029 * There are two implementations of the interface. See {@link Socks5BytestreamRequest} and
030 * {@link InBandBytestreamRequest}.
031 * 
032 * @author Henning Staib
033 */
034public interface BytestreamRequest {
035
036    /**
037     * Returns the sender of the bytestream open request.
038     * 
039     * @return the sender of the bytestream open request
040     */
041    public String getFrom();
042
043    /**
044     * Returns the session ID of the bytestream open request.
045     * 
046     * @return the session ID of the bytestream open request
047     */
048    public String getSessionID();
049
050    /**
051     * Accepts the bytestream open request and returns the session to send/receive data.
052     * 
053     * @return the session to send/receive data
054     * @throws XMPPErrorException if an error occurred while accepting the bytestream request
055     * @throws InterruptedException if the thread was interrupted while waiting in a blocking
056     *         operation
057     * @throws NoResponseException 
058     * @throws SmackException 
059     */
060    public BytestreamSession accept() throws InterruptedException, NoResponseException, XMPPErrorException, SmackException;
061
062    /**
063     * Rejects the bytestream request by sending a reject error to the initiator.
064     * @throws NotConnectedException 
065     */
066    public void reject() throws NotConnectedException;
067
068}