mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-12-22 18:48:00 +01:00
Merge of 3.2 stream back into trunk
git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@12965 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
commit
6dc64671e2
21 changed files with 254 additions and 91 deletions
|
@ -164,21 +164,32 @@
|
|||
<copy todir="${compile.dir}/META-INF" file="${basedir}/build/resources/META-INF/smack-config.xml" />
|
||||
<jar destfile="${jar.dest.dir}/smack.jar"
|
||||
basedir="${compile.dir}"
|
||||
includes="org/jivesoftware/smack/**/*.class, **/smack-config.xml"
|
||||
>
|
||||
includes="org/jivesoftware/smack/**/*.class, **/smack-config.xml">
|
||||
<zipfileset src="${merge.lib.dir}/xpp.jar"/>
|
||||
</jar>
|
||||
<taskdef resource="aQute/bnd/ant/taskdef.properties" classpath="${basedir}/build/build/biz.aQute.bnd.jar"/>
|
||||
<bndwrap jars="${jar.dest.dir}/smack.jar" output="${jar.dest.dir}/smack.jar" />
|
||||
<jar file="${jar.dest.dir}/smack.jar" update="true">
|
||||
<manifest>
|
||||
<attribute name="Bundle-SymbolicName" value="org.igniterealtime.smack" />
|
||||
</manifest>
|
||||
</jar>
|
||||
<copy todir="${compile.dir}/META-INF" file="${basedir}/build/resources/META-INF/smack.providers" />
|
||||
<jar destfile="${jar.dest.dir}/smackx.jar"
|
||||
basedir="${compile.dir}"
|
||||
includes="org/jivesoftware/smackx/**/*.class, **/*.providers"
|
||||
excludes="org/jivesoftware/smackx/debugger/*.class"
|
||||
>
|
||||
excludes="org/jivesoftware/smackx/debugger/*.class">
|
||||
<manifest>
|
||||
<attribute name="Class-Path" value="smack.jar" />
|
||||
</manifest>
|
||||
<zipfileset src="${merge.lib.dir}/jzlib.jar"/>
|
||||
</jar>
|
||||
<bndwrap jars="${jar.dest.dir}/smackx.jar" output="${jar.dest.dir}/smackx.jar" />
|
||||
<jar file="${jar.dest.dir}/smackx.jar" update="true">
|
||||
<manifest>
|
||||
<attribute name="Bundle-SymbolicName" value="org.igniterealtime.smack-ext" />
|
||||
</manifest>
|
||||
</jar>
|
||||
<copy todir="${compile.dir}/images">
|
||||
<fileset dir="${basedir}/build/resources/images">
|
||||
<include name="*.png"/>
|
||||
|
@ -186,21 +197,31 @@
|
|||
</copy>
|
||||
<jar destfile="${jar.dest.dir}/smackx-debug.jar"
|
||||
basedir="${compile.dir}"
|
||||
includes="org/jivesoftware/smackx/debugger/*.class, **/*.png"
|
||||
>
|
||||
includes="org/jivesoftware/smackx/debugger/*.class, **/*.png">
|
||||
<manifest>
|
||||
<attribute name="Class-Path" value="smack.jar" />
|
||||
</manifest>
|
||||
</jar>
|
||||
<bndwrap jars="${jar.dest.dir}/smackx-debug.jar" output="${jar.dest.dir}/smackx-debug.jar" />
|
||||
<jar file="${jar.dest.dir}/smackx-debug.jar" update="true">
|
||||
<manifest>
|
||||
<attribute name="Bundle-SymbolicName" value="org.igniterealtime.smack-ext-debug" />
|
||||
</manifest>
|
||||
</jar>
|
||||
<jar destfile="${jar.dest.dir}/smackx-jingle.jar"
|
||||
basedir="${compile.dir}/jingle/extension"
|
||||
includes="org/jivesoftware/smackx/**/*.class"
|
||||
>
|
||||
includes="org/jivesoftware/smackx/**/*.class">
|
||||
<manifest>
|
||||
<attribute name="Class-Path" value="smack.jar, smackx.jar" />
|
||||
</manifest>
|
||||
<zipfileset src="${jingle.extension.merge.lib.dir}/jstun.jar"/>
|
||||
</jar>
|
||||
<bndwrap jars="${jar.dest.dir}/smackx-jingle.jar" output="${jar.dest.dir}/smackx-jingle.jar" />
|
||||
<jar file="${jar.dest.dir}/smackx-jingle.jar" update="true">
|
||||
<manifest>
|
||||
<attribute name="Bundle-SymbolicName" value="org.igniterealtime.smack-ext-jingle" />
|
||||
</manifest>
|
||||
</jar>
|
||||
<delete file="${compile.dir}/META-INF/smack-config.xml" />
|
||||
<delete file="${compile.dir}/META-INF/smack.providers" />
|
||||
<delete>
|
||||
|
|
BIN
build/build/biz.aQute.bnd.jar
Normal file
BIN
build/build/biz.aQute.bnd.jar
Normal file
Binary file not shown.
|
@ -69,6 +69,7 @@
|
|||
<include name="README.html" />
|
||||
<include name="lib/*.jar" />
|
||||
<include name="merge/*.jar" />
|
||||
<include name="build/*.jar" />
|
||||
</fileset>
|
||||
</copy>
|
||||
<copy todir="${release-dev.dir}/jingle/extension/build">
|
||||
|
|
|
@ -141,6 +141,29 @@ hr {
|
|||
|
||||
<div id="pageBody">
|
||||
|
||||
<h2>3.2.2 -- <span style="font-weight: normal;">Dec. 23, 2011</span></h2>
|
||||
|
||||
<h3>Bug</h3>
|
||||
<ul>
|
||||
<li>[<a href='http://issues.igniterealtime.org/browse/SMACK-263'>SMACK-263</a>] - Set file info in all send* methods</li>
|
||||
<li>[<a href='http://issues.igniterealtime.org/browse/SMACK-322'>SMACK-322</a>] - NPE in XMPPConnection</li>
|
||||
<li>[<a href='http://issues.igniterealtime.org/browse/SMACK-324'>SMACK-324</a>] - Investigate SASL issue with jabberd2 servers</li>
|
||||
<li>[<a href='http://issues.igniterealtime.org/browse/SMACK-338'>SMACK-338</a>] - IBB filetransfer doesn't work as expected</li>
|
||||
<li>[<a href='http://issues.igniterealtime.org/browse/SMACK-346'>SMACK-346</a>] - Bug in return code for rejection handling in FileTransferManager</li>
|
||||
<li>[<a href='http://issues.igniterealtime.org/browse/SMACK-348'>SMACK-348</a>] - Documentation error - broken link</li>
|
||||
<li>[<a href='http://issues.igniterealtime.org/browse/SMACK-349'>SMACK-349</a>] - Smack's IBB sends too much data in a packet</li>
|
||||
<li>[<a href='http://issues.igniterealtime.org/browse/SMACK-350'>SMACK-350</a>] - Bytestream is not working in Spark 2.6.3 from XP to W7</li>
|
||||
<li>[<a href='http://issues.igniterealtime.org/browse/SMACK-353'>SMACK-353</a>] - Thread leak in the FaultTolerantNegotiator</li>
|
||||
<li>[<a href='http://issues.igniterealtime.org/browse/SMACK-362'>SMACK-362</a>] - smack throw NoSuchElementException if the muc#roominfo_subject has no values</li>
|
||||
</ul>
|
||||
|
||||
<h3>Improvement</h3>
|
||||
<ul>
|
||||
<li>[<a href='http://issues.igniterealtime.org/browse/SMACK-343'>SMACK-343</a>] - Make Smack jar an OSGi bundle.</li>
|
||||
<li>[<a href='http://issues.igniterealtime.org/browse/SMACK-354'>SMACK-354</a>] - Provide milliseconds in timestamp colum debugwindow</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h2>3.2.1 -- <span style="font-weight: normal;">July 4, 2011</span></h2>
|
||||
<h3>Bug</h3>
|
||||
<ul>
|
||||
|
|
|
@ -44,14 +44,14 @@ import java.util.*;
|
|||
*/
|
||||
public final class SmackConfiguration {
|
||||
|
||||
private static final String SMACK_VERSION = "3.2.1";
|
||||
private static final String SMACK_VERSION = "3.2.2";
|
||||
|
||||
private static int packetReplyTimeout = 5000;
|
||||
private static int keepAliveInterval = 30000;
|
||||
private static Vector<String> defaultMechs = new Vector<String>();
|
||||
|
||||
private static boolean localSocks5ProxyEnabled = true;
|
||||
private static int localSocks5ProxyPort = 7778;
|
||||
private static int localSocks5ProxyPort = 7777;
|
||||
private static int packetCollectorSize = 5000;
|
||||
|
||||
private SmackConfiguration() {
|
||||
|
|
|
@ -0,0 +1,109 @@
|
|||
/**
|
||||
* 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.smack.provider;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.provider.PacketExtensionProvider;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
import org.jivesoftware.smackx.pubsub.provider.ItemProvider;
|
||||
import org.jivesoftware.smackx.pubsub.provider.ItemsProvider;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
|
||||
/**
|
||||
*
|
||||
* This class simplifies parsing of embedded elements by using the
|
||||
* <a href="http://en.wikipedia.org/wiki/Template_method_pattern">Template Method Pattern</a>.
|
||||
* After extracting the current element attributes and content of any child elements, the template method
|
||||
* ({@link #createReturnExtension(String, String, Map, List)} is called. Subclasses
|
||||
* then override this method to create the specific return type.
|
||||
*
|
||||
* <p>To use this class, you simply register your subclasses as extension providers in the
|
||||
* <b>smack.properties</b> file. Then they will be automatically picked up and used to parse
|
||||
* any child elements.
|
||||
*
|
||||
* <pre>
|
||||
* For example, given the following message
|
||||
*
|
||||
* <message from='pubsub.shakespeare.lit' to='francisco@denmark.lit' id='foo>
|
||||
* <event xmlns='http://jabber.org/protocol/pubsub#event>
|
||||
* <items node='princely_musings'>
|
||||
* <item id='asdjkwei3i34234n356'>
|
||||
* <entry xmlns='http://www.w3.org/2005/Atom'>
|
||||
* <title>Soliloquy</title>
|
||||
* <link rel='alternative' type='text/html'/>
|
||||
* <id>tag:denmark.lit,2003:entry-32397</id>
|
||||
* </entry>
|
||||
* </item>
|
||||
* </items>
|
||||
* </event>
|
||||
* </message>
|
||||
*
|
||||
* I would have a classes
|
||||
* {@link ItemsProvider} extends {@link EmbeddedExtensionProvider}
|
||||
* {@link ItemProvider} extends {@link EmbeddedExtensionProvider}
|
||||
* and
|
||||
* AtomProvider extends {@link PacketExtensionProvider}
|
||||
*
|
||||
* These classes are then registered in the meta-inf/smack.providers file
|
||||
* as follows.
|
||||
*
|
||||
* <extensionProvider>
|
||||
* <elementName>items</elementName>
|
||||
* <namespace>http://jabber.org/protocol/pubsub#event</namespace>
|
||||
* <className>org.jivesoftware.smackx.provider.ItemsEventProvider</className>
|
||||
* </extensionProvider>
|
||||
* <extensionProvider>
|
||||
* <elementName>item</elementName>
|
||||
* <namespace>http://jabber.org/protocol/pubsub#event</namespace>
|
||||
* <className>org.jivesoftware.smackx.provider.ItemProvider</className>
|
||||
* </extensionProvider>
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author Robin Collier
|
||||
*/
|
||||
abstract public class EmbeddedExtensionProvider implements PacketExtensionProvider
|
||||
{
|
||||
|
||||
final public PacketExtension parseExtension(XmlPullParser parser) throws Exception
|
||||
{
|
||||
String namespace = parser.getNamespace();
|
||||
String name = parser.getName();
|
||||
Map<String, String> attMap = new HashMap<String, String>();
|
||||
|
||||
for(int i=0; i<parser.getAttributeCount(); i++)
|
||||
{
|
||||
attMap.put(parser.getAttributeName(i), parser.getAttributeValue(i));
|
||||
}
|
||||
List<PacketExtension> extensions = new ArrayList<PacketExtension>();
|
||||
|
||||
do
|
||||
{
|
||||
int tag = parser.next();
|
||||
|
||||
if (tag == XmlPullParser.START_TAG)
|
||||
extensions.add(PacketParserUtils.parsePacketExtension(parser.getName(), parser.getNamespace(), parser));
|
||||
} while (!name.equals(parser.getName()));
|
||||
|
||||
return createReturnExtension(name, namespace, attMap, extensions);
|
||||
}
|
||||
|
||||
abstract protected PacketExtension createReturnExtension(String currentElement, String currentNamespace, Map<String, String> attributeMap, List<? extends PacketExtension> content);
|
||||
}
|
|
@ -11,7 +11,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jivesoftware.smackx.packet;
|
||||
package org.jivesoftware.smack.util;
|
||||
|
||||
import org.jivesoftware.smack.PacketCollector;
|
||||
import org.jivesoftware.smack.SmackConfiguration;
|
|
@ -27,11 +27,11 @@ import org.jivesoftware.smack.ConnectionCreationListener;
|
|||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.XMPPError;
|
||||
import org.jivesoftware.smack.util.SyncPacketSend;
|
||||
import org.jivesoftware.smackx.bytestreams.BytestreamListener;
|
||||
import org.jivesoftware.smackx.bytestreams.BytestreamManager;
|
||||
import org.jivesoftware.smackx.bytestreams.ibb.packet.Open;
|
||||
import org.jivesoftware.smackx.filetransfer.FileTransferManager;
|
||||
import org.jivesoftware.smackx.packet.SyncPacketSend;
|
||||
|
||||
/**
|
||||
* The InBandBytestreamManager class handles establishing In-Band Bytestreams as specified in the <a
|
||||
|
|
|
@ -33,12 +33,12 @@ import org.jivesoftware.smack.packet.Packet;
|
|||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.packet.XMPPError;
|
||||
import org.jivesoftware.smack.util.StringUtils;
|
||||
import org.jivesoftware.smack.util.SyncPacketSend;
|
||||
import org.jivesoftware.smackx.bytestreams.BytestreamSession;
|
||||
import org.jivesoftware.smackx.bytestreams.ibb.packet.Close;
|
||||
import org.jivesoftware.smackx.bytestreams.ibb.packet.Data;
|
||||
import org.jivesoftware.smackx.bytestreams.ibb.packet.DataPacketExtension;
|
||||
import org.jivesoftware.smackx.bytestreams.ibb.packet.Open;
|
||||
import org.jivesoftware.smackx.packet.SyncPacketSend;
|
||||
|
||||
/**
|
||||
* InBandBytestreamSession class represents an In-Band Bytestream session.
|
||||
|
@ -594,7 +594,7 @@ public class InBandBytestreamSession implements BytestreamSession {
|
|||
* Constructor.
|
||||
*/
|
||||
public IBBOutputStream() {
|
||||
this.buffer = new byte[byteStreamRequest.getBlockSize()];
|
||||
this.buffer = new byte[(byteStreamRequest.getBlockSize()/4)*3];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -33,6 +33,7 @@ import org.jivesoftware.smack.XMPPException;
|
|||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.Packet;
|
||||
import org.jivesoftware.smack.packet.XMPPError;
|
||||
import org.jivesoftware.smack.util.SyncPacketSend;
|
||||
import org.jivesoftware.smackx.ServiceDiscoveryManager;
|
||||
import org.jivesoftware.smackx.bytestreams.BytestreamListener;
|
||||
import org.jivesoftware.smackx.bytestreams.BytestreamManager;
|
||||
|
@ -42,7 +43,6 @@ import org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream.StreamHostUs
|
|||
import org.jivesoftware.smackx.filetransfer.FileTransferManager;
|
||||
import org.jivesoftware.smackx.packet.DiscoverInfo;
|
||||
import org.jivesoftware.smackx.packet.DiscoverItems;
|
||||
import org.jivesoftware.smackx.packet.SyncPacketSend;
|
||||
import org.jivesoftware.smackx.packet.DiscoverInfo.Identity;
|
||||
import org.jivesoftware.smackx.packet.DiscoverItems.Item;
|
||||
|
||||
|
|
|
@ -20,9 +20,9 @@ import java.util.concurrent.TimeoutException;
|
|||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.util.SyncPacketSend;
|
||||
import org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream;
|
||||
import org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream.StreamHost;
|
||||
import org.jivesoftware.smackx.packet.SyncPacketSend;
|
||||
|
||||
/**
|
||||
* Implementation of a SOCKS5 client used on the initiators side. This is needed because connecting
|
||||
|
|
|
@ -170,7 +170,7 @@ public class EnhancedDebugger implements SmackDebugger {
|
|||
// the GUI. This is what we call "interpreted" packet data, since it's the packet
|
||||
// data as Smack sees it and not as it's coming in as raw XML.
|
||||
packetReaderListener = new PacketListener() {
|
||||
SimpleDateFormat dateFormatter = new SimpleDateFormat("hh:mm:ss aaa");
|
||||
SimpleDateFormat dateFormatter = new SimpleDateFormat("hh:mm:ss:SS aaa");
|
||||
|
||||
public void processPacket(final Packet packet) {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
|
@ -185,7 +185,7 @@ public class EnhancedDebugger implements SmackDebugger {
|
|||
// Create a thread that will listen for all outgoing packets and write them to
|
||||
// the GUI.
|
||||
packetWriterListener = new PacketListener() {
|
||||
SimpleDateFormat dateFormatter = new SimpleDateFormat("hh:mm:ss aaa");
|
||||
SimpleDateFormat dateFormatter = new SimpleDateFormat("hh:mm:ss:SS aaa");
|
||||
|
||||
public void processPacket(final Packet packet) {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
|
@ -276,7 +276,7 @@ public class EnhancedDebugger implements SmackDebugger {
|
|||
table.getTableHeader().getColumnModel().getColumn(0).setMinWidth(0);
|
||||
// Set the column "timestamp" size
|
||||
table.getColumnModel().getColumn(1).setMaxWidth(300);
|
||||
table.getColumnModel().getColumn(1).setPreferredWidth(70);
|
||||
table.getColumnModel().getColumn(1).setPreferredWidth(90);
|
||||
// Set the column "direction" icon size
|
||||
table.getColumnModel().getColumn(2).setMaxWidth(50);
|
||||
table.getColumnModel().getColumn(2).setPreferredWidth(30);
|
||||
|
@ -625,7 +625,7 @@ public class EnhancedDebugger implements SmackDebugger {
|
|||
connPanel.add(
|
||||
label,
|
||||
new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, 21, 0, new Insets(0, 0, 0, 0), 0, 0));
|
||||
field = new JFormattedTextField(new SimpleDateFormat("yyyy.MM.dd hh:mm:ss aaa"));
|
||||
field = new JFormattedTextField(new SimpleDateFormat("yyyy.MM.dd hh:mm:ss:SS aaa"));
|
||||
field.setMinimumSize(new java.awt.Dimension(150, 20));
|
||||
field.setMaximumSize(new java.awt.Dimension(150, 20));
|
||||
field.setValue(creationTime);
|
||||
|
|
|
@ -79,8 +79,9 @@ public class FaultTolerantNegotiator extends StreamNegotiator {
|
|||
|
||||
connection.sendPacket(super.createInitiationAccept(initiation, getNamespaces()));
|
||||
|
||||
ExecutorService threadPoolExecutor = Executors.newFixedThreadPool(2);
|
||||
CompletionService<InputStream> service
|
||||
= new ExecutorCompletionService<InputStream>(Executors.newFixedThreadPool(2));
|
||||
= new ExecutorCompletionService<InputStream>(threadPoolExecutor);
|
||||
List<Future<InputStream>> futures = new ArrayList<Future<InputStream>>();
|
||||
InputStream stream = null;
|
||||
XMPPException exception = null;
|
||||
|
@ -119,6 +120,7 @@ public class FaultTolerantNegotiator extends StreamNegotiator {
|
|||
future.cancel(true);
|
||||
}
|
||||
collector.cancel();
|
||||
threadPoolExecutor.shutdownNow();
|
||||
}
|
||||
if (stream == null) {
|
||||
if (exception != null) {
|
||||
|
|
|
@ -130,10 +130,10 @@ public abstract class FileTransfer {
|
|||
|
||||
/**
|
||||
* Returns true if the transfer has been cancelled, if it has stopped because
|
||||
* of a an error, or the transfer completed succesfully.
|
||||
* of a an error, or the transfer completed successfully.
|
||||
*
|
||||
* @return Returns true if the transfer has been cancelled, if it has stopped
|
||||
* because of a an error, or the transfer completed succesfully.
|
||||
* because of a an error, or the transfer completed successfully.
|
||||
*/
|
||||
public boolean isDone() {
|
||||
return status == Status.cancelled || status == Status.error
|
||||
|
@ -141,9 +141,9 @@ public abstract class FileTransfer {
|
|||
}
|
||||
|
||||
/**
|
||||
* Retuns the current status of the file transfer.
|
||||
* Returns the current status of the file transfer.
|
||||
*
|
||||
* @return Retuns the current status of the file transfer.
|
||||
* @return Returns the current status of the file transfer.
|
||||
*/
|
||||
public Status getStatus() {
|
||||
return status;
|
||||
|
@ -158,7 +158,7 @@ public abstract class FileTransfer {
|
|||
* during the transfer, the type of error can be retrieved through this
|
||||
* method.
|
||||
*
|
||||
* @return Returns the type of error that occured if one has occured.
|
||||
* @return Returns the type of error that occurred if one has occurred.
|
||||
*/
|
||||
public Error getError() {
|
||||
return error;
|
||||
|
@ -166,9 +166,9 @@ public abstract class FileTransfer {
|
|||
|
||||
/**
|
||||
* If an exception occurs asynchronously it will be stored for later
|
||||
* retrival. If there is an error there maybe an exception set.
|
||||
* retrieval. If there is an error there maybe an exception set.
|
||||
*
|
||||
* @return The exception that occured or null if there was no exception.
|
||||
* @return The exception that occurred or null if there was no exception.
|
||||
* @see #getError()
|
||||
*/
|
||||
public Exception getException() {
|
||||
|
@ -246,7 +246,7 @@ public abstract class FileTransfer {
|
|||
public enum Status {
|
||||
|
||||
/**
|
||||
* An error occured during the transfer.
|
||||
* An error occurred during the transfer.
|
||||
*
|
||||
* @see FileTransfer#getError()
|
||||
*/
|
||||
|
@ -259,7 +259,7 @@ public abstract class FileTransfer {
|
|||
|
||||
/**
|
||||
* The file transfer is being negotiated with the peer. The party
|
||||
* recieving the file has the option to accept or refuse a file transfer
|
||||
* Receiving the file has the option to accept or refuse a file transfer
|
||||
* request. If they accept, then the process of stream negotiation will
|
||||
* begin. If they refuse the file will not be transfered.
|
||||
*
|
||||
|
@ -283,7 +283,7 @@ public abstract class FileTransfer {
|
|||
negotiating_stream("Negotiating Stream"),
|
||||
|
||||
/**
|
||||
* After the stream negotitation has completed the intermediate state
|
||||
* After the stream negotiation has completed the intermediate state
|
||||
* between the time when the negotiation is finished and the actual
|
||||
* transfer begins.
|
||||
*/
|
||||
|
@ -302,7 +302,7 @@ public abstract class FileTransfer {
|
|||
complete("Complete"),
|
||||
|
||||
/**
|
||||
* The file transfer was canceled
|
||||
* The file transfer was cancelled
|
||||
*/
|
||||
cancelled("Cancelled");
|
||||
|
||||
|
@ -348,12 +348,12 @@ public abstract class FileTransfer {
|
|||
no_response("The remote user did not respond or the connection timed out."),
|
||||
|
||||
/**
|
||||
* An error occured over the socket connected to send the file.
|
||||
* An error occurred over the socket connected to send the file.
|
||||
*/
|
||||
connection("An error occured over the socket connected to send the file."),
|
||||
|
||||
/**
|
||||
* An error occured while sending or recieving the file
|
||||
* An error occurred while sending or receiving the file
|
||||
*/
|
||||
stream("An error occured while sending or recieving the file.");
|
||||
|
||||
|
|
|
@ -172,7 +172,7 @@ public class FileTransferManager {
|
|||
IQ rejection = FileTransferNegotiator.createIQ(
|
||||
initiation.getPacketID(), initiation.getFrom(), initiation
|
||||
.getTo(), IQ.Type.ERROR);
|
||||
rejection.setError(new XMPPError(XMPPError.Condition.forbidden));
|
||||
rejection.setError(new XMPPError(XMPPError.Condition.no_acceptable));
|
||||
connection.sendPacket(rejection);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ import org.jivesoftware.smackx.packet.StreamInitiation;
|
|||
* will be sent.
|
||||
*
|
||||
* @author Alexander Wenckus
|
||||
* @see <a href="http://www.jabber.org/jeps/jep-0096.html">JEP-0096: File Transfer</a>
|
||||
* @see <a href="http://xmpp.org/extensions/xep-0096.html">XEP-0096: SI File Transfer</a>
|
||||
*/
|
||||
public class FileTransferNegotiator {
|
||||
|
||||
|
@ -76,7 +76,7 @@ public class FileTransferNegotiator {
|
|||
* set this variable to true for testing purposes as IBB is the backup file transfer method
|
||||
* and shouldn't be used as the only transfer method in production systems.
|
||||
*/
|
||||
public static boolean IBB_ONLY = false;
|
||||
public static boolean IBB_ONLY = (System.getProperty("ibb") != null);//true;
|
||||
|
||||
/**
|
||||
* Returns the file transfer negotiator related to a particular connection.
|
||||
|
|
|
@ -80,7 +80,7 @@ public class OutgoingFileTransfer extends FileTransfer {
|
|||
|
||||
/**
|
||||
* Returns the output stream connected to the peer to transfer the file. It
|
||||
* is only available after it has been succesfully negotiated by the
|
||||
* is only available after it has been successfully negotiated by the
|
||||
* {@link StreamNegotiator}.
|
||||
*
|
||||
* @return Returns the output stream connected to the peer to transfer the
|
||||
|
@ -120,6 +120,7 @@ public class OutgoingFileTransfer extends FileTransfer {
|
|||
+ " been attempted on this file transfer");
|
||||
}
|
||||
try {
|
||||
setFileInfo(fileName, fileSize);
|
||||
this.outputStream = negotiateStream(fileName, fileSize, description);
|
||||
} catch (XMPPException e) {
|
||||
handleXMPPException(e);
|
||||
|
@ -159,6 +160,7 @@ public class OutgoingFileTransfer extends FileTransfer {
|
|||
"The negotation process has already"
|
||||
+ " been attempted for this file transfer");
|
||||
}
|
||||
setFileInfo(fileName, fileSize);
|
||||
this.callback = progress;
|
||||
transferThread = new Thread(new Runnable() {
|
||||
public void run() {
|
||||
|
@ -184,7 +186,7 @@ public class OutgoingFileTransfer extends FileTransfer {
|
|||
|
||||
/**
|
||||
* This method handles the stream negotiation process and transmits the file
|
||||
* to the remote user. It returns immediatly and the progress of the file
|
||||
* to the remote user. It returns immediately and the progress of the file
|
||||
* transfer can be monitored through several methods:
|
||||
*
|
||||
* <UL>
|
||||
|
@ -257,7 +259,7 @@ public class OutgoingFileTransfer extends FileTransfer {
|
|||
|
||||
/**
|
||||
* This method handles the stream negotiation process and transmits the file
|
||||
* to the remote user. It returns immediatly and the progress of the file
|
||||
* to the remote user. It returns immediately and the progress of the file
|
||||
* transfer can be monitored through several methods:
|
||||
*
|
||||
* <UL>
|
||||
|
@ -274,6 +276,7 @@ public class OutgoingFileTransfer extends FileTransfer {
|
|||
public synchronized void sendStream(final InputStream in, final String fileName, final long fileSize, final String description){
|
||||
checkTransferThread();
|
||||
|
||||
setFileInfo(fileName, fileSize);
|
||||
transferThread = new Thread(new Runnable() {
|
||||
public void run() {
|
||||
//Create packet filter
|
||||
|
@ -339,7 +342,7 @@ public class OutgoingFileTransfer extends FileTransfer {
|
|||
* -1 if the file transfer has not started.
|
||||
* <p>
|
||||
* Note: This method is only useful when the {@link #sendFile(File, String)}
|
||||
* method is called, as it is the only method that actualy transmits the
|
||||
* method is called, as it is the only method that actually transmits the
|
||||
* file.
|
||||
*
|
||||
* @return Returns the amount of bytes that have been sent for the file
|
||||
|
@ -410,7 +413,7 @@ public class OutgoingFileTransfer extends FileTransfer {
|
|||
}
|
||||
|
||||
/**
|
||||
* A callback class to retrive the status of an outgoing transfer
|
||||
* A callback class to retrieve the status of an outgoing transfer
|
||||
* negotiation process.
|
||||
*
|
||||
* @author Alexander Wenckus
|
||||
|
@ -438,7 +441,7 @@ public class OutgoingFileTransfer extends FileTransfer {
|
|||
/**
|
||||
* Called when an exception occurs during the negotiation progress.
|
||||
*
|
||||
* @param e the exception that occured.
|
||||
* @param e the exception that occurred.
|
||||
*/
|
||||
void errorEstablishingStream(Exception e);
|
||||
}
|
||||
|
|
|
@ -90,10 +90,10 @@ public class RoomInfo {
|
|||
Form form = Form.getFormFrom(info);
|
||||
if (form != null) {
|
||||
FormField descField = form.getField("muc#roominfo_description");
|
||||
this.description = descField == null ? "" : descField.getValues().next();
|
||||
this.description = ( descField == null || !(descField.getValues().hasNext()) )? "" : descField.getValues().next();
|
||||
|
||||
FormField subjField = form.getField("muc#roominfo_subject");
|
||||
this.subject = subjField == null ? "" : subjField.getValues().next();
|
||||
this.subject = ( subjField == null || !(subjField.getValues().hasNext()) ) ? "" : subjField.getValues().next();
|
||||
|
||||
FormField occCountField = form.getField("muc#roominfo_occupants");
|
||||
this.occupantsCount = occCountField == null ? -1 : Integer.parseInt(occCountField.getValues()
|
||||
|
|
|
@ -78,6 +78,8 @@ import org.xmlpull.v1.XmlPullParser;
|
|||
* </pre>
|
||||
*
|
||||
* @author Robin Collier
|
||||
*
|
||||
* @deprecated This has been moved to {@link org.jivesoftware.smack.provider.EmbeddedExtensionProvider}
|
||||
*/
|
||||
abstract public class EmbeddedExtensionProvider implements PacketExtensionProvider
|
||||
{
|
||||
|
|
|
@ -40,6 +40,7 @@ public class InBandBytestreamSessionMessageTest {
|
|||
String sessionID = "session_id";
|
||||
|
||||
int blockSize = 10;
|
||||
int dataSize = blockSize/4 * 3;
|
||||
|
||||
// protocol verifier
|
||||
Protocol protocol;
|
||||
|
@ -102,7 +103,7 @@ public class InBandBytestreamSessionMessageTest {
|
|||
protocol.addResponse(null, incrementingSequence);
|
||||
protocol.addResponse(null, incrementingSequence);
|
||||
|
||||
byte[] controlData = new byte[blockSize * 3];
|
||||
byte[] controlData = new byte[dataSize * 3];
|
||||
|
||||
OutputStream outputStream = session.getOutputStream();
|
||||
outputStream.write(controlData);
|
||||
|
@ -127,7 +128,7 @@ public class InBandBytestreamSessionMessageTest {
|
|||
protocol.addResponse(null, incrementingSequence);
|
||||
protocol.addResponse(null, incrementingSequence);
|
||||
|
||||
byte[] controlData = new byte[blockSize * 3];
|
||||
byte[] controlData = new byte[dataSize * 3];
|
||||
|
||||
OutputStream outputStream = session.getOutputStream();
|
||||
for (byte b : controlData) {
|
||||
|
@ -154,11 +155,11 @@ public class InBandBytestreamSessionMessageTest {
|
|||
protocol.addResponse(null, incrementingSequence);
|
||||
protocol.addResponse(null, incrementingSequence);
|
||||
|
||||
byte[] controlData = new byte[(blockSize * 3) - 2];
|
||||
byte[] controlData = new byte[(dataSize * 3) - 2];
|
||||
|
||||
OutputStream outputStream = session.getOutputStream();
|
||||
int off = 0;
|
||||
for (int i = 1; i <= 7; i++) {
|
||||
for (int i = 1; off+i <= controlData.length; i++) {
|
||||
outputStream.write(controlData, off, i);
|
||||
off += i;
|
||||
}
|
||||
|
@ -175,7 +176,7 @@ public class InBandBytestreamSessionMessageTest {
|
|||
*/
|
||||
@Test
|
||||
public void shouldSendThirtyDataPackets() throws Exception {
|
||||
byte[] controlData = new byte[blockSize * 3];
|
||||
byte[] controlData = new byte[dataSize * 3];
|
||||
|
||||
InBandBytestreamSession session = new InBandBytestreamSession(connection, initBytestream,
|
||||
initiatorJID);
|
||||
|
@ -202,7 +203,7 @@ public class InBandBytestreamSessionMessageTest {
|
|||
*/
|
||||
@Test
|
||||
public void shouldSendNothingOnSuccessiveCallsToFlush() throws Exception {
|
||||
byte[] controlData = new byte[blockSize * 3];
|
||||
byte[] controlData = new byte[dataSize * 3];
|
||||
|
||||
InBandBytestreamSession session = new InBandBytestreamSession(connection, initBytestream,
|
||||
initiatorJID);
|
||||
|
@ -273,7 +274,7 @@ public class InBandBytestreamSessionMessageTest {
|
|||
public void shouldReadAllReceivedData1() throws Exception {
|
||||
// create random data
|
||||
Random rand = new Random();
|
||||
byte[] controlData = new byte[3 * blockSize];
|
||||
byte[] controlData = new byte[3 * dataSize];
|
||||
rand.nextBytes(controlData);
|
||||
|
||||
// get IBB sessions data packet listener
|
||||
|
@ -283,8 +284,8 @@ public class InBandBytestreamSessionMessageTest {
|
|||
PacketListener listener = Whitebox.getInternalState(inputStream, PacketListener.class);
|
||||
|
||||
// verify data packet and notify listener
|
||||
for (int i = 0; i < controlData.length / blockSize; i++) {
|
||||
String base64Data = StringUtils.encodeBase64(controlData, i * blockSize, blockSize,
|
||||
for (int i = 0; i < controlData.length / dataSize; i++) {
|
||||
String base64Data = StringUtils.encodeBase64(controlData, i * dataSize, dataSize,
|
||||
false);
|
||||
DataPacketExtension dpe = new DataPacketExtension(sessionID, i, base64Data);
|
||||
Message dataMessage = new Message();
|
||||
|
@ -292,14 +293,14 @@ public class InBandBytestreamSessionMessageTest {
|
|||
listener.processPacket(dataMessage);
|
||||
}
|
||||
|
||||
byte[] bytes = new byte[3 * blockSize];
|
||||
byte[] bytes = new byte[3 * dataSize];
|
||||
int read = 0;
|
||||
read = inputStream.read(bytes, 0, blockSize);
|
||||
assertEquals(blockSize, read);
|
||||
read = inputStream.read(bytes, 10, blockSize);
|
||||
assertEquals(blockSize, read);
|
||||
read = inputStream.read(bytes, 20, blockSize);
|
||||
assertEquals(blockSize, read);
|
||||
read = inputStream.read(bytes, 0, dataSize);
|
||||
assertEquals(dataSize, read);
|
||||
read = inputStream.read(bytes, dataSize, dataSize);
|
||||
assertEquals(dataSize, read);
|
||||
read = inputStream.read(bytes, dataSize*2, dataSize);
|
||||
assertEquals(dataSize, read);
|
||||
|
||||
// verify data
|
||||
for (int i = 0; i < bytes.length; i++) {
|
||||
|
@ -319,7 +320,7 @@ public class InBandBytestreamSessionMessageTest {
|
|||
public void shouldReadAllReceivedData2() throws Exception {
|
||||
// create random data
|
||||
Random rand = new Random();
|
||||
byte[] controlData = new byte[3 * blockSize];
|
||||
byte[] controlData = new byte[3 * dataSize];
|
||||
rand.nextBytes(controlData);
|
||||
|
||||
// get IBB sessions data packet listener
|
||||
|
@ -329,8 +330,8 @@ public class InBandBytestreamSessionMessageTest {
|
|||
PacketListener listener = Whitebox.getInternalState(inputStream, PacketListener.class);
|
||||
|
||||
// verify data packet and notify listener
|
||||
for (int i = 0; i < controlData.length / blockSize; i++) {
|
||||
String base64Data = StringUtils.encodeBase64(controlData, i * blockSize, blockSize,
|
||||
for (int i = 0; i < controlData.length / dataSize; i++) {
|
||||
String base64Data = StringUtils.encodeBase64(controlData, i * dataSize, dataSize,
|
||||
false);
|
||||
DataPacketExtension dpe = new DataPacketExtension(sessionID, i, base64Data);
|
||||
Message dataMessage = new Message();
|
||||
|
@ -339,7 +340,7 @@ public class InBandBytestreamSessionMessageTest {
|
|||
}
|
||||
|
||||
// read data
|
||||
byte[] bytes = new byte[3 * blockSize];
|
||||
byte[] bytes = new byte[3 * dataSize];
|
||||
for (int i = 0; i < bytes.length; i++) {
|
||||
bytes[i] = (byte) inputStream.read();
|
||||
}
|
||||
|
|
|
@ -40,7 +40,8 @@ public class InBandBytestreamSessionTest {
|
|||
String xmppServer = "xmpp-server";
|
||||
String sessionID = "session_id";
|
||||
|
||||
int blockSize = 10;
|
||||
int blockSize = 20;
|
||||
int dataSize = blockSize/4 * 3;
|
||||
|
||||
// protocol verifier
|
||||
Protocol protocol;
|
||||
|
@ -102,7 +103,7 @@ public class InBandBytestreamSessionTest {
|
|||
protocol.addResponse(resultIQ, incrementingSequence);
|
||||
protocol.addResponse(resultIQ, incrementingSequence);
|
||||
|
||||
byte[] controlData = new byte[blockSize * 3];
|
||||
byte[] controlData = new byte[dataSize * 3];
|
||||
|
||||
OutputStream outputStream = session.getOutputStream();
|
||||
outputStream.write(controlData);
|
||||
|
@ -128,7 +129,7 @@ public class InBandBytestreamSessionTest {
|
|||
protocol.addResponse(resultIQ, incrementingSequence);
|
||||
protocol.addResponse(resultIQ, incrementingSequence);
|
||||
|
||||
byte[] controlData = new byte[blockSize * 3];
|
||||
byte[] controlData = new byte[dataSize * 3];
|
||||
|
||||
OutputStream outputStream = session.getOutputStream();
|
||||
for (byte b : controlData) {
|
||||
|
@ -156,11 +157,11 @@ public class InBandBytestreamSessionTest {
|
|||
protocol.addResponse(resultIQ, incrementingSequence);
|
||||
protocol.addResponse(resultIQ, incrementingSequence);
|
||||
|
||||
byte[] controlData = new byte[(blockSize * 3) - 2];
|
||||
byte[] controlData = new byte[(dataSize * 3) - 2];
|
||||
|
||||
OutputStream outputStream = session.getOutputStream();
|
||||
int off = 0;
|
||||
for (int i = 1; i <= 7; i++) {
|
||||
for (int i = 1; i+off <= controlData.length; i++) {
|
||||
outputStream.write(controlData, off, i);
|
||||
off += i;
|
||||
}
|
||||
|
@ -177,7 +178,7 @@ public class InBandBytestreamSessionTest {
|
|||
*/
|
||||
@Test
|
||||
public void shouldSendThirtyDataPackets() throws Exception {
|
||||
byte[] controlData = new byte[blockSize * 3];
|
||||
byte[] controlData = new byte[dataSize * 3];
|
||||
|
||||
InBandBytestreamSession session = new InBandBytestreamSession(connection, initBytestream,
|
||||
initiatorJID);
|
||||
|
@ -205,7 +206,7 @@ public class InBandBytestreamSessionTest {
|
|||
*/
|
||||
@Test
|
||||
public void shouldSendNothingOnSuccessiveCallsToFlush() throws Exception {
|
||||
byte[] controlData = new byte[blockSize * 3];
|
||||
byte[] controlData = new byte[dataSize * 3];
|
||||
|
||||
InBandBytestreamSession session = new InBandBytestreamSession(connection, initBytestream,
|
||||
initiatorJID);
|
||||
|
@ -236,7 +237,7 @@ public class InBandBytestreamSessionTest {
|
|||
public void shouldSendDataCorrectly() throws Exception {
|
||||
// create random data
|
||||
Random rand = new Random();
|
||||
final byte[] controlData = new byte[256 * blockSize];
|
||||
final byte[] controlData = new byte[256 * dataSize];
|
||||
rand.nextBytes(controlData);
|
||||
|
||||
// compares the data of each packet with the control data
|
||||
|
@ -246,7 +247,7 @@ public class InBandBytestreamSessionTest {
|
|||
byte[] decodedData = request.getDataPacketExtension().getDecodedData();
|
||||
int seq = (int) request.getDataPacketExtension().getSeq();
|
||||
for (int i = 0; i < decodedData.length; i++) {
|
||||
assertEquals(controlData[(seq * blockSize) + i], decodedData[i]);
|
||||
assertEquals(controlData[(seq * dataSize) + i], decodedData[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -254,7 +255,7 @@ public class InBandBytestreamSessionTest {
|
|||
|
||||
// set acknowledgments for the data packets
|
||||
IQ resultIQ = IBBPacketUtils.createResultIQ(initiatorJID, targetJID);
|
||||
for (int i = 0; i < controlData.length / blockSize; i++) {
|
||||
for (int i = 0; i < controlData.length / dataSize; i++) {
|
||||
protocol.addResponse(resultIQ, incrementingSequence, dataVerification);
|
||||
}
|
||||
|
||||
|
@ -462,7 +463,7 @@ public class InBandBytestreamSessionTest {
|
|||
public void shouldReadAllReceivedData1() throws Exception {
|
||||
// create random data
|
||||
Random rand = new Random();
|
||||
byte[] controlData = new byte[3 * blockSize];
|
||||
byte[] controlData = new byte[3 * dataSize];
|
||||
rand.nextBytes(controlData);
|
||||
|
||||
IQ resultIQ = IBBPacketUtils.createResultIQ(initiatorJID, targetJID);
|
||||
|
@ -473,24 +474,24 @@ public class InBandBytestreamSessionTest {
|
|||
InputStream inputStream = session.getInputStream();
|
||||
PacketListener listener = Whitebox.getInternalState(inputStream, PacketListener.class);
|
||||
|
||||
// set data packet acknowledgment and notify listener
|
||||
for (int i = 0; i < controlData.length / blockSize; i++) {
|
||||
// set data packet acknowledgement and notify listener
|
||||
for (int i = 0; i < controlData.length / dataSize; i++) {
|
||||
protocol.addResponse(resultIQ);
|
||||
String base64Data = StringUtils.encodeBase64(controlData, i * blockSize, blockSize,
|
||||
String base64Data = StringUtils.encodeBase64(controlData, i * dataSize, dataSize,
|
||||
false);
|
||||
DataPacketExtension dpe = new DataPacketExtension(sessionID, i, base64Data);
|
||||
Data data = new Data(dpe);
|
||||
listener.processPacket(data);
|
||||
}
|
||||
|
||||
byte[] bytes = new byte[3 * blockSize];
|
||||
byte[] bytes = new byte[3 * dataSize];
|
||||
int read = 0;
|
||||
read = inputStream.read(bytes, 0, blockSize);
|
||||
assertEquals(blockSize, read);
|
||||
read = inputStream.read(bytes, 10, blockSize);
|
||||
assertEquals(blockSize, read);
|
||||
read = inputStream.read(bytes, 20, blockSize);
|
||||
assertEquals(blockSize, read);
|
||||
read = inputStream.read(bytes, 0, dataSize);
|
||||
assertEquals(dataSize, read);
|
||||
read = inputStream.read(bytes, dataSize, dataSize);
|
||||
assertEquals(dataSize, read);
|
||||
read = inputStream.read(bytes, dataSize*2, dataSize);
|
||||
assertEquals(dataSize, read);
|
||||
|
||||
// verify data
|
||||
for (int i = 0; i < bytes.length; i++) {
|
||||
|
@ -510,7 +511,7 @@ public class InBandBytestreamSessionTest {
|
|||
public void shouldReadAllReceivedData2() throws Exception {
|
||||
// create random data
|
||||
Random rand = new Random();
|
||||
byte[] controlData = new byte[3 * blockSize];
|
||||
byte[] controlData = new byte[3 * dataSize];
|
||||
rand.nextBytes(controlData);
|
||||
|
||||
IQ resultIQ = IBBPacketUtils.createResultIQ(initiatorJID, targetJID);
|
||||
|
@ -522,9 +523,9 @@ public class InBandBytestreamSessionTest {
|
|||
PacketListener listener = Whitebox.getInternalState(inputStream, PacketListener.class);
|
||||
|
||||
// set data packet acknowledgment and notify listener
|
||||
for (int i = 0; i < controlData.length / blockSize; i++) {
|
||||
for (int i = 0; i < controlData.length / dataSize; i++) {
|
||||
protocol.addResponse(resultIQ);
|
||||
String base64Data = StringUtils.encodeBase64(controlData, i * blockSize, blockSize,
|
||||
String base64Data = StringUtils.encodeBase64(controlData, i * dataSize, dataSize,
|
||||
false);
|
||||
DataPacketExtension dpe = new DataPacketExtension(sessionID, i, base64Data);
|
||||
Data data = new Data(dpe);
|
||||
|
@ -532,7 +533,7 @@ public class InBandBytestreamSessionTest {
|
|||
}
|
||||
|
||||
// read data
|
||||
byte[] bytes = new byte[3 * blockSize];
|
||||
byte[] bytes = new byte[3 * dataSize];
|
||||
for (int i = 0; i < bytes.length; i++) {
|
||||
bytes[i] = (byte) inputStream.read();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue