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 java.io.IOException; 020 021import org.jivesoftware.smack.SmackException; 022import org.jivesoftware.smack.XMPPException; 023import org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamManager; 024import org.jivesoftware.smackx.bytestreams.socks5.Socks5BytestreamManager; 025 026/** 027 * BytestreamManager provides a generic interface for bytestream managers. 028 * <p> 029 * There are two implementations of the interface. See {@link Socks5BytestreamManager} and 030 * {@link InBandBytestreamManager}. 031 * 032 * @author Henning Staib 033 */ 034public interface BytestreamManager { 035 036 /** 037 * Adds {@link BytestreamListener} that is called for every incoming bytestream request unless 038 * there is a user specific {@link BytestreamListener} registered. 039 * <p> 040 * See {@link Socks5BytestreamManager#addIncomingBytestreamListener(BytestreamListener)} and 041 * {@link InBandBytestreamManager#addIncomingBytestreamListener(BytestreamListener)} for further 042 * details. 043 * 044 * @param listener the listener to register 045 */ 046 public void addIncomingBytestreamListener(BytestreamListener listener); 047 048 /** 049 * Removes the given listener from the list of listeners for all incoming bytestream requests. 050 * 051 * @param listener the listener to remove 052 */ 053 public void removeIncomingBytestreamListener(BytestreamListener listener); 054 055 /** 056 * Adds {@link BytestreamListener} that is called for every incoming bytestream request unless 057 * there is a user specific {@link BytestreamListener} registered. 058 * <p> 059 * Use this method if you are awaiting an incoming bytestream request from a specific user. 060 * <p> 061 * See {@link Socks5BytestreamManager#addIncomingBytestreamListener(BytestreamListener, String)} 062 * and {@link InBandBytestreamManager#addIncomingBytestreamListener(BytestreamListener, String)} 063 * for further details. 064 * 065 * @param listener the listener to register 066 * @param initiatorJID the JID of the user that wants to establish a bytestream 067 */ 068 public void addIncomingBytestreamListener(BytestreamListener listener, String initiatorJID); 069 070 /** 071 * Removes the listener for the given user. 072 * 073 * @param initiatorJID the JID of the user the listener should be removed 074 */ 075 public void removeIncomingBytestreamListener(String initiatorJID); 076 077 /** 078 * Establishes a bytestream with the given user and returns the session to send/receive data 079 * to/from the user. 080 * <p> 081 * Use this method to establish bytestreams to users accepting all incoming bytestream requests 082 * since this method doesn't provide a way to tell the user something about the data to be sent. 083 * <p> 084 * To establish a bytestream after negotiation the kind of data to be sent (e.g. file transfer) 085 * use {@link #establishSession(String, String)}. 086 * <p> 087 * See {@link Socks5BytestreamManager#establishSession(String)} and 088 * {@link InBandBytestreamManager#establishSession(String)} for further details. 089 * 090 * @param targetJID the JID of the user a bytestream should be established 091 * @return the session to send/receive data to/from the user 092 * @throws XMPPException if an error occurred while establishing the session 093 * @throws IOException if an IO error occurred while establishing the session 094 * @throws InterruptedException if the thread was interrupted while waiting in a blocking 095 * operation 096 */ 097 public BytestreamSession establishSession(String targetJID) throws XMPPException, IOException, 098 InterruptedException, SmackException; 099 100 /** 101 * Establishes a bytestream with the given user and returns the session to send/receive data 102 * to/from the user. 103 * <p> 104 * See {@link Socks5BytestreamManager#establishSession(String)} and 105 * {@link InBandBytestreamManager#establishSession(String)} for further details. 106 * 107 * @param targetJID the JID of the user a bytestream should be established 108 * @param sessionID the session ID for the bytestream request 109 * @return the session to send/receive data to/from the user 110 * @throws XMPPException if an error occurred while establishing the session 111 * @throws IOException if an IO error occurred while establishing the session 112 * @throws InterruptedException if the thread was interrupted while waiting in a blocking 113 * operation 114 */ 115 public BytestreamSession establishSession(String targetJID, String sessionID) 116 throws XMPPException, IOException, InterruptedException, SmackException; 117 118}