don't make subsequent iq request when original stanza returned an error
This commit is contained in:
parent
496f531e2e
commit
1688b65965
|
@ -871,28 +871,31 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onIqPacketReceived(final Account account, final IqPacket packet) {
|
public void onIqPacketReceived(final Account account, final IqPacket packet) {
|
||||||
final Element query = packet.query();
|
if (packet.getType() == IqPacket.TYPE.RESULT) {
|
||||||
final List<Bookmark> bookmarks = new CopyOnWriteArrayList<>();
|
final Element query = packet.query();
|
||||||
final Element storage = query.findChild("storage",
|
final List<Bookmark> bookmarks = new CopyOnWriteArrayList<>();
|
||||||
"storage:bookmarks");
|
final Element storage = query.findChild("storage", "storage:bookmarks");
|
||||||
if (storage != null) {
|
if (storage != null) {
|
||||||
for (final Element item : storage.getChildren()) {
|
for (final Element item : storage.getChildren()) {
|
||||||
if (item.getName().equals("conference")) {
|
if (item.getName().equals("conference")) {
|
||||||
final Bookmark bookmark = Bookmark.parse(item, account);
|
final Bookmark bookmark = Bookmark.parse(item, account);
|
||||||
bookmarks.add(bookmark);
|
bookmarks.add(bookmark);
|
||||||
Conversation conversation = find(bookmark);
|
Conversation conversation = find(bookmark);
|
||||||
if (conversation != null) {
|
if (conversation != null) {
|
||||||
conversation.setBookmark(bookmark);
|
conversation.setBookmark(bookmark);
|
||||||
} else if (bookmark.autojoin() && bookmark.getJid() != null) {
|
} else if (bookmark.autojoin() && bookmark.getJid() != null) {
|
||||||
conversation = findOrCreateConversation(
|
conversation = findOrCreateConversation(
|
||||||
account, bookmark.getJid(), true);
|
account, bookmark.getJid(), true);
|
||||||
conversation.setBookmark(bookmark);
|
conversation.setBookmark(bookmark);
|
||||||
joinMuc(conversation);
|
joinMuc(conversation);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
account.setBookmarks(bookmarks);
|
||||||
|
} else {
|
||||||
|
Log.d(Config.LOGTAG,account.getJid().toBareJid()+": could not fetch bookmarks");
|
||||||
}
|
}
|
||||||
account.setBookmarks(bookmarks);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
sendIqPacket(account, iqPacket, callback);
|
sendIqPacket(account, iqPacket, callback);
|
||||||
|
@ -1955,10 +1958,8 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
|
||||||
final IqPacket packet = XmppConnectionService.this.mIqGenerator
|
final IqPacket packet = XmppConnectionService.this.mIqGenerator
|
||||||
.publishAvatarMetadata(avatar);
|
.publishAvatarMetadata(avatar);
|
||||||
sendIqPacket(account, packet, new OnIqPacketReceived() {
|
sendIqPacket(account, packet, new OnIqPacketReceived() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onIqPacketReceived(Account account,
|
public void onIqPacketReceived(Account account, IqPacket result) {
|
||||||
IqPacket result) {
|
|
||||||
if (result.getType() == IqPacket.TYPE.RESULT) {
|
if (result.getType() == IqPacket.TYPE.RESULT) {
|
||||||
if (account.setAvatar(avatar.getFilename())) {
|
if (account.setAvatar(avatar.getFilename())) {
|
||||||
getAvatarService().clear(account);
|
getAvatarService().clear(account);
|
||||||
|
|
|
@ -414,9 +414,12 @@ public class XmppConnection implements Runnable {
|
||||||
this.sendIqPacket(iq, new OnIqPacketReceived() {
|
this.sendIqPacket(iq, new OnIqPacketReceived() {
|
||||||
@Override
|
@Override
|
||||||
public void onIqPacketReceived(final Account account, final IqPacket packet) {
|
public void onIqPacketReceived(final Account account, final IqPacket packet) {
|
||||||
Log.d(Config.LOGTAG, account.getJid().toBareJid().toString()
|
if (packet.getType() == IqPacket.TYPE.RESULT) {
|
||||||
+ ": online with resource " + account.getResource());
|
Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": online with resource " + account.getResource());
|
||||||
changeStatus(Account.State.ONLINE);
|
changeStatus(Account.State.ONLINE);
|
||||||
|
} else {
|
||||||
|
Log.d(Config.LOGTAG,account.getJid().toBareJid()+": initial ping failed");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -656,8 +659,8 @@ public class XmppConnection implements Runnable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onIqPacketReceived(final Account account, final IqPacket packet) {
|
public void onIqPacketReceived(final Account account, final IqPacket packet) {
|
||||||
final Element instructions = packet.query().findChild("instructions");
|
if (packet.getType() == IqPacket.TYPE.RESULT
|
||||||
if (packet.query().hasChild("username")
|
&& packet.query().hasChild("username")
|
||||||
&& (packet.query().hasChild("password"))) {
|
&& (packet.query().hasChild("password"))) {
|
||||||
final IqPacket register = new IqPacket(IqPacket.TYPE.SET);
|
final IqPacket register = new IqPacket(IqPacket.TYPE.SET);
|
||||||
final Element username = new Element("username").setContent(account.getUsername());
|
final Element username = new Element("username").setContent(account.getUsername());
|
||||||
|
@ -684,6 +687,7 @@ public class XmppConnection implements Runnable {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
final Element instructions = packet.query().findChild("instructions");
|
||||||
changeStatus(Account.State.REGISTRATION_FAILED);
|
changeStatus(Account.State.REGISTRATION_FAILED);
|
||||||
disconnect(true);
|
disconnect(true);
|
||||||
Log.d(Config.LOGTAG, account.getJid().toBareJid()
|
Log.d(Config.LOGTAG, account.getJid().toBareJid()
|
||||||
|
@ -735,10 +739,13 @@ public class XmppConnection implements Runnable {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void clearIqCallbacks() {
|
private void clearIqCallbacks() {
|
||||||
Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": clearing "+this.packetCallbacks.size()+" iq callbacks");
|
|
||||||
final IqPacket failurePacket = new IqPacket(IqPacket.TYPE.ERROR);
|
final IqPacket failurePacket = new IqPacket(IqPacket.TYPE.ERROR);
|
||||||
final ArrayList<OnIqPacketReceived> callbacks = new ArrayList<>();
|
final ArrayList<OnIqPacketReceived> callbacks = new ArrayList<>();
|
||||||
synchronized (this.packetCallbacks) {
|
synchronized (this.packetCallbacks) {
|
||||||
|
if (this.packetCallbacks.size() == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": clearing "+this.packetCallbacks.size()+" iq callbacks");
|
||||||
final Iterator<Pair<IqPacket, OnIqPacketReceived>> iterator = this.packetCallbacks.values().iterator();
|
final Iterator<Pair<IqPacket, OnIqPacketReceived>> iterator = this.packetCallbacks.values().iterator();
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
Pair<IqPacket, OnIqPacketReceived> entry = iterator.next();
|
Pair<IqPacket, OnIqPacketReceived> entry = iterator.next();
|
||||||
|
@ -749,6 +756,7 @@ public class XmppConnection implements Runnable {
|
||||||
for(OnIqPacketReceived callback : callbacks) {
|
for(OnIqPacketReceived callback : callbacks) {
|
||||||
callback.onIqPacketReceived(account,failurePacket);
|
callback.onIqPacketReceived(account,failurePacket);
|
||||||
}
|
}
|
||||||
|
Log.d(Config.LOGTAG,account.getJid().toBareJid()+": done clearing iq callbacks");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendStartSession() {
|
private void sendStartSession() {
|
||||||
|
@ -760,7 +768,7 @@ public class XmppConnection implements Runnable {
|
||||||
if (packet.getType() == IqPacket.TYPE.RESULT) {
|
if (packet.getType() == IqPacket.TYPE.RESULT) {
|
||||||
sendPostBindInitialization();
|
sendPostBindInitialization();
|
||||||
} else {
|
} else {
|
||||||
Log.d(Config.LOGTAG,account.getJid().toBareJid()+": could not init sessions");
|
Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": could not init sessions");
|
||||||
disconnect(true);
|
disconnect(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -805,26 +813,29 @@ public class XmppConnection implements Runnable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onIqPacketReceived(final Account account, final IqPacket packet) {
|
public void onIqPacketReceived(final Account account, final IqPacket packet) {
|
||||||
final List<Element> elements = packet.query().getChildren();
|
if (packet.getType() == IqPacket.TYPE.RESULT) {
|
||||||
final Info info = new Info();
|
final List<Element> elements = packet.query().getChildren();
|
||||||
for (final Element element : elements) {
|
final Info info = new Info();
|
||||||
if (element.getName().equals("identity")) {
|
for (final Element element : elements) {
|
||||||
String type = element.getAttribute("type");
|
if (element.getName().equals("identity")) {
|
||||||
String category = element.getAttribute("category");
|
String type = element.getAttribute("type");
|
||||||
if (type != null && category != null) {
|
String category = element.getAttribute("category");
|
||||||
info.identities.add(new Pair<>(category,type));
|
if (type != null && category != null) {
|
||||||
|
info.identities.add(new Pair<>(category, type));
|
||||||
|
}
|
||||||
|
} else if (element.getName().equals("feature")) {
|
||||||
|
info.features.add(element.getAttribute("var"));
|
||||||
}
|
}
|
||||||
} else if (element.getName().equals("feature")) {
|
|
||||||
info.features.add(element.getAttribute("var"));
|
|
||||||
}
|
}
|
||||||
}
|
disco.put(jid, info);
|
||||||
disco.put(jid, info);
|
if (account.getServer().equals(jid)) {
|
||||||
|
enableAdvancedStreamFeatures();
|
||||||
if (account.getServer().equals(jid)) {
|
for (final OnAdvancedStreamFeaturesLoaded listener : advancedStreamFeaturesLoadedListeners) {
|
||||||
enableAdvancedStreamFeatures();
|
listener.onAdvancedStreamFeaturesAvailable(account);
|
||||||
for (final OnAdvancedStreamFeaturesLoaded listener : advancedStreamFeaturesLoadedListeners) {
|
}
|
||||||
listener.onAdvancedStreamFeaturesAvailable(account);
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
Log.d(Config.LOGTAG,account.getJid().toBareJid()+": could not query disco info for "+jid.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -849,14 +860,18 @@ public class XmppConnection implements Runnable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onIqPacketReceived(final Account account, final IqPacket packet) {
|
public void onIqPacketReceived(final Account account, final IqPacket packet) {
|
||||||
final List<Element> elements = packet.query().getChildren();
|
if (packet.getType() == IqPacket.TYPE.RESULT) {
|
||||||
for (final Element element : elements) {
|
final List<Element> elements = packet.query().getChildren();
|
||||||
if (element.getName().equals("item")) {
|
for (final Element element : elements) {
|
||||||
final Jid jid = element.getAttributeAsJid("jid");
|
if (element.getName().equals("item")) {
|
||||||
if (jid != null && !jid.equals(account.getServer())) {
|
final Jid jid = element.getAttributeAsJid("jid");
|
||||||
sendServiceDiscoveryInfo(jid);
|
if (jid != null && !jid.equals(account.getServer())) {
|
||||||
|
sendServiceDiscoveryInfo(jid);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
Log.d(Config.LOGTAG,account.getJid().toBareJid()+": could not query disco items of "+server);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue