2015-08-13 16:25:10 +00:00
|
|
|
package eu.siacs.conversations.xmpp.stanzas;
|
|
|
|
|
2015-10-22 09:20:36 +00:00
|
|
|
import eu.siacs.conversations.xml.Element;
|
2018-04-28 14:26:40 +00:00
|
|
|
import eu.siacs.conversations.xmpp.InvalidJid;
|
2015-10-22 09:20:36 +00:00
|
|
|
|
2015-08-13 16:25:10 +00:00
|
|
|
abstract public class AbstractAcknowledgeableStanza extends AbstractStanza {
|
|
|
|
|
|
|
|
protected AbstractAcknowledgeableStanza(String name) {
|
|
|
|
super(name);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public String getId() {
|
|
|
|
return this.getAttribute("id");
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setId(final String id) {
|
|
|
|
setAttribute("id", id);
|
|
|
|
}
|
2015-10-22 09:20:36 +00:00
|
|
|
|
|
|
|
public Element getError() {
|
|
|
|
Element error = findChild("error");
|
|
|
|
if (error != null) {
|
|
|
|
for(Element element : error.getChildren()) {
|
|
|
|
if (!element.getName().equals("text")) {
|
|
|
|
return element;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
2018-04-28 14:26:40 +00:00
|
|
|
|
2020-04-09 13:22:03 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2018-04-28 14:26:40 +00:00
|
|
|
public boolean valid() {
|
|
|
|
return InvalidJid.isValid(getFrom()) && InvalidJid.isValid(getTo());
|
|
|
|
}
|
2015-08-13 16:25:10 +00:00
|
|
|
}
|