diff options
Diffstat (limited to 'src/com/isode')
10 files changed, 253 insertions, 0 deletions
diff --git a/src/com/isode/stroke/elements/DeliveryReceipt.java b/src/com/isode/stroke/elements/DeliveryReceipt.java new file mode 100644 index 0000000..0bf6d75 --- /dev/null +++ b/src/com/isode/stroke/elements/DeliveryReceipt.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2015, Isode Limited, London, England. + * All rights reserved. + */ +/* + * Copyright (c) 2011 Tobias Markmann + * Licensed under the BSD license. + * See http://www.opensource.org/licenses/bsd-license.php for more information. + */ + +package com.isode.stroke.elements; + +public class DeliveryReceipt extends Payload { + + private String receivedID_; + + public DeliveryReceipt() {receivedID_ = "";} + + public DeliveryReceipt(String msgId) { + receivedID_= msgId; + } + + public void setReceivedID(String msgId) { + receivedID_ = msgId; + } + + public String getReceivedID() { + return receivedID_; + } +} diff --git a/src/com/isode/stroke/elements/DeliveryReceiptRequest.java b/src/com/isode/stroke/elements/DeliveryReceiptRequest.java new file mode 100644 index 0000000..a85dc0f --- /dev/null +++ b/src/com/isode/stroke/elements/DeliveryReceiptRequest.java @@ -0,0 +1,15 @@ +/* + * Copyright (c) 2015, Isode Limited, London, England. + * All rights reserved. + */ +/* + * Copyright (c) 2011 Tobias Markmann + * Licensed under the BSD license. + * See http://www.opensource.org/licenses/bsd-license.php for more information. + */ + +package com.isode.stroke.elements; + +public class DeliveryReceiptRequest extends Payload { + public DeliveryReceiptRequest() {} +} diff --git a/src/com/isode/stroke/parser/payloadparsers/DeliveryReceiptParser.java b/src/com/isode/stroke/parser/payloadparsers/DeliveryReceiptParser.java new file mode 100644 index 0000000..7b94b78 --- /dev/null +++ b/src/com/isode/stroke/parser/payloadparsers/DeliveryReceiptParser.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2015, Isode Limited, London, England. + * All rights reserved. + */ +/* + * Copyright (c) 2011 Tobias Markmann + * Licensed under the BSD license. + * See http://www.opensource.org/licenses/bsd-license.php for more information. + */ + +package com.isode.stroke.parser.payloadparsers; + +import com.isode.stroke.elements.DeliveryReceipt; +import com.isode.stroke.parser.AttributeMap; +import com.isode.stroke.parser.GenericPayloadParser; + +public class DeliveryReceiptParser extends GenericPayloadParser<DeliveryReceipt> { + + private int level_; + + public DeliveryReceiptParser() { + super(new DeliveryReceipt()); + } + + public void handleStartElement(String element, String ns, AttributeMap attributeMap) { + if (level_ == 0) { + if ("received".equals(element)) { + String id = attributeMap.getAttributeValue("id"); + if (id != null) { + getPayloadInternal().setReceivedID(id); + } + } + } + ++level_; + } + + public void handleEndElement(String element, String ns) { + --level_; + } + + public void handleCharacterData(String data) { + + } + + +} diff --git a/src/com/isode/stroke/parser/payloadparsers/DeliveryReceiptParserFactory.java b/src/com/isode/stroke/parser/payloadparsers/DeliveryReceiptParserFactory.java new file mode 100644 index 0000000..c93f467 --- /dev/null +++ b/src/com/isode/stroke/parser/payloadparsers/DeliveryReceiptParserFactory.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2015, Isode Limited, London, England. + * All rights reserved. + */ +/* + * Copyright (c) 2011 Tobias Markmann + * Licensed under the BSD license. + * See http://www.opensource.org/licenses/bsd-license.php for more information. + */ +package com.isode.stroke.parser.payloadparsers; + +import com.isode.stroke.parser.AttributeMap; +import com.isode.stroke.parser.PayloadParser; +import com.isode.stroke.parser.PayloadParserFactory; + +class DeliveryReceiptParserFactory implements PayloadParserFactory { + + public DeliveryReceiptParserFactory() { + } + + @Override + public boolean canParse(String element, String ns, AttributeMap attributes) { + return "urn:xmpp:receipts".equals(ns) && "received".equals(element); + } + + @Override + public PayloadParser createPayloadParser() { + return new DeliveryReceiptParser(); + } + +} diff --git a/src/com/isode/stroke/parser/payloadparsers/DeliveryReceiptRequestParser.java b/src/com/isode/stroke/parser/payloadparsers/DeliveryReceiptRequestParser.java new file mode 100644 index 0000000..ee24cc5 --- /dev/null +++ b/src/com/isode/stroke/parser/payloadparsers/DeliveryReceiptRequestParser.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2015, Isode Limited, London, England. + * All rights reserved. + */ +/* + * Copyright (c) 2011 Tobias Markmann + * Licensed under the BSD license. + * See http://www.opensource.org/licenses/bsd-license.php for more information. + */ + +package com.isode.stroke.parser.payloadparsers; + +import com.isode.stroke.elements.DeliveryReceiptRequest; +import com.isode.stroke.parser.AttributeMap; +import com.isode.stroke.parser.GenericPayloadParser; + +public class DeliveryReceiptRequestParser extends GenericPayloadParser<DeliveryReceiptRequest> { + + public DeliveryReceiptRequestParser() { + super(new DeliveryReceiptRequest()); + } + + public void handleStartElement(String element, String ns, AttributeMap attributes) { + + } + + public void handleEndElement(String element, String ns) { + + } + + public void handleCharacterData(String data) { + + } + + +} diff --git a/src/com/isode/stroke/parser/payloadparsers/DeliveryReceiptRequestParserFactory.java b/src/com/isode/stroke/parser/payloadparsers/DeliveryReceiptRequestParserFactory.java new file mode 100644 index 0000000..dc7f181 --- /dev/null +++ b/src/com/isode/stroke/parser/payloadparsers/DeliveryReceiptRequestParserFactory.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2015, Isode Limited, London, England. + * All rights reserved. + */ +/* + * Copyright (c) 2011 Tobias Markmann + * Licensed under the BSD license. + * See http://www.opensource.org/licenses/bsd-license.php for more information. + */ +package com.isode.stroke.parser.payloadparsers; + +import com.isode.stroke.parser.AttributeMap; +import com.isode.stroke.parser.PayloadParser; +import com.isode.stroke.parser.PayloadParserFactory; + +class DeliveryReceiptRequestParserFactory implements PayloadParserFactory { + + public DeliveryReceiptRequestParserFactory() { + } + + @Override + public boolean canParse(String element, String ns, AttributeMap attributes) { + return "urn:xmpp:receipts".equals(ns) && "request".equals(element); + } + + @Override + public PayloadParser createPayloadParser() { + return new DeliveryReceiptRequestParser(); + } + +} diff --git a/src/com/isode/stroke/parser/payloadparsers/FullPayloadParserFactoryCollection.java b/src/com/isode/stroke/parser/payloadparsers/FullPayloadParserFactoryCollection.java index af91aff..4294370 100644 --- a/src/com/isode/stroke/parser/payloadparsers/FullPayloadParserFactoryCollection.java +++ b/src/com/isode/stroke/parser/payloadparsers/FullPayloadParserFactoryCollection.java @@ -57,6 +57,9 @@ public class FullPayloadParserFactoryCollection extends PayloadParserFactoryColl "http://jabber.org/protocol/muc#owner",MUCDestroyPayloadParser.class)); addFactory(new GenericPayloadParserFactory<IdleParser>("idle", "urn:xmpp:idle:1",IdleParser.class)); + addFactory(new DeliveryReceiptParserFactory()); + addFactory(new DeliveryReceiptRequestParserFactory()); + addFactory(new GenericPayloadParserFactory2<PubSubParser>("pubsub", "http://jabber.org/protocol/pubsub", this, PubSubParser.class)); addFactory(new GenericPayloadParserFactory2<PubSubOwnerPubSubParser>("pubsub", "http://jabber.org/protocol/pubsub#owner", this, PubSubOwnerPubSubParser.class)); addFactory(new GenericPayloadParserFactory2<PubSubEventParser>("event", "http://jabber.org/protocol/pubsub#event", this, PubSubEventParser.class)); diff --git a/src/com/isode/stroke/serializer/payloadserializers/DeliveryReceiptRequestSerializer.java b/src/com/isode/stroke/serializer/payloadserializers/DeliveryReceiptRequestSerializer.java new file mode 100644 index 0000000..81381c5 --- /dev/null +++ b/src/com/isode/stroke/serializer/payloadserializers/DeliveryReceiptRequestSerializer.java @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2015, Isode Limited, London, England. + * All rights reserved. + */ +/* + * Copyright (c) 2011 Tobias Markmann + * Licensed under the BSD license. + * See http://www.opensource.org/licenses/bsd-license.php for more information. + */ + +package com.isode.stroke.serializer.payloadserializers; + +import com.isode.stroke.elements.DeliveryReceiptRequest; +import com.isode.stroke.serializer.GenericPayloadSerializer; +import com.isode.stroke.serializer.xml.XMLElement; + +class DeliveryReceiptRequestSerializer extends GenericPayloadSerializer<DeliveryReceiptRequest> { + + public DeliveryReceiptRequestSerializer() { + super(DeliveryReceiptRequest.class); + } + + @Override + protected String serializePayload(DeliveryReceiptRequest payload) { + return new XMLElement("request", "urn:xmpp:receipts").serialize(); + } + +} diff --git a/src/com/isode/stroke/serializer/payloadserializers/DeliveryReceiptSerializer.java b/src/com/isode/stroke/serializer/payloadserializers/DeliveryReceiptSerializer.java new file mode 100644 index 0000000..74a55e3 --- /dev/null +++ b/src/com/isode/stroke/serializer/payloadserializers/DeliveryReceiptSerializer.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2015, Isode Limited, London, England. + * All rights reserved. + */ +/* + * Copyright (c) 2011 Tobias Markmann + * Licensed under the BSD license. + * See http://www.opensource.org/licenses/bsd-license.php for more information. + */ + +package com.isode.stroke.serializer.payloadserializers; + +import com.isode.stroke.elements.DeliveryReceipt; +import com.isode.stroke.serializer.GenericPayloadSerializer; +import com.isode.stroke.serializer.xml.XMLElement; + +class DeliveryReceiptSerializer extends GenericPayloadSerializer<DeliveryReceipt> { + + public DeliveryReceiptSerializer() { + super(DeliveryReceipt.class); + } + + @Override + protected String serializePayload(DeliveryReceipt receipt) { + XMLElement received = new XMLElement("received", "urn:xmpp:receipts"); + received.setAttribute("id", receipt.getReceivedID()); + return received.serialize(); + } + +} diff --git a/src/com/isode/stroke/serializer/payloadserializers/FullPayloadSerializerCollection.java b/src/com/isode/stroke/serializer/payloadserializers/FullPayloadSerializerCollection.java index a0dcebd..66fb664 100644 --- a/src/com/isode/stroke/serializer/payloadserializers/FullPayloadSerializerCollection.java +++ b/src/com/isode/stroke/serializer/payloadserializers/FullPayloadSerializerCollection.java @@ -55,6 +55,9 @@ public class FullPayloadSerializerCollection extends PayloadSerializerCollection addSerializer(new LastSerializer()); addSerializer(new IdleSerializer()); + addSerializer(new DeliveryReceiptSerializer()); + addSerializer(new DeliveryReceiptRequestSerializer()); + addSerializer(new PubSubSerializer(this)); addSerializer(new PubSubEventSerializer(this)); addSerializer(new PubSubOwnerPubSubSerializer(this)); |