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; 023 024import org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamRequest; 025import org.jivesoftware.smackx.bytestreams.socks5.Socks5BytestreamRequest; 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 NoResponseException 061 * @throws SmackException 062 */ 063 BytestreamSession accept() throws InterruptedException, XMPPErrorException, SmackException; 064 065 /** 066 * Rejects the bytestream request by sending a reject error to the initiator. 067 * @throws NotConnectedException 068 * @throws InterruptedException 069 */ 070 void reject() throws NotConnectedException, InterruptedException; 071 072}