mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-12-23 13:07:59 +01:00
Merge branch '3.4'
Conflicts: build/build.xml
This commit is contained in:
commit
5f5805cd1c
10 changed files with 145 additions and 102 deletions
134
build/build.xml
134
build/build.xml
|
@ -26,36 +26,65 @@
|
||||||
|
|
||||||
<!-- Smack Version -->
|
<!-- Smack Version -->
|
||||||
<property name="version.major" value="3" />
|
<property name="version.major" value="3" />
|
||||||
<property name="version.minor" value="4" />
|
<property name="version.minor" value="5" />
|
||||||
<property name="version.revision" value="1" />
|
<property name="version.revision" value="0" />
|
||||||
<property name="version.extra" value="SNAPSHOT" />
|
<property name="version.extra" value="SNAPSHOT" />
|
||||||
|
|
||||||
<var name="mutable-version" value="${version.major}.${version.minor}.${version.revision}"/>
|
<var name="mutable-version" value="${version.major}.${version.minor}.${version.revision}"/>
|
||||||
<var name="mutable-experimental-version" value="0.1"/>
|
<var name="mutable-experimental-version" value="0.2"/>
|
||||||
|
|
||||||
<if>
|
<available file=".git" type="dir" property="gitDir.present"/>
|
||||||
|
|
||||||
|
<!-- <target name="git.revision" description="Store git revision in ${repository.version}" if="gitDir.present"> -->
|
||||||
|
<if>
|
||||||
|
<isset property="gitDir.present"/>
|
||||||
|
<then>
|
||||||
|
<exec executable="git" outputproperty="git.revision" failifexecutionfails="false" errorproperty="">
|
||||||
|
<arg value="log"/>
|
||||||
|
<arg value="-n 1"/>
|
||||||
|
<arg value="--pretty=format:%h"/>
|
||||||
|
</exec>
|
||||||
|
</then>
|
||||||
|
</if>
|
||||||
|
<condition property="repository.version" value="${git.revision}" else="">
|
||||||
|
<and>
|
||||||
|
<isset property="git.revision"/>
|
||||||
|
<length string="${git.revision}" trim="yes" length="0" when="greater"/>
|
||||||
|
</and>
|
||||||
|
</condition>
|
||||||
|
<!-- </target> -->
|
||||||
|
|
||||||
|
<if>
|
||||||
<length string="${version.extra}" when="greater" length="0"/>
|
<length string="${version.extra}" when="greater" length="0"/>
|
||||||
<then>
|
<then>
|
||||||
<var name="mutable-version" value="${mutable-version}.${version.extra}"/>
|
<var name="mutable-version" value="${mutable-version}-${version.extra}"/>
|
||||||
<var name="mutable-experimental-version" value="${mutable-experimental-version}.${version.extra}" />
|
<var name="mutable-experimental-version" value="${mutable-experimental-version}-${version.extra}" />
|
||||||
</then>
|
</then>
|
||||||
</if>
|
</if>
|
||||||
|
|
||||||
<if>
|
<if>
|
||||||
<equals arg1="${dailybuild}" arg2="true" />
|
<equals arg1="${dailybuild}" arg2="true" />
|
||||||
<then>
|
<then>
|
||||||
<tstamp>
|
<tstamp>
|
||||||
<format property="build.date" pattern="yyyyMMdd" locale="en"/>
|
<format property="build.date" pattern="yyyyMMdd" locale="en"/>
|
||||||
</tstamp>
|
</tstamp>
|
||||||
<var name="mutable-version" value="${mutable-version}-${build.date}" />
|
<var name="mutable-version" value="${mutable-version}-${build.date}" />
|
||||||
<var name="mutable-experimental-version" value="${mutable-experimental-version}-${build.date}" />
|
<var name="mutable-experimental-version" value="${mutable-experimental-version}-${build.date}" />
|
||||||
</then>
|
</then>
|
||||||
</if>
|
</if>
|
||||||
|
|
||||||
|
<if>
|
||||||
|
<length string="${repository.version}" when="greater" length="0"/>
|
||||||
|
<then>
|
||||||
|
<var name="mutable-version" value="${mutable-version}-${repository.version}"/>
|
||||||
|
<var name="mutable-experimental-version" value="${mutable-experimental-version}-${repository.version}" />
|
||||||
|
</then>
|
||||||
|
</if>
|
||||||
|
|
||||||
<property name="version" value="${mutable-version}" />
|
<property name="version" value="${mutable-version}" />
|
||||||
<property name="experimental.version" value="${mutable-experimental-version}" />
|
<property name="experimental.version" value="${mutable-experimental-version}" />
|
||||||
|
|
||||||
<property name="bundle.name" value="org.igniterealtime.smack" />
|
<property name="bundle.name" value="org.igniterealtime.smack" />
|
||||||
<property file="${basedir}/build/build.properties" />
|
<property file="${basedir}/build/build.properties" />
|
||||||
<property name="compile.dir" value="${basedir}/target/classes" />
|
<property name="compile.dir" value="${basedir}/target/classes" />
|
||||||
<property name="compile.test.dir" value="${basedir}/target/classes-test" />
|
<property name="compile.test.dir" value="${basedir}/target/classes-test" />
|
||||||
|
@ -141,7 +170,7 @@
|
||||||
</classpath>
|
</classpath>
|
||||||
</javac>
|
</javac>
|
||||||
|
|
||||||
<mkdir dir="${compile.dir}/workgroup" />
|
<mkdir dir="${compile.dir}/workgroup" />
|
||||||
<javac
|
<javac
|
||||||
destdir="${compile.dir}/workgroup"
|
destdir="${compile.dir}/workgroup"
|
||||||
includeAntRuntime="no"
|
includeAntRuntime="no"
|
||||||
|
@ -158,7 +187,7 @@
|
||||||
</classpath>
|
</classpath>
|
||||||
</javac>
|
</javac>
|
||||||
|
|
||||||
<mkdir dir="${compile.dir}/experimental" />
|
<mkdir dir="${compile.dir}/experimental" />
|
||||||
<javac
|
<javac
|
||||||
destdir="${compile.dir}/experimental"
|
destdir="${compile.dir}/experimental"
|
||||||
includeAntRuntime="no"
|
includeAntRuntime="no"
|
||||||
|
@ -212,7 +241,7 @@
|
||||||
<!-- jar -->
|
<!-- jar -->
|
||||||
<!-- ======================================================================================= -->
|
<!-- ======================================================================================= -->
|
||||||
<target name="jar" depends="compile" unless="jar.uptodate" description="Produces smack.jar">
|
<target name="jar" depends="compile" unless="jar.uptodate" description="Produces smack.jar">
|
||||||
<property name="smack.jar.name" value="${jar.dest.dir}/smack-${version}.jar" />
|
<property name="smack.jar.name" value="${jar.dest.dir}/smack-${version}.jar" />
|
||||||
<jar destfile="${smack.jar.name}"
|
<jar destfile="${smack.jar.name}"
|
||||||
basedir="${compile.dir}"
|
basedir="${compile.dir}"
|
||||||
includes="org/jivesoftware/smack/**/*.class" >
|
includes="org/jivesoftware/smack/**/*.class" >
|
||||||
|
@ -227,8 +256,7 @@
|
||||||
<attribute name="Bundle-Version" value="${version}" />
|
<attribute name="Bundle-Version" value="${version}" />
|
||||||
</manifest>
|
</manifest>
|
||||||
</jar>
|
</jar>
|
||||||
|
<property name="smackx.jar.name" value="${jar.dest.dir}/smackx-${version}.jar" />
|
||||||
<property name="smackx.jar.name" value="${jar.dest.dir}/smackx-${version}.jar" />
|
|
||||||
<jar destfile="${smackx.jar.name}"
|
<jar destfile="${smackx.jar.name}"
|
||||||
basedir="${compile.dir}"
|
basedir="${compile.dir}"
|
||||||
includes="org/jivesoftware/smackx/**/*.class"
|
includes="org/jivesoftware/smackx/**/*.class"
|
||||||
|
@ -248,8 +276,8 @@
|
||||||
</manifest>
|
</manifest>
|
||||||
</jar>
|
</jar>
|
||||||
|
|
||||||
<property name="debug.jar.name" value="${jar.dest.dir}/smackx-debug-${version}.jar" />
|
<property name="debug.jar.name" value="${jar.dest.dir}/smackx-debug-${version}.jar" />
|
||||||
<copy todir="${compile.dir}/images">
|
<copy todir="${compile.dir}/images">
|
||||||
<fileset dir="${basedir}/build/resources/images">
|
<fileset dir="${basedir}/build/resources/images">
|
||||||
<include name="*.png"/>
|
<include name="*.png"/>
|
||||||
</fileset>
|
</fileset>
|
||||||
|
@ -270,7 +298,7 @@
|
||||||
</manifest>
|
</manifest>
|
||||||
</jar>
|
</jar>
|
||||||
|
|
||||||
<property name="jingle.jar.name" value="${jar.dest.dir}/smackx-jingle-${version}.jar" />
|
<property name="jingle.jar.name" value="${jar.dest.dir}/smackx-jingle-${version}.jar" />
|
||||||
<jar destfile="${jingle.jar.name}"
|
<jar destfile="${jingle.jar.name}"
|
||||||
basedir="${compile.dir}/jingle/extension"
|
basedir="${compile.dir}/jingle/extension"
|
||||||
includes="org/jivesoftware/smackx/**/*.class">
|
includes="org/jivesoftware/smackx/**/*.class">
|
||||||
|
@ -288,14 +316,14 @@
|
||||||
</manifest>
|
</manifest>
|
||||||
</jar>
|
</jar>
|
||||||
|
|
||||||
<property name="workgroup.jar.name" value="${jar.dest.dir}/smackx-workgroup-${version}.jar" />
|
<property name="workgroup.jar.name" value="${jar.dest.dir}/smackx-workgroup-${version}.jar" />
|
||||||
<jar destfile="${workgroup.jar.name}"
|
<jar destfile="${workgroup.jar.name}"
|
||||||
basedir="${compile.dir}/workgroup"
|
basedir="${compile.dir}/workgroup"
|
||||||
includes="org/jivesoftware/smackx/workgroup/**/*.class">
|
includes="org/jivesoftware/smackx/workgroup/**/*.class">
|
||||||
<manifest>
|
<manifest>
|
||||||
<attribute name="Class-Path" value="smack.jar, smackx.jar" />
|
<attribute name="Class-Path" value="smack.jar, smackx.jar" />
|
||||||
</manifest>
|
</manifest>
|
||||||
<metainf dir="${basedir}/workgroup/resources/META-INF/" includes="workgroup.providers" />
|
<metainf dir="${basedir}/workgroup/resources/META-INF/" includes="workgroup.providers" />
|
||||||
</jar>
|
</jar>
|
||||||
<bndwrap jars="${workgroup.jar.name}" output="${workgroup.jar.name}" />
|
<bndwrap jars="${workgroup.jar.name}" output="${workgroup.jar.name}" />
|
||||||
<jar file="${workgroup.jar.name}" update="true">
|
<jar file="${workgroup.jar.name}" update="true">
|
||||||
|
@ -306,7 +334,7 @@
|
||||||
</manifest>
|
</manifest>
|
||||||
</jar>
|
</jar>
|
||||||
|
|
||||||
<property name="experimental.jar.name" value="${jar.dest.dir}/smackx-experimental-${experimental.version}.jar" />
|
<property name="experimental.jar.name" value="${jar.dest.dir}/smackx-experimental-${experimental.version}.jar" />
|
||||||
<jar destfile="${experimental.jar.name}"
|
<jar destfile="${experimental.jar.name}"
|
||||||
basedir="${compile.dir}/experimental"
|
basedir="${compile.dir}/experimental"
|
||||||
includes="org/jivesoftware/smackx/**/*.class" >
|
includes="org/jivesoftware/smackx/**/*.class" >
|
||||||
|
@ -325,7 +353,7 @@
|
||||||
</jar>
|
</jar>
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
<delete file="${compile.dir}/META-INF/smack-config.xml" />
|
<delete file="${compile.dir}/META-INF/smack-config.xml" />
|
||||||
<delete file="${compile.dir}/META-INF/*.providers" />
|
<delete file="${compile.dir}/META-INF/*.providers" />
|
||||||
<delete>
|
<delete>
|
||||||
<fileset dir="${compile.dir}/images">
|
<fileset dir="${compile.dir}/images">
|
||||||
|
@ -350,7 +378,7 @@
|
||||||
basedir="${compile.test.dir}"
|
basedir="${compile.test.dir}"
|
||||||
includes="org/jivesoftware/smackx/**/*.class, org/jivesoftware/util/**/*.class" >
|
includes="org/jivesoftware/smackx/**/*.class, org/jivesoftware/util/**/*.class" >
|
||||||
<metainf dir="${basedir}/build/resources/META-INF/" includes="extension.providers" />
|
<metainf dir="${basedir}/build/resources/META-INF/" includes="extension.providers" />
|
||||||
</jar>
|
</jar>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
|
|
||||||
|
@ -376,10 +404,9 @@
|
||||||
<doctitle><![CDATA[<font face="arial,helvetica">Smack ${version}</font>]]></doctitle>
|
<doctitle><![CDATA[<font face="arial,helvetica">Smack ${version}</font>]]></doctitle>
|
||||||
<header><![CDATA[<b>Smack</b>]]></header>
|
<header><![CDATA[<b>Smack</b>]]></header>
|
||||||
<bottom><![CDATA[<i>Copyright © 2003-2007 Jive Software. </i>]]></bottom>
|
<bottom><![CDATA[<i>Copyright © 2003-2007 Jive Software. </i>]]></bottom>
|
||||||
<link href="http://java.sun.com/j2se/1.3/docs/api/" />
|
<link href="http://docs.oracle.com/javase/7/docs/api/" />
|
||||||
<link href="http://java.sun.com/j2ee/sdk_1.2.1/techdocs/api/" />
|
|
||||||
</javadoc>
|
</javadoc>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
|
|
||||||
<!-- test -->
|
<!-- test -->
|
||||||
|
@ -515,43 +542,30 @@
|
||||||
|
|
||||||
<!-- release -->
|
<!-- release -->
|
||||||
<!-- ======================================================================================= -->
|
<!-- ======================================================================================= -->
|
||||||
<target name="release" description="Builds a release" if="release.exists" depends="release-exists">
|
<target name="release" description="Builds a release" depends="jar,javadoc">
|
||||||
<antcall target="jar">
|
|
||||||
<param name="no.test" value="true" />
|
|
||||||
</antcall>
|
|
||||||
<antcall target="javadoc">
|
|
||||||
<param name="no.test" value="true" />
|
|
||||||
</antcall>
|
|
||||||
<ant antfile="${basedir}/build/release.xml" />
|
<ant antfile="${basedir}/build/release.xml" />
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
<!-- checkcode -->
|
<!-- checkcode -->
|
||||||
<!-- ======================================================================================= -->
|
|
||||||
<target name="checkcode" >
|
|
||||||
<taskdef name="pmd" classname="net.sourceforge.pmd.ant.PMDTask">
|
|
||||||
<classpath>
|
|
||||||
<pathelement location="${basedir}/build/pmd.jar" />
|
|
||||||
<pathelement location="${basedir}/build/asm.jar" />
|
|
||||||
<pathelement location="${basedir}/build/jaxen.jar" />
|
|
||||||
</classpath>
|
|
||||||
</taskdef>
|
|
||||||
<pmd shortFilenames="true">
|
|
||||||
<ruleset>migrating</ruleset>
|
|
||||||
<ruleset>finalizers</ruleset>
|
|
||||||
<formatter type="html" toFile="target/pmd_report.html" toConsole="true" />
|
|
||||||
<fileset dir="source/">
|
|
||||||
<include name="**/*.java" />
|
|
||||||
</fileset>
|
|
||||||
</pmd>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<!-- release-exists -->
|
|
||||||
<!-- ======================================================================================= -->
|
<!-- ======================================================================================= -->
|
||||||
<target name="release-exists" >
|
<target name="checkcode" >
|
||||||
<available file="${basedir}/build/release.xml" property="release.exists"/>
|
<taskdef name="pmd" classname="net.sourceforge.pmd.ant.PMDTask">
|
||||||
|
<classpath>
|
||||||
|
<pathelement location="${basedir}/build/pmd.jar" />
|
||||||
|
<pathelement location="${basedir}/build/asm.jar" />
|
||||||
|
<pathelement location="${basedir}/build/jaxen.jar" />
|
||||||
|
</classpath>
|
||||||
|
</taskdef>
|
||||||
|
<pmd shortFilenames="true">
|
||||||
|
<ruleset>migrating</ruleset>
|
||||||
|
<ruleset>finalizers</ruleset>
|
||||||
|
<formatter type="html" toFile="target/pmd_report.html" toConsole="true" />
|
||||||
|
<fileset dir="source/">
|
||||||
|
<include name="**/*.java" />
|
||||||
|
</fileset>
|
||||||
|
</pmd>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
|
|
||||||
<!-- clean -->
|
<!-- clean -->
|
||||||
<!-- ======================================================================================= -->
|
<!-- ======================================================================================= -->
|
||||||
<target name="clean" description="Deletes all generated content.">
|
<target name="clean" description="Deletes all generated content.">
|
||||||
|
@ -568,3 +582,7 @@
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
||||||
|
<!-- Local Variables: -->
|
||||||
|
<!-- indent-tabs-mode: nil -->
|
||||||
|
<!-- End: -->
|
||||||
|
|
|
@ -33,5 +33,6 @@
|
||||||
<classpathentry kind="lib" path="build/junit-4.10.jar"/>
|
<classpathentry kind="lib" path="build/junit-4.10.jar"/>
|
||||||
<classpathentry kind="lib" path="build/merge/jzlib.jar"/>
|
<classpathentry kind="lib" path="build/merge/jzlib.jar"/>
|
||||||
<classpathentry kind="lib" path="build/merge/org.xbill.dns_2.1.4.jar"/>
|
<classpathentry kind="lib" path="build/merge/org.xbill.dns_2.1.4.jar"/>
|
||||||
|
<classpathentry kind="lib" path="build/resources"/>
|
||||||
<classpathentry kind="output" path="target/classes"/>
|
<classpathentry kind="output" path="target/classes"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<projectDescription>
|
<projectDescription>
|
||||||
<name>smack-3.4.x</name>
|
<name>Smack</name>
|
||||||
<comment></comment>
|
<comment></comment>
|
||||||
<projects>
|
<projects>
|
||||||
</projects>
|
</projects>
|
||||||
|
|
|
@ -141,6 +141,14 @@ hr {
|
||||||
|
|
||||||
<div id="pageBody">
|
<div id="pageBody">
|
||||||
|
|
||||||
|
<h2>3.4.1 -- <span style="font-weight: normal;">Feb 9, 2014</span></h2>
|
||||||
|
|
||||||
|
<h2>Bug</h2>
|
||||||
|
<ul>
|
||||||
|
<li>[<a href='http://issues.igniterealtime.org/browse/SMACK-540'>SMACK-540</a>] - Memory leak in MultiUserChat
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
<h2>3.4.0 -- <span style="font-weight: normal;">Feb 2, 2014</span></h2>
|
<h2>3.4.0 -- <span style="font-weight: normal;">Feb 2, 2014</span></h2>
|
||||||
|
|
||||||
<h2>Bug Fixes</h2>
|
<h2>Bug Fixes</h2>
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
package org.jivesoftware.smackx.carbons;
|
package org.jivesoftware.smackx.carbons;
|
||||||
|
|
||||||
|
import java.lang.ref.WeakReference;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.WeakHashMap;
|
import java.util.WeakHashMap;
|
||||||
|
@ -51,18 +52,18 @@ public class CarbonManager {
|
||||||
static {
|
static {
|
||||||
Connection.addConnectionCreationListener(new ConnectionCreationListener() {
|
Connection.addConnectionCreationListener(new ConnectionCreationListener() {
|
||||||
public void connectionCreated(Connection connection) {
|
public void connectionCreated(Connection connection) {
|
||||||
new CarbonManager(connection);
|
getInstanceFor(connection);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private Connection connection;
|
private WeakReference<Connection> weakRefConnection;
|
||||||
private volatile boolean enabled_state = false;
|
private volatile boolean enabled_state = false;
|
||||||
|
|
||||||
private CarbonManager(Connection connection) {
|
private CarbonManager(Connection connection) {
|
||||||
ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(connection);
|
ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(connection);
|
||||||
sdm.addFeature(Carbon.NAMESPACE);
|
sdm.addFeature(Carbon.NAMESPACE);
|
||||||
this.connection = connection;
|
weakRefConnection = new WeakReference<Connection>(connection);
|
||||||
instances.put(connection, this);
|
instances.put(connection, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,7 +74,7 @@ public class CarbonManager {
|
||||||
*
|
*
|
||||||
* @return a CarbonManager instance
|
* @return a CarbonManager instance
|
||||||
*/
|
*/
|
||||||
public static CarbonManager getInstanceFor(Connection connection) {
|
public static synchronized CarbonManager getInstanceFor(Connection connection) {
|
||||||
CarbonManager carbonManager = instances.get(connection);
|
CarbonManager carbonManager = instances.get(connection);
|
||||||
|
|
||||||
if (carbonManager == null) {
|
if (carbonManager == null) {
|
||||||
|
@ -99,6 +100,7 @@ public class CarbonManager {
|
||||||
* @return true if supported
|
* @return true if supported
|
||||||
*/
|
*/
|
||||||
public boolean isSupportedByServer() {
|
public boolean isSupportedByServer() {
|
||||||
|
Connection connection = weakRefConnection.get();
|
||||||
try {
|
try {
|
||||||
DiscoverInfo result = ServiceDiscoveryManager
|
DiscoverInfo result = ServiceDiscoveryManager
|
||||||
.getInstanceFor(connection).discoverInfo(connection.getServiceName());
|
.getInstanceFor(connection).discoverInfo(connection.getServiceName());
|
||||||
|
@ -118,6 +120,7 @@ public class CarbonManager {
|
||||||
* @param new_state whether carbons should be enabled or disabled
|
* @param new_state whether carbons should be enabled or disabled
|
||||||
*/
|
*/
|
||||||
public void sendCarbonsEnabled(final boolean new_state) {
|
public void sendCarbonsEnabled(final boolean new_state) {
|
||||||
|
final Connection connection = weakRefConnection.get();
|
||||||
IQ setIQ = carbonsEnabledIQ(new_state);
|
IQ setIQ = carbonsEnabledIQ(new_state);
|
||||||
|
|
||||||
connection.addPacketListener(new PacketListener() {
|
connection.addPacketListener(new PacketListener() {
|
||||||
|
@ -148,6 +151,7 @@ public class CarbonManager {
|
||||||
if (enabled_state == new_state)
|
if (enabled_state == new_state)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
Connection connection = weakRefConnection.get();
|
||||||
IQ setIQ = carbonsEnabledIQ(new_state);
|
IQ setIQ = carbonsEnabledIQ(new_state);
|
||||||
|
|
||||||
PacketCollector collector =
|
PacketCollector collector =
|
||||||
|
|
|
@ -16,12 +16,12 @@
|
||||||
|
|
||||||
package org.jivesoftware.smack.keepalive;
|
package org.jivesoftware.smack.keepalive;
|
||||||
|
|
||||||
|
import java.lang.ref.WeakReference;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.WeakHashMap;
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
import java.util.concurrent.ScheduledFuture;
|
import java.util.concurrent.ScheduledFuture;
|
||||||
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
||||||
|
@ -52,7 +52,7 @@ import org.jivesoftware.smack.ping.packet.Ping;
|
||||||
* @author Florian Schmaus
|
* @author Florian Schmaus
|
||||||
*/
|
*/
|
||||||
public class KeepAliveManager {
|
public class KeepAliveManager {
|
||||||
private static Map<Connection, KeepAliveManager> instances = new HashMap<Connection, KeepAliveManager>();
|
private static Map<Connection, KeepAliveManager> instances = Collections.synchronizedMap(new WeakHashMap<Connection, KeepAliveManager>());
|
||||||
private static volatile ScheduledExecutorService periodicPingExecutorService;
|
private static volatile ScheduledExecutorService periodicPingExecutorService;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
@ -65,7 +65,7 @@ public class KeepAliveManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Connection connection;
|
private WeakReference<Connection> weakRefConnection;
|
||||||
private long pingInterval = SmackConfiguration.getKeepAliveInterval();
|
private long pingInterval = SmackConfiguration.getKeepAliveInterval();
|
||||||
private Set<PingFailedListener> pingFailedListeners = Collections.synchronizedSet(new HashSet<PingFailedListener>());
|
private Set<PingFailedListener> pingFailedListeners = Collections.synchronizedSet(new HashSet<PingFailedListener>());
|
||||||
private volatile ScheduledFuture<?> periodicPingTask;
|
private volatile ScheduledFuture<?> periodicPingTask;
|
||||||
|
@ -120,40 +120,21 @@ public class KeepAliveManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
private KeepAliveManager(Connection connection) {
|
private KeepAliveManager(Connection connection) {
|
||||||
this.connection = connection;
|
weakRefConnection = new WeakReference<Connection>(connection);
|
||||||
init();
|
|
||||||
handleConnect();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Call after every connection to add the packet listener.
|
|
||||||
*/
|
|
||||||
private void handleConnect() {
|
|
||||||
// Listen for all incoming packets and reset the scheduled ping whenever
|
|
||||||
// one arrives.
|
|
||||||
connection.addPacketListener(new PacketListener() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void processPacket(Packet packet) {
|
|
||||||
// reschedule the ping based on this last server contact
|
|
||||||
lastSuccessfulContact = System.currentTimeMillis();
|
|
||||||
schedulePingServerTask();
|
|
||||||
}
|
|
||||||
}, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void init() {
|
|
||||||
connection.addConnectionListener(new ConnectionListener() {
|
connection.addConnectionListener(new ConnectionListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void connectionClosed() {
|
public void connectionClosed() {
|
||||||
stopPingServerTask();
|
stopPingServerTask();
|
||||||
|
Connection connection = weakRefConnection.get();
|
||||||
handleDisconnect(connection);
|
handleDisconnect(connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void connectionClosedOnError(Exception arg0) {
|
public void connectionClosedOnError(Exception arg0) {
|
||||||
stopPingServerTask();
|
stopPingServerTask();
|
||||||
|
Connection connection = weakRefConnection.get();
|
||||||
handleDisconnect(connection);
|
handleDisconnect(connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -174,6 +155,25 @@ public class KeepAliveManager {
|
||||||
|
|
||||||
instances.put(connection, this);
|
instances.put(connection, this);
|
||||||
schedulePingServerTask();
|
schedulePingServerTask();
|
||||||
|
handleConnect();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Call after every connection to add the packet listener.
|
||||||
|
*/
|
||||||
|
private void handleConnect() {
|
||||||
|
Connection connection = weakRefConnection.get();
|
||||||
|
// Listen for all incoming packets and reset the scheduled ping whenever
|
||||||
|
// one arrives.
|
||||||
|
connection.addPacketListener(new PacketListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void processPacket(Packet packet) {
|
||||||
|
// reschedule the ping based on this last server contact
|
||||||
|
lastSuccessfulContact = System.currentTimeMillis();
|
||||||
|
schedulePingServerTask();
|
||||||
|
}
|
||||||
|
}, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -276,6 +276,7 @@ public class KeepAliveManager {
|
||||||
public void run() {
|
public void run() {
|
||||||
Ping ping = new Ping();
|
Ping ping = new Ping();
|
||||||
PacketFilter responseFilter = new PacketIDFilter(ping.getPacketID());
|
PacketFilter responseFilter = new PacketIDFilter(ping.getPacketID());
|
||||||
|
Connection connection = weakRefConnection.get();
|
||||||
final PacketCollector response = pingFailedListeners.isEmpty() ? null : connection.createPacketCollector(responseFilter);
|
final PacketCollector response = pingFailedListeners.isEmpty() ? null : connection.createPacketCollector(responseFilter);
|
||||||
connection.sendPacket(ping);
|
connection.sendPacket(ping);
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,6 @@
|
||||||
|
|
||||||
package org.jivesoftware.smackx;
|
package org.jivesoftware.smackx;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
|
@ -27,6 +27,7 @@ import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.WeakHashMap;
|
import java.util.WeakHashMap;
|
||||||
|
@ -116,12 +117,16 @@ public class MultiUserChat {
|
||||||
// Chat protocol. This information will be used when another client tries to
|
// Chat protocol. This information will be used when another client tries to
|
||||||
// discover whether this client supports MUC or not.
|
// discover whether this client supports MUC or not.
|
||||||
ServiceDiscoveryManager.getInstanceFor(connection).addFeature(discoNamespace);
|
ServiceDiscoveryManager.getInstanceFor(connection).addFeature(discoNamespace);
|
||||||
|
|
||||||
// Set the NodeInformationProvider that will provide information about the
|
// Set the NodeInformationProvider that will provide information about the
|
||||||
// joined rooms whenever a disco request is received
|
// joined rooms whenever a disco request is received
|
||||||
|
final WeakReference<Connection> weakRefConnection = new WeakReference<Connection>(connection);
|
||||||
ServiceDiscoveryManager.getInstanceFor(connection).setNodeInformationProvider(
|
ServiceDiscoveryManager.getInstanceFor(connection).setNodeInformationProvider(
|
||||||
discoNode,
|
discoNode,
|
||||||
new NodeInformationProvider() {
|
new NodeInformationProvider() {
|
||||||
public List<DiscoverItems.Item> getNodeItems() {
|
public List<DiscoverItems.Item> getNodeItems() {
|
||||||
|
Connection connection = weakRefConnection.get();
|
||||||
|
if (connection == null) return new LinkedList<DiscoverItems.Item>();
|
||||||
List<DiscoverItems.Item> answer = new ArrayList<DiscoverItems.Item>();
|
List<DiscoverItems.Item> answer = new ArrayList<DiscoverItems.Item>();
|
||||||
Iterator<String> rooms=MultiUserChat.getJoinedRooms(connection);
|
Iterator<String> rooms=MultiUserChat.getJoinedRooms(connection);
|
||||||
while (rooms.hasNext()) {
|
while (rooms.hasNext()) {
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
package org.jivesoftware.smackx.ping;
|
package org.jivesoftware.smackx.ping;
|
||||||
|
|
||||||
|
import java.lang.ref.WeakReference;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.WeakHashMap;
|
import java.util.WeakHashMap;
|
||||||
|
@ -65,7 +66,7 @@ public class PingManager {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private Connection connection;
|
private WeakReference<Connection> weakRefConnection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves a {@link PingManager} for the specified {@link Connection}, creating one if it doesn't already
|
* Retrieves a {@link PingManager} for the specified {@link Connection}, creating one if it doesn't already
|
||||||
|
@ -84,8 +85,8 @@ public class PingManager {
|
||||||
return pingManager;
|
return pingManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
private PingManager(Connection con) {
|
private PingManager(Connection connection) {
|
||||||
this.connection = con;
|
weakRefConnection = new WeakReference<Connection>(connection);
|
||||||
ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(connection);
|
ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(connection);
|
||||||
|
|
||||||
// The ServiceDiscoveryManager was not pre-initialized
|
// The ServiceDiscoveryManager was not pre-initialized
|
||||||
|
@ -101,6 +102,7 @@ public class PingManager {
|
||||||
* Sends a Pong for every Ping
|
* Sends a Pong for every Ping
|
||||||
*/
|
*/
|
||||||
public void processPacket(Packet packet) {
|
public void processPacket(Packet packet) {
|
||||||
|
Connection connection = weakRefConnection.get();
|
||||||
IQ pong = IQ.createResultIQ((Ping) packet);
|
IQ pong = IQ.createResultIQ((Ping) packet);
|
||||||
connection.sendPacket(pong);
|
connection.sendPacket(pong);
|
||||||
}
|
}
|
||||||
|
@ -121,7 +123,7 @@ public class PingManager {
|
||||||
*/
|
*/
|
||||||
public boolean ping(String jid, long pingTimeout) {
|
public boolean ping(String jid, long pingTimeout) {
|
||||||
Ping ping = new Ping(jid);
|
Ping ping = new Ping(jid);
|
||||||
|
Connection connection = weakRefConnection.get();
|
||||||
try {
|
try {
|
||||||
SyncPacketSend.getReply(connection, ping);
|
SyncPacketSend.getReply(connection, ping);
|
||||||
}
|
}
|
||||||
|
@ -151,6 +153,7 @@ public class PingManager {
|
||||||
* @throws XMPPException An XMPP related error occurred during the request
|
* @throws XMPPException An XMPP related error occurred during the request
|
||||||
*/
|
*/
|
||||||
public boolean isPingSupported(String jid) throws XMPPException {
|
public boolean isPingSupported(String jid) throws XMPPException {
|
||||||
|
Connection connection = weakRefConnection.get();
|
||||||
DiscoverInfo result = ServiceDiscoveryManager.getInstanceFor(connection).discoverInfo(jid);
|
DiscoverInfo result = ServiceDiscoveryManager.getInstanceFor(connection).discoverInfo(jid);
|
||||||
return result.containsFeature(Ping.NAMESPACE);
|
return result.containsFeature(Ping.NAMESPACE);
|
||||||
}
|
}
|
||||||
|
@ -165,6 +168,7 @@ public class PingManager {
|
||||||
* @return true if a reply was received from the server, false otherwise.
|
* @return true if a reply was received from the server, false otherwise.
|
||||||
*/
|
*/
|
||||||
public boolean pingMyServer() {
|
public boolean pingMyServer() {
|
||||||
|
Connection connection = weakRefConnection.get();
|
||||||
return ping(connection.getServiceName());
|
return ping(connection.getServiceName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
package org.jivesoftware.smackx.receipts;
|
package org.jivesoftware.smackx.receipts;
|
||||||
|
|
||||||
|
import java.lang.ref.WeakReference;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -52,7 +53,7 @@ public class DeliveryReceiptManager implements PacketListener {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private Connection connection;
|
private WeakReference<Connection> weakRefConnection;
|
||||||
private boolean auto_receipts_enabled = false;
|
private boolean auto_receipts_enabled = false;
|
||||||
private Set<ReceiptReceivedListener> receiptReceivedListeners = Collections
|
private Set<ReceiptReceivedListener> receiptReceivedListeners = Collections
|
||||||
.synchronizedSet(new HashSet<ReceiptReceivedListener>());
|
.synchronizedSet(new HashSet<ReceiptReceivedListener>());
|
||||||
|
@ -60,7 +61,7 @@ public class DeliveryReceiptManager implements PacketListener {
|
||||||
private DeliveryReceiptManager(Connection connection) {
|
private DeliveryReceiptManager(Connection connection) {
|
||||||
ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(connection);
|
ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(connection);
|
||||||
sdm.addFeature(DeliveryReceipt.NAMESPACE);
|
sdm.addFeature(DeliveryReceipt.NAMESPACE);
|
||||||
this.connection = connection;
|
weakRefConnection = new WeakReference<Connection>(connection);
|
||||||
instances.put(connection, this);
|
instances.put(connection, this);
|
||||||
|
|
||||||
// register listener for delivery receipts and requests
|
// register listener for delivery receipts and requests
|
||||||
|
@ -91,6 +92,7 @@ public class DeliveryReceiptManager implements PacketListener {
|
||||||
* @return true if supported
|
* @return true if supported
|
||||||
*/
|
*/
|
||||||
public boolean isSupported(String jid) {
|
public boolean isSupported(String jid) {
|
||||||
|
Connection connection = weakRefConnection.get();
|
||||||
try {
|
try {
|
||||||
DiscoverInfo result =
|
DiscoverInfo result =
|
||||||
ServiceDiscoveryManager.getInstanceFor(connection).discoverInfo(jid);
|
ServiceDiscoveryManager.getInstanceFor(connection).discoverInfo(jid);
|
||||||
|
@ -119,6 +121,7 @@ public class DeliveryReceiptManager implements PacketListener {
|
||||||
DeliveryReceiptRequest drr = (DeliveryReceiptRequest)packet.getExtension(
|
DeliveryReceiptRequest drr = (DeliveryReceiptRequest)packet.getExtension(
|
||||||
DeliveryReceiptRequest.ELEMENT, DeliveryReceipt.NAMESPACE);
|
DeliveryReceiptRequest.ELEMENT, DeliveryReceipt.NAMESPACE);
|
||||||
if (drr != null) {
|
if (drr != null) {
|
||||||
|
Connection connection = weakRefConnection.get();
|
||||||
Message ack = new Message(packet.getFrom(), Message.Type.normal);
|
Message ack = new Message(packet.getFrom(), Message.Type.normal);
|
||||||
ack.addExtension(new DeliveryReceipt(packet.getPacketID()));
|
ack.addExtension(new DeliveryReceipt(packet.getPacketID()));
|
||||||
connection.sendPacket(ack);
|
connection.sendPacket(ack);
|
||||||
|
|
Loading…
Reference in a new issue