1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2025-09-09 17:19:39 +02:00

Don't append closing body in XHTMLText.toString()

Also add XHTMLExtension.from(Message) and change XHTMLManager.addBody()
signature so that it expects a XHTMLText (Modifications to the original
patch by Florian Schmaus).
This commit is contained in:
vito-c 2015-01-04 20:11:06 -08:00 committed by Florian Schmaus
parent b77d61527c
commit e31b284afa
4 changed files with 23 additions and 23 deletions

View file

@ -78,9 +78,10 @@ xhtmlText.appendOpenEmTag();
xhtmlText.append("!!!!");
xhtmlText.appendCloseEmTag();
xhtmlText.appendCloseParagraphTag();
xhtmlText.appendCloseBodyTag();
// Add the XHTML text to the message
XHTMLManager.addBody(msg, xhtmlText.toString());
XHTMLManager.addBody(msg, xhtmlText);
```
Send an XHTML Message
@ -109,7 +110,7 @@ a chat.
// Create a message to send
Message msg = chat.createMessage();
// Obtain the XHTML text to send from somewhere
String xhtmlBody = getXHTMLTextToSend();
XHTMLText xhtmlBody = getXHTMLTextToSend();
// Add the XHTML text to the message
XHTMLManager.addBody(msg, xhtmlBody);
@ -131,7 +132,7 @@ XHTML bodies where each body should be for a different language.
To get the XHTML bodies of a given message just send the message
**#getBodies(Message)** to the class _**XHTMLManager**_. The answer of this
message will be an _**Iterator**_ with the different XHTML bodies of the
message will be an _**List**_ with the different XHTML bodies of the
message or null if none.
**Example**
@ -143,16 +144,15 @@ XHTML bodies of any received message.
// Create a listener for the chat and display any XHTML content
PacketListener packetListener = new PacketListener() {
public void processPacket(Packet packet) {
Message message = (Message) packet;
// Obtain the XHTML bodies of the message
Iterator it = XHTMLManager.getBodies(message);
if (it != null) {
// Display the bodies on the console
while (it.hasNext()) {
String body = (String) it.next();
System.out.println(body);
}
}
Message message = (Message) packet;
// Obtain the XHTML bodies of the message
List<CharSequence> bodies = XHTMLManager.getBodies(message);
if (bodies != null) {
// Display the bodies on the console
for (CharSequence body : bodies) {
System.out.println(body);
}
}
};
chat.addMessageListener(packetListener);
```