1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2025-12-12 05:51:08 +01:00

Use Jid (and subclasses) from jxmpp-jid

Fixes SMACK-634
This commit is contained in:
Florian Schmaus 2015-02-14 17:15:02 +01:00
parent 0ee2d9ed1e
commit 5bb4727c57
180 changed files with 1510 additions and 1032 deletions

View file

@ -45,6 +45,7 @@ import org.jivesoftware.smack.packet.IQ.Type;
import org.jivesoftware.smack.util.SmackExecutorThreadFactory;
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
import org.jivesoftware.smackx.ping.packet.Ping;
import org.jxmpp.jid.Jid;
/**
* Implements the XMPP Ping as defined by XEP-0199. The XMPP Ping protocol allows one entity to
@ -147,7 +148,7 @@ public class PingManager extends Manager {
* to this, is a server ping, which will always return true if the server is reachable,
* event if there is an error on the ping itself (i.e. ping not supported).
* <p>
* Use {@link #isPingSupported(String)} to determine if XMPP Ping is supported
* Use {@link #isPingSupported(Jid)} to determine if XMPP Ping is supported
* by the entity.
*
* @param jid The id of the entity the ping is being sent to
@ -157,7 +158,7 @@ public class PingManager extends Manager {
* @throws NotConnectedException
* @throws InterruptedException
*/
public boolean ping(String jid, long pingTimeout) throws NotConnectedException, NoResponseException, InterruptedException {
public boolean ping(Jid jid, long pingTimeout) throws NotConnectedException, NoResponseException, InterruptedException {
final XMPPConnection connection = connection();
// Packet collector for IQs needs an connection that was at least authenticated once,
// otherwise the client JID will be null causing an NPE
@ -175,7 +176,7 @@ public class PingManager extends Manager {
}
/**
* Same as calling {@link #ping(String, long)} with the defaultpacket reply
* Same as calling {@link #ping(Jid, long)} with the defaultpacket reply
* timeout.
*
* @param jid The id of the entity the ping is being sent to
@ -184,7 +185,7 @@ public class PingManager extends Manager {
* @throws NoResponseException if there was no response from the jid.
* @throws InterruptedException
*/
public boolean ping(String jid) throws NotConnectedException, NoResponseException, InterruptedException {
public boolean ping(Jid jid) throws NotConnectedException, NoResponseException, InterruptedException {
return ping(jid, connection().getPacketReplyTimeout());
}
@ -198,7 +199,7 @@ public class PingManager extends Manager {
* @throws NotConnectedException
* @throws InterruptedException
*/
public boolean isPingSupported(String jid) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
public boolean isPingSupported(Jid jid) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
return ServiceDiscoveryManager.getInstanceFor(connection()).supportsFeature(jid, Ping.NAMESPACE);
}
@ -206,8 +207,8 @@ public class PingManager extends Manager {
* Pings the server. This method will return true if the server is reachable. It
* is the equivalent of calling <code>ping</code> with the XMPP domain.
* <p>
* Unlike the {@link #ping(String)} case, this method will return true even if
* {@link #isPingSupported(String)} is false.
* Unlike the {@link #ping(Jid)} case, this method will return true even if
* {@link #isPingSupported(Jid)} is false.
*
* @return true if a reply was received from the server, false otherwise.
* @throws NotConnectedException
@ -221,8 +222,8 @@ public class PingManager extends Manager {
* Pings the server. This method will return true if the server is reachable. It
* is the equivalent of calling <code>ping</code> with the XMPP domain.
* <p>
* Unlike the {@link #ping(String)} case, this method will return true even if
* {@link #isPingSupported(String)} is false.
* Unlike the {@link #ping(Jid)} case, this method will return true even if
* {@link #isPingSupported(Jid)} is false.
*
* @param notifyListeners Notify the PingFailedListener in case of error if true
* @return true if the user's server could be pinged.
@ -237,8 +238,8 @@ public class PingManager extends Manager {
* Pings the server. This method will return true if the server is reachable. It
* is the equivalent of calling <code>ping</code> with the XMPP domain.
* <p>
* Unlike the {@link #ping(String)} case, this method will return true even if
* {@link #isPingSupported(String)} is false.
* Unlike the {@link #ping(Jid)} case, this method will return true even if
* {@link #isPingSupported(Jid)} is false.
*
* @param notifyListeners Notify the PingFailedListener in case of error if true
* @param pingTimeout The time to wait for a reply in milliseconds

View file

@ -1,6 +1,6 @@
/**
*
* Copyright 2012 Florian Schmaus
* Copyright 2012-2015 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -18,6 +18,7 @@ package org.jivesoftware.smackx.ping.packet;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.SimpleIQ;
import org.jxmpp.jid.Jid;
public class Ping extends SimpleIQ {
@ -28,7 +29,7 @@ public class Ping extends SimpleIQ {
super(ELEMENT, NAMESPACE);
}
public Ping(String to) {
public Ping(Jid to) {
this();
setTo(to);
setType(IQ.Type.get);