From 388ae4280a3ee6cdfec486459b99abe7feb6653a Mon Sep 17 00:00:00 2001 From: Derek DeMoro Date: Wed, 9 Nov 2005 04:22:14 +0000 Subject: [PATCH] Saving the VCard now throws an exception if setting vcard fails. git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@3044 b35dd754-fafc-0310-a699-88a17e54d16e --- .../org/jivesoftware/smackx/packet/VCard.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/source/org/jivesoftware/smackx/packet/VCard.java b/source/org/jivesoftware/smackx/packet/VCard.java index a35ec8cad..4f1248859 100644 --- a/source/org/jivesoftware/smackx/packet/VCard.java +++ b/source/org/jivesoftware/smackx/packet/VCard.java @@ -27,6 +27,7 @@ import org.jivesoftware.smack.XMPPException; import org.jivesoftware.smack.filter.PacketIDFilter; import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.XMPPError; +import org.jivesoftware.smack.packet.Packet; import org.jivesoftware.smack.util.StringUtils; import java.io.BufferedInputStream; @@ -419,13 +420,27 @@ public class VCard extends IQ { * and not anonymous.

*

* NOTE: the method is asynchronous and does not wait for the returned value. + * @param connection the XMPPConnection to use. + * @throws XMPPException thrown if there was an issue setting the VCard in the server. */ - public void save(XMPPConnection connection) { + public void save(XMPPConnection connection) throws XMPPException { checkAuthenticated(connection); setType(IQ.Type.SET); setFrom(connection.getUser()); + PacketCollector collector = connection.createPacketCollector(new PacketIDFilter(getPacketID())); connection.sendPacket(this); + + Packet response = collector.nextResult(SmackConfiguration.getPacketReplyTimeout()); + + // Cancel the collector. + collector.cancel(); + if (response == null) { + throw new XMPPException("No response from server on status set."); + } + if (response.getError() != null) { + throw new XMPPException(response.getError()); + } } /**