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

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
This commit is contained in:
Derek DeMoro 2005-11-09 04:22:14 +00:00 committed by derek
parent 428a82d596
commit 388ae4280a

View file

@ -27,6 +27,7 @@ import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.filter.PacketIDFilter; import org.jivesoftware.smack.filter.PacketIDFilter;
import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.XMPPError; import org.jivesoftware.smack.packet.XMPPError;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.util.StringUtils; import org.jivesoftware.smack.util.StringUtils;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
@ -419,13 +420,27 @@ public class VCard extends IQ {
* and not anonymous.<p> * and not anonymous.<p>
* <p/> * <p/>
* NOTE: the method is asynchronous and does not wait for the returned value. * 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); checkAuthenticated(connection);
setType(IQ.Type.SET); setType(IQ.Type.SET);
setFrom(connection.getUser()); setFrom(connection.getUser());
PacketCollector collector = connection.createPacketCollector(new PacketIDFilter(getPacketID()));
connection.sendPacket(this); 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());
}
} }
/** /**