From 0b49cbc374a3afed631e1735612d3b99480b1a85 Mon Sep 17 00:00:00 2001 From: Gaston Dombiak Date: Mon, 14 Jun 2004 17:27:09 +0000 Subject: [PATCH] Adds ability to listen for possible errors while sending the room configuration form. git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@2329 b35dd754-fafc-0310-a699-88a17e54d16e --- .../jivesoftware/smackx/MultiUserChat.java | 28 +++++++++++++------ 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/source/org/jivesoftware/smackx/MultiUserChat.java b/source/org/jivesoftware/smackx/MultiUserChat.java index cb8454098..85f546da7 100644 --- a/source/org/jivesoftware/smackx/MultiUserChat.java +++ b/source/org/jivesoftware/smackx/MultiUserChat.java @@ -357,7 +357,7 @@ public class MultiUserChat { * decide to create a new room or not. * * @param nickname the nickname to use. - * @param timeout the number of seconds to wait for reply from the group chat server. + * @param timeout the amount of time to wait for a reply from the MUC service(in milleseconds). * @param password the password to use. * @param maxchars the total number of characters to receive in the history. * @param maxstanzas the total number of messages to receive in the history. @@ -485,7 +485,7 @@ public class MultiUserChat { iq.setTo(room); iq.setType(IQ.Type.GET); - // Wait for a presence packet back from the server. + // Filter packets looking for an answer from the server. PacketFilter responseFilter = new PacketIDFilter(iq.getPacketID()); PacketCollector response = connection.createPacketCollector(responseFilter); // Request the configuration form to the server. @@ -518,11 +518,22 @@ public class MultiUserChat { iq.setType(IQ.Type.SET); iq.addExtension(form.getDataFormToSend()); + // Filter packets looking for an answer from the server. + PacketFilter responseFilter = new PacketIDFilter(iq.getPacketID()); + PacketCollector response = connection.createPacketCollector(responseFilter); // Send the completed configuration form to the server. connection.sendPacket(iq); + // Wait up to a certain number of seconds for a reply. + IQ answer = (IQ) response.nextResult(SmackConfiguration.getPacketReplyTimeout()); + // Stop queuing results + response.cancel(); - // TODO Check for possible returned errors? permission errors? - // TODO Check that the form is of type "submit" or "cancel" + if (answer == null) { + throw new XMPPException("No response from server."); + } + else if (answer.getError() != null) { + throw new XMPPException(answer.getError()); + } } /** @@ -1882,11 +1893,11 @@ public class MultiUserChat { * * ModeratorParticipantmoderatorRevoked * ParticipantVisitorvoiceRevoked - * VisitorNone-- + * VisitorNonekicked * * ModeratorVisitorvoiceRevoked + moderatorRevoked - * ModeratorNonevoiceRevoked + moderatorRevoked - * ParticipantNonevoiceRevoked + * ModeratorNonekicked + * ParticipantNonekicked * * * @@ -1986,6 +1997,7 @@ public class MultiUserChat { * OwnerMemberownershipRevoked + membershipGranted * OwnerNoneownershipRevoked * AdminNoneadminRevoked + * AnyoneOutcastbanned * * * @@ -2110,7 +2122,7 @@ public class MultiUserChat { userHasLeft(); } else { - // TODO Check is we have to send the JID of the banned user + // TODO Check if we have to send the JID of the banned user fireParticipantStatusListeners("banned", from); } }