mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2025-12-14 09:01: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
|
|
@ -56,7 +56,7 @@ import org.jivesoftware.smackx.privacy.packet.PrivacyItem;
|
|||
* @see <a href="http://xmpp.org/extensions/xep-0016.html">XEP-16: Privacy Lists</a>
|
||||
*/
|
||||
public class PrivacyListManager extends Manager {
|
||||
public static final String NAMESPACE = "jabber:iq:privacy";
|
||||
public static final String NAMESPACE = Privacy.NAMESPACE;
|
||||
|
||||
private static final PacketFilter PACKET_FILTER = new AndFilter(IQTypeFilter.SET,
|
||||
new PacketExtensionFilter("query", NAMESPACE));
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ import java.util.Map;
|
|||
import java.util.Set;
|
||||
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smackx.privacy.PrivacyListManager;
|
||||
|
||||
/**
|
||||
* A Privacy IQ Packet, is used by the {@link org.jivesoftware.smackx.privacy.PrivacyListManager}
|
||||
|
|
@ -43,6 +42,9 @@ import org.jivesoftware.smackx.privacy.PrivacyListManager;
|
|||
* @author Francisco Vives
|
||||
*/
|
||||
public class Privacy extends IQ {
|
||||
public static final String ELEMENT = QUERY_ELEMENT;
|
||||
public static final String NAMESPACE = "jabber:iq:privacy";
|
||||
|
||||
/** declineActiveList is true when the user declines the use of the active list **/
|
||||
private boolean declineActiveList=false;
|
||||
/** activeName is the name associated with the active list set for the session **/
|
||||
|
|
@ -55,6 +57,10 @@ public class Privacy extends IQ {
|
|||
* key is the name of the list and the value a collection with privacy items. **/
|
||||
private Map<String, List<PrivacyItem>> itemLists = new HashMap<String, List<PrivacyItem>>();
|
||||
|
||||
public Privacy() {
|
||||
super(ELEMENT, NAMESPACE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set or update a privacy list with privacy items.
|
||||
*
|
||||
|
|
@ -276,10 +282,10 @@ public class Privacy extends IQ {
|
|||
public Set<String> getPrivacyListNames() {
|
||||
return this.itemLists.keySet();
|
||||
}
|
||||
|
||||
public String getChildElementXML() {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append("<query xmlns=\"" + PrivacyListManager.NAMESPACE + "\">");
|
||||
|
||||
@Override
|
||||
protected IQChildElementXmlStringBuilder getIQChildElementBuilder(IQChildElementXmlStringBuilder buf) {
|
||||
buf.rightAngleBracket();
|
||||
|
||||
// Add the active tag
|
||||
if (this.isDeclineActiveList()) {
|
||||
|
|
@ -318,10 +324,7 @@ public class Privacy extends IQ {
|
|||
}
|
||||
}
|
||||
|
||||
// Add packet extensions, if any are defined.
|
||||
buf.append(getExtensionsXML());
|
||||
buf.append("</query>");
|
||||
return buf.toString();
|
||||
return buf;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue