mirror of
https://github.com/vanitasvitae/Smack.git
synced 2025-12-14 06:51:08 +01:00
Enable PacketExtensions for IQs
This is actually only part one, i.e. with this commit if the user adds a PacketExtension to an IQ it will be included in IQ.toXml(). Which was previously only the case if the IQ subclass explicitly included packet extensions. The second part of the change is to change the IQ provider, so that packet extensions are automatically parsed. Cases where PacketExtensions are used for Message and IQ are slightly changed. The IQ sublcass now only has a field with this PacketExtension (see for example bytestreams.ibb.packet.DataPacketExtension). Also changed hoxt API: Removed unnecessary indirection and made the API more Smack idiomatic.
This commit is contained in:
parent
a9c798f3bb
commit
9e797c1b17
93 changed files with 1347 additions and 1438 deletions
|
|
@ -35,10 +35,17 @@ import java.util.List;
|
|||
*/
|
||||
public class OfflineMessageRequest extends IQ {
|
||||
|
||||
public static final String ELEMENT = "offline";
|
||||
public static final String NAMESPACE = "http://jabber.org/protocol/offline";
|
||||
|
||||
private List<Item> items = new ArrayList<Item>();
|
||||
private boolean purge = false;
|
||||
private boolean fetch = false;
|
||||
|
||||
public OfflineMessageRequest() {
|
||||
super(ELEMENT, NAMESPACE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a List of item childs that holds information about offline messages to
|
||||
* view or delete.
|
||||
|
|
@ -99,9 +106,10 @@ public class OfflineMessageRequest extends IQ {
|
|||
this.fetch = fetch;
|
||||
}
|
||||
|
||||
public String getChildElementXML() {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append("<offline xmlns=\"http://jabber.org/protocol/offline\">");
|
||||
@Override
|
||||
protected IQChildElementXmlStringBuilder getIQChildElementBuilder(IQChildElementXmlStringBuilder buf) {
|
||||
buf.rightAngleBracket();
|
||||
|
||||
synchronized (items) {
|
||||
for (int i = 0; i < items.size(); i++) {
|
||||
Item item = items.get(i);
|
||||
|
|
@ -114,10 +122,8 @@ public class OfflineMessageRequest extends IQ {
|
|||
if (fetch) {
|
||||
buf.append("<fetch/>");
|
||||
}
|
||||
// Add packet extensions, if any are defined.
|
||||
buf.append(getExtensionsXML());
|
||||
buf.append("</offline>");
|
||||
return buf.toString();
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue