Stanza.getErrorCondation only ever needs the tag name

This commit is contained in:
Daniel Gultsch 2021-03-18 11:35:41 +01:00
parent 6f1b71970d
commit b09a1432a3
3 changed files with 35 additions and 42 deletions

View file

@ -1797,7 +1797,7 @@ public class XmppConnectionService extends Service {
IqPacket request = mIqGenerator.deleteItem(Namespace.BOOKMARKS2, bookmark.getJid().asBareJid().toEscapedString());
sendIqPacket(account, request, (a, response) -> {
if (response.getType() == IqPacket.TYPE.ERROR) {
Log.d(Config.LOGTAG, a.getJid().asBareJid() + ": unable to delete bookmark " + response.getError());
Log.d(Config.LOGTAG, a.getJid().asBareJid() + ": unable to delete bookmark " + response.getErrorCondition());
}
});
} else if (connection.getFeatures().bookmarksConversion()) {
@ -2867,13 +2867,12 @@ public class XmppConnectionService extends Service {
}
@Override
public void onFetchFailed(final Conversation conversation, Element error) {
public void onFetchFailed(final Conversation conversation, final String errorCondition) {
if (conversation.getStatus() == Conversation.STATUS_ARCHIVED) {
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": conversation (" + conversation.getJid() + ") got archived before IQ result");
return;
}
if (error != null && "remote-server-not-found".equals(error.getName())) {
if ("remote-server-not-found".equals(errorCondition)) {
synchronized (account.inProgressConferenceJoins) {
account.inProgressConferenceJoins.remove(conversation);
}
@ -3239,7 +3238,7 @@ public class XmppConnectionService extends Service {
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": received timeout waiting for conference configuration fetch");
} else {
if (callback != null) {
callback.onFetchFailed(conversation, packet.getError());
callback.onFetchFailed(conversation, packet.getErrorCondition());
}
}
}
@ -3534,7 +3533,7 @@ public class XmppConnectionService extends Service {
if (publicationResponse.getType() == IqPacket.TYPE.RESULT) {
callback.onAvatarPublicationSucceeded();
} else {
Log.d(Config.LOGTAG, "failed to publish vcard " + publicationResponse.getError());
Log.d(Config.LOGTAG, "failed to publish vcard " + publicationResponse.getErrorCondition());
callback.onAvatarPublicationFailed(R.string.error_publish_avatar_server_reject);
}
});
@ -4817,7 +4816,7 @@ public class XmppConnectionService extends Service {
public interface OnConferenceConfigurationFetched {
void onConferenceConfigurationFetched(Conversation conversation);
void onFetchFailed(Conversation conversation, Element error);
void onFetchFailed(Conversation conversation, String errorCondition);
}
public interface OnConferenceJoined {

View file

@ -930,7 +930,7 @@ public class XmppConnection implements Runnable {
if (response.getType() == IqPacket.TYPE.RESULT) {
sendRegistryRequest();
} else {
final Element error = response.getError();
final String error = response.getErrorCondition();
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": failed to pre auth. " + error);
throw new StateChangingError(Account.State.REGISTRATION_INVALID_TOKEN);
}

View file

@ -5,44 +5,38 @@ import eu.siacs.conversations.xmpp.InvalidJid;
abstract public class AbstractAcknowledgeableStanza extends AbstractStanza {
protected AbstractAcknowledgeableStanza(String name) {
super(name);
}
protected AbstractAcknowledgeableStanza(String name) {
super(name);
}
public String getId() {
return this.getAttribute("id");
}
public String getId() {
return this.getAttribute("id");
}
public void setId(final String id) {
setAttribute("id", id);
}
public void setId(final String id) {
setAttribute("id", id);
}
public Element getError() {
Element error = findChild("error");
if (error != null) {
for(Element element : error.getChildren()) {
if (!element.getName().equals("text")) {
return element;
}
}
}
return null;
}
private Element getErrorConditionElement() {
final Element error = findChild("error");
if (error == null) {
return null;
}
for (final Element element : error.getChildren()) {
if (!element.getName().equals("text")) {
return element;
}
}
return null;
}
public String getErrorCondition() {
Element error = findChild("error");
if (error != null) {
for(Element element : error.getChildren()) {
if (!element.getName().equals("text")) {
return element.getName();
}
}
}
return null;
}
public String getErrorCondition() {
final Element condition = getErrorConditionElement();
return condition == null ? null : condition.getName();
}
public boolean valid() {
return InvalidJid.isValid(getFrom()) && InvalidJid.isValid(getTo());
}
public boolean valid() {
return InvalidJid.isValid(getFrom()) && InvalidJid.isValid(getTo());
}
}