mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-26 00:02:06 +01:00
Improve the Message Correction
add missing provider registration and improve a few bits here and there. SMACK-714
This commit is contained in:
parent
ca58c65a26
commit
0afbee55e0
6 changed files with 18 additions and 28 deletions
|
@ -66,6 +66,7 @@ Smack Extensions and currently supported XEPs of smack-extensions
|
|||
| Delayed Delivery | [XEP-0203](http://xmpp.org/extensions/xep-0203.html) | Extension for communicating the fact that an XML stanza has been delivered with a delay. |
|
||||
| XMPP Over BOSH | [XEP-0206](http://xmpp.org/extensions/xep-0206.html) | Use Bidirectional-streams Over Synchronous HTTP (BOSH) to transport XMPP stanzas. |
|
||||
| Attention | [XEP-0224](http://xmpp.org/extensions/xep-0224.html) | Getting attention of another user. |
|
||||
| Last Message Correction | [XEP-0308](http://xmpp.org/extensions/xep-0308.html) | Provides a method for indicating that a message is a correction of the last sent message. |
|
||||
| [Group Chat Invitations](invitation.md) | n/a | Send invitations to other users to join a group chat room. |
|
||||
| [Jive Properties](properties.md) | n/a | TODO |
|
||||
|
||||
|
|
|
@ -14,10 +14,11 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jivesoftware.smackx.message_correct;
|
||||
package org.jivesoftware.smackx.message_correct.element;
|
||||
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
import org.jivesoftware.smack.util.StringUtils;
|
||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||
|
||||
/**
|
||||
|
@ -51,35 +52,21 @@ public class MessageCorrectExtension implements ExtensionElement {
|
|||
/**
|
||||
* The id of the message to correct.
|
||||
*/
|
||||
private String idInitialMessage;
|
||||
private final String idInitialMessage;
|
||||
|
||||
public MessageCorrectExtension(String idInitialMessage) {
|
||||
this.setIdInitialMessage(idInitialMessage);
|
||||
this.idInitialMessage = StringUtils.requireNotNullOrEmpty(idInitialMessage, "idInitialMessage must not be null");
|
||||
}
|
||||
|
||||
public String getIdInitialMessage() {
|
||||
return idInitialMessage;
|
||||
}
|
||||
|
||||
public void setIdInitialMessage(String idInitialMessage) {
|
||||
this.idInitialMessage = idInitialMessage;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.jivesoftware.smack.packet.PacketExtension#getElementName()
|
||||
*/
|
||||
@Override
|
||||
public String getElementName() {
|
||||
return ELEMENT;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.jivesoftware.smack.packet.PacketExtension#toXML()
|
||||
*/
|
||||
@Override
|
||||
public XmlStringBuilder toXML() {
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this);
|
||||
|
@ -88,11 +75,6 @@ public class MessageCorrectExtension implements ExtensionElement {
|
|||
return xml;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.jivesoftware.smack.packet.PacketExtension#getNamespace()
|
||||
*/
|
||||
@Override
|
||||
public String getNamespace() {
|
||||
return NAMESPACE;
|
|
@ -16,6 +16,6 @@
|
|||
*/
|
||||
|
||||
/**
|
||||
* Classes and Interfaces that implement Last Message Correction as defined in XEP-0308.
|
||||
* XMPP stream elements for Last Message Correction as defined in XEP-0308.
|
||||
*/
|
||||
package org.jivesoftware.smackx.message_correct;
|
||||
package org.jivesoftware.smackx.message_correct.element;
|
|
@ -20,7 +20,7 @@ import java.io.IOException;
|
|||
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.provider.ExtensionElementProvider;
|
||||
import org.jivesoftware.smackx.message_correct.MessageCorrectExtension;
|
||||
import org.jivesoftware.smackx.message_correct.element.MessageCorrectExtension;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
|
|
|
@ -507,4 +507,12 @@
|
|||
<namespace>http://jabber.org/protocol/geoloc</namespace>
|
||||
<className>org.jivesoftware.smackx.geoloc.provider.GeoLocationProvider</className>
|
||||
</extensionProvider>
|
||||
|
||||
<!-- XEP-0308: Last Message Correction -->
|
||||
<extensionProvider>
|
||||
<elementName>replace</elementName>
|
||||
<namespace>urn:xmpp:message-correct:0</namespace>
|
||||
<className>org.jivesoftware.smackx.message_correct.provider.MessageCorrectProvider</className>
|
||||
</extensionProvider>
|
||||
|
||||
</smackProviders>
|
||||
|
|
|
@ -18,13 +18,12 @@ package org.jivesoftware.smackx.message_correct;
|
|||
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
import org.jivesoftware.smackx.message_correct.element.MessageCorrectExtension;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class MessageCorrectExtensionTest {
|
||||
|
||||
private Message initialMessage;
|
||||
|
||||
private final String idInitialMessage = "bad1";
|
||||
|
||||
private final String initialMessageXml = "<message to='juliet@capulet.net/balcony' id='good1'>"
|
||||
|
@ -38,7 +37,7 @@ public class MessageCorrectExtensionTest {
|
|||
|
||||
@Test
|
||||
public void checkStanzas() throws Exception {
|
||||
initialMessage = (Message) PacketParserUtils.parseStanza(initialMessageXml);
|
||||
Message initialMessage = (Message) PacketParserUtils.parseStanza(initialMessageXml);
|
||||
MessageCorrectExtension messageCorrectExtension = new MessageCorrectExtension(idInitialMessage);
|
||||
|
||||
Assert.assertEquals(messageCorrectExtension.toXML().toString(), messageCorrectionXml);
|
||||
|
|
Loading…
Reference in a new issue