1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-02 06:45:59 +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 org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.Registration;
@ -89,8 +90,9 @@ public class AccountManager extends Manager {
* @return true if the server support creating new accounts.
* @throws XMPPErrorException
* @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
if (accountCreationSupported) {
return true;
@ -130,8 +132,9 @@ public class AccountManager extends Manager {
* @return the required account attributes.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*/
public Collection<String> getAccountAttributes() throws NoResponseException, XMPPErrorException {
public Collection<String> getAccountAttributes() throws NoResponseException, XMPPErrorException, NotConnectedException {
if (info == null) {
getRegistrationInfo();
}
@ -152,8 +155,9 @@ public class AccountManager extends Manager {
* attribute wasn't found for the requested name.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*/
public String getAccountAttribute(String name) throws NoResponseException, XMPPErrorException {
public String getAccountAttribute(String name) throws NoResponseException, XMPPErrorException, NotConnectedException {
if (info == null) {
getRegistrationInfo();
}
@ -168,8 +172,9 @@ public class AccountManager extends Manager {
* @return the account creation instructions, or <tt>null</tt> if there are none.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*/
public String getAccountInstructions() throws NoResponseException, XMPPErrorException {
public String getAccountInstructions() throws NoResponseException, XMPPErrorException, NotConnectedException {
if (info == null) {
getRegistrationInfo();
}
@ -188,8 +193,9 @@ public class AccountManager extends Manager {
* @param password the password.
* @throws XMPPErrorException
* @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.
Map<String, String> attributes = new HashMap<String, String>();
for (String attributeName : getAccountAttributes()) {
@ -208,10 +214,11 @@ public class AccountManager extends Manager {
* @param attributes the account attributes.
* @throws XMPPErrorException if an error occurs creating the account.
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
* @see #getAccountAttributes()
*/
public void createAccount(String username, String password, Map<String, String> attributes)
throws NoResponseException, XMPPErrorException {
throws NoResponseException, XMPPErrorException, NotConnectedException {
Registration reg = new Registration();
reg.setType(IQ.Type.SET);
reg.setTo(connection().getServiceName());
@ -229,8 +236,9 @@ public class AccountManager extends Manager {
* @throws IllegalStateException if not currently logged-in to the server.
* @throws XMPPErrorException if an error occurs when changing the password.
* @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();
reg.setType(IQ.Type.SET);
reg.setTo(connection().getServiceName());
@ -249,8 +257,9 @@ public class AccountManager extends Manager {
* @throws IllegalStateException if not currently logged-in to the server.
* @throws XMPPErrorException if an error occurs when deleting the account.
* @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();
reg.setType(IQ.Type.SET);
reg.setTo(connection().getServiceName());
@ -265,11 +274,12 @@ public class AccountManager extends Manager {
* Gets the account registration info from the server.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*
* @throws XMPPException if an error occurs.
* @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();
reg.setTo(connection().getServiceName());
info = (Registration) connection().createPacketCollectorAndSend(reg).nextResultOrThrow();

View file

@ -17,6 +17,7 @@
package org.jivesoftware.smack;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.packet.Message;
import java.util.Set;
@ -86,8 +87,9 @@ public class Chat {
*
* @param text the text to send.
* @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.setThread(threadID);
message.setBody(text);
@ -99,8 +101,9 @@ public class Chat {
* and message type of the message will automatically set to those of this chat.
*
* @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
// to send the message through this chat object.
message.setTo(participant);

View file

@ -26,6 +26,7 @@ import java.util.UUID;
import java.util.WeakHashMap;
import java.util.concurrent.CopyOnWriteArraySet;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.filter.AndFilter;
import org.jivesoftware.smack.filter.FromMatchesFilter;
import org.jivesoftware.smack.filter.PacketFilter;
@ -334,7 +335,7 @@ public class ChatManager extends Manager{
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()) {
PacketFilter filter = interceptor.getValue();
if(filter != null && filter.accept(message)) {

View file

@ -17,6 +17,7 @@
package org.jivesoftware.smack;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.packet.Packet;
/**
@ -40,6 +41,6 @@ public interface PacketListener {
*
* @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 org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.SmackException.NotLoggedInException;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.filter.IQReplyFilter;
@ -132,12 +133,22 @@ public class Roster {
public void connectionClosed() {
// 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) {
// 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 {
reload();
}
catch (NotLoggedInException e) {
catch (SmackException e) {
LOGGER.log(Level.SEVERE, "Could not reload Roster", e);
}
}
@ -162,7 +173,7 @@ public class Roster {
try {
Roster.this.reload();
}
catch (NotLoggedInException e) {
catch (SmackException e) {
LOGGER.log(Level.SEVERE, "Could not reload Roster", e);
return;
}
@ -205,8 +216,9 @@ public class Roster {
* 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.
* @throws NotLoggedInException If not logged in.
* @throws NotConnectedException
*/
public void reload() throws NotLoggedInException{
public void reload() throws NotLoggedInException, NotConnectedException{
if (!connection.isAuthenticated()) {
throw new NotLoggedInException();
}
@ -285,9 +297,10 @@ public class Roster {
* @throws NoResponseException if there was no response from the server.
* @throws XMPPErrorException if an XMPP exception occurs.
* @throws NotLoggedInException If not logged in.
* @throws NotConnectedException
* @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()) {
throw new NotLoggedInException();
}
@ -325,9 +338,10 @@ public class Roster {
* @throws XMPPErrorException if an XMPP error occurs.
* @throws NotLoggedInException if not logged in.
* @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
*/
public void removeEntry(RosterEntry entry) throws NotLoggedInException, NoResponseException, XMPPErrorException {
public void removeEntry(RosterEntry entry) throws NotLoggedInException, NoResponseException, XMPPErrorException, NotConnectedException {
if (!connection.isAuthenticated()) {
throw new NotLoggedInException();
}
@ -626,8 +640,9 @@ public class Roster {
* Changes the presence of available contacts offline by simulating an unavailable
* presence sent from the server. After a disconnection, every Presence is set
* to offline.
* @throws NotConnectedException
*/
private void setOfflinePresences() {
private void setOfflinePresences() throws NotConnectedException {
Presence packetUnavailable;
for (String user : presenceMap.keySet()) {
Map<String, Presence> resources = presenceMap.get(user);
@ -813,7 +828,7 @@ public class Roster {
*/
private class PresencePacketListener implements PacketListener {
public void processPacket(Packet packet) {
public void processPacket(Packet packet) throws NotConnectedException {
Presence presence = (Presence) packet;
String from = presence.getFrom();
String key = getPresenceMapKey(from);
@ -1024,7 +1039,7 @@ public class Roster {
*/
private class RosterPushListener implements PacketListener {
public void processPacket(Packet packet) {
public void processPacket(Packet packet) throws NotConnectedException {
RosterPacket rosterPacket = (RosterPacket) packet;
if (!rosterPacket.getType().equals(IQ.Type.SET)) {
return;

View file

@ -17,6 +17,7 @@
package org.jivesoftware.smack;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.RosterPacket;
@ -78,8 +79,9 @@ public class RosterEntry {
* Sets the name associated with this entry.
*
* @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.
if (name != null && name.equals(this.name)) {
return;

View file

@ -24,6 +24,7 @@ import java.util.LinkedHashSet;
import java.util.Set;
import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.packet.IQ;
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.
*
* @param name the name of the group.
* @throws NotConnectedException
*/
public void setName(String name) {
public void setName(String name) throws NotConnectedException {
synchronized (entries) {
for (RosterEntry entry : entries) {
RosterPacket packet = new RosterPacket();
@ -162,8 +164,9 @@ public class RosterGroup {
* @param entry a roster entry.
* @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 NotConnectedException
*/
public void addEntry(RosterEntry entry) throws NoResponseException, XMPPErrorException {
public void addEntry(RosterEntry entry) throws NoResponseException, XMPPErrorException, NotConnectedException {
PacketCollector collector = null;
// Only add the entry if it isn't already in the list.
synchronized (entries) {
@ -192,8 +195,9 @@ public class RosterGroup {
* @param entry a roster entry.
* @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 NotConnectedException
*/
public void removeEntry(RosterEntry entry) throws NoResponseException, XMPPErrorException {
public void removeEntry(RosterEntry entry) throws NoResponseException, XMPPErrorException, NotConnectedException {
PacketCollector collector = null;
// Only remove the entry if it's in the entry list.
// Remove the entry locally, if we wait for RosterPacketListenerprocess>>Packet(Packet)

View file

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

View file

@ -41,6 +41,7 @@ import java.util.logging.Logger;
import javax.security.sasl.SaslException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.SmackException.ConnectionException;
import org.jivesoftware.smack.compression.XMPPInputOutputStream;
import org.jivesoftware.smack.debugger.SmackDebugger;
@ -438,10 +439,11 @@ public abstract class XMPPConnection {
* Sends the specified packet to the server.
*
* @param packet the packet to send.
* @throws NotConnectedException
*/
public void sendPacket(Packet packet) {
public void sendPacket(Packet packet) throws NotConnectedException {
if (!isConnected()) {
throw new IllegalStateException("Not connected to server.");
throw new NotConnectedException();
}
if (packet == null) {
throw new NullPointerException("Packet is null.");
@ -627,8 +629,9 @@ public abstract class XMPPConnection {
*
* @param packet the packet to filter responses from
* @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);
// Create the packet collector before sending the packet
PacketCollector packetCollector = createPacketCollector(packetFilter);
@ -755,7 +758,13 @@ public abstract class XMPPConnection {
private void firePacketSendingListeners(Packet packet) {
// Notify the listeners of the new sent packet
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()) {
try {
listenerWrapper.notifyListener(packet);
} catch(NotConnectedException e) {
LOGGER.log(Level.WARNING, "Got not connected exception, aborting", e);
break;
} catch (Exception 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.
*
* @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)) {
packetListener.processPacket(packet);
}

View file

@ -17,8 +17,10 @@
package org.jivesoftware.smack.sasl;
import org.jivesoftware.smack.SASLAuthentication;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import java.io.IOException;
import javax.security.auth.callback.CallbackHandler;
/**
@ -36,20 +38,20 @@ public class SASLAnonymous extends SASLMechanism {
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();
}
public void authenticate(String username, String host, String password) throws IOException {
public void authenticate(String username, String host, String password) throws IOException, NotConnectedException {
authenticate();
}
protected void authenticate() throws IOException {
protected void authenticate() throws IOException, NotConnectedException {
// Send the authentication to the server
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
// and send the authentication to the server
getSASLAuthentication().send(new Response());

View file

@ -17,6 +17,7 @@
package org.jivesoftware.smack.sasl;
import org.jivesoftware.smack.SASLAuthentication;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import java.io.IOException;
import java.util.Map;
@ -55,8 +56,9 @@ public class SASLGSSAPIMechanism extends SASLMechanism {
* @param host the hostname where the user account resides.
* @param cbh the CallbackHandler (not used with GSSAPI)
* @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() };
Map<String,String> props = new HashMap<String,String>();
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 password the password of the user (ignored for GSSAPI)
* @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() };
Map<String,String> props = new HashMap<String, String>();
props.put(Sasl.SERVER_AUTH,"TRUE");

View file

@ -17,12 +17,14 @@
package org.jivesoftware.smack.sasl;
import org.jivesoftware.smack.SASLAuthentication;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.util.StringUtils;
import java.io.IOException;
import java.util.Map;
import java.util.HashMap;
import javax.security.auth.callback.CallbackHandler;
import javax.security.auth.callback.UnsupportedCallbackException;
import javax.security.auth.callback.Callback;
@ -129,8 +131,9 @@ public abstract class SASLMechanism implements CallbackHandler {
* @param password the password for this account.
* @throws IOException If a network error occurs while authenticating.
* @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
//information
@ -153,15 +156,16 @@ public abstract class SASLMechanism implements CallbackHandler {
* @param cbh the CallbackHandler to obtain user information.
* @throws IOException If a network error occures while authenticating.
* @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() };
Map<String,String> props = new HashMap<String,String>();
sc = Sasl.createSaslClient(mechanisms, null, "xmpp", host, props, cbh);
authenticate();
}
protected void authenticate() throws IOException, SaslException {
protected void authenticate() throws IOException, SaslException, NotConnectedException {
String authenticationText = null;
if (sc.hasInitialResponse()) {
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.
* @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[];
if(challenge != null) {
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.TimeUnit;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.ConnectionConfiguration;
import org.jivesoftware.smack.ConnectionCreationListener;
@ -249,7 +250,12 @@ public class DummyConnection extends XMPPConnection {
// Deliver the incoming packet to listeners.
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.LinkedBlockingQueue;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.Packet;
@ -37,7 +38,12 @@ public class ThreadedDummyConnection extends DummyConnection {
@Override
public void sendPacket(Packet packet) {
super.sendPacket(packet);
try {
super.sendPacket(packet);
}
catch (NotConnectedException e) {
e.printStackTrace();
}
if (packet instanceof IQ && !timeout) {
timeout = false;

View file

@ -20,6 +20,7 @@ package org.jivesoftware.smackx.debugger;
import org.jivesoftware.smack.AbstractConnectionListener;
import org.jivesoftware.smack.ConnectionListener;
import org.jivesoftware.smack.PacketListener;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.debugger.SmackDebugger;
import org.jivesoftware.smack.packet.IQ;
@ -36,6 +37,7 @@ import javax.swing.text.BadLocationException;
import javax.xml.transform.*;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
import java.awt.*;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;
@ -545,7 +547,12 @@ public class EnhancedDebugger implements SmackDebugger {
public void actionPerformed(ActionEvent e) {
if (!"".equals(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.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.ConnectionCreationListener;
import org.jivesoftware.smack.Manager;
@ -113,8 +114,9 @@ public class CarbonManager extends Manager {
* You should first check for support using isSupportedByServer().
*
* @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);
connection().addPacketListener(new PacketListener() {
@ -140,10 +142,11 @@ public class CarbonManager extends Manager {
* @param new_state whether carbons should be enabled or disabled
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*
*/
public synchronized void setCarbonsEnabled(final boolean new_state) throws NoResponseException,
XMPPErrorException {
XMPPErrorException, NotConnectedException {
if (enabled_state == new_state)
return;

View file

@ -20,6 +20,7 @@ package org.jivesoftware.smackx.address;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.FeatureNotSupportedException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
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
* some JEP-33 specific features were requested.
* @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);
}
@ -98,9 +100,10 @@ public class MultipleRecipientManager {
* @throws NoResponseException if there was no response from the server.
* @throws FeatureNotSupportedException if special XEP-33 features where requested, but the
* server does not support them.
* @throws NotConnectedException
*/
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);
if (serviceAddress != null) {
// 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,
List<String> to, List<String> cc, List<String> bcc) {
List<String> to, List<String> cc, List<String> bcc) throws NotConnectedException {
if (to != null) {
for (Iterator<String> it = to.iterator(); it.hasNext();) {
String jid = it.next();
@ -232,7 +235,7 @@ public class MultipleRecipientManager {
private static void sendThroughService(XMPPConnection connection, Packet packet, List<String> to,
List<String> cc, List<String> bcc, String replyTo, String replyRoom, boolean noReply,
String serviceAddress) {
String serviceAddress) throws NotConnectedException {
// Create multiple recipient extension
MultipleAddresses multipleAddresses = new MultipleAddresses();
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.
* @throws NoResponseException if there was no response from the server.
* @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 serviceAddress = (String) services.get(serviceName);
if (serviceAddress == null) {

View file

@ -17,6 +17,7 @@
package org.jivesoftware.smackx.amp;
import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smackx.amp.packet.AMPExtension;
@ -31,8 +32,9 @@ public class AMPDeliverCondition implements AMPExtension.Condition {
* @return true if deliver condition is supported.
* @throws XMPPErrorException
* @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);
}

View file

@ -17,6 +17,7 @@
package org.jivesoftware.smackx.amp;
import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.util.XmppDateTime;
@ -35,8 +36,9 @@ public class AMPExpireAtCondition implements AMPExtension.Condition {
* @return true if expire-at condition is supported.
* @throws XMPPErrorException
* @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);
}

View file

@ -17,6 +17,7 @@
package org.jivesoftware.smackx.amp;
import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.ConnectionCreationListener;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
@ -86,8 +87,9 @@ public class AMPManager {
* @return true if this action is supported.
* @throws XMPPErrorException
* @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();
return isFeatureSupportedByServer(connection, featureName, AMPExtension.NAMESPACE);
}
@ -99,16 +101,17 @@ public class AMPManager {
* @return true if this condition is supported.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
* @see AMPDeliverCondition
* @see AMPExpireAtCondition
* @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;
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);
DiscoverInfo info = discoveryManager.discoverInfo(connection.getServiceName(), node);
Iterator<DiscoverInfo.Feature> it = info.getFeatures();

View file

@ -17,6 +17,7 @@
package org.jivesoftware.smackx.amp;
import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
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.
* @throws XMPPErrorException
* @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);
}

View file

@ -19,6 +19,7 @@ package org.jivesoftware.smackx.bookmarks;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
@ -92,9 +93,10 @@ public class BookmarkManager {
* @return returns all currently bookmarked conferences
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
* @see BookmarkedConference
*/
public Collection<BookmarkedConference> getBookmarkedConferences() throws NoResponseException, XMPPErrorException {
public Collection<BookmarkedConference> getBookmarkedConferences() throws NoResponseException, XMPPErrorException, NotConnectedException {
retrieveBookmarks();
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
* the server.
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
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();
BookmarkedConference bookmark
@ -141,10 +144,11 @@ public class BookmarkManager {
* @throws XMPPErrorException thrown when there is a problem with the connection attempting to
* retrieve the bookmarks or persist the bookmarks.
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
* @throws IllegalArgumentException thrown when the conference being removed is a shared
* conference
*/
public void removeBookmarkedConference(String jid) throws NoResponseException, XMPPErrorException {
public void removeBookmarkedConference(String jid) throws NoResponseException, XMPPErrorException, NotConnectedException {
retrieveBookmarks();
Iterator<BookmarkedConference> it = bookmarks.getBookmarkedConferences().iterator();
while(it.hasNext()) {
@ -166,8 +170,9 @@ public class BookmarkManager {
* @return returns an unmodifiable collection of all bookmarked urls.
* @throws XMPPErrorException thrown when there is a problem retriving bookmarks 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();
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
* 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();
BookmarkedURL bookmark = new BookmarkedURL(URL, name, isRSS);
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
* 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();
Iterator<BookmarkedURL> it = bookmarks.getBookmarkedURLS().iterator();
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) {
if(bookmarks == null) {
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.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamRequest;
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.
* @throws NotConnectedException
*/
public void reject();
public void reject() throws NotConnectedException;
}

View file

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

View file

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

View file

@ -27,6 +27,7 @@ import java.util.concurrent.ConcurrentHashMap;
import org.jivesoftware.smack.AbstractConnectionListener;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.ConnectionCreationListener;
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
* user prefers smaller block sizes
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
public InBandBytestreamSession establishSession(String targetJID, String sessionID)
throws NoResponseException, XMPPErrorException {
throws NoResponseException, XMPPErrorException, NotConnectedException {
Open byteStreamRequest = new Open(sessionID, this.defaultBlockSize, this.stanza);
byteStreamRequest.setTo(targetJID);
@ -446,8 +448,9 @@ public class InBandBytestreamManager implements BytestreamManager {
* not accepted.
*
* @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);
IQ error = IQ.createErrorResponse(request, xmppError);
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.
*
* @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);
IQ error = IQ.createErrorResponse(request, xmppError);
this.connection.sendPacket(error);
@ -470,8 +474,9 @@ public class InBandBytestreamManager implements BytestreamManager {
* session could not be found.
*
* @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);
IQ error = IQ.createErrorResponse(request, xmppError);
this.connection.sendPacket(error);

View file

@ -16,6 +16,7 @@
*/
package org.jivesoftware.smackx.bytestreams.ibb;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smackx.bytestreams.BytestreamRequest;
@ -66,8 +67,9 @@ public class InBandBytestreamRequest implements BytestreamRequest {
* 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();
// 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
* initiator.
* @throws NotConnectedException
*/
public void reject() {
public void reject() throws NotConnectedException {
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.TimeUnit;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.PacketListener;
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.
*
* @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
@ -445,7 +447,7 @@ public class InBandBytestreamSession implements BytestreamSession {
private long lastSequence = -1;
public void processPacket(Packet packet) {
public void processPacket(Packet packet) throws NotConnectedException {
// get data packet extension
DataPacketExtension data = (DataPacketExtension) packet.getExtension(
DataPacketExtension.ELEMENT_NAME,
@ -607,8 +609,9 @@ public class InBandBytestreamSession implements BytestreamSession {
*
* @param data the data packet
* @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 {
if (this.isClosed) {
@ -709,7 +712,14 @@ public class InBandBytestreamSession implements BytestreamSession {
this.seq, enc);
// write to XMPP stream
writeToXML(data);
try {
writeToXML(data);
}
catch (NotConnectedException e) {
IOException ioException = new IOException();
ioException.initCause(e);
throw ioException;
}
// reset buffer pointer
bufferPointer = 0;
@ -790,7 +800,7 @@ public class InBandBytestreamSession implements BytestreamSession {
private class MessageIBBOutputStream extends IBBOutputStream {
@Override
protected synchronized void writeToXML(DataPacketExtension data) {
protected synchronized void writeToXML(DataPacketExtension data) throws NotConnectedException {
// create message stanza containing data packet
Message message = new Message(remoteJID);
message.addExtension(data);

View file

@ -18,8 +18,11 @@ package org.jivesoftware.smackx.bytestreams.ibb;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.jivesoftware.smack.PacketListener;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.filter.AndFilter;
import org.jivesoftware.smack.filter.IQTypeFilter;
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.ibb.packet.Open;
/**
* 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
@ -42,6 +46,7 @@ import org.jivesoftware.smackx.bytestreams.ibb.packet.Open;
* @author Henning Staib
*/
class InitiationListener implements PacketListener {
private static final Logger LOGGER = Logger.getLogger(InitiationListener.class.getName());
/* manager containing the listeners and the XMPP connection */
private final InBandBytestreamManager manager;
@ -67,12 +72,17 @@ class InitiationListener implements PacketListener {
initiationListenerExecutor.execute(new Runnable() {
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;
// 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.Executors;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.jivesoftware.smack.PacketListener;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.filter.AndFilter;
import org.jivesoftware.smack.filter.IQTypeFilter;
import org.jivesoftware.smack.filter.PacketFilter;
@ -38,6 +41,7 @@ import org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream;
* @author Henning Staib
*/
final class InitiationListener implements PacketListener {
private static final Logger LOGGER = Logger.getLogger(InitiationListener.class.getName());
/* manager containing the listeners and the XMPP connection */
private final Socks5BytestreamManager manager;
@ -63,12 +67,17 @@ final class InitiationListener implements PacketListener {
initiationListenerExecutor.execute(new Runnable() {
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;
// 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.NoResponseException;
import org.jivesoftware.smack.SmackException.FeatureNotSupportedException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.ConnectionCreationListener;
import org.jivesoftware.smack.XMPPException;
@ -536,8 +537,9 @@ public final class Socks5BytestreamManager implements BytestreamManager {
* otherwise <code>false</code>
* @throws XMPPErrorException
* @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);
}
@ -548,8 +550,9 @@ public final class Socks5BytestreamManager implements BytestreamManager {
* @return list of JIDs of 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 NotConnectedException
*/
private List<String> determineProxies() throws NoResponseException, XMPPErrorException {
private List<String> determineProxies() throws NoResponseException, XMPPErrorException, NotConnectedException {
ServiceDiscoveryManager serviceDiscoveryManager = ServiceDiscoveryManager.getInstanceFor(this.connection);
List<String> proxies = new ArrayList<String>();
@ -708,8 +711,9 @@ public final class Socks5BytestreamManager implements BytestreamManager {
* accepted.
*
* @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);
IQ errorIQ = IQ.createErrorResponse(packet, xmppError);
this.connection.sendPacket(errorIQ);

View file

@ -22,6 +22,7 @@ import java.util.Collection;
import java.util.concurrent.TimeoutException;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
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.
* @throws NotConnectedException
*/
public void reject() {
public void reject() throws NotConnectedException {
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
* XMPP exception.
* @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";
XMPPError error = new XMPPError(XMPPError.Condition.item_not_found, errorMessage);
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.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
@ -102,9 +103,10 @@ class Socks5ClientForInitiator extends Socks5Client {
* SOCKS5 proxy.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
* @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();
// if activation fails #nextResultOrThrow() throws an exception
connection.createPacketCollectorAndSend(activate).nextResultOrThrow();

View file

@ -18,6 +18,7 @@ package org.jivesoftware.smackx.caps;
import org.jivesoftware.smack.AbstractConnectionListener;
import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.ConnectionCreationListener;
import org.jivesoftware.smack.Manager;
@ -59,6 +60,8 @@ import java.util.SortedSet;
import java.util.TreeSet;
import java.util.WeakHashMap;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.io.IOException;
import java.security.MessageDigest;
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>
*/
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 ELEMENT = "c";
@ -351,7 +355,7 @@ public class EntityCapsManager extends Manager {
return entityCapsEnabled;
}
public void setEntityNode(String entityNode) {
public void setEntityNode(String entityNode) throws NotConnectedException {
this.entityNode = entityNode;
updateLocalEntityCaps();
}
@ -394,8 +398,9 @@ public class EntityCapsManager extends Manager {
* @return true if the entity supports Entity Capabilities.
* @throws XMPPErrorException
* @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);
}
@ -405,8 +410,9 @@ public class EntityCapsManager extends Manager {
* @return true if the user's server supports Entity Capabilities.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*/
public boolean areEntityCapsSupportedByServer() throws NoResponseException, XMPPErrorException {
public boolean areEntityCapsSupportedByServer() throws NoResponseException, XMPPErrorException, NotConnectedException {
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
* presence is send to inform others about your new Entity Caps node string.
* @throws NotConnectedException
*
*/
public void updateLocalEntityCaps() {
@ -472,7 +479,12 @@ public class EntityCapsManager extends Manager {
// to respect ConnectionConfiguration.isSendPresence()
if (connection != null && connection.isAuthenticated() && presenceSend) {
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.ChatManager;
import org.jivesoftware.smack.ChatManagerListener;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.Manager;
import org.jivesoftware.smack.MessageListener;
@ -101,8 +102,9 @@ public class ChatStateManager extends Manager {
*
* @param newState the new state of 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) {
throw new IllegalArgumentException("Arguments cannot be null.");
}

View file

@ -17,6 +17,7 @@
package org.jivesoftware.smackx.commands;
import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.packet.XMPPError;
import org.jivesoftware.smackx.commands.packet.AdHocCommandData;
@ -209,8 +210,9 @@ public abstract class AdHocCommand {
* the command it throws an XMPPException.
*
* @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
@ -221,8 +223,9 @@ public abstract class AdHocCommand {
*
* @param response the form answer of the previous stage.
* @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
@ -233,8 +236,9 @@ public abstract class AdHocCommand {
*
* @param response the form answer of the previous stage.
* @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
@ -243,8 +247,9 @@ public abstract class AdHocCommand {
* an XMPPException.
*
* @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
@ -252,8 +257,9 @@ public abstract class AdHocCommand {
* XMPPException.
*
* @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.

View file

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

View file

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

View file

@ -18,6 +18,7 @@
package org.jivesoftware.smackx.disco;
import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.ConnectionCreationListener;
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
PacketFilter packetFilter = new PacketTypeFilter(DiscoverItems.class);
PacketListener packetListener = new PacketListener() {
public void processPacket(Packet packet) {
public void processPacket(Packet packet) throws NotConnectedException {
XMPPConnection connection = connection();
if (connection == null) return;
DiscoverItems discoverItems = (DiscoverItems) packet;
@ -152,7 +153,7 @@ public class ServiceDiscoveryManager extends Manager {
// To add a new feature as supported use the #addFeature message
packetFilter = new PacketTypeFilter(DiscoverInfo.class);
packetListener = new PacketListener() {
public void processPacket(Packet packet) {
public void processPacket(Packet packet) throws NotConnectedException {
XMPPConnection connection = connection();
if (connection == null) return;
DiscoverInfo discoverInfo = (DiscoverInfo) packet;
@ -496,8 +497,9 @@ public class ServiceDiscoveryManager extends Manager {
* @return the discovered information.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*/
public DiscoverInfo discoverInfo(String entityID) throws NoResponseException, XMPPErrorException {
public DiscoverInfo discoverInfo(String entityID) throws NoResponseException, XMPPErrorException, NotConnectedException {
if (entityID == null)
return discoverInfo(null, null);
@ -540,8 +542,9 @@ public class ServiceDiscoveryManager extends Manager {
* @return the discovered information.
* @throws XMPPErrorException if the operation failed for some reason.
* @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
DiscoverInfo disco = new DiscoverInfo();
disco.setType(IQ.Type.GET);
@ -560,8 +563,9 @@ public class ServiceDiscoveryManager extends Manager {
* @return the discovered information.
* @throws XMPPErrorException if the operation failed for some reason.
* @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);
}
@ -575,8 +579,9 @@ public class ServiceDiscoveryManager extends Manager {
* @return the discovered items.
* @throws XMPPErrorException if the operation failed for some reason.
* @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
DiscoverItems disco = new DiscoverItems();
disco.setType(IQ.Type.GET);
@ -597,8 +602,9 @@ public class ServiceDiscoveryManager extends Manager {
* @return true if the server supports publishing of items.
* @throws XMPPErrorException
* @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);
return canPublishItems(info);
}
@ -626,8 +632,9 @@ public class ServiceDiscoveryManager extends Manager {
* @param discoverItems the DiscoveryItems to publish.
* @throws XMPPErrorException
* @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);
}
@ -642,8 +649,9 @@ public class ServiceDiscoveryManager extends Manager {
* @param discoverItems the DiscoveryItems to publish.
* @throws XMPPErrorException if the operation failed for some reason.
* @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.setTo(entityID);
@ -660,8 +668,9 @@ public class ServiceDiscoveryManager extends Manager {
* @return true if the entity supports the feature, false otherwise
* @throws XMPPErrorException
* @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);
return result.containsFeature(feature);
}

View file

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

View file

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

View file

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

View file

@ -20,6 +20,7 @@ import java.io.InputStream;
import java.io.OutputStream;
import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.filter.AndFilter;
@ -61,14 +62,14 @@ public class IBBTransferNegotiator extends StreamNegotiator {
}
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);
session.setCloseBothStreamsEnabled(true);
return session.getOutputStream();
}
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
* given session ID
@ -94,7 +95,7 @@ public class IBBTransferNegotiator extends StreamNegotiator {
return new String[] { InBandBytestreamManager.NAMESPACE };
}
InputStream negotiateIncomingStream(Packet streamInitiation) {
InputStream negotiateIncomingStream(Packet streamInitiation) throws NotConnectedException {
// build In-Band Bytestream request
InBandBytestreamRequest request = new ByteStreamRequest(this.manager,
(Open) streamInitiation);

View file

@ -19,6 +19,7 @@ package org.jivesoftware.smackx.filetransfer;
import org.jivesoftware.smack.PacketCollector;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
@ -80,7 +81,7 @@ public abstract class StreamNegotiator {
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,
getNamespaces());

View file

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

View file

@ -18,6 +18,7 @@
package org.jivesoftware.smackx.iqprivate;
import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.packet.IQ;
@ -170,8 +171,9 @@ public class PrivateDataManager {
* @return the private data.
* @throws XMPPErrorException
* @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.
IQ privateDataGet = new IQ() {
@ -202,8 +204,9 @@ public class PrivateDataManager {
* @param privateData the private data.
* @throws XMPPErrorException
* @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.
IQ privateDataSet = new IQ() {
public String getChildElementXML() {

View file

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

View file

@ -43,6 +43,7 @@ import org.jivesoftware.smack.PacketListener;
import org.jivesoftware.smack.SmackConfiguration;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException;
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.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*/
public static boolean isServiceEnabled(XMPPConnection connection, String user)
throws NoResponseException, XMPPErrorException {
throws NoResponseException, XMPPErrorException, NotConnectedException {
return ServiceDiscoveryManager.getInstanceFor(connection).supportsFeature(user,
discoNamespace);
}
@ -214,9 +216,10 @@ public class MultiUserChat {
* @return an Iterator on the rooms where the requested user has joined.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*/
public static Iterator<String> getJoinedRooms(XMPPConnection connection, String user)
throws NoResponseException, XMPPErrorException {
throws NoResponseException, XMPPErrorException, NotConnectedException {
ArrayList<String> answer = new ArrayList<String>();
// Send the disco packet to the user
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.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*/
public static RoomInfo getRoomInfo(XMPPConnection connection, String room)
throws NoResponseException, XMPPErrorException {
throws NoResponseException, XMPPErrorException, NotConnectedException {
DiscoverInfo info = ServiceDiscoveryManager.getInstanceFor(connection).discoverInfo(room);
return new RoomInfo(info);
}
@ -252,8 +256,9 @@ public class MultiUserChat {
* @return a collection with the XMPP addresses of the Multi-User Chat services.
* @throws XMPPErrorException
* @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>();
ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(connection);
DiscoverItems items = discoManager.discoverItems(connection.getServiceName());
@ -277,9 +282,10 @@ public class MultiUserChat {
* @return a collection of HostedRooms.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*/
public static Collection<HostedRoom> getHostedRooms(XMPPConnection connection,
String serviceName) throws NoResponseException, XMPPErrorException {
String serviceName) throws NoResponseException, XMPPErrorException, NotConnectedException {
List<HostedRoom> answer = new ArrayList<HostedRoom>();
ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(connection);
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
* 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 NotConnectedException
*/
public void join(String nickname) throws NoResponseException, XMPPErrorException {
public void join(String nickname) throws NoResponseException, XMPPErrorException, NotConnectedException {
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
* 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 NotConnectedException
*/
public synchronized void join(
String nickname,
String password,
DiscussionHistory history,
long timeout)
throws XMPPErrorException, NoResponseException {
throws XMPPErrorException, NoResponseException, NotConnectedException {
if (nickname == null || nickname.equals("")) {
throw new IllegalArgumentException("Nickname must not be null or blank.");
}
@ -503,8 +511,9 @@ public class MultiUserChat {
/**
* Leave the chat room.
* @throws NotConnectedException
*/
public synchronized void leave() {
public synchronized void leave() throws NotConnectedException {
// If not joined already, do nothing.
if (!joined) {
return;
@ -534,8 +543,9 @@ public class MultiUserChat {
* <tt>null</tt> if no configuration is possible.
* @throws XMPPErrorException if an error occurs asking the configuration form for the room.
* @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();
iq.setTo(room);
iq.setType(IQ.Type.GET);
@ -552,8 +562,9 @@ public class MultiUserChat {
* @param form the form with the new settings.
* @throws XMPPErrorException if an error occurs setting the new rooms' configuration.
* @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();
iq.setTo(room);
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
* 405 error if the user is not allowed to register with the room.
* @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();
reg.setType(IQ.Type.GET);
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;
* or a 503 error can occur if the room does not support registration.
* @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();
reg.setType(IQ.Type.SET);
reg.setTo(room);
@ -622,8 +635,9 @@ public class MultiUserChat {
* XMPP error code 403. The error code can be used to present more
* appropiate error messages to end-users.
* @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();
iq.setTo(room);
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 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);
}
@ -667,8 +682,9 @@ public class MultiUserChat {
* @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 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
message.setTo(room);
@ -692,8 +708,9 @@ public class MultiUserChat {
* @param room the room that sent the original invitation.
* @param inviter the inviter of the declined 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);
// Create the MUCUser packet that will include the rejection
@ -901,8 +918,9 @@ public class MultiUserChat {
* @param nickname the new nickname within the room.
* @throws XMPPErrorException if the new nickname is already in use by another occupant.
* @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("")) {
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 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("")) {
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
* 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 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);
}
@ -1003,8 +1023,9 @@ public class MultiUserChat {
* 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.
* @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");
}
@ -1019,8 +1040,9 @@ public class MultiUserChat {
* 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.
* @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);
}
@ -1035,8 +1057,9 @@ public class MultiUserChat {
* 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.
* @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");
}
@ -1051,8 +1074,9 @@ public class MultiUserChat {
* 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.
* @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);
}
@ -1068,8 +1092,9 @@ public class MultiUserChat {
* 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).
* @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");
}
@ -1086,8 +1111,9 @@ public class MultiUserChat {
* 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).
* @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);
}
@ -1099,8 +1125,9 @@ public class MultiUserChat {
* @param jids the XMPP user IDs of the users to grant membership.
* @throws XMPPErrorException if an error occurs granting membership to a user.
* @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");
}
@ -1112,8 +1139,9 @@ public class MultiUserChat {
* @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 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);
}
@ -1126,8 +1154,9 @@ public class MultiUserChat {
* @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 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");
}
@ -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").
* @throws XMPPErrorException if an error occurs revoking membership to a user.
* @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);
}
@ -1153,8 +1183,9 @@ public class MultiUserChat {
* @param nicknames the nicknames of the occupants to grant moderator privileges.
* @throws XMPPErrorException if an error occurs granting moderator privileges to a user.
* @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");
}
@ -1166,8 +1197,9 @@ public class MultiUserChat {
* @param nickname the nickname of the occupant to grant moderator privileges.
* @throws XMPPErrorException if an error occurs granting moderator privileges to a user.
* @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);
}
@ -1180,8 +1212,9 @@ public class MultiUserChat {
* @param nicknames the nicknames of the occupants to revoke moderator privileges.
* @throws XMPPErrorException if an error occurs revoking moderator privileges from a user.
* @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");
}
@ -1194,8 +1227,9 @@ public class MultiUserChat {
* @param nickname the nickname of the occupant to revoke moderator privileges.
* @throws XMPPErrorException if an error occurs revoking moderator privileges from a user.
* @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);
}
@ -1208,8 +1242,9 @@ public class MultiUserChat {
* @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 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");
}
@ -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").
* @throws XMPPErrorException if an error occurs granting ownership privileges to a user.
* @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);
}
@ -1235,8 +1271,9 @@ public class MultiUserChat {
* @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 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");
}
@ -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").
* @throws XMPPErrorException if an error occurs revoking ownership privileges from a user.
* @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);
}
@ -1261,8 +1299,9 @@ public class MultiUserChat {
* @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 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");
}
@ -1275,8 +1314,9 @@ public class MultiUserChat {
* (e.g. "user@host.org").
* @throws XMPPErrorException if an error occurs granting administrator privileges to a user.
* @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");
}
@ -1288,8 +1328,9 @@ public class MultiUserChat {
* @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 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");
}
@ -1302,13 +1343,14 @@ public class MultiUserChat {
* (e.g. "user@host.org").
* @throws XMPPErrorException if an error occurs revoking administrator privileges from a user.
* @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");
}
private void changeAffiliationByOwner(String jid, String affiliation)
throws XMPPErrorException, NoResponseException {
throws XMPPErrorException, NoResponseException, NotConnectedException {
MUCOwner iq = new MUCOwner();
iq.setTo(room);
iq.setType(IQ.Type.SET);
@ -1321,7 +1363,7 @@ public class MultiUserChat {
}
private void changeAffiliationByOwner(Collection<String> jids, String affiliation)
throws NoResponseException, XMPPErrorException {
throws NoResponseException, XMPPErrorException, NotConnectedException {
MUCOwner iq = new MUCOwner();
iq.setTo(room);
iq.setType(IQ.Type.SET);
@ -1343,8 +1385,9 @@ public class MultiUserChat {
* @param reason the reason for the affiliation change (optional)
* @throws XMPPErrorException
* @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();
iq.setTo(room);
@ -1359,7 +1402,7 @@ public class MultiUserChat {
}
private void changeAffiliationByAdmin(Collection<String> jids, String affiliation)
throws NoResponseException, XMPPErrorException {
throws NoResponseException, XMPPErrorException, NotConnectedException {
MUCAdmin iq = new MUCAdmin();
iq.setTo(room);
iq.setType(IQ.Type.SET);
@ -1373,7 +1416,7 @@ public class MultiUserChat {
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();
iq.setTo(room);
iq.setType(IQ.Type.SET);
@ -1386,7 +1429,7 @@ public class MultiUserChat {
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();
iq.setTo(room);
iq.setType(IQ.Type.SET);
@ -1491,8 +1534,9 @@ public class MultiUserChat {
* @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 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");
}
@ -1502,8 +1546,9 @@ public class MultiUserChat {
* @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 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");
}
@ -1513,8 +1558,9 @@ public class MultiUserChat {
* @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 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");
}
@ -1524,8 +1570,9 @@ public class MultiUserChat {
* @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 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");
}
@ -1537,8 +1584,9 @@ public class MultiUserChat {
* @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 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();
iq.setTo(room);
iq.setType(IQ.Type.GET);
@ -1562,8 +1610,9 @@ public class MultiUserChat {
* @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 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");
}
@ -1573,8 +1622,9 @@ public class MultiUserChat {
* @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 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");
}
@ -1586,8 +1636,9 @@ public class MultiUserChat {
* @throws XMPPErrorException if an error occured while performing the request to the server or you
* don't have enough privileges to get this information.
* @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();
iq.setTo(room);
iq.setType(IQ.Type.GET);
@ -1609,8 +1660,9 @@ public class MultiUserChat {
*
* @param text the text of the message to send.
* @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.setBody(text);
connection.sendPacket(message);
@ -1645,8 +1697,9 @@ public class MultiUserChat {
*
* @param message the message.
* @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);
}
@ -1724,8 +1777,9 @@ public class MultiUserChat {
* @throws XMPPErrorException if someone without appropriate privileges attempts to change the
* room subject will throw an error with code 403 (i.e. Forbidden)
* @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.setSubject(subject);
// Wait for an error or confirmation message back from the server.

View file

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

View file

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

View file

@ -20,6 +20,7 @@ package org.jivesoftware.smackx.offline;
import org.jivesoftware.smack.PacketCollector;
import org.jivesoftware.smack.SmackConfiguration;
import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
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.
* @throws XMPPErrorException If the user is not allowed to make this request.
* @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);
}
@ -90,8 +92,9 @@ public class OfflineMessageManager {
* @throws XMPPErrorException If the user is not allowed to make this request or the server does
* not support offline message retrieval.
* @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,
namespace);
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
* not support offline message retrieval.
* @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>();
DiscoverItems items = ServiceDiscoveryManager.getInstanceFor(connection).discoverItems(
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
* not support offline message retrieval.
* @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>();
OfflineMessageRequest request = new OfflineMessageRequest();
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
* not support offline message retrieval.
* @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>();
OfflineMessageRequest request = new OfflineMessageRequest();
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
* not support offline message retrieval.
* @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();
for (String node : nodes) {
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
* not support offline message retrieval.
* @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();
request.setPurge(true);
connection.createPacketCollectorAndSend(request).nextResultOrThrow();

View file

@ -21,6 +21,7 @@ import java.util.ArrayList;
import java.util.List;
import org.jivesoftware.smack.PacketListener;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.filter.PacketExtensionFilter;
import org.jivesoftware.smack.filter.PacketFilter;
@ -105,8 +106,9 @@ public class PEPManager {
* Publish an event.
*
* @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.
PEPPubSub pubSub = new PEPPubSub(item);
pubSub.setType(Type.SET);

View file

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

View file

@ -24,6 +24,7 @@ import java.util.Set;
import java.util.WeakHashMap;
import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.ConnectionCreationListener;
import org.jivesoftware.smack.Manager;
@ -88,7 +89,7 @@ public class PrivacyListManager extends Manager {
connection.addPacketListener(new PacketListener() {
@Override
public void processPacket(Packet packet) {
public void processPacket(Packet packet) throws NotConnectedException {
Privacy privacy = (Privacy) packet;
// 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.
* @throws XMPPErrorException
* @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
requestPrivacy.setType(Privacy.Type.GET);
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.
* @throws XMPPErrorException
* @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
requestPrivacy.setType(Privacy.Type.SET);
requestPrivacy.setFrom(this.getUser());
@ -176,8 +179,9 @@ public class PrivacyListManager extends Manager {
* @return a Privacy with the list names.
* @throws XMPPErrorException
* @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
Privacy request = new Privacy();
@ -191,8 +195,9 @@ public class PrivacyListManager extends Manager {
* @return the privacy list of the active list.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*/
public PrivacyList getActiveList() throws NoResponseException, XMPPErrorException {
public PrivacyList getActiveList() throws NoResponseException, XMPPErrorException, NotConnectedException {
Privacy privacyAnswer = this.getPrivacyWithListNames();
String listName = privacyAnswer.getActiveName();
boolean isDefaultAndActive = privacyAnswer.getActiveName() != null
@ -208,8 +213,9 @@ public class PrivacyListManager extends Manager {
* @return the privacy list of the default list.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*/
public PrivacyList getDefaultList() throws NoResponseException, XMPPErrorException {
public PrivacyList getDefaultList() throws NoResponseException, XMPPErrorException, NotConnectedException {
Privacy privacyAnswer = this.getPrivacyWithListNames();
String listName = privacyAnswer.getDefaultName();
boolean isDefaultAndActive = privacyAnswer.getActiveName() != null
@ -226,8 +232,9 @@ public class PrivacyListManager extends Manager {
* @return a list of privacy items under the list listName.
* @throws XMPPErrorException
* @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
Privacy request = new Privacy();
request.setPrivacyList(listName, new ArrayList<PrivacyItem>());
@ -245,8 +252,9 @@ public class PrivacyListManager extends Manager {
* @return a privacy list under the list listName.
* @throws XMPPErrorException
* @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));
}
@ -256,8 +264,9 @@ public class PrivacyListManager extends Manager {
* @return an array of privacy lists.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*/
public PrivacyList[] getPrivacyLists() throws NoResponseException, XMPPErrorException {
public PrivacyList[] getPrivacyLists() throws NoResponseException, XMPPErrorException, NotConnectedException {
Privacy privacyAnswer = this.getPrivacyWithListNames();
Set<String> names = privacyAnswer.getPrivacyListNames();
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.
* @throws XMPPErrorException
* @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
Privacy request = new Privacy();
request.setActiveName(listName);
@ -294,8 +304,9 @@ public class PrivacyListManager extends Manager {
* Client declines the use of active lists.
* @throws XMPPErrorException
* @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
Privacy request = new Privacy();
request.setDeclineActiveList(true);
@ -310,8 +321,9 @@ public class PrivacyListManager extends Manager {
* @param listName the list name to set as the default one.
* @throws XMPPErrorException
* @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
Privacy request = new Privacy();
request.setDefaultName(listName);
@ -324,8 +336,9 @@ public class PrivacyListManager extends Manager {
* Client declines the use of default lists.
* @throws XMPPErrorException
* @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
Privacy request = new Privacy();
request.setDeclineDefaultList(true);
@ -341,8 +354,9 @@ public class PrivacyListManager extends Manager {
* @param privacyItems a List with every privacy item in the list.
* @throws XMPPErrorException
* @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);
}
@ -355,8 +369,9 @@ public class PrivacyListManager extends Manager {
* @param privacyItems a List with every privacy item in the list.
* @throws XMPPErrorException
* @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
Privacy request = new Privacy();
request.setPrivacyList(listName, privacyItems);
@ -371,8 +386,9 @@ public class PrivacyListManager extends Manager {
* @param listName the list that has changed its content.
* @throws XMPPErrorException
* @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
Privacy request = new Privacy();
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.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*/
public boolean isSupported() throws NoResponseException, XMPPErrorException{
public boolean isSupported() throws NoResponseException, XMPPErrorException, NotConnectedException{
return ServiceDiscoveryManager.getInstanceFor(connection()).supportsFeature(
connection().getServiceName(), NAMESPACE);
}

View file

@ -21,6 +21,7 @@ import java.util.Collection;
import java.util.List;
import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.packet.IQ.Type;
@ -49,8 +50,9 @@ public class LeafNode extends Node
* @return The item details in {@link DiscoverItems} format
* @throws XMPPErrorException
* @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();
items.setTo(to);
@ -64,9 +66,10 @@ public class LeafNode extends Node
* @return List of {@link Item} in the node
* @throws XMPPErrorException
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
@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()));
@ -85,9 +88,10 @@ public class LeafNode extends Node
* @return List of {@link Item} in the node
* @throws XMPPErrorException
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
@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));
@ -108,9 +112,10 @@ public class LeafNode extends Node
* @return The list of {@link Item} with payload
* @throws XMPPErrorException
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
@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());
@ -133,9 +138,10 @@ public class LeafNode extends Node
* @return List of {@link Item}
* @throws XMPPErrorException
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
@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));
@ -155,9 +161,10 @@ public class LeafNode extends Node
* @return List of {@link Item}
* @throws XMPPErrorException
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
@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));
@ -177,8 +184,9 @@ public class LeafNode extends Node
* packet has been sent.
*
* 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()));
@ -199,9 +207,10 @@ public class LeafNode extends Node
* For synchronous calls use {@link #send(Item) send(Item))}.
*
* @param item - The item being sent
* @throws NotConnectedException
*/
@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);
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))}.
*
* @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));
@ -241,9 +251,10 @@ public class LeafNode extends Node
* For asynchronous calls, use {@link #publish() publish()}.
* @throws XMPPErrorException
* @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()));
@ -270,10 +281,11 @@ public class LeafNode extends Node
* @param item - The item being sent
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*
*/
@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);
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
* @throws XMPPErrorException
* @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));
@ -310,8 +323,9 @@ public class LeafNode extends Node
* sent.
* @throws XMPPErrorException
* @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());
@ -324,8 +338,9 @@ public class LeafNode extends Node
* @param itemId The id of the item
* @throws XMPPErrorException
* @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);
items.add(itemId);
@ -338,8 +353,9 @@ public class LeafNode extends Node
* @param itemIds The list of id's of items to delete
* @throws XMPPErrorException
* @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());

View file

@ -24,6 +24,7 @@ import java.util.concurrent.ConcurrentHashMap;
import org.jivesoftware.smack.PacketListener;
import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.filter.OrFilter;
@ -94,8 +95,9 @@ abstract public class Node
* @return the configuration form
* @throws XMPPErrorException
* @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);
return NodeUtils.getFormFromPacket(reply, PubSubElementType.CONFIGURE_OWNER);
@ -107,8 +109,9 @@ abstract public class Node
* @param submitForm
* @throws XMPPErrorException
* @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);
con.createPacketCollectorAndSend(packet).nextResultOrThrow();
@ -120,8 +123,9 @@ abstract public class Node
* @return The discovery information about the node.
* @throws XMPPErrorException
* @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();
info.setTo(to);
@ -135,9 +139,10 @@ abstract public class Node
* @return List of {@link Subscription}
* @throws XMPPErrorException
* @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()));
SubscriptionsExtension subElem = (SubscriptionsExtension)reply.getExtension(PubSubElementType.SUBSCRIPTIONS);
@ -159,8 +164,9 @@ abstract public class Node
* @return The subscription
* @throws XMPPErrorException
* @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()));
return (Subscription)reply.getExtension(PubSubElementType.SUBSCRIPTION);
@ -182,8 +188,9 @@ abstract public class Node
* @return The subscription
* @throws XMPPErrorException
* @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()));
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
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*
*/
public void unsubscribe(String jid) throws NoResponseException, XMPPErrorException
public void unsubscribe(String jid) throws NoResponseException, XMPPErrorException, NotConnectedException
{
unsubscribe(jid, null);
}
@ -213,8 +221,9 @@ abstract public class Node
* @param subscriptionId The id of the subscription being removed
* @throws XMPPErrorException
* @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));
}
@ -226,8 +235,9 @@ abstract public class Node
* @return A subscription options form
* @throws XMPPErrorException
* @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);
}
@ -242,9 +252,10 @@ abstract public class Node
* @return The subscription option form
* @throws XMPPErrorException
* @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));
FormNode ext = (FormNode)packet.getExtension(PubSubElementType.OPTIONS);
@ -349,12 +360,12 @@ abstract public class Node
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);
}
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);
}

View file

@ -21,6 +21,7 @@ import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.packet.IQ.Type;
@ -81,8 +82,9 @@ final public class PubSubManager
* @return The node that was created
* @throws XMPPErrorException
* @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));
NodeExtension elem = (NodeExtension)reply.getExtension("create", PubSubNamespace.BASIC.getXmlns());
@ -102,8 +104,9 @@ final public class PubSubManager
* @return The node that was created
* @throws XMPPErrorException
* @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);
}
@ -119,8 +122,9 @@ final public class PubSubManager
* @return The node that was created
* @throws XMPPErrorException
* @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));
boolean isLeafNode = true;
@ -152,9 +156,10 @@ final public class PubSubManager
* @return the node
* @throws XMPPErrorException The node does not exist
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
@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);
@ -189,8 +194,9 @@ final public class PubSubManager
* @return {@link DiscoverItems} representing the existing nodes
* @throws XMPPErrorException
* @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();
@ -207,8 +213,9 @@ final public class PubSubManager
* @return List of exceptions
* @throws XMPPErrorException
* @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));
SubscriptionsExtension subElem = (SubscriptionsExtension)reply.getExtension(PubSubElementType.SUBSCRIPTIONS.getElementName(), PubSubElementType.SUBSCRIPTIONS.getNamespace().getXmlns());
@ -221,9 +228,10 @@ final public class PubSubManager
* @return List of affiliations
* @throws XMPPErrorException
* @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));
AffiliationsExtension listElem = (AffiliationsExtension)reply.getExtension(PubSubElementType.AFFILIATIONS);
@ -236,8 +244,9 @@ final public class PubSubManager
* @param nodeId
* @throws XMPPErrorException
* @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());
nodeMap.remove(nodeId);
@ -249,8 +258,9 @@ final public class PubSubManager
* @return configuration form containing the default settings.
* @throws XMPPErrorException
* @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
// on success.
@ -265,19 +275,20 @@ final public class PubSubManager
* @return The supported features
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*/
public DiscoverInfo getSupportedFeatures() throws NoResponseException, XMPPErrorException
public DiscoverInfo getSupportedFeatures() throws NoResponseException, XMPPErrorException, NotConnectedException
{
ServiceDiscoveryManager mgr = ServiceDiscoveryManager.getInstanceFor(con);
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);
}
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);
}
@ -302,22 +313,22 @@ final public class PubSubManager
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);
}
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();
}
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);
}
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();
}

View file

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

View file

@ -17,6 +17,7 @@
package org.jivesoftware.smackx.search;
import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.packet.IQ;
@ -61,8 +62,9 @@ public class UserSearch extends IQ {
* @return the search form received by the server.
* @throws XMPPErrorException
* @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();
search.setType(IQ.Type.GET);
search.setTo(searchService);
@ -80,8 +82,9 @@ public class UserSearch extends IQ {
* @return ReportedData the data found from the query.
* @throws XMPPErrorException
* @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();
search.setType(IQ.Type.SET);
search.setTo(searchService);
@ -100,8 +103,9 @@ public class UserSearch extends IQ {
* @return ReportedData the data found from the query.
* @throws XMPPErrorException
* @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();
search.setForm(searchForm);
search.setType(IQ.Type.SET);

View file

@ -17,6 +17,7 @@
package org.jivesoftware.smackx.search;
import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
@ -70,8 +71,9 @@ public class UserSearchManager {
* @return the form to fill out to perform a search.
* @throws XMPPErrorException
* @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);
}
@ -84,8 +86,9 @@ public class UserSearchManager {
* @return the ReportedData returned by the server.
* @throws XMPPErrorException
* @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);
}
@ -96,8 +99,9 @@ public class UserSearchManager {
* @return a Collection of search services found on the server.
* @throws XMPPErrorException
* @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>();
ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(con);
DiscoverItems items = discoManager.discoverItems(con.getServiceName());

View file

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

View file

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

View file

@ -18,6 +18,7 @@ package org.jivesoftware.smackx.vcardtemp;
import org.jivesoftware.smack.ConnectionCreationListener;
import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
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.
* @throws XMPPErrorException
* @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);
}
}

View file

@ -34,6 +34,7 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.packet.IQ;
@ -518,8 +519,9 @@ public class VCard extends IQ {
* @param connection the XMPPConnection to use.
* @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 NotConnectedException
*/
public void save(XMPPConnection connection) throws NoResponseException, XMPPErrorException {
public void save(XMPPConnection connection) throws NoResponseException, XMPPErrorException, NotConnectedException {
checkAuthenticated(connection, true);
setType(IQ.Type.SET);
@ -532,8 +534,9 @@ public class VCard extends IQ {
* and not anonymous.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*/
public void load(XMPPConnection connection) throws NoResponseException, XMPPErrorException {
public void load(XMPPConnection connection) throws NoResponseException, XMPPErrorException, NotConnectedException {
checkAuthenticated(connection, true);
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.
* @throws XMPPErrorException
* @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);
setTo(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);
VCard result = (VCard) connection.createPacketCollectorAndSend(this).nextResultOrThrow();
copyFieldsFrom(result);

View file

@ -17,6 +17,8 @@
package org.jivesoftware.smackx.xevent;
import org.jivesoftware.smack.SmackException.NotConnectedException;
/**
*
* Default implementation of the MessageEventRequestListener interface.<p>
@ -29,7 +31,7 @@ package org.jivesoftware.smackx.xevent;
public class DefaultMessageEventRequestListener implements MessageEventRequestListener {
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
messageEventManager.sendDeliveredNotification(from, packetID);

View file

@ -25,6 +25,7 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import org.jivesoftware.smack.PacketListener;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.filter.PacketExtensionFilter;
import org.jivesoftware.smack.filter.PacketFilter;
@ -221,8 +222,9 @@ public class MessageEventManager {
*
* @param to the recipient of the notification.
* @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
Message msg = new Message(to);
// 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 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
Message msg = new Message(to);
// 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 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
Message msg = new Message(to);
// 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 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
Message msg = new Message(to);
// Create a MessageEvent Package and add it to the message

View file

@ -17,6 +17,8 @@
package org.jivesoftware.smackx.xevent;
import org.jivesoftware.smack.SmackException.NotConnectedException;
/**
*
* 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 packetID the id of the message that was sent.
* @param messageEventManager the messageEventManager that fired the listener.
* @throws NotConnectedException
*/
public void deliveredNotificationRequested(String from, String packetID,
MessageEventManager messageEventManager);
MessageEventManager messageEventManager) throws NotConnectedException;
/**
* 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.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.packet.Message;
@ -128,9 +129,10 @@ public class XHTMLManager {
* @return a boolean indicating whether the specified user handles XHTML messages
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*/
public static boolean isServiceEnabled(XMPPConnection connection, String userID)
throws NoResponseException, XMPPErrorException {
throws NoResponseException, XMPPErrorException, NotConnectedException {
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.mockito.Mockito.*;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.XMPPError;
@ -66,9 +67,10 @@ public class InBandBytestreamRequestTest {
/**
* Test reject() method.
* @throws NotConnectedException
*/
@Test
public void shouldReplyWithErrorIfRequestIsRejected() {
public void shouldReplyWithErrorIfRequestIsRejected() throws NotConnectedException {
InBandBytestreamRequest ibbRequest = new InBandBytestreamRequest(
byteStreamManager, initBytestream);

View file

@ -20,6 +20,7 @@ import java.util.ArrayList;
import java.util.List;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smackx.jingle.listeners.JingleListener;
@ -254,7 +255,7 @@ public class ContentNegotiator extends JingleNegotiator {
return result;
}
public void triggerContentEstablished() {
public void triggerContentEstablished() throws NotConnectedException {
PayloadType bestCommonAudioPt = getMediaNegotiator().getBestCommonAudioPt();
TransportCandidate bestRemoteCandidate = getTransportNegotiator().getBestRemoteCandidate();
@ -266,8 +267,9 @@ public class ContentNegotiator extends JingleNegotiator {
/**
* 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.
JingleSession session = getSession();

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -17,6 +17,7 @@
package org.jivesoftware.smackx.jingle.listeners;
import org.jivesoftware.smack.SmackException.NotConnectedException;
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.
*
* @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

View file

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

View file

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

View file

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

View file

@ -16,6 +16,7 @@
*/
package org.jivesoftware.smackx.jingle.nat;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smackx.jingle.JingleSession;
@ -43,8 +44,9 @@ public class BasicResolver extends TransportResolver {
* <p/>
* The BasicResolver takes the IP addresses of the interfaces and uses the
* 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();

View file

@ -17,6 +17,7 @@
package org.jivesoftware.smackx.jingle.nat;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
@ -58,8 +59,9 @@ public class BridgedResolver extends TransportResolver {
* Resolve Bridged Candidate.
* <p/>
* 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();

View file

@ -16,6 +16,7 @@
*/
package org.jivesoftware.smackx.jingle.nat;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException;
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
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);
}

View file

@ -16,6 +16,7 @@
*/
package org.jivesoftware.smackx.jingle.nat;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smackx.jingle.JingleSession;
@ -50,8 +51,9 @@ public class FixedResolver extends TransportResolver {
/**
* 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()) {
setResolveInit();

View file

@ -17,6 +17,7 @@
package org.jivesoftware.smackx.jingle.nat;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException;
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
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 (((ICECandidate) lc).getType().equals("relay")) {
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 org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.PacketCollector;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
@ -383,8 +384,9 @@ public class RTPBridge extends IQ {
* @param connection
* @param sessionID
* @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()) {
return null;
@ -410,9 +412,10 @@ public class RTPBridge extends IQ {
* @return true if the server supports the RTPBridge service
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*/
public static boolean serviceAvailable(XMPPConnection connection) throws NoResponseException,
XMPPErrorException {
XMPPErrorException, NotConnectedException {
if (!connection.isConnected()) {
return false;
@ -448,8 +451,9 @@ public class RTPBridge extends IQ {
*
* @param connection
* @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()) {
return null;
@ -482,8 +486,9 @@ public class RTPBridge extends IQ {
*
* @param xmppConnection
* @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()) {
return null;

View file

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

View file

@ -26,6 +26,7 @@ import java.util.Enumeration;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smackx.jingle.JingleSession;
import org.xmlpull.v1.XmlPullParserFactory;
@ -262,8 +263,9 @@ public class STUNResolver extends TransportResolver {
/**
* 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();

View file

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

View file

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

View file

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

View file

@ -16,6 +16,8 @@
*/
package org.jivesoftware.smackx.jingle.nat;
import org.jivesoftware.smack.SmackException.NotConnectedException;
/**
* Transport resolver Interface
*/
@ -33,8 +35,9 @@ public abstract interface TransportResolverListener {
* A transport candidate has been added
*
* @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.

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.AgentWorkgroups;
import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.packet.IQ;
@ -35,7 +36,7 @@ public class Agent {
private XMPPConnection connection;
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);
request.setTo(serviceJID);
AgentWorkgroups response = (AgentWorkgroups) connection.createPacketCollectorAndSend(request).nextResultOrThrow();
@ -65,8 +66,9 @@ public class Agent {
* @return - the agents name.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*/
public String getName() throws NoResponseException, XMPPErrorException {
public String getName() throws NoResponseException, XMPPErrorException, NotConnectedException {
AgentInfo agentInfo = new AgentInfo();
agentInfo.setType(IQ.Type.GET);
agentInfo.setTo(workgroupJID);
@ -84,8 +86,9 @@ public class Agent {
* @param newName the new name of the agent.
* @throws XMPPErrorException
* @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.setType(IQ.Type.SET);
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.AgentStatusRequest;
import org.jivesoftware.smack.PacketListener;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.filter.PacketFilter;
import org.jivesoftware.smack.filter.PacketTypeFilter;
@ -62,8 +63,9 @@ public class AgentRoster {
* Constructs a new AgentRoster.
*
* @param connection an XMPP connection.
* @throws NotConnectedException
*/
AgentRoster(XMPPConnection connection, String workgroupJID) {
AgentRoster(XMPPConnection connection, String workgroupJID) throws NotConnectedException {
this.connection = connection;
this.workgroupJID = workgroupJID;
entries = new ArrayList<String>();
@ -86,8 +88,9 @@ public class AgentRoster {
* Reloads the entire roster from the server. This is an asynchronous operation,
* 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.
* @throws NotConnectedException
*/
public void reload() {
public void reload() throws NotConnectedException {
AgentStatusRequest request = new AgentStatusRequest();
request.setTo(workgroupJID);
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.smack.*;
import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.filter.*;
import org.jivesoftware.smack.packet.*;
@ -143,8 +144,9 @@ public class AgentSession {
* Returns the agent roster for the workgroup, which contains
*
* @return the AgentRoster
* @throws NotConnectedException
*/
public AgentRoster getAgentRoster() {
public AgentRoster getAgentRoster() throws NotConnectedException {
if (agentRoster == null) {
agentRoster = new AgentRoster(connection, workgroupJID);
}
@ -340,10 +342,11 @@ public class AgentSession {
* @param status sets the status message of the presence update.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
* @throws IllegalStateException if the agent is not online with the workgroup.
*/
public void setStatus(Presence.Mode presenceMode, int maxChats, String status)
throws NoResponseException, XMPPErrorException {
throws NoResponseException, XMPPErrorException, NotConnectedException {
if (!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.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
* @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) {
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.
* @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.
DepartQueuePacket departPacket = new DepartQueuePacket(this.workgroupJID);
@ -500,8 +505,9 @@ public class AgentSession {
* @return information about the occupants of the specified room.
* @throws XMPPErrorException
* @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);
request.setType(IQ.Type.GET);
request.setTo(workgroupJID);
@ -658,7 +664,7 @@ public class AgentSession {
// PacketListener Implementation.
private void handlePacket(Packet packet) {
private void handlePacket(Packet packet) throws NotConnectedException {
if (packet instanceof OfferRequestProvider.OfferRequestPacket) {
// Acknowledge the IQ set.
IQ reply = new IQ() {
@ -777,8 +783,9 @@ public class AgentSession {
* @param note the chat note to add.
* @throws XMPPErrorException
* @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 = StringUtils.escapeForXML(note);
@ -797,8 +804,9 @@ public class AgentSession {
* @return the <code>ChatNote</code> associated with a given chat session.
* @throws XMPPErrorException if an error occurs while retrieving the ChatNote.
* @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();
request.setType(IQ.Type.GET);
request.setTo(workgroupJID);
@ -815,8 +823,9 @@ public class AgentSession {
* @param maxSessions the max number of sessions to retrieve.
* @return the chat history associated with a given jid.
* @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;
if (startDate != null) {
request = new AgentChatHistory(jid, maxSessions, startDate);
@ -840,8 +849,9 @@ public class AgentSession {
* @return SearchSettings the search settings for this workgroup.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*/
public SearchSettings getSearchSettings() throws NoResponseException, XMPPErrorException {
public SearchSettings getSearchSettings() throws NoResponseException, XMPPErrorException, NotConnectedException {
SearchSettings request = new SearchSettings();
request.setType(IQ.Type.GET);
request.setTo(workgroupJID);
@ -857,8 +867,9 @@ public class AgentSession {
* @return MacroGroup the root macro group.
* @throws XMPPErrorException if an error occurs while getting information from the server.
* @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();
request.setType(IQ.Type.GET);
request.setTo(workgroupJID);
@ -874,8 +885,9 @@ public class AgentSession {
* @param group the macro group to save.
* @throws XMPPErrorException
* @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();
request.setType(IQ.Type.SET);
request.setTo(workgroupJID);
@ -891,8 +903,9 @@ public class AgentSession {
* @param sessionID the sessionID to query for.
* @return Map a map of all metadata associated with the sessionID.
* @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();
request.setType(IQ.Type.GET);
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
* the request.
* @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);
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
* the request.
* @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);
IQ iq = new IQ() {
@ -995,8 +1010,9 @@ public class AgentSession {
* @return the settings for the workgroup.
* @throws XMPPErrorException if an error occurs while sending the request to the server.
* @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();
setting.setType(IQ.Type.GET);
setting.setTo(workgroupJID);
@ -1006,7 +1022,7 @@ public class AgentSession {
return response;
}
public boolean hasMonitorPrivileges(XMPPConnection con) throws NoResponseException, XMPPErrorException {
public boolean hasMonitorPrivileges(XMPPConnection con) throws NoResponseException, XMPPErrorException, NotConnectedException {
MonitorPacket request = new MonitorPacket();
request.setType(IQ.Type.GET);
request.setTo(workgroupJID);
@ -1015,7 +1031,7 @@ public class AgentSession {
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();
request.setType(IQ.Type.SET);
request.setTo(workgroupJID);

View file

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

View file

@ -17,6 +17,7 @@
package org.jivesoftware.smackx.workgroup.agent;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.packet.IQ;
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);
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.Transcripts;
import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
@ -45,8 +46,9 @@ public class TranscriptManager {
* @return the full conversation transcript of a given session.
* @throws XMPPErrorException
* @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);
request.setTo(workgroupJID);
Transcript response = (Transcript) connection.createPacketCollectorAndSend(request).nextResultOrThrow();
@ -62,8 +64,9 @@ public class TranscriptManager {
* @return the transcripts of a given user.
* @throws XMPPErrorException
* @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);
request.setTo(workgroupJID);
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.xdata.Form;
import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.packet.IQ;
@ -48,8 +49,9 @@ public class TranscriptSearchManager {
* @return the Form to use for searching transcripts.
* @throws XMPPErrorException
* @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();
search.setType(IQ.Type.GET);
search.setTo(serviceJID);
@ -69,8 +71,9 @@ public class TranscriptSearchManager {
* @return the result of the transcript search.
* @throws XMPPErrorException
* @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();
search.setType(IQ.Type.GET);
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.smack.*;
import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.filter.*;
import org.jivesoftware.smack.packet.*;
@ -157,8 +158,9 @@ public class Workgroup {
* @return true if the workgroup is available for receiving new requests.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*/
public boolean isAvailable() throws NoResponseException, XMPPErrorException {
public boolean isAvailable() throws NoResponseException, XMPPErrorException, NotConnectedException {
Presence directedPresence = new Presence(Presence.Type.available);
directedPresence.setTo(workgroupJID);
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
* request to join the queue.
* @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 (inQueue) {
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
* request to the server.
* @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 (!inQueue) {
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.
* @throws NoResponseException
* @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();
if (key != null) {
request.setKey(key);
@ -677,8 +682,9 @@ public class Workgroup {
* @return offlineSettings the offline settings for this workgroup.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*/
public OfflineSettings getOfflineSettings() throws NoResponseException, XMPPErrorException {
public OfflineSettings getOfflineSettings() throws NoResponseException, XMPPErrorException, NotConnectedException {
OfflineSettings request = new OfflineSettings();
request.setType(IQ.Type.GET);
request.setTo(workgroupJID);
@ -694,8 +700,9 @@ public class Workgroup {
* @return soundSettings the sound settings for the specified workgroup.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*/
public SoundSettings getSoundSettings() throws NoResponseException, XMPPErrorException {
public SoundSettings getSoundSettings() throws NoResponseException, XMPPErrorException, NotConnectedException {
SoundSettings request = new SoundSettings();
request.setType(IQ.Type.GET);
request.setTo(workgroupJID);
@ -710,8 +717,9 @@ public class Workgroup {
* @return the WorkgroupProperties for the specified workgroup.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*/
public WorkgroupProperties getWorkgroupProperties() throws NoResponseException, XMPPErrorException {
public WorkgroupProperties getWorkgroupProperties() throws NoResponseException, XMPPErrorException, NotConnectedException {
WorkgroupProperties request = new WorkgroupProperties();
request.setType(IQ.Type.GET);
request.setTo(workgroupJID);
@ -728,8 +736,9 @@ public class Workgroup {
* @return the WorkgroupProperties for the specified workgroup.
* @throws XMPPErrorException
* @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();
request.setJid(jid);
request.setType(IQ.Type.GET);
@ -749,8 +758,9 @@ public class Workgroup {
* @return the Form to use for searching transcripts.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*/
public Form getWorkgroupForm() throws NoResponseException, XMPPErrorException {
public Form getWorkgroupForm() throws NoResponseException, XMPPErrorException, NotConnectedException {
WorkgroupForm workgroupForm = new WorkgroupForm();
workgroupForm.setType(IQ.Type.GET);
workgroupForm.setTo(workgroupJID);

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