1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-11-26 05:52:06 +01:00

"not connected" is now a checked Exception thrown by sendPacket()

There is a unsolveable race condition between the connection state and
sendPacket(), i.e. the connection could go down, right after the
method calling sendPacket is called, but before sendPacket() is
invoked. Before this change, sendPacket() has thrown an unchecked
IllegalStateException, which could be ignored by the Smack user, who
would also not notice the race condition. We have decided to throw a
checked Exception in this case now, to make the Smack user aware of
this situation.

SMACK-426
This commit is contained in:
Florian Schmaus 2014-03-19 14:22:20 +01:00
parent d8c656270e
commit fcc8414a92
101 changed files with 845 additions and 382 deletions

View file

@ -24,6 +24,7 @@ import java.util.Map;
import java.util.WeakHashMap; import java.util.WeakHashMap;
import org.jivesoftware.smack.SmackException.NoResponseException; import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPException.XMPPErrorException; import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.Registration; import org.jivesoftware.smack.packet.Registration;
@ -89,8 +90,9 @@ public class AccountManager extends Manager {
* @return true if the server support creating new accounts. * @return true if the server support creating new accounts.
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
*/ */
public boolean supportsAccountCreation() throws NoResponseException, XMPPErrorException { public boolean supportsAccountCreation() throws NoResponseException, XMPPErrorException, NotConnectedException {
// Check if we already know that the server supports creating new accounts // Check if we already know that the server supports creating new accounts
if (accountCreationSupported) { if (accountCreationSupported) {
return true; return true;
@ -130,8 +132,9 @@ public class AccountManager extends Manager {
* @return the required account attributes. * @return the required account attributes.
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
*/ */
public Collection<String> getAccountAttributes() throws NoResponseException, XMPPErrorException { public Collection<String> getAccountAttributes() throws NoResponseException, XMPPErrorException, NotConnectedException {
if (info == null) { if (info == null) {
getRegistrationInfo(); getRegistrationInfo();
} }
@ -152,8 +155,9 @@ public class AccountManager extends Manager {
* attribute wasn't found for the requested name. * attribute wasn't found for the requested name.
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
*/ */
public String getAccountAttribute(String name) throws NoResponseException, XMPPErrorException { public String getAccountAttribute(String name) throws NoResponseException, XMPPErrorException, NotConnectedException {
if (info == null) { if (info == null) {
getRegistrationInfo(); getRegistrationInfo();
} }
@ -168,8 +172,9 @@ public class AccountManager extends Manager {
* @return the account creation instructions, or <tt>null</tt> if there are none. * @return the account creation instructions, or <tt>null</tt> if there are none.
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
*/ */
public String getAccountInstructions() throws NoResponseException, XMPPErrorException { public String getAccountInstructions() throws NoResponseException, XMPPErrorException, NotConnectedException {
if (info == null) { if (info == null) {
getRegistrationInfo(); getRegistrationInfo();
} }
@ -188,8 +193,9 @@ public class AccountManager extends Manager {
* @param password the password. * @param password the password.
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
*/ */
public void createAccount(String username, String password) throws NoResponseException, XMPPErrorException { public void createAccount(String username, String password) throws NoResponseException, XMPPErrorException, NotConnectedException {
// Create a map for all the required attributes, but give them blank values. // Create a map for all the required attributes, but give them blank values.
Map<String, String> attributes = new HashMap<String, String>(); Map<String, String> attributes = new HashMap<String, String>();
for (String attributeName : getAccountAttributes()) { for (String attributeName : getAccountAttributes()) {
@ -208,10 +214,11 @@ public class AccountManager extends Manager {
* @param attributes the account attributes. * @param attributes the account attributes.
* @throws XMPPErrorException if an error occurs creating the account. * @throws XMPPErrorException if an error occurs creating the account.
* @throws NoResponseException if there was no response from the server. * @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
* @see #getAccountAttributes() * @see #getAccountAttributes()
*/ */
public void createAccount(String username, String password, Map<String, String> attributes) public void createAccount(String username, String password, Map<String, String> attributes)
throws NoResponseException, XMPPErrorException { throws NoResponseException, XMPPErrorException, NotConnectedException {
Registration reg = new Registration(); Registration reg = new Registration();
reg.setType(IQ.Type.SET); reg.setType(IQ.Type.SET);
reg.setTo(connection().getServiceName()); reg.setTo(connection().getServiceName());
@ -229,8 +236,9 @@ public class AccountManager extends Manager {
* @throws IllegalStateException if not currently logged-in to the server. * @throws IllegalStateException if not currently logged-in to the server.
* @throws XMPPErrorException if an error occurs when changing the password. * @throws XMPPErrorException if an error occurs when changing the password.
* @throws NoResponseException if there was no response from the server. * @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/ */
public void changePassword(String newPassword) throws NoResponseException, XMPPErrorException { public void changePassword(String newPassword) throws NoResponseException, XMPPErrorException, NotConnectedException {
Registration reg = new Registration(); Registration reg = new Registration();
reg.setType(IQ.Type.SET); reg.setType(IQ.Type.SET);
reg.setTo(connection().getServiceName()); reg.setTo(connection().getServiceName());
@ -249,8 +257,9 @@ public class AccountManager extends Manager {
* @throws IllegalStateException if not currently logged-in to the server. * @throws IllegalStateException if not currently logged-in to the server.
* @throws XMPPErrorException if an error occurs when deleting the account. * @throws XMPPErrorException if an error occurs when deleting the account.
* @throws NoResponseException if there was no response from the server. * @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/ */
public void deleteAccount() throws NoResponseException, XMPPErrorException { public void deleteAccount() throws NoResponseException, XMPPErrorException, NotConnectedException {
Registration reg = new Registration(); Registration reg = new Registration();
reg.setType(IQ.Type.SET); reg.setType(IQ.Type.SET);
reg.setTo(connection().getServiceName()); reg.setTo(connection().getServiceName());
@ -265,11 +274,12 @@ public class AccountManager extends Manager {
* Gets the account registration info from the server. * Gets the account registration info from the server.
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
* *
* @throws XMPPException if an error occurs. * @throws XMPPException if an error occurs.
* @throws SmackException if there was no response from the server. * @throws SmackException if there was no response from the server.
*/ */
private synchronized void getRegistrationInfo() throws NoResponseException, XMPPErrorException { private synchronized void getRegistrationInfo() throws NoResponseException, XMPPErrorException, NotConnectedException {
Registration reg = new Registration(); Registration reg = new Registration();
reg.setTo(connection().getServiceName()); reg.setTo(connection().getServiceName());
info = (Registration) connection().createPacketCollectorAndSend(reg).nextResultOrThrow(); info = (Registration) connection().createPacketCollectorAndSend(reg).nextResultOrThrow();

View file

@ -17,6 +17,7 @@
package org.jivesoftware.smack; package org.jivesoftware.smack;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.packet.Message; import org.jivesoftware.smack.packet.Message;
import java.util.Set; import java.util.Set;
@ -86,8 +87,9 @@ public class Chat {
* *
* @param text the text to send. * @param text the text to send.
* @throws XMPPException if sending the message fails. * @throws XMPPException if sending the message fails.
* @throws NotConnectedException
*/ */
public void sendMessage(String text) throws XMPPException { public void sendMessage(String text) throws XMPPException, NotConnectedException {
Message message = new Message(participant, Message.Type.chat); Message message = new Message(participant, Message.Type.chat);
message.setThread(threadID); message.setThread(threadID);
message.setBody(text); message.setBody(text);
@ -99,8 +101,9 @@ public class Chat {
* and message type of the message will automatically set to those of this chat. * and message type of the message will automatically set to those of this chat.
* *
* @param message the message to send. * @param message the message to send.
* @throws NotConnectedException
*/ */
public void sendMessage(Message message) { public void sendMessage(Message message) throws NotConnectedException {
// Force the recipient, message type, and thread ID since the user elected // Force the recipient, message type, and thread ID since the user elected
// to send the message through this chat object. // to send the message through this chat object.
message.setTo(participant); message.setTo(participant);

View file

@ -26,6 +26,7 @@ import java.util.UUID;
import java.util.WeakHashMap; import java.util.WeakHashMap;
import java.util.concurrent.CopyOnWriteArraySet; import java.util.concurrent.CopyOnWriteArraySet;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.filter.AndFilter; import org.jivesoftware.smack.filter.AndFilter;
import org.jivesoftware.smack.filter.FromMatchesFilter; import org.jivesoftware.smack.filter.FromMatchesFilter;
import org.jivesoftware.smack.filter.PacketFilter; import org.jivesoftware.smack.filter.PacketFilter;
@ -334,7 +335,7 @@ public class ChatManager extends Manager{
chat.deliver(message); chat.deliver(message);
} }
void sendMessage(Chat chat, Message message) { void sendMessage(Chat chat, Message message) throws NotConnectedException {
for(Map.Entry<PacketInterceptor, PacketFilter> interceptor : interceptors.entrySet()) { for(Map.Entry<PacketInterceptor, PacketFilter> interceptor : interceptors.entrySet()) {
PacketFilter filter = interceptor.getValue(); PacketFilter filter = interceptor.getValue();
if(filter != null && filter.accept(message)) { if(filter != null && filter.accept(message)) {

View file

@ -17,6 +17,7 @@
package org.jivesoftware.smack; package org.jivesoftware.smack;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.packet.Packet; import org.jivesoftware.smack.packet.Packet;
/** /**
@ -40,6 +41,6 @@ public interface PacketListener {
* *
* @param packet the packet to process. * @param packet the packet to process.
*/ */
public void processPacket(Packet packet); public void processPacket(Packet packet) throws NotConnectedException;
} }

View file

@ -33,6 +33,7 @@ import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import org.jivesoftware.smack.SmackException.NoResponseException; import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.SmackException.NotLoggedInException; import org.jivesoftware.smack.SmackException.NotLoggedInException;
import org.jivesoftware.smack.XMPPException.XMPPErrorException; import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.filter.IQReplyFilter; import org.jivesoftware.smack.filter.IQReplyFilter;
@ -132,12 +133,22 @@ public class Roster {
public void connectionClosed() { public void connectionClosed() {
// Changes the presence available contacts to unavailable // Changes the presence available contacts to unavailable
setOfflinePresences(); try {
setOfflinePresences();
}
catch (NotConnectedException e) {
LOGGER.log(Level.SEVERE, "Not connected exception" ,e);
}
} }
public void connectionClosedOnError(Exception e) { public void connectionClosedOnError(Exception e) {
// Changes the presence available contacts to unavailable // Changes the presence available contacts to unavailable
setOfflinePresences(); try {
setOfflinePresences();
}
catch (NotConnectedException e1) {
LOGGER.log(Level.SEVERE, "Not connected exception" ,e);
}
} }
}); });
@ -146,7 +157,7 @@ public class Roster {
try { try {
reload(); reload();
} }
catch (NotLoggedInException e) { catch (SmackException e) {
LOGGER.log(Level.SEVERE, "Could not reload Roster", e); LOGGER.log(Level.SEVERE, "Could not reload Roster", e);
} }
} }
@ -162,7 +173,7 @@ public class Roster {
try { try {
Roster.this.reload(); Roster.this.reload();
} }
catch (NotLoggedInException e) { catch (SmackException e) {
LOGGER.log(Level.SEVERE, "Could not reload Roster", e); LOGGER.log(Level.SEVERE, "Could not reload Roster", e);
return; return;
} }
@ -205,8 +216,9 @@ public class Roster {
* which means the method will return immediately, and the roster will be * which means the method will return immediately, and the roster will be
* reloaded at a later point when the server responds to the reload request. * reloaded at a later point when the server responds to the reload request.
* @throws NotLoggedInException If not logged in. * @throws NotLoggedInException If not logged in.
* @throws NotConnectedException
*/ */
public void reload() throws NotLoggedInException{ public void reload() throws NotLoggedInException, NotConnectedException{
if (!connection.isAuthenticated()) { if (!connection.isAuthenticated()) {
throw new NotLoggedInException(); throw new NotLoggedInException();
} }
@ -285,9 +297,10 @@ public class Roster {
* @throws NoResponseException if there was no response from the server. * @throws NoResponseException if there was no response from the server.
* @throws XMPPErrorException if an XMPP exception occurs. * @throws XMPPErrorException if an XMPP exception occurs.
* @throws NotLoggedInException If not logged in. * @throws NotLoggedInException If not logged in.
* @throws NotConnectedException
* @throws IllegalStateException if logged in anonymously * @throws IllegalStateException if logged in anonymously
*/ */
public void createEntry(String user, String name, String[] groups) throws NotLoggedInException, NoResponseException, XMPPErrorException { public void createEntry(String user, String name, String[] groups) throws NotLoggedInException, NoResponseException, XMPPErrorException, NotConnectedException {
if (!connection.isAuthenticated()) { if (!connection.isAuthenticated()) {
throw new NotLoggedInException(); throw new NotLoggedInException();
} }
@ -325,9 +338,10 @@ public class Roster {
* @throws XMPPErrorException if an XMPP error occurs. * @throws XMPPErrorException if an XMPP error occurs.
* @throws NotLoggedInException if not logged in. * @throws NotLoggedInException if not logged in.
* @throws NoResponseException SmackException if there was no response from the server. * @throws NoResponseException SmackException if there was no response from the server.
* @throws NotConnectedException
* @throws IllegalStateException if connection is not logged in or logged in anonymously * @throws IllegalStateException if connection is not logged in or logged in anonymously
*/ */
public void removeEntry(RosterEntry entry) throws NotLoggedInException, NoResponseException, XMPPErrorException { public void removeEntry(RosterEntry entry) throws NotLoggedInException, NoResponseException, XMPPErrorException, NotConnectedException {
if (!connection.isAuthenticated()) { if (!connection.isAuthenticated()) {
throw new NotLoggedInException(); throw new NotLoggedInException();
} }
@ -626,8 +640,9 @@ public class Roster {
* Changes the presence of available contacts offline by simulating an unavailable * Changes the presence of available contacts offline by simulating an unavailable
* presence sent from the server. After a disconnection, every Presence is set * presence sent from the server. After a disconnection, every Presence is set
* to offline. * to offline.
* @throws NotConnectedException
*/ */
private void setOfflinePresences() { private void setOfflinePresences() throws NotConnectedException {
Presence packetUnavailable; Presence packetUnavailable;
for (String user : presenceMap.keySet()) { for (String user : presenceMap.keySet()) {
Map<String, Presence> resources = presenceMap.get(user); Map<String, Presence> resources = presenceMap.get(user);
@ -813,7 +828,7 @@ public class Roster {
*/ */
private class PresencePacketListener implements PacketListener { private class PresencePacketListener implements PacketListener {
public void processPacket(Packet packet) { public void processPacket(Packet packet) throws NotConnectedException {
Presence presence = (Presence) packet; Presence presence = (Presence) packet;
String from = presence.getFrom(); String from = presence.getFrom();
String key = getPresenceMapKey(from); String key = getPresenceMapKey(from);
@ -1024,7 +1039,7 @@ public class Roster {
*/ */
private class RosterPushListener implements PacketListener { private class RosterPushListener implements PacketListener {
public void processPacket(Packet packet) { public void processPacket(Packet packet) throws NotConnectedException {
RosterPacket rosterPacket = (RosterPacket) packet; RosterPacket rosterPacket = (RosterPacket) packet;
if (!rosterPacket.getType().equals(IQ.Type.SET)) { if (!rosterPacket.getType().equals(IQ.Type.SET)) {
return; return;

View file

@ -17,6 +17,7 @@
package org.jivesoftware.smack; package org.jivesoftware.smack;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.RosterPacket; import org.jivesoftware.smack.packet.RosterPacket;
@ -78,8 +79,9 @@ public class RosterEntry {
* Sets the name associated with this entry. * Sets the name associated with this entry.
* *
* @param name the name. * @param name the name.
* @throws NotConnectedException
*/ */
public void setName(String name) { public void setName(String name) throws NotConnectedException {
// Do nothing if the name hasn't changed. // Do nothing if the name hasn't changed.
if (name != null && name.equals(this.name)) { if (name != null && name.equals(this.name)) {
return; return;

View file

@ -24,6 +24,7 @@ import java.util.LinkedHashSet;
import java.util.Set; import java.util.Set;
import org.jivesoftware.smack.SmackException.NoResponseException; import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPException.XMPPErrorException; import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.RosterPacket; import org.jivesoftware.smack.packet.RosterPacket;
@ -69,8 +70,9 @@ public class RosterGroup {
* be invalid and will need to be updated to the new group specified by the new name. * be invalid and will need to be updated to the new group specified by the new name.
* *
* @param name the name of the group. * @param name the name of the group.
* @throws NotConnectedException
*/ */
public void setName(String name) { public void setName(String name) throws NotConnectedException {
synchronized (entries) { synchronized (entries) {
for (RosterEntry entry : entries) { for (RosterEntry entry : entries) {
RosterPacket packet = new RosterPacket(); RosterPacket packet = new RosterPacket();
@ -162,8 +164,9 @@ public class RosterGroup {
* @param entry a roster entry. * @param entry a roster entry.
* @throws XMPPErrorException if an error occured while trying to add the entry to the group. * @throws XMPPErrorException if an error occured while trying to add the entry to the group.
* @throws NoResponseException if there was no response from the server. * @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/ */
public void addEntry(RosterEntry entry) throws NoResponseException, XMPPErrorException { public void addEntry(RosterEntry entry) throws NoResponseException, XMPPErrorException, NotConnectedException {
PacketCollector collector = null; PacketCollector collector = null;
// Only add the entry if it isn't already in the list. // Only add the entry if it isn't already in the list.
synchronized (entries) { synchronized (entries) {
@ -192,8 +195,9 @@ public class RosterGroup {
* @param entry a roster entry. * @param entry a roster entry.
* @throws XMPPErrorException if an error occurred while trying to remove the entry from the group. * @throws XMPPErrorException if an error occurred while trying to remove the entry from the group.
* @throws NoResponseException if there was no response from the server. * @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/ */
public void removeEntry(RosterEntry entry) throws NoResponseException, XMPPErrorException { public void removeEntry(RosterEntry entry) throws NoResponseException, XMPPErrorException, NotConnectedException {
PacketCollector collector = null; PacketCollector collector = null;
// Only remove the entry if it's in the entry list. // Only remove the entry if it's in the entry list.
// Remove the entry locally, if we wait for RosterPacketListenerprocess>>Packet(Packet) // Remove the entry locally, if we wait for RosterPacketListenerprocess>>Packet(Packet)

View file

@ -18,6 +18,7 @@
package org.jivesoftware.smack; package org.jivesoftware.smack;
import org.jivesoftware.smack.SmackException.NoResponseException; import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.SmackException.ResourceBindingNotOfferedException; import org.jivesoftware.smack.SmackException.ResourceBindingNotOfferedException;
import org.jivesoftware.smack.XMPPException.XMPPErrorException; import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.packet.Bind; import org.jivesoftware.smack.packet.Bind;
@ -212,9 +213,10 @@ public class SASLAuthentication {
* @throws NoResponseException * @throws NoResponseException
* @throws SASLErrorException * @throws SASLErrorException
* @throws ResourceBindingNotOfferedException * @throws ResourceBindingNotOfferedException
* @throws NotConnectedException
*/ */
public String authenticate(String resource, CallbackHandler cbh) throws IOException, public String authenticate(String resource, CallbackHandler cbh) throws IOException,
NoResponseException, XMPPErrorException, SASLErrorException, ResourceBindingNotOfferedException { NoResponseException, XMPPErrorException, SASLErrorException, ResourceBindingNotOfferedException, NotConnectedException {
// Locate the SASLMechanism to use // Locate the SASLMechanism to use
String selectedMechanism = null; String selectedMechanism = null;
for (String mechanism : mechanismsPreferences) { for (String mechanism : mechanismsPreferences) {
@ -409,7 +411,7 @@ public class SASLAuthentication {
} }
private String bindResourceAndEstablishSession(String resource) throws XMPPErrorException, private String bindResourceAndEstablishSession(String resource) throws XMPPErrorException,
ResourceBindingNotOfferedException, NoResponseException { ResourceBindingNotOfferedException, NoResponseException, NotConnectedException {
// Wait until server sends response containing the <bind> element // Wait until server sends response containing the <bind> element
synchronized (this) { synchronized (this) {
if (!resourceBinded) { if (!resourceBinded) {
@ -470,8 +472,9 @@ public class SASLAuthentication {
* *
* @param challenge a base64 encoded string representing the challenge. * @param challenge a base64 encoded string representing the challenge.
* @throws IOException If a network error occures while authenticating. * @throws IOException If a network error occures while authenticating.
* @throws NotConnectedException
*/ */
void challengeReceived(String challenge) throws IOException { void challengeReceived(String challenge) throws IOException, NotConnectedException {
currentMechanism.challengeReceived(challenge); currentMechanism.challengeReceived(challenge);
} }
@ -514,7 +517,7 @@ public class SASLAuthentication {
} }
} }
public void send(Packet stanza) { public void send(Packet stanza) throws NotConnectedException {
connection.sendPacket(stanza); connection.sendPacket(stanza);
} }

View file

@ -41,6 +41,7 @@ import java.util.logging.Logger;
import javax.security.sasl.SaslException; import javax.security.sasl.SaslException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.SmackException.ConnectionException; import org.jivesoftware.smack.SmackException.ConnectionException;
import org.jivesoftware.smack.compression.XMPPInputOutputStream; import org.jivesoftware.smack.compression.XMPPInputOutputStream;
import org.jivesoftware.smack.debugger.SmackDebugger; import org.jivesoftware.smack.debugger.SmackDebugger;
@ -438,10 +439,11 @@ public abstract class XMPPConnection {
* Sends the specified packet to the server. * Sends the specified packet to the server.
* *
* @param packet the packet to send. * @param packet the packet to send.
* @throws NotConnectedException
*/ */
public void sendPacket(Packet packet) { public void sendPacket(Packet packet) throws NotConnectedException {
if (!isConnected()) { if (!isConnected()) {
throw new IllegalStateException("Not connected to server."); throw new NotConnectedException();
} }
if (packet == null) { if (packet == null) {
throw new NullPointerException("Packet is null."); throw new NullPointerException("Packet is null.");
@ -627,8 +629,9 @@ public abstract class XMPPConnection {
* *
* @param packet the packet to filter responses from * @param packet the packet to filter responses from
* @return a new packet collector. * @return a new packet collector.
* @throws NotConnectedException
*/ */
public PacketCollector createPacketCollectorAndSend(IQ packet) { public PacketCollector createPacketCollectorAndSend(IQ packet) throws NotConnectedException {
PacketFilter packetFilter = new IQReplyFilter(packet, this); PacketFilter packetFilter = new IQReplyFilter(packet, this);
// Create the packet collector before sending the packet // Create the packet collector before sending the packet
PacketCollector packetCollector = createPacketCollector(packetFilter); PacketCollector packetCollector = createPacketCollector(packetFilter);
@ -755,7 +758,13 @@ public abstract class XMPPConnection {
private void firePacketSendingListeners(Packet packet) { private void firePacketSendingListeners(Packet packet) {
// Notify the listeners of the new sent packet // Notify the listeners of the new sent packet
for (ListenerWrapper listenerWrapper : sendListeners.values()) { for (ListenerWrapper listenerWrapper : sendListeners.values()) {
listenerWrapper.notifyListener(packet); try {
listenerWrapper.notifyListener(packet);
}
catch (NotConnectedException e) {
LOGGER.log(Level.WARNING, "Got not connected exception, aborting");
break;
}
} }
} }
@ -962,6 +971,9 @@ public abstract class XMPPConnection {
for (ListenerWrapper listenerWrapper : recvListeners.values()) { for (ListenerWrapper listenerWrapper : recvListeners.values()) {
try { try {
listenerWrapper.notifyListener(packet); listenerWrapper.notifyListener(packet);
} catch(NotConnectedException e) {
LOGGER.log(Level.WARNING, "Got not connected exception, aborting", e);
break;
} catch (Exception e) { } catch (Exception e) {
LOGGER.log(Level.SEVERE, "Exception in packet listener", e); LOGGER.log(Level.SEVERE, "Exception in packet listener", e);
} }
@ -1030,8 +1042,9 @@ public abstract class XMPPConnection {
* Notify and process the packet listener if the filter matches the packet. * Notify and process the packet listener if the filter matches the packet.
* *
* @param packet the packet which was sent or received. * @param packet the packet which was sent or received.
* @throws NotConnectedException
*/ */
public void notifyListener(Packet packet) { public void notifyListener(Packet packet) throws NotConnectedException {
if (packetFilter == null || packetFilter.accept(packet)) { if (packetFilter == null || packetFilter.accept(packet)) {
packetListener.processPacket(packet); packetListener.processPacket(packet);
} }

View file

@ -17,8 +17,10 @@
package org.jivesoftware.smack.sasl; package org.jivesoftware.smack.sasl;
import org.jivesoftware.smack.SASLAuthentication; import org.jivesoftware.smack.SASLAuthentication;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import java.io.IOException; import java.io.IOException;
import javax.security.auth.callback.CallbackHandler; import javax.security.auth.callback.CallbackHandler;
/** /**
@ -36,20 +38,20 @@ public class SASLAnonymous extends SASLMechanism {
return "ANONYMOUS"; return "ANONYMOUS";
} }
public void authenticate(String username, String host, CallbackHandler cbh) throws IOException { public void authenticate(String username, String host, CallbackHandler cbh) throws IOException, NotConnectedException {
authenticate(); authenticate();
} }
public void authenticate(String username, String host, String password) throws IOException { public void authenticate(String username, String host, String password) throws IOException, NotConnectedException {
authenticate(); authenticate();
} }
protected void authenticate() throws IOException { protected void authenticate() throws IOException, NotConnectedException {
// Send the authentication to the server // Send the authentication to the server
getSASLAuthentication().send(new AuthMechanism(getName(), null)); getSASLAuthentication().send(new AuthMechanism(getName(), null));
} }
public void challengeReceived(String challenge) throws IOException { public void challengeReceived(String challenge) throws IOException, NotConnectedException {
// Build the challenge response stanza encoding the response text // Build the challenge response stanza encoding the response text
// and send the authentication to the server // and send the authentication to the server
getSASLAuthentication().send(new Response()); getSASLAuthentication().send(new Response());

View file

@ -17,6 +17,7 @@
package org.jivesoftware.smack.sasl; package org.jivesoftware.smack.sasl;
import org.jivesoftware.smack.SASLAuthentication; import org.jivesoftware.smack.SASLAuthentication;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import java.io.IOException; import java.io.IOException;
import java.util.Map; import java.util.Map;
@ -55,8 +56,9 @@ public class SASLGSSAPIMechanism extends SASLMechanism {
* @param host the hostname where the user account resides. * @param host the hostname where the user account resides.
* @param cbh the CallbackHandler (not used with GSSAPI) * @param cbh the CallbackHandler (not used with GSSAPI)
* @throws IOException If a network error occures while authenticating. * @throws IOException If a network error occures while authenticating.
* @throws NotConnectedException
*/ */
public void authenticate(String username, String host, CallbackHandler cbh) throws IOException, SaslException { public void authenticate(String username, String host, CallbackHandler cbh) throws IOException, SaslException, NotConnectedException {
String[] mechanisms = { getName() }; String[] mechanisms = { getName() };
Map<String,String> props = new HashMap<String,String>(); Map<String,String> props = new HashMap<String,String>();
props.put(Sasl.SERVER_AUTH,"TRUE"); props.put(Sasl.SERVER_AUTH,"TRUE");
@ -74,8 +76,9 @@ public class SASLGSSAPIMechanism extends SASLMechanism {
* @param host the hostname where the user account resides. * @param host the hostname where the user account resides.
* @param password the password of the user (ignored for GSSAPI) * @param password the password of the user (ignored for GSSAPI)
* @throws IOException If a network error occures while authenticating. * @throws IOException If a network error occures while authenticating.
* @throws NotConnectedException
*/ */
public void authenticate(String username, String host, String password) throws IOException, SaslException { public void authenticate(String username, String host, String password) throws IOException, SaslException, NotConnectedException {
String[] mechanisms = { getName() }; String[] mechanisms = { getName() };
Map<String,String> props = new HashMap<String, String>(); Map<String,String> props = new HashMap<String, String>();
props.put(Sasl.SERVER_AUTH,"TRUE"); props.put(Sasl.SERVER_AUTH,"TRUE");

View file

@ -17,12 +17,14 @@
package org.jivesoftware.smack.sasl; package org.jivesoftware.smack.sasl;
import org.jivesoftware.smack.SASLAuthentication; import org.jivesoftware.smack.SASLAuthentication;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.packet.Packet; import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.util.StringUtils; import org.jivesoftware.smack.util.StringUtils;
import java.io.IOException; import java.io.IOException;
import java.util.Map; import java.util.Map;
import java.util.HashMap; import java.util.HashMap;
import javax.security.auth.callback.CallbackHandler; import javax.security.auth.callback.CallbackHandler;
import javax.security.auth.callback.UnsupportedCallbackException; import javax.security.auth.callback.UnsupportedCallbackException;
import javax.security.auth.callback.Callback; import javax.security.auth.callback.Callback;
@ -129,8 +131,9 @@ public abstract class SASLMechanism implements CallbackHandler {
* @param password the password for this account. * @param password the password for this account.
* @throws IOException If a network error occurs while authenticating. * @throws IOException If a network error occurs while authenticating.
* @throws SaslException * @throws SaslException
* @throws NotConnectedException
*/ */
public void authenticate(String username, String host, String serviceName, String password) throws IOException, SaslException { public void authenticate(String username, String host, String serviceName, String password) throws IOException, SaslException, NotConnectedException {
//Since we were not provided with a CallbackHandler, we will use our own with the given //Since we were not provided with a CallbackHandler, we will use our own with the given
//information //information
@ -153,15 +156,16 @@ public abstract class SASLMechanism implements CallbackHandler {
* @param cbh the CallbackHandler to obtain user information. * @param cbh the CallbackHandler to obtain user information.
* @throws IOException If a network error occures while authenticating. * @throws IOException If a network error occures while authenticating.
* @throws SaslException If a protocol error occurs or the user is not authenticated. * @throws SaslException If a protocol error occurs or the user is not authenticated.
* @throws NotConnectedException
*/ */
public void authenticate(String host, CallbackHandler cbh) throws IOException, SaslException { public void authenticate(String host, CallbackHandler cbh) throws IOException, SaslException, NotConnectedException {
String[] mechanisms = { getName() }; String[] mechanisms = { getName() };
Map<String,String> props = new HashMap<String,String>(); Map<String,String> props = new HashMap<String,String>();
sc = Sasl.createSaslClient(mechanisms, null, "xmpp", host, props, cbh); sc = Sasl.createSaslClient(mechanisms, null, "xmpp", host, props, cbh);
authenticate(); authenticate();
} }
protected void authenticate() throws IOException, SaslException { protected void authenticate() throws IOException, SaslException, NotConnectedException {
String authenticationText = null; String authenticationText = null;
if (sc.hasInitialResponse()) { if (sc.hasInitialResponse()) {
byte[] response = sc.evaluateChallenge(new byte[0]); byte[] response = sc.evaluateChallenge(new byte[0]);
@ -178,8 +182,9 @@ public abstract class SASLMechanism implements CallbackHandler {
* *
* @param challenge a base64 encoded string representing the challenge. * @param challenge a base64 encoded string representing the challenge.
* @throws IOException if an exception sending the response occurs. * @throws IOException if an exception sending the response occurs.
* @throws NotConnectedException
*/ */
public void challengeReceived(String challenge) throws IOException { public void challengeReceived(String challenge) throws IOException, NotConnectedException {
byte response[]; byte response[];
if(challenge != null) { if(challenge != null) {
response = sc.evaluateChallenge(StringUtils.decodeBase64(challenge)); response = sc.evaluateChallenge(StringUtils.decodeBase64(challenge));

View file

@ -23,6 +23,7 @@ import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.ConnectionConfiguration; import org.jivesoftware.smack.ConnectionConfiguration;
import org.jivesoftware.smack.ConnectionCreationListener; import org.jivesoftware.smack.ConnectionCreationListener;
@ -249,7 +250,12 @@ public class DummyConnection extends XMPPConnection {
// Deliver the incoming packet to listeners. // Deliver the incoming packet to listeners.
for (ListenerWrapper listenerWrapper : recvListeners.values()) { for (ListenerWrapper listenerWrapper : recvListeners.values()) {
listenerWrapper.notifyListener(packet); try {
listenerWrapper.notifyListener(packet);
}
catch (NotConnectedException e) {
e.printStackTrace();
}
} }
} }
} }

View file

@ -20,6 +20,7 @@ import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue; import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.LinkedBlockingQueue;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.Message; import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.Packet; import org.jivesoftware.smack.packet.Packet;
@ -37,7 +38,12 @@ public class ThreadedDummyConnection extends DummyConnection {
@Override @Override
public void sendPacket(Packet packet) { public void sendPacket(Packet packet) {
super.sendPacket(packet); try {
super.sendPacket(packet);
}
catch (NotConnectedException e) {
e.printStackTrace();
}
if (packet instanceof IQ && !timeout) { if (packet instanceof IQ && !timeout) {
timeout = false; timeout = false;

View file

@ -20,6 +20,7 @@ package org.jivesoftware.smackx.debugger;
import org.jivesoftware.smack.AbstractConnectionListener; import org.jivesoftware.smack.AbstractConnectionListener;
import org.jivesoftware.smack.ConnectionListener; import org.jivesoftware.smack.ConnectionListener;
import org.jivesoftware.smack.PacketListener; import org.jivesoftware.smack.PacketListener;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.debugger.SmackDebugger; import org.jivesoftware.smack.debugger.SmackDebugger;
import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.IQ;
@ -36,6 +37,7 @@ import javax.swing.text.BadLocationException;
import javax.xml.transform.*; import javax.xml.transform.*;
import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource; import javax.xml.transform.stream.StreamSource;
import java.awt.*; import java.awt.*;
import java.awt.datatransfer.Clipboard; import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection; import java.awt.datatransfer.StringSelection;
@ -545,7 +547,12 @@ public class EnhancedDebugger implements SmackDebugger {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
if (!"".equals(adhocMessages.getText())) { if (!"".equals(adhocMessages.getText())) {
AdHocPacket packetToSend = new AdHocPacket(adhocMessages.getText()); AdHocPacket packetToSend = new AdHocPacket(adhocMessages.getText());
connection.sendPacket(packetToSend); try {
connection.sendPacket(packetToSend);
}
catch (NotConnectedException e1) {
e1.printStackTrace();
}
} }
} }
}); });

View file

@ -22,6 +22,7 @@ import java.util.WeakHashMap;
import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.SmackException.NoResponseException; import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.ConnectionCreationListener; import org.jivesoftware.smack.ConnectionCreationListener;
import org.jivesoftware.smack.Manager; import org.jivesoftware.smack.Manager;
@ -113,8 +114,9 @@ public class CarbonManager extends Manager {
* You should first check for support using isSupportedByServer(). * You should first check for support using isSupportedByServer().
* *
* @param new_state whether carbons should be enabled or disabled * @param new_state whether carbons should be enabled or disabled
* @throws NotConnectedException
*/ */
public void sendCarbonsEnabled(final boolean new_state) { public void sendCarbonsEnabled(final boolean new_state) throws NotConnectedException {
IQ setIQ = carbonsEnabledIQ(new_state); IQ setIQ = carbonsEnabledIQ(new_state);
connection().addPacketListener(new PacketListener() { connection().addPacketListener(new PacketListener() {
@ -140,10 +142,11 @@ public class CarbonManager extends Manager {
* @param new_state whether carbons should be enabled or disabled * @param new_state whether carbons should be enabled or disabled
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
* *
*/ */
public synchronized void setCarbonsEnabled(final boolean new_state) throws NoResponseException, public synchronized void setCarbonsEnabled(final boolean new_state) throws NoResponseException,
XMPPErrorException { XMPPErrorException, NotConnectedException {
if (enabled_state == new_state) if (enabled_state == new_state)
return; return;

View file

@ -20,6 +20,7 @@ package org.jivesoftware.smackx.address;
import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.SmackException.NoResponseException; import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.FeatureNotSupportedException; import org.jivesoftware.smack.SmackException.FeatureNotSupportedException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException.XMPPErrorException; import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.packet.Message; import org.jivesoftware.smack.packet.Message;
@ -70,8 +71,9 @@ public class MultipleRecipientManager {
* @throws XMPPErrorException if server does not support JEP-33: Extended Stanza Addressing and * @throws XMPPErrorException if server does not support JEP-33: Extended Stanza Addressing and
* some JEP-33 specific features were requested. * some JEP-33 specific features were requested.
* @throws NoResponseException if there was no response from the server. * @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/ */
public static void send(XMPPConnection connection, Packet packet, List<String> to, List<String> cc, List<String> bcc) throws NoResponseException, XMPPErrorException, FeatureNotSupportedException public static void send(XMPPConnection connection, Packet packet, List<String> to, List<String> cc, List<String> bcc) throws NoResponseException, XMPPErrorException, FeatureNotSupportedException, NotConnectedException
{ {
send(connection, packet, to, cc, bcc, null, null, false); send(connection, packet, to, cc, bcc, null, null, false);
} }
@ -98,9 +100,10 @@ public class MultipleRecipientManager {
* @throws NoResponseException if there was no response from the server. * @throws NoResponseException if there was no response from the server.
* @throws FeatureNotSupportedException if special XEP-33 features where requested, but the * @throws FeatureNotSupportedException if special XEP-33 features where requested, but the
* server does not support them. * server does not support them.
* @throws NotConnectedException
*/ */
public static void send(XMPPConnection connection, Packet packet, List<String> to, List<String> cc, List<String> bcc, public static void send(XMPPConnection connection, Packet packet, List<String> to, List<String> cc, List<String> bcc,
String replyTo, String replyRoom, boolean noReply) throws NoResponseException, XMPPErrorException, FeatureNotSupportedException { String replyTo, String replyRoom, boolean noReply) throws NoResponseException, XMPPErrorException, FeatureNotSupportedException, NotConnectedException {
String serviceAddress = getMultipleRecipienServiceAddress(connection); String serviceAddress = getMultipleRecipienServiceAddress(connection);
if (serviceAddress != null) { if (serviceAddress != null) {
// Send packet to target users using multiple recipient service provided by the server // Send packet to target users using multiple recipient service provided by the server
@ -206,7 +209,7 @@ public class MultipleRecipientManager {
} }
private static void sendToIndividualRecipients(XMPPConnection connection, Packet packet, private static void sendToIndividualRecipients(XMPPConnection connection, Packet packet,
List<String> to, List<String> cc, List<String> bcc) { List<String> to, List<String> cc, List<String> bcc) throws NotConnectedException {
if (to != null) { if (to != null) {
for (Iterator<String> it = to.iterator(); it.hasNext();) { for (Iterator<String> it = to.iterator(); it.hasNext();) {
String jid = it.next(); String jid = it.next();
@ -232,7 +235,7 @@ public class MultipleRecipientManager {
private static void sendThroughService(XMPPConnection connection, Packet packet, List<String> to, private static void sendThroughService(XMPPConnection connection, Packet packet, List<String> to,
List<String> cc, List<String> bcc, String replyTo, String replyRoom, boolean noReply, List<String> cc, List<String> bcc, String replyTo, String replyRoom, boolean noReply,
String serviceAddress) { String serviceAddress) throws NotConnectedException {
// Create multiple recipient extension // Create multiple recipient extension
MultipleAddresses multipleAddresses = new MultipleAddresses(); MultipleAddresses multipleAddresses = new MultipleAddresses();
if (to != null) { if (to != null) {
@ -285,8 +288,9 @@ public class MultipleRecipientManager {
* @return the address of the multiple recipients service or <tt>null</tt> if none was found. * @return the address of the multiple recipients service or <tt>null</tt> if none was found.
* @throws NoResponseException if there was no response from the server. * @throws NoResponseException if there was no response from the server.
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NotConnectedException
*/ */
private static String getMultipleRecipienServiceAddress(XMPPConnection connection) throws NoResponseException, XMPPErrorException { private static String getMultipleRecipienServiceAddress(XMPPConnection connection) throws NoResponseException, XMPPErrorException, NotConnectedException {
String serviceName = connection.getServiceName(); String serviceName = connection.getServiceName();
String serviceAddress = (String) services.get(serviceName); String serviceAddress = (String) services.get(serviceName);
if (serviceAddress == null) { if (serviceAddress == null) {

View file

@ -17,6 +17,7 @@
package org.jivesoftware.smackx.amp; package org.jivesoftware.smackx.amp;
import org.jivesoftware.smack.SmackException.NoResponseException; import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException.XMPPErrorException; import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smackx.amp.packet.AMPExtension; import org.jivesoftware.smackx.amp.packet.AMPExtension;
@ -31,8 +32,9 @@ public class AMPDeliverCondition implements AMPExtension.Condition {
* @return true if deliver condition is supported. * @return true if deliver condition is supported.
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
*/ */
public static boolean isSupported(XMPPConnection connection) throws NoResponseException, XMPPErrorException { public static boolean isSupported(XMPPConnection connection) throws NoResponseException, XMPPErrorException, NotConnectedException {
return AMPManager.isConditionSupported(connection, NAME); return AMPManager.isConditionSupported(connection, NAME);
} }

View file

@ -17,6 +17,7 @@
package org.jivesoftware.smackx.amp; package org.jivesoftware.smackx.amp;
import org.jivesoftware.smack.SmackException.NoResponseException; import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException.XMPPErrorException; import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.util.XmppDateTime; import org.jivesoftware.smack.util.XmppDateTime;
@ -35,8 +36,9 @@ public class AMPExpireAtCondition implements AMPExtension.Condition {
* @return true if expire-at condition is supported. * @return true if expire-at condition is supported.
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
*/ */
public static boolean isSupported(XMPPConnection connection) throws NoResponseException, XMPPErrorException { public static boolean isSupported(XMPPConnection connection) throws NoResponseException, XMPPErrorException, NotConnectedException {
return AMPManager.isConditionSupported(connection, NAME); return AMPManager.isConditionSupported(connection, NAME);
} }

View file

@ -17,6 +17,7 @@
package org.jivesoftware.smackx.amp; package org.jivesoftware.smackx.amp;
import org.jivesoftware.smack.SmackException.NoResponseException; import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.ConnectionCreationListener; import org.jivesoftware.smack.ConnectionCreationListener;
import org.jivesoftware.smack.XMPPException.XMPPErrorException; import org.jivesoftware.smack.XMPPException.XMPPErrorException;
@ -86,8 +87,9 @@ public class AMPManager {
* @return true if this action is supported. * @return true if this action is supported.
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
*/ */
public static boolean isActionSupported(XMPPConnection connection, AMPExtension.Action action) throws NoResponseException, XMPPErrorException { public static boolean isActionSupported(XMPPConnection connection, AMPExtension.Action action) throws NoResponseException, XMPPErrorException, NotConnectedException {
String featureName = AMPExtension.NAMESPACE + "?action=" + action.toString(); String featureName = AMPExtension.NAMESPACE + "?action=" + action.toString();
return isFeatureSupportedByServer(connection, featureName, AMPExtension.NAMESPACE); return isFeatureSupportedByServer(connection, featureName, AMPExtension.NAMESPACE);
} }
@ -99,16 +101,17 @@ public class AMPManager {
* @return true if this condition is supported. * @return true if this condition is supported.
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
* @see AMPDeliverCondition * @see AMPDeliverCondition
* @see AMPExpireAtCondition * @see AMPExpireAtCondition
* @see AMPMatchResourceCondition * @see AMPMatchResourceCondition
*/ */
public static boolean isConditionSupported(XMPPConnection connection, String conditionName) throws NoResponseException, XMPPErrorException { public static boolean isConditionSupported(XMPPConnection connection, String conditionName) throws NoResponseException, XMPPErrorException, NotConnectedException {
String featureName = AMPExtension.NAMESPACE + "?condition=" + conditionName; String featureName = AMPExtension.NAMESPACE + "?condition=" + conditionName;
return isFeatureSupportedByServer(connection, featureName, AMPExtension.NAMESPACE); return isFeatureSupportedByServer(connection, featureName, AMPExtension.NAMESPACE);
} }
private static boolean isFeatureSupportedByServer(XMPPConnection connection, String featureName, String node) throws NoResponseException, XMPPErrorException { private static boolean isFeatureSupportedByServer(XMPPConnection connection, String featureName, String node) throws NoResponseException, XMPPErrorException, NotConnectedException {
ServiceDiscoveryManager discoveryManager = ServiceDiscoveryManager.getInstanceFor(connection); ServiceDiscoveryManager discoveryManager = ServiceDiscoveryManager.getInstanceFor(connection);
DiscoverInfo info = discoveryManager.discoverInfo(connection.getServiceName(), node); DiscoverInfo info = discoveryManager.discoverInfo(connection.getServiceName(), node);
Iterator<DiscoverInfo.Feature> it = info.getFeatures(); Iterator<DiscoverInfo.Feature> it = info.getFeatures();

View file

@ -17,6 +17,7 @@
package org.jivesoftware.smackx.amp; package org.jivesoftware.smackx.amp;
import org.jivesoftware.smack.SmackException.NoResponseException; import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException.XMPPErrorException; import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smackx.amp.packet.AMPExtension; import org.jivesoftware.smackx.amp.packet.AMPExtension;
@ -31,8 +32,9 @@ public class AMPMatchResourceCondition implements AMPExtension.Condition {
* @return true if match-resource condition is supported. * @return true if match-resource condition is supported.
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
*/ */
public static boolean isSupported(XMPPConnection connection) throws NoResponseException, XMPPErrorException { public static boolean isSupported(XMPPConnection connection) throws NoResponseException, XMPPErrorException, NotConnectedException {
return AMPManager.isConditionSupported(connection, NAME); return AMPManager.isConditionSupported(connection, NAME);
} }

View file

@ -19,6 +19,7 @@ package org.jivesoftware.smackx.bookmarks;
import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.SmackException.NoResponseException; import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException; import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.XMPPException.XMPPErrorException; import org.jivesoftware.smack.XMPPException.XMPPErrorException;
@ -92,9 +93,10 @@ public class BookmarkManager {
* @return returns all currently bookmarked conferences * @return returns all currently bookmarked conferences
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
* @see BookmarkedConference * @see BookmarkedConference
*/ */
public Collection<BookmarkedConference> getBookmarkedConferences() throws NoResponseException, XMPPErrorException { public Collection<BookmarkedConference> getBookmarkedConferences() throws NoResponseException, XMPPErrorException, NotConnectedException {
retrieveBookmarks(); retrieveBookmarks();
return Collections.unmodifiableCollection(bookmarks.getBookmarkedConferences()); return Collections.unmodifiableCollection(bookmarks.getBookmarkedConferences());
} }
@ -110,9 +112,10 @@ public class BookmarkManager {
* @throws XMPPErrorException thrown when there is an issue retrieving the current bookmarks from * @throws XMPPErrorException thrown when there is an issue retrieving the current bookmarks from
* the server. * the server.
* @throws NoResponseException if there was no response from the server. * @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/ */
public void addBookmarkedConference(String name, String jid, boolean isAutoJoin, public void addBookmarkedConference(String name, String jid, boolean isAutoJoin,
String nickname, String password) throws NoResponseException, XMPPErrorException String nickname, String password) throws NoResponseException, XMPPErrorException, NotConnectedException
{ {
retrieveBookmarks(); retrieveBookmarks();
BookmarkedConference bookmark BookmarkedConference bookmark
@ -141,10 +144,11 @@ public class BookmarkManager {
* @throws XMPPErrorException thrown when there is a problem with the connection attempting to * @throws XMPPErrorException thrown when there is a problem with the connection attempting to
* retrieve the bookmarks or persist the bookmarks. * retrieve the bookmarks or persist the bookmarks.
* @throws NoResponseException if there was no response from the server. * @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
* @throws IllegalArgumentException thrown when the conference being removed is a shared * @throws IllegalArgumentException thrown when the conference being removed is a shared
* conference * conference
*/ */
public void removeBookmarkedConference(String jid) throws NoResponseException, XMPPErrorException { public void removeBookmarkedConference(String jid) throws NoResponseException, XMPPErrorException, NotConnectedException {
retrieveBookmarks(); retrieveBookmarks();
Iterator<BookmarkedConference> it = bookmarks.getBookmarkedConferences().iterator(); Iterator<BookmarkedConference> it = bookmarks.getBookmarkedConferences().iterator();
while(it.hasNext()) { while(it.hasNext()) {
@ -166,8 +170,9 @@ public class BookmarkManager {
* @return returns an unmodifiable collection of all bookmarked urls. * @return returns an unmodifiable collection of all bookmarked urls.
* @throws XMPPErrorException thrown when there is a problem retriving bookmarks from the server. * @throws XMPPErrorException thrown when there is a problem retriving bookmarks from the server.
* @throws NoResponseException if there was no response from the server. * @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/ */
public Collection<BookmarkedURL> getBookmarkedURLs() throws NoResponseException, XMPPErrorException { public Collection<BookmarkedURL> getBookmarkedURLs() throws NoResponseException, XMPPErrorException, NotConnectedException {
retrieveBookmarks(); retrieveBookmarks();
return Collections.unmodifiableCollection(bookmarks.getBookmarkedURLS()); return Collections.unmodifiableCollection(bookmarks.getBookmarkedURLS());
} }
@ -181,8 +186,9 @@ public class BookmarkManager {
* @throws XMPPErrorException thrown when there is an error retriving or saving bookmarks from or to * @throws XMPPErrorException thrown when there is an error retriving or saving bookmarks from or to
* the server * the server
* @throws NoResponseException if there was no response from the server. * @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/ */
public void addBookmarkedURL(String URL, String name, boolean isRSS) throws NoResponseException, XMPPErrorException { public void addBookmarkedURL(String URL, String name, boolean isRSS) throws NoResponseException, XMPPErrorException, NotConnectedException {
retrieveBookmarks(); retrieveBookmarks();
BookmarkedURL bookmark = new BookmarkedURL(URL, name, isRSS); BookmarkedURL bookmark = new BookmarkedURL(URL, name, isRSS);
List<BookmarkedURL> urls = bookmarks.getBookmarkedURLS(); List<BookmarkedURL> urls = bookmarks.getBookmarkedURLS();
@ -207,8 +213,9 @@ public class BookmarkManager {
* @throws XMPPErrorException thrown if there is an error retriving or saving bookmarks from or to * @throws XMPPErrorException thrown if there is an error retriving or saving bookmarks from or to
* the server. * the server.
* @throws NoResponseException if there was no response from the server. * @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/ */
public void removeBookmarkedURL(String bookmarkURL) throws NoResponseException, XMPPErrorException { public void removeBookmarkedURL(String bookmarkURL) throws NoResponseException, XMPPErrorException, NotConnectedException {
retrieveBookmarks(); retrieveBookmarks();
Iterator<BookmarkedURL> it = bookmarks.getBookmarkedURLS().iterator(); Iterator<BookmarkedURL> it = bookmarks.getBookmarkedURLS().iterator();
while(it.hasNext()) { while(it.hasNext()) {
@ -224,7 +231,7 @@ public class BookmarkManager {
} }
} }
private Bookmarks retrieveBookmarks() throws NoResponseException, XMPPErrorException { private Bookmarks retrieveBookmarks() throws NoResponseException, XMPPErrorException, NotConnectedException {
synchronized(bookmarkLock) { synchronized(bookmarkLock) {
if(bookmarks == null) { if(bookmarks == null) {
bookmarks = (Bookmarks) privateDataManager.getPrivateData("storage", bookmarks = (Bookmarks) privateDataManager.getPrivateData("storage",

View file

@ -18,6 +18,7 @@ package org.jivesoftware.smackx.bytestreams;
import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.SmackException.NoResponseException; import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPException.XMPPErrorException; import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamRequest; import org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamRequest;
import org.jivesoftware.smackx.bytestreams.socks5.Socks5BytestreamRequest; import org.jivesoftware.smackx.bytestreams.socks5.Socks5BytestreamRequest;
@ -60,7 +61,8 @@ public interface BytestreamRequest {
/** /**
* Rejects the bytestream request by sending a reject error to the initiator. * Rejects the bytestream request by sending a reject error to the initiator.
* @throws NotConnectedException
*/ */
public void reject(); public void reject() throws NotConnectedException;
} }

View file

@ -17,6 +17,7 @@
package org.jivesoftware.smackx.bytestreams.ibb; package org.jivesoftware.smackx.bytestreams.ibb;
import org.jivesoftware.smack.PacketListener; import org.jivesoftware.smack.PacketListener;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.filter.AndFilter; import org.jivesoftware.smack.filter.AndFilter;
import org.jivesoftware.smack.filter.IQTypeFilter; import org.jivesoftware.smack.filter.IQTypeFilter;
import org.jivesoftware.smack.filter.PacketFilter; import org.jivesoftware.smack.filter.PacketFilter;
@ -52,7 +53,7 @@ class CloseListener implements PacketListener {
this.manager = manager; this.manager = manager;
} }
public void processPacket(Packet packet) { public void processPacket(Packet packet) throws NotConnectedException {
Close closeRequest = (Close) packet; Close closeRequest = (Close) packet;
InBandBytestreamSession ibbSession = this.manager.getSessions().get( InBandBytestreamSession ibbSession = this.manager.getSessions().get(
closeRequest.getSessionID()); closeRequest.getSessionID());

View file

@ -17,6 +17,7 @@
package org.jivesoftware.smackx.bytestreams.ibb; package org.jivesoftware.smackx.bytestreams.ibb;
import org.jivesoftware.smack.PacketListener; import org.jivesoftware.smack.PacketListener;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.filter.AndFilter; import org.jivesoftware.smack.filter.AndFilter;
import org.jivesoftware.smack.filter.PacketFilter; import org.jivesoftware.smack.filter.PacketFilter;
import org.jivesoftware.smack.filter.PacketTypeFilter; import org.jivesoftware.smack.filter.PacketTypeFilter;
@ -55,7 +56,7 @@ class DataListener implements PacketListener {
this.manager = manager; this.manager = manager;
} }
public void processPacket(Packet packet) { public void processPacket(Packet packet) throws NotConnectedException {
Data data = (Data) packet; Data data = (Data) packet;
InBandBytestreamSession ibbSession = this.manager.getSessions().get( InBandBytestreamSession ibbSession = this.manager.getSessions().get(
data.getDataPacketExtension().getSessionID()); data.getDataPacketExtension().getSessionID());

View file

@ -27,6 +27,7 @@ import java.util.concurrent.ConcurrentHashMap;
import org.jivesoftware.smack.AbstractConnectionListener; import org.jivesoftware.smack.AbstractConnectionListener;
import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.SmackException.NoResponseException; import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.ConnectionCreationListener; import org.jivesoftware.smack.ConnectionCreationListener;
import org.jivesoftware.smack.XMPPException; import org.jivesoftware.smack.XMPPException;
@ -425,9 +426,10 @@ public class InBandBytestreamManager implements BytestreamManager {
* @throws XMPPErrorException if the user doesn't support or accept in-band bytestreams, or if the * @throws XMPPErrorException if the user doesn't support or accept in-band bytestreams, or if the
* user prefers smaller block sizes * user prefers smaller block sizes
* @throws NoResponseException if there was no response from the server. * @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/ */
public InBandBytestreamSession establishSession(String targetJID, String sessionID) public InBandBytestreamSession establishSession(String targetJID, String sessionID)
throws NoResponseException, XMPPErrorException { throws NoResponseException, XMPPErrorException, NotConnectedException {
Open byteStreamRequest = new Open(sessionID, this.defaultBlockSize, this.stanza); Open byteStreamRequest = new Open(sessionID, this.defaultBlockSize, this.stanza);
byteStreamRequest.setTo(targetJID); byteStreamRequest.setTo(targetJID);
@ -446,8 +448,9 @@ public class InBandBytestreamManager implements BytestreamManager {
* not accepted. * not accepted.
* *
* @param request IQ packet that should be answered with a not-acceptable error * @param request IQ packet that should be answered with a not-acceptable error
* @throws NotConnectedException
*/ */
protected void replyRejectPacket(IQ request) { protected void replyRejectPacket(IQ request) throws NotConnectedException {
XMPPError xmppError = new XMPPError(XMPPError.Condition.no_acceptable); XMPPError xmppError = new XMPPError(XMPPError.Condition.no_acceptable);
IQ error = IQ.createErrorResponse(request, xmppError); IQ error = IQ.createErrorResponse(request, xmppError);
this.connection.sendPacket(error); this.connection.sendPacket(error);
@ -458,8 +461,9 @@ public class InBandBytestreamManager implements BytestreamManager {
* request is rejected because its block size is greater than the maximum allowed block size. * request is rejected because its block size is greater than the maximum allowed block size.
* *
* @param request IQ packet that should be answered with a resource-constraint error * @param request IQ packet that should be answered with a resource-constraint error
* @throws NotConnectedException
*/ */
protected void replyResourceConstraintPacket(IQ request) { protected void replyResourceConstraintPacket(IQ request) throws NotConnectedException {
XMPPError xmppError = new XMPPError(XMPPError.Condition.resource_constraint); XMPPError xmppError = new XMPPError(XMPPError.Condition.resource_constraint);
IQ error = IQ.createErrorResponse(request, xmppError); IQ error = IQ.createErrorResponse(request, xmppError);
this.connection.sendPacket(error); this.connection.sendPacket(error);
@ -470,8 +474,9 @@ public class InBandBytestreamManager implements BytestreamManager {
* session could not be found. * session could not be found.
* *
* @param request IQ packet that should be answered with a item-not-found error * @param request IQ packet that should be answered with a item-not-found error
* @throws NotConnectedException
*/ */
protected void replyItemNotFoundPacket(IQ request) { protected void replyItemNotFoundPacket(IQ request) throws NotConnectedException {
XMPPError xmppError = new XMPPError(XMPPError.Condition.item_not_found); XMPPError xmppError = new XMPPError(XMPPError.Condition.item_not_found);
IQ error = IQ.createErrorResponse(request, xmppError); IQ error = IQ.createErrorResponse(request, xmppError);
this.connection.sendPacket(error); this.connection.sendPacket(error);

View file

@ -16,6 +16,7 @@
*/ */
package org.jivesoftware.smackx.bytestreams.ibb; package org.jivesoftware.smackx.bytestreams.ibb;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smackx.bytestreams.BytestreamRequest; import org.jivesoftware.smackx.bytestreams.BytestreamRequest;
@ -66,8 +67,9 @@ public class InBandBytestreamRequest implements BytestreamRequest {
* send/receive data. * send/receive data.
* *
* @return the session to send/receive data * @return the session to send/receive data
* @throws NotConnectedException
*/ */
public InBandBytestreamSession accept() { public InBandBytestreamSession accept() throws NotConnectedException {
XMPPConnection connection = this.manager.getConnection(); XMPPConnection connection = this.manager.getConnection();
// create In-Band Bytestream session and store it // create In-Band Bytestream session and store it
@ -85,8 +87,9 @@ public class InBandBytestreamRequest implements BytestreamRequest {
/** /**
* Rejects the In-Band Bytestream request by sending a reject error to the * Rejects the In-Band Bytestream request by sending a reject error to the
* initiator. * initiator.
* @throws NotConnectedException
*/ */
public void reject() { public void reject() throws NotConnectedException {
this.manager.replyRejectPacket(this.byteStreamRequest); this.manager.replyRejectPacket(this.byteStreamRequest);
} }

View file

@ -24,6 +24,7 @@ import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.PacketListener; import org.jivesoftware.smack.PacketListener;
import org.jivesoftware.smack.filter.AndFilter; import org.jivesoftware.smack.filter.AndFilter;
@ -159,8 +160,9 @@ public class InBandBytestreamSession implements BytestreamSession {
* This method is invoked if a request to close the In-Band Bytestream has been received. * This method is invoked if a request to close the In-Band Bytestream has been received.
* *
* @param closeRequest the close request from the remote peer * @param closeRequest the close request from the remote peer
* @throws NotConnectedException
*/ */
protected void closeByPeer(Close closeRequest) { protected void closeByPeer(Close closeRequest) throws NotConnectedException {
/* /*
* close streams without flushing them, because stream is already considered closed on the * close streams without flushing them, because stream is already considered closed on the
@ -445,7 +447,7 @@ public class InBandBytestreamSession implements BytestreamSession {
private long lastSequence = -1; private long lastSequence = -1;
public void processPacket(Packet packet) { public void processPacket(Packet packet) throws NotConnectedException {
// get data packet extension // get data packet extension
DataPacketExtension data = (DataPacketExtension) packet.getExtension( DataPacketExtension data = (DataPacketExtension) packet.getExtension(
DataPacketExtension.ELEMENT_NAME, DataPacketExtension.ELEMENT_NAME,
@ -607,8 +609,9 @@ public class InBandBytestreamSession implements BytestreamSession {
* *
* @param data the data packet * @param data the data packet
* @throws IOException if an I/O error occurred while sending or if the stream is closed * @throws IOException if an I/O error occurred while sending or if the stream is closed
* @throws NotConnectedException
*/ */
protected abstract void writeToXML(DataPacketExtension data) throws IOException; protected abstract void writeToXML(DataPacketExtension data) throws IOException, NotConnectedException;
public synchronized void write(int b) throws IOException { public synchronized void write(int b) throws IOException {
if (this.isClosed) { if (this.isClosed) {
@ -709,7 +712,14 @@ public class InBandBytestreamSession implements BytestreamSession {
this.seq, enc); this.seq, enc);
// write to XMPP stream // write to XMPP stream
writeToXML(data); try {
writeToXML(data);
}
catch (NotConnectedException e) {
IOException ioException = new IOException();
ioException.initCause(e);
throw ioException;
}
// reset buffer pointer // reset buffer pointer
bufferPointer = 0; bufferPointer = 0;
@ -790,7 +800,7 @@ public class InBandBytestreamSession implements BytestreamSession {
private class MessageIBBOutputStream extends IBBOutputStream { private class MessageIBBOutputStream extends IBBOutputStream {
@Override @Override
protected synchronized void writeToXML(DataPacketExtension data) { protected synchronized void writeToXML(DataPacketExtension data) throws NotConnectedException {
// create message stanza containing data packet // create message stanza containing data packet
Message message = new Message(remoteJID); Message message = new Message(remoteJID);
message.addExtension(data); message.addExtension(data);

View file

@ -18,8 +18,11 @@ package org.jivesoftware.smackx.bytestreams.ibb;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.jivesoftware.smack.PacketListener; import org.jivesoftware.smack.PacketListener;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.filter.AndFilter; import org.jivesoftware.smack.filter.AndFilter;
import org.jivesoftware.smack.filter.IQTypeFilter; import org.jivesoftware.smack.filter.IQTypeFilter;
import org.jivesoftware.smack.filter.PacketFilter; import org.jivesoftware.smack.filter.PacketFilter;
@ -29,6 +32,7 @@ import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smackx.bytestreams.BytestreamListener; import org.jivesoftware.smackx.bytestreams.BytestreamListener;
import org.jivesoftware.smackx.bytestreams.ibb.packet.Open; import org.jivesoftware.smackx.bytestreams.ibb.packet.Open;
/** /**
* InitiationListener handles all incoming In-Band Bytestream open requests. If there are no * InitiationListener handles all incoming In-Band Bytestream open requests. If there are no
* listeners for a In-Band Bytestream request InitiationListener will always refuse the request and * listeners for a In-Band Bytestream request InitiationListener will always refuse the request and
@ -42,6 +46,7 @@ import org.jivesoftware.smackx.bytestreams.ibb.packet.Open;
* @author Henning Staib * @author Henning Staib
*/ */
class InitiationListener implements PacketListener { class InitiationListener implements PacketListener {
private static final Logger LOGGER = Logger.getLogger(InitiationListener.class.getName());
/* manager containing the listeners and the XMPP connection */ /* manager containing the listeners and the XMPP connection */
private final InBandBytestreamManager manager; private final InBandBytestreamManager manager;
@ -67,12 +72,17 @@ class InitiationListener implements PacketListener {
initiationListenerExecutor.execute(new Runnable() { initiationListenerExecutor.execute(new Runnable() {
public void run() { public void run() {
processRequest(packet); try {
processRequest(packet);
}
catch (NotConnectedException e) {
LOGGER.log(Level.WARNING, "proccessRequest", e);
}
} }
}); });
} }
private void processRequest(Packet packet) { private void processRequest(Packet packet) throws NotConnectedException {
Open ibbRequest = (Open) packet; Open ibbRequest = (Open) packet;
// validate that block size is within allowed range // validate that block size is within allowed range

View file

@ -18,8 +18,11 @@ package org.jivesoftware.smackx.bytestreams.socks5;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.jivesoftware.smack.PacketListener; import org.jivesoftware.smack.PacketListener;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.filter.AndFilter; import org.jivesoftware.smack.filter.AndFilter;
import org.jivesoftware.smack.filter.IQTypeFilter; import org.jivesoftware.smack.filter.IQTypeFilter;
import org.jivesoftware.smack.filter.PacketFilter; import org.jivesoftware.smack.filter.PacketFilter;
@ -38,6 +41,7 @@ import org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream;
* @author Henning Staib * @author Henning Staib
*/ */
final class InitiationListener implements PacketListener { final class InitiationListener implements PacketListener {
private static final Logger LOGGER = Logger.getLogger(InitiationListener.class.getName());
/* manager containing the listeners and the XMPP connection */ /* manager containing the listeners and the XMPP connection */
private final Socks5BytestreamManager manager; private final Socks5BytestreamManager manager;
@ -63,12 +67,17 @@ final class InitiationListener implements PacketListener {
initiationListenerExecutor.execute(new Runnable() { initiationListenerExecutor.execute(new Runnable() {
public void run() { public void run() {
processRequest(packet); try {
processRequest(packet);
}
catch (NotConnectedException e) {
LOGGER.log(Level.WARNING, "process request", e);
}
} }
}); });
} }
private void processRequest(Packet packet) { private void processRequest(Packet packet) throws NotConnectedException {
Bytestream byteStreamRequest = (Bytestream) packet; Bytestream byteStreamRequest = (Bytestream) packet;
// ignore request if in ignore list // ignore request if in ignore list

View file

@ -33,6 +33,7 @@ import org.jivesoftware.smack.AbstractConnectionListener;
import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.SmackException.NoResponseException; import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.FeatureNotSupportedException; import org.jivesoftware.smack.SmackException.FeatureNotSupportedException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.ConnectionCreationListener; import org.jivesoftware.smack.ConnectionCreationListener;
import org.jivesoftware.smack.XMPPException; import org.jivesoftware.smack.XMPPException;
@ -536,8 +537,9 @@ public final class Socks5BytestreamManager implements BytestreamManager {
* otherwise <code>false</code> * otherwise <code>false</code>
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
*/ */
private boolean supportsSocks5(String targetJID) throws NoResponseException, XMPPErrorException { private boolean supportsSocks5(String targetJID) throws NoResponseException, XMPPErrorException, NotConnectedException {
return ServiceDiscoveryManager.getInstanceFor(connection).supportsFeature(targetJID, NAMESPACE); return ServiceDiscoveryManager.getInstanceFor(connection).supportsFeature(targetJID, NAMESPACE);
} }
@ -548,8 +550,9 @@ public final class Socks5BytestreamManager implements BytestreamManager {
* @return list of JIDs of SOCKS5 proxies * @return list of JIDs of SOCKS5 proxies
* @throws XMPPErrorException if there was an error querying the XMPP server for SOCKS5 proxies * @throws XMPPErrorException if there was an error querying the XMPP server for SOCKS5 proxies
* @throws NoResponseException if there was no response from the server. * @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/ */
private List<String> determineProxies() throws NoResponseException, XMPPErrorException { private List<String> determineProxies() throws NoResponseException, XMPPErrorException, NotConnectedException {
ServiceDiscoveryManager serviceDiscoveryManager = ServiceDiscoveryManager.getInstanceFor(this.connection); ServiceDiscoveryManager serviceDiscoveryManager = ServiceDiscoveryManager.getInstanceFor(this.connection);
List<String> proxies = new ArrayList<String>(); List<String> proxies = new ArrayList<String>();
@ -708,8 +711,9 @@ public final class Socks5BytestreamManager implements BytestreamManager {
* accepted. * accepted.
* *
* @param packet Packet that should be answered with a not-acceptable error * @param packet Packet that should be answered with a not-acceptable error
* @throws NotConnectedException
*/ */
protected void replyRejectPacket(IQ packet) { protected void replyRejectPacket(IQ packet) throws NotConnectedException {
XMPPError xmppError = new XMPPError(XMPPError.Condition.no_acceptable); XMPPError xmppError = new XMPPError(XMPPError.Condition.no_acceptable);
IQ errorIQ = IQ.createErrorResponse(packet, xmppError); IQ errorIQ = IQ.createErrorResponse(packet, xmppError);
this.connection.sendPacket(errorIQ); this.connection.sendPacket(errorIQ);

View file

@ -22,6 +22,7 @@ import java.util.Collection;
import java.util.concurrent.TimeoutException; import java.util.concurrent.TimeoutException;
import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPException; import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.XMPPException.XMPPErrorException; import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.IQ;
@ -264,8 +265,9 @@ public class Socks5BytestreamRequest implements BytestreamRequest {
/** /**
* Rejects the SOCKS5 Bytestream request by sending a reject error to the initiator. * Rejects the SOCKS5 Bytestream request by sending a reject error to the initiator.
* @throws NotConnectedException
*/ */
public void reject() { public void reject() throws NotConnectedException {
this.manager.replyRejectPacket(this.bytestreamRequest); this.manager.replyRejectPacket(this.bytestreamRequest);
} }
@ -273,8 +275,9 @@ public class Socks5BytestreamRequest implements BytestreamRequest {
* Cancels the SOCKS5 Bytestream request by sending an error to the initiator and building a * Cancels the SOCKS5 Bytestream request by sending an error to the initiator and building a
* XMPP exception. * XMPP exception.
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NotConnectedException
*/ */
private void cancelRequest() throws XMPPErrorException { private void cancelRequest() throws XMPPErrorException, NotConnectedException {
String errorMessage = "Could not establish socket with any provided host"; String errorMessage = "Could not establish socket with any provided host";
XMPPError error = new XMPPError(XMPPError.Condition.item_not_found, errorMessage); XMPPError error = new XMPPError(XMPPError.Condition.item_not_found, errorMessage);
IQ errorIQ = IQ.createErrorResponse(this.bytestreamRequest, error); IQ errorIQ = IQ.createErrorResponse(this.bytestreamRequest, error);

View file

@ -22,6 +22,7 @@ import java.util.concurrent.TimeoutException;
import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.SmackException.NoResponseException; import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException; import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.XMPPException.XMPPErrorException; import org.jivesoftware.smack.XMPPException.XMPPErrorException;
@ -102,9 +103,10 @@ class Socks5ClientForInitiator extends Socks5Client {
* SOCKS5 proxy. * SOCKS5 proxy.
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
* @throws SmackException if there was no response from the server. * @throws SmackException if there was no response from the server.
*/ */
private void activate() throws NoResponseException, XMPPErrorException { private void activate() throws NoResponseException, XMPPErrorException, NotConnectedException {
Bytestream activate = createStreamHostActivation(); Bytestream activate = createStreamHostActivation();
// if activation fails #nextResultOrThrow() throws an exception // if activation fails #nextResultOrThrow() throws an exception
connection.createPacketCollectorAndSend(activate).nextResultOrThrow(); connection.createPacketCollectorAndSend(activate).nextResultOrThrow();

View file

@ -18,6 +18,7 @@ package org.jivesoftware.smackx.caps;
import org.jivesoftware.smack.AbstractConnectionListener; import org.jivesoftware.smack.AbstractConnectionListener;
import org.jivesoftware.smack.SmackException.NoResponseException; import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.ConnectionCreationListener; import org.jivesoftware.smack.ConnectionCreationListener;
import org.jivesoftware.smack.Manager; import org.jivesoftware.smack.Manager;
@ -59,6 +60,8 @@ import java.util.SortedSet;
import java.util.TreeSet; import java.util.TreeSet;
import java.util.WeakHashMap; import java.util.WeakHashMap;
import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.io.IOException; import java.io.IOException;
import java.security.MessageDigest; import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
@ -70,6 +73,7 @@ import java.security.NoSuchAlgorithmException;
* @see <a href="http://www.xmpp.org/extensions/xep-0115.html">XEP-0115: Entity Capabilities</a> * @see <a href="http://www.xmpp.org/extensions/xep-0115.html">XEP-0115: Entity Capabilities</a>
*/ */
public class EntityCapsManager extends Manager { public class EntityCapsManager extends Manager {
private static final Logger LOGGER = Logger.getLogger(EntityCapsManager.class.getName());
public static final String NAMESPACE = "http://jabber.org/protocol/caps"; public static final String NAMESPACE = "http://jabber.org/protocol/caps";
public static final String ELEMENT = "c"; public static final String ELEMENT = "c";
@ -351,7 +355,7 @@ public class EntityCapsManager extends Manager {
return entityCapsEnabled; return entityCapsEnabled;
} }
public void setEntityNode(String entityNode) { public void setEntityNode(String entityNode) throws NotConnectedException {
this.entityNode = entityNode; this.entityNode = entityNode;
updateLocalEntityCaps(); updateLocalEntityCaps();
} }
@ -394,8 +398,9 @@ public class EntityCapsManager extends Manager {
* @return true if the entity supports Entity Capabilities. * @return true if the entity supports Entity Capabilities.
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
*/ */
public boolean areEntityCapsSupported(String jid) throws NoResponseException, XMPPErrorException { public boolean areEntityCapsSupported(String jid) throws NoResponseException, XMPPErrorException, NotConnectedException {
return sdm.supportsFeature(jid, NAMESPACE); return sdm.supportsFeature(jid, NAMESPACE);
} }
@ -405,8 +410,9 @@ public class EntityCapsManager extends Manager {
* @return true if the user's server supports Entity Capabilities. * @return true if the user's server supports Entity Capabilities.
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
*/ */
public boolean areEntityCapsSupportedByServer() throws NoResponseException, XMPPErrorException { public boolean areEntityCapsSupportedByServer() throws NoResponseException, XMPPErrorException, NotConnectedException {
return areEntityCapsSupported(connection().getServiceName()); return areEntityCapsSupported(connection().getServiceName());
} }
@ -415,6 +421,7 @@ public class EntityCapsManager extends Manager {
* *
* If we are connected and there was already a presence send, another * If we are connected and there was already a presence send, another
* presence is send to inform others about your new Entity Caps node string. * presence is send to inform others about your new Entity Caps node string.
* @throws NotConnectedException
* *
*/ */
public void updateLocalEntityCaps() { public void updateLocalEntityCaps() {
@ -472,7 +479,12 @@ public class EntityCapsManager extends Manager {
// to respect ConnectionConfiguration.isSendPresence() // to respect ConnectionConfiguration.isSendPresence()
if (connection != null && connection.isAuthenticated() && presenceSend) { if (connection != null && connection.isAuthenticated() && presenceSend) {
Presence presence = new Presence(Presence.Type.available); Presence presence = new Presence(Presence.Type.available);
connection.sendPacket(presence); try {
connection.sendPacket(presence);
}
catch (NotConnectedException e) {
LOGGER.log(Level.WARNING, "Could could not update presence with caps info", e);
}
} }
} }

View file

@ -23,6 +23,7 @@ import java.util.WeakHashMap;
import org.jivesoftware.smack.Chat; import org.jivesoftware.smack.Chat;
import org.jivesoftware.smack.ChatManager; import org.jivesoftware.smack.ChatManager;
import org.jivesoftware.smack.ChatManagerListener; import org.jivesoftware.smack.ChatManagerListener;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.Manager; import org.jivesoftware.smack.Manager;
import org.jivesoftware.smack.MessageListener; import org.jivesoftware.smack.MessageListener;
@ -101,8 +102,9 @@ public class ChatStateManager extends Manager {
* *
* @param newState the new state of the chat * @param newState the new state of the chat
* @param chat the chat. * @param chat the chat.
* @throws NotConnectedException
*/ */
public void setCurrentState(ChatState newState, Chat chat) { public void setCurrentState(ChatState newState, Chat chat) throws NotConnectedException {
if(chat == null || newState == null) { if(chat == null || newState == null) {
throw new IllegalArgumentException("Arguments cannot be null."); throw new IllegalArgumentException("Arguments cannot be null.");
} }

View file

@ -17,6 +17,7 @@
package org.jivesoftware.smackx.commands; package org.jivesoftware.smackx.commands;
import org.jivesoftware.smack.SmackException.NoResponseException; import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPException.XMPPErrorException; import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.packet.XMPPError; import org.jivesoftware.smack.packet.XMPPError;
import org.jivesoftware.smackx.commands.packet.AdHocCommandData; import org.jivesoftware.smackx.commands.packet.AdHocCommandData;
@ -209,8 +210,9 @@ public abstract class AdHocCommand {
* the command it throws an XMPPException. * the command it throws an XMPPException.
* *
* @throws XMPPErrorException if there is an error executing the command. * @throws XMPPErrorException if there is an error executing the command.
* @throws NotConnectedException
*/ */
public abstract void execute() throws NoResponseException, XMPPErrorException; public abstract void execute() throws NoResponseException, XMPPErrorException, NotConnectedException;
/** /**
* Executes the next action of the command with the information provided in * Executes the next action of the command with the information provided in
@ -221,8 +223,9 @@ public abstract class AdHocCommand {
* *
* @param response the form answer of the previous stage. * @param response the form answer of the previous stage.
* @throws XMPPErrorException if there is a problem executing the command. * @throws XMPPErrorException if there is a problem executing the command.
* @throws NotConnectedException
*/ */
public abstract void next(Form response) throws NoResponseException, XMPPErrorException; public abstract void next(Form response) throws NoResponseException, XMPPErrorException, NotConnectedException;
/** /**
* Completes the command execution with the information provided in the * Completes the command execution with the information provided in the
@ -233,8 +236,9 @@ public abstract class AdHocCommand {
* *
* @param response the form answer of the previous stage. * @param response the form answer of the previous stage.
* @throws XMPPErrorException if there is a problem executing the command. * @throws XMPPErrorException if there is a problem executing the command.
* @throws NotConnectedException
*/ */
public abstract void complete(Form response) throws NoResponseException, XMPPErrorException; public abstract void complete(Form response) throws NoResponseException, XMPPErrorException, NotConnectedException;
/** /**
* Goes to the previous stage. The requester is asking to re-send the * Goes to the previous stage. The requester is asking to re-send the
@ -243,8 +247,9 @@ public abstract class AdHocCommand {
* an XMPPException. * an XMPPException.
* *
* @throws XMPPErrorException if there is a problem executing the command. * @throws XMPPErrorException if there is a problem executing the command.
* @throws NotConnectedException
*/ */
public abstract void prev() throws NoResponseException, XMPPErrorException; public abstract void prev() throws NoResponseException, XMPPErrorException, NotConnectedException;
/** /**
* Cancels the execution of the command. This can be invoked on any stage of * Cancels the execution of the command. This can be invoked on any stage of
@ -252,8 +257,9 @@ public abstract class AdHocCommand {
* XMPPException. * XMPPException.
* *
* @throws XMPPErrorException if there is a problem executing the command. * @throws XMPPErrorException if there is a problem executing the command.
* @throws NotConnectedException
*/ */
public abstract void cancel() throws NoResponseException, XMPPErrorException; public abstract void cancel() throws NoResponseException, XMPPErrorException, NotConnectedException;
/** /**
* Returns a collection with the allowed actions based on the current stage. * Returns a collection with the allowed actions based on the current stage.

View file

@ -18,6 +18,7 @@
package org.jivesoftware.smackx.commands; package org.jivesoftware.smackx.commands;
import org.jivesoftware.smack.*; import org.jivesoftware.smack.*;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPException.XMPPErrorException; import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.filter.PacketFilter; import org.jivesoftware.smack.filter.PacketFilter;
import org.jivesoftware.smack.filter.PacketTypeFilter; import org.jivesoftware.smack.filter.PacketTypeFilter;
@ -591,9 +592,10 @@ public class AdHocCommandManager extends Manager {
* *
* @param response the response to send. * @param response the response to send.
* @param condition the condition of the error. * @param condition the condition of the error.
* @throws NotConnectedException
*/ */
private void respondError(AdHocCommandData response, private void respondError(AdHocCommandData response,
XMPPError.Condition condition) { XMPPError.Condition condition) throws NotConnectedException {
respondError(response, new XMPPError(condition)); respondError(response, new XMPPError(condition));
} }
@ -603,9 +605,10 @@ public class AdHocCommandManager extends Manager {
* @param response the response to send. * @param response the response to send.
* @param condition the condition of the error. * @param condition the condition of the error.
* @param specificCondition the adhoc command error condition. * @param specificCondition the adhoc command error condition.
* @throws NotConnectedException
*/ */
private void respondError(AdHocCommandData response, XMPPError.Condition condition, private void respondError(AdHocCommandData response, XMPPError.Condition condition,
AdHocCommand.SpecificErrorCondition specificCondition) AdHocCommand.SpecificErrorCondition specificCondition) throws NotConnectedException
{ {
XMPPError error = new XMPPError(condition); XMPPError error = new XMPPError(condition);
error.addExtension(new AdHocCommandData.SpecificError(specificCondition)); error.addExtension(new AdHocCommandData.SpecificError(specificCondition));
@ -617,8 +620,9 @@ public class AdHocCommandManager extends Manager {
* *
* @param response the response to send. * @param response the response to send.
* @param error the error to send. * @param error the error to send.
* @throws NotConnectedException
*/ */
private void respondError(AdHocCommandData response, XMPPError error) { private void respondError(AdHocCommandData response, XMPPError error) throws NotConnectedException {
response.setType(IQ.Type.ERROR); response.setType(IQ.Type.ERROR);
response.setError(error); response.setError(error);
connection().sendPacket(response); connection().sendPacket(response);

View file

@ -18,6 +18,7 @@ package org.jivesoftware.smackx.commands;
import org.jivesoftware.smack.SmackConfiguration; import org.jivesoftware.smack.SmackConfiguration;
import org.jivesoftware.smack.SmackException.NoResponseException; import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException.XMPPErrorException; import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.IQ;
@ -80,17 +81,17 @@ public class RemoteCommand extends AdHocCommand {
} }
@Override @Override
public void cancel() throws NoResponseException, XMPPErrorException { public void cancel() throws NoResponseException, XMPPErrorException, NotConnectedException {
executeAction(Action.cancel, packetReplyTimeout); executeAction(Action.cancel, packetReplyTimeout);
} }
@Override @Override
public void complete(Form form) throws NoResponseException, XMPPErrorException { public void complete(Form form) throws NoResponseException, XMPPErrorException, NotConnectedException {
executeAction(Action.complete, form, packetReplyTimeout); executeAction(Action.complete, form, packetReplyTimeout);
} }
@Override @Override
public void execute() throws NoResponseException, XMPPErrorException { public void execute() throws NoResponseException, XMPPErrorException, NotConnectedException {
executeAction(Action.execute, packetReplyTimeout); executeAction(Action.execute, packetReplyTimeout);
} }
@ -102,22 +103,23 @@ public class RemoteCommand extends AdHocCommand {
* @param form the form anwser of the previous stage. * @param form the form anwser of the previous stage.
* @throws XMPPErrorException if an error occurs. * @throws XMPPErrorException if an error occurs.
* @throws NoResponseException if there was no response from the server. * @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/ */
public void execute(Form form) throws NoResponseException, XMPPErrorException { public void execute(Form form) throws NoResponseException, XMPPErrorException, NotConnectedException {
executeAction(Action.execute, form, packetReplyTimeout); executeAction(Action.execute, form, packetReplyTimeout);
} }
@Override @Override
public void next(Form form) throws NoResponseException, XMPPErrorException { public void next(Form form) throws NoResponseException, XMPPErrorException, NotConnectedException {
executeAction(Action.next, form, packetReplyTimeout); executeAction(Action.next, form, packetReplyTimeout);
} }
@Override @Override
public void prev() throws NoResponseException, XMPPErrorException { public void prev() throws NoResponseException, XMPPErrorException, NotConnectedException {
executeAction(Action.prev, packetReplyTimeout); executeAction(Action.prev, packetReplyTimeout);
} }
private void executeAction(Action action, long packetReplyTimeout) throws NoResponseException, XMPPErrorException { private void executeAction(Action action, long packetReplyTimeout) throws NoResponseException, XMPPErrorException, NotConnectedException {
executeAction(action, null, packetReplyTimeout); executeAction(action, null, packetReplyTimeout);
} }
@ -131,8 +133,9 @@ public class RemoteCommand extends AdHocCommand {
* @param timeout the amount of time to wait for a reply. * @param timeout the amount of time to wait for a reply.
* @throws XMPPErrorException if there is a problem executing the command. * @throws XMPPErrorException if there is a problem executing the command.
* @throws NoResponseException if there was no response from the server. * @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/ */
private void executeAction(Action action, Form form, long timeout) throws NoResponseException, XMPPErrorException { private void executeAction(Action action, Form form, long timeout) throws NoResponseException, XMPPErrorException, NotConnectedException {
// TODO: Check that all the required fields of the form were filled, if // TODO: Check that all the required fields of the form were filled, if
// TODO: not throw the corresponding exeption. This will make a faster response, // TODO: not throw the corresponding exeption. This will make a faster response,
// TODO: since the request is stoped before it's sent. // TODO: since the request is stoped before it's sent.

View file

@ -18,6 +18,7 @@
package org.jivesoftware.smackx.disco; package org.jivesoftware.smackx.disco;
import org.jivesoftware.smack.SmackException.NoResponseException; import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.ConnectionCreationListener; import org.jivesoftware.smack.ConnectionCreationListener;
import org.jivesoftware.smack.Manager; import org.jivesoftware.smack.Manager;
@ -115,7 +116,7 @@ public class ServiceDiscoveryManager extends Manager {
// Listen for disco#items requests and answer with an empty result // Listen for disco#items requests and answer with an empty result
PacketFilter packetFilter = new PacketTypeFilter(DiscoverItems.class); PacketFilter packetFilter = new PacketTypeFilter(DiscoverItems.class);
PacketListener packetListener = new PacketListener() { PacketListener packetListener = new PacketListener() {
public void processPacket(Packet packet) { public void processPacket(Packet packet) throws NotConnectedException {
XMPPConnection connection = connection(); XMPPConnection connection = connection();
if (connection == null) return; if (connection == null) return;
DiscoverItems discoverItems = (DiscoverItems) packet; DiscoverItems discoverItems = (DiscoverItems) packet;
@ -152,7 +153,7 @@ public class ServiceDiscoveryManager extends Manager {
// To add a new feature as supported use the #addFeature message // To add a new feature as supported use the #addFeature message
packetFilter = new PacketTypeFilter(DiscoverInfo.class); packetFilter = new PacketTypeFilter(DiscoverInfo.class);
packetListener = new PacketListener() { packetListener = new PacketListener() {
public void processPacket(Packet packet) { public void processPacket(Packet packet) throws NotConnectedException {
XMPPConnection connection = connection(); XMPPConnection connection = connection();
if (connection == null) return; if (connection == null) return;
DiscoverInfo discoverInfo = (DiscoverInfo) packet; DiscoverInfo discoverInfo = (DiscoverInfo) packet;
@ -496,8 +497,9 @@ public class ServiceDiscoveryManager extends Manager {
* @return the discovered information. * @return the discovered information.
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
*/ */
public DiscoverInfo discoverInfo(String entityID) throws NoResponseException, XMPPErrorException { public DiscoverInfo discoverInfo(String entityID) throws NoResponseException, XMPPErrorException, NotConnectedException {
if (entityID == null) if (entityID == null)
return discoverInfo(null, null); return discoverInfo(null, null);
@ -540,8 +542,9 @@ public class ServiceDiscoveryManager extends Manager {
* @return the discovered information. * @return the discovered information.
* @throws XMPPErrorException if the operation failed for some reason. * @throws XMPPErrorException if the operation failed for some reason.
* @throws NoResponseException if there was no response from the server. * @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/ */
public DiscoverInfo discoverInfo(String entityID, String node) throws NoResponseException, XMPPErrorException { public DiscoverInfo discoverInfo(String entityID, String node) throws NoResponseException, XMPPErrorException, NotConnectedException {
// Discover the entity's info // Discover the entity's info
DiscoverInfo disco = new DiscoverInfo(); DiscoverInfo disco = new DiscoverInfo();
disco.setType(IQ.Type.GET); disco.setType(IQ.Type.GET);
@ -560,8 +563,9 @@ public class ServiceDiscoveryManager extends Manager {
* @return the discovered information. * @return the discovered information.
* @throws XMPPErrorException if the operation failed for some reason. * @throws XMPPErrorException if the operation failed for some reason.
* @throws NoResponseException if there was no response from the server. * @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/ */
public DiscoverItems discoverItems(String entityID) throws NoResponseException, XMPPErrorException { public DiscoverItems discoverItems(String entityID) throws NoResponseException, XMPPErrorException, NotConnectedException {
return discoverItems(entityID, null); return discoverItems(entityID, null);
} }
@ -575,8 +579,9 @@ public class ServiceDiscoveryManager extends Manager {
* @return the discovered items. * @return the discovered items.
* @throws XMPPErrorException if the operation failed for some reason. * @throws XMPPErrorException if the operation failed for some reason.
* @throws NoResponseException if there was no response from the server. * @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/ */
public DiscoverItems discoverItems(String entityID, String node) throws NoResponseException, XMPPErrorException { public DiscoverItems discoverItems(String entityID, String node) throws NoResponseException, XMPPErrorException, NotConnectedException {
// Discover the entity's items // Discover the entity's items
DiscoverItems disco = new DiscoverItems(); DiscoverItems disco = new DiscoverItems();
disco.setType(IQ.Type.GET); disco.setType(IQ.Type.GET);
@ -597,8 +602,9 @@ public class ServiceDiscoveryManager extends Manager {
* @return true if the server supports publishing of items. * @return true if the server supports publishing of items.
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
*/ */
public boolean canPublishItems(String entityID) throws NoResponseException, XMPPErrorException { public boolean canPublishItems(String entityID) throws NoResponseException, XMPPErrorException, NotConnectedException {
DiscoverInfo info = discoverInfo(entityID); DiscoverInfo info = discoverInfo(entityID);
return canPublishItems(info); return canPublishItems(info);
} }
@ -626,8 +632,9 @@ public class ServiceDiscoveryManager extends Manager {
* @param discoverItems the DiscoveryItems to publish. * @param discoverItems the DiscoveryItems to publish.
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
*/ */
public void publishItems(String entityID, DiscoverItems discoverItems) throws NoResponseException, XMPPErrorException { public void publishItems(String entityID, DiscoverItems discoverItems) throws NoResponseException, XMPPErrorException, NotConnectedException {
publishItems(entityID, null, discoverItems); publishItems(entityID, null, discoverItems);
} }
@ -642,8 +649,9 @@ public class ServiceDiscoveryManager extends Manager {
* @param discoverItems the DiscoveryItems to publish. * @param discoverItems the DiscoveryItems to publish.
* @throws XMPPErrorException if the operation failed for some reason. * @throws XMPPErrorException if the operation failed for some reason.
* @throws NoResponseException if there was no response from the server. * @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/ */
public void publishItems(String entityID, String node, DiscoverItems discoverItems) throws NoResponseException, XMPPErrorException public void publishItems(String entityID, String node, DiscoverItems discoverItems) throws NoResponseException, XMPPErrorException, NotConnectedException
{ {
discoverItems.setType(IQ.Type.SET); discoverItems.setType(IQ.Type.SET);
discoverItems.setTo(entityID); discoverItems.setTo(entityID);
@ -660,8 +668,9 @@ public class ServiceDiscoveryManager extends Manager {
* @return true if the entity supports the feature, false otherwise * @return true if the entity supports the feature, false otherwise
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
*/ */
public boolean supportsFeature(String jid, String feature) throws NoResponseException, XMPPErrorException { public boolean supportsFeature(String jid, String feature) throws NoResponseException, XMPPErrorException, NotConnectedException {
DiscoverInfo result = discoverInfo(jid); DiscoverInfo result = discoverInfo(jid);
return result.containsFeature(feature); return result.containsFeature(feature);
} }

View file

@ -17,6 +17,7 @@
package org.jivesoftware.smackx.filetransfer; package org.jivesoftware.smackx.filetransfer;
import org.jivesoftware.smack.PacketListener; import org.jivesoftware.smack.PacketListener;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.filter.AndFilter; import org.jivesoftware.smack.filter.AndFilter;
import org.jivesoftware.smack.filter.IQTypeFilter; import org.jivesoftware.smack.filter.IQTypeFilter;
@ -167,7 +168,7 @@ public class FileTransferManager {
return transfer; return transfer;
} }
protected void rejectIncomingFileTransfer(FileTransferRequest request) { protected void rejectIncomingFileTransfer(FileTransferRequest request) throws NotConnectedException {
StreamInitiation initiation = request.getStreamInitiation(); StreamInitiation initiation = request.getStreamInitiation();
IQ rejection = FileTransferNegotiator.createIQ( IQ rejection = FileTransferNegotiator.createIQ(

View file

@ -28,6 +28,7 @@ import java.util.Random;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import org.jivesoftware.smack.AbstractConnectionListener; import org.jivesoftware.smack.AbstractConnectionListener;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.PacketCollector; import org.jivesoftware.smack.PacketCollector;
import org.jivesoftware.smack.XMPPException.XMPPErrorException; import org.jivesoftware.smack.XMPPException.XMPPErrorException;
@ -241,9 +242,10 @@ public class FileTransferNegotiator {
* @return The file transfer object that handles the transfer * @return The file transfer object that handles the transfer
* @throws XMPPErrorException If there are either no stream methods contained in the packet, or * @throws XMPPErrorException If there are either no stream methods contained in the packet, or
* there is not an appropriate stream method. * there is not an appropriate stream method.
* @throws NotConnectedException
*/ */
public StreamNegotiator selectStreamNegotiator( public StreamNegotiator selectStreamNegotiator(
FileTransferRequest request) throws XMPPErrorException { FileTransferRequest request) throws XMPPErrorException, NotConnectedException {
StreamInitiation si = request.getStreamInitiation(); StreamInitiation si = request.getStreamInitiation();
FormField streamMethodField = getStreamMethodField(si FormField streamMethodField = getStreamMethodField(si
.getFeatureNegotiationForm()); .getFeatureNegotiationForm());
@ -328,8 +330,9 @@ public class FileTransferNegotiator {
* Reject a stream initiation request from a remote user. * Reject a stream initiation request from a remote user.
* *
* @param si The Stream Initiation request to reject. * @param si The Stream Initiation request to reject.
* @throws NotConnectedException
*/ */
public void rejectStream(final StreamInitiation si) { public void rejectStream(final StreamInitiation si) throws NotConnectedException {
XMPPError error = new XMPPError(XMPPError.Condition.forbidden, "Offer Declined"); XMPPError error = new XMPPError(XMPPError.Condition.forbidden, "Offer Declined");
IQ iqPacket = createIQ(si.getPacketID(), si.getFrom(), si.getTo(), IQ iqPacket = createIQ(si.getPacketID(), si.getFrom(), si.getTo(),
IQ.Type.ERROR); IQ.Type.ERROR);
@ -380,10 +383,11 @@ public class FileTransferNegotiator {
* user to respond. If they do not respond in time, this * user to respond. If they do not respond in time, this
* @return Returns the stream negotiator selected by the peer. * @return Returns the stream negotiator selected by the peer.
* @throws XMPPErrorException Thrown if there is an error negotiating the file transfer. * @throws XMPPErrorException Thrown if there is an error negotiating the file transfer.
* @throws NotConnectedException
*/ */
public StreamNegotiator negotiateOutgoingTransfer(final String userID, public StreamNegotiator negotiateOutgoingTransfer(final String userID,
final String streamID, final String fileName, final long size, final String streamID, final String fileName, final long size,
final String desc, int responseTimeout) throws XMPPErrorException { final String desc, int responseTimeout) throws XMPPErrorException, NotConnectedException {
StreamInitiation si = new StreamInitiation(); StreamInitiation si = new StreamInitiation();
si.setSessionID(streamID); si.setSessionID(streamID);
si.setMimeType(URLConnection.guessContentTypeFromName(fileName)); si.setMimeType(URLConnection.guessContentTypeFromName(fileName));

View file

@ -16,6 +16,7 @@
*/ */
package org.jivesoftware.smackx.filetransfer; package org.jivesoftware.smackx.filetransfer;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smackx.si.packet.StreamInitiation; import org.jivesoftware.smackx.si.packet.StreamInitiation;
/** /**
@ -127,8 +128,9 @@ public class FileTransferRequest {
/** /**
* Rejects the file transfer request. * Rejects the file transfer request.
* @throws NotConnectedException
*/ */
public void reject() { public void reject() throws NotConnectedException {
manager.rejectIncomingFileTransfer(this); manager.rejectIncomingFileTransfer(this);
} }

View file

@ -20,6 +20,7 @@ import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import org.jivesoftware.smack.SmackException.NoResponseException; import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException.XMPPErrorException; import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.filter.AndFilter; import org.jivesoftware.smack.filter.AndFilter;
@ -61,14 +62,14 @@ public class IBBTransferNegotiator extends StreamNegotiator {
} }
public OutputStream createOutgoingStream(String streamID, String initiator, public OutputStream createOutgoingStream(String streamID, String initiator,
String target) throws NoResponseException, XMPPErrorException { String target) throws NoResponseException, XMPPErrorException, NotConnectedException {
InBandBytestreamSession session = this.manager.establishSession(target, streamID); InBandBytestreamSession session = this.manager.establishSession(target, streamID);
session.setCloseBothStreamsEnabled(true); session.setCloseBothStreamsEnabled(true);
return session.getOutputStream(); return session.getOutputStream();
} }
public InputStream createIncomingStream(StreamInitiation initiation) public InputStream createIncomingStream(StreamInitiation initiation)
throws NoResponseException, XMPPErrorException { throws NoResponseException, XMPPErrorException, NotConnectedException {
/* /*
* In-Band Bytestream initiation listener must ignore next in-band bytestream request with * In-Band Bytestream initiation listener must ignore next in-band bytestream request with
* given session ID * given session ID
@ -94,7 +95,7 @@ public class IBBTransferNegotiator extends StreamNegotiator {
return new String[] { InBandBytestreamManager.NAMESPACE }; return new String[] { InBandBytestreamManager.NAMESPACE };
} }
InputStream negotiateIncomingStream(Packet streamInitiation) { InputStream negotiateIncomingStream(Packet streamInitiation) throws NotConnectedException {
// build In-Band Bytestream request // build In-Band Bytestream request
InBandBytestreamRequest request = new ByteStreamRequest(this.manager, InBandBytestreamRequest request = new ByteStreamRequest(this.manager,
(Open) streamInitiation); (Open) streamInitiation);

View file

@ -19,6 +19,7 @@ package org.jivesoftware.smackx.filetransfer;
import org.jivesoftware.smack.PacketCollector; import org.jivesoftware.smack.PacketCollector;
import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.SmackException.NoResponseException; import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException; import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.XMPPException.XMPPErrorException; import org.jivesoftware.smack.XMPPException.XMPPErrorException;
@ -80,7 +81,7 @@ public abstract class StreamNegotiator {
return iq; return iq;
} }
Packet initiateIncomingStream(XMPPConnection connection, StreamInitiation initiation) throws NoResponseException, XMPPErrorException { Packet initiateIncomingStream(XMPPConnection connection, StreamInitiation initiation) throws NoResponseException, XMPPErrorException, NotConnectedException {
StreamInitiation response = createInitiationAccept(initiation, StreamInitiation response = createInitiationAccept(initiation,
getNamespaces()); getNamespaces());

View file

@ -19,6 +19,7 @@ package org.jivesoftware.smackx.iqlast;
import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.SmackException.NoResponseException; import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.ConnectionCreationListener; import org.jivesoftware.smack.ConnectionCreationListener;
import org.jivesoftware.smack.PacketListener; import org.jivesoftware.smack.PacketListener;
@ -137,7 +138,7 @@ public class LastActivityManager {
// Register a listener for a last activity query // Register a listener for a last activity query
connection.addPacketListener(new PacketListener() { connection.addPacketListener(new PacketListener() {
public void processPacket(Packet packet) { public void processPacket(Packet packet) throws NotConnectedException {
LastActivity message = new LastActivity(); LastActivity message = new LastActivity();
message.setType(IQ.Type.RESULT); message.setType(IQ.Type.RESULT);
message.setTo(packet.getFrom()); message.setTo(packet.getFrom());
@ -195,9 +196,10 @@ public class LastActivityManager {
* @throws XMPPErrorException * @throws XMPPErrorException
* thrown if a server error has occured. * thrown if a server error has occured.
* @throws NoResponseException if there was no response from the server. * @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/ */
public static LastActivity getLastActivity(XMPPConnection con, String jid) public static LastActivity getLastActivity(XMPPConnection con, String jid)
throws NoResponseException, XMPPErrorException { throws NoResponseException, XMPPErrorException, NotConnectedException {
LastActivity activity = new LastActivity(); LastActivity activity = new LastActivity();
activity.setTo(jid); activity.setTo(jid);

View file

@ -18,6 +18,7 @@
package org.jivesoftware.smackx.iqprivate; package org.jivesoftware.smackx.iqprivate;
import org.jivesoftware.smack.SmackException.NoResponseException; import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException.XMPPErrorException; import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.IQ;
@ -170,8 +171,9 @@ public class PrivateDataManager {
* @return the private data. * @return the private data.
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
*/ */
public PrivateData getPrivateData(final String elementName, final String namespace) throws NoResponseException, XMPPErrorException public PrivateData getPrivateData(final String elementName, final String namespace) throws NoResponseException, XMPPErrorException, NotConnectedException
{ {
// Create an IQ packet to get the private data. // Create an IQ packet to get the private data.
IQ privateDataGet = new IQ() { IQ privateDataGet = new IQ() {
@ -202,8 +204,9 @@ public class PrivateDataManager {
* @param privateData the private data. * @param privateData the private data.
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
*/ */
public void setPrivateData(final PrivateData privateData) throws NoResponseException, XMPPErrorException { public void setPrivateData(final PrivateData privateData) throws NoResponseException, XMPPErrorException, NotConnectedException {
// Create an IQ packet to set the private data. // Create an IQ packet to set the private data.
IQ privateDataSet = new IQ() { IQ privateDataSet = new IQ() {
public String getChildElementXML() { public String getChildElementXML() {

View file

@ -21,6 +21,7 @@ import java.util.Collections;
import java.util.Map; import java.util.Map;
import java.util.WeakHashMap; import java.util.WeakHashMap;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.Manager; import org.jivesoftware.smack.Manager;
import org.jivesoftware.smack.PacketListener; import org.jivesoftware.smack.PacketListener;
@ -64,8 +65,9 @@ public class VersionManager extends Manager {
connection.addPacketListener(new PacketListener() { connection.addPacketListener(new PacketListener() {
/** /**
* Sends a Version reply on request * Sends a Version reply on request
* @throws NotConnectedException
*/ */
public void processPacket(Packet packet) { public void processPacket(Packet packet) throws NotConnectedException {
if (own_version == null) if (own_version == null)
return; return;

View file

@ -43,6 +43,7 @@ import org.jivesoftware.smack.PacketListener;
import org.jivesoftware.smack.SmackConfiguration; import org.jivesoftware.smack.SmackConfiguration;
import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.SmackException.NoResponseException; import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException; import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.XMPPException.XMPPErrorException; import org.jivesoftware.smack.XMPPException.XMPPErrorException;
@ -181,9 +182,10 @@ public class MultiUserChat {
* @return a boolean indicating whether the specified user supports the MUC protocol. * @return a boolean indicating whether the specified user supports the MUC protocol.
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
*/ */
public static boolean isServiceEnabled(XMPPConnection connection, String user) public static boolean isServiceEnabled(XMPPConnection connection, String user)
throws NoResponseException, XMPPErrorException { throws NoResponseException, XMPPErrorException, NotConnectedException {
return ServiceDiscoveryManager.getInstanceFor(connection).supportsFeature(user, return ServiceDiscoveryManager.getInstanceFor(connection).supportsFeature(user,
discoNamespace); discoNamespace);
} }
@ -214,9 +216,10 @@ public class MultiUserChat {
* @return an Iterator on the rooms where the requested user has joined. * @return an Iterator on the rooms where the requested user has joined.
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
*/ */
public static Iterator<String> getJoinedRooms(XMPPConnection connection, String user) public static Iterator<String> getJoinedRooms(XMPPConnection connection, String user)
throws NoResponseException, XMPPErrorException { throws NoResponseException, XMPPErrorException, NotConnectedException {
ArrayList<String> answer = new ArrayList<String>(); ArrayList<String> answer = new ArrayList<String>();
// Send the disco packet to the user // Send the disco packet to the user
DiscoverItems result = ServiceDiscoveryManager.getInstanceFor(connection).discoverItems( DiscoverItems result = ServiceDiscoveryManager.getInstanceFor(connection).discoverItems(
@ -238,9 +241,10 @@ public class MultiUserChat {
* @return the discovered information of a given room without actually having to join the room. * @return the discovered information of a given room without actually having to join the room.
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
*/ */
public static RoomInfo getRoomInfo(XMPPConnection connection, String room) public static RoomInfo getRoomInfo(XMPPConnection connection, String room)
throws NoResponseException, XMPPErrorException { throws NoResponseException, XMPPErrorException, NotConnectedException {
DiscoverInfo info = ServiceDiscoveryManager.getInstanceFor(connection).discoverInfo(room); DiscoverInfo info = ServiceDiscoveryManager.getInstanceFor(connection).discoverInfo(room);
return new RoomInfo(info); return new RoomInfo(info);
} }
@ -252,8 +256,9 @@ public class MultiUserChat {
* @return a collection with the XMPP addresses of the Multi-User Chat services. * @return a collection with the XMPP addresses of the Multi-User Chat services.
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
*/ */
public static Collection<String> getServiceNames(XMPPConnection connection) throws NoResponseException, XMPPErrorException { public static Collection<String> getServiceNames(XMPPConnection connection) throws NoResponseException, XMPPErrorException, NotConnectedException {
final List<String> answer = new ArrayList<String>(); final List<String> answer = new ArrayList<String>();
ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(connection); ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(connection);
DiscoverItems items = discoManager.discoverItems(connection.getServiceName()); DiscoverItems items = discoManager.discoverItems(connection.getServiceName());
@ -277,9 +282,10 @@ public class MultiUserChat {
* @return a collection of HostedRooms. * @return a collection of HostedRooms.
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
*/ */
public static Collection<HostedRoom> getHostedRooms(XMPPConnection connection, public static Collection<HostedRoom> getHostedRooms(XMPPConnection connection,
String serviceName) throws NoResponseException, XMPPErrorException { String serviceName) throws NoResponseException, XMPPErrorException, NotConnectedException {
List<HostedRoom> answer = new ArrayList<HostedRoom>(); List<HostedRoom> answer = new ArrayList<HostedRoom>();
ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(connection); ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(connection);
DiscoverItems items = discoManager.discoverItems(serviceName); DiscoverItems items = discoManager.discoverItems(serviceName);
@ -385,8 +391,9 @@ public class MultiUserChat {
* 407 error can occur if user is not on the member list; or a * 407 error can occur if user is not on the member list; or a
* 409 error can occur if someone is already in the group chat with the same nickname. * 409 error can occur if someone is already in the group chat with the same nickname.
* @throws NoResponseException if there was no response from the server. * @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/ */
public void join(String nickname) throws NoResponseException, XMPPErrorException { public void join(String nickname) throws NoResponseException, XMPPErrorException, NotConnectedException {
join(nickname, null, null, SmackConfiguration.getDefaultPacketReplyTimeout()); join(nickname, null, null, SmackConfiguration.getDefaultPacketReplyTimeout());
} }
@ -439,13 +446,14 @@ public class MultiUserChat {
* 407 error can occur if user is not on the member list; or a * 407 error can occur if user is not on the member list; or a
* 409 error can occur if someone is already in the group chat with the same nickname. * 409 error can occur if someone is already in the group chat with the same nickname.
* @throws NoResponseException if there was no response from the server. * @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/ */
public synchronized void join( public synchronized void join(
String nickname, String nickname,
String password, String password,
DiscussionHistory history, DiscussionHistory history,
long timeout) long timeout)
throws XMPPErrorException, NoResponseException { throws XMPPErrorException, NoResponseException, NotConnectedException {
if (nickname == null || nickname.equals("")) { if (nickname == null || nickname.equals("")) {
throw new IllegalArgumentException("Nickname must not be null or blank."); throw new IllegalArgumentException("Nickname must not be null or blank.");
} }
@ -503,8 +511,9 @@ public class MultiUserChat {
/** /**
* Leave the chat room. * Leave the chat room.
* @throws NotConnectedException
*/ */
public synchronized void leave() { public synchronized void leave() throws NotConnectedException {
// If not joined already, do nothing. // If not joined already, do nothing.
if (!joined) { if (!joined) {
return; return;
@ -534,8 +543,9 @@ public class MultiUserChat {
* <tt>null</tt> if no configuration is possible. * <tt>null</tt> if no configuration is possible.
* @throws XMPPErrorException if an error occurs asking the configuration form for the room. * @throws XMPPErrorException if an error occurs asking the configuration form for the room.
* @throws NoResponseException if there was no response from the server. * @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/ */
public Form getConfigurationForm() throws NoResponseException, XMPPErrorException { public Form getConfigurationForm() throws NoResponseException, XMPPErrorException, NotConnectedException {
MUCOwner iq = new MUCOwner(); MUCOwner iq = new MUCOwner();
iq.setTo(room); iq.setTo(room);
iq.setType(IQ.Type.GET); iq.setType(IQ.Type.GET);
@ -552,8 +562,9 @@ public class MultiUserChat {
* @param form the form with the new settings. * @param form the form with the new settings.
* @throws XMPPErrorException if an error occurs setting the new rooms' configuration. * @throws XMPPErrorException if an error occurs setting the new rooms' configuration.
* @throws NoResponseException if there was no response from the server. * @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/ */
public void sendConfigurationForm(Form form) throws NoResponseException, XMPPErrorException { public void sendConfigurationForm(Form form) throws NoResponseException, XMPPErrorException, NotConnectedException {
MUCOwner iq = new MUCOwner(); MUCOwner iq = new MUCOwner();
iq.setTo(room); iq.setTo(room);
iq.setType(IQ.Type.SET); iq.setType(IQ.Type.SET);
@ -576,8 +587,9 @@ public class MultiUserChat {
* @throws XMPPErrorException if an error occurs asking the registration form for the room or a * @throws XMPPErrorException if an error occurs asking the registration form for the room or a
* 405 error if the user is not allowed to register with the room. * 405 error if the user is not allowed to register with the room.
* @throws NoResponseException if there was no response from the server. * @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/ */
public Form getRegistrationForm() throws NoResponseException, XMPPErrorException { public Form getRegistrationForm() throws NoResponseException, XMPPErrorException, NotConnectedException {
Registration reg = new Registration(); Registration reg = new Registration();
reg.setType(IQ.Type.GET); reg.setType(IQ.Type.GET);
reg.setTo(room); reg.setTo(room);
@ -600,8 +612,9 @@ public class MultiUserChat {
* 409 error can occur if the desired room nickname is already reserved for that room; * 409 error can occur if the desired room nickname is already reserved for that room;
* or a 503 error can occur if the room does not support registration. * or a 503 error can occur if the room does not support registration.
* @throws NoResponseException if there was no response from the server. * @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/ */
public void sendRegistrationForm(Form form) throws NoResponseException, XMPPErrorException { public void sendRegistrationForm(Form form) throws NoResponseException, XMPPErrorException, NotConnectedException {
Registration reg = new Registration(); Registration reg = new Registration();
reg.setType(IQ.Type.SET); reg.setType(IQ.Type.SET);
reg.setTo(room); reg.setTo(room);
@ -622,8 +635,9 @@ public class MultiUserChat {
* XMPP error code 403. The error code can be used to present more * XMPP error code 403. The error code can be used to present more
* appropiate error messages to end-users. * appropiate error messages to end-users.
* @throws NoResponseException if there was no response from the server. * @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/ */
public void destroy(String reason, String alternateJID) throws NoResponseException, XMPPErrorException { public void destroy(String reason, String alternateJID) throws NoResponseException, XMPPErrorException, NotConnectedException {
MUCOwner iq = new MUCOwner(); MUCOwner iq = new MUCOwner();
iq.setTo(room); iq.setTo(room);
iq.setType(IQ.Type.SET); iq.setType(IQ.Type.SET);
@ -652,8 +666,9 @@ public class MultiUserChat {
* *
* @param user the user to invite to the room.(e.g. hecate@shakespeare.lit) * @param user the user to invite to the room.(e.g. hecate@shakespeare.lit)
* @param reason the reason why the user is being invited. * @param reason the reason why the user is being invited.
* @throws NotConnectedException
*/ */
public void invite(String user, String reason) { public void invite(String user, String reason) throws NotConnectedException {
invite(new Message(), user, reason); invite(new Message(), user, reason);
} }
@ -667,8 +682,9 @@ public class MultiUserChat {
* @param message the message to use for sending the invitation. * @param message the message to use for sending the invitation.
* @param user the user to invite to the room.(e.g. hecate@shakespeare.lit) * @param user the user to invite to the room.(e.g. hecate@shakespeare.lit)
* @param reason the reason why the user is being invited. * @param reason the reason why the user is being invited.
* @throws NotConnectedException
*/ */
public void invite(Message message, String user, String reason) { public void invite(Message message, String user, String reason) throws NotConnectedException {
// TODO listen for 404 error code when inviter supplies a non-existent JID // TODO listen for 404 error code when inviter supplies a non-existent JID
message.setTo(room); message.setTo(room);
@ -692,8 +708,9 @@ public class MultiUserChat {
* @param room the room that sent the original invitation. * @param room the room that sent the original invitation.
* @param inviter the inviter of the declined invitation. * @param inviter the inviter of the declined invitation.
* @param reason the reason why the invitee is declining the invitation. * @param reason the reason why the invitee is declining the invitation.
* @throws NotConnectedException
*/ */
public static void decline(XMPPConnection conn, String room, String inviter, String reason) { public static void decline(XMPPConnection conn, String room, String inviter, String reason) throws NotConnectedException {
Message message = new Message(room); Message message = new Message(room);
// Create the MUCUser packet that will include the rejection // Create the MUCUser packet that will include the rejection
@ -901,8 +918,9 @@ public class MultiUserChat {
* @param nickname the new nickname within the room. * @param nickname the new nickname within the room.
* @throws XMPPErrorException if the new nickname is already in use by another occupant. * @throws XMPPErrorException if the new nickname is already in use by another occupant.
* @throws NoResponseException if there was no response from the server. * @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/ */
public void changeNickname(String nickname) throws NoResponseException, XMPPErrorException { public void changeNickname(String nickname) throws NoResponseException, XMPPErrorException, NotConnectedException {
if (nickname == null || nickname.equals("")) { if (nickname == null || nickname.equals("")) {
throw new IllegalArgumentException("Nickname must not be null or blank."); throw new IllegalArgumentException("Nickname must not be null or blank.");
} }
@ -943,8 +961,9 @@ public class MultiUserChat {
* *
* @param status a text message describing the presence update. * @param status a text message describing the presence update.
* @param mode the mode type for the presence update. * @param mode the mode type for the presence update.
* @throws NotConnectedException
*/ */
public void changeAvailabilityStatus(String status, Presence.Mode mode) { public void changeAvailabilityStatus(String status, Presence.Mode mode) throws NotConnectedException {
if (nickname == null || nickname.equals("")) { if (nickname == null || nickname.equals("")) {
throw new IllegalArgumentException("Nickname must not be null or blank."); throw new IllegalArgumentException("Nickname must not be null or blank.");
} }
@ -987,8 +1006,9 @@ public class MultiUserChat {
* not have kicking privileges (i.e. Forbidden error); or a * not have kicking privileges (i.e. Forbidden error); or a
* 400 error can occur if the provided nickname is not present in the room. * 400 error can occur if the provided nickname is not present in the room.
* @throws NoResponseException if there was no response from the server. * @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/ */
public void kickParticipant(String nickname, String reason) throws XMPPErrorException, NoResponseException { public void kickParticipant(String nickname, String reason) throws XMPPErrorException, NoResponseException, NotConnectedException {
changeRole(nickname, "none", reason); changeRole(nickname, "none", reason);
} }
@ -1003,8 +1023,9 @@ public class MultiUserChat {
* a moderator in this room (i.e. Forbidden error); or a * a moderator in this room (i.e. Forbidden error); or a
* 400 error can occur if the provided nickname is not present in the room. * 400 error can occur if the provided nickname is not present in the room.
* @throws NoResponseException if there was no response from the server. * @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/ */
public void grantVoice(Collection<String> nicknames) throws XMPPErrorException, NoResponseException { public void grantVoice(Collection<String> nicknames) throws XMPPErrorException, NoResponseException, NotConnectedException {
changeRole(nicknames, "participant"); changeRole(nicknames, "participant");
} }
@ -1019,8 +1040,9 @@ public class MultiUserChat {
* a moderator in this room (i.e. Forbidden error); or a * a moderator in this room (i.e. Forbidden error); or a
* 400 error can occur if the provided nickname is not present in the room. * 400 error can occur if the provided nickname is not present in the room.
* @throws NoResponseException if there was no response from the server. * @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/ */
public void grantVoice(String nickname) throws XMPPErrorException, NoResponseException { public void grantVoice(String nickname) throws XMPPErrorException, NoResponseException, NotConnectedException {
changeRole(nickname, "participant", null); changeRole(nickname, "participant", null);
} }
@ -1035,8 +1057,9 @@ public class MultiUserChat {
* was tried to revoke his voice (i.e. Not Allowed error); or a * was tried to revoke his voice (i.e. Not Allowed error); or a
* 400 error can occur if the provided nickname is not present in the room. * 400 error can occur if the provided nickname is not present in the room.
* @throws NoResponseException if there was no response from the server. * @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/ */
public void revokeVoice(Collection<String> nicknames) throws XMPPErrorException, NoResponseException { public void revokeVoice(Collection<String> nicknames) throws XMPPErrorException, NoResponseException, NotConnectedException {
changeRole(nicknames, "visitor"); changeRole(nicknames, "visitor");
} }
@ -1051,8 +1074,9 @@ public class MultiUserChat {
* was tried to revoke his voice (i.e. Not Allowed error); or a * was tried to revoke his voice (i.e. Not Allowed error); or a
* 400 error can occur if the provided nickname is not present in the room. * 400 error can occur if the provided nickname is not present in the room.
* @throws NoResponseException if there was no response from the server. * @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/ */
public void revokeVoice(String nickname) throws XMPPErrorException, NoResponseException { public void revokeVoice(String nickname) throws XMPPErrorException, NoResponseException, NotConnectedException {
changeRole(nickname, "visitor", null); changeRole(nickname, "visitor", null);
} }
@ -1068,8 +1092,9 @@ public class MultiUserChat {
* 405 error can occur if a moderator or a user with an affiliation of "owner" or "admin" * 405 error can occur if a moderator or a user with an affiliation of "owner" or "admin"
* was tried to be banned (i.e. Not Allowed error). * was tried to be banned (i.e. Not Allowed error).
* @throws NoResponseException if there was no response from the server. * @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/ */
public void banUsers(Collection<String> jids) throws XMPPErrorException, NoResponseException { public void banUsers(Collection<String> jids) throws XMPPErrorException, NoResponseException, NotConnectedException {
changeAffiliationByAdmin(jids, "outcast"); changeAffiliationByAdmin(jids, "outcast");
} }
@ -1086,8 +1111,9 @@ public class MultiUserChat {
* 405 error can occur if a moderator or a user with an affiliation of "owner" or "admin" * 405 error can occur if a moderator or a user with an affiliation of "owner" or "admin"
* was tried to be banned (i.e. Not Allowed error). * was tried to be banned (i.e. Not Allowed error).
* @throws NoResponseException if there was no response from the server. * @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/ */
public void banUser(String jid, String reason) throws XMPPErrorException, NoResponseException { public void banUser(String jid, String reason) throws XMPPErrorException, NoResponseException, NotConnectedException {
changeAffiliationByAdmin(jid, "outcast", reason); changeAffiliationByAdmin(jid, "outcast", reason);
} }
@ -1099,8 +1125,9 @@ public class MultiUserChat {
* @param jids the XMPP user IDs of the users to grant membership. * @param jids the XMPP user IDs of the users to grant membership.
* @throws XMPPErrorException if an error occurs granting membership to a user. * @throws XMPPErrorException if an error occurs granting membership to a user.
* @throws NoResponseException if there was no response from the server. * @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/ */
public void grantMembership(Collection<String> jids) throws XMPPErrorException, NoResponseException { public void grantMembership(Collection<String> jids) throws XMPPErrorException, NoResponseException, NotConnectedException {
changeAffiliationByAdmin(jids, "member"); changeAffiliationByAdmin(jids, "member");
} }
@ -1112,8 +1139,9 @@ public class MultiUserChat {
* @param jid the XMPP user ID of the user to grant membership (e.g. "user@host.org"). * @param jid the XMPP user ID of the user to grant membership (e.g. "user@host.org").
* @throws XMPPErrorException if an error occurs granting membership to a user. * @throws XMPPErrorException if an error occurs granting membership to a user.
* @throws NoResponseException if there was no response from the server. * @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/ */
public void grantMembership(String jid) throws XMPPErrorException, NoResponseException { public void grantMembership(String jid) throws XMPPErrorException, NoResponseException, NotConnectedException {
changeAffiliationByAdmin(jid, "member", null); changeAffiliationByAdmin(jid, "member", null);
} }
@ -1126,8 +1154,9 @@ public class MultiUserChat {
* @param jids the bare XMPP user IDs of the users to revoke membership. * @param jids the bare XMPP user IDs of the users to revoke membership.
* @throws XMPPErrorException if an error occurs revoking membership to a user. * @throws XMPPErrorException if an error occurs revoking membership to a user.
* @throws NoResponseException if there was no response from the server. * @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/ */
public void revokeMembership(Collection<String> jids) throws XMPPErrorException, NoResponseException { public void revokeMembership(Collection<String> jids) throws XMPPErrorException, NoResponseException, NotConnectedException {
changeAffiliationByAdmin(jids, "none"); changeAffiliationByAdmin(jids, "none");
} }
@ -1140,8 +1169,9 @@ public class MultiUserChat {
* @param jid the bare XMPP user ID of the user to revoke membership (e.g. "user@host.org"). * @param jid the bare XMPP user ID of the user to revoke membership (e.g. "user@host.org").
* @throws XMPPErrorException if an error occurs revoking membership to a user. * @throws XMPPErrorException if an error occurs revoking membership to a user.
* @throws NoResponseException if there was no response from the server. * @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/ */
public void revokeMembership(String jid) throws XMPPErrorException, NoResponseException { public void revokeMembership(String jid) throws XMPPErrorException, NoResponseException, NotConnectedException {
changeAffiliationByAdmin(jid, "none", null); changeAffiliationByAdmin(jid, "none", null);
} }
@ -1153,8 +1183,9 @@ public class MultiUserChat {
* @param nicknames the nicknames of the occupants to grant moderator privileges. * @param nicknames the nicknames of the occupants to grant moderator privileges.
* @throws XMPPErrorException if an error occurs granting moderator privileges to a user. * @throws XMPPErrorException if an error occurs granting moderator privileges to a user.
* @throws NoResponseException if there was no response from the server. * @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/ */
public void grantModerator(Collection<String> nicknames) throws XMPPErrorException, NoResponseException { public void grantModerator(Collection<String> nicknames) throws XMPPErrorException, NoResponseException, NotConnectedException {
changeRole(nicknames, "moderator"); changeRole(nicknames, "moderator");
} }
@ -1166,8 +1197,9 @@ public class MultiUserChat {
* @param nickname the nickname of the occupant to grant moderator privileges. * @param nickname the nickname of the occupant to grant moderator privileges.
* @throws XMPPErrorException if an error occurs granting moderator privileges to a user. * @throws XMPPErrorException if an error occurs granting moderator privileges to a user.
* @throws NoResponseException if there was no response from the server. * @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/ */
public void grantModerator(String nickname) throws XMPPErrorException, NoResponseException { public void grantModerator(String nickname) throws XMPPErrorException, NoResponseException, NotConnectedException {
changeRole(nickname, "moderator", null); changeRole(nickname, "moderator", null);
} }
@ -1180,8 +1212,9 @@ public class MultiUserChat {
* @param nicknames the nicknames of the occupants to revoke moderator privileges. * @param nicknames the nicknames of the occupants to revoke moderator privileges.
* @throws XMPPErrorException if an error occurs revoking moderator privileges from a user. * @throws XMPPErrorException if an error occurs revoking moderator privileges from a user.
* @throws NoResponseException if there was no response from the server. * @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/ */
public void revokeModerator(Collection<String> nicknames) throws XMPPErrorException, NoResponseException { public void revokeModerator(Collection<String> nicknames) throws XMPPErrorException, NoResponseException, NotConnectedException {
changeRole(nicknames, "participant"); changeRole(nicknames, "participant");
} }
@ -1194,8 +1227,9 @@ public class MultiUserChat {
* @param nickname the nickname of the occupant to revoke moderator privileges. * @param nickname the nickname of the occupant to revoke moderator privileges.
* @throws XMPPErrorException if an error occurs revoking moderator privileges from a user. * @throws XMPPErrorException if an error occurs revoking moderator privileges from a user.
* @throws NoResponseException if there was no response from the server. * @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/ */
public void revokeModerator(String nickname) throws XMPPErrorException, NoResponseException { public void revokeModerator(String nickname) throws XMPPErrorException, NoResponseException, NotConnectedException {
changeRole(nickname, "participant", null); changeRole(nickname, "participant", null);
} }
@ -1208,8 +1242,9 @@ public class MultiUserChat {
* @param jids the collection of bare XMPP user IDs of the users to grant ownership. * @param jids the collection of bare XMPP user IDs of the users to grant ownership.
* @throws XMPPErrorException if an error occurs granting ownership privileges to a user. * @throws XMPPErrorException if an error occurs granting ownership privileges to a user.
* @throws NoResponseException if there was no response from the server. * @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/ */
public void grantOwnership(Collection<String> jids) throws XMPPErrorException, NoResponseException { public void grantOwnership(Collection<String> jids) throws XMPPErrorException, NoResponseException, NotConnectedException {
changeAffiliationByAdmin(jids, "owner"); changeAffiliationByAdmin(jids, "owner");
} }
@ -1222,8 +1257,9 @@ public class MultiUserChat {
* @param jid the bare XMPP user ID of the user to grant ownership (e.g. "user@host.org"). * @param jid the bare XMPP user ID of the user to grant ownership (e.g. "user@host.org").
* @throws XMPPErrorException if an error occurs granting ownership privileges to a user. * @throws XMPPErrorException if an error occurs granting ownership privileges to a user.
* @throws NoResponseException if there was no response from the server. * @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/ */
public void grantOwnership(String jid) throws XMPPErrorException, NoResponseException { public void grantOwnership(String jid) throws XMPPErrorException, NoResponseException, NotConnectedException {
changeAffiliationByAdmin(jid, "owner", null); changeAffiliationByAdmin(jid, "owner", null);
} }
@ -1235,8 +1271,9 @@ public class MultiUserChat {
* @param jids the bare XMPP user IDs of the users to revoke ownership. * @param jids the bare XMPP user IDs of the users to revoke ownership.
* @throws XMPPErrorException if an error occurs revoking ownership privileges from a user. * @throws XMPPErrorException if an error occurs revoking ownership privileges from a user.
* @throws NoResponseException if there was no response from the server. * @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/ */
public void revokeOwnership(Collection<String> jids) throws XMPPErrorException, NoResponseException { public void revokeOwnership(Collection<String> jids) throws XMPPErrorException, NoResponseException, NotConnectedException {
changeAffiliationByAdmin(jids, "admin"); changeAffiliationByAdmin(jids, "admin");
} }
@ -1248,8 +1285,9 @@ public class MultiUserChat {
* @param jid the bare XMPP user ID of the user to revoke ownership (e.g. "user@host.org"). * @param jid the bare XMPP user ID of the user to revoke ownership (e.g. "user@host.org").
* @throws XMPPErrorException if an error occurs revoking ownership privileges from a user. * @throws XMPPErrorException if an error occurs revoking ownership privileges from a user.
* @throws NoResponseException if there was no response from the server. * @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/ */
public void revokeOwnership(String jid) throws XMPPErrorException, NoResponseException { public void revokeOwnership(String jid) throws XMPPErrorException, NoResponseException, NotConnectedException {
changeAffiliationByAdmin(jid, "admin", null); changeAffiliationByAdmin(jid, "admin", null);
} }
@ -1261,8 +1299,9 @@ public class MultiUserChat {
* @param jids the bare XMPP user IDs of the users to grant administrator privileges. * @param jids the bare XMPP user IDs of the users to grant administrator privileges.
* @throws XMPPErrorException if an error occurs granting administrator privileges to a user. * @throws XMPPErrorException if an error occurs granting administrator privileges to a user.
* @throws NoResponseException if there was no response from the server. * @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/ */
public void grantAdmin(Collection<String> jids) throws XMPPErrorException, NoResponseException { public void grantAdmin(Collection<String> jids) throws XMPPErrorException, NoResponseException, NotConnectedException {
changeAffiliationByOwner(jids, "admin"); changeAffiliationByOwner(jids, "admin");
} }
@ -1275,8 +1314,9 @@ public class MultiUserChat {
* (e.g. "user@host.org"). * (e.g. "user@host.org").
* @throws XMPPErrorException if an error occurs granting administrator privileges to a user. * @throws XMPPErrorException if an error occurs granting administrator privileges to a user.
* @throws NoResponseException if there was no response from the server. * @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/ */
public void grantAdmin(String jid) throws XMPPErrorException, NoResponseException { public void grantAdmin(String jid) throws XMPPErrorException, NoResponseException, NotConnectedException {
changeAffiliationByOwner(jid, "admin"); changeAffiliationByOwner(jid, "admin");
} }
@ -1288,8 +1328,9 @@ public class MultiUserChat {
* @param jids the bare XMPP user IDs of the user to revoke administrator privileges. * @param jids the bare XMPP user IDs of the user to revoke administrator privileges.
* @throws XMPPErrorException if an error occurs revoking administrator privileges from a user. * @throws XMPPErrorException if an error occurs revoking administrator privileges from a user.
* @throws NoResponseException if there was no response from the server. * @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/ */
public void revokeAdmin(Collection<String> jids) throws XMPPErrorException, NoResponseException { public void revokeAdmin(Collection<String> jids) throws XMPPErrorException, NoResponseException, NotConnectedException {
changeAffiliationByOwner(jids, "member"); changeAffiliationByOwner(jids, "member");
} }
@ -1302,13 +1343,14 @@ public class MultiUserChat {
* (e.g. "user@host.org"). * (e.g. "user@host.org").
* @throws XMPPErrorException if an error occurs revoking administrator privileges from a user. * @throws XMPPErrorException if an error occurs revoking administrator privileges from a user.
* @throws NoResponseException if there was no response from the server. * @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/ */
public void revokeAdmin(String jid) throws XMPPErrorException, NoResponseException { public void revokeAdmin(String jid) throws XMPPErrorException, NoResponseException, NotConnectedException {
changeAffiliationByOwner(jid, "member"); changeAffiliationByOwner(jid, "member");
} }
private void changeAffiliationByOwner(String jid, String affiliation) private void changeAffiliationByOwner(String jid, String affiliation)
throws XMPPErrorException, NoResponseException { throws XMPPErrorException, NoResponseException, NotConnectedException {
MUCOwner iq = new MUCOwner(); MUCOwner iq = new MUCOwner();
iq.setTo(room); iq.setTo(room);
iq.setType(IQ.Type.SET); iq.setType(IQ.Type.SET);
@ -1321,7 +1363,7 @@ public class MultiUserChat {
} }
private void changeAffiliationByOwner(Collection<String> jids, String affiliation) private void changeAffiliationByOwner(Collection<String> jids, String affiliation)
throws NoResponseException, XMPPErrorException { throws NoResponseException, XMPPErrorException, NotConnectedException {
MUCOwner iq = new MUCOwner(); MUCOwner iq = new MUCOwner();
iq.setTo(room); iq.setTo(room);
iq.setType(IQ.Type.SET); iq.setType(IQ.Type.SET);
@ -1343,8 +1385,9 @@ public class MultiUserChat {
* @param reason the reason for the affiliation change (optional) * @param reason the reason for the affiliation change (optional)
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
*/ */
private void changeAffiliationByAdmin(String jid, String affiliation, String reason) throws NoResponseException, XMPPErrorException private void changeAffiliationByAdmin(String jid, String affiliation, String reason) throws NoResponseException, XMPPErrorException, NotConnectedException
{ {
MUCAdmin iq = new MUCAdmin(); MUCAdmin iq = new MUCAdmin();
iq.setTo(room); iq.setTo(room);
@ -1359,7 +1402,7 @@ public class MultiUserChat {
} }
private void changeAffiliationByAdmin(Collection<String> jids, String affiliation) private void changeAffiliationByAdmin(Collection<String> jids, String affiliation)
throws NoResponseException, XMPPErrorException { throws NoResponseException, XMPPErrorException, NotConnectedException {
MUCAdmin iq = new MUCAdmin(); MUCAdmin iq = new MUCAdmin();
iq.setTo(room); iq.setTo(room);
iq.setType(IQ.Type.SET); iq.setType(IQ.Type.SET);
@ -1373,7 +1416,7 @@ public class MultiUserChat {
connection.createPacketCollectorAndSend(iq).nextResultOrThrow(); connection.createPacketCollectorAndSend(iq).nextResultOrThrow();
} }
private void changeRole(String nickname, String role, String reason) throws NoResponseException, XMPPErrorException { private void changeRole(String nickname, String role, String reason) throws NoResponseException, XMPPErrorException, NotConnectedException {
MUCAdmin iq = new MUCAdmin(); MUCAdmin iq = new MUCAdmin();
iq.setTo(room); iq.setTo(room);
iq.setType(IQ.Type.SET); iq.setType(IQ.Type.SET);
@ -1386,7 +1429,7 @@ public class MultiUserChat {
connection.createPacketCollectorAndSend(iq).nextResultOrThrow(); connection.createPacketCollectorAndSend(iq).nextResultOrThrow();
} }
private void changeRole(Collection<String> nicknames, String role) throws NoResponseException, XMPPErrorException { private void changeRole(Collection<String> nicknames, String role) throws NoResponseException, XMPPErrorException, NotConnectedException {
MUCAdmin iq = new MUCAdmin(); MUCAdmin iq = new MUCAdmin();
iq.setTo(room); iq.setTo(room);
iq.setType(IQ.Type.SET); iq.setType(IQ.Type.SET);
@ -1491,8 +1534,9 @@ public class MultiUserChat {
* @return a collection of <code>Affiliate</code> with the room owners. * @return a collection of <code>Affiliate</code> with the room owners.
* @throws XMPPErrorException if you don't have enough privileges to get this information. * @throws XMPPErrorException if you don't have enough privileges to get this information.
* @throws NoResponseException if there was no response from the server. * @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/ */
public Collection<Affiliate> getOwners() throws NoResponseException, XMPPErrorException { public Collection<Affiliate> getOwners() throws NoResponseException, XMPPErrorException, NotConnectedException {
return getAffiliatesByAdmin("owner"); return getAffiliatesByAdmin("owner");
} }
@ -1502,8 +1546,9 @@ public class MultiUserChat {
* @return a collection of <code>Affiliate</code> with the room administrators. * @return a collection of <code>Affiliate</code> with the room administrators.
* @throws XMPPErrorException if you don't have enough privileges to get this information. * @throws XMPPErrorException if you don't have enough privileges to get this information.
* @throws NoResponseException if there was no response from the server. * @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/ */
public Collection<Affiliate> getAdmins() throws NoResponseException, XMPPErrorException { public Collection<Affiliate> getAdmins() throws NoResponseException, XMPPErrorException, NotConnectedException {
return getAffiliatesByAdmin("admin"); return getAffiliatesByAdmin("admin");
} }
@ -1513,8 +1558,9 @@ public class MultiUserChat {
* @return a collection of <code>Affiliate</code> with the room members. * @return a collection of <code>Affiliate</code> with the room members.
* @throws XMPPErrorException if you don't have enough privileges to get this information. * @throws XMPPErrorException if you don't have enough privileges to get this information.
* @throws NoResponseException if there was no response from the server. * @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/ */
public Collection<Affiliate> getMembers() throws NoResponseException, XMPPErrorException { public Collection<Affiliate> getMembers() throws NoResponseException, XMPPErrorException, NotConnectedException {
return getAffiliatesByAdmin("member"); return getAffiliatesByAdmin("member");
} }
@ -1524,8 +1570,9 @@ public class MultiUserChat {
* @return a collection of <code>Affiliate</code> with the room outcasts. * @return a collection of <code>Affiliate</code> with the room outcasts.
* @throws XMPPErrorException if you don't have enough privileges to get this information. * @throws XMPPErrorException if you don't have enough privileges to get this information.
* @throws NoResponseException if there was no response from the server. * @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/ */
public Collection<Affiliate> getOutcasts() throws NoResponseException, XMPPErrorException { public Collection<Affiliate> getOutcasts() throws NoResponseException, XMPPErrorException, NotConnectedException {
return getAffiliatesByAdmin("outcast"); return getAffiliatesByAdmin("outcast");
} }
@ -1537,8 +1584,9 @@ public class MultiUserChat {
* @return a collection of <code>Affiliate</code> that have the specified room affiliation. * @return a collection of <code>Affiliate</code> that have the specified room affiliation.
* @throws XMPPErrorException if you don't have enough privileges to get this information. * @throws XMPPErrorException if you don't have enough privileges to get this information.
* @throws NoResponseException if there was no response from the server. * @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/ */
private Collection<Affiliate> getAffiliatesByAdmin(String affiliation) throws NoResponseException, XMPPErrorException { private Collection<Affiliate> getAffiliatesByAdmin(String affiliation) throws NoResponseException, XMPPErrorException, NotConnectedException {
MUCAdmin iq = new MUCAdmin(); MUCAdmin iq = new MUCAdmin();
iq.setTo(room); iq.setTo(room);
iq.setType(IQ.Type.GET); iq.setType(IQ.Type.GET);
@ -1562,8 +1610,9 @@ public class MultiUserChat {
* @return a collection of <code>Occupant</code> with the room moderators. * @return a collection of <code>Occupant</code> with the room moderators.
* @throws XMPPErrorException if you don't have enough privileges to get this information. * @throws XMPPErrorException if you don't have enough privileges to get this information.
* @throws NoResponseException if there was no response from the server. * @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/ */
public Collection<Occupant> getModerators() throws NoResponseException, XMPPErrorException { public Collection<Occupant> getModerators() throws NoResponseException, XMPPErrorException, NotConnectedException {
return getOccupants("moderator"); return getOccupants("moderator");
} }
@ -1573,8 +1622,9 @@ public class MultiUserChat {
* @return a collection of <code>Occupant</code> with the room participants. * @return a collection of <code>Occupant</code> with the room participants.
* @throws XMPPErrorException if you don't have enough privileges to get this information. * @throws XMPPErrorException if you don't have enough privileges to get this information.
* @throws NoResponseException if there was no response from the server. * @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/ */
public Collection<Occupant> getParticipants() throws NoResponseException, XMPPErrorException { public Collection<Occupant> getParticipants() throws NoResponseException, XMPPErrorException, NotConnectedException {
return getOccupants("participant"); return getOccupants("participant");
} }
@ -1586,8 +1636,9 @@ public class MultiUserChat {
* @throws XMPPErrorException if an error occured while performing the request to the server or you * @throws XMPPErrorException if an error occured while performing the request to the server or you
* don't have enough privileges to get this information. * don't have enough privileges to get this information.
* @throws NoResponseException if there was no response from the server. * @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/ */
private Collection<Occupant> getOccupants(String role) throws NoResponseException, XMPPErrorException { private Collection<Occupant> getOccupants(String role) throws NoResponseException, XMPPErrorException, NotConnectedException {
MUCAdmin iq = new MUCAdmin(); MUCAdmin iq = new MUCAdmin();
iq.setTo(room); iq.setTo(room);
iq.setType(IQ.Type.GET); iq.setType(IQ.Type.GET);
@ -1609,8 +1660,9 @@ public class MultiUserChat {
* *
* @param text the text of the message to send. * @param text the text of the message to send.
* @throws XMPPException if sending the message fails. * @throws XMPPException if sending the message fails.
* @throws NotConnectedException
*/ */
public void sendMessage(String text) throws XMPPException { public void sendMessage(String text) throws XMPPException, NotConnectedException {
Message message = new Message(room, Message.Type.groupchat); Message message = new Message(room, Message.Type.groupchat);
message.setBody(text); message.setBody(text);
connection.sendPacket(message); connection.sendPacket(message);
@ -1645,8 +1697,9 @@ public class MultiUserChat {
* *
* @param message the message. * @param message the message.
* @throws XMPPException if sending the message fails. * @throws XMPPException if sending the message fails.
* @throws NotConnectedException
*/ */
public void sendMessage(Message message) throws XMPPException { public void sendMessage(Message message) throws XMPPException, NotConnectedException {
connection.sendPacket(message); connection.sendPacket(message);
} }
@ -1724,8 +1777,9 @@ public class MultiUserChat {
* @throws XMPPErrorException if someone without appropriate privileges attempts to change the * @throws XMPPErrorException if someone without appropriate privileges attempts to change the
* room subject will throw an error with code 403 (i.e. Forbidden) * room subject will throw an error with code 403 (i.e. Forbidden)
* @throws NoResponseException if there was no response from the server. * @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/ */
public void changeSubject(final String subject) throws NoResponseException, XMPPErrorException { public void changeSubject(final String subject) throws NoResponseException, XMPPErrorException, NotConnectedException {
Message message = new Message(room, Message.Type.groupchat); Message message = new Message(room, Message.Type.groupchat);
message.setSubject(subject); message.setSubject(subject);
// Wait for an error or confirmation message back from the server. // Wait for an error or confirmation message back from the server.

View file

@ -18,6 +18,7 @@
package org.jivesoftware.smackx.muc; package org.jivesoftware.smackx.muc;
import org.jivesoftware.smack.PacketListener; import org.jivesoftware.smack.PacketListener;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.filter.MessageTypeFilter; import org.jivesoftware.smack.filter.MessageTypeFilter;
import org.jivesoftware.smack.filter.PacketExtensionFilter; import org.jivesoftware.smack.filter.PacketExtensionFilter;
import org.jivesoftware.smack.filter.PacketFilter; import org.jivesoftware.smack.filter.PacketFilter;
@ -74,7 +75,7 @@ class PacketMultiplexListener implements PacketListener {
this.declinesListener = declinesListener; this.declinesListener = declinesListener;
} }
public void processPacket(Packet p) { public void processPacket(Packet p) throws NotConnectedException {
if (PRESENCE_FILTER.accept(p)) { if (PRESENCE_FILTER.accept(p)) {
presenceListener.processPacket(p); presenceListener.processPacket(p);
} }

View file

@ -19,6 +19,7 @@ package org.jivesoftware.smackx.muc;
import org.jivesoftware.smack.AbstractConnectionListener; import org.jivesoftware.smack.AbstractConnectionListener;
import org.jivesoftware.smack.PacketListener; import org.jivesoftware.smack.PacketListener;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.filter.PacketFilter; import org.jivesoftware.smack.filter.PacketFilter;
import org.jivesoftware.smack.packet.Packet; import org.jivesoftware.smack.packet.Packet;
@ -183,7 +184,7 @@ class RoomListenerMultiplexor extends AbstractConnectionListener {
private Map<String, PacketMultiplexListener> roomListenersByAddress = private Map<String, PacketMultiplexListener> roomListenersByAddress =
new ConcurrentHashMap<String, PacketMultiplexListener>(); new ConcurrentHashMap<String, PacketMultiplexListener>();
public void processPacket(Packet p) { public void processPacket(Packet p) throws NotConnectedException {
String from = p.getFrom(); String from = p.getFrom();
if (from == null) { if (from == null) {
return; return;

View file

@ -20,6 +20,7 @@ package org.jivesoftware.smackx.offline;
import org.jivesoftware.smack.PacketCollector; import org.jivesoftware.smack.PacketCollector;
import org.jivesoftware.smack.SmackConfiguration; import org.jivesoftware.smack.SmackConfiguration;
import org.jivesoftware.smack.SmackException.NoResponseException; import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException.XMPPErrorException; import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.filter.AndFilter; import org.jivesoftware.smack.filter.AndFilter;
@ -78,8 +79,9 @@ public class OfflineMessageManager {
* @return a boolean indicating if the server supports Flexible Offline Message Retrieval. * @return a boolean indicating if the server supports Flexible Offline Message Retrieval.
* @throws XMPPErrorException If the user is not allowed to make this request. * @throws XMPPErrorException If the user is not allowed to make this request.
* @throws NoResponseException if there was no response from the server. * @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/ */
public boolean supportsFlexibleRetrieval() throws NoResponseException, XMPPErrorException { public boolean supportsFlexibleRetrieval() throws NoResponseException, XMPPErrorException, NotConnectedException {
return ServiceDiscoveryManager.getInstanceFor(connection).supportsFeature(connection.getServiceName(), namespace); return ServiceDiscoveryManager.getInstanceFor(connection).supportsFeature(connection.getServiceName(), namespace);
} }
@ -90,8 +92,9 @@ public class OfflineMessageManager {
* @throws XMPPErrorException If the user is not allowed to make this request or the server does * @throws XMPPErrorException If the user is not allowed to make this request or the server does
* not support offline message retrieval. * not support offline message retrieval.
* @throws NoResponseException if there was no response from the server. * @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/ */
public int getMessageCount() throws NoResponseException, XMPPErrorException { public int getMessageCount() throws NoResponseException, XMPPErrorException, NotConnectedException {
DiscoverInfo info = ServiceDiscoveryManager.getInstanceFor(connection).discoverInfo(null, DiscoverInfo info = ServiceDiscoveryManager.getInstanceFor(connection).discoverInfo(null,
namespace); namespace);
Form extendedInfo = Form.getFormFrom(info); Form extendedInfo = Form.getFormFrom(info);
@ -112,8 +115,9 @@ public class OfflineMessageManager {
* @throws XMPPErrorException If the user is not allowed to make this request or the server does * @throws XMPPErrorException If the user is not allowed to make this request or the server does
* not support offline message retrieval. * not support offline message retrieval.
* @throws NoResponseException if there was no response from the server. * @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/ */
public Iterator<OfflineMessageHeader> getHeaders() throws NoResponseException, XMPPErrorException { public Iterator<OfflineMessageHeader> getHeaders() throws NoResponseException, XMPPErrorException, NotConnectedException {
List<OfflineMessageHeader> answer = new ArrayList<OfflineMessageHeader>(); List<OfflineMessageHeader> answer = new ArrayList<OfflineMessageHeader>();
DiscoverItems items = ServiceDiscoveryManager.getInstanceFor(connection).discoverItems( DiscoverItems items = ServiceDiscoveryManager.getInstanceFor(connection).discoverItems(
null, namespace); null, namespace);
@ -136,8 +140,9 @@ public class OfflineMessageManager {
* @throws XMPPErrorException If the user is not allowed to make this request or the server does * @throws XMPPErrorException If the user is not allowed to make this request or the server does
* not support offline message retrieval. * not support offline message retrieval.
* @throws NoResponseException if there was no response from the server. * @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/ */
public Iterator<Message> getMessages(final List<String> nodes) throws NoResponseException, XMPPErrorException { public Iterator<Message> getMessages(final List<String> nodes) throws NoResponseException, XMPPErrorException, NotConnectedException {
List<Message> messages = new ArrayList<Message>(); List<Message> messages = new ArrayList<Message>();
OfflineMessageRequest request = new OfflineMessageRequest(); OfflineMessageRequest request = new OfflineMessageRequest();
for (String node : nodes) { for (String node : nodes) {
@ -177,8 +182,9 @@ public class OfflineMessageManager {
* @throws XMPPErrorException If the user is not allowed to make this request or the server does * @throws XMPPErrorException If the user is not allowed to make this request or the server does
* not support offline message retrieval. * not support offline message retrieval.
* @throws NoResponseException if there was no response from the server. * @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/ */
public Iterator<Message> getMessages() throws NoResponseException, XMPPErrorException { public Iterator<Message> getMessages() throws NoResponseException, XMPPErrorException, NotConnectedException {
List<Message> messages = new ArrayList<Message>(); List<Message> messages = new ArrayList<Message>();
OfflineMessageRequest request = new OfflineMessageRequest(); OfflineMessageRequest request = new OfflineMessageRequest();
request.setFetch(true); request.setFetch(true);
@ -206,8 +212,9 @@ public class OfflineMessageManager {
* @throws XMPPErrorException If the user is not allowed to make this request or the server does * @throws XMPPErrorException If the user is not allowed to make this request or the server does
* not support offline message retrieval. * not support offline message retrieval.
* @throws NoResponseException if there was no response from the server. * @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/ */
public void deleteMessages(List<String> nodes) throws NoResponseException, XMPPErrorException { public void deleteMessages(List<String> nodes) throws NoResponseException, XMPPErrorException, NotConnectedException {
OfflineMessageRequest request = new OfflineMessageRequest(); OfflineMessageRequest request = new OfflineMessageRequest();
for (String node : nodes) { for (String node : nodes) {
OfflineMessageRequest.Item item = new OfflineMessageRequest.Item(node); OfflineMessageRequest.Item item = new OfflineMessageRequest.Item(node);
@ -223,8 +230,9 @@ public class OfflineMessageManager {
* @throws XMPPErrorException If the user is not allowed to make this request or the server does * @throws XMPPErrorException If the user is not allowed to make this request or the server does
* not support offline message retrieval. * not support offline message retrieval.
* @throws NoResponseException if there was no response from the server. * @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/ */
public void deleteMessages() throws NoResponseException, XMPPErrorException { public void deleteMessages() throws NoResponseException, XMPPErrorException, NotConnectedException {
OfflineMessageRequest request = new OfflineMessageRequest(); OfflineMessageRequest request = new OfflineMessageRequest();
request.setPurge(true); request.setPurge(true);
connection.createPacketCollectorAndSend(request).nextResultOrThrow(); connection.createPacketCollectorAndSend(request).nextResultOrThrow();

View file

@ -21,6 +21,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.jivesoftware.smack.PacketListener; import org.jivesoftware.smack.PacketListener;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.filter.PacketExtensionFilter; import org.jivesoftware.smack.filter.PacketExtensionFilter;
import org.jivesoftware.smack.filter.PacketFilter; import org.jivesoftware.smack.filter.PacketFilter;
@ -105,8 +106,9 @@ public class PEPManager {
* Publish an event. * Publish an event.
* *
* @param item the item to publish. * @param item the item to publish.
* @throws NotConnectedException
*/ */
public void publish(PEPItem item) { public void publish(PEPItem item) throws NotConnectedException {
// Create a new message to publish the event. // Create a new message to publish the event.
PEPPubSub pubSub = new PEPPubSub(item); PEPPubSub pubSub = new PEPPubSub(item);
pubSub.setType(Type.SET); pubSub.setType(Type.SET);

View file

@ -29,6 +29,7 @@ import java.util.logging.Logger;
import org.jivesoftware.smack.AbstractConnectionListener; import org.jivesoftware.smack.AbstractConnectionListener;
import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.SmackException.NoResponseException; import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.ConnectionCreationListener; import org.jivesoftware.smack.ConnectionCreationListener;
import org.jivesoftware.smack.Manager; import org.jivesoftware.smack.Manager;
@ -129,7 +130,7 @@ public class PingManager extends Manager {
connection.addPacketListener(new PacketListener() { connection.addPacketListener(new PacketListener() {
// Send a Pong for every Ping // Send a Pong for every Ping
@Override @Override
public void processPacket(Packet packet) { public void processPacket(Packet packet) throws NotConnectedException {
Pong pong = new Pong(packet); Pong pong = new Pong(packet);
connection().sendPacket(pong); connection().sendPacket(pong);
} }
@ -163,8 +164,9 @@ public class PingManager extends Manager {
* @param pingTimeout The time to wait for a reply * @param pingTimeout The time to wait for a reply
* @return true if a reply was received from the entity, false otherwise. * @return true if a reply was received from the entity, false otherwise.
* @throws NoResponseException if there was no response from the server. * @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/ */
public boolean ping(String jid, long pingTimeout) throws NoResponseException { public boolean ping(String jid, long pingTimeout) throws NoResponseException, NotConnectedException {
Ping ping = new Ping(jid); Ping ping = new Ping(jid);
try { try {
connection().createPacketCollectorAndSend(ping).nextResultOrThrow(); connection().createPacketCollectorAndSend(ping).nextResultOrThrow();
@ -194,8 +196,9 @@ public class PingManager extends Manager {
* @return true if it supports ping, false otherwise. * @return true if it supports ping, false otherwise.
* @throws XMPPErrorException An XMPP related error occurred during the request * @throws XMPPErrorException An XMPP related error occurred during the request
* @throws NoResponseException if there was no response from the server. * @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/ */
public boolean isPingSupported(String jid) throws NoResponseException, XMPPErrorException { public boolean isPingSupported(String jid) throws NoResponseException, XMPPErrorException, NotConnectedException {
return ServiceDiscoveryManager.getInstanceFor(connection()).supportsFeature(jid, PingManager.NAMESPACE); return ServiceDiscoveryManager.getInstanceFor(connection()).supportsFeature(jid, PingManager.NAMESPACE);
} }

View file

@ -24,6 +24,7 @@ import java.util.Set;
import java.util.WeakHashMap; import java.util.WeakHashMap;
import org.jivesoftware.smack.SmackException.NoResponseException; import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.ConnectionCreationListener; import org.jivesoftware.smack.ConnectionCreationListener;
import org.jivesoftware.smack.Manager; import org.jivesoftware.smack.Manager;
@ -88,7 +89,7 @@ public class PrivacyListManager extends Manager {
connection.addPacketListener(new PacketListener() { connection.addPacketListener(new PacketListener() {
@Override @Override
public void processPacket(Packet packet) { public void processPacket(Packet packet) throws NotConnectedException {
Privacy privacy = (Privacy) packet; Privacy privacy = (Privacy) packet;
// Notifies the event to the listeners. // Notifies the event to the listeners.
@ -142,8 +143,9 @@ public class PrivacyListManager extends Manager {
* @return a new {@link Privacy} with the data received from the server. * @return a new {@link Privacy} with the data received from the server.
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
*/ */
private Privacy getRequest(Privacy requestPrivacy) throws NoResponseException, XMPPErrorException { private Privacy getRequest(Privacy requestPrivacy) throws NoResponseException, XMPPErrorException, NotConnectedException {
// The request is a get iq type // The request is a get iq type
requestPrivacy.setType(Privacy.Type.GET); requestPrivacy.setType(Privacy.Type.GET);
requestPrivacy.setFrom(this.getUser()); requestPrivacy.setFrom(this.getUser());
@ -161,8 +163,9 @@ public class PrivacyListManager extends Manager {
* @return a new {@link Privacy} with the data received from the server. * @return a new {@link Privacy} with the data received from the server.
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
*/ */
private Packet setRequest(Privacy requestPrivacy) throws NoResponseException, XMPPErrorException { private Packet setRequest(Privacy requestPrivacy) throws NoResponseException, XMPPErrorException, NotConnectedException {
// The request is a get iq type // The request is a get iq type
requestPrivacy.setType(Privacy.Type.SET); requestPrivacy.setType(Privacy.Type.SET);
requestPrivacy.setFrom(this.getUser()); requestPrivacy.setFrom(this.getUser());
@ -176,8 +179,9 @@ public class PrivacyListManager extends Manager {
* @return a Privacy with the list names. * @return a Privacy with the list names.
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
*/ */
private Privacy getPrivacyWithListNames() throws NoResponseException, XMPPErrorException { private Privacy getPrivacyWithListNames() throws NoResponseException, XMPPErrorException, NotConnectedException {
// The request of the list is an empty privacy message // The request of the list is an empty privacy message
Privacy request = new Privacy(); Privacy request = new Privacy();
@ -191,8 +195,9 @@ public class PrivacyListManager extends Manager {
* @return the privacy list of the active list. * @return the privacy list of the active list.
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
*/ */
public PrivacyList getActiveList() throws NoResponseException, XMPPErrorException { public PrivacyList getActiveList() throws NoResponseException, XMPPErrorException, NotConnectedException {
Privacy privacyAnswer = this.getPrivacyWithListNames(); Privacy privacyAnswer = this.getPrivacyWithListNames();
String listName = privacyAnswer.getActiveName(); String listName = privacyAnswer.getActiveName();
boolean isDefaultAndActive = privacyAnswer.getActiveName() != null boolean isDefaultAndActive = privacyAnswer.getActiveName() != null
@ -208,8 +213,9 @@ public class PrivacyListManager extends Manager {
* @return the privacy list of the default list. * @return the privacy list of the default list.
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
*/ */
public PrivacyList getDefaultList() throws NoResponseException, XMPPErrorException { public PrivacyList getDefaultList() throws NoResponseException, XMPPErrorException, NotConnectedException {
Privacy privacyAnswer = this.getPrivacyWithListNames(); Privacy privacyAnswer = this.getPrivacyWithListNames();
String listName = privacyAnswer.getDefaultName(); String listName = privacyAnswer.getDefaultName();
boolean isDefaultAndActive = privacyAnswer.getActiveName() != null boolean isDefaultAndActive = privacyAnswer.getActiveName() != null
@ -226,8 +232,9 @@ public class PrivacyListManager extends Manager {
* @return a list of privacy items under the list listName. * @return a list of privacy items under the list listName.
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
*/ */
private List<PrivacyItem> getPrivacyListItems(String listName) throws NoResponseException, XMPPErrorException { private List<PrivacyItem> getPrivacyListItems(String listName) throws NoResponseException, XMPPErrorException, NotConnectedException {
// The request of the list is an privacy message with an empty list // The request of the list is an privacy message with an empty list
Privacy request = new Privacy(); Privacy request = new Privacy();
request.setPrivacyList(listName, new ArrayList<PrivacyItem>()); request.setPrivacyList(listName, new ArrayList<PrivacyItem>());
@ -245,8 +252,9 @@ public class PrivacyListManager extends Manager {
* @return a privacy list under the list listName. * @return a privacy list under the list listName.
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
*/ */
public PrivacyList getPrivacyList(String listName) throws NoResponseException, XMPPErrorException { public PrivacyList getPrivacyList(String listName) throws NoResponseException, XMPPErrorException, NotConnectedException {
return new PrivacyList(false, false, listName, getPrivacyListItems(listName)); return new PrivacyList(false, false, listName, getPrivacyListItems(listName));
} }
@ -256,8 +264,9 @@ public class PrivacyListManager extends Manager {
* @return an array of privacy lists. * @return an array of privacy lists.
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
*/ */
public PrivacyList[] getPrivacyLists() throws NoResponseException, XMPPErrorException { public PrivacyList[] getPrivacyLists() throws NoResponseException, XMPPErrorException, NotConnectedException {
Privacy privacyAnswer = this.getPrivacyWithListNames(); Privacy privacyAnswer = this.getPrivacyWithListNames();
Set<String> names = privacyAnswer.getPrivacyListNames(); Set<String> names = privacyAnswer.getPrivacyListNames();
PrivacyList[] lists = new PrivacyList[names.size()]; PrivacyList[] lists = new PrivacyList[names.size()];
@ -280,8 +289,9 @@ public class PrivacyListManager extends Manager {
* @param listName the list name to set as the active one. * @param listName the list name to set as the active one.
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
*/ */
public void setActiveListName(String listName) throws NoResponseException, XMPPErrorException { public void setActiveListName(String listName) throws NoResponseException, XMPPErrorException, NotConnectedException {
// The request of the list is an privacy message with an empty list // The request of the list is an privacy message with an empty list
Privacy request = new Privacy(); Privacy request = new Privacy();
request.setActiveName(listName); request.setActiveName(listName);
@ -294,8 +304,9 @@ public class PrivacyListManager extends Manager {
* Client declines the use of active lists. * Client declines the use of active lists.
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
*/ */
public void declineActiveList() throws NoResponseException, XMPPErrorException { public void declineActiveList() throws NoResponseException, XMPPErrorException, NotConnectedException {
// The request of the list is an privacy message with an empty list // The request of the list is an privacy message with an empty list
Privacy request = new Privacy(); Privacy request = new Privacy();
request.setDeclineActiveList(true); request.setDeclineActiveList(true);
@ -310,8 +321,9 @@ public class PrivacyListManager extends Manager {
* @param listName the list name to set as the default one. * @param listName the list name to set as the default one.
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
*/ */
public void setDefaultListName(String listName) throws NoResponseException, XMPPErrorException { public void setDefaultListName(String listName) throws NoResponseException, XMPPErrorException, NotConnectedException {
// The request of the list is an privacy message with an empty list // The request of the list is an privacy message with an empty list
Privacy request = new Privacy(); Privacy request = new Privacy();
request.setDefaultName(listName); request.setDefaultName(listName);
@ -324,8 +336,9 @@ public class PrivacyListManager extends Manager {
* Client declines the use of default lists. * Client declines the use of default lists.
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
*/ */
public void declineDefaultList() throws NoResponseException, XMPPErrorException { public void declineDefaultList() throws NoResponseException, XMPPErrorException, NotConnectedException {
// The request of the list is an privacy message with an empty list // The request of the list is an privacy message with an empty list
Privacy request = new Privacy(); Privacy request = new Privacy();
request.setDeclineDefaultList(true); request.setDeclineDefaultList(true);
@ -341,8 +354,9 @@ public class PrivacyListManager extends Manager {
* @param privacyItems a List with every privacy item in the list. * @param privacyItems a List with every privacy item in the list.
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
*/ */
public void createPrivacyList(String listName, List<PrivacyItem> privacyItems) throws NoResponseException, XMPPErrorException { public void createPrivacyList(String listName, List<PrivacyItem> privacyItems) throws NoResponseException, XMPPErrorException, NotConnectedException {
updatePrivacyList(listName, privacyItems); updatePrivacyList(listName, privacyItems);
} }
@ -355,8 +369,9 @@ public class PrivacyListManager extends Manager {
* @param privacyItems a List with every privacy item in the list. * @param privacyItems a List with every privacy item in the list.
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
*/ */
public void updatePrivacyList(String listName, List<PrivacyItem> privacyItems) throws NoResponseException, XMPPErrorException { public void updatePrivacyList(String listName, List<PrivacyItem> privacyItems) throws NoResponseException, XMPPErrorException, NotConnectedException {
// Build the privacy package to add or update the new list // Build the privacy package to add or update the new list
Privacy request = new Privacy(); Privacy request = new Privacy();
request.setPrivacyList(listName, privacyItems); request.setPrivacyList(listName, privacyItems);
@ -371,8 +386,9 @@ public class PrivacyListManager extends Manager {
* @param listName the list that has changed its content. * @param listName the list that has changed its content.
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
*/ */
public void deletePrivacyList(String listName) throws NoResponseException, XMPPErrorException { public void deletePrivacyList(String listName) throws NoResponseException, XMPPErrorException, NotConnectedException {
// The request of the list is an privacy message with an empty list // The request of the list is an privacy message with an empty list
Privacy request = new Privacy(); Privacy request = new Privacy();
request.setPrivacyList(listName, new ArrayList<PrivacyItem>()); request.setPrivacyList(listName, new ArrayList<PrivacyItem>());
@ -401,8 +417,9 @@ public class PrivacyListManager extends Manager {
* @return true, if the server supports privacy lists, false otherwise. * @return true, if the server supports privacy lists, false otherwise.
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
*/ */
public boolean isSupported() throws NoResponseException, XMPPErrorException{ public boolean isSupported() throws NoResponseException, XMPPErrorException, NotConnectedException{
return ServiceDiscoveryManager.getInstanceFor(connection()).supportsFeature( return ServiceDiscoveryManager.getInstanceFor(connection()).supportsFeature(
connection().getServiceName(), NAMESPACE); connection().getServiceName(), NAMESPACE);
} }

View file

@ -21,6 +21,7 @@ import java.util.Collection;
import java.util.List; import java.util.List;
import org.jivesoftware.smack.SmackException.NoResponseException; import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException.XMPPErrorException; import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.packet.IQ.Type; import org.jivesoftware.smack.packet.IQ.Type;
@ -49,8 +50,9 @@ public class LeafNode extends Node
* @return The item details in {@link DiscoverItems} format * @return The item details in {@link DiscoverItems} format
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException if there was no response from the server. * @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/ */
public DiscoverItems discoverItems() throws NoResponseException, XMPPErrorException public DiscoverItems discoverItems() throws NoResponseException, XMPPErrorException, NotConnectedException
{ {
DiscoverItems items = new DiscoverItems(); DiscoverItems items = new DiscoverItems();
items.setTo(to); items.setTo(to);
@ -64,9 +66,10 @@ public class LeafNode extends Node
* @return List of {@link Item} in the node * @return List of {@link Item} in the node
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException if there was no response from the server. * @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public <T extends Item> List<T> getItems() throws NoResponseException, XMPPErrorException public <T extends Item> List<T> getItems() throws NoResponseException, XMPPErrorException, NotConnectedException
{ {
PubSub request = createPubsubPacket(Type.GET, new GetItemsRequest(getId())); PubSub request = createPubsubPacket(Type.GET, new GetItemsRequest(getId()));
@ -85,9 +88,10 @@ public class LeafNode extends Node
* @return List of {@link Item} in the node * @return List of {@link Item} in the node
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException if there was no response from the server. * @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public <T extends Item> List<T> getItems(String subscriptionId) throws NoResponseException, XMPPErrorException public <T extends Item> List<T> getItems(String subscriptionId) throws NoResponseException, XMPPErrorException, NotConnectedException
{ {
PubSub request = createPubsubPacket(Type.GET, new GetItemsRequest(getId(), subscriptionId)); PubSub request = createPubsubPacket(Type.GET, new GetItemsRequest(getId(), subscriptionId));
@ -108,9 +112,10 @@ public class LeafNode extends Node
* @return The list of {@link Item} with payload * @return The list of {@link Item} with payload
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException if there was no response from the server. * @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public <T extends Item> List<T> getItems(Collection<String> ids) throws NoResponseException, XMPPErrorException public <T extends Item> List<T> getItems(Collection<String> ids) throws NoResponseException, XMPPErrorException, NotConnectedException
{ {
List<Item> itemList = new ArrayList<Item>(ids.size()); List<Item> itemList = new ArrayList<Item>(ids.size());
@ -133,9 +138,10 @@ public class LeafNode extends Node
* @return List of {@link Item} * @return List of {@link Item}
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException if there was no response from the server. * @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public <T extends Item> List<T> getItems(int maxItems) throws NoResponseException, XMPPErrorException public <T extends Item> List<T> getItems(int maxItems) throws NoResponseException, XMPPErrorException, NotConnectedException
{ {
PubSub request = createPubsubPacket(Type.GET, new GetItemsRequest(getId(), maxItems)); PubSub request = createPubsubPacket(Type.GET, new GetItemsRequest(getId(), maxItems));
@ -155,9 +161,10 @@ public class LeafNode extends Node
* @return List of {@link Item} * @return List of {@link Item}
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException if there was no response from the server. * @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public <T extends Item> List<T> getItems(int maxItems, String subscriptionId) throws NoResponseException, XMPPErrorException public <T extends Item> List<T> getItems(int maxItems, String subscriptionId) throws NoResponseException, XMPPErrorException, NotConnectedException
{ {
PubSub request = createPubsubPacket(Type.GET, new GetItemsRequest(getId(), subscriptionId, maxItems)); PubSub request = createPubsubPacket(Type.GET, new GetItemsRequest(getId(), subscriptionId, maxItems));
@ -177,8 +184,9 @@ public class LeafNode extends Node
* packet has been sent. * packet has been sent.
* *
* For synchronous calls use {@link #send() send()}. * For synchronous calls use {@link #send() send()}.
* @throws NotConnectedException
*/ */
public void publish() public void publish() throws NotConnectedException
{ {
PubSub packet = createPubsubPacket(Type.SET, new NodeExtension(PubSubElementType.PUBLISH, getId())); PubSub packet = createPubsubPacket(Type.SET, new NodeExtension(PubSubElementType.PUBLISH, getId()));
@ -199,9 +207,10 @@ public class LeafNode extends Node
* For synchronous calls use {@link #send(Item) send(Item))}. * For synchronous calls use {@link #send(Item) send(Item))}.
* *
* @param item - The item being sent * @param item - The item being sent
* @throws NotConnectedException
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public <T extends Item> void publish(T item) public <T extends Item> void publish(T item) throws NotConnectedException
{ {
Collection<T> items = new ArrayList<T>(1); Collection<T> items = new ArrayList<T>(1);
items.add((T)(item == null ? new Item() : item)); items.add((T)(item == null ? new Item() : item));
@ -220,8 +229,9 @@ public class LeafNode extends Node
* For synchronous calls use {@link #send(Collection) send(Collection))}. * For synchronous calls use {@link #send(Collection) send(Collection))}.
* *
* @param items - The collection of items being sent * @param items - The collection of items being sent
* @throws NotConnectedException
*/ */
public <T extends Item> void publish(Collection<T> items) public <T extends Item> void publish(Collection<T> items) throws NotConnectedException
{ {
PubSub packet = createPubsubPacket(Type.SET, new PublishItem<T>(getId(), items)); PubSub packet = createPubsubPacket(Type.SET, new PublishItem<T>(getId(), items));
@ -241,9 +251,10 @@ public class LeafNode extends Node
* For asynchronous calls, use {@link #publish() publish()}. * For asynchronous calls, use {@link #publish() publish()}.
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
* *
*/ */
public void send() throws NoResponseException, XMPPErrorException public void send() throws NoResponseException, XMPPErrorException, NotConnectedException
{ {
PubSub packet = createPubsubPacket(Type.SET, new NodeExtension(PubSubElementType.PUBLISH, getId())); PubSub packet = createPubsubPacket(Type.SET, new NodeExtension(PubSubElementType.PUBLISH, getId()));
@ -270,10 +281,11 @@ public class LeafNode extends Node
* @param item - The item being sent * @param item - The item being sent
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
* *
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public <T extends Item> void send(T item) throws NoResponseException, XMPPErrorException public <T extends Item> void send(T item) throws NoResponseException, XMPPErrorException, NotConnectedException
{ {
Collection<T> items = new ArrayList<T>(1); Collection<T> items = new ArrayList<T>(1);
items.add((item == null ? (T)new Item() : item)); items.add((item == null ? (T)new Item() : item));
@ -294,9 +306,10 @@ public class LeafNode extends Node
* @param items - The collection of {@link Item} objects being sent * @param items - The collection of {@link Item} objects being sent
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
* *
*/ */
public <T extends Item> void send(Collection<T> items) throws NoResponseException, XMPPErrorException public <T extends Item> void send(Collection<T> items) throws NoResponseException, XMPPErrorException, NotConnectedException
{ {
PubSub packet = createPubsubPacket(Type.SET, new PublishItem<T>(getId(), items)); PubSub packet = createPubsubPacket(Type.SET, new PublishItem<T>(getId(), items));
@ -310,8 +323,9 @@ public class LeafNode extends Node
* sent. * sent.
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException if there was no response from the server. * @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/ */
public void deleteAllItems() throws NoResponseException, XMPPErrorException public void deleteAllItems() throws NoResponseException, XMPPErrorException, NotConnectedException
{ {
PubSub request = createPubsubPacket(Type.SET, new NodeExtension(PubSubElementType.PURGE_OWNER, getId()), PubSubElementType.PURGE_OWNER.getNamespace()); PubSub request = createPubsubPacket(Type.SET, new NodeExtension(PubSubElementType.PURGE_OWNER, getId()), PubSubElementType.PURGE_OWNER.getNamespace());
@ -324,8 +338,9 @@ public class LeafNode extends Node
* @param itemId The id of the item * @param itemId The id of the item
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
*/ */
public void deleteItem(String itemId) throws NoResponseException, XMPPErrorException public void deleteItem(String itemId) throws NoResponseException, XMPPErrorException, NotConnectedException
{ {
Collection<String> items = new ArrayList<String>(1); Collection<String> items = new ArrayList<String>(1);
items.add(itemId); items.add(itemId);
@ -338,8 +353,9 @@ public class LeafNode extends Node
* @param itemIds The list of id's of items to delete * @param itemIds The list of id's of items to delete
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException if there was no response from the server. * @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/ */
public void deleteItem(Collection<String> itemIds) throws NoResponseException, XMPPErrorException public void deleteItem(Collection<String> itemIds) throws NoResponseException, XMPPErrorException, NotConnectedException
{ {
List<Item> items = new ArrayList<Item>(itemIds.size()); List<Item> items = new ArrayList<Item>(itemIds.size());

View file

@ -24,6 +24,7 @@ import java.util.concurrent.ConcurrentHashMap;
import org.jivesoftware.smack.PacketListener; import org.jivesoftware.smack.PacketListener;
import org.jivesoftware.smack.SmackException.NoResponseException; import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException.XMPPErrorException; import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.filter.OrFilter; import org.jivesoftware.smack.filter.OrFilter;
@ -94,8 +95,9 @@ abstract public class Node
* @return the configuration form * @return the configuration form
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
*/ */
public ConfigureForm getNodeConfiguration() throws NoResponseException, XMPPErrorException public ConfigureForm getNodeConfiguration() throws NoResponseException, XMPPErrorException, NotConnectedException
{ {
Packet reply = sendPubsubPacket(Type.GET, new NodeExtension(PubSubElementType.CONFIGURE_OWNER, getId()), PubSubNamespace.OWNER); Packet reply = sendPubsubPacket(Type.GET, new NodeExtension(PubSubElementType.CONFIGURE_OWNER, getId()), PubSubNamespace.OWNER);
return NodeUtils.getFormFromPacket(reply, PubSubElementType.CONFIGURE_OWNER); return NodeUtils.getFormFromPacket(reply, PubSubElementType.CONFIGURE_OWNER);
@ -107,8 +109,9 @@ abstract public class Node
* @param submitForm * @param submitForm
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
*/ */
public void sendConfigurationForm(Form submitForm) throws NoResponseException, XMPPErrorException public void sendConfigurationForm(Form submitForm) throws NoResponseException, XMPPErrorException, NotConnectedException
{ {
PubSub packet = createPubsubPacket(Type.SET, new FormNode(FormNodeType.CONFIGURE_OWNER, getId(), submitForm), PubSubNamespace.OWNER); PubSub packet = createPubsubPacket(Type.SET, new FormNode(FormNodeType.CONFIGURE_OWNER, getId(), submitForm), PubSubNamespace.OWNER);
con.createPacketCollectorAndSend(packet).nextResultOrThrow(); con.createPacketCollectorAndSend(packet).nextResultOrThrow();
@ -120,8 +123,9 @@ abstract public class Node
* @return The discovery information about the node. * @return The discovery information about the node.
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException if there was no response from the server. * @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/ */
public DiscoverInfo discoverInfo() throws NoResponseException, XMPPErrorException public DiscoverInfo discoverInfo() throws NoResponseException, XMPPErrorException, NotConnectedException
{ {
DiscoverInfo info = new DiscoverInfo(); DiscoverInfo info = new DiscoverInfo();
info.setTo(to); info.setTo(to);
@ -135,9 +139,10 @@ abstract public class Node
* @return List of {@link Subscription} * @return List of {@link Subscription}
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
* *
*/ */
public List<Subscription> getSubscriptions() throws NoResponseException, XMPPErrorException public List<Subscription> getSubscriptions() throws NoResponseException, XMPPErrorException, NotConnectedException
{ {
PubSub reply = (PubSub)sendPubsubPacket(Type.GET, new NodeExtension(PubSubElementType.SUBSCRIPTIONS, getId())); PubSub reply = (PubSub)sendPubsubPacket(Type.GET, new NodeExtension(PubSubElementType.SUBSCRIPTIONS, getId()));
SubscriptionsExtension subElem = (SubscriptionsExtension)reply.getExtension(PubSubElementType.SUBSCRIPTIONS); SubscriptionsExtension subElem = (SubscriptionsExtension)reply.getExtension(PubSubElementType.SUBSCRIPTIONS);
@ -159,8 +164,9 @@ abstract public class Node
* @return The subscription * @return The subscription
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
*/ */
public Subscription subscribe(String jid) throws NoResponseException, XMPPErrorException public Subscription subscribe(String jid) throws NoResponseException, XMPPErrorException, NotConnectedException
{ {
PubSub reply = (PubSub)sendPubsubPacket(Type.SET, new SubscribeExtension(jid, getId())); PubSub reply = (PubSub)sendPubsubPacket(Type.SET, new SubscribeExtension(jid, getId()));
return (Subscription)reply.getExtension(PubSubElementType.SUBSCRIPTION); return (Subscription)reply.getExtension(PubSubElementType.SUBSCRIPTION);
@ -182,8 +188,9 @@ abstract public class Node
* @return The subscription * @return The subscription
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
*/ */
public Subscription subscribe(String jid, SubscribeForm subForm) throws NoResponseException, XMPPErrorException public Subscription subscribe(String jid, SubscribeForm subForm) throws NoResponseException, XMPPErrorException, NotConnectedException
{ {
PubSub request = createPubsubPacket(Type.SET, new SubscribeExtension(jid, getId())); PubSub request = createPubsubPacket(Type.SET, new SubscribeExtension(jid, getId()));
request.addExtension(new FormNode(FormNodeType.OPTIONS, subForm)); request.addExtension(new FormNode(FormNodeType.OPTIONS, subForm));
@ -199,9 +206,10 @@ abstract public class Node
* @param jid The JID used to subscribe to the node * @param jid The JID used to subscribe to the node
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
* *
*/ */
public void unsubscribe(String jid) throws NoResponseException, XMPPErrorException public void unsubscribe(String jid) throws NoResponseException, XMPPErrorException, NotConnectedException
{ {
unsubscribe(jid, null); unsubscribe(jid, null);
} }
@ -213,8 +221,9 @@ abstract public class Node
* @param subscriptionId The id of the subscription being removed * @param subscriptionId The id of the subscription being removed
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
*/ */
public void unsubscribe(String jid, String subscriptionId) throws NoResponseException, XMPPErrorException public void unsubscribe(String jid, String subscriptionId) throws NoResponseException, XMPPErrorException, NotConnectedException
{ {
sendPubsubPacket(Type.SET, new UnsubscribeExtension(jid, getId(), subscriptionId)); sendPubsubPacket(Type.SET, new UnsubscribeExtension(jid, getId(), subscriptionId));
} }
@ -226,8 +235,9 @@ abstract public class Node
* @return A subscription options form * @return A subscription options form
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
*/ */
public SubscribeForm getSubscriptionOptions(String jid) throws NoResponseException, XMPPErrorException public SubscribeForm getSubscriptionOptions(String jid) throws NoResponseException, XMPPErrorException, NotConnectedException
{ {
return getSubscriptionOptions(jid, null); return getSubscriptionOptions(jid, null);
} }
@ -242,9 +252,10 @@ abstract public class Node
* @return The subscription option form * @return The subscription option form
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
* *
*/ */
public SubscribeForm getSubscriptionOptions(String jid, String subscriptionId) throws NoResponseException, XMPPErrorException public SubscribeForm getSubscriptionOptions(String jid, String subscriptionId) throws NoResponseException, XMPPErrorException, NotConnectedException
{ {
PubSub packet = (PubSub)sendPubsubPacket(Type.GET, new OptionsExtension(jid, getId(), subscriptionId)); PubSub packet = (PubSub)sendPubsubPacket(Type.GET, new OptionsExtension(jid, getId(), subscriptionId));
FormNode ext = (FormNode)packet.getExtension(PubSubElementType.OPTIONS); FormNode ext = (FormNode)packet.getExtension(PubSubElementType.OPTIONS);
@ -349,12 +360,12 @@ abstract public class Node
return PubSubManager.createPubsubPacket(to, type, ext, ns); return PubSubManager.createPubsubPacket(to, type, ext, ns);
} }
protected Packet sendPubsubPacket(Type type, NodeExtension ext) throws NoResponseException, XMPPErrorException protected Packet sendPubsubPacket(Type type, NodeExtension ext) throws NoResponseException, XMPPErrorException, NotConnectedException
{ {
return PubSubManager.sendPubsubPacket(con, to, type, ext); return PubSubManager.sendPubsubPacket(con, to, type, ext);
} }
protected Packet sendPubsubPacket(Type type, NodeExtension ext, PubSubNamespace ns) throws NoResponseException, XMPPErrorException protected Packet sendPubsubPacket(Type type, NodeExtension ext, PubSubNamespace ns) throws NoResponseException, XMPPErrorException, NotConnectedException
{ {
return PubSubManager.sendPubsubPacket(con, to, type, ext, ns); return PubSubManager.sendPubsubPacket(con, to, type, ext, ns);
} }

View file

@ -21,6 +21,7 @@ import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import org.jivesoftware.smack.SmackException.NoResponseException; import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException.XMPPErrorException; import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.packet.IQ.Type; import org.jivesoftware.smack.packet.IQ.Type;
@ -81,8 +82,9 @@ final public class PubSubManager
* @return The node that was created * @return The node that was created
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
*/ */
public LeafNode createNode() throws NoResponseException, XMPPErrorException public LeafNode createNode() throws NoResponseException, XMPPErrorException, NotConnectedException
{ {
PubSub reply = (PubSub)sendPubsubPacket(Type.SET, new NodeExtension(PubSubElementType.CREATE)); PubSub reply = (PubSub)sendPubsubPacket(Type.SET, new NodeExtension(PubSubElementType.CREATE));
NodeExtension elem = (NodeExtension)reply.getExtension("create", PubSubNamespace.BASIC.getXmlns()); NodeExtension elem = (NodeExtension)reply.getExtension("create", PubSubNamespace.BASIC.getXmlns());
@ -102,8 +104,9 @@ final public class PubSubManager
* @return The node that was created * @return The node that was created
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
*/ */
public LeafNode createNode(String id) throws NoResponseException, XMPPErrorException public LeafNode createNode(String id) throws NoResponseException, XMPPErrorException, NotConnectedException
{ {
return (LeafNode)createNode(id, null); return (LeafNode)createNode(id, null);
} }
@ -119,8 +122,9 @@ final public class PubSubManager
* @return The node that was created * @return The node that was created
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
*/ */
public Node createNode(String name, Form config) throws NoResponseException, XMPPErrorException public Node createNode(String name, Form config) throws NoResponseException, XMPPErrorException, NotConnectedException
{ {
PubSub request = createPubsubPacket(to, Type.SET, new NodeExtension(PubSubElementType.CREATE, name)); PubSub request = createPubsubPacket(to, Type.SET, new NodeExtension(PubSubElementType.CREATE, name));
boolean isLeafNode = true; boolean isLeafNode = true;
@ -152,9 +156,10 @@ final public class PubSubManager
* @return the node * @return the node
* @throws XMPPErrorException The node does not exist * @throws XMPPErrorException The node does not exist
* @throws NoResponseException if there was no response from the server. * @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public <T extends Node> T getNode(String id) throws NoResponseException, XMPPErrorException public <T extends Node> T getNode(String id) throws NoResponseException, XMPPErrorException, NotConnectedException
{ {
Node node = nodeMap.get(id); Node node = nodeMap.get(id);
@ -189,8 +194,9 @@ final public class PubSubManager
* @return {@link DiscoverItems} representing the existing nodes * @return {@link DiscoverItems} representing the existing nodes
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException if there was no response from the server. * @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/ */
public DiscoverItems discoverNodes(String nodeId) throws NoResponseException, XMPPErrorException public DiscoverItems discoverNodes(String nodeId) throws NoResponseException, XMPPErrorException, NotConnectedException
{ {
DiscoverItems items = new DiscoverItems(); DiscoverItems items = new DiscoverItems();
@ -207,8 +213,9 @@ final public class PubSubManager
* @return List of exceptions * @return List of exceptions
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
*/ */
public List<Subscription> getSubscriptions() throws NoResponseException, XMPPErrorException public List<Subscription> getSubscriptions() throws NoResponseException, XMPPErrorException, NotConnectedException
{ {
Packet reply = sendPubsubPacket(Type.GET, new NodeExtension(PubSubElementType.SUBSCRIPTIONS)); Packet reply = sendPubsubPacket(Type.GET, new NodeExtension(PubSubElementType.SUBSCRIPTIONS));
SubscriptionsExtension subElem = (SubscriptionsExtension)reply.getExtension(PubSubElementType.SUBSCRIPTIONS.getElementName(), PubSubElementType.SUBSCRIPTIONS.getNamespace().getXmlns()); SubscriptionsExtension subElem = (SubscriptionsExtension)reply.getExtension(PubSubElementType.SUBSCRIPTIONS.getElementName(), PubSubElementType.SUBSCRIPTIONS.getNamespace().getXmlns());
@ -221,9 +228,10 @@ final public class PubSubManager
* @return List of affiliations * @return List of affiliations
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
* *
*/ */
public List<Affiliation> getAffiliations() throws NoResponseException, XMPPErrorException public List<Affiliation> getAffiliations() throws NoResponseException, XMPPErrorException, NotConnectedException
{ {
PubSub reply = (PubSub)sendPubsubPacket(Type.GET, new NodeExtension(PubSubElementType.AFFILIATIONS)); PubSub reply = (PubSub)sendPubsubPacket(Type.GET, new NodeExtension(PubSubElementType.AFFILIATIONS));
AffiliationsExtension listElem = (AffiliationsExtension)reply.getExtension(PubSubElementType.AFFILIATIONS); AffiliationsExtension listElem = (AffiliationsExtension)reply.getExtension(PubSubElementType.AFFILIATIONS);
@ -236,8 +244,9 @@ final public class PubSubManager
* @param nodeId * @param nodeId
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
*/ */
public void deleteNode(String nodeId) throws NoResponseException, XMPPErrorException public void deleteNode(String nodeId) throws NoResponseException, XMPPErrorException, NotConnectedException
{ {
sendPubsubPacket(Type.SET, new NodeExtension(PubSubElementType.DELETE, nodeId), PubSubElementType.DELETE.getNamespace()); sendPubsubPacket(Type.SET, new NodeExtension(PubSubElementType.DELETE, nodeId), PubSubElementType.DELETE.getNamespace());
nodeMap.remove(nodeId); nodeMap.remove(nodeId);
@ -249,8 +258,9 @@ final public class PubSubManager
* @return configuration form containing the default settings. * @return configuration form containing the default settings.
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
*/ */
public ConfigureForm getDefaultConfiguration() throws NoResponseException, XMPPErrorException public ConfigureForm getDefaultConfiguration() throws NoResponseException, XMPPErrorException, NotConnectedException
{ {
// Errors will cause exceptions in getReply, so it only returns // Errors will cause exceptions in getReply, so it only returns
// on success. // on success.
@ -265,19 +275,20 @@ final public class PubSubManager
* @return The supported features * @return The supported features
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
*/ */
public DiscoverInfo getSupportedFeatures() throws NoResponseException, XMPPErrorException public DiscoverInfo getSupportedFeatures() throws NoResponseException, XMPPErrorException, NotConnectedException
{ {
ServiceDiscoveryManager mgr = ServiceDiscoveryManager.getInstanceFor(con); ServiceDiscoveryManager mgr = ServiceDiscoveryManager.getInstanceFor(con);
return mgr.discoverInfo(to); return mgr.discoverInfo(to);
} }
private Packet sendPubsubPacket(Type type, PacketExtension ext, PubSubNamespace ns) throws NoResponseException, XMPPErrorException private Packet sendPubsubPacket(Type type, PacketExtension ext, PubSubNamespace ns) throws NoResponseException, XMPPErrorException, NotConnectedException
{ {
return sendPubsubPacket(con, to, type, ext, ns); return sendPubsubPacket(con, to, type, ext, ns);
} }
private Packet sendPubsubPacket(Type type, PacketExtension ext) throws NoResponseException, XMPPErrorException private Packet sendPubsubPacket(Type type, PacketExtension ext) throws NoResponseException, XMPPErrorException, NotConnectedException
{ {
return sendPubsubPacket(type, ext, null); return sendPubsubPacket(type, ext, null);
} }
@ -302,22 +313,22 @@ final public class PubSubManager
return request; return request;
} }
static Packet sendPubsubPacket(XMPPConnection con, String to, Type type, PacketExtension ext) throws NoResponseException, XMPPErrorException static Packet sendPubsubPacket(XMPPConnection con, String to, Type type, PacketExtension ext) throws NoResponseException, XMPPErrorException, NotConnectedException
{ {
return sendPubsubPacket(con, to, type, ext, null); return sendPubsubPacket(con, to, type, ext, null);
} }
static Packet sendPubsubPacket(XMPPConnection con, String to, Type type, PacketExtension ext, PubSubNamespace ns) throws NoResponseException, XMPPErrorException static Packet sendPubsubPacket(XMPPConnection con, String to, Type type, PacketExtension ext, PubSubNamespace ns) throws NoResponseException, XMPPErrorException, NotConnectedException
{ {
return con.createPacketCollectorAndSend(createPubsubPacket(to, type, ext, ns)).nextResultOrThrow(); return con.createPacketCollectorAndSend(createPubsubPacket(to, type, ext, ns)).nextResultOrThrow();
} }
static Packet sendPubsubPacket(XMPPConnection con, String to, Type type, PubSub packet) throws NoResponseException, XMPPErrorException static Packet sendPubsubPacket(XMPPConnection con, String to, Type type, PubSub packet) throws NoResponseException, XMPPErrorException, NotConnectedException
{ {
return sendPubsubPacket(con, to, type, packet, null); return sendPubsubPacket(con, to, type, packet, null);
} }
static Packet sendPubsubPacket(XMPPConnection con, String to, Type type, PubSub packet, PubSubNamespace ns) throws NoResponseException, XMPPErrorException static Packet sendPubsubPacket(XMPPConnection con, String to, Type type, PubSub packet, PubSubNamespace ns) throws NoResponseException, XMPPErrorException, NotConnectedException
{ {
return con.createPacketCollectorAndSend(packet).nextResultOrThrow(); return con.createPacketCollectorAndSend(packet).nextResultOrThrow();
} }

View file

@ -23,6 +23,7 @@ import java.util.Set;
import java.util.WeakHashMap; import java.util.WeakHashMap;
import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.ConnectionCreationListener; import org.jivesoftware.smack.ConnectionCreationListener;
import org.jivesoftware.smack.Manager; import org.jivesoftware.smack.Manager;
@ -99,7 +100,7 @@ public class DeliveryReceiptManager extends Manager implements PacketListener {
// handle incoming receipts and receipt requests // handle incoming receipts and receipt requests
@Override @Override
public void processPacket(Packet packet) { public void processPacket(Packet packet) throws NotConnectedException {
DeliveryReceipt dr = (DeliveryReceipt)packet.getExtension( DeliveryReceipt dr = (DeliveryReceipt)packet.getExtension(
DeliveryReceipt.ELEMENT, DeliveryReceipt.NAMESPACE); DeliveryReceipt.ELEMENT, DeliveryReceipt.NAMESPACE);
if (dr != null) { if (dr != null) {

View file

@ -17,6 +17,7 @@
package org.jivesoftware.smackx.search; package org.jivesoftware.smackx.search;
import org.jivesoftware.smack.SmackException.NoResponseException; import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException.XMPPErrorException; import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.IQ;
@ -61,8 +62,9 @@ public class UserSearch extends IQ {
* @return the search form received by the server. * @return the search form received by the server.
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
*/ */
public Form getSearchForm(XMPPConnection con, String searchService) throws NoResponseException, XMPPErrorException { public Form getSearchForm(XMPPConnection con, String searchService) throws NoResponseException, XMPPErrorException, NotConnectedException {
UserSearch search = new UserSearch(); UserSearch search = new UserSearch();
search.setType(IQ.Type.GET); search.setType(IQ.Type.GET);
search.setTo(searchService); search.setTo(searchService);
@ -80,8 +82,9 @@ public class UserSearch extends IQ {
* @return ReportedData the data found from the query. * @return ReportedData the data found from the query.
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
*/ */
public ReportedData sendSearchForm(XMPPConnection con, Form searchForm, String searchService) throws NoResponseException, XMPPErrorException { public ReportedData sendSearchForm(XMPPConnection con, Form searchForm, String searchService) throws NoResponseException, XMPPErrorException, NotConnectedException {
UserSearch search = new UserSearch(); UserSearch search = new UserSearch();
search.setType(IQ.Type.SET); search.setType(IQ.Type.SET);
search.setTo(searchService); search.setTo(searchService);
@ -100,8 +103,9 @@ public class UserSearch extends IQ {
* @return ReportedData the data found from the query. * @return ReportedData the data found from the query.
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
*/ */
public ReportedData sendSimpleSearchForm(XMPPConnection con, Form searchForm, String searchService) throws NoResponseException, XMPPErrorException { public ReportedData sendSimpleSearchForm(XMPPConnection con, Form searchForm, String searchService) throws NoResponseException, XMPPErrorException, NotConnectedException {
SimpleUserSearch search = new SimpleUserSearch(); SimpleUserSearch search = new SimpleUserSearch();
search.setForm(searchForm); search.setForm(searchForm);
search.setType(IQ.Type.SET); search.setType(IQ.Type.SET);

View file

@ -17,6 +17,7 @@
package org.jivesoftware.smackx.search; package org.jivesoftware.smackx.search;
import org.jivesoftware.smack.SmackException.NoResponseException; import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException; import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.XMPPException.XMPPErrorException; import org.jivesoftware.smack.XMPPException.XMPPErrorException;
@ -70,8 +71,9 @@ public class UserSearchManager {
* @return the form to fill out to perform a search. * @return the form to fill out to perform a search.
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
*/ */
public Form getSearchForm(String searchService) throws NoResponseException, XMPPErrorException { public Form getSearchForm(String searchService) throws NoResponseException, XMPPErrorException, NotConnectedException {
return userSearch.getSearchForm(con, searchService); return userSearch.getSearchForm(con, searchService);
} }
@ -84,8 +86,9 @@ public class UserSearchManager {
* @return the ReportedData returned by the server. * @return the ReportedData returned by the server.
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
*/ */
public ReportedData getSearchResults(Form searchForm, String searchService) throws NoResponseException, XMPPErrorException { public ReportedData getSearchResults(Form searchForm, String searchService) throws NoResponseException, XMPPErrorException, NotConnectedException {
return userSearch.sendSearchForm(con, searchForm, searchService); return userSearch.sendSearchForm(con, searchForm, searchService);
} }
@ -96,8 +99,9 @@ public class UserSearchManager {
* @return a Collection of search services found on the server. * @return a Collection of search services found on the server.
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
*/ */
public Collection<String> getSearchServices() throws NoResponseException, XMPPErrorException { public Collection<String> getSearchServices() throws NoResponseException, XMPPErrorException, NotConnectedException {
final List<String> searchServices = new ArrayList<String>(); final List<String> searchServices = new ArrayList<String>();
ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(con); ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(con);
DiscoverItems items = discoManager.discoverItems(con.getServiceName()); DiscoverItems items = discoManager.discoverItems(con.getServiceName());

View file

@ -17,6 +17,7 @@
package org.jivesoftware.smackx.sharedgroups; package org.jivesoftware.smackx.sharedgroups;
import org.jivesoftware.smack.SmackException.NoResponseException; import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException.XMPPErrorException; import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.IQ;
@ -42,8 +43,9 @@ public class SharedGroupManager {
* @return collection with the shared groups' name of the logged user. * @return collection with the shared groups' name of the logged user.
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
*/ */
public static List<String> getSharedGroups(XMPPConnection connection) throws NoResponseException, XMPPErrorException { public static List<String> getSharedGroups(XMPPConnection connection) throws NoResponseException, XMPPErrorException, NotConnectedException {
// Discover the shared groups of the logged user // Discover the shared groups of the logged user
SharedGroupsInfo info = new SharedGroupsInfo(); SharedGroupsInfo info = new SharedGroupsInfo();
info.setType(IQ.Type.GET); info.setType(IQ.Type.GET);

View file

@ -20,6 +20,7 @@ import java.util.Map;
import java.util.WeakHashMap; import java.util.WeakHashMap;
import org.jivesoftware.smack.SmackException.NoResponseException; import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.ConnectionCreationListener; import org.jivesoftware.smack.ConnectionCreationListener;
import org.jivesoftware.smack.Manager; import org.jivesoftware.smack.Manager;
@ -73,7 +74,7 @@ public class EntityTimeManager extends Manager {
connection.addPacketListener(new PacketListener() { connection.addPacketListener(new PacketListener() {
@Override @Override
public void processPacket(Packet packet) { public void processPacket(Packet packet) throws NotConnectedException {
if (!enabled) if (!enabled)
return; return;
connection().sendPacket(Time.createResponse(packet)); connection().sendPacket(Time.createResponse(packet));
@ -97,11 +98,11 @@ public class EntityTimeManager extends Manager {
enabled = false; enabled = false;
} }
public boolean isTimeSupported(String jid) throws NoResponseException, XMPPErrorException { public boolean isTimeSupported(String jid) throws NoResponseException, XMPPErrorException, NotConnectedException {
return ServiceDiscoveryManager.getInstanceFor(connection()).supportsFeature(jid, Time.NAMESPACE); return ServiceDiscoveryManager.getInstanceFor(connection()).supportsFeature(jid, Time.NAMESPACE);
} }
public Time getTime(String jid) throws NoResponseException, XMPPErrorException { public Time getTime(String jid) throws NoResponseException, XMPPErrorException, NotConnectedException {
if (!isTimeSupported(jid)) if (!isTimeSupported(jid))
return null; return null;

View file

@ -18,6 +18,7 @@ package org.jivesoftware.smackx.vcardtemp;
import org.jivesoftware.smack.ConnectionCreationListener; import org.jivesoftware.smack.ConnectionCreationListener;
import org.jivesoftware.smack.SmackException.NoResponseException; import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException.XMPPErrorException; import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager; import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
@ -43,8 +44,9 @@ public class VCardManager {
* @return true if the given entity understands the vCard-XML format and exchange. * @return true if the given entity understands the vCard-XML format and exchange.
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
*/ */
public static boolean isSupported(String jid, XMPPConnection connection) throws NoResponseException, XMPPErrorException { public static boolean isSupported(String jid, XMPPConnection connection) throws NoResponseException, XMPPErrorException, NotConnectedException {
return ServiceDiscoveryManager.getInstanceFor(connection).supportsFeature(jid, NAMESPACE); return ServiceDiscoveryManager.getInstanceFor(connection).supportsFeature(jid, NAMESPACE);
} }
} }

View file

@ -34,6 +34,7 @@ import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import org.jivesoftware.smack.SmackException.NoResponseException; import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException.XMPPErrorException; import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.IQ;
@ -518,8 +519,9 @@ public class VCard extends IQ {
* @param connection the XMPPConnection to use. * @param connection the XMPPConnection to use.
* @throws XMPPErrorException thrown if there was an issue setting the VCard in the server. * @throws XMPPErrorException thrown if there was an issue setting the VCard in the server.
* @throws NoResponseException if there was no response from the server. * @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/ */
public void save(XMPPConnection connection) throws NoResponseException, XMPPErrorException { public void save(XMPPConnection connection) throws NoResponseException, XMPPErrorException, NotConnectedException {
checkAuthenticated(connection, true); checkAuthenticated(connection, true);
setType(IQ.Type.SET); setType(IQ.Type.SET);
@ -532,8 +534,9 @@ public class VCard extends IQ {
* and not anonymous. * and not anonymous.
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
*/ */
public void load(XMPPConnection connection) throws NoResponseException, XMPPErrorException { public void load(XMPPConnection connection) throws NoResponseException, XMPPErrorException, NotConnectedException {
checkAuthenticated(connection, true); checkAuthenticated(connection, true);
setFrom(connection.getUser()); setFrom(connection.getUser());
@ -544,15 +547,16 @@ public class VCard extends IQ {
* Load VCard information for a given user. XMPPConnection should be authenticated and not anonymous. * Load VCard information for a given user. XMPPConnection should be authenticated and not anonymous.
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException if there was no response from the server. * @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/ */
public void load(XMPPConnection connection, String user) throws NoResponseException, XMPPErrorException { public void load(XMPPConnection connection, String user) throws NoResponseException, XMPPErrorException, NotConnectedException {
checkAuthenticated(connection, false); checkAuthenticated(connection, false);
setTo(user); setTo(user);
doLoad(connection, user); doLoad(connection, user);
} }
private void doLoad(XMPPConnection connection, String user) throws NoResponseException, XMPPErrorException { private void doLoad(XMPPConnection connection, String user) throws NoResponseException, XMPPErrorException, NotConnectedException {
setType(Type.GET); setType(Type.GET);
VCard result = (VCard) connection.createPacketCollectorAndSend(this).nextResultOrThrow(); VCard result = (VCard) connection.createPacketCollectorAndSend(this).nextResultOrThrow();
copyFieldsFrom(result); copyFieldsFrom(result);

View file

@ -17,6 +17,8 @@
package org.jivesoftware.smackx.xevent; package org.jivesoftware.smackx.xevent;
import org.jivesoftware.smack.SmackException.NotConnectedException;
/** /**
* *
* Default implementation of the MessageEventRequestListener interface.<p> * Default implementation of the MessageEventRequestListener interface.<p>
@ -29,7 +31,7 @@ package org.jivesoftware.smackx.xevent;
public class DefaultMessageEventRequestListener implements MessageEventRequestListener { public class DefaultMessageEventRequestListener implements MessageEventRequestListener {
public void deliveredNotificationRequested(String from, String packetID, public void deliveredNotificationRequested(String from, String packetID,
MessageEventManager messageEventManager) MessageEventManager messageEventManager) throws NotConnectedException
{ {
// Send to the message's sender that the message has been delivered // Send to the message's sender that the message has been delivered
messageEventManager.sendDeliveredNotification(from, packetID); messageEventManager.sendDeliveredNotification(from, packetID);

View file

@ -25,6 +25,7 @@ import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import org.jivesoftware.smack.PacketListener; import org.jivesoftware.smack.PacketListener;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.filter.PacketExtensionFilter; import org.jivesoftware.smack.filter.PacketExtensionFilter;
import org.jivesoftware.smack.filter.PacketFilter; import org.jivesoftware.smack.filter.PacketFilter;
@ -221,8 +222,9 @@ public class MessageEventManager {
* *
* @param to the recipient of the notification. * @param to the recipient of the notification.
* @param packetID the id of the message to send. * @param packetID the id of the message to send.
* @throws NotConnectedException
*/ */
public void sendDeliveredNotification(String to, String packetID) { public void sendDeliveredNotification(String to, String packetID) throws NotConnectedException {
// Create the message to send // Create the message to send
Message msg = new Message(to); Message msg = new Message(to);
// Create a MessageEvent Package and add it to the message // Create a MessageEvent Package and add it to the message
@ -239,8 +241,9 @@ public class MessageEventManager {
* *
* @param to the recipient of the notification. * @param to the recipient of the notification.
* @param packetID the id of the message to send. * @param packetID the id of the message to send.
* @throws NotConnectedException
*/ */
public void sendDisplayedNotification(String to, String packetID) { public void sendDisplayedNotification(String to, String packetID) throws NotConnectedException {
// Create the message to send // Create the message to send
Message msg = new Message(to); Message msg = new Message(to);
// Create a MessageEvent Package and add it to the message // Create a MessageEvent Package and add it to the message
@ -257,8 +260,9 @@ public class MessageEventManager {
* *
* @param to the recipient of the notification. * @param to the recipient of the notification.
* @param packetID the id of the message to send. * @param packetID the id of the message to send.
* @throws NotConnectedException
*/ */
public void sendComposingNotification(String to, String packetID) { public void sendComposingNotification(String to, String packetID) throws NotConnectedException {
// Create the message to send // Create the message to send
Message msg = new Message(to); Message msg = new Message(to);
// Create a MessageEvent Package and add it to the message // Create a MessageEvent Package and add it to the message
@ -275,8 +279,9 @@ public class MessageEventManager {
* *
* @param to the recipient of the notification. * @param to the recipient of the notification.
* @param packetID the id of the message to send. * @param packetID the id of the message to send.
* @throws NotConnectedException
*/ */
public void sendCancelledNotification(String to, String packetID) { public void sendCancelledNotification(String to, String packetID) throws NotConnectedException {
// Create the message to send // Create the message to send
Message msg = new Message(to); Message msg = new Message(to);
// Create a MessageEvent Package and add it to the message // Create a MessageEvent Package and add it to the message

View file

@ -17,6 +17,8 @@
package org.jivesoftware.smackx.xevent; package org.jivesoftware.smackx.xevent;
import org.jivesoftware.smack.SmackException.NotConnectedException;
/** /**
* *
* A listener that is fired anytime a message event request is received. * A listener that is fired anytime a message event request is received.
@ -45,9 +47,10 @@ public interface MessageEventRequestListener {
* @param from the user that sent the notification. * @param from the user that sent the notification.
* @param packetID the id of the message that was sent. * @param packetID the id of the message that was sent.
* @param messageEventManager the messageEventManager that fired the listener. * @param messageEventManager the messageEventManager that fired the listener.
* @throws NotConnectedException
*/ */
public void deliveredNotificationRequested(String from, String packetID, public void deliveredNotificationRequested(String from, String packetID,
MessageEventManager messageEventManager); MessageEventManager messageEventManager) throws NotConnectedException;
/** /**
* Called when a request for message displayed notification is received. * Called when a request for message displayed notification is received.

View file

@ -19,6 +19,7 @@ package org.jivesoftware.smackx.xhtmlim;
import org.jivesoftware.smack.ConnectionCreationListener; import org.jivesoftware.smack.ConnectionCreationListener;
import org.jivesoftware.smack.SmackException.NoResponseException; import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException.XMPPErrorException; import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.packet.Message; import org.jivesoftware.smack.packet.Message;
@ -128,9 +129,10 @@ public class XHTMLManager {
* @return a boolean indicating whether the specified user handles XHTML messages * @return a boolean indicating whether the specified user handles XHTML messages
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
*/ */
public static boolean isServiceEnabled(XMPPConnection connection, String userID) public static boolean isServiceEnabled(XMPPConnection connection, String userID)
throws NoResponseException, XMPPErrorException { throws NoResponseException, XMPPErrorException, NotConnectedException {
return ServiceDiscoveryManager.getInstanceFor(connection).supportsFeature(userID, namespace); return ServiceDiscoveryManager.getInstanceFor(connection).supportsFeature(userID, namespace);
} }
} }

View file

@ -19,6 +19,7 @@ package org.jivesoftware.smackx.bytestreams.ibb;
import static org.junit.Assert.*; import static org.junit.Assert.*;
import static org.mockito.Mockito.*; import static org.mockito.Mockito.*;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.XMPPError; import org.jivesoftware.smack.packet.XMPPError;
@ -66,9 +67,10 @@ public class InBandBytestreamRequestTest {
/** /**
* Test reject() method. * Test reject() method.
* @throws NotConnectedException
*/ */
@Test @Test
public void shouldReplyWithErrorIfRequestIsRejected() { public void shouldReplyWithErrorIfRequestIsRejected() throws NotConnectedException {
InBandBytestreamRequest ibbRequest = new InBandBytestreamRequest( InBandBytestreamRequest ibbRequest = new InBandBytestreamRequest(
byteStreamManager, initBytestream); byteStreamManager, initBytestream);

View file

@ -20,6 +20,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPException; import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smackx.jingle.listeners.JingleListener; import org.jivesoftware.smackx.jingle.listeners.JingleListener;
@ -254,7 +255,7 @@ public class ContentNegotiator extends JingleNegotiator {
return result; return result;
} }
public void triggerContentEstablished() { public void triggerContentEstablished() throws NotConnectedException {
PayloadType bestCommonAudioPt = getMediaNegotiator().getBestCommonAudioPt(); PayloadType bestCommonAudioPt = getMediaNegotiator().getBestCommonAudioPt();
TransportCandidate bestRemoteCandidate = getTransportNegotiator().getBestRemoteCandidate(); TransportCandidate bestRemoteCandidate = getTransportNegotiator().getBestRemoteCandidate();
@ -266,8 +267,9 @@ public class ContentNegotiator extends JingleNegotiator {
/** /**
* Trigger a session established event. * Trigger a session established event.
* @throws NotConnectedException
*/ */
private void triggerContentEstablished(PayloadType pt, TransportCandidate rc, TransportCandidate lc) { private void triggerContentEstablished(PayloadType pt, TransportCandidate rc, TransportCandidate lc) throws NotConnectedException {
// Let the session know that we've established a content/media segment. // Let the session know that we've established a content/media segment.
JingleSession session = getSession(); JingleSession session = getSession();

View file

@ -235,7 +235,7 @@ public class JingleManager implements JingleSessionListener {
if (aux != null) if (aux != null)
try { try {
aux.terminate(); aux.terminate();
} catch (XMPPException e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
@ -478,7 +478,7 @@ public class JingleManager implements JingleSessionListener {
for (JingleSession jingleSession : sessions) for (JingleSession jingleSession : sessions)
try { try {
jingleSession.terminate(); jingleSession.terminate();
} catch (XMPPException e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }

View file

@ -27,6 +27,7 @@ import org.jivesoftware.smack.AbstractConnectionListener;
import org.jivesoftware.smack.ConnectionListener; import org.jivesoftware.smack.ConnectionListener;
import org.jivesoftware.smack.PacketListener; import org.jivesoftware.smack.PacketListener;
import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException; import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.filter.PacketFilter; import org.jivesoftware.smack.filter.PacketFilter;
@ -397,7 +398,7 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList
// Send section // Send section
// ---------------------------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------------------------
public void sendPacket(IQ iq) { public void sendPacket(IQ iq) throws NotConnectedException {
if (iq instanceof Jingle) { if (iq instanceof Jingle) {
@ -415,8 +416,9 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList
* *
* @param jout * @param jout
* the Jingle packet we want to complete and send * the Jingle packet we want to complete and send
* @throws NotConnectedException
*/ */
public Jingle sendFormattedJingle(Jingle jout) { public Jingle sendFormattedJingle(Jingle jout) throws NotConnectedException {
return sendFormattedJingle(null, jout); return sendFormattedJingle(null, jout);
} }
@ -429,8 +431,9 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList
* The Jingle packet we are responing to * The Jingle packet we are responing to
* @param jout * @param jout
* the Jingle packet we want to complete and send * the Jingle packet we want to complete and send
* @throws NotConnectedException
*/ */
public Jingle sendFormattedJingle(IQ iq, Jingle jout) { public Jingle sendFormattedJingle(IQ iq, Jingle jout) throws NotConnectedException {
if (jout != null) { if (jout != null) {
if (jout.getInitiator() == null) { if (jout.getInitiator() == null) {
jout.setInitiator(getInitiator()); jout.setInitiator(getInitiator());
@ -798,7 +801,7 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList
public void mediaClosed(PayloadType cand) { public void mediaClosed(PayloadType cand) {
} }
public void mediaEstablished(PayloadType pt) { public void mediaEstablished(PayloadType pt) throws NotConnectedException {
if (isFullyEstablished()) { if (isFullyEstablished()) {
Jingle jout = new Jingle(JingleActionEnum.SESSION_ACCEPT); Jingle jout = new Jingle(JingleActionEnum.SESSION_ACCEPT);
@ -819,7 +822,7 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList
JingleTransportListener jingleTransportListener = new JingleTransportListener() { JingleTransportListener jingleTransportListener = new JingleTransportListener() {
public void transportEstablished(TransportCandidate local, TransportCandidate remote) { public void transportEstablished(TransportCandidate local, TransportCandidate remote) throws NotConnectedException {
if (isFullyEstablished()) { if (isFullyEstablished()) {
// Indicate that this session is active. // Indicate that this session is active.
@ -959,8 +962,9 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList
* Terminates the session with default reason. * Terminates the session with default reason.
* *
* @throws XMPPException * @throws XMPPException
* @throws NotConnectedException
*/ */
public void terminate() throws XMPPException { public void terminate() throws XMPPException, NotConnectedException {
terminate("Closed Locally"); terminate("Closed Locally");
} }
@ -968,8 +972,9 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList
* Terminates the session with a custom reason. * Terminates the session with a custom reason.
* *
* @throws XMPPException * @throws XMPPException
* @throws NotConnectedException
*/ */
public void terminate(String reason) throws XMPPException { public void terminate(String reason) throws XMPPException, NotConnectedException {
if (isClosed()) if (isClosed())
return; return;
LOGGER.fine("Terminate " + reason); LOGGER.fine("Terminate " + reason);

View file

@ -134,8 +134,8 @@ public class JingleSessionRequest {
//session.sendAck(this.getJingle()); //session.sendAck(this.getJingle());
session.updatePacketListener(); session.updatePacketListener();
session.terminate("Declined"); session.terminate("Declined");
} catch (XMPPException e) { } catch (Exception e) {
LOGGER.log(Level.SEVERE, "XMPPexception in reject", e); LOGGER.log(Level.SEVERE, "Exception in reject", e);
} }
} }
} }

View file

@ -16,7 +16,6 @@
*/ */
package org.jivesoftware.smackx.jingle; package org.jivesoftware.smackx.jingle;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smackx.jingle.packet.Jingle; import org.jivesoftware.smackx.jingle.packet.Jingle;
import org.jivesoftware.smackx.jingle.packet.JingleError; import org.jivesoftware.smackx.jingle.packet.JingleError;
@ -98,7 +97,7 @@ public class JingleSessionStateActive extends JingleSessionState {
try { try {
session.terminate("Closed remotely"); session.terminate("Closed remotely");
} catch (XMPPException e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }

View file

@ -16,7 +16,6 @@
*/ */
package org.jivesoftware.smackx.jingle; package org.jivesoftware.smackx.jingle;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smackx.jingle.packet.Jingle; import org.jivesoftware.smackx.jingle.packet.Jingle;
@ -124,7 +123,7 @@ public class JingleSessionStatePending extends JingleSessionState {
try { try {
session.terminate("Closed remotely"); session.terminate("Closed remotely");
} catch (XMPPException e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }

View file

@ -203,7 +203,7 @@ public class JingleSessionStateUnknown extends JingleSessionState {
try { try {
session.terminate("Closed remotely"); session.terminate("Closed remotely");
} catch (XMPPException e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }

View file

@ -17,6 +17,7 @@
package org.jivesoftware.smackx.jingle.listeners; package org.jivesoftware.smackx.jingle.listeners;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smackx.jingle.media.PayloadType; import org.jivesoftware.smackx.jingle.media.PayloadType;
/** /**
@ -28,8 +29,9 @@ public interface JingleMediaListener extends JingleListener {
* Notification that the jmf has been negotiated and established. * Notification that the jmf has been negotiated and established.
* *
* @param pt The payload type agreed. * @param pt The payload type agreed.
* @throws NotConnectedException
*/ */
public void mediaEstablished(PayloadType pt); public void mediaEstablished(PayloadType pt) throws NotConnectedException;
/** /**
* Notification that a payload type must be cancelled * Notification that a payload type must be cancelled

View file

@ -16,6 +16,7 @@
*/ */
package org.jivesoftware.smackx.jingle.listeners; package org.jivesoftware.smackx.jingle.listeners;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPException; import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smackx.jingle.JingleSession; import org.jivesoftware.smackx.jingle.JingleSession;
import org.jivesoftware.smackx.jingle.media.PayloadType; import org.jivesoftware.smackx.jingle.media.PayloadType;
@ -35,9 +36,10 @@ public interface JingleSessionListener extends JingleListener {
* service. * service.
* @param localCandidate the local candidate where we must listen for connections * @param localCandidate the local candidate where we must listen for connections
* @param jingleSession Session that called the method * @param jingleSession Session that called the method
* @throws NotConnectedException
*/ */
public void sessionEstablished(PayloadType pt, TransportCandidate remoteCandidate, public void sessionEstablished(PayloadType pt, TransportCandidate remoteCandidate,
TransportCandidate localCandidate, JingleSession jingleSession); TransportCandidate localCandidate, JingleSession jingleSession) throws NotConnectedException;
/** /**
* Notification that the session was declined. * Notification that the session was declined.

View file

@ -16,6 +16,7 @@
*/ */
package org.jivesoftware.smackx.jingle.listeners; package org.jivesoftware.smackx.jingle.listeners;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPException; import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smackx.jingle.nat.TransportCandidate; import org.jivesoftware.smackx.jingle.nat.TransportCandidate;
@ -33,9 +34,10 @@ public interface JingleTransportListener extends JingleListener {
* in the local machine * in the local machine
* @param remote The transport candidate that has been used for * @param remote The transport candidate that has been used for
* transmitting to the remote machine * transmitting to the remote machine
* @throws NotConnectedException
*/ */
public void transportEstablished(TransportCandidate local, public void transportEstablished(TransportCandidate local,
TransportCandidate remote); TransportCandidate remote) throws NotConnectedException;
/** /**
* Notification that a transport must be cancelled. * Notification that a transport must be cancelled.

View file

@ -20,6 +20,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.logging.Logger; import java.util.logging.Logger;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPException; import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smackx.jingle.ContentNegotiator; import org.jivesoftware.smackx.jingle.ContentNegotiator;
@ -101,8 +102,9 @@ public class MediaNegotiator extends JingleNegotiator {
* the packet received * the packet received
* @return the new Jingle packet to send. * @return the new Jingle packet to send.
* @throws XMPPException * @throws XMPPException
* @throws NotConnectedException
*/ */
public List<IQ> dispatchIncomingPacket(IQ iq, String id) throws XMPPException { public List<IQ> dispatchIncomingPacket(IQ iq, String id) throws XMPPException, NotConnectedException {
List<IQ> responses = new ArrayList<IQ>(); List<IQ> responses = new ArrayList<IQ>();
IQ response = null; IQ response = null;
@ -199,8 +201,9 @@ public class MediaNegotiator extends JingleNegotiator {
* *
* @param jingle * @param jingle
* @return the iq * @return the iq
* @throws NotConnectedException
*/ */
private IQ receiveContentAcceptAction(Jingle jingle, JingleDescription description) throws XMPPException { private IQ receiveContentAcceptAction(Jingle jingle, JingleDescription description) throws XMPPException, NotConnectedException {
IQ response = null; IQ response = null;
List<PayloadType> offeredPayloads = new ArrayList<PayloadType>(); List<PayloadType> offeredPayloads = new ArrayList<PayloadType>();
@ -473,8 +476,9 @@ public class MediaNegotiator extends JingleNegotiator {
* *
* @param bestPt * @param bestPt
* payload type that has been agreed. * payload type that has been agreed.
* @throws NotConnectedException
*/ */
protected void triggerMediaEstablished(PayloadType bestPt) { protected void triggerMediaEstablished(PayloadType bestPt) throws NotConnectedException {
List<JingleListener> listeners = getListenersList(); List<JingleListener> listeners = getListenersList();
for (JingleListener li : listeners) { for (JingleListener li : listeners) {
if (li instanceof JingleMediaListener) { if (li instanceof JingleMediaListener) {

View file

@ -16,6 +16,7 @@
*/ */
package org.jivesoftware.smackx.jingle.nat; package org.jivesoftware.smackx.jingle.nat;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPException; import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smackx.jingle.JingleSession; import org.jivesoftware.smackx.jingle.JingleSession;
@ -43,8 +44,9 @@ public class BasicResolver extends TransportResolver {
* <p/> * <p/>
* The BasicResolver takes the IP addresses of the interfaces and uses the * The BasicResolver takes the IP addresses of the interfaces and uses the
* first non-loopback, non-linklocal and non-sitelocal address. * first non-loopback, non-linklocal and non-sitelocal address.
* @throws NotConnectedException
*/ */
public synchronized void resolve(JingleSession session) throws XMPPException { public synchronized void resolve(JingleSession session) throws XMPPException, NotConnectedException {
setResolveInit(); setResolveInit();

View file

@ -17,6 +17,7 @@
package org.jivesoftware.smackx.jingle.nat; package org.jivesoftware.smackx.jingle.nat;
import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException; import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.XMPPException.XMPPErrorException; import org.jivesoftware.smack.XMPPException.XMPPErrorException;
@ -58,8 +59,9 @@ public class BridgedResolver extends TransportResolver {
* Resolve Bridged Candidate. * Resolve Bridged Candidate.
* <p/> * <p/>
* The BridgedResolver takes the IP addresse and ports of a jmf proxy service. * The BridgedResolver takes the IP addresse and ports of a jmf proxy service.
* @throws NotConnectedException
*/ */
public synchronized void resolve(JingleSession session) throws XMPPException { public synchronized void resolve(JingleSession session) throws XMPPException, NotConnectedException {
setResolveInit(); setResolveInit();

View file

@ -16,6 +16,7 @@
*/ */
package org.jivesoftware.smackx.jingle.nat; package org.jivesoftware.smackx.jingle.nat;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException; import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smackx.jingle.JingleSession; import org.jivesoftware.smackx.jingle.JingleSession;
@ -52,7 +53,7 @@ public class BridgedTransportManager extends JingleTransportManager implements J
// Implement a Session Listener to relay candidates after establishment // Implement a Session Listener to relay candidates after establishment
public void sessionEstablished(PayloadType pt, TransportCandidate rc, TransportCandidate lc, JingleSession jingleSession) { public void sessionEstablished(PayloadType pt, TransportCandidate rc, TransportCandidate lc, JingleSession jingleSession) throws NotConnectedException {
RTPBridge rtpBridge = RTPBridge.relaySession(lc.getConnection(), lc.getSessionId(), lc.getPassword(), rc, lc); RTPBridge rtpBridge = RTPBridge.relaySession(lc.getConnection(), lc.getSessionId(), lc.getPassword(), rc, lc);
} }

View file

@ -16,6 +16,7 @@
*/ */
package org.jivesoftware.smackx.jingle.nat; package org.jivesoftware.smackx.jingle.nat;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPException; import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smackx.jingle.JingleSession; import org.jivesoftware.smackx.jingle.JingleSession;
@ -50,8 +51,9 @@ public class FixedResolver extends TransportResolver {
/** /**
* Resolve the IP address. * Resolve the IP address.
* @throws NotConnectedException
*/ */
public synchronized void resolve(JingleSession session) throws XMPPException { public synchronized void resolve(JingleSession session) throws XMPPException, NotConnectedException {
if (!isResolving()) { if (!isResolving()) {
setResolveInit(); setResolveInit();

View file

@ -17,6 +17,7 @@
package org.jivesoftware.smackx.jingle.nat; package org.jivesoftware.smackx.jingle.nat;
import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException; import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smackx.jingle.JingleSession; import org.jivesoftware.smackx.jingle.JingleSession;
@ -50,7 +51,7 @@ public class ICETransportManager extends JingleTransportManager implements Jingl
// Implement a Session Listener to relay candidates after establishment // Implement a Session Listener to relay candidates after establishment
public void sessionEstablished(PayloadType pt, TransportCandidate rc, TransportCandidate lc, JingleSession jingleSession) { public void sessionEstablished(PayloadType pt, TransportCandidate rc, TransportCandidate lc, JingleSession jingleSession) throws NotConnectedException {
if (lc instanceof ICECandidate) { if (lc instanceof ICECandidate) {
if (((ICECandidate) lc).getType().equals("relay")) { if (((ICECandidate) lc).getType().equals("relay")) {
RTPBridge rtpBridge = RTPBridge.relaySession(lc.getConnection(), lc.getSessionId(), lc.getPassword(), rc, lc); RTPBridge rtpBridge = RTPBridge.relaySession(lc.getConnection(), lc.getSessionId(), lc.getPassword(), rc, lc);

View file

@ -25,6 +25,7 @@ import java.util.Iterator;
import java.util.logging.Logger; import java.util.logging.Logger;
import org.jivesoftware.smack.SmackException.NoResponseException; import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.PacketCollector; import org.jivesoftware.smack.PacketCollector;
import org.jivesoftware.smack.XMPPException.XMPPErrorException; import org.jivesoftware.smack.XMPPException.XMPPErrorException;
@ -383,8 +384,9 @@ public class RTPBridge extends IQ {
* @param connection * @param connection
* @param sessionID * @param sessionID
* @return the new RTPBridge * @return the new RTPBridge
* @throws NotConnectedException
*/ */
public static RTPBridge getRTPBridge(XMPPConnection connection, String sessionID) { public static RTPBridge getRTPBridge(XMPPConnection connection, String sessionID) throws NotConnectedException {
if (!connection.isConnected()) { if (!connection.isConnected()) {
return null; return null;
@ -410,9 +412,10 @@ public class RTPBridge extends IQ {
* @return true if the server supports the RTPBridge service * @return true if the server supports the RTPBridge service
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
*/ */
public static boolean serviceAvailable(XMPPConnection connection) throws NoResponseException, public static boolean serviceAvailable(XMPPConnection connection) throws NoResponseException,
XMPPErrorException { XMPPErrorException, NotConnectedException {
if (!connection.isConnected()) { if (!connection.isConnected()) {
return false; return false;
@ -448,8 +451,9 @@ public class RTPBridge extends IQ {
* *
* @param connection * @param connection
* @return the RTPBridge * @return the RTPBridge
* @throws NotConnectedException
*/ */
public static RTPBridge relaySession(XMPPConnection connection, String sessionID, String pass, TransportCandidate proxyCandidate, TransportCandidate localCandidate) { public static RTPBridge relaySession(XMPPConnection connection, String sessionID, String pass, TransportCandidate proxyCandidate, TransportCandidate localCandidate) throws NotConnectedException {
if (!connection.isConnected()) { if (!connection.isConnected()) {
return null; return null;
@ -482,8 +486,9 @@ public class RTPBridge extends IQ {
* *
* @param xmppConnection * @param xmppConnection
* @return public IP String or null if not found * @return public IP String or null if not found
* @throws NotConnectedException
*/ */
public static String getPublicIP(XMPPConnection xmppConnection) { public static String getPublicIP(XMPPConnection xmppConnection) throws NotConnectedException {
if (!xmppConnection.isConnected()) { if (!xmppConnection.isConnected()) {
return null; return null;

View file

@ -22,6 +22,7 @@ import java.util.List;
import java.util.logging.Logger; import java.util.logging.Logger;
import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.PacketCollector; import org.jivesoftware.smack.PacketCollector;
import org.jivesoftware.smack.XMPPException; import org.jivesoftware.smack.XMPPException;
@ -181,8 +182,9 @@ public class STUN extends IQ {
* *
* @param connection * @param connection
* @return the STUN server address * @return the STUN server address
* @throws NotConnectedException
*/ */
public static STUN getSTUNServer(XMPPConnection connection) { public static STUN getSTUNServer(XMPPConnection connection) throws NotConnectedException {
if (!connection.isConnected()) { if (!connection.isConnected()) {
return null; return null;

View file

@ -26,6 +26,7 @@ import java.util.Enumeration;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPException; import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smackx.jingle.JingleSession; import org.jivesoftware.smackx.jingle.JingleSession;
import org.xmlpull.v1.XmlPullParserFactory; import org.xmlpull.v1.XmlPullParserFactory;
@ -262,8 +263,9 @@ public class STUNResolver extends TransportResolver {
/** /**
* Resolve the IP and obtain a valid transport method. * Resolve the IP and obtain a valid transport method.
* @throws NotConnectedException
*/ */
public synchronized void resolve(JingleSession session) throws XMPPException { public synchronized void resolve(JingleSession session) throws XMPPException, NotConnectedException {
setResolveInit(); setResolveInit();

View file

@ -16,7 +16,6 @@
*/ */
package org.jivesoftware.smackx.jingle.nat; package org.jivesoftware.smackx.jingle.nat;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smackx.jingle.JingleSession; import org.jivesoftware.smackx.jingle.JingleSession;
/** /**
@ -40,7 +39,7 @@ public class STUNTransportManager extends JingleTransportManager {
protected TransportResolver createResolver(JingleSession session) { protected TransportResolver createResolver(JingleSession session) {
try { try {
stunResolver.resolve(session); stunResolver.resolve(session);
} catch (XMPPException e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
return stunResolver; return stunResolver;

View file

@ -24,6 +24,7 @@ import java.util.List;
import java.util.logging.Logger; import java.util.logging.Logger;
import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPException; import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smackx.jingle.ContentNegotiator; import org.jivesoftware.smackx.jingle.ContentNegotiator;
@ -319,12 +320,22 @@ public abstract class TransportNegotiator extends JingleNegotiator {
jout.addContent(content); jout.addContent(content);
// Send the packet // Send the packet
js.sendFormattedJingle(jin, jout); try {
js.sendFormattedJingle(jin, jout);
}
catch (NotConnectedException e) {
throw new IllegalStateException(e);
}
acceptedRemoteCandidates.add(bestRemote); acceptedRemoteCandidates.add(bestRemote);
} }
if ((isEstablished()) && (getNegotiatorState() == JingleNegotiatorState.PENDING)) { if ((isEstablished()) && (getNegotiatorState() == JingleNegotiatorState.PENDING)) {
setNegotiatorState(JingleNegotiatorState.SUCCEEDED); setNegotiatorState(JingleNegotiatorState.SUCCEEDED);
triggerTransportEstablished(getAcceptedLocalCandidate(), bestRemote); try {
triggerTransportEstablished(getAcceptedLocalCandidate(), bestRemote);
}
catch (NotConnectedException e) {
throw new IllegalStateException(e);
}
break; break;
} }
} }
@ -400,7 +411,12 @@ public abstract class TransportNegotiator extends JingleNegotiator {
jout.addContent(content); jout.addContent(content);
// Send the packet // Send the packet
js.sendFormattedJingle(jin, jout); try {
js.sendFormattedJingle(jin, jout);
}
catch (NotConnectedException e) {
throw new IllegalStateException(e);
}
acceptedRemoteCandidates.add(bestRemote); acceptedRemoteCandidates.add(bestRemote);
} }
if (isEstablished()) { if (isEstablished()) {
@ -414,7 +430,7 @@ public abstract class TransportNegotiator extends JingleNegotiator {
try { try {
session session
.terminate("Unable to negotiate session. This may be caused by firewall configuration problems."); .terminate("Unable to negotiate session. This may be caused by firewall configuration problems.");
} catch (XMPPException e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
@ -508,8 +524,9 @@ public abstract class TransportNegotiator extends JingleNegotiator {
* Send an offer for a transport candidate * Send an offer for a transport candidate
* *
* @param cand * @param cand
* @throws NotConnectedException
*/ */
private synchronized void sendTransportCandidateOffer(TransportCandidate cand) { private synchronized void sendTransportCandidateOffer(TransportCandidate cand) throws NotConnectedException {
if (!cand.isNull()) { if (!cand.isNull()) {
// Offer our new candidate... // Offer our new candidate...
addOfferedCandidate(cand); addOfferedCandidate(cand);
@ -545,7 +562,7 @@ public abstract class TransportNegotiator extends JingleNegotiator {
if (resolverListener == null) { if (resolverListener == null) {
// Add a listener that sends the offer when the resolver finishes... // Add a listener that sends the offer when the resolver finishes...
resolverListener = new TransportResolverListener.Resolver() { resolverListener = new TransportResolverListener.Resolver() {
public void candidateAdded(TransportCandidate cand) { public void candidateAdded(TransportCandidate cand) throws NotConnectedException {
sendTransportCandidateOffer(cand); sendTransportCandidateOffer(cand);
} }
@ -763,8 +780,9 @@ public abstract class TransportNegotiator extends JingleNegotiator {
* *
* @param local TransportCandidate that has been agreed. * @param local TransportCandidate that has been agreed.
* @param remote TransportCandidate that has been agreed. * @param remote TransportCandidate that has been agreed.
* @throws NotConnectedException
*/ */
private void triggerTransportEstablished(TransportCandidate local, TransportCandidate remote) { private void triggerTransportEstablished(TransportCandidate local, TransportCandidate remote) throws NotConnectedException {
List<JingleListener> listeners = getListenersList(); List<JingleListener> listeners = getListenersList();
for (JingleListener li : listeners) { for (JingleListener li : listeners) {
if (li instanceof JingleTransportListener) { if (li instanceof JingleTransportListener) {

View file

@ -25,6 +25,7 @@ import java.util.List;
import java.util.logging.Logger; import java.util.logging.Logger;
import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPException; import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smackx.jingle.JingleSession; import org.jivesoftware.smackx.jingle.JingleSession;
@ -208,8 +209,9 @@ public abstract class TransportResolver {
* Trigger a new candidate added event. * Trigger a new candidate added event.
* *
* @param cand The candidate added to the list of candidates. * @param cand The candidate added to the list of candidates.
* @throws NotConnectedException
*/ */
protected void triggerCandidateAdded(TransportCandidate cand) { protected void triggerCandidateAdded(TransportCandidate cand) throws NotConnectedException {
Iterator<TransportResolverListener> iter = getListenersList().iterator(); Iterator<TransportResolverListener> iter = getListenersList().iterator();
while (iter.hasNext()) { while (iter.hasNext()) {
TransportResolverListener trl = iter.next(); TransportResolverListener trl = iter.next();
@ -264,8 +266,9 @@ public abstract class TransportResolver {
* Add a new transport candidate * Add a new transport candidate
* *
* @param cand The candidate to add * @param cand The candidate to add
* @throws NotConnectedException
*/ */
protected void addCandidate(TransportCandidate cand) { protected void addCandidate(TransportCandidate cand) throws NotConnectedException {
synchronized (candidates) { synchronized (candidates) {
if (!candidates.contains(cand)) if (!candidates.contains(cand))
candidates.add(cand); candidates.add(cand);

View file

@ -16,6 +16,8 @@
*/ */
package org.jivesoftware.smackx.jingle.nat; package org.jivesoftware.smackx.jingle.nat;
import org.jivesoftware.smack.SmackException.NotConnectedException;
/** /**
* Transport resolver Interface * Transport resolver Interface
*/ */
@ -33,8 +35,9 @@ public abstract interface TransportResolverListener {
* A transport candidate has been added * A transport candidate has been added
* *
* @param cand The transport candidate. * @param cand The transport candidate.
* @throws NotConnectedException
*/ */
public void candidateAdded(TransportCandidate cand); public void candidateAdded(TransportCandidate cand) throws NotConnectedException;
/** /**
* All the transport candidates have been obtained. * All the transport candidates have been obtained.

View file

@ -20,6 +20,7 @@ package org.jivesoftware.smackx.workgroup.agent;
import org.jivesoftware.smackx.workgroup.packet.AgentInfo; import org.jivesoftware.smackx.workgroup.packet.AgentInfo;
import org.jivesoftware.smackx.workgroup.packet.AgentWorkgroups; import org.jivesoftware.smackx.workgroup.packet.AgentWorkgroups;
import org.jivesoftware.smack.SmackException.NoResponseException; import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException.XMPPErrorException; import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.IQ;
@ -35,7 +36,7 @@ public class Agent {
private XMPPConnection connection; private XMPPConnection connection;
private String workgroupJID; private String workgroupJID;
public static Collection<String> getWorkgroups(String serviceJID, String agentJID, XMPPConnection connection) throws NoResponseException, XMPPErrorException { public static Collection<String> getWorkgroups(String serviceJID, String agentJID, XMPPConnection connection) throws NoResponseException, XMPPErrorException, NotConnectedException {
AgentWorkgroups request = new AgentWorkgroups(agentJID); AgentWorkgroups request = new AgentWorkgroups(agentJID);
request.setTo(serviceJID); request.setTo(serviceJID);
AgentWorkgroups response = (AgentWorkgroups) connection.createPacketCollectorAndSend(request).nextResultOrThrow(); AgentWorkgroups response = (AgentWorkgroups) connection.createPacketCollectorAndSend(request).nextResultOrThrow();
@ -65,8 +66,9 @@ public class Agent {
* @return - the agents name. * @return - the agents name.
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
*/ */
public String getName() throws NoResponseException, XMPPErrorException { public String getName() throws NoResponseException, XMPPErrorException, NotConnectedException {
AgentInfo agentInfo = new AgentInfo(); AgentInfo agentInfo = new AgentInfo();
agentInfo.setType(IQ.Type.GET); agentInfo.setType(IQ.Type.GET);
agentInfo.setTo(workgroupJID); agentInfo.setTo(workgroupJID);
@ -84,8 +86,9 @@ public class Agent {
* @param newName the new name of the agent. * @param newName the new name of the agent.
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
*/ */
public void setName(String newName) throws NoResponseException, XMPPErrorException { public void setName(String newName) throws NoResponseException, XMPPErrorException, NotConnectedException {
AgentInfo agentInfo = new AgentInfo(); AgentInfo agentInfo = new AgentInfo();
agentInfo.setType(IQ.Type.SET); agentInfo.setType(IQ.Type.SET);
agentInfo.setTo(workgroupJID); agentInfo.setTo(workgroupJID);

View file

@ -20,6 +20,7 @@ package org.jivesoftware.smackx.workgroup.agent;
import org.jivesoftware.smackx.workgroup.packet.AgentStatus; import org.jivesoftware.smackx.workgroup.packet.AgentStatus;
import org.jivesoftware.smackx.workgroup.packet.AgentStatusRequest; import org.jivesoftware.smackx.workgroup.packet.AgentStatusRequest;
import org.jivesoftware.smack.PacketListener; import org.jivesoftware.smack.PacketListener;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.filter.PacketFilter; import org.jivesoftware.smack.filter.PacketFilter;
import org.jivesoftware.smack.filter.PacketTypeFilter; import org.jivesoftware.smack.filter.PacketTypeFilter;
@ -62,8 +63,9 @@ public class AgentRoster {
* Constructs a new AgentRoster. * Constructs a new AgentRoster.
* *
* @param connection an XMPP connection. * @param connection an XMPP connection.
* @throws NotConnectedException
*/ */
AgentRoster(XMPPConnection connection, String workgroupJID) { AgentRoster(XMPPConnection connection, String workgroupJID) throws NotConnectedException {
this.connection = connection; this.connection = connection;
this.workgroupJID = workgroupJID; this.workgroupJID = workgroupJID;
entries = new ArrayList<String>(); entries = new ArrayList<String>();
@ -86,8 +88,9 @@ public class AgentRoster {
* Reloads the entire roster from the server. This is an asynchronous operation, * Reloads the entire roster from the server. This is an asynchronous operation,
* which means the method will return immediately, and the roster will be * which means the method will return immediately, and the roster will be
* reloaded at a later point when the server responds to the reload request. * reloaded at a later point when the server responds to the reload request.
* @throws NotConnectedException
*/ */
public void reload() { public void reload() throws NotConnectedException {
AgentStatusRequest request = new AgentStatusRequest(); AgentStatusRequest request = new AgentStatusRequest();
request.setTo(workgroupJID); request.setTo(workgroupJID);
connection.sendPacket(request); connection.sendPacket(request);

View file

@ -35,6 +35,7 @@ import org.jivesoftware.smackx.workgroup.settings.SearchSettings;
import org.jivesoftware.smackx.xdata.Form; import org.jivesoftware.smackx.xdata.Form;
import org.jivesoftware.smack.*; import org.jivesoftware.smack.*;
import org.jivesoftware.smack.SmackException.NoResponseException; import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPException.XMPPErrorException; import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.filter.*; import org.jivesoftware.smack.filter.*;
import org.jivesoftware.smack.packet.*; import org.jivesoftware.smack.packet.*;
@ -143,8 +144,9 @@ public class AgentSession {
* Returns the agent roster for the workgroup, which contains * Returns the agent roster for the workgroup, which contains
* *
* @return the AgentRoster * @return the AgentRoster
* @throws NotConnectedException
*/ */
public AgentRoster getAgentRoster() { public AgentRoster getAgentRoster() throws NotConnectedException {
if (agentRoster == null) { if (agentRoster == null) {
agentRoster = new AgentRoster(connection, workgroupJID); agentRoster = new AgentRoster(connection, workgroupJID);
} }
@ -340,10 +342,11 @@ public class AgentSession {
* @param status sets the status message of the presence update. * @param status sets the status message of the presence update.
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
* @throws IllegalStateException if the agent is not online with the workgroup. * @throws IllegalStateException if the agent is not online with the workgroup.
*/ */
public void setStatus(Presence.Mode presenceMode, int maxChats, String status) public void setStatus(Presence.Mode presenceMode, int maxChats, String status)
throws NoResponseException, XMPPErrorException { throws NoResponseException, XMPPErrorException, NotConnectedException {
if (!online) { if (!online) {
throw new IllegalStateException("Cannot set status when the agent is not online."); throw new IllegalStateException("Cannot set status when the agent is not online.");
} }
@ -392,9 +395,10 @@ public class AgentSession {
* @param status sets the status message of the presence update. * @param status sets the status message of the presence update.
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
* @throws IllegalStateException if the agent is not online with the workgroup. * @throws IllegalStateException if the agent is not online with the workgroup.
*/ */
public void setStatus(Presence.Mode presenceMode, String status) throws NoResponseException, XMPPErrorException { public void setStatus(Presence.Mode presenceMode, String status) throws NoResponseException, XMPPErrorException, NotConnectedException {
if (!online) { if (!online) {
throw new IllegalStateException("Cannot set status when the agent is not online."); throw new IllegalStateException("Cannot set status when the agent is not online.");
} }
@ -429,8 +433,9 @@ public class AgentSession {
* *
* @param userID the ID of the user to remove. * @param userID the ID of the user to remove.
* @throws XMPPException if an exception occurs. * @throws XMPPException if an exception occurs.
* @throws NotConnectedException
*/ */
public void dequeueUser(String userID) throws XMPPException { public void dequeueUser(String userID) throws XMPPException, NotConnectedException {
// todo: this method simply won't work right now. // todo: this method simply won't work right now.
DepartQueuePacket departPacket = new DepartQueuePacket(this.workgroupJID); DepartQueuePacket departPacket = new DepartQueuePacket(this.workgroupJID);
@ -500,8 +505,9 @@ public class AgentSession {
* @return information about the occupants of the specified room. * @return information about the occupants of the specified room.
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
*/ */
public OccupantsInfo getOccupantsInfo(String roomID) throws NoResponseException, XMPPErrorException { public OccupantsInfo getOccupantsInfo(String roomID) throws NoResponseException, XMPPErrorException, NotConnectedException {
OccupantsInfo request = new OccupantsInfo(roomID); OccupantsInfo request = new OccupantsInfo(roomID);
request.setType(IQ.Type.GET); request.setType(IQ.Type.GET);
request.setTo(workgroupJID); request.setTo(workgroupJID);
@ -658,7 +664,7 @@ public class AgentSession {
// PacketListener Implementation. // PacketListener Implementation.
private void handlePacket(Packet packet) { private void handlePacket(Packet packet) throws NotConnectedException {
if (packet instanceof OfferRequestProvider.OfferRequestPacket) { if (packet instanceof OfferRequestProvider.OfferRequestPacket) {
// Acknowledge the IQ set. // Acknowledge the IQ set.
IQ reply = new IQ() { IQ reply = new IQ() {
@ -777,8 +783,9 @@ public class AgentSession {
* @param note the chat note to add. * @param note the chat note to add.
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
*/ */
public void setNote(String sessionID, String note) throws NoResponseException, XMPPErrorException { public void setNote(String sessionID, String note) throws NoResponseException, XMPPErrorException, NotConnectedException {
note = ChatNotes.replace(note, "\n", "\\n"); note = ChatNotes.replace(note, "\n", "\\n");
note = StringUtils.escapeForXML(note); note = StringUtils.escapeForXML(note);
@ -797,8 +804,9 @@ public class AgentSession {
* @return the <code>ChatNote</code> associated with a given chat session. * @return the <code>ChatNote</code> associated with a given chat session.
* @throws XMPPErrorException if an error occurs while retrieving the ChatNote. * @throws XMPPErrorException if an error occurs while retrieving the ChatNote.
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
*/ */
public ChatNotes getNote(String sessionID) throws NoResponseException, XMPPErrorException { public ChatNotes getNote(String sessionID) throws NoResponseException, XMPPErrorException, NotConnectedException {
ChatNotes request = new ChatNotes(); ChatNotes request = new ChatNotes();
request.setType(IQ.Type.GET); request.setType(IQ.Type.GET);
request.setTo(workgroupJID); request.setTo(workgroupJID);
@ -815,8 +823,9 @@ public class AgentSession {
* @param maxSessions the max number of sessions to retrieve. * @param maxSessions the max number of sessions to retrieve.
* @return the chat history associated with a given jid. * @return the chat history associated with a given jid.
* @throws XMPPException if an error occurs while retrieving the AgentChatHistory. * @throws XMPPException if an error occurs while retrieving the AgentChatHistory.
* @throws NotConnectedException
*/ */
public AgentChatHistory getAgentHistory(String jid, int maxSessions, Date startDate) throws XMPPException { public AgentChatHistory getAgentHistory(String jid, int maxSessions, Date startDate) throws XMPPException, NotConnectedException {
AgentChatHistory request; AgentChatHistory request;
if (startDate != null) { if (startDate != null) {
request = new AgentChatHistory(jid, maxSessions, startDate); request = new AgentChatHistory(jid, maxSessions, startDate);
@ -840,8 +849,9 @@ public class AgentSession {
* @return SearchSettings the search settings for this workgroup. * @return SearchSettings the search settings for this workgroup.
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
*/ */
public SearchSettings getSearchSettings() throws NoResponseException, XMPPErrorException { public SearchSettings getSearchSettings() throws NoResponseException, XMPPErrorException, NotConnectedException {
SearchSettings request = new SearchSettings(); SearchSettings request = new SearchSettings();
request.setType(IQ.Type.GET); request.setType(IQ.Type.GET);
request.setTo(workgroupJID); request.setTo(workgroupJID);
@ -857,8 +867,9 @@ public class AgentSession {
* @return MacroGroup the root macro group. * @return MacroGroup the root macro group.
* @throws XMPPErrorException if an error occurs while getting information from the server. * @throws XMPPErrorException if an error occurs while getting information from the server.
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
*/ */
public MacroGroup getMacros(boolean global) throws NoResponseException, XMPPErrorException { public MacroGroup getMacros(boolean global) throws NoResponseException, XMPPErrorException, NotConnectedException {
Macros request = new Macros(); Macros request = new Macros();
request.setType(IQ.Type.GET); request.setType(IQ.Type.GET);
request.setTo(workgroupJID); request.setTo(workgroupJID);
@ -874,8 +885,9 @@ public class AgentSession {
* @param group the macro group to save. * @param group the macro group to save.
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
*/ */
public void saveMacros(MacroGroup group) throws NoResponseException, XMPPErrorException { public void saveMacros(MacroGroup group) throws NoResponseException, XMPPErrorException, NotConnectedException {
Macros request = new Macros(); Macros request = new Macros();
request.setType(IQ.Type.SET); request.setType(IQ.Type.SET);
request.setTo(workgroupJID); request.setTo(workgroupJID);
@ -891,8 +903,9 @@ public class AgentSession {
* @param sessionID the sessionID to query for. * @param sessionID the sessionID to query for.
* @return Map a map of all metadata associated with the sessionID. * @return Map a map of all metadata associated with the sessionID.
* @throws XMPPException if an error occurs while getting information from the server. * @throws XMPPException if an error occurs while getting information from the server.
* @throws NotConnectedException
*/ */
public Map<String, List<String>> getChatMetadata(String sessionID) throws XMPPException { public Map<String, List<String>> getChatMetadata(String sessionID) throws XMPPException, NotConnectedException {
ChatMetadata request = new ChatMetadata(); ChatMetadata request = new ChatMetadata();
request.setType(IQ.Type.GET); request.setType(IQ.Type.GET);
request.setTo(workgroupJID); request.setTo(workgroupJID);
@ -929,8 +942,9 @@ public class AgentSession {
* @throws XMPPErrorException if the sender of the invitation is not an agent or the service failed to process * @throws XMPPErrorException if the sender of the invitation is not an agent or the service failed to process
* the request. * the request.
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
*/ */
public void sendRoomInvitation(RoomInvitation.Type type, String invitee, String sessionID, String reason) throws NoResponseException, XMPPErrorException public void sendRoomInvitation(RoomInvitation.Type type, String invitee, String sessionID, String reason) throws NoResponseException, XMPPErrorException, NotConnectedException
{ {
final RoomInvitation invitation = new RoomInvitation(type, invitee, sessionID, reason); final RoomInvitation invitation = new RoomInvitation(type, invitee, sessionID, reason);
IQ iq = new IQ() { IQ iq = new IQ() {
@ -970,8 +984,9 @@ public class AgentSession {
* @throws XMPPErrorException if the sender of the invitation is not an agent or the service failed to process * @throws XMPPErrorException if the sender of the invitation is not an agent or the service failed to process
* the request. * the request.
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
*/ */
public void sendRoomTransfer(RoomTransfer.Type type, String invitee, String sessionID, String reason) throws NoResponseException, XMPPErrorException public void sendRoomTransfer(RoomTransfer.Type type, String invitee, String sessionID, String reason) throws NoResponseException, XMPPErrorException, NotConnectedException
{ {
final RoomTransfer transfer = new RoomTransfer(type, invitee, sessionID, reason); final RoomTransfer transfer = new RoomTransfer(type, invitee, sessionID, reason);
IQ iq = new IQ() { IQ iq = new IQ() {
@ -995,8 +1010,9 @@ public class AgentSession {
* @return the settings for the workgroup. * @return the settings for the workgroup.
* @throws XMPPErrorException if an error occurs while sending the request to the server. * @throws XMPPErrorException if an error occurs while sending the request to the server.
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
*/ */
public GenericSettings getGenericSettings(XMPPConnection con, String query) throws NoResponseException, XMPPErrorException { public GenericSettings getGenericSettings(XMPPConnection con, String query) throws NoResponseException, XMPPErrorException, NotConnectedException {
GenericSettings setting = new GenericSettings(); GenericSettings setting = new GenericSettings();
setting.setType(IQ.Type.GET); setting.setType(IQ.Type.GET);
setting.setTo(workgroupJID); setting.setTo(workgroupJID);
@ -1006,7 +1022,7 @@ public class AgentSession {
return response; return response;
} }
public boolean hasMonitorPrivileges(XMPPConnection con) throws NoResponseException, XMPPErrorException { public boolean hasMonitorPrivileges(XMPPConnection con) throws NoResponseException, XMPPErrorException, NotConnectedException {
MonitorPacket request = new MonitorPacket(); MonitorPacket request = new MonitorPacket();
request.setType(IQ.Type.GET); request.setType(IQ.Type.GET);
request.setTo(workgroupJID); request.setTo(workgroupJID);
@ -1015,7 +1031,7 @@ public class AgentSession {
return response.isMonitor(); return response.isMonitor();
} }
public void makeRoomOwner(XMPPConnection con, String sessionID) throws NoResponseException, XMPPErrorException { public void makeRoomOwner(XMPPConnection con, String sessionID) throws NoResponseException, XMPPErrorException, NotConnectedException {
MonitorPacket request = new MonitorPacket(); MonitorPacket request = new MonitorPacket();
request.setType(IQ.Type.SET); request.setType(IQ.Type.SET);
request.setTo(workgroupJID); request.setTo(workgroupJID);

View file

@ -17,6 +17,7 @@
package org.jivesoftware.smackx.workgroup.agent; package org.jivesoftware.smackx.workgroup.agent;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.Packet; import org.jivesoftware.smack.packet.Packet;
@ -79,8 +80,9 @@ public class Offer {
/** /**
* Accepts the offer. * Accepts the offer.
* @throws NotConnectedException
*/ */
public void accept() { public void accept() throws NotConnectedException {
Packet acceptPacket = new AcceptPacket(this.session.getWorkgroupJID()); Packet acceptPacket = new AcceptPacket(this.session.getWorkgroupJID());
connection.sendPacket(acceptPacket); connection.sendPacket(acceptPacket);
// TODO: listen for a reply. // TODO: listen for a reply.
@ -89,8 +91,9 @@ public class Offer {
/** /**
* Rejects the offer. * Rejects the offer.
* @throws NotConnectedException
*/ */
public void reject() { public void reject() throws NotConnectedException {
RejectPacket rejectPacket = new RejectPacket(this.session.getWorkgroupJID()); RejectPacket rejectPacket = new RejectPacket(this.session.getWorkgroupJID());
connection.sendPacket(rejectPacket); connection.sendPacket(rejectPacket);
// TODO: listen for a reply. // TODO: listen for a reply.

View file

@ -17,6 +17,7 @@
package org.jivesoftware.smackx.workgroup.agent; package org.jivesoftware.smackx.workgroup.agent;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.provider.IQProvider; import org.jivesoftware.smack.provider.IQProvider;
@ -44,7 +45,7 @@ public class OfferConfirmation extends IQ {
} }
public void notifyService(XMPPConnection con, String workgroup, String createdRoomName) { public void notifyService(XMPPConnection con, String workgroup, String createdRoomName) throws NotConnectedException {
NotifyServicePacket packet = new NotifyServicePacket(workgroup, createdRoomName); NotifyServicePacket packet = new NotifyServicePacket(workgroup, createdRoomName);
con.sendPacket(packet); con.sendPacket(packet);
} }

View file

@ -20,6 +20,7 @@ package org.jivesoftware.smackx.workgroup.agent;
import org.jivesoftware.smackx.workgroup.packet.Transcript; import org.jivesoftware.smackx.workgroup.packet.Transcript;
import org.jivesoftware.smackx.workgroup.packet.Transcripts; import org.jivesoftware.smackx.workgroup.packet.Transcripts;
import org.jivesoftware.smack.SmackException.NoResponseException; import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException.XMPPErrorException; import org.jivesoftware.smack.XMPPException.XMPPErrorException;
@ -45,8 +46,9 @@ public class TranscriptManager {
* @return the full conversation transcript of a given session. * @return the full conversation transcript of a given session.
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
*/ */
public Transcript getTranscript(String workgroupJID, String sessionID) throws NoResponseException, XMPPErrorException { public Transcript getTranscript(String workgroupJID, String sessionID) throws NoResponseException, XMPPErrorException, NotConnectedException {
Transcript request = new Transcript(sessionID); Transcript request = new Transcript(sessionID);
request.setTo(workgroupJID); request.setTo(workgroupJID);
Transcript response = (Transcript) connection.createPacketCollectorAndSend(request).nextResultOrThrow(); Transcript response = (Transcript) connection.createPacketCollectorAndSend(request).nextResultOrThrow();
@ -62,8 +64,9 @@ public class TranscriptManager {
* @return the transcripts of a given user. * @return the transcripts of a given user.
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
*/ */
public Transcripts getTranscripts(String workgroupJID, String userID) throws NoResponseException, XMPPErrorException { public Transcripts getTranscripts(String workgroupJID, String userID) throws NoResponseException, XMPPErrorException, NotConnectedException {
Transcripts request = new Transcripts(userID); Transcripts request = new Transcripts(userID);
request.setTo(workgroupJID); request.setTo(workgroupJID);
Transcripts response = (Transcripts) connection.createPacketCollectorAndSend(request).nextResultOrThrow(); Transcripts response = (Transcripts) connection.createPacketCollectorAndSend(request).nextResultOrThrow();

View file

@ -21,6 +21,7 @@ import org.jivesoftware.smackx.search.ReportedData;
import org.jivesoftware.smackx.workgroup.packet.TranscriptSearch; import org.jivesoftware.smackx.workgroup.packet.TranscriptSearch;
import org.jivesoftware.smackx.xdata.Form; import org.jivesoftware.smackx.xdata.Form;
import org.jivesoftware.smack.SmackException.NoResponseException; import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException.XMPPErrorException; import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.IQ;
@ -48,8 +49,9 @@ public class TranscriptSearchManager {
* @return the Form to use for searching transcripts. * @return the Form to use for searching transcripts.
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
*/ */
public Form getSearchForm(String serviceJID) throws NoResponseException, XMPPErrorException { public Form getSearchForm(String serviceJID) throws NoResponseException, XMPPErrorException, NotConnectedException {
TranscriptSearch search = new TranscriptSearch(); TranscriptSearch search = new TranscriptSearch();
search.setType(IQ.Type.GET); search.setType(IQ.Type.GET);
search.setTo(serviceJID); search.setTo(serviceJID);
@ -69,8 +71,9 @@ public class TranscriptSearchManager {
* @return the result of the transcript search. * @return the result of the transcript search.
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
*/ */
public ReportedData submitSearch(String serviceJID, Form completedForm) throws NoResponseException, XMPPErrorException { public ReportedData submitSearch(String serviceJID, Form completedForm) throws NoResponseException, XMPPErrorException, NotConnectedException {
TranscriptSearch search = new TranscriptSearch(); TranscriptSearch search = new TranscriptSearch();
search.setType(IQ.Type.GET); search.setType(IQ.Type.GET);
search.setTo(serviceJID); search.setTo(serviceJID);

View file

@ -30,6 +30,7 @@ import org.jivesoftware.smackx.xdata.FormField;
import org.jivesoftware.smackx.xdata.packet.DataForm; import org.jivesoftware.smackx.xdata.packet.DataForm;
import org.jivesoftware.smack.*; import org.jivesoftware.smack.*;
import org.jivesoftware.smack.SmackException.NoResponseException; import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPException.XMPPErrorException; import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.filter.*; import org.jivesoftware.smack.filter.*;
import org.jivesoftware.smack.packet.*; import org.jivesoftware.smack.packet.*;
@ -157,8 +158,9 @@ public class Workgroup {
* @return true if the workgroup is available for receiving new requests. * @return true if the workgroup is available for receiving new requests.
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
*/ */
public boolean isAvailable() throws NoResponseException, XMPPErrorException { public boolean isAvailable() throws NoResponseException, XMPPErrorException, NotConnectedException {
Presence directedPresence = new Presence(Presence.Type.available); Presence directedPresence = new Presence(Presence.Type.available);
directedPresence.setTo(workgroupJID); directedPresence.setTo(workgroupJID);
PacketFilter typeFilter = new PacketTypeFilter(Presence.class); PacketFilter typeFilter = new PacketTypeFilter(Presence.class);
@ -310,8 +312,9 @@ public class Workgroup {
* that a connection failure occured or that the server explicitly rejected the * that a connection failure occured or that the server explicitly rejected the
* request to join the queue. * request to join the queue.
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
*/ */
public void joinQueue(Form answerForm, String userID) throws NoResponseException, XMPPErrorException { public void joinQueue(Form answerForm, String userID) throws NoResponseException, XMPPErrorException, NotConnectedException {
// If already in the queue ignore the join request. // If already in the queue ignore the join request.
if (inQueue) { if (inQueue) {
throw new IllegalStateException("Already in queue " + workgroupJID); throw new IllegalStateException("Already in queue " + workgroupJID);
@ -393,8 +396,9 @@ public class Workgroup {
* @throws XMPPErrorException if an error occured trying to send the depart queue * @throws XMPPErrorException if an error occured trying to send the depart queue
* request to the server. * request to the server.
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
*/ */
public void departQueue() throws NoResponseException, XMPPErrorException { public void departQueue() throws NoResponseException, XMPPErrorException, NotConnectedException {
// If not in the queue ignore the depart request. // If not in the queue ignore the depart request.
if (!inQueue) { if (!inQueue) {
return; return;
@ -634,8 +638,9 @@ public class Workgroup {
* @return key specify a key to retrieve only that settings. Otherwise for all settings, key should be null. * @return key specify a key to retrieve only that settings. Otherwise for all settings, key should be null.
* @throws NoResponseException * @throws NoResponseException
* @throws XMPPErrorException if an error occurs while getting information from the server. * @throws XMPPErrorException if an error occurs while getting information from the server.
* @throws NotConnectedException
*/ */
private ChatSettings getChatSettings(String key, int type) throws NoResponseException, XMPPErrorException { private ChatSettings getChatSettings(String key, int type) throws NoResponseException, XMPPErrorException, NotConnectedException {
ChatSettings request = new ChatSettings(); ChatSettings request = new ChatSettings();
if (key != null) { if (key != null) {
request.setKey(key); request.setKey(key);
@ -677,8 +682,9 @@ public class Workgroup {
* @return offlineSettings the offline settings for this workgroup. * @return offlineSettings the offline settings for this workgroup.
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
*/ */
public OfflineSettings getOfflineSettings() throws NoResponseException, XMPPErrorException { public OfflineSettings getOfflineSettings() throws NoResponseException, XMPPErrorException, NotConnectedException {
OfflineSettings request = new OfflineSettings(); OfflineSettings request = new OfflineSettings();
request.setType(IQ.Type.GET); request.setType(IQ.Type.GET);
request.setTo(workgroupJID); request.setTo(workgroupJID);
@ -694,8 +700,9 @@ public class Workgroup {
* @return soundSettings the sound settings for the specified workgroup. * @return soundSettings the sound settings for the specified workgroup.
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
*/ */
public SoundSettings getSoundSettings() throws NoResponseException, XMPPErrorException { public SoundSettings getSoundSettings() throws NoResponseException, XMPPErrorException, NotConnectedException {
SoundSettings request = new SoundSettings(); SoundSettings request = new SoundSettings();
request.setType(IQ.Type.GET); request.setType(IQ.Type.GET);
request.setTo(workgroupJID); request.setTo(workgroupJID);
@ -710,8 +717,9 @@ public class Workgroup {
* @return the WorkgroupProperties for the specified workgroup. * @return the WorkgroupProperties for the specified workgroup.
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
*/ */
public WorkgroupProperties getWorkgroupProperties() throws NoResponseException, XMPPErrorException { public WorkgroupProperties getWorkgroupProperties() throws NoResponseException, XMPPErrorException, NotConnectedException {
WorkgroupProperties request = new WorkgroupProperties(); WorkgroupProperties request = new WorkgroupProperties();
request.setType(IQ.Type.GET); request.setType(IQ.Type.GET);
request.setTo(workgroupJID); request.setTo(workgroupJID);
@ -728,8 +736,9 @@ public class Workgroup {
* @return the WorkgroupProperties for the specified workgroup. * @return the WorkgroupProperties for the specified workgroup.
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
*/ */
public WorkgroupProperties getWorkgroupProperties(String jid) throws NoResponseException, XMPPErrorException { public WorkgroupProperties getWorkgroupProperties(String jid) throws NoResponseException, XMPPErrorException, NotConnectedException {
WorkgroupProperties request = new WorkgroupProperties(); WorkgroupProperties request = new WorkgroupProperties();
request.setJid(jid); request.setJid(jid);
request.setType(IQ.Type.GET); request.setType(IQ.Type.GET);
@ -749,8 +758,9 @@ public class Workgroup {
* @return the Form to use for searching transcripts. * @return the Form to use for searching transcripts.
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotConnectedException
*/ */
public Form getWorkgroupForm() throws NoResponseException, XMPPErrorException { public Form getWorkgroupForm() throws NoResponseException, XMPPErrorException, NotConnectedException {
WorkgroupForm workgroupForm = new WorkgroupForm(); WorkgroupForm workgroupForm = new WorkgroupForm();
workgroupForm.setType(IQ.Type.GET); workgroupForm.setType(IQ.Type.GET);
workgroupForm.setTo(workgroupJID); workgroupForm.setTo(workgroupJID);

Some files were not shown because too many files have changed in this diff Show more