moves delay element references to xmpp package
This commit is contained in:
parent
9d51972239
commit
ae30167461
4 changed files with 38 additions and 9 deletions
src/main/java/de/thedevstack/conversationsplus
|
@ -17,6 +17,7 @@ import de.thedevstack.conversationsplus.entities.Message;
|
|||
import de.thedevstack.conversationsplus.xml.Element;
|
||||
import de.thedevstack.conversationsplus.xmpp.carbons.Carbons;
|
||||
import de.thedevstack.conversationsplus.xmpp.chatstate.ChatState;
|
||||
import de.thedevstack.conversationsplus.xmpp.delay.Delay;
|
||||
import de.thedevstack.conversationsplus.xmpp.httpuploadim.HttpUploadHint;
|
||||
import de.thedevstack.conversationsplus.xmpp.jid.Jid;
|
||||
import de.thedevstack.conversationsplus.xmpp.openpgp.OpenPgpXep;
|
||||
|
@ -28,7 +29,7 @@ public class MessageGenerator extends AbstractGenerator {
|
|||
/**
|
||||
* Moved to messaging.MessageGenerator
|
||||
*/
|
||||
private MessagePacket preparePacket(Message message) {
|
||||
protected MessagePacket preparePacket(Message message) {
|
||||
Conversation conversation = message.getConversation();
|
||||
Account account = conversation.getAccount();
|
||||
MessagePacket packet = new MessagePacket();
|
||||
|
@ -59,7 +60,7 @@ public class MessageGenerator extends AbstractGenerator {
|
|||
final SimpleDateFormat mDateFormat = new SimpleDateFormat(
|
||||
"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.US);
|
||||
mDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||
Element delay = packet.addChild("delay", "urn:xmpp:delay");
|
||||
Element delay = packet.addChild(Delay.DELAY.getXmlElement());
|
||||
Date date = new Date(timestamp);
|
||||
delay.setAttribute("stamp", mDateFormat.format(date));
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ import de.thedevstack.conversationsplus.entities.Account;
|
|||
import de.thedevstack.conversationsplus.entities.Contact;
|
||||
import de.thedevstack.conversationsplus.services.XmppConnectionService;
|
||||
import de.thedevstack.conversationsplus.xml.Element;
|
||||
import de.thedevstack.conversationsplus.xmpp.delay.Delay;
|
||||
import de.thedevstack.conversationsplus.xmpp.jid.Jid;
|
||||
import de.thedevstack.conversationsplus.xmpp.stanzas.AbstractStanza;
|
||||
|
||||
|
@ -30,7 +31,7 @@ public abstract class AbstractParser {
|
|||
* attribute the current time is returned.
|
||||
*/
|
||||
public static Long getTimestamp(Element element, Long defaultValue) {
|
||||
Element delay = element.findChild("delay","urn:xmpp:delay");
|
||||
Element delay = element.findChild(Delay.DELAY);
|
||||
if (delay != null) {
|
||||
String stamp = delay.getAttribute("stamp");
|
||||
if (stamp != null) {
|
||||
|
|
|
@ -31,18 +31,18 @@ public class Element {
|
|||
}
|
||||
|
||||
public Element addChild(String name) {
|
||||
this.content = null;
|
||||
Element child = new Element(name);
|
||||
children.add(child);
|
||||
return child;
|
||||
return this.addChild(new Element(name));
|
||||
}
|
||||
|
||||
public Element addChild(String name, String xmlns) {
|
||||
this.content = null;
|
||||
Element child = new Element(name);
|
||||
child.setAttribute("xmlns", xmlns);
|
||||
children.add(child);
|
||||
return child;
|
||||
return this.addChild(child);
|
||||
}
|
||||
|
||||
public Element addChild(XmlElementContainer container) {
|
||||
return this.addChild(container.getXmlElement());
|
||||
}
|
||||
|
||||
public Element setContent(String content) {
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
package de.thedevstack.conversationsplus.xmpp.delay;
|
||||
|
||||
import de.thedevstack.conversationsplus.xml.Element;
|
||||
import de.thedevstack.conversationsplus.xml.XmlElementContainer;
|
||||
|
||||
/**
|
||||
*/
|
||||
public enum Delay implements XmlElementContainer {
|
||||
DELAY("delay");
|
||||
|
||||
private Element xmlElement;
|
||||
|
||||
Delay(String elementName) {
|
||||
this.xmlElement = new Element(elementName, NAMESPACE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Element getXmlElement() {
|
||||
return xmlElement;
|
||||
}
|
||||
|
||||
/**
|
||||
* The namespace of the delay timestamp as defined in XEP-0203.
|
||||
* @see <a href="https://xmpp.org/extensions/xep-0203.html">https://xmpp.org/extensions/xep-0203.html</a>
|
||||
*/
|
||||
public static final String NAMESPACE = "urn:xmpp:delay";
|
||||
}
|
Loading…
Add table
Reference in a new issue