1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-26 00:02:06 +01:00

Don't use IQReplyFilter in AccountManager

This is a follow up on 6caf2cbdb5 where IQReplyFilter was changed so
that getUser() must not return null. But this is the case in
AccountManager where no resource binding has taken place and the user is
therefore not set.

The fix is the same as in 6caf2cbdb5, instead of IQReplyFilter we
simply use a PacketIDFilter.
This commit is contained in:
Florian Schmaus 2014-08-11 21:09:26 +02:00
parent 7caf413637
commit c5b7f14527

View file

@ -26,6 +26,7 @@ import java.util.WeakHashMap;
import org.jivesoftware.smack.SmackException.NoResponseException; import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException; import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPException.XMPPErrorException; import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.filter.PacketIDFilter;
import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.Registration; import org.jivesoftware.smack.packet.Registration;
import org.jxmpp.util.XmppStringUtils; import org.jxmpp.util.XmppStringUtils;
@ -226,7 +227,7 @@ public class AccountManager extends Manager {
attributes.put("username", username); attributes.put("username", username);
attributes.put("password", password); attributes.put("password", password);
reg.setAttributes(attributes); reg.setAttributes(attributes);
connection().createPacketCollectorAndSend(reg).nextResultOrThrow(); createPacketCollectorAndSend(reg).nextResultOrThrow();
} }
/** /**
@ -247,7 +248,7 @@ public class AccountManager extends Manager {
map.put("username",XmppStringUtils.parseLocalpart(connection().getUser())); map.put("username",XmppStringUtils.parseLocalpart(connection().getUser()));
map.put("password",newPassword); map.put("password",newPassword);
reg.setAttributes(map); reg.setAttributes(map);
connection().createPacketCollectorAndSend(reg).nextResultOrThrow(); createPacketCollectorAndSend(reg).nextResultOrThrow();
} }
/** /**
@ -268,7 +269,7 @@ public class AccountManager extends Manager {
// To delete an account, we add a single attribute, "remove", that is blank. // To delete an account, we add a single attribute, "remove", that is blank.
attributes.put("remove", ""); attributes.put("remove", "");
reg.setAttributes(attributes); reg.setAttributes(attributes);
connection().createPacketCollectorAndSend(reg).nextResultOrThrow(); createPacketCollectorAndSend(reg).nextResultOrThrow();
} }
/** /**
@ -283,6 +284,12 @@ public class AccountManager extends Manager {
private synchronized void getRegistrationInfo() throws NoResponseException, XMPPErrorException, NotConnectedException { private synchronized void getRegistrationInfo() throws NoResponseException, XMPPErrorException, NotConnectedException {
Registration reg = new Registration(); Registration reg = new Registration();
reg.setTo(connection().getServiceName()); reg.setTo(connection().getServiceName());
info = (Registration) connection().createPacketCollectorAndSend(reg).nextResultOrThrow(); info = createPacketCollectorAndSend(reg).nextResultOrThrow();
}
private PacketCollector createPacketCollectorAndSend(IQ req) throws NotConnectedException {
PacketCollector collector = connection().createPacketCollector(new PacketIDFilter(req.getPacketID()));
connection().sendPacket(req);
return collector;
} }
} }