1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2025-12-12 14:01:08 +01:00

PacketExtension.from(Packet), deprecate getFrom()

add 'from(Packet)' to DataForm
This commit is contained in:
Florian Schmaus 2014-09-16 22:14:10 +02:00
parent f0651bae2d
commit 58e430af42
14 changed files with 158 additions and 13 deletions

View file

@ -22,7 +22,6 @@ import java.util.List;
import java.util.StringTokenizer;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.PacketExtension;
import org.jivesoftware.smackx.xdata.packet.DataForm;
/**
@ -61,10 +60,8 @@ public class Form {
*/
public static Form getFormFrom(Packet packet) {
// Check if the packet includes the DataForm extension
PacketExtension packetExtension = packet.getExtension("x","jabber:x:data");
if (packetExtension != null) {
// Check if the existing DataForm is not a result of a search
DataForm dataForm = (DataForm) packetExtension;
DataForm dataForm = DataForm.from(packet);
if (dataForm != null) {
if (dataForm.getReportedData() == null)
return new Form(dataForm);
}

View file

@ -18,6 +18,7 @@
package org.jivesoftware.smackx.xdata.packet;
import org.jivesoftware.smack.packet.Element;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.PacketExtension;
import org.jivesoftware.smack.util.XmlStringBuilder;
import org.jivesoftware.smackx.xdata.FormField;
@ -249,6 +250,15 @@ public class DataForm implements PacketExtension {
return buf;
}
/**
*
* @param packet
* @return the DataForm or null
*/
public static DataForm from(Packet packet) {
return (DataForm) packet.getExtension(ELEMENT, NAMESPACE);
}
/**
*
* Represents the fields that will be returned from a search. This information is useful when