mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2025-12-08 06:01:07 +01:00
applied patches for extracted api for socks5 bytestreams and in-band bytestream
git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/branches/improve_bytestreams@11818 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
parent
0540662db2
commit
8cb01900c9
72 changed files with 11761 additions and 1893 deletions
|
|
@ -0,0 +1,47 @@
|
|||
/**
|
||||
* All rights reserved. Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jivesoftware.smackx.bytestreams;
|
||||
|
||||
import org.jivesoftware.smackx.ibb.InBandBytestreamListener;
|
||||
import org.jivesoftware.smackx.ibb.InBandBytestreamManager;
|
||||
import org.jivesoftware.smackx.socks5bytestream.Socks5BytestreamListener;
|
||||
import org.jivesoftware.smackx.socks5bytestream.Socks5BytestreamManager;
|
||||
|
||||
/**
|
||||
* BytestreamListener are notified if a remote user wants to initiate a bytestream. Implement this
|
||||
* interface to handle incoming bytestream requests.
|
||||
* <p>
|
||||
* BytestreamListener can be registered at the {@link Socks5BytestreamManager} or the
|
||||
* {@link InBandBytestreamManager}.
|
||||
* <p>
|
||||
* There are two ways to add this listener. See
|
||||
* {@link BytestreamManager#addIncomingBytestreamListener(BytestreamListener)} and
|
||||
* {@link BytestreamManager#addIncomingBytestreamListener(BytestreamListener, String)} for further
|
||||
* details.
|
||||
* <p>
|
||||
* {@link Socks5BytestreamListener} or {@link InBandBytestreamListener} provide a more specific
|
||||
* interface of the BytestreamListener.
|
||||
*
|
||||
* @author Henning Staib
|
||||
*/
|
||||
public interface BytestreamListener {
|
||||
|
||||
/**
|
||||
* This listener is notified if a bytestream request from another user has been received.
|
||||
*
|
||||
* @param request the incoming bytestream request
|
||||
*/
|
||||
public void incomingBytestreamRequest(BytestreamRequest request);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,114 @@
|
|||
/**
|
||||
* All rights reserved. Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jivesoftware.smackx.bytestreams;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smackx.ibb.InBandBytestreamManager;
|
||||
import org.jivesoftware.smackx.socks5bytestream.Socks5BytestreamManager;
|
||||
|
||||
/**
|
||||
* BytestreamManager provides a generic interface for bytestream managers.
|
||||
* <p>
|
||||
* There are two implementations of the interface. See {@link Socks5BytestreamManager} and
|
||||
* {@link InBandBytestreamManager}.
|
||||
*
|
||||
* @author Henning Staib
|
||||
*/
|
||||
public interface BytestreamManager {
|
||||
|
||||
/**
|
||||
* Adds {@link BytestreamListener} that is called for every incoming bytestream request unless
|
||||
* there is a user specific {@link BytestreamListener} registered.
|
||||
* <p>
|
||||
* See {@link Socks5BytestreamManager#addIncomingBytestreamListener(BytestreamListener)} and
|
||||
* {@link InBandBytestreamManager#addIncomingBytestreamListener(BytestreamListener)} for further
|
||||
* details.
|
||||
*
|
||||
* @param listener the listener to register
|
||||
*/
|
||||
public void addIncomingBytestreamListener(BytestreamListener listener);
|
||||
|
||||
/**
|
||||
* Removes the given listener from the list of listeners for all incoming bytestream requests.
|
||||
*
|
||||
* @param listener the listener to remove
|
||||
*/
|
||||
public void removeIncomingBytestreamListener(BytestreamListener listener);
|
||||
|
||||
/**
|
||||
* Adds {@link BytestreamListener} that is called for every incoming bytestream request unless
|
||||
* there is a user specific {@link BytestreamListener} registered.
|
||||
* <p>
|
||||
* Use this method if you are awaiting an incoming bytestream request from a specific user.
|
||||
* <p>
|
||||
* See {@link Socks5BytestreamManager#addIncomingBytestreamListener(BytestreamListener, String)}
|
||||
* and {@link InBandBytestreamManager#addIncomingBytestreamListener(BytestreamListener, String)}
|
||||
* for further details.
|
||||
*
|
||||
* @param listener the listener to register
|
||||
* @param initiatorJID the JID of the user that wants to establish a bytestream
|
||||
*/
|
||||
public void addIncomingBytestreamListener(BytestreamListener listener, String initiatorJID);
|
||||
|
||||
/**
|
||||
* Removes the listener for the given user.
|
||||
*
|
||||
* @param initiatorJID the JID of the user the listener should be removed
|
||||
*/
|
||||
public void removeIncomingBytestreamListener(String initiatorJID);
|
||||
|
||||
/**
|
||||
* Establishes a bytestream with the given user and returns the session to send/receive data
|
||||
* to/from the user.
|
||||
* <p>
|
||||
* Use this method to establish bytestreams to users accepting all incoming bytestream requests
|
||||
* since this method doesn't provide a way to tell the user something about the data to be sent.
|
||||
* <p>
|
||||
* To establish a bytestream after negotiation the kind of data to be sent (e.g. file transfer)
|
||||
* use {@link #establishSession(String, String)}.
|
||||
* <p>
|
||||
* See {@link Socks5BytestreamManager#establishSession(String)} and
|
||||
* {@link InBandBytestreamManager#establishSession(String)} for further details.
|
||||
*
|
||||
* @param targetJID the JID of the user a bytestream should be established
|
||||
* @return the session to send/receive data to/from the user
|
||||
* @throws XMPPException if an error occurred while establishing the session
|
||||
* @throws IOException if an IO error occurred while establishing the session
|
||||
* @throws InterruptedException if the thread was interrupted while waiting in a blocking
|
||||
* operation
|
||||
*/
|
||||
public BytestreamSession establishSession(String targetJID) throws XMPPException, IOException,
|
||||
InterruptedException;
|
||||
|
||||
/**
|
||||
* Establishes a bytestream with the given user and returns the session to send/receive data
|
||||
* to/from the user.
|
||||
* <p>
|
||||
* See {@link Socks5BytestreamManager#establishSession(String)} and
|
||||
* {@link InBandBytestreamManager#establishSession(String)} for further details.
|
||||
*
|
||||
* @param targetJID the JID of the user a bytestream should be established
|
||||
* @param sessionID the session ID for the bytestream request
|
||||
* @return the session to send/receive data to/from the user
|
||||
* @throws XMPPException if an error occurred while establishing the session
|
||||
* @throws IOException if an IO error occurred while establishing the session
|
||||
* @throws InterruptedException if the thread was interrupted while waiting in a blocking
|
||||
* operation
|
||||
*/
|
||||
public BytestreamSession establishSession(String targetJID, String sessionID)
|
||||
throws XMPPException, IOException, InterruptedException;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
/**
|
||||
* All rights reserved. Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jivesoftware.smackx.bytestreams;
|
||||
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smackx.ibb.InBandBytestreamRequest;
|
||||
import org.jivesoftware.smackx.socks5bytestream.Socks5BytestreamRequest;
|
||||
|
||||
/**
|
||||
* BytestreamRequest provides an interface to handle incoming bytestream requests.
|
||||
* <p>
|
||||
* There are two implementations of the interface. See {@link Socks5BytestreamRequest} and
|
||||
* {@link InBandBytestreamRequest}.
|
||||
*
|
||||
* @author Henning Staib
|
||||
*/
|
||||
public interface BytestreamRequest {
|
||||
|
||||
/**
|
||||
* Returns the sender of the bytestream open request.
|
||||
*
|
||||
* @return the sender of the bytestream open request
|
||||
*/
|
||||
public String getFrom();
|
||||
|
||||
/**
|
||||
* Returns the session ID of the bytestream open request.
|
||||
*
|
||||
* @return the session ID of the bytestream open request
|
||||
*/
|
||||
public String getSessionID();
|
||||
|
||||
/**
|
||||
* Accepts the bytestream open request and returns the session to send/receive data.
|
||||
*
|
||||
* @return the session to send/receive data
|
||||
* @throws XMPPException if an error occurred while accepting the bytestream request
|
||||
* @throws InterruptedException if the thread was interrupted while waiting in a blocking
|
||||
* operation
|
||||
*/
|
||||
public BytestreamSession accept() throws XMPPException, InterruptedException;
|
||||
|
||||
/**
|
||||
* Rejects the bytestream request by sending a reject error to the initiator.
|
||||
*/
|
||||
public void reject();
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,81 @@
|
|||
/**
|
||||
* All rights reserved. Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jivesoftware.smackx.bytestreams;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import org.jivesoftware.smackx.ibb.InBandBytestreamSession;
|
||||
import org.jivesoftware.smackx.socks5bytestream.Socks5BytestreamSession;
|
||||
|
||||
/**
|
||||
* BytestreamSession provides an interface for established bytestream sessions.
|
||||
* <p>
|
||||
* There are two implementations of the interface. See {@link Socks5BytestreamSession} and
|
||||
* {@link InBandBytestreamSession}.
|
||||
*
|
||||
* @author Henning Staib
|
||||
*/
|
||||
public interface BytestreamSession {
|
||||
|
||||
/**
|
||||
* Returns the InputStream associated with this session to send data.
|
||||
*
|
||||
* @return the InputStream associated with this session to send data
|
||||
* @throws IOException if an error occurs while retrieving the input stream
|
||||
*/
|
||||
public InputStream getInputStream() throws IOException;
|
||||
|
||||
/**
|
||||
* Returns the OutputStream associated with this session to receive data.
|
||||
*
|
||||
* @return the OutputStream associated with this session to receive data
|
||||
* @throws IOException if an error occurs while retrieving the output stream
|
||||
*/
|
||||
public OutputStream getOutputStream() throws IOException;
|
||||
|
||||
/**
|
||||
* Closes the bytestream session.
|
||||
* <p>
|
||||
* Closing the session will also close the input stream and the output stream associated to this
|
||||
* session.
|
||||
*
|
||||
* @throws IOException if an error occurs while closing the session
|
||||
*/
|
||||
public void close() throws IOException;
|
||||
|
||||
/**
|
||||
* Returns the timeout for read operations of the input stream associated with this session. 0
|
||||
* returns implies that the option is disabled (i.e., timeout of infinity). Default is 0.
|
||||
*
|
||||
* @return the timeout for read operations
|
||||
* @throws IOException if there is an error in the underlying protocol
|
||||
*/
|
||||
public int getReadTimeout() throws IOException;
|
||||
|
||||
/**
|
||||
* Sets the specified timeout, in milliseconds. With this option set to a non-zero timeout, a
|
||||
* read() call on the input stream associated with this session will block for only this amount
|
||||
* of time. If the timeout expires, a java.net.SocketTimeoutException is raised, though the
|
||||
* session is still valid. The option must be enabled prior to entering the blocking operation
|
||||
* to have effect. The timeout must be > 0. A timeout of zero is interpreted as an infinite
|
||||
* timeout. Default is 0.
|
||||
*
|
||||
* @param timeout the specified timeout, in milliseconds
|
||||
* @throws IOException if there is an error in the underlying protocol
|
||||
*/
|
||||
public void setReadTimeout(int timeout) throws IOException;
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue